@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.cjs +44 -36
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +36 -36
- package/dist/index.d.ts +36 -36
- package/dist/index.mjs +43 -35
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -6707,8 +6707,8 @@ var isNativeToken = (chainId, token) => {
|
|
|
6707
6707
|
return token.address.toLowerCase() === spokeChainConfig[chainId].nativeToken.toLowerCase();
|
|
6708
6708
|
};
|
|
6709
6709
|
|
|
6710
|
-
// src/entities/
|
|
6711
|
-
var
|
|
6710
|
+
// src/entities/injective/Injective20Token.ts
|
|
6711
|
+
var Injective20Token = class {
|
|
6712
6712
|
client;
|
|
6713
6713
|
contractAddress;
|
|
6714
6714
|
constructor(client, contractAddress) {
|
|
@@ -6773,8 +6773,8 @@ var CW20Token = class {
|
|
|
6773
6773
|
}
|
|
6774
6774
|
};
|
|
6775
6775
|
|
|
6776
|
-
// src/entities/
|
|
6777
|
-
var
|
|
6776
|
+
// src/entities/injective/InjectiveSpokeProvider.ts
|
|
6777
|
+
var InjectiveSpokeProvider = class {
|
|
6778
6778
|
walletProvider;
|
|
6779
6779
|
chainConfig;
|
|
6780
6780
|
constructor(conf, walletProvider) {
|
|
@@ -6822,8 +6822,8 @@ var CWSpokeProvider = class {
|
|
|
6822
6822
|
return res.transactionHash;
|
|
6823
6823
|
}
|
|
6824
6824
|
async depositToken(sender, tokenAddress, to, amount, data = new Uint8Array(), raw) {
|
|
6825
|
-
const
|
|
6826
|
-
await
|
|
6825
|
+
const injective20Token = new Injective20Token(this.walletProvider, tokenAddress);
|
|
6826
|
+
await injective20Token.increaseAllowance(sender, this.chainConfig.addresses.assetManager, amount);
|
|
6827
6827
|
return this.transfer(sender, tokenAddress, to, amount, data, [], raw);
|
|
6828
6828
|
}
|
|
6829
6829
|
static async deposit(sender, token_address, to, amount, data = "0x", provider, raw) {
|
|
@@ -6841,11 +6841,13 @@ var CWSpokeProvider = class {
|
|
|
6841
6841
|
}
|
|
6842
6842
|
async isNative(token) {
|
|
6843
6843
|
let isNative2 = true;
|
|
6844
|
-
const
|
|
6844
|
+
const injective20Token = new Injective20Token(this.walletProvider, token);
|
|
6845
6845
|
try {
|
|
6846
|
-
await
|
|
6846
|
+
await injective20Token.getTokenInfo();
|
|
6847
6847
|
isNative2 = false;
|
|
6848
6848
|
} catch (err) {
|
|
6849
|
+
console.log("[InjectiveSpokeProvider] isNative error", err);
|
|
6850
|
+
throw err;
|
|
6849
6851
|
}
|
|
6850
6852
|
return isNative2;
|
|
6851
6853
|
}
|
|
@@ -6916,7 +6918,7 @@ var CWSpokeProvider = class {
|
|
|
6916
6918
|
return num.toString();
|
|
6917
6919
|
}
|
|
6918
6920
|
};
|
|
6919
|
-
var IconSdk = IconSdkRaw__namespace.default
|
|
6921
|
+
var IconSdk = "default" in IconSdkRaw__namespace.default ? IconSdkRaw__namespace.default : IconSdkRaw__namespace;
|
|
6920
6922
|
var IconSpokeProvider = class {
|
|
6921
6923
|
walletProvider;
|
|
6922
6924
|
chainConfig;
|
|
@@ -9416,16 +9418,16 @@ var EvmSpokeService = class _EvmSpokeService {
|
|
|
9416
9418
|
return spokeProvider.walletProvider.sendTransaction(rawTx);
|
|
9417
9419
|
}
|
|
9418
9420
|
};
|
|
9419
|
-
var
|
|
9421
|
+
var InjectiveSpokeService = class _InjectiveSpokeService {
|
|
9420
9422
|
constructor() {
|
|
9421
9423
|
}
|
|
9422
9424
|
/**
|
|
9423
9425
|
* Deposit tokens to the spoke chain.
|
|
9424
|
-
* @param {
|
|
9425
|
-
* @param {
|
|
9426
|
+
* @param {InjectiveSpokeDepositParams} params - The parameters for the deposit, including the user's address, token address, amount, and additional data.
|
|
9427
|
+
* @param {InjectiveSpokeProvider} spokeProvider - The provider for the spoke chain.
|
|
9426
9428
|
* @param {EvmHubProvider} hubProvider - The provider for the hub chain.
|
|
9427
9429
|
* @param {boolean} raw - The return type raw or just transaction hash
|
|
9428
|
-
* @returns {
|
|
9430
|
+
* @returns {PromiseInjectiveTxReturnType<R>} A promise that resolves to the transaction hash.
|
|
9429
9431
|
*/
|
|
9430
9432
|
static async deposit(params, spokeProvider, hubProvider, raw) {
|
|
9431
9433
|
const userWallet = params.to ?? await EvmWalletAbstraction.getUserHubWalletAddress(
|
|
@@ -9433,7 +9435,7 @@ var CWSpokeService = class _CWSpokeService {
|
|
|
9433
9435
|
viem.toHex(Buffer.from(params.from, "utf-8")),
|
|
9434
9436
|
hubProvider
|
|
9435
9437
|
);
|
|
9436
|
-
return
|
|
9438
|
+
return _InjectiveSpokeService.transfer(
|
|
9437
9439
|
{
|
|
9438
9440
|
token: params.token,
|
|
9439
9441
|
recipient: userWallet,
|
|
@@ -9447,7 +9449,7 @@ var CWSpokeService = class _CWSpokeService {
|
|
|
9447
9449
|
/**
|
|
9448
9450
|
* Get the balance of the token in the spoke chain.
|
|
9449
9451
|
* @param {Address} token - The address of the token to get the balance of.
|
|
9450
|
-
* @param {
|
|
9452
|
+
* @param {InjectiveSpokeProvider} spokeProvider - The spoke provider.
|
|
9451
9453
|
* @returns {Promise<bigint>} The balance of the token.
|
|
9452
9454
|
*/
|
|
9453
9455
|
static async getDeposit(token, spokeProvider) {
|
|
@@ -9458,43 +9460,43 @@ var CWSpokeService = class _CWSpokeService {
|
|
|
9458
9460
|
* Calls a contract on the spoke chain using the user's wallet.
|
|
9459
9461
|
* @param {HubAddress} from - The address of the user on the hub chain.
|
|
9460
9462
|
* @param {Hex} payload - The payload to send to the contract.
|
|
9461
|
-
* @param {
|
|
9463
|
+
* @param {InjectiveSpokeProvider} spokeProvider - The provider for the spoke chain.
|
|
9462
9464
|
* @param {EvmHubProvider} hubProvider - The provider for the hub chain.
|
|
9463
|
-
* @returns {
|
|
9465
|
+
* @returns {PromiseInjectiveTxReturnType<R>} A promise that resolves to the transaction hash.
|
|
9464
9466
|
*/
|
|
9465
9467
|
static async callWallet(from, payload, spokeProvider, hubProvider, raw) {
|
|
9466
9468
|
const relayId = getIntentRelayChainId(hubProvider.chainConfig.chain.id);
|
|
9467
|
-
return
|
|
9469
|
+
return _InjectiveSpokeService.call(BigInt(relayId), from, payload, spokeProvider, raw);
|
|
9468
9470
|
}
|
|
9469
9471
|
/**
|
|
9470
9472
|
* Transfers tokens to the hub chain.
|
|
9471
|
-
* @param {
|
|
9473
|
+
* @param {InjectiveTransferToHubParams} params - The parameters for the transfer, including:
|
|
9472
9474
|
* - {string} token: The address of the token to transfer (use address(0) for native token).
|
|
9473
9475
|
* - {Uint8Array} recipient: The recipient address on the hub chain.
|
|
9474
9476
|
* - {string} amount: The amount to transfer.
|
|
9475
9477
|
* - {Uint8Array} [data=new Uint8Array([])]: Additional data for the transfer.
|
|
9476
|
-
* @param {
|
|
9478
|
+
* @param {InjectiveSpokeProvider} spokeProvider - The provider for the spoke chain.
|
|
9477
9479
|
* @param {boolean} raw - The return type raw or just transaction hash
|
|
9478
|
-
* @returns {
|
|
9480
|
+
* @returns {PromiseInjectiveTxReturnType<R>} A promise that resolves to the transaction hash.
|
|
9479
9481
|
*/
|
|
9480
9482
|
static async transfer({ token, recipient, amount, data = "0x" }, spokeProvider, raw) {
|
|
9481
9483
|
const sender = await spokeProvider.walletProvider.getWalletAddress();
|
|
9482
|
-
return
|
|
9484
|
+
return InjectiveSpokeProvider.deposit(sender, token, recipient, amount, data, spokeProvider, raw);
|
|
9483
9485
|
}
|
|
9484
9486
|
/**
|
|
9485
9487
|
* Sends a message to the hub chain.
|
|
9486
9488
|
* @param {bigint} dstChainId - The chain ID of the hub chain.
|
|
9487
9489
|
* @param {Address} dstAddress - The address on the hub chain.
|
|
9488
9490
|
* @param {Hex} payload - The payload to send.
|
|
9489
|
-
* @param {
|
|
9490
|
-
* @returns {
|
|
9491
|
+
* @param {InjectiveSpokeProvider} spokeProvider - The provider for the spoke chain.
|
|
9492
|
+
* @returns {PromiseInjectiveTxReturnType<R>} A promise that resolves to the transaction hash.
|
|
9491
9493
|
*/
|
|
9492
9494
|
static async call(dstChainId, dstAddress, payload, spokeProvider, raw) {
|
|
9493
9495
|
const sender = await spokeProvider.walletProvider.getWalletAddress();
|
|
9494
9496
|
return spokeProvider.send_message(sender, dstChainId.toString(), dstAddress, payload, raw);
|
|
9495
9497
|
}
|
|
9496
9498
|
};
|
|
9497
|
-
var IconSdk2 = IconSdkRaw__namespace.default
|
|
9499
|
+
var IconSdk2 = "default" in IconSdkRaw__namespace.default ? IconSdkRaw__namespace.default : IconSdkRaw__namespace;
|
|
9498
9500
|
var { Converter, CallTransactionBuilder, CallBuilder } = IconSdk2;
|
|
9499
9501
|
var IconSpokeService = class _IconSpokeService {
|
|
9500
9502
|
constructor() {
|
|
@@ -9923,7 +9925,7 @@ var SuiSpokeService = class _SuiSpokeService {
|
|
|
9923
9925
|
}
|
|
9924
9926
|
/**
|
|
9925
9927
|
* Deposit tokens to the spoke chain.
|
|
9926
|
-
* @param {
|
|
9928
|
+
* @param {InjectiveSpokeDepositParams} params - The parameters for the deposit, including the user's address, token address, amount, and additional data.
|
|
9927
9929
|
* @param {SuiSpokeProvider} spokeProvider - The provider for the spoke chain.
|
|
9928
9930
|
* @param {EvmHubProvider} hubProvider - The provider for the hub chain.
|
|
9929
9931
|
* @param {boolean} raw - The return type raw or just transaction hash
|
|
@@ -10373,8 +10375,8 @@ function isSolanaSpokeProvider(value) {
|
|
|
10373
10375
|
function isStellarSpokeProvider(value) {
|
|
10374
10376
|
return typeof value === "object" && value !== null && value instanceof StellarSpokeProvider && value.chainConfig.chain.type === "STELLAR";
|
|
10375
10377
|
}
|
|
10376
|
-
function
|
|
10377
|
-
return typeof value === "object" && value !== null && value instanceof
|
|
10378
|
+
function isInjectiveSpokeProvider(value) {
|
|
10379
|
+
return typeof value === "object" && value !== null && value instanceof InjectiveSpokeProvider && value.chainConfig.chain.type === "INJECTIVE";
|
|
10378
10380
|
}
|
|
10379
10381
|
function isIconSpokeProvider(value) {
|
|
10380
10382
|
return typeof value === "object" && value !== null && value instanceof IconSpokeProvider && value.chainConfig.chain.type === "ICON";
|
|
@@ -10461,8 +10463,8 @@ var SpokeService = class {
|
|
|
10461
10463
|
raw
|
|
10462
10464
|
);
|
|
10463
10465
|
}
|
|
10464
|
-
if (spokeProvider instanceof
|
|
10465
|
-
return
|
|
10466
|
+
if (spokeProvider instanceof InjectiveSpokeProvider) {
|
|
10467
|
+
return InjectiveSpokeService.deposit(
|
|
10466
10468
|
params,
|
|
10467
10469
|
spokeProvider,
|
|
10468
10470
|
hubProvider,
|
|
@@ -10513,8 +10515,8 @@ var SpokeService = class {
|
|
|
10513
10515
|
if (spokeProvider instanceof EvmSpokeProvider) {
|
|
10514
10516
|
return EvmSpokeService.getDeposit(token, spokeProvider);
|
|
10515
10517
|
}
|
|
10516
|
-
if (spokeProvider instanceof
|
|
10517
|
-
return
|
|
10518
|
+
if (spokeProvider instanceof InjectiveSpokeProvider) {
|
|
10519
|
+
return InjectiveSpokeService.getDeposit(token, spokeProvider);
|
|
10518
10520
|
}
|
|
10519
10521
|
if (spokeProvider instanceof StellarSpokeProvider) {
|
|
10520
10522
|
return StellarSpokeService.getDeposit(token, spokeProvider);
|
|
@@ -10548,8 +10550,14 @@ var SpokeService = class {
|
|
|
10548
10550
|
if (isEvmSpokeProvider(spokeProvider)) {
|
|
10549
10551
|
return await EvmSpokeService.callWallet(from, payload, spokeProvider, hubProvider);
|
|
10550
10552
|
}
|
|
10551
|
-
if (
|
|
10552
|
-
return await
|
|
10553
|
+
if (isInjectiveSpokeProvider(spokeProvider)) {
|
|
10554
|
+
return await InjectiveSpokeService.callWallet(
|
|
10555
|
+
from,
|
|
10556
|
+
payload,
|
|
10557
|
+
spokeProvider,
|
|
10558
|
+
hubProvider,
|
|
10559
|
+
raw
|
|
10560
|
+
);
|
|
10553
10561
|
}
|
|
10554
10562
|
if (isIconSpokeProvider(spokeProvider)) {
|
|
10555
10563
|
return await IconSpokeService.callWallet(from, payload, spokeProvider, hubProvider, raw);
|
|
@@ -12601,7 +12609,6 @@ var SolverIntentErrorCode = /* @__PURE__ */ ((SolverIntentErrorCode2) => {
|
|
|
12601
12609
|
})(SolverIntentErrorCode || {});
|
|
12602
12610
|
|
|
12603
12611
|
exports.BigIntToHex = BigIntToHex;
|
|
12604
|
-
exports.CWSpokeProvider = CWSpokeProvider;
|
|
12605
12612
|
exports.DEFAULT_MAX_RETRY = DEFAULT_MAX_RETRY;
|
|
12606
12613
|
exports.DEFAULT_RELAYER_API_ENDPOINT = DEFAULT_RELAYER_API_ENDPOINT;
|
|
12607
12614
|
exports.DEFAULT_RELAY_TX_TIMEOUT = DEFAULT_RELAY_TX_TIMEOUT;
|
|
@@ -12622,6 +12629,7 @@ exports.ICON_TX_RESULT_WAIT_MAX_RETRY = ICON_TX_RESULT_WAIT_MAX_RETRY;
|
|
|
12622
12629
|
exports.INTENT_RELAY_CHAIN_IDS = INTENT_RELAY_CHAIN_IDS;
|
|
12623
12630
|
exports.IconSpokeProvider = IconSpokeProvider;
|
|
12624
12631
|
exports.IcxMigrationService = IcxMigrationService;
|
|
12632
|
+
exports.InjectiveSpokeProvider = InjectiveSpokeProvider;
|
|
12625
12633
|
exports.IntentCreatedEventAbi = IntentCreatedEventAbi;
|
|
12626
12634
|
exports.IntentDataType = IntentDataType;
|
|
12627
12635
|
exports.IntentsAbi = IntentsAbi;
|
|
@@ -12670,7 +12678,6 @@ exports.hubAssets = hubAssets;
|
|
|
12670
12678
|
exports.hubVaults = hubVaults;
|
|
12671
12679
|
exports.hubVaultsAddressSet = hubVaultsAddressSet;
|
|
12672
12680
|
exports.intentRelayChainIdToSpokeChainIdMap = intentRelayChainIdToSpokeChainIdMap;
|
|
12673
|
-
exports.isCWSpokeProvider = isCWSpokeProvider;
|
|
12674
12681
|
exports.isConfiguredMoneyMarketConfig = isConfiguredMoneyMarketConfig;
|
|
12675
12682
|
exports.isConfiguredSolverConfig = isConfiguredSolverConfig;
|
|
12676
12683
|
exports.isEvmHubChainConfig = isEvmHubChainConfig;
|
|
@@ -12682,6 +12689,7 @@ exports.isEvmUninitializedConfig = isEvmUninitializedConfig;
|
|
|
12682
12689
|
exports.isEvmUninitializedPrivateKeyConfig = isEvmUninitializedPrivateKeyConfig;
|
|
12683
12690
|
exports.isIconAddress = isIconAddress;
|
|
12684
12691
|
exports.isIconSpokeProvider = isIconSpokeProvider;
|
|
12692
|
+
exports.isInjectiveSpokeProvider = isInjectiveSpokeProvider;
|
|
12685
12693
|
exports.isIntentCreationFailedError = isIntentCreationFailedError;
|
|
12686
12694
|
exports.isIntentCreationUnknownError = isIntentCreationUnknownError;
|
|
12687
12695
|
exports.isIntentPostExecutionFailedError = isIntentPostExecutionFailedError;
|