@hinkal/common 0.2.23 → 0.2.25
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 +267 -63
- package/data-structures/Hinkal/hinkalDepositAndWithdraw.cjs +1 -1
- package/data-structures/Hinkal/hinkalDepositAndWithdraw.mjs +26 -26
- package/data-structures/Hinkal/hinkalDepositOnChainUtxos.cjs +1 -1
- package/data-structures/Hinkal/hinkalDepositOnChainUtxos.d.ts +1 -0
- package/data-structures/Hinkal/hinkalDepositOnChainUtxos.mjs +25 -25
- package/data-structures/Hinkal/hinkalDepostAndBridge.cjs +1 -1
- package/data-structures/Hinkal/hinkalDepostAndBridge.mjs +84 -80
- package/data-structures/Hinkal/hinkalSolanaDepositAndWithdraw.cjs +1 -1
- package/data-structures/Hinkal/hinkalSolanaDepositAndWithdraw.mjs +41 -41
- package/package.json +1 -1
|
@@ -59,33 +59,33 @@ import { updateDepositAndWithdrawStatus as ht, safeUpdateDepositAndWithdrawStatu
|
|
|
59
59
|
const ft = async (t, r, p, d, l, u) => {
|
|
60
60
|
const g = p.map((o) => o + nt(o, l)), {
|
|
61
61
|
hinkalIdl: h,
|
|
62
|
-
hinkalAddress:
|
|
62
|
+
hinkalAddress: S,
|
|
63
63
|
originalDeployer: s
|
|
64
64
|
} = $[t.getCurrentChainId()].contractData;
|
|
65
65
|
if (!h)
|
|
66
66
|
throw new Error("No IDL configured for Solana program on this network");
|
|
67
67
|
if (!s)
|
|
68
68
|
throw new Error("missing original deployer");
|
|
69
|
-
const f = t.userKeys.getShieldedPrivateKey(), E = z.findCorrectRandomization(M(31), f),
|
|
69
|
+
const f = t.userKeys.getShieldedPrivateKey(), E = z.findCorrectRandomization(M(31), f), w = ct(E, f), e = t.getSolanaProgram(h), v = t.getSolanaPublicKey(), a = new W(s), A = new W(S), { mintPublicKey: c } = q(r), x = c.toString(), H = tt(A, a), R = ot(A, a), F = rt(A, a), b = et(w), T = t.getCurrentChainId(), D = g.reduce((o, n) => o + n, 0n), I = await pt(
|
|
70
70
|
e,
|
|
71
71
|
new W(a),
|
|
72
72
|
[r],
|
|
73
73
|
[D]
|
|
74
74
|
), K = g.map((o) => `${o}`);
|
|
75
75
|
let i = "";
|
|
76
|
-
const P = (await ht(
|
|
76
|
+
const P = (await ht(T, {
|
|
77
77
|
hashedEthereumAddress: u,
|
|
78
78
|
phase: k.BEFORE_DEPOSIT
|
|
79
79
|
})).id ?? void 0;
|
|
80
|
-
if (
|
|
81
|
-
const { serializedTransaction: o, blockhash: n, lastValidBlockHeight:
|
|
82
|
-
|
|
80
|
+
if (I) {
|
|
81
|
+
const { serializedTransaction: o, blockhash: n, lastValidBlockHeight: y } = await G.generateMultiPaymentDepositLimitless(
|
|
82
|
+
T,
|
|
83
83
|
{
|
|
84
84
|
amounts: K,
|
|
85
85
|
payer: t.getSolanaPublicKey().toBase58(),
|
|
86
86
|
ethereumAddress: await t.getEthereumAddress(),
|
|
87
87
|
mint: r,
|
|
88
|
-
stealthAddressStructure:
|
|
88
|
+
stealthAddressStructure: b
|
|
89
89
|
}
|
|
90
90
|
), { wallet: m } = e.provider;
|
|
91
91
|
if (!m)
|
|
@@ -94,23 +94,23 @@ const ft = async (t, r, p, d, l, u) => {
|
|
|
94
94
|
e.provider,
|
|
95
95
|
o,
|
|
96
96
|
n,
|
|
97
|
-
|
|
97
|
+
y
|
|
98
98
|
);
|
|
99
99
|
} else {
|
|
100
|
-
const o = at(e.programId, a, c), n =
|
|
100
|
+
const o = at(e.programId, a, c), n = x === U ? null : c, y = x === U ? null : void 0;
|
|
101
101
|
i = await e.methods.multiPaymentDeposit(
|
|
102
102
|
K.map((V) => new Q(V)),
|
|
103
|
-
|
|
103
|
+
b
|
|
104
104
|
).accounts({
|
|
105
105
|
mint: n,
|
|
106
106
|
signer: v,
|
|
107
|
-
signerAta:
|
|
107
|
+
signerAta: y,
|
|
108
108
|
originalDeployer: a,
|
|
109
|
-
storageAccount:
|
|
110
|
-
storageVault:
|
|
111
|
-
merkleAccount:
|
|
109
|
+
storageAccount: H,
|
|
110
|
+
storageVault: R,
|
|
111
|
+
merkleAccount: F,
|
|
112
112
|
tokenLimitStorage: o,
|
|
113
|
-
storageVaultAta:
|
|
113
|
+
storageVaultAta: y,
|
|
114
114
|
accessTokenOwner: null
|
|
115
115
|
}).rpc();
|
|
116
116
|
const m = await e.provider.connection.getLatestBlockhash();
|
|
@@ -129,7 +129,7 @@ const ft = async (t, r, p, d, l, u) => {
|
|
|
129
129
|
});
|
|
130
130
|
if (!B)
|
|
131
131
|
throw new Error("Transaction missing");
|
|
132
|
-
await N(
|
|
132
|
+
await N(T, {
|
|
133
133
|
id: P,
|
|
134
134
|
hashedEthereumAddress: u,
|
|
135
135
|
phase: k.AFTER_DEPOSIT,
|
|
@@ -137,45 +137,45 @@ const ft = async (t, r, p, d, l, u) => {
|
|
|
137
137
|
});
|
|
138
138
|
const L = dt(B, e, t.userKeys), O = [], C = [...L];
|
|
139
139
|
return d.forEach((o, n) => {
|
|
140
|
-
const
|
|
140
|
+
const y = g[n], m = C.find((X) => X.amount === y);
|
|
141
141
|
if (!m)
|
|
142
|
-
throw new Error(`Could not find newly created UTXO with amount ${
|
|
142
|
+
throw new Error(`Could not find newly created UTXO with amount ${y} for recipient ${o}.`);
|
|
143
143
|
O.push({
|
|
144
144
|
recipientAddress: o,
|
|
145
145
|
utxo: m
|
|
146
146
|
});
|
|
147
147
|
const V = C.indexOf(m);
|
|
148
148
|
C.splice(V, 1);
|
|
149
|
-
}), { userDepositedUtxos: O,
|
|
149
|
+
}), { userDepositedUtxos: O, depositTxHash: i, statusId: P };
|
|
150
150
|
}, wt = async (t, r, p, d, l, u, g, h) => {
|
|
151
|
-
const
|
|
151
|
+
const S = t.getCurrentChainId();
|
|
152
152
|
if (p.length === 0)
|
|
153
153
|
throw new Error("userDepositedUtxos must not be empty");
|
|
154
154
|
const { hinkalIdl: s, originalDeployer: f } = $[t.getCurrentChainId()].contractData;
|
|
155
155
|
if (!f || !s)
|
|
156
156
|
throw new Error("missing data");
|
|
157
|
-
const E = t.getSolanaProgram(s),
|
|
158
|
-
if (!
|
|
157
|
+
const E = t.getSolanaProgram(s), w = await t.getRandomRelay(!0);
|
|
158
|
+
if (!w)
|
|
159
159
|
throw new Error(Y.RELAYER_NOT_AVAILABLE);
|
|
160
160
|
const e = it().toString(), v = t.generateProofRemotely ? 5 : 1, a = [];
|
|
161
161
|
for (let c = 0; c < p.length; c += v) {
|
|
162
|
-
const
|
|
163
|
-
|
|
164
|
-
const { compressedAddress:
|
|
162
|
+
const x = p.slice(c, c + v), H = await Promise.all(
|
|
163
|
+
x.map(async ({ recipientAddress: R, utxo: F }) => {
|
|
164
|
+
const { compressedAddress: b } = q(U), T = new z({
|
|
165
165
|
amount: 0n,
|
|
166
166
|
mintAddress: r,
|
|
167
|
-
erc20TokenAddress:
|
|
167
|
+
erc20TokenAddress: b,
|
|
168
168
|
shieldedPrivateKey: t.userKeys.getShieldedPrivateKey(),
|
|
169
169
|
timeStamp: e,
|
|
170
170
|
tokenId: 0
|
|
171
|
-
}), D = [
|
|
171
|
+
}), D = [F, T], I = [T], K = z.findCorrectRandomization(
|
|
172
172
|
M(31),
|
|
173
173
|
t.userKeys.getShieldedPrivateKey()
|
|
174
174
|
), i = {
|
|
175
175
|
tokenNumber: 1,
|
|
176
176
|
nullifierAmount: D.length,
|
|
177
|
-
outputAmount:
|
|
178
|
-
}, _ = mt([
|
|
177
|
+
outputAmount: I.length
|
|
178
|
+
}, _ = mt([I])[0][0], P = Array.from(Z.getBytes(_)), { proofAArr: B, proofBArr: L, proofCArr: O, publicInputsArr: C } = await lt(
|
|
179
179
|
t.generateProofRemotely,
|
|
180
180
|
f,
|
|
181
181
|
t.merkleTreeHinkal,
|
|
@@ -184,12 +184,12 @@ const ft = async (t, r, p, d, l, u) => {
|
|
|
184
184
|
E,
|
|
185
185
|
[r],
|
|
186
186
|
[D],
|
|
187
|
-
[
|
|
187
|
+
[I],
|
|
188
188
|
K,
|
|
189
189
|
d.flatFee,
|
|
190
190
|
d.variableRate,
|
|
191
|
-
|
|
192
|
-
|
|
191
|
+
R,
|
|
192
|
+
w,
|
|
193
193
|
i,
|
|
194
194
|
[P],
|
|
195
195
|
t.getCurrentChainId(),
|
|
@@ -200,11 +200,11 @@ const ft = async (t, r, p, d, l, u) => {
|
|
|
200
200
|
void 0,
|
|
201
201
|
!1
|
|
202
202
|
), n = {
|
|
203
|
-
recipient:
|
|
203
|
+
recipient: R,
|
|
204
204
|
mint: r === U ? void 0 : r
|
|
205
205
|
};
|
|
206
206
|
return {
|
|
207
|
-
relayAddress:
|
|
207
|
+
relayAddress: w,
|
|
208
208
|
functionName: "transact",
|
|
209
209
|
args: {
|
|
210
210
|
proofAArr: B,
|
|
@@ -219,9 +219,9 @@ const ft = async (t, r, p, d, l, u) => {
|
|
|
219
219
|
};
|
|
220
220
|
})
|
|
221
221
|
);
|
|
222
|
-
a.push(...
|
|
222
|
+
a.push(...H);
|
|
223
223
|
}
|
|
224
|
-
await N(
|
|
224
|
+
await N(S, {
|
|
225
225
|
id: u,
|
|
226
226
|
hashedEthereumAddress: l,
|
|
227
227
|
phase: k.BEFORE_SCHEDULE_WITHDRAW
|
|
@@ -233,14 +233,14 @@ const ft = async (t, r, p, d, l, u) => {
|
|
|
233
233
|
g,
|
|
234
234
|
h
|
|
235
235
|
);
|
|
236
|
-
return await N(
|
|
236
|
+
return await N(S, {
|
|
237
237
|
id: u,
|
|
238
238
|
hashedEthereumAddress: l,
|
|
239
239
|
phase: k.AFTER_SCHEDULE_WITHDRAW,
|
|
240
240
|
scheduleId: A
|
|
241
241
|
}), A;
|
|
242
|
-
},
|
|
243
|
-
const h = j(await t.getEthereumAddress()),
|
|
242
|
+
}, Io = async (t, r, p, d, l, u, g) => {
|
|
243
|
+
const h = j(await t.getEthereumAddress()), S = t.getCurrentChainId(), s = u ?? await gt(S, r, [r], J.Transact, [], 0n), { userDepositedUtxos: f, statusId: E, depositTxHash: w } = await ft(
|
|
244
244
|
t,
|
|
245
245
|
r,
|
|
246
246
|
p,
|
|
@@ -257,8 +257,8 @@ const ft = async (t, r, p, d, l, u) => {
|
|
|
257
257
|
E,
|
|
258
258
|
l,
|
|
259
259
|
g
|
|
260
|
-
);
|
|
260
|
+
), w;
|
|
261
261
|
};
|
|
262
262
|
export {
|
|
263
|
-
|
|
263
|
+
Io as hinkalSolanaDepositAndWithdraw
|
|
264
264
|
};
|