h_test_1 0.0.39 → 0.0.40
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require(`../../types/ethereum-network.types.cjs`),t=require(`../../types/external-action.types.cjs`),n=require(`../../constants/chains.constants.cjs`),r=require(`../../constants/protocol.constants.cjs`),i=require(`../../types/hinkal.types.cjs`);require(`../../types/index.cjs`);const a=require(`../../error-handling/error-codes.constants.cjs`),o=require(`../../functions/utils/time.utils.cjs`),s=require(`../../functions/utils/tron.utils.cjs`),c=require(`../../functions/utils/token-check.utils.cjs`),l=require(`../../functions/web3/events/getShieldedBalance.cjs`),u=require(`../../functions/pre-transaction/outputUtxoProcessing.cjs`),d=require(`../../functions/utils/fees.utils.cjs`),f=require(`../../functions/pre-transaction/outputApprovalDataProcessing.cjs`),p=require(`../../functions/pre-transaction/getVolatileTransferAmount.cjs`),m=require(`../../functions/pre-transaction/constructAdminData.cjs`),h=require(`../../functions/pre-transaction/getFeeStructure.cjs`),g=require(`../../functions/pre-transaction/getKycAndSignatureData.cjs`);require(`../../functions/pre-transaction/index.cjs`);const _=require(`../../functions/snarkjs/constructGeneralZkProof.cjs`),v=require(`../../functions/web3/functionCalls/transactCallDirect.cjs`),y=require(`../../functions/web3/functionCalls/transactCallRelayer.cjs`),b=require(`../../functions/pre-transaction/merge-with-fee-structure.cjs`);var x=async(e,t,n,r)=>{let a=[...await l.addPaddingToUtxos(e,t,n,r)]
|
|
1
|
+
const e=require(`../../types/ethereum-network.types.cjs`),t=require(`../../types/external-action.types.cjs`),n=require(`../../constants/chains.constants.cjs`),r=require(`../../constants/protocol.constants.cjs`),i=require(`../../types/hinkal.types.cjs`);require(`../../types/index.cjs`);const a=require(`../../error-handling/error-codes.constants.cjs`),o=require(`../../functions/utils/time.utils.cjs`),s=require(`../../functions/utils/tron.utils.cjs`),c=require(`../../functions/utils/token-check.utils.cjs`),l=require(`../../functions/web3/events/getShieldedBalance.cjs`),u=require(`../../functions/pre-transaction/outputUtxoProcessing.cjs`),d=require(`../../functions/utils/fees.utils.cjs`),f=require(`../../functions/pre-transaction/outputApprovalDataProcessing.cjs`),p=require(`../../functions/pre-transaction/getVolatileTransferAmount.cjs`),m=require(`../../functions/pre-transaction/constructAdminData.cjs`),h=require(`../../functions/pre-transaction/getFeeStructure.cjs`),g=require(`../../functions/pre-transaction/getKycAndSignatureData.cjs`);require(`../../functions/pre-transaction/index.cjs`);const _=require(`../../functions/snarkjs/constructGeneralZkProof.cjs`),v=require(`../../functions/web3/functionCalls/transactCallDirect.cjs`),y=require(`../../functions/web3/functionCalls/transactCallRelayer.cjs`),b=require(`../../functions/pre-transaction/merge-with-fee-structure.cjs`);var x=async(e,t,n,r)=>{console.log(`hinkalWithdraw 0 deltaAmounts`,{deltaAmounts:r,erc20Addresses:n});let a=[...await l.addPaddingToUtxos(e,t,n,r)];console.log(`hinkalWithdraw 1 inputUtxosArray`,a);let s=[],c=i.defaultHinkalLogicArgs(r.length,e.userKeys),d=o.getCurrentTimeInSeconds().toString();for(let i=0;i<n.length;i+=1){let{outputUtxos:n}=u.outputUtxoProcessing(e.userKeys,a[i],r[i],d,void 0,!1);s.push(n),console.log(`hinkalWithdraw 2 outputUtxosArray`,s);let{useApprovalUtxoData:o}=f.outputApprovalDataProcessing(e,t,a[i],r[i]);o&&(c.useApprovalUtxoData[i]=o,c.doPreTxApproval=!0)}return{inputUtxosArray:a,outputUtxosArray:s,hinkalLogicArgs:c}},S=async(i,o,l,u,f,S,C,w)=>{let T=c.validateAndGetChainId(o),E=n.isTronLike(T),D=s.addressToHexFormat(await i.getEthereumAddressByChain(T)),O=o.map(e=>e.erc20TokenAddress),k=await p.modifyVolatileTokenAmountChanges(T,o,l),A;if(!f){let e=C??await h.getFeeStructure(T,S,O,t.ExternalActionId.Transact),n=d.calculateTotalFee(-k[0],e);A={feeToken:e.feeToken,flatFee:n,variableRate:0n},b.mergeWithFeeStructure(T,O,k,A)}let j=o[0];if(!j)throw Error(`Deposit Action: No Token Found`);let M={externalActionId:0n,externalAddress:s.addressToHexFormat(u),externalActionMetadata:`0x00`},[N,{patchAccessTokenMerkleTree:P,signatureData:F},{inputUtxosArray:I,outputUtxosArray:L,hinkalLogicArgs:R}]=await Promise.all([i.getRandomRelay(T,!0),g.getKycAndSignatureData(i,T,O,k,D),x(i,T,O,k)]);if(!f&&!N)throw Error(a.transactionErrorCodes.RELAYER_NOT_AVAILABLE);let z=`swapperM${k.length.toString()}x${I[0].length}x1`,{zkCallData:B,circomData:V,dimData:H}=await _.constructZkProof(i.merkleTreeHinkalByChain[T],i.merkleTreeAccessTokenByChain[T],I,L,i.userKeys,z,M.externalActionId,M.externalAddress,M.externalActionMetadata,i.generateProofRemotely,f?r.zeroAddress:N,T,void 0,void 0,void 0,P,R,void 0,A,i.getContractWithFetcher(T,e.ContractType.HinkalHelperContract),F,f?D:void 0),U=await s.reorderZkCallData(E,B,H,V);if(f){if(!j)throw Error(`Withdraw Action: No Token Found`);return await v.transactCallDirect(i,T,k[0],j,B,V,H)}return await y.transactCallRelayer(T,B,H,V,void 0,void 0,m.constructAdminData(w,T,O,k,D),U)};exports.hinkalWithdraw=S;
|
|
@@ -23,10 +23,16 @@ import { transactCallRelayer as b } from "../../functions/web3/functionCalls/tra
|
|
|
23
23
|
import { mergeWithFeeStructure as x } from "../../functions/pre-transaction/merge-with-fee-structure.mjs";
|
|
24
24
|
//#region libs/shared/common/src/data-structures/Hinkal/hinkalWithdraw.ts
|
|
25
25
|
var S = async (e, t, n, r) => {
|
|
26
|
-
|
|
26
|
+
console.log("hinkalWithdraw 0 deltaAmounts", {
|
|
27
|
+
deltaAmounts: r,
|
|
28
|
+
erc20Addresses: n
|
|
29
|
+
});
|
|
30
|
+
let a = [...await u(e, t, n, r)];
|
|
31
|
+
console.log("hinkalWithdraw 1 inputUtxosArray", a);
|
|
32
|
+
let s = [], c = i(r.length, e.userKeys), l = o().toString();
|
|
27
33
|
for (let i = 0; i < n.length; i += 1) {
|
|
28
34
|
let { outputUtxos: n } = d(e.userKeys, a[i], r[i], l, void 0, !1);
|
|
29
|
-
s.push(n);
|
|
35
|
+
s.push(n), console.log("hinkalWithdraw 2 outputUtxosArray", s);
|
|
30
36
|
let { useApprovalUtxoData: o } = p(e, t, a[i], r[i]);
|
|
31
37
|
o && (c.useApprovalUtxoData[i] = o, c.doPreTxApproval = !0);
|
|
32
38
|
}
|