Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ABI-encoding feature #247

Merged
merged 71 commits into from
Sep 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
437e463
Initial interface definitions
jasonpaulos Aug 6, 2021
fc01f86
update abi-type serialization, partly de-serialization
ahangsu Aug 9, 2021
a5dec05
abi-type serialization/deserialization prototype done
ahangsu Aug 9, 2021
91551f8
public methods for making abi-types
ahangsu Aug 9, 2021
79858fa
adding default values to supress err msg
ahangsu Aug 9, 2021
9416b95
update some test cases
ahangsu Aug 10, 2021
0d1eff1
minor fix on abi regexp
ahangsu Aug 10, 2021
518cd5a
update bool type test
ahangsu Aug 10, 2021
069e95a
rewrite tuple component
ahangsu Aug 11, 2021
57b7c50
minor fix
ahangsu Aug 11, 2021
f7d9693
minor fix
ahangsu Aug 11, 2021
cda3ec4
minor fix
ahangsu Aug 11, 2021
42f0411
minor changes on tuple parsing, add readability
ahangsu Aug 11, 2021
c510fb5
update abi testcases
ahangsu Aug 11, 2021
36d5186
update testcase code
ahangsu Aug 11, 2021
d9ccca1
update testcase code
ahangsu Aug 11, 2021
17b1976
update regex rule for parsing numbers
ahangsu Aug 11, 2021
e059c76
reorder parsing priority
ahangsu Aug 12, 2021
bd8e645
reformat testing file
ahangsu Aug 12, 2021
7ab0e76
add tuple testcase
ahangsu Aug 12, 2021
a1650ee
add tuple testcase
ahangsu Aug 12, 2021
0f417dc
add encoding/get/make method for uint/ufixed type
ahangsu Aug 13, 2021
979a508
add decode method for uint/ufixed type
ahangsu Aug 13, 2021
6a33d43
add methods for address/byte/string
ahangsu Aug 13, 2021
23d203c
fix length of static type to uint16
ahangsu Aug 13, 2021
a3e5f87
use reflection on array type infering
ahangsu Aug 13, 2021
e11660b
update make tuple/bool, get tuple/bool methods
ahangsu Aug 16, 2021
0383092
update tuple parsing
ahangsu Aug 16, 2021
8847113
update comments for tuple type parsing
ahangsu Aug 17, 2021
782dc5c
working on tuple encoding
ahangsu Aug 17, 2021
5406faa
update encoding scheme, decode todo
ahangsu Aug 17, 2021
eca0444
move to decode
ahangsu Aug 17, 2021
fb481ad
minor
ahangsu Aug 17, 2021
f1cb782
minor
ahangsu Aug 17, 2021
d15a79a
minor optimization
ahangsu Aug 17, 2021
c701bc7
prototype decoding
ahangsu Aug 18, 2021
3a84d95
minor update
ahangsu Aug 18, 2021
60a238d
minor update
ahangsu Aug 18, 2021
8da033c
compress bool encoding update
ahangsu Aug 18, 2021
1c0485c
update abi test case for encoding and decoding
ahangsu Aug 19, 2021
2ce7c1b
minor fixes in tuple encoding
ahangsu Aug 20, 2021
443b6c2
update byte test
ahangsu Aug 20, 2021
bd5bd9a
update test scripts
ahangsu Aug 20, 2021
8d45068
add string utf8 fuzzer
ahangsu Aug 20, 2021
41ba037
update type struct testing
ahangsu Aug 23, 2021
4c7bd18
update type struct testing
ahangsu Aug 23, 2021
202de03
whoops need to work with previous version of golang
ahangsu Aug 23, 2021
990a78f
bug fix on dynamic type decision
ahangsu Aug 23, 2021
2b1fc5e
remove fill bytes usage
ahangsu Aug 23, 2021
c0a3a43
update helper script
ahangsu Aug 23, 2021
dc393fb
remove some dead code
ahangsu Aug 23, 2021
18e2c0f
bug fix on tuple encoding
ahangsu Aug 24, 2021
4d27e96
bug fix on tuple encoding
ahangsu Aug 24, 2021
14077ce
update test cases
ahangsu Aug 24, 2021
33db3d2
update test cases, minor bug fix
ahangsu Aug 24, 2021
d7daf20
update tuple decoding scope limit
ahangsu Aug 24, 2021
6330321
tuple decoding error check fixing
ahangsu Aug 25, 2021
4028cea
decoding full comsumption check
ahangsu Aug 25, 2021
973438a
remove some dead code
ahangsu Aug 25, 2021
59392c7
update tests
ahangsu Aug 25, 2021
b03b5d1
update travis settings
ahangsu Aug 25, 2021
046b3db
Merge branch 'develop' into abi-encoding, update travis ci config
ahangsu Aug 26, 2021
389778a
resort to copy-paste from go-algorand
ahangsu Sep 27, 2021
8d93c5e
remove redundant
ahangsu Sep 27, 2021
7e6ee1a
remove redundant
ahangsu Sep 27, 2021
c3cdcf0
try to use go1.14 to go get go-algorand
ahangsu Sep 29, 2021
6f0e247
try to use go1.14 to go get go-algorand
ahangsu Sep 29, 2021
0e677b1
wrapper for abi method in go-algorand
ahangsu Sep 29, 2021
4f9473d
update naming
ahangsu Sep 29, 2021
9969071
back to embedding
ahangsu Sep 29, 2021
103521e
go to type aliasing
ahangsu Sep 29, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
106 changes: 106 additions & 0 deletions encoding/abi/abi.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
package abi

import (
"math/big"

"github.com/algorand/go-algorand/data/abi"
)

type Value = abi.Value
type Type = abi.Type

func Decode(encoded []byte, abiType Type) (Value, error) {
return abi.Decode(encoded, abiType)
}

func TypeFromString(str string) (Type, error) {
return abi.TypeFromString(str)
}

func MakeUint8(val uint8) Value {
return abi.MakeUint8(val)
}

func MakeUint16(val uint16) Value {
return abi.MakeUint16(val)
}

func MakeUint32(val uint32) Value {
return abi.MakeUint32(val)
}

func MakeUint64(val uint64) Value {
return abi.MakeUint64(val)
}

func MakeUint(val *big.Int, size uint16) (Value, error) {
return abi.MakeUint(val, size)
}

func MakeUfixed(val *big.Int, size uint16, precision uint16) (Value, error) {
return abi.MakeUfixed(val, size, precision)
}

func MakeString(val string) Value {
return abi.MakeString(val)
}

func MakeByte(val byte) Value {
return abi.MakeByte(val)
}

func MakeAddress(val [32]byte) Value {
return abi.MakeAddress(val)
}

func MakeBool(val bool) Value {
return abi.MakeBool(val)
}

func MakeDynamicArray(values []Value, elemType Type) (Value, error) {
return abi.MakeDynamicArray(values, elemType)
}

func MakeStaticArray(values []Value) (Value, error) {
return abi.MakeStaticArray(values)
}

func MakeTuple(values []Value) (Value, error) {
return abi.MakeTuple(values)
}

func MakeUintType(size uint16) (Type, error) {
return abi.MakeUintType(size)
}

func MakeUfixedType(size uint16, precision uint16) (Type, error) {
return abi.MakeUfixedType(size, precision)
}

func MakeByteType() Type {
return abi.MakeByteType()
}

func MakeAddressType() Type {
return abi.MakeAddressType()
}

func MakeStringType() Type {
return abi.MakeStringType()
}

func MakeBoolType() Type {
return abi.MakeBoolType()
}

func MakeDynamicArrayType(elemType Type) Type {
return abi.MakeDynamicArrayType(elemType)
}

func MakeStaticArrayType(elemType Type, length uint16) Type {
return abi.MakeStaticArrayType(elemType, length)
}

func MakeTupleType(elemTypes []Type) (Type, error) {
return abi.MakeTupleType(elemTypes)
}
5 changes: 3 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ module github.com/algorand/go-algorand-sdk
go 1.13

require (
github.com/algorand/go-algorand v0.0.0-20210929134638-1202d32142af // indirect
github.com/algorand/go-codec v1.1.7
github.com/algorand/go-codec/codec v1.1.7
github.com/cucumber/godog v0.8.1
github.com/davecgh/go-spew v1.1.1
github.com/google/go-querystring v1.0.0
github.com/nsf/jsondiff v0.0.0-20200515183724-f29ed568f4ce
github.com/pmezard/go-difflib v1.0.0
github.com/stretchr/testify v1.3.0
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550
github.com/stretchr/testify v1.7.0
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519
golang.org/x/tools v0.0.0-20200426102838-f3a5411a4c3b // indirect
)
Loading