@smithii_io/mixoor 0.0.13 → 0.0.14
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/src/index.js +89 -2
- package/dist/src/index.js.map +1 -1
- package/dist/src/index.mjs +83 -3
- package/dist/src/index.mjs.map +1 -1
- package/dist/test/_setup.js +20 -0
- package/dist/test/_setup.js.map +1 -1
- package/dist/types/src/generated/instructions/index.d.ts +1 -0
- package/dist/types/src/generated/instructions/index.d.ts.map +1 -1
- package/dist/types/src/generated/instructions/updateRoot.d.ts +44 -0
- package/dist/types/src/generated/instructions/updateRoot.d.ts.map +1 -0
- package/dist/types/src/generated/programs/mixoor.d.ts +5 -2
- package/dist/types/src/generated/programs/mixoor.d.ts.map +1 -1
- package/dist/types/test/_setup.d.ts +3 -0
- package/dist/types/test/_setup.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/test/_setup.js
CHANGED
|
@@ -172,6 +172,25 @@ const transferForAuthority = async (client, ixArgs) => {
|
|
|
172
172
|
);
|
|
173
173
|
return { relayer: relayer.address };
|
|
174
174
|
};
|
|
175
|
+
const updatePoolForRelayer = async (client, root, assetType) => {
|
|
176
|
+
const [relayer] = await Promise.all([loadDefaultKeypair()]);
|
|
177
|
+
const [pool] = await src.findPoolAddress({
|
|
178
|
+
mint: _constants.WRAPPED_SOL_MINT_TOKEN_PROGRAM,
|
|
179
|
+
assetType
|
|
180
|
+
});
|
|
181
|
+
const updateRootIx = await src.getUpdateRootInstruction({
|
|
182
|
+
pool,
|
|
183
|
+
root
|
|
184
|
+
});
|
|
185
|
+
await kit.pipe(
|
|
186
|
+
await createDefaultTransaction(client, relayer),
|
|
187
|
+
(tx) => kit.appendTransactionMessageInstruction(updateRootIx, tx),
|
|
188
|
+
(tx) => signAndSendTransaction(client, tx)
|
|
189
|
+
);
|
|
190
|
+
return {
|
|
191
|
+
relayer: relayer.address
|
|
192
|
+
};
|
|
193
|
+
};
|
|
175
194
|
|
|
176
195
|
exports.airdropSolToAddress = airdropSolToAddress;
|
|
177
196
|
exports.createDefaultSolanaClient = createDefaultSolanaClient;
|
|
@@ -188,5 +207,6 @@ exports.loadReceiverKeypair = loadReceiverKeypair;
|
|
|
188
207
|
exports.loadRelayerKeypair = loadRelayerKeypair;
|
|
189
208
|
exports.signAndSendTransaction = signAndSendTransaction;
|
|
190
209
|
exports.transferForAuthority = transferForAuthority;
|
|
210
|
+
exports.updatePoolForRelayer = updatePoolForRelayer;
|
|
191
211
|
//# sourceMappingURL=_setup.js.map
|
|
192
212
|
//# sourceMappingURL=_setup.js.map
|
package/dist/test/_setup.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../test/_setup.ts"],"names":["createSolanaRpc","createSolanaRpcSubscriptions","generateKeyPairSigner","airdropFactory","lamports","path","os","fs","createKeyPairSignerFromBytes","pipe","createTransactionMessage","setTransactionMessageFeePayerSigner","setTransactionMessageLifetimeUsingBlockhash","signTransactionMessageWithSigners","assertIsSendableTransaction","getSignatureFromTransaction","assertIsTransactionWithBlockhashLifetime","sendAndConfirmTransactionFactory","getInitializePoolInstructionAsync","WRAPPED_SOL_MINT_TOKEN_PROGRAM","AssetType","appendTransactionMessageInstruction","findPoolAddress","randomBytes","generateCommitment","getDepositInstructionAsync","getTransferInstructionAsync","appendTransactionMessageInstructions","getSetComputeUnitLimitInstruction"],"mappings":";;;;;;;;;;;;;;;;;AAqDO,MAAM,4BAA4B,MAAc;AACrD,EAAA,MAAM,GAAA,GAAMA,oBAAgB,uBAAuB,CAAA;AACnD,EAAA,MAAM,gBAAA,GAAmBC,iCAA6B,qBAAqB,CAAA;AAC3E,EAAA,OAAO,EAAE,KAAK,gBAAA,EAAiB;AACjC;AAEO,MAAM,qBAAqB,MAAc;AAC9C,EAAA,MAAM,GAAA,GAAMD,oBAAgB,+BAA+B,CAAA;AAC3D,EAAA,MAAM,gBAAA,GAAmBC,gCAAA;AAAA,IACvB;AAAA,GACF;AAEA,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OAAA;AAAA,IACA,IAAA;AAAA,IACA,WAAW,SAAA,CAAU,OAAA;AAAA,IACrB,MAAA;AAAA,IACA,MAAA;AAAA,IACA,MAAA;AAAA,IACA,aAAA;AAAA,IACA,YAAA;AAAA,IACA,eAAA;AAAA,IACA,UAAA;AAAA,IACA;AAAA,GACD,CAAA;AAED,EAAA,MAAMjB,QAAA;AAAA,IACJ,MAAM,wBAAA,CAAyB,MAAA,EAAQ,OAAO,CAAA;AAAA,IAC9C,CAAC,EAAA,KAAOY,uCAAA,CAAoC,UAAA,EAAY,EAAE,CAAA;AAAA,IAC1D,CAAC,EAAA,KACCM,wCAAA;AAAA,MACE,CAACC,+CAAA,CAAkC,EAAE,KAAA,EAAO,IAAA,EAAW,CAAC,CAAA;AAAA,MACxD;AAAA,KACF;AAAA,IACF,CAAC,EAAA,KAAO,sBAAA,CAAuB,MAAA,EAAQ,EAAE;AAAA,GAC3C;AAIA,EAAA,OAAO,EAAE,OAAA,EAAS,OAAA,CAAQ,OAAA,EAAQ;AACpC","file":"_setup.js","sourcesContent":["import { getSetComputeUnitLimitInstruction } from '@solana-program/compute-budget';\nimport {\n Address,\n airdropFactory,\n appendTransactionMessageInstruction,\n appendTransactionMessageInstructions,\n assertIsSendableTransaction,\n assertIsTransactionWithBlockhashLifetime,\n Commitment,\n createKeyPairSignerFromBytes,\n createSolanaRpc,\n createSolanaRpcSubscriptions,\n createTransactionMessage,\n generateKeyPairSigner,\n getSignatureFromTransaction,\n KeyPairSigner,\n lamports,\n pipe,\n Rpc,\n RpcSubscriptions,\n sendAndConfirmTransactionFactory,\n setTransactionMessageFeePayerSigner,\n setTransactionMessageLifetimeUsingBlockhash,\n signTransactionMessageWithSigners,\n SolanaRpcApi,\n SolanaRpcSubscriptionsApi,\n TransactionMessage,\n TransactionMessageWithFeePayer,\n TransactionSigner,\n} from '@solana/kit';\n\nimport fs from 'fs';\nimport os from 'os';\nimport path from 'path';\n\nimport { randomBytes } from 'crypto';\nimport {\n AssetType,\n findPoolAddress,\n generateCommitment,\n getDepositInstructionAsync,\n getInitializePoolInstructionAsync,\n getTransferInstructionAsync,\n MerkleTree,\n ProofData,\n} from '../src';\nimport { WRAPPED_SOL_MINT_TOKEN_PROGRAM } from './_constants';\n\nexport type Client = {\n rpc: Rpc<SolanaRpcApi>;\n rpcSubscriptions: RpcSubscriptions<SolanaRpcSubscriptionsApi>;\n};\n\nexport const createDefaultSolanaClient = (): Client => {\n const rpc = createSolanaRpc('http://127.0.0.1:8899');\n const rpcSubscriptions = createSolanaRpcSubscriptions('ws://127.0.0.1:8900');\n return { rpc, rpcSubscriptions };\n};\n\nexport const createDevnetClient = (): Client => {\n const rpc = createSolanaRpc('https://api.devnet.solana.com');\n const rpcSubscriptions = createSolanaRpcSubscriptions(\n 'wss://api.devnet.solana.com/'\n );\n\n return { rpc, rpcSubscriptions };\n};\n\nexport const generateKeyPairSignerWithSol = async (\n client: Client,\n putativeLamports: bigint = 1_000_000_000n\n) => {\n const signer = await generateKeyPairSigner();\n await airdropFactory(client)({\n recipientAddress: signer.address,\n lamports: lamports(putativeLamports),\n commitment: 'confirmed',\n });\n return signer;\n};\n\nexport const airdropSolToAddress = async (\n client: Client,\n receiver: Address, // 5 sol\n putativeLamports: bigint = 5_000_000_000n // 5 sol\n) => {\n await airdropFactory(client)({\n recipientAddress: receiver,\n lamports: lamports(putativeLamports),\n commitment: 'confirmed',\n });\n};\n\nexport async function loadKeypairFromFile(\n filePath: string\n): Promise<KeyPairSigner<string>> {\n // This is here so you can also load the default keypair from the file system.\n const resolvedPath = path.resolve(\n filePath.startsWith('~') ? filePath.replace('~', os.homedir()) : filePath\n );\n const loadedKeyBytes = Uint8Array.from(\n JSON.parse(fs.readFileSync(resolvedPath, 'utf8'))\n );\n // Here you can also set the second parameter to true in case you need to extract your private key.\n const keypairSigner = await createKeyPairSignerFromBytes(loadedKeyBytes);\n return keypairSigner;\n}\n\nexport const createDefaultTransaction = async (\n client: Client,\n feePayer: TransactionSigner\n) => {\n const { value: latestBlockhash } = await client.rpc\n .getLatestBlockhash()\n .send();\n return pipe(\n createTransactionMessage({ version: 0 }),\n (tx) => setTransactionMessageFeePayerSigner(feePayer, tx),\n (tx) => setTransactionMessageLifetimeUsingBlockhash(latestBlockhash, tx)\n );\n};\n\nexport const signAndSendTransaction = async (\n client: Client,\n transactionMessage: TransactionMessage & TransactionMessageWithFeePayer,\n // & TransactionMessageWithLifetime,\n commitment: Commitment = 'finalized'\n) => {\n const signedTransaction =\n await signTransactionMessageWithSigners(transactionMessage);\n assertIsSendableTransaction(signedTransaction);\n\n const signature = getSignatureFromTransaction(signedTransaction);\n\n assertIsTransactionWithBlockhashLifetime(signedTransaction);\n await sendAndConfirmTransactionFactory(client)(signedTransaction, {\n commitment,\n skipPreflight: true,\n });\n\n console.log('[DEBUG;] le signature ->', signature, '\\n'); // ! debug\n return signature;\n};\n\nexport const getBalance = async (client: Client, address: Address) =>\n (await client.rpc.getBalance(address, { commitment: 'confirmed' }).send())\n .value;\n\nexport async function loadDefaultKeypair(): Promise<KeyPairSigner<string>> {\n return await loadKeypairFromFile('~/.config/solana/id.json');\n}\n\nexport async function loadReceiverKeypair(): Promise<KeyPairSigner<string>> {\n return await loadKeypairFromFile('~/.config/solana/id-new.json');\n}\n\nexport async function loadRelayerKeypair(): Promise<KeyPairSigner<string>> {\n return await loadKeypairFromFile('~/.config/solana/relayer.json');\n}\n\nexport const getTokenBalance = async (client: Client, tokenAccount: Address) =>\n (\n await client.rpc\n .getTokenAccountBalance(tokenAccount, { commitment: 'confirmed' })\n .send()\n ).value;\n\n// -------------------------------------------------- instructions\n\nexport const createSolPoolForAuthority = async (\n client: Client\n // merkleTree?: Address\n): Promise<{ authority: Address }> => {\n const [authority] = await Promise.all([loadDefaultKeypair()]);\n\n const createIx = await getInitializePoolInstructionAsync({\n authority,\n mint: WRAPPED_SOL_MINT_TOKEN_PROGRAM,\n assetType: AssetType.Sol,\n });\n\n await pipe(\n await createDefaultTransaction(client, authority),\n (tx) => appendTransactionMessageInstruction(createIx, tx),\n (tx) => signAndSendTransaction(client, tx)\n );\n\n return { authority: authority.address };\n};\n\nexport const depositSolPoolForAuthority = async (\n client: Client,\n amount: bigint,\n assetType: AssetType,\n merkleTree: MerkleTree\n): Promise<{\n depositor: Address;\n commitment: Uint8Array;\n secret: Uint8Array;\n nullifier: Uint8Array;\n}> => {\n const [authority] = await Promise.all([loadDefaultKeypair()]);\n\n // find pool address\n const [pool] = await findPoolAddress({\n mint: WRAPPED_SOL_MINT_TOKEN_PROGRAM,\n assetType,\n });\n\n // generate commitment\n const secret = randomBytes(32);\n const nullifier = randomBytes(32);\n const commitment = await generateCommitment(secret, nullifier, amount, pool);\n\n // Insert commitment into merkle tree and compute new root\n merkleTree.insert(commitment);\n const newRoot = merkleTree.root();\n\n // ! NOTE, DURING INITIALIZATION,\n const depositIx = await getDepositInstructionAsync({\n depositor: authority,\n pool,\n amount,\n commitment,\n newRoot,\n mint: WRAPPED_SOL_MINT_TOKEN_PROGRAM,\n });\n\n await pipe(\n await createDefaultTransaction(client, authority),\n (tx) => appendTransactionMessageInstruction(depositIx, tx),\n (tx) => signAndSendTransaction(client, tx)\n );\n\n return {\n depositor: authority.address,\n commitment,\n secret,\n nullifier,\n };\n};\n\nexport const transferForAuthority = async (\n client: Client,\n ixArgs: {\n relayerFee: number;\n recipientAmount: bigint;\n nullifierHash: Uint8Array;\n proofData: ProofData;\n publicInputs: Uint8Array[];\n mint: Address;\n assetType: AssetType;\n }\n): Promise<{\n relayer: Address;\n}> => {\n const [relayer, recipient] = await Promise.all([\n loadRelayerKeypair(),\n loadReceiverKeypair(),\n ]);\n\n // airdrop relayer\n await airdropSolToAddress(client, relayer.address);\n\n const {\n relayerFee,\n recipientAmount,\n nullifierHash,\n assetType,\n mint,\n publicInputs,\n proofData: { proofA, proofB, proofC },\n } = ixArgs;\n\n // find pool address\n const [pool] = await findPoolAddress({\n mint,\n assetType,\n });\n\n // TEMPORARY: The autogenerated client hasn't been regenerated yet\n // The Rust program expects: relayer_fee (6th), recipient_amount (7th)\n // But the old client has: amount (6th), fee (7th)\n // So we swap them here until the client is regenerated\n const transferIx = await getTransferInstructionAsync({\n relayer,\n pool,\n recipient: recipient.address,\n proofA,\n proofB,\n proofC,\n nullifierHash,\n publicInputs,\n recipientAmount: recipientAmount,\n relayerFee: relayerFee,\n mint,\n });\n\n await pipe(\n await createDefaultTransaction(client, relayer),\n (tx) => appendTransactionMessageInstruction(transferIx, tx),\n (tx) =>\n appendTransactionMessageInstructions(\n [getSetComputeUnitLimitInstruction({ units: 1_400_000 })],\n tx\n ),\n (tx) => signAndSendTransaction(client, tx)\n );\n\n // todo: return the address of the pool\n // todo: what to return\n return { relayer: relayer.address };\n};\n"]}
|
|
1
|
+
{"version":3,"sources":["../../test/_setup.ts"],"names":["createSolanaRpc","createSolanaRpcSubscriptions","generateKeyPairSigner","airdropFactory","lamports","path","os","fs","createKeyPairSignerFromBytes","pipe","createTransactionMessage","setTransactionMessageFeePayerSigner","setTransactionMessageLifetimeUsingBlockhash","signTransactionMessageWithSigners","assertIsSendableTransaction","getSignatureFromTransaction","assertIsTransactionWithBlockhashLifetime","sendAndConfirmTransactionFactory","getInitializePoolInstructionAsync","WRAPPED_SOL_MINT_TOKEN_PROGRAM","AssetType","appendTransactionMessageInstruction","findPoolAddress","randomBytes","generateCommitment","getDepositInstructionAsync","getTransferInstructionAsync","appendTransactionMessageInstructions","getSetComputeUnitLimitInstruction","getUpdateRootInstruction"],"mappings":";;;;;;;;;;;;;;;;;AAsDO,MAAM,4BAA4B,MAAc;AACrD,EAAA,MAAM,GAAA,GAAMA,oBAAgB,uBAAuB,CAAA;AACnD,EAAA,MAAM,gBAAA,GAAmBC,iCAA6B,qBAAqB,CAAA;AAC3E,EAAA,OAAO,EAAE,KAAK,gBAAA,EAAiB;AACjC;AAEO,MAAM,qBAAqB,MAAc;AAC9C,EAAA,MAAM,GAAA,GAAMD,oBAAgB,+BAA+B,CAAA;AAC3D,EAAA,MAAM,gB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A,IAC5D,CAAC,EAAA,KAAO,sBAAA,CAAuB,MAAA,EAAQ,EAAE;AAAA,GAC3C;AAEA,EAAA,OAAO;AAAA,IACL,SAAS,OAAA,CAAQ;AAAA,GACnB;AACF","file":"_setup.js","sourcesContent":["import { getSetComputeUnitLimitInstruction } from '@solana-program/compute-budget';\nimport {\n Address,\n airdropFactory,\n appendTransactionMessageInstruction,\n appendTransactionMessageInstructions,\n assertIsSendableTransaction,\n assertIsTransactionWithBlockhashLifetime,\n Commitment,\n createKeyPairSignerFromBytes,\n createSolanaRpc,\n createSolanaRpcSubscriptions,\n createTransactionMessage,\n generateKeyPairSigner,\n getSignatureFromTransaction,\n KeyPairSigner,\n lamports,\n pipe,\n Rpc,\n RpcSubscriptions,\n sendAndConfirmTransactionFactory,\n setTransactionMessageFeePayerSigner,\n setTransactionMessageLifetimeUsingBlockhash,\n signTransactionMessageWithSigners,\n SolanaRpcApi,\n SolanaRpcSubscriptionsApi,\n TransactionMessage,\n TransactionMessageWithFeePayer,\n TransactionSigner,\n} from '@solana/kit';\n\nimport fs from 'fs';\nimport os from 'os';\nimport path from 'path';\n\nimport { randomBytes } from 'crypto';\nimport {\n AssetType,\n findPoolAddress,\n generateCommitment,\n getDepositInstructionAsync,\n getInitializePoolInstructionAsync,\n getTransferInstructionAsync,\n getUpdateRootInstruction,\n MerkleTree,\n ProofData,\n} from '../src';\nimport { WRAPPED_SOL_MINT_TOKEN_PROGRAM } from './_constants';\n\nexport type Client = {\n rpc: Rpc<SolanaRpcApi>;\n rpcSubscriptions: RpcSubscriptions<SolanaRpcSubscriptionsApi>;\n};\n\nexport const createDefaultSolanaClient = (): Client => {\n const rpc = createSolanaRpc('http://127.0.0.1:8899');\n const rpcSubscriptions = createSolanaRpcSubscriptions('ws://127.0.0.1:8900');\n return { rpc, rpcSubscriptions };\n};\n\nexport const createDevnetClient = (): Client => {\n const rpc = createSolanaRpc('https://api.devnet.solana.com');\n const rpcSubscriptions = createSolanaRpcSubscriptions(\n 'wss://api.devnet.solana.com/'\n );\n\n return { rpc, rpcSubscriptions };\n};\n\nexport const generateKeyPairSignerWithSol = async (\n client: Client,\n putativeLamports: bigint = 1_000_000_000n\n) => {\n const signer = await generateKeyPairSigner();\n await airdropFactory(client)({\n recipientAddress: signer.address,\n lamports: lamports(putativeLamports),\n commitment: 'confirmed',\n });\n return signer;\n};\n\nexport const airdropSolToAddress = async (\n client: Client,\n receiver: Address, // 5 sol\n putativeLamports: bigint = 5_000_000_000n // 5 sol\n) => {\n await airdropFactory(client)({\n recipientAddress: receiver,\n lamports: lamports(putativeLamports),\n commitment: 'confirmed',\n });\n};\n\nexport async function loadKeypairFromFile(\n filePath: string\n): Promise<KeyPairSigner<string>> {\n // This is here so you can also load the default keypair from the file system.\n const resolvedPath = path.resolve(\n filePath.startsWith('~') ? filePath.replace('~', os.homedir()) : filePath\n );\n const loadedKeyBytes = Uint8Array.from(\n JSON.parse(fs.readFileSync(resolvedPath, 'utf8'))\n );\n // Here you can also set the second parameter to true in case you need to extract your private key.\n const keypairSigner = await createKeyPairSignerFromBytes(loadedKeyBytes);\n return keypairSigner;\n}\n\nexport const createDefaultTransaction = async (\n client: Client,\n feePayer: TransactionSigner\n) => {\n const { value: latestBlockhash } = await client.rpc\n .getLatestBlockhash()\n .send();\n return pipe(\n createTransactionMessage({ version: 0 }),\n (tx) => setTransactionMessageFeePayerSigner(feePayer, tx),\n (tx) => setTransactionMessageLifetimeUsingBlockhash(latestBlockhash, tx)\n );\n};\n\nexport const signAndSendTransaction = async (\n client: Client,\n transactionMessage: TransactionMessage & TransactionMessageWithFeePayer,\n // & TransactionMessageWithLifetime,\n commitment: Commitment = 'finalized'\n) => {\n const signedTransaction =\n await signTransactionMessageWithSigners(transactionMessage);\n assertIsSendableTransaction(signedTransaction);\n\n const signature = getSignatureFromTransaction(signedTransaction);\n\n assertIsTransactionWithBlockhashLifetime(signedTransaction);\n await sendAndConfirmTransactionFactory(client)(signedTransaction, {\n commitment,\n skipPreflight: true,\n });\n\n console.log('[DEBUG;] le signature ->', signature, '\\n'); // ! debug\n return signature;\n};\n\nexport const getBalance = async (client: Client, address: Address) =>\n (await client.rpc.getBalance(address, { commitment: 'confirmed' }).send())\n .value;\n\nexport async function loadDefaultKeypair(): Promise<KeyPairSigner<string>> {\n return await loadKeypairFromFile('~/.config/solana/id.json');\n}\n\nexport async function loadReceiverKeypair(): Promise<KeyPairSigner<string>> {\n return await loadKeypairFromFile('~/.config/solana/id-new.json');\n}\n\nexport async function loadRelayerKeypair(): Promise<KeyPairSigner<string>> {\n return await loadKeypairFromFile('~/.config/solana/relayer.json');\n}\n\nexport const getTokenBalance = async (client: Client, tokenAccount: Address) =>\n (\n await client.rpc\n .getTokenAccountBalance(tokenAccount, { commitment: 'confirmed' })\n .send()\n ).value;\n\n// -------------------------------------------------- instructions\n\nexport const createSolPoolForAuthority = async (\n client: Client\n // merkleTree?: Address\n): Promise<{ authority: Address }> => {\n const [authority] = await Promise.all([loadDefaultKeypair()]);\n\n const createIx = await getInitializePoolInstructionAsync({\n authority,\n mint: WRAPPED_SOL_MINT_TOKEN_PROGRAM,\n assetType: AssetType.Sol,\n });\n\n await pipe(\n await createDefaultTransaction(client, authority),\n (tx) => appendTransactionMessageInstruction(createIx, tx),\n (tx) => signAndSendTransaction(client, tx)\n );\n\n return { authority: authority.address };\n};\n\nexport const depositSolPoolForAuthority = async (\n client: Client,\n amount: bigint,\n assetType: AssetType,\n merkleTree: MerkleTree\n): Promise<{\n depositor: Address;\n commitment: Uint8Array;\n secret: Uint8Array;\n nullifier: Uint8Array;\n}> => {\n const [authority] = await Promise.all([loadDefaultKeypair()]);\n\n // find pool address\n const [pool] = await findPoolAddress({\n mint: WRAPPED_SOL_MINT_TOKEN_PROGRAM,\n assetType,\n });\n\n // generate commitment\n const secret = randomBytes(32);\n const nullifier = randomBytes(32);\n const commitment = await generateCommitment(secret, nullifier, amount, pool);\n\n // Insert commitment into merkle tree and compute new root\n merkleTree.insert(commitment);\n const newRoot = merkleTree.root();\n\n // ! NOTE, DURING INITIALIZATION,\n const depositIx = await getDepositInstructionAsync({\n depositor: authority,\n pool,\n amount,\n commitment,\n newRoot,\n mint: WRAPPED_SOL_MINT_TOKEN_PROGRAM,\n });\n\n await pipe(\n await createDefaultTransaction(client, authority),\n (tx) => appendTransactionMessageInstruction(depositIx, tx),\n (tx) => signAndSendTransaction(client, tx)\n );\n\n return {\n depositor: authority.address,\n commitment,\n secret,\n nullifier,\n };\n};\n\nexport const transferForAuthority = async (\n client: Client,\n ixArgs: {\n relayerFee: number;\n recipientAmount: bigint;\n nullifierHash: Uint8Array;\n proofData: ProofData;\n publicInputs: Uint8Array[];\n mint: Address;\n assetType: AssetType;\n }\n): Promise<{\n relayer: Address;\n}> => {\n const [relayer, recipient] = await Promise.all([\n loadRelayerKeypair(),\n loadReceiverKeypair(),\n ]);\n\n // airdrop relayer\n await airdropSolToAddress(client, relayer.address);\n\n const {\n relayerFee,\n recipientAmount,\n nullifierHash,\n assetType,\n mint,\n publicInputs,\n proofData: { proofA, proofB, proofC },\n } = ixArgs;\n\n // find pool address\n const [pool] = await findPoolAddress({\n mint,\n assetType,\n });\n\n // TEMPORARY: The autogenerated client hasn't been regenerated yet\n // The Rust program expects: relayer_fee (6th), recipient_amount (7th)\n // But the old client has: amount (6th), fee (7th)\n // So we swap them here until the client is regenerated\n const transferIx = await getTransferInstructionAsync({\n relayer,\n pool,\n recipient: recipient.address,\n proofA,\n proofB,\n proofC,\n nullifierHash,\n publicInputs,\n recipientAmount: recipientAmount,\n relayerFee: relayerFee,\n mint,\n });\n\n await pipe(\n await createDefaultTransaction(client, relayer),\n (tx) => appendTransactionMessageInstruction(transferIx, tx),\n (tx) =>\n appendTransactionMessageInstructions(\n [getSetComputeUnitLimitInstruction({ units: 1_400_000 })],\n tx\n ),\n (tx) => signAndSendTransaction(client, tx)\n );\n\n // todo: return the address of the pool\n // todo: what to return\n return { relayer: relayer.address };\n};\n\nexport const updatePoolForRelayer = async (\n client: Client,\n root: Uint8Array,\n assetType: AssetType\n): Promise<{\n relayer: Address;\n}> => {\n const [relayer] = await Promise.all([loadDefaultKeypair()]);\n\n // find pool address\n const [pool] = await findPoolAddress({\n mint: WRAPPED_SOL_MINT_TOKEN_PROGRAM,\n assetType,\n });\n\n const updateRootIx = await getUpdateRootInstruction({\n pool,\n root,\n });\n\n await pipe(\n await createDefaultTransaction(client, relayer),\n (tx) => appendTransactionMessageInstruction(updateRootIx, tx),\n (tx) => signAndSendTransaction(client, tx)\n );\n\n return {\n relayer: relayer.address,\n };\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/generated/instructions/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,cAAc,WAAW,CAAC;AAC1B,cAAc,kBAAkB,CAAC;AACjC,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/generated/instructions/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,cAAc,WAAW,CAAC;AAC1B,cAAc,kBAAkB,CAAC;AACjC,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code was AUTOGENERATED using the Codama library.
|
|
3
|
+
* Please DO NOT EDIT THIS FILE, instead use visitors
|
|
4
|
+
* to add features, then rerun Codama to update it.
|
|
5
|
+
*
|
|
6
|
+
* @see https://github.com/codama-idl/codama
|
|
7
|
+
*/
|
|
8
|
+
import { type AccountMeta, type AccountSignerMeta, type Address, type FixedSizeCodec, type FixedSizeDecoder, type FixedSizeEncoder, type Instruction, type InstructionWithAccounts, type InstructionWithData, type ReadonlyUint8Array, type TransactionSigner, type WritableAccount, type WritableSignerAccount } from '@solana/kit';
|
|
9
|
+
import { MIXOOR_PROGRAM_ADDRESS } from '../programs';
|
|
10
|
+
export declare const UPDATE_ROOT_DISCRIMINATOR: Uint8Array<ArrayBuffer>;
|
|
11
|
+
export declare function getUpdateRootDiscriminatorBytes(): ReadonlyUint8Array;
|
|
12
|
+
export type UpdateRootInstruction<TProgram extends string = typeof MIXOOR_PROGRAM_ADDRESS, TAccountRelayer extends string | AccountMeta<string> = 're1R63DiMLtDyHMAS1ohszqfFTHcF9Q3uEXSYdHzHWU', TAccountPool extends string | AccountMeta<string> = string, TRemainingAccounts extends readonly AccountMeta<string>[] = []> = Instruction<TProgram> & InstructionWithData<ReadonlyUint8Array> & InstructionWithAccounts<[
|
|
13
|
+
TAccountRelayer extends string ? WritableSignerAccount<TAccountRelayer> & AccountSignerMeta<TAccountRelayer> : TAccountRelayer,
|
|
14
|
+
TAccountPool extends string ? WritableAccount<TAccountPool> : TAccountPool,
|
|
15
|
+
...TRemainingAccounts
|
|
16
|
+
]>;
|
|
17
|
+
export type UpdateRootInstructionData = {
|
|
18
|
+
discriminator: ReadonlyUint8Array;
|
|
19
|
+
root: ReadonlyUint8Array;
|
|
20
|
+
};
|
|
21
|
+
export type UpdateRootInstructionDataArgs = {
|
|
22
|
+
root: ReadonlyUint8Array;
|
|
23
|
+
};
|
|
24
|
+
export declare function getUpdateRootInstructionDataEncoder(): FixedSizeEncoder<UpdateRootInstructionDataArgs>;
|
|
25
|
+
export declare function getUpdateRootInstructionDataDecoder(): FixedSizeDecoder<UpdateRootInstructionData>;
|
|
26
|
+
export declare function getUpdateRootInstructionDataCodec(): FixedSizeCodec<UpdateRootInstructionDataArgs, UpdateRootInstructionData>;
|
|
27
|
+
export type UpdateRootInput<TAccountRelayer extends string = string, TAccountPool extends string = string> = {
|
|
28
|
+
relayer?: TransactionSigner<TAccountRelayer>;
|
|
29
|
+
pool: Address<TAccountPool>;
|
|
30
|
+
root: UpdateRootInstructionDataArgs['root'];
|
|
31
|
+
};
|
|
32
|
+
export declare function getUpdateRootInstruction<TAccountRelayer extends string, TAccountPool extends string, TProgramAddress extends Address = typeof MIXOOR_PROGRAM_ADDRESS>(input: UpdateRootInput<TAccountRelayer, TAccountPool>, config?: {
|
|
33
|
+
programAddress?: TProgramAddress;
|
|
34
|
+
}): UpdateRootInstruction<TProgramAddress, TAccountRelayer, TAccountPool>;
|
|
35
|
+
export type ParsedUpdateRootInstruction<TProgram extends string = typeof MIXOOR_PROGRAM_ADDRESS, TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[]> = {
|
|
36
|
+
programAddress: Address<TProgram>;
|
|
37
|
+
accounts: {
|
|
38
|
+
relayer: TAccountMetas[0];
|
|
39
|
+
pool: TAccountMetas[1];
|
|
40
|
+
};
|
|
41
|
+
data: UpdateRootInstructionData;
|
|
42
|
+
};
|
|
43
|
+
export declare function parseUpdateRootInstruction<TProgram extends string, TAccountMetas extends readonly AccountMeta[]>(instruction: Instruction<TProgram> & InstructionWithAccounts<TAccountMetas> & InstructionWithData<ReadonlyUint8Array>): ParsedUpdateRootInstruction<TProgram, TAccountMetas>;
|
|
44
|
+
//# sourceMappingURL=updateRoot.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"updateRoot.d.ts","sourceRoot":"","sources":["../../../../../src/generated/instructions/updateRoot.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EASL,KAAK,WAAW,EAChB,KAAK,iBAAiB,EACtB,KAAK,OAAO,EACZ,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACrB,KAAK,WAAW,EAChB,KAAK,uBAAuB,EAC5B,KAAK,mBAAmB,EACxB,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACtB,KAAK,eAAe,EACpB,KAAK,qBAAqB,EAC3B,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAGrD,eAAO,MAAM,yBAAyB,yBAEpC,CAAC;AAEH,wBAAgB,+BAA+B,uBAE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7C,CAAC;AAEF,wBAAgB,wBAAwB,CACtC,eAAe,SAAS,MAAM,EAC9B,YAAY,SAAS,MAAM,EAC3B,eAAe,SAAS,OAAO,GAAG,OAAO,sBAAsB,EAE/D,KAAK,EAAE,eAAe,CAAC,eAAe,EAAE,YAAY,CAAC,EACrD,MAAM,CAAC,EAAE;IAAE,cAAc,CAAC,EAAE,eAAe,CAAA;CAAE,GAC5C,qBAAqB,CAAC,eAAe,EAAE,eAAe,EAAE,YAAY,CAAC,CA+BvE;AAED,MAAM,MAAM,2BAA2B,CACrC,QAAQ,SAAS,MAAM,GAAG,OAAO,sBAAsB,EACvD,aAAa,SAAS,SAAS,WAAW,EAAE,GAAG,SAAS,WAAW,EAAE,IACnE;IACF,cAAc,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;IAClC,QAAQ,EAAE;QACR,OAAO,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC;QAC1B,IAAI,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC;KACxB,CAAC;IACF,IAAI,EAAE,yBAAyB,CAAC;CACjC,CAAC;AAEF,wBAAgB,0BAA0B,CACxC,QAAQ,SAAS,MAAM,EACvB,aAAa,SAAS,SAAS,WAAW,EAAE,EAE5C,WAAW,EAAE,WAAW,CAAC,QAAQ,CAAC,GAChC,uBAAuB,CAAC,aAAa,CAAC,GACtC,mBAAmB,CAAC,kBAAkB,CAAC,GACxC,2BAA2B,CAAC,QAAQ,EAAE,aAAa,CAAC,CAgBtD"}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* @see https://github.com/codama-idl/codama
|
|
7
7
|
*/
|
|
8
8
|
import { type Address, type ReadonlyUint8Array } from '@solana/kit';
|
|
9
|
-
import { type ParsedDepositInstruction, type ParsedInitializePoolInstruction, type ParsedTransferInstruction, type ParsedWithdrawInstruction } from '../instructions';
|
|
9
|
+
import { type ParsedDepositInstruction, type ParsedInitializePoolInstruction, type ParsedTransferInstruction, type ParsedUpdateRootInstruction, type ParsedWithdrawInstruction } from '../instructions';
|
|
10
10
|
export declare const MIXOOR_PROGRAM_ADDRESS: Address<"mixEcfx7w47hvRwb9Nj7UeSQkCz6vZMbRHixMyYMLMb">;
|
|
11
11
|
export declare enum MixoorAccount {
|
|
12
12
|
NullifierAccount = 0,
|
|
@@ -20,7 +20,8 @@ export declare enum MixoorInstruction {
|
|
|
20
20
|
Deposit = 0,
|
|
21
21
|
InitializePool = 1,
|
|
22
22
|
Transfer = 2,
|
|
23
|
-
|
|
23
|
+
UpdateRoot = 3,
|
|
24
|
+
Withdraw = 4
|
|
24
25
|
}
|
|
25
26
|
export declare function identifyMixoorInstruction(instruction: {
|
|
26
27
|
data: ReadonlyUint8Array;
|
|
@@ -32,6 +33,8 @@ export type ParsedMixoorInstruction<TProgram extends string = 'mixEcfx7w47hvRwb9
|
|
|
32
33
|
} & ParsedInitializePoolInstruction<TProgram>) | ({
|
|
33
34
|
instructionType: MixoorInstruction.Transfer;
|
|
34
35
|
} & ParsedTransferInstruction<TProgram>) | ({
|
|
36
|
+
instructionType: MixoorInstruction.UpdateRoot;
|
|
37
|
+
} & ParsedUpdateRootInstruction<TProgram>) | ({
|
|
35
38
|
instructionType: MixoorInstruction.Withdraw;
|
|
36
39
|
} & ParsedWithdrawInstruction<TProgram>);
|
|
37
40
|
//# sourceMappingURL=mixoor.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mixoor.d.ts","sourceRoot":"","sources":["../../../../../src/generated/programs/mixoor.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAIL,KAAK,OAAO,EACZ,KAAK,kBAAkB,EACxB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,KAAK,wBAAwB,EAC7B,KAAK,+BAA+B,EACpC,KAAK,yBAAyB,EAC9B,KAAK,yBAAyB,EAC/B,MAAM,iBAAiB,CAAC;AAEzB,eAAO,MAAM,sBAAsB,EACgB,OAAO,CAAC,6CAA6C,CAAC,CAAC;AAE1G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AAuB,CACjC,QAAQ,SAAS,MAAM,GAAG,6CAA6C,IAErE,CAAC;IACC,eAAe,EAAE,iBAAiB,CAAC,OAAO,CAAC;CAC5C,GAAG,wBAAwB,CAAC,QAAQ,CAAC,CAAC,GACvC,CAAC;IACC,eAAe,EAAE,iBAAiB,CAAC,cAAc,CAAC;CACnD,GAAG,+BAA+B,CAAC,QAAQ,CAAC,CAAC,GAC9C,CAAC;IACC,eAAe,EAAE,iBAAiB,CAAC,QAAQ,CAAC;CAC7C,GAAG,yBAAyB,CAAC,QAAQ,CAAC,CAAC,GACxC,CAAC;IACC,eAAe,EAAE,iBAAiB,CAAC,UAAU,CAAC;CAC/C,GAAG,2BAA2B,CAAC,QAAQ,CAAC,CAAC,GAC1C,CAAC;IACC,eAAe,EAAE,iBAAiB,CAAC,QAAQ,CAAC;CAC7C,GAAG,yBAAyB,CAAC,QAAQ,CAAC,CAAC,CAAC"}
|
|
@@ -47,4 +47,7 @@ export declare const transferForAuthority: (client: Client, ixArgs: {
|
|
|
47
47
|
}) => Promise<{
|
|
48
48
|
relayer: Address;
|
|
49
49
|
}>;
|
|
50
|
+
export declare const updatePoolForRelayer: (client: Client, root: Uint8Array, assetType: AssetType) => Promise<{
|
|
51
|
+
relayer: Address;
|
|
52
|
+
}>;
|
|
50
53
|
//# sourceMappingURL=_setup.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_setup.d.ts","sourceRoot":"","sources":["../../../test/_setup.ts"],"names":[],"mappings":"AACA,OAAO,EACL,OAAO,EAMP,UAAU,EAOV,aAAa,EAGb,GAAG,EACH,gBAAgB,EAKhB,YAAY,EACZ,yBAAyB,EACzB,kBAAkB,EAClB,8BAA8B,EAC9B,iBAAiB,EAClB,MAAM,aAAa,CAAC;AAOrB,OAAO,EACL,SAAS,
|
|
1
|
+
{"version":3,"file":"_setup.d.ts","sourceRoot":"","sources":["../../../test/_setup.ts"],"names":[],"mappings":"AACA,OAAO,EACL,OAAO,EAMP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