@kapa123456789/sdk 0.0.80 → 0.0.82
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/common/src/data-structures/Hinkal/Hinkal.cjs +1 -1
- package/common/src/data-structures/Hinkal/Hinkal.mjs +41 -4
- package/common/src/data-structures/Hinkal/hinkalDeposit.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalDeposit.mjs +73 -46
- package/common/src/data-structures/Hinkal/hinkalTransfer.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalTransfer.mjs +37 -16
- package/common/src/data-structures/Hinkal/hinkalWithdraw.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalWithdraw.mjs +47 -18
- package/common/src/functions/pre-transaction/getFeeStructure.cjs +1 -1
- package/common/src/functions/pre-transaction/getFeeStructure.mjs +21 -10
- package/common/src/functions/snarkjs/constructGeneralZkProof.cjs +1 -1
- package/common/src/functions/snarkjs/constructGeneralZkProof.mjs +89 -71
- package/common/src/functions/snarkjs/generateMainAndCommitmentZkProof.cjs +1 -1
- package/common/src/functions/snarkjs/generateMainAndCommitmentZkProof.mjs +17 -8
- package/common/src/functions/snarkjs/generateZkProof.cjs +1 -1
- package/common/src/functions/snarkjs/generateZkProof.mjs +26 -8
- package/common/src/functions/utils/process.utils.cjs +1 -1
- package/common/src/functions/utils/process.utils.mjs +14 -13
- package/common/src/functions/web3/functionCalls/transactCallDirect.cjs +1 -1
- package/common/src/functions/web3/functionCalls/transactCallDirect.mjs +61 -43
- package/common/src/functions/web3/functionCalls/transactCallDirectTron.cjs +1 -1
- package/common/src/functions/web3/functionCalls/transactCallDirectTron.mjs +73 -65
- package/common/src/functions/web3/functionCalls/transactCallRelayer.cjs +1 -1
- package/common/src/functions/web3/functionCalls/transactCallRelayer.mjs +22 -14
- package/common/src/webworker/package.json +1 -1
- package/package.json +1 -1
- package/services/Hinkal.cjs +1 -1
- package/services/Hinkal.mjs +42 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require(`../../../error-handling/customErrors/ErrorWithTx.cjs`),t=require(`../../../constants/server.constants.cjs`),n=require(`../../../API/getServerURL.cjs`),r=require(`../../../data-structures/http/HttpClient.cjs`),i=require(`../../../API/callRelayer.cjs`),a=require(`../../snarkjs/common.snarkjs.cjs`);require(`../../../error-handling/index.cjs`),require(`../../snarkjs/index.cjs`);var o=t=>{if(t.status===`success`)return t.message;throw t.message&&t.error?new e.ErrorWithRelayerTransaction(t.error,t.message):Error(t.error)},s=async(e,t,n,r,s,c,l,u,d)=>{let f=a.serializeCircomData(r);
|
|
1
|
+
const e=require(`../../../error-handling/customErrors/ErrorWithTx.cjs`),t=require(`../../../constants/server.constants.cjs`),n=require(`../../../API/getServerURL.cjs`),r=require(`../../../data-structures/http/HttpClient.cjs`),i=require(`../../../API/callRelayer.cjs`),a=require(`../../snarkjs/common.snarkjs.cjs`);require(`../../../error-handling/index.cjs`),require(`../../snarkjs/index.cjs`);var o=t=>{if(t.status===`success`)return t.message;throw t.message&&t.error?new e.ErrorWithRelayerTransaction(t.error,t.message):Error(t.error)},s=async(e,t,n,r,s,c,l,u,d)=>{console.log(`[transactCallRelayer] start`,{chainId:e});try{console.log(`[transactCallRelayer] serializeCircomData`);let f=a.serializeCircomData(r);console.log(`[transactCallRelayer] callRelayerTransactAPI`);let p=o(await i.callRelayerTransactAPI({chainId:e,a:t[0],b:t[1],c:t[2],dimData:n,circomData:f,withUniswapWorkAround:c,authorizationData:l,adminData:u,tronProofSignature:d,commitmentValidationData:s}));return console.log(`[transactCallRelayer] success`,{txHash:p}),p}catch(e){throw console.log(`[transactCallRelayer] error`,e),e}},c=async e=>o(await r.httpClient.post(`${n.RELAYER_URL}${t.RELAYER_CONFIG.SOLANA_TRANSACT}`,e)),l=e=>{if(e.status===`success`)return e.message.scheduleId;throw Error(e.error||`Batch transaction failed`)},u=async(e,t,n,r,o,s)=>{let c=t.map(e=>a.serializeCircomData(e.circomData));return l(await i.callRelayerTransactBatchAPI({chainId:e,transactions:t.map((t,n)=>({chainId:e,a:t.zkCallData[0],b:t.zkCallData[1],c:t.zkCallData[2],dimData:t.dimData,circomData:c[n],commitmentValidationData:t.commitmentValidationData,withUniswapWorkAround:t.withUniswapWorkAround,authorizationData:t.authorizationData,adminData:t.adminData,recipientAddress:t.recipientAddress,tronProofSignature:t.tronProofSignature})),txCompletionTime:r,hashedEthereumAddress:n,ref:o,hashedDashboardAccountId:s}))},d=async(e,t,n,r,a,o)=>l(await i.callRelayerSolanaTransactBatchAPI({chainId:e,transactions:t,hashedEthereumAddress:n,txCompletionTime:r,ref:a,hashedDashboardAccountId:o}));exports.solanaTransactCallRelayer=c,exports.solanaTransactCallRelayerBatch=d,exports.transactCallRelayer=s,exports.transactCallRelayerBatch=u;
|
|
@@ -11,20 +11,28 @@ var c = (t) => {
|
|
|
11
11
|
if (t.status === "success") return t.message;
|
|
12
12
|
throw t.message && t.error ? new e(t.error, t.message) : Error(t.error);
|
|
13
13
|
}, l = async (e, t, n, r, i, o, l, u, d) => {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
c
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
14
|
+
console.log("[transactCallRelayer] start", { chainId: e });
|
|
15
|
+
try {
|
|
16
|
+
console.log("[transactCallRelayer] serializeCircomData");
|
|
17
|
+
let f = s(r);
|
|
18
|
+
console.log("[transactCallRelayer] callRelayerTransactAPI");
|
|
19
|
+
let p = c(await a({
|
|
20
|
+
chainId: e,
|
|
21
|
+
a: t[0],
|
|
22
|
+
b: t[1],
|
|
23
|
+
c: t[2],
|
|
24
|
+
dimData: n,
|
|
25
|
+
circomData: f,
|
|
26
|
+
withUniswapWorkAround: o,
|
|
27
|
+
authorizationData: l,
|
|
28
|
+
adminData: u,
|
|
29
|
+
tronProofSignature: d,
|
|
30
|
+
commitmentValidationData: i
|
|
31
|
+
}));
|
|
32
|
+
return console.log("[transactCallRelayer] success", { txHash: p }), p;
|
|
33
|
+
} catch (e) {
|
|
34
|
+
throw console.log("[transactCallRelayer] error", e), e;
|
|
35
|
+
}
|
|
28
36
|
}, u = async (e) => c(await r.post(`${n}${t.SOLANA_TRANSACT}`, e)), d = (e) => {
|
|
29
37
|
if (e.status === "success") return e.message.scheduleId;
|
|
30
38
|
throw Error(e.error || "Batch transaction failed");
|
package/package.json
CHANGED
package/services/Hinkal.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require(`../common/src/constants/chains.constants.cjs`),t=require(`../common/src/types/hinkal.types.cjs`);require(`../common/src/types/index.cjs`);const n=require(`../common/src/functions/utils/erc20tokenFunctions.cjs`);require(`../common/src/functions/index.cjs`);const r=require(`../common/src/data-structures/Hinkal/Hinkal.cjs`),i=require(`../internal/token.utils.cjs`);var a=class{hinkalCommon;mappedPrivateBalancesSource;mappedPrivateBalances={};constructor(e){this.hinkalCommon=new r.Hinkal(e)}getProviderAdapter(e){return this.hinkalCommon.getProviderAdapter(e)}initProviderAdapter(e,t){return this.hinkalCommon.initProviderAdapter(e,t)}initUserKeys(e=t.LoginMessageMode.PROTOCOL){return this.hinkalCommon.initUserKeys(e)}initUserKeysWithSignature(e){return this.hinkalCommon.initUserKeysWithSignature(e)}initUserKeysFromSeedPhrases(e){return this.hinkalCommon.initUserKeysFromSeedPhrases(e)}storeAndGetInitialSignature(e,t=!1,n){return this.hinkalCommon.storeAndGetInitialSignature(e,t,n)}resetProviderAdapters(){return this.hinkalCommon.resetProviderAdapters()}disconnectFromConnector(){return this.hinkalCommon.disconnectFromConnector()}destroy(){return this.hinkalCommon.destroy()}signMessage(e){return this.hinkalCommon.signMessage(e)}signTypedData(e,t,n){return this.hinkalCommon.signTypedData(e,t,n)}getSupportedChains(){return this.hinkalCommon.getSupportedChains()}isSelectedNetworkSupported(e){return this.hinkalCommon.isSelectedNetworkSupported(e)}switchNetwork(t){let n=e.networkRegistry[t];if(!n)throw Error(`Network with chainId ${t} not supported`);return this.hinkalCommon.switchNetwork(n)}resetMerkle(e){return this.hinkalCommon.resetMerkle(e)}resetMerkleTreesIfNecessary(e){return this.hinkalCommon.resetMerkleTreesIfNecessary(e)}getMappedPrivateBalances(e){return e===this.mappedPrivateBalancesSource?this.mappedPrivateBalances:(this.mappedPrivateBalancesSource=e,this.mappedPrivateBalances=i.mapPrivateBalances(e),this.mappedPrivateBalances)}get privateBalancesWithUSD(){return this.getMappedPrivateBalances(this.hinkalCommon.privateBalancesWithUSD)}onPrivateBalancesWithUSDChange(e){return this.hinkalCommon.onPrivateBalancesWithUSDChange(t=>e(this.getMappedPrivateBalances(t)))}async getTotalBalance(e,t=!1,n=!1){return(await this.hinkalCommon.getTotalBalance(e,void 0,void 0,t,n)).map(i.mapTokenBalance)}async getStuckShieldedBalances(e,t=!1,n=!1){return(await this.hinkalCommon.getStuckShieldedBalances(e,void 0,void 0,t,n)).map(i.mapTokenBalance)}monitorConnectedAddress(e){return this.hinkalCommon.monitorConnectedAddress(e)}waitForTransaction(e,t,n){return this.hinkalCommon.waitForTransaction(e,t,n)}getSolanaPublicKey(){return this.hinkalCommon.getSolanaPublicKey()}getEthereumAddress(){return this.hinkalCommon.getEthereumAddress()}getEthereumAddressByChain(e){return this.hinkalCommon.getEthereumAddressByChain(e)}getRecipientInfo(){return this.hinkalCommon.getRecipientInfo()}getShieldedPublicKey(){return this.hinkalCommon.userKeys.getShieldedPublicKey()}async prooflessDeposit(e,t,r,i){return this.hinkalCommon.prooflessDeposit(await n.resolveErc20Tokens(e,t),r,i)}async prooflessDepositWithPublicFee(e,t,r,i,a){return this.hinkalCommon.prooflessDepositWithPublicFee(await n.resolveErc20Token(e,t),r,i,a)}async deposit(e,t,r,i,a){
|
|
1
|
+
const e=require(`../common/src/constants/chains.constants.cjs`),t=require(`../common/src/types/hinkal.types.cjs`);require(`../common/src/types/index.cjs`);const n=require(`../common/src/functions/utils/erc20tokenFunctions.cjs`);require(`../common/src/functions/index.cjs`);const r=require(`../common/src/data-structures/Hinkal/Hinkal.cjs`),i=require(`../internal/token.utils.cjs`);var a=class{hinkalCommon;mappedPrivateBalancesSource;mappedPrivateBalances={};constructor(e){this.hinkalCommon=new r.Hinkal(e)}getProviderAdapter(e){return this.hinkalCommon.getProviderAdapter(e)}initProviderAdapter(e,t){return this.hinkalCommon.initProviderAdapter(e,t)}initUserKeys(e=t.LoginMessageMode.PROTOCOL){return this.hinkalCommon.initUserKeys(e)}initUserKeysWithSignature(e){return this.hinkalCommon.initUserKeysWithSignature(e)}initUserKeysFromSeedPhrases(e){return this.hinkalCommon.initUserKeysFromSeedPhrases(e)}storeAndGetInitialSignature(e,t=!1,n){return this.hinkalCommon.storeAndGetInitialSignature(e,t,n)}resetProviderAdapters(){return this.hinkalCommon.resetProviderAdapters()}disconnectFromConnector(){return this.hinkalCommon.disconnectFromConnector()}destroy(){return this.hinkalCommon.destroy()}signMessage(e){return this.hinkalCommon.signMessage(e)}signTypedData(e,t,n){return this.hinkalCommon.signTypedData(e,t,n)}getSupportedChains(){return this.hinkalCommon.getSupportedChains()}isSelectedNetworkSupported(e){return this.hinkalCommon.isSelectedNetworkSupported(e)}switchNetwork(t){let n=e.networkRegistry[t];if(!n)throw Error(`Network with chainId ${t} not supported`);return this.hinkalCommon.switchNetwork(n)}resetMerkle(e){return this.hinkalCommon.resetMerkle(e)}resetMerkleTreesIfNecessary(e){return this.hinkalCommon.resetMerkleTreesIfNecessary(e)}getMappedPrivateBalances(e){return e===this.mappedPrivateBalancesSource?this.mappedPrivateBalances:(this.mappedPrivateBalancesSource=e,this.mappedPrivateBalances=i.mapPrivateBalances(e),this.mappedPrivateBalances)}get privateBalancesWithUSD(){return this.getMappedPrivateBalances(this.hinkalCommon.privateBalancesWithUSD)}onPrivateBalancesWithUSDChange(e){return this.hinkalCommon.onPrivateBalancesWithUSDChange(t=>e(this.getMappedPrivateBalances(t)))}async getTotalBalance(e,t=!1,n=!1){return(await this.hinkalCommon.getTotalBalance(e,void 0,void 0,t,n)).map(i.mapTokenBalance)}async getStuckShieldedBalances(e,t=!1,n=!1){return(await this.hinkalCommon.getStuckShieldedBalances(e,void 0,void 0,t,n)).map(i.mapTokenBalance)}monitorConnectedAddress(e){return this.hinkalCommon.monitorConnectedAddress(e)}waitForTransaction(e,t,n){return this.hinkalCommon.waitForTransaction(e,t,n)}getSolanaPublicKey(){return this.hinkalCommon.getSolanaPublicKey()}getEthereumAddress(){return this.hinkalCommon.getEthereumAddress()}getEthereumAddressByChain(e){return this.hinkalCommon.getEthereumAddressByChain(e)}getRecipientInfo(){return this.hinkalCommon.getRecipientInfo()}getShieldedPublicKey(){return this.hinkalCommon.userKeys.getShieldedPublicKey()}async prooflessDeposit(e,t,r,i){return this.hinkalCommon.prooflessDeposit(await n.resolveErc20Tokens(e,t),r,i)}async prooflessDepositWithPublicFee(e,t,r,i,a){return this.hinkalCommon.prooflessDepositWithPublicFee(await n.resolveErc20Token(e,t),r,i,a)}async deposit(e,t,r,i,a){console.log(`[hinkal.deposit] start`,{chainId:e,erc20Addresses:t,amountChanges:r.map(String)});try{let o=await n.resolveErc20Tokens(e,t);console.log(`[hinkal.deposit] resolved tokens`);let s=await this.hinkalCommon.deposit(o,r,i,a);return console.log(`[hinkal.deposit] success`,{result:s}),s}catch(e){throw console.log(`[hinkal.deposit] error`,e),e}}async depositSolana(e,t,r){return this.hinkalCommon.depositSolana(r,await n.resolveErc20Token(e,t))}async depositForOther(e,t,r,i,a,o){return this.hinkalCommon.depositForOther(await n.resolveErc20Tokens(e,t),r,i,a,o)}async depositSolanaForOther(e,t,r,i){return this.hinkalCommon.depositSolanaForOther(r,await n.resolveErc20Token(e,t),i)}async depositAndWithdraw(e,t,r,i,a,o,s){return this.hinkalCommon.depositAndWithdraw(await n.resolveErc20Token(e,t),r,i,a,o,void 0,void 0,void 0,s)}async depositAndBridge(e,t,r,i,a,o){return this.hinkalCommon.depositAndBridge(await n.resolveErc20Token(e,t),r,i,a,void 0,void 0,void 0,o)}async checkSendTransactionStatus(e){return this.hinkalCommon.checkSendTransactionStatus(e)}async nearDepositAndBridge(e,t,r,i,a,o,s){return this.hinkalCommon.nearDepositAndBridge(await n.resolveErc20Token(e,t),r,i,a,o,s)}async claimUtxo(e,t,r,i,a){return this.hinkalCommon.claimUtxo(await n.resolveErc20Token(e,t),r,i,a)}async transfer(e,t,r,i,a,o){console.log(`[hinkal.transfer] start`,{chainId:e,erc20Addresses:t,amountChanges:r.map(String),recipientAddress:i});try{let s=await n.resolveErc20Tokens(e,t);console.log(`[hinkal.transfer] resolved tokens`);let c=await this.hinkalCommon.transfer(s,r,i,a,o);return console.log(`[hinkal.transfer] success`,{result:c}),c}catch(e){throw console.log(`[hinkal.transfer] error`,e),e}}async withdraw(e,t,r,i,a,o,s){console.log(`[hinkal.withdraw] start`,{chainId:e,erc20Addresses:t,deltaAmounts:r.map(String),recipientAddress:i,isRelayerOff:a});try{let c=await n.resolveErc20Tokens(e,t);console.log(`[hinkal.withdraw] resolved tokens`);let l=await this.hinkalCommon.withdraw(c,r,i,a,o,s);return console.log(`[hinkal.withdraw] success`,{result:l}),l}catch(e){throw console.log(`[hinkal.withdraw] error`,e),e}}async withdrawStuckUtxos(e,t,r){return this.hinkalCommon.withdrawStuckUtxos(await n.resolveErc20Token(e,t),r)}async swap(e,t,r,i,a,o,s){return this.hinkalCommon.swap(await n.resolveErc20Tokens(e,t),r,i,a,o,s)}async actionPrivateWallet(e,t,r,a,o,s,c,l,u){return this.hinkalCommon.actionPrivateWallet(e,await n.resolveErc20Tokens(e,t),r,a,o,await i.resolveCommonTokenChanges(e,s),c,l,u)}async proxySwap(e,t,r,i,a,o,s,c,l){return this.hinkalCommon.proxySwap(await n.resolveErc20Tokens(e,t),r,i,a,o,s,c,l)}async proxyToPrivate(e,t,r,i,a,o,s){return this.hinkalCommon.proxyToPrivate(await n.resolveErc20Tokens(e,t),r,i,a,o,s)}async proxySend(e,t,r,i,a,o,s){return this.hinkalCommon.proxySend(await n.resolveErc20Tokens(e,t),r,i,a,o,s)}};exports.Hinkal=a;
|
package/services/Hinkal.mjs
CHANGED
|
@@ -106,7 +106,19 @@ var c = class {
|
|
|
106
106
|
return this.hinkalCommon.prooflessDepositWithPublicFee(await n(e, t), r, i, a);
|
|
107
107
|
}
|
|
108
108
|
async deposit(e, t, n, i, a) {
|
|
109
|
-
|
|
109
|
+
console.log("[hinkal.deposit] start", {
|
|
110
|
+
chainId: e,
|
|
111
|
+
erc20Addresses: t,
|
|
112
|
+
amountChanges: n.map(String)
|
|
113
|
+
});
|
|
114
|
+
try {
|
|
115
|
+
let o = await r(e, t);
|
|
116
|
+
console.log("[hinkal.deposit] resolved tokens");
|
|
117
|
+
let s = await this.hinkalCommon.deposit(o, n, i, a);
|
|
118
|
+
return console.log("[hinkal.deposit] success", { result: s }), s;
|
|
119
|
+
} catch (e) {
|
|
120
|
+
throw console.log("[hinkal.deposit] error", e), e;
|
|
121
|
+
}
|
|
110
122
|
}
|
|
111
123
|
async depositSolana(e, t, r) {
|
|
112
124
|
return this.hinkalCommon.depositSolana(r, await n(e, t));
|
|
@@ -133,10 +145,37 @@ var c = class {
|
|
|
133
145
|
return this.hinkalCommon.claimUtxo(await n(e, t), r, i, a);
|
|
134
146
|
}
|
|
135
147
|
async transfer(e, t, n, i, a, o) {
|
|
136
|
-
|
|
148
|
+
console.log("[hinkal.transfer] start", {
|
|
149
|
+
chainId: e,
|
|
150
|
+
erc20Addresses: t,
|
|
151
|
+
amountChanges: n.map(String),
|
|
152
|
+
recipientAddress: i
|
|
153
|
+
});
|
|
154
|
+
try {
|
|
155
|
+
let s = await r(e, t);
|
|
156
|
+
console.log("[hinkal.transfer] resolved tokens");
|
|
157
|
+
let c = await this.hinkalCommon.transfer(s, n, i, a, o);
|
|
158
|
+
return console.log("[hinkal.transfer] success", { result: c }), c;
|
|
159
|
+
} catch (e) {
|
|
160
|
+
throw console.log("[hinkal.transfer] error", e), e;
|
|
161
|
+
}
|
|
137
162
|
}
|
|
138
163
|
async withdraw(e, t, n, i, a, o, s) {
|
|
139
|
-
|
|
164
|
+
console.log("[hinkal.withdraw] start", {
|
|
165
|
+
chainId: e,
|
|
166
|
+
erc20Addresses: t,
|
|
167
|
+
deltaAmounts: n.map(String),
|
|
168
|
+
recipientAddress: i,
|
|
169
|
+
isRelayerOff: a
|
|
170
|
+
});
|
|
171
|
+
try {
|
|
172
|
+
let c = await r(e, t);
|
|
173
|
+
console.log("[hinkal.withdraw] resolved tokens");
|
|
174
|
+
let l = await this.hinkalCommon.withdraw(c, n, i, a, o, s);
|
|
175
|
+
return console.log("[hinkal.withdraw] success", { result: l }), l;
|
|
176
|
+
} catch (e) {
|
|
177
|
+
throw console.log("[hinkal.withdraw] error", e), e;
|
|
178
|
+
}
|
|
140
179
|
}
|
|
141
180
|
async withdrawStuckUtxos(e, t, r) {
|
|
142
181
|
return this.hinkalCommon.withdrawStuckUtxos(await n(e, t), r);
|