@sodax/sdk 1.2.5-beta → 1.2.6-beta

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
@@ -16468,6 +16468,18 @@ function isSonicRawSpokeProvider(value) {
16468
16468
  function isAddressString(value) {
16469
16469
  return typeof value === "string";
16470
16470
  }
16471
+ function isEvmRawSpokeProviderConfig(value) {
16472
+ return typeof value === "object" && value !== null && "walletAddress" in value && "chainConfig" in value && value.chainConfig.chain.type === "EVM";
16473
+ }
16474
+ function isSonicRawSpokeProviderConfig(value) {
16475
+ return typeof value === "object" && value !== null && "walletAddress" in value && "chainConfig" in value && value.chainConfig.chain.type === "EVM" && value.chainConfig.chain.id === types.SONIC_MAINNET_CHAIN_ID;
16476
+ }
16477
+ function isStellarRawSpokeProviderConfig(value) {
16478
+ return typeof value === "object" && value !== null && "walletAddress" in value && "chainConfig" in value && value.chainConfig.chain.type === "STELLAR";
16479
+ }
16480
+ function isSolanaRawSpokeProviderConfig(value) {
16481
+ return typeof value === "object" && value !== null && "walletAddress" in value && "chainConfig" in value && "connection" in value && value.chainConfig.chain.type === "SOLANA";
16482
+ }
16471
16483
  async function retry(action, retryCount = DEFAULT_MAX_RETRY, delayMs = DEFAULT_RETRY_DELAY_MS) {
16472
16484
  do {
16473
16485
  try {
@@ -16579,6 +16591,51 @@ function sleep(ms) {
16579
16591
  function isHubSpokeProvider(spokeProvider, hubProvider) {
16580
16592
  return spokeProvider.chainConfig.chain.id === hubProvider.chainConfig.chain.id;
16581
16593
  }
16594
+ function constructRawSpokeProvider(config) {
16595
+ const chainType = config.chainConfig?.chain?.type;
16596
+ switch (chainType) {
16597
+ case "EVM": {
16598
+ if (config.chainConfig.chain.id === types.SONIC_MAINNET_CHAIN_ID) {
16599
+ invariant6__default.default(isSonicRawSpokeProviderConfig(config), "Invalid Sonic raw spoke provider config");
16600
+ return new SonicRawSpokeProvider(config.walletAddress, config.chainConfig, config.rpcUrl);
16601
+ }
16602
+ invariant6__default.default(isEvmRawSpokeProviderConfig(config), "Invalid Evm raw spoke provider config");
16603
+ return new EvmRawSpokeProvider(config.walletAddress, config.chainConfig, config.rpcUrl);
16604
+ }
16605
+ case "STELLAR":
16606
+ invariant6__default.default(isStellarRawSpokeProviderConfig(config), "Invalid Stellar raw spoke provider config");
16607
+ return new StellarRawSpokeProvider(config.walletAddress, config.chainConfig, config.rpcConfig);
16608
+ case "SOLANA": {
16609
+ invariant6__default.default(isSolanaRawSpokeProviderConfig(config), "Invalid Solana raw spoke provider config");
16610
+ return new SolanaRawSpokeProvider({
16611
+ connection: config.connection,
16612
+ walletAddress: config.walletAddress,
16613
+ chainConfig: config.chainConfig
16614
+ });
16615
+ }
16616
+ case "ICON": {
16617
+ return new IconRawSpokeProvider(
16618
+ config.chainConfig,
16619
+ config.walletAddress
16620
+ );
16621
+ }
16622
+ case "INJECTIVE": {
16623
+ return new InjectiveRawSpokeProvider(
16624
+ config.chainConfig,
16625
+ config.walletAddress
16626
+ );
16627
+ }
16628
+ case "SUI": {
16629
+ return new SuiRawSpokeProvider(
16630
+ config.chainConfig,
16631
+ config.walletAddress
16632
+ );
16633
+ }
16634
+ default: {
16635
+ throw new Error(`Unsupported chain type: ${chainType}`);
16636
+ }
16637
+ }
16638
+ }
16582
16639
 
16583
16640
  // src/shared/types.ts
16584
16641
  var SolverIntentStatusCode = /* @__PURE__ */ ((SolverIntentStatusCode2) => {
@@ -20825,6 +20882,7 @@ exports.calculateHealthFactorFromBalancesBigUnits = calculateHealthFactorFromBal
20825
20882
  exports.calculateLinearInterest = calculateLinearInterest;
20826
20883
  exports.calculatePercentageFeeAmount = calculatePercentageFeeAmount;
20827
20884
  exports.connectionAbi = connectionAbi;
20885
+ exports.constructRawSpokeProvider = constructRawSpokeProvider;
20828
20886
  exports.convertTransactionInstructionToRaw = convertTransactionInstructionToRaw;
20829
20887
  exports.deriveUserWalletAddress = deriveUserWalletAddress;
20830
20888
  exports.encodeAddress = encodeAddress;
@@ -20865,6 +20923,7 @@ exports.isCreateIntentAutoSwapError = isCreateIntentAutoSwapError;
20865
20923
  exports.isEvmHubChainConfig = isEvmHubChainConfig;
20866
20924
  exports.isEvmInitializedConfig = isEvmInitializedConfig;
20867
20925
  exports.isEvmRawSpokeProvider = isEvmRawSpokeProvider;
20926
+ exports.isEvmRawSpokeProviderConfig = isEvmRawSpokeProviderConfig;
20868
20927
  exports.isEvmSpokeChainConfig = isEvmSpokeChainConfig;
20869
20928
  exports.isEvmSpokeProvider = isEvmSpokeProvider;
20870
20929
  exports.isEvmSpokeProviderType = isEvmSpokeProviderType;
@@ -20909,13 +20968,16 @@ exports.isResponseSigningType = isResponseSigningType;
20909
20968
  exports.isSetSwapPreferenceError = isSetSwapPreferenceError;
20910
20969
  exports.isSolanaNativeToken = isSolanaNativeToken;
20911
20970
  exports.isSolanaRawSpokeProvider = isSolanaRawSpokeProvider;
20971
+ exports.isSolanaRawSpokeProviderConfig = isSolanaRawSpokeProviderConfig;
20912
20972
  exports.isSolanaSpokeProvider = isSolanaSpokeProvider;
20913
20973
  exports.isSolanaSpokeProviderType = isSolanaSpokeProviderType;
20914
20974
  exports.isSolverErrorResponse = isSolverErrorResponse;
20915
20975
  exports.isSonicRawSpokeProvider = isSonicRawSpokeProvider;
20976
+ exports.isSonicRawSpokeProviderConfig = isSonicRawSpokeProviderConfig;
20916
20977
  exports.isSonicSpokeProvider = isSonicSpokeProvider;
20917
20978
  exports.isSonicSpokeProviderType = isSonicSpokeProviderType;
20918
20979
  exports.isStellarRawSpokeProvider = isStellarRawSpokeProvider;
20980
+ exports.isStellarRawSpokeProviderConfig = isStellarRawSpokeProviderConfig;
20919
20981
  exports.isStellarSpokeProvider = isStellarSpokeProvider;
20920
20982
  exports.isStellarSpokeProviderType = isStellarSpokeProviderType;
20921
20983
  exports.isSuiRawSpokeProvider = isSuiRawSpokeProvider;