Skip to content

Commit 06524f4

Browse files
committed
Revert "Revert "Add ABI-encoding feature (#247)""
This reverts commit 48a72ca.
1 parent b442677 commit 06524f4

File tree

3 files changed

+236
-2
lines changed

3 files changed

+236
-2
lines changed

encoding/abi/abi.go

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
package abi
2+
3+
import (
4+
"math/big"
5+
6+
"github.com/algorand/go-algorand/data/abi"
7+
)
8+
9+
type Value = abi.Value
10+
type Type = abi.Type
11+
12+
func Decode(encoded []byte, abiType Type) (Value, error) {
13+
return abi.Decode(encoded, abiType)
14+
}
15+
16+
func TypeFromString(str string) (Type, error) {
17+
return abi.TypeFromString(str)
18+
}
19+
20+
func MakeUint8(val uint8) Value {
21+
return abi.MakeUint8(val)
22+
}
23+
24+
func MakeUint16(val uint16) Value {
25+
return abi.MakeUint16(val)
26+
}
27+
28+
func MakeUint32(val uint32) Value {
29+
return abi.MakeUint32(val)
30+
}
31+
32+
func MakeUint64(val uint64) Value {
33+
return abi.MakeUint64(val)
34+
}
35+
36+
func MakeUint(val *big.Int, size uint16) (Value, error) {
37+
return abi.MakeUint(val, size)
38+
}
39+
40+
func MakeUfixed(val *big.Int, size uint16, precision uint16) (Value, error) {
41+
return abi.MakeUfixed(val, size, precision)
42+
}
43+
44+
func MakeString(val string) Value {
45+
return abi.MakeString(val)
46+
}
47+
48+
func MakeByte(val byte) Value {
49+
return abi.MakeByte(val)
50+
}
51+
52+
func MakeAddress(val [32]byte) Value {
53+
return abi.MakeAddress(val)
54+
}
55+
56+
func MakeBool(val bool) Value {
57+
return abi.MakeBool(val)
58+
}
59+
60+
func MakeDynamicArray(values []Value, elemType Type) (Value, error) {
61+
return abi.MakeDynamicArray(values, elemType)
62+
}
63+
64+
func MakeStaticArray(values []Value) (Value, error) {
65+
return abi.MakeStaticArray(values)
66+
}
67+
68+
func MakeTuple(values []Value) (Value, error) {
69+
return abi.MakeTuple(values)
70+
}
71+
72+
func MakeUintType(size uint16) (Type, error) {
73+
return abi.MakeUintType(size)
74+
}
75+
76+
func MakeUfixedType(size uint16, precision uint16) (Type, error) {
77+
return abi.MakeUfixedType(size, precision)
78+
}
79+
80+
func MakeByteType() Type {
81+
return abi.MakeByteType()
82+
}
83+
84+
func MakeAddressType() Type {
85+
return abi.MakeAddressType()
86+
}
87+
88+
func MakeStringType() Type {
89+
return abi.MakeStringType()
90+
}
91+
92+
func MakeBoolType() Type {
93+
return abi.MakeBoolType()
94+
}
95+
96+
func MakeDynamicArrayType(elemType Type) Type {
97+
return abi.MakeDynamicArrayType(elemType)
98+
}
99+
100+
func MakeStaticArrayType(elemType Type, length uint16) Type {
101+
return abi.MakeStaticArrayType(elemType, length)
102+
}
103+
104+
func MakeTupleType(elemTypes []Type) (Type, error) {
105+
return abi.MakeTupleType(elemTypes)
106+
}

go.mod

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@ module github.com/algorand/go-algorand-sdk
33
go 1.13
44

55
require (
6+
github.com/algorand/go-algorand v0.0.0-20210929134638-1202d32142af // indirect
67
github.com/algorand/go-codec v1.1.7
78
github.com/algorand/go-codec/codec v1.1.7
89
github.com/cucumber/godog v0.8.1
910
github.com/davecgh/go-spew v1.1.1
1011
github.com/google/go-querystring v1.0.0
1112
github.com/nsf/jsondiff v0.0.0-20200515183724-f29ed568f4ce
1213
github.com/pmezard/go-difflib v1.0.0
13-
github.com/stretchr/testify v1.3.0
14-
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550
14+
github.com/stretchr/testify v1.7.0
15+
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519
1516
golang.org/x/tools v0.0.0-20200426102838-f3a5411a4c3b // indirect
1617
)

0 commit comments

Comments
 (0)