@smithii_io/mixoor 0.0.8 → 0.0.10
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 +20 -15
- package/dist/src/index.js.map +1 -1
- package/dist/src/index.mjs +20 -16
- package/dist/src/index.mjs.map +1 -1
- package/dist/test/_setup.js +3 -10
- package/dist/test/_setup.js.map +1 -1
- package/dist/test/transfer.test.js +6 -7
- package/dist/test/transfer.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/transfer.d.ts +8 -8
- package/dist/types/src/generated/instructions/transfer.d.ts.map +1 -1
- package/dist/types/src/utils/circuit.d.ts +2 -2
- package/dist/types/src/utils/circuit.d.ts.map +1 -1
- package/dist/types/src/utils/pda.d.ts +2 -0
- package/dist/types/src/utils/pda.d.ts.map +1 -1
- package/dist/types/test/_setup.d.ts +1 -1
- package/dist/types/test/_setup.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/src/index.js
CHANGED
|
@@ -381,6 +381,7 @@ var MIXOOR_ERROR__INVALID_MERKLE_TREE = 6009;
|
|
|
381
381
|
var MIXOOR_ERROR__POSEIDON_HASH_ERROR = 6010;
|
|
382
382
|
var MIXOOR_ERROR__MERKLE_TREE_FULL = 6011;
|
|
383
383
|
var MIXOOR_ERROR__INVALID_MERKLE_PROOF = 6012;
|
|
384
|
+
var MIXOOR_ERROR__PUBLIC_INPUT_MISMATCH = 6013;
|
|
384
385
|
var mixoorErrorMessages;
|
|
385
386
|
if (process.env.NODE_ENV !== "production") {
|
|
386
387
|
mixoorErrorMessages = {
|
|
@@ -396,6 +397,7 @@ if (process.env.NODE_ENV !== "production") {
|
|
|
396
397
|
[MIXOOR_ERROR__MISSING_TOKEN_ACCOUNT]: `Missing token account`,
|
|
397
398
|
[MIXOOR_ERROR__OVERFLOW]: `Overflow`,
|
|
398
399
|
[MIXOOR_ERROR__POSEIDON_HASH_ERROR]: `Poseidon hash error`,
|
|
400
|
+
[MIXOOR_ERROR__PUBLIC_INPUT_MISMATCH]: `Public input does not match instruction parameter`,
|
|
399
401
|
[MIXOOR_ERROR__UNKNOWN_ROOT]: `Unknown merkle root`
|
|
400
402
|
};
|
|
401
403
|
}
|
|
@@ -846,8 +848,8 @@ function getTransferInstructionDataEncoder() {
|
|
|
846
848
|
kit.getArrayEncoder(kit.fixEncoderSize(kit.getBytesEncoder(), 32), { size: 7 })
|
|
847
849
|
],
|
|
848
850
|
["nullifierHash", kit.fixEncoderSize(kit.getBytesEncoder(), 32)],
|
|
849
|
-
["
|
|
850
|
-
["
|
|
851
|
+
["relayerFee", kit.getU64Encoder()],
|
|
852
|
+
["recipientAmount", kit.getU64Encoder()]
|
|
851
853
|
]),
|
|
852
854
|
(value) => ({ ...value, discriminator: TRANSFER_DISCRIMINATOR })
|
|
853
855
|
);
|
|
@@ -863,8 +865,8 @@ function getTransferInstructionDataDecoder() {
|
|
|
863
865
|
kit.getArrayDecoder(kit.fixDecoderSize(kit.getBytesDecoder(), 32), { size: 7 })
|
|
864
866
|
],
|
|
865
867
|
["nullifierHash", kit.fixDecoderSize(kit.getBytesDecoder(), 32)],
|
|
866
|
-
["
|
|
867
|
-
["
|
|
868
|
+
["relayerFee", kit.getU64Decoder()],
|
|
869
|
+
["recipientAmount", kit.getU64Decoder()]
|
|
868
870
|
]);
|
|
869
871
|
}
|
|
870
872
|
function getTransferInstructionDataCodec() {
|
|
@@ -920,6 +922,7 @@ async function getTransferInstructionAsync(input, config) {
|
|
|
920
922
|
kit.getBytesEncoder().encode(
|
|
921
923
|
new Uint8Array([110, 117, 108, 108, 105, 102, 105, 101, 114])
|
|
922
924
|
),
|
|
925
|
+
kit.getAddressEncoder().encode(expectAddress(accounts.pool.value)),
|
|
923
926
|
kit.fixEncoderSize(kit.getBytesEncoder(), 32).encode(
|
|
924
927
|
expectSome(args.nullifierHash)
|
|
925
928
|
)
|
|
@@ -1191,8 +1194,13 @@ async function generateProof(input) {
|
|
|
1191
1194
|
pathIndices: input.pathIndices,
|
|
1192
1195
|
amount: BigInt(input.amount).toString()
|
|
1193
1196
|
};
|
|
1194
|
-
|
|
1195
|
-
|
|
1197
|
+
let __dirname;
|
|
1198
|
+
if (typeof __filename !== "undefined") {
|
|
1199
|
+
__dirname = path__namespace.dirname(__filename);
|
|
1200
|
+
} else {
|
|
1201
|
+
const __filename_esm = url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.js', document.baseURI).href)));
|
|
1202
|
+
__dirname = path__namespace.dirname(__filename_esm);
|
|
1203
|
+
}
|
|
1196
1204
|
const packageRoot = path__namespace.join(__dirname, "../..");
|
|
1197
1205
|
const wasmPath = path__namespace.join(
|
|
1198
1206
|
packageRoot,
|
|
@@ -1217,14 +1225,6 @@ async function generateProof(input) {
|
|
|
1217
1225
|
const publicInputs = publicSignals.map(
|
|
1218
1226
|
(signal) => publicSignalToBytes(signal)
|
|
1219
1227
|
);
|
|
1220
|
-
console.log(
|
|
1221
|
-
"DEBUG: Generated Public Inputs (Keys: root, nullifierHash, recipient, relayer, fee, refund, poolId):"
|
|
1222
|
-
);
|
|
1223
|
-
publicInputs.forEach((input2, i) => {
|
|
1224
|
-
const hexBE = Buffer.from(input2).toString("hex");
|
|
1225
|
-
const hexLE = Buffer.from(input2.slice().reverse()).toString("hex");
|
|
1226
|
-
console.log(`Input ${i}: BE=${hexBE} | LE=${hexLE}`);
|
|
1227
|
-
});
|
|
1228
1228
|
const proof_a = g1PointToBytes([proof.pi_a[0], proof.pi_a[1]]);
|
|
1229
1229
|
const proof_b = g2PointToBytes([
|
|
1230
1230
|
[proof.pi_b[0][0], proof.pi_b[0][1]],
|
|
@@ -1383,7 +1383,11 @@ async function findNullifierAddress(seeds, config = {}) {
|
|
|
1383
1383
|
const { programAddress = MIXOOR_PROGRAM_ADDRESS } = config;
|
|
1384
1384
|
return await kit.getProgramDerivedAddress({
|
|
1385
1385
|
programAddress,
|
|
1386
|
-
seeds: [
|
|
1386
|
+
seeds: [
|
|
1387
|
+
"nullifier",
|
|
1388
|
+
kit.getAddressEncoder().encode(seeds.pool),
|
|
1389
|
+
seeds.nullifierHash
|
|
1390
|
+
]
|
|
1387
1391
|
});
|
|
1388
1392
|
}
|
|
1389
1393
|
|
|
@@ -1402,6 +1406,7 @@ exports.MIXOOR_ERROR__MERKLE_TREE_FULL = MIXOOR_ERROR__MERKLE_TREE_FULL;
|
|
|
1402
1406
|
exports.MIXOOR_ERROR__MISSING_TOKEN_ACCOUNT = MIXOOR_ERROR__MISSING_TOKEN_ACCOUNT;
|
|
1403
1407
|
exports.MIXOOR_ERROR__OVERFLOW = MIXOOR_ERROR__OVERFLOW;
|
|
1404
1408
|
exports.MIXOOR_ERROR__POSEIDON_HASH_ERROR = MIXOOR_ERROR__POSEIDON_HASH_ERROR;
|
|
1409
|
+
exports.MIXOOR_ERROR__PUBLIC_INPUT_MISMATCH = MIXOOR_ERROR__PUBLIC_INPUT_MISMATCH;
|
|
1405
1410
|
exports.MIXOOR_ERROR__UNKNOWN_ROOT = MIXOOR_ERROR__UNKNOWN_ROOT;
|
|
1406
1411
|
exports.MIXOOR_PROGRAM_ADDRESS = MIXOOR_PROGRAM_ADDRESS;
|
|
1407
1412
|
exports.MerkleTree = MerkleTree;
|