@smithii_io/mixoor 0.0.16 → 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 +24 -41
- package/dist/src/index.js.map +1 -1
- package/dist/src/index.mjs +24 -42
- package/dist/src/index.mjs.map +1 -1
- package/dist/test/_setup.js +35 -20
- package/dist/test/_setup.js.map +1 -1
- package/dist/test/{transfer.test.js → _transferSol.test.js} +19 -15
- package/dist/test/_transferSol.test.js.map +1 -0
- package/dist/test/transferSpl.test.js +111 -0
- package/dist/test/transferSpl.test.js.map +1 -0
- package/dist/types/src/generated/errors/mixoor.d.ts +3 -1
- package/dist/types/src/generated/errors/mixoor.d.ts.map +1 -1
- package/dist/types/src/generated/instructions/transfer.d.ts.map +1 -1
- package/dist/types/src/generated/instructions/withdraw.d.ts +11 -11
- package/dist/types/src/generated/instructions/withdraw.d.ts.map +1 -1
- package/dist/types/test/_setup.d.ts +12 -4
- package/dist/types/test/_setup.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/test/transfer.test.js.map +0 -1
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`,
|
|
@@ -950,35 +952,15 @@ async function getTransferInstructionAsync(input, config) {
|
|
|
950
952
|
]
|
|
951
953
|
});
|
|
952
954
|
}
|
|
953
|
-
if (!accounts.tokenProgram.value) {
|
|
954
|
-
accounts.tokenProgram.value = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";
|
|
955
|
-
}
|
|
956
|
-
if (!accounts.recipientTokenAccount.value) {
|
|
957
|
-
accounts.recipientTokenAccount.value = await kit.getProgramDerivedAddress({
|
|
958
|
-
programAddress: "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL",
|
|
959
|
-
seeds: [
|
|
960
|
-
kit.getAddressEncoder().encode(expectAddress(accounts.recipient.value)),
|
|
961
|
-
kit.getAddressEncoder().encode(expectAddress(accounts.tokenProgram.value)),
|
|
962
|
-
kit.getAddressEncoder().encode(expectAddress(accounts.mint.value))
|
|
963
|
-
]
|
|
964
|
-
});
|
|
965
|
-
}
|
|
966
955
|
if (!accounts.feeCollector.value) {
|
|
967
956
|
accounts.feeCollector.value = "9qX97Bd8dvHAknHVjCxz4uEJcPSE3NGjjgniMVdDBu6d";
|
|
968
957
|
}
|
|
969
|
-
if (!accounts.feeCollectorTokenAccount.value) {
|
|
970
|
-
accounts.feeCollectorTokenAccount.value = await kit.getProgramDerivedAddress({
|
|
971
|
-
programAddress: "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL",
|
|
972
|
-
seeds: [
|
|
973
|
-
kit.getAddressEncoder().encode(expectAddress(accounts.feeCollector.value)),
|
|
974
|
-
kit.getAddressEncoder().encode(expectAddress(accounts.tokenProgram.value)),
|
|
975
|
-
kit.getAddressEncoder().encode(expectAddress(accounts.mint.value))
|
|
976
|
-
]
|
|
977
|
-
});
|
|
978
|
-
}
|
|
979
958
|
if (!accounts.systemProgram.value) {
|
|
980
959
|
accounts.systemProgram.value = "11111111111111111111111111111111";
|
|
981
960
|
}
|
|
961
|
+
if (!accounts.tokenProgram.value) {
|
|
962
|
+
accounts.tokenProgram.value = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";
|
|
963
|
+
}
|
|
982
964
|
if (!accounts.associatedTokenProgram.value) {
|
|
983
965
|
accounts.associatedTokenProgram.value = "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL";
|
|
984
966
|
}
|
|
@@ -1036,15 +1018,15 @@ function getTransferInstruction(input, config) {
|
|
|
1036
1018
|
};
|
|
1037
1019
|
const accounts = originalAccounts;
|
|
1038
1020
|
const args = { ...input };
|
|
1039
|
-
if (!accounts.tokenProgram.value) {
|
|
1040
|
-
accounts.tokenProgram.value = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";
|
|
1041
|
-
}
|
|
1042
1021
|
if (!accounts.feeCollector.value) {
|
|
1043
1022
|
accounts.feeCollector.value = "9qX97Bd8dvHAknHVjCxz4uEJcPSE3NGjjgniMVdDBu6d";
|
|
1044
1023
|
}
|
|
1045
1024
|
if (!accounts.systemProgram.value) {
|
|
1046
1025
|
accounts.systemProgram.value = "11111111111111111111111111111111";
|
|
1047
1026
|
}
|
|
1027
|
+
if (!accounts.tokenProgram.value) {
|
|
1028
|
+
accounts.tokenProgram.value = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";
|
|
1029
|
+
}
|
|
1048
1030
|
if (!accounts.associatedTokenProgram.value) {
|
|
1049
1031
|
accounts.associatedTokenProgram.value = "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL";
|
|
1050
1032
|
}
|
|
@@ -1216,7 +1198,10 @@ async function getWithdrawInstructionAsync(input, config) {
|
|
|
1216
1198
|
pool: { value: input.pool ?? null, isWritable: true },
|
|
1217
1199
|
vault: { value: input.vault ?? null, isWritable: true },
|
|
1218
1200
|
vaultAta: { value: input.vaultAta ?? null, isWritable: false },
|
|
1219
|
-
|
|
1201
|
+
authorityTokenAccount: {
|
|
1202
|
+
value: input.authorityTokenAccount ?? null,
|
|
1203
|
+
isWritable: true
|
|
1204
|
+
},
|
|
1220
1205
|
mint: { value: input.mint ?? null, isWritable: true },
|
|
1221
1206
|
systemProgram: { value: input.systemProgram ?? null, isWritable: false },
|
|
1222
1207
|
tokenProgram: { value: input.tokenProgram ?? null, isWritable: false },
|
|
@@ -1252,16 +1237,6 @@ async function getWithdrawInstructionAsync(input, config) {
|
|
|
1252
1237
|
]
|
|
1253
1238
|
});
|
|
1254
1239
|
}
|
|
1255
|
-
if (!accounts.authorityAta.value) {
|
|
1256
|
-
accounts.authorityAta.value = await kit.getProgramDerivedAddress({
|
|
1257
|
-
programAddress: "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL",
|
|
1258
|
-
seeds: [
|
|
1259
|
-
kit.getAddressEncoder().encode(expectAddress(accounts.authority.value)),
|
|
1260
|
-
kit.getAddressEncoder().encode(expectAddress(accounts.tokenProgram.value)),
|
|
1261
|
-
kit.getAddressEncoder().encode(expectAddress(accounts.mint.value))
|
|
1262
|
-
]
|
|
1263
|
-
});
|
|
1264
|
-
}
|
|
1265
1240
|
if (!accounts.systemProgram.value) {
|
|
1266
1241
|
accounts.systemProgram.value = "11111111111111111111111111111111";
|
|
1267
1242
|
}
|
|
@@ -1275,7 +1250,7 @@ async function getWithdrawInstructionAsync(input, config) {
|
|
|
1275
1250
|
getAccountMeta(accounts.pool),
|
|
1276
1251
|
getAccountMeta(accounts.vault),
|
|
1277
1252
|
getAccountMeta(accounts.vaultAta),
|
|
1278
|
-
getAccountMeta(accounts.
|
|
1253
|
+
getAccountMeta(accounts.authorityTokenAccount),
|
|
1279
1254
|
getAccountMeta(accounts.mint),
|
|
1280
1255
|
getAccountMeta(accounts.systemProgram),
|
|
1281
1256
|
getAccountMeta(accounts.tokenProgram),
|
|
@@ -1294,7 +1269,10 @@ function getWithdrawInstruction(input, config) {
|
|
|
1294
1269
|
pool: { value: input.pool ?? null, isWritable: true },
|
|
1295
1270
|
vault: { value: input.vault ?? null, isWritable: true },
|
|
1296
1271
|
vaultAta: { value: input.vaultAta ?? null, isWritable: false },
|
|
1297
|
-
|
|
1272
|
+
authorityTokenAccount: {
|
|
1273
|
+
value: input.authorityTokenAccount ?? null,
|
|
1274
|
+
isWritable: true
|
|
1275
|
+
},
|
|
1298
1276
|
mint: { value: input.mint ?? null, isWritable: true },
|
|
1299
1277
|
systemProgram: { value: input.systemProgram ?? null, isWritable: false },
|
|
1300
1278
|
tokenProgram: { value: input.tokenProgram ?? null, isWritable: false },
|
|
@@ -1324,7 +1302,7 @@ function getWithdrawInstruction(input, config) {
|
|
|
1324
1302
|
getAccountMeta(accounts.pool),
|
|
1325
1303
|
getAccountMeta(accounts.vault),
|
|
1326
1304
|
getAccountMeta(accounts.vaultAta),
|
|
1327
|
-
getAccountMeta(accounts.
|
|
1305
|
+
getAccountMeta(accounts.authorityTokenAccount),
|
|
1328
1306
|
getAccountMeta(accounts.mint),
|
|
1329
1307
|
getAccountMeta(accounts.systemProgram),
|
|
1330
1308
|
getAccountMeta(accounts.tokenProgram),
|
|
@@ -1346,6 +1324,10 @@ function parseWithdrawInstruction(instruction) {
|
|
|
1346
1324
|
accountIndex += 1;
|
|
1347
1325
|
return accountMeta;
|
|
1348
1326
|
};
|
|
1327
|
+
const getNextOptionalAccount = () => {
|
|
1328
|
+
const accountMeta = getNextAccount();
|
|
1329
|
+
return accountMeta.address === MIXOOR_PROGRAM_ADDRESS ? void 0 : accountMeta;
|
|
1330
|
+
};
|
|
1349
1331
|
return {
|
|
1350
1332
|
programAddress: instruction.programAddress,
|
|
1351
1333
|
accounts: {
|
|
@@ -1353,7 +1335,7 @@ function parseWithdrawInstruction(instruction) {
|
|
|
1353
1335
|
pool: getNextAccount(),
|
|
1354
1336
|
vault: getNextAccount(),
|
|
1355
1337
|
vaultAta: getNextAccount(),
|
|
1356
|
-
|
|
1338
|
+
authorityTokenAccount: getNextOptionalAccount(),
|
|
1357
1339
|
mint: getNextAccount(),
|
|
1358
1340
|
systemProgram: getNextAccount(),
|
|
1359
1341
|
tokenProgram: getNextAccount(),
|
|
@@ -1682,6 +1664,7 @@ exports.MIXOOR_ERROR__INVALID_ASSET_TYPE = MIXOOR_ERROR__INVALID_ASSET_TYPE;
|
|
|
1682
1664
|
exports.MIXOOR_ERROR__INVALID_MERKLE_PROOF = MIXOOR_ERROR__INVALID_MERKLE_PROOF;
|
|
1683
1665
|
exports.MIXOOR_ERROR__INVALID_MERKLE_TREE = MIXOOR_ERROR__INVALID_MERKLE_TREE;
|
|
1684
1666
|
exports.MIXOOR_ERROR__INVALID_MERKLE_TREE_ADDRESS = MIXOOR_ERROR__INVALID_MERKLE_TREE_ADDRESS;
|
|
1667
|
+
exports.MIXOOR_ERROR__INVALID_MINT = MIXOOR_ERROR__INVALID_MINT;
|
|
1685
1668
|
exports.MIXOOR_ERROR__INVALID_PROOF = MIXOOR_ERROR__INVALID_PROOF;
|
|
1686
1669
|
exports.MIXOOR_ERROR__INVALID_PUBLIC_INPUTS = MIXOOR_ERROR__INVALID_PUBLIC_INPUTS;
|
|
1687
1670
|
exports.MIXOOR_ERROR__MERKLE_TREE_FULL = MIXOOR_ERROR__MERKLE_TREE_FULL;
|