@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.
Binary file
@@ -1,124 +1,115 @@
1
1
  {
2
- "protocol": "groth16",
3
- "curve": "bn128",
4
- "nPublic": 7,
5
- "vk_alpha_1": [
6
- "5546433345559129444237190777830761250332113749146486872468235040665291734547",
7
- "13963905734702601515485862894046335164180959786365513804837155437966338284436",
8
- "1"
9
- ],
10
- "vk_beta_2": [
11
- [
12
- "21412145793220292067859405918112107716359293542119378539352891116432217911143",
13
- "2611966564152221085363047640833318876719586724975105066179882056173108088903"
2
+ "protocol": "groth16",
3
+ "curve": "bn128",
4
+ "nPublic": 7,
5
+ "vk_alpha_1": [
6
+ "10682077369620390470672191943941755806401562773406118168125211005198142236229",
7
+ "18516280274548043265075789800457661020967268084471806959300470959610232621362",
8
+ "1"
14
9
  ],
15
- [
16
- "5683913335783624892102444117130791035155207942152776919376767806572080471466",
17
- "20424418561484727324565184652251513974075649083989440164478053411013464042109"
10
+ "vk_beta_2": [
11
+ [
12
+ "1721186449098360879715205785763954946450032460477406779451565366651601272997",
13
+ "15975801424202176299743118874578724262799622074807931890167230307041296454694"
14
+ ],
15
+ [
16
+ "768812259572708274067987333022194397471490825841210597153387150410437539788",
17
+ "12314575679613070604619946798376425642024326214433278915467225005027639469645"
18
+ ],
19
+ ["1", "0"]
18
20
  ],
19
- [
20
- "1",
21
- "0"
22
- ]
23
- ],
24
- "vk_gamma_2": [
25
- [
26
- "10857046999023057135944570762232829481370756359578518086990519993285655852781",
27
- "11559732032986387107991004021392285783925812861821192530917403151452391805634"
28
- ],
29
- [
30
- "8495653923123431417604973247489272438418190587263600148770280649306958101930",
31
- "4082367875863433681332203403145435568316851327593401208105741076214120093531"
32
- ],
33
- [
34
- "1",
35
- "0"
36
- ]
37
- ],
38
- "vk_delta_2": [
39
- [
40
- "14990800869627850257893476139502138886842300073782552416527527220211999051021",
41
- "12019227350316302784523778352691865318953394316697895104204947035916007498199"
42
- ],
43
- [
44
- "4782487834358741961569897821318547231280402135966285712520334657603277542574",
45
- "2749538355489199106712219902886462447683742227659308580079039377096586499583"
46
- ],
47
- [
48
- "1",
49
- "0"
50
- ]
51
- ],
52
- "vk_alphabeta_12": [
53
- [
54
- [
55
- "16004604140728965578138661638211594037063293277199793332563710415107506403520",
56
- "11147560166332981252925195150980455467875144655505899867249798224526410047168"
57
- ],
58
- [
59
- "6885248949178366070388253878092568893637466600168081265843685606931844530240",
60
- "16338979583697105458788164829930805615704040650316790143822770401021791453011"
61
- ],
62
- [
63
- "16999255288466657357929768473293392136087902628034586995869476993675858607964",
64
- "17319716874845868217639405801798359751259784577964908873054359885398726572212"
65
- ]
66
- ],
67
- [
68
- [
69
- "16065932114393349213400212155432985804364119886372730654401480458147339753454",
70
- "19492410405735392736025405612326078134005714512479382795304779697851446975052"
71
- ],
72
- [
73
- "19316995995129947188171619844923027852024324073427133485549527394782130881463",
74
- "15152158843247135514589563238821772760234127722300614674014602048664122417314"
75
- ],
76
- [
77
- "4413911027750469686293381147712195016200499995285328063918209101558201901380",
78
- "13756379472300325575468067886046279096717793365882446758762570308974885229873"
79
- ]
80
- ]
81
- ],
82
- "IC": [
83
- [
84
- "3949268453856671477837944156738550879784344849318952569404254752776571543558",
85
- "18880214408650637025151652959348151451776787379955660714374817103157848430447",
86
- "1"
87
- ],
88
- [
89
- "7595383299465162355762836247608390932868047357866691105205992865750052290945",
90
- "20433437015153212901089547709024839459004759345208190123539659491221344306189",
91
- "1"
92
- ],
93
- [
94
- "13374632508151173855086275271447357852814774320197819996760809172154184804557",
95
- "16243978781153453546157051308457933764757039947655668837125687410464695287676",
96
- "1"
97
- ],
98
- [
99
- "5100006802904210985453765707472395269225543487583823550337192150736970528292",
100
- "11422826625115544450768095068673594582668285010128785727772989005420123848364",
101
- "1"
102
- ],
103
- [
104
- "6372192181718433266625543056882793633891933831629698322649596298241635548389",
105
- "1709100153456215113738425147889192593829068042544692876702518987995366013294",
106
- "1"
21
+ "vk_gamma_2": [
22
+ [
23
+ "10857046999023057135944570762232829481370756359578518086990519993285655852781",
24
+ "11559732032986387107991004021392285783925812861821192530917403151452391805634"
25
+ ],
26
+ [
27
+ "8495653923123431417604973247489272438418190587263600148770280649306958101930",
28
+ "4082367875863433681332203403145435568316851327593401208105741076214120093531"
29
+ ],
30
+ ["1", "0"]
107
31
  ],
108
- [
109
- "19023554220556579593405142750585200583727431288001850956526899901383498587894",
110
- "18297669907692343833002904807534260395539852692277207966597076894953025600140",
111
- "1"
32
+ "vk_delta_2": [
33
+ [
34
+ "11288288598486280333888896815388982141923920071063235530573263155299681574663",
35
+ "20204709969587071650290879313621593092672746746019171366651596352828588169015"
36
+ ],
37
+ [
38
+ "16028446280144140733417863155990994277946461311560136943295621069314843993463",
39
+ "13219556331739353167326336871085263223517435300657854349663555662288681302820"
40
+ ],
41
+ ["1", "0"]
112
42
  ],
113
- [
114
- "8941916294769993668611112875396217591149851648038239397926633496081198913978",
115
- "9988646368972541886335809760033327451475524812702990285260789674301170666927",
116
- "1"
43
+ "vk_alphabeta_12": [
44
+ [
45
+ [
46
+ "9518393467030687778362421976414365543442395444074114717946109423555856390800",
47
+ "10494959380723343697407652664710741755507871538095970815698653867876454444460"
48
+ ],
49
+ [
50
+ "21707761660911474091257886735768318442459314721770099121620404251246606795918",
51
+ "20298782457644837729671984411114036654961751675881335324009014602862417708496"
52
+ ],
53
+ [
54
+ "11521001865771922669452267308933996867023570860304919440000362482946247816571",
55
+ "15688401513242912467371425405728069066161657347478477258423528592888793863046"
56
+ ]
57
+ ],
58
+ [
59
+ [
60
+ "17926964466292241307753679690071545611894135095194611278005300459638735985275",
61
+ "4294893626773636618729713105095130779223800196533566051625817280313404966262"
62
+ ],
63
+ [
64
+ "10904353822845988768072629637622809686476950637689044427798094714297050913553",
65
+ "11281209735348744001516242567334022729276183574028464182923678770132768229384"
66
+ ],
67
+ [
68
+ "1756564607795176477222752371032854291139593544552439699787324126232466385418",
69
+ "9981039337733913835270922061423936011994489455127830453076124991671391188899"
70
+ ]
71
+ ]
117
72
  ],
118
- [
119
- "1442460910073871138127576487044360633238044344422191659635689177249834998473",
120
- "14346911267655939600069210937090128179049312695187836316371484475583295682383",
121
- "1"
73
+ "IC": [
74
+ [
75
+ "20900658727185368861189514638640394334687544907429003224592977157339464086399",
76
+ "8404536624604833207697675211543991349815864918911893838947144025192618330306",
77
+ "1"
78
+ ],
79
+ [
80
+ "6608587653630007035440323386802184877437336970939721453016507018215158477721",
81
+ "6849722319551100654606971003136630622999162217818215653480003984933738191350",
82
+ "1"
83
+ ],
84
+ [
85
+ "17314278680230802744556788650287395270877776058258795875397726285390368761769",
86
+ "8538456233993825786511409342233924822486233013209564644051142048898858014462",
87
+ "1"
88
+ ],
89
+ [
90
+ "2379791508054612066223968488060803268212351162467242184911036096789433279574",
91
+ "9294447565247345541626090703957177969390258948149368176400159038909870325052",
92
+ "1"
93
+ ],
94
+ [
95
+ "11634073295286663567488987523044607222026400804941157797325897067133160732987",
96
+ "4411574583372809640582532197134768896724830303468704698621344226310034980457",
97
+ "1"
98
+ ],
99
+ [
100
+ "1051309528532532181495401458524320915480800154043197311568239379175701995237",
101
+ "16049650041774514901903699946886420271437149091901188280115629660280394231382",
102
+ "1"
103
+ ],
104
+ [
105
+ "10765307682165219589500307233502571823837307903862854252412437845558662033180",
106
+ "5810241881886990319631921824916908518649587202772244188940553300875033523615",
107
+ "1"
108
+ ],
109
+ [
110
+ "21390118222734437031030539323317055818291450854673372268124653216684520473972",
111
+ "20379989733267052681730672792521850270626738173993553817946684140254030745648",
112
+ "1"
113
+ ]
122
114
  ]
123
- ]
124
- }
115
+ }
package/dist/src/index.js CHANGED
@@ -174,7 +174,7 @@ function getPoolEncoder() {
174
174
  ["mint", kit.getAddressEncoder()],
175
175
  ["vault", kit.getAddressEncoder()],
176
176
  ["feeCollector", kit.getAddressEncoder()],
177
- ["rootHistory", kit.getArrayEncoder(getRootEntryEncoder(), { size: 30 })],
177
+ ["rootHistory", kit.getArrayEncoder(getRootEntryEncoder(), { size: 50 })],
178
178
  ["totalDeposited", kit.getU64Encoder()],
179
179
  ["totalWithdrawn", kit.getU64Encoder()],
180
180
  ["nextLeafIndex", kit.getU32Encoder()],
@@ -193,7 +193,7 @@ function getPoolDecoder() {
193
193
  ["mint", kit.getAddressDecoder()],
194
194
  ["vault", kit.getAddressDecoder()],
195
195
  ["feeCollector", kit.getAddressDecoder()],
196
- ["rootHistory", kit.getArrayDecoder(getRootEntryDecoder(), { size: 30 })],
196
+ ["rootHistory", kit.getArrayDecoder(getRootEntryDecoder(), { size: 50 })],
197
197
  ["totalDeposited", kit.getU64Decoder()],
198
198
  ["totalWithdrawn", kit.getU64Decoder()],
199
199
  ["nextLeafIndex", kit.getU32Decoder()],
@@ -231,7 +231,7 @@ async function fetchAllMaybePool(rpc, addresses, config) {
231
231
  return maybeAccounts.map((maybeAccount) => decodePool(maybeAccount));
232
232
  }
233
233
  function getPoolSize() {
234
- return 1360;
234
+ return 2160;
235
235
  }
236
236
  var VAULT_DISCRIMINATOR = new Uint8Array([
237
237
  211,
@@ -287,7 +287,7 @@ async function fetchAllMaybeVault(rpc, addresses, config) {
287
287
  function getVaultSize() {
288
288
  return 8;
289
289
  }
290
- var MIXOOR_PROGRAM_ADDRESS = "mixmC791jTymqvJR2Zgvd8NAvXpXw99GdCW5uQcMBj8";
290
+ var MIXOOR_PROGRAM_ADDRESS = "mixEcfx7w47hvRwb9Nj7UeSQkCz6vZMbRHixMyYMLMb";
291
291
  var MixoorAccount = /* @__PURE__ */ ((MixoorAccount2) => {
292
292
  MixoorAccount2[MixoorAccount2["NullifierAccount"] = 0] = "NullifierAccount";
293
293
  MixoorAccount2[MixoorAccount2["Pool"] = 1] = "Pool";
@@ -381,6 +381,7 @@ var MIXOOR_ERROR__INVALID_MERKLE_TREE = 6009;
381
381
  var MIXOOR_ERROR__POSEIDON_HASH_ERROR = 6010;
382
382
  var MIXOOR_ERROR__MERKLE_TREE_FULL = 6011;
383
383
  var MIXOOR_ERROR__INVALID_MERKLE_PROOF = 6012;
384
+ var MIXOOR_ERROR__PUBLIC_INPUT_MISMATCH = 6013;
384
385
  var mixoorErrorMessages;
385
386
  if (process.env.NODE_ENV !== "production") {
386
387
  mixoorErrorMessages = {
@@ -396,6 +397,7 @@ if (process.env.NODE_ENV !== "production") {
396
397
  [MIXOOR_ERROR__MISSING_TOKEN_ACCOUNT]: `Missing token account`,
397
398
  [MIXOOR_ERROR__OVERFLOW]: `Overflow`,
398
399
  [MIXOOR_ERROR__POSEIDON_HASH_ERROR]: `Poseidon hash error`,
400
+ [MIXOOR_ERROR__PUBLIC_INPUT_MISMATCH]: `Public input does not match instruction parameter`,
399
401
  [MIXOOR_ERROR__UNKNOWN_ROOT]: `Unknown merkle root`
400
402
  };
401
403
  }
@@ -692,7 +694,8 @@ async function getInitializePoolInstructionAsync(input, config) {
692
694
  programAddress,
693
695
  seeds: [
694
696
  kit.getBytesEncoder().encode(new Uint8Array([112, 111, 111, 108])),
695
- kit.getAddressEncoder().encode(expectAddress(accounts.mint.value))
697
+ kit.getAddressEncoder().encode(expectAddress(accounts.mint.value)),
698
+ getAssetTypeEncoder().encode(expectSome(args.assetType))
696
699
  ]
697
700
  });
698
701
  }
@@ -846,8 +849,8 @@ function getTransferInstructionDataEncoder() {
846
849
  kit.getArrayEncoder(kit.fixEncoderSize(kit.getBytesEncoder(), 32), { size: 7 })
847
850
  ],
848
851
  ["nullifierHash", kit.fixEncoderSize(kit.getBytesEncoder(), 32)],
849
- ["amount", kit.getU64Encoder()],
850
- ["fee", kit.getU64Encoder()]
852
+ ["relayerFee", kit.getU64Encoder()],
853
+ ["recipientAmount", kit.getU64Encoder()]
851
854
  ]),
852
855
  (value) => ({ ...value, discriminator: TRANSFER_DISCRIMINATOR })
853
856
  );
@@ -863,8 +866,8 @@ function getTransferInstructionDataDecoder() {
863
866
  kit.getArrayDecoder(kit.fixDecoderSize(kit.getBytesDecoder(), 32), { size: 7 })
864
867
  ],
865
868
  ["nullifierHash", kit.fixDecoderSize(kit.getBytesDecoder(), 32)],
866
- ["amount", kit.getU64Decoder()],
867
- ["fee", kit.getU64Decoder()]
869
+ ["relayerFee", kit.getU64Decoder()],
870
+ ["recipientAmount", kit.getU64Decoder()]
868
871
  ]);
869
872
  }
870
873
  function getTransferInstructionDataCodec() {
@@ -920,6 +923,7 @@ async function getTransferInstructionAsync(input, config) {
920
923
  kit.getBytesEncoder().encode(
921
924
  new Uint8Array([110, 117, 108, 108, 105, 102, 105, 101, 114])
922
925
  ),
926
+ kit.getAddressEncoder().encode(expectAddress(accounts.pool.value)),
923
927
  kit.fixEncoderSize(kit.getBytesEncoder(), 32).encode(
924
928
  expectSome(args.nullifierHash)
925
929
  )
@@ -1222,14 +1226,6 @@ async function generateProof(input) {
1222
1226
  const publicInputs = publicSignals.map(
1223
1227
  (signal) => publicSignalToBytes(signal)
1224
1228
  );
1225
- console.log(
1226
- "DEBUG: Generated Public Inputs (Keys: root, nullifierHash, recipient, relayer, fee, refund, poolId):"
1227
- );
1228
- publicInputs.forEach((input2, i) => {
1229
- const hexBE = Buffer.from(input2).toString("hex");
1230
- const hexLE = Buffer.from(input2.slice().reverse()).toString("hex");
1231
- console.log(`Input ${i}: BE=${hexBE} | LE=${hexLE}`);
1232
- });
1233
1229
  const proof_a = g1PointToBytes([proof.pi_a[0], proof.pi_a[1]]);
1234
1230
  const proof_b = g2PointToBytes([
1235
1231
  [proof.pi_b[0][0], proof.pi_b[0][1]],
@@ -1367,7 +1363,11 @@ async function findPoolAddress(seeds, config = {}) {
1367
1363
  const { programAddress = MIXOOR_PROGRAM_ADDRESS } = config;
1368
1364
  return await kit.getProgramDerivedAddress({
1369
1365
  programAddress,
1370
- seeds: ["pool", kit.getAddressEncoder().encode(seeds.mint)]
1366
+ seeds: [
1367
+ "pool",
1368
+ kit.getAddressEncoder().encode(seeds.mint),
1369
+ kit.getEnumCodec(AssetType).encode(seeds.assetType)
1370
+ ]
1371
1371
  });
1372
1372
  }
1373
1373
  async function findMerkleTreeAddress(seeds, config = {}) {
@@ -1388,7 +1388,11 @@ async function findNullifierAddress(seeds, config = {}) {
1388
1388
  const { programAddress = MIXOOR_PROGRAM_ADDRESS } = config;
1389
1389
  return await kit.getProgramDerivedAddress({
1390
1390
  programAddress,
1391
- seeds: ["nullifier", seeds.nullifierHash]
1391
+ seeds: [
1392
+ "nullifier",
1393
+ kit.getAddressEncoder().encode(seeds.pool),
1394
+ seeds.nullifierHash
1395
+ ]
1392
1396
  });
1393
1397
  }
1394
1398
 
@@ -1407,6 +1411,7 @@ exports.MIXOOR_ERROR__MERKLE_TREE_FULL = MIXOOR_ERROR__MERKLE_TREE_FULL;
1407
1411
  exports.MIXOOR_ERROR__MISSING_TOKEN_ACCOUNT = MIXOOR_ERROR__MISSING_TOKEN_ACCOUNT;
1408
1412
  exports.MIXOOR_ERROR__OVERFLOW = MIXOOR_ERROR__OVERFLOW;
1409
1413
  exports.MIXOOR_ERROR__POSEIDON_HASH_ERROR = MIXOOR_ERROR__POSEIDON_HASH_ERROR;
1414
+ exports.MIXOOR_ERROR__PUBLIC_INPUT_MISMATCH = MIXOOR_ERROR__PUBLIC_INPUT_MISMATCH;
1410
1415
  exports.MIXOOR_ERROR__UNKNOWN_ROOT = MIXOOR_ERROR__UNKNOWN_ROOT;
1411
1416
  exports.MIXOOR_PROGRAM_ADDRESS = MIXOOR_PROGRAM_ADDRESS;
1412
1417
  exports.MerkleTree = MerkleTree;