@pioneer-platform/pioneer-sdk 8.20.0 → 8.21.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 +102 -0
- package/dist/index.es.js +102 -0
- package/dist/index.js +102 -0
- package/package.json +5 -5
- package/src/TransactionManager.ts +87 -0
- package/src/index.ts +22 -0
- package/src/supportedCaips.ts +2 -1
package/dist/index.cjs
CHANGED
|
@@ -59468,6 +59468,7 @@ var CAIP_TO_COIN_MAP = {
|
|
|
59468
59468
|
var OTHER_SUPPORT = [
|
|
59469
59469
|
"ripple:4109c6f2045fc7eff4cde8f9905d19c2/slip44:144",
|
|
59470
59470
|
"solana:5eykt4usfv8p8njdtrepy1vzqkqzkvdp/solana:so11111111111111111111111111111111111111112",
|
|
59471
|
+
"solana:5eykt4usfv8p8njdtrepy1vzqkqzkvdp",
|
|
59471
59472
|
"tron:0x2b6653dc/slip44:195",
|
|
59472
59473
|
"ton:-239/slip44:607"
|
|
59473
59474
|
];
|
|
@@ -61292,6 +61293,85 @@ class TransactionManager {
|
|
|
61292
61293
|
throw e;
|
|
61293
61294
|
}
|
|
61294
61295
|
}
|
|
61296
|
+
async signMessage({ caip, message, addressNList }) {
|
|
61297
|
+
let tag = TAG7 + " | signMessage | ";
|
|
61298
|
+
try {
|
|
61299
|
+
if (!this.pioneer)
|
|
61300
|
+
throw Error("Failed to init! pioneer");
|
|
61301
|
+
if (!caip)
|
|
61302
|
+
throw Error("Missing required param! caip");
|
|
61303
|
+
if (!message)
|
|
61304
|
+
throw Error("Missing required param! message");
|
|
61305
|
+
if (!addressNList)
|
|
61306
|
+
throw Error("Missing required param! addressNList");
|
|
61307
|
+
const type = await this.classifyCaip(caip);
|
|
61308
|
+
let signedMessage;
|
|
61309
|
+
switch (type) {
|
|
61310
|
+
case "OTHER": {
|
|
61311
|
+
if (caip.startsWith("solana:")) {
|
|
61312
|
+
const signRequest = {
|
|
61313
|
+
addressNList,
|
|
61314
|
+
message,
|
|
61315
|
+
showDisplay: true
|
|
61316
|
+
};
|
|
61317
|
+
try {
|
|
61318
|
+
const controller = new AbortController;
|
|
61319
|
+
const timeoutId = setTimeout(() => controller.abort(), 120000);
|
|
61320
|
+
try {
|
|
61321
|
+
const response = await fetch("http://localhost:1646/solana/sign-message", {
|
|
61322
|
+
method: "POST",
|
|
61323
|
+
headers: {
|
|
61324
|
+
"Content-Type": "application/json"
|
|
61325
|
+
},
|
|
61326
|
+
body: JSON.stringify(signRequest),
|
|
61327
|
+
signal: controller.signal
|
|
61328
|
+
});
|
|
61329
|
+
clearTimeout(timeoutId);
|
|
61330
|
+
if (!response.ok) {
|
|
61331
|
+
const errorData = await response.json();
|
|
61332
|
+
throw new Error(`Solana message signing failed: ${errorData.error || response.statusText}`);
|
|
61333
|
+
}
|
|
61334
|
+
const responseSign = await response.json();
|
|
61335
|
+
if (responseSign?.signature) {
|
|
61336
|
+
signedMessage = {
|
|
61337
|
+
signature: responseSign.signature,
|
|
61338
|
+
publicKey: responseSign.publicKey
|
|
61339
|
+
};
|
|
61340
|
+
} else {
|
|
61341
|
+
throw new Error("Solana message signing failed - no signature in response");
|
|
61342
|
+
}
|
|
61343
|
+
} catch (fetchError) {
|
|
61344
|
+
clearTimeout(timeoutId);
|
|
61345
|
+
if (fetchError.name === "AbortError") {
|
|
61346
|
+
throw new Error("Solana message signing timed out after 2 minutes");
|
|
61347
|
+
}
|
|
61348
|
+
throw fetchError;
|
|
61349
|
+
}
|
|
61350
|
+
} catch (e) {
|
|
61351
|
+
console.error(tag, "Solana message signing error:", e);
|
|
61352
|
+
throw new Error(`Solana message signing failed: ${e.message}`);
|
|
61353
|
+
}
|
|
61354
|
+
} else {
|
|
61355
|
+
throw new Error(`Message signing not supported for CAIP: ${caip}`);
|
|
61356
|
+
}
|
|
61357
|
+
break;
|
|
61358
|
+
}
|
|
61359
|
+
default: {
|
|
61360
|
+
throw new Error(`Message signing not supported for CAIP type: ${type}`);
|
|
61361
|
+
}
|
|
61362
|
+
}
|
|
61363
|
+
if (!signedMessage) {
|
|
61364
|
+
console.error(tag, "CRITICAL ERROR: signedMessage is missing after signing process");
|
|
61365
|
+
console.error(tag, "CAIP:", caip);
|
|
61366
|
+
console.error(tag, "Type:", type);
|
|
61367
|
+
throw Error("Failed to sign message! missing signedMessage");
|
|
61368
|
+
}
|
|
61369
|
+
return signedMessage;
|
|
61370
|
+
} catch (e) {
|
|
61371
|
+
console.error(tag, e);
|
|
61372
|
+
throw e;
|
|
61373
|
+
}
|
|
61374
|
+
}
|
|
61295
61375
|
async broadcast({ networkId, serialized }) {
|
|
61296
61376
|
let tag = TAG7 + " | broadcast | ";
|
|
61297
61377
|
try {
|
|
@@ -62964,6 +63044,7 @@ class SDK {
|
|
|
62964
63044
|
followTransaction;
|
|
62965
63045
|
broadcastTx;
|
|
62966
63046
|
signTx;
|
|
63047
|
+
signMessage;
|
|
62967
63048
|
buildTx;
|
|
62968
63049
|
buildDelegateTx;
|
|
62969
63050
|
buildUndelegateTx;
|
|
@@ -63527,6 +63608,27 @@ class SDK {
|
|
|
63527
63608
|
throw e;
|
|
63528
63609
|
}
|
|
63529
63610
|
};
|
|
63611
|
+
this.signMessage = async function(caip, message, addressNList) {
|
|
63612
|
+
let tag6 = TAG14 + " | signMessage | ";
|
|
63613
|
+
try {
|
|
63614
|
+
const transactionDependencies = {
|
|
63615
|
+
context: this.context,
|
|
63616
|
+
assetContext: this.assetContext,
|
|
63617
|
+
balances: this.balances,
|
|
63618
|
+
pioneer: this.pioneer,
|
|
63619
|
+
pubkeys: this.pubkeys,
|
|
63620
|
+
pubkeyContext: this.pubkeyContext,
|
|
63621
|
+
nodes: this.nodes,
|
|
63622
|
+
keepKeySdk: this.keepKeySdk
|
|
63623
|
+
};
|
|
63624
|
+
let txManager = new TransactionManager(transactionDependencies, this.events);
|
|
63625
|
+
let signedMessage = await txManager.signMessage({ caip, message, addressNList });
|
|
63626
|
+
return signedMessage;
|
|
63627
|
+
} catch (e) {
|
|
63628
|
+
console.error(e);
|
|
63629
|
+
throw e;
|
|
63630
|
+
}
|
|
63631
|
+
};
|
|
63530
63632
|
this.broadcastTx = async function(caip, signedTx) {
|
|
63531
63633
|
let tag6 = TAG14 + " | broadcastTx | ";
|
|
63532
63634
|
try {
|
package/dist/index.es.js
CHANGED
|
@@ -34788,6 +34788,7 @@ var CAIP_TO_COIN_MAP = {
|
|
|
34788
34788
|
var OTHER_SUPPORT = [
|
|
34789
34789
|
"ripple:4109c6f2045fc7eff4cde8f9905d19c2/slip44:144",
|
|
34790
34790
|
"solana:5eykt4usfv8p8njdtrepy1vzqkqzkvdp/solana:so11111111111111111111111111111111111111112",
|
|
34791
|
+
"solana:5eykt4usfv8p8njdtrepy1vzqkqzkvdp",
|
|
34791
34792
|
"tron:0x2b6653dc/slip44:195",
|
|
34792
34793
|
"ton:-239/slip44:607"
|
|
34793
34794
|
];
|
|
@@ -47648,6 +47649,85 @@ class TransactionManager {
|
|
|
47648
47649
|
throw e;
|
|
47649
47650
|
}
|
|
47650
47651
|
}
|
|
47652
|
+
async signMessage({ caip, message, addressNList }) {
|
|
47653
|
+
let tag = TAG7 + " | signMessage | ";
|
|
47654
|
+
try {
|
|
47655
|
+
if (!this.pioneer)
|
|
47656
|
+
throw Error("Failed to init! pioneer");
|
|
47657
|
+
if (!caip)
|
|
47658
|
+
throw Error("Missing required param! caip");
|
|
47659
|
+
if (!message)
|
|
47660
|
+
throw Error("Missing required param! message");
|
|
47661
|
+
if (!addressNList)
|
|
47662
|
+
throw Error("Missing required param! addressNList");
|
|
47663
|
+
const type2 = await this.classifyCaip(caip);
|
|
47664
|
+
let signedMessage;
|
|
47665
|
+
switch (type2) {
|
|
47666
|
+
case "OTHER": {
|
|
47667
|
+
if (caip.startsWith("solana:")) {
|
|
47668
|
+
const signRequest = {
|
|
47669
|
+
addressNList,
|
|
47670
|
+
message,
|
|
47671
|
+
showDisplay: true
|
|
47672
|
+
};
|
|
47673
|
+
try {
|
|
47674
|
+
const controller = new AbortController;
|
|
47675
|
+
const timeoutId = setTimeout(() => controller.abort(), 120000);
|
|
47676
|
+
try {
|
|
47677
|
+
const response = await fetch("http://localhost:1646/solana/sign-message", {
|
|
47678
|
+
method: "POST",
|
|
47679
|
+
headers: {
|
|
47680
|
+
"Content-Type": "application/json"
|
|
47681
|
+
},
|
|
47682
|
+
body: JSON.stringify(signRequest),
|
|
47683
|
+
signal: controller.signal
|
|
47684
|
+
});
|
|
47685
|
+
clearTimeout(timeoutId);
|
|
47686
|
+
if (!response.ok) {
|
|
47687
|
+
const errorData = await response.json();
|
|
47688
|
+
throw new Error(`Solana message signing failed: ${errorData.error || response.statusText}`);
|
|
47689
|
+
}
|
|
47690
|
+
const responseSign = await response.json();
|
|
47691
|
+
if (responseSign?.signature) {
|
|
47692
|
+
signedMessage = {
|
|
47693
|
+
signature: responseSign.signature,
|
|
47694
|
+
publicKey: responseSign.publicKey
|
|
47695
|
+
};
|
|
47696
|
+
} else {
|
|
47697
|
+
throw new Error("Solana message signing failed - no signature in response");
|
|
47698
|
+
}
|
|
47699
|
+
} catch (fetchError) {
|
|
47700
|
+
clearTimeout(timeoutId);
|
|
47701
|
+
if (fetchError.name === "AbortError") {
|
|
47702
|
+
throw new Error("Solana message signing timed out after 2 minutes");
|
|
47703
|
+
}
|
|
47704
|
+
throw fetchError;
|
|
47705
|
+
}
|
|
47706
|
+
} catch (e) {
|
|
47707
|
+
console.error(tag, "Solana message signing error:", e);
|
|
47708
|
+
throw new Error(`Solana message signing failed: ${e.message}`);
|
|
47709
|
+
}
|
|
47710
|
+
} else {
|
|
47711
|
+
throw new Error(`Message signing not supported for CAIP: ${caip}`);
|
|
47712
|
+
}
|
|
47713
|
+
break;
|
|
47714
|
+
}
|
|
47715
|
+
default: {
|
|
47716
|
+
throw new Error(`Message signing not supported for CAIP type: ${type2}`);
|
|
47717
|
+
}
|
|
47718
|
+
}
|
|
47719
|
+
if (!signedMessage) {
|
|
47720
|
+
console.error(tag, "CRITICAL ERROR: signedMessage is missing after signing process");
|
|
47721
|
+
console.error(tag, "CAIP:", caip);
|
|
47722
|
+
console.error(tag, "Type:", type2);
|
|
47723
|
+
throw Error("Failed to sign message! missing signedMessage");
|
|
47724
|
+
}
|
|
47725
|
+
return signedMessage;
|
|
47726
|
+
} catch (e) {
|
|
47727
|
+
console.error(tag, e);
|
|
47728
|
+
throw e;
|
|
47729
|
+
}
|
|
47730
|
+
}
|
|
47651
47731
|
async broadcast({ networkId, serialized }) {
|
|
47652
47732
|
let tag = TAG7 + " | broadcast | ";
|
|
47653
47733
|
try {
|
|
@@ -49320,6 +49400,7 @@ class SDK {
|
|
|
49320
49400
|
followTransaction;
|
|
49321
49401
|
broadcastTx;
|
|
49322
49402
|
signTx;
|
|
49403
|
+
signMessage;
|
|
49323
49404
|
buildTx;
|
|
49324
49405
|
buildDelegateTx;
|
|
49325
49406
|
buildUndelegateTx;
|
|
@@ -49883,6 +49964,27 @@ class SDK {
|
|
|
49883
49964
|
throw e;
|
|
49884
49965
|
}
|
|
49885
49966
|
};
|
|
49967
|
+
this.signMessage = async function(caip, message, addressNList) {
|
|
49968
|
+
let tag6 = TAG14 + " | signMessage | ";
|
|
49969
|
+
try {
|
|
49970
|
+
const transactionDependencies = {
|
|
49971
|
+
context: this.context,
|
|
49972
|
+
assetContext: this.assetContext,
|
|
49973
|
+
balances: this.balances,
|
|
49974
|
+
pioneer: this.pioneer,
|
|
49975
|
+
pubkeys: this.pubkeys,
|
|
49976
|
+
pubkeyContext: this.pubkeyContext,
|
|
49977
|
+
nodes: this.nodes,
|
|
49978
|
+
keepKeySdk: this.keepKeySdk
|
|
49979
|
+
};
|
|
49980
|
+
let txManager = new TransactionManager(transactionDependencies, this.events);
|
|
49981
|
+
let signedMessage = await txManager.signMessage({ caip, message, addressNList });
|
|
49982
|
+
return signedMessage;
|
|
49983
|
+
} catch (e) {
|
|
49984
|
+
console.error(e);
|
|
49985
|
+
throw e;
|
|
49986
|
+
}
|
|
49987
|
+
};
|
|
49886
49988
|
this.broadcastTx = async function(caip, signedTx) {
|
|
49887
49989
|
let tag6 = TAG14 + " | broadcastTx | ";
|
|
49888
49990
|
try {
|
package/dist/index.js
CHANGED
|
@@ -34788,6 +34788,7 @@ var CAIP_TO_COIN_MAP = {
|
|
|
34788
34788
|
var OTHER_SUPPORT = [
|
|
34789
34789
|
"ripple:4109c6f2045fc7eff4cde8f9905d19c2/slip44:144",
|
|
34790
34790
|
"solana:5eykt4usfv8p8njdtrepy1vzqkqzkvdp/solana:so11111111111111111111111111111111111111112",
|
|
34791
|
+
"solana:5eykt4usfv8p8njdtrepy1vzqkqzkvdp",
|
|
34791
34792
|
"tron:0x2b6653dc/slip44:195",
|
|
34792
34793
|
"ton:-239/slip44:607"
|
|
34793
34794
|
];
|
|
@@ -47648,6 +47649,85 @@ class TransactionManager {
|
|
|
47648
47649
|
throw e;
|
|
47649
47650
|
}
|
|
47650
47651
|
}
|
|
47652
|
+
async signMessage({ caip, message, addressNList }) {
|
|
47653
|
+
let tag = TAG7 + " | signMessage | ";
|
|
47654
|
+
try {
|
|
47655
|
+
if (!this.pioneer)
|
|
47656
|
+
throw Error("Failed to init! pioneer");
|
|
47657
|
+
if (!caip)
|
|
47658
|
+
throw Error("Missing required param! caip");
|
|
47659
|
+
if (!message)
|
|
47660
|
+
throw Error("Missing required param! message");
|
|
47661
|
+
if (!addressNList)
|
|
47662
|
+
throw Error("Missing required param! addressNList");
|
|
47663
|
+
const type2 = await this.classifyCaip(caip);
|
|
47664
|
+
let signedMessage;
|
|
47665
|
+
switch (type2) {
|
|
47666
|
+
case "OTHER": {
|
|
47667
|
+
if (caip.startsWith("solana:")) {
|
|
47668
|
+
const signRequest = {
|
|
47669
|
+
addressNList,
|
|
47670
|
+
message,
|
|
47671
|
+
showDisplay: true
|
|
47672
|
+
};
|
|
47673
|
+
try {
|
|
47674
|
+
const controller = new AbortController;
|
|
47675
|
+
const timeoutId = setTimeout(() => controller.abort(), 120000);
|
|
47676
|
+
try {
|
|
47677
|
+
const response = await fetch("http://localhost:1646/solana/sign-message", {
|
|
47678
|
+
method: "POST",
|
|
47679
|
+
headers: {
|
|
47680
|
+
"Content-Type": "application/json"
|
|
47681
|
+
},
|
|
47682
|
+
body: JSON.stringify(signRequest),
|
|
47683
|
+
signal: controller.signal
|
|
47684
|
+
});
|
|
47685
|
+
clearTimeout(timeoutId);
|
|
47686
|
+
if (!response.ok) {
|
|
47687
|
+
const errorData = await response.json();
|
|
47688
|
+
throw new Error(`Solana message signing failed: ${errorData.error || response.statusText}`);
|
|
47689
|
+
}
|
|
47690
|
+
const responseSign = await response.json();
|
|
47691
|
+
if (responseSign?.signature) {
|
|
47692
|
+
signedMessage = {
|
|
47693
|
+
signature: responseSign.signature,
|
|
47694
|
+
publicKey: responseSign.publicKey
|
|
47695
|
+
};
|
|
47696
|
+
} else {
|
|
47697
|
+
throw new Error("Solana message signing failed - no signature in response");
|
|
47698
|
+
}
|
|
47699
|
+
} catch (fetchError) {
|
|
47700
|
+
clearTimeout(timeoutId);
|
|
47701
|
+
if (fetchError.name === "AbortError") {
|
|
47702
|
+
throw new Error("Solana message signing timed out after 2 minutes");
|
|
47703
|
+
}
|
|
47704
|
+
throw fetchError;
|
|
47705
|
+
}
|
|
47706
|
+
} catch (e) {
|
|
47707
|
+
console.error(tag, "Solana message signing error:", e);
|
|
47708
|
+
throw new Error(`Solana message signing failed: ${e.message}`);
|
|
47709
|
+
}
|
|
47710
|
+
} else {
|
|
47711
|
+
throw new Error(`Message signing not supported for CAIP: ${caip}`);
|
|
47712
|
+
}
|
|
47713
|
+
break;
|
|
47714
|
+
}
|
|
47715
|
+
default: {
|
|
47716
|
+
throw new Error(`Message signing not supported for CAIP type: ${type2}`);
|
|
47717
|
+
}
|
|
47718
|
+
}
|
|
47719
|
+
if (!signedMessage) {
|
|
47720
|
+
console.error(tag, "CRITICAL ERROR: signedMessage is missing after signing process");
|
|
47721
|
+
console.error(tag, "CAIP:", caip);
|
|
47722
|
+
console.error(tag, "Type:", type2);
|
|
47723
|
+
throw Error("Failed to sign message! missing signedMessage");
|
|
47724
|
+
}
|
|
47725
|
+
return signedMessage;
|
|
47726
|
+
} catch (e) {
|
|
47727
|
+
console.error(tag, e);
|
|
47728
|
+
throw e;
|
|
47729
|
+
}
|
|
47730
|
+
}
|
|
47651
47731
|
async broadcast({ networkId, serialized }) {
|
|
47652
47732
|
let tag = TAG7 + " | broadcast | ";
|
|
47653
47733
|
try {
|
|
@@ -49320,6 +49400,7 @@ class SDK {
|
|
|
49320
49400
|
followTransaction;
|
|
49321
49401
|
broadcastTx;
|
|
49322
49402
|
signTx;
|
|
49403
|
+
signMessage;
|
|
49323
49404
|
buildTx;
|
|
49324
49405
|
buildDelegateTx;
|
|
49325
49406
|
buildUndelegateTx;
|
|
@@ -49883,6 +49964,27 @@ class SDK {
|
|
|
49883
49964
|
throw e;
|
|
49884
49965
|
}
|
|
49885
49966
|
};
|
|
49967
|
+
this.signMessage = async function(caip, message, addressNList) {
|
|
49968
|
+
let tag6 = TAG14 + " | signMessage | ";
|
|
49969
|
+
try {
|
|
49970
|
+
const transactionDependencies = {
|
|
49971
|
+
context: this.context,
|
|
49972
|
+
assetContext: this.assetContext,
|
|
49973
|
+
balances: this.balances,
|
|
49974
|
+
pioneer: this.pioneer,
|
|
49975
|
+
pubkeys: this.pubkeys,
|
|
49976
|
+
pubkeyContext: this.pubkeyContext,
|
|
49977
|
+
nodes: this.nodes,
|
|
49978
|
+
keepKeySdk: this.keepKeySdk
|
|
49979
|
+
};
|
|
49980
|
+
let txManager = new TransactionManager(transactionDependencies, this.events);
|
|
49981
|
+
let signedMessage = await txManager.signMessage({ caip, message, addressNList });
|
|
49982
|
+
return signedMessage;
|
|
49983
|
+
} catch (e) {
|
|
49984
|
+
console.error(e);
|
|
49985
|
+
throw e;
|
|
49986
|
+
}
|
|
49987
|
+
};
|
|
49886
49988
|
this.broadcastTx = async function(caip, signedTx) {
|
|
49887
49989
|
let tag6 = TAG14 + " | broadcastTx | ";
|
|
49888
49990
|
try {
|
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.21.0",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"keepkey-vault-sdk": "^1.0.2",
|
|
7
|
-
"@pioneer-platform/pioneer-caip": "^9.
|
|
7
|
+
"@pioneer-platform/pioneer-caip": "^9.16.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.17.0",
|
|
10
|
+
"@pioneer-platform/pioneer-discovery": "^8.21.0",
|
|
11
|
+
"@pioneer-platform/pioneer-events": "^8.17.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
|
];
|