From 29a1f143896eaf0f0ed9d3f7038aaaebcc005d7f Mon Sep 17 00:00:00 2001 From: Containerman17 <8990432+containerman17@users.noreply.github.com> Date: Thu, 10 Oct 2024 04:20:49 +0000 Subject: [PATCH 1/6] add boolean support to the ABI spec --- abi/abi_test.go | 1 + abi/auto_marshal_abi_spec_test.go | 1 + abi/mockabi_test.go | 10 ++++++++++ abi/testdata/Booleans.json | 9 +++++++++ abi/testdata/abi.hash.hex | 2 +- abi/testdata/abi.json | 33 +++++++++++++++++++++++++------ abi/testdata/booleans.hex | 1 + 7 files changed, 50 insertions(+), 7 deletions(-) create mode 100644 abi/testdata/Booleans.json create mode 100644 abi/testdata/booleans.hex diff --git a/abi/abi_test.go b/abi/abi_test.go index a91202a66f..e13e82702b 100644 --- a/abi/abi_test.go +++ b/abi/abi_test.go @@ -26,6 +26,7 @@ func TestNewABI(t *testing.T) { Outer{}, ActionWithOutput{}, FixedBytes{}, + Booleans{}, }, []codec.Typed{ ActionOutput{}, }) diff --git a/abi/auto_marshal_abi_spec_test.go b/abi/auto_marshal_abi_spec_test.go index 3a84bd4451..4e35b179cc 100644 --- a/abi/auto_marshal_abi_spec_test.go +++ b/abi/auto_marshal_abi_spec_test.go @@ -60,6 +60,7 @@ func TestMarshalSpecs(t *testing.T) { {"strOnly", &MockObjectStringAndBytes{}}, {"outer", &Outer{}}, {"fixedBytes", &FixedBytes{}}, + {"booleans", &Booleans{}}, } for _, tc := range testCases { diff --git a/abi/mockabi_test.go b/abi/mockabi_test.go index be59da4b2e..d86fb5e7da 100644 --- a/abi/mockabi_test.go +++ b/abi/mockabi_test.go @@ -70,6 +70,12 @@ type FixedBytes struct { ThirtyTwoBytes [32]uint8 `serialize:"true" json:"thirtyTwoBytes"` } +type Booleans 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"` } @@ -114,6 +120,10 @@ func (FixedBytes) GetTypeID() uint8 { return 9 } +func (Booleans) GetTypeID() uint8 { + return 10 +} + func (ActionOutput) GetTypeID() uint8 { return 0 } diff --git a/abi/testdata/Booleans.json b/abi/testdata/Booleans.json new file mode 100644 index 0000000000..8102f3d71c --- /dev/null +++ b/abi/testdata/Booleans.json @@ -0,0 +1,9 @@ +{ + "bool1": false, + "bool2": true, + "boolArray": [ + true, + false, + true + ] +} diff --git a/abi/testdata/abi.hash.hex b/abi/testdata/abi.hash.hex index 3fb15dc199..3ec1bdd443 100644 --- a/abi/testdata/abi.hash.hex +++ b/abi/testdata/abi.hash.hex @@ -1 +1 @@ -075005590e3e3e39dffbf8e5a6d77559b8a33e621078782571695f60938126d3 +58a84810851491da7378318c3439393ba91da1e85dab59d39ca5a6da16a90345 diff --git a/abi/testdata/abi.json b/abi/testdata/abi.json index 50ee4382d6..dfb3b08222 100644 --- a/abi/testdata/abi.json +++ b/abi/testdata/abi.json @@ -39,6 +39,10 @@ { "id": 9, "name": "FixedBytes" + }, + { + "id": 10, + "name": "Booleans" } ], "outputs": [ @@ -210,15 +214,16 @@ ] }, { + "name": "ActionWithOutput", "fields": [ { "name": "field1", "type": "uint8" } - ], - "name": "ActionWithOutput" + ] }, { + "name": "FixedBytes", "fields": [ { "name": "twoBytes", @@ -228,17 +233,33 @@ "name": "thirtyTwoBytes", "type": "[32]uint8" } - ], - "name": "FixedBytes" + ] + }, + { + "name": "Booleans", + "fields": [ + { + "name": "bool1", + "type": "bool" + }, + { + "name": "bool2", + "type": "bool" + }, + { + "name": "boolArray", + "type": "[]bool" + } + ] }, { + "name": "ActionOutput", "fields": [ { "name": "field1", "type": "uint16" } - ], - "name": "ActionOutput" + ] } ] } diff --git a/abi/testdata/booleans.hex b/abi/testdata/booleans.hex new file mode 100644 index 0000000000..3a2b3cd07a --- /dev/null +++ b/abi/testdata/booleans.hex @@ -0,0 +1 @@ +000100000003010001 From f988a403ae9c66251d4fc36bb77356604214941f Mon Sep 17 00:00:00 2001 From: Containerman17 <8990432+containerman17@users.noreply.github.com> Date: Thu, 10 Oct 2024 04:28:41 +0000 Subject: [PATCH 2/6] change name case step 1 --- abi/testdata/booleans2.json | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 abi/testdata/booleans2.json diff --git a/abi/testdata/booleans2.json b/abi/testdata/booleans2.json new file mode 100644 index 0000000000..8102f3d71c --- /dev/null +++ b/abi/testdata/booleans2.json @@ -0,0 +1,9 @@ +{ + "bool1": false, + "bool2": true, + "boolArray": [ + true, + false, + true + ] +} From bbf2d249a7985f2882ba80ca670cbe3609f367e0 Mon Sep 17 00:00:00 2001 From: Containerman17 <8990432+containerman17@users.noreply.github.com> Date: Thu, 10 Oct 2024 04:29:02 +0000 Subject: [PATCH 3/6] change name case step 2 --- abi/testdata/booleans2.json | 9 --------- 1 file changed, 9 deletions(-) delete mode 100644 abi/testdata/booleans2.json diff --git a/abi/testdata/booleans2.json b/abi/testdata/booleans2.json deleted file mode 100644 index 8102f3d71c..0000000000 --- a/abi/testdata/booleans2.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "bool1": false, - "bool2": true, - "boolArray": [ - true, - false, - true - ] -} From 7f7722a7f44f2101473dd9c55fa8683a85f4141b Mon Sep 17 00:00:00 2001 From: Containerman17 <8990432+containerman17@users.noreply.github.com> Date: Thu, 10 Oct 2024 04:31:18 +0000 Subject: [PATCH 4/6] rename to bool to avoid the case bug --- abi/abi_test.go | 2 +- abi/auto_marshal_abi_spec_test.go | 2 +- abi/mockabi_test.go | 4 ++-- abi/testdata/abi.hash.hex | 2 +- abi/testdata/abi.json | 4 ++-- abi/testdata/{booleans.hex => bools.hex} | 0 abi/testdata/bools.json | 9 +++++++++ 7 files changed, 16 insertions(+), 7 deletions(-) rename abi/testdata/{booleans.hex => bools.hex} (100%) create mode 100644 abi/testdata/bools.json diff --git a/abi/abi_test.go b/abi/abi_test.go index e13e82702b..f918ba0033 100644 --- a/abi/abi_test.go +++ b/abi/abi_test.go @@ -26,7 +26,7 @@ func TestNewABI(t *testing.T) { Outer{}, ActionWithOutput{}, FixedBytes{}, - Booleans{}, + Bools{}, }, []codec.Typed{ ActionOutput{}, }) diff --git a/abi/auto_marshal_abi_spec_test.go b/abi/auto_marshal_abi_spec_test.go index 4e35b179cc..4cbc744d34 100644 --- a/abi/auto_marshal_abi_spec_test.go +++ b/abi/auto_marshal_abi_spec_test.go @@ -60,7 +60,7 @@ func TestMarshalSpecs(t *testing.T) { {"strOnly", &MockObjectStringAndBytes{}}, {"outer", &Outer{}}, {"fixedBytes", &FixedBytes{}}, - {"booleans", &Booleans{}}, + {"bools", &Bools{}}, } for _, tc := range testCases { diff --git a/abi/mockabi_test.go b/abi/mockabi_test.go index d86fb5e7da..6a5355ec79 100644 --- a/abi/mockabi_test.go +++ b/abi/mockabi_test.go @@ -70,7 +70,7 @@ type FixedBytes struct { ThirtyTwoBytes [32]uint8 `serialize:"true" json:"thirtyTwoBytes"` } -type Booleans struct { +type Bools struct { Bool1 bool `serialize:"true" json:"bool1"` Bool2 bool `serialize:"true" json:"bool2"` BoolArray []bool `serialize:"true" json:"boolArray"` @@ -120,7 +120,7 @@ func (FixedBytes) GetTypeID() uint8 { return 9 } -func (Booleans) GetTypeID() uint8 { +func (Bools) GetTypeID() uint8 { return 10 } diff --git a/abi/testdata/abi.hash.hex b/abi/testdata/abi.hash.hex index 3ec1bdd443..ebbaaf8b49 100644 --- a/abi/testdata/abi.hash.hex +++ b/abi/testdata/abi.hash.hex @@ -1 +1 @@ -58a84810851491da7378318c3439393ba91da1e85dab59d39ca5a6da16a90345 +3b634237434bc35076e790b52986d735f30d582e9b7b94ad357d91b33072e284 diff --git a/abi/testdata/abi.json b/abi/testdata/abi.json index dfb3b08222..673aefdaf2 100644 --- a/abi/testdata/abi.json +++ b/abi/testdata/abi.json @@ -42,7 +42,7 @@ }, { "id": 10, - "name": "Booleans" + "name": "Bools" } ], "outputs": [ @@ -236,7 +236,7 @@ ] }, { - "name": "Booleans", + "name": "Bools", "fields": [ { "name": "bool1", diff --git a/abi/testdata/booleans.hex b/abi/testdata/bools.hex similarity index 100% rename from abi/testdata/booleans.hex rename to abi/testdata/bools.hex diff --git a/abi/testdata/bools.json b/abi/testdata/bools.json new file mode 100644 index 0000000000..8102f3d71c --- /dev/null +++ b/abi/testdata/bools.json @@ -0,0 +1,9 @@ +{ + "bool1": false, + "bool2": true, + "boolArray": [ + true, + false, + true + ] +} From a5c0b19928570e0342dd3b886f1dba4f95196902 Mon Sep 17 00:00:00 2001 From: containerman17 <8990432+containerman17@users.noreply.github.com> Date: Thu, 10 Oct 2024 13:33:17 +0900 Subject: [PATCH 5/6] Rename Booleans.json to booleans.json Signed-off-by: containerman17 <8990432+containerman17@users.noreply.github.com> --- abi/testdata/{Booleans.json => booleans.json} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename abi/testdata/{Booleans.json => booleans.json} (100%) diff --git a/abi/testdata/Booleans.json b/abi/testdata/booleans.json similarity index 100% rename from abi/testdata/Booleans.json rename to abi/testdata/booleans.json From ff046ff1601f3735e2cf4f39ac4241cc1cf6a61b Mon Sep 17 00:00:00 2001 From: Containerman17 <8990432+containerman17@users.noreply.github.com> Date: Thu, 10 Oct 2024 04:33:58 +0000 Subject: [PATCH 6/6] remove extra booleans.json --- abi/testdata/booleans.json | 9 --------- 1 file changed, 9 deletions(-) delete mode 100644 abi/testdata/booleans.json diff --git a/abi/testdata/booleans.json b/abi/testdata/booleans.json deleted file mode 100644 index 8102f3d71c..0000000000 --- a/abi/testdata/booleans.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "bool1": false, - "bool2": true, - "boolArray": [ - true, - false, - true - ] -}