@pioneer-platform/pioneer-sdk 4.20.0 → 4.20.2
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 +594 -838
- package/dist/index.es.js +595 -838
- package/dist/index.js +595 -838
- package/package.json +2 -2
- package/src/TransactionManager.ts +21 -4
- package/src/fees/index.ts +60 -57
- package/src/fees/index.ts.backup +510 -0
- package/src/getPubkey.ts +57 -26
- package/src/index.ts +391 -61
- package/src/txbuilder/createUnsignedEvmTx.ts +118 -63
- package/src/txbuilder/createUnsignedRippleTx.ts +12 -11
- package/src/txbuilder/createUnsignedStakingTx.ts +13 -11
- package/src/txbuilder/createUnsignedTendermintTx.ts +41 -17
- package/src/txbuilder/createUnsignedUxtoTx.ts +122 -57
- package/src/txbuilder/createUnsignedUxtoTx.ts.backup +384 -0
- package/src/txbuilder/templates/mayachain.ts +2 -0
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"author": "highlander",
|
|
3
3
|
"name": "@pioneer-platform/pioneer-sdk",
|
|
4
|
-
"version": "4.20.
|
|
4
|
+
"version": "4.20.2",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@keepkey/keepkey-sdk": "^0.2.62",
|
|
7
7
|
"@pioneer-platform/loggerdog": "^8.11.0",
|
|
8
8
|
"@pioneer-platform/pioneer-caip": "^9.10.0",
|
|
9
|
-
"@pioneer-platform/pioneer-client": "^9.10.
|
|
9
|
+
"@pioneer-platform/pioneer-client": "^9.10.1",
|
|
10
10
|
"@pioneer-platform/pioneer-coins": "^9.11.0",
|
|
11
11
|
"@pioneer-platform/pioneer-discovery": "^0.8.0",
|
|
12
12
|
"@pioneer-platform/pioneer-events": "^8.11.0",
|
|
@@ -16,6 +16,7 @@ interface TransactionDependencies {
|
|
|
16
16
|
assetContext: any;
|
|
17
17
|
balances: any[];
|
|
18
18
|
pubkeys: any[];
|
|
19
|
+
pubkeyContext: any; // Current pubkey context for signing
|
|
19
20
|
nodes: any[];
|
|
20
21
|
pioneer: any;
|
|
21
22
|
keepKeySdk: any;
|
|
@@ -26,6 +27,7 @@ export class TransactionManager {
|
|
|
26
27
|
private assetContext: any;
|
|
27
28
|
private balances: any[];
|
|
28
29
|
private pubkeys: any[];
|
|
30
|
+
private pubkeyContext: any;
|
|
29
31
|
private nodes: any[];
|
|
30
32
|
private pioneer: any;
|
|
31
33
|
private keepKeySdk: any;
|
|
@@ -36,6 +38,7 @@ export class TransactionManager {
|
|
|
36
38
|
this.assetContext = dependencies.assetContext;
|
|
37
39
|
this.balances = dependencies.balances;
|
|
38
40
|
this.pubkeys = dependencies.pubkeys;
|
|
41
|
+
this.pubkeyContext = dependencies.pubkeyContext;
|
|
39
42
|
this.nodes = dependencies.nodes;
|
|
40
43
|
this.pioneer = dependencies.pioneer;
|
|
41
44
|
this.keepKeySdk = dependencies.keepKeySdk;
|
|
@@ -70,7 +73,7 @@ export class TransactionManager {
|
|
|
70
73
|
memo,
|
|
71
74
|
this.pubkeys,
|
|
72
75
|
this.pioneer,
|
|
73
|
-
this.
|
|
76
|
+
this.pubkeyContext,
|
|
74
77
|
isMax,
|
|
75
78
|
feeLevel,
|
|
76
79
|
changeScriptType,
|
|
@@ -86,7 +89,7 @@ export class TransactionManager {
|
|
|
86
89
|
memo,
|
|
87
90
|
this.pubkeys,
|
|
88
91
|
this.pioneer,
|
|
89
|
-
this.
|
|
92
|
+
this.pubkeyContext,
|
|
90
93
|
isMax,
|
|
91
94
|
to,
|
|
92
95
|
);
|
|
@@ -100,7 +103,7 @@ export class TransactionManager {
|
|
|
100
103
|
memo,
|
|
101
104
|
this.pubkeys,
|
|
102
105
|
this.pioneer,
|
|
103
|
-
this.
|
|
106
|
+
this.pubkeyContext,
|
|
104
107
|
isMax,
|
|
105
108
|
feeLevel,
|
|
106
109
|
);
|
|
@@ -114,7 +117,7 @@ export class TransactionManager {
|
|
|
114
117
|
memo,
|
|
115
118
|
this.pubkeys,
|
|
116
119
|
this.pioneer,
|
|
117
|
-
this.
|
|
120
|
+
this.pubkeyContext,
|
|
118
121
|
isMax,
|
|
119
122
|
);
|
|
120
123
|
break;
|
|
@@ -237,10 +240,24 @@ export class TransactionManager {
|
|
|
237
240
|
}
|
|
238
241
|
case 'cosmos:mayachain-mainnet-v1/slip44:931':
|
|
239
242
|
case 'cosmos:mayachain-mainnet-v1/denom:maya': {
|
|
243
|
+
// CRITICAL AUDIT: Log everything about the signing context
|
|
244
|
+
console.log(tag, '🔍 ===== MAYACHAIN SIGNING AUDIT =====');
|
|
245
|
+
console.log(tag, '📋 unsignedTx:', JSON.stringify(unsignedTx, null, 2));
|
|
246
|
+
console.log(tag, '🔑 unsignedTx.addressNList:', unsignedTx.addressNList);
|
|
247
|
+
console.log(tag, '📍 unsignedTx.signerAddress:', unsignedTx.signerAddress);
|
|
248
|
+
console.log(tag, '🌐 pubkeyContext:', this.pubkeyContext);
|
|
249
|
+
console.log(tag, '🔐 pubkeyContext.addressNList:', this.pubkeyContext?.addressNList);
|
|
250
|
+
console.log(tag, '🔐 pubkeyContext.addressNListMaster:', this.pubkeyContext?.addressNListMaster);
|
|
251
|
+
console.log(tag, '📬 pubkeyContext.address:', this.pubkeyContext?.address);
|
|
252
|
+
console.log(tag, '=======================================');
|
|
253
|
+
|
|
240
254
|
if (unsignedTx.signDoc.msgs[0].type === 'mayachain/MsgSend') {
|
|
241
255
|
const responseSign =
|
|
242
256
|
await this.keepKeySdk.mayachain.mayachainSignAminoTransfer(unsignedTx);
|
|
243
257
|
signedTx = responseSign.serialized;
|
|
258
|
+
|
|
259
|
+
console.log(tag, '✅ Signing completed');
|
|
260
|
+
console.log(tag, '📦 responseSign:', responseSign);
|
|
244
261
|
} else if (unsignedTx.signDoc.msgs[0].type === 'mayachain/MsgDeposit') {
|
|
245
262
|
const responseSign =
|
|
246
263
|
await this.keepKeySdk.mayachain.mayachainSignAminoDeposit(unsignedTx);
|
package/src/fees/index.ts
CHANGED
|
@@ -63,6 +63,18 @@ function getNetworkName(networkId: string): string {
|
|
|
63
63
|
return networkNames[networkId] || networkId;
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
+
/**
|
|
67
|
+
* Timeout wrapper for async operations
|
|
68
|
+
*/
|
|
69
|
+
function withTimeout<T>(promise: Promise<T>, timeoutMs: number): Promise<T> {
|
|
70
|
+
return Promise.race([
|
|
71
|
+
promise,
|
|
72
|
+
new Promise<T>((_, reject) =>
|
|
73
|
+
setTimeout(() => reject(new Error('Request timeout')), timeoutMs)
|
|
74
|
+
)
|
|
75
|
+
]);
|
|
76
|
+
}
|
|
77
|
+
|
|
66
78
|
/**
|
|
67
79
|
* Main fee fetching and normalization function
|
|
68
80
|
* Handles all the complexity of different API formats and returns
|
|
@@ -84,12 +96,6 @@ export async function getFees(
|
|
|
84
96
|
return getCosmosFees(networkId);
|
|
85
97
|
}
|
|
86
98
|
|
|
87
|
-
// For Ripple, always use hardcoded fees (API doesn't support it)
|
|
88
|
-
if (networkType === 'RIPPLE') {
|
|
89
|
-
console.log(tag, 'Using hardcoded fees for Ripple:', networkId);
|
|
90
|
-
return getRippleFees(networkId);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
99
|
// Hardcode DOGE fees at 10 sat/byte (API and Blockbook often unreliable for DOGE)
|
|
94
100
|
if (networkId === 'bip122:00000000001a91e3dace36e2be3bf030') {
|
|
95
101
|
console.log(tag, 'Using hardcoded fees for Dogecoin: 10 sat/byte');
|
|
@@ -124,10 +130,53 @@ export async function getFees(
|
|
|
124
130
|
};
|
|
125
131
|
}
|
|
126
132
|
|
|
127
|
-
// Get raw fee data from API
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
133
|
+
// Get raw fee data from API with timeout for Dash (slow API)
|
|
134
|
+
let feeResponse;
|
|
135
|
+
if (networkId === 'bip122:000007d91d1254d60e2dd1ae58038307') {
|
|
136
|
+
// Dash with 3 second timeout and fallback
|
|
137
|
+
try {
|
|
138
|
+
const apiCall = pioneer.GetFeeRateByNetwork
|
|
139
|
+
? pioneer.GetFeeRateByNetwork({ networkId })
|
|
140
|
+
: pioneer.GetFeeRate({ networkId });
|
|
141
|
+
feeResponse = await withTimeout(apiCall, 3000);
|
|
142
|
+
} catch (timeoutError) {
|
|
143
|
+
console.warn(tag, 'Dash fee API timeout, using fallback fees');
|
|
144
|
+
return {
|
|
145
|
+
slow: {
|
|
146
|
+
label: 'Economy',
|
|
147
|
+
value: '5',
|
|
148
|
+
unit: 'sat/byte',
|
|
149
|
+
description: 'Low priority - 30+ minutes',
|
|
150
|
+
estimatedTime: '~30 minutes',
|
|
151
|
+
priority: 'low'
|
|
152
|
+
},
|
|
153
|
+
average: {
|
|
154
|
+
label: 'Standard',
|
|
155
|
+
value: '8',
|
|
156
|
+
unit: 'sat/byte',
|
|
157
|
+
description: 'Normal priority - 10-30 minutes',
|
|
158
|
+
estimatedTime: '~15 minutes',
|
|
159
|
+
priority: 'medium'
|
|
160
|
+
},
|
|
161
|
+
fastest: {
|
|
162
|
+
label: 'Priority',
|
|
163
|
+
value: '10',
|
|
164
|
+
unit: 'sat/byte',
|
|
165
|
+
description: 'High priority - next block',
|
|
166
|
+
estimatedTime: '~5 minutes',
|
|
167
|
+
priority: 'high'
|
|
168
|
+
},
|
|
169
|
+
networkId,
|
|
170
|
+
networkType: 'UTXO',
|
|
171
|
+
raw: { hardcoded: true, reason: 'Dash API timeout, using conservative fallback fees' }
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
} else {
|
|
175
|
+
// Normal API call for other networks
|
|
176
|
+
feeResponse = await (pioneer.GetFeeRateByNetwork
|
|
177
|
+
? pioneer.GetFeeRateByNetwork({ networkId })
|
|
178
|
+
: pioneer.GetFeeRate({ networkId }));
|
|
179
|
+
}
|
|
131
180
|
|
|
132
181
|
if (!feeResponse || !feeResponse.data) {
|
|
133
182
|
throw new Error(`No fee data returned for ${networkId}`);
|
|
@@ -136,11 +185,6 @@ export async function getFees(
|
|
|
136
185
|
const feeData = feeResponse.data;
|
|
137
186
|
console.log(tag, 'Raw fee data:', feeData);
|
|
138
187
|
|
|
139
|
-
// Check if API returned an error response
|
|
140
|
-
if (feeData.success === false || feeData.error) {
|
|
141
|
-
throw new Error(feeData.error || `API error for ${networkId}`);
|
|
142
|
-
}
|
|
143
|
-
|
|
144
188
|
// Network type already detected above, just get network name
|
|
145
189
|
const networkName = getNetworkName(networkId);
|
|
146
190
|
|
|
@@ -438,7 +482,7 @@ function getCosmosFees(networkId: string): NormalizedFeeRates {
|
|
|
438
482
|
// These match the fees in txbuilder/createUnsignedTendermintTx.ts
|
|
439
483
|
const cosmosFeesMap: Record<string, { base: number; unit: string; denom: string }> = {
|
|
440
484
|
'cosmos:thorchain-mainnet-v1': { base: 0.02, unit: 'RUNE', denom: 'rune' },
|
|
441
|
-
'cosmos:mayachain-mainnet-v1': { base: 0.
|
|
485
|
+
'cosmos:mayachain-mainnet-v1': { base: 0.5, unit: 'CACAO', denom: 'cacao' },
|
|
442
486
|
'cosmos:cosmoshub-4': { base: 0.005, unit: 'ATOM', denom: 'uatom' },
|
|
443
487
|
'cosmos:osmosis-1': { base: 0.035, unit: 'OSMO', denom: 'uosmo' },
|
|
444
488
|
};
|
|
@@ -481,47 +525,6 @@ function getCosmosFees(networkId: string): NormalizedFeeRates {
|
|
|
481
525
|
};
|
|
482
526
|
}
|
|
483
527
|
|
|
484
|
-
/**
|
|
485
|
-
* Get hardcoded Ripple fees
|
|
486
|
-
*/
|
|
487
|
-
function getRippleFees(networkId: string): NormalizedFeeRates {
|
|
488
|
-
const networkName = getNetworkName(networkId);
|
|
489
|
-
|
|
490
|
-
// XRP has a fixed minimum fee of 0.00001 XRP (10 drops)
|
|
491
|
-
// This is hardcoded in the network protocol
|
|
492
|
-
const baseFee = '0.00001';
|
|
493
|
-
|
|
494
|
-
return {
|
|
495
|
-
slow: {
|
|
496
|
-
label: 'Standard',
|
|
497
|
-
value: baseFee,
|
|
498
|
-
unit: 'XRP',
|
|
499
|
-
description: `Fixed network fee for ${networkName}. All transactions use the same fee.`,
|
|
500
|
-
estimatedTime: '~4 seconds',
|
|
501
|
-
priority: 'low',
|
|
502
|
-
},
|
|
503
|
-
average: {
|
|
504
|
-
label: 'Standard',
|
|
505
|
-
value: baseFee,
|
|
506
|
-
unit: 'XRP',
|
|
507
|
-
description: `Fixed network fee for ${networkName}. All transactions use the same fee.`,
|
|
508
|
-
estimatedTime: '~4 seconds',
|
|
509
|
-
priority: 'medium',
|
|
510
|
-
},
|
|
511
|
-
fastest: {
|
|
512
|
-
label: 'Standard',
|
|
513
|
-
value: baseFee,
|
|
514
|
-
unit: 'XRP',
|
|
515
|
-
description: `Fixed network fee for ${networkName}. All transactions use the same fee.`,
|
|
516
|
-
estimatedTime: '~4 seconds',
|
|
517
|
-
priority: 'high',
|
|
518
|
-
},
|
|
519
|
-
networkId,
|
|
520
|
-
networkType: 'RIPPLE',
|
|
521
|
-
raw: { hardcoded: true, baseFee, reason: 'Ripple uses fixed network fees' },
|
|
522
|
-
};
|
|
523
|
-
}
|
|
524
|
-
|
|
525
528
|
/**
|
|
526
529
|
* Get fallback fees when API fails
|
|
527
530
|
*/
|