@1llet.xyz/erc4337-gasless-sdk 0.4.21 → 0.4.23

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/dist/index.mjs CHANGED
@@ -1,11 +1,59 @@
1
+ import { optimism, gnosis, baseSepolia, base, avalanche, worldchain, monad, bsc, polygon, unichain, arbitrum } from 'viem/chains';
1
2
  import { createPublicClient, http, createWalletClient, decodeErrorResult, parseSignature, maxUint256, encodeFunctionData, encodeAbiParameters, keccak256, padHex } from 'viem';
2
3
  import { privateKeyToAccount } from 'viem/accounts';
3
- import { optimism, gnosis, baseSepolia, base, avalanche, worldchain, monad, bsc, polygon, unichain, arbitrum } from 'viem/chains';
4
4
  import axios from 'axios';
5
5
  import { Networks } from 'stellar-sdk';
6
6
  import { OpenAPI, QuoteRequest, OneClickService } from '@defuse-protocol/one-click-sdk-typescript';
7
7
 
8
- // src/AccountAbstraction.ts
8
+ var __defProp = Object.defineProperty;
9
+ var __getOwnPropNames = Object.getOwnPropertyNames;
10
+ var __esm = (fn, res) => function __init() {
11
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
12
+ };
13
+ var __export = (target, all) => {
14
+ for (var name in all)
15
+ __defProp(target, name, { get: all[name], enumerable: true });
16
+ };
17
+
18
+ // src/constants/facilitator.ts
19
+ var facilitator_exports = {};
20
+ __export(facilitator_exports, {
21
+ FACILITATOR_NETWORKS: () => FACILITATOR_NETWORKS,
22
+ calculateFee: () => calculateFee
23
+ });
24
+ var calculateFee, FACILITATOR_NETWORKS;
25
+ var init_facilitator = __esm({
26
+ "src/constants/facilitator.ts"() {
27
+ calculateFee = () => {
28
+ return BigInt(1e4);
29
+ };
30
+ FACILITATOR_NETWORKS = {
31
+ Base: {
32
+ chainId: 8453,
33
+ chain: base,
34
+ usdc: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
35
+ usdcName: "USD Coin",
36
+ usdcVersion: "2",
37
+ domain: 6,
38
+ tokenMessenger: "0x28b5a0e9C621a5BadaA536219b3a228C8168cf5d",
39
+ messageTransmitter: "0x81D40F21F12A8F0E3252Bccb954D722d4c464B64",
40
+ rpcUrl: "https://base-mainnet.g.alchemy.com/v2/49fUGmuW05ynCui0VEvDN"
41
+ },
42
+ Optimism: {
43
+ chainId: 10,
44
+ chain: optimism,
45
+ usdc: "0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85",
46
+ usdcName: "USD Coin",
47
+ usdcVersion: "2",
48
+ domain: 2,
49
+ tokenMessenger: "0x28b5a0e9C621a5BadaA536219b3a228C8168cf5d",
50
+ messageTransmitter: "0x81D40F21F12A8F0E3252Bccb954D722d4c464B64",
51
+ rpcUrl: "https://opt-mainnet.g.alchemy.com/v2/49fUGmuW05ynCui0VEvDN"
52
+ // Assuming same key works or public
53
+ }
54
+ };
55
+ }
56
+ });
9
57
 
10
58
  // src/constants.ts
11
59
  var factoryAbi = [
@@ -812,34 +860,10 @@ var CHAIN_CONFIGS = {
812
860
  [gnosis.id]: GNOSIS_MAINNET,
813
861
  [optimism.id]: OPTIMISM_MAINNET
814
862
  };
815
- var calculateFee = () => {
816
- return BigInt(1e4);
817
- };
818
- var FACILITATOR_NETWORKS = {
819
- Base: {
820
- chainId: 8453,
821
- chain: base,
822
- usdc: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
823
- usdcName: "USD Coin",
824
- usdcVersion: "2",
825
- domain: 6,
826
- tokenMessenger: "0x28b5a0e9C621a5BadaA536219b3a228C8168cf5d",
827
- messageTransmitter: "0x81D40F21F12A8F0E3252Bccb954D722d4c464B64",
828
- rpcUrl: "https://base-mainnet.g.alchemy.com/v2/49fUGmuW05ynCui0VEvDN"
829
- },
830
- Optimism: {
831
- chainId: 10,
832
- chain: optimism,
833
- usdc: "0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85",
834
- usdcName: "USD Coin",
835
- usdcVersion: "2",
836
- domain: 2,
837
- tokenMessenger: "0x28b5a0e9C621a5BadaA536219b3a228C8168cf5d",
838
- messageTransmitter: "0x81D40F21F12A8F0E3252Bccb954D722d4c464B64",
839
- rpcUrl: "https://opt-mainnet.g.alchemy.com/v2/49fUGmuW05ynCui0VEvDN"
840
- // Assuming same key works or public
841
- }
842
- };
863
+
864
+ // src/services/gasless.ts
865
+ init_facilitator();
866
+ init_facilitator();
843
867
 
844
868
  // src/constants/abis.ts
845
869
  var usdcErc3009Abi = [
@@ -1039,6 +1063,10 @@ async function processGaslessSettlement(paymentPayload, sourceChain, amount, fac
1039
1063
  netAmount: amountBigInt.toString()
1040
1064
  };
1041
1065
  }
1066
+
1067
+ // src/services/cctp.ts
1068
+ init_facilitator();
1069
+ init_facilitator();
1042
1070
  var createRetrieveAttestation = async (transactionHash, chainId, timeout = 6e4) => {
1043
1071
  const baseUrl = "https://iris-api.circle.com";
1044
1072
  const url = `${baseUrl}/v2/messages/${chainId}?transactionHash=${transactionHash}`;
@@ -1749,6 +1777,7 @@ var CCTPStrategy = class {
1749
1777
  };
1750
1778
  async function processCCTPSettlement(context, crossChainConfig) {
1751
1779
  const { paymentPayload, sourceChain, amount, recipient, facilitatorPrivateKey, depositTxHash } = context;
1780
+ console.log(`[SDK v0.4.22] Processing CCTP. DepositHash: ${depositTxHash} (${typeof depositTxHash})`);
1752
1781
  if (!facilitatorPrivateKey) {
1753
1782
  return {
1754
1783
  success: false,
@@ -1802,6 +1831,7 @@ async function processCCTPSettlement(context, crossChainConfig) {
1802
1831
  };
1803
1832
  }
1804
1833
  } else {
1834
+ console.log("[SDK v0.4.22] No deposit hash. Returning PENDING_USER_DEPOSIT.");
1805
1835
  return {
1806
1836
  success: true,
1807
1837
  data: {
@@ -1810,10 +1840,10 @@ async function processCCTPSettlement(context, crossChainConfig) {
1810
1840
  chainId: networkConfig.chainId
1811
1841
  },
1812
1842
  attestation: {
1813
- message: "PENDING_USER_DEPOSIT",
1843
+ message: "PENDING_USER_DEPOSIT_v22",
1814
1844
  attestation: "0x"
1815
1845
  },
1816
- transactionHash: "PENDING_USER_DEPOSIT"
1846
+ transactionHash: "PENDING_USER_DEPOSIT_v22"
1817
1847
  };
1818
1848
  }
1819
1849
  const transferHash = depositTxHash || "0x0000000000000000000000000000000000000000000000000000000000000000";
@@ -2006,7 +2036,37 @@ var NearStrategy = class {
2006
2036
  return !!(sourceNear && destNear);
2007
2037
  }
2008
2038
  async execute(context) {
2009
- const { sourceChain, destChain, amount, recipient, destToken, sourceToken, senderAddress } = context;
2039
+ const { sourceChain, destChain, amount, recipient, destToken, sourceToken, senderAddress, depositTxHash } = context;
2040
+ if (depositTxHash) {
2041
+ console.log(`[NearStrategy] Verifying deposit hash: ${depositTxHash}`);
2042
+ const { createPublicClient: createPublicClient4, http: http4 } = await import('viem');
2043
+ const { FACILITATOR_NETWORKS: FACILITATOR_NETWORKS2 } = await Promise.resolve().then(() => (init_facilitator(), facilitator_exports));
2044
+ const networkConfig = FACILITATOR_NETWORKS2[sourceChain];
2045
+ if (!networkConfig) {
2046
+ return { success: false, errorReason: `Unsupported source chain for verification: ${sourceChain}` };
2047
+ }
2048
+ const publicClient = createPublicClient4({
2049
+ chain: networkConfig.chain,
2050
+ transport: http4(networkConfig.rpcUrl)
2051
+ });
2052
+ try {
2053
+ const receipt = await publicClient.waitForTransactionReceipt({ hash: depositTxHash });
2054
+ if (receipt.status === "success") {
2055
+ return {
2056
+ success: true,
2057
+ transactionHash: depositTxHash,
2058
+ netAmount: amount,
2059
+ // rough estimate or we can re-quote if needed
2060
+ data: {
2061
+ // Info for UI
2062
+ completed: true
2063
+ }
2064
+ };
2065
+ }
2066
+ } catch (e) {
2067
+ return { success: false, errorReason: `Invalid deposit transaction: ${e.message}` };
2068
+ }
2069
+ }
2010
2070
  try {
2011
2071
  const quoteResult = await getNearQuote(
2012
2072
  sourceChain,