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 boolean support to the ABI spec #1648

Merged
merged 6 commits into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions abi/abi_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ func TestNewABI(t *testing.T) {
Outer{},
ActionWithOutput{},
FixedBytes{},
Bools{},
}, []codec.Typed{
ActionOutput{},
})
Expand Down
1 change: 1 addition & 0 deletions abi/auto_marshal_abi_spec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ func TestMarshalSpecs(t *testing.T) {
{"strOnly", &MockObjectStringAndBytes{}},
{"outer", &Outer{}},
{"fixedBytes", &FixedBytes{}},
{"bools", &Bools{}},
}

for _, tc := range testCases {
Expand Down
10 changes: 10 additions & 0 deletions abi/mockabi_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@ type FixedBytes struct {
ThirtyTwoBytes [32]uint8 `serialize:"true" json:"thirtyTwoBytes"`
}

type Bools struct {
Bool1 bool `serialize:"true" json:"bool1"`
Bool2 bool `serialize:"true" json:"bool2"`
BoolArray []bool `serialize:"true" json:"boolArray"`
}

type ActionOutput struct {
Field1 uint16 `serialize:"true" json:"field1"`
}
Expand Down Expand Up @@ -114,6 +120,10 @@ func (FixedBytes) GetTypeID() uint8 {
return 9
}

func (Bools) GetTypeID() uint8 {
return 10
}

func (ActionOutput) GetTypeID() uint8 {
return 0
}
2 changes: 1 addition & 1 deletion abi/testdata/abi.hash.hex
Original file line number Diff line number Diff line change
@@ -1 +1 @@
075005590e3e3e39dffbf8e5a6d77559b8a33e621078782571695f60938126d3
3b634237434bc35076e790b52986d735f30d582e9b7b94ad357d91b33072e284
33 changes: 27 additions & 6 deletions abi/testdata/abi.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@
{
"id": 9,
"name": "FixedBytes"
},
{
"id": 10,
"name": "Bools"
}
],
"outputs": [
Expand Down Expand Up @@ -210,15 +214,16 @@
]
},
{
"name": "ActionWithOutput",
"fields": [
{
"name": "field1",
"type": "uint8"
}
],
"name": "ActionWithOutput"
]
},
{
"name": "FixedBytes",
"fields": [
{
"name": "twoBytes",
Expand All @@ -228,17 +233,33 @@
"name": "thirtyTwoBytes",
"type": "[32]uint8"
}
],
"name": "FixedBytes"
]
},
{
"name": "Bools",
"fields": [
{
"name": "bool1",
"type": "bool"
},
{
"name": "bool2",
"type": "bool"
},
{
"name": "boolArray",
"type": "[]bool"
}
]
},
{
"name": "ActionOutput",
"fields": [
{
"name": "field1",
"type": "uint16"
}
],
"name": "ActionOutput"
]
}
]
}
1 change: 1 addition & 0 deletions abi/testdata/bools.hex
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
000100000003010001
9 changes: 9 additions & 0 deletions abi/testdata/bools.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"bool1": false,
"bool2": true,
"boolArray": [
true,
false,
true
]
}
Loading