@smithii_io/mixoor 0.0.17 → 0.0.19
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 -33
- package/dist/src/index.js.map +1 -1
- package/dist/src/index.mjs +24 -33
- package/dist/src/index.mjs.map +1 -1
- package/dist/test/_helpers.js +54 -0
- package/dist/test/_helpers.js.map +1 -1
- package/dist/test/_setup.js +2 -1
- package/dist/test/_setup.js.map +1 -1
- package/dist/test/transferSpl.test.js +21 -11
- package/dist/test/transferSpl.test.js.map +1 -1
- 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/initializePool.d.ts +1 -1
- package/dist/types/src/generated/instructions/transfer.d.ts +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/src/utils/circuit.d.ts.map +1 -1
- package/package.json +2 -1
package/dist/src/index.js
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
var kit = require('@solana/kit');
|
|
4
4
|
var circomlibjs = require('circomlibjs');
|
|
5
|
-
var fs = require('fs');
|
|
6
5
|
var path = require('path');
|
|
7
6
|
var snarkjs = require('snarkjs');
|
|
8
7
|
var url = require('url');
|
|
@@ -27,7 +26,6 @@ function _interopNamespace(e) {
|
|
|
27
26
|
return Object.freeze(n);
|
|
28
27
|
}
|
|
29
28
|
|
|
30
|
-
var fs__namespace = /*#__PURE__*/_interopNamespace(fs);
|
|
31
29
|
var path__namespace = /*#__PURE__*/_interopNamespace(path);
|
|
32
30
|
|
|
33
31
|
// src/generated/accounts/nullifierAccount.ts
|
|
@@ -402,6 +400,7 @@ var MIXOOR_ERROR__POSEIDON_HASH_ERROR = 6010;
|
|
|
402
400
|
var MIXOOR_ERROR__MERKLE_TREE_FULL = 6011;
|
|
403
401
|
var MIXOOR_ERROR__INVALID_MERKLE_PROOF = 6012;
|
|
404
402
|
var MIXOOR_ERROR__PUBLIC_INPUT_MISMATCH = 6013;
|
|
403
|
+
var MIXOOR_ERROR__INVALID_MINT = 6014;
|
|
405
404
|
var mixoorErrorMessages;
|
|
406
405
|
if (process.env.NODE_ENV !== "production") {
|
|
407
406
|
mixoorErrorMessages = {
|
|
@@ -411,6 +410,7 @@ if (process.env.NODE_ENV !== "production") {
|
|
|
411
410
|
[MIXOOR_ERROR__INVALID_MERKLE_PROOF]: `Invalid merkle proof`,
|
|
412
411
|
[MIXOOR_ERROR__INVALID_MERKLE_TREE]: `Invalid merkle tree structure or out of bounds access`,
|
|
413
412
|
[MIXOOR_ERROR__INVALID_MERKLE_TREE_ADDRESS]: `Invalid merkle tree address`,
|
|
413
|
+
[MIXOOR_ERROR__INVALID_MINT]: `Invalid mint provided to instruction`,
|
|
414
414
|
[MIXOOR_ERROR__INVALID_PROOF]: `Invalid proof`,
|
|
415
415
|
[MIXOOR_ERROR__INVALID_PUBLIC_INPUTS]: `Invalid number of public inputs`,
|
|
416
416
|
[MIXOOR_ERROR__MERKLE_TREE_FULL]: `Merkle tree is full`,
|
|
@@ -742,7 +742,7 @@ async function getInitializePoolInstructionAsync(input, config) {
|
|
|
742
742
|
});
|
|
743
743
|
}
|
|
744
744
|
if (!accounts.feeCollector.value) {
|
|
745
|
-
accounts.feeCollector.value = "
|
|
745
|
+
accounts.feeCollector.value = "4kg8oh3jdNtn7j2wcS7TrUua31AgbLzDVkBZgTAe44aF";
|
|
746
746
|
}
|
|
747
747
|
if (!accounts.systemProgram.value) {
|
|
748
748
|
accounts.systemProgram.value = "11111111111111111111111111111111";
|
|
@@ -791,7 +791,7 @@ function getInitializePoolInstruction(input, config) {
|
|
|
791
791
|
accounts.tokenProgram.value = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";
|
|
792
792
|
}
|
|
793
793
|
if (!accounts.feeCollector.value) {
|
|
794
|
-
accounts.feeCollector.value = "
|
|
794
|
+
accounts.feeCollector.value = "4kg8oh3jdNtn7j2wcS7TrUua31AgbLzDVkBZgTAe44aF";
|
|
795
795
|
}
|
|
796
796
|
if (!accounts.systemProgram.value) {
|
|
797
797
|
accounts.systemProgram.value = "11111111111111111111111111111111";
|
|
@@ -951,7 +951,7 @@ async function getTransferInstructionAsync(input, config) {
|
|
|
951
951
|
});
|
|
952
952
|
}
|
|
953
953
|
if (!accounts.feeCollector.value) {
|
|
954
|
-
accounts.feeCollector.value = "
|
|
954
|
+
accounts.feeCollector.value = "4kg8oh3jdNtn7j2wcS7TrUua31AgbLzDVkBZgTAe44aF";
|
|
955
955
|
}
|
|
956
956
|
if (!accounts.systemProgram.value) {
|
|
957
957
|
accounts.systemProgram.value = "11111111111111111111111111111111";
|
|
@@ -1017,7 +1017,7 @@ function getTransferInstruction(input, config) {
|
|
|
1017
1017
|
const accounts = originalAccounts;
|
|
1018
1018
|
const args = { ...input };
|
|
1019
1019
|
if (!accounts.feeCollector.value) {
|
|
1020
|
-
accounts.feeCollector.value = "
|
|
1020
|
+
accounts.feeCollector.value = "4kg8oh3jdNtn7j2wcS7TrUua31AgbLzDVkBZgTAe44aF";
|
|
1021
1021
|
}
|
|
1022
1022
|
if (!accounts.systemProgram.value) {
|
|
1023
1023
|
accounts.systemProgram.value = "11111111111111111111111111111111";
|
|
@@ -1196,7 +1196,10 @@ async function getWithdrawInstructionAsync(input, config) {
|
|
|
1196
1196
|
pool: { value: input.pool ?? null, isWritable: true },
|
|
1197
1197
|
vault: { value: input.vault ?? null, isWritable: true },
|
|
1198
1198
|
vaultAta: { value: input.vaultAta ?? null, isWritable: false },
|
|
1199
|
-
|
|
1199
|
+
authorityTokenAccount: {
|
|
1200
|
+
value: input.authorityTokenAccount ?? null,
|
|
1201
|
+
isWritable: true
|
|
1202
|
+
},
|
|
1200
1203
|
mint: { value: input.mint ?? null, isWritable: true },
|
|
1201
1204
|
systemProgram: { value: input.systemProgram ?? null, isWritable: false },
|
|
1202
1205
|
tokenProgram: { value: input.tokenProgram ?? null, isWritable: false },
|
|
@@ -1208,7 +1211,7 @@ async function getWithdrawInstructionAsync(input, config) {
|
|
|
1208
1211
|
const accounts = originalAccounts;
|
|
1209
1212
|
const args = { ...input };
|
|
1210
1213
|
if (!accounts.authority.value) {
|
|
1211
|
-
accounts.authority.value = "
|
|
1214
|
+
accounts.authority.value = "4kg8oh3jdNtn7j2wcS7TrUua31AgbLzDVkBZgTAe44aF";
|
|
1212
1215
|
}
|
|
1213
1216
|
if (!accounts.vault.value) {
|
|
1214
1217
|
accounts.vault.value = await kit.getProgramDerivedAddress({
|
|
@@ -1232,16 +1235,6 @@ async function getWithdrawInstructionAsync(input, config) {
|
|
|
1232
1235
|
]
|
|
1233
1236
|
});
|
|
1234
1237
|
}
|
|
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
1238
|
if (!accounts.systemProgram.value) {
|
|
1246
1239
|
accounts.systemProgram.value = "11111111111111111111111111111111";
|
|
1247
1240
|
}
|
|
@@ -1255,7 +1248,7 @@ async function getWithdrawInstructionAsync(input, config) {
|
|
|
1255
1248
|
getAccountMeta(accounts.pool),
|
|
1256
1249
|
getAccountMeta(accounts.vault),
|
|
1257
1250
|
getAccountMeta(accounts.vaultAta),
|
|
1258
|
-
getAccountMeta(accounts.
|
|
1251
|
+
getAccountMeta(accounts.authorityTokenAccount),
|
|
1259
1252
|
getAccountMeta(accounts.mint),
|
|
1260
1253
|
getAccountMeta(accounts.systemProgram),
|
|
1261
1254
|
getAccountMeta(accounts.tokenProgram),
|
|
@@ -1274,7 +1267,10 @@ function getWithdrawInstruction(input, config) {
|
|
|
1274
1267
|
pool: { value: input.pool ?? null, isWritable: true },
|
|
1275
1268
|
vault: { value: input.vault ?? null, isWritable: true },
|
|
1276
1269
|
vaultAta: { value: input.vaultAta ?? null, isWritable: false },
|
|
1277
|
-
|
|
1270
|
+
authorityTokenAccount: {
|
|
1271
|
+
value: input.authorityTokenAccount ?? null,
|
|
1272
|
+
isWritable: true
|
|
1273
|
+
},
|
|
1278
1274
|
mint: { value: input.mint ?? null, isWritable: true },
|
|
1279
1275
|
systemProgram: { value: input.systemProgram ?? null, isWritable: false },
|
|
1280
1276
|
tokenProgram: { value: input.tokenProgram ?? null, isWritable: false },
|
|
@@ -1286,7 +1282,7 @@ function getWithdrawInstruction(input, config) {
|
|
|
1286
1282
|
const accounts = originalAccounts;
|
|
1287
1283
|
const args = { ...input };
|
|
1288
1284
|
if (!accounts.authority.value) {
|
|
1289
|
-
accounts.authority.value = "
|
|
1285
|
+
accounts.authority.value = "4kg8oh3jdNtn7j2wcS7TrUua31AgbLzDVkBZgTAe44aF";
|
|
1290
1286
|
}
|
|
1291
1287
|
if (!accounts.tokenProgram.value) {
|
|
1292
1288
|
accounts.tokenProgram.value = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";
|
|
@@ -1304,7 +1300,7 @@ function getWithdrawInstruction(input, config) {
|
|
|
1304
1300
|
getAccountMeta(accounts.pool),
|
|
1305
1301
|
getAccountMeta(accounts.vault),
|
|
1306
1302
|
getAccountMeta(accounts.vaultAta),
|
|
1307
|
-
getAccountMeta(accounts.
|
|
1303
|
+
getAccountMeta(accounts.authorityTokenAccount),
|
|
1308
1304
|
getAccountMeta(accounts.mint),
|
|
1309
1305
|
getAccountMeta(accounts.systemProgram),
|
|
1310
1306
|
getAccountMeta(accounts.tokenProgram),
|
|
@@ -1326,6 +1322,10 @@ function parseWithdrawInstruction(instruction) {
|
|
|
1326
1322
|
accountIndex += 1;
|
|
1327
1323
|
return accountMeta;
|
|
1328
1324
|
};
|
|
1325
|
+
const getNextOptionalAccount = () => {
|
|
1326
|
+
const accountMeta = getNextAccount();
|
|
1327
|
+
return accountMeta.address === MIXOOR_PROGRAM_ADDRESS ? void 0 : accountMeta;
|
|
1328
|
+
};
|
|
1329
1329
|
return {
|
|
1330
1330
|
programAddress: instruction.programAddress,
|
|
1331
1331
|
accounts: {
|
|
@@ -1333,7 +1333,7 @@ function parseWithdrawInstruction(instruction) {
|
|
|
1333
1333
|
pool: getNextAccount(),
|
|
1334
1334
|
vault: getNextAccount(),
|
|
1335
1335
|
vaultAta: getNextAccount(),
|
|
1336
|
-
|
|
1336
|
+
authorityTokenAccount: getNextOptionalAccount(),
|
|
1337
1337
|
mint: getNextAccount(),
|
|
1338
1338
|
systemProgram: getNextAccount(),
|
|
1339
1339
|
tokenProgram: getNextAccount(),
|
|
@@ -1470,16 +1470,6 @@ async function generateProof(input) {
|
|
|
1470
1470
|
wasmPath,
|
|
1471
1471
|
zkeyPath
|
|
1472
1472
|
);
|
|
1473
|
-
const vKeyPath = path__namespace.join(packageRoot, "circuits/verification_key.json");
|
|
1474
|
-
const isValid = await snarkjs.groth16.verify(
|
|
1475
|
-
JSON.parse(fs__namespace.readFileSync(vKeyPath, "utf8")),
|
|
1476
|
-
publicSignals,
|
|
1477
|
-
proof
|
|
1478
|
-
);
|
|
1479
|
-
console.log("Local proof verification:", isValid ? "VALID \u2713" : "INVALID \u2717");
|
|
1480
|
-
if (!isValid) {
|
|
1481
|
-
throw new Error("Generated proof is invalid - check circuit inputs");
|
|
1482
|
-
}
|
|
1483
1473
|
const publicInputs = publicSignals.map(
|
|
1484
1474
|
(signal) => publicSignalToBytes(signal)
|
|
1485
1475
|
);
|
|
@@ -1662,6 +1652,7 @@ exports.MIXOOR_ERROR__INVALID_ASSET_TYPE = MIXOOR_ERROR__INVALID_ASSET_TYPE;
|
|
|
1662
1652
|
exports.MIXOOR_ERROR__INVALID_MERKLE_PROOF = MIXOOR_ERROR__INVALID_MERKLE_PROOF;
|
|
1663
1653
|
exports.MIXOOR_ERROR__INVALID_MERKLE_TREE = MIXOOR_ERROR__INVALID_MERKLE_TREE;
|
|
1664
1654
|
exports.MIXOOR_ERROR__INVALID_MERKLE_TREE_ADDRESS = MIXOOR_ERROR__INVALID_MERKLE_TREE_ADDRESS;
|
|
1655
|
+
exports.MIXOOR_ERROR__INVALID_MINT = MIXOOR_ERROR__INVALID_MINT;
|
|
1665
1656
|
exports.MIXOOR_ERROR__INVALID_PROOF = MIXOOR_ERROR__INVALID_PROOF;
|
|
1666
1657
|
exports.MIXOOR_ERROR__INVALID_PUBLIC_INPUTS = MIXOOR_ERROR__INVALID_PUBLIC_INPUTS;
|
|
1667
1658
|
exports.MIXOOR_ERROR__MERKLE_TREE_FULL = MIXOOR_ERROR__MERKLE_TREE_FULL;
|