@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.mjs
CHANGED
|
@@ -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`,
|
|
@@ -926,35 +928,15 @@ async function getTransferInstructionAsync(input, config) {
|
|
|
926
928
|
]
|
|
927
929
|
});
|
|
928
930
|
}
|
|
929
|
-
if (!accounts.tokenProgram.value) {
|
|
930
|
-
accounts.tokenProgram.value = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";
|
|
931
|
-
}
|
|
932
|
-
if (!accounts.recipientTokenAccount.value) {
|
|
933
|
-
accounts.recipientTokenAccount.value = await getProgramDerivedAddress({
|
|
934
|
-
programAddress: "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL",
|
|
935
|
-
seeds: [
|
|
936
|
-
getAddressEncoder().encode(expectAddress(accounts.recipient.value)),
|
|
937
|
-
getAddressEncoder().encode(expectAddress(accounts.tokenProgram.value)),
|
|
938
|
-
getAddressEncoder().encode(expectAddress(accounts.mint.value))
|
|
939
|
-
]
|
|
940
|
-
});
|
|
941
|
-
}
|
|
942
931
|
if (!accounts.feeCollector.value) {
|
|
943
932
|
accounts.feeCollector.value = "9qX97Bd8dvHAknHVjCxz4uEJcPSE3NGjjgniMVdDBu6d";
|
|
944
933
|
}
|
|
945
|
-
if (!accounts.feeCollectorTokenAccount.value) {
|
|
946
|
-
accounts.feeCollectorTokenAccount.value = await getProgramDerivedAddress({
|
|
947
|
-
programAddress: "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL",
|
|
948
|
-
seeds: [
|
|
949
|
-
getAddressEncoder().encode(expectAddress(accounts.feeCollector.value)),
|
|
950
|
-
getAddressEncoder().encode(expectAddress(accounts.tokenProgram.value)),
|
|
951
|
-
getAddressEncoder().encode(expectAddress(accounts.mint.value))
|
|
952
|
-
]
|
|
953
|
-
});
|
|
954
|
-
}
|
|
955
934
|
if (!accounts.systemProgram.value) {
|
|
956
935
|
accounts.systemProgram.value = "11111111111111111111111111111111";
|
|
957
936
|
}
|
|
937
|
+
if (!accounts.tokenProgram.value) {
|
|
938
|
+
accounts.tokenProgram.value = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";
|
|
939
|
+
}
|
|
958
940
|
if (!accounts.associatedTokenProgram.value) {
|
|
959
941
|
accounts.associatedTokenProgram.value = "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL";
|
|
960
942
|
}
|
|
@@ -1012,15 +994,15 @@ function getTransferInstruction(input, config) {
|
|
|
1012
994
|
};
|
|
1013
995
|
const accounts = originalAccounts;
|
|
1014
996
|
const args = { ...input };
|
|
1015
|
-
if (!accounts.tokenProgram.value) {
|
|
1016
|
-
accounts.tokenProgram.value = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";
|
|
1017
|
-
}
|
|
1018
997
|
if (!accounts.feeCollector.value) {
|
|
1019
998
|
accounts.feeCollector.value = "9qX97Bd8dvHAknHVjCxz4uEJcPSE3NGjjgniMVdDBu6d";
|
|
1020
999
|
}
|
|
1021
1000
|
if (!accounts.systemProgram.value) {
|
|
1022
1001
|
accounts.systemProgram.value = "11111111111111111111111111111111";
|
|
1023
1002
|
}
|
|
1003
|
+
if (!accounts.tokenProgram.value) {
|
|
1004
|
+
accounts.tokenProgram.value = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";
|
|
1005
|
+
}
|
|
1024
1006
|
if (!accounts.associatedTokenProgram.value) {
|
|
1025
1007
|
accounts.associatedTokenProgram.value = "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL";
|
|
1026
1008
|
}
|
|
@@ -1192,7 +1174,10 @@ async function getWithdrawInstructionAsync(input, config) {
|
|
|
1192
1174
|
pool: { value: input.pool ?? null, isWritable: true },
|
|
1193
1175
|
vault: { value: input.vault ?? null, isWritable: true },
|
|
1194
1176
|
vaultAta: { value: input.vaultAta ?? null, isWritable: false },
|
|
1195
|
-
|
|
1177
|
+
authorityTokenAccount: {
|
|
1178
|
+
value: input.authorityTokenAccount ?? null,
|
|
1179
|
+
isWritable: true
|
|
1180
|
+
},
|
|
1196
1181
|
mint: { value: input.mint ?? null, isWritable: true },
|
|
1197
1182
|
systemProgram: { value: input.systemProgram ?? null, isWritable: false },
|
|
1198
1183
|
tokenProgram: { value: input.tokenProgram ?? null, isWritable: false },
|
|
@@ -1228,16 +1213,6 @@ async function getWithdrawInstructionAsync(input, config) {
|
|
|
1228
1213
|
]
|
|
1229
1214
|
});
|
|
1230
1215
|
}
|
|
1231
|
-
if (!accounts.authorityAta.value) {
|
|
1232
|
-
accounts.authorityAta.value = await getProgramDerivedAddress({
|
|
1233
|
-
programAddress: "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL",
|
|
1234
|
-
seeds: [
|
|
1235
|
-
getAddressEncoder().encode(expectAddress(accounts.authority.value)),
|
|
1236
|
-
getAddressEncoder().encode(expectAddress(accounts.tokenProgram.value)),
|
|
1237
|
-
getAddressEncoder().encode(expectAddress(accounts.mint.value))
|
|
1238
|
-
]
|
|
1239
|
-
});
|
|
1240
|
-
}
|
|
1241
1216
|
if (!accounts.systemProgram.value) {
|
|
1242
1217
|
accounts.systemProgram.value = "11111111111111111111111111111111";
|
|
1243
1218
|
}
|
|
@@ -1251,7 +1226,7 @@ async function getWithdrawInstructionAsync(input, config) {
|
|
|
1251
1226
|
getAccountMeta(accounts.pool),
|
|
1252
1227
|
getAccountMeta(accounts.vault),
|
|
1253
1228
|
getAccountMeta(accounts.vaultAta),
|
|
1254
|
-
getAccountMeta(accounts.
|
|
1229
|
+
getAccountMeta(accounts.authorityTokenAccount),
|
|
1255
1230
|
getAccountMeta(accounts.mint),
|
|
1256
1231
|
getAccountMeta(accounts.systemProgram),
|
|
1257
1232
|
getAccountMeta(accounts.tokenProgram),
|
|
@@ -1270,7 +1245,10 @@ function getWithdrawInstruction(input, config) {
|
|
|
1270
1245
|
pool: { value: input.pool ?? null, isWritable: true },
|
|
1271
1246
|
vault: { value: input.vault ?? null, isWritable: true },
|
|
1272
1247
|
vaultAta: { value: input.vaultAta ?? null, isWritable: false },
|
|
1273
|
-
|
|
1248
|
+
authorityTokenAccount: {
|
|
1249
|
+
value: input.authorityTokenAccount ?? null,
|
|
1250
|
+
isWritable: true
|
|
1251
|
+
},
|
|
1274
1252
|
mint: { value: input.mint ?? null, isWritable: true },
|
|
1275
1253
|
systemProgram: { value: input.systemProgram ?? null, isWritable: false },
|
|
1276
1254
|
tokenProgram: { value: input.tokenProgram ?? null, isWritable: false },
|
|
@@ -1300,7 +1278,7 @@ function getWithdrawInstruction(input, config) {
|
|
|
1300
1278
|
getAccountMeta(accounts.pool),
|
|
1301
1279
|
getAccountMeta(accounts.vault),
|
|
1302
1280
|
getAccountMeta(accounts.vaultAta),
|
|
1303
|
-
getAccountMeta(accounts.
|
|
1281
|
+
getAccountMeta(accounts.authorityTokenAccount),
|
|
1304
1282
|
getAccountMeta(accounts.mint),
|
|
1305
1283
|
getAccountMeta(accounts.systemProgram),
|
|
1306
1284
|
getAccountMeta(accounts.tokenProgram),
|
|
@@ -1322,6 +1300,10 @@ function parseWithdrawInstruction(instruction) {
|
|
|
1322
1300
|
accountIndex += 1;
|
|
1323
1301
|
return accountMeta;
|
|
1324
1302
|
};
|
|
1303
|
+
const getNextOptionalAccount = () => {
|
|
1304
|
+
const accountMeta = getNextAccount();
|
|
1305
|
+
return accountMeta.address === MIXOOR_PROGRAM_ADDRESS ? void 0 : accountMeta;
|
|
1306
|
+
};
|
|
1325
1307
|
return {
|
|
1326
1308
|
programAddress: instruction.programAddress,
|
|
1327
1309
|
accounts: {
|
|
@@ -1329,7 +1311,7 @@ function parseWithdrawInstruction(instruction) {
|
|
|
1329
1311
|
pool: getNextAccount(),
|
|
1330
1312
|
vault: getNextAccount(),
|
|
1331
1313
|
vaultAta: getNextAccount(),
|
|
1332
|
-
|
|
1314
|
+
authorityTokenAccount: getNextOptionalAccount(),
|
|
1333
1315
|
mint: getNextAccount(),
|
|
1334
1316
|
systemProgram: getNextAccount(),
|
|
1335
1317
|
tokenProgram: getNextAccount(),
|
|
@@ -1649,6 +1631,6 @@ async function findNullifierAddress(seeds, config = {}) {
|
|
|
1649
1631
|
});
|
|
1650
1632
|
}
|
|
1651
1633
|
|
|
1652
|
-
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 };
|
|
1653
1635
|
//# sourceMappingURL=index.mjs.map
|
|
1654
1636
|
//# sourceMappingURL=index.mjs.map
|