@pioneer-platform/pioneer-sdk 4.21.10 → 4.21.12
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 +26 -5
- package/dist/index.es.js +26 -5
- package/dist/index.js +26 -5
- package/package.json +1 -1
- package/src/TransactionManager.ts +34 -6
- package/src/fees/index.ts +1 -1
package/dist/index.cjs
CHANGED
|
@@ -2752,15 +2752,36 @@ class TransactionManager {
|
|
|
2752
2752
|
this.events = events;
|
|
2753
2753
|
}
|
|
2754
2754
|
async classifyCaip(caip) {
|
|
2755
|
-
|
|
2755
|
+
let caipString;
|
|
2756
|
+
if (typeof caip === "string") {
|
|
2757
|
+
caipString = caip;
|
|
2758
|
+
} else if (caip && typeof caip === "object") {
|
|
2759
|
+
if (caip.caip && typeof caip.caip === "string") {
|
|
2760
|
+
caipString = caip.caip;
|
|
2761
|
+
} else if (caip.toString && typeof caip.toString === "function") {
|
|
2762
|
+
caipString = caip.toString();
|
|
2763
|
+
if (caipString === "[object Object]") {
|
|
2764
|
+
if (caip.chainId && caip.network) {
|
|
2765
|
+
caipString = `${caip.chainId}:${caip.network}`;
|
|
2766
|
+
} else {
|
|
2767
|
+
throw new Error(`Cannot extract CAIP string from object: ${JSON.stringify(caip)}`);
|
|
2768
|
+
}
|
|
2769
|
+
}
|
|
2770
|
+
} else {
|
|
2771
|
+
throw new Error(`Cannot extract CAIP string from object: ${JSON.stringify(caip)}`);
|
|
2772
|
+
}
|
|
2773
|
+
} else {
|
|
2774
|
+
throw new Error(`Invalid CAIP parameter: ${caip}`);
|
|
2775
|
+
}
|
|
2776
|
+
if (SUPPORTED_CAIPS.UTXO.includes(caipString))
|
|
2756
2777
|
return "UTXO";
|
|
2757
|
-
if (SUPPORTED_CAIPS.TENDERMINT.includes(
|
|
2778
|
+
if (SUPPORTED_CAIPS.TENDERMINT.includes(caipString))
|
|
2758
2779
|
return "TENDERMINT";
|
|
2759
|
-
if (
|
|
2780
|
+
if (caipString.startsWith("eip155"))
|
|
2760
2781
|
return "EIP155";
|
|
2761
|
-
if (SUPPORTED_CAIPS.OTHER.includes(
|
|
2782
|
+
if (SUPPORTED_CAIPS.OTHER.includes(caipString))
|
|
2762
2783
|
return "OTHER";
|
|
2763
|
-
throw new Error(`Unsupported CAIP: ${
|
|
2784
|
+
throw new Error(`Unsupported CAIP: ${caipString}`);
|
|
2764
2785
|
}
|
|
2765
2786
|
async transfer({ caip, to, amount, memo, isMax = false, feeLevel = 5, changeScriptType }) {
|
|
2766
2787
|
let tag6 = TAG5 + " | transfer | ";
|
package/dist/index.es.js
CHANGED
|
@@ -2928,15 +2928,36 @@ class TransactionManager {
|
|
|
2928
2928
|
this.events = events;
|
|
2929
2929
|
}
|
|
2930
2930
|
async classifyCaip(caip) {
|
|
2931
|
-
|
|
2931
|
+
let caipString;
|
|
2932
|
+
if (typeof caip === "string") {
|
|
2933
|
+
caipString = caip;
|
|
2934
|
+
} else if (caip && typeof caip === "object") {
|
|
2935
|
+
if (caip.caip && typeof caip.caip === "string") {
|
|
2936
|
+
caipString = caip.caip;
|
|
2937
|
+
} else if (caip.toString && typeof caip.toString === "function") {
|
|
2938
|
+
caipString = caip.toString();
|
|
2939
|
+
if (caipString === "[object Object]") {
|
|
2940
|
+
if (caip.chainId && caip.network) {
|
|
2941
|
+
caipString = `${caip.chainId}:${caip.network}`;
|
|
2942
|
+
} else {
|
|
2943
|
+
throw new Error(`Cannot extract CAIP string from object: ${JSON.stringify(caip)}`);
|
|
2944
|
+
}
|
|
2945
|
+
}
|
|
2946
|
+
} else {
|
|
2947
|
+
throw new Error(`Cannot extract CAIP string from object: ${JSON.stringify(caip)}`);
|
|
2948
|
+
}
|
|
2949
|
+
} else {
|
|
2950
|
+
throw new Error(`Invalid CAIP parameter: ${caip}`);
|
|
2951
|
+
}
|
|
2952
|
+
if (SUPPORTED_CAIPS.UTXO.includes(caipString))
|
|
2932
2953
|
return "UTXO";
|
|
2933
|
-
if (SUPPORTED_CAIPS.TENDERMINT.includes(
|
|
2954
|
+
if (SUPPORTED_CAIPS.TENDERMINT.includes(caipString))
|
|
2934
2955
|
return "TENDERMINT";
|
|
2935
|
-
if (
|
|
2956
|
+
if (caipString.startsWith("eip155"))
|
|
2936
2957
|
return "EIP155";
|
|
2937
|
-
if (SUPPORTED_CAIPS.OTHER.includes(
|
|
2958
|
+
if (SUPPORTED_CAIPS.OTHER.includes(caipString))
|
|
2938
2959
|
return "OTHER";
|
|
2939
|
-
throw new Error(`Unsupported CAIP: ${
|
|
2960
|
+
throw new Error(`Unsupported CAIP: ${caipString}`);
|
|
2940
2961
|
}
|
|
2941
2962
|
async transfer({ caip, to, amount, memo, isMax = false, feeLevel = 5, changeScriptType }) {
|
|
2942
2963
|
let tag6 = TAG5 + " | transfer | ";
|
package/dist/index.js
CHANGED
|
@@ -2928,15 +2928,36 @@ class TransactionManager {
|
|
|
2928
2928
|
this.events = events;
|
|
2929
2929
|
}
|
|
2930
2930
|
async classifyCaip(caip) {
|
|
2931
|
-
|
|
2931
|
+
let caipString;
|
|
2932
|
+
if (typeof caip === "string") {
|
|
2933
|
+
caipString = caip;
|
|
2934
|
+
} else if (caip && typeof caip === "object") {
|
|
2935
|
+
if (caip.caip && typeof caip.caip === "string") {
|
|
2936
|
+
caipString = caip.caip;
|
|
2937
|
+
} else if (caip.toString && typeof caip.toString === "function") {
|
|
2938
|
+
caipString = caip.toString();
|
|
2939
|
+
if (caipString === "[object Object]") {
|
|
2940
|
+
if (caip.chainId && caip.network) {
|
|
2941
|
+
caipString = `${caip.chainId}:${caip.network}`;
|
|
2942
|
+
} else {
|
|
2943
|
+
throw new Error(`Cannot extract CAIP string from object: ${JSON.stringify(caip)}`);
|
|
2944
|
+
}
|
|
2945
|
+
}
|
|
2946
|
+
} else {
|
|
2947
|
+
throw new Error(`Cannot extract CAIP string from object: ${JSON.stringify(caip)}`);
|
|
2948
|
+
}
|
|
2949
|
+
} else {
|
|
2950
|
+
throw new Error(`Invalid CAIP parameter: ${caip}`);
|
|
2951
|
+
}
|
|
2952
|
+
if (SUPPORTED_CAIPS.UTXO.includes(caipString))
|
|
2932
2953
|
return "UTXO";
|
|
2933
|
-
if (SUPPORTED_CAIPS.TENDERMINT.includes(
|
|
2954
|
+
if (SUPPORTED_CAIPS.TENDERMINT.includes(caipString))
|
|
2934
2955
|
return "TENDERMINT";
|
|
2935
|
-
if (
|
|
2956
|
+
if (caipString.startsWith("eip155"))
|
|
2936
2957
|
return "EIP155";
|
|
2937
|
-
if (SUPPORTED_CAIPS.OTHER.includes(
|
|
2958
|
+
if (SUPPORTED_CAIPS.OTHER.includes(caipString))
|
|
2938
2959
|
return "OTHER";
|
|
2939
|
-
throw new Error(`Unsupported CAIP: ${
|
|
2960
|
+
throw new Error(`Unsupported CAIP: ${caipString}`);
|
|
2940
2961
|
}
|
|
2941
2962
|
async transfer({ caip, to, amount, memo, isMax = false, feeLevel = 5, changeScriptType }) {
|
|
2942
2963
|
let tag6 = TAG5 + " | transfer | ";
|
package/package.json
CHANGED
|
@@ -45,12 +45,40 @@ export class TransactionManager {
|
|
|
45
45
|
this.events = events;
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
async classifyCaip(caip:
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
if (
|
|
53
|
-
|
|
48
|
+
async classifyCaip(caip: any): Promise<string> {
|
|
49
|
+
// Ensure caip is a string (handle case where it might be an object)
|
|
50
|
+
let caipString: string;
|
|
51
|
+
|
|
52
|
+
if (typeof caip === 'string') {
|
|
53
|
+
caipString = caip;
|
|
54
|
+
} else if (caip && typeof caip === 'object') {
|
|
55
|
+
// If it's an object, try to extract the caip string
|
|
56
|
+
// It might have a 'caip' property, or we need to stringify it
|
|
57
|
+
if (caip.caip && typeof caip.caip === 'string') {
|
|
58
|
+
caipString = caip.caip;
|
|
59
|
+
} else if (caip.toString && typeof caip.toString === 'function') {
|
|
60
|
+
caipString = caip.toString();
|
|
61
|
+
// If toString() returned "[object Object]", it's not helpful
|
|
62
|
+
if (caipString === '[object Object]') {
|
|
63
|
+
// Try to construct from chainId and network properties if they exist
|
|
64
|
+
if (caip.chainId && caip.network) {
|
|
65
|
+
caipString = `${caip.chainId}:${caip.network}`;
|
|
66
|
+
} else {
|
|
67
|
+
throw new Error(`Cannot extract CAIP string from object: ${JSON.stringify(caip)}`);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
} else {
|
|
71
|
+
throw new Error(`Cannot extract CAIP string from object: ${JSON.stringify(caip)}`);
|
|
72
|
+
}
|
|
73
|
+
} else {
|
|
74
|
+
throw new Error(`Invalid CAIP parameter: ${caip}`);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if (SUPPORTED_CAIPS.UTXO.includes(caipString)) return 'UTXO';
|
|
78
|
+
if (SUPPORTED_CAIPS.TENDERMINT.includes(caipString)) return 'TENDERMINT';
|
|
79
|
+
if (caipString.startsWith('eip155')) return 'EIP155';
|
|
80
|
+
if (SUPPORTED_CAIPS.OTHER.includes(caipString)) return 'OTHER';
|
|
81
|
+
throw new Error(`Unsupported CAIP: ${caipString}`);
|
|
54
82
|
}
|
|
55
83
|
|
|
56
84
|
async transfer({ caip, to, amount, memo, isMax = false, feeLevel = 5, changeScriptType }: any): Promise<any> {
|
package/src/fees/index.ts
CHANGED
|
@@ -246,7 +246,7 @@ function normalizeFeeData(
|
|
|
246
246
|
averageValue = feeData.average.toString();
|
|
247
247
|
fastestValue = feeData.fastest.toString();
|
|
248
248
|
} else if (hasAverageFastFastest) {
|
|
249
|
-
//
|
|
249
|
+
// EVM API format: {average, fast, fastest}
|
|
250
250
|
slowValue = feeData.average.toString();
|
|
251
251
|
averageValue = feeData.fast.toString();
|
|
252
252
|
fastestValue = feeData.fastest.toString();
|