@sodax/sdk 0.0.1-rc.12 → 0.0.1-rc.13

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
@@ -6680,8 +6680,8 @@ var isNativeToken = (chainId, token) => {
6680
6680
  return token.address.toLowerCase() === spokeChainConfig[chainId].nativeToken.toLowerCase();
6681
6681
  };
6682
6682
 
6683
- // src/entities/cosmos/CW20Token.ts
6684
- var CW20Token = class {
6683
+ // src/entities/injective/Injective20Token.ts
6684
+ var Injective20Token = class {
6685
6685
  client;
6686
6686
  contractAddress;
6687
6687
  constructor(client, contractAddress) {
@@ -6746,8 +6746,8 @@ var CW20Token = class {
6746
6746
  }
6747
6747
  };
6748
6748
 
6749
- // src/entities/cosmos/CWSpokeProvider.ts
6750
- var CWSpokeProvider = class {
6749
+ // src/entities/injective/InjectiveSpokeProvider.ts
6750
+ var InjectiveSpokeProvider = class {
6751
6751
  walletProvider;
6752
6752
  chainConfig;
6753
6753
  constructor(conf, walletProvider) {
@@ -6795,8 +6795,8 @@ var CWSpokeProvider = class {
6795
6795
  return res.transactionHash;
6796
6796
  }
6797
6797
  async depositToken(sender, tokenAddress, to, amount, data = new Uint8Array(), raw) {
6798
- const cw20Token = new CW20Token(this.walletProvider, tokenAddress);
6799
- await cw20Token.increaseAllowance(sender, this.chainConfig.addresses.assetManager, amount);
6798
+ const injective20Token = new Injective20Token(this.walletProvider, tokenAddress);
6799
+ await injective20Token.increaseAllowance(sender, this.chainConfig.addresses.assetManager, amount);
6800
6800
  return this.transfer(sender, tokenAddress, to, amount, data, [], raw);
6801
6801
  }
6802
6802
  static async deposit(sender, token_address, to, amount, data = "0x", provider, raw) {
@@ -6814,11 +6814,13 @@ var CWSpokeProvider = class {
6814
6814
  }
6815
6815
  async isNative(token) {
6816
6816
  let isNative2 = true;
6817
- const cw20Token = new CW20Token(this.walletProvider, token);
6817
+ const injective20Token = new Injective20Token(this.walletProvider, token);
6818
6818
  try {
6819
- await cw20Token.getTokenInfo();
6819
+ await injective20Token.getTokenInfo();
6820
6820
  isNative2 = false;
6821
6821
  } catch (err) {
6822
+ console.log("[InjectiveSpokeProvider] isNative error", err);
6823
+ throw err;
6822
6824
  }
6823
6825
  return isNative2;
6824
6826
  }
@@ -6889,7 +6891,7 @@ var CWSpokeProvider = class {
6889
6891
  return num.toString();
6890
6892
  }
6891
6893
  };
6892
- var IconSdk = IconSdkRaw.default?.default ? IconSdkRaw.default : IconSdkRaw;
6894
+ var IconSdk = "default" in IconSdkRaw.default ? IconSdkRaw.default : IconSdkRaw;
6893
6895
  var IconSpokeProvider = class {
6894
6896
  walletProvider;
6895
6897
  chainConfig;
@@ -9389,16 +9391,16 @@ var EvmSpokeService = class _EvmSpokeService {
9389
9391
  return spokeProvider.walletProvider.sendTransaction(rawTx);
9390
9392
  }
9391
9393
  };
9392
- var CWSpokeService = class _CWSpokeService {
9394
+ var InjectiveSpokeService = class _InjectiveSpokeService {
9393
9395
  constructor() {
9394
9396
  }
9395
9397
  /**
9396
9398
  * Deposit tokens to the spoke chain.
9397
- * @param {CWSpokeDepositParams} params - The parameters for the deposit, including the user's address, token address, amount, and additional data.
9398
- * @param {CWSpokeProvider} spokeProvider - The provider for the spoke chain.
9399
+ * @param {InjectiveSpokeDepositParams} params - The parameters for the deposit, including the user's address, token address, amount, and additional data.
9400
+ * @param {InjectiveSpokeProvider} spokeProvider - The provider for the spoke chain.
9399
9401
  * @param {EvmHubProvider} hubProvider - The provider for the hub chain.
9400
9402
  * @param {boolean} raw - The return type raw or just transaction hash
9401
- * @returns {PromiseCWTxReturnType<R>} A promise that resolves to the transaction hash.
9403
+ * @returns {PromiseInjectiveTxReturnType<R>} A promise that resolves to the transaction hash.
9402
9404
  */
9403
9405
  static async deposit(params, spokeProvider, hubProvider, raw) {
9404
9406
  const userWallet = params.to ?? await EvmWalletAbstraction.getUserHubWalletAddress(
@@ -9406,7 +9408,7 @@ var CWSpokeService = class _CWSpokeService {
9406
9408
  toHex(Buffer.from(params.from, "utf-8")),
9407
9409
  hubProvider
9408
9410
  );
9409
- return _CWSpokeService.transfer(
9411
+ return _InjectiveSpokeService.transfer(
9410
9412
  {
9411
9413
  token: params.token,
9412
9414
  recipient: userWallet,
@@ -9420,7 +9422,7 @@ var CWSpokeService = class _CWSpokeService {
9420
9422
  /**
9421
9423
  * Get the balance of the token in the spoke chain.
9422
9424
  * @param {Address} token - The address of the token to get the balance of.
9423
- * @param {CWSpokeProvider} spokeProvider - The spoke provider.
9425
+ * @param {InjectiveSpokeProvider} spokeProvider - The spoke provider.
9424
9426
  * @returns {Promise<bigint>} The balance of the token.
9425
9427
  */
9426
9428
  static async getDeposit(token, spokeProvider) {
@@ -9431,43 +9433,43 @@ var CWSpokeService = class _CWSpokeService {
9431
9433
  * Calls a contract on the spoke chain using the user's wallet.
9432
9434
  * @param {HubAddress} from - The address of the user on the hub chain.
9433
9435
  * @param {Hex} payload - The payload to send to the contract.
9434
- * @param {CWSpokeProvider} spokeProvider - The provider for the spoke chain.
9436
+ * @param {InjectiveSpokeProvider} spokeProvider - The provider for the spoke chain.
9435
9437
  * @param {EvmHubProvider} hubProvider - The provider for the hub chain.
9436
- * @returns {PromiseCWTxReturnType<R>} A promise that resolves to the transaction hash.
9438
+ * @returns {PromiseInjectiveTxReturnType<R>} A promise that resolves to the transaction hash.
9437
9439
  */
9438
9440
  static async callWallet(from, payload, spokeProvider, hubProvider, raw) {
9439
9441
  const relayId = getIntentRelayChainId(hubProvider.chainConfig.chain.id);
9440
- return _CWSpokeService.call(BigInt(relayId), from, payload, spokeProvider, raw);
9442
+ return _InjectiveSpokeService.call(BigInt(relayId), from, payload, spokeProvider, raw);
9441
9443
  }
9442
9444
  /**
9443
9445
  * Transfers tokens to the hub chain.
9444
- * @param {TransferToHubParams} params - The parameters for the transfer, including:
9446
+ * @param {InjectiveTransferToHubParams} params - The parameters for the transfer, including:
9445
9447
  * - {string} token: The address of the token to transfer (use address(0) for native token).
9446
9448
  * - {Uint8Array} recipient: The recipient address on the hub chain.
9447
9449
  * - {string} amount: The amount to transfer.
9448
9450
  * - {Uint8Array} [data=new Uint8Array([])]: Additional data for the transfer.
9449
- * @param {CWSpokeProvider} spokeProvider - The provider for the spoke chain.
9451
+ * @param {InjectiveSpokeProvider} spokeProvider - The provider for the spoke chain.
9450
9452
  * @param {boolean} raw - The return type raw or just transaction hash
9451
- * @returns {PromiseCWTxReturnType<R>} A promise that resolves to the transaction hash.
9453
+ * @returns {PromiseInjectiveTxReturnType<R>} A promise that resolves to the transaction hash.
9452
9454
  */
9453
9455
  static async transfer({ token, recipient, amount, data = "0x" }, spokeProvider, raw) {
9454
9456
  const sender = await spokeProvider.walletProvider.getWalletAddress();
9455
- return CWSpokeProvider.deposit(sender, token, recipient, amount, data, spokeProvider, raw);
9457
+ return InjectiveSpokeProvider.deposit(sender, token, recipient, amount, data, spokeProvider, raw);
9456
9458
  }
9457
9459
  /**
9458
9460
  * Sends a message to the hub chain.
9459
9461
  * @param {bigint} dstChainId - The chain ID of the hub chain.
9460
9462
  * @param {Address} dstAddress - The address on the hub chain.
9461
9463
  * @param {Hex} payload - The payload to send.
9462
- * @param {CWSpokeProvider} spokeProvider - The provider for the spoke chain.
9463
- * @returns {PromiseCWTxReturnType<R>} A promise that resolves to the transaction hash.
9464
+ * @param {InjectiveSpokeProvider} spokeProvider - The provider for the spoke chain.
9465
+ * @returns {PromiseInjectiveTxReturnType<R>} A promise that resolves to the transaction hash.
9464
9466
  */
9465
9467
  static async call(dstChainId, dstAddress, payload, spokeProvider, raw) {
9466
9468
  const sender = await spokeProvider.walletProvider.getWalletAddress();
9467
9469
  return spokeProvider.send_message(sender, dstChainId.toString(), dstAddress, payload, raw);
9468
9470
  }
9469
9471
  };
9470
- var IconSdk2 = IconSdkRaw.default?.default ? IconSdkRaw.default : IconSdkRaw;
9472
+ var IconSdk2 = "default" in IconSdkRaw.default ? IconSdkRaw.default : IconSdkRaw;
9471
9473
  var { Converter, CallTransactionBuilder, CallBuilder } = IconSdk2;
9472
9474
  var IconSpokeService = class _IconSpokeService {
9473
9475
  constructor() {
@@ -9896,7 +9898,7 @@ var SuiSpokeService = class _SuiSpokeService {
9896
9898
  }
9897
9899
  /**
9898
9900
  * Deposit tokens to the spoke chain.
9899
- * @param {CWSpokeDepositParams} params - The parameters for the deposit, including the user's address, token address, amount, and additional data.
9901
+ * @param {InjectiveSpokeDepositParams} params - The parameters for the deposit, including the user's address, token address, amount, and additional data.
9900
9902
  * @param {SuiSpokeProvider} spokeProvider - The provider for the spoke chain.
9901
9903
  * @param {EvmHubProvider} hubProvider - The provider for the hub chain.
9902
9904
  * @param {boolean} raw - The return type raw or just transaction hash
@@ -10346,8 +10348,8 @@ function isSolanaSpokeProvider(value) {
10346
10348
  function isStellarSpokeProvider(value) {
10347
10349
  return typeof value === "object" && value !== null && value instanceof StellarSpokeProvider && value.chainConfig.chain.type === "STELLAR";
10348
10350
  }
10349
- function isCWSpokeProvider(value) {
10350
- return typeof value === "object" && value !== null && value instanceof CWSpokeProvider && value.chainConfig.chain.type === "INJECTIVE";
10351
+ function isInjectiveSpokeProvider(value) {
10352
+ return typeof value === "object" && value !== null && value instanceof InjectiveSpokeProvider && value.chainConfig.chain.type === "INJECTIVE";
10351
10353
  }
10352
10354
  function isIconSpokeProvider(value) {
10353
10355
  return typeof value === "object" && value !== null && value instanceof IconSpokeProvider && value.chainConfig.chain.type === "ICON";
@@ -10434,8 +10436,8 @@ var SpokeService = class {
10434
10436
  raw
10435
10437
  );
10436
10438
  }
10437
- if (spokeProvider instanceof CWSpokeProvider) {
10438
- return CWSpokeService.deposit(
10439
+ if (spokeProvider instanceof InjectiveSpokeProvider) {
10440
+ return InjectiveSpokeService.deposit(
10439
10441
  params,
10440
10442
  spokeProvider,
10441
10443
  hubProvider,
@@ -10486,8 +10488,8 @@ var SpokeService = class {
10486
10488
  if (spokeProvider instanceof EvmSpokeProvider) {
10487
10489
  return EvmSpokeService.getDeposit(token, spokeProvider);
10488
10490
  }
10489
- if (spokeProvider instanceof CWSpokeProvider) {
10490
- return CWSpokeService.getDeposit(token, spokeProvider);
10491
+ if (spokeProvider instanceof InjectiveSpokeProvider) {
10492
+ return InjectiveSpokeService.getDeposit(token, spokeProvider);
10491
10493
  }
10492
10494
  if (spokeProvider instanceof StellarSpokeProvider) {
10493
10495
  return StellarSpokeService.getDeposit(token, spokeProvider);
@@ -10521,8 +10523,14 @@ var SpokeService = class {
10521
10523
  if (isEvmSpokeProvider(spokeProvider)) {
10522
10524
  return await EvmSpokeService.callWallet(from, payload, spokeProvider, hubProvider);
10523
10525
  }
10524
- if (isCWSpokeProvider(spokeProvider)) {
10525
- return await CWSpokeService.callWallet(from, payload, spokeProvider, hubProvider, raw);
10526
+ if (isInjectiveSpokeProvider(spokeProvider)) {
10527
+ return await InjectiveSpokeService.callWallet(
10528
+ from,
10529
+ payload,
10530
+ spokeProvider,
10531
+ hubProvider,
10532
+ raw
10533
+ );
10526
10534
  }
10527
10535
  if (isIconSpokeProvider(spokeProvider)) {
10528
10536
  return await IconSpokeService.callWallet(from, payload, spokeProvider, hubProvider, raw);
@@ -12573,6 +12581,6 @@ var SolverIntentErrorCode = /* @__PURE__ */ ((SolverIntentErrorCode2) => {
12573
12581
  return SolverIntentErrorCode2;
12574
12582
  })(SolverIntentErrorCode || {});
12575
12583
 
12576
- export { BigIntToHex, CWSpokeProvider, 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, IntentCreatedEventAbi, IntentDataType, IntentsAbi, MAX_UINT256, MigrationService, MoneyMarketService, STELLAR_DEFAULT_TX_TIMEOUT_SECONDS, STELLAR_PRIORITY_FEE, Sodax, SolanaSpokeProvider, SolverIntentErrorCode, SolverIntentStatusCode, SolverService, SonicSpokeProvider, SonicSpokeService, SpokeService, StellarSpokeProvider, SuiSpokeProvider, VAULT_TOKEN_DECIMALS, WalletAbstractionService, assetManagerAbi, calculateFeeAmount, calculatePercentageFeeAmount, chainIdToHubAssetsMap, connectionAbi, encodeAddress, encodeContractCalls, erc20Abi, getEvmViemChain, getHubAssetInfo, getHubChainConfig, getIconAddressBytes, getIntentRelayChainId, getMoneyMarketConfig, getOriginalAssetAddress, getPacket, getRandomBytes, getSolanaAddressBytes, getSolverConfig, getSpokeChainIdFromIntentRelayChainId, getSupportedMoneyMarketTokens, getSupportedSolverTokens, getTransactionPackets, hubAssetToOriginalAssetMap, hubAssets, hubVaults, hubVaultsAddressSet, intentRelayChainIdToSpokeChainIdMap, isCWSpokeProvider, isConfiguredMoneyMarketConfig, isConfiguredSolverConfig, isEvmHubChainConfig, isEvmInitializedConfig, isEvmSpokeChainConfig, isEvmSpokeProvider, isEvmUninitializedBrowserConfig, isEvmUninitializedConfig, isEvmUninitializedPrivateKeyConfig, isIconAddress, isIconSpokeProvider, 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, 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 };
12584
+ export { BigIntToHex, 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, MAX_UINT256, MigrationService, MoneyMarketService, STELLAR_DEFAULT_TX_TIMEOUT_SECONDS, STELLAR_PRIORITY_FEE, Sodax, SolanaSpokeProvider, SolverIntentErrorCode, SolverIntentStatusCode, SolverService, SonicSpokeProvider, SonicSpokeService, SpokeService, StellarSpokeProvider, SuiSpokeProvider, VAULT_TOKEN_DECIMALS, WalletAbstractionService, assetManagerAbi, calculateFeeAmount, calculatePercentageFeeAmount, chainIdToHubAssetsMap, connectionAbi, encodeAddress, encodeContractCalls, erc20Abi, getEvmViemChain, getHubAssetInfo, getHubChainConfig, getIconAddressBytes, getIntentRelayChainId, getMoneyMarketConfig, getOriginalAssetAddress, getPacket, getRandomBytes, getSolanaAddressBytes, getSolverConfig, getSpokeChainIdFromIntentRelayChainId, getSupportedMoneyMarketTokens, getSupportedSolverTokens, getTransactionPackets, 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, 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 };
12577
12585
  //# sourceMappingURL=index.mjs.map
12578
12586
  //# sourceMappingURL=index.mjs.map