@pioneer-platform/pioneer-sdk 4.20.15 → 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 +11 -6
- package/dist/index.es.js +11 -6
- package/dist/index.js +11 -6
- package/package.json +1 -1
- package/src/TransactionManager.ts +4 -3
- package/src/txbuilder/createUnsignedEvmTx.ts +9 -4
- package/src/txbuilder/templates/thorchain.ts +1 -1
- package/src/utils/build-dashboard.ts +3 -0
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);
|
|
@@ -2315,7 +2318,7 @@ var thorchainTransferTemplate = (params) => ({
|
|
|
2315
2318
|
to_address: params.to_address,
|
|
2316
2319
|
from_address: params.from_address
|
|
2317
2320
|
},
|
|
2318
|
-
type: "
|
|
2321
|
+
type: "thorchain/MsgSend"
|
|
2319
2322
|
}
|
|
2320
2323
|
],
|
|
2321
2324
|
memo: params.memo,
|
|
@@ -3054,14 +3057,15 @@ class TransactionManager {
|
|
|
3054
3057
|
break;
|
|
3055
3058
|
}
|
|
3056
3059
|
case "cosmos:thorchain-mainnet-v1/slip44:931": {
|
|
3057
|
-
|
|
3060
|
+
const msgType = unsignedTx.signDoc.msgs[0].type;
|
|
3061
|
+
if (msgType === "thorchain/MsgSend" || msgType === "cosmos-sdk/MsgSend") {
|
|
3058
3062
|
const responseSign = await this.keepKeySdk.thorchain.thorchainSignAminoTransfer(unsignedTx);
|
|
3059
3063
|
signedTx = responseSign.serialized;
|
|
3060
|
-
} else if (
|
|
3064
|
+
} else if (msgType === "thorchain/MsgDeposit") {
|
|
3061
3065
|
const responseSign = await this.keepKeySdk.thorchain.thorchainSignAminoDeposit(unsignedTx);
|
|
3062
3066
|
signedTx = responseSign.serialized;
|
|
3063
3067
|
} else {
|
|
3064
|
-
throw new Error(`Unsupported Thorchain message type: ${
|
|
3068
|
+
throw new Error(`Unsupported Thorchain message type: ${msgType}`);
|
|
3065
3069
|
}
|
|
3066
3070
|
break;
|
|
3067
3071
|
}
|
|
@@ -3983,6 +3987,7 @@ function buildDashboardFromBalances(balances, blockchains, assetsMap) {
|
|
|
3983
3987
|
totalValueUsd: networkTotal,
|
|
3984
3988
|
gasAssetCaip: nativeAssetCaip || null,
|
|
3985
3989
|
gasAssetSymbol: gasAsset?.ticker || gasAsset?.symbol || assetInfo?.symbol || null,
|
|
3990
|
+
gasAssetName: gasAsset?.name || assetInfo?.name || null,
|
|
3986
3991
|
icon: gasAsset?.icon || assetInfo?.icon || null,
|
|
3987
3992
|
color: gasAsset?.color || assetInfo?.color || null,
|
|
3988
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);
|
|
@@ -2491,7 +2494,7 @@ var thorchainTransferTemplate = (params) => ({
|
|
|
2491
2494
|
to_address: params.to_address,
|
|
2492
2495
|
from_address: params.from_address
|
|
2493
2496
|
},
|
|
2494
|
-
type: "
|
|
2497
|
+
type: "thorchain/MsgSend"
|
|
2495
2498
|
}
|
|
2496
2499
|
],
|
|
2497
2500
|
memo: params.memo,
|
|
@@ -3230,14 +3233,15 @@ class TransactionManager {
|
|
|
3230
3233
|
break;
|
|
3231
3234
|
}
|
|
3232
3235
|
case "cosmos:thorchain-mainnet-v1/slip44:931": {
|
|
3233
|
-
|
|
3236
|
+
const msgType = unsignedTx.signDoc.msgs[0].type;
|
|
3237
|
+
if (msgType === "thorchain/MsgSend" || msgType === "cosmos-sdk/MsgSend") {
|
|
3234
3238
|
const responseSign = await this.keepKeySdk.thorchain.thorchainSignAminoTransfer(unsignedTx);
|
|
3235
3239
|
signedTx = responseSign.serialized;
|
|
3236
|
-
} else if (
|
|
3240
|
+
} else if (msgType === "thorchain/MsgDeposit") {
|
|
3237
3241
|
const responseSign = await this.keepKeySdk.thorchain.thorchainSignAminoDeposit(unsignedTx);
|
|
3238
3242
|
signedTx = responseSign.serialized;
|
|
3239
3243
|
} else {
|
|
3240
|
-
throw new Error(`Unsupported Thorchain message type: ${
|
|
3244
|
+
throw new Error(`Unsupported Thorchain message type: ${msgType}`);
|
|
3241
3245
|
}
|
|
3242
3246
|
break;
|
|
3243
3247
|
}
|
|
@@ -4159,6 +4163,7 @@ function buildDashboardFromBalances(balances, blockchains, assetsMap) {
|
|
|
4159
4163
|
totalValueUsd: networkTotal,
|
|
4160
4164
|
gasAssetCaip: nativeAssetCaip || null,
|
|
4161
4165
|
gasAssetSymbol: gasAsset?.ticker || gasAsset?.symbol || assetInfo?.symbol || null,
|
|
4166
|
+
gasAssetName: gasAsset?.name || assetInfo?.name || null,
|
|
4162
4167
|
icon: gasAsset?.icon || assetInfo?.icon || null,
|
|
4163
4168
|
color: gasAsset?.color || assetInfo?.color || null,
|
|
4164
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);
|
|
@@ -2491,7 +2494,7 @@ var thorchainTransferTemplate = (params) => ({
|
|
|
2491
2494
|
to_address: params.to_address,
|
|
2492
2495
|
from_address: params.from_address
|
|
2493
2496
|
},
|
|
2494
|
-
type: "
|
|
2497
|
+
type: "thorchain/MsgSend"
|
|
2495
2498
|
}
|
|
2496
2499
|
],
|
|
2497
2500
|
memo: params.memo,
|
|
@@ -3230,14 +3233,15 @@ class TransactionManager {
|
|
|
3230
3233
|
break;
|
|
3231
3234
|
}
|
|
3232
3235
|
case "cosmos:thorchain-mainnet-v1/slip44:931": {
|
|
3233
|
-
|
|
3236
|
+
const msgType = unsignedTx.signDoc.msgs[0].type;
|
|
3237
|
+
if (msgType === "thorchain/MsgSend" || msgType === "cosmos-sdk/MsgSend") {
|
|
3234
3238
|
const responseSign = await this.keepKeySdk.thorchain.thorchainSignAminoTransfer(unsignedTx);
|
|
3235
3239
|
signedTx = responseSign.serialized;
|
|
3236
|
-
} else if (
|
|
3240
|
+
} else if (msgType === "thorchain/MsgDeposit") {
|
|
3237
3241
|
const responseSign = await this.keepKeySdk.thorchain.thorchainSignAminoDeposit(unsignedTx);
|
|
3238
3242
|
signedTx = responseSign.serialized;
|
|
3239
3243
|
} else {
|
|
3240
|
-
throw new Error(`Unsupported Thorchain message type: ${
|
|
3244
|
+
throw new Error(`Unsupported Thorchain message type: ${msgType}`);
|
|
3241
3245
|
}
|
|
3242
3246
|
break;
|
|
3243
3247
|
}
|
|
@@ -4159,6 +4163,7 @@ function buildDashboardFromBalances(balances, blockchains, assetsMap) {
|
|
|
4159
4163
|
totalValueUsd: networkTotal,
|
|
4160
4164
|
gasAssetCaip: nativeAssetCaip || null,
|
|
4161
4165
|
gasAssetSymbol: gasAsset?.ticker || gasAsset?.symbol || assetInfo?.symbol || null,
|
|
4166
|
+
gasAssetName: gasAsset?.name || assetInfo?.name || null,
|
|
4162
4167
|
icon: gasAsset?.icon || assetInfo?.icon || null,
|
|
4163
4168
|
color: gasAsset?.color || assetInfo?.color || null,
|
|
4164
4169
|
totalNativeBalance
|
package/package.json
CHANGED
|
@@ -223,17 +223,18 @@ export class TransactionManager {
|
|
|
223
223
|
break;
|
|
224
224
|
}
|
|
225
225
|
case 'cosmos:thorchain-mainnet-v1/slip44:931': {
|
|
226
|
-
|
|
226
|
+
const msgType = unsignedTx.signDoc.msgs[0].type;
|
|
227
|
+
if (msgType === 'thorchain/MsgSend' || msgType === 'cosmos-sdk/MsgSend') {
|
|
227
228
|
const responseSign =
|
|
228
229
|
await this.keepKeySdk.thorchain.thorchainSignAminoTransfer(unsignedTx);
|
|
229
230
|
signedTx = responseSign.serialized;
|
|
230
|
-
} else if (
|
|
231
|
+
} else if (msgType === 'thorchain/MsgDeposit') {
|
|
231
232
|
const responseSign =
|
|
232
233
|
await this.keepKeySdk.thorchain.thorchainSignAminoDeposit(unsignedTx);
|
|
233
234
|
signedTx = responseSign.serialized;
|
|
234
235
|
} else {
|
|
235
236
|
throw new Error(
|
|
236
|
-
`Unsupported Thorchain message type: ${
|
|
237
|
+
`Unsupported Thorchain message type: ${msgType}`,
|
|
237
238
|
);
|
|
238
239
|
}
|
|
239
240
|
break;
|
|
@@ -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,
|