@hinkal/common 0.2.4 → 0.2.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.
Files changed (32) hide show
  1. package/constants/deploy-data/deploy-data-optimism.json.cjs +1 -1
  2. package/constants/deploy-data/deploy-data-optimism.json.mjs +21 -17
  3. package/data-structures/cacheDevices/LocalStorageCacheDevice.cjs +1 -1
  4. package/data-structures/cacheDevices/LocalStorageCacheDevice.d.ts +1 -1
  5. package/data-structures/cacheDevices/LocalStorageCacheDevice.mjs +2 -2
  6. package/data-structures/custom-token-registry/CustomTokenRegistry.cjs +1 -1
  7. package/data-structures/custom-token-registry/CustomTokenRegistry.mjs +14 -18
  8. package/functions/private-wallet/emporium.helpers.cjs +1 -1
  9. package/functions/private-wallet/emporium.helpers.d.ts +8 -3
  10. package/functions/private-wallet/emporium.helpers.mjs +23 -11
  11. package/functions/private-wallet/index.d.ts +1 -0
  12. package/functions/private-wallet/opProducer.cjs +1 -1
  13. package/functions/private-wallet/opProducer.mjs +1 -1
  14. package/functions/private-wallet/smartContractWalletCalculator.cjs +1 -0
  15. package/functions/private-wallet/smartContractWalletCalculator.d.ts +1 -0
  16. package/functions/private-wallet/smartContractWalletCalculator.mjs +20 -0
  17. package/functions/protocols/pendle.helpers.cjs +1 -1
  18. package/functions/protocols/pendle.helpers.mjs +13 -14
  19. package/functions/utils/cacheDevice.utils.cjs +1 -1
  20. package/functions/utils/cacheDevice.utils.mjs +8 -8
  21. package/functions/utils/string.utils.cjs +1 -1
  22. package/functions/utils/string.utils.d.ts +1 -0
  23. package/functions/utils/string.utils.mjs +16 -6
  24. package/index.cjs +1 -1
  25. package/index.mjs +229 -226
  26. package/package.json +1 -1
  27. package/providers/prepareEthersHinkal.cjs +1 -1
  28. package/providers/prepareEthersHinkal.mjs +2 -3
  29. package/providers/prepareWagmiHinkal.cjs +1 -1
  30. package/providers/prepareWagmiHinkal.mjs +2 -3
  31. package/types/ethereum-network.types.d.ts +2 -0
  32. package/types/hinkal.types.d.ts +1 -0
@@ -6200,7 +6200,7 @@ const e = "0x41658B0DaF59Bb2FbB2D9A5249207011d2B364De", t = [
6200
6200
  stateMutability: "nonpayable",
6201
6201
  type: "function"
6202
6202
  }
6203
- ], M = "0xfCD0dFB2e8157018165AD7A11B3e072f4aFf8954", k = [
6203
+ ], k = "0xfCD0dFB2e8157018165AD7A11B3e072f4aFf8954", M = [
6204
6204
  {
6205
6205
  inputs: [
6206
6206
  {
@@ -6512,7 +6512,7 @@ const e = "0x41658B0DaF59Bb2FbB2D9A5249207011d2B364De", t = [
6512
6512
  stateMutability: "payable",
6513
6513
  type: "receive"
6514
6514
  }
6515
- ], w = "0xbd0E2Df0D151C680499C49d06445912E74822e95", h = [
6515
+ ], h = "0xbd0E2Df0D151C680499C49d06445912E74822e95", w = [
6516
6516
  {
6517
6517
  inputs: [
6518
6518
  {
@@ -7356,7 +7356,7 @@ const e = "0x41658B0DaF59Bb2FbB2D9A5249207011d2B364De", t = [
7356
7356
  stateMutability: "nonpayable",
7357
7357
  type: "function"
7358
7358
  }
7359
- ], C = "0xB92188976A4bbeF3008f9DD21CCf7D23Dcbae391", H = "0xAEe3165436156b0C8c98A747Fa7257353dFE9EF9", S = [
7359
+ ], C = "0xB92188976A4bbeF3008f9DD21CCf7D23Dcbae391", H = "0x7cfAfA5dFe424Aae55120d434FeCAb9637BB0007", S = "0x387B93a7eD515Ecb7bd8bAC556bc63f1bB64DaDA", O = "0xAEe3165436156b0C8c98A747Fa7257353dFE9EF9", I = [
7360
7360
  {
7361
7361
  inputs: [
7362
7362
  {
@@ -8187,7 +8187,7 @@ const e = "0x41658B0DaF59Bb2FbB2D9A5249207011d2B364De", t = [
8187
8187
  stateMutability: "payable",
8188
8188
  type: "receive"
8189
8189
  }
8190
- ], O = {
8190
+ ], R = {
8191
8191
  hinkalAddress: e,
8192
8192
  hinkalABI: t,
8193
8193
  hinkalHelperAddress: n,
@@ -8208,45 +8208,49 @@ const e = "0x41658B0DaF59Bb2FbB2D9A5249207011d2B364De", t = [
8208
8208
  BeefyExternalActionABI: f,
8209
8209
  pendleExternalActionInstanceAddress: A,
8210
8210
  WrappedStakedBeefyLpABI: v,
8211
- volatileVaultInstanceAddress: M,
8212
- VolatileVaultABI: k,
8213
- volatileTokenActionInstanceAddress: w,
8214
- VolatileTokenActionABI: h,
8211
+ volatileVaultInstanceAddress: k,
8212
+ VolatileVaultABI: M,
8213
+ volatileTokenActionInstanceAddress: h,
8214
+ VolatileTokenActionABI: w,
8215
8215
  hinkalWrapperAddress: x,
8216
8216
  HinkalWrapperABI: g,
8217
8217
  emporiumAddress: C,
8218
- crossChainAccessTokenManagerAddress: H,
8219
- crossChainAccessTokenManagerABI: S
8218
+ hinkalWalletFactoryAddress: H,
8219
+ hinkalWalletBeaconAddress: S,
8220
+ crossChainAccessTokenManagerAddress: O,
8221
+ crossChainAccessTokenManagerABI: I
8220
8222
  };
8221
8223
  export {
8222
8224
  f as BeefyExternalActionABI,
8223
8225
  g as HinkalWrapperABI,
8224
- h as VolatileTokenActionABI,
8225
- k as VolatileVaultABI,
8226
+ w as VolatileTokenActionABI,
8227
+ M as VolatileVaultABI,
8226
8228
  v as WrappedStakedBeefyLpABI,
8227
8229
  u as beefyExternalActionInstanceAddress,
8228
8230
  c as convexExternalActionABI,
8229
8231
  T as convexExternalActionInstanceAddress,
8230
8232
  s as crossChainAccessTokenABI,
8231
8233
  i as crossChainAccessTokenAddress,
8232
- S as crossChainAccessTokenManagerABI,
8233
- H as crossChainAccessTokenManagerAddress,
8234
+ I as crossChainAccessTokenManagerABI,
8235
+ O as crossChainAccessTokenManagerAddress,
8234
8236
  o as curveExternalActionABI,
8235
8237
  d as curveExternalActionInstanceAddress,
8236
8238
  l as curveStakeExternalActionInstanceAddress,
8237
- O as default,
8239
+ R as default,
8238
8240
  C as emporiumAddress,
8239
8241
  t as hinkalABI,
8240
8242
  e as hinkalAddress,
8241
8243
  a as hinkalHelperABI,
8242
8244
  n as hinkalHelperAddress,
8245
+ S as hinkalWalletBeaconAddress,
8246
+ H as hinkalWalletFactoryAddress,
8243
8247
  x as hinkalWrapperAddress,
8244
8248
  y as odosExternalActionInstanceAddress,
8245
8249
  r as oneInchExternalActionInstanceAddress,
8246
8250
  A as pendleExternalActionInstanceAddress,
8247
8251
  p as uniswapExternalActionAddress,
8248
- w as volatileTokenActionInstanceAddress,
8249
- M as volatileVaultInstanceAddress,
8252
+ h as volatileTokenActionInstanceAddress,
8253
+ k as volatileVaultInstanceAddress,
8250
8254
  b as wrappedStakedConvexLpABI,
8251
8255
  m as wrappedStakedCurveLpABI
8252
8256
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./BaseCacheDevice.cjs");class o extends a.BaseCacheDevice{localDataStorage;constructor(){super(),typeof localStorage<"u"&&(this.localDataStorage=localStorage)}get(e){return this.localDataStorage?this.localDataStorage.getItem(e)??void 0:this.getInMemory(e)}set(e,t){this.localDataStorage?this.localDataStorage.setItem(e,t):this.setInMemory(e,t)}}exports.LocalStorageCacheDevice=o;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./BaseCacheDevice.cjs");class o extends a.BaseCacheDevice{localDataStorage;constructor(e){super(),!e&&typeof localStorage<"u"&&(this.localDataStorage=localStorage)}get(e){return this.localDataStorage?this.localDataStorage.getItem(e)??void 0:this.getInMemory(e)}set(e,t){this.localDataStorage?this.localDataStorage.setItem(e,t):this.setInMemory(e,t)}}exports.LocalStorageCacheDevice=o;
@@ -1,7 +1,7 @@
1
1
  import { BaseCacheDevice } from './BaseCacheDevice';
2
2
  export declare class LocalStorageCacheDevice extends BaseCacheDevice {
3
3
  private localDataStorage;
4
- constructor();
4
+ constructor(disableCaching?: boolean);
5
5
  get(key: string): string | undefined;
6
6
  set(key: string, value: string): void;
7
7
  }
@@ -1,8 +1,8 @@
1
1
  import { BaseCacheDevice as a } from "./BaseCacheDevice.mjs";
2
2
  class l extends a {
3
3
  localDataStorage;
4
- constructor() {
5
- super(), typeof localStorage < "u" && (this.localDataStorage = localStorage);
4
+ constructor(t) {
5
+ super(), !t && typeof localStorage < "u" && (this.localDataStorage = localStorage);
6
6
  }
7
7
  get(t) {
8
8
  return this.localDataStorage ? this.localDataStorage.getItem(t) ?? void 0 : this.getInMemory(t);
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class o{localStorageKey="tokenRegistry";tokenRegistry;constructor(){if(this.tokenRegistry=[],typeof localStorage<"u"){const t=localStorage.getItem(this.localStorageKey);t&&(this.tokenRegistry=JSON.parse(t))}}persistRegistry(){typeof localStorage<"u"&&localStorage.setItem(this.localStorageKey,JSON.stringify(this.tokenRegistry))}getCustomTokens(t){return this.tokenRegistry.filter(e=>e.chainId===t)}tokenExists(t,e){return t.find(s=>s.erc20TokenAddress===e.erc20TokenAddress||s.symbol===e.symbol||s.name===e.name)}addCustomToken(t){const{chainId:e}=t,s=this.getCustomTokens(e);this.tokenExists(s,t)||this.tokenRegistry.push(t),this.persistRegistry()}removeCustomToken(t){const{chainId:e}=t,r=this.getCustomTokens(e).filter(i=>i.erc20TokenAddress!==t.erc20TokenAddress);this.tokenRegistry=r,this.persistRegistry()}}const n=new o;exports.customTokenRegistry=n;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class o{localStorageKey="tokenRegistry";tokenRegistry;constructor(){this.tokenRegistry=[]}persistRegistry(){}getCustomTokens(s){return this.tokenRegistry.filter(t=>t.chainId===s)}tokenExists(s,t){return s.find(e=>e.erc20TokenAddress===t.erc20TokenAddress||e.symbol===t.symbol||e.name===t.name)}addCustomToken(s){const{chainId:t}=s,e=this.getCustomTokens(t);this.tokenExists(e,s)||this.tokenRegistry.push(s),this.persistRegistry()}removeCustomToken(s){const{chainId:t}=s,r=this.getCustomTokens(t).filter(i=>i.erc20TokenAddress!==s.erc20TokenAddress);this.tokenRegistry=r,this.persistRegistry()}}const n=new o;exports.customTokenRegistry=n;
@@ -1,33 +1,29 @@
1
- class o {
1
+ class n {
2
2
  localStorageKey = "tokenRegistry";
3
3
  tokenRegistry;
4
4
  constructor() {
5
- if (this.tokenRegistry = [], typeof localStorage < "u") {
6
- const t = localStorage.getItem(this.localStorageKey);
7
- t && (this.tokenRegistry = JSON.parse(t));
8
- }
5
+ this.tokenRegistry = [];
9
6
  }
10
7
  persistRegistry() {
11
- typeof localStorage < "u" && localStorage.setItem(this.localStorageKey, JSON.stringify(this.tokenRegistry));
12
8
  }
13
- getCustomTokens(t) {
14
- return this.tokenRegistry.filter((s) => s.chainId === t);
9
+ getCustomTokens(s) {
10
+ return this.tokenRegistry.filter((t) => t.chainId === s);
15
11
  }
16
- tokenExists(t, s) {
17
- return t.find(
18
- (e) => e.erc20TokenAddress === s.erc20TokenAddress || e.symbol === s.symbol || e.name === s.name
12
+ tokenExists(s, t) {
13
+ return s.find(
14
+ (e) => e.erc20TokenAddress === t.erc20TokenAddress || e.symbol === t.symbol || e.name === t.name
19
15
  );
20
16
  }
21
- addCustomToken(t) {
22
- const { chainId: s } = t, e = this.getCustomTokens(s);
23
- this.tokenExists(e, t) || this.tokenRegistry.push(t), this.persistRegistry();
17
+ addCustomToken(s) {
18
+ const { chainId: t } = s, e = this.getCustomTokens(t);
19
+ this.tokenExists(e, s) || this.tokenRegistry.push(s), this.persistRegistry();
24
20
  }
25
- removeCustomToken(t) {
26
- const { chainId: s } = t, r = this.getCustomTokens(s).filter((i) => i.erc20TokenAddress !== t.erc20TokenAddress);
21
+ removeCustomToken(s) {
22
+ const { chainId: t } = s, r = this.getCustomTokens(t).filter((i) => i.erc20TokenAddress !== s.erc20TokenAddress);
27
23
  this.tokenRegistry = r, this.persistRegistry();
28
24
  }
29
25
  }
30
- const g = new o();
26
+ const c = new n();
31
27
  export {
32
- g as customTokenRegistry
28
+ c as customTokenRegistry
33
29
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("ethers"),d=(t,r,a,l,y)=>{let s=new Uint8Array,i=new Uint8Array;typeof t=="object"&&"address"in t?(s=e.ethers.utils.arrayify(t.address),r&&(i=e.ethers.utils.arrayify(t.interface.encodeFunctionData(r,a)))):s=e.ethers.utils.arrayify(t);const o=e.ethers.utils.arrayify([l?1:0]),n=e.ethers.utils.zeroPad(e.ethers.utils.arrayify(e.BigNumber.from(y??0n)),16),u=e.ethers.utils.concat([s,o,n,i]);return e.ethers.utils.hexlify(u)},f=(t,r)=>e.ethers.utils.defaultAbiCoder.encode(["tuple(bytes32 walletSalt, bytes[] ops)"],[{walletSalt:r??e.ethers.utils.hexlify(new Uint8Array(32)),ops:t}]);exports.emporiumOp=d;exports.encodeEmporiumMetadata=f;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("ethers"),f=({contract:t,func:r,args:a,callDataString:i,invokeWallet:l,value:y})=>{let s=new Uint8Array,o=i?e.utils.arrayify(i):new Uint8Array;if(typeof t=="object"&&"address"in t){if(s=e.utils.arrayify(t.address),i?.length&&i?.length>0)throw Error("If function and args are providedm no calldata is needed");r&&a&&!i&&(o=e.utils.arrayify(t.interface.encodeFunctionData(r,a)))}else s=e.utils.arrayify(t);const n=e.utils.arrayify([l?1:0]),u=e.utils.zeroPad(e.utils.arrayify(e.BigNumber.from(y??0n)),16),d=e.utils.concat([s,n,u,o]);return e.utils.hexlify(d)},m=(t,r)=>e.utils.defaultAbiCoder.encode(["tuple(bytes32 walletSalt, bytes[] ops)"],[{walletSalt:r??e.utils.hexlify(new Uint8Array(32)),ops:t}]);exports.emporiumOp=f;exports.encodeEmporiumMetadata=m;
@@ -1,5 +1,10 @@
1
1
  import { Contract, ContractTransaction } from 'ethers';
2
- export declare const emporiumOp: <ContractInstance extends Contract, ContractFunctions extends ContractInstance["functions"], ExactFunction extends { [K in keyof ContractFunctions]: ReturnType<ContractFunctions[K]> extends Promise<ContractTransaction> ? K : never; }[keyof ContractFunctions], FunctionArguments extends Parameters<ContractFunctions[ExactFunction]>>(contract: ContractInstance | string, func?: ExactFunction, args?: FunctionArguments extends [
3
- ] ? [
4
- ] : FunctionArguments, invokeWallet?: boolean, value?: bigint) => string;
2
+ export declare const emporiumOp: <ContractInstance extends Contract, ContractFunctions extends ContractInstance["functions"], ExactFunction extends { [K in keyof ContractFunctions]: ReturnType<ContractFunctions[K]> extends Promise<ContractTransaction> ? K : never; }[keyof ContractFunctions], FunctionArguments extends Parameters<ContractFunctions[ExactFunction]>>({ contract, func, args, callDataString, invokeWallet, value, }: {
3
+ contract: ContractInstance | string;
4
+ func?: ExactFunction | undefined;
5
+ args?: (FunctionArguments extends [] ? [] : FunctionArguments) | undefined;
6
+ callDataString?: string | undefined;
7
+ invokeWallet?: boolean | undefined;
8
+ value?: bigint | undefined;
9
+ }) => string;
5
10
  export declare const encodeEmporiumMetadata: (ops: string[], walletSalt?: string) => string;
@@ -1,19 +1,31 @@
1
- import { ethers as e, BigNumber as d } from "ethers";
2
- const p = (t, i, s, r, y) => {
3
- let a = new Uint8Array(), l = new Uint8Array();
4
- typeof t == "object" && "address" in t ? (a = e.utils.arrayify(t.address), i && (l = e.utils.arrayify(t.interface.encodeFunctionData(i, s)))) : a = e.utils.arrayify(t);
5
- const n = e.utils.arrayify([r ? 1 : 0]), o = e.utils.zeroPad(e.utils.arrayify(d.from(y ?? 0n)), 16), u = e.utils.concat([a, n, o, l]);
6
- return e.utils.hexlify(u);
7
- }, m = (t, i) => e.utils.defaultAbiCoder.encode(
1
+ import { utils as e, BigNumber as p } from "ethers";
2
+ const u = ({
3
+ contract: r,
4
+ func: a,
5
+ args: i,
6
+ callDataString: t,
7
+ invokeWallet: n,
8
+ value: d
9
+ }) => {
10
+ let y = new Uint8Array(), o = t ? e.arrayify(t) : new Uint8Array();
11
+ if (typeof r == "object" && "address" in r) {
12
+ if (y = e.arrayify(r.address), t?.length && t?.length > 0)
13
+ throw Error("If function and args are providedm no calldata is needed");
14
+ a && i && !t && (o = e.arrayify(r.interface.encodeFunctionData(a, i)));
15
+ } else
16
+ y = e.arrayify(r);
17
+ const s = e.arrayify([n ? 1 : 0]), f = e.zeroPad(e.arrayify(p.from(d ?? 0n)), 16), l = e.concat([y, s, f, o]);
18
+ return e.hexlify(l);
19
+ }, w = (r, a) => e.defaultAbiCoder.encode(
8
20
  ["tuple(bytes32 walletSalt, bytes[] ops)"],
9
21
  [
10
22
  {
11
- walletSalt: i ?? e.utils.hexlify(new Uint8Array(32)),
12
- ops: t
23
+ walletSalt: a ?? e.hexlify(new Uint8Array(32)),
24
+ ops: r
13
25
  }
14
26
  ]
15
27
  );
16
28
  export {
17
- p as emporiumOp,
18
- m as encodeEmporiumMetadata
29
+ u as emporiumOp,
30
+ w as encodeEmporiumMetadata
19
31
  };
@@ -1,2 +1,3 @@
1
1
  export * from './emporium.helpers';
2
2
  export * from './opProducer';
3
+ export * from './smartContractWalletCalculator';
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("../../externalABIs/index.cjs"),p=require("ethers"),d=require("./emporium.helpers.cjs");var o=(e=>(e[e.Erc20Token=0]="Erc20Token",e[e.Uniswap=1]="Uniswap",e))(o||{});const h=(e,c,n,i,s,a)=>{let r="";switch(e){case 0:r=t.ERC20ABI;break;case 1:r=t.ISwapRouterABI;break}if(!r)throw Error("No ABI match in produceOp");const u=new p.ethers.Contract(c,r);return d.emporiumOp(u,n,i,s,a)};exports.OpType=o;exports.produceOp=h;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("../../externalABIs/index.cjs"),p=require("ethers"),d=require("./emporium.helpers.cjs");var o=(e=>(e[e.Erc20Token=0]="Erc20Token",e[e.Uniswap=1]="Uniswap",e))(o||{});const h=(e,c,n,i,s,a)=>{let r="";switch(e){case 0:r=t.ERC20ABI;break;case 1:r=t.ISwapRouterABI;break}if(!r)throw Error("No ABI match in produceOp");const u=new p.ethers.Contract(c,r);return d.emporiumOp({contract:u,func:n,args:i,invokeWallet:s,value:a})};exports.OpType=o;exports.produceOp=h;
@@ -15,7 +15,7 @@ const E = (r, t, e, c, a, n) => {
15
15
  if (!o)
16
16
  throw Error("No ABI match in produceOp");
17
17
  const i = new p.Contract(t, o);
18
- return u(i, e, c, a, n);
18
+ return u({ contract: i, func: e, args: c, invokeWallet: a, value: n });
19
19
  };
20
20
  export {
21
21
  w as OpType,
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("ethers"),l=require("../../constants/chains.constants.cjs"),u=async(s,r,t)=>{const o=await new e.ethers.providers.JsonRpcProvider(l.networkRegistry[`${s}`].fetchRpcUrl).getCode(r),n=[t],i=["address"],a=e.utils.defaultAbiCoder.encode(i,n);return o+a.slice(2)},y=async(s,r)=>{const{hinkalWalletFactoryAddress:t,hinkalWalletBeaconAddress:c}=l.networkRegistry[s].contractData;if(!t||!c||!e.utils.isAddress(t))throw new Error(`Invalid deployer address ${t}`);const o=e.utils.hexlify(e.utils.zeroPad(e.utils.arrayify(r),32)),n=`0xff${t.slice(2)}`,i=await u(s,t,c),a=e.utils.keccak256(i),d=e.utils.keccak256(`${n}${o.slice(2)}${a.slice(2)}`);return e.utils.getAddress(`0x${d.slice(-40)}`)};exports.calculateSmartContractWalletAddress=y;
@@ -0,0 +1 @@
1
+ export declare const calculateSmartContractWalletAddress: (chainId: number, salt: number) => Promise<string>;
@@ -0,0 +1,20 @@
1
+ import { utils as e, ethers as f } from "ethers";
2
+ import { networkRegistry as l } from "../../constants/chains.constants.mjs";
3
+ const p = async (s, r, t) => {
4
+ const c = await new f.providers.JsonRpcProvider(l[`${s}`].fetchRpcUrl).getCode(r), d = [t], n = ["address"], a = e.defaultAbiCoder.encode(
5
+ n,
6
+ // Constructor argument types
7
+ d
8
+ // Constructor argument values
9
+ );
10
+ return c + a.slice(2);
11
+ }, C = async (s, r) => {
12
+ const { hinkalWalletFactoryAddress: t, hinkalWalletBeaconAddress: o } = l[s].contractData;
13
+ if (!t || !o || !e.isAddress(t))
14
+ throw new Error(`Invalid deployer address ${t}`);
15
+ const c = e.hexlify(e.zeroPad(e.arrayify(r), 32)), d = `0xff${t.slice(2)}`, n = await p(s, t, o), a = e.keccak256(n), i = e.keccak256(`${d}${c.slice(2)}${a.slice(2)}`);
16
+ return e.getAddress(`0x${i.slice(-40)}`);
17
+ };
18
+ export {
19
+ C as calculateSmartContractWalletAddress
20
+ };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("../../constants/token-data/index.cjs");require("../../constants/chains.constants.cjs");require("../../constants/vite.constants.cjs");require("../../constants/contracts.constants.cjs");require("../../constants/kyc.constants.cjs");const o=require("../../constants/server.constants.cjs");require("../../constants/coingecko.constants.cjs");require("../../constants/axelar.constants.cjs");require("../../constants/rewards.constants.cjs");require("../../constants/reorg-depths.constants.cjs");const i=require("../utils/caseInsensitive.utils.cjs");require("../../types/circom-data.types.cjs");const s=require("../../types/hinkal.types.cjs");require("../../types/transactions.types.cjs");const n=require("../../types/pendle.types.cjs");require("../../types/curve.types.cjs");require("ethers");require("circomlibjs-hinkal-fork");require("libsodium-wrappers");require("idb-keyval");require("../utils/external-action.utils.cjs");const c=require("../utils/erc20tokenFunctions.cjs");require("../utils/convertIntegrationProviderToExternalActionId.cjs");require("axios");require("process");require("buffer");require("../utils/userAgent.cjs");require("../../data-structures/custom-token-registry/CustomTokenRegistry.cjs");require("../../data-structures/volatile-helper/VolatileHelper.cjs");const T=require("../utils/enum.utils.cjs");function P(e){if(!e)return;const r=c.getERC20Token(e.address,e.chainId);if(!r?.isVolatile)return r}function q(e,r){if(!e||!r)return;let t;switch(r){case n.PendleAssetType.YT:t=e?.yt;break;case n.PendleAssetType.PT:t=e?.pt;break;case n.PendleAssetType.PENDLE_LP:t=e?.lp;break;case n.PendleAssetType.SY:t=e?.sy;break;default:t=void 0;break}return t}const w=(e,r,t)=>{if(i.caseInsensitiveEqual(e.yt.address,t.erc20TokenAddress))return n.PendleSwapType.SwapExactTokenForYt;if(i.caseInsensitiveEqual(e.pt.address,t.erc20TokenAddress))return n.PendleSwapType.SwapExactTokenForPt;if(i.caseInsensitiveEqual(e.yt.address,r.erc20TokenAddress))return n.PendleSwapType.SwapExactYtForToken;if(i.caseInsensitiveEqual(e.pt.address,r.erc20TokenAddress))return n.PendleSwapType.SwapExactPtForToken},F=e=>{let r;switch(e){case n.PendleSwapType.SwapExactTokenForYt:r=o.API_CONFIG.ROUTES.pendleSwapExactTokenForYT;break;case n.PendleSwapType.SwapExactTokenForPt:r=o.API_CONFIG.ROUTES.pendleSwapExactTokenForPt;break;case n.PendleSwapType.SwapExactYtForToken:r=o.API_CONFIG.ROUTES.pendleSwapExactYtForToken;break;case n.PendleSwapType.SwapExactPtForToken:r=o.API_CONFIG.ROUTES.pendleSwapExactPtForToken;break;default:throw new Error("Cant determine Pendle Swap Type Api Route")}return r},k=(e,r,t,a)=>{if(!T.isInEnum(s.PendleAction,e))throw new Error("getTokenIndexForPendleFlatFee: Invalid Pendle Action");if(a)return t.findIndex(d=>d.toLowerCase()===a?.toLowerCase());const l=r.findIndex(d=>d>0n),p=r.length-1;if(r[p]<=0n)throw new Error("getTokenIndexForPendleFlatFee: Last token in amountChange is not > 0");let u=l;return(e===s.PendleAction.Mint||e===s.PendleAction.Redeem||e===s.PendleAction.PoolRemove)&&(u=l),u};exports.determinePendleSwapType=w;exports.determinePendleSwapTypeApiRoute=F;exports.erc20TokenFromPendleAsset=P;exports.getAssetTypeFromPendleMarket=q;exports.getTokenIndexForPendleFlatFee=k;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("../../constants/token-data/index.cjs");require("../../constants/chains.constants.cjs");require("../../constants/vite.constants.cjs");require("../../constants/contracts.constants.cjs");require("../../constants/kyc.constants.cjs");const o=require("../../constants/server.constants.cjs");require("../../constants/coingecko.constants.cjs");require("../../constants/axelar.constants.cjs");require("../../constants/rewards.constants.cjs");require("../../constants/reorg-depths.constants.cjs");const i=require("../utils/caseInsensitive.utils.cjs");require("../../types/circom-data.types.cjs");const s=require("../../types/hinkal.types.cjs");require("../../types/transactions.types.cjs");const n=require("../../types/pendle.types.cjs");require("../../types/curve.types.cjs");require("ethers");require("circomlibjs-hinkal-fork");require("libsodium-wrappers");require("idb-keyval");require("../utils/external-action.utils.cjs");const c=require("../utils/erc20tokenFunctions.cjs");require("../utils/convertIntegrationProviderToExternalActionId.cjs");require("axios");require("process");require("buffer");require("../utils/userAgent.cjs");require("../../data-structures/volatile-helper/VolatileHelper.cjs");const T=require("../utils/enum.utils.cjs");function P(e){if(!e)return;const r=c.getERC20Token(e.address,e.chainId);if(!r?.isVolatile)return r}function w(e,r){if(!e||!r)return;let t;switch(r){case n.PendleAssetType.YT:t=e?.yt;break;case n.PendleAssetType.PT:t=e?.pt;break;case n.PendleAssetType.PENDLE_LP:t=e?.lp;break;case n.PendleAssetType.SY:t=e?.sy;break;default:t=void 0;break}return t}const q=(e,r,t)=>{if(i.caseInsensitiveEqual(e.yt.address,t.erc20TokenAddress))return n.PendleSwapType.SwapExactTokenForYt;if(i.caseInsensitiveEqual(e.pt.address,t.erc20TokenAddress))return n.PendleSwapType.SwapExactTokenForPt;if(i.caseInsensitiveEqual(e.yt.address,r.erc20TokenAddress))return n.PendleSwapType.SwapExactYtForToken;if(i.caseInsensitiveEqual(e.pt.address,r.erc20TokenAddress))return n.PendleSwapType.SwapExactPtForToken},F=e=>{let r;switch(e){case n.PendleSwapType.SwapExactTokenForYt:r=o.API_CONFIG.ROUTES.pendleSwapExactTokenForYT;break;case n.PendleSwapType.SwapExactTokenForPt:r=o.API_CONFIG.ROUTES.pendleSwapExactTokenForPt;break;case n.PendleSwapType.SwapExactYtForToken:r=o.API_CONFIG.ROUTES.pendleSwapExactYtForToken;break;case n.PendleSwapType.SwapExactPtForToken:r=o.API_CONFIG.ROUTES.pendleSwapExactPtForToken;break;default:throw new Error("Cant determine Pendle Swap Type Api Route")}return r},k=(e,r,t,a)=>{if(!T.isInEnum(s.PendleAction,e))throw new Error("getTokenIndexForPendleFlatFee: Invalid Pendle Action");if(a)return t.findIndex(d=>d.toLowerCase()===a?.toLowerCase());const l=r.findIndex(d=>d>0n),p=r.length-1;if(r[p]<=0n)throw new Error("getTokenIndexForPendleFlatFee: Last token in amountChange is not > 0");let u=l;return(e===s.PendleAction.Mint||e===s.PendleAction.Redeem||e===s.PendleAction.PoolRemove)&&(u=l),u};exports.determinePendleSwapType=q;exports.determinePendleSwapTypeApiRoute=F;exports.erc20TokenFromPendleAsset=P;exports.getAssetTypeFromPendleMarket=w;exports.getTokenIndexForPendleFlatFee=k;
@@ -25,17 +25,16 @@ import "axios";
25
25
  import "process";
26
26
  import "buffer";
27
27
  import "../utils/userAgent.mjs";
28
- import "../../data-structures/custom-token-registry/CustomTokenRegistry.mjs";
29
28
  import "../../data-structures/volatile-helper/VolatileHelper.mjs";
30
29
  import { isInEnum as k } from "../utils/enum.utils.mjs";
31
- function H(e) {
30
+ function z(e) {
32
31
  if (!e)
33
32
  return;
34
33
  const r = T(e.address, e.chainId);
35
34
  if (!r?.isVolatile)
36
35
  return r;
37
36
  }
38
- function J(e, r) {
37
+ function H(e, r) {
39
38
  if (!e || !r)
40
39
  return;
41
40
  let t;
@@ -58,7 +57,7 @@ function J(e, r) {
58
57
  }
59
58
  return t;
60
59
  }
61
- const K = (e, r, t) => {
60
+ const J = (e, r, t) => {
62
61
  if (i(e.yt.address, t.erc20TokenAddress))
63
62
  return o.SwapExactTokenForYt;
64
63
  if (i(e.pt.address, t.erc20TokenAddress))
@@ -67,7 +66,7 @@ const K = (e, r, t) => {
67
66
  return o.SwapExactYtForToken;
68
67
  if (i(e.pt.address, r.erc20TokenAddress))
69
68
  return o.SwapExactPtForToken;
70
- }, Q = (e) => {
69
+ }, K = (e) => {
71
70
  let r;
72
71
  switch (e) {
73
72
  case o.SwapExactTokenForYt:
@@ -86,23 +85,23 @@ const K = (e, r, t) => {
86
85
  throw new Error("Cant determine Pendle Swap Type Api Route");
87
86
  }
88
87
  return r;
89
- }, W = (e, r, t, s) => {
88
+ }, Q = (e, r, t, s) => {
90
89
  if (!k(p, e))
91
90
  throw new Error("getTokenIndexForPendleFlatFee: Invalid Pendle Action");
92
91
  if (s)
93
92
  return t.findIndex(
94
93
  (a) => a.toLowerCase() === s?.toLowerCase()
95
94
  );
96
- const m = r.findIndex((a) => a > 0n), l = r.length - 1;
95
+ const c = r.findIndex((a) => a > 0n), l = r.length - 1;
97
96
  if (r[l] <= 0n)
98
97
  throw new Error("getTokenIndexForPendleFlatFee: Last token in amountChange is not > 0");
99
- let c = m;
100
- return (e === p.Mint || e === p.Redeem || e === p.PoolRemove) && (c = m), c;
98
+ let m = c;
99
+ return (e === p.Mint || e === p.Redeem || e === p.PoolRemove) && (m = c), m;
101
100
  };
102
101
  export {
103
- K as determinePendleSwapType,
104
- Q as determinePendleSwapTypeApiRoute,
105
- H as erc20TokenFromPendleAsset,
106
- J as getAssetTypeFromPendleMarket,
107
- W as getTokenIndexForPendleFlatFee
102
+ J as determinePendleSwapType,
103
+ K as determinePendleSwapTypeApiRoute,
104
+ z as erc20TokenFromPendleAsset,
105
+ H as getAssetTypeFromPendleMarket,
106
+ Q as getTokenIndexForPendleFlatFee
108
107
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("../../constants/token-data/index.cjs");require("../../constants/chains.constants.cjs");const t=require("../../constants/vite.constants.cjs");require("../../constants/contracts.constants.cjs");require("../../constants/kyc.constants.cjs");require("../../constants/coingecko.constants.cjs");require("../../constants/axelar.constants.cjs");require("../../constants/rewards.constants.cjs");require("../../constants/reorg-depths.constants.cjs");const a=require("../../data-structures/cacheDevices/FileCacheDevice.cjs"),o=require("../../data-structures/cacheDevices/LocalStorageCacheDevice.cjs"),u=e=>{if(t.isNode){let r,c;e&&({useFileCache:r,cacheFilePath:c}=e);const i=require("path").resolve(process.cwd(),"hinkalCache.json");return new a.FileCacheDevice(r,c??i)}else return new o.LocalStorageCacheDevice};exports.createCacheDevice=u;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("../../constants/token-data/index.cjs");require("../../constants/chains.constants.cjs");const t=require("../../constants/vite.constants.cjs");require("../../constants/contracts.constants.cjs");require("../../constants/kyc.constants.cjs");require("../../constants/coingecko.constants.cjs");require("../../constants/axelar.constants.cjs");require("../../constants/rewards.constants.cjs");require("../../constants/reorg-depths.constants.cjs");const a=require("../../data-structures/cacheDevices/FileCacheDevice.cjs"),s=require("../../data-structures/cacheDevices/LocalStorageCacheDevice.cjs"),u=e=>{if(t.isNode){let r,c;e&&({useFileCache:r,cacheFilePath:c}=e);const i=require("path").resolve(process.cwd(),"hinkalCache.json");return new a.FileCacheDevice(r,c??i)}else return new s.LocalStorageCacheDevice(e?.disableCaching)};exports.createCacheDevice=u;
@@ -1,23 +1,23 @@
1
1
  import "../../constants/token-data/index.mjs";
2
2
  import "../../constants/chains.constants.mjs";
3
- import { isNode as i } from "../../constants/vite.constants.mjs";
3
+ import { isNode as c } from "../../constants/vite.constants.mjs";
4
4
  import "../../constants/contracts.constants.mjs";
5
5
  import "../../constants/kyc.constants.mjs";
6
6
  import "../../constants/coingecko.constants.mjs";
7
7
  import "../../constants/axelar.constants.mjs";
8
8
  import "../../constants/rewards.constants.mjs";
9
9
  import "../../constants/reorg-depths.constants.mjs";
10
- import { FileCacheDevice as c } from "../../data-structures/cacheDevices/FileCacheDevice.mjs";
11
- import { LocalStorageCacheDevice as p } from "../../data-structures/cacheDevices/LocalStorageCacheDevice.mjs";
12
- const F = (e) => {
13
- if (i) {
10
+ import { FileCacheDevice as i } from "../../data-structures/cacheDevices/FileCacheDevice.mjs";
11
+ import { LocalStorageCacheDevice as a } from "../../data-structures/cacheDevices/LocalStorageCacheDevice.mjs";
12
+ const D = (e) => {
13
+ if (c) {
14
14
  let r, t;
15
15
  e && ({ useFileCache: r, cacheFilePath: t } = e);
16
16
  const o = require("path").resolve(process.cwd(), "hinkalCache.json");
17
- return new c(r, t ?? o);
17
+ return new i(r, t ?? o);
18
18
  } else
19
- return new p();
19
+ return new a(e?.disableCaching);
20
20
  };
21
21
  export {
22
- F as createCacheDevice
22
+ D as createCacheDevice
23
23
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function r(t){return t?.toLowerCase().split(" ").map(e=>e.charAt(0).toUpperCase()+e.substring(1)).join(" ")}function i(t){return t.charAt(0).toUpperCase()+t.slice(1)}function n(t){return!t||t===null||Array.isArray(t)&&t.length===0?!0:Object.keys(t).length===0&&t.constructor===Object}exports.capitalizeFirstLetter=i;exports.isNullOrEmpty=n;exports.toTitleCase=r;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function n(t){return t?.toLowerCase().split(" ").map(e=>e.charAt(0).toUpperCase()+e.substring(1)).join(" ")}function s(t){return t.charAt(0).toUpperCase()+t.slice(1)}function u(t){return!t||t===null||Array.isArray(t)&&t.length===0?!0:Object.keys(t).length===0&&t.constructor===Object}const c=t=>{t.startsWith("0x")&&(t=t.slice(2));const e=[];for(let r=0;r<t.length;r+=2){const i=parseInt(t.slice(r,r+2),16);e.push(i)}return new TextDecoder("utf-8").decode(new Uint8Array(e))};exports.capitalizeFirstLetter=s;exports.hexToUtf8=c;exports.isNullOrEmpty=u;exports.toTitleCase=n;
@@ -6,3 +6,4 @@ export declare function toTitleCase(str: string): string;
6
6
  export declare function capitalizeFirstLetter(str: string): string;
7
7
  /** Returns true if a value is null, undefined, or an empty object, array (length 0), or string (e.g. '') */
8
8
  export declare function isNullOrEmpty(obj: unknown): boolean;
9
+ export declare const hexToUtf8: (hex: string) => string;
@@ -1,14 +1,24 @@
1
- function e(t) {
1
+ function s(t) {
2
2
  return t?.toLowerCase().split(" ").map((r) => r.charAt(0).toUpperCase() + r.substring(1)).join(" ");
3
3
  }
4
- function n(t) {
4
+ function u(t) {
5
5
  return t.charAt(0).toUpperCase() + t.slice(1);
6
6
  }
7
- function i(t) {
7
+ function c(t) {
8
8
  return !t || t === null || Array.isArray(t) && t.length === 0 ? !0 : Object.keys(t).length === 0 && t.constructor === Object;
9
9
  }
10
+ const o = (t) => {
11
+ t.startsWith("0x") && (t = t.slice(2));
12
+ const r = [];
13
+ for (let e = 0; e < t.length; e += 2) {
14
+ const n = parseInt(t.slice(e, e + 2), 16);
15
+ r.push(n);
16
+ }
17
+ return new TextDecoder("utf-8").decode(new Uint8Array(r));
18
+ };
10
19
  export {
11
- n as capitalizeFirstLetter,
12
- i as isNullOrEmpty,
13
- e as toTitleCase
20
+ u as capitalizeFirstLetter,
21
+ o as hexToUtf8,
22
+ c as isNullOrEmpty,
23
+ s as toTitleCase
14
24
  };