@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.
@@ -357,6 +357,7 @@ var MIXOOR_ERROR__INVALID_MERKLE_TREE = 6009;
357
357
  var MIXOOR_ERROR__POSEIDON_HASH_ERROR = 6010;
358
358
  var MIXOOR_ERROR__MERKLE_TREE_FULL = 6011;
359
359
  var MIXOOR_ERROR__INVALID_MERKLE_PROOF = 6012;
360
+ var MIXOOR_ERROR__PUBLIC_INPUT_MISMATCH = 6013;
360
361
  var mixoorErrorMessages;
361
362
  if (process.env.NODE_ENV !== "production") {
362
363
  mixoorErrorMessages = {
@@ -372,6 +373,7 @@ if (process.env.NODE_ENV !== "production") {
372
373
  [MIXOOR_ERROR__MISSING_TOKEN_ACCOUNT]: `Missing token account`,
373
374
  [MIXOOR_ERROR__OVERFLOW]: `Overflow`,
374
375
  [MIXOOR_ERROR__POSEIDON_HASH_ERROR]: `Poseidon hash error`,
376
+ [MIXOOR_ERROR__PUBLIC_INPUT_MISMATCH]: `Public input does not match instruction parameter`,
375
377
  [MIXOOR_ERROR__UNKNOWN_ROOT]: `Unknown merkle root`
376
378
  };
377
379
  }
@@ -822,8 +824,8 @@ function getTransferInstructionDataEncoder() {
822
824
  getArrayEncoder(fixEncoderSize(getBytesEncoder(), 32), { size: 7 })
823
825
  ],
824
826
  ["nullifierHash", fixEncoderSize(getBytesEncoder(), 32)],
825
- ["amount", getU64Encoder()],
826
- ["fee", getU64Encoder()]
827
+ ["relayerFee", getU64Encoder()],
828
+ ["recipientAmount", getU64Encoder()]
827
829
  ]),
828
830
  (value) => ({ ...value, discriminator: TRANSFER_DISCRIMINATOR })
829
831
  );
@@ -839,8 +841,8 @@ function getTransferInstructionDataDecoder() {
839
841
  getArrayDecoder(fixDecoderSize(getBytesDecoder(), 32), { size: 7 })
840
842
  ],
841
843
  ["nullifierHash", fixDecoderSize(getBytesDecoder(), 32)],
842
- ["amount", getU64Decoder()],
843
- ["fee", getU64Decoder()]
844
+ ["relayerFee", getU64Decoder()],
845
+ ["recipientAmount", getU64Decoder()]
844
846
  ]);
845
847
  }
846
848
  function getTransferInstructionDataCodec() {
@@ -896,6 +898,7 @@ async function getTransferInstructionAsync(input, config) {
896
898
  getBytesEncoder().encode(
897
899
  new Uint8Array([110, 117, 108, 108, 105, 102, 105, 101, 114])
898
900
  ),
901
+ getAddressEncoder().encode(expectAddress(accounts.pool.value)),
899
902
  fixEncoderSize(getBytesEncoder(), 32).encode(
900
903
  expectSome(args.nullifierHash)
901
904
  )
@@ -1167,8 +1170,13 @@ async function generateProof(input) {
1167
1170
  pathIndices: input.pathIndices,
1168
1171
  amount: BigInt(input.amount).toString()
1169
1172
  };
1170
- const __filename = fileURLToPath(import.meta.url);
1171
- const __dirname = path.dirname(__filename);
1173
+ let __dirname;
1174
+ if (typeof __filename !== "undefined") {
1175
+ __dirname = path.dirname(__filename);
1176
+ } else {
1177
+ const __filename_esm = fileURLToPath(import.meta.url);
1178
+ __dirname = path.dirname(__filename_esm);
1179
+ }
1172
1180
  const packageRoot = path.join(__dirname, "../..");
1173
1181
  const wasmPath = path.join(
1174
1182
  packageRoot,
@@ -1193,14 +1201,6 @@ async function generateProof(input) {
1193
1201
  const publicInputs = publicSignals.map(
1194
1202
  (signal) => publicSignalToBytes(signal)
1195
1203
  );
1196
- console.log(
1197
- "DEBUG: Generated Public Inputs (Keys: root, nullifierHash, recipient, relayer, fee, refund, poolId):"
1198
- );
1199
- publicInputs.forEach((input2, i) => {
1200
- const hexBE = Buffer.from(input2).toString("hex");
1201
- const hexLE = Buffer.from(input2.slice().reverse()).toString("hex");
1202
- console.log(`Input ${i}: BE=${hexBE} | LE=${hexLE}`);
1203
- });
1204
1204
  const proof_a = g1PointToBytes([proof.pi_a[0], proof.pi_a[1]]);
1205
1205
  const proof_b = g2PointToBytes([
1206
1206
  [proof.pi_b[0][0], proof.pi_b[0][1]],
@@ -1359,10 +1359,14 @@ async function findNullifierAddress(seeds, config = {}) {
1359
1359
  const { programAddress = MIXOOR_PROGRAM_ADDRESS } = config;
1360
1360
  return await getProgramDerivedAddress({
1361
1361
  programAddress,
1362
- seeds: ["nullifier", seeds.nullifierHash]
1362
+ seeds: [
1363
+ "nullifier",
1364
+ getAddressEncoder().encode(seeds.pool),
1365
+ seeds.nullifierHash
1366
+ ]
1363
1367
  });
1364
1368
  }
1365
1369
 
1366
- 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__UNKNOWN_ROOT, MIXOOR_PROGRAM_ADDRESS, MerkleTree, MixoorAccount, MixoorInstruction, NULLIFIER_ACCOUNT_DISCRIMINATOR, POOL_DISCRIMINATOR, TRANSFER_DISCRIMINATOR, VAULT_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, identifyMixoorAccount, identifyMixoorInstruction, isMixoorError, parseDepositInstruction, parseInitializePoolInstruction, parseTransferInstruction, poseidonHash, randomBytes, toHex };
1370
+ 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, 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, identifyMixoorAccount, identifyMixoorInstruction, isMixoorError, parseDepositInstruction, parseInitializePoolInstruction, parseTransferInstruction, poseidonHash, randomBytes, toHex };
1367
1371
  //# sourceMappingURL=index.mjs.map
1368
1372
  //# sourceMappingURL=index.mjs.map