@sodax/sdk 0.0.1-rc.24 → 0.0.1-rc.25

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.cjs CHANGED
@@ -6331,6 +6331,7 @@ var hubChainConfig = {
6331
6331
  sodaToken: "0x7c7d53eecda37a87ce0d5bf8e0b24512a48dc963"
6332
6332
  },
6333
6333
  nativeToken: "0x0000000000000000000000000000000000000000",
6334
+ wrappedNativeToken: "0x039e2fB66102314Ce7b64Ce5Ce3E5183bc94aD38",
6334
6335
  supportedTokens: []
6335
6336
  }
6336
6337
  };
@@ -6827,6 +6828,7 @@ var spokeChainConfig = {
6827
6828
  [types.SUI_MAINNET_CHAIN_ID]: {
6828
6829
  addresses: {
6829
6830
  connection: "0xf3b1e696a66d02cb776dc15aae73c68bc8f03adcb6ba0ec7f6332d9d90a6a3d2::connectionv3::0x3ee76d13909ac58ae13baab4c9be5a5142818d9a387aed641825e5d4356969bf",
6831
+ assetManagerId: "0xa17a409164d1676db71b411ab50813ba2c7dd547d2df538c699049566f1ff922::asset_manager::0xcb7346339340b7f8dea40fcafb70721dc2fcfa7e8626a89fd954d46c1f928b61",
6830
6832
  assetManager: "0x897f911a4b7691870a1a2513af7e85fdee8de275615c77068fd8b90b8e78c678::asset_manager::0xcb7346339340b7f8dea40fcafb70721dc2fcfa7e8626a89fd954d46c1f928b61",
6831
6833
  xTokenManager: "",
6832
6834
  rateLimit: "",
@@ -9250,6 +9252,32 @@ var EvmSpokeService = class _EvmSpokeService {
9250
9252
  args: [token]
9251
9253
  });
9252
9254
  }
9255
+ /**
9256
+ * Generate simulation parameters for deposit from EvmSpokeDepositParams.
9257
+ * @param {EvmSpokeDepositParams} params - The deposit parameters.
9258
+ * @param {EvmSpokeProvider} spokeProvider - The provider for the spoke chain.
9259
+ * @param {EvmHubProvider} hubProvider - The provider for the hub chain.
9260
+ * @returns {Promise<DepositSimulationParams>} The simulation parameters.
9261
+ */
9262
+ static async getSimulateDepositParams(params, spokeProvider, hubProvider) {
9263
+ const to = params.to ?? await EvmWalletAbstraction.getUserHubWalletAddress(
9264
+ spokeProvider.chainConfig.chain.id,
9265
+ params.from,
9266
+ hubProvider
9267
+ );
9268
+ return {
9269
+ spokeChainID: spokeProvider.chainConfig.chain.id,
9270
+ token: encodeAddress(spokeProvider.chainConfig.chain.id, params.token),
9271
+ from: encodeAddress(spokeProvider.chainConfig.chain.id, params.from),
9272
+ to,
9273
+ amount: params.amount,
9274
+ data: params.data,
9275
+ srcAddress: encodeAddress(
9276
+ spokeProvider.chainConfig.chain.id,
9277
+ spokeProvider.chainConfig.addresses.assetManager
9278
+ )
9279
+ };
9280
+ }
9253
9281
  /**
9254
9282
  * Calls a contract on the spoke chain using the user's wallet.
9255
9283
  * @param {HubAddress} from - The address of the user on the hub chain.
@@ -9372,6 +9400,32 @@ var InjectiveSpokeService = class _InjectiveSpokeService {
9372
9400
  raw
9373
9401
  );
9374
9402
  }
9403
+ /**
9404
+ * Generate simulation parameters for deposit from InjectiveSpokeDepositParams.
9405
+ * @param {InjectiveSpokeDepositParams} params - The deposit parameters.
9406
+ * @param {InjectiveSpokeProvider} spokeProvider - The provider for the spoke chain.
9407
+ * @param {EvmHubProvider} hubProvider - The provider for the hub chain.
9408
+ * @returns {Promise<DepositSimulationParams>} The simulation parameters.
9409
+ */
9410
+ static async getSimulateDepositParams(params, spokeProvider, hubProvider) {
9411
+ const to = params.to ?? await EvmWalletAbstraction.getUserHubWalletAddress(
9412
+ spokeProvider.chainConfig.chain.id,
9413
+ viem.toHex(Buffer.from(params.from, "utf-8")),
9414
+ hubProvider
9415
+ );
9416
+ return {
9417
+ spokeChainID: spokeProvider.chainConfig.chain.id,
9418
+ token: encodeAddress(spokeProvider.chainConfig.chain.id, params.token),
9419
+ from: encodeAddress(spokeProvider.chainConfig.chain.id, params.from),
9420
+ to,
9421
+ amount: params.amount,
9422
+ data: params.data,
9423
+ srcAddress: encodeAddress(
9424
+ spokeProvider.chainConfig.chain.id,
9425
+ spokeProvider.chainConfig.addresses.assetManager
9426
+ )
9427
+ };
9428
+ }
9375
9429
  /**
9376
9430
  * Get the balance of the token that deposited in the spoke chain Asset Manager.
9377
9431
  * @param {Address} token - The address of the token to get the balance of.
@@ -9509,6 +9563,32 @@ var IconSpokeService = class _IconSpokeService {
9509
9563
  const relayId = getIntentRelayChainId(hubProvider.chainConfig.chain.id);
9510
9564
  return _IconSpokeService.call(BigInt(relayId), from, payload, spokeProvider, raw);
9511
9565
  }
9566
+ /**
9567
+ * Generate simulation parameters for deposit from IconSpokeDepositParams.
9568
+ * @param {IconSpokeDepositParams} params - The deposit parameters.
9569
+ * @param {IconSpokeProvider} spokeProvider - The provider for the spoke chain.
9570
+ * @param {EvmHubProvider} hubProvider - The provider for the hub chain.
9571
+ * @returns {Promise<DepositSimulationParams>} The simulation parameters.
9572
+ */
9573
+ static async getSimulateDepositParams(params, spokeProvider, hubProvider) {
9574
+ const to = params.to ?? await EvmWalletAbstraction.getUserHubWalletAddress(
9575
+ spokeProvider.chainConfig.chain.id,
9576
+ getIconAddressBytes(params.from),
9577
+ hubProvider
9578
+ );
9579
+ return {
9580
+ spokeChainID: spokeProvider.chainConfig.chain.id,
9581
+ token: encodeAddress(spokeProvider.chainConfig.chain.id, params.token),
9582
+ from: encodeAddress(spokeProvider.chainConfig.chain.id, params.from),
9583
+ to,
9584
+ amount: params.amount,
9585
+ data: params.data,
9586
+ srcAddress: encodeAddress(
9587
+ spokeProvider.chainConfig.chain.id,
9588
+ spokeProvider.chainConfig.addresses.assetManager
9589
+ )
9590
+ };
9591
+ }
9512
9592
  /**
9513
9593
  * Transfers tokens to the hub chain.
9514
9594
  */
@@ -9709,6 +9789,32 @@ var SolanaSpokeService = class _SolanaSpokeService {
9709
9789
  const relayId = getIntentRelayChainId(hubProvider.chainConfig.chain.id);
9710
9790
  return _SolanaSpokeService.call(BigInt(relayId), from, viem.keccak256(payload), spokeProvider, raw);
9711
9791
  }
9792
+ /**
9793
+ * Generate simulation parameters for deposit from SolanaSpokeDepositParams.
9794
+ * @param {SolanaSpokeDepositParams} params - The deposit parameters.
9795
+ * @param {SolanaSpokeProvider} spokeProvider - The provider for the spoke chain.
9796
+ * @param {EvmHubProvider} hubProvider - The provider for the hub chain.
9797
+ * @returns {Promise<DepositSimulationParams>} The simulation parameters.
9798
+ */
9799
+ static async getSimulateDepositParams(params, spokeProvider, hubProvider) {
9800
+ const to = params.to ?? await EvmWalletAbstraction.getUserHubWalletAddress(
9801
+ spokeProvider.chainConfig.chain.id,
9802
+ encodeAddress(spokeProvider.chainConfig.chain.id, params.from),
9803
+ hubProvider
9804
+ );
9805
+ return {
9806
+ spokeChainID: spokeProvider.chainConfig.chain.id,
9807
+ token: encodeAddress(spokeProvider.chainConfig.chain.id, params.token),
9808
+ from: encodeAddress(spokeProvider.chainConfig.chain.id, params.from),
9809
+ to,
9810
+ amount: params.amount,
9811
+ data: params.data,
9812
+ srcAddress: encodeAddress(
9813
+ spokeProvider.chainConfig.chain.id,
9814
+ spokeProvider.chainConfig.addresses.assetManager
9815
+ )
9816
+ };
9817
+ }
9712
9818
  static async transfer({ token, recipient, amount, data }, spokeProvider, raw) {
9713
9819
  let depositInstruction;
9714
9820
  const amountBN = new BN__default.default(amount);
@@ -9877,6 +9983,32 @@ var StellarSpokeService = class _StellarSpokeService {
9877
9983
  static async getDeposit(token, spokeProvider) {
9878
9984
  return BigInt(await spokeProvider.getBalance(token));
9879
9985
  }
9986
+ /**
9987
+ * Generate simulation parameters for deposit from StellarSpokeDepositParams.
9988
+ * @param {StellarSpokeDepositParams} params - The deposit parameters.
9989
+ * @param {StellarSpokeProvider} spokeProvider - The provider for the spoke chain.
9990
+ * @param {EvmHubProvider} hubProvider - The provider for the hub chain.
9991
+ * @returns {Promise<DepositSimulationParams>} The simulation parameters.
9992
+ */
9993
+ static async getSimulateDepositParams(params, spokeProvider, hubProvider) {
9994
+ const to = params.to ?? await EvmWalletAbstraction.getUserHubWalletAddress(
9995
+ spokeProvider.chainConfig.chain.id,
9996
+ params.from,
9997
+ hubProvider
9998
+ );
9999
+ return {
10000
+ spokeChainID: spokeProvider.chainConfig.chain.id,
10001
+ token: encodeAddress(spokeProvider.chainConfig.chain.id, params.token),
10002
+ from: params.from,
10003
+ to,
10004
+ amount: params.amount,
10005
+ data: params.data,
10006
+ srcAddress: encodeAddress(
10007
+ spokeProvider.chainConfig.chain.id,
10008
+ spokeProvider.chainConfig.addresses.assetManager
10009
+ )
10010
+ };
10011
+ }
9880
10012
  /**
9881
10013
  * Calls a contract on the spoke chain using the user's wallet.
9882
10014
  * @param from - The address of the user on the hub chain.
@@ -9959,6 +10091,30 @@ var SuiSpokeService = class _SuiSpokeService {
9959
10091
  static async getDeposit(token, spokeProvider) {
9960
10092
  return spokeProvider.getBalance(token);
9961
10093
  }
10094
+ /**
10095
+ * Generate simulation parameters for deposit from SuiSpokeDepositParams.
10096
+ * @param {SuiSpokeDepositParams} params - The deposit parameters.
10097
+ * @param {SuiSpokeProvider} spokeProvider - The provider for the spoke chain.
10098
+ * @param {EvmHubProvider} hubProvider - The provider for the hub chain.
10099
+ * @returns {Promise<DepositSimulationParams>} The simulation parameters.
10100
+ */
10101
+ static async getSimulateDepositParams(params, spokeProvider, hubProvider) {
10102
+ const to = params.to ?? await EvmWalletAbstraction.getUserHubWalletAddress(
10103
+ spokeProvider.chainConfig.chain.id,
10104
+ params.from,
10105
+ hubProvider
10106
+ );
10107
+ const encoder = new TextEncoder();
10108
+ return {
10109
+ spokeChainID: spokeProvider.chainConfig.chain.id,
10110
+ token: viem.toHex(encoder.encode(params.token)),
10111
+ from: encodeAddress(spokeProvider.chainConfig.chain.id, params.from),
10112
+ to,
10113
+ amount: params.amount,
10114
+ data: params.data,
10115
+ srcAddress: viem.toHex(encoder.encode(spokeProvider.chainConfig.addresses.assetManagerId))
10116
+ };
10117
+ }
9962
10118
  /**
9963
10119
  * Calls a contract on the spoke chain using the user's wallet.
9964
10120
  * @param {HubAddress} from - The address of the user on the spoke chain.
@@ -10474,9 +10630,7 @@ function isBalnMigrateParams(value) {
10474
10630
  function isIcxCreateRevertMigrationParams(value) {
10475
10631
  return typeof value === "object" && value !== null && "amount" in value && "to" in value;
10476
10632
  }
10477
-
10478
- // src/services/spoke/SpokeService.ts
10479
- var SpokeService = class {
10633
+ var SpokeService = class _SpokeService {
10480
10634
  constructor() {
10481
10635
  }
10482
10636
  /**
@@ -10530,14 +10684,99 @@ var SpokeService = class {
10530
10684
  }
10531
10685
  throw new Error("Invalid spoke provider");
10532
10686
  }
10687
+ /**
10688
+
10689
+ * Encodes transfer data using RLP encoding to match Solidity Transfer struct.
10690
+ * @param {Hex} token - The token contract address.
10691
+ * @param {Hex} from - The sender address.
10692
+ * @param {Hex} to - The recipient address.
10693
+ * @param {bigint} amount - The transfer amount.
10694
+ * @param {Hex} data - The encoded data payload.
10695
+ * @returns {Promise<Hex>} A promise that resolves to the RLP encoded transfer data.
10696
+ */
10697
+ static encodeTransfer(token, from, to, amount, data) {
10698
+ const rlpInput = [
10699
+ token,
10700
+ // token (bytes)
10701
+ from,
10702
+ // from (bytes)
10703
+ to,
10704
+ // to (bytes)
10705
+ amount,
10706
+ // amount (uint256)
10707
+ data
10708
+ // data (bytes)
10709
+ ];
10710
+ const rlpEncodedData = rlp__namespace.encode(rlpInput);
10711
+ return `0x${Buffer.from(rlpEncodedData).toString("hex")}`;
10712
+ }
10713
+ static async simulateDeposit(params, hubProvider) {
10714
+ const chainId = getIntentRelayChainId(params.spokeChainID);
10715
+ const hubAssetManager = hubProvider.chainConfig.addresses.assetManager;
10716
+ const payload = _SpokeService.encodeTransfer(params.token, params.from, params.to, params.amount, params.data);
10717
+ return _SpokeService.simulateRecvMessage(
10718
+ { target: hubAssetManager, srcChainId: chainId, srcAddress: params.srcAddress, payload },
10719
+ hubProvider
10720
+ );
10721
+ }
10722
+ /**
10723
+ * Simulates receiving a message without signature verification.
10724
+ * This function calls simulateRecvMessage which always reverts with 'Simulation completed'.
10725
+ * @param {bigint} srcChainId - The chain ID of the originating chain.
10726
+ * @param {Hex} srcAddress - The address of the sender on the originating chain.
10727
+ * @param {Hex} payload - The encoded payload containing call data (from encodeTransfer).
10728
+ * @param {EvmHubProvider} hubProvider - The provider for the hub chain.
10729
+ * @returns {Promise<{ success: boolean; error?: string }>} Result of the simulation.
10730
+ */
10731
+ static async simulateRecvMessage(params, hubProvider) {
10732
+ try {
10733
+ const result = await hubProvider.publicClient.call({
10734
+ to: params.target,
10735
+ data: viem.encodeFunctionData({
10736
+ abi: [
10737
+ {
10738
+ name: "simulateRecvMessage",
10739
+ type: "function",
10740
+ stateMutability: "nonpayable",
10741
+ inputs: [
10742
+ { name: "srcChainId", type: "uint256" },
10743
+ { name: "srcAddress", type: "bytes" },
10744
+ { name: "payload", type: "bytes" }
10745
+ ],
10746
+ outputs: []
10747
+ }
10748
+ ],
10749
+ functionName: "simulateRecvMessage",
10750
+ args: [params.srcChainId, params.srcAddress, params.payload]
10751
+ })
10752
+ });
10753
+ console.warn("simulateRecvMessage did not revert as expected", { result });
10754
+ return {
10755
+ success: false,
10756
+ error: 'Function should have reverted with "Simulation completed"'
10757
+ };
10758
+ } catch (error) {
10759
+ if (error instanceof Error && error.message?.includes("Simulation completed")) {
10760
+ console.warn("simulateRecvMessage completed successfully with expected revert");
10761
+ return { success: true };
10762
+ }
10763
+ console.error("simulateRecvMessage failed with unexpected error:", error);
10764
+ return {
10765
+ success: false,
10766
+ error: error instanceof Error ? error.message || "Unknown simulation error" : "Unknown simulation error"
10767
+ };
10768
+ }
10769
+ }
10533
10770
  /**
10534
10771
  * Deposit tokens to the spoke chain.
10535
10772
  * @param {GetSpokeDepositParamsType<T extends SpokeProvider>} params - The parameters for the deposit, including the user's address, token address, amount, and additional data.
10536
10773
  * @param {SpokeProvider} spokeProvider - The provider for the spoke chain.
10537
10774
  * @param {EvmHubProvider} hubProvider - The provider for the hub chain.
10775
+ * @param {boolean} raw - Whether to return raw transaction data.
10776
+ * @param {boolean} skipSimulation - Whether to skip deposit simulation (optional, defaults to false).
10538
10777
  * @returns {Promise<Hash>} A promise that resolves to the transaction hash.
10539
10778
  */
10540
- static async deposit(params, spokeProvider, hubProvider, raw) {
10779
+ static async deposit(params, spokeProvider, hubProvider, raw, skipSimulation = false) {
10541
10780
  if (spokeProvider instanceof SonicSpokeProvider) {
10542
10781
  return SonicSpokeService.deposit(
10543
10782
  params,
@@ -10546,6 +10785,7 @@ var SpokeService = class {
10546
10785
  );
10547
10786
  }
10548
10787
  if (spokeProvider instanceof EvmSpokeProvider) {
10788
+ await _SpokeService.verifyDepositSimulation(params, spokeProvider, hubProvider, skipSimulation);
10549
10789
  return EvmSpokeService.deposit(
10550
10790
  params,
10551
10791
  spokeProvider,
@@ -10554,14 +10794,11 @@ var SpokeService = class {
10554
10794
  );
10555
10795
  }
10556
10796
  if (spokeProvider instanceof InjectiveSpokeProvider) {
10557
- return InjectiveSpokeService.deposit(
10558
- params,
10559
- spokeProvider,
10560
- hubProvider,
10561
- raw
10562
- );
10797
+ await _SpokeService.verifyDepositSimulation(params, spokeProvider, hubProvider, skipSimulation);
10798
+ return InjectiveSpokeService.deposit(params, spokeProvider, hubProvider, raw);
10563
10799
  }
10564
10800
  if (spokeProvider instanceof IconSpokeProvider) {
10801
+ await _SpokeService.verifyDepositSimulation(params, spokeProvider, hubProvider, skipSimulation);
10565
10802
  return IconSpokeService.deposit(
10566
10803
  params,
10567
10804
  spokeProvider,
@@ -10570,6 +10807,7 @@ var SpokeService = class {
10570
10807
  );
10571
10808
  }
10572
10809
  if (spokeProvider instanceof SuiSpokeProvider) {
10810
+ await _SpokeService.verifyDepositSimulation(params, spokeProvider, hubProvider, skipSimulation);
10573
10811
  return SuiSpokeService.deposit(
10574
10812
  params,
10575
10813
  spokeProvider,
@@ -10578,6 +10816,7 @@ var SpokeService = class {
10578
10816
  );
10579
10817
  }
10580
10818
  if (spokeProvider instanceof SolanaSpokeProvider) {
10819
+ await _SpokeService.verifyDepositSimulation(params, spokeProvider, hubProvider, skipSimulation);
10581
10820
  return SolanaSpokeService.deposit(
10582
10821
  params,
10583
10822
  spokeProvider,
@@ -10586,6 +10825,7 @@ var SpokeService = class {
10586
10825
  );
10587
10826
  }
10588
10827
  if (spokeProvider instanceof StellarSpokeProvider) {
10828
+ await _SpokeService.verifyDepositSimulation(params, spokeProvider, hubProvider, skipSimulation);
10589
10829
  return StellarSpokeService.deposit(
10590
10830
  params,
10591
10831
  spokeProvider,
@@ -10595,6 +10835,60 @@ var SpokeService = class {
10595
10835
  }
10596
10836
  throw new Error("Invalid spoke provider");
10597
10837
  }
10838
+ static getSimulateDepositParams(params, spokeProvider, hubProvider) {
10839
+ if (spokeProvider instanceof EvmSpokeProvider) {
10840
+ return EvmSpokeService.getSimulateDepositParams(
10841
+ params,
10842
+ spokeProvider,
10843
+ hubProvider
10844
+ );
10845
+ }
10846
+ if (spokeProvider instanceof InjectiveSpokeProvider) {
10847
+ return InjectiveSpokeService.getSimulateDepositParams(
10848
+ params,
10849
+ spokeProvider,
10850
+ hubProvider
10851
+ );
10852
+ }
10853
+ if (spokeProvider instanceof IconSpokeProvider) {
10854
+ return IconSpokeService.getSimulateDepositParams(
10855
+ params,
10856
+ spokeProvider,
10857
+ hubProvider
10858
+ );
10859
+ }
10860
+ if (spokeProvider instanceof SuiSpokeProvider) {
10861
+ return SuiSpokeService.getSimulateDepositParams(
10862
+ params,
10863
+ spokeProvider,
10864
+ hubProvider
10865
+ );
10866
+ }
10867
+ if (spokeProvider instanceof SolanaSpokeProvider) {
10868
+ return SolanaSpokeService.getSimulateDepositParams(
10869
+ params,
10870
+ spokeProvider,
10871
+ hubProvider
10872
+ );
10873
+ }
10874
+ if (spokeProvider instanceof StellarSpokeProvider) {
10875
+ return StellarSpokeService.getSimulateDepositParams(
10876
+ params,
10877
+ spokeProvider,
10878
+ hubProvider
10879
+ );
10880
+ }
10881
+ throw new Error("Invalid spoke provider");
10882
+ }
10883
+ static async verifyDepositSimulation(params, spokeProvider, hubProvider, skipSimulation) {
10884
+ if (!skipSimulation) {
10885
+ const simulationParams = await _SpokeService.getSimulateDepositParams(params, spokeProvider, hubProvider);
10886
+ const result = await _SpokeService.simulateDeposit(simulationParams, hubProvider);
10887
+ if (!result.success) {
10888
+ throw new Error("Simulation failed", { cause: result });
10889
+ }
10890
+ }
10891
+ }
10598
10892
  /**
10599
10893
  * Get the balance of the token in the spoke chain.
10600
10894
  * @param {Address} token - The address of the token to get the balance of.
@@ -10633,14 +10927,16 @@ var SpokeService = class {
10633
10927
  * @param {EvmHubProvider} hubProvider - The provider for the hub chain.
10634
10928
  * @returns {Promise<Hash>} A promise that resolves to the transaction hash.
10635
10929
  */
10636
- static async callWallet(from, payload, spokeProvider, hubProvider, raw) {
10930
+ static async callWallet(from, payload, spokeProvider, hubProvider, raw, skipSimulation = false) {
10637
10931
  if (isSonicSpokeProvider(spokeProvider)) {
10638
10932
  return await SonicSpokeService.callWallet(payload, spokeProvider, raw);
10639
10933
  }
10640
10934
  if (isEvmSpokeProvider(spokeProvider)) {
10935
+ await _SpokeService.verifySimulation(from, payload, spokeProvider, hubProvider, skipSimulation);
10641
10936
  return await EvmSpokeService.callWallet(from, payload, spokeProvider, hubProvider);
10642
10937
  }
10643
10938
  if (isInjectiveSpokeProvider(spokeProvider)) {
10939
+ await _SpokeService.verifySimulation(from, payload, spokeProvider, hubProvider, skipSimulation);
10644
10940
  return await InjectiveSpokeService.callWallet(
10645
10941
  from,
10646
10942
  payload,
@@ -10650,12 +10946,15 @@ var SpokeService = class {
10650
10946
  );
10651
10947
  }
10652
10948
  if (isIconSpokeProvider(spokeProvider)) {
10949
+ await _SpokeService.verifySimulation(from, payload, spokeProvider, hubProvider, skipSimulation);
10653
10950
  return await IconSpokeService.callWallet(from, payload, spokeProvider, hubProvider, raw);
10654
10951
  }
10655
10952
  if (isSuiSpokeProvider(spokeProvider)) {
10953
+ await _SpokeService.verifySimulation(from, payload, spokeProvider, hubProvider, skipSimulation);
10656
10954
  return await SuiSpokeService.callWallet(from, payload, spokeProvider, hubProvider, raw);
10657
10955
  }
10658
10956
  if (isSolanaSpokeProvider(spokeProvider)) {
10957
+ await _SpokeService.verifySimulation(from, payload, spokeProvider, hubProvider, skipSimulation);
10659
10958
  return await SolanaSpokeService.callWallet(
10660
10959
  from,
10661
10960
  payload,
@@ -10665,10 +10964,27 @@ var SpokeService = class {
10665
10964
  );
10666
10965
  }
10667
10966
  if (isStellarSpokeProvider(spokeProvider)) {
10967
+ await _SpokeService.verifySimulation(from, payload, spokeProvider, hubProvider, skipSimulation);
10668
10968
  return await StellarSpokeService.callWallet(from, payload, spokeProvider, hubProvider);
10669
10969
  }
10670
10970
  throw new Error("Invalid spoke provider");
10671
10971
  }
10972
+ static async verifySimulation(from, payload, spokeProvider, hubProvider, skipSimulation) {
10973
+ if (!skipSimulation) {
10974
+ const result = await _SpokeService.simulateRecvMessage(
10975
+ {
10976
+ target: from,
10977
+ srcChainId: getIntentRelayChainId(spokeProvider.chainConfig.chain.id),
10978
+ srcAddress: await spokeProvider.walletProvider.getWalletAddressBytes(),
10979
+ payload
10980
+ },
10981
+ hubProvider
10982
+ );
10983
+ if (!result.success) {
10984
+ throw new Error("Simulation failed", { cause: result });
10985
+ }
10986
+ }
10987
+ }
10672
10988
  };
10673
10989
  async function postRequest(payload, apiUrl) {
10674
10990
  const response = await retry(
@@ -10820,8 +11136,11 @@ var EvmSolverService = class _EvmSolverService {
10820
11136
  * @param {PartnerFee} fee - The partner fee configuration
10821
11137
  * @returns {Promise<[Hex, Intent, bigint]>} The encoded contract call, intent and fee amount
10822
11138
  */
10823
- static constructCreateIntentData(createIntentParams, creatorHubWalletAddress, solverConfig2, fee) {
10824
- const inputToken = getHubAssetInfo(createIntentParams.srcChain, createIntentParams.inputToken)?.asset;
11139
+ static constructCreateIntentData(createIntentParams, creatorHubWalletAddress, solverConfig2, fee, hubProvider) {
11140
+ let inputToken = getHubAssetInfo(createIntentParams.srcChain, createIntentParams.inputToken)?.asset;
11141
+ if (createIntentParams.srcChain === hubProvider.chainConfig.chain.id && createIntentParams.inputToken.toLowerCase() === hubProvider.chainConfig.nativeToken.toLowerCase()) {
11142
+ inputToken = hubProvider.chainConfig.wrappedNativeToken;
11143
+ }
10825
11144
  const outputToken = getHubAssetInfo(createIntentParams.dstChain, createIntentParams.outputToken)?.asset;
10826
11145
  invariant10__default.default(
10827
11146
  inputToken,
@@ -11373,13 +11692,15 @@ var SolverService = class {
11373
11692
  intentParams: params,
11374
11693
  spokeProvider,
11375
11694
  fee = this.config.partnerFee,
11376
- timeout = DEFAULT_RELAY_TX_TIMEOUT
11695
+ timeout = DEFAULT_RELAY_TX_TIMEOUT,
11696
+ skipSimulation = false
11377
11697
  }) {
11378
11698
  return this.createAndSubmitIntent({
11379
11699
  intentParams: params,
11380
11700
  spokeProvider,
11381
11701
  fee,
11382
- timeout
11702
+ timeout,
11703
+ skipSimulation
11383
11704
  });
11384
11705
  }
11385
11706
  /**
@@ -11428,14 +11749,16 @@ var SolverService = class {
11428
11749
  intentParams: params,
11429
11750
  spokeProvider,
11430
11751
  fee = this.config.partnerFee,
11431
- timeout = DEFAULT_RELAY_TX_TIMEOUT
11752
+ timeout = DEFAULT_RELAY_TX_TIMEOUT,
11753
+ skipSimulation = false
11432
11754
  }) {
11433
11755
  try {
11434
11756
  const createIntentResult = await this.createIntent({
11435
11757
  intentParams: params,
11436
11758
  spokeProvider,
11437
11759
  fee,
11438
- raw: false
11760
+ raw: false,
11761
+ skipSimulation
11439
11762
  });
11440
11763
  if (!createIntentResult.ok) {
11441
11764
  return createIntentResult;
@@ -11723,7 +12046,8 @@ var SolverService = class {
11723
12046
  },
11724
12047
  creatorHubWalletAddress,
11725
12048
  this.config,
11726
- fee
12049
+ fee,
12050
+ this.hubProvider
11727
12051
  );
11728
12052
  const txResult = await SpokeService.deposit(
11729
12053
  {