@smithii_io/mixoor 0.0.9 → 0.0.11
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/circuits/build/transaction_js/transaction.wasm +0 -0
- package/circuits/transaction_0001.zkey +0 -0
- package/circuits/verification_key.json +108 -117
- package/dist/src/index.js +24 -19
- package/dist/src/index.js.map +1 -1
- package/dist/src/index.mjs +25 -21
- package/dist/src/index.mjs.map +1 -1
- package/dist/test/_create.test.js +4 -2
- package/dist/test/_create.test.js.map +1 -1
- package/dist/test/_deposit.test.js +3 -1
- package/dist/test/_deposit.test.js.map +1 -1
- package/dist/test/_setup.js +9 -14
- package/dist/test/_setup.js.map +1 -1
- package/dist/test/transfer.test.js +12 -9
- 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/initializePool.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/generated/programs/mixoor.d.ts +2 -2
- 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 +5 -0
- package/dist/types/src/utils/pda.d.ts.map +1 -1
- package/dist/types/test/_setup.d.ts +4 -3
- package/dist/types/test/_setup.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/src/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { fixEncoderSize, getBytesEncoder, transformEncoder, getStructEncoder, getI64Encoder, getStructDecoder, fixDecoderSize, getI64Decoder, getBytesDecoder, combineCodec, decodeAccount, assertAccountExists, fetchEncodedAccount, assertAccountsExist, fetchEncodedAccounts, getEnumEncoder, getEnumDecoder, getU32Encoder, getAddressEncoder, getU32Decoder, getAddressDecoder, getArrayEncoder, getU64Encoder, getU8Encoder, getArrayDecoder, getU64Decoder, getU8Decoder, containsBytes, isProgramError, getProgramDerivedAddress, AccountRole, upgradeRoleToSigner, isTransactionSigner as isTransactionSigner$1 } from '@solana/kit';
|
|
1
|
+
import { fixEncoderSize, getBytesEncoder, transformEncoder, getStructEncoder, getI64Encoder, getStructDecoder, fixDecoderSize, getI64Decoder, getBytesDecoder, combineCodec, decodeAccount, assertAccountExists, fetchEncodedAccount, assertAccountsExist, fetchEncodedAccounts, getEnumEncoder, getEnumDecoder, getU32Encoder, getAddressEncoder, getU32Decoder, getAddressDecoder, getArrayEncoder, getU64Encoder, getU8Encoder, getArrayDecoder, getU64Decoder, getU8Decoder, containsBytes, isProgramError, getProgramDerivedAddress, getEnumCodec, AccountRole, upgradeRoleToSigner, isTransactionSigner as isTransactionSigner$1 } from '@solana/kit';
|
|
2
2
|
import { buildPoseidon } from 'circomlibjs';
|
|
3
3
|
import * as fs from 'fs';
|
|
4
4
|
import * as path from 'path';
|
|
@@ -150,7 +150,7 @@ function getPoolEncoder() {
|
|
|
150
150
|
["mint", getAddressEncoder()],
|
|
151
151
|
["vault", getAddressEncoder()],
|
|
152
152
|
["feeCollector", getAddressEncoder()],
|
|
153
|
-
["rootHistory", getArrayEncoder(getRootEntryEncoder(), { size:
|
|
153
|
+
["rootHistory", getArrayEncoder(getRootEntryEncoder(), { size: 50 })],
|
|
154
154
|
["totalDeposited", getU64Encoder()],
|
|
155
155
|
["totalWithdrawn", getU64Encoder()],
|
|
156
156
|
["nextLeafIndex", getU32Encoder()],
|
|
@@ -169,7 +169,7 @@ function getPoolDecoder() {
|
|
|
169
169
|
["mint", getAddressDecoder()],
|
|
170
170
|
["vault", getAddressDecoder()],
|
|
171
171
|
["feeCollector", getAddressDecoder()],
|
|
172
|
-
["rootHistory", getArrayDecoder(getRootEntryDecoder(), { size:
|
|
172
|
+
["rootHistory", getArrayDecoder(getRootEntryDecoder(), { size: 50 })],
|
|
173
173
|
["totalDeposited", getU64Decoder()],
|
|
174
174
|
["totalWithdrawn", getU64Decoder()],
|
|
175
175
|
["nextLeafIndex", getU32Decoder()],
|
|
@@ -207,7 +207,7 @@ async function fetchAllMaybePool(rpc, addresses, config) {
|
|
|
207
207
|
return maybeAccounts.map((maybeAccount) => decodePool(maybeAccount));
|
|
208
208
|
}
|
|
209
209
|
function getPoolSize() {
|
|
210
|
-
return
|
|
210
|
+
return 2160;
|
|
211
211
|
}
|
|
212
212
|
var VAULT_DISCRIMINATOR = new Uint8Array([
|
|
213
213
|
211,
|
|
@@ -263,7 +263,7 @@ async function fetchAllMaybeVault(rpc, addresses, config) {
|
|
|
263
263
|
function getVaultSize() {
|
|
264
264
|
return 8;
|
|
265
265
|
}
|
|
266
|
-
var MIXOOR_PROGRAM_ADDRESS = "
|
|
266
|
+
var MIXOOR_PROGRAM_ADDRESS = "mixEcfx7w47hvRwb9Nj7UeSQkCz6vZMbRHixMyYMLMb";
|
|
267
267
|
var MixoorAccount = /* @__PURE__ */ ((MixoorAccount2) => {
|
|
268
268
|
MixoorAccount2[MixoorAccount2["NullifierAccount"] = 0] = "NullifierAccount";
|
|
269
269
|
MixoorAccount2[MixoorAccount2["Pool"] = 1] = "Pool";
|
|
@@ -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
|
}
|
|
@@ -668,7 +670,8 @@ async function getInitializePoolInstructionAsync(input, config) {
|
|
|
668
670
|
programAddress,
|
|
669
671
|
seeds: [
|
|
670
672
|
getBytesEncoder().encode(new Uint8Array([112, 111, 111, 108])),
|
|
671
|
-
getAddressEncoder().encode(expectAddress(accounts.mint.value))
|
|
673
|
+
getAddressEncoder().encode(expectAddress(accounts.mint.value)),
|
|
674
|
+
getAssetTypeEncoder().encode(expectSome(args.assetType))
|
|
672
675
|
]
|
|
673
676
|
});
|
|
674
677
|
}
|
|
@@ -822,8 +825,8 @@ function getTransferInstructionDataEncoder() {
|
|
|
822
825
|
getArrayEncoder(fixEncoderSize(getBytesEncoder(), 32), { size: 7 })
|
|
823
826
|
],
|
|
824
827
|
["nullifierHash", fixEncoderSize(getBytesEncoder(), 32)],
|
|
825
|
-
["
|
|
826
|
-
["
|
|
828
|
+
["relayerFee", getU64Encoder()],
|
|
829
|
+
["recipientAmount", getU64Encoder()]
|
|
827
830
|
]),
|
|
828
831
|
(value) => ({ ...value, discriminator: TRANSFER_DISCRIMINATOR })
|
|
829
832
|
);
|
|
@@ -839,8 +842,8 @@ function getTransferInstructionDataDecoder() {
|
|
|
839
842
|
getArrayDecoder(fixDecoderSize(getBytesDecoder(), 32), { size: 7 })
|
|
840
843
|
],
|
|
841
844
|
["nullifierHash", fixDecoderSize(getBytesDecoder(), 32)],
|
|
842
|
-
["
|
|
843
|
-
["
|
|
845
|
+
["relayerFee", getU64Decoder()],
|
|
846
|
+
["recipientAmount", getU64Decoder()]
|
|
844
847
|
]);
|
|
845
848
|
}
|
|
846
849
|
function getTransferInstructionDataCodec() {
|
|
@@ -896,6 +899,7 @@ async function getTransferInstructionAsync(input, config) {
|
|
|
896
899
|
getBytesEncoder().encode(
|
|
897
900
|
new Uint8Array([110, 117, 108, 108, 105, 102, 105, 101, 114])
|
|
898
901
|
),
|
|
902
|
+
getAddressEncoder().encode(expectAddress(accounts.pool.value)),
|
|
899
903
|
fixEncoderSize(getBytesEncoder(), 32).encode(
|
|
900
904
|
expectSome(args.nullifierHash)
|
|
901
905
|
)
|
|
@@ -1198,14 +1202,6 @@ async function generateProof(input) {
|
|
|
1198
1202
|
const publicInputs = publicSignals.map(
|
|
1199
1203
|
(signal) => publicSignalToBytes(signal)
|
|
1200
1204
|
);
|
|
1201
|
-
console.log(
|
|
1202
|
-
"DEBUG: Generated Public Inputs (Keys: root, nullifierHash, recipient, relayer, fee, refund, poolId):"
|
|
1203
|
-
);
|
|
1204
|
-
publicInputs.forEach((input2, i) => {
|
|
1205
|
-
const hexBE = Buffer.from(input2).toString("hex");
|
|
1206
|
-
const hexLE = Buffer.from(input2.slice().reverse()).toString("hex");
|
|
1207
|
-
console.log(`Input ${i}: BE=${hexBE} | LE=${hexLE}`);
|
|
1208
|
-
});
|
|
1209
1205
|
const proof_a = g1PointToBytes([proof.pi_a[0], proof.pi_a[1]]);
|
|
1210
1206
|
const proof_b = g2PointToBytes([
|
|
1211
1207
|
[proof.pi_b[0][0], proof.pi_b[0][1]],
|
|
@@ -1343,7 +1339,11 @@ async function findPoolAddress(seeds, config = {}) {
|
|
|
1343
1339
|
const { programAddress = MIXOOR_PROGRAM_ADDRESS } = config;
|
|
1344
1340
|
return await getProgramDerivedAddress({
|
|
1345
1341
|
programAddress,
|
|
1346
|
-
seeds: [
|
|
1342
|
+
seeds: [
|
|
1343
|
+
"pool",
|
|
1344
|
+
getAddressEncoder().encode(seeds.mint),
|
|
1345
|
+
getEnumCodec(AssetType).encode(seeds.assetType)
|
|
1346
|
+
]
|
|
1347
1347
|
});
|
|
1348
1348
|
}
|
|
1349
1349
|
async function findMerkleTreeAddress(seeds, config = {}) {
|
|
@@ -1364,10 +1364,14 @@ async function findNullifierAddress(seeds, config = {}) {
|
|
|
1364
1364
|
const { programAddress = MIXOOR_PROGRAM_ADDRESS } = config;
|
|
1365
1365
|
return await getProgramDerivedAddress({
|
|
1366
1366
|
programAddress,
|
|
1367
|
-
seeds: [
|
|
1367
|
+
seeds: [
|
|
1368
|
+
"nullifier",
|
|
1369
|
+
getAddressEncoder().encode(seeds.pool),
|
|
1370
|
+
seeds.nullifierHash
|
|
1371
|
+
]
|
|
1368
1372
|
});
|
|
1369
1373
|
}
|
|
1370
1374
|
|
|
1371
|
-
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 };
|
|
1375
|
+
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 };
|
|
1372
1376
|
//# sourceMappingURL=index.mjs.map
|
|
1373
1377
|
//# sourceMappingURL=index.mjs.map
|