Skip to content

Commit

Permalink
Add "data" parameter to transfer methods/events
Browse files Browse the repository at this point in the history
Signed-off-by: Andrew Richardson <[email protected]>
  • Loading branch information
awrichar committed Sep 20, 2024
1 parent 883234e commit 371b5db
Show file tree
Hide file tree
Showing 12 changed files with 36 additions and 18 deletions.
3 changes: 2 additions & 1 deletion solidity/contracts/lib/interfaces/izeto.sol
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ interface IZeto is IZetoBase {
event UTXOTransfer(
uint256[] inputs,
uint256[] outputs,
address indexed submitter
address indexed submitter,
bytes data
);
}
5 changes: 3 additions & 2 deletions solidity/contracts/zeto_anon.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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;
}
Expand Down
5 changes: 3 additions & 2 deletions solidity/contracts/zeto_anon_nullifier.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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;
}

Expand Down
5 changes: 3 additions & 2 deletions solidity/contracts/zeto_anon_nullifier_kyc.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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;
}

Expand Down
5 changes: 3 additions & 2 deletions solidity/contracts/zeto_nf_anon.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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;
}

Expand Down
5 changes: 3 additions & 2 deletions solidity/contracts/zeto_nf_anon_nullifier.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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;
}

Expand Down
6 changes: 4 additions & 2 deletions solidity/contracts/zkDvP.sol
Original file line number Diff line number Diff line change
Expand Up @@ -220,15 +220,17 @@ contract zkDvP {
paymentToken.transfer(
trade.paymentInputs,
trade.paymentOutputs,
trade.paymentProof
trade.paymentProof,
""
),
"Payment branch of the trade failed"
);
require(
assetToken.transfer(
trade.assetInput,
trade.assetOutput,
trade.assetProof
trade.assetProof,
""
),
"Asset branch of the trade failed"
);
Expand Down
4 changes: 3 additions & 1 deletion solidity/test/zeto_anon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`);

Expand Down
4 changes: 3 additions & 1 deletion solidity/test/zeto_anon_nullifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 3 additions & 1 deletion solidity/test/zeto_anon_nullifier_kyc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 3 additions & 1 deletion solidity/test/zeto_nf_anon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`);

Expand Down
4 changes: 3 additions & 1 deletion solidity/test/zeto_nf_anon_nullifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 371b5db

Please sign in to comment.