@rhinestone/sdk 0.4.1 → 0.4.3

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
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../execution/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,KAAK,EAKL,GAAG,EAKJ,MAAM,MAAM,CAAA;AAmBb,OAAO,KAAK,EACV,YAAY,EAGb,MAAM,iBAAiB,CAAA;AAUxB,OAAO,EAEL,uBAAuB,EAIvB,WAAW,EACZ,MAAM,UAAU,CAAA;AAUjB,KAAK,iBAAiB,GAClB;IACE,IAAI,EAAE,QAAQ,CAAA;IACd,IAAI,EAAE,GAAG,CAAA;IACT,WAAW,EAAE,KAAK,CAAA;IAClB,WAAW,EAAE,KAAK,CAAA;CACnB,GACD;IACE,IAAI,EAAE,QAAQ,CAAA;IACd,EAAE,EAAE,MAAM,CAAA;IACV,WAAW,EAAE,KAAK,CAAA;IAClB,WAAW,EAAE,KAAK,CAAA;CACnB,CAAA;AAEL,iBAAe,eAAe,CAC5B,MAAM,EAAE,uBAAuB,EAC/B,WAAW,EAAE,WAAW,8BAuBzB;AAyQD,iBAAe,gBAAgB,CAC7B,MAAM,EAAE,uBAAuB,EAC/B,MAAM,EAAE,iBAAiB;;;;;;;;;;;;GAgC1B;AAED,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,CAAA;AAC5C,YAAY,EAAE,iBAAiB,EAAE,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../execution/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,KAAK,EAKL,GAAG,EAKJ,MAAM,MAAM,CAAA;AAmBb,OAAO,KAAK,EACV,YAAY,EAGb,MAAM,iBAAiB,CAAA;AAUxB,OAAO,EAEL,uBAAuB,EAIvB,WAAW,EACZ,MAAM,UAAU,CAAA;AAUjB,KAAK,iBAAiB,GAClB;IACE,IAAI,EAAE,QAAQ,CAAA;IACd,IAAI,EAAE,GAAG,CAAA;IACT,WAAW,EAAE,KAAK,CAAA;IAClB,WAAW,EAAE,KAAK,CAAA;CACnB,GACD;IACE,IAAI,EAAE,QAAQ,CAAA;IACd,EAAE,EAAE,MAAM,CAAA;IACV,WAAW,EAAE,KAAK,CAAA;IAClB,WAAW,EAAE,KAAK,CAAA;CACnB,CAAA;AAEL,iBAAe,eAAe,CAC5B,MAAM,EAAE,uBAAuB,EAC/B,WAAW,EAAE,WAAW,8BAuBzB;AAyQD,iBAAe,gBAAgB,CAC7B,MAAM,EAAE,uBAAuB,EAC/B,MAAM,EAAE,iBAAiB;;;;;;;;;;;;GAgC1B;AAED,iBAAe,qBAAqB,CAClC,MAAM,EAAE,uBAAuB,EAC/B,KAAK,EAAE,KAAK,EACZ,YAAY,EAAE,OAAO,EACrB,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,MAAM,CAAC,CASjB;AAED,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,CAAA;AACnE,YAAY,EAAE,iBAAiB,EAAE,CAAA"}
@@ -218,4 +218,9 @@ async function waitForExecution(config, result) {
218
218
  }
219
219
  }
220
220
  }
221
- export { sendTransaction, waitForExecution };
221
+ async function getMaxSpendableAmount(config, chain, tokenAddress, gasUnits) {
222
+ const address = getAddress(config);
223
+ const orchestrator = getOrchestrator(config.rhinestoneApiKey);
224
+ return orchestrator.getMaxTokenAmount(address, chain.id, tokenAddress, gasUnits);
225
+ }
226
+ export { sendTransaction, waitForExecution, getMaxSpendableAmount };
@@ -1,3 +1,4 @@
1
+ import { Address, Chain } from 'viem';
1
2
  import type { TransactionResult } from './execution';
2
3
  import type { RhinestoneAccountConfig, Session, Transaction } from './types';
3
4
  /**
@@ -12,17 +13,18 @@ declare function createRhinestoneAccount(config: RhinestoneAccountConfig): Promi
12
13
  waitForExecution: (result: TransactionResult) => Promise<import("./orchestrator").BundleResult | {
13
14
  actualGasCost: bigint;
14
15
  actualGasUsed: bigint;
15
- entryPoint: import("abitype").Address;
16
+ entryPoint: Address;
16
17
  logs: import("viem").Log<bigint, number, false>[];
17
18
  nonce: bigint;
18
19
  paymaster?: `0x${string}` | undefined;
19
20
  reason?: string | undefined | undefined;
20
21
  receipt: import("viem").TransactionReceipt<bigint, number, "success" | "reverted">;
21
- sender: import("abitype").Address;
22
+ sender: Address;
22
23
  success: boolean;
23
24
  userOpHash: import("viem").Hash;
24
25
  }>;
25
- getAddress: () => string;
26
+ getAddress: () => `0x${string}`;
27
+ getMaxSpendableAmount: (chain: Chain, tokenAddress: Address, gasUnits: bigint) => Promise<bigint>;
26
28
  }>;
27
29
  export { createRhinestoneAccount };
28
30
  export type { Session };
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAKpD,OAAO,KAAK,EAAE,uBAAuB,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAE5E;;;;;GAKG;AACH,iBAAe,uBAAuB,CAAC,MAAM,EAAE,uBAAuB;;oCAM7B,WAAW;+BAShB,iBAAiB;;;;;;;;;;;;;sBAQ5B,MAAM;GAU9B;AAED,OAAO,EAAE,uBAAuB,EAAE,CAAA;AAClC,YAAY,EAAE,OAAO,EAAE,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,MAAM,CAAA;AAErC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAMpD,OAAO,KAAK,EAAE,uBAAuB,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAE5E;;;;;GAKG;AACH,iBAAe,uBAAuB,CAAC,MAAM,EAAE,uBAAuB;;oCAM7B,WAAW;+BAShB,iBAAiB;;;;;;;;;;;;;;mCAoB1C,KAAK,gBACE,OAAO,YACX,MAAM;GAYnB;AAED,OAAO,EAAE,uBAAuB,EAAE,CAAA;AAClC,YAAY,EAAE,OAAO,EAAE,CAAA"}
package/dist/src/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { getAddress as getAddressInternal } from './accounts';
2
- import { sendTransaction as sendTransactionInternal, waitForExecution as waitForExecutionInternal, } from './execution';
2
+ import { getMaxSpendableAmount as getMaxSpendableAmountInternal, sendTransaction as sendTransactionInternal, waitForExecution as waitForExecutionInternal, } from './execution';
3
3
  /**
4
4
  * Initialize a Rhinestone account
5
5
  * Note: accounts are deployed onchain only when the first transaction is sent.
@@ -30,11 +30,22 @@ async function createRhinestoneAccount(config) {
30
30
  function getAddress() {
31
31
  return getAddressInternal(config);
32
32
  }
33
+ /**
34
+ * Get the maximum spendable token amount on the target chain
35
+ * @param chain Target chain
36
+ * @param tokenAddress Token address (on the target chain)
37
+ * @param gasUnits Gas cost estimate for the transaction execution
38
+ * @returns Maximum spendable amount in absolute units
39
+ */
40
+ function getMaxSpendableAmount(chain, tokenAddress, gasUnits) {
41
+ return getMaxSpendableAmountInternal(config, chain, tokenAddress, gasUnits);
42
+ }
33
43
  return {
34
44
  config,
35
45
  sendTransactions,
36
46
  waitForExecution,
37
47
  getAddress,
48
+ getMaxSpendableAmount,
38
49
  };
39
50
  }
40
51
  export { createRhinestoneAccount };
@@ -11,6 +11,7 @@ export declare class Orchestrator {
11
11
  [chainId: number]: Address[];
12
12
  };
13
13
  }): Promise<UserTokenBalance[]>;
14
+ getMaxTokenAmount(userAddress: Address, targetChainId: number, targetTokenAddress: Address, targetGasUnits: bigint): Promise<bigint>;
14
15
  getIntentCost(intent: MetaIntent | OrderFeeInput, userAddress: Address): Promise<OrderCostResult>;
15
16
  getOrderPath(intent: MetaIntent, userAddress: Address): Promise<OrderPath>;
16
17
  postSignedOrderBundle(signedOrderBundles: {
@@ -1 +1 @@
1
- {"version":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AAE,OAAO,GACnB,OAAO,CAAC,SAAS,CAAC;IAgCf,qBAAqB,CACzB,kBAAkB,EAAE;QAClB,iBAAiB,EAAE,uBAAuB,CAAA;QAC1C,QAAQ,CAAC,EAAE,GAAG,CAAA;QACd,MAAM,CAAC,EAAE,aAAa,CAAA;KACvB,EAAE,GACF,OAAO,CAAC,qBAAqB,CAAC;IA2C3B,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;IAyBxD,iBAAiB,CACrB,KAAK,GAAE,MAAW,EAClB,MAAM,GAAE,MAAU,GACjB,OAAO,CAAC;QAAE,cAAc,EAAE,WAAW,EAAE,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAuBlE,OAAO,CAAC,UAAU;CA6DnB"}
@@ -42,6 +42,29 @@ export class Orchestrator {
42
42
  throw new Error('Failed to get portfolio');
43
43
  }
44
44
  }
45
+ async getMaxTokenAmount(userAddress, targetChainId, targetTokenAddress, targetGasUnits) {
46
+ const intentCost = await this.getIntentCost({
47
+ targetChainId,
48
+ targetGasUnits,
49
+ tokenTransfers: [
50
+ {
51
+ tokenAddress: targetTokenAddress,
52
+ },
53
+ ],
54
+ }, userAddress);
55
+ if (!intentCost.hasFulfilledAll) {
56
+ return 0n;
57
+ }
58
+ const tokenReceived = intentCost.tokensReceived.find((token) => token.tokenAddress.toLowerCase() === targetTokenAddress.toLowerCase());
59
+ if (!tokenReceived) {
60
+ return 0n;
61
+ }
62
+ const tokenAmount = tokenReceived.targetAmount;
63
+ if (tokenAmount < 0n) {
64
+ throw new Error(`Balance not available. Make sure the account is deployed`);
65
+ }
66
+ return tokenReceived.targetAmount;
67
+ }
45
68
  async getIntentCost(intent, userAddress) {
46
69
  try {
47
70
  const response = await axios.post(`${this.serverUrl}/accounts/${userAddress}/bundles/cost`, {
@@ -1,11 +1,11 @@
1
1
  import { Orchestrator } from './client';
2
2
  import { RHINESTONE_SPOKE_POOL_ADDRESS } from './consts';
3
3
  import { OrchestratorError } from './error';
4
- import { getTokenBalanceSlot, getWethAddress } from './registry';
5
- import type { BundleResult, MetaIntent, OrderPath, SignedMultiChainCompact } from './types';
4
+ import { getHookAddress, getSameChainModuleAddress, getTargetModuleAddress, getTokenAddress, getTokenBalanceSlot, getWethAddress } from './registry';
5
+ import type { BundleResult, MetaIntent, OrderPath, PostOrderBundleResult, SignedMultiChainCompact } from './types';
6
6
  import { BUNDLE_STATUS_FAILED, BUNDLE_STATUS_PARTIALLY_COMPLETED, BUNDLE_STATUS_PENDING } from './types';
7
7
  import { getEmptyUserOp, getOrderBundleHash } from './utils';
8
8
  declare function getOrchestrator(apiKey: string, orchestratorUrl?: string): Orchestrator;
9
- export type { BundleResult, MetaIntent, OrderPath, SignedMultiChainCompact };
10
- export { BUNDLE_STATUS_FAILED, BUNDLE_STATUS_PARTIALLY_COMPLETED, BUNDLE_STATUS_PENDING, RHINESTONE_SPOKE_POOL_ADDRESS, Orchestrator, OrchestratorError, getOrchestrator, getOrderBundleHash, getEmptyUserOp, getWethAddress, getTokenBalanceSlot, };
9
+ export type { BundleResult, MetaIntent, OrderPath, SignedMultiChainCompact, PostOrderBundleResult, };
10
+ export { BUNDLE_STATUS_FAILED, BUNDLE_STATUS_PARTIALLY_COMPLETED, BUNDLE_STATUS_PENDING, RHINESTONE_SPOKE_POOL_ADDRESS, Orchestrator, OrchestratorError, getOrchestrator, getOrderBundleHash, getEmptyUserOp, getWethAddress, getTokenBalanceSlot, getHookAddress, getSameChainModuleAddress, getTargetModuleAddress, getTokenAddress, };
11
11
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../orchestrator/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AACvC,OAAO,EAAoB,6BAA6B,EAAE,MAAM,UAAU,CAAA;AAC1E,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAC3C,OAAO,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAChE,OAAO,KAAK,EACV,YAAY,EACZ,UAAU,EACV,SAAS,EACT,uBAAuB,EACxB,MAAM,SAAS,CAAA;AAChB,OAAO,EACL,oBAAoB,EACpB,iCAAiC,EACjC,qBAAqB,EACtB,MAAM,SAAS,CAAA;AAChB,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAA;AAE5D,iBAAS,eAAe,CACtB,MAAM,EAAE,MAAM,EACd,eAAe,CAAC,EAAE,MAAM,GACvB,YAAY,CAEd;AAED,YAAY,EAAE,YAAY,EAAE,UAAU,EAAE,SAAS,EAAE,uBAAuB,EAAE,CAAA;AAC5E,OAAO,EACL,oBAAoB,EACpB,iCAAiC,EACjC,qBAAqB,EACrB,6BAA6B,EAC7B,YAAY,EACZ,iBAAiB,EACjB,eAAe,EACf,kBAAkB,EAClB,cAAc,EACd,cAAc,EACd,mBAAmB,GACpB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../orchestrator/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AACvC,OAAO,EAAoB,6BAA6B,EAAE,MAAM,UAAU,CAAA;AAC1E,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAC3C,OAAO,EACL,cAAc,EACd,yBAAyB,EACzB,sBAAsB,EACtB,eAAe,EACf,mBAAmB,EACnB,cAAc,EACf,MAAM,YAAY,CAAA;AACnB,OAAO,KAAK,EACV,YAAY,EACZ,UAAU,EACV,SAAS,EACT,qBAAqB,EACrB,uBAAuB,EACxB,MAAM,SAAS,CAAA;AAChB,OAAO,EACL,oBAAoB,EACpB,iCAAiC,EACjC,qBAAqB,EACtB,MAAM,SAAS,CAAA;AAChB,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAA;AAE5D,iBAAS,eAAe,CACtB,MAAM,EAAE,MAAM,EACd,eAAe,CAAC,EAAE,MAAM,GACvB,YAAY,CAEd;AAED,YAAY,EACV,YAAY,EACZ,UAAU,EACV,SAAS,EACT,uBAAuB,EACvB,qBAAqB,GACtB,CAAA;AACD,OAAO,EACL,oBAAoB,EACpB,iCAAiC,EACjC,qBAAqB,EACrB,6BAA6B,EAC7B,YAAY,EACZ,iBAAiB,EACjB,eAAe,EACf,kBAAkB,EAClB,cAAc,EACd,cAAc,EACd,mBAAmB,EACnB,cAAc,EACd,yBAAyB,EACzB,sBAAsB,EACtB,eAAe,GAChB,CAAA"}
@@ -1,10 +1,10 @@
1
1
  import { Orchestrator } from './client';
2
2
  import { ORCHESTRATOR_URL, RHINESTONE_SPOKE_POOL_ADDRESS } from './consts';
3
3
  import { OrchestratorError } from './error';
4
- import { getTokenBalanceSlot, getWethAddress } from './registry';
4
+ import { getHookAddress, getSameChainModuleAddress, getTargetModuleAddress, getTokenAddress, getTokenBalanceSlot, getWethAddress, } from './registry';
5
5
  import { BUNDLE_STATUS_FAILED, BUNDLE_STATUS_PARTIALLY_COMPLETED, BUNDLE_STATUS_PENDING, } from './types';
6
6
  import { getEmptyUserOp, getOrderBundleHash } from './utils';
7
7
  function getOrchestrator(apiKey, orchestratorUrl) {
8
8
  return new Orchestrator(orchestratorUrl ?? ORCHESTRATOR_URL, apiKey);
9
9
  }
10
- export { BUNDLE_STATUS_FAILED, BUNDLE_STATUS_PARTIALLY_COMPLETED, BUNDLE_STATUS_PENDING, RHINESTONE_SPOKE_POOL_ADDRESS, Orchestrator, OrchestratorError, getOrchestrator, getOrderBundleHash, getEmptyUserOp, getWethAddress, getTokenBalanceSlot, };
10
+ export { BUNDLE_STATUS_FAILED, BUNDLE_STATUS_PARTIALLY_COMPLETED, BUNDLE_STATUS_PENDING, RHINESTONE_SPOKE_POOL_ADDRESS, Orchestrator, OrchestratorError, getOrchestrator, getOrderBundleHash, getEmptyUserOp, getWethAddress, getTokenBalanceSlot, getHookAddress, getSameChainModuleAddress, getTargetModuleAddress, getTokenAddress, };
@@ -1,5 +1,9 @@
1
1
  import { Address, Chain } from 'viem';
2
2
  declare function getWethAddress(chain: Chain): "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2" | "0xfFf9976782d46CC05630D1f6eBAb18b2324d6B14" | "0x4200000000000000000000000000000000000006" | "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1" | "0x980B62Da83eFf3D4576C647993b0c1D7faf17c73" | "0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619" | "0x52eF3d68BaB452a294342DC3e5f464d7f610f72E";
3
3
  declare function getTokenBalanceSlot(chain: Chain, tokenAddress: Address): bigint | null;
4
- export { getTokenBalanceSlot, getWethAddress };
4
+ declare function getHookAddress(): string;
5
+ declare function getSameChainModuleAddress(): string;
6
+ declare function getTargetModuleAddress(): string;
7
+ declare function getTokenAddress(tokenSymbol: string, chainId: number): Address;
8
+ export { getTokenAddress, getTokenBalanceSlot, getWethAddress, getHookAddress, getSameChainModuleAddress, getTargetModuleAddress, };
5
9
  //# sourceMappingURL=registry.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../../orchestrator/registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,KAAK,EAAe,MAAM,MAAM,CAAA;AAclD,iBAAS,cAAc,CAAC,KAAK,EAAE,KAAK,0UAoCnC;AAED,iBAAS,mBAAmB,CAC1B,KAAK,EAAE,KAAK,EACZ,YAAY,EAAE,OAAO,GACpB,MAAM,GAAG,IAAI,CAqJf;AAED,OAAO,EAAE,mBAAmB,EAAE,cAAc,EAAE,CAAA"}
1
+ {"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../../orchestrator/registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,KAAK,EAAe,MAAM,MAAM,CAAA;AAclD,iBAAS,cAAc,CAAC,KAAK,EAAE,KAAK,0UAoCnC;AAwCD,iBAAS,mBAAmB,CAC1B,KAAK,EAAE,KAAK,EACZ,YAAY,EAAE,OAAO,GACpB,MAAM,GAAG,IAAI,CAqJf;AAED,iBAAS,cAAc,WAEtB;AAED,iBAAS,yBAAyB,WAEjC;AAED,iBAAS,sBAAsB,WAE9B;AAED,iBAAS,eAAe,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAetE;AAsBD,OAAO,EACL,eAAe,EACf,mBAAmB,EACnB,cAAc,EACd,cAAc,EACd,yBAAyB,EACzB,sBAAsB,GACvB,CAAA"}
@@ -37,6 +37,43 @@ function getWethAddress(chain) {
37
37
  }
38
38
  }
39
39
  }
40
+ function getUsdcAddress(chain) {
41
+ switch (chain.id) {
42
+ case mainnet.id: {
43
+ return '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48';
44
+ }
45
+ case sepolia.id: {
46
+ return '0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238';
47
+ }
48
+ case base.id: {
49
+ return '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913';
50
+ }
51
+ case baseSepolia.id: {
52
+ return '0x036CbD53842c5426634e7929541eC2318f3dCF7e';
53
+ }
54
+ case arbitrum.id: {
55
+ return '0xaf88d065e77c8cC2239327C5EDb3A432268e5831';
56
+ }
57
+ case arbitrumSepolia.id: {
58
+ return '0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d';
59
+ }
60
+ case optimism.id: {
61
+ return '0x0b2c639c533813f4aa9d7837caf62653d097ff85';
62
+ }
63
+ case optimismSepolia.id: {
64
+ return '0x5fd84259d66Cd46123540766Be93DFE6D43130D7';
65
+ }
66
+ case polygon.id: {
67
+ return '0x3c499c542cef5e3811e1192ce70d8cc03d5c3359';
68
+ }
69
+ case polygonAmoy.id: {
70
+ return '0x41e94eb019c0762f9bfcf9fb1e58725bfb0e7582';
71
+ }
72
+ default: {
73
+ throw new Error(`Unsupported chain ${chain.id}`);
74
+ }
75
+ }
76
+ }
40
77
  function getTokenBalanceSlot(chain, tokenAddress) {
41
78
  switch (chain.id) {
42
79
  case mainnet.id: {
@@ -184,4 +221,48 @@ function getTokenBalanceSlot(chain, tokenAddress) {
184
221
  }
185
222
  throw new Error(`Unsupported token address ${tokenAddress} for chain ${chain.id}`);
186
223
  }
187
- export { getTokenBalanceSlot, getWethAddress };
224
+ function getHookAddress() {
225
+ return '0x0000000000f6Ed8Be424d673c63eeFF8b9267420';
226
+ }
227
+ function getSameChainModuleAddress() {
228
+ return '0x000000000043ff16d5776c7F0f65Ec485C17Ca04';
229
+ }
230
+ function getTargetModuleAddress() {
231
+ return '0x0000000000E5a37279A001301A837a91b5de1D5E';
232
+ }
233
+ function getTokenAddress(tokenSymbol, chainId) {
234
+ if (tokenSymbol === 'ETH') {
235
+ return zeroAddress;
236
+ }
237
+ const chain = getChainById(chainId);
238
+ if (!chain) {
239
+ throw new Error(`Unsupported chain ${chainId}`);
240
+ }
241
+ if (tokenSymbol === 'WETH') {
242
+ return getWethAddress(chain);
243
+ }
244
+ if (tokenSymbol === 'USDC') {
245
+ return getUsdcAddress(chain);
246
+ }
247
+ throw new Error(`Unsupported token symbol ${tokenSymbol}`);
248
+ }
249
+ function getChainById(chainId) {
250
+ const supportedChains = [
251
+ mainnet,
252
+ sepolia,
253
+ base,
254
+ baseSepolia,
255
+ arbitrum,
256
+ arbitrumSepolia,
257
+ optimism,
258
+ optimismSepolia,
259
+ polygon,
260
+ polygonAmoy,
261
+ ];
262
+ for (const chain of supportedChains) {
263
+ if (chain.id === chainId) {
264
+ return chain;
265
+ }
266
+ }
267
+ }
268
+ export { getTokenAddress, getTokenBalanceSlot, getWethAddress, getHookAddress, getSameChainModuleAddress, getTargetModuleAddress, };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rhinestone/sdk",
3
- "version": "0.4.1",
3
+ "version": "0.4.3",
4
4
  "description": "End-to-end chain abstraction and modularity toolkit",
5
5
  "author": {
6
6
  "name": "Rhinestone",
@@ -18,6 +18,10 @@
18
18
  ".": {
19
19
  "types": "./dist/index.d.ts",
20
20
  "import": "./dist/index.js"
21
+ },
22
+ "./orchestrator": {
23
+ "types": "./dist/orchestrator/index.d.ts",
24
+ "import": "./dist/orchestrator/index.js"
21
25
  }
22
26
  },
23
27
  "files": [