@smithii_io/mixoor 0.0.17 → 0.0.18

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.
@@ -378,6 +378,7 @@ var MIXOOR_ERROR__POSEIDON_HASH_ERROR = 6010;
378
378
  var MIXOOR_ERROR__MERKLE_TREE_FULL = 6011;
379
379
  var MIXOOR_ERROR__INVALID_MERKLE_PROOF = 6012;
380
380
  var MIXOOR_ERROR__PUBLIC_INPUT_MISMATCH = 6013;
381
+ var MIXOOR_ERROR__INVALID_MINT = 6014;
381
382
  var mixoorErrorMessages;
382
383
  if (process.env.NODE_ENV !== "production") {
383
384
  mixoorErrorMessages = {
@@ -387,6 +388,7 @@ if (process.env.NODE_ENV !== "production") {
387
388
  [MIXOOR_ERROR__INVALID_MERKLE_PROOF]: `Invalid merkle proof`,
388
389
  [MIXOOR_ERROR__INVALID_MERKLE_TREE]: `Invalid merkle tree structure or out of bounds access`,
389
390
  [MIXOOR_ERROR__INVALID_MERKLE_TREE_ADDRESS]: `Invalid merkle tree address`,
391
+ [MIXOOR_ERROR__INVALID_MINT]: `Invalid mint provided to instruction`,
390
392
  [MIXOOR_ERROR__INVALID_PROOF]: `Invalid proof`,
391
393
  [MIXOOR_ERROR__INVALID_PUBLIC_INPUTS]: `Invalid number of public inputs`,
392
394
  [MIXOOR_ERROR__MERKLE_TREE_FULL]: `Merkle tree is full`,
@@ -1172,7 +1174,10 @@ async function getWithdrawInstructionAsync(input, config) {
1172
1174
  pool: { value: input.pool ?? null, isWritable: true },
1173
1175
  vault: { value: input.vault ?? null, isWritable: true },
1174
1176
  vaultAta: { value: input.vaultAta ?? null, isWritable: false },
1175
- authorityAta: { value: input.authorityAta ?? null, isWritable: false },
1177
+ authorityTokenAccount: {
1178
+ value: input.authorityTokenAccount ?? null,
1179
+ isWritable: true
1180
+ },
1176
1181
  mint: { value: input.mint ?? null, isWritable: true },
1177
1182
  systemProgram: { value: input.systemProgram ?? null, isWritable: false },
1178
1183
  tokenProgram: { value: input.tokenProgram ?? null, isWritable: false },
@@ -1208,16 +1213,6 @@ async function getWithdrawInstructionAsync(input, config) {
1208
1213
  ]
1209
1214
  });
1210
1215
  }
1211
- if (!accounts.authorityAta.value) {
1212
- accounts.authorityAta.value = await getProgramDerivedAddress({
1213
- programAddress: "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL",
1214
- seeds: [
1215
- getAddressEncoder().encode(expectAddress(accounts.authority.value)),
1216
- getAddressEncoder().encode(expectAddress(accounts.tokenProgram.value)),
1217
- getAddressEncoder().encode(expectAddress(accounts.mint.value))
1218
- ]
1219
- });
1220
- }
1221
1216
  if (!accounts.systemProgram.value) {
1222
1217
  accounts.systemProgram.value = "11111111111111111111111111111111";
1223
1218
  }
@@ -1231,7 +1226,7 @@ async function getWithdrawInstructionAsync(input, config) {
1231
1226
  getAccountMeta(accounts.pool),
1232
1227
  getAccountMeta(accounts.vault),
1233
1228
  getAccountMeta(accounts.vaultAta),
1234
- getAccountMeta(accounts.authorityAta),
1229
+ getAccountMeta(accounts.authorityTokenAccount),
1235
1230
  getAccountMeta(accounts.mint),
1236
1231
  getAccountMeta(accounts.systemProgram),
1237
1232
  getAccountMeta(accounts.tokenProgram),
@@ -1250,7 +1245,10 @@ function getWithdrawInstruction(input, config) {
1250
1245
  pool: { value: input.pool ?? null, isWritable: true },
1251
1246
  vault: { value: input.vault ?? null, isWritable: true },
1252
1247
  vaultAta: { value: input.vaultAta ?? null, isWritable: false },
1253
- authorityAta: { value: input.authorityAta ?? null, isWritable: false },
1248
+ authorityTokenAccount: {
1249
+ value: input.authorityTokenAccount ?? null,
1250
+ isWritable: true
1251
+ },
1254
1252
  mint: { value: input.mint ?? null, isWritable: true },
1255
1253
  systemProgram: { value: input.systemProgram ?? null, isWritable: false },
1256
1254
  tokenProgram: { value: input.tokenProgram ?? null, isWritable: false },
@@ -1280,7 +1278,7 @@ function getWithdrawInstruction(input, config) {
1280
1278
  getAccountMeta(accounts.pool),
1281
1279
  getAccountMeta(accounts.vault),
1282
1280
  getAccountMeta(accounts.vaultAta),
1283
- getAccountMeta(accounts.authorityAta),
1281
+ getAccountMeta(accounts.authorityTokenAccount),
1284
1282
  getAccountMeta(accounts.mint),
1285
1283
  getAccountMeta(accounts.systemProgram),
1286
1284
  getAccountMeta(accounts.tokenProgram),
@@ -1302,6 +1300,10 @@ function parseWithdrawInstruction(instruction) {
1302
1300
  accountIndex += 1;
1303
1301
  return accountMeta;
1304
1302
  };
1303
+ const getNextOptionalAccount = () => {
1304
+ const accountMeta = getNextAccount();
1305
+ return accountMeta.address === MIXOOR_PROGRAM_ADDRESS ? void 0 : accountMeta;
1306
+ };
1305
1307
  return {
1306
1308
  programAddress: instruction.programAddress,
1307
1309
  accounts: {
@@ -1309,7 +1311,7 @@ function parseWithdrawInstruction(instruction) {
1309
1311
  pool: getNextAccount(),
1310
1312
  vault: getNextAccount(),
1311
1313
  vaultAta: getNextAccount(),
1312
- authorityAta: getNextAccount(),
1314
+ authorityTokenAccount: getNextOptionalAccount(),
1313
1315
  mint: getNextAccount(),
1314
1316
  systemProgram: getNextAccount(),
1315
1317
  tokenProgram: getNextAccount(),
@@ -1629,6 +1631,6 @@ async function findNullifierAddress(seeds, config = {}) {
1629
1631
  });
1630
1632
  }
1631
1633
 
1632
- export { AssetType, DEPOSIT_DISCRIMINATOR, INITIALIZE_POOL_DISCRIMINATOR, MIXOOR_ERROR__INSUFFICIENT_FUNDS, MIXOOR_ERROR__INVALID_AMOUNT, MIXOOR_ERROR__INVALID_ASSET_TYPE, MIXOOR_ERROR__INVALID_MERKLE_PROOF, MIXOOR_ERROR__INVALID_MERKLE_TREE, MIXOOR_ERROR__INVALID_MERKLE_TREE_ADDRESS, MIXOOR_ERROR__INVALID_PROOF, MIXOOR_ERROR__INVALID_PUBLIC_INPUTS, MIXOOR_ERROR__MERKLE_TREE_FULL, MIXOOR_ERROR__MISSING_TOKEN_ACCOUNT, MIXOOR_ERROR__OVERFLOW, MIXOOR_ERROR__POSEIDON_HASH_ERROR, MIXOOR_ERROR__PUBLIC_INPUT_MISMATCH, MIXOOR_ERROR__UNKNOWN_ROOT, MIXOOR_PROGRAM_ADDRESS, MerkleTree, MixoorAccount, MixoorInstruction, NULLIFIER_ACCOUNT_DISCRIMINATOR, POOL_DISCRIMINATOR, TRANSFER_DISCRIMINATOR, UPDATE_ROOT_DISCRIMINATOR, VAULT_DISCRIMINATOR, WITHDRAW_DISCRIMINATOR, decodeNullifierAccount, decodePool, decodeVault, extractMerkleRootFromAccount, fetchAllMaybeNullifierAccount, fetchAllMaybePool, fetchAllMaybeVault, fetchAllNullifierAccount, fetchAllPool, fetchAllVault, fetchMaybeNullifierAccount, fetchMaybePool, fetchMaybeVault, fetchNullifierAccount, fetchPool, fetchVault, findMerkleTreeAddress, findNullifierAddress, findPoolAddress, findVaultAddress, fromHex, generateCommitment, generateNullifier, generateProof, getAssetTypeCodec, getAssetTypeDecoder, getAssetTypeEncoder, getCommitmentInsertedCodec, getCommitmentInsertedDecoder, getCommitmentInsertedEncoder, getDepositDiscriminatorBytes, getDepositInstruction, getDepositInstructionAsync, getDepositInstructionDataCodec, getDepositInstructionDataDecoder, getDepositInstructionDataEncoder, getInitializePoolDiscriminatorBytes, getInitializePoolInstruction, getInitializePoolInstructionAsync, getInitializePoolInstructionDataCodec, getInitializePoolInstructionDataDecoder, getInitializePoolInstructionDataEncoder, getMixoorErrorMessage, getNullifierAccountCodec, getNullifierAccountDecoder, getNullifierAccountDiscriminatorBytes, getNullifierAccountEncoder, getNullifierAccountSize, getPoolCodec, getPoolDecoder, getPoolDiscriminatorBytes, getPoolEncoder, getPoolSize, getRootEntryCodec, getRootEntryDecoder, getRootEntryEncoder, getTransferDiscriminatorBytes, getTransferInstruction, getTransferInstructionAsync, getTransferInstructionDataCodec, getTransferInstructionDataDecoder, getTransferInstructionDataEncoder, getUpdateRootDiscriminatorBytes, getUpdateRootInstruction, getUpdateRootInstructionDataCodec, getUpdateRootInstructionDataDecoder, getUpdateRootInstructionDataEncoder, getVaultCodec, getVaultDecoder, getVaultDiscriminatorBytes, getVaultEncoder, getVaultSize, getWithdrawDiscriminatorBytes, getWithdrawInstruction, getWithdrawInstructionAsync, getWithdrawInstructionDataCodec, getWithdrawInstructionDataDecoder, getWithdrawInstructionDataEncoder, identifyMixoorAccount, identifyMixoorInstruction, isMixoorError, parseDepositInstruction, parseInitializePoolInstruction, parseTransferInstruction, parseUpdateRootInstruction, parseWithdrawInstruction, poseidonHash, randomBytes, toHex };
1634
+ export { AssetType, DEPOSIT_DISCRIMINATOR, INITIALIZE_POOL_DISCRIMINATOR, MIXOOR_ERROR__INSUFFICIENT_FUNDS, MIXOOR_ERROR__INVALID_AMOUNT, MIXOOR_ERROR__INVALID_ASSET_TYPE, MIXOOR_ERROR__INVALID_MERKLE_PROOF, MIXOOR_ERROR__INVALID_MERKLE_TREE, MIXOOR_ERROR__INVALID_MERKLE_TREE_ADDRESS, MIXOOR_ERROR__INVALID_MINT, MIXOOR_ERROR__INVALID_PROOF, MIXOOR_ERROR__INVALID_PUBLIC_INPUTS, MIXOOR_ERROR__MERKLE_TREE_FULL, MIXOOR_ERROR__MISSING_TOKEN_ACCOUNT, MIXOOR_ERROR__OVERFLOW, MIXOOR_ERROR__POSEIDON_HASH_ERROR, MIXOOR_ERROR__PUBLIC_INPUT_MISMATCH, MIXOOR_ERROR__UNKNOWN_ROOT, MIXOOR_PROGRAM_ADDRESS, MerkleTree, MixoorAccount, MixoorInstruction, NULLIFIER_ACCOUNT_DISCRIMINATOR, POOL_DISCRIMINATOR, TRANSFER_DISCRIMINATOR, UPDATE_ROOT_DISCRIMINATOR, VAULT_DISCRIMINATOR, WITHDRAW_DISCRIMINATOR, decodeNullifierAccount, decodePool, decodeVault, extractMerkleRootFromAccount, fetchAllMaybeNullifierAccount, fetchAllMaybePool, fetchAllMaybeVault, fetchAllNullifierAccount, fetchAllPool, fetchAllVault, fetchMaybeNullifierAccount, fetchMaybePool, fetchMaybeVault, fetchNullifierAccount, fetchPool, fetchVault, findMerkleTreeAddress, findNullifierAddress, findPoolAddress, findVaultAddress, fromHex, generateCommitment, generateNullifier, generateProof, getAssetTypeCodec, getAssetTypeDecoder, getAssetTypeEncoder, getCommitmentInsertedCodec, getCommitmentInsertedDecoder, getCommitmentInsertedEncoder, getDepositDiscriminatorBytes, getDepositInstruction, getDepositInstructionAsync, getDepositInstructionDataCodec, getDepositInstructionDataDecoder, getDepositInstructionDataEncoder, getInitializePoolDiscriminatorBytes, getInitializePoolInstruction, getInitializePoolInstructionAsync, getInitializePoolInstructionDataCodec, getInitializePoolInstructionDataDecoder, getInitializePoolInstructionDataEncoder, getMixoorErrorMessage, getNullifierAccountCodec, getNullifierAccountDecoder, getNullifierAccountDiscriminatorBytes, getNullifierAccountEncoder, getNullifierAccountSize, getPoolCodec, getPoolDecoder, getPoolDiscriminatorBytes, getPoolEncoder, getPoolSize, getRootEntryCodec, getRootEntryDecoder, getRootEntryEncoder, getTransferDiscriminatorBytes, getTransferInstruction, getTransferInstructionAsync, getTransferInstructionDataCodec, getTransferInstructionDataDecoder, getTransferInstructionDataEncoder, getUpdateRootDiscriminatorBytes, getUpdateRootInstruction, getUpdateRootInstructionDataCodec, getUpdateRootInstructionDataDecoder, getUpdateRootInstructionDataEncoder, getVaultCodec, getVaultDecoder, getVaultDiscriminatorBytes, getVaultEncoder, getVaultSize, getWithdrawDiscriminatorBytes, getWithdrawInstruction, getWithdrawInstructionAsync, getWithdrawInstructionDataCodec, getWithdrawInstructionDataDecoder, getWithdrawInstructionDataEncoder, identifyMixoorAccount, identifyMixoorInstruction, isMixoorError, parseDepositInstruction, parseInitializePoolInstruction, parseTransferInstruction, parseUpdateRootInstruction, parseWithdrawInstruction, poseidonHash, randomBytes, toHex };
1633
1635
  //# sourceMappingURL=index.mjs.map
1634
1636
  //# sourceMappingURL=index.mjs.map