From 371b5db5344d4fffff15608757248b83154a4918 Mon Sep 17 00:00:00 2001 From: Andrew Richardson Date: Fri, 20 Sep 2024 14:49:01 -0400 Subject: [PATCH] Add "data" parameter to transfer methods/events Signed-off-by: Andrew Richardson --- solidity/contracts/lib/interfaces/izeto.sol | 3 ++- solidity/contracts/zeto_anon.sol | 5 +++-- solidity/contracts/zeto_anon_nullifier.sol | 5 +++-- solidity/contracts/zeto_anon_nullifier_kyc.sol | 5 +++-- solidity/contracts/zeto_nf_anon.sol | 5 +++-- solidity/contracts/zeto_nf_anon_nullifier.sol | 5 +++-- solidity/contracts/zkDvP.sol | 6 ++++-- solidity/test/zeto_anon.ts | 4 +++- solidity/test/zeto_anon_nullifier.ts | 4 +++- solidity/test/zeto_anon_nullifier_kyc.ts | 4 +++- solidity/test/zeto_nf_anon.ts | 4 +++- solidity/test/zeto_nf_anon_nullifier.ts | 4 +++- 12 files changed, 36 insertions(+), 18 deletions(-) diff --git a/solidity/contracts/lib/interfaces/izeto.sol b/solidity/contracts/lib/interfaces/izeto.sol index 6b16fc9..a7f1034 100644 --- a/solidity/contracts/lib/interfaces/izeto.sol +++ b/solidity/contracts/lib/interfaces/izeto.sol @@ -21,6 +21,7 @@ interface IZeto is IZetoBase { event UTXOTransfer( uint256[] inputs, uint256[] outputs, - address indexed submitter + address indexed submitter, + bytes data ); } diff --git a/solidity/contracts/zeto_anon.sol b/solidity/contracts/zeto_anon.sol index 5132462..74b0dc0 100644 --- a/solidity/contracts/zeto_anon.sol +++ b/solidity/contracts/zeto_anon.sol @@ -63,7 +63,8 @@ contract Zeto_Anon is IZeto, ZetoBase, ZetoFungibleWithdraw, UUPSUpgradeable { function transfer( uint256[2] memory inputs, uint256[2] memory outputs, - Commonlib.Proof calldata proof + Commonlib.Proof calldata proof, + bytes calldata data ) public returns (bool) { require( validateTransactionProposal(inputs, outputs, proof), @@ -91,7 +92,7 @@ contract Zeto_Anon is IZeto, ZetoBase, ZetoFungibleWithdraw, UUPSUpgradeable { inputArray[i] = inputs[i]; outputArray[i] = outputs[i]; } - emit UTXOTransfer(inputArray, outputArray, msg.sender); + emit UTXOTransfer(inputArray, outputArray, msg.sender, data); return true; } diff --git a/solidity/contracts/zeto_anon_nullifier.sol b/solidity/contracts/zeto_anon_nullifier.sol index 2a003dd..144a64f 100644 --- a/solidity/contracts/zeto_anon_nullifier.sol +++ b/solidity/contracts/zeto_anon_nullifier.sol @@ -77,7 +77,8 @@ contract Zeto_AnonNullifier is uint256[2] memory nullifiers, uint256[2] memory outputs, uint256 root, - Commonlib.Proof calldata proof + Commonlib.Proof calldata proof, + bytes calldata data ) public returns (bool) { require( validateTransactionProposal(nullifiers, outputs, root), @@ -108,7 +109,7 @@ contract Zeto_AnonNullifier is nullifierArray[i] = nullifiers[i]; outputArray[i] = outputs[i]; } - emit UTXOTransfer(nullifierArray, outputArray, msg.sender); + emit UTXOTransfer(nullifierArray, outputArray, msg.sender, data); return true; } diff --git a/solidity/contracts/zeto_anon_nullifier_kyc.sol b/solidity/contracts/zeto_anon_nullifier_kyc.sol index 340ea00..0d5469b 100644 --- a/solidity/contracts/zeto_anon_nullifier_kyc.sol +++ b/solidity/contracts/zeto_anon_nullifier_kyc.sol @@ -83,7 +83,8 @@ contract Zeto_AnonNullifierKyc is uint256[2] memory nullifiers, uint256[2] memory outputs, uint256 root, - Commonlib.Proof calldata proof + Commonlib.Proof calldata proof, + bytes calldata data ) public returns (bool) { require( validateTransactionProposal(nullifiers, outputs, root), @@ -115,7 +116,7 @@ contract Zeto_AnonNullifierKyc is nullifierArray[i] = nullifiers[i]; outputArray[i] = outputs[i]; } - emit UTXOTransfer(nullifierArray, outputArray, msg.sender); + emit UTXOTransfer(nullifierArray, outputArray, msg.sender, data); return true; } diff --git a/solidity/contracts/zeto_nf_anon.sol b/solidity/contracts/zeto_nf_anon.sol index c8166d8..7424a28 100644 --- a/solidity/contracts/zeto_nf_anon.sol +++ b/solidity/contracts/zeto_nf_anon.sol @@ -55,7 +55,8 @@ contract Zeto_NfAnon is IZeto, ZetoBase, UUPSUpgradeable { function transfer( uint256 input, uint256 output, - Commonlib.Proof calldata proof + Commonlib.Proof calldata proof, + bytes calldata data ) public returns (bool) { require( validateTransactionProposal([input, 0], [output, 0], proof), @@ -81,7 +82,7 @@ contract Zeto_NfAnon is IZeto, ZetoBase, UUPSUpgradeable { inputArray[0] = input; outputArray[0] = output; - emit UTXOTransfer(inputArray, outputArray, msg.sender); + emit UTXOTransfer(inputArray, outputArray, msg.sender, data); return true; } diff --git a/solidity/contracts/zeto_nf_anon_nullifier.sol b/solidity/contracts/zeto_nf_anon_nullifier.sol index 64853af..2a758dd 100644 --- a/solidity/contracts/zeto_nf_anon_nullifier.sol +++ b/solidity/contracts/zeto_nf_anon_nullifier.sol @@ -63,7 +63,8 @@ contract Zeto_NfAnonNullifier is IZeto, ZetoNullifier, UUPSUpgradeable { uint256 nullifier, uint256 output, uint256 root, - Commonlib.Proof calldata proof + Commonlib.Proof calldata proof, + bytes calldata data ) public returns (bool) { require( validateTransactionProposal([nullifier, 0], [output, 0], root), @@ -89,7 +90,7 @@ contract Zeto_NfAnonNullifier is IZeto, ZetoNullifier, UUPSUpgradeable { nullifierArray[0] = nullifier; outputArray[0] = output; - emit UTXOTransfer(nullifierArray, outputArray, msg.sender); + emit UTXOTransfer(nullifierArray, outputArray, msg.sender, data); return true; } diff --git a/solidity/contracts/zkDvP.sol b/solidity/contracts/zkDvP.sol index bf47aa6..a36d2f9 100644 --- a/solidity/contracts/zkDvP.sol +++ b/solidity/contracts/zkDvP.sol @@ -220,7 +220,8 @@ contract zkDvP { paymentToken.transfer( trade.paymentInputs, trade.paymentOutputs, - trade.paymentProof + trade.paymentProof, + "" ), "Payment branch of the trade failed" ); @@ -228,7 +229,8 @@ contract zkDvP { assetToken.transfer( trade.assetInput, trade.assetOutput, - trade.assetProof + trade.assetProof, + "" ), "Asset branch of the trade failed" ); diff --git a/solidity/test/zeto_anon.ts b/solidity/test/zeto_anon.ts index 4a1a043..765a94c 100644 --- a/solidity/test/zeto_anon.ts +++ b/solidity/test/zeto_anon.ts @@ -221,7 +221,9 @@ describe("Zeto based fungible token with anonymity without encryption or nullifi encodedProof: any ) { const signerAddress = await signer.signer.getAddress(); - const tx = await zeto.connect(signer.signer).transfer(inputCommitments, outputCommitments, encodedProof); + const tx = await zeto + .connect(signer.signer) + .transfer(inputCommitments, outputCommitments, encodedProof, "0x"); const results = await tx.wait(); console.log(`Method transfer() complete. Gas used: ${results?.gasUsed}`); diff --git a/solidity/test/zeto_anon_nullifier.ts b/solidity/test/zeto_anon_nullifier.ts index 04b0ed5..82bbee4 100644 --- a/solidity/test/zeto_anon_nullifier.ts +++ b/solidity/test/zeto_anon_nullifier.ts @@ -404,7 +404,9 @@ describe("Zeto based fungible token with anonymity using nullifiers without encr encodedProof: any ) { const startTx = Date.now(); - const tx = await zeto.connect(signer.signer).transfer(nullifiers, outputCommitments, root, encodedProof); + const tx = await zeto + .connect(signer.signer) + .transfer(nullifiers, outputCommitments, root, encodedProof, "0x"); const results: ContractTransactionReceipt | null = await tx.wait(); console.log(`Time to execute transaction: ${Date.now() - startTx}ms. Gas used: ${results?.gasUsed}`); return results; diff --git a/solidity/test/zeto_anon_nullifier_kyc.ts b/solidity/test/zeto_anon_nullifier_kyc.ts index c33bf9d..3abaf07 100644 --- a/solidity/test/zeto_anon_nullifier_kyc.ts +++ b/solidity/test/zeto_anon_nullifier_kyc.ts @@ -582,7 +582,9 @@ describe("Zeto based fungible token with anonymity, KYC, using nullifiers withou encodedProof: any ) { const startTx = Date.now(); - const tx = await zeto.connect(signer.signer).transfer(nullifiers, outputCommitments, root, encodedProof); + const tx = await zeto + .connect(signer.signer) + .transfer(nullifiers, outputCommitments, root, encodedProof, "0x"); const results: ContractTransactionReceipt | null = await tx.wait(); console.log(`Time to execute transaction: ${Date.now() - startTx}ms. Gas used: ${results?.gasUsed}`); return results; diff --git a/solidity/test/zeto_nf_anon.ts b/solidity/test/zeto_nf_anon.ts index 543fae0..c514609 100644 --- a/solidity/test/zeto_nf_anon.ts +++ b/solidity/test/zeto_nf_anon.ts @@ -126,7 +126,9 @@ describe("Zeto based non-fungible token with anonymity without encryption or nul outputCommitment: BigNumberish, encodedProof: any ) { - const tx = await zeto.connect(signer.signer).transfer(inputCommitment, outputCommitment, encodedProof); + const tx = await zeto + .connect(signer.signer) + .transfer(inputCommitment, outputCommitment, encodedProof, "0x"); const results = await tx.wait(); console.log(`Method transfer() complete. Gas used: ${results?.gasUsed}`); diff --git a/solidity/test/zeto_nf_anon_nullifier.ts b/solidity/test/zeto_nf_anon_nullifier.ts index 8b2a33f..f721e66 100644 --- a/solidity/test/zeto_nf_anon_nullifier.ts +++ b/solidity/test/zeto_nf_anon_nullifier.ts @@ -264,7 +264,9 @@ describe("Zeto based non-fungible token with anonymity using nullifiers without encodedProof: any ) { const startTx = Date.now(); - const tx = await zeto.connect(signer.signer).transfer(nullifier, outputCommitment, root, encodedProof); + const tx = await zeto + .connect(signer.signer) + .transfer(nullifier, outputCommitment, root, encodedProof, "0x"); const results: ContractTransactionReceipt | null = await tx.wait(); console.log(`Time to execute transaction: ${Date.now() - startTx}ms. Gas used: ${results?.gasUsed}`); return results;