@pioneer-platform/pioneer-sdk 8.15.31 → 8.15.33
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 +229 -46
- package/dist/index.es.js +229 -46
- package/dist/index.js +229 -46
- package/package.json +6 -6
- package/src/fees/index.ts +1 -0
- package/src/index.ts +85 -8
- package/src/txbuilder/createUnsignedUxtoTx.ts +20 -3
- package/src/utils/build-dashboard.ts +86 -46
- package/src/utils/portfolio-helpers.ts +135 -1
package/dist/index.cjs
CHANGED
|
@@ -2639,7 +2639,21 @@ async function createUnsignedUxtoTx(caip, to, amount, memo, pubkeys, pioneer, pu
|
|
|
2639
2639
|
}
|
|
2640
2640
|
} catch (error) {
|
|
2641
2641
|
console.error(`${tag}: Failed to get fee rates from Pioneer API:`, error.message || error);
|
|
2642
|
-
|
|
2642
|
+
const defaultFees = {
|
|
2643
|
+
"bip122:000000000019d6689c085ae165831e93": { slow: 3, average: 5, fast: 10, fastest: 15 },
|
|
2644
|
+
"bip122:12a765e31ffd4059bada1e25190f6e98": { slow: 2, average: 3, fast: 5, fastest: 10 },
|
|
2645
|
+
"bip122:00000000001a91e3dace36e2be3bf030": { slow: 1, average: 1, fast: 2, fastest: 3 },
|
|
2646
|
+
"bip122:000000000000000000651ef99cb9fcbe": { slow: 1, average: 1, fast: 2, fastest: 3 },
|
|
2647
|
+
"bip122:000007d91d1254d60e2dd1ae58038307": { slow: 1, average: 1, fast: 2, fastest: 3 },
|
|
2648
|
+
"bip122:4da631f2ac1bed857bd968c67c913978": { slow: 75, average: 80, fast: 100, fastest: 120 },
|
|
2649
|
+
"bip122:00040fe8ec8471911baa1db1266ea15d": { slow: 1, average: 1, fast: 2, fastest: 3 }
|
|
2650
|
+
};
|
|
2651
|
+
if (defaultFees[networkId]) {
|
|
2652
|
+
console.warn(`${tag}: Using default fee rates for ${networkId}`);
|
|
2653
|
+
feeRateFromNode = defaultFees[networkId];
|
|
2654
|
+
} else {
|
|
2655
|
+
throw new Error(`Unable to get fee rate for network ${networkId}: ${error.message || "API unavailable"}`);
|
|
2656
|
+
}
|
|
2643
2657
|
}
|
|
2644
2658
|
}
|
|
2645
2659
|
let effectiveFeeRate;
|
|
@@ -3355,6 +3369,7 @@ function getNetworkName(networkId) {
|
|
|
3355
3369
|
"bip122:00000000001a91e3dace36e2be3bf030": "Dogecoin",
|
|
3356
3370
|
"bip122:000000000000000000651ef99cb9fcbe": "Bitcoin Cash",
|
|
3357
3371
|
"bip122:000007d91d1254d60e2dd1ae58038307": "Dash",
|
|
3372
|
+
"bip122:00040fe8ec8471911baa1db1266ea15d": "Zcash",
|
|
3358
3373
|
"bip122:4da631f2ac1bed857bd968c67c913978": "DigiByte",
|
|
3359
3374
|
"eip155:1": "Ethereum",
|
|
3360
3375
|
"eip155:56": "BNB Smart Chain",
|
|
@@ -3926,7 +3941,7 @@ function buildDashboardFromBalances(balances, blockchains, assetsMap) {
|
|
|
3926
3941
|
totalValueUsd: 0,
|
|
3927
3942
|
networkPercentages: []
|
|
3928
3943
|
};
|
|
3929
|
-
let
|
|
3944
|
+
let totalPortfolioValueCents = 0;
|
|
3930
3945
|
const networksTemp = [];
|
|
3931
3946
|
for (const blockchain of blockchains) {
|
|
3932
3947
|
const filteredBalances = balances.filter((b) => {
|
|
@@ -3934,50 +3949,46 @@ function buildDashboardFromBalances(balances, blockchains, assetsMap) {
|
|
|
3934
3949
|
return networkId === blockchain || blockchain === "eip155:*" && networkId.startsWith("eip155:");
|
|
3935
3950
|
});
|
|
3936
3951
|
const balanceMap = new Map;
|
|
3937
|
-
|
|
3938
|
-
|
|
3939
|
-
|
|
3940
|
-
|
|
3941
|
-
|
|
3942
|
-
|
|
3943
|
-
|
|
3944
|
-
|
|
3945
|
-
|
|
3946
|
-
|
|
3947
|
-
|
|
3948
|
-
|
|
3949
|
-
|
|
3950
|
-
|
|
3951
|
-
|
|
3952
|
-
} else {
|
|
3953
|
-
balances2.forEach((balance) => {
|
|
3954
|
-
const key = `${balance.caip}_${balance.pubkey || "default"}`;
|
|
3955
|
-
balanceMap.set(key, balance);
|
|
3956
|
-
});
|
|
3957
|
-
}
|
|
3952
|
+
filteredBalances.forEach((balance) => {
|
|
3953
|
+
const key = `${balance.caip}_${balance.pubkey || "default"}`;
|
|
3954
|
+
if (!balanceMap.has(key) || parseFloat(balance.valueUsd || "0") > parseFloat(balanceMap.get(key).valueUsd || "0")) {
|
|
3955
|
+
balanceMap.set(key, balance);
|
|
3956
|
+
} else {
|
|
3957
|
+
const existing = balanceMap.get(key);
|
|
3958
|
+
const existingValue = parseFloat(existing.valueUsd || "0");
|
|
3959
|
+
const newValue = parseFloat(balance.valueUsd || "0");
|
|
3960
|
+
console.log(`⚠️ [BUILD-DASHBOARD] ${blockchain} dedup skipped (same caip+pubkey):`, {
|
|
3961
|
+
caip: balance.caip,
|
|
3962
|
+
pubkey: (balance.pubkey || "default").substring(0, 20),
|
|
3963
|
+
existing: existingValue,
|
|
3964
|
+
new: newValue,
|
|
3965
|
+
diff: Math.abs(existingValue - newValue)
|
|
3966
|
+
});
|
|
3958
3967
|
}
|
|
3959
|
-
}
|
|
3960
|
-
filteredBalances.forEach((balance) => {
|
|
3961
|
-
const key = `${balance.caip}_${balance.pubkey || "default"}`;
|
|
3962
|
-
if (!balanceMap.has(key) || parseFloat(balance.valueUsd || "0") > parseFloat(balanceMap.get(key).valueUsd || "0")) {
|
|
3963
|
-
balanceMap.set(key, balance);
|
|
3964
|
-
}
|
|
3965
|
-
});
|
|
3966
|
-
}
|
|
3968
|
+
});
|
|
3967
3969
|
const networkBalances = Array.from(balanceMap.values());
|
|
3968
|
-
const
|
|
3969
|
-
|
|
3970
|
+
const networkTotalCents = networkBalances.reduce((sumCents, balance, idx) => {
|
|
3971
|
+
let valueUsd = typeof balance.valueUsd === "string" ? parseFloat(balance.valueUsd) : balance.valueUsd || 0;
|
|
3972
|
+
if (isNaN(valueUsd)) {
|
|
3973
|
+
console.warn(`⚠️ [BUILD-DASHBOARD] NaN value detected for ${balance.caip}:`, balance.valueUsd);
|
|
3974
|
+
return sumCents;
|
|
3975
|
+
}
|
|
3976
|
+
balance.valueUsd = valueUsd;
|
|
3977
|
+
const valueCents = Math.round(valueUsd * 100 * 1000) / 1000;
|
|
3970
3978
|
if (idx < 2) {
|
|
3971
3979
|
console.log(`\uD83D\uDCB0 [BUILD-DASHBOARD] ${blockchain} balance #${idx}:`, {
|
|
3972
3980
|
caip: balance.caip,
|
|
3973
3981
|
balance: balance.balance,
|
|
3974
3982
|
valueUsd: balance.valueUsd,
|
|
3983
|
+
valueUsdType: typeof balance.valueUsd,
|
|
3975
3984
|
parsedValueUsd: valueUsd,
|
|
3976
|
-
|
|
3985
|
+
valueCents,
|
|
3986
|
+
runningSumCents: sumCents + valueCents
|
|
3977
3987
|
});
|
|
3978
3988
|
}
|
|
3979
|
-
return
|
|
3989
|
+
return sumCents + valueCents;
|
|
3980
3990
|
}, 0);
|
|
3991
|
+
const networkTotal = networkTotalCents / 100;
|
|
3981
3992
|
console.log(`\uD83D\uDCB0 [BUILD-DASHBOARD] ${blockchain} totals:`, {
|
|
3982
3993
|
balancesCount: networkBalances.length,
|
|
3983
3994
|
networkTotal,
|
|
@@ -4000,8 +4011,9 @@ function buildDashboardFromBalances(balances, blockchains, assetsMap) {
|
|
|
4000
4011
|
color: gasAsset?.color || assetInfo?.color || null,
|
|
4001
4012
|
totalNativeBalance
|
|
4002
4013
|
});
|
|
4003
|
-
|
|
4014
|
+
totalPortfolioValueCents += networkTotalCents;
|
|
4004
4015
|
}
|
|
4016
|
+
const totalPortfolioValue = totalPortfolioValueCents / 100;
|
|
4005
4017
|
dashboardData.networks = networksTemp.sort((a, b) => b.totalValueUsd - a.totalValueUsd);
|
|
4006
4018
|
dashboardData.totalValueUsd = totalPortfolioValue;
|
|
4007
4019
|
dashboardData.networkPercentages = dashboardData.networks.map((network) => ({
|
|
@@ -4009,6 +4021,26 @@ function buildDashboardFromBalances(balances, blockchains, assetsMap) {
|
|
|
4009
4021
|
percentage: totalPortfolioValue > 0 ? Number((network.totalValueUsd / totalPortfolioValue * 100).toFixed(2)) : 0
|
|
4010
4022
|
})).filter((entry) => entry.percentage > 0);
|
|
4011
4023
|
console.log(`[FAST DASHBOARD] ✅ Built dashboard: ${dashboardData.networks.length} networks, $${totalPortfolioValue.toFixed(2)} total`);
|
|
4024
|
+
const inputBalancesTotal = balances.reduce((sum, b) => {
|
|
4025
|
+
const value = typeof b.valueUsd === "string" ? parseFloat(b.valueUsd) : b.valueUsd || 0;
|
|
4026
|
+
return sum + (isNaN(value) ? 0 : value);
|
|
4027
|
+
}, 0);
|
|
4028
|
+
const difference = Math.abs(inputBalancesTotal - totalPortfolioValue);
|
|
4029
|
+
if (difference > 0.01) {
|
|
4030
|
+
console.error(`\uD83D\uDEA8 [BUILD-DASHBOARD] BALANCE MISMATCH DETECTED!`);
|
|
4031
|
+
console.error(` Input balances total: $${inputBalancesTotal.toFixed(2)} USD`);
|
|
4032
|
+
console.error(` Dashboard total: $${totalPortfolioValue.toFixed(2)} USD`);
|
|
4033
|
+
console.error(` Difference: $${difference.toFixed(2)} USD`);
|
|
4034
|
+
console.error(` This indicates lost balances during dashboard aggregation!`);
|
|
4035
|
+
console.error(` Network breakdown:`);
|
|
4036
|
+
dashboardData.networks.forEach((network) => {
|
|
4037
|
+
console.error(` ${network.networkId}: $${network.totalValueUsd.toFixed(2)}`);
|
|
4038
|
+
});
|
|
4039
|
+
} else if (difference > 0.001) {
|
|
4040
|
+
console.warn(`⚠️ [BUILD-DASHBOARD] Minor balance rounding difference: $${difference.toFixed(4)} USD`);
|
|
4041
|
+
} else {
|
|
4042
|
+
console.log(`✅ [BUILD-DASHBOARD] Balance reconciliation passed (diff: $${difference.toFixed(4)})`);
|
|
4043
|
+
}
|
|
4012
4044
|
return dashboardData;
|
|
4013
4045
|
}
|
|
4014
4046
|
|
|
@@ -4143,6 +4175,80 @@ function filterPubkeysForAsset(pubkeys, caip, caipToNetworkId7) {
|
|
|
4143
4175
|
|
|
4144
4176
|
// src/utils/portfolio-helpers.ts
|
|
4145
4177
|
var TAG9 = " | portfolio-helpers | ";
|
|
4178
|
+
var EXPLORER_BASE_URLS = {
|
|
4179
|
+
"eip155:1": {
|
|
4180
|
+
address: "https://etherscan.io/address/",
|
|
4181
|
+
tx: "https://etherscan.io/tx/"
|
|
4182
|
+
},
|
|
4183
|
+
"eip155:137": {
|
|
4184
|
+
address: "https://polygonscan.com/address/",
|
|
4185
|
+
tx: "https://polygonscan.com/tx/"
|
|
4186
|
+
},
|
|
4187
|
+
"eip155:8453": {
|
|
4188
|
+
address: "https://basescan.org/address/",
|
|
4189
|
+
tx: "https://basescan.org/tx/"
|
|
4190
|
+
},
|
|
4191
|
+
"eip155:56": {
|
|
4192
|
+
address: "https://bscscan.com/address/",
|
|
4193
|
+
tx: "https://bscscan.com/tx/"
|
|
4194
|
+
},
|
|
4195
|
+
"eip155:41454": {
|
|
4196
|
+
address: "https://explorer.monad.xyz/address/",
|
|
4197
|
+
tx: "https://explorer.monad.xyz/tx/"
|
|
4198
|
+
},
|
|
4199
|
+
"eip155:2868": {
|
|
4200
|
+
address: "https://app.hyperliquid.xyz/explorer/address/",
|
|
4201
|
+
tx: "https://app.hyperliquid.xyz/explorer/tx/"
|
|
4202
|
+
},
|
|
4203
|
+
"bip122:000000000019d6689c085ae165831e93": {
|
|
4204
|
+
address: "https://blockstream.info/address/",
|
|
4205
|
+
tx: "https://blockstream.info/tx/"
|
|
4206
|
+
},
|
|
4207
|
+
"bip122:12a765e31ffd4059bada1e25190f6e98": {
|
|
4208
|
+
address: "https://blockchair.com/litecoin/address/",
|
|
4209
|
+
tx: "https://blockchair.com/litecoin/transaction/"
|
|
4210
|
+
},
|
|
4211
|
+
"bip122:00000000001a91e3dace36e2be3bf030": {
|
|
4212
|
+
address: "https://dogechain.info/address/",
|
|
4213
|
+
tx: "https://dogechain.info/tx/"
|
|
4214
|
+
},
|
|
4215
|
+
"bip122:000000000000000000651ef99cb9fcbe": {
|
|
4216
|
+
address: "https://blockchair.com/bitcoin-cash/address/",
|
|
4217
|
+
tx: "https://blockchair.com/bitcoin-cash/transaction/"
|
|
4218
|
+
},
|
|
4219
|
+
"bip122:000007d91d1254d60e2dd1ae58038307": {
|
|
4220
|
+
address: "https://chainz.cryptoid.info/dash/address.dws?",
|
|
4221
|
+
tx: "https://chainz.cryptoid.info/dash/tx.dws?"
|
|
4222
|
+
},
|
|
4223
|
+
"bip122:4da631f2ac1bed857bd968c67c913978": {
|
|
4224
|
+
address: "https://digiexplorer.info/address/",
|
|
4225
|
+
tx: "https://digiexplorer.info/tx/"
|
|
4226
|
+
},
|
|
4227
|
+
"bip122:00040fe8ec8471911baa1db1266ea15d": {
|
|
4228
|
+
address: "https://explorer.zcha.in/accounts/",
|
|
4229
|
+
tx: "https://explorer.zcha.in/transactions/"
|
|
4230
|
+
},
|
|
4231
|
+
"cosmos:cosmoshub-4": {
|
|
4232
|
+
address: "https://www.mintscan.io/cosmos/address/",
|
|
4233
|
+
tx: "https://www.mintscan.io/cosmos/tx/"
|
|
4234
|
+
},
|
|
4235
|
+
"cosmos:osmosis-1": {
|
|
4236
|
+
address: "https://www.mintscan.io/osmosis/address/",
|
|
4237
|
+
tx: "https://www.mintscan.io/osmosis/tx/"
|
|
4238
|
+
},
|
|
4239
|
+
"cosmos:thorchain-mainnet-v1": {
|
|
4240
|
+
address: "https://thorchain.net/address/",
|
|
4241
|
+
tx: "https://thorchain.net/tx/"
|
|
4242
|
+
},
|
|
4243
|
+
"cosmos:mayachain-mainnet-v1": {
|
|
4244
|
+
address: "https://www.mayascan.org/address/",
|
|
4245
|
+
tx: "https://www.mayascan.org/tx/"
|
|
4246
|
+
},
|
|
4247
|
+
"ripple:4109c6f2045fc7eff4cde8f9905d19c2": {
|
|
4248
|
+
address: "https://xrpscan.com/account/",
|
|
4249
|
+
tx: "https://xrpscan.com/tx/"
|
|
4250
|
+
}
|
|
4251
|
+
};
|
|
4146
4252
|
function isCacheDataValid(portfolioData) {
|
|
4147
4253
|
if (!portfolioData.networks || !Array.isArray(portfolioData.networks)) {
|
|
4148
4254
|
console.warn("[CACHE VALIDATION] Networks is not an array");
|
|
@@ -4281,14 +4387,37 @@ function enrichBalancesWithAssetInfo(balances, assetsMap, caipToNetworkId7) {
|
|
|
4281
4387
|
console.warn(tag, `Missing AssetInfo for CAIP: "${balance.caip}" - skipping this balance`);
|
|
4282
4388
|
continue;
|
|
4283
4389
|
}
|
|
4390
|
+
if (typeof balance.valueUsd === "string") {
|
|
4391
|
+
balance.valueUsd = parseFloat(balance.valueUsd) || 0;
|
|
4392
|
+
} else if (typeof balance.valueUsd !== "number") {
|
|
4393
|
+
balance.valueUsd = 0;
|
|
4394
|
+
}
|
|
4395
|
+
if (typeof balance.balance === "string") {
|
|
4396
|
+
balance.balance = balance.balance;
|
|
4397
|
+
}
|
|
4398
|
+
if (typeof balance.priceUsd === "string") {
|
|
4399
|
+
balance.priceUsd = parseFloat(balance.priceUsd) || 0;
|
|
4400
|
+
} else if (typeof balance.priceUsd !== "number") {
|
|
4401
|
+
balance.priceUsd = 0;
|
|
4402
|
+
}
|
|
4403
|
+
const networkId = caipToNetworkId7(balance.caip);
|
|
4404
|
+
const explorerUrls = EXPLORER_BASE_URLS[networkId];
|
|
4405
|
+
const explorerAddressLink = explorerUrls && balance.pubkey ? explorerUrls.address + balance.pubkey : undefined;
|
|
4406
|
+
const explorerTxLink = explorerUrls?.tx;
|
|
4284
4407
|
Object.assign(balance, assetInfo, {
|
|
4285
4408
|
type: balance.type || assetInfo.type,
|
|
4286
4409
|
isNative: balance.isNative ?? assetInfo.isNative,
|
|
4287
|
-
networkId
|
|
4410
|
+
networkId,
|
|
4288
4411
|
icon: assetInfo.icon || "https://pioneers.dev/coins/etherum.png",
|
|
4289
4412
|
identifier: `${balance.caip}:${balance.pubkey}`,
|
|
4290
4413
|
updated: Date.now(),
|
|
4291
|
-
color: assetInfo.color
|
|
4414
|
+
color: assetInfo.color,
|
|
4415
|
+
decimals: assetInfo.decimals || balance.decimals || 8,
|
|
4416
|
+
explorerAddressLink,
|
|
4417
|
+
explorerTxLink,
|
|
4418
|
+
explorer: explorerUrls?.address,
|
|
4419
|
+
valueUsd: balance.valueUsd,
|
|
4420
|
+
priceUsd: balance.priceUsd
|
|
4292
4421
|
});
|
|
4293
4422
|
enrichedBalances.push(balance);
|
|
4294
4423
|
}
|
|
@@ -4823,6 +4952,20 @@ class SDK {
|
|
|
4823
4952
|
this.balances[index] = balance;
|
|
4824
4953
|
}
|
|
4825
4954
|
this.events.emit("BALANCE_UPDATE", balance);
|
|
4955
|
+
console.log(tag7, "\uD83D\uDD04 Rebuilding dashboard after balance update...");
|
|
4956
|
+
const previousTotal = this.dashboard?.totalValueUsd || 0;
|
|
4957
|
+
this.dashboard = this.buildDashboardFromBalances();
|
|
4958
|
+
const newTotal = this.dashboard?.totalValueUsd || 0;
|
|
4959
|
+
if (Math.abs(newTotal - previousTotal) > 0.01) {
|
|
4960
|
+
console.log(tag7, `\uD83D\uDCB0 Portfolio value changed: $${previousTotal.toFixed(2)} → $${newTotal.toFixed(2)}`);
|
|
4961
|
+
}
|
|
4962
|
+
this.events.emit("DASHBOARD_UPDATE", {
|
|
4963
|
+
dashboard: this.dashboard,
|
|
4964
|
+
trigger: "balance_update",
|
|
4965
|
+
affectedAsset: balance.caip,
|
|
4966
|
+
previousTotal,
|
|
4967
|
+
newTotal
|
|
4968
|
+
});
|
|
4826
4969
|
} catch (e) {
|
|
4827
4970
|
console.error(tag7, "Error processing balance update:", e);
|
|
4828
4971
|
}
|
|
@@ -5700,7 +5843,7 @@ class SDK {
|
|
|
5700
5843
|
const pubkeysForNetwork = findPubkeysForNetwork(this.pubkeys, asset.networkId);
|
|
5701
5844
|
console.log(tag6, `✅ Validated: Found ${pubkeysForNetwork.length} addresses for ${asset.networkId}`);
|
|
5702
5845
|
const freshPriceUsd = await fetchMarketPrice(this.pioneer, asset.caip);
|
|
5703
|
-
let assetInfo = resolveAssetInfo(this.assetsMap,
|
|
5846
|
+
let assetInfo = resolveAssetInfo(this.assetsMap, this.assets, asset);
|
|
5704
5847
|
const matchingBalances = this.balances.filter((b) => b.caip === asset.caip);
|
|
5705
5848
|
if (matchingBalances.length > 0) {
|
|
5706
5849
|
const priceValue = extractPriceFromBalances(matchingBalances);
|
|
@@ -5716,14 +5859,47 @@ class SDK {
|
|
|
5716
5859
|
assetInfo.balance = totalBalance.toString();
|
|
5717
5860
|
assetInfo.valueUsd = totalValueUsd.toFixed(2);
|
|
5718
5861
|
}
|
|
5862
|
+
const EXPLORER_BASE_URLS2 = {
|
|
5863
|
+
"eip155:1": { address: "https://etherscan.io/address/", tx: "https://etherscan.io/tx/" },
|
|
5864
|
+
"eip155:137": { address: "https://polygonscan.com/address/", tx: "https://polygonscan.com/tx/" },
|
|
5865
|
+
"eip155:8453": { address: "https://basescan.org/address/", tx: "https://basescan.org/tx/" },
|
|
5866
|
+
"eip155:56": { address: "https://bscscan.com/address/", tx: "https://bscscan.com/tx/" },
|
|
5867
|
+
"eip155:41454": { address: "https://explorer.monad.xyz/address/", tx: "https://explorer.monad.xyz/tx/" },
|
|
5868
|
+
"eip155:2868": { address: "https://app.hyperliquid.xyz/explorer/address/", tx: "https://app.hyperliquid.xyz/explorer/tx/" },
|
|
5869
|
+
"bip122:000000000019d6689c085ae165831e93": { address: "https://blockstream.info/address/", tx: "https://blockstream.info/tx/" },
|
|
5870
|
+
"bip122:12a765e31ffd4059bada1e25190f6e98": { address: "https://blockchair.com/litecoin/address/", tx: "https://blockchair.com/litecoin/transaction/" },
|
|
5871
|
+
"bip122:00000000001a91e3dace36e2be3bf030": { address: "https://dogechain.info/address/", tx: "https://dogechain.info/tx/" },
|
|
5872
|
+
"bip122:000000000000000000651ef99cb9fcbe": { address: "https://blockchair.com/bitcoin-cash/address/", tx: "https://blockchair.com/bitcoin-cash/transaction/" },
|
|
5873
|
+
"bip122:000007d91d1254d60e2dd1ae58038307": { address: "https://chainz.cryptoid.info/dash/address.dws?", tx: "https://chainz.cryptoid.info/dash/tx.dws?" },
|
|
5874
|
+
"bip122:4da631f2ac1bed857bd968c67c913978": { address: "https://digiexplorer.info/address/", tx: "https://digiexplorer.info/tx/" },
|
|
5875
|
+
"bip122:00040fe8ec8471911baa1db1266ea15d": { address: "https://explorer.zcha.in/accounts/", tx: "https://explorer.zcha.in/transactions/" },
|
|
5876
|
+
"cosmos:cosmoshub-4": { address: "https://www.mintscan.io/cosmos/address/", tx: "https://www.mintscan.io/cosmos/tx/" },
|
|
5877
|
+
"cosmos:osmosis-1": { address: "https://www.mintscan.io/osmosis/address/", tx: "https://www.mintscan.io/osmosis/tx/" },
|
|
5878
|
+
"cosmos:thorchain-mainnet-v1": { address: "https://thorchain.net/address/", tx: "https://thorchain.net/tx/" },
|
|
5879
|
+
"cosmos:mayachain-mainnet-v1": { address: "https://www.mayascan.org/address/", tx: "https://www.mayascan.org/tx/" },
|
|
5880
|
+
"ripple:4109c6f2045fc7eff4cde8f9905d19c2": { address: "https://xrpscan.com/account/", tx: "https://xrpscan.com/tx/" }
|
|
5881
|
+
};
|
|
5882
|
+
const networkId = import_pioneer_caip8.caipToNetworkId(asset.caip);
|
|
5883
|
+
const explorerUrls = EXPLORER_BASE_URLS2[networkId];
|
|
5884
|
+
const firstPubkey = pubkeysForNetwork && pubkeysForNetwork.length > 0 ? pubkeysForNetwork[0].address || pubkeysForNetwork[0].pubkey : null;
|
|
5885
|
+
if (explorerUrls && firstPubkey) {
|
|
5886
|
+
assetInfo.explorerAddressLink = explorerUrls.address + firstPubkey;
|
|
5887
|
+
assetInfo.explorerTxLink = explorerUrls.tx;
|
|
5888
|
+
assetInfo.explorer = explorerUrls.address;
|
|
5889
|
+
}
|
|
5719
5890
|
const assetBalances = this.balances.filter((b) => b.caip === asset.caip);
|
|
5720
5891
|
const assetPubkeys = filterPubkeysForAsset(this.pubkeys, asset.caip, import_pioneer_caip8.caipToNetworkId);
|
|
5892
|
+
const criticalFields = ["decimals", "precision", "explorerAddressLink", "explorerTxLink", "explorer"];
|
|
5721
5893
|
const finalAssetContext = {
|
|
5722
5894
|
...assetInfo,
|
|
5723
|
-
...asset,
|
|
5895
|
+
...Object.fromEntries(Object.entries(asset).filter(([k, v]) => v !== undefined && !criticalFields.includes(k))),
|
|
5724
5896
|
pubkeys: assetPubkeys,
|
|
5725
5897
|
balances: assetBalances
|
|
5726
5898
|
};
|
|
5899
|
+
if (assetInfo.decimals !== undefined) {
|
|
5900
|
+
finalAssetContext.decimals = assetInfo.decimals;
|
|
5901
|
+
finalAssetContext.precision = assetInfo.decimals;
|
|
5902
|
+
}
|
|
5727
5903
|
if ((!asset.priceUsd || asset.priceUsd === 0) && assetInfo.priceUsd && assetInfo.priceUsd > 0) {
|
|
5728
5904
|
finalAssetContext.priceUsd = assetInfo.priceUsd;
|
|
5729
5905
|
}
|
|
@@ -5732,15 +5908,22 @@ class SDK {
|
|
|
5732
5908
|
}
|
|
5733
5909
|
this.assetContext = finalAssetContext;
|
|
5734
5910
|
if (asset.isToken || asset.type === "token" || assetInfo.isToken || assetInfo.type === "token") {
|
|
5735
|
-
const
|
|
5736
|
-
|
|
5737
|
-
|
|
5911
|
+
const networkId2 = asset.networkId || assetInfo.networkId;
|
|
5912
|
+
try {
|
|
5913
|
+
const nativeCaip = import_pioneer_caip8.networkIdToCaip(networkId2);
|
|
5914
|
+
const nativeAssetInfo = import_pioneer_discovery2.assetData[nativeCaip];
|
|
5915
|
+
const nativeSymbol = nativeAssetInfo?.symbol || "GAS";
|
|
5916
|
+
this.assetContext.nativeSymbol = nativeSymbol;
|
|
5738
5917
|
const nativeBalance = this.balances.find((b) => b.caip === nativeCaip);
|
|
5739
5918
|
if (nativeBalance) {
|
|
5740
5919
|
this.assetContext.nativeBalance = nativeBalance.balance || "0";
|
|
5741
5920
|
} else {
|
|
5742
5921
|
this.assetContext.nativeBalance = "0";
|
|
5743
5922
|
}
|
|
5923
|
+
} catch (error) {
|
|
5924
|
+
console.error(`[Pioneer SDK] Unable to get native asset for networkId ${networkId2}:`, error);
|
|
5925
|
+
this.assetContext.nativeSymbol = "GAS";
|
|
5926
|
+
this.assetContext.nativeBalance = "0";
|
|
5744
5927
|
}
|
|
5745
5928
|
}
|
|
5746
5929
|
if (asset.caip) {
|
|
@@ -5749,8 +5932,8 @@ class SDK {
|
|
|
5749
5932
|
this.blockchainContext = asset.networkId;
|
|
5750
5933
|
}
|
|
5751
5934
|
if (assetPubkeys && assetPubkeys.length > 0) {
|
|
5752
|
-
const
|
|
5753
|
-
const currentContextValid = this.pubkeyContext?.networks?.includes(
|
|
5935
|
+
const networkId2 = import_pioneer_caip8.caipToNetworkId(asset.caip || asset.networkId);
|
|
5936
|
+
const currentContextValid = this.pubkeyContext?.networks?.includes(networkId2);
|
|
5754
5937
|
if (!this.pubkeyContext || !currentContextValid) {
|
|
5755
5938
|
this.pubkeyContext = assetPubkeys[0];
|
|
5756
5939
|
console.log(tag6, "Auto-set pubkey context for network:", this.pubkeyContext.address || this.pubkeyContext.pubkey);
|
|
@@ -5801,7 +5984,7 @@ class SDK {
|
|
|
5801
5984
|
if (!pubkey)
|
|
5802
5985
|
throw Error("Invalid network! missing pubkey for network! " + asset.networkId);
|
|
5803
5986
|
const freshPriceUsd = await fetchMarketPrice(this.pioneer, asset.caip);
|
|
5804
|
-
let assetInfo = resolveAssetInfo(this.assetsMap,
|
|
5987
|
+
let assetInfo = resolveAssetInfo(this.assetsMap, this.assets, asset);
|
|
5805
5988
|
const matchingBalances = this.balances.filter((b) => b.caip === asset.caip);
|
|
5806
5989
|
if (matchingBalances.length > 0) {
|
|
5807
5990
|
const priceValue = extractPriceFromBalances(matchingBalances);
|