@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/src/index.mjs
CHANGED
|
@@ -307,7 +307,8 @@ var MixoorInstruction = /* @__PURE__ */ ((MixoorInstruction2) => {
|
|
|
307
307
|
MixoorInstruction2[MixoorInstruction2["Deposit"] = 0] = "Deposit";
|
|
308
308
|
MixoorInstruction2[MixoorInstruction2["InitializePool"] = 1] = "InitializePool";
|
|
309
309
|
MixoorInstruction2[MixoorInstruction2["Transfer"] = 2] = "Transfer";
|
|
310
|
-
MixoorInstruction2[MixoorInstruction2["
|
|
310
|
+
MixoorInstruction2[MixoorInstruction2["UpdateRoot"] = 3] = "UpdateRoot";
|
|
311
|
+
MixoorInstruction2[MixoorInstruction2["Withdraw"] = 4] = "Withdraw";
|
|
311
312
|
return MixoorInstruction2;
|
|
312
313
|
})(MixoorInstruction || {});
|
|
313
314
|
function identifyMixoorInstruction(instruction) {
|
|
@@ -339,6 +340,15 @@ function identifyMixoorInstruction(instruction) {
|
|
|
339
340
|
)) {
|
|
340
341
|
return 2 /* Transfer */;
|
|
341
342
|
}
|
|
343
|
+
if (containsBytes(
|
|
344
|
+
data,
|
|
345
|
+
fixEncoderSize(getBytesEncoder(), 8).encode(
|
|
346
|
+
new Uint8Array([58, 195, 57, 246, 116, 198, 170, 138])
|
|
347
|
+
),
|
|
348
|
+
0
|
|
349
|
+
)) {
|
|
350
|
+
return 3 /* UpdateRoot */;
|
|
351
|
+
}
|
|
342
352
|
if (containsBytes(
|
|
343
353
|
data,
|
|
344
354
|
fixEncoderSize(getBytesEncoder(), 8).encode(
|
|
@@ -346,7 +356,7 @@ function identifyMixoorInstruction(instruction) {
|
|
|
346
356
|
),
|
|
347
357
|
0
|
|
348
358
|
)) {
|
|
349
|
-
return
|
|
359
|
+
return 4 /* Withdraw */;
|
|
350
360
|
}
|
|
351
361
|
throw new Error(
|
|
352
362
|
"The provided instruction could not be identified as a mixoor instruction."
|
|
@@ -1071,6 +1081,76 @@ function parseTransferInstruction(instruction) {
|
|
|
1071
1081
|
data: getTransferInstructionDataDecoder().decode(instruction.data)
|
|
1072
1082
|
};
|
|
1073
1083
|
}
|
|
1084
|
+
var UPDATE_ROOT_DISCRIMINATOR = new Uint8Array([
|
|
1085
|
+
58,
|
|
1086
|
+
195,
|
|
1087
|
+
57,
|
|
1088
|
+
246,
|
|
1089
|
+
116,
|
|
1090
|
+
198,
|
|
1091
|
+
170,
|
|
1092
|
+
138
|
|
1093
|
+
]);
|
|
1094
|
+
function getUpdateRootDiscriminatorBytes() {
|
|
1095
|
+
return fixEncoderSize(getBytesEncoder(), 8).encode(UPDATE_ROOT_DISCRIMINATOR);
|
|
1096
|
+
}
|
|
1097
|
+
function getUpdateRootInstructionDataEncoder() {
|
|
1098
|
+
return transformEncoder(
|
|
1099
|
+
getStructEncoder([
|
|
1100
|
+
["discriminator", fixEncoderSize(getBytesEncoder(), 8)],
|
|
1101
|
+
["root", fixEncoderSize(getBytesEncoder(), 32)]
|
|
1102
|
+
]),
|
|
1103
|
+
(value) => ({ ...value, discriminator: UPDATE_ROOT_DISCRIMINATOR })
|
|
1104
|
+
);
|
|
1105
|
+
}
|
|
1106
|
+
function getUpdateRootInstructionDataDecoder() {
|
|
1107
|
+
return getStructDecoder([
|
|
1108
|
+
["discriminator", fixDecoderSize(getBytesDecoder(), 8)],
|
|
1109
|
+
["root", fixDecoderSize(getBytesDecoder(), 32)]
|
|
1110
|
+
]);
|
|
1111
|
+
}
|
|
1112
|
+
function getUpdateRootInstructionDataCodec() {
|
|
1113
|
+
return combineCodec(
|
|
1114
|
+
getUpdateRootInstructionDataEncoder(),
|
|
1115
|
+
getUpdateRootInstructionDataDecoder()
|
|
1116
|
+
);
|
|
1117
|
+
}
|
|
1118
|
+
function getUpdateRootInstruction(input, config) {
|
|
1119
|
+
const programAddress = config?.programAddress ?? MIXOOR_PROGRAM_ADDRESS;
|
|
1120
|
+
const originalAccounts = {
|
|
1121
|
+
relayer: { value: input.relayer ?? null, isWritable: true },
|
|
1122
|
+
pool: { value: input.pool ?? null, isWritable: true }
|
|
1123
|
+
};
|
|
1124
|
+
const accounts = originalAccounts;
|
|
1125
|
+
const args = { ...input };
|
|
1126
|
+
if (!accounts.relayer.value) {
|
|
1127
|
+
accounts.relayer.value = "re1R63DiMLtDyHMAS1ohszqfFTHcF9Q3uEXSYdHzHWU";
|
|
1128
|
+
}
|
|
1129
|
+
const getAccountMeta = getAccountMetaFactory(programAddress);
|
|
1130
|
+
return Object.freeze({
|
|
1131
|
+
accounts: [getAccountMeta(accounts.relayer), getAccountMeta(accounts.pool)],
|
|
1132
|
+
data: getUpdateRootInstructionDataEncoder().encode(
|
|
1133
|
+
args
|
|
1134
|
+
),
|
|
1135
|
+
programAddress
|
|
1136
|
+
});
|
|
1137
|
+
}
|
|
1138
|
+
function parseUpdateRootInstruction(instruction) {
|
|
1139
|
+
if (instruction.accounts.length < 2) {
|
|
1140
|
+
throw new Error("Not enough accounts");
|
|
1141
|
+
}
|
|
1142
|
+
let accountIndex = 0;
|
|
1143
|
+
const getNextAccount = () => {
|
|
1144
|
+
const accountMeta = instruction.accounts[accountIndex];
|
|
1145
|
+
accountIndex += 1;
|
|
1146
|
+
return accountMeta;
|
|
1147
|
+
};
|
|
1148
|
+
return {
|
|
1149
|
+
programAddress: instruction.programAddress,
|
|
1150
|
+
accounts: { relayer: getNextAccount(), pool: getNextAccount() },
|
|
1151
|
+
data: getUpdateRootInstructionDataDecoder().decode(instruction.data)
|
|
1152
|
+
};
|
|
1153
|
+
}
|
|
1074
1154
|
var WITHDRAW_DISCRIMINATOR = new Uint8Array([
|
|
1075
1155
|
183,
|
|
1076
1156
|
18,
|
|
@@ -1569,6 +1649,6 @@ async function findNullifierAddress(seeds, config = {}) {
|
|
|
1569
1649
|
});
|
|
1570
1650
|
}
|
|
1571
1651
|
|
|
1572
|
-
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, 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, getVaultCodec, getVaultDecoder, getVaultDiscriminatorBytes, getVaultEncoder, getVaultSize, getWithdrawDiscriminatorBytes, getWithdrawInstruction, getWithdrawInstructionAsync, getWithdrawInstructionDataCodec, getWithdrawInstructionDataDecoder, getWithdrawInstructionDataEncoder, identifyMixoorAccount, identifyMixoorInstruction, isMixoorError, parseDepositInstruction, parseInitializePoolInstruction, parseTransferInstruction, parseWithdrawInstruction, poseidonHash, randomBytes, toHex };
|
|
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 };
|
|
1573
1653
|
//# sourceMappingURL=index.mjs.map
|
|
1574
1654
|
//# sourceMappingURL=index.mjs.map
|