@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.js
CHANGED
|
@@ -331,7 +331,8 @@ var MixoorInstruction = /* @__PURE__ */ ((MixoorInstruction2) => {
|
|
|
331
331
|
MixoorInstruction2[MixoorInstruction2["Deposit"] = 0] = "Deposit";
|
|
332
332
|
MixoorInstruction2[MixoorInstruction2["InitializePool"] = 1] = "InitializePool";
|
|
333
333
|
MixoorInstruction2[MixoorInstruction2["Transfer"] = 2] = "Transfer";
|
|
334
|
-
MixoorInstruction2[MixoorInstruction2["
|
|
334
|
+
MixoorInstruction2[MixoorInstruction2["UpdateRoot"] = 3] = "UpdateRoot";
|
|
335
|
+
MixoorInstruction2[MixoorInstruction2["Withdraw"] = 4] = "Withdraw";
|
|
335
336
|
return MixoorInstruction2;
|
|
336
337
|
})(MixoorInstruction || {});
|
|
337
338
|
function identifyMixoorInstruction(instruction) {
|
|
@@ -363,6 +364,15 @@ function identifyMixoorInstruction(instruction) {
|
|
|
363
364
|
)) {
|
|
364
365
|
return 2 /* Transfer */;
|
|
365
366
|
}
|
|
367
|
+
if (kit.containsBytes(
|
|
368
|
+
data,
|
|
369
|
+
kit.fixEncoderSize(kit.getBytesEncoder(), 8).encode(
|
|
370
|
+
new Uint8Array([58, 195, 57, 246, 116, 198, 170, 138])
|
|
371
|
+
),
|
|
372
|
+
0
|
|
373
|
+
)) {
|
|
374
|
+
return 3 /* UpdateRoot */;
|
|
375
|
+
}
|
|
366
376
|
if (kit.containsBytes(
|
|
367
377
|
data,
|
|
368
378
|
kit.fixEncoderSize(kit.getBytesEncoder(), 8).encode(
|
|
@@ -370,7 +380,7 @@ function identifyMixoorInstruction(instruction) {
|
|
|
370
380
|
),
|
|
371
381
|
0
|
|
372
382
|
)) {
|
|
373
|
-
return
|
|
383
|
+
return 4 /* Withdraw */;
|
|
374
384
|
}
|
|
375
385
|
throw new Error(
|
|
376
386
|
"The provided instruction could not be identified as a mixoor instruction."
|
|
@@ -1095,6 +1105,76 @@ function parseTransferInstruction(instruction) {
|
|
|
1095
1105
|
data: getTransferInstructionDataDecoder().decode(instruction.data)
|
|
1096
1106
|
};
|
|
1097
1107
|
}
|
|
1108
|
+
var UPDATE_ROOT_DISCRIMINATOR = new Uint8Array([
|
|
1109
|
+
58,
|
|
1110
|
+
195,
|
|
1111
|
+
57,
|
|
1112
|
+
246,
|
|
1113
|
+
116,
|
|
1114
|
+
198,
|
|
1115
|
+
170,
|
|
1116
|
+
138
|
|
1117
|
+
]);
|
|
1118
|
+
function getUpdateRootDiscriminatorBytes() {
|
|
1119
|
+
return kit.fixEncoderSize(kit.getBytesEncoder(), 8).encode(UPDATE_ROOT_DISCRIMINATOR);
|
|
1120
|
+
}
|
|
1121
|
+
function getUpdateRootInstructionDataEncoder() {
|
|
1122
|
+
return kit.transformEncoder(
|
|
1123
|
+
kit.getStructEncoder([
|
|
1124
|
+
["discriminator", kit.fixEncoderSize(kit.getBytesEncoder(), 8)],
|
|
1125
|
+
["root", kit.fixEncoderSize(kit.getBytesEncoder(), 32)]
|
|
1126
|
+
]),
|
|
1127
|
+
(value) => ({ ...value, discriminator: UPDATE_ROOT_DISCRIMINATOR })
|
|
1128
|
+
);
|
|
1129
|
+
}
|
|
1130
|
+
function getUpdateRootInstructionDataDecoder() {
|
|
1131
|
+
return kit.getStructDecoder([
|
|
1132
|
+
["discriminator", kit.fixDecoderSize(kit.getBytesDecoder(), 8)],
|
|
1133
|
+
["root", kit.fixDecoderSize(kit.getBytesDecoder(), 32)]
|
|
1134
|
+
]);
|
|
1135
|
+
}
|
|
1136
|
+
function getUpdateRootInstructionDataCodec() {
|
|
1137
|
+
return kit.combineCodec(
|
|
1138
|
+
getUpdateRootInstructionDataEncoder(),
|
|
1139
|
+
getUpdateRootInstructionDataDecoder()
|
|
1140
|
+
);
|
|
1141
|
+
}
|
|
1142
|
+
function getUpdateRootInstruction(input, config) {
|
|
1143
|
+
const programAddress = config?.programAddress ?? MIXOOR_PROGRAM_ADDRESS;
|
|
1144
|
+
const originalAccounts = {
|
|
1145
|
+
relayer: { value: input.relayer ?? null, isWritable: true },
|
|
1146
|
+
pool: { value: input.pool ?? null, isWritable: true }
|
|
1147
|
+
};
|
|
1148
|
+
const accounts = originalAccounts;
|
|
1149
|
+
const args = { ...input };
|
|
1150
|
+
if (!accounts.relayer.value) {
|
|
1151
|
+
accounts.relayer.value = "re1R63DiMLtDyHMAS1ohszqfFTHcF9Q3uEXSYdHzHWU";
|
|
1152
|
+
}
|
|
1153
|
+
const getAccountMeta = getAccountMetaFactory(programAddress);
|
|
1154
|
+
return Object.freeze({
|
|
1155
|
+
accounts: [getAccountMeta(accounts.relayer), getAccountMeta(accounts.pool)],
|
|
1156
|
+
data: getUpdateRootInstructionDataEncoder().encode(
|
|
1157
|
+
args
|
|
1158
|
+
),
|
|
1159
|
+
programAddress
|
|
1160
|
+
});
|
|
1161
|
+
}
|
|
1162
|
+
function parseUpdateRootInstruction(instruction) {
|
|
1163
|
+
if (instruction.accounts.length < 2) {
|
|
1164
|
+
throw new Error("Not enough accounts");
|
|
1165
|
+
}
|
|
1166
|
+
let accountIndex = 0;
|
|
1167
|
+
const getNextAccount = () => {
|
|
1168
|
+
const accountMeta = instruction.accounts[accountIndex];
|
|
1169
|
+
accountIndex += 1;
|
|
1170
|
+
return accountMeta;
|
|
1171
|
+
};
|
|
1172
|
+
return {
|
|
1173
|
+
programAddress: instruction.programAddress,
|
|
1174
|
+
accounts: { relayer: getNextAccount(), pool: getNextAccount() },
|
|
1175
|
+
data: getUpdateRootInstructionDataDecoder().decode(instruction.data)
|
|
1176
|
+
};
|
|
1177
|
+
}
|
|
1098
1178
|
var WITHDRAW_DISCRIMINATOR = new Uint8Array([
|
|
1099
1179
|
183,
|
|
1100
1180
|
18,
|
|
@@ -1617,6 +1697,7 @@ exports.MixoorInstruction = MixoorInstruction;
|
|
|
1617
1697
|
exports.NULLIFIER_ACCOUNT_DISCRIMINATOR = NULLIFIER_ACCOUNT_DISCRIMINATOR;
|
|
1618
1698
|
exports.POOL_DISCRIMINATOR = POOL_DISCRIMINATOR;
|
|
1619
1699
|
exports.TRANSFER_DISCRIMINATOR = TRANSFER_DISCRIMINATOR;
|
|
1700
|
+
exports.UPDATE_ROOT_DISCRIMINATOR = UPDATE_ROOT_DISCRIMINATOR;
|
|
1620
1701
|
exports.VAULT_DISCRIMINATOR = VAULT_DISCRIMINATOR;
|
|
1621
1702
|
exports.WITHDRAW_DISCRIMINATOR = WITHDRAW_DISCRIMINATOR;
|
|
1622
1703
|
exports.decodeNullifierAccount = decodeNullifierAccount;
|
|
@@ -1681,6 +1762,11 @@ exports.getTransferInstructionAsync = getTransferInstructionAsync;
|
|
|
1681
1762
|
exports.getTransferInstructionDataCodec = getTransferInstructionDataCodec;
|
|
1682
1763
|
exports.getTransferInstructionDataDecoder = getTransferInstructionDataDecoder;
|
|
1683
1764
|
exports.getTransferInstructionDataEncoder = getTransferInstructionDataEncoder;
|
|
1765
|
+
exports.getUpdateRootDiscriminatorBytes = getUpdateRootDiscriminatorBytes;
|
|
1766
|
+
exports.getUpdateRootInstruction = getUpdateRootInstruction;
|
|
1767
|
+
exports.getUpdateRootInstructionDataCodec = getUpdateRootInstructionDataCodec;
|
|
1768
|
+
exports.getUpdateRootInstructionDataDecoder = getUpdateRootInstructionDataDecoder;
|
|
1769
|
+
exports.getUpdateRootInstructionDataEncoder = getUpdateRootInstructionDataEncoder;
|
|
1684
1770
|
exports.getVaultCodec = getVaultCodec;
|
|
1685
1771
|
exports.getVaultDecoder = getVaultDecoder;
|
|
1686
1772
|
exports.getVaultDiscriminatorBytes = getVaultDiscriminatorBytes;
|
|
@@ -1698,6 +1784,7 @@ exports.isMixoorError = isMixoorError;
|
|
|
1698
1784
|
exports.parseDepositInstruction = parseDepositInstruction;
|
|
1699
1785
|
exports.parseInitializePoolInstruction = parseInitializePoolInstruction;
|
|
1700
1786
|
exports.parseTransferInstruction = parseTransferInstruction;
|
|
1787
|
+
exports.parseUpdateRootInstruction = parseUpdateRootInstruction;
|
|
1701
1788
|
exports.parseWithdrawInstruction = parseWithdrawInstruction;
|
|
1702
1789
|
exports.poseidonHash = poseidonHash;
|
|
1703
1790
|
exports.randomBytes = randomBytes;
|