@pioneer-platform/pioneer-sdk 4.21.0 → 4.21.1
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
CHANGED
|
@@ -1914,8 +1914,9 @@ async function createUnsignedEvmTx(caip, to, amount, memo, pubkeys, pioneer, pub
|
|
|
1914
1914
|
nonce = 0;
|
|
1915
1915
|
}
|
|
1916
1916
|
const balanceData = await pioneer.GetBalanceAddressByNetwork({ networkId, address });
|
|
1917
|
-
const balanceEth = parseFloat(balanceData.data.balance);
|
|
1917
|
+
const balanceEth = parseFloat(balanceData.data.nativeBalance || balanceData.data.balance || "0");
|
|
1918
1918
|
const balance = BigInt(Math.round(balanceEth * 1000000000000000000));
|
|
1919
|
+
console.log(tag5, "Native ETH balance from API:", balanceData.data.nativeBalance || balanceData.data.balance, "ETH (", balance.toString(), "wei)");
|
|
1919
1920
|
if (balance <= 0n)
|
|
1920
1921
|
throw new Error("Wallet balance is zero");
|
|
1921
1922
|
const assetType = classifyCaipEvm(caip);
|
|
@@ -2075,7 +2076,9 @@ async function createUnsignedEvmTx(caip, to, amount, memo, pubkeys, pioneer, pub
|
|
|
2075
2076
|
resultWei: amountWei.toString()
|
|
2076
2077
|
});
|
|
2077
2078
|
}
|
|
2078
|
-
|
|
2079
|
+
const estimatedGasForCheck = BigInt(25000);
|
|
2080
|
+
const estimatedGasFee = gasPrice * estimatedGasForCheck;
|
|
2081
|
+
if (estimatedGasFee > balance) {
|
|
2079
2082
|
throw new Error("Insufficient ETH balance to cover gas fees");
|
|
2080
2083
|
}
|
|
2081
2084
|
const data = encodeTransferData(to, amountWei);
|
|
@@ -3984,6 +3987,7 @@ function buildDashboardFromBalances(balances, blockchains, assetsMap) {
|
|
|
3984
3987
|
totalValueUsd: networkTotal,
|
|
3985
3988
|
gasAssetCaip: nativeAssetCaip || null,
|
|
3986
3989
|
gasAssetSymbol: gasAsset?.ticker || gasAsset?.symbol || assetInfo?.symbol || null,
|
|
3990
|
+
gasAssetName: gasAsset?.name || assetInfo?.name || null,
|
|
3987
3991
|
icon: gasAsset?.icon || assetInfo?.icon || null,
|
|
3988
3992
|
color: gasAsset?.color || assetInfo?.color || null,
|
|
3989
3993
|
totalNativeBalance
|
package/dist/index.es.js
CHANGED
|
@@ -2090,8 +2090,9 @@ async function createUnsignedEvmTx(caip, to, amount, memo, pubkeys, pioneer, pub
|
|
|
2090
2090
|
nonce = 0;
|
|
2091
2091
|
}
|
|
2092
2092
|
const balanceData = await pioneer.GetBalanceAddressByNetwork({ networkId, address });
|
|
2093
|
-
const balanceEth = parseFloat(balanceData.data.balance);
|
|
2093
|
+
const balanceEth = parseFloat(balanceData.data.nativeBalance || balanceData.data.balance || "0");
|
|
2094
2094
|
const balance = BigInt(Math.round(balanceEth * 1000000000000000000));
|
|
2095
|
+
console.log(tag5, "Native ETH balance from API:", balanceData.data.nativeBalance || balanceData.data.balance, "ETH (", balance.toString(), "wei)");
|
|
2095
2096
|
if (balance <= 0n)
|
|
2096
2097
|
throw new Error("Wallet balance is zero");
|
|
2097
2098
|
const assetType = classifyCaipEvm(caip);
|
|
@@ -2251,7 +2252,9 @@ async function createUnsignedEvmTx(caip, to, amount, memo, pubkeys, pioneer, pub
|
|
|
2251
2252
|
resultWei: amountWei.toString()
|
|
2252
2253
|
});
|
|
2253
2254
|
}
|
|
2254
|
-
|
|
2255
|
+
const estimatedGasForCheck = BigInt(25000);
|
|
2256
|
+
const estimatedGasFee = gasPrice * estimatedGasForCheck;
|
|
2257
|
+
if (estimatedGasFee > balance) {
|
|
2255
2258
|
throw new Error("Insufficient ETH balance to cover gas fees");
|
|
2256
2259
|
}
|
|
2257
2260
|
const data = encodeTransferData(to, amountWei);
|
|
@@ -4160,6 +4163,7 @@ function buildDashboardFromBalances(balances, blockchains, assetsMap) {
|
|
|
4160
4163
|
totalValueUsd: networkTotal,
|
|
4161
4164
|
gasAssetCaip: nativeAssetCaip || null,
|
|
4162
4165
|
gasAssetSymbol: gasAsset?.ticker || gasAsset?.symbol || assetInfo?.symbol || null,
|
|
4166
|
+
gasAssetName: gasAsset?.name || assetInfo?.name || null,
|
|
4163
4167
|
icon: gasAsset?.icon || assetInfo?.icon || null,
|
|
4164
4168
|
color: gasAsset?.color || assetInfo?.color || null,
|
|
4165
4169
|
totalNativeBalance
|
package/dist/index.js
CHANGED
|
@@ -2090,8 +2090,9 @@ async function createUnsignedEvmTx(caip, to, amount, memo, pubkeys, pioneer, pub
|
|
|
2090
2090
|
nonce = 0;
|
|
2091
2091
|
}
|
|
2092
2092
|
const balanceData = await pioneer.GetBalanceAddressByNetwork({ networkId, address });
|
|
2093
|
-
const balanceEth = parseFloat(balanceData.data.balance);
|
|
2093
|
+
const balanceEth = parseFloat(balanceData.data.nativeBalance || balanceData.data.balance || "0");
|
|
2094
2094
|
const balance = BigInt(Math.round(balanceEth * 1000000000000000000));
|
|
2095
|
+
console.log(tag5, "Native ETH balance from API:", balanceData.data.nativeBalance || balanceData.data.balance, "ETH (", balance.toString(), "wei)");
|
|
2095
2096
|
if (balance <= 0n)
|
|
2096
2097
|
throw new Error("Wallet balance is zero");
|
|
2097
2098
|
const assetType = classifyCaipEvm(caip);
|
|
@@ -2251,7 +2252,9 @@ async function createUnsignedEvmTx(caip, to, amount, memo, pubkeys, pioneer, pub
|
|
|
2251
2252
|
resultWei: amountWei.toString()
|
|
2252
2253
|
});
|
|
2253
2254
|
}
|
|
2254
|
-
|
|
2255
|
+
const estimatedGasForCheck = BigInt(25000);
|
|
2256
|
+
const estimatedGasFee = gasPrice * estimatedGasForCheck;
|
|
2257
|
+
if (estimatedGasFee > balance) {
|
|
2255
2258
|
throw new Error("Insufficient ETH balance to cover gas fees");
|
|
2256
2259
|
}
|
|
2257
2260
|
const data = encodeTransferData(to, amountWei);
|
|
@@ -4160,6 +4163,7 @@ function buildDashboardFromBalances(balances, blockchains, assetsMap) {
|
|
|
4160
4163
|
totalValueUsd: networkTotal,
|
|
4161
4164
|
gasAssetCaip: nativeAssetCaip || null,
|
|
4162
4165
|
gasAssetSymbol: gasAsset?.ticker || gasAsset?.symbol || assetInfo?.symbol || null,
|
|
4166
|
+
gasAssetName: gasAsset?.name || assetInfo?.name || null,
|
|
4163
4167
|
icon: gasAsset?.icon || assetInfo?.icon || null,
|
|
4164
4168
|
color: gasAsset?.color || assetInfo?.color || null,
|
|
4165
4169
|
totalNativeBalance
|
package/package.json
CHANGED
|
@@ -269,9 +269,10 @@ export async function createUnsignedEvmTx(
|
|
|
269
269
|
//console.log(tag, 'nonce:', nonce);
|
|
270
270
|
|
|
271
271
|
const balanceData = await pioneer.GetBalanceAddressByNetwork({ networkId, address });
|
|
272
|
-
|
|
272
|
+
// Use nativeBalance for ETH balance (needed for gas fees), fallback to balance
|
|
273
|
+
const balanceEth = parseFloat(balanceData.data.nativeBalance || balanceData.data.balance || '0'); // Native ETH balance
|
|
273
274
|
const balance = BigInt(Math.round(balanceEth * 1e18)); // Convert to wei
|
|
274
|
-
|
|
275
|
+
console.log(tag, 'Native ETH balance from API:', balanceData.data.nativeBalance || balanceData.data.balance, 'ETH (', balance.toString(), 'wei)');
|
|
275
276
|
if (balance <= 0n) throw new Error('Wallet balance is zero');
|
|
276
277
|
|
|
277
278
|
// Classify asset type by CAIP
|
|
@@ -529,8 +530,12 @@ export async function createUnsignedEvmTx(
|
|
|
529
530
|
});
|
|
530
531
|
}
|
|
531
532
|
|
|
532
|
-
//
|
|
533
|
-
|
|
533
|
+
// Check balance using minimal gas estimate (25k)
|
|
534
|
+
// We use higher gasLimit (100k) for safety, but check with lower estimate to allow users to "push it"
|
|
535
|
+
// Most ERC20 transfers use 50-65k gas, so 25k gives users maximum flexibility
|
|
536
|
+
const estimatedGasForCheck = BigInt(25000);
|
|
537
|
+
const estimatedGasFee = gasPrice * estimatedGasForCheck;
|
|
538
|
+
if (estimatedGasFee > balance) {
|
|
534
539
|
throw new Error('Insufficient ETH balance to cover gas fees');
|
|
535
540
|
}
|
|
536
541
|
|
|
@@ -12,6 +12,7 @@ export function buildDashboardFromBalances(balances: any[], blockchains: string[
|
|
|
12
12
|
totalValueUsd: number;
|
|
13
13
|
gasAssetCaip: string | null;
|
|
14
14
|
gasAssetSymbol: string | null;
|
|
15
|
+
gasAssetName: string | null;
|
|
15
16
|
icon: string | null;
|
|
16
17
|
color: string | null;
|
|
17
18
|
totalNativeBalance: string;
|
|
@@ -30,6 +31,7 @@ export function buildDashboardFromBalances(balances: any[], blockchains: string[
|
|
|
30
31
|
totalValueUsd: number;
|
|
31
32
|
gasAssetCaip: string | null;
|
|
32
33
|
gasAssetSymbol: string | null;
|
|
34
|
+
gasAssetName: string | null;
|
|
33
35
|
icon: string | null;
|
|
34
36
|
color: string | null;
|
|
35
37
|
totalNativeBalance: string;
|
|
@@ -149,6 +151,7 @@ export function buildDashboardFromBalances(balances: any[], blockchains: string[
|
|
|
149
151
|
totalValueUsd: networkTotal,
|
|
150
152
|
gasAssetCaip: nativeAssetCaip || null,
|
|
151
153
|
gasAssetSymbol: gasAsset?.ticker || gasAsset?.symbol || assetInfo?.symbol || null,
|
|
154
|
+
gasAssetName: gasAsset?.name || assetInfo?.name || null,
|
|
152
155
|
icon: gasAsset?.icon || assetInfo?.icon || null,
|
|
153
156
|
color: gasAsset?.color || assetInfo?.color || null,
|
|
154
157
|
totalNativeBalance,
|