@sodax/sdk 0.0.1-rc.16 → 0.0.1-rc.17

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
@@ -6214,8 +6214,8 @@ var spokeChainConfig = {
6214
6214
  nativeToken: "0x0000000000000000000000000000000000000000",
6215
6215
  bnUSD: "0x6958a4CBFe11406E2a1c1d3a71A1971aD8B3b92F",
6216
6216
  supportedTokens: {
6217
- Sonic: {
6218
- symbol: "Sonic",
6217
+ S: {
6218
+ symbol: "S",
6219
6219
  name: "Sonic",
6220
6220
  decimals: 18,
6221
6221
  address: "0x0000000000000000000000000000000000000000"
@@ -6238,8 +6238,8 @@ var spokeChainConfig = {
6238
6238
  decimals: 6,
6239
6239
  address: "0x6047828dc181963ba44974801FF68e538dA5eaF9"
6240
6240
  },
6241
- wSonic: {
6242
- symbol: "wSonic",
6241
+ wS: {
6242
+ symbol: "wS",
6243
6243
  name: "Wrapped Sonic",
6244
6244
  decimals: 18,
6245
6245
  address: "0x039e2fB66102314Ce7b64Ce5Ce3E5183bc94aD38"
@@ -7003,42 +7003,42 @@ var hubVaults = {
7003
7003
  var hubAssets = {
7004
7004
  [SONIC_MAINNET_CHAIN_ID]: {
7005
7005
  [spokeChainConfig[SONIC_MAINNET_CHAIN_ID].nativeToken]: {
7006
- asset: "0x039e2fB66102314Ce7b64Ce5Ce3E5183bc94aD38",
7006
+ asset: spokeChainConfig[SONIC_MAINNET_CHAIN_ID].supportedTokens.wS.address,
7007
7007
  decimal: 18,
7008
7008
  symbol: "S",
7009
7009
  name: "Sonic",
7010
7010
  vault: hubVaults.sodaS.address
7011
7011
  },
7012
- [spokeChainConfig[SONIC_MAINNET_CHAIN_ID].supportedTokens.wSonic.address]: {
7013
- asset: "0x039e2fB66102314Ce7b64Ce5Ce3E5183bc94aD38",
7012
+ [spokeChainConfig[SONIC_MAINNET_CHAIN_ID].supportedTokens.wS.address]: {
7013
+ asset: spokeChainConfig[SONIC_MAINNET_CHAIN_ID].supportedTokens.wS.address,
7014
7014
  decimal: 18,
7015
- symbol: "wSonic",
7015
+ symbol: "wS",
7016
7016
  name: "Sonic",
7017
7017
  vault: hubVaults.sodaS.address
7018
7018
  },
7019
7019
  [spokeChainConfig[SONIC_MAINNET_CHAIN_ID].supportedTokens.WETH.address]: {
7020
- asset: "0x50c42dEAcD8Fc9773493ED674b675bE577f2634b",
7020
+ asset: spokeChainConfig[SONIC_MAINNET_CHAIN_ID].supportedTokens.WETH.address,
7021
7021
  decimal: 18,
7022
7022
  symbol: "WETH",
7023
7023
  name: "Wrapped Ethereum",
7024
7024
  vault: hubVaults.sodaETH.address
7025
7025
  },
7026
7026
  [spokeChainConfig[SONIC_MAINNET_CHAIN_ID].supportedTokens.USDC.address]: {
7027
- asset: "0x29219dd400f2Bf60E5a23d13Be72B486D4038894",
7027
+ asset: spokeChainConfig[SONIC_MAINNET_CHAIN_ID].supportedTokens.USDC.address,
7028
7028
  decimal: 6,
7029
7029
  symbol: "USDC ",
7030
7030
  name: "USD Coin",
7031
7031
  vault: hubVaults.sodaUSDC.address
7032
7032
  },
7033
7033
  [spokeChainConfig[SONIC_MAINNET_CHAIN_ID].supportedTokens.USDT.address]: {
7034
- asset: "0x6047828dc181963ba44974801ff68e538da5eaf9",
7034
+ asset: spokeChainConfig[SONIC_MAINNET_CHAIN_ID].supportedTokens.USDT.address,
7035
7035
  decimal: 6,
7036
7036
  symbol: "USDT",
7037
7037
  name: "Tether USD",
7038
7038
  vault: hubVaults.sodaUSDT.address
7039
7039
  },
7040
7040
  [spokeChainConfig[SONIC_MAINNET_CHAIN_ID].supportedTokens.SODA.address]: {
7041
- asset: "0x7c7d53EEcda37a87ce0D5bf8E0b24512A48dC963",
7041
+ asset: spokeChainConfig[SONIC_MAINNET_CHAIN_ID].supportedTokens.SODA.address,
7042
7042
  decimal: 18,
7043
7043
  symbol: "SODA",
7044
7044
  name: "SODA",
@@ -7500,10 +7500,11 @@ var solverConfig = {
7500
7500
  var getSolverConfig = (chainId) => solverConfig[chainId];
7501
7501
  var solverSupportedTokens = {
7502
7502
  [SONIC_MAINNET_CHAIN_ID]: [
7503
- // spokeChainConfig[SONIC_MAINNET_CHAIN_ID].supportedTokens.WETH, // NOTE: Planned for next release (1 - 2 weeks)
7504
- // spokeChainConfig[SONIC_MAINNET_CHAIN_ID].supportedTokens.USDC, // NOTE: Planned for next release (1 - 2 weeks)
7505
- // spokeChainConfig[SONIC_MAINNET_CHAIN_ID].supportedTokens.USDT, // NOTE: Planned for next release (1 - 2 weeks)
7506
- // spokeChainConfig[SONIC_MAINNET_CHAIN_ID].supportedTokens.wSonic, // NOTE: Planned for next release (1 - 2 weeks)
7503
+ spokeChainConfig[SONIC_MAINNET_CHAIN_ID].supportedTokens.S,
7504
+ spokeChainConfig[SONIC_MAINNET_CHAIN_ID].supportedTokens.WETH,
7505
+ spokeChainConfig[SONIC_MAINNET_CHAIN_ID].supportedTokens.USDC,
7506
+ spokeChainConfig[SONIC_MAINNET_CHAIN_ID].supportedTokens.USDT,
7507
+ spokeChainConfig[SONIC_MAINNET_CHAIN_ID].supportedTokens.wS
7507
7508
  ],
7508
7509
  [AVALANCHE_MAINNET_CHAIN_ID]: [
7509
7510
  spokeChainConfig[AVALANCHE_MAINNET_CHAIN_ID].supportedTokens.AVAX,
@@ -7670,11 +7671,11 @@ var moneyMarketSupportedTokens = {
7670
7671
  ],
7671
7672
  [NIBIRU_MAINNET_CHAIN_ID]: [],
7672
7673
  [SONIC_MAINNET_CHAIN_ID]: [
7673
- spokeChainConfig[SONIC_MAINNET_CHAIN_ID].supportedTokens.Sonic,
7674
+ spokeChainConfig[SONIC_MAINNET_CHAIN_ID].supportedTokens.S,
7674
7675
  spokeChainConfig[SONIC_MAINNET_CHAIN_ID].supportedTokens.WETH,
7675
7676
  spokeChainConfig[SONIC_MAINNET_CHAIN_ID].supportedTokens.USDC,
7676
7677
  spokeChainConfig[SONIC_MAINNET_CHAIN_ID].supportedTokens.USDT,
7677
- spokeChainConfig[SONIC_MAINNET_CHAIN_ID].supportedTokens.wSonic
7678
+ spokeChainConfig[SONIC_MAINNET_CHAIN_ID].supportedTokens.wS
7678
7679
  ]
7679
7680
  };
7680
7681
  var migrationConfig = {
@@ -9025,16 +9026,28 @@ var EvmWalletAbstraction = class {
9025
9026
  var WalletAbstractionService = class {
9026
9027
  constructor() {
9027
9028
  }
9028
- static async getUserHubWalletAddress(chainId, address, hubProvider, spokeProvider) {
9029
- if (chainId === hubProvider.chainConfig.chain.id) {
9029
+ /**
9030
+ * Gets the hub wallet address for a user based on their spoke chain address.
9031
+ * @param address - The user's address on the spoke chain
9032
+ * @param spokeProvider - The provider for interacting with the spoke chain
9033
+ * @param hubProvider - The provider for interacting with the hub chain
9034
+ * @returns The user's hub wallet address
9035
+ */
9036
+ static async getUserHubWalletAddress(address, spokeProvider, hubProvider) {
9037
+ const encodedAddress = encodeAddress(spokeProvider.chainConfig.chain.id, address);
9038
+ if (spokeProvider.chainConfig.chain.id === hubProvider.chainConfig.chain.id) {
9030
9039
  if (spokeProvider instanceof SonicSpokeProvider) {
9031
- return SonicSpokeService.getUserRouter(address, spokeProvider);
9040
+ return SonicSpokeService.getUserRouter(encodedAddress, spokeProvider);
9032
9041
  }
9033
9042
  throw new Error(
9034
9043
  "[WalletAbstractionService.getUserHubWalletAddress] Invalid spoke provider. Sonic spoke provider is required."
9035
9044
  );
9036
9045
  }
9037
- return EvmWalletAbstraction.getUserHubWalletAddress(chainId, address, hubProvider);
9046
+ return EvmWalletAbstraction.getUserHubWalletAddress(
9047
+ spokeProvider.chainConfig.chain.id,
9048
+ encodedAddress,
9049
+ hubProvider
9050
+ );
9038
9051
  }
9039
9052
  };
9040
9053
  async function retry(action, retryCount = DEFAULT_MAX_RETRY, delayMs = DEFAULT_RETRY_DELAY_MS) {
@@ -9412,26 +9425,32 @@ var MoneyMarketService = class _MoneyMarketService {
9412
9425
  if (!txResult.ok) {
9413
9426
  return txResult;
9414
9427
  }
9415
- const packetResult = await relayTxAndWaitPacket(
9416
- txResult.value,
9417
- spokeProvider instanceof SolanaSpokeProvider ? txResult.data : void 0,
9418
- spokeProvider,
9419
- this.config.relayerApiEndpoint,
9420
- timeout
9421
- );
9422
- if (!packetResult.ok) {
9423
- return {
9424
- ok: false,
9425
- error: {
9426
- code: packetResult.error.code,
9427
- data: {
9428
- error: packetResult.error,
9429
- payload: txResult.value
9428
+ let intentTxHash = null;
9429
+ if (spokeProvider.chainConfig.chain.id !== SONIC_MAINNET_CHAIN_ID) {
9430
+ const packetResult = await relayTxAndWaitPacket(
9431
+ txResult.value,
9432
+ spokeProvider instanceof SolanaSpokeProvider ? txResult.data : void 0,
9433
+ spokeProvider,
9434
+ this.config.relayerApiEndpoint,
9435
+ timeout
9436
+ );
9437
+ if (!packetResult.ok) {
9438
+ return {
9439
+ ok: false,
9440
+ error: {
9441
+ code: packetResult.error.code,
9442
+ data: {
9443
+ error: packetResult.error,
9444
+ payload: txResult.value
9445
+ }
9430
9446
  }
9431
- }
9432
- };
9447
+ };
9448
+ }
9449
+ intentTxHash = packetResult.value.dst_tx_hash;
9450
+ } else {
9451
+ intentTxHash = txResult.value;
9433
9452
  }
9434
- return { ok: true, value: [txResult.value, packetResult.value.dst_tx_hash] };
9453
+ return { ok: true, value: [txResult.value, intentTxHash] };
9435
9454
  } catch (error) {
9436
9455
  return {
9437
9456
  ok: false,
@@ -9486,12 +9505,11 @@ var MoneyMarketService = class _MoneyMarketService {
9486
9505
  isMoneyMarketSupportedToken(spokeProvider.chainConfig.chain.id, params.token),
9487
9506
  `Unsupported spoke chain (${spokeProvider.chainConfig.chain.id}) token: ${params.token}`
9488
9507
  );
9489
- const walletAddressBytes = await spokeProvider.walletProvider.getWalletAddressBytes();
9508
+ const walletAddress = await spokeProvider.walletProvider.getWalletAddress();
9490
9509
  const hubWallet = await WalletAbstractionService.getUserHubWalletAddress(
9491
- spokeProvider.chainConfig.chain.id,
9492
- walletAddressBytes,
9493
- this.hubProvider,
9494
- spokeProvider
9510
+ walletAddress,
9511
+ spokeProvider,
9512
+ this.hubProvider
9495
9513
  );
9496
9514
  const data = this.buildSupplyData(
9497
9515
  params.token,
@@ -9499,7 +9517,6 @@ var MoneyMarketService = class _MoneyMarketService {
9499
9517
  params.amount,
9500
9518
  spokeProvider.chainConfig.chain.id
9501
9519
  );
9502
- const walletAddress = await spokeProvider.walletProvider.getWalletAddress();
9503
9520
  const txResult = await SpokeService.deposit(
9504
9521
  {
9505
9522
  from: walletAddress,
@@ -9566,26 +9583,32 @@ var MoneyMarketService = class _MoneyMarketService {
9566
9583
  if (!txResult.ok) {
9567
9584
  return txResult;
9568
9585
  }
9569
- const packetResult = await relayTxAndWaitPacket(
9570
- txResult.value,
9571
- spokeProvider instanceof SolanaSpokeProvider ? txResult.data : void 0,
9572
- spokeProvider,
9573
- this.config.relayerApiEndpoint,
9574
- timeout
9575
- );
9576
- if (!packetResult.ok) {
9577
- return {
9578
- ok: false,
9579
- error: {
9580
- code: packetResult.error.code,
9581
- data: {
9582
- error: packetResult.error,
9583
- payload: txResult.value
9586
+ let intentTxHash = null;
9587
+ if (spokeProvider.chainConfig.chain.id !== SONIC_MAINNET_CHAIN_ID) {
9588
+ const packetResult = await relayTxAndWaitPacket(
9589
+ txResult.value,
9590
+ spokeProvider instanceof SolanaSpokeProvider ? txResult.data : void 0,
9591
+ spokeProvider,
9592
+ this.config.relayerApiEndpoint,
9593
+ timeout
9594
+ );
9595
+ if (!packetResult.ok) {
9596
+ return {
9597
+ ok: false,
9598
+ error: {
9599
+ code: packetResult.error.code,
9600
+ data: {
9601
+ error: packetResult.error,
9602
+ payload: txResult.value
9603
+ }
9584
9604
  }
9585
- }
9586
- };
9605
+ };
9606
+ }
9607
+ intentTxHash = packetResult.value.dst_tx_hash;
9608
+ } else {
9609
+ intentTxHash = txResult.value;
9587
9610
  }
9588
- return { ok: true, value: [txResult.value, packetResult.value.dst_tx_hash] };
9611
+ return { ok: true, value: [txResult.value, intentTxHash] };
9589
9612
  } catch (error) {
9590
9613
  return {
9591
9614
  ok: false,
@@ -9637,16 +9660,16 @@ var MoneyMarketService = class _MoneyMarketService {
9637
9660
  isMoneyMarketSupportedToken(spokeProvider.chainConfig.chain.id, params.token),
9638
9661
  `Unsupported spoke chain (${spokeProvider.chainConfig.chain.id}) token: ${params.token}`
9639
9662
  );
9640
- const walletAddressBytes = await spokeProvider.walletProvider.getWalletAddressBytes();
9663
+ const walletAddress = await spokeProvider.walletProvider.getWalletAddress();
9664
+ const encodedAddress = encodeAddress(spokeProvider.chainConfig.chain.id, walletAddress);
9641
9665
  const hubWallet = await WalletAbstractionService.getUserHubWalletAddress(
9642
- spokeProvider.chainConfig.chain.id,
9643
- walletAddressBytes,
9644
- this.hubProvider,
9645
- spokeProvider
9666
+ walletAddress,
9667
+ spokeProvider,
9668
+ this.hubProvider
9646
9669
  );
9647
9670
  const data = this.buildBorrowData(
9648
9671
  hubWallet,
9649
- walletAddressBytes,
9672
+ encodedAddress,
9650
9673
  params.token,
9651
9674
  params.amount,
9652
9675
  spokeProvider.chainConfig.chain.id
@@ -9695,26 +9718,32 @@ var MoneyMarketService = class _MoneyMarketService {
9695
9718
  if (!txResult.ok) {
9696
9719
  return txResult;
9697
9720
  }
9698
- const packetResult = await relayTxAndWaitPacket(
9699
- txResult.value,
9700
- spokeProvider instanceof SolanaSpokeProvider ? txResult.data : void 0,
9701
- spokeProvider,
9702
- this.config.relayerApiEndpoint,
9703
- timeout
9704
- );
9705
- if (!packetResult.ok) {
9706
- return {
9707
- ok: false,
9708
- error: {
9709
- code: packetResult.error.code,
9710
- data: {
9711
- error: packetResult.error,
9712
- payload: txResult.value
9721
+ let intentTxHash = null;
9722
+ if (spokeProvider.chainConfig.chain.id !== SONIC_MAINNET_CHAIN_ID) {
9723
+ const packetResult = await relayTxAndWaitPacket(
9724
+ txResult.value,
9725
+ spokeProvider instanceof SolanaSpokeProvider ? txResult.data : void 0,
9726
+ spokeProvider,
9727
+ this.config.relayerApiEndpoint,
9728
+ timeout
9729
+ );
9730
+ if (!packetResult.ok) {
9731
+ return {
9732
+ ok: false,
9733
+ error: {
9734
+ code: packetResult.error.code,
9735
+ data: {
9736
+ error: packetResult.error,
9737
+ payload: txResult.value
9738
+ }
9713
9739
  }
9714
- }
9715
- };
9740
+ };
9741
+ }
9742
+ intentTxHash = packetResult.value.dst_tx_hash;
9743
+ } else {
9744
+ intentTxHash = txResult.value;
9716
9745
  }
9717
- return { ok: true, value: [txResult.value, packetResult.value.dst_tx_hash] };
9746
+ return { ok: true, value: [txResult.value, intentTxHash] };
9718
9747
  } catch (error) {
9719
9748
  return {
9720
9749
  ok: false,
@@ -9766,16 +9795,16 @@ var MoneyMarketService = class _MoneyMarketService {
9766
9795
  isMoneyMarketSupportedToken(spokeProvider.chainConfig.chain.id, params.token),
9767
9796
  `Unsupported spoke chain (${spokeProvider.chainConfig.chain.id}) token: ${params.token}`
9768
9797
  );
9769
- const walletAddressBytes = await spokeProvider.walletProvider.getWalletAddressBytes();
9798
+ const walletAddress = await spokeProvider.walletProvider.getWalletAddress();
9799
+ const encodedAddress = encodeAddress(spokeProvider.chainConfig.chain.id, walletAddress);
9770
9800
  const hubWallet = await WalletAbstractionService.getUserHubWalletAddress(
9771
- spokeProvider.chainConfig.chain.id,
9772
- walletAddressBytes,
9773
- this.hubProvider,
9774
- spokeProvider
9801
+ walletAddress,
9802
+ spokeProvider,
9803
+ this.hubProvider
9775
9804
  );
9776
9805
  const data = this.buildWithdrawData(
9777
9806
  hubWallet,
9778
- walletAddressBytes,
9807
+ encodedAddress,
9779
9808
  params.token,
9780
9809
  params.amount,
9781
9810
  spokeProvider.chainConfig.chain.id
@@ -9824,26 +9853,32 @@ var MoneyMarketService = class _MoneyMarketService {
9824
9853
  if (!txResult.ok) {
9825
9854
  return txResult;
9826
9855
  }
9827
- const packetResult = await relayTxAndWaitPacket(
9828
- txResult.value,
9829
- spokeProvider instanceof SolanaSpokeProvider ? txResult.data : void 0,
9830
- spokeProvider,
9831
- this.config.relayerApiEndpoint,
9832
- timeout
9833
- );
9834
- if (!packetResult.ok) {
9835
- return {
9836
- ok: false,
9837
- error: {
9838
- code: packetResult.error.code,
9839
- data: {
9840
- error: packetResult.error,
9841
- payload: txResult.value
9856
+ let intentTxHash = null;
9857
+ if (spokeProvider.chainConfig.chain.id !== SONIC_MAINNET_CHAIN_ID) {
9858
+ const packetResult = await relayTxAndWaitPacket(
9859
+ txResult.value,
9860
+ spokeProvider instanceof SolanaSpokeProvider ? txResult.data : void 0,
9861
+ spokeProvider,
9862
+ this.config.relayerApiEndpoint,
9863
+ timeout
9864
+ );
9865
+ if (!packetResult.ok) {
9866
+ return {
9867
+ ok: false,
9868
+ error: {
9869
+ code: packetResult.error.code,
9870
+ data: {
9871
+ error: packetResult.error,
9872
+ payload: txResult.value
9873
+ }
9842
9874
  }
9843
- }
9844
- };
9875
+ };
9876
+ }
9877
+ intentTxHash = packetResult.value.dst_tx_hash;
9878
+ } else {
9879
+ intentTxHash = txResult.value;
9845
9880
  }
9846
- return { ok: true, value: [txResult.value, packetResult.value.dst_tx_hash] };
9881
+ return { ok: true, value: [txResult.value, intentTxHash] };
9847
9882
  } catch (error) {
9848
9883
  return {
9849
9884
  ok: false,
@@ -9897,15 +9932,13 @@ var MoneyMarketService = class _MoneyMarketService {
9897
9932
  isMoneyMarketSupportedToken(spokeProvider.chainConfig.chain.id, params.token),
9898
9933
  `Unsupported spoke chain (${spokeProvider.chainConfig.chain.id}) token: ${params.token}`
9899
9934
  );
9900
- const walletAddressBytes = await spokeProvider.walletProvider.getWalletAddressBytes();
9935
+ const walletAddress = await spokeProvider.walletProvider.getWalletAddress();
9901
9936
  const hubWallet = await WalletAbstractionService.getUserHubWalletAddress(
9902
- spokeProvider.chainConfig.chain.id,
9903
- walletAddressBytes,
9904
- this.hubProvider,
9905
- spokeProvider
9937
+ walletAddress,
9938
+ spokeProvider,
9939
+ this.hubProvider
9906
9940
  );
9907
9941
  const data = this.buildRepayData(params.token, hubWallet, params.amount, spokeProvider.chainConfig.chain.id);
9908
- const walletAddress = await spokeProvider.walletProvider.getWalletAddress();
9909
9942
  const txResult = await SpokeService.deposit(
9910
9943
  {
9911
9944
  from: walletAddress,
@@ -12504,7 +12537,7 @@ var SolverService = class {
12504
12537
  * @param {CreateIntentParams} payload - The intent to create
12505
12538
  * @param {ISpokeProvider} spokeProvider - The spoke provider
12506
12539
  * @param {number} timeout - The timeout in milliseconds for the transaction. Default is 60 seconds.
12507
- * @returns {Promise<Result<[SolverExecutionResponse, Intent, PacketData], IntentError<IntentErrorCode>>>} The solver execution response, intent, and packet data
12540
+ * @returns {Promise<Result<[SolverExecutionResponse, Intent, Hex], IntentError<IntentErrorCode>>>} The solver execution response, intent, and packet data
12508
12541
  *
12509
12542
  * @example
12510
12543
  * const payload = {
@@ -12540,42 +12573,48 @@ var SolverService = class {
12540
12573
  return createIntentResult;
12541
12574
  }
12542
12575
  const [spokeTxHash, intent, data] = createIntentResult.value;
12543
- const intentRelayChainId = getIntentRelayChainId(payload.srcChain).toString();
12544
- const submitPayload = payload.srcChain === SOLANA_MAINNET_CHAIN_ID && data ? {
12545
- action: "submit",
12546
- params: {
12547
- chain_id: intentRelayChainId,
12548
- tx_hash: spokeTxHash,
12549
- data: {
12550
- address: intent.creator,
12551
- payload: data
12576
+ let intentTxHash = null;
12577
+ if (spokeProvider.chainConfig.chain.id !== SONIC_MAINNET_CHAIN_ID) {
12578
+ const intentRelayChainId = getIntentRelayChainId(payload.srcChain).toString();
12579
+ const submitPayload = payload.srcChain === SOLANA_MAINNET_CHAIN_ID && data ? {
12580
+ action: "submit",
12581
+ params: {
12582
+ chain_id: intentRelayChainId,
12583
+ tx_hash: spokeTxHash,
12584
+ data: {
12585
+ address: intent.creator,
12586
+ payload: data
12587
+ }
12552
12588
  }
12589
+ } : {
12590
+ action: "submit",
12591
+ params: {
12592
+ chain_id: intentRelayChainId,
12593
+ tx_hash: spokeTxHash
12594
+ }
12595
+ };
12596
+ const submitResult = await this.submitIntent(submitPayload);
12597
+ if (!submitResult.ok) {
12598
+ return submitResult;
12553
12599
  }
12554
- } : {
12555
- action: "submit",
12556
- params: {
12557
- chain_id: intentRelayChainId,
12558
- tx_hash: spokeTxHash
12600
+ const packet = await waitUntilIntentExecuted({
12601
+ intentRelayChainId,
12602
+ spokeTxHash,
12603
+ timeout,
12604
+ apiUrl: this.config.relayerApiEndpoint
12605
+ });
12606
+ if (!packet.ok) {
12607
+ return {
12608
+ ok: false,
12609
+ error: packet.error
12610
+ };
12559
12611
  }
12560
- };
12561
- const submitResult = await this.submitIntent(submitPayload);
12562
- if (!submitResult.ok) {
12563
- return submitResult;
12564
- }
12565
- const packet = await waitUntilIntentExecuted({
12566
- intentRelayChainId,
12567
- spokeTxHash,
12568
- timeout,
12569
- apiUrl: this.config.relayerApiEndpoint
12570
- });
12571
- if (!packet.ok) {
12572
- return {
12573
- ok: false,
12574
- error: packet.error
12575
- };
12612
+ intentTxHash = packet.value.dst_tx_hash;
12613
+ } else {
12614
+ intentTxHash = spokeTxHash;
12576
12615
  }
12577
12616
  const result = await this.postExecution({
12578
- intent_tx_hash: packet.value.dst_tx_hash
12617
+ intent_tx_hash: intentTxHash
12579
12618
  });
12580
12619
  if (!result.ok) {
12581
12620
  return {
@@ -12588,7 +12627,7 @@ var SolverService = class {
12588
12627
  }
12589
12628
  return {
12590
12629
  ok: true,
12591
- value: [result.value, intent, packet.value]
12630
+ value: [result.value, intent, intentTxHash]
12592
12631
  };
12593
12632
  } catch (error) {
12594
12633
  return {
@@ -12758,12 +12797,7 @@ var SolverService = class {
12758
12797
  "srcAddress must be the same as wallet address"
12759
12798
  );
12760
12799
  const walletAddressBytes = encodeAddress(params.srcChain, walletAddress);
12761
- const creatorHubWalletAddress = spokeProvider.chainConfig.chain.id === this.hubProvider.chainConfig.chain.id ? walletAddressBytes : await WalletAbstractionService.getUserHubWalletAddress(
12762
- params.srcChain,
12763
- walletAddressBytes,
12764
- this.hubProvider,
12765
- spokeProvider
12766
- );
12800
+ const creatorHubWalletAddress = spokeProvider.chainConfig.chain.id === this.hubProvider.chainConfig.chain.id ? walletAddressBytes : await WalletAbstractionService.getUserHubWalletAddress(walletAddress, spokeProvider, this.hubProvider);
12767
12801
  const [data, intent, feeAmount] = EvmSolverService.constructCreateIntentData(
12768
12802
  {
12769
12803
  ...params,
@@ -12813,13 +12847,9 @@ var SolverService = class {
12813
12847
  try {
12814
12848
  invariant2(isValidIntentRelayChainId(intent.srcChain), `Invalid intent.srcChain: ${intent.srcChain}`);
12815
12849
  invariant2(isValidIntentRelayChainId(intent.dstChain), `Invalid intent.dstChain: ${intent.dstChain}`);
12816
- const walletAddressBytes = await spokeProvider.walletProvider.getWalletAddressBytes();
12817
- const creatorHubWalletAddress = spokeProvider.chainConfig.chain.id === this.hubProvider.chainConfig.chain.id ? walletAddressBytes : await WalletAbstractionService.getUserHubWalletAddress(
12818
- spokeProvider.chainConfig.chain.id,
12819
- walletAddressBytes,
12820
- this.hubProvider,
12821
- spokeProvider
12822
- );
12850
+ const walletAddress = await spokeProvider.walletProvider.getWalletAddress();
12851
+ const walletAddressBytes = encodeAddress(spokeProvider.chainConfig.chain.id, walletAddress);
12852
+ const creatorHubWalletAddress = spokeProvider.chainConfig.chain.id === this.hubProvider.chainConfig.chain.id ? walletAddressBytes : await WalletAbstractionService.getUserHubWalletAddress(walletAddress, spokeProvider, this.hubProvider);
12823
12853
  const calls = [];
12824
12854
  const intentsContract = this.config.intentsContract;
12825
12855
  calls.push(EvmSolverService.encodeCancelIntent(intent, intentsContract));
@@ -14538,6 +14568,6 @@ var SolverIntentErrorCode = /* @__PURE__ */ ((SolverIntentErrorCode2) => {
14538
14568
  return SolverIntentErrorCode2;
14539
14569
  })(SolverIntentErrorCode || {});
14540
14570
 
14541
- export { BalnSwapService, BigIntToHex, BnUSDMigrationService, DEFAULT_MAX_RETRY, DEFAULT_RELAYER_API_ENDPOINT, DEFAULT_RELAY_TX_TIMEOUT, DEFAULT_RETRY_DELAY_MS, EVM_CHAIN_IDS, EVM_SPOKE_CHAIN_IDS, Erc20Service, EvmAssetManagerService, EvmHubProvider, EvmSolverService, EvmSpokeProvider, EvmSpokeService, EvmVaultTokenService, EvmWalletAbstraction, FEE_PERCENTAGE_SCALE, HubVaultSymbols, ICON_TX_RESULT_WAIT_MAX_RETRY, INTENT_RELAY_CHAIN_IDS, IconSpokeProvider, IcxMigrationService, InjectiveSpokeProvider, IntentCreatedEventAbi, IntentDataType, IntentsAbi, LockupMultiplier, LockupPeriod, MAX_UINT256, MigrationService, MoneyMarketService, STELLAR_DEFAULT_TX_TIMEOUT_SECONDS, STELLAR_PRIORITY_FEE, Sodax, SolanaSpokeProvider, SolverIntentErrorCode, SolverIntentStatusCode, SolverService, SonicSpokeProvider, SonicSpokeService, SpokeService, StellarSpokeProvider, SuiSpokeProvider, SupportedMigrationTokens, VAULT_TOKEN_DECIMALS, WalletAbstractionService, assetManagerAbi, balnSwapAbi, calculateFeeAmount, calculatePercentageFeeAmount, chainIdToHubAssetsMap, connectionAbi, encodeAddress, encodeContractCalls, erc20Abi, getEvmViemChain, getHubAssetInfo, getHubChainConfig, getIconAddressBytes, getIntentRelayChainId, getMoneyMarketConfig, getOriginalAssetAddress, getPacket, getRandomBytes, getSolanaAddressBytes, getSolverConfig, getSpokeChainIdFromIntentRelayChainId, getSupportedMoneyMarketTokens, getSupportedSolverTokens, getTransactionPackets, hexToBigInt, hubAssetToOriginalAssetMap, hubAssets, hubVaults, hubVaultsAddressSet, intentRelayChainIdToSpokeChainIdMap, isConfiguredMoneyMarketConfig, isConfiguredSolverConfig, isEvmHubChainConfig, isEvmInitializedConfig, isEvmSpokeChainConfig, isEvmSpokeProvider, isEvmUninitializedBrowserConfig, isEvmUninitializedConfig, isEvmUninitializedPrivateKeyConfig, isIconAddress, isIconSpokeProvider, isInjectiveSpokeProvider, isIntentCreationFailedError, isIntentCreationUnknownError, isIntentPostExecutionFailedError, isIntentRelayChainId, isIntentSubmitTxFailedError, isJsonRpcPayloadResponse, isMoneyMarketBorrowUnknownError, isMoneyMarketCreateBorrowIntentFailedError, isMoneyMarketCreateRepayIntentFailedError, isMoneyMarketCreateSupplyIntentFailedError, isMoneyMarketCreateWithdrawIntentFailedError, isMoneyMarketRelayTimeoutError, isMoneyMarketRepayUnknownError, isMoneyMarketReserveAsset, isMoneyMarketReserveHubAsset, isMoneyMarketSubmitTxFailedError, isMoneyMarketSupplyUnknownError, isMoneyMarketSupportedToken, isMoneyMarketWithdrawUnknownError, isNativeToken, isPartnerFeeAmount, isPartnerFeePercentage, isResponseAddressType, isResponseSigningType, isSolanaSpokeProvider, isSolverSupportedToken, isSonicSpokeProvider, isStellarSpokeProvider, isSuiSpokeProvider, isValidChainHubAsset, isValidHubAsset, isValidIntentRelayChainId, isValidOriginalAssetAddress, isValidSpokeChainId, isWaitUntilIntentExecutedFailed, migrationConfig, moneyMarketReserveAssets, moneyMarketReserveHubAssetsSet, moneyMarketSupportedTokens, originalAssetTohubAssetMap, poolAbi, randomUint256, relayTxAndWaitPacket, requestAddress, requestJsonRpc, requestSigning, retry, sonicWalletFactoryAbi, spokeAssetManagerAbi, spokeChainConfig, spokeChainIdsSet, submitTransaction, supportedHubAssets, supportedHubChains, supportedSpokeChains, supportedTokensPerChain, uiPoolDataAbi, variableDebtTokenAbi, vaultTokenAbi, waitForTransactionReceipt, waitUntilIntentExecuted, walletFactoryAbi, wrappedSonicAbi };
14571
+ export { BalnSwapService, BigIntToHex, BnUSDMigrationService, ChainIdToIntentRelayChainId, DEFAULT_MAX_RETRY, DEFAULT_RELAYER_API_ENDPOINT, DEFAULT_RELAY_TX_TIMEOUT, DEFAULT_RETRY_DELAY_MS, EVM_CHAIN_IDS, EVM_SPOKE_CHAIN_IDS, Erc20Service, EvmAssetManagerService, EvmHubProvider, EvmSolverService, EvmSpokeProvider, EvmSpokeService, EvmVaultTokenService, EvmWalletAbstraction, FEE_PERCENTAGE_SCALE, HubVaultSymbols, ICON_TX_RESULT_WAIT_MAX_RETRY, INTENT_RELAY_CHAIN_IDS, IconSpokeProvider, IcxMigrationService, InjectiveSpokeProvider, IntentCreatedEventAbi, IntentDataType, IntentsAbi, LockupMultiplier, LockupPeriod, MAX_UINT256, MigrationService, MoneyMarketService, STELLAR_DEFAULT_TX_TIMEOUT_SECONDS, STELLAR_PRIORITY_FEE, Sodax, SolanaSpokeProvider, SolverIntentErrorCode, SolverIntentStatusCode, SolverService, SonicSpokeProvider, SonicSpokeService, SpokeService, StellarSpokeProvider, SuiSpokeProvider, SupportedMigrationTokens, VAULT_TOKEN_DECIMALS, WalletAbstractionService, assetManagerAbi, balnSwapAbi, calculateFeeAmount, calculatePercentageFeeAmount, chainIdToHubAssetsMap, connectionAbi, encodeAddress, encodeContractCalls, erc20Abi, getEvmViemChain, getHubAssetInfo, getHubChainConfig, getIconAddressBytes, getIntentRelayChainId, getMoneyMarketConfig, getOriginalAssetAddress, getPacket, getRandomBytes, getSolanaAddressBytes, getSolverConfig, getSpokeChainIdFromIntentRelayChainId, getSupportedMoneyMarketTokens, getSupportedSolverTokens, getTransactionPackets, hexToBigInt, hubAssetToOriginalAssetMap, hubAssets, hubVaults, hubVaultsAddressSet, intentRelayChainIdToSpokeChainIdMap, isConfiguredMoneyMarketConfig, isConfiguredSolverConfig, isEvmHubChainConfig, isEvmInitializedConfig, isEvmSpokeChainConfig, isEvmSpokeProvider, isEvmUninitializedBrowserConfig, isEvmUninitializedConfig, isEvmUninitializedPrivateKeyConfig, isIconAddress, isIconSpokeProvider, isInjectiveSpokeProvider, isIntentCreationFailedError, isIntentCreationUnknownError, isIntentPostExecutionFailedError, isIntentRelayChainId, isIntentSubmitTxFailedError, isJsonRpcPayloadResponse, isMoneyMarketBorrowUnknownError, isMoneyMarketCreateBorrowIntentFailedError, isMoneyMarketCreateRepayIntentFailedError, isMoneyMarketCreateSupplyIntentFailedError, isMoneyMarketCreateWithdrawIntentFailedError, isMoneyMarketRelayTimeoutError, isMoneyMarketRepayUnknownError, isMoneyMarketReserveAsset, isMoneyMarketReserveHubAsset, isMoneyMarketSubmitTxFailedError, isMoneyMarketSupplyUnknownError, isMoneyMarketSupportedToken, isMoneyMarketWithdrawUnknownError, isNativeToken, isPartnerFeeAmount, isPartnerFeePercentage, isResponseAddressType, isResponseSigningType, isSolanaSpokeProvider, isSolverSupportedToken, isSonicSpokeProvider, isStellarSpokeProvider, isSuiSpokeProvider, isValidChainHubAsset, isValidHubAsset, isValidIntentRelayChainId, isValidOriginalAssetAddress, isValidSpokeChainId, isWaitUntilIntentExecutedFailed, migrationConfig, moneyMarketReserveAssets, moneyMarketReserveHubAssetsSet, moneyMarketSupportedTokens, originalAssetTohubAssetMap, poolAbi, randomUint256, relayTxAndWaitPacket, requestAddress, requestJsonRpc, requestSigning, retry, sonicWalletFactoryAbi, spokeAssetManagerAbi, spokeChainConfig, spokeChainIdsSet, submitTransaction, supportedHubAssets, supportedHubChains, supportedSpokeChains, supportedTokensPerChain, uiPoolDataAbi, variableDebtTokenAbi, vaultTokenAbi, waitForTransactionReceipt, waitUntilIntentExecuted, walletFactoryAbi, wrappedSonicAbi };
14542
14572
  //# sourceMappingURL=index.mjs.map
14543
14573
  //# sourceMappingURL=index.mjs.map