• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

unpackdev / solgo / 8466155403

28 Mar 2024 10:51AM UTC coverage: 67.93% (-0.3%) from 68.187%
8466155403

push

github

web-flow
ABI: Bugfix - now it's compliant (#165)

* Abi updates

* Fixing unit tests

* Overall data tests

74 of 176 new or added lines in 11 files covered. (42.05%)

38 existing lines in 4 files now uncovered.

26660 of 39246 relevant lines covered (67.93%)

0.75 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

73.68
/abi/function.go
1
// Package abi provides tools for building and parsing Ethereum ABI (Application Binary Interface) data.
2
package abi
3

4
import (
5
        "fmt"
6

7
        "github.com/unpackdev/solgo/ir"
8
)
9

10
// processFunction processes an IR function and returns a Method representation of it.
11
// It extracts the name, input, and output parameters of the function, sets its type to "function",
12
// and normalizes its state mutability.
13
func (b *Builder) processFunction(unit *ir.Function) (*Method, error) {
1✔
14
        toReturn := &Method{
1✔
15
                Name:            unit.GetName(),
1✔
16
                Inputs:          make([]MethodIO, 0),
1✔
17
                Outputs:         make([]MethodIO, 0),
1✔
18
                Type:            "function",
1✔
19
                StateMutability: b.normalizeStateMutability(unit.GetStateMutability()),
1✔
20
        }
1✔
21

1✔
22
        for _, parameter := range unit.GetParameters() {
2✔
23
                if parameter.GetTypeDescription() == nil {
1✔
NEW
24
                        return nil, fmt.Errorf("nil type description for function parameter %s", parameter.GetName())
×
NEW
25
                }
×
26

27
                methodIo := MethodIO{
1✔
28
                        Name: parameter.GetName(),
1✔
29
                }
1✔
30
                toReturn.Inputs = append(
1✔
31
                        toReturn.Inputs,
1✔
32
                        b.buildMethodIO(methodIo, parameter.GetTypeDescription()),
1✔
33
                )
1✔
34
        }
35

36
        for _, parameter := range unit.GetReturnStatements() {
2✔
37
                if parameter.GetTypeDescription() == nil {
1✔
NEW
38
                        return nil, fmt.Errorf("nil type description for function return parameter %s", parameter.GetName())
×
NEW
39
                }
×
40

41
                methodIo := MethodIO{
1✔
42
                        Name: parameter.GetName(),
1✔
43
                }
1✔
44
                toReturn.Outputs = append(
1✔
45
                        toReturn.Outputs,
1✔
46
                        b.buildMethodIO(methodIo, parameter.GetTypeDescription()),
1✔
47
                )
1✔
48

49
        }
50

51
        return toReturn, nil
1✔
52
}
53

NEW
54
func (b *Builder) GetFunctionAsABI(unit *ir.Function) ([]*Method, error) {
×
NEW
55
        method, err := b.processFunction(unit)
×
NEW
56
        if err != nil {
×
NEW
57
                return nil, err
×
NEW
58
        }
×
59

NEW
60
        return []*Method{method}, nil
×
61
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc