@smithii_io/mixoor 0.0.1
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/README.md +38 -0
- package/dist/src/index.js +1484 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/index.mjs +1363 -0
- package/dist/src/index.mjs.map +1 -0
- package/dist/types/src/generated/accounts/index.d.ts +11 -0
- package/dist/types/src/generated/accounts/index.d.ts.map +1 -0
- package/dist/types/src/generated/accounts/nullifierAccount.d.ts +33 -0
- package/dist/types/src/generated/accounts/nullifierAccount.d.ts.map +1 -0
- package/dist/types/src/generated/accounts/pool.d.ts +54 -0
- package/dist/types/src/generated/accounts/pool.d.ts.map +1 -0
- package/dist/types/src/generated/accounts/vault.d.ts +28 -0
- package/dist/types/src/generated/accounts/vault.d.ts.map +1 -0
- package/dist/types/src/generated/errors/index.d.ts +9 -0
- package/dist/types/src/generated/errors/index.d.ts.map +1 -0
- package/dist/types/src/generated/errors/mixoor.d.ts +46 -0
- package/dist/types/src/generated/errors/mixoor.d.ts.map +1 -0
- package/dist/types/src/generated/index.d.ts +13 -0
- package/dist/types/src/generated/index.d.ts.map +1 -0
- package/dist/types/src/generated/instructions/deposit.d.ts +88 -0
- package/dist/types/src/generated/instructions/deposit.d.ts.map +1 -0
- package/dist/types/src/generated/instructions/index.d.ts +11 -0
- package/dist/types/src/generated/instructions/index.d.ts.map +1 -0
- package/dist/types/src/generated/instructions/initializePool.d.ts +81 -0
- package/dist/types/src/generated/instructions/initializePool.d.ts.map +1 -0
- package/dist/types/src/generated/instructions/transfer.d.ts +120 -0
- package/dist/types/src/generated/instructions/transfer.d.ts.map +1 -0
- package/dist/types/src/generated/programs/index.d.ts +9 -0
- package/dist/types/src/generated/programs/index.d.ts.map +1 -0
- package/dist/types/src/generated/programs/mixoor.d.ts +34 -0
- package/dist/types/src/generated/programs/mixoor.d.ts.map +1 -0
- package/dist/types/src/generated/shared/index.d.ts +50 -0
- package/dist/types/src/generated/shared/index.d.ts.map +1 -0
- package/dist/types/src/generated/types/assetType.d.ts +17 -0
- package/dist/types/src/generated/types/assetType.d.ts.map +1 -0
- package/dist/types/src/generated/types/commitmentInserted.d.ts +18 -0
- package/dist/types/src/generated/types/commitmentInserted.d.ts.map +1 -0
- package/dist/types/src/generated/types/index.d.ts +11 -0
- package/dist/types/src/generated/types/index.d.ts.map +1 -0
- package/dist/types/src/generated/types/rootEntry.d.ts +20 -0
- package/dist/types/src/generated/types/rootEntry.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +3 -0
- package/dist/types/src/index.d.ts.map +1 -0
- package/dist/types/src/utils/circuit.d.ts +32 -0
- package/dist/types/src/utils/circuit.d.ts.map +1 -0
- package/dist/types/src/utils/crypto.d.ts +4 -0
- package/dist/types/src/utils/crypto.d.ts.map +1 -0
- package/dist/types/src/utils/index.d.ts +5 -0
- package/dist/types/src/utils/index.d.ts.map +1 -0
- package/dist/types/src/utils/merkle.d.ts +33 -0
- package/dist/types/src/utils/merkle.d.ts.map +1 -0
- package/dist/types/src/utils/pda.d.ts +29 -0
- package/dist/types/src/utils/pda.d.ts.map +1 -0
- package/dist/types/test/_constants.d.ts +4 -0
- package/dist/types/test/_constants.d.ts.map +1 -0
- package/dist/types/test/_setup.d.ts +49 -0
- package/dist/types/test/_setup.d.ts.map +1 -0
- package/package.json +87 -0
|
@@ -0,0 +1,1484 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var kit = require('@solana/kit');
|
|
4
|
+
var circomlibjs = require('circomlibjs');
|
|
5
|
+
var fs = require('fs');
|
|
6
|
+
var path = require('path');
|
|
7
|
+
var snarkjs = require('snarkjs');
|
|
8
|
+
var crypto = require('crypto');
|
|
9
|
+
|
|
10
|
+
function _interopNamespace(e) {
|
|
11
|
+
if (e && e.__esModule) return e;
|
|
12
|
+
var n = Object.create(null);
|
|
13
|
+
if (e) {
|
|
14
|
+
Object.keys(e).forEach(function (k) {
|
|
15
|
+
if (k !== 'default') {
|
|
16
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
17
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: function () { return e[k]; }
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
n.default = e;
|
|
25
|
+
return Object.freeze(n);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
var fs__namespace = /*#__PURE__*/_interopNamespace(fs);
|
|
29
|
+
var path__namespace = /*#__PURE__*/_interopNamespace(path);
|
|
30
|
+
|
|
31
|
+
// src/generated/accounts/nullifierAccount.ts
|
|
32
|
+
var NULLIFIER_ACCOUNT_DISCRIMINATOR = new Uint8Array([
|
|
33
|
+
250,
|
|
34
|
+
31,
|
|
35
|
+
238,
|
|
36
|
+
177,
|
|
37
|
+
213,
|
|
38
|
+
98,
|
|
39
|
+
48,
|
|
40
|
+
172
|
|
41
|
+
]);
|
|
42
|
+
function getNullifierAccountDiscriminatorBytes() {
|
|
43
|
+
return kit.fixEncoderSize(kit.getBytesEncoder(), 8).encode(
|
|
44
|
+
NULLIFIER_ACCOUNT_DISCRIMINATOR
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
function getNullifierAccountEncoder() {
|
|
48
|
+
return kit.transformEncoder(
|
|
49
|
+
kit.getStructEncoder([
|
|
50
|
+
["discriminator", kit.fixEncoderSize(kit.getBytesEncoder(), 8)],
|
|
51
|
+
["nullifierHash", kit.fixEncoderSize(kit.getBytesEncoder(), 32)],
|
|
52
|
+
["spentAt", kit.getI64Encoder()]
|
|
53
|
+
]),
|
|
54
|
+
(value) => ({ ...value, discriminator: NULLIFIER_ACCOUNT_DISCRIMINATOR })
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
function getNullifierAccountDecoder() {
|
|
58
|
+
return kit.getStructDecoder([
|
|
59
|
+
["discriminator", kit.fixDecoderSize(kit.getBytesDecoder(), 8)],
|
|
60
|
+
["nullifierHash", kit.fixDecoderSize(kit.getBytesDecoder(), 32)],
|
|
61
|
+
["spentAt", kit.getI64Decoder()]
|
|
62
|
+
]);
|
|
63
|
+
}
|
|
64
|
+
function getNullifierAccountCodec() {
|
|
65
|
+
return kit.combineCodec(
|
|
66
|
+
getNullifierAccountEncoder(),
|
|
67
|
+
getNullifierAccountDecoder()
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
function decodeNullifierAccount(encodedAccount) {
|
|
71
|
+
return kit.decodeAccount(
|
|
72
|
+
encodedAccount,
|
|
73
|
+
getNullifierAccountDecoder()
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
async function fetchNullifierAccount(rpc, address, config) {
|
|
77
|
+
const maybeAccount = await fetchMaybeNullifierAccount(rpc, address, config);
|
|
78
|
+
kit.assertAccountExists(maybeAccount);
|
|
79
|
+
return maybeAccount;
|
|
80
|
+
}
|
|
81
|
+
async function fetchMaybeNullifierAccount(rpc, address, config) {
|
|
82
|
+
const maybeAccount = await kit.fetchEncodedAccount(rpc, address, config);
|
|
83
|
+
return decodeNullifierAccount(maybeAccount);
|
|
84
|
+
}
|
|
85
|
+
async function fetchAllNullifierAccount(rpc, addresses, config) {
|
|
86
|
+
const maybeAccounts = await fetchAllMaybeNullifierAccount(
|
|
87
|
+
rpc,
|
|
88
|
+
addresses,
|
|
89
|
+
config
|
|
90
|
+
);
|
|
91
|
+
kit.assertAccountsExist(maybeAccounts);
|
|
92
|
+
return maybeAccounts;
|
|
93
|
+
}
|
|
94
|
+
async function fetchAllMaybeNullifierAccount(rpc, addresses, config) {
|
|
95
|
+
const maybeAccounts = await kit.fetchEncodedAccounts(rpc, addresses, config);
|
|
96
|
+
return maybeAccounts.map(
|
|
97
|
+
(maybeAccount) => decodeNullifierAccount(maybeAccount)
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
function getNullifierAccountSize() {
|
|
101
|
+
return 48;
|
|
102
|
+
}
|
|
103
|
+
var AssetType = /* @__PURE__ */ ((AssetType2) => {
|
|
104
|
+
AssetType2[AssetType2["Sol"] = 0] = "Sol";
|
|
105
|
+
AssetType2[AssetType2["SplToken"] = 1] = "SplToken";
|
|
106
|
+
return AssetType2;
|
|
107
|
+
})(AssetType || {});
|
|
108
|
+
function getAssetTypeEncoder() {
|
|
109
|
+
return kit.getEnumEncoder(AssetType);
|
|
110
|
+
}
|
|
111
|
+
function getAssetTypeDecoder() {
|
|
112
|
+
return kit.getEnumDecoder(AssetType);
|
|
113
|
+
}
|
|
114
|
+
function getAssetTypeCodec() {
|
|
115
|
+
return kit.combineCodec(getAssetTypeEncoder(), getAssetTypeDecoder());
|
|
116
|
+
}
|
|
117
|
+
function getCommitmentInsertedEncoder() {
|
|
118
|
+
return kit.getStructEncoder([
|
|
119
|
+
["commitment", kit.fixEncoderSize(kit.getBytesEncoder(), 32)],
|
|
120
|
+
["leafIndex", kit.getU32Encoder()],
|
|
121
|
+
["pool", kit.getAddressEncoder()]
|
|
122
|
+
]);
|
|
123
|
+
}
|
|
124
|
+
function getCommitmentInsertedDecoder() {
|
|
125
|
+
return kit.getStructDecoder([
|
|
126
|
+
["commitment", kit.fixDecoderSize(kit.getBytesDecoder(), 32)],
|
|
127
|
+
["leafIndex", kit.getU32Decoder()],
|
|
128
|
+
["pool", kit.getAddressDecoder()]
|
|
129
|
+
]);
|
|
130
|
+
}
|
|
131
|
+
function getCommitmentInsertedCodec() {
|
|
132
|
+
return kit.combineCodec(
|
|
133
|
+
getCommitmentInsertedEncoder(),
|
|
134
|
+
getCommitmentInsertedDecoder()
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
function getRootEntryEncoder() {
|
|
138
|
+
return kit.getStructEncoder([
|
|
139
|
+
["root", kit.fixEncoderSize(kit.getBytesEncoder(), 32)],
|
|
140
|
+
["timestamp", kit.getI64Encoder()]
|
|
141
|
+
]);
|
|
142
|
+
}
|
|
143
|
+
function getRootEntryDecoder() {
|
|
144
|
+
return kit.getStructDecoder([
|
|
145
|
+
["root", kit.fixDecoderSize(kit.getBytesDecoder(), 32)],
|
|
146
|
+
["timestamp", kit.getI64Decoder()]
|
|
147
|
+
]);
|
|
148
|
+
}
|
|
149
|
+
function getRootEntryCodec() {
|
|
150
|
+
return kit.combineCodec(getRootEntryEncoder(), getRootEntryDecoder());
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
// src/generated/accounts/pool.ts
|
|
154
|
+
var POOL_DISCRIMINATOR = new Uint8Array([
|
|
155
|
+
241,
|
|
156
|
+
154,
|
|
157
|
+
109,
|
|
158
|
+
4,
|
|
159
|
+
17,
|
|
160
|
+
177,
|
|
161
|
+
109,
|
|
162
|
+
188
|
|
163
|
+
]);
|
|
164
|
+
function getPoolDiscriminatorBytes() {
|
|
165
|
+
return kit.fixEncoderSize(kit.getBytesEncoder(), 8).encode(POOL_DISCRIMINATOR);
|
|
166
|
+
}
|
|
167
|
+
function getPoolEncoder() {
|
|
168
|
+
return kit.transformEncoder(
|
|
169
|
+
kit.getStructEncoder([
|
|
170
|
+
["discriminator", kit.fixEncoderSize(kit.getBytesEncoder(), 8)],
|
|
171
|
+
["authority", kit.getAddressEncoder()],
|
|
172
|
+
["mint", kit.getAddressEncoder()],
|
|
173
|
+
["vault", kit.getAddressEncoder()],
|
|
174
|
+
["feeCollector", kit.getAddressEncoder()],
|
|
175
|
+
["rootHistory", kit.getArrayEncoder(getRootEntryEncoder(), { size: 30 })],
|
|
176
|
+
["totalDeposited", kit.getU64Encoder()],
|
|
177
|
+
["totalWithdrawn", kit.getU64Encoder()],
|
|
178
|
+
["nextLeafIndex", kit.getU32Encoder()],
|
|
179
|
+
["assetType", kit.getU8Encoder()],
|
|
180
|
+
["rootHistoryIndex", kit.getU8Encoder()],
|
|
181
|
+
["bump", kit.getU8Encoder()],
|
|
182
|
+
["padding", kit.fixEncoderSize(kit.getBytesEncoder(), 1)]
|
|
183
|
+
]),
|
|
184
|
+
(value) => ({ ...value, discriminator: POOL_DISCRIMINATOR })
|
|
185
|
+
);
|
|
186
|
+
}
|
|
187
|
+
function getPoolDecoder() {
|
|
188
|
+
return kit.getStructDecoder([
|
|
189
|
+
["discriminator", kit.fixDecoderSize(kit.getBytesDecoder(), 8)],
|
|
190
|
+
["authority", kit.getAddressDecoder()],
|
|
191
|
+
["mint", kit.getAddressDecoder()],
|
|
192
|
+
["vault", kit.getAddressDecoder()],
|
|
193
|
+
["feeCollector", kit.getAddressDecoder()],
|
|
194
|
+
["rootHistory", kit.getArrayDecoder(getRootEntryDecoder(), { size: 30 })],
|
|
195
|
+
["totalDeposited", kit.getU64Decoder()],
|
|
196
|
+
["totalWithdrawn", kit.getU64Decoder()],
|
|
197
|
+
["nextLeafIndex", kit.getU32Decoder()],
|
|
198
|
+
["assetType", kit.getU8Decoder()],
|
|
199
|
+
["rootHistoryIndex", kit.getU8Decoder()],
|
|
200
|
+
["bump", kit.getU8Decoder()],
|
|
201
|
+
["padding", kit.fixDecoderSize(kit.getBytesDecoder(), 1)]
|
|
202
|
+
]);
|
|
203
|
+
}
|
|
204
|
+
function getPoolCodec() {
|
|
205
|
+
return kit.combineCodec(getPoolEncoder(), getPoolDecoder());
|
|
206
|
+
}
|
|
207
|
+
function decodePool(encodedAccount) {
|
|
208
|
+
return kit.decodeAccount(
|
|
209
|
+
encodedAccount,
|
|
210
|
+
getPoolDecoder()
|
|
211
|
+
);
|
|
212
|
+
}
|
|
213
|
+
async function fetchPool(rpc, address, config) {
|
|
214
|
+
const maybeAccount = await fetchMaybePool(rpc, address, config);
|
|
215
|
+
kit.assertAccountExists(maybeAccount);
|
|
216
|
+
return maybeAccount;
|
|
217
|
+
}
|
|
218
|
+
async function fetchMaybePool(rpc, address, config) {
|
|
219
|
+
const maybeAccount = await kit.fetchEncodedAccount(rpc, address, config);
|
|
220
|
+
return decodePool(maybeAccount);
|
|
221
|
+
}
|
|
222
|
+
async function fetchAllPool(rpc, addresses, config) {
|
|
223
|
+
const maybeAccounts = await fetchAllMaybePool(rpc, addresses, config);
|
|
224
|
+
kit.assertAccountsExist(maybeAccounts);
|
|
225
|
+
return maybeAccounts;
|
|
226
|
+
}
|
|
227
|
+
async function fetchAllMaybePool(rpc, addresses, config) {
|
|
228
|
+
const maybeAccounts = await kit.fetchEncodedAccounts(rpc, addresses, config);
|
|
229
|
+
return maybeAccounts.map((maybeAccount) => decodePool(maybeAccount));
|
|
230
|
+
}
|
|
231
|
+
function getPoolSize() {
|
|
232
|
+
return 1360;
|
|
233
|
+
}
|
|
234
|
+
var VAULT_DISCRIMINATOR = new Uint8Array([
|
|
235
|
+
211,
|
|
236
|
+
8,
|
|
237
|
+
232,
|
|
238
|
+
43,
|
|
239
|
+
2,
|
|
240
|
+
152,
|
|
241
|
+
117,
|
|
242
|
+
119
|
|
243
|
+
]);
|
|
244
|
+
function getVaultDiscriminatorBytes() {
|
|
245
|
+
return kit.fixEncoderSize(kit.getBytesEncoder(), 8).encode(VAULT_DISCRIMINATOR);
|
|
246
|
+
}
|
|
247
|
+
function getVaultEncoder() {
|
|
248
|
+
return kit.transformEncoder(
|
|
249
|
+
kit.getStructEncoder([["discriminator", kit.fixEncoderSize(kit.getBytesEncoder(), 8)]]),
|
|
250
|
+
(value) => ({ ...value, discriminator: VAULT_DISCRIMINATOR })
|
|
251
|
+
);
|
|
252
|
+
}
|
|
253
|
+
function getVaultDecoder() {
|
|
254
|
+
return kit.getStructDecoder([
|
|
255
|
+
["discriminator", kit.fixDecoderSize(kit.getBytesDecoder(), 8)]
|
|
256
|
+
]);
|
|
257
|
+
}
|
|
258
|
+
function getVaultCodec() {
|
|
259
|
+
return kit.combineCodec(getVaultEncoder(), getVaultDecoder());
|
|
260
|
+
}
|
|
261
|
+
function decodeVault(encodedAccount) {
|
|
262
|
+
return kit.decodeAccount(
|
|
263
|
+
encodedAccount,
|
|
264
|
+
getVaultDecoder()
|
|
265
|
+
);
|
|
266
|
+
}
|
|
267
|
+
async function fetchVault(rpc, address, config) {
|
|
268
|
+
const maybeAccount = await fetchMaybeVault(rpc, address, config);
|
|
269
|
+
kit.assertAccountExists(maybeAccount);
|
|
270
|
+
return maybeAccount;
|
|
271
|
+
}
|
|
272
|
+
async function fetchMaybeVault(rpc, address, config) {
|
|
273
|
+
const maybeAccount = await kit.fetchEncodedAccount(rpc, address, config);
|
|
274
|
+
return decodeVault(maybeAccount);
|
|
275
|
+
}
|
|
276
|
+
async function fetchAllVault(rpc, addresses, config) {
|
|
277
|
+
const maybeAccounts = await fetchAllMaybeVault(rpc, addresses, config);
|
|
278
|
+
kit.assertAccountsExist(maybeAccounts);
|
|
279
|
+
return maybeAccounts;
|
|
280
|
+
}
|
|
281
|
+
async function fetchAllMaybeVault(rpc, addresses, config) {
|
|
282
|
+
const maybeAccounts = await kit.fetchEncodedAccounts(rpc, addresses, config);
|
|
283
|
+
return maybeAccounts.map((maybeAccount) => decodeVault(maybeAccount));
|
|
284
|
+
}
|
|
285
|
+
function getVaultSize() {
|
|
286
|
+
return 8;
|
|
287
|
+
}
|
|
288
|
+
var MIXOOR_PROGRAM_ADDRESS = "mixmC791jTymqvJR2Zgvd8NAvXpXw99GdCW5uQcMBj8";
|
|
289
|
+
var MixoorAccount = /* @__PURE__ */ ((MixoorAccount2) => {
|
|
290
|
+
MixoorAccount2[MixoorAccount2["NullifierAccount"] = 0] = "NullifierAccount";
|
|
291
|
+
MixoorAccount2[MixoorAccount2["Pool"] = 1] = "Pool";
|
|
292
|
+
MixoorAccount2[MixoorAccount2["Vault"] = 2] = "Vault";
|
|
293
|
+
return MixoorAccount2;
|
|
294
|
+
})(MixoorAccount || {});
|
|
295
|
+
function identifyMixoorAccount(account) {
|
|
296
|
+
const data = "data" in account ? account.data : account;
|
|
297
|
+
if (kit.containsBytes(
|
|
298
|
+
data,
|
|
299
|
+
kit.fixEncoderSize(kit.getBytesEncoder(), 8).encode(
|
|
300
|
+
new Uint8Array([250, 31, 238, 177, 213, 98, 48, 172])
|
|
301
|
+
),
|
|
302
|
+
0
|
|
303
|
+
)) {
|
|
304
|
+
return 0 /* NullifierAccount */;
|
|
305
|
+
}
|
|
306
|
+
if (kit.containsBytes(
|
|
307
|
+
data,
|
|
308
|
+
kit.fixEncoderSize(kit.getBytesEncoder(), 8).encode(
|
|
309
|
+
new Uint8Array([241, 154, 109, 4, 17, 177, 109, 188])
|
|
310
|
+
),
|
|
311
|
+
0
|
|
312
|
+
)) {
|
|
313
|
+
return 1 /* Pool */;
|
|
314
|
+
}
|
|
315
|
+
if (kit.containsBytes(
|
|
316
|
+
data,
|
|
317
|
+
kit.fixEncoderSize(kit.getBytesEncoder(), 8).encode(
|
|
318
|
+
new Uint8Array([211, 8, 232, 43, 2, 152, 117, 119])
|
|
319
|
+
),
|
|
320
|
+
0
|
|
321
|
+
)) {
|
|
322
|
+
return 2 /* Vault */;
|
|
323
|
+
}
|
|
324
|
+
throw new Error(
|
|
325
|
+
"The provided account could not be identified as a mixoor account."
|
|
326
|
+
);
|
|
327
|
+
}
|
|
328
|
+
var MixoorInstruction = /* @__PURE__ */ ((MixoorInstruction2) => {
|
|
329
|
+
MixoorInstruction2[MixoorInstruction2["Deposit"] = 0] = "Deposit";
|
|
330
|
+
MixoorInstruction2[MixoorInstruction2["InitializePool"] = 1] = "InitializePool";
|
|
331
|
+
MixoorInstruction2[MixoorInstruction2["Transfer"] = 2] = "Transfer";
|
|
332
|
+
return MixoorInstruction2;
|
|
333
|
+
})(MixoorInstruction || {});
|
|
334
|
+
function identifyMixoorInstruction(instruction) {
|
|
335
|
+
const data = "data" in instruction ? instruction.data : instruction;
|
|
336
|
+
if (kit.containsBytes(
|
|
337
|
+
data,
|
|
338
|
+
kit.fixEncoderSize(kit.getBytesEncoder(), 8).encode(
|
|
339
|
+
new Uint8Array([242, 35, 198, 137, 82, 225, 242, 182])
|
|
340
|
+
),
|
|
341
|
+
0
|
|
342
|
+
)) {
|
|
343
|
+
return 0 /* Deposit */;
|
|
344
|
+
}
|
|
345
|
+
if (kit.containsBytes(
|
|
346
|
+
data,
|
|
347
|
+
kit.fixEncoderSize(kit.getBytesEncoder(), 8).encode(
|
|
348
|
+
new Uint8Array([95, 180, 10, 172, 84, 174, 232, 40])
|
|
349
|
+
),
|
|
350
|
+
0
|
|
351
|
+
)) {
|
|
352
|
+
return 1 /* InitializePool */;
|
|
353
|
+
}
|
|
354
|
+
if (kit.containsBytes(
|
|
355
|
+
data,
|
|
356
|
+
kit.fixEncoderSize(kit.getBytesEncoder(), 8).encode(
|
|
357
|
+
new Uint8Array([163, 52, 200, 231, 140, 3, 69, 186])
|
|
358
|
+
),
|
|
359
|
+
0
|
|
360
|
+
)) {
|
|
361
|
+
return 2 /* Transfer */;
|
|
362
|
+
}
|
|
363
|
+
throw new Error(
|
|
364
|
+
"The provided instruction could not be identified as a mixoor instruction."
|
|
365
|
+
);
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
// src/generated/errors/mixoor.ts
|
|
369
|
+
var MIXOOR_ERROR__INVALID_PROOF = 6e3;
|
|
370
|
+
var MIXOOR_ERROR__UNKNOWN_ROOT = 6001;
|
|
371
|
+
var MIXOOR_ERROR__INVALID_AMOUNT = 6002;
|
|
372
|
+
var MIXOOR_ERROR__INSUFFICIENT_FUNDS = 6003;
|
|
373
|
+
var MIXOOR_ERROR__MISSING_TOKEN_ACCOUNT = 6004;
|
|
374
|
+
var MIXOOR_ERROR__OVERFLOW = 6005;
|
|
375
|
+
var MIXOOR_ERROR__INVALID_PUBLIC_INPUTS = 6006;
|
|
376
|
+
var MIXOOR_ERROR__INVALID_ASSET_TYPE = 6007;
|
|
377
|
+
var MIXOOR_ERROR__INVALID_MERKLE_TREE_ADDRESS = 6008;
|
|
378
|
+
var MIXOOR_ERROR__INVALID_MERKLE_TREE = 6009;
|
|
379
|
+
var MIXOOR_ERROR__POSEIDON_HASH_ERROR = 6010;
|
|
380
|
+
var MIXOOR_ERROR__MERKLE_TREE_FULL = 6011;
|
|
381
|
+
var MIXOOR_ERROR__INVALID_MERKLE_PROOF = 6012;
|
|
382
|
+
var mixoorErrorMessages;
|
|
383
|
+
if (process.env.NODE_ENV !== "production") {
|
|
384
|
+
mixoorErrorMessages = {
|
|
385
|
+
[MIXOOR_ERROR__INSUFFICIENT_FUNDS]: `Insufficient funds`,
|
|
386
|
+
[MIXOOR_ERROR__INVALID_AMOUNT]: `Invalid amount`,
|
|
387
|
+
[MIXOOR_ERROR__INVALID_ASSET_TYPE]: `Invalid asset type deserialized`,
|
|
388
|
+
[MIXOOR_ERROR__INVALID_MERKLE_PROOF]: `Invalid merkle proof`,
|
|
389
|
+
[MIXOOR_ERROR__INVALID_MERKLE_TREE]: `Invalid merkle tree structure or out of bounds access`,
|
|
390
|
+
[MIXOOR_ERROR__INVALID_MERKLE_TREE_ADDRESS]: `Invalid merkle tree address`,
|
|
391
|
+
[MIXOOR_ERROR__INVALID_PROOF]: `Invalid proof`,
|
|
392
|
+
[MIXOOR_ERROR__INVALID_PUBLIC_INPUTS]: `Invalid number of public inputs`,
|
|
393
|
+
[MIXOOR_ERROR__MERKLE_TREE_FULL]: `Merkle tree is full`,
|
|
394
|
+
[MIXOOR_ERROR__MISSING_TOKEN_ACCOUNT]: `Missing token account`,
|
|
395
|
+
[MIXOOR_ERROR__OVERFLOW]: `Overflow`,
|
|
396
|
+
[MIXOOR_ERROR__POSEIDON_HASH_ERROR]: `Poseidon hash error`,
|
|
397
|
+
[MIXOOR_ERROR__UNKNOWN_ROOT]: `Unknown merkle root`
|
|
398
|
+
};
|
|
399
|
+
}
|
|
400
|
+
function getMixoorErrorMessage(code) {
|
|
401
|
+
if (process.env.NODE_ENV !== "production") {
|
|
402
|
+
return mixoorErrorMessages[code];
|
|
403
|
+
}
|
|
404
|
+
return "Error message not available in production bundles.";
|
|
405
|
+
}
|
|
406
|
+
function isMixoorError(error, transactionMessage, code) {
|
|
407
|
+
return kit.isProgramError(
|
|
408
|
+
error,
|
|
409
|
+
transactionMessage,
|
|
410
|
+
MIXOOR_PROGRAM_ADDRESS,
|
|
411
|
+
code
|
|
412
|
+
);
|
|
413
|
+
}
|
|
414
|
+
function expectSome(value) {
|
|
415
|
+
if (value === null || value === void 0) {
|
|
416
|
+
throw new Error("Expected a value but received null or undefined.");
|
|
417
|
+
}
|
|
418
|
+
return value;
|
|
419
|
+
}
|
|
420
|
+
function expectAddress(value) {
|
|
421
|
+
if (!value) {
|
|
422
|
+
throw new Error("Expected a Address.");
|
|
423
|
+
}
|
|
424
|
+
if (typeof value === "object" && "address" in value) {
|
|
425
|
+
return value.address;
|
|
426
|
+
}
|
|
427
|
+
if (Array.isArray(value)) {
|
|
428
|
+
return value[0];
|
|
429
|
+
}
|
|
430
|
+
return value;
|
|
431
|
+
}
|
|
432
|
+
function getAccountMetaFactory(programAddress, optionalAccountStrategy) {
|
|
433
|
+
return (account) => {
|
|
434
|
+
if (!account.value) {
|
|
435
|
+
return Object.freeze({
|
|
436
|
+
address: programAddress,
|
|
437
|
+
role: kit.AccountRole.READONLY
|
|
438
|
+
});
|
|
439
|
+
}
|
|
440
|
+
const writableRole = account.isWritable ? kit.AccountRole.WRITABLE : kit.AccountRole.READONLY;
|
|
441
|
+
return Object.freeze({
|
|
442
|
+
address: expectAddress(account.value),
|
|
443
|
+
role: isTransactionSigner(account.value) ? kit.upgradeRoleToSigner(writableRole) : writableRole,
|
|
444
|
+
...isTransactionSigner(account.value) ? { signer: account.value } : {}
|
|
445
|
+
});
|
|
446
|
+
};
|
|
447
|
+
}
|
|
448
|
+
function isTransactionSigner(value) {
|
|
449
|
+
return !!value && typeof value === "object" && "address" in value && kit.isTransactionSigner(value);
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
// src/generated/instructions/deposit.ts
|
|
453
|
+
var DEPOSIT_DISCRIMINATOR = new Uint8Array([
|
|
454
|
+
242,
|
|
455
|
+
35,
|
|
456
|
+
198,
|
|
457
|
+
137,
|
|
458
|
+
82,
|
|
459
|
+
225,
|
|
460
|
+
242,
|
|
461
|
+
182
|
|
462
|
+
]);
|
|
463
|
+
function getDepositDiscriminatorBytes() {
|
|
464
|
+
return kit.fixEncoderSize(kit.getBytesEncoder(), 8).encode(DEPOSIT_DISCRIMINATOR);
|
|
465
|
+
}
|
|
466
|
+
function getDepositInstructionDataEncoder() {
|
|
467
|
+
return kit.transformEncoder(
|
|
468
|
+
kit.getStructEncoder([
|
|
469
|
+
["discriminator", kit.fixEncoderSize(kit.getBytesEncoder(), 8)],
|
|
470
|
+
["amount", kit.getU64Encoder()],
|
|
471
|
+
["commitment", kit.fixEncoderSize(kit.getBytesEncoder(), 32)],
|
|
472
|
+
["newRoot", kit.fixEncoderSize(kit.getBytesEncoder(), 32)]
|
|
473
|
+
]),
|
|
474
|
+
(value) => ({ ...value, discriminator: DEPOSIT_DISCRIMINATOR })
|
|
475
|
+
);
|
|
476
|
+
}
|
|
477
|
+
function getDepositInstructionDataDecoder() {
|
|
478
|
+
return kit.getStructDecoder([
|
|
479
|
+
["discriminator", kit.fixDecoderSize(kit.getBytesDecoder(), 8)],
|
|
480
|
+
["amount", kit.getU64Decoder()],
|
|
481
|
+
["commitment", kit.fixDecoderSize(kit.getBytesDecoder(), 32)],
|
|
482
|
+
["newRoot", kit.fixDecoderSize(kit.getBytesDecoder(), 32)]
|
|
483
|
+
]);
|
|
484
|
+
}
|
|
485
|
+
function getDepositInstructionDataCodec() {
|
|
486
|
+
return kit.combineCodec(
|
|
487
|
+
getDepositInstructionDataEncoder(),
|
|
488
|
+
getDepositInstructionDataDecoder()
|
|
489
|
+
);
|
|
490
|
+
}
|
|
491
|
+
async function getDepositInstructionAsync(input, config) {
|
|
492
|
+
const programAddress = config?.programAddress ?? MIXOOR_PROGRAM_ADDRESS;
|
|
493
|
+
const originalAccounts = {
|
|
494
|
+
depositor: { value: input.depositor ?? null, isWritable: true },
|
|
495
|
+
pool: { value: input.pool ?? null, isWritable: true },
|
|
496
|
+
mint: { value: input.mint ?? null, isWritable: true },
|
|
497
|
+
vault: { value: input.vault ?? null, isWritable: true },
|
|
498
|
+
depositorTokenAccount: {
|
|
499
|
+
value: input.depositorTokenAccount ?? null,
|
|
500
|
+
isWritable: true
|
|
501
|
+
},
|
|
502
|
+
vaultTokenAccount: {
|
|
503
|
+
value: input.vaultTokenAccount ?? null,
|
|
504
|
+
isWritable: true
|
|
505
|
+
},
|
|
506
|
+
systemProgram: { value: input.systemProgram ?? null, isWritable: false },
|
|
507
|
+
tokenProgram: { value: input.tokenProgram ?? null, isWritable: false },
|
|
508
|
+
associatedTokenProgram: {
|
|
509
|
+
value: input.associatedTokenProgram ?? null,
|
|
510
|
+
isWritable: false
|
|
511
|
+
}
|
|
512
|
+
};
|
|
513
|
+
const accounts = originalAccounts;
|
|
514
|
+
const args = { ...input };
|
|
515
|
+
if (!accounts.vault.value) {
|
|
516
|
+
accounts.vault.value = await kit.getProgramDerivedAddress({
|
|
517
|
+
programAddress,
|
|
518
|
+
seeds: [
|
|
519
|
+
kit.getBytesEncoder().encode(new Uint8Array([118, 97, 117, 108, 116])),
|
|
520
|
+
kit.getAddressEncoder().encode(expectAddress(accounts.pool.value))
|
|
521
|
+
]
|
|
522
|
+
});
|
|
523
|
+
}
|
|
524
|
+
if (!accounts.systemProgram.value) {
|
|
525
|
+
accounts.systemProgram.value = "11111111111111111111111111111111";
|
|
526
|
+
}
|
|
527
|
+
if (!accounts.tokenProgram.value) {
|
|
528
|
+
accounts.tokenProgram.value = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";
|
|
529
|
+
}
|
|
530
|
+
if (!accounts.associatedTokenProgram.value) {
|
|
531
|
+
accounts.associatedTokenProgram.value = "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL";
|
|
532
|
+
}
|
|
533
|
+
const getAccountMeta = getAccountMetaFactory(programAddress);
|
|
534
|
+
return Object.freeze({
|
|
535
|
+
accounts: [
|
|
536
|
+
getAccountMeta(accounts.depositor),
|
|
537
|
+
getAccountMeta(accounts.pool),
|
|
538
|
+
getAccountMeta(accounts.mint),
|
|
539
|
+
getAccountMeta(accounts.vault),
|
|
540
|
+
getAccountMeta(accounts.depositorTokenAccount),
|
|
541
|
+
getAccountMeta(accounts.vaultTokenAccount),
|
|
542
|
+
getAccountMeta(accounts.systemProgram),
|
|
543
|
+
getAccountMeta(accounts.tokenProgram),
|
|
544
|
+
getAccountMeta(accounts.associatedTokenProgram)
|
|
545
|
+
],
|
|
546
|
+
data: getDepositInstructionDataEncoder().encode(
|
|
547
|
+
args
|
|
548
|
+
),
|
|
549
|
+
programAddress
|
|
550
|
+
});
|
|
551
|
+
}
|
|
552
|
+
function getDepositInstruction(input, config) {
|
|
553
|
+
const programAddress = config?.programAddress ?? MIXOOR_PROGRAM_ADDRESS;
|
|
554
|
+
const originalAccounts = {
|
|
555
|
+
depositor: { value: input.depositor ?? null, isWritable: true },
|
|
556
|
+
pool: { value: input.pool ?? null, isWritable: true },
|
|
557
|
+
mint: { value: input.mint ?? null, isWritable: true },
|
|
558
|
+
vault: { value: input.vault ?? null, isWritable: true },
|
|
559
|
+
depositorTokenAccount: {
|
|
560
|
+
value: input.depositorTokenAccount ?? null,
|
|
561
|
+
isWritable: true
|
|
562
|
+
},
|
|
563
|
+
vaultTokenAccount: {
|
|
564
|
+
value: input.vaultTokenAccount ?? null,
|
|
565
|
+
isWritable: true
|
|
566
|
+
},
|
|
567
|
+
systemProgram: { value: input.systemProgram ?? null, isWritable: false },
|
|
568
|
+
tokenProgram: { value: input.tokenProgram ?? null, isWritable: false },
|
|
569
|
+
associatedTokenProgram: {
|
|
570
|
+
value: input.associatedTokenProgram ?? null,
|
|
571
|
+
isWritable: false
|
|
572
|
+
}
|
|
573
|
+
};
|
|
574
|
+
const accounts = originalAccounts;
|
|
575
|
+
const args = { ...input };
|
|
576
|
+
if (!accounts.systemProgram.value) {
|
|
577
|
+
accounts.systemProgram.value = "11111111111111111111111111111111";
|
|
578
|
+
}
|
|
579
|
+
if (!accounts.tokenProgram.value) {
|
|
580
|
+
accounts.tokenProgram.value = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";
|
|
581
|
+
}
|
|
582
|
+
if (!accounts.associatedTokenProgram.value) {
|
|
583
|
+
accounts.associatedTokenProgram.value = "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL";
|
|
584
|
+
}
|
|
585
|
+
const getAccountMeta = getAccountMetaFactory(programAddress);
|
|
586
|
+
return Object.freeze({
|
|
587
|
+
accounts: [
|
|
588
|
+
getAccountMeta(accounts.depositor),
|
|
589
|
+
getAccountMeta(accounts.pool),
|
|
590
|
+
getAccountMeta(accounts.mint),
|
|
591
|
+
getAccountMeta(accounts.vault),
|
|
592
|
+
getAccountMeta(accounts.depositorTokenAccount),
|
|
593
|
+
getAccountMeta(accounts.vaultTokenAccount),
|
|
594
|
+
getAccountMeta(accounts.systemProgram),
|
|
595
|
+
getAccountMeta(accounts.tokenProgram),
|
|
596
|
+
getAccountMeta(accounts.associatedTokenProgram)
|
|
597
|
+
],
|
|
598
|
+
data: getDepositInstructionDataEncoder().encode(
|
|
599
|
+
args
|
|
600
|
+
),
|
|
601
|
+
programAddress
|
|
602
|
+
});
|
|
603
|
+
}
|
|
604
|
+
function parseDepositInstruction(instruction) {
|
|
605
|
+
if (instruction.accounts.length < 9) {
|
|
606
|
+
throw new Error("Not enough accounts");
|
|
607
|
+
}
|
|
608
|
+
let accountIndex = 0;
|
|
609
|
+
const getNextAccount = () => {
|
|
610
|
+
const accountMeta = instruction.accounts[accountIndex];
|
|
611
|
+
accountIndex += 1;
|
|
612
|
+
return accountMeta;
|
|
613
|
+
};
|
|
614
|
+
const getNextOptionalAccount = () => {
|
|
615
|
+
const accountMeta = getNextAccount();
|
|
616
|
+
return accountMeta.address === MIXOOR_PROGRAM_ADDRESS ? void 0 : accountMeta;
|
|
617
|
+
};
|
|
618
|
+
return {
|
|
619
|
+
programAddress: instruction.programAddress,
|
|
620
|
+
accounts: {
|
|
621
|
+
depositor: getNextAccount(),
|
|
622
|
+
pool: getNextAccount(),
|
|
623
|
+
mint: getNextAccount(),
|
|
624
|
+
vault: getNextAccount(),
|
|
625
|
+
depositorTokenAccount: getNextOptionalAccount(),
|
|
626
|
+
vaultTokenAccount: getNextOptionalAccount(),
|
|
627
|
+
systemProgram: getNextAccount(),
|
|
628
|
+
tokenProgram: getNextAccount(),
|
|
629
|
+
associatedTokenProgram: getNextAccount()
|
|
630
|
+
},
|
|
631
|
+
data: getDepositInstructionDataDecoder().decode(instruction.data)
|
|
632
|
+
};
|
|
633
|
+
}
|
|
634
|
+
var INITIALIZE_POOL_DISCRIMINATOR = new Uint8Array([
|
|
635
|
+
95,
|
|
636
|
+
180,
|
|
637
|
+
10,
|
|
638
|
+
172,
|
|
639
|
+
84,
|
|
640
|
+
174,
|
|
641
|
+
232,
|
|
642
|
+
40
|
|
643
|
+
]);
|
|
644
|
+
function getInitializePoolDiscriminatorBytes() {
|
|
645
|
+
return kit.fixEncoderSize(kit.getBytesEncoder(), 8).encode(
|
|
646
|
+
INITIALIZE_POOL_DISCRIMINATOR
|
|
647
|
+
);
|
|
648
|
+
}
|
|
649
|
+
function getInitializePoolInstructionDataEncoder() {
|
|
650
|
+
return kit.transformEncoder(
|
|
651
|
+
kit.getStructEncoder([
|
|
652
|
+
["discriminator", kit.fixEncoderSize(kit.getBytesEncoder(), 8)],
|
|
653
|
+
["assetType", getAssetTypeEncoder()]
|
|
654
|
+
]),
|
|
655
|
+
(value) => ({ ...value, discriminator: INITIALIZE_POOL_DISCRIMINATOR })
|
|
656
|
+
);
|
|
657
|
+
}
|
|
658
|
+
function getInitializePoolInstructionDataDecoder() {
|
|
659
|
+
return kit.getStructDecoder([
|
|
660
|
+
["discriminator", kit.fixDecoderSize(kit.getBytesDecoder(), 8)],
|
|
661
|
+
["assetType", getAssetTypeDecoder()]
|
|
662
|
+
]);
|
|
663
|
+
}
|
|
664
|
+
function getInitializePoolInstructionDataCodec() {
|
|
665
|
+
return kit.combineCodec(
|
|
666
|
+
getInitializePoolInstructionDataEncoder(),
|
|
667
|
+
getInitializePoolInstructionDataDecoder()
|
|
668
|
+
);
|
|
669
|
+
}
|
|
670
|
+
async function getInitializePoolInstructionAsync(input, config) {
|
|
671
|
+
const programAddress = config?.programAddress ?? MIXOOR_PROGRAM_ADDRESS;
|
|
672
|
+
const originalAccounts = {
|
|
673
|
+
authority: { value: input.authority ?? null, isWritable: true },
|
|
674
|
+
pool: { value: input.pool ?? null, isWritable: true },
|
|
675
|
+
vault: { value: input.vault ?? null, isWritable: true },
|
|
676
|
+
vaultAta: { value: input.vaultAta ?? null, isWritable: true },
|
|
677
|
+
mint: { value: input.mint ?? null, isWritable: true },
|
|
678
|
+
feeCollector: { value: input.feeCollector ?? null, isWritable: false },
|
|
679
|
+
systemProgram: { value: input.systemProgram ?? null, isWritable: false },
|
|
680
|
+
tokenProgram: { value: input.tokenProgram ?? null, isWritable: false },
|
|
681
|
+
associatedTokenProgram: {
|
|
682
|
+
value: input.associatedTokenProgram ?? null,
|
|
683
|
+
isWritable: false
|
|
684
|
+
}
|
|
685
|
+
};
|
|
686
|
+
const accounts = originalAccounts;
|
|
687
|
+
const args = { ...input };
|
|
688
|
+
if (!accounts.pool.value) {
|
|
689
|
+
accounts.pool.value = await kit.getProgramDerivedAddress({
|
|
690
|
+
programAddress,
|
|
691
|
+
seeds: [
|
|
692
|
+
kit.getBytesEncoder().encode(new Uint8Array([112, 111, 111, 108])),
|
|
693
|
+
kit.getAddressEncoder().encode(expectAddress(accounts.mint.value))
|
|
694
|
+
]
|
|
695
|
+
});
|
|
696
|
+
}
|
|
697
|
+
if (!accounts.vault.value) {
|
|
698
|
+
accounts.vault.value = await kit.getProgramDerivedAddress({
|
|
699
|
+
programAddress,
|
|
700
|
+
seeds: [
|
|
701
|
+
kit.getBytesEncoder().encode(new Uint8Array([118, 97, 117, 108, 116])),
|
|
702
|
+
kit.getAddressEncoder().encode(expectAddress(accounts.pool.value))
|
|
703
|
+
]
|
|
704
|
+
});
|
|
705
|
+
}
|
|
706
|
+
if (!accounts.tokenProgram.value) {
|
|
707
|
+
accounts.tokenProgram.value = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";
|
|
708
|
+
}
|
|
709
|
+
if (!accounts.vaultAta.value) {
|
|
710
|
+
accounts.vaultAta.value = await kit.getProgramDerivedAddress({
|
|
711
|
+
programAddress: "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL",
|
|
712
|
+
seeds: [
|
|
713
|
+
kit.getAddressEncoder().encode(expectAddress(accounts.vault.value)),
|
|
714
|
+
kit.getAddressEncoder().encode(expectAddress(accounts.tokenProgram.value)),
|
|
715
|
+
kit.getAddressEncoder().encode(expectAddress(accounts.mint.value))
|
|
716
|
+
]
|
|
717
|
+
});
|
|
718
|
+
}
|
|
719
|
+
if (!accounts.feeCollector.value) {
|
|
720
|
+
accounts.feeCollector.value = "5KgfWjGePnbFgDAuCqxB5oymuFxQskvCtrw6eYfDa7fj";
|
|
721
|
+
}
|
|
722
|
+
if (!accounts.systemProgram.value) {
|
|
723
|
+
accounts.systemProgram.value = "11111111111111111111111111111111";
|
|
724
|
+
}
|
|
725
|
+
if (!accounts.associatedTokenProgram.value) {
|
|
726
|
+
accounts.associatedTokenProgram.value = "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL";
|
|
727
|
+
}
|
|
728
|
+
const getAccountMeta = getAccountMetaFactory(programAddress);
|
|
729
|
+
return Object.freeze({
|
|
730
|
+
accounts: [
|
|
731
|
+
getAccountMeta(accounts.authority),
|
|
732
|
+
getAccountMeta(accounts.pool),
|
|
733
|
+
getAccountMeta(accounts.vault),
|
|
734
|
+
getAccountMeta(accounts.vaultAta),
|
|
735
|
+
getAccountMeta(accounts.mint),
|
|
736
|
+
getAccountMeta(accounts.feeCollector),
|
|
737
|
+
getAccountMeta(accounts.systemProgram),
|
|
738
|
+
getAccountMeta(accounts.tokenProgram),
|
|
739
|
+
getAccountMeta(accounts.associatedTokenProgram)
|
|
740
|
+
],
|
|
741
|
+
data: getInitializePoolInstructionDataEncoder().encode(
|
|
742
|
+
args
|
|
743
|
+
),
|
|
744
|
+
programAddress
|
|
745
|
+
});
|
|
746
|
+
}
|
|
747
|
+
function getInitializePoolInstruction(input, config) {
|
|
748
|
+
const programAddress = config?.programAddress ?? MIXOOR_PROGRAM_ADDRESS;
|
|
749
|
+
const originalAccounts = {
|
|
750
|
+
authority: { value: input.authority ?? null, isWritable: true },
|
|
751
|
+
pool: { value: input.pool ?? null, isWritable: true },
|
|
752
|
+
vault: { value: input.vault ?? null, isWritable: true },
|
|
753
|
+
vaultAta: { value: input.vaultAta ?? null, isWritable: true },
|
|
754
|
+
mint: { value: input.mint ?? null, isWritable: true },
|
|
755
|
+
feeCollector: { value: input.feeCollector ?? null, isWritable: false },
|
|
756
|
+
systemProgram: { value: input.systemProgram ?? null, isWritable: false },
|
|
757
|
+
tokenProgram: { value: input.tokenProgram ?? null, isWritable: false },
|
|
758
|
+
associatedTokenProgram: {
|
|
759
|
+
value: input.associatedTokenProgram ?? null,
|
|
760
|
+
isWritable: false
|
|
761
|
+
}
|
|
762
|
+
};
|
|
763
|
+
const accounts = originalAccounts;
|
|
764
|
+
const args = { ...input };
|
|
765
|
+
if (!accounts.tokenProgram.value) {
|
|
766
|
+
accounts.tokenProgram.value = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";
|
|
767
|
+
}
|
|
768
|
+
if (!accounts.feeCollector.value) {
|
|
769
|
+
accounts.feeCollector.value = "5KgfWjGePnbFgDAuCqxB5oymuFxQskvCtrw6eYfDa7fj";
|
|
770
|
+
}
|
|
771
|
+
if (!accounts.systemProgram.value) {
|
|
772
|
+
accounts.systemProgram.value = "11111111111111111111111111111111";
|
|
773
|
+
}
|
|
774
|
+
if (!accounts.associatedTokenProgram.value) {
|
|
775
|
+
accounts.associatedTokenProgram.value = "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL";
|
|
776
|
+
}
|
|
777
|
+
const getAccountMeta = getAccountMetaFactory(programAddress);
|
|
778
|
+
return Object.freeze({
|
|
779
|
+
accounts: [
|
|
780
|
+
getAccountMeta(accounts.authority),
|
|
781
|
+
getAccountMeta(accounts.pool),
|
|
782
|
+
getAccountMeta(accounts.vault),
|
|
783
|
+
getAccountMeta(accounts.vaultAta),
|
|
784
|
+
getAccountMeta(accounts.mint),
|
|
785
|
+
getAccountMeta(accounts.feeCollector),
|
|
786
|
+
getAccountMeta(accounts.systemProgram),
|
|
787
|
+
getAccountMeta(accounts.tokenProgram),
|
|
788
|
+
getAccountMeta(accounts.associatedTokenProgram)
|
|
789
|
+
],
|
|
790
|
+
data: getInitializePoolInstructionDataEncoder().encode(
|
|
791
|
+
args
|
|
792
|
+
),
|
|
793
|
+
programAddress
|
|
794
|
+
});
|
|
795
|
+
}
|
|
796
|
+
function parseInitializePoolInstruction(instruction) {
|
|
797
|
+
if (instruction.accounts.length < 9) {
|
|
798
|
+
throw new Error("Not enough accounts");
|
|
799
|
+
}
|
|
800
|
+
let accountIndex = 0;
|
|
801
|
+
const getNextAccount = () => {
|
|
802
|
+
const accountMeta = instruction.accounts[accountIndex];
|
|
803
|
+
accountIndex += 1;
|
|
804
|
+
return accountMeta;
|
|
805
|
+
};
|
|
806
|
+
return {
|
|
807
|
+
programAddress: instruction.programAddress,
|
|
808
|
+
accounts: {
|
|
809
|
+
authority: getNextAccount(),
|
|
810
|
+
pool: getNextAccount(),
|
|
811
|
+
vault: getNextAccount(),
|
|
812
|
+
vaultAta: getNextAccount(),
|
|
813
|
+
mint: getNextAccount(),
|
|
814
|
+
feeCollector: getNextAccount(),
|
|
815
|
+
systemProgram: getNextAccount(),
|
|
816
|
+
tokenProgram: getNextAccount(),
|
|
817
|
+
associatedTokenProgram: getNextAccount()
|
|
818
|
+
},
|
|
819
|
+
data: getInitializePoolInstructionDataDecoder().decode(instruction.data)
|
|
820
|
+
};
|
|
821
|
+
}
|
|
822
|
+
var TRANSFER_DISCRIMINATOR = new Uint8Array([
|
|
823
|
+
163,
|
|
824
|
+
52,
|
|
825
|
+
200,
|
|
826
|
+
231,
|
|
827
|
+
140,
|
|
828
|
+
3,
|
|
829
|
+
69,
|
|
830
|
+
186
|
|
831
|
+
]);
|
|
832
|
+
function getTransferDiscriminatorBytes() {
|
|
833
|
+
return kit.fixEncoderSize(kit.getBytesEncoder(), 8).encode(TRANSFER_DISCRIMINATOR);
|
|
834
|
+
}
|
|
835
|
+
function getTransferInstructionDataEncoder() {
|
|
836
|
+
return kit.transformEncoder(
|
|
837
|
+
kit.getStructEncoder([
|
|
838
|
+
["discriminator", kit.fixEncoderSize(kit.getBytesEncoder(), 8)],
|
|
839
|
+
["proofA", kit.fixEncoderSize(kit.getBytesEncoder(), 64)],
|
|
840
|
+
["proofB", kit.fixEncoderSize(kit.getBytesEncoder(), 128)],
|
|
841
|
+
["proofC", kit.fixEncoderSize(kit.getBytesEncoder(), 64)],
|
|
842
|
+
[
|
|
843
|
+
"publicInputs",
|
|
844
|
+
kit.getArrayEncoder(kit.fixEncoderSize(kit.getBytesEncoder(), 32), { size: 7 })
|
|
845
|
+
],
|
|
846
|
+
["nullifierHash", kit.fixEncoderSize(kit.getBytesEncoder(), 32)],
|
|
847
|
+
["amount", kit.getU64Encoder()],
|
|
848
|
+
["fee", kit.getU64Encoder()]
|
|
849
|
+
]),
|
|
850
|
+
(value) => ({ ...value, discriminator: TRANSFER_DISCRIMINATOR })
|
|
851
|
+
);
|
|
852
|
+
}
|
|
853
|
+
function getTransferInstructionDataDecoder() {
|
|
854
|
+
return kit.getStructDecoder([
|
|
855
|
+
["discriminator", kit.fixDecoderSize(kit.getBytesDecoder(), 8)],
|
|
856
|
+
["proofA", kit.fixDecoderSize(kit.getBytesDecoder(), 64)],
|
|
857
|
+
["proofB", kit.fixDecoderSize(kit.getBytesDecoder(), 128)],
|
|
858
|
+
["proofC", kit.fixDecoderSize(kit.getBytesDecoder(), 64)],
|
|
859
|
+
[
|
|
860
|
+
"publicInputs",
|
|
861
|
+
kit.getArrayDecoder(kit.fixDecoderSize(kit.getBytesDecoder(), 32), { size: 7 })
|
|
862
|
+
],
|
|
863
|
+
["nullifierHash", kit.fixDecoderSize(kit.getBytesDecoder(), 32)],
|
|
864
|
+
["amount", kit.getU64Decoder()],
|
|
865
|
+
["fee", kit.getU64Decoder()]
|
|
866
|
+
]);
|
|
867
|
+
}
|
|
868
|
+
function getTransferInstructionDataCodec() {
|
|
869
|
+
return kit.combineCodec(
|
|
870
|
+
getTransferInstructionDataEncoder(),
|
|
871
|
+
getTransferInstructionDataDecoder()
|
|
872
|
+
);
|
|
873
|
+
}
|
|
874
|
+
async function getTransferInstructionAsync(input, config) {
|
|
875
|
+
const programAddress = config?.programAddress ?? MIXOOR_PROGRAM_ADDRESS;
|
|
876
|
+
const originalAccounts = {
|
|
877
|
+
relayer: { value: input.relayer ?? null, isWritable: true },
|
|
878
|
+
pool: { value: input.pool ?? null, isWritable: true },
|
|
879
|
+
mint: { value: input.mint ?? null, isWritable: true },
|
|
880
|
+
vault: { value: input.vault ?? null, isWritable: true },
|
|
881
|
+
nullifier: { value: input.nullifier ?? null, isWritable: true },
|
|
882
|
+
recipient: { value: input.recipient ?? null, isWritable: true },
|
|
883
|
+
vaultTokenAccount: {
|
|
884
|
+
value: input.vaultTokenAccount ?? null,
|
|
885
|
+
isWritable: true
|
|
886
|
+
},
|
|
887
|
+
recipientTokenAccount: {
|
|
888
|
+
value: input.recipientTokenAccount ?? null,
|
|
889
|
+
isWritable: true
|
|
890
|
+
},
|
|
891
|
+
feeCollector: { value: input.feeCollector ?? null, isWritable: true },
|
|
892
|
+
feeCollectorTokenAccount: {
|
|
893
|
+
value: input.feeCollectorTokenAccount ?? null,
|
|
894
|
+
isWritable: true
|
|
895
|
+
},
|
|
896
|
+
systemProgram: { value: input.systemProgram ?? null, isWritable: false },
|
|
897
|
+
tokenProgram: { value: input.tokenProgram ?? null, isWritable: false },
|
|
898
|
+
associatedTokenProgram: {
|
|
899
|
+
value: input.associatedTokenProgram ?? null,
|
|
900
|
+
isWritable: false
|
|
901
|
+
}
|
|
902
|
+
};
|
|
903
|
+
const accounts = originalAccounts;
|
|
904
|
+
const args = { ...input };
|
|
905
|
+
if (!accounts.vault.value) {
|
|
906
|
+
accounts.vault.value = await kit.getProgramDerivedAddress({
|
|
907
|
+
programAddress,
|
|
908
|
+
seeds: [
|
|
909
|
+
kit.getBytesEncoder().encode(new Uint8Array([118, 97, 117, 108, 116])),
|
|
910
|
+
kit.getAddressEncoder().encode(expectAddress(accounts.pool.value))
|
|
911
|
+
]
|
|
912
|
+
});
|
|
913
|
+
}
|
|
914
|
+
if (!accounts.nullifier.value) {
|
|
915
|
+
accounts.nullifier.value = await kit.getProgramDerivedAddress({
|
|
916
|
+
programAddress,
|
|
917
|
+
seeds: [
|
|
918
|
+
kit.getBytesEncoder().encode(
|
|
919
|
+
new Uint8Array([110, 117, 108, 108, 105, 102, 105, 101, 114])
|
|
920
|
+
),
|
|
921
|
+
kit.fixEncoderSize(kit.getBytesEncoder(), 32).encode(
|
|
922
|
+
expectSome(args.nullifierHash)
|
|
923
|
+
)
|
|
924
|
+
]
|
|
925
|
+
});
|
|
926
|
+
}
|
|
927
|
+
if (!accounts.tokenProgram.value) {
|
|
928
|
+
accounts.tokenProgram.value = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";
|
|
929
|
+
}
|
|
930
|
+
if (!accounts.recipientTokenAccount.value) {
|
|
931
|
+
accounts.recipientTokenAccount.value = await kit.getProgramDerivedAddress({
|
|
932
|
+
programAddress: "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL",
|
|
933
|
+
seeds: [
|
|
934
|
+
kit.getAddressEncoder().encode(expectAddress(accounts.recipient.value)),
|
|
935
|
+
kit.getAddressEncoder().encode(expectAddress(accounts.tokenProgram.value)),
|
|
936
|
+
kit.getAddressEncoder().encode(expectAddress(accounts.mint.value))
|
|
937
|
+
]
|
|
938
|
+
});
|
|
939
|
+
}
|
|
940
|
+
if (!accounts.feeCollector.value) {
|
|
941
|
+
accounts.feeCollector.value = "5KgfWjGePnbFgDAuCqxB5oymuFxQskvCtrw6eYfDa7fj";
|
|
942
|
+
}
|
|
943
|
+
if (!accounts.feeCollectorTokenAccount.value) {
|
|
944
|
+
accounts.feeCollectorTokenAccount.value = await kit.getProgramDerivedAddress({
|
|
945
|
+
programAddress: "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL",
|
|
946
|
+
seeds: [
|
|
947
|
+
kit.getAddressEncoder().encode(expectAddress(accounts.feeCollector.value)),
|
|
948
|
+
kit.getAddressEncoder().encode(expectAddress(accounts.tokenProgram.value)),
|
|
949
|
+
kit.getAddressEncoder().encode(expectAddress(accounts.mint.value))
|
|
950
|
+
]
|
|
951
|
+
});
|
|
952
|
+
}
|
|
953
|
+
if (!accounts.systemProgram.value) {
|
|
954
|
+
accounts.systemProgram.value = "11111111111111111111111111111111";
|
|
955
|
+
}
|
|
956
|
+
if (!accounts.associatedTokenProgram.value) {
|
|
957
|
+
accounts.associatedTokenProgram.value = "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL";
|
|
958
|
+
}
|
|
959
|
+
const getAccountMeta = getAccountMetaFactory(programAddress);
|
|
960
|
+
return Object.freeze({
|
|
961
|
+
accounts: [
|
|
962
|
+
getAccountMeta(accounts.relayer),
|
|
963
|
+
getAccountMeta(accounts.pool),
|
|
964
|
+
getAccountMeta(accounts.mint),
|
|
965
|
+
getAccountMeta(accounts.vault),
|
|
966
|
+
getAccountMeta(accounts.nullifier),
|
|
967
|
+
getAccountMeta(accounts.recipient),
|
|
968
|
+
getAccountMeta(accounts.vaultTokenAccount),
|
|
969
|
+
getAccountMeta(accounts.recipientTokenAccount),
|
|
970
|
+
getAccountMeta(accounts.feeCollector),
|
|
971
|
+
getAccountMeta(accounts.feeCollectorTokenAccount),
|
|
972
|
+
getAccountMeta(accounts.systemProgram),
|
|
973
|
+
getAccountMeta(accounts.tokenProgram),
|
|
974
|
+
getAccountMeta(accounts.associatedTokenProgram)
|
|
975
|
+
],
|
|
976
|
+
data: getTransferInstructionDataEncoder().encode(
|
|
977
|
+
args
|
|
978
|
+
),
|
|
979
|
+
programAddress
|
|
980
|
+
});
|
|
981
|
+
}
|
|
982
|
+
function getTransferInstruction(input, config) {
|
|
983
|
+
const programAddress = config?.programAddress ?? MIXOOR_PROGRAM_ADDRESS;
|
|
984
|
+
const originalAccounts = {
|
|
985
|
+
relayer: { value: input.relayer ?? null, isWritable: true },
|
|
986
|
+
pool: { value: input.pool ?? null, isWritable: true },
|
|
987
|
+
mint: { value: input.mint ?? null, isWritable: true },
|
|
988
|
+
vault: { value: input.vault ?? null, isWritable: true },
|
|
989
|
+
nullifier: { value: input.nullifier ?? null, isWritable: true },
|
|
990
|
+
recipient: { value: input.recipient ?? null, isWritable: true },
|
|
991
|
+
vaultTokenAccount: {
|
|
992
|
+
value: input.vaultTokenAccount ?? null,
|
|
993
|
+
isWritable: true
|
|
994
|
+
},
|
|
995
|
+
recipientTokenAccount: {
|
|
996
|
+
value: input.recipientTokenAccount ?? null,
|
|
997
|
+
isWritable: true
|
|
998
|
+
},
|
|
999
|
+
feeCollector: { value: input.feeCollector ?? null, isWritable: true },
|
|
1000
|
+
feeCollectorTokenAccount: {
|
|
1001
|
+
value: input.feeCollectorTokenAccount ?? null,
|
|
1002
|
+
isWritable: true
|
|
1003
|
+
},
|
|
1004
|
+
systemProgram: { value: input.systemProgram ?? null, isWritable: false },
|
|
1005
|
+
tokenProgram: { value: input.tokenProgram ?? null, isWritable: false },
|
|
1006
|
+
associatedTokenProgram: {
|
|
1007
|
+
value: input.associatedTokenProgram ?? null,
|
|
1008
|
+
isWritable: false
|
|
1009
|
+
}
|
|
1010
|
+
};
|
|
1011
|
+
const accounts = originalAccounts;
|
|
1012
|
+
const args = { ...input };
|
|
1013
|
+
if (!accounts.tokenProgram.value) {
|
|
1014
|
+
accounts.tokenProgram.value = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";
|
|
1015
|
+
}
|
|
1016
|
+
if (!accounts.feeCollector.value) {
|
|
1017
|
+
accounts.feeCollector.value = "5KgfWjGePnbFgDAuCqxB5oymuFxQskvCtrw6eYfDa7fj";
|
|
1018
|
+
}
|
|
1019
|
+
if (!accounts.systemProgram.value) {
|
|
1020
|
+
accounts.systemProgram.value = "11111111111111111111111111111111";
|
|
1021
|
+
}
|
|
1022
|
+
if (!accounts.associatedTokenProgram.value) {
|
|
1023
|
+
accounts.associatedTokenProgram.value = "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL";
|
|
1024
|
+
}
|
|
1025
|
+
const getAccountMeta = getAccountMetaFactory(programAddress);
|
|
1026
|
+
return Object.freeze({
|
|
1027
|
+
accounts: [
|
|
1028
|
+
getAccountMeta(accounts.relayer),
|
|
1029
|
+
getAccountMeta(accounts.pool),
|
|
1030
|
+
getAccountMeta(accounts.mint),
|
|
1031
|
+
getAccountMeta(accounts.vault),
|
|
1032
|
+
getAccountMeta(accounts.nullifier),
|
|
1033
|
+
getAccountMeta(accounts.recipient),
|
|
1034
|
+
getAccountMeta(accounts.vaultTokenAccount),
|
|
1035
|
+
getAccountMeta(accounts.recipientTokenAccount),
|
|
1036
|
+
getAccountMeta(accounts.feeCollector),
|
|
1037
|
+
getAccountMeta(accounts.feeCollectorTokenAccount),
|
|
1038
|
+
getAccountMeta(accounts.systemProgram),
|
|
1039
|
+
getAccountMeta(accounts.tokenProgram),
|
|
1040
|
+
getAccountMeta(accounts.associatedTokenProgram)
|
|
1041
|
+
],
|
|
1042
|
+
data: getTransferInstructionDataEncoder().encode(
|
|
1043
|
+
args
|
|
1044
|
+
),
|
|
1045
|
+
programAddress
|
|
1046
|
+
});
|
|
1047
|
+
}
|
|
1048
|
+
function parseTransferInstruction(instruction) {
|
|
1049
|
+
if (instruction.accounts.length < 13) {
|
|
1050
|
+
throw new Error("Not enough accounts");
|
|
1051
|
+
}
|
|
1052
|
+
let accountIndex = 0;
|
|
1053
|
+
const getNextAccount = () => {
|
|
1054
|
+
const accountMeta = instruction.accounts[accountIndex];
|
|
1055
|
+
accountIndex += 1;
|
|
1056
|
+
return accountMeta;
|
|
1057
|
+
};
|
|
1058
|
+
const getNextOptionalAccount = () => {
|
|
1059
|
+
const accountMeta = getNextAccount();
|
|
1060
|
+
return accountMeta.address === MIXOOR_PROGRAM_ADDRESS ? void 0 : accountMeta;
|
|
1061
|
+
};
|
|
1062
|
+
return {
|
|
1063
|
+
programAddress: instruction.programAddress,
|
|
1064
|
+
accounts: {
|
|
1065
|
+
relayer: getNextAccount(),
|
|
1066
|
+
pool: getNextAccount(),
|
|
1067
|
+
mint: getNextAccount(),
|
|
1068
|
+
vault: getNextAccount(),
|
|
1069
|
+
nullifier: getNextAccount(),
|
|
1070
|
+
recipient: getNextAccount(),
|
|
1071
|
+
vaultTokenAccount: getNextOptionalAccount(),
|
|
1072
|
+
recipientTokenAccount: getNextOptionalAccount(),
|
|
1073
|
+
feeCollector: getNextAccount(),
|
|
1074
|
+
feeCollectorTokenAccount: getNextOptionalAccount(),
|
|
1075
|
+
systemProgram: getNextAccount(),
|
|
1076
|
+
tokenProgram: getNextAccount(),
|
|
1077
|
+
associatedTokenProgram: getNextAccount()
|
|
1078
|
+
},
|
|
1079
|
+
data: getTransferInstructionDataDecoder().decode(instruction.data)
|
|
1080
|
+
};
|
|
1081
|
+
}
|
|
1082
|
+
var poseidon;
|
|
1083
|
+
async function initPoseidon() {
|
|
1084
|
+
if (!poseidon) {
|
|
1085
|
+
poseidon = await circomlibjs.buildPoseidon();
|
|
1086
|
+
}
|
|
1087
|
+
return poseidon;
|
|
1088
|
+
}
|
|
1089
|
+
var SNARK_FIELD_SIZE = BigInt(
|
|
1090
|
+
"21888242871839275222246405745257275088548364400416034343698204186575808495617"
|
|
1091
|
+
);
|
|
1092
|
+
function toFieldElement(bytes) {
|
|
1093
|
+
let bigInt = 0n;
|
|
1094
|
+
for (let i = 0; i < bytes.length; i++) {
|
|
1095
|
+
bigInt = bigInt << 8n | BigInt(bytes[i]);
|
|
1096
|
+
}
|
|
1097
|
+
return (bigInt % SNARK_FIELD_SIZE).toString();
|
|
1098
|
+
}
|
|
1099
|
+
async function poseidonHash(inputs) {
|
|
1100
|
+
await initPoseidon();
|
|
1101
|
+
const hash = poseidon(inputs.map((x) => BigInt(toFieldElement(x))));
|
|
1102
|
+
const hashBigInt = poseidon.F.toObject(hash);
|
|
1103
|
+
const bytes = new Uint8Array(32);
|
|
1104
|
+
let temp = BigInt(hashBigInt);
|
|
1105
|
+
for (let i = 31; i >= 0; i--) {
|
|
1106
|
+
bytes[i] = Number(temp & BigInt(255));
|
|
1107
|
+
temp = temp >> BigInt(8);
|
|
1108
|
+
}
|
|
1109
|
+
return bytes;
|
|
1110
|
+
}
|
|
1111
|
+
async function generateCommitment(secret, nullifier, amount, poolId) {
|
|
1112
|
+
await initPoseidon();
|
|
1113
|
+
const poolIdBytes = kit.getAddressEncoder().encode(poolId);
|
|
1114
|
+
const secretField = BigInt(toFieldElement(secret));
|
|
1115
|
+
const nullifierField = BigInt(toFieldElement(nullifier));
|
|
1116
|
+
const amountField = BigInt(amount);
|
|
1117
|
+
const poolIdField = BigInt(toFieldElement(Uint8Array.from(poolIdBytes)));
|
|
1118
|
+
const hash = poseidon([
|
|
1119
|
+
secretField,
|
|
1120
|
+
nullifierField,
|
|
1121
|
+
amountField,
|
|
1122
|
+
poolIdField
|
|
1123
|
+
]);
|
|
1124
|
+
const hashBigInt = poseidon.F.toObject(hash);
|
|
1125
|
+
const bytes = new Uint8Array(32);
|
|
1126
|
+
let temp = BigInt(hashBigInt);
|
|
1127
|
+
for (let i = 31; i >= 0; i--) {
|
|
1128
|
+
bytes[i] = Number(temp & BigInt(255));
|
|
1129
|
+
temp = temp >> BigInt(8);
|
|
1130
|
+
}
|
|
1131
|
+
return bytes;
|
|
1132
|
+
}
|
|
1133
|
+
async function generateNullifier(nullifier, poolId) {
|
|
1134
|
+
const poolIdBytes = kit.getAddressEncoder().encode(poolId);
|
|
1135
|
+
return await poseidonHash([nullifier, Uint8Array.from(poolIdBytes)]);
|
|
1136
|
+
}
|
|
1137
|
+
function fieldElementToBytes(element) {
|
|
1138
|
+
const bigInt = BigInt(element);
|
|
1139
|
+
const bytes = new Uint8Array(32);
|
|
1140
|
+
for (let i = 0; i < 32; i++) {
|
|
1141
|
+
bytes[31 - i] = Number(bigInt >> BigInt(i * 8) & BigInt(255));
|
|
1142
|
+
}
|
|
1143
|
+
return bytes;
|
|
1144
|
+
}
|
|
1145
|
+
function publicSignalToBytes(signal) {
|
|
1146
|
+
const bigInt = BigInt(signal);
|
|
1147
|
+
const bytes = new Uint8Array(32);
|
|
1148
|
+
for (let i = 0; i < 32; i++) {
|
|
1149
|
+
bytes[31 - i] = Number(bigInt >> BigInt(i * 8) & BigInt(255));
|
|
1150
|
+
}
|
|
1151
|
+
return bytes;
|
|
1152
|
+
}
|
|
1153
|
+
function g1PointToBytes(point) {
|
|
1154
|
+
const x = fieldElementToBytes(point[0]);
|
|
1155
|
+
const y = fieldElementToBytes(point[1]);
|
|
1156
|
+
const result = new Uint8Array(64);
|
|
1157
|
+
result.set(x, 0);
|
|
1158
|
+
result.set(y, 32);
|
|
1159
|
+
return result;
|
|
1160
|
+
}
|
|
1161
|
+
function g2PointToBytes(point) {
|
|
1162
|
+
const x1 = fieldElementToBytes(point[0][1]);
|
|
1163
|
+
const x0 = fieldElementToBytes(point[0][0]);
|
|
1164
|
+
const y1 = fieldElementToBytes(point[1][1]);
|
|
1165
|
+
const y0 = fieldElementToBytes(point[1][0]);
|
|
1166
|
+
const result = new Uint8Array(128);
|
|
1167
|
+
result.set(x1, 0);
|
|
1168
|
+
result.set(x0, 32);
|
|
1169
|
+
result.set(y1, 64);
|
|
1170
|
+
result.set(y0, 96);
|
|
1171
|
+
return result;
|
|
1172
|
+
}
|
|
1173
|
+
async function generateProof(input) {
|
|
1174
|
+
await initPoseidon();
|
|
1175
|
+
const poolIdBytes = kit.getAddressEncoder().encode(input.poolAddress);
|
|
1176
|
+
const circuitInputs = {
|
|
1177
|
+
root: toFieldElement(input.root),
|
|
1178
|
+
nullifierHash: toFieldElement(
|
|
1179
|
+
await generateNullifier(input.nullifier, input.poolAddress)
|
|
1180
|
+
),
|
|
1181
|
+
recipient: toFieldElement(input.recipient),
|
|
1182
|
+
relayer: toFieldElement(input.relayer),
|
|
1183
|
+
fee: input.fee,
|
|
1184
|
+
refund: input.refund,
|
|
1185
|
+
poolId: toFieldElement(Uint8Array.from(poolIdBytes)),
|
|
1186
|
+
secret: toFieldElement(input.secret),
|
|
1187
|
+
nullifier: toFieldElement(input.nullifier),
|
|
1188
|
+
pathElements: input.pathElements.map((x) => toFieldElement(x)),
|
|
1189
|
+
pathIndices: input.pathIndices,
|
|
1190
|
+
amount: BigInt(input.amount).toString()
|
|
1191
|
+
};
|
|
1192
|
+
const wasmPath = path__namespace.join(
|
|
1193
|
+
__dirname,
|
|
1194
|
+
"../../../../circuits/build/transaction_js/transaction.wasm"
|
|
1195
|
+
);
|
|
1196
|
+
const zkeyPath = path__namespace.join(
|
|
1197
|
+
__dirname,
|
|
1198
|
+
"../../../../circuits/transaction_0001.zkey"
|
|
1199
|
+
);
|
|
1200
|
+
const { proof, publicSignals } = await snarkjs.groth16.fullProve(
|
|
1201
|
+
circuitInputs,
|
|
1202
|
+
wasmPath,
|
|
1203
|
+
zkeyPath
|
|
1204
|
+
);
|
|
1205
|
+
const vKeyPath = path__namespace.join(
|
|
1206
|
+
__dirname,
|
|
1207
|
+
"../../../../circuits/verification_key.json"
|
|
1208
|
+
);
|
|
1209
|
+
const isValid = await snarkjs.groth16.verify(
|
|
1210
|
+
JSON.parse(fs__namespace.readFileSync(vKeyPath, "utf8")),
|
|
1211
|
+
publicSignals,
|
|
1212
|
+
proof
|
|
1213
|
+
);
|
|
1214
|
+
console.log("Local proof verification:", isValid ? "VALID \u2713" : "INVALID \u2717");
|
|
1215
|
+
if (!isValid) {
|
|
1216
|
+
throw new Error("Generated proof is invalid - check circuit inputs");
|
|
1217
|
+
}
|
|
1218
|
+
const publicInputs = publicSignals.map(
|
|
1219
|
+
(signal) => publicSignalToBytes(signal)
|
|
1220
|
+
);
|
|
1221
|
+
console.log(
|
|
1222
|
+
"DEBUG: Generated Public Inputs (Keys: root, nullifierHash, recipient, relayer, fee, refund, poolId):"
|
|
1223
|
+
);
|
|
1224
|
+
publicInputs.forEach((input2, i) => {
|
|
1225
|
+
const hexBE = Buffer.from(input2).toString("hex");
|
|
1226
|
+
const hexLE = Buffer.from(input2.slice().reverse()).toString("hex");
|
|
1227
|
+
console.log(`Input ${i}: BE=${hexBE} | LE=${hexLE}`);
|
|
1228
|
+
});
|
|
1229
|
+
const proof_a = g1PointToBytes([proof.pi_a[0], proof.pi_a[1]]);
|
|
1230
|
+
const proof_b = g2PointToBytes([
|
|
1231
|
+
[proof.pi_b[0][0], proof.pi_b[0][1]],
|
|
1232
|
+
[proof.pi_b[1][0], proof.pi_b[1][1]]
|
|
1233
|
+
]);
|
|
1234
|
+
const proof_c = g1PointToBytes([proof.pi_c[0], proof.pi_c[1]]);
|
|
1235
|
+
return {
|
|
1236
|
+
proofData: {
|
|
1237
|
+
proofA: proof_a,
|
|
1238
|
+
proofB: proof_b,
|
|
1239
|
+
proofC: proof_c
|
|
1240
|
+
},
|
|
1241
|
+
publicInputs
|
|
1242
|
+
};
|
|
1243
|
+
}
|
|
1244
|
+
function randomBytes(size) {
|
|
1245
|
+
return new Uint8Array(crypto.randomBytes(size));
|
|
1246
|
+
}
|
|
1247
|
+
function toHex(bytes) {
|
|
1248
|
+
return Buffer.from(bytes).toString("hex");
|
|
1249
|
+
}
|
|
1250
|
+
function fromHex(hex) {
|
|
1251
|
+
return new Uint8Array(Buffer.from(hex, "hex"));
|
|
1252
|
+
}
|
|
1253
|
+
var MerkleTree = class {
|
|
1254
|
+
levels;
|
|
1255
|
+
_leaves;
|
|
1256
|
+
_zeros;
|
|
1257
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1258
|
+
poseidon;
|
|
1259
|
+
initialized = false;
|
|
1260
|
+
constructor(levels) {
|
|
1261
|
+
this.levels = levels;
|
|
1262
|
+
this._leaves = [];
|
|
1263
|
+
this._zeros = [];
|
|
1264
|
+
}
|
|
1265
|
+
async initialize() {
|
|
1266
|
+
if (this.initialized) return;
|
|
1267
|
+
this.poseidon = await circomlibjs.buildPoseidon();
|
|
1268
|
+
this._zeros[0] = new Uint8Array(32);
|
|
1269
|
+
this.initialized = true;
|
|
1270
|
+
for (let i = 1; i <= this.levels; i++) {
|
|
1271
|
+
this._zeros[i] = this.hash(this._zeros[i - 1], this._zeros[i - 1]);
|
|
1272
|
+
}
|
|
1273
|
+
}
|
|
1274
|
+
hash(left, right) {
|
|
1275
|
+
if (!this.poseidon) {
|
|
1276
|
+
throw new Error("MerkleTree not initialized. Call initialize() first");
|
|
1277
|
+
}
|
|
1278
|
+
const SNARK_FIELD_SIZE2 = BigInt(
|
|
1279
|
+
"21888242871839275222246405745257275088548364400416034343698204186575808495617"
|
|
1280
|
+
);
|
|
1281
|
+
const leftBigInt = this.uint8ArrayToBigInt(left) % SNARK_FIELD_SIZE2;
|
|
1282
|
+
const rightBigInt = this.uint8ArrayToBigInt(right) % SNARK_FIELD_SIZE2;
|
|
1283
|
+
const result = this.poseidon([leftBigInt, rightBigInt]);
|
|
1284
|
+
const resultBytes = this.poseidon.F.toObject(result);
|
|
1285
|
+
return this.bigIntToUint8Array(BigInt(resultBytes));
|
|
1286
|
+
}
|
|
1287
|
+
uint8ArrayToBigInt(arr) {
|
|
1288
|
+
let hex = "0x";
|
|
1289
|
+
for (let i = 0; i < arr.length; i++) {
|
|
1290
|
+
hex += arr[i].toString(16).padStart(2, "0");
|
|
1291
|
+
}
|
|
1292
|
+
return BigInt(hex);
|
|
1293
|
+
}
|
|
1294
|
+
bigIntToUint8Array(value) {
|
|
1295
|
+
const bytes = new Uint8Array(32);
|
|
1296
|
+
let temp = value;
|
|
1297
|
+
for (let i = 31; i >= 0; i--) {
|
|
1298
|
+
bytes[i] = Number(temp & BigInt(255));
|
|
1299
|
+
temp = temp >> BigInt(8);
|
|
1300
|
+
}
|
|
1301
|
+
return bytes;
|
|
1302
|
+
}
|
|
1303
|
+
insert(leaf) {
|
|
1304
|
+
if (!this.initialized) {
|
|
1305
|
+
throw new Error("MerkleTree not initialized. Call initialize() first");
|
|
1306
|
+
}
|
|
1307
|
+
this._leaves.push(leaf);
|
|
1308
|
+
}
|
|
1309
|
+
root() {
|
|
1310
|
+
if (!this.initialized) {
|
|
1311
|
+
throw new Error("MerkleTree not initialized. Call initialize() first");
|
|
1312
|
+
}
|
|
1313
|
+
if (this._leaves.length === 0) {
|
|
1314
|
+
return this._zeros[this.levels];
|
|
1315
|
+
}
|
|
1316
|
+
let currentLevel = [...this._leaves];
|
|
1317
|
+
for (let level = 0; level < this.levels; level++) {
|
|
1318
|
+
const nextLevel = [];
|
|
1319
|
+
for (let i = 0; i < currentLevel.length; i += 2) {
|
|
1320
|
+
const left = currentLevel[i];
|
|
1321
|
+
const right = i + 1 < currentLevel.length ? currentLevel[i + 1] : this._zeros[level];
|
|
1322
|
+
nextLevel.push(this.hash(left, right));
|
|
1323
|
+
}
|
|
1324
|
+
currentLevel = nextLevel;
|
|
1325
|
+
}
|
|
1326
|
+
return currentLevel[0];
|
|
1327
|
+
}
|
|
1328
|
+
getProof(index) {
|
|
1329
|
+
if (!this.initialized) {
|
|
1330
|
+
throw new Error("MerkleTree not initialized. Call initialize() first");
|
|
1331
|
+
}
|
|
1332
|
+
if (index >= this._leaves.length) {
|
|
1333
|
+
throw new Error("Leaf index out of bounds");
|
|
1334
|
+
}
|
|
1335
|
+
const pathElements = [];
|
|
1336
|
+
const pathIndices = [];
|
|
1337
|
+
let currentLevel = [...this._leaves];
|
|
1338
|
+
let currentIndex = index;
|
|
1339
|
+
for (let level = 0; level < this.levels; level++) {
|
|
1340
|
+
const isLeft = currentIndex % 2 === 0;
|
|
1341
|
+
const siblingIndex = isLeft ? currentIndex + 1 : currentIndex - 1;
|
|
1342
|
+
const sibling = siblingIndex < currentLevel.length ? currentLevel[siblingIndex] : this._zeros[level];
|
|
1343
|
+
pathElements.push(sibling);
|
|
1344
|
+
pathIndices.push(isLeft ? 0 : 1);
|
|
1345
|
+
const nextLevel = [];
|
|
1346
|
+
for (let i = 0; i < currentLevel.length; i += 2) {
|
|
1347
|
+
const left = currentLevel[i];
|
|
1348
|
+
const right = i + 1 < currentLevel.length ? currentLevel[i + 1] : this._zeros[level];
|
|
1349
|
+
nextLevel.push(this.hash(left, right));
|
|
1350
|
+
}
|
|
1351
|
+
currentLevel = nextLevel;
|
|
1352
|
+
currentIndex = Math.floor(currentIndex / 2);
|
|
1353
|
+
}
|
|
1354
|
+
return { pathElements, pathIndices };
|
|
1355
|
+
}
|
|
1356
|
+
};
|
|
1357
|
+
function extractMerkleRootFromAccount(_client, _poolAddress) {
|
|
1358
|
+
throw new Error(
|
|
1359
|
+
"Merkle tree is off-chain now. Build it locally from CommitmentInserted events. For tests, use your MerkleTree instance: merkleTree.root()"
|
|
1360
|
+
);
|
|
1361
|
+
}
|
|
1362
|
+
async function findPoolAddress(seeds, config = {}) {
|
|
1363
|
+
const { programAddress = MIXOOR_PROGRAM_ADDRESS } = config;
|
|
1364
|
+
return await kit.getProgramDerivedAddress({
|
|
1365
|
+
programAddress,
|
|
1366
|
+
seeds: ["pool", kit.getAddressEncoder().encode(seeds.mint)]
|
|
1367
|
+
});
|
|
1368
|
+
}
|
|
1369
|
+
async function findMerkleTreeAddress(seeds, config = {}) {
|
|
1370
|
+
const { programAddress = MIXOOR_PROGRAM_ADDRESS } = config;
|
|
1371
|
+
return await kit.getProgramDerivedAddress({
|
|
1372
|
+
programAddress,
|
|
1373
|
+
seeds: ["merkle", kit.getAddressEncoder().encode(seeds.pool)]
|
|
1374
|
+
});
|
|
1375
|
+
}
|
|
1376
|
+
async function findVaultAddress(seeds, config = {}) {
|
|
1377
|
+
const { programAddress = MIXOOR_PROGRAM_ADDRESS } = config;
|
|
1378
|
+
return await kit.getProgramDerivedAddress({
|
|
1379
|
+
programAddress,
|
|
1380
|
+
seeds: ["vault", kit.getAddressEncoder().encode(seeds.pool)]
|
|
1381
|
+
});
|
|
1382
|
+
}
|
|
1383
|
+
|
|
1384
|
+
exports.AssetType = AssetType;
|
|
1385
|
+
exports.DEPOSIT_DISCRIMINATOR = DEPOSIT_DISCRIMINATOR;
|
|
1386
|
+
exports.INITIALIZE_POOL_DISCRIMINATOR = INITIALIZE_POOL_DISCRIMINATOR;
|
|
1387
|
+
exports.MIXOOR_ERROR__INSUFFICIENT_FUNDS = MIXOOR_ERROR__INSUFFICIENT_FUNDS;
|
|
1388
|
+
exports.MIXOOR_ERROR__INVALID_AMOUNT = MIXOOR_ERROR__INVALID_AMOUNT;
|
|
1389
|
+
exports.MIXOOR_ERROR__INVALID_ASSET_TYPE = MIXOOR_ERROR__INVALID_ASSET_TYPE;
|
|
1390
|
+
exports.MIXOOR_ERROR__INVALID_MERKLE_PROOF = MIXOOR_ERROR__INVALID_MERKLE_PROOF;
|
|
1391
|
+
exports.MIXOOR_ERROR__INVALID_MERKLE_TREE = MIXOOR_ERROR__INVALID_MERKLE_TREE;
|
|
1392
|
+
exports.MIXOOR_ERROR__INVALID_MERKLE_TREE_ADDRESS = MIXOOR_ERROR__INVALID_MERKLE_TREE_ADDRESS;
|
|
1393
|
+
exports.MIXOOR_ERROR__INVALID_PROOF = MIXOOR_ERROR__INVALID_PROOF;
|
|
1394
|
+
exports.MIXOOR_ERROR__INVALID_PUBLIC_INPUTS = MIXOOR_ERROR__INVALID_PUBLIC_INPUTS;
|
|
1395
|
+
exports.MIXOOR_ERROR__MERKLE_TREE_FULL = MIXOOR_ERROR__MERKLE_TREE_FULL;
|
|
1396
|
+
exports.MIXOOR_ERROR__MISSING_TOKEN_ACCOUNT = MIXOOR_ERROR__MISSING_TOKEN_ACCOUNT;
|
|
1397
|
+
exports.MIXOOR_ERROR__OVERFLOW = MIXOOR_ERROR__OVERFLOW;
|
|
1398
|
+
exports.MIXOOR_ERROR__POSEIDON_HASH_ERROR = MIXOOR_ERROR__POSEIDON_HASH_ERROR;
|
|
1399
|
+
exports.MIXOOR_ERROR__UNKNOWN_ROOT = MIXOOR_ERROR__UNKNOWN_ROOT;
|
|
1400
|
+
exports.MIXOOR_PROGRAM_ADDRESS = MIXOOR_PROGRAM_ADDRESS;
|
|
1401
|
+
exports.MerkleTree = MerkleTree;
|
|
1402
|
+
exports.MixoorAccount = MixoorAccount;
|
|
1403
|
+
exports.MixoorInstruction = MixoorInstruction;
|
|
1404
|
+
exports.NULLIFIER_ACCOUNT_DISCRIMINATOR = NULLIFIER_ACCOUNT_DISCRIMINATOR;
|
|
1405
|
+
exports.POOL_DISCRIMINATOR = POOL_DISCRIMINATOR;
|
|
1406
|
+
exports.TRANSFER_DISCRIMINATOR = TRANSFER_DISCRIMINATOR;
|
|
1407
|
+
exports.VAULT_DISCRIMINATOR = VAULT_DISCRIMINATOR;
|
|
1408
|
+
exports.decodeNullifierAccount = decodeNullifierAccount;
|
|
1409
|
+
exports.decodePool = decodePool;
|
|
1410
|
+
exports.decodeVault = decodeVault;
|
|
1411
|
+
exports.extractMerkleRootFromAccount = extractMerkleRootFromAccount;
|
|
1412
|
+
exports.fetchAllMaybeNullifierAccount = fetchAllMaybeNullifierAccount;
|
|
1413
|
+
exports.fetchAllMaybePool = fetchAllMaybePool;
|
|
1414
|
+
exports.fetchAllMaybeVault = fetchAllMaybeVault;
|
|
1415
|
+
exports.fetchAllNullifierAccount = fetchAllNullifierAccount;
|
|
1416
|
+
exports.fetchAllPool = fetchAllPool;
|
|
1417
|
+
exports.fetchAllVault = fetchAllVault;
|
|
1418
|
+
exports.fetchMaybeNullifierAccount = fetchMaybeNullifierAccount;
|
|
1419
|
+
exports.fetchMaybePool = fetchMaybePool;
|
|
1420
|
+
exports.fetchMaybeVault = fetchMaybeVault;
|
|
1421
|
+
exports.fetchNullifierAccount = fetchNullifierAccount;
|
|
1422
|
+
exports.fetchPool = fetchPool;
|
|
1423
|
+
exports.fetchVault = fetchVault;
|
|
1424
|
+
exports.findMerkleTreeAddress = findMerkleTreeAddress;
|
|
1425
|
+
exports.findPoolAddress = findPoolAddress;
|
|
1426
|
+
exports.findVaultAddress = findVaultAddress;
|
|
1427
|
+
exports.fromHex = fromHex;
|
|
1428
|
+
exports.generateCommitment = generateCommitment;
|
|
1429
|
+
exports.generateNullifier = generateNullifier;
|
|
1430
|
+
exports.generateProof = generateProof;
|
|
1431
|
+
exports.getAssetTypeCodec = getAssetTypeCodec;
|
|
1432
|
+
exports.getAssetTypeDecoder = getAssetTypeDecoder;
|
|
1433
|
+
exports.getAssetTypeEncoder = getAssetTypeEncoder;
|
|
1434
|
+
exports.getCommitmentInsertedCodec = getCommitmentInsertedCodec;
|
|
1435
|
+
exports.getCommitmentInsertedDecoder = getCommitmentInsertedDecoder;
|
|
1436
|
+
exports.getCommitmentInsertedEncoder = getCommitmentInsertedEncoder;
|
|
1437
|
+
exports.getDepositDiscriminatorBytes = getDepositDiscriminatorBytes;
|
|
1438
|
+
exports.getDepositInstruction = getDepositInstruction;
|
|
1439
|
+
exports.getDepositInstructionAsync = getDepositInstructionAsync;
|
|
1440
|
+
exports.getDepositInstructionDataCodec = getDepositInstructionDataCodec;
|
|
1441
|
+
exports.getDepositInstructionDataDecoder = getDepositInstructionDataDecoder;
|
|
1442
|
+
exports.getDepositInstructionDataEncoder = getDepositInstructionDataEncoder;
|
|
1443
|
+
exports.getInitializePoolDiscriminatorBytes = getInitializePoolDiscriminatorBytes;
|
|
1444
|
+
exports.getInitializePoolInstruction = getInitializePoolInstruction;
|
|
1445
|
+
exports.getInitializePoolInstructionAsync = getInitializePoolInstructionAsync;
|
|
1446
|
+
exports.getInitializePoolInstructionDataCodec = getInitializePoolInstructionDataCodec;
|
|
1447
|
+
exports.getInitializePoolInstructionDataDecoder = getInitializePoolInstructionDataDecoder;
|
|
1448
|
+
exports.getInitializePoolInstructionDataEncoder = getInitializePoolInstructionDataEncoder;
|
|
1449
|
+
exports.getMixoorErrorMessage = getMixoorErrorMessage;
|
|
1450
|
+
exports.getNullifierAccountCodec = getNullifierAccountCodec;
|
|
1451
|
+
exports.getNullifierAccountDecoder = getNullifierAccountDecoder;
|
|
1452
|
+
exports.getNullifierAccountDiscriminatorBytes = getNullifierAccountDiscriminatorBytes;
|
|
1453
|
+
exports.getNullifierAccountEncoder = getNullifierAccountEncoder;
|
|
1454
|
+
exports.getNullifierAccountSize = getNullifierAccountSize;
|
|
1455
|
+
exports.getPoolCodec = getPoolCodec;
|
|
1456
|
+
exports.getPoolDecoder = getPoolDecoder;
|
|
1457
|
+
exports.getPoolDiscriminatorBytes = getPoolDiscriminatorBytes;
|
|
1458
|
+
exports.getPoolEncoder = getPoolEncoder;
|
|
1459
|
+
exports.getPoolSize = getPoolSize;
|
|
1460
|
+
exports.getRootEntryCodec = getRootEntryCodec;
|
|
1461
|
+
exports.getRootEntryDecoder = getRootEntryDecoder;
|
|
1462
|
+
exports.getRootEntryEncoder = getRootEntryEncoder;
|
|
1463
|
+
exports.getTransferDiscriminatorBytes = getTransferDiscriminatorBytes;
|
|
1464
|
+
exports.getTransferInstruction = getTransferInstruction;
|
|
1465
|
+
exports.getTransferInstructionAsync = getTransferInstructionAsync;
|
|
1466
|
+
exports.getTransferInstructionDataCodec = getTransferInstructionDataCodec;
|
|
1467
|
+
exports.getTransferInstructionDataDecoder = getTransferInstructionDataDecoder;
|
|
1468
|
+
exports.getTransferInstructionDataEncoder = getTransferInstructionDataEncoder;
|
|
1469
|
+
exports.getVaultCodec = getVaultCodec;
|
|
1470
|
+
exports.getVaultDecoder = getVaultDecoder;
|
|
1471
|
+
exports.getVaultDiscriminatorBytes = getVaultDiscriminatorBytes;
|
|
1472
|
+
exports.getVaultEncoder = getVaultEncoder;
|
|
1473
|
+
exports.getVaultSize = getVaultSize;
|
|
1474
|
+
exports.identifyMixoorAccount = identifyMixoorAccount;
|
|
1475
|
+
exports.identifyMixoorInstruction = identifyMixoorInstruction;
|
|
1476
|
+
exports.isMixoorError = isMixoorError;
|
|
1477
|
+
exports.parseDepositInstruction = parseDepositInstruction;
|
|
1478
|
+
exports.parseInitializePoolInstruction = parseInitializePoolInstruction;
|
|
1479
|
+
exports.parseTransferInstruction = parseTransferInstruction;
|
|
1480
|
+
exports.poseidonHash = poseidonHash;
|
|
1481
|
+
exports.randomBytes = randomBytes;
|
|
1482
|
+
exports.toHex = toHex;
|
|
1483
|
+
//# sourceMappingURL=index.js.map
|
|
1484
|
+
//# sourceMappingURL=index.js.map
|