@sodax/wallet-sdk-react 1.0.4-beta → 1.1.0-beta-rc2
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/README.md +1 -1
- package/dist/index.cjs +22 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +24 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
- package/src/xchains/evm/EvmXService.ts +17 -3
- package/src/xchains/stellar/StellarXService.ts +34 -1
package/README.md
CHANGED
|
@@ -12,7 +12,7 @@ A comprehensive React Wallet SDK tailored for the Sodax ecosystem that provides
|
|
|
12
12
|
- ICON Wallets: ✅ (Hana Wallet and other ICON-compatible extensions)
|
|
13
13
|
|
|
14
14
|
- Address and connection state management
|
|
15
|
-
- EVM (Arbitrum, Avalanche, Base, BSC, Optimism, Polygon, Sonic, HyperEVM, LightLink) ✅
|
|
15
|
+
- EVM (Arbitrum, Avalanche, Base, BSC, Optimism, Polygon, Sonic, HyperEVM, LightLink, Kaia) ✅
|
|
16
16
|
- Sui ✅
|
|
17
17
|
- Solana ✅
|
|
18
18
|
- Stellar ✅
|
package/dist/index.cjs
CHANGED
|
@@ -197,7 +197,7 @@ var hyper = /* @__PURE__ */ viem.defineChain({
|
|
|
197
197
|
});
|
|
198
198
|
var createWagmiConfig = (config) => {
|
|
199
199
|
return wagmi.createConfig({
|
|
200
|
-
chains: [chains.mainnet, chains.avalanche, chains.arbitrum, chains.base, chains.bsc, chains.sonic, chains.optimism, chains.polygon, hyper, chains.lightlinkPhoenix],
|
|
200
|
+
chains: [chains.mainnet, chains.avalanche, chains.arbitrum, chains.base, chains.bsc, chains.sonic, chains.optimism, chains.polygon, hyper, chains.lightlinkPhoenix, chains.kaia],
|
|
201
201
|
ssr: true,
|
|
202
202
|
transports: {
|
|
203
203
|
[chains.mainnet.id]: wagmi.http(config[types.ETHEREUM_MAINNET_CHAIN_ID]),
|
|
@@ -209,7 +209,8 @@ var createWagmiConfig = (config) => {
|
|
|
209
209
|
[chains.optimism.id]: wagmi.http(config[types.OPTIMISM_MAINNET_CHAIN_ID]),
|
|
210
210
|
[chains.polygon.id]: wagmi.http(config[types.POLYGON_MAINNET_CHAIN_ID]),
|
|
211
211
|
[hyper.id]: wagmi.http(config[types.HYPEREVM_MAINNET_CHAIN_ID]),
|
|
212
|
-
[chains.lightlinkPhoenix.id]: wagmi.http(config[types.LIGHTLINK_MAINNET_CHAIN_ID])
|
|
212
|
+
[chains.lightlinkPhoenix.id]: wagmi.http(config[types.LIGHTLINK_MAINNET_CHAIN_ID]),
|
|
213
|
+
[chains.kaia.id]: wagmi.http(config[types.KAIA_MAINNET_CHAIN_ID])
|
|
213
214
|
}
|
|
214
215
|
});
|
|
215
216
|
};
|
|
@@ -234,6 +235,7 @@ var EvmXService = class _EvmXService extends XService {
|
|
|
234
235
|
const balance = await actions.getPublicClient(this.wagmiConfig, { chainId })?.getBalance({
|
|
235
236
|
address
|
|
236
237
|
});
|
|
238
|
+
console.log("balance", balance);
|
|
237
239
|
return balance || 0n;
|
|
238
240
|
}
|
|
239
241
|
throw new Error(`Unsupported token: ${xToken.symbol}`);
|
|
@@ -261,6 +263,7 @@ var EvmXService = class _EvmXService extends XService {
|
|
|
261
263
|
chainId: getWagmiChainId(xChainId)
|
|
262
264
|
}))
|
|
263
265
|
});
|
|
266
|
+
console.log("result", result);
|
|
264
267
|
return nonNativeXTokens.map((token, index) => ({
|
|
265
268
|
symbol: token.symbol,
|
|
266
269
|
address: token.address,
|
|
@@ -648,6 +651,13 @@ var getTokenBalance = async (address, tokenId, txBuilder, server) => {
|
|
|
648
651
|
};
|
|
649
652
|
|
|
650
653
|
// src/xchains/stellar/StellarXService.ts
|
|
654
|
+
var STELLAR_BASE_RESERVE_STROOPS = 5e6;
|
|
655
|
+
function parseXlmBalanceToStroops(balanceStr) {
|
|
656
|
+
const parts = balanceStr.split(".");
|
|
657
|
+
const whole = parts[0] ?? "0";
|
|
658
|
+
const frac = (parts[1] ?? "").padEnd(7, "0").slice(0, 7);
|
|
659
|
+
return BigInt(whole + frac);
|
|
660
|
+
}
|
|
651
661
|
var StellarXService = class _StellarXService extends XService {
|
|
652
662
|
constructor() {
|
|
653
663
|
super("STELLAR");
|
|
@@ -670,7 +680,16 @@ var StellarXService = class _StellarXService extends XService {
|
|
|
670
680
|
if (xToken.symbol === "XLM") {
|
|
671
681
|
const xlmBalance = stellarAccount.balances.find((balance) => balance.asset_type === "native");
|
|
672
682
|
if (xlmBalance) {
|
|
673
|
-
|
|
683
|
+
const rawBalanceStroops = parseXlmBalanceToStroops(xlmBalance.balance);
|
|
684
|
+
const sellingLiabilitiesStroops = xlmBalance.selling_liabilities ? parseXlmBalanceToStroops(xlmBalance.selling_liabilities) : BigInt(0);
|
|
685
|
+
const reserveFields = stellarAccount;
|
|
686
|
+
const subentryCount = reserveFields.subentry_count ?? 0;
|
|
687
|
+
const numSponsoring = reserveFields.num_sponsoring ?? 0;
|
|
688
|
+
const numSponsored = reserveFields.num_sponsored ?? 0;
|
|
689
|
+
const reserveCount = Math.max(0, 2 + subentryCount + numSponsoring - numSponsored);
|
|
690
|
+
const minBalanceStroops = BigInt(reserveCount) * BigInt(STELLAR_BASE_RESERVE_STROOPS) + sellingLiabilitiesStroops;
|
|
691
|
+
const availableStroops = rawBalanceStroops > minBalanceStroops ? rawBalanceStroops - minBalanceStroops : BigInt(0);
|
|
692
|
+
return availableStroops;
|
|
674
693
|
}
|
|
675
694
|
} else {
|
|
676
695
|
try {
|