@pioneer-platform/pioneer-sdk 8.11.14 → 8.11.18
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 +3 -5
- package/dist/index.es.js +3 -5
- package/dist/index.js +3 -5
- package/package.json +1 -1
- package/src/txbuilder/createUnsignedEvmTx.ts +4 -8
package/dist/index.cjs
CHANGED
|
@@ -1187,10 +1187,9 @@ async function createUnsignedEvmTx(caip, to, amount, memo, pubkeys, pioneer, pub
|
|
|
1187
1187
|
}
|
|
1188
1188
|
case "erc20": {
|
|
1189
1189
|
const contractAddress = extractContractAddressFromCaip(caip);
|
|
1190
|
-
console.log(tag, "Fetching token decimals
|
|
1190
|
+
console.log(tag, "Fetching token decimals via pioneer-server API for", contractAddress, "on", networkId);
|
|
1191
1191
|
let tokenDecimals;
|
|
1192
1192
|
try {
|
|
1193
|
-
console.log(tag, "Fetching token decimals via pioneer-server API for", contractAddress, "on", networkId);
|
|
1194
1193
|
const decimalsResponse = await pioneer.GetTokenDecimals({
|
|
1195
1194
|
networkId,
|
|
1196
1195
|
contractAddress
|
|
@@ -1198,9 +1197,8 @@ async function createUnsignedEvmTx(caip, to, amount, memo, pubkeys, pioneer, pub
|
|
|
1198
1197
|
tokenDecimals = Number(decimalsResponse.data.decimals);
|
|
1199
1198
|
console.log(tag, "✅ Fetched decimals from pioneer-server:", tokenDecimals);
|
|
1200
1199
|
} catch (error) {
|
|
1201
|
-
console.error(tag, "Failed to fetch token decimals from pioneer-server:", error);
|
|
1202
|
-
|
|
1203
|
-
tokenDecimals = 18;
|
|
1200
|
+
console.error(tag, "❌ CRITICAL ERROR: Failed to fetch token decimals from pioneer-server:", error);
|
|
1201
|
+
throw new Error(`Cannot build transaction: Failed to fetch decimals for token ${contractAddress} on ${networkId}. Error: ${error.message}`);
|
|
1204
1202
|
}
|
|
1205
1203
|
const tokenMultiplier = 10n ** BigInt(tokenDecimals);
|
|
1206
1204
|
let gasLimit = BigInt(1e5);
|
package/dist/index.es.js
CHANGED
|
@@ -1363,10 +1363,9 @@ async function createUnsignedEvmTx(caip, to, amount, memo, pubkeys, pioneer, pub
|
|
|
1363
1363
|
}
|
|
1364
1364
|
case "erc20": {
|
|
1365
1365
|
const contractAddress = extractContractAddressFromCaip(caip);
|
|
1366
|
-
console.log(tag, "Fetching token decimals
|
|
1366
|
+
console.log(tag, "Fetching token decimals via pioneer-server API for", contractAddress, "on", networkId);
|
|
1367
1367
|
let tokenDecimals;
|
|
1368
1368
|
try {
|
|
1369
|
-
console.log(tag, "Fetching token decimals via pioneer-server API for", contractAddress, "on", networkId);
|
|
1370
1369
|
const decimalsResponse = await pioneer.GetTokenDecimals({
|
|
1371
1370
|
networkId,
|
|
1372
1371
|
contractAddress
|
|
@@ -1374,9 +1373,8 @@ async function createUnsignedEvmTx(caip, to, amount, memo, pubkeys, pioneer, pub
|
|
|
1374
1373
|
tokenDecimals = Number(decimalsResponse.data.decimals);
|
|
1375
1374
|
console.log(tag, "✅ Fetched decimals from pioneer-server:", tokenDecimals);
|
|
1376
1375
|
} catch (error) {
|
|
1377
|
-
console.error(tag, "Failed to fetch token decimals from pioneer-server:", error);
|
|
1378
|
-
|
|
1379
|
-
tokenDecimals = 18;
|
|
1376
|
+
console.error(tag, "❌ CRITICAL ERROR: Failed to fetch token decimals from pioneer-server:", error);
|
|
1377
|
+
throw new Error(`Cannot build transaction: Failed to fetch decimals for token ${contractAddress} on ${networkId}. Error: ${error.message}`);
|
|
1380
1378
|
}
|
|
1381
1379
|
const tokenMultiplier = 10n ** BigInt(tokenDecimals);
|
|
1382
1380
|
let gasLimit = BigInt(1e5);
|
package/dist/index.js
CHANGED
|
@@ -1363,10 +1363,9 @@ async function createUnsignedEvmTx(caip, to, amount, memo, pubkeys, pioneer, pub
|
|
|
1363
1363
|
}
|
|
1364
1364
|
case "erc20": {
|
|
1365
1365
|
const contractAddress = extractContractAddressFromCaip(caip);
|
|
1366
|
-
console.log(tag, "Fetching token decimals
|
|
1366
|
+
console.log(tag, "Fetching token decimals via pioneer-server API for", contractAddress, "on", networkId);
|
|
1367
1367
|
let tokenDecimals;
|
|
1368
1368
|
try {
|
|
1369
|
-
console.log(tag, "Fetching token decimals via pioneer-server API for", contractAddress, "on", networkId);
|
|
1370
1369
|
const decimalsResponse = await pioneer.GetTokenDecimals({
|
|
1371
1370
|
networkId,
|
|
1372
1371
|
contractAddress
|
|
@@ -1374,9 +1373,8 @@ async function createUnsignedEvmTx(caip, to, amount, memo, pubkeys, pioneer, pub
|
|
|
1374
1373
|
tokenDecimals = Number(decimalsResponse.data.decimals);
|
|
1375
1374
|
console.log(tag, "✅ Fetched decimals from pioneer-server:", tokenDecimals);
|
|
1376
1375
|
} catch (error) {
|
|
1377
|
-
console.error(tag, "Failed to fetch token decimals from pioneer-server:", error);
|
|
1378
|
-
|
|
1379
|
-
tokenDecimals = 18;
|
|
1376
|
+
console.error(tag, "❌ CRITICAL ERROR: Failed to fetch token decimals from pioneer-server:", error);
|
|
1377
|
+
throw new Error(`Cannot build transaction: Failed to fetch decimals for token ${contractAddress} on ${networkId}. Error: ${error.message}`);
|
|
1380
1378
|
}
|
|
1381
1379
|
const tokenMultiplier = 10n ** BigInt(tokenDecimals);
|
|
1382
1380
|
let gasLimit = BigInt(1e5);
|
package/package.json
CHANGED
|
@@ -470,13 +470,11 @@ export async function createUnsignedEvmTx(
|
|
|
470
470
|
const contractAddress = extractContractAddressFromCaip(caip);
|
|
471
471
|
|
|
472
472
|
// Get token decimals from contract - CRITICAL for correct amount calculation
|
|
473
|
-
//
|
|
474
|
-
console.log(tag, 'Fetching token decimals
|
|
473
|
+
// FAIL FAST: No fallback to 18 decimals - if we can't fetch decimals, abort the transaction
|
|
474
|
+
console.log(tag, 'Fetching token decimals via pioneer-server API for', contractAddress, 'on', networkId);
|
|
475
475
|
|
|
476
476
|
let tokenDecimals: number;
|
|
477
477
|
try {
|
|
478
|
-
// Call pioneer-server API to get token decimals (server handles RPC calls)
|
|
479
|
-
console.log(tag, 'Fetching token decimals via pioneer-server API for', contractAddress, 'on', networkId);
|
|
480
478
|
const decimalsResponse = await pioneer.GetTokenDecimals({
|
|
481
479
|
networkId,
|
|
482
480
|
contractAddress,
|
|
@@ -485,10 +483,8 @@ export async function createUnsignedEvmTx(
|
|
|
485
483
|
tokenDecimals = Number(decimalsResponse.data.decimals);
|
|
486
484
|
console.log(tag, '✅ Fetched decimals from pioneer-server:', tokenDecimals);
|
|
487
485
|
} catch (error: any) {
|
|
488
|
-
console.error(tag, 'Failed to fetch token decimals from pioneer-server:', error);
|
|
489
|
-
|
|
490
|
-
console.warn(tag, '⚠️ FALLBACK: Using default 18 decimals - THIS MAY BE INCORRECT!');
|
|
491
|
-
tokenDecimals = 18;
|
|
486
|
+
console.error(tag, '❌ CRITICAL ERROR: Failed to fetch token decimals from pioneer-server:', error);
|
|
487
|
+
throw new Error(`Cannot build transaction: Failed to fetch decimals for token ${contractAddress} on ${networkId}. Error: ${error.message}`);
|
|
492
488
|
}
|
|
493
489
|
|
|
494
490
|
// Use BigInt for precise decimal math (no float drift)
|