@hinkal/common 0.3.3 → 0.3.5
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 +2 -2
- package/assets/snarkjsWorkerLauncher-SrStwJvX.js +1 -0
- package/assets/snarkjsWorkerLogic-DtIjisbE.js +132 -0
- package/assets/utxoWorkerLauncher-CIBeBAML.js +1 -0
- package/assets/utxoWorkerLogic-C8R4GSaf.js +199 -0
- package/assets/zkProofWorkerLauncher-DfwteloJ.js +1 -0
- package/assets/zkProofWorkerLogic-CY9y6rOV.js +199 -0
- package/common/src/constants/vite.constants.cjs +1 -1
- package/common/src/constants/vite.constants.mjs +23 -5
- package/common/src/crypto/index.cjs +1 -1
- package/common/src/crypto/index.d.ts +0 -1
- package/common/src/crypto/index.mjs +0 -1
- package/common/src/data-structures/Hinkal/hinkalSolanaClaimUtxo.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalSolanaClaimUtxo.mjs +50 -97
- package/common/src/data-structures/Hinkal/hinkalSolanaDepositAndWithdraw.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalSolanaDepositAndWithdraw.mjs +90 -128
- package/common/src/data-structures/Hinkal/hinkalSolanaSwap.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalSolanaSwap.mjs +56 -110
- package/common/src/data-structures/Hinkal/hinkalSolanaTransact.cjs +1 -0
- package/common/src/data-structures/Hinkal/hinkalSolanaTransact.d.ts +3 -0
- package/common/src/data-structures/Hinkal/hinkalSolanaTransact.mjs +117 -0
- package/common/src/data-structures/Hinkal/hinkalSolanaTransfer.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalSolanaTransfer.d.ts +2 -31
- package/common/src/data-structures/Hinkal/hinkalSolanaTransfer.mjs +45 -121
- package/common/src/data-structures/Hinkal/hinkalSolanaWithdraw.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalSolanaWithdraw.mjs +41 -83
- package/common/src/data-structures/Hinkal/hinkalTransact.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalTransact.mjs +41 -42
- package/common/src/data-structures/Hinkal/hinkalWithdrawStuckUtxos.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalWithdrawStuckUtxos.mjs +106 -125
- package/common/src/data-structures/IndexedDB/pay-activity-db.cjs +1 -1
- package/common/src/data-structures/IndexedDB/pay-activity-db.mjs +43 -1
- package/common/src/functions/index.cjs +1 -1
- package/common/src/functions/index.mjs +0 -1
- package/common/src/functions/pre-transaction/ensureAmountChanges.cjs +1 -1
- package/common/src/functions/pre-transaction/ensureAmountChanges.mjs +3 -10
- package/common/src/functions/pre-transaction/outputUtxoProcessing.cjs +1 -1
- package/common/src/functions/pre-transaction/outputUtxoProcessing.d.ts +1 -0
- package/common/src/functions/pre-transaction/outputUtxoProcessing.mjs +13 -9
- package/common/src/functions/snarkjs/constructSolanaZkProof.cjs +1 -1
- package/common/src/functions/snarkjs/constructSolanaZkProof.d.ts +1 -1
- package/common/src/functions/snarkjs/constructSolanaZkProof.mjs +35 -35
- package/common/src/functions/snarkjs/constructTxEnclave.cjs +1 -1
- package/common/src/functions/snarkjs/constructTxEnclave.d.ts +2 -0
- package/common/src/functions/snarkjs/constructTxEnclave.mjs +40 -40
- package/common/src/functions/utils/enum.utils.cjs +1 -0
- package/common/src/functions/utils/enum.utils.mjs +12 -0
- package/common/src/functions/utils/index.cjs +1 -1
- package/common/src/functions/utils/index.mjs +0 -1
- package/common/src/types/index.cjs +1 -1
- package/common/src/types/index.d.ts +1 -0
- package/common/src/types/index.mjs +1 -0
- package/common/src/types/pay-activities.types.d.ts +18 -3
- package/common/src/types/solana-transact.types.cjs +1 -0
- package/common/src/types/solana-transact.types.d.ts +35 -0
- package/common/src/types/solana-transact.types.mjs +6 -0
- package/common/src/webworker/logError-Dex6ch32.js +2 -0
- package/common/src/webworker/package.json +1 -1
- package/common/src/webworker/snarkjsWorker/snarkjsWorkerLauncher.ts?worker&url.cjs +1 -1
- package/common/src/webworker/snarkjsWorker/snarkjsWorkerLauncher.ts?worker&url.mjs +1 -1
- package/common/src/webworker/snarkjsWorkerNode.cjs +1 -1
- package/common/src/webworker/utxoWorker/utxoWorkerLauncher.ts?worker&url.cjs +1 -1
- package/common/src/webworker/utxoWorker/utxoWorkerLauncher.ts?worker&url.mjs +1 -1
- package/common/src/webworker/utxoWorkerNode.cjs +1 -1
- package/common/src/webworker/viteWorkerURL.constant.cjs +1 -28
- package/common/src/webworker/viteWorkerURL.constant.mjs +13 -27
- package/common/src/webworker/workerProxy-BuJUMCQ4.js +1 -0
- package/common/src/webworker/zkProofWorker/zkProofWorkerLauncher.ts?worker&url.cjs +1 -1
- package/common/src/webworker/zkProofWorker/zkProofWorkerLauncher.ts?worker&url.mjs +1 -1
- package/common/src/webworker/zkProofWorkerNode.cjs +1 -1
- package/package.json +12 -12
- package/common/src/crypto/ecdh-dual-path.cjs +0 -1
- package/common/src/crypto/ecdh-dual-path.d.ts +0 -13
- package/common/src/crypto/ecdh-dual-path.mjs +0 -6
- package/common/src/webworker/logError-CxZzSALU.js +0 -2
- package/common/src/webworker/workerProxy-swwPYw6e.js +0 -1
|
@@ -1,128 +1,74 @@
|
|
|
1
1
|
import { networkRegistry as e } from "../../constants/chains.constants.mjs";
|
|
2
2
|
import { solanaNativeAddress as t } from "../../constants/protocol.constants.mjs";
|
|
3
3
|
import { transactionErrorCodes as n } from "../../error-handling/error-codes.constants.mjs";
|
|
4
|
-
import { getAmountInToken as r, getAmountInWei as i
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { StorageKeys as l } from "../../types/cache.types.mjs";
|
|
4
|
+
import { getAmountInToken as r, getAmountInWei as i } from "../../functions/web3/etherFunctions.mjs";
|
|
5
|
+
import { ExternalActionId as a } from "../../types/external-action.types.mjs";
|
|
6
|
+
import { StorageKeys as o } from "../../types/cache.types.mjs";
|
|
7
|
+
import { SolanaSubmitMode as s } from "../../types/solana-transact.types.mjs";
|
|
9
8
|
import "../../types/index.mjs";
|
|
10
|
-
import { validateAndGetChainId as
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import { ensureAmountChanges as te } from "../../functions/pre-transaction/ensureAmountChanges.mjs";
|
|
19
|
-
import { getFeeStructure as ne } from "../../functions/pre-transaction/getFeeStructure.mjs";
|
|
20
|
-
import { solanaTransactCallRelayer as b } from "../../functions/web3/functionCalls/transactCallRelayer.mjs";
|
|
21
|
-
import { constructSolanaZkProof as x } from "../../functions/snarkjs/constructSolanaZkProof.mjs";
|
|
22
|
-
import { PublicKey as S } from "@solana/web3.js";
|
|
9
|
+
import { validateAndGetChainId as c } from "../../functions/utils/token-check.utils.mjs";
|
|
10
|
+
import { getStorageAccountPublicKey as l, getStorageVaultPublicKey as u, getSwapperAccountPublicKeyFromSalt as ee } from "../../functions/pre-transaction/solana.mjs";
|
|
11
|
+
import { constructAdminData as d } from "../../functions/pre-transaction/constructAdminData.mjs";
|
|
12
|
+
import { calculateSolanaNullifierCount as f } from "../../functions/pre-transaction/calculateSolanaNullifierCount.mjs";
|
|
13
|
+
import { convertOKXToHinkalInstructions as p } from "../../functions/pre-transaction/convert-okx-instructions.mjs";
|
|
14
|
+
import { getFeeStructure as m } from "../../functions/pre-transaction/getFeeStructure.mjs";
|
|
15
|
+
import { hinkalSolanaTransact as h } from "./hinkalSolanaTransact.mjs";
|
|
16
|
+
import { PublicKey as g } from "@solana/web3.js";
|
|
23
17
|
//#region libs/shared/common/src/data-structures/Hinkal/hinkalSolanaSwap.ts
|
|
24
|
-
var
|
|
25
|
-
let
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
};
|
|
34
|
-
}, ie = async (e, t, n, r, i, a, o, s, c, l, u, d, f, p) => {
|
|
35
|
-
let { jobId: m, signedMessageHash: h } = await v(e, {
|
|
36
|
-
chainId: t,
|
|
37
|
-
mintAddresses: n,
|
|
38
|
-
amountChanges: r,
|
|
39
|
-
relayAddress: a,
|
|
40
|
-
recipient: o,
|
|
41
|
-
signer: a,
|
|
42
|
-
functionName: "swap",
|
|
43
|
-
accounts: s,
|
|
44
|
-
onChainCreation: i,
|
|
45
|
-
relayerFee: c,
|
|
46
|
-
variableRate: l,
|
|
47
|
-
hinkalInstructions: u,
|
|
48
|
-
remainingAccounts: d,
|
|
49
|
-
swapperAccountSalt: f
|
|
50
|
-
}), { R8: g, S: y } = e.userKeys.signEddsa(BigInt(h));
|
|
51
|
-
return _(m, {
|
|
52
|
-
R8: g,
|
|
53
|
-
S: y
|
|
54
|
-
}, t, { adminData: p });
|
|
55
|
-
}, C = async (s, d, f, _, v, C, w, T, E) => {
|
|
56
|
-
let D = u(d), O = new S(t), { hinkalAddress: k, originalDeployer: A } = e[D].contractData;
|
|
57
|
-
if (!A) throw Error("No IDL configured for Solana program on this network");
|
|
58
|
-
let j = new S(A), M = new S(k), N = d.map((e) => e.erc20TokenAddress), { userKeys: ae, merkleTreeHinkalByChain: oe } = s, se = w ?? N[1];
|
|
59
|
-
if (w && w !== N[1]) throw Error("Solana swap fee token must match the output token");
|
|
60
|
-
let ce = {
|
|
61
|
-
mintFrom: N[0],
|
|
62
|
-
mintTo: N[1],
|
|
63
|
-
nullifierCount: await y(s, D, N, f),
|
|
18
|
+
var _ = async (_, v, y, b, x, S, C, w, T) => {
|
|
19
|
+
let E = c(v), D = new g(t), { hinkalAddress: O, originalDeployer: k } = e[E].contractData;
|
|
20
|
+
if (!k) throw Error("No IDL configured for Solana program on this network");
|
|
21
|
+
let A = new g(k), j = new g(O), M = v.map((e) => e.erc20TokenAddress), N = C ?? M[1];
|
|
22
|
+
if (C && C !== M[1]) throw Error("Solana swap fee token must match the output token");
|
|
23
|
+
let P = {
|
|
24
|
+
mintFrom: M[0],
|
|
25
|
+
mintTo: M[1],
|
|
26
|
+
nullifierCount: await f(_, E, M, y),
|
|
64
27
|
rootInsertCount: 2
|
|
65
|
-
},
|
|
66
|
-
|
|
67
|
-
let
|
|
68
|
-
if (
|
|
69
|
-
let
|
|
28
|
+
}, F = w ?? await m(E, N, M, a.Okx, [], void 0, P), I = y[1], L = Number(_.cacheDevice.get(o.SLIPPAGE_PERCENTAGE) ?? 0), R = v[1], z = r(R, I), B = Number(z) * L / 100;
|
|
29
|
+
y[1] -= i(R, B.toFixed(R.decimals));
|
|
30
|
+
let V = I * BigInt(F.variableRate ?? 0) / 10000n + F.flatFee;
|
|
31
|
+
if (y[1] -= V, y[1] < 0) throw Error(n.LOW_OUTPUT_AMOUNT);
|
|
32
|
+
let [H, U] = await Promise.all([_.getRandomRelay(E, !0), _.getEthereumAddressByChain(E)]);
|
|
70
33
|
if (!H) throw Error(n.RELAYER_NOT_AVAILABLE);
|
|
71
|
-
let W =
|
|
72
|
-
recipient:
|
|
73
|
-
storageAccount:
|
|
74
|
-
storageVault:
|
|
34
|
+
let W = ee(j, A, b), { remainingAccounts: G, hinkalInstructions: K } = p(x, W), q = l(j, A), J = u(j, A), Y = v[0].erc20TokenAddress === "11111111111111111111111111111111" ? null : new g(v[0].erc20TokenAddress), X = v[1].erc20TokenAddress === "11111111111111111111111111111111" ? null : new g(v[1].erc20TokenAddress), Z = {
|
|
35
|
+
recipient: D.toString(),
|
|
36
|
+
storageAccount: q.toString(),
|
|
37
|
+
storageVault: J.toString(),
|
|
75
38
|
swapperAccount: W.toString(),
|
|
76
|
-
mintFrom:
|
|
77
|
-
mintTo:
|
|
39
|
+
mintFrom: Y?.toString() ?? null,
|
|
40
|
+
mintTo: X?.toString() ?? null,
|
|
78
41
|
remainingAccounts: G.map((e) => ({
|
|
79
42
|
pubkey: e.pubkey.toString(),
|
|
80
43
|
isSigner: e.isSigner,
|
|
81
44
|
isWritable: e.isWritable
|
|
82
45
|
})),
|
|
83
|
-
addressLookupTableAccount:
|
|
84
|
-
},
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
let { inputUtxosArray: X, outputUtxosArray: Z } = await re(s, D, N, f), pe = s.userKeys.getShieldedPrivateKey(), Q = o.findCorrectRandomization(a(31), pe), $ = {
|
|
94
|
-
tokenNumber: 2,
|
|
95
|
-
nullifierAmount: X[0].length,
|
|
96
|
-
outputAmount: 1
|
|
97
|
-
};
|
|
98
|
-
te(X, Z, f);
|
|
99
|
-
let { proofAArr: me, proofBArr: he, proofCArr: ge, publicInputsArr: _e, commitmentValidationData: ve, rootHashHinkalIndex: ye, encryptedOutputs: be, onChainEncryptedOutput: xe } = await x(oe[D], ae, N, X, Z, Q, P.flatFee, P.variableRate, O.toString(), H, $, Y, D, K, G, _);
|
|
100
|
-
return b({
|
|
101
|
-
chainId: D,
|
|
46
|
+
addressLookupTableAccount: S
|
|
47
|
+
}, Q = d(T, E, M, y, U, v), $ = K.map((e) => ({
|
|
48
|
+
accountIndexes: [...e.accountIndexes],
|
|
49
|
+
data: [...e.data],
|
|
50
|
+
programIndex: e.programIndex
|
|
51
|
+
}));
|
|
52
|
+
return h(_, {
|
|
53
|
+
chainId: E,
|
|
54
|
+
mintAddresses: M,
|
|
55
|
+
amountChanges: y,
|
|
102
56
|
relayAddress: H,
|
|
57
|
+
recipient: D.toString(),
|
|
58
|
+
signer: H,
|
|
103
59
|
functionName: "swap",
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
rootHashIndex: ye.toString(),
|
|
116
|
-
hinkalInstructions: K.map((e) => ({
|
|
117
|
-
accountIndexes: [...e.accountIndexes],
|
|
118
|
-
data: [...e.data],
|
|
119
|
-
programIndex: e.programIndex
|
|
120
|
-
}))
|
|
121
|
-
},
|
|
122
|
-
accounts: q,
|
|
123
|
-
commitmentValidationData: ve,
|
|
124
|
-
adminData: J
|
|
60
|
+
accounts: Z,
|
|
61
|
+
onChainCreation: [!1, !0],
|
|
62
|
+
relayerFee: F.flatFee,
|
|
63
|
+
variableRate: F.variableRate,
|
|
64
|
+
hinkalInstructions: $,
|
|
65
|
+
remainingAccounts: Z.remainingAccounts,
|
|
66
|
+
swapperAccountSalt: b,
|
|
67
|
+
submit: {
|
|
68
|
+
mode: s.Relayer,
|
|
69
|
+
adminData: Q
|
|
70
|
+
}
|
|
125
71
|
});
|
|
126
72
|
};
|
|
127
73
|
//#endregion
|
|
128
|
-
export {
|
|
74
|
+
export { _ as hinkalSolanaSwap };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require(`../../../../_virtual/_rolldown/runtime.cjs`);const e=require(`../../types/solana-transact.types.cjs`),t=require(`../../functions/web3/events/getShieldedBalance.cjs`),n=require(`../../functions/pre-transaction/outputUtxoProcessing.cjs`),r=require(`../../functions/snarkjs/common.snarkjs.cjs`),i=require(`../../functions/snarkjs/constructTxEnclave.cjs`),a=require(`../../functions/web3/functionCalls/transactCallRelayer.cjs`),o=require(`../../functions/snarkjs/constructSolanaZkProof.cjs`);let s=require(`ethers`),c=require(`@solana/web3.js`);var l=(e=[])=>e.map(({accountIndexes:e,data:t,programIndex:n})=>({accountIndexes:Buffer.from(e),data:Buffer.from(t),programIndex:n})),u=(e=[])=>e.map(({pubkey:e,isSigner:t,isWritable:n})=>({pubkey:new c.PublicKey(e),isSigner:t,isWritable:n})),d=async(e,n)=>{let{inputUtxos:r,chainId:i,mintAddresses:a,amountChanges:o,useBlockedUtxos:s}=n;return r||[...await t.addPaddingToUtxos(e,i,a,o,void 0,void 0,s)]},f=(e,t,r)=>{let{amountChanges:i,recipientAddress:a,recipientAmounts:o}=e;return n.buildOutputUtxos(t,r,i,a===void 0?void 0:[a],a===void 0?void 0:[o??[]])},p=async(e,t,n)=>{let{chainId:i,mintAddresses:a,relayAddress:c,recipient:p,relayerFee:m,variableRate:h,functionName:g,hinkalInstructions:_,remainingAccounts:v,swapperAccountSalt:y,onChainCreation:b}=t,x=await d(e,t),S=f(t,n,x),C={tokenNumber:a.length,nullifierAmount:x[0].length,outputAmount:S[0].length},{proofAArr:w,proofBArr:T,proofCArr:E,publicInputsArr:D,commitmentValidationData:O,rootHashHinkalIndex:k,encryptedOutputs:A,onChainEncryptedOutput:j}=await o.constructSolanaZkProof(e.merkleTreeHinkalByChain[i],n,a,x,S,m??0n,h??0n,p,c,C,b,i,l(_),u(v),y);return{args:{proofAArr:w,proofBArr:T,proofCArr:E,publicInputsArr:D,encryptedOutputs:A,relayerFee:(m??0n).toString(),...g===`swap`?{variableRate:(h??0n).toString(),onChainEncryptedOutput:j,onChainCreation:b??[],hinkalInstructions:_??[]}:{},dimensions:C,rootHashIndex:k.toString()},commitmentValidationData:O,notes:{inputNullifiers:x.flat().filter(e=>e.amount>0n).map(e=>e.getNullifier()),outCommitments:r.buildOutCommitments(S).flat(),encryptedOutputs:A.map(e=>s.ethers.hexlify(new Uint8Array(e)))}}},m=async(e,t,n)=>{let{inputUtxos:r}=t,{jobId:a,signedMessageHash:o}=await i.prepareSolanaTxEnclaveCall(e,{chainId:t.chainId,mintAddresses:t.mintAddresses,amountChanges:t.amountChanges,relayAddress:t.relayAddress,recipient:t.recipient,signer:t.signer,functionName:t.functionName,accounts:t.accounts,onChainCreation:t.onChainCreation,relayerFee:t.relayerFee,variableRate:t.variableRate,swapperAccountSalt:t.swapperAccountSalt,hinkalInstructions:t.hinkalInstructions,remainingAccounts:t.remainingAccounts,recipientAddress:t.recipientAddress,recipientAmounts:t.recipientAmounts,recipientAmount:t.recipientAmount,displayRecipient:t.displayRecipient,useBlockedUtxos:t.useBlockedUtxos,messageSeed:t.messageSeed,inputCommitments:i.collectInputCommitments(r)},n),{R8:s,S:c}=n.signEddsa(BigInt(o));return{jobId:a,eddsaSignature:{R8:s,S:c}}},h=(t,n)=>{let{chainId:r,relayAddress:i,functionName:o,accounts:s,submit:c}=t;if(c.mode!==e.SolanaSubmitMode.Relayer)throw Error(`hinkalSolanaTransact: relayer submit expected`);return a.solanaTransactCallRelayer({chainId:r,relayAddress:i,functionName:o,args:n.args,accounts:s,commitmentValidationData:n.commitmentValidationData,adminData:c.adminData})},g=async(t,n)=>{if(t.submit.mode!==e.SolanaSubmitMode.Relayer)return n;let r=await h(t,n);return n.notes&&t.onTxSubmitLocally?.(n.notes),r},_=async(t,n)=>{if(n.userKeys&&!n.inputUtxos)throw Error(`hinkalSolanaTransact: userKeys requires explicit inputUtxos`);let r=n.userKeys??t.userKeys,{chainId:a,submit:o}=n;if(t.generateProofRemotely){let{jobId:s,eddsaSignature:c}=await m(t,n,r);if(o.mode===e.SolanaSubmitMode.Relayer)return i.finalizeSolanaTxEnclaveCallRelay(s,c,a,{adminData:o.adminData});let{solanaArgs:l,commitmentValidationData:u}=await i.finalizeSolanaTxEnclaveCall(s,c);return g(n,{args:l,commitmentValidationData:u})}return g(n,await p(t,n,r))};exports.hinkalSolanaTransact=_;
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { SolanaSubmitMode as e } from "../../types/solana-transact.types.mjs";
|
|
2
|
+
import { addPaddingToUtxos as t } from "../../functions/web3/events/getShieldedBalance.mjs";
|
|
3
|
+
import { buildOutputUtxos as n } from "../../functions/pre-transaction/outputUtxoProcessing.mjs";
|
|
4
|
+
import { buildOutCommitments as r } from "../../functions/snarkjs/common.snarkjs.mjs";
|
|
5
|
+
import { collectInputCommitments as i, finalizeSolanaTxEnclaveCall as a, finalizeSolanaTxEnclaveCallRelay as o, prepareSolanaTxEnclaveCall as s } from "../../functions/snarkjs/constructTxEnclave.mjs";
|
|
6
|
+
import { solanaTransactCallRelayer as c } from "../../functions/web3/functionCalls/transactCallRelayer.mjs";
|
|
7
|
+
import { constructSolanaZkProof as l } from "../../functions/snarkjs/constructSolanaZkProof.mjs";
|
|
8
|
+
import { ethers as u } from "ethers";
|
|
9
|
+
import { PublicKey as d } from "@solana/web3.js";
|
|
10
|
+
//#region libs/shared/common/src/data-structures/Hinkal/hinkalSolanaTransact.ts
|
|
11
|
+
var f = (e = []) => e.map(({ accountIndexes: e, data: t, programIndex: n }) => ({
|
|
12
|
+
accountIndexes: Buffer.from(e),
|
|
13
|
+
data: Buffer.from(t),
|
|
14
|
+
programIndex: n
|
|
15
|
+
})), p = (e = []) => e.map(({ pubkey: e, isSigner: t, isWritable: n }) => ({
|
|
16
|
+
pubkey: new d(e),
|
|
17
|
+
isSigner: t,
|
|
18
|
+
isWritable: n
|
|
19
|
+
})), m = async (e, n) => {
|
|
20
|
+
let { inputUtxos: r, chainId: i, mintAddresses: a, amountChanges: o, useBlockedUtxos: s } = n;
|
|
21
|
+
return r || [...await t(e, i, a, o, void 0, void 0, s)];
|
|
22
|
+
}, h = (e, t, r) => {
|
|
23
|
+
let { amountChanges: i, recipientAddress: a, recipientAmounts: o } = e;
|
|
24
|
+
return n(t, r, i, a === void 0 ? void 0 : [a], a === void 0 ? void 0 : [o ?? []]);
|
|
25
|
+
}, g = async (e, t, n) => {
|
|
26
|
+
let { chainId: i, mintAddresses: a, relayAddress: o, recipient: s, relayerFee: c, variableRate: d, functionName: g, hinkalInstructions: _, remainingAccounts: v, swapperAccountSalt: y, onChainCreation: b } = t, x = await m(e, t), S = h(t, n, x), C = {
|
|
27
|
+
tokenNumber: a.length,
|
|
28
|
+
nullifierAmount: x[0].length,
|
|
29
|
+
outputAmount: S[0].length
|
|
30
|
+
}, { proofAArr: w, proofBArr: T, proofCArr: E, publicInputsArr: D, commitmentValidationData: O, rootHashHinkalIndex: k, encryptedOutputs: A, onChainEncryptedOutput: j } = await l(e.merkleTreeHinkalByChain[i], n, a, x, S, c ?? 0n, d ?? 0n, s, o, C, b, i, f(_), p(v), y);
|
|
31
|
+
return {
|
|
32
|
+
args: {
|
|
33
|
+
proofAArr: w,
|
|
34
|
+
proofBArr: T,
|
|
35
|
+
proofCArr: E,
|
|
36
|
+
publicInputsArr: D,
|
|
37
|
+
encryptedOutputs: A,
|
|
38
|
+
relayerFee: (c ?? 0n).toString(),
|
|
39
|
+
...g === "swap" ? {
|
|
40
|
+
variableRate: (d ?? 0n).toString(),
|
|
41
|
+
onChainEncryptedOutput: j,
|
|
42
|
+
onChainCreation: b ?? [],
|
|
43
|
+
hinkalInstructions: _ ?? []
|
|
44
|
+
} : {},
|
|
45
|
+
dimensions: C,
|
|
46
|
+
rootHashIndex: k.toString()
|
|
47
|
+
},
|
|
48
|
+
commitmentValidationData: O,
|
|
49
|
+
notes: {
|
|
50
|
+
inputNullifiers: x.flat().filter((e) => e.amount > 0n).map((e) => e.getNullifier()),
|
|
51
|
+
outCommitments: r(S).flat(),
|
|
52
|
+
encryptedOutputs: A.map((e) => u.hexlify(new Uint8Array(e)))
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
}, _ = async (e, t, n) => {
|
|
56
|
+
let { inputUtxos: r } = t, { jobId: a, signedMessageHash: o } = await s(e, {
|
|
57
|
+
chainId: t.chainId,
|
|
58
|
+
mintAddresses: t.mintAddresses,
|
|
59
|
+
amountChanges: t.amountChanges,
|
|
60
|
+
relayAddress: t.relayAddress,
|
|
61
|
+
recipient: t.recipient,
|
|
62
|
+
signer: t.signer,
|
|
63
|
+
functionName: t.functionName,
|
|
64
|
+
accounts: t.accounts,
|
|
65
|
+
onChainCreation: t.onChainCreation,
|
|
66
|
+
relayerFee: t.relayerFee,
|
|
67
|
+
variableRate: t.variableRate,
|
|
68
|
+
swapperAccountSalt: t.swapperAccountSalt,
|
|
69
|
+
hinkalInstructions: t.hinkalInstructions,
|
|
70
|
+
remainingAccounts: t.remainingAccounts,
|
|
71
|
+
recipientAddress: t.recipientAddress,
|
|
72
|
+
recipientAmounts: t.recipientAmounts,
|
|
73
|
+
recipientAmount: t.recipientAmount,
|
|
74
|
+
displayRecipient: t.displayRecipient,
|
|
75
|
+
useBlockedUtxos: t.useBlockedUtxos,
|
|
76
|
+
messageSeed: t.messageSeed,
|
|
77
|
+
inputCommitments: i(r)
|
|
78
|
+
}, n), { R8: c, S: l } = n.signEddsa(BigInt(o));
|
|
79
|
+
return {
|
|
80
|
+
jobId: a,
|
|
81
|
+
eddsaSignature: {
|
|
82
|
+
R8: c,
|
|
83
|
+
S: l
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
}, v = (t, n) => {
|
|
87
|
+
let { chainId: r, relayAddress: i, functionName: a, accounts: o, submit: s } = t;
|
|
88
|
+
if (s.mode !== e.Relayer) throw Error("hinkalSolanaTransact: relayer submit expected");
|
|
89
|
+
return c({
|
|
90
|
+
chainId: r,
|
|
91
|
+
relayAddress: i,
|
|
92
|
+
functionName: a,
|
|
93
|
+
args: n.args,
|
|
94
|
+
accounts: o,
|
|
95
|
+
commitmentValidationData: n.commitmentValidationData,
|
|
96
|
+
adminData: s.adminData
|
|
97
|
+
});
|
|
98
|
+
}, y = async (t, n) => {
|
|
99
|
+
if (t.submit.mode !== e.Relayer) return n;
|
|
100
|
+
let r = await v(t, n);
|
|
101
|
+
return n.notes && t.onTxSubmitLocally?.(n.notes), r;
|
|
102
|
+
}, b = async (t, n) => {
|
|
103
|
+
if (n.userKeys && !n.inputUtxos) throw Error("hinkalSolanaTransact: userKeys requires explicit inputUtxos");
|
|
104
|
+
let r = n.userKeys ?? t.userKeys, { chainId: i, submit: s } = n;
|
|
105
|
+
if (t.generateProofRemotely) {
|
|
106
|
+
let { jobId: c, eddsaSignature: l } = await _(t, n, r);
|
|
107
|
+
if (s.mode === e.Relayer) return o(c, l, i, { adminData: s.adminData });
|
|
108
|
+
let { solanaArgs: u, commitmentValidationData: d } = await a(c, l);
|
|
109
|
+
return y(n, {
|
|
110
|
+
args: u,
|
|
111
|
+
commitmentValidationData: d
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
return y(n, await g(t, n, r));
|
|
115
|
+
};
|
|
116
|
+
//#endregion
|
|
117
|
+
export { b as hinkalSolanaTransact };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require(`../../constants/chains.constants.cjs`),t=require(`../../constants/protocol.constants.cjs`),n=require(`../../error-handling/error-codes.constants.cjs`),r=require(`../../functions/
|
|
1
|
+
const e=require(`../../constants/chains.constants.cjs`),t=require(`../../constants/protocol.constants.cjs`),n=require(`../../error-handling/error-codes.constants.cjs`),r=require(`../../functions/utils/addresses.cjs`),i=require(`../../types/external-action.types.cjs`),a=require(`../../types/solana-transact.types.cjs`);require(`../../types/index.cjs`);const o=require(`../../functions/utils/token-check.utils.cjs`),s=require(`../../functions/pre-transaction/constructAdminData.cjs`),c=require(`../../functions/pre-transaction/calculateSolanaNullifierCount.cjs`),l=require(`../../functions/pre-transaction/getFeeStructure.cjs`);require(`../../functions/pre-transaction/index.cjs`);const u=require(`../../functions/utils/fees.utils.cjs`),d=require(`./hinkalSolanaTransact.cjs`);var f=async(f,p,m,h,g,_,v,y=!1)=>{if(y)throw Error(`onlyGasEstimate is not supported for Solana transfer`);if(!r.isValidPrivateAddress(h))throw Error(n.transactionErrorCodes.RECIPIENT_FORMAT_INCORRECT);let b=o.validateAndGetChainId(p),x=[...m],S=p.map(e=>e.erc20TokenAddress);if(S.length>1)throw Error(`Solana Transfer: Only one mint address is supported`);let{originalDeployer:C}=e.networkRegistry[b].contractData;if(!C)throw Error(`missing data`);let w=g??S[0],T={mintTo:w,nullifierCount:await c.calculateSolanaNullifierCount(f,b,S,x),rootInsertCount:2},E=_??await l.getFeeStructure(b,w,S,i.ExternalActionId.Transact,[],5n,T);E.variableRate||=t.HINKAL_PRIVATE_SEND_VARIABLE_RATE;let D=-x[0],O=u.calculateTotalFee(D,E);x[0]-=O;let[k,A]=await Promise.all([f.getRandomRelay(b,!0),f.getEthereumAddressByChain(b)]);if(!k)throw Error(n.transactionErrorCodes.RELAYER_NOT_AVAILABLE);let j={recipient:k,mint:S[0]===`11111111111111111111111111111111`?void 0:S[0]},M=s.constructAdminData(v,b,S,x,A);return d.hinkalSolanaTransact(f,{chainId:b,mintAddresses:S,amountChanges:x,relayAddress:k,recipient:t.solanaNativeAddress,signer:k,functionName:`transfer`,accounts:j,relayerFee:O,recipientAddress:h,recipientAmounts:[D],submit:{mode:a.SolanaSubmitMode.Relayer,adminData:M}})};exports.hinkalSolanaTransfer=f;
|
|
@@ -1,32 +1,3 @@
|
|
|
1
|
-
import { AdminTransactionType,
|
|
1
|
+
import { AdminTransactionType, ERC20Token, FeeStructure } from '../../types';
|
|
2
2
|
import { IHinkal } from './IHinkal';
|
|
3
|
-
|
|
4
|
-
import { constructAdminData } from '../../functions/pre-transaction';
|
|
5
|
-
type SolanaTransferPlan = {
|
|
6
|
-
chainId: number;
|
|
7
|
-
relay: string;
|
|
8
|
-
commitmentValidationData?: CommitmentValidationDataType;
|
|
9
|
-
args: {
|
|
10
|
-
proofAArr: number[];
|
|
11
|
-
proofBArr: number[];
|
|
12
|
-
proofCArr: number[];
|
|
13
|
-
publicInputsArr: number[][];
|
|
14
|
-
encryptedOutputs: number[][];
|
|
15
|
-
relayerFee: string;
|
|
16
|
-
dimensions: {
|
|
17
|
-
tokenNumber: number;
|
|
18
|
-
nullifierAmount: number;
|
|
19
|
-
outputAmount: number;
|
|
20
|
-
};
|
|
21
|
-
rootHashIndex: string;
|
|
22
|
-
};
|
|
23
|
-
accounts: {
|
|
24
|
-
recipient: string;
|
|
25
|
-
mint?: string;
|
|
26
|
-
};
|
|
27
|
-
adminData: ReturnType<typeof constructAdminData>;
|
|
28
|
-
recipientUtxo: Utxo;
|
|
29
|
-
};
|
|
30
|
-
export declare const buildSolanaTransferPlan: (hinkal: IHinkal, erc20Tokens: ERC20Token[], amountChangesInput: bigint[], recipientAddress: string, feeToken?: string, feeStructureOverride?: FeeStructure, action?: AdminTransactionType) => Promise<SolanaTransferPlan>;
|
|
31
|
-
export declare const hinkalSolanaTransfer: (hinkal: IHinkal, erc20Tokens: ERC20Token[], amountChanges: bigint[], recipientAddress: string, feeToken?: string, feeStructureOverride?: FeeStructure, action?: AdminTransactionType, onlyGasEstimate?: boolean) => Promise<string>;
|
|
32
|
-
export {};
|
|
3
|
+
export declare const hinkalSolanaTransfer: (hinkal: IHinkal, erc20Tokens: ERC20Token[], amountChangesInput: bigint[], recipientAddress: string, feeToken?: string, feeStructureOverride?: FeeStructure, action?: AdminTransactionType, onlyGasEstimate?: boolean) => Promise<string>;
|
|
@@ -1,132 +1,56 @@
|
|
|
1
1
|
import { networkRegistry as e } from "../../constants/chains.constants.mjs";
|
|
2
2
|
import { HINKAL_PRIVATE_SEND_VARIABLE_RATE as t, solanaNativeAddress as n } from "../../constants/protocol.constants.mjs";
|
|
3
3
|
import { transactionErrorCodes as r } from "../../error-handling/error-codes.constants.mjs";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { isValidPrivateAddress as s } from "../../functions/utils/addresses.mjs";
|
|
8
|
-
import { ExternalActionId as c } from "../../types/external-action.types.mjs";
|
|
4
|
+
import { isValidPrivateAddress as i } from "../../functions/utils/addresses.mjs";
|
|
5
|
+
import { ExternalActionId as a } from "../../types/external-action.types.mjs";
|
|
6
|
+
import { SolanaSubmitMode as o } from "../../types/solana-transact.types.mjs";
|
|
9
7
|
import "../../types/index.mjs";
|
|
10
|
-
import { validateAndGetChainId as
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import { finalizeSolanaTxEnclaveCallRelay as p, prepareSolanaTxEnclaveCall as m } from "../../functions/snarkjs/constructTxEnclave.mjs";
|
|
15
|
-
import { calculateSolanaNullifierCount as h } from "../../functions/pre-transaction/calculateSolanaNullifierCount.mjs";
|
|
16
|
-
import { ensureAmountChanges as g } from "../../functions/pre-transaction/ensureAmountChanges.mjs";
|
|
17
|
-
import { getFeeStructure as _ } from "../../functions/pre-transaction/getFeeStructure.mjs";
|
|
8
|
+
import { validateAndGetChainId as s } from "../../functions/utils/token-check.utils.mjs";
|
|
9
|
+
import { constructAdminData as c } from "../../functions/pre-transaction/constructAdminData.mjs";
|
|
10
|
+
import { calculateSolanaNullifierCount as l } from "../../functions/pre-transaction/calculateSolanaNullifierCount.mjs";
|
|
11
|
+
import { getFeeStructure as u } from "../../functions/pre-transaction/getFeeStructure.mjs";
|
|
18
12
|
import "../../functions/pre-transaction/index.mjs";
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import { constructSolanaZkProof as b } from "../../functions/snarkjs/constructSolanaZkProof.mjs";
|
|
13
|
+
import { calculateTotalFee as d } from "../../functions/utils/fees.utils.mjs";
|
|
14
|
+
import { hinkalSolanaTransact as f } from "./hinkalSolanaTransact.mjs";
|
|
22
15
|
//#region libs/shared/common/src/data-structures/Hinkal/hinkalSolanaTransfer.ts
|
|
23
|
-
var
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
mintAddresses: r,
|
|
34
|
-
amountChanges: i,
|
|
35
|
-
relayAddress: s,
|
|
36
|
-
recipient: n,
|
|
37
|
-
signer: s,
|
|
38
|
-
functionName: "transfer",
|
|
39
|
-
accounts: c,
|
|
40
|
-
relayerFee: l,
|
|
41
|
-
variableRate: 0n,
|
|
42
|
-
hinkalInstructions: [],
|
|
43
|
-
remainingAccounts: [],
|
|
44
|
-
recipientAddress: a,
|
|
45
|
-
recipientAmounts: [o]
|
|
46
|
-
}), { R8: h, S: g } = e.userKeys.signEddsa(BigInt(f));
|
|
47
|
-
return p(d, {
|
|
48
|
-
R8: h,
|
|
49
|
-
S: g
|
|
50
|
-
}, t, { adminData: u });
|
|
51
|
-
}, C = async (o, u, d, p, m, v, S) => {
|
|
52
|
-
if (!s(p)) throw Error(r.RECIPIENT_FORMAT_INCORRECT);
|
|
53
|
-
let C = l(u), w = [...d], { originalDeployer: T } = e[C].contractData;
|
|
54
|
-
if (!T) throw Error("missing data");
|
|
55
|
-
let { userKeys: E, merkleTreeHinkalByChain: D } = o, O = u.map((e) => e.erc20TokenAddress);
|
|
56
|
-
if (O.length > 1) throw Error("Solana Transfer: Only one mint address is supported");
|
|
57
|
-
let k = m ?? O[0], A = {
|
|
58
|
-
mintTo: k,
|
|
59
|
-
nullifierCount: await h(o, C, O, w),
|
|
16
|
+
var p = async (p, m, h, g, _, v, y, b = !1) => {
|
|
17
|
+
if (b) throw Error("onlyGasEstimate is not supported for Solana transfer");
|
|
18
|
+
if (!i(g)) throw Error(r.RECIPIENT_FORMAT_INCORRECT);
|
|
19
|
+
let x = s(m), S = [...h], C = m.map((e) => e.erc20TokenAddress);
|
|
20
|
+
if (C.length > 1) throw Error("Solana Transfer: Only one mint address is supported");
|
|
21
|
+
let { originalDeployer: w } = e[x].contractData;
|
|
22
|
+
if (!w) throw Error("missing data");
|
|
23
|
+
let T = _ ?? C[0], E = {
|
|
24
|
+
mintTo: T,
|
|
25
|
+
nullifierCount: await l(p, x, C, S),
|
|
60
26
|
rootInsertCount: 2
|
|
61
|
-
},
|
|
62
|
-
|
|
63
|
-
let
|
|
64
|
-
|
|
65
|
-
let [
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
recipient: P,
|
|
79
|
-
mint: O[0] === "11111111111111111111111111111111" ? void 0 : O[0]
|
|
80
|
-
};
|
|
81
|
-
return {
|
|
82
|
-
chainId: C,
|
|
83
|
-
relay: P,
|
|
84
|
-
args: {
|
|
85
|
-
proofAArr: V,
|
|
86
|
-
proofBArr: H,
|
|
87
|
-
proofCArr: U,
|
|
88
|
-
publicInputsArr: W,
|
|
89
|
-
encryptedOutputs: q,
|
|
90
|
-
relayerFee: M.toString(),
|
|
91
|
-
dimensions: B,
|
|
92
|
-
rootHashIndex: K.toString()
|
|
93
|
-
},
|
|
94
|
-
accounts: J,
|
|
95
|
-
adminData: f(S, C, O, w, F),
|
|
96
|
-
commitmentValidationData: G,
|
|
97
|
-
recipientUtxo: R
|
|
98
|
-
};
|
|
99
|
-
}, w = async (e, n, i, a, o, u, d, p = !1) => {
|
|
100
|
-
if (p) throw Error("onlyGasEstimate is not supported for Solana transfer");
|
|
101
|
-
if (!s(a)) throw Error(r.RECIPIENT_FORMAT_INCORRECT);
|
|
102
|
-
let m = l(n), g = [...i], b = n.map((e) => e.erc20TokenAddress);
|
|
103
|
-
if (b.length > 1) throw Error("Solana Transfer: Only one mint address is supported");
|
|
104
|
-
if (e.generateProofRemotely) {
|
|
105
|
-
let n = u ?? await _(m, o, b, c.Transact, [], 5n, {
|
|
106
|
-
mintTo: o ?? b[0],
|
|
107
|
-
nullifierCount: await h(e, m, b, g),
|
|
108
|
-
rootInsertCount: 2
|
|
109
|
-
});
|
|
110
|
-
n.variableRate ||= t;
|
|
111
|
-
let i = y(-g[0], n), s = -g[0];
|
|
112
|
-
g[0] -= i;
|
|
113
|
-
let [l, p] = await Promise.all([e.getRandomRelay(m, !0), e.getEthereumAddressByChain(m)]);
|
|
114
|
-
if (!l) throw Error(r.RELAYER_NOT_AVAILABLE);
|
|
115
|
-
return S(e, m, b, g, a, s, l, {
|
|
116
|
-
recipient: l,
|
|
117
|
-
mint: b[0] === "11111111111111111111111111111111" ? void 0 : b[0]
|
|
118
|
-
}, i, f(d, m, b, g, p));
|
|
119
|
-
}
|
|
120
|
-
let x = await C(e, n, i, a, o, u, d);
|
|
121
|
-
return v({
|
|
122
|
-
chainId: x.chainId,
|
|
123
|
-
relayAddress: x.relay,
|
|
27
|
+
}, D = v ?? await u(x, T, C, a.Transact, [], 5n, E);
|
|
28
|
+
D.variableRate ||= t;
|
|
29
|
+
let O = -S[0], k = d(O, D);
|
|
30
|
+
S[0] -= k;
|
|
31
|
+
let [A, j] = await Promise.all([p.getRandomRelay(x, !0), p.getEthereumAddressByChain(x)]);
|
|
32
|
+
if (!A) throw Error(r.RELAYER_NOT_AVAILABLE);
|
|
33
|
+
let M = {
|
|
34
|
+
recipient: A,
|
|
35
|
+
mint: C[0] === "11111111111111111111111111111111" ? void 0 : C[0]
|
|
36
|
+
}, N = c(y, x, C, S, j);
|
|
37
|
+
return f(p, {
|
|
38
|
+
chainId: x,
|
|
39
|
+
mintAddresses: C,
|
|
40
|
+
amountChanges: S,
|
|
41
|
+
relayAddress: A,
|
|
42
|
+
recipient: n,
|
|
43
|
+
signer: A,
|
|
124
44
|
functionName: "transfer",
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
45
|
+
accounts: M,
|
|
46
|
+
relayerFee: k,
|
|
47
|
+
recipientAddress: g,
|
|
48
|
+
recipientAmounts: [O],
|
|
49
|
+
submit: {
|
|
50
|
+
mode: o.Relayer,
|
|
51
|
+
adminData: N
|
|
52
|
+
}
|
|
129
53
|
});
|
|
130
54
|
};
|
|
131
55
|
//#endregion
|
|
132
|
-
export {
|
|
56
|
+
export { p as hinkalSolanaTransfer };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require(`../../constants/chains.constants.cjs`);require(`../../constants/protocol.constants.cjs`);const t=require(`../../error-handling/error-codes.constants.cjs`),n=require(`../../
|
|
1
|
+
const e=require(`../../constants/chains.constants.cjs`);require(`../../constants/protocol.constants.cjs`);const t=require(`../../error-handling/error-codes.constants.cjs`),n=require(`../../types/external-action.types.cjs`),r=require(`../../types/solana-transact.types.cjs`);require(`../../types/index.cjs`);const i=require(`../../functions/utils/token-check.utils.cjs`),a=require(`../../functions/pre-transaction/constructAdminData.cjs`),o=require(`../../functions/pre-transaction/calculateSolanaNullifierCount.cjs`),s=require(`../../functions/pre-transaction/getFeeStructure.cjs`);require(`../../functions/pre-transaction/index.cjs`),require(`../../constants/index.cjs`);const c=require(`../../functions/utils/fees.utils.cjs`),l=require(`./hinkalSolanaTransact.cjs`);var u=async(u,d,f,p,m,h,g)=>{let _=i.validateAndGetChainId(d),v=d.map(e=>e.erc20TokenAddress),y=d[0];if(!y)throw Error(`Solana Withdraw: No Token Found`);let{originalDeployer:b}=e.networkRegistry[_].contractData;if(!b)throw Error(`missing data`);let x=m??v[0],S={mintTo:v[0],recipient:p,nullifierCount:await o.calculateSolanaNullifierCount(u,_,v,f)},C=h??await s.getFeeStructure(_,x,v,n.ExternalActionId.Transact,[],void 0,S),w=await c.calculateModifiedFeeStructure(_,y,-f[0],C);f[0]-=w.flatFee;let[T,E]=await Promise.all([u.getRandomRelay(_,!0),u.getEthereumAddress()]);if(!T)throw Error(t.transactionErrorCodes.RELAYER_NOT_AVAILABLE);if(v.length>1)throw Error(`Solana Withdraw: Only one mint address is supported`);let D={recipient:p,mint:v[0]===`11111111111111111111111111111111`?void 0:v[0]},O=a.constructAdminData(g,_,v,f,E);return l.hinkalSolanaTransact(u,{chainId:_,mintAddresses:v,amountChanges:f,relayAddress:T,recipient:p,signer:T,functionName:`transact`,accounts:D,relayerFee:w.flatFee,variableRate:w.variableRate,submit:{mode:r.SolanaSubmitMode.Relayer,adminData:O}})};exports.hinkalSolanaWithdraw=u;
|