@pioneer-platform/pioneer-sdk 8.20.0 → 8.22.0
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 +1570 -1240
- package/dist/index.es.js +1570 -1240
- package/dist/index.js +1570 -1240
- package/package.json +6 -6
- package/src/TransactionManager.ts +87 -0
- package/src/index.ts +22 -0
- package/src/supportedCaips.ts +2 -1
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"author": "highlander",
|
|
3
3
|
"name": "@pioneer-platform/pioneer-sdk",
|
|
4
|
-
"version": "8.
|
|
4
|
+
"version": "8.22.0",
|
|
5
5
|
"dependencies": {
|
|
6
|
-
"keepkey-vault-sdk": "^1.
|
|
7
|
-
"@pioneer-platform/pioneer-caip": "^9.
|
|
6
|
+
"keepkey-vault-sdk": "^1.2.1",
|
|
7
|
+
"@pioneer-platform/pioneer-caip": "^9.17.0",
|
|
8
8
|
"@pioneer-platform/pioneer-client": "^9.10.24",
|
|
9
|
-
"@pioneer-platform/pioneer-coins": "^9.
|
|
10
|
-
"@pioneer-platform/pioneer-discovery": "^8.
|
|
11
|
-
"@pioneer-platform/pioneer-events": "^8.
|
|
9
|
+
"@pioneer-platform/pioneer-coins": "^9.18.0",
|
|
10
|
+
"@pioneer-platform/pioneer-discovery": "^8.22.0",
|
|
11
|
+
"@pioneer-platform/pioneer-events": "^8.18.0",
|
|
12
12
|
"coinselect": "^3.1.13",
|
|
13
13
|
"eventemitter3": "^5.0.1",
|
|
14
14
|
"neotraverse": "^0.6.8",
|
|
@@ -456,6 +456,93 @@ export class TransactionManager {
|
|
|
456
456
|
}
|
|
457
457
|
}
|
|
458
458
|
|
|
459
|
+
async signMessage({ caip, message, addressNList }: any): Promise<any> {
|
|
460
|
+
let tag = TAG + ' | signMessage | ';
|
|
461
|
+
try {
|
|
462
|
+
if (!this.pioneer) throw Error('Failed to init! pioneer');
|
|
463
|
+
if (!caip) throw Error('Missing required param! caip');
|
|
464
|
+
if (!message) throw Error('Missing required param! message');
|
|
465
|
+
if (!addressNList) throw Error('Missing required param! addressNList');
|
|
466
|
+
|
|
467
|
+
const type = await this.classifyCaip(caip);
|
|
468
|
+
|
|
469
|
+
let signedMessage: any;
|
|
470
|
+
|
|
471
|
+
switch (type) {
|
|
472
|
+
case 'OTHER': {
|
|
473
|
+
if (caip.startsWith('solana:')) {
|
|
474
|
+
// Solana message signing via keepkey-server REST API
|
|
475
|
+
const signRequest = {
|
|
476
|
+
addressNList,
|
|
477
|
+
message, // Already base64 encoded
|
|
478
|
+
showDisplay: true
|
|
479
|
+
};
|
|
480
|
+
|
|
481
|
+
try {
|
|
482
|
+
// Create AbortController with 2-minute timeout for manual device confirmation
|
|
483
|
+
const controller = new AbortController();
|
|
484
|
+
const timeoutId = setTimeout(() => controller.abort(), 120000); // 2 minutes
|
|
485
|
+
|
|
486
|
+
try {
|
|
487
|
+
const response = await fetch('http://localhost:1646/solana/sign-message', {
|
|
488
|
+
method: 'POST',
|
|
489
|
+
headers: {
|
|
490
|
+
'Content-Type': 'application/json',
|
|
491
|
+
},
|
|
492
|
+
body: JSON.stringify(signRequest),
|
|
493
|
+
signal: controller.signal
|
|
494
|
+
});
|
|
495
|
+
|
|
496
|
+
clearTimeout(timeoutId);
|
|
497
|
+
|
|
498
|
+
if (!response.ok) {
|
|
499
|
+
const errorData = await response.json();
|
|
500
|
+
throw new Error(`Solana message signing failed: ${errorData.error || response.statusText}`);
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
const responseSign = await response.json();
|
|
504
|
+
if (responseSign?.signature) {
|
|
505
|
+
signedMessage = {
|
|
506
|
+
signature: responseSign.signature,
|
|
507
|
+
publicKey: responseSign.publicKey
|
|
508
|
+
};
|
|
509
|
+
} else {
|
|
510
|
+
throw new Error('Solana message signing failed - no signature in response');
|
|
511
|
+
}
|
|
512
|
+
} catch (fetchError: any) {
|
|
513
|
+
clearTimeout(timeoutId);
|
|
514
|
+
if (fetchError.name === 'AbortError') {
|
|
515
|
+
throw new Error('Solana message signing timed out after 2 minutes');
|
|
516
|
+
}
|
|
517
|
+
throw fetchError;
|
|
518
|
+
}
|
|
519
|
+
} catch (e: any) {
|
|
520
|
+
console.error(tag, 'Solana message signing error:', e);
|
|
521
|
+
throw new Error(`Solana message signing failed: ${e.message}`);
|
|
522
|
+
}
|
|
523
|
+
} else {
|
|
524
|
+
throw new Error(`Message signing not supported for CAIP: ${caip}`);
|
|
525
|
+
}
|
|
526
|
+
break;
|
|
527
|
+
}
|
|
528
|
+
default: {
|
|
529
|
+
throw new Error(`Message signing not supported for CAIP type: ${type}`);
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
if (!signedMessage) {
|
|
534
|
+
console.error(tag, 'CRITICAL ERROR: signedMessage is missing after signing process');
|
|
535
|
+
console.error(tag, 'CAIP:', caip);
|
|
536
|
+
console.error(tag, 'Type:', type);
|
|
537
|
+
throw Error('Failed to sign message! missing signedMessage');
|
|
538
|
+
}
|
|
539
|
+
return signedMessage;
|
|
540
|
+
} catch (e: any) {
|
|
541
|
+
console.error(tag, e);
|
|
542
|
+
throw e;
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
|
|
459
546
|
async broadcast({ networkId, serialized }: any): Promise<any> {
|
|
460
547
|
let tag = TAG + ' | broadcast | ';
|
|
461
548
|
try {
|
package/src/index.ts
CHANGED
|
@@ -192,6 +192,7 @@ export class SDK {
|
|
|
192
192
|
}>;
|
|
193
193
|
public broadcastTx: (caip: string, signedTx: any) => Promise<any>;
|
|
194
194
|
public signTx: (caip: string, unsignedTx: any) => Promise<any>;
|
|
195
|
+
public signMessage: (caip: string, message: string, addressNList: number[]) => Promise<any>;
|
|
195
196
|
public buildTx: (sendPayload: any) => Promise<any>;
|
|
196
197
|
public buildDelegateTx: (caip: string, params: StakingTxParams) => Promise<any>;
|
|
197
198
|
public buildUndelegateTx: (caip: string, params: StakingTxParams) => Promise<any>;
|
|
@@ -978,6 +979,27 @@ export class SDK {
|
|
|
978
979
|
throw e;
|
|
979
980
|
}
|
|
980
981
|
};
|
|
982
|
+
this.signMessage = async function (caip: string, message: string, addressNList: number[]) {
|
|
983
|
+
let tag = TAG + ' | signMessage | ';
|
|
984
|
+
try {
|
|
985
|
+
const transactionDependencies = {
|
|
986
|
+
context: this.context,
|
|
987
|
+
assetContext: this.assetContext,
|
|
988
|
+
balances: this.balances,
|
|
989
|
+
pioneer: this.pioneer,
|
|
990
|
+
pubkeys: this.pubkeys,
|
|
991
|
+
pubkeyContext: this.pubkeyContext,
|
|
992
|
+
nodes: this.nodes,
|
|
993
|
+
keepKeySdk: this.keepKeySdk,
|
|
994
|
+
};
|
|
995
|
+
let txManager = new TransactionManager(transactionDependencies, this.events);
|
|
996
|
+
let signedMessage = await txManager.signMessage({ caip, message, addressNList });
|
|
997
|
+
return signedMessage;
|
|
998
|
+
} catch (e) {
|
|
999
|
+
console.error(e);
|
|
1000
|
+
throw e;
|
|
1001
|
+
}
|
|
1002
|
+
};
|
|
981
1003
|
this.broadcastTx = async function (caip: string, signedTx: any) {
|
|
982
1004
|
let tag = TAG + ' | broadcastTx | ';
|
|
983
1005
|
try {
|
package/src/supportedCaips.ts
CHANGED
|
@@ -32,7 +32,8 @@ export const CAIP_TO_COIN_MAP: { [key: string]: string } = {
|
|
|
32
32
|
|
|
33
33
|
export const OTHER_SUPPORT = [
|
|
34
34
|
'ripple:4109c6f2045fc7eff4cde8f9905d19c2/slip44:144', // XRP
|
|
35
|
-
'solana:5eykt4usfv8p8njdtrepy1vzqkqzkvdp/solana:so11111111111111111111111111111111111111112', // SOL
|
|
35
|
+
'solana:5eykt4usfv8p8njdtrepy1vzqkqzkvdp/solana:so11111111111111111111111111111111111111112', // SOL (native asset)
|
|
36
|
+
'solana:5eykt4usfv8p8njdtrepy1vzqkqzkvdp', // SOL (chain-only for message signing)
|
|
36
37
|
'tron:0x2b6653dc/slip44:195', // TRX
|
|
37
38
|
'ton:-239/slip44:607', // TON
|
|
38
39
|
];
|