@sodax/sdk 0.0.1-rc.40 → 0.0.1-rc.42
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 +31 -18
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +25 -13
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -5,7 +5,7 @@ var chains = require('viem/chains');
|
|
|
5
5
|
var types = require('@sodax/types');
|
|
6
6
|
var sdkTs = require('@injectivelabs/sdk-ts');
|
|
7
7
|
var networks = require('@injectivelabs/networks');
|
|
8
|
-
var
|
|
8
|
+
var IconSdkRaw = require('icon-sdk-js');
|
|
9
9
|
var stellarSdk = require('@stellar/stellar-sdk');
|
|
10
10
|
var bcs = require('@mysten/sui/bcs');
|
|
11
11
|
var client = require('@mysten/sui/client');
|
|
@@ -39,6 +39,7 @@ function _interopNamespace(e) {
|
|
|
39
39
|
return Object.freeze(n);
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
+
var IconSdkRaw__namespace = /*#__PURE__*/_interopNamespace(IconSdkRaw);
|
|
42
43
|
var rlp__namespace = /*#__PURE__*/_interopNamespace(rlp);
|
|
43
44
|
var anchor__namespace = /*#__PURE__*/_interopNamespace(anchor);
|
|
44
45
|
var BN__default = /*#__PURE__*/_interopDefault(BN);
|
|
@@ -8740,6 +8741,7 @@ var InjectiveSpokeProvider = class {
|
|
|
8740
8741
|
return num.toString();
|
|
8741
8742
|
}
|
|
8742
8743
|
};
|
|
8744
|
+
var IconSdk = "default" in IconSdkRaw__namespace.default ? IconSdkRaw__namespace.default : IconSdkRaw__namespace;
|
|
8743
8745
|
var IconSpokeProvider = class {
|
|
8744
8746
|
walletProvider;
|
|
8745
8747
|
chainConfig;
|
|
@@ -8748,7 +8750,7 @@ var IconSpokeProvider = class {
|
|
|
8748
8750
|
constructor(walletProvider, chainConfig, rpcUrl = "https://ctz.solidwallet.io/api/v3", debugRpcUrl = "https://ctz.solidwallet.io/api/v3d") {
|
|
8749
8751
|
this.walletProvider = walletProvider;
|
|
8750
8752
|
this.chainConfig = chainConfig;
|
|
8751
|
-
this.iconService = new
|
|
8753
|
+
this.iconService = new IconSdk.IconService(new IconSdk.IconService.HttpProvider(rpcUrl));
|
|
8752
8754
|
this.debugRpcUrl = debugRpcUrl;
|
|
8753
8755
|
}
|
|
8754
8756
|
};
|
|
@@ -9006,12 +9008,8 @@ var StellarSpokeProvider = class {
|
|
|
9006
9008
|
}
|
|
9007
9009
|
handleSendTransactionError(response) {
|
|
9008
9010
|
if (response.status === "ERROR") {
|
|
9009
|
-
|
|
9010
|
-
|
|
9011
|
-
name: response?.errorResult?.result()?.switch()?.name ?? "unknown",
|
|
9012
|
-
value: response?.errorResult?.result()?.switch()?.value ?? "unknown"
|
|
9013
|
-
})}, diagnosticEvents: ${JSON.stringify(response?.diagnosticEvents ?? "{}")}`
|
|
9014
|
-
);
|
|
9011
|
+
console.error(JSON.stringify(response, null, 2));
|
|
9012
|
+
throw new Error(JSON.stringify(response, null, 2));
|
|
9015
9013
|
}
|
|
9016
9014
|
return response;
|
|
9017
9015
|
}
|
|
@@ -9127,13 +9125,14 @@ var StellarSpokeProvider = class {
|
|
|
9127
9125
|
const accountResponse = await this.server.loadAccount(walletAddress);
|
|
9128
9126
|
const stellarAccount = new CustomStellarAccount(accountResponse);
|
|
9129
9127
|
const sendMessageCall = this.buildSendMessageCall(walletAddress, dst_chain_id, dst_address, payload);
|
|
9130
|
-
const [
|
|
9128
|
+
const [rawPriorityTx, simulation] = await this.buildPriorityStellarTransaction(
|
|
9131
9129
|
stellarAccount,
|
|
9132
9130
|
network,
|
|
9133
9131
|
sendMessageCall
|
|
9134
9132
|
);
|
|
9133
|
+
const assembledPriorityTx = stellarSdk.SorobanRpc.assembleTransaction(rawPriorityTx, simulation).build();
|
|
9135
9134
|
if (raw) {
|
|
9136
|
-
const transactionXdr =
|
|
9135
|
+
const transactionXdr = rawPriorityTx.toXDR();
|
|
9137
9136
|
return {
|
|
9138
9137
|
from: walletAddress,
|
|
9139
9138
|
to: this.chainConfig.addresses.assetManager,
|
|
@@ -9141,7 +9140,13 @@ var StellarSpokeProvider = class {
|
|
|
9141
9140
|
data: transactionXdr
|
|
9142
9141
|
};
|
|
9143
9142
|
}
|
|
9144
|
-
const hash = await this.submitOrRestoreAndRetry(
|
|
9143
|
+
const hash = await this.submitOrRestoreAndRetry(
|
|
9144
|
+
stellarAccount,
|
|
9145
|
+
network,
|
|
9146
|
+
assembledPriorityTx,
|
|
9147
|
+
sendMessageCall,
|
|
9148
|
+
simulation
|
|
9149
|
+
);
|
|
9145
9150
|
return `${hash}`;
|
|
9146
9151
|
} catch (error) {
|
|
9147
9152
|
console.error("Error during sendMessage:", error);
|
|
@@ -10343,6 +10348,8 @@ async function estimateStepCost(rawTx, debugRpcUrl) {
|
|
|
10343
10348
|
}
|
|
10344
10349
|
|
|
10345
10350
|
// src/services/spoke/IconSpokeService.ts
|
|
10351
|
+
var IconSdk2 = "default" in IconSdkRaw__namespace.default ? IconSdkRaw__namespace.default : IconSdkRaw__namespace;
|
|
10352
|
+
var { Converter, CallTransactionBuilder, CallBuilder } = IconSdk2;
|
|
10346
10353
|
var IconSpokeService = class _IconSpokeService {
|
|
10347
10354
|
constructor() {
|
|
10348
10355
|
}
|
|
@@ -10381,7 +10388,7 @@ var IconSpokeService = class _IconSpokeService {
|
|
|
10381
10388
|
* @returns {Promise<bigint>} The balance of the token
|
|
10382
10389
|
*/
|
|
10383
10390
|
static async getDeposit(token, spokeProvider) {
|
|
10384
|
-
const transaction = new
|
|
10391
|
+
const transaction = new CallBuilder().to(token).method("balanceOf").params({ _owner: spokeProvider.chainConfig.addresses.assetManager }).build();
|
|
10385
10392
|
const result = await spokeProvider.iconService.call(transaction).execute();
|
|
10386
10393
|
return BigInt(result.value);
|
|
10387
10394
|
}
|
|
@@ -10440,8 +10447,8 @@ var IconSpokeService = class _IconSpokeService {
|
|
|
10440
10447
|
const value = isNativeToken(spokeProvider.chainConfig.chain.id, token) ? BigIntToHex(amount) : "0x0";
|
|
10441
10448
|
const walletAddress = await spokeProvider.walletProvider.getWalletAddress();
|
|
10442
10449
|
const to = isNativeToken(spokeProvider.chainConfig.chain.id, token) ? spokeProvider.chainConfig.addresses.wICX : token;
|
|
10443
|
-
const rawTransaction =
|
|
10444
|
-
new
|
|
10450
|
+
const rawTransaction = Converter.toRawTransaction(
|
|
10451
|
+
new CallTransactionBuilder().from(walletAddress).to(to).stepLimit(Converter.toBigNumber("2000000")).nid(spokeProvider.chainConfig.nid).version("0x3").timestamp((/* @__PURE__ */ new Date()).getTime() * 1e3).value(value).method("transfer").params(params).build()
|
|
10445
10452
|
);
|
|
10446
10453
|
if (raw) {
|
|
10447
10454
|
return rawTransaction;
|
|
@@ -10465,9 +10472,9 @@ var IconSpokeService = class _IconSpokeService {
|
|
|
10465
10472
|
payload
|
|
10466
10473
|
};
|
|
10467
10474
|
const walletAddress = await spokeProvider.walletProvider.getWalletAddress();
|
|
10468
|
-
const transaction = new
|
|
10475
|
+
const transaction = new CallTransactionBuilder().from(walletAddress).to(spokeProvider.chainConfig.addresses.connection).stepLimit(Converter.toBigNumber("2000000")).nid(spokeProvider.chainConfig.nid).version("0x3").timestamp((/* @__PURE__ */ new Date()).getTime() * 1e3).method("sendMessage").params(params).build();
|
|
10469
10476
|
if (raw) {
|
|
10470
|
-
return
|
|
10477
|
+
return Converter.toRawTransaction(transaction);
|
|
10471
10478
|
}
|
|
10472
10479
|
return spokeProvider.walletProvider.sendTransaction({
|
|
10473
10480
|
from: walletAddress,
|
|
@@ -11802,7 +11809,7 @@ var SpokeService = class _SpokeService {
|
|
|
11802
11809
|
}
|
|
11803
11810
|
if (isEvmSpokeProvider(spokeProvider)) {
|
|
11804
11811
|
await _SpokeService.verifySimulation(from, payload, spokeProvider, hubProvider, skipSimulation);
|
|
11805
|
-
return await EvmSpokeService.callWallet(from, payload, spokeProvider, hubProvider);
|
|
11812
|
+
return await EvmSpokeService.callWallet(from, payload, spokeProvider, hubProvider, raw);
|
|
11806
11813
|
}
|
|
11807
11814
|
if (isInjectiveSpokeProvider(spokeProvider)) {
|
|
11808
11815
|
await _SpokeService.verifySimulation(from, payload, spokeProvider, hubProvider, skipSimulation);
|
|
@@ -11834,7 +11841,13 @@ var SpokeService = class _SpokeService {
|
|
|
11834
11841
|
}
|
|
11835
11842
|
if (isStellarSpokeProvider(spokeProvider)) {
|
|
11836
11843
|
await _SpokeService.verifySimulation(from, payload, spokeProvider, hubProvider, skipSimulation);
|
|
11837
|
-
return await StellarSpokeService.callWallet(
|
|
11844
|
+
return await StellarSpokeService.callWallet(
|
|
11845
|
+
from,
|
|
11846
|
+
payload,
|
|
11847
|
+
spokeProvider,
|
|
11848
|
+
hubProvider,
|
|
11849
|
+
raw
|
|
11850
|
+
);
|
|
11838
11851
|
}
|
|
11839
11852
|
throw new Error("Invalid spoke provider");
|
|
11840
11853
|
}
|