@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.
package/dist/src/index.js CHANGED
@@ -402,6 +402,7 @@ var MIXOOR_ERROR__POSEIDON_HASH_ERROR = 6010;
402
402
  var MIXOOR_ERROR__MERKLE_TREE_FULL = 6011;
403
403
  var MIXOOR_ERROR__INVALID_MERKLE_PROOF = 6012;
404
404
  var MIXOOR_ERROR__PUBLIC_INPUT_MISMATCH = 6013;
405
+ var MIXOOR_ERROR__INVALID_MINT = 6014;
405
406
  var mixoorErrorMessages;
406
407
  if (process.env.NODE_ENV !== "production") {
407
408
  mixoorErrorMessages = {
@@ -411,6 +412,7 @@ if (process.env.NODE_ENV !== "production") {
411
412
  [MIXOOR_ERROR__INVALID_MERKLE_PROOF]: `Invalid merkle proof`,
412
413
  [MIXOOR_ERROR__INVALID_MERKLE_TREE]: `Invalid merkle tree structure or out of bounds access`,
413
414
  [MIXOOR_ERROR__INVALID_MERKLE_TREE_ADDRESS]: `Invalid merkle tree address`,
415
+ [MIXOOR_ERROR__INVALID_MINT]: `Invalid mint provided to instruction`,
414
416
  [MIXOOR_ERROR__INVALID_PROOF]: `Invalid proof`,
415
417
  [MIXOOR_ERROR__INVALID_PUBLIC_INPUTS]: `Invalid number of public inputs`,
416
418
  [MIXOOR_ERROR__MERKLE_TREE_FULL]: `Merkle tree is full`,
@@ -1196,7 +1198,10 @@ async function getWithdrawInstructionAsync(input, config) {
1196
1198
  pool: { value: input.pool ?? null, isWritable: true },
1197
1199
  vault: { value: input.vault ?? null, isWritable: true },
1198
1200
  vaultAta: { value: input.vaultAta ?? null, isWritable: false },
1199
- authorityAta: { value: input.authorityAta ?? null, isWritable: false },
1201
+ authorityTokenAccount: {
1202
+ value: input.authorityTokenAccount ?? null,
1203
+ isWritable: true
1204
+ },
1200
1205
  mint: { value: input.mint ?? null, isWritable: true },
1201
1206
  systemProgram: { value: input.systemProgram ?? null, isWritable: false },
1202
1207
  tokenProgram: { value: input.tokenProgram ?? null, isWritable: false },
@@ -1232,16 +1237,6 @@ async function getWithdrawInstructionAsync(input, config) {
1232
1237
  ]
1233
1238
  });
1234
1239
  }
1235
- if (!accounts.authorityAta.value) {
1236
- accounts.authorityAta.value = await kit.getProgramDerivedAddress({
1237
- programAddress: "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL",
1238
- seeds: [
1239
- kit.getAddressEncoder().encode(expectAddress(accounts.authority.value)),
1240
- kit.getAddressEncoder().encode(expectAddress(accounts.tokenProgram.value)),
1241
- kit.getAddressEncoder().encode(expectAddress(accounts.mint.value))
1242
- ]
1243
- });
1244
- }
1245
1240
  if (!accounts.systemProgram.value) {
1246
1241
  accounts.systemProgram.value = "11111111111111111111111111111111";
1247
1242
  }
@@ -1255,7 +1250,7 @@ async function getWithdrawInstructionAsync(input, config) {
1255
1250
  getAccountMeta(accounts.pool),
1256
1251
  getAccountMeta(accounts.vault),
1257
1252
  getAccountMeta(accounts.vaultAta),
1258
- getAccountMeta(accounts.authorityAta),
1253
+ getAccountMeta(accounts.authorityTokenAccount),
1259
1254
  getAccountMeta(accounts.mint),
1260
1255
  getAccountMeta(accounts.systemProgram),
1261
1256
  getAccountMeta(accounts.tokenProgram),
@@ -1274,7 +1269,10 @@ function getWithdrawInstruction(input, config) {
1274
1269
  pool: { value: input.pool ?? null, isWritable: true },
1275
1270
  vault: { value: input.vault ?? null, isWritable: true },
1276
1271
  vaultAta: { value: input.vaultAta ?? null, isWritable: false },
1277
- authorityAta: { value: input.authorityAta ?? null, isWritable: false },
1272
+ authorityTokenAccount: {
1273
+ value: input.authorityTokenAccount ?? null,
1274
+ isWritable: true
1275
+ },
1278
1276
  mint: { value: input.mint ?? null, isWritable: true },
1279
1277
  systemProgram: { value: input.systemProgram ?? null, isWritable: false },
1280
1278
  tokenProgram: { value: input.tokenProgram ?? null, isWritable: false },
@@ -1304,7 +1302,7 @@ function getWithdrawInstruction(input, config) {
1304
1302
  getAccountMeta(accounts.pool),
1305
1303
  getAccountMeta(accounts.vault),
1306
1304
  getAccountMeta(accounts.vaultAta),
1307
- getAccountMeta(accounts.authorityAta),
1305
+ getAccountMeta(accounts.authorityTokenAccount),
1308
1306
  getAccountMeta(accounts.mint),
1309
1307
  getAccountMeta(accounts.systemProgram),
1310
1308
  getAccountMeta(accounts.tokenProgram),
@@ -1326,6 +1324,10 @@ function parseWithdrawInstruction(instruction) {
1326
1324
  accountIndex += 1;
1327
1325
  return accountMeta;
1328
1326
  };
1327
+ const getNextOptionalAccount = () => {
1328
+ const accountMeta = getNextAccount();
1329
+ return accountMeta.address === MIXOOR_PROGRAM_ADDRESS ? void 0 : accountMeta;
1330
+ };
1329
1331
  return {
1330
1332
  programAddress: instruction.programAddress,
1331
1333
  accounts: {
@@ -1333,7 +1335,7 @@ function parseWithdrawInstruction(instruction) {
1333
1335
  pool: getNextAccount(),
1334
1336
  vault: getNextAccount(),
1335
1337
  vaultAta: getNextAccount(),
1336
- authorityAta: getNextAccount(),
1338
+ authorityTokenAccount: getNextOptionalAccount(),
1337
1339
  mint: getNextAccount(),
1338
1340
  systemProgram: getNextAccount(),
1339
1341
  tokenProgram: getNextAccount(),
@@ -1662,6 +1664,7 @@ exports.MIXOOR_ERROR__INVALID_ASSET_TYPE = MIXOOR_ERROR__INVALID_ASSET_TYPE;
1662
1664
  exports.MIXOOR_ERROR__INVALID_MERKLE_PROOF = MIXOOR_ERROR__INVALID_MERKLE_PROOF;
1663
1665
  exports.MIXOOR_ERROR__INVALID_MERKLE_TREE = MIXOOR_ERROR__INVALID_MERKLE_TREE;
1664
1666
  exports.MIXOOR_ERROR__INVALID_MERKLE_TREE_ADDRESS = MIXOOR_ERROR__INVALID_MERKLE_TREE_ADDRESS;
1667
+ exports.MIXOOR_ERROR__INVALID_MINT = MIXOOR_ERROR__INVALID_MINT;
1665
1668
  exports.MIXOOR_ERROR__INVALID_PROOF = MIXOOR_ERROR__INVALID_PROOF;
1666
1669
  exports.MIXOOR_ERROR__INVALID_PUBLIC_INPUTS = MIXOOR_ERROR__INVALID_PUBLIC_INPUTS;
1667
1670
  exports.MIXOOR_ERROR__MERKLE_TREE_FULL = MIXOOR_ERROR__MERKLE_TREE_FULL;