From 88770e4b9bb5a72217889deb53a0f4dbf7381d13 Mon Sep 17 00:00:00 2001 From: Peter Broadhurst Date: Wed, 20 Nov 2024 11:19:40 -0500 Subject: [PATCH 1/2] Add salt to info schema for noto Signed-off-by: Peter Broadhurst --- domains/noto/internal/noto/states.go | 1 + domains/noto/pkg/types/states.go | 2 ++ 2 files changed, 3 insertions(+) diff --git a/domains/noto/internal/noto/states.go b/domains/noto/internal/noto/states.go index c69e7c777..703e9ff5a 100644 --- a/domains/noto/internal/noto/states.go +++ b/domains/noto/internal/noto/states.go @@ -155,6 +155,7 @@ func (n *Noto) prepareOutputs(ownerAddress *tktypes.EthAddress, amount *tktypes. func (n *Noto) prepareInfo(data tktypes.HexBytes, distributionList []string) ([]*prototk.NewState, error) { newData := &types.TransactionData{ + Salt: tktypes.RandHex(32), Data: data, } newState, err := n.makeNewInfoState(newData, distributionList) diff --git a/domains/noto/pkg/types/states.go b/domains/noto/pkg/types/states.go index beb23fdf7..3efa04c9f 100644 --- a/domains/noto/pkg/types/states.go +++ b/domains/noto/pkg/types/states.go @@ -44,6 +44,7 @@ var NotoCoinABI = &abi.Parameter{ } type TransactionData struct { + Salt string `json:"salt"` Data tktypes.HexBytes `json:"data"` } @@ -51,6 +52,7 @@ var TransactionDataABI = &abi.Parameter{ Type: "tuple", InternalType: "struct TransactionData", Components: abi.ParameterArray{ + {Name: "salt", Type: "bytes32"}, {Name: "data", Type: "bytes"}, }, } From 41fa9252c0edc465cb59bc450feb1eaf7086ac61 Mon Sep 17 00:00:00 2001 From: Peter Broadhurst Date: Wed, 20 Nov 2024 11:34:59 -0500 Subject: [PATCH 2/2] Update how Java tests extract coin schema to handle ordering Signed-off-by: Peter Broadhurst --- .../io/kaleido/paladin/pente/domain/BondTest.java | 12 +++++++++--- .../paladin/pente/domain/DomainIntegrationTests.java | 12 +++++++++--- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/domains/pente/src/test/java/io/kaleido/paladin/pente/domain/BondTest.java b/domains/pente/src/test/java/io/kaleido/paladin/pente/domain/BondTest.java index ad107b844..059bc1542 100644 --- a/domains/pente/src/test/java/io/kaleido/paladin/pente/domain/BondTest.java +++ b/domains/pente/src/test/java/io/kaleido/paladin/pente/domain/BondTest.java @@ -124,9 +124,15 @@ void testBond() throws Exception { List notoSchemas = testbed.getRpcClient().request("pstate_listSchemas", "noto"); assertEquals(2, notoSchemas.size()); - var notoSchema = mapper.convertValue(notoSchemas.getLast(), StateSchema.class); - assertEquals("type=NotoCoin(bytes32 salt,string owner,uint256 amount),labels=[owner,amount]", - notoSchema.signature()); + StateSchema notoSchema = null; + for (var i = 0; i < 2; i++) { + var schema = mapper.convertValue(notoSchemas.get(i), StateSchema.class); + if (schema.signature().equals("type=NotoCoin(bytes32 salt,string owner,uint256 amount),labels=[owner,amount]")) { + notoSchema = schema; + } else { + assertEquals("type=TransactionData(bytes32 salt,bytes data),labels=[]", schema.signature()); + } + } String bondTrackerPublicBytecode = ResourceLoader.jsonResourceEntryText( this.getClass().getClassLoader(), diff --git a/domains/pente/src/test/java/io/kaleido/paladin/pente/domain/DomainIntegrationTests.java b/domains/pente/src/test/java/io/kaleido/paladin/pente/domain/DomainIntegrationTests.java index 6de322d66..df0d1bd05 100644 --- a/domains/pente/src/test/java/io/kaleido/paladin/pente/domain/DomainIntegrationTests.java +++ b/domains/pente/src/test/java/io/kaleido/paladin/pente/domain/DomainIntegrationTests.java @@ -212,9 +212,15 @@ void testNotoPente() throws Exception { List notoSchemas = testbed.getRpcClient().request("pstate_listSchemas", "noto"); assertEquals(2, notoSchemas.size()); - var notoSchema = mapper.convertValue(notoSchemas.getLast(), StateSchema.class); - assertEquals("type=NotoCoin(bytes32 salt,string owner,uint256 amount),labels=[owner,amount]", - notoSchema.signature()); + StateSchema notoSchema = null; + for (var i = 0; i < 2; i++) { + var schema = mapper.convertValue(notoSchemas.get(i), StateSchema.class); + if (schema.signature().equals("type=NotoCoin(bytes32 salt,string owner,uint256 amount),labels=[owner,amount]")) { + notoSchema = schema; + } else { + assertEquals("type=TransactionData(bytes32 salt,bytes data),labels=[]", schema.signature()); + } + } // Create the privacy group String penteInstanceAddress = testbed.getRpcClient().request("testbed_deploy",