h_test_1 0.0.41 → 0.0.42

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
- require(`../../../_virtual/_rolldown/runtime.cjs`);const e=require(`../../../constants/chains.constants.cjs`),t=require(`../../utils/caseInsensitive.utils.cjs`),n=require(`../../utils/addresses.cjs`),r=require(`../../../API/scheduled-transactions-calls.cjs`),i=require(`../../../data-structures/utxo/Utxo.cjs`),a=require(`../../utils/upToDateState.cjs`),o=require(`../../utils/cacheFunctions.cjs`),s=require(`../../utils/encodeTokenWithId.cjs`),c=require(`../../utils/solanaMint.utils.cjs`),l=require(`./getInputUtxosEnclave.cjs`),u=require(`../../utils/tron.utils.cjs`);var d=new(require(`async-mutex`)).Mutex,f=async(e,t,n,r,i,s,c,l,u)=>d.runExclusive(async()=>{u+=1;let d=s.slice(u),{lastOutput:f,additionalEncryptedOutputs:p}=await e.utxoUtils.batchProcess(d,l,t,n),m=[...c,...p];return await a.checkAddressNotUpdated(e,r),o.setHinkalCache({lastOutput:f,encryptedOutputs:m},e,n,i),await e.utxoUtils.buildBatchProcess(m,t,n)}),p=async(e,t,n,r)=>{let{utxos:i,encryptedOutputs:a,lastOutput:s}=await l.getInputUtxosEnclave(e,n,t);return o.setHinkalCache({encryptedOutputs:a,lastOutput:s},e,n,r),i},m=async(e,t,n,r,i,a,o,s,c)=>{try{return await p(e,t,n,i)}catch{return f(e,t,n,r,i,a,o,s,c)}},h=e=>{if(Array.isArray(e))return e;if(e!==void 0)return[e]},g=async(e,t,n)=>await e.utxoUtils.batchFilterUtxosWithNullifier(t,n),_=(e,t,n,r,a,o,s)=>{for(e.sort((e,t)=>e.amount<=t.amount?1:-1);e.length<t||e.length>t&&e.length<6;)if(e.push(new i.Utxo({amount:0n,erc20TokenAddress:a,mintAddress:s,shieldedPrivateKey:r,tokenId:o})),n)for(;e.length>6;)e.splice(e.length-1)},v=async({hinkal:e,chainId:t,passedShieldedPublicKey:n=void 0,ethAddress:r=void 0,resetCacheBefore:i=!1,allowRemoteDecryption:s=!1,useBlockedUtxos:c=!1})=>{let l=r??await e.getEthereumAddress(),u=n??e.userKeys.getShieldedPublicKey(),{userKeys:d}=e,p=e.encryptedOutputsByChain[t],h=e.nullifiersByChain[t],_=Array.from(p);i&&o.resetCache(e,t,u);let{encryptedOutputs:v,lastOutput:y}=o.getHinkalCache(e,t,u);await a.checkAddressNotUpdated(e,l);let b=y!==``,x=_.findIndex(e=>e.value===y),S=x>-1,C=!b&&x===-1,w=e.areMerkleTreeUpdatesDisabled(),T=!w&&(S||!s&&C),E=!w&&s&&C,D=!T&&!E,O=[];T?O=await f(e,d,t,l,u,_,v,y,x):E?O=await m(e,d,t,l,u,_,v,y,x):D&&(O=await e.utxoUtils.buildBatchProcess(v,d,t)),await a.checkAddressNotUpdated(e,l);let k=await g(e,O,h);return{inputUtxos:c?k.filter(e=>e.isBlocked):k.filter(e=>!e.isBlocked)}},y=async({hinkal:t,chainId:i,passedShieldedPublicKey:a=void 0,ethAddress:o=void 0,resetCacheBefore:s=!1,allowRemoteDecryption:c=!1})=>{let l=o??await t.getEthereumAddressByChain(i),d=n.hashEthereumAddress(e.isTronLike(i)?u.addressToHexFormat(l):l),{inputUtxos:f}=await v({hinkal:t,chainId:i,passedShieldedPublicKey:a,ethAddress:l,resetCacheBefore:s,allowRemoteDecryption:c,useBlockedUtxos:!0});if(!f.length)return{inputUtxos:[]};let{indexes:p}=await r.getScheduledTransactionsNullifierIndexes({hashedEthereumAddress:d,nullifiers:f.map(e=>e.getNullifier())});return{inputUtxos:p.map(e=>f[e]).filter(e=>!!e)}},b=async({hinkal:n,tokenWithId:r,minInput:i=2,sliceIfMore6:a=!0,chainId:o,passedShieldedPrivateKey:l=void 0,passedShieldedPublicKey:u=void 0,ethAddress:d=void 0,resetCacheBefore:f=!1,ensuredTokensWithId:p,useBlockedUtxos:m=!1})=>{let g=l??n.userKeys.getShieldedPrivateKey(),{inputUtxos:b}=m?await y({hinkal:n,chainId:o,ethAddress:d,passedShieldedPrivateKey:l,resetCacheBefore:f}):await v({hinkal:n,tokenWithId:r,minInput:i,sliceIfMore6:a,chainId:o,passedShieldedPrivateKey:l,passedShieldedPublicKey:u,ethAddress:d,resetCacheBefore:f}),x=h(r),S=new Map;b.forEach(e=>{let n=e.getTokenAddress(o);if(x&&!x.some(r=>t.caseInsensitiveEqual(r.erc20TokenAddress,n)&&r.tokenId===e.tokenId))return;let r=s.encodeTokenWithId(o,{erc20TokenAddress:n,tokenId:e.tokenId}),i=S.get(r)??[];S.set(r,[...i,e])}),p?.forEach(e=>{let t=s.encodeTokenWithId(o,{erc20TokenAddress:e.erc20TokenAddress,tokenId:e.tokenId});S.set(t,S.get(t)??[])});for(let[t,n]of S){let r=t.split(`-`)[0],s=Number(t.split(`-`)[1]),l=e.isSolanaLike(o),u=l?r:void 0;_(n,i,a,g,l?c.formatMintAddress(r).compressedAddress.toLowerCase():r.toLowerCase(),s,u)}return S};exports.attemptGetInputUtxosRemotely=m,exports.getInputUtxoAndBalance=v,exports.getInputUtxoAndBalanceOfStuckUtxos=y,exports.getInputUtxoAndBalancePerToken=b,exports.getInputUtxosRemotely=p;
1
+ require(`../../../_virtual/_rolldown/runtime.cjs`);const e=require(`../../../constants/chains.constants.cjs`),t=require(`../../utils/caseInsensitive.utils.cjs`),n=require(`../../utils/addresses.cjs`),r=require(`../../../API/scheduled-transactions-calls.cjs`),i=require(`../../../data-structures/utxo/Utxo.cjs`),a=require(`../../utils/upToDateState.cjs`),o=require(`../../utils/cacheFunctions.cjs`),s=require(`../../utils/encodeTokenWithId.cjs`),c=require(`../../utils/solanaMint.utils.cjs`),l=require(`./getInputUtxosEnclave.cjs`),u=require(`../../utils/tron.utils.cjs`);var d=new(require(`async-mutex`)).Mutex,f=async(e,t,n,r,i,s,c,l,u)=>d.runExclusive(async()=>{u+=1;let d=s.slice(u),{lastOutput:f,additionalEncryptedOutputs:p}=await e.utxoUtils.batchProcess(d,l,t,n),m=[...c,...p];return await a.checkAddressNotUpdated(e,r),o.setHinkalCache({lastOutput:f,encryptedOutputs:m},e,n,i),await e.utxoUtils.buildBatchProcess(m,t,n)}),p=async(e,t,n,r)=>{let{utxos:i,encryptedOutputs:a,lastOutput:s}=await l.getInputUtxosEnclave(e,n,t);return o.setHinkalCache({encryptedOutputs:a,lastOutput:s},e,n,r),i},m=async(e,t,n,r,i,a,o,s,c)=>{try{return await p(e,t,n,i)}catch{return f(e,t,n,r,i,a,o,s,c)}},h=e=>{if(Array.isArray(e))return e;if(e!==void 0)return[e]},g=async(e,t,n)=>await e.utxoUtils.batchFilterUtxosWithNullifier(t,n),_=(e,t,n,r,a,o,s)=>{for(e.sort((e,t)=>e.amount<=t.amount?1:-1);e.length<t||e.length>t&&e.length<6;)if(e.push(new i.Utxo({amount:0n,erc20TokenAddress:a,mintAddress:s,shieldedPrivateKey:r,tokenId:o})),n)for(;e.length>6;)e.splice(e.length-1)},v=async({hinkal:e,chainId:t,passedShieldedPublicKey:n=void 0,ethAddress:r=void 0,resetCacheBefore:i=!1,allowRemoteDecryption:s=!1,useBlockedUtxos:c=!1})=>{let l=r??await e.getEthereumAddress(),u=n??e.userKeys.getShieldedPublicKey(),{userKeys:d}=e,p=e.encryptedOutputsByChain[t],h=e.nullifiersByChain[t],_=Array.from(p);i&&o.resetCache(e,t,u);let{encryptedOutputs:v,lastOutput:y}=o.getHinkalCache(e,t,u);await a.checkAddressNotUpdated(e,l);let b=y!==``,x=_.findIndex(e=>e.value===y),S=x>-1,C=!b&&x===-1,w=e.areMerkleTreeUpdatesDisabled(),T=!w&&(S||!s&&C),E=!w&&s&&C,D=!T&&!E,O=[];T?O=await f(e,d,t,l,u,_,v,y,x):E?O=await m(e,d,t,l,u,_,v,y,x):D&&(O=await e.utxoUtils.buildBatchProcess(v,d,t)),await a.checkAddressNotUpdated(e,l);let k=await g(e,O,h);return{inputUtxos:c?k.filter(e=>e.isBlocked):k.filter(e=>!e.isBlocked)}},y=async({hinkal:t,chainId:i,passedShieldedPublicKey:a=void 0,ethAddress:o=void 0,resetCacheBefore:s=!1,allowRemoteDecryption:c=!1})=>{let l=o??await t.getEthereumAddressByChain(i),d=n.hashEthereumAddress(e.isTronLike(i)?u.addressToHexFormat(l):l),{inputUtxos:f}=await v({hinkal:t,chainId:i,passedShieldedPublicKey:a,ethAddress:l,resetCacheBefore:s,allowRemoteDecryption:c,useBlockedUtxos:!0});if(!f.length)return{inputUtxos:[]};let{indexes:p}=await r.getScheduledTransactionsNullifierIndexes({hashedEthereumAddress:d,nullifiers:f.map(e=>e.getNullifier())});return{inputUtxos:p.map(e=>f[e]).filter(e=>!!e)}},b=async({hinkal:n,tokenWithId:r,minInput:i=2,sliceIfMore6:a=!0,chainId:o,passedShieldedPrivateKey:l=void 0,passedShieldedPublicKey:u=void 0,ethAddress:d=void 0,resetCacheBefore:f=!1,ensuredTokensWithId:p,useBlockedUtxos:m=!1})=>{console.log(`getInputUtxoAndBalancePerToken 0 start`,{tokenWithId:r,minInput:i,sliceIfMore6:a,chainId:o,passedShieldedPrivateKey:l,passedShieldedPublicKey:u,ethAddress:d,resetCacheBefore:f,ensuredTokensWithId:p,useBlockedUtxos:m});let g=l??n.userKeys.getShieldedPrivateKey();console.log(`getInputUtxoAndBalancePerToken 1 useBlockedUtxos`,m);let{inputUtxos:b}=m?await y({hinkal:n,chainId:o,ethAddress:d,passedShieldedPrivateKey:l,resetCacheBefore:f}):await v({hinkal:n,tokenWithId:r,minInput:i,sliceIfMore6:a,chainId:o,passedShieldedPrivateKey:l,passedShieldedPublicKey:u,ethAddress:d,resetCacheBefore:f});console.log(`getInputUtxoAndBalancePerToken 2 inputUtxos`,b);let x=h(r);console.log(`getInputUtxoAndBalancePerToken 3 tokensWithId`,x);let S=new Map;b.forEach(e=>{let n=e.getTokenAddress(o);if(x&&!x.some(r=>t.caseInsensitiveEqual(r.erc20TokenAddress,n)&&r.tokenId===e.tokenId))return;let r=s.encodeTokenWithId(o,{erc20TokenAddress:n,tokenId:e.tokenId}),i=S.get(r)??[];S.set(r,[...i,e])}),console.log(`getInputUtxoAndBalancePerToken 4 inputUtxosPerToken`,S),p?.forEach(e=>{let t=s.encodeTokenWithId(o,{erc20TokenAddress:e.erc20TokenAddress,tokenId:e.tokenId});S.set(t,S.get(t)??[])}),console.log(`getInputUtxoAndBalancePerToken 5 ensuredTokensWithId`,p);for(let[t,n]of S){let r=t.split(`-`)[0],s=Number(t.split(`-`)[1]),l=e.isSolanaLike(o),u=l?r:void 0;_(n,i,a,g,l?c.formatMintAddress(r).compressedAddress.toLowerCase():r.toLowerCase(),s,u)}return console.log(`getInputUtxoAndBalancePerToken 6 inputUtxosPerToken`,S),S};exports.attemptGetInputUtxosRemotely=m,exports.getInputUtxoAndBalance=v,exports.getInputUtxoAndBalanceOfStuckUtxos=y,exports.getInputUtxoAndBalancePerToken=b,exports.getInputUtxosRemotely=p;
@@ -67,7 +67,21 @@ var h = new m(), g = async (e, t, n, r, i, a, s, c, u) => h.runExclusive(async (
67
67
  });
68
68
  return { inputUtxos: f.map((e) => d[e]).filter((e) => !!e) };
69
69
  }, w = async ({ hinkal: t, tokenWithId: r, minInput: i = 2, sliceIfMore6: a = !0, chainId: o, passedShieldedPrivateKey: s = void 0, passedShieldedPublicKey: c = void 0, ethAddress: l = void 0, resetCacheBefore: f = !1, ensuredTokensWithId: p, useBlockedUtxos: m = !1 }) => {
70
- let h = s ?? t.userKeys.getShieldedPrivateKey(), { inputUtxos: g } = m ? await C({
70
+ console.log("getInputUtxoAndBalancePerToken 0 start", {
71
+ tokenWithId: r,
72
+ minInput: i,
73
+ sliceIfMore6: a,
74
+ chainId: o,
75
+ passedShieldedPrivateKey: s,
76
+ passedShieldedPublicKey: c,
77
+ ethAddress: l,
78
+ resetCacheBefore: f,
79
+ ensuredTokensWithId: p,
80
+ useBlockedUtxos: m
81
+ });
82
+ let h = s ?? t.userKeys.getShieldedPrivateKey();
83
+ console.log("getInputUtxoAndBalancePerToken 1 useBlockedUtxos", m);
84
+ let { inputUtxos: g } = m ? await C({
71
85
  hinkal: t,
72
86
  chainId: o,
73
87
  ethAddress: l,
@@ -83,7 +97,11 @@ var h = new m(), g = async (e, t, n, r, i, a, s, c, u) => h.runExclusive(async (
83
97
  passedShieldedPublicKey: c,
84
98
  ethAddress: l,
85
99
  resetCacheBefore: f
86
- }), _ = y(r), v = /* @__PURE__ */ new Map();
100
+ });
101
+ console.log("getInputUtxoAndBalancePerToken 2 inputUtxos", g);
102
+ let _ = y(r);
103
+ console.log("getInputUtxoAndBalancePerToken 3 tokensWithId", _);
104
+ let v = /* @__PURE__ */ new Map();
87
105
  g.forEach((e) => {
88
106
  let t = e.getTokenAddress(o);
89
107
  if (_ && !_.some((r) => n(r.erc20TokenAddress, t) && r.tokenId === e.tokenId)) return;
@@ -92,18 +110,18 @@ var h = new m(), g = async (e, t, n, r, i, a, s, c, u) => h.runExclusive(async (
92
110
  tokenId: e.tokenId
93
111
  }), i = v.get(r) ?? [];
94
112
  v.set(r, [...i, e]);
95
- }), p?.forEach((e) => {
113
+ }), console.log("getInputUtxoAndBalancePerToken 4 inputUtxosPerToken", v), p?.forEach((e) => {
96
114
  let t = u(o, {
97
115
  erc20TokenAddress: e.erc20TokenAddress,
98
116
  tokenId: e.tokenId
99
117
  });
100
118
  v.set(t, v.get(t) ?? []);
101
- });
119
+ }), console.log("getInputUtxoAndBalancePerToken 5 ensuredTokensWithId", p);
102
120
  for (let [t, n] of v) {
103
121
  let r = t.split("-")[0], s = Number(t.split("-")[1]), c = e(o), l = c ? r : void 0;
104
122
  x(n, i, a, h, c ? d(r).compressedAddress.toLowerCase() : r.toLowerCase(), s, l);
105
123
  }
106
- return v;
124
+ return console.log("getInputUtxoAndBalancePerToken 6 inputUtxosPerToken", v), v;
107
125
  };
108
126
  //#endregion
109
127
  export { v as attemptGetInputUtxosRemotely, S as getInputUtxoAndBalance, C as getInputUtxoAndBalanceOfStuckUtxos, w as getInputUtxoAndBalancePerToken, _ as getInputUtxosRemotely };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "h_test_1",
3
- "version": "0.0.41",
3
+ "version": "0.0.42",
4
4
  "homepage": "hinkal.io",
5
5
  "author": {
6
6
  "name": "Hinkal Protocol"