dop-wallet-v6 1.2.5 → 1.2.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/services/transactions/__tests__/tx-proof-transfer-with-data.test.js +6 -49
- package/dist/services/transactions/__tests__/tx-proof-transfer-with-data.test.js.map +1 -1
- package/dist/services/transactions/tx-proof-transfer-with-data.d.ts +3 -31
- package/dist/services/transactions/tx-proof-transfer-with-data.js +5 -50
- package/dist/services/transactions/tx-proof-transfer-with-data.js.map +1 -1
- package/package.json +1 -1
|
@@ -3,53 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const chai_1 = require("chai");
|
|
4
4
|
const tx_proof_transfer_with_data_1 = require("../tx-proof-transfer-with-data");
|
|
5
5
|
describe('tx-proof-transfer-with-data', () => {
|
|
6
|
-
describe('TransferProofData interface structure', () => {
|
|
7
|
-
it('should have the correct TypeScript interface structure', () => {
|
|
8
|
-
// Test that we can create a valid TransferProofData object
|
|
9
|
-
const mockProofData = {
|
|
10
|
-
proof: {
|
|
11
|
-
a: { x: '0x123', y: '0x456' },
|
|
12
|
-
b: {
|
|
13
|
-
x: ['0x789', '0xabc'],
|
|
14
|
-
y: ['0xdef', '0x012']
|
|
15
|
-
},
|
|
16
|
-
c: { x: '0x345', y: '0x678' }
|
|
17
|
-
},
|
|
18
|
-
publicInputs: {
|
|
19
|
-
merkleRoot: '0xmerkleroot',
|
|
20
|
-
nullifiers: ['0xnullifier1', '0xnullifier2'],
|
|
21
|
-
commitments: ['0xcommitment1', '0xcommitment2'],
|
|
22
|
-
boundParamsHash: '0xboundparams'
|
|
23
|
-
},
|
|
24
|
-
transaction: {
|
|
25
|
-
data: '0xtxdata',
|
|
26
|
-
to: '0xrecipient',
|
|
27
|
-
value: '1000000000000000000'
|
|
28
|
-
},
|
|
29
|
-
nullifiers: ['0xnullifier1', '0xnullifier2']
|
|
30
|
-
};
|
|
31
|
-
// Verify the structure matches our interface
|
|
32
|
-
(0, chai_1.expect)(mockProofData).to.have.property('proof');
|
|
33
|
-
(0, chai_1.expect)(mockProofData.proof).to.have.property('a');
|
|
34
|
-
(0, chai_1.expect)(mockProofData.proof).to.have.property('b');
|
|
35
|
-
(0, chai_1.expect)(mockProofData.proof).to.have.property('c');
|
|
36
|
-
(0, chai_1.expect)(mockProofData.proof.a).to.have.property('x');
|
|
37
|
-
(0, chai_1.expect)(mockProofData.proof.a).to.have.property('y');
|
|
38
|
-
(0, chai_1.expect)(mockProofData.proof.b.x).to.be.an('array').with.length(2);
|
|
39
|
-
(0, chai_1.expect)(mockProofData.proof.b.y).to.be.an('array').with.length(2);
|
|
40
|
-
(0, chai_1.expect)(mockProofData).to.have.property('publicInputs');
|
|
41
|
-
(0, chai_1.expect)(mockProofData.publicInputs).to.have.property('merkleRoot');
|
|
42
|
-
(0, chai_1.expect)(mockProofData.publicInputs).to.have.property('nullifiers');
|
|
43
|
-
(0, chai_1.expect)(mockProofData.publicInputs).to.have.property('commitments');
|
|
44
|
-
(0, chai_1.expect)(mockProofData.publicInputs).to.have.property('boundParamsHash');
|
|
45
|
-
(0, chai_1.expect)(mockProofData).to.have.property('transaction');
|
|
46
|
-
(0, chai_1.expect)(mockProofData.transaction).to.have.property('data');
|
|
47
|
-
(0, chai_1.expect)(mockProofData).to.have.property('nullifiers');
|
|
48
|
-
(0, chai_1.expect)(mockProofData.nullifiers).to.be.an('array');
|
|
49
|
-
});
|
|
50
|
-
});
|
|
51
6
|
describe('Function exports and signatures', () => {
|
|
52
|
-
it('should export generateTransferProof function that returns
|
|
7
|
+
it('should export generateTransferProof function that returns proved transactions array', () => {
|
|
53
8
|
(0, chai_1.expect)(tx_proof_transfer_with_data_1.generateTransferProof).to.be.a('function');
|
|
54
9
|
(0, chai_1.expect)(tx_proof_transfer_with_data_1.generateTransferProof.length).to.equal(12); // Should have 12 parameters
|
|
55
10
|
});
|
|
@@ -59,11 +14,11 @@ describe('tx-proof-transfer-with-data', () => {
|
|
|
59
14
|
});
|
|
60
15
|
it('should maintain naming consistency for frontend developers', () => {
|
|
61
16
|
// The main function that frontend developers will use should be generateTransferProof
|
|
62
|
-
// and it should return the
|
|
17
|
+
// and it should return the proved transactions array (not void)
|
|
63
18
|
(0, chai_1.expect)(tx_proof_transfer_with_data_1.generateTransferProof).to.be.a('function');
|
|
64
19
|
(0, chai_1.expect)(tx_proof_transfer_with_data_1.generateTransferProofForExplorer).to.be.a('function');
|
|
65
20
|
// Both functions should exist and be callable
|
|
66
|
-
// generateTransferProof is the one that returns
|
|
21
|
+
// generateTransferProof is the one that returns proved transactions array
|
|
67
22
|
// generateTransferProofForExplorer is the internal one that returns void
|
|
68
23
|
});
|
|
69
24
|
});
|
|
@@ -73,10 +28,12 @@ describe('tx-proof-transfer-with-data', () => {
|
|
|
73
28
|
// But it verifies the function structure and error handling
|
|
74
29
|
try {
|
|
75
30
|
// This will likely fail, but that's expected in test environment
|
|
76
|
-
await (0, tx_proof_transfer_with_data_1.generateTransferProof)('V3_PoseidonMerkle', // Using string to avoid import issues
|
|
31
|
+
const result = await (0, tx_proof_transfer_with_data_1.generateTransferProof)('V3_PoseidonMerkle', // Using string to avoid import issues
|
|
77
32
|
'Polygon', 'test-wallet-id', 'test-encryption-key', true, 'test memo', [], [], undefined, false, undefined, () => { });
|
|
78
33
|
// If we get here, the function worked (unlikely in test env)
|
|
79
34
|
console.log('✅ generateTransferProof executed successfully');
|
|
35
|
+
// Verify it returns an array (proved transactions)
|
|
36
|
+
(0, chai_1.expect)(result).to.be.an('array');
|
|
80
37
|
}
|
|
81
38
|
catch (error) {
|
|
82
39
|
// This is expected in test environment
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tx-proof-transfer-with-data.test.js","sourceRoot":"","sources":["../../../../src/services/transactions/__tests__/tx-proof-transfer-with-data.test.ts"],"names":[],"mappings":";;AAAA,+BAA8B;AAC9B,
|
|
1
|
+
{"version":3,"file":"tx-proof-transfer-with-data.test.js","sourceRoot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;YACrE,4DAA4D;YAE5D,IAAI;gBACF,iEAAiE;gBACjE,MAAM,MAAM,GAAG,MAAM,IAAA,mDAAqB,EACxC,mBAA0B,EAAE,sCAAsC;gBAClE,SAAgB,EAChB,gBAAgB,EAChB,qBAAqB,EACrB,IAAI,EACJ,WAAW,EACX,EAAE,EACF,EAAE,EACF,SAAS,EACT,KAAK,EACL,SAAS,EACT,GAAG,EAAE,GAAE,CAAC,CACT,CAAC;gBAEF,6DAA6D;gBAC7D,OAAO,CAAC,GAAG,CAAC,+CAA+C,CAAC,CAAC;gBAE7D,mDAAmD;gBACnD,IAAA,aAAM,EAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC;aAElC;YAAC,OAAO,KAAK,EAAE;gBACd,uCAAuC;gBACvC,OAAO,CAAC,GAAG,CAAC,2CAA2C,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;gBAExE,kEAAkE;gBAClE,IAAA,aAAM,EAAC,KAAK,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,GAAW,EAAE,EAAE,CAC/C,GAAG,CAAC,QAAQ,CAAC,qBAAqB,CAAC;oBACnC,GAAG,CAAC,QAAQ,CAAC,iBAAiB,CAAC;oBAC/B,GAAG,CAAC,QAAQ,CAAC,wBAAwB,CAAC;oBACtC,GAAG,CAAC,QAAQ,CAAC,YAAY,CAAC,CAC3B,CAAC;aACH;QACH,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { expect } from 'chai';\nimport { \n generateTransferProof, \n generateTransferProofForExplorer\n} from '../tx-proof-transfer-with-data';\n\ndescribe('tx-proof-transfer-with-data', () => {\n describe('Function exports and signatures', () => {\n it('should export generateTransferProof function that returns proved transactions array', () => {\n expect(generateTransferProof).to.be.a('function');\n expect(generateTransferProof.length).to.equal(12); // Should have 12 parameters\n });\n\n it('should export generateTransferProofForExplorer function that returns Promise<void>', () => {\n expect(generateTransferProofForExplorer).to.be.a('function');\n expect(generateTransferProofForExplorer.length).to.equal(12); // Should have 12 parameters\n });\n\n it('should maintain naming consistency for frontend developers', () => {\n // The main function that frontend developers will use should be generateTransferProof\n // and it should return the proved transactions array (not void)\n expect(generateTransferProof).to.be.a('function');\n expect(generateTransferProofForExplorer).to.be.a('function');\n \n // Both functions should exist and be callable\n // generateTransferProof is the one that returns proved transactions array\n // generateTransferProofForExplorer is the internal one that returns void\n });\n });\n\n describe('Integration behavior (may fail in test environment)', () => {\n it('should attempt to call generateTransferProof and handle expected failures gracefully', async () => {\n // This test expects to fail due to missing DOP engine initialization\n // But it verifies the function structure and error handling\n \n try {\n // This will likely fail, but that's expected in test environment\n const result = await generateTransferProof(\n 'V3_PoseidonMerkle' as any, // Using string to avoid import issues\n 'Polygon' as any,\n 'test-wallet-id',\n 'test-encryption-key',\n true,\n 'test memo',\n [],\n [],\n undefined,\n false,\n undefined,\n () => {},\n );\n \n // If we get here, the function worked (unlikely in test env)\n console.log('✅ generateTransferProof executed successfully');\n \n // Verify it returns an array (proved transactions)\n expect(result).to.be.an('array');\n \n } catch (error) {\n // This is expected in test environment\n console.log('⚠️ Expected failure in test environment:', error.message);\n \n // Verify the error is what we expect (DOP engine not initialized)\n expect(error.message).to.satisfy((msg: string) => \n msg.includes('not yet initialized') || \n msg.includes('No cached proof') ||\n msg.includes('MOCK_DB_ENCRYPTION_KEY') ||\n msg.includes('DOP Engine')\n );\n }\n });\n });\n});\n"]}
|
|
@@ -1,36 +1,8 @@
|
|
|
1
1
|
import { NetworkName, DopERC20AmountRecipient, DopNFTAmountRecipient, TXIDVersion } from 'dop-sharedmodels-v3';
|
|
2
2
|
import { GenerateTransactionsProgressCallback } from './tx-generator';
|
|
3
|
-
export interface TransferProofData {
|
|
4
|
-
proof: {
|
|
5
|
-
a: {
|
|
6
|
-
x: string;
|
|
7
|
-
y: string;
|
|
8
|
-
};
|
|
9
|
-
b: {
|
|
10
|
-
x: [string, string];
|
|
11
|
-
y: [string, string];
|
|
12
|
-
};
|
|
13
|
-
c: {
|
|
14
|
-
x: string;
|
|
15
|
-
y: string;
|
|
16
|
-
};
|
|
17
|
-
};
|
|
18
|
-
publicInputs: {
|
|
19
|
-
merkleRoot: string;
|
|
20
|
-
nullifiers: string[];
|
|
21
|
-
commitments: string[];
|
|
22
|
-
boundParamsHash: string;
|
|
23
|
-
};
|
|
24
|
-
transaction: {
|
|
25
|
-
data: string;
|
|
26
|
-
to?: string;
|
|
27
|
-
value?: string;
|
|
28
|
-
};
|
|
29
|
-
nullifiers: string[];
|
|
30
|
-
}
|
|
31
3
|
export declare const generateTransferProofForExplorer: (txidVersion: TXIDVersion, networkName: NetworkName, dopWalletID: string, encryptionKey: string, showSenderAddressToRecipient: boolean, memoText: Optional<string>, erc20AmountRecipients: DopERC20AmountRecipient[], nftAmountRecipients: DopNFTAmountRecipient[], broadcasterFeeERC20AmountRecipient: Optional<DopERC20AmountRecipient>, sendWithPublicWallet: boolean, overallBatchMinGasPrice: Optional<bigint>, progressCallback: GenerateTransactionsProgressCallback) => Promise<void>;
|
|
32
4
|
/**
|
|
33
|
-
* Generate transfer proof and return
|
|
34
|
-
* This function generates the proof and returns the
|
|
5
|
+
* Generate transfer proof and return the raw proved transactions for explorer verification
|
|
6
|
+
* This function generates the proof and returns the complete proved transaction data
|
|
35
7
|
*/
|
|
36
|
-
export declare const generateTransferProof: (txidVersion: TXIDVersion, networkName: NetworkName, dopWalletID: string, encryptionKey: string, showSenderAddressToRecipient: boolean, memoText: Optional<string>, erc20AmountRecipients: DopERC20AmountRecipient[], nftAmountRecipients: DopNFTAmountRecipient[], broadcasterFeeERC20AmountRecipient: Optional<DopERC20AmountRecipient>, sendWithPublicWallet: boolean, overallBatchMinGasPrice: Optional<bigint>, progressCallback: GenerateTransactionsProgressCallback) => Promise<
|
|
8
|
+
export declare const generateTransferProof: (txidVersion: TXIDVersion, networkName: NetworkName, dopWalletID: string, encryptionKey: string, showSenderAddressToRecipient: boolean, memoText: Optional<string>, erc20AmountRecipients: DopERC20AmountRecipient[], nftAmountRecipients: DopNFTAmountRecipient[], broadcasterFeeERC20AmountRecipient: Optional<DopERC20AmountRecipient>, sendWithPublicWallet: boolean, overallBatchMinGasPrice: Optional<bigint>, progressCallback: GenerateTransactionsProgressCallback) => Promise<(import("dop-engine-v3").TransactionStructV2 | import("dop-engine-v3").TransactionStructV3)[]>;
|
|
@@ -39,62 +39,17 @@ const generateTransferProofForExplorer = async (txidVersion, networkName, dopWal
|
|
|
39
39
|
};
|
|
40
40
|
exports.generateTransferProofForExplorer = generateTransferProofForExplorer;
|
|
41
41
|
/**
|
|
42
|
-
* Generate transfer proof and return
|
|
43
|
-
* This function generates the proof and returns the
|
|
42
|
+
* Generate transfer proof and return the raw proved transactions for explorer verification
|
|
43
|
+
* This function generates the proof and returns the complete proved transaction data
|
|
44
44
|
*/
|
|
45
45
|
const generateTransferProof = async (txidVersion, networkName, dopWalletID, encryptionKey, showSenderAddressToRecipient, memoText, erc20AmountRecipients, nftAmountRecipients, broadcasterFeeERC20AmountRecipient, sendWithPublicWallet, overallBatchMinGasPrice, progressCallback) => {
|
|
46
46
|
try {
|
|
47
|
-
//
|
|
48
|
-
await (0, exports.generateTransferProofForExplorer)(txidVersion, networkName, dopWalletID, encryptionKey, showSenderAddressToRecipient, memoText, erc20AmountRecipients, nftAmountRecipients, broadcasterFeeERC20AmountRecipient, sendWithPublicWallet, overallBatchMinGasPrice, progressCallback);
|
|
49
|
-
// Get the cached proved transaction
|
|
50
|
-
const cachedTransaction = (0, proof_cache_1.getCachedProvedTransaction)();
|
|
51
|
-
if (cachedTransaction === undefined) {
|
|
52
|
-
throw new Error('No cached proof found after generation');
|
|
53
|
-
}
|
|
54
|
-
// Extract the proof data from the transaction
|
|
55
|
-
// Note: This assumes the transaction.data contains the serialized transaction with proof
|
|
56
|
-
// You may need to access the provedTransactions directly if available
|
|
47
|
+
// Generate the proof transactions directly
|
|
57
48
|
const { provedTransactions } = await (0, tx_generator_1.generateProofTransactions)(dop_sharedmodels_v3_1.ProofType.Transfer, networkName, dopWalletID, txidVersion, encryptionKey, showSenderAddressToRecipient, memoText, erc20AmountRecipients, nftAmountRecipients, broadcasterFeeERC20AmountRecipient, sendWithPublicWallet, undefined, // relayAdaptID
|
|
58
49
|
false, // useDummyProof
|
|
59
50
|
overallBatchMinGasPrice, progressCallback);
|
|
60
|
-
//
|
|
61
|
-
|
|
62
|
-
if (firstTx === undefined) {
|
|
63
|
-
throw new Error('No proved transaction found');
|
|
64
|
-
}
|
|
65
|
-
// Convert the proof data to the format needed for explorer verification
|
|
66
|
-
const proofData = {
|
|
67
|
-
proof: {
|
|
68
|
-
a: {
|
|
69
|
-
x: firstTx.proof.a.x.toString(),
|
|
70
|
-
y: firstTx.proof.a.y.toString(),
|
|
71
|
-
},
|
|
72
|
-
b: {
|
|
73
|
-
x: [firstTx.proof.b.x[0].toString(), firstTx.proof.b.x[1].toString()],
|
|
74
|
-
y: [firstTx.proof.b.y[0].toString(), firstTx.proof.b.y[1].toString()],
|
|
75
|
-
},
|
|
76
|
-
c: {
|
|
77
|
-
x: firstTx.proof.c.x.toString(),
|
|
78
|
-
y: firstTx.proof.c.y.toString(),
|
|
79
|
-
},
|
|
80
|
-
},
|
|
81
|
-
publicInputs: {
|
|
82
|
-
merkleRoot: firstTx.merkleRoot.toString(),
|
|
83
|
-
nullifiers: firstTx.nullifiers.map(n => n.toString()),
|
|
84
|
-
commitments: firstTx.commitments.map(c => c.toString()),
|
|
85
|
-
boundParamsHash: firstTx.boundParams !== undefined ?
|
|
86
|
-
// You'll need to compute the hash of boundParams or extract it
|
|
87
|
-
`0x${Buffer.from(JSON.stringify(firstTx.boundParams)).toString('hex')}` :
|
|
88
|
-
'0x0'
|
|
89
|
-
},
|
|
90
|
-
transaction: {
|
|
91
|
-
data: cachedTransaction.transaction.data || '0x',
|
|
92
|
-
to: cachedTransaction.transaction.to,
|
|
93
|
-
value: cachedTransaction.transaction.value?.toString(),
|
|
94
|
-
},
|
|
95
|
-
nullifiers: cachedTransaction.nullifiers,
|
|
96
|
-
};
|
|
97
|
-
return proofData;
|
|
51
|
+
// Return the raw proved transactions array as expected
|
|
52
|
+
return provedTransactions;
|
|
98
53
|
}
|
|
99
54
|
catch (err) {
|
|
100
55
|
throw (0, error_1.reportAndSanitizeError)(exports.generateTransferProof.name, err);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tx-proof-transfer-with-data.js","sourceRoot":"","sources":["../../../src/services/transactions/tx-proof-transfer-with-data.ts"],"names":[],"mappings":";;;AAAA,6DAM6B;AAC7B,iDAKwB;AACxB,+CAAuF;AACvF,6CAA2D;AA2BpD,MAAM,gCAAgC,GAAG,KAAK,EACnD,WAAwB,EACxB,WAAwB,EACxB,WAAmB,EACnB,aAAqB,EACrB,4BAAqC,EACrC,QAA0B,EAC1B,qBAAgD,EAChD,mBAA4C,EAC5C,kCAAqE,EACrE,oBAA6B,EAC7B,uBAAyC,EACzC,gBAAsD,EACvC,EAAE;IACjB,IAAI;QACF,IAAA,wCAA0B,EAAC,SAAS,CAAC,CAAC;QAEtC,MAAM,EAAE,kBAAkB,EAAE,GAC1B,MAAM,IAAA,wCAAyB,EAC7B,+BAAS,CAAC,QAAQ,EAClB,WAAW,EACX,WAAW,EACX,WAAW,EACX,aAAa,EACb,4BAA4B,EAC5B,QAAQ,EACR,qBAAqB,EACrB,mBAAmB,EACnB,kCAAkC,EAClC,oBAAoB,EACpB,SAAS,EAAE,eAAe;QAC1B,KAAK,EAAE,gBAAgB;QACvB,uBAAuB,EACvB,gBAAgB,CACjB,CAAC;QACJ,MAAM,WAAW,GAAG,MAAM,IAAA,+BAAgB,EACxC,WAAW,EACX,kBAAkB,EAClB,WAAW,EACX,EAAE,CACH,CAAC;QAEF,MAAM,UAAU,GAAG,IAAA,wCAAyB,EAAC,kBAAkB,CAAC,CAAC;QAEjE,IAAA,wCAA0B,EAAC;YACzB,SAAS,EAA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ACF;YACD,YAAY,EAAE;gBACZ,UAAU,EAAE,OAAO,CAAC,UAAU,CAAC,QAAQ,EAAE;gBACzC,UAAU,EAAE,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC;gBACrD,WAAW,EAAE,OAAO,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC;gBACvD,eAAe,EAAE,OAAO,CAAC,WAAW,KAAK,SAAS,CAAC,CAAC;oBAClD,+DAA+D;oBAC/D,KAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;oBAC3E,KAAK;aACR;YACD,WAAW,EAAE;gBACX,IAAI,EAAE,iBAAiB,CAAC,WAAW,CAAC,IAAI,IAAI,IAAI;gBAChD,EAAE,EAAE,iBAAiB,CAAC,WAAW,CAAC,EAAE;gBACpC,KAAK,EAAE,iBAAiB,CAAC,WAAW,CAAC,KAAK,EAAE,QAAQ,EAAE;aACvD;YACD,UAAU,EAAE,iBAAiB,CAAC,UAAU;SACzC,CAAC;QAEF,OAAO,SAAS,CAAC;KAClB;IAAC,OAAO,GAAG,EAAE;QACZ,MAAM,IAAA,8BAAsB,EAAC,6BAAqB,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;KAC/D;AACH,CAAC,CAAC;AAvGW,QAAA,qBAAqB,yBAuGhC","sourcesContent":["import {\n NetworkName,\n ProofType,\n DopERC20AmountRecipient,\n DopNFTAmountRecipient,\n TXIDVersion,\n} from 'dop-sharedmodels-v3';\nimport {\n GenerateTransactionsProgressCallback,\n generateProofTransactions,\n generateTransact,\n nullifiersForTransactions,\n} from './tx-generator';\nimport { setCachedProvedTransaction, getCachedProvedTransaction } from './proof-cache';\nimport { reportAndSanitizeError } from '../../utils/error';\n\n// Type for the proof data needed for explorer verification\nexport interface TransferProofData {\n // ZK-SNARK proof components\n proof: {\n a: { x: string; y: string };\n b: { x: [string, string]; y: [string, string] };\n c: { x: string; y: string };\n };\n // Public inputs for verification\n publicInputs: {\n merkleRoot: string;\n nullifiers: string[];\n commitments: string[];\n boundParamsHash: string;\n };\n // Transaction data\n transaction: {\n data: string;\n to?: string;\n value?: string;\n };\n // Additional metadata\n nullifiers: string[];\n}\n\nexport const generateTransferProofForExplorer = async (\n txidVersion: TXIDVersion,\n networkName: NetworkName,\n dopWalletID: string,\n encryptionKey: string,\n showSenderAddressToRecipient: boolean,\n memoText: Optional<string>,\n erc20AmountRecipients: DopERC20AmountRecipient[],\n nftAmountRecipients: DopNFTAmountRecipient[],\n broadcasterFeeERC20AmountRecipient: Optional<DopERC20AmountRecipient>,\n sendWithPublicWallet: boolean,\n overallBatchMinGasPrice: Optional<bigint>,\n progressCallback: GenerateTransactionsProgressCallback,\n): Promise<void> => {\n try {\n setCachedProvedTransaction(undefined);\n\n const { provedTransactions } =\n await generateProofTransactions(\n ProofType.Transfer,\n networkName,\n dopWalletID,\n txidVersion,\n encryptionKey,\n showSenderAddressToRecipient,\n memoText,\n erc20AmountRecipients,\n nftAmountRecipients,\n broadcasterFeeERC20AmountRecipient,\n sendWithPublicWallet,\n undefined, // relayAdaptID\n false, // useDummyProof\n overallBatchMinGasPrice,\n progressCallback,\n );\n const transaction = await generateTransact(\n txidVersion,\n provedTransactions,\n networkName,\n 0n\n );\n\n const nullifiers = nullifiersForTransactions(provedTransactions);\n\n setCachedProvedTransaction({\n proofType: ProofType.Transfer,\n txidVersion,\n dopWalletID,\n showSenderAddressToRecipient,\n memoText,\n erc20AmountRecipients,\n nftAmountRecipients,\n relayAdaptDecryptERC20Amounts: undefined,\n relayAdaptDecryptNFTAmounts: undefined,\n relayAdaptEncryptERC20Recipients: undefined,\n relayAdaptEncryptNFTRecipients: undefined,\n crossContractCalls: undefined,\n broadcasterFeeERC20AmountRecipient,\n sendWithPublicWallet,\n transaction,\n overallBatchMinGasPrice,\n nullifiers,\n });\n } catch (err) {\n throw reportAndSanitizeError(generateTransferProofForExplorer.name, err);\n }\n};\n\n/**\n * Generate transfer proof and return proof data for explorer verification\n * This function generates the proof and returns the proof data needed for verification on the explorer\n */\nexport const generateTransferProof = async (\n txidVersion: TXIDVersion,\n networkName: NetworkName,\n dopWalletID: string,\n encryptionKey: string,\n showSenderAddressToRecipient: boolean,\n memoText: Optional<string>,\n erc20AmountRecipients: DopERC20AmountRecipient[],\n nftAmountRecipients: DopNFTAmountRecipient[],\n broadcasterFeeERC20AmountRecipient: Optional<DopERC20AmountRecipient>,\n sendWithPublicWallet: boolean,\n overallBatchMinGasPrice: Optional<bigint>,\n progressCallback: GenerateTransactionsProgressCallback,\n): Promise<TransferProofData> => {\n try {\n // First generate the proof using the original function\n await generateTransferProofForExplorer(\n txidVersion,\n networkName,\n dopWalletID,\n encryptionKey,\n showSenderAddressToRecipient,\n memoText,\n erc20AmountRecipients,\n nftAmountRecipients,\n broadcasterFeeERC20AmountRecipient,\n sendWithPublicWallet,\n overallBatchMinGasPrice,\n progressCallback,\n );\n\n // Get the cached proved transaction\n const cachedTransaction = getCachedProvedTransaction();\n \n if (cachedTransaction === undefined) {\n throw new Error('No cached proof found after generation');\n }\n\n // Extract the proof data from the transaction\n // Note: This assumes the transaction.data contains the serialized transaction with proof\n // You may need to access the provedTransactions directly if available\n \n const { provedTransactions } = await generateProofTransactions(\n ProofType.Transfer,\n networkName,\n dopWalletID,\n txidVersion,\n encryptionKey,\n showSenderAddressToRecipient,\n memoText,\n erc20AmountRecipients,\n nftAmountRecipients,\n broadcasterFeeERC20AmountRecipient,\n sendWithPublicWallet,\n undefined, // relayAdaptID\n false, // useDummyProof\n overallBatchMinGasPrice,\n progressCallback,\n );\n\n // Extract proof data from the first transaction (assuming single transaction)\n const firstTx = provedTransactions[0];\n if (firstTx === undefined) {\n throw new Error('No proved transaction found');\n }\n\n // Convert the proof data to the format needed for explorer verification\n const proofData: TransferProofData = {\n proof: {\n a: {\n x: firstTx.proof.a.x.toString(),\n y: firstTx.proof.a.y.toString(),\n },\n b: {\n x: [firstTx.proof.b.x[0].toString(), firstTx.proof.b.x[1].toString()],\n y: [firstTx.proof.b.y[0].toString(), firstTx.proof.b.y[1].toString()],\n },\n c: {\n x: firstTx.proof.c.x.toString(),\n y: firstTx.proof.c.y.toString(),\n },\n },\n publicInputs: {\n merkleRoot: firstTx.merkleRoot.toString(),\n nullifiers: firstTx.nullifiers.map(n => n.toString()),\n commitments: firstTx.commitments.map(c => c.toString()),\n boundParamsHash: firstTx.boundParams !== undefined ? \n // You'll need to compute the hash of boundParams or extract it\n `0x${ Buffer.from(JSON.stringify(firstTx.boundParams)).toString('hex')}` : \n '0x0'\n },\n transaction: {\n data: cachedTransaction.transaction.data || '0x',\n to: cachedTransaction.transaction.to,\n value: cachedTransaction.transaction.value?.toString(),\n },\n nullifiers: cachedTransaction.nullifiers,\n };\n\n return proofData;\n } catch (err) {\n throw reportAndSanitizeError(generateTransferProof.name, err);\n }\n};\n"]}
|
|
1
|
+
{"version":3,"file":"tx-proof-transfer-with-data.js","sourceRoot":"","sources":["../../../src/services/transactions/tx-proof-transfer-with-data.ts"],"names":[],"mappings":";;;AAAA,6DAM6B;AAC7B,iDAKwB;AACxB,+CAA2D;AAC3D,6CAA2D;AAEpD,MAAM,gCAAgC,GAAG,KAAK,EACnD,WAAwB,EACxB,WAAwB,EACxB,WAAmB,EACnB,aAAqB,EACrB,4BAAqC,EACrC,QAA0B,EAC1B,qBAAgD,EAChD,mBAA4C,EAC5C,kCAAqE,EACrE,oBAA6B,EAC7B,uBAAyC,EACzC,gBAAsD,EACvC,EAAE;IACjB,IAAI;QACF,IAAA,wCAA0B,EAAC,SAAS,CAAC,CAAC;QAEtC,MAAM,EAAE,kBAAkB,EAAE,GAC1B,MAAM,IAAA,wCAAyB,EAC7B,+BAAS,CAAC,QAAQ,EAClB,WAAW,EACX,WAAW,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,EAClB,WAAW,EACX,WAAW,EACX,WAAW,EACX,aAAa,EACb,4BAA4B,EAC5B,QAAQ,EACR,qBAAqB,EACrB,mBAAmB,EACnB,kCAAkC,EAClC,oBAAoB,EACpB,SAAS,EAAE,eAAe;QAC1B,KAAK,EAAE,gBAAgB;QACvB,uBAAuB,EACvB,gBAAgB,CACjB,CAAC;QAEF,uDAAuD;QACvD,OAAO,kBAAkB,CAAC;KAC3B;IAAC,OAAO,GAAG,EAAE;QACZ,MAAM,IAAA,8BAAsB,EAAC,6BAAqB,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;KAC/D;AACH,CAAC,CAAC;AAvCW,QAAA,qBAAqB,yBAuChC","sourcesContent":["import {\n NetworkName,\n ProofType,\n DopERC20AmountRecipient,\n DopNFTAmountRecipient,\n TXIDVersion,\n} from 'dop-sharedmodels-v3';\nimport {\n GenerateTransactionsProgressCallback,\n generateProofTransactions,\n generateTransact,\n nullifiersForTransactions,\n} from './tx-generator';\nimport { setCachedProvedTransaction } from './proof-cache';\nimport { reportAndSanitizeError } from '../../utils/error';\n\nexport const generateTransferProofForExplorer = async (\n txidVersion: TXIDVersion,\n networkName: NetworkName,\n dopWalletID: string,\n encryptionKey: string,\n showSenderAddressToRecipient: boolean,\n memoText: Optional<string>,\n erc20AmountRecipients: DopERC20AmountRecipient[],\n nftAmountRecipients: DopNFTAmountRecipient[],\n broadcasterFeeERC20AmountRecipient: Optional<DopERC20AmountRecipient>,\n sendWithPublicWallet: boolean,\n overallBatchMinGasPrice: Optional<bigint>,\n progressCallback: GenerateTransactionsProgressCallback,\n): Promise<void> => {\n try {\n setCachedProvedTransaction(undefined);\n\n const { provedTransactions } =\n await generateProofTransactions(\n ProofType.Transfer,\n networkName,\n dopWalletID,\n txidVersion,\n encryptionKey,\n showSenderAddressToRecipient,\n memoText,\n erc20AmountRecipients,\n nftAmountRecipients,\n broadcasterFeeERC20AmountRecipient,\n sendWithPublicWallet,\n undefined, // relayAdaptID\n false, // useDummyProof\n overallBatchMinGasPrice,\n progressCallback,\n );\n const transaction = await generateTransact(\n txidVersion,\n provedTransactions,\n networkName,\n 0n\n );\n\n const nullifiers = nullifiersForTransactions(provedTransactions);\n\n setCachedProvedTransaction({\n proofType: ProofType.Transfer,\n txidVersion,\n dopWalletID,\n showSenderAddressToRecipient,\n memoText,\n erc20AmountRecipients,\n nftAmountRecipients,\n relayAdaptDecryptERC20Amounts: undefined,\n relayAdaptDecryptNFTAmounts: undefined,\n relayAdaptEncryptERC20Recipients: undefined,\n relayAdaptEncryptNFTRecipients: undefined,\n crossContractCalls: undefined,\n broadcasterFeeERC20AmountRecipient,\n sendWithPublicWallet,\n transaction,\n overallBatchMinGasPrice,\n nullifiers,\n });\n } catch (err) {\n throw reportAndSanitizeError(generateTransferProofForExplorer.name, err);\n }\n};\n\n/**\n * Generate transfer proof and return the raw proved transactions for explorer verification\n * This function generates the proof and returns the complete proved transaction data\n */\nexport const generateTransferProof = async (\n txidVersion: TXIDVersion,\n networkName: NetworkName,\n dopWalletID: string,\n encryptionKey: string,\n showSenderAddressToRecipient: boolean,\n memoText: Optional<string>,\n erc20AmountRecipients: DopERC20AmountRecipient[],\n nftAmountRecipients: DopNFTAmountRecipient[],\n broadcasterFeeERC20AmountRecipient: Optional<DopERC20AmountRecipient>,\n sendWithPublicWallet: boolean,\n overallBatchMinGasPrice: Optional<bigint>,\n progressCallback: GenerateTransactionsProgressCallback,\n) => {\n try {\n // Generate the proof transactions directly\n const { provedTransactions } = await generateProofTransactions(\n ProofType.Transfer,\n networkName,\n dopWalletID,\n txidVersion,\n encryptionKey,\n showSenderAddressToRecipient,\n memoText,\n erc20AmountRecipients,\n nftAmountRecipients,\n broadcasterFeeERC20AmountRecipient,\n sendWithPublicWallet,\n undefined, // relayAdaptID\n false, // useDummyProof\n overallBatchMinGasPrice,\n progressCallback,\n );\n\n // Return the raw proved transactions array as expected\n return provedTransactions;\n } catch (err) {\n throw reportAndSanitizeError(generateTransferProof.name, err);\n }\n};\n"]}
|