@pioneer-platform/pioneer-sdk 8.15.2 → 8.15.3
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 +35 -24
- package/dist/index.es.js +35 -24
- package/dist/index.js +35 -24
- package/package.json +5 -5
- package/src/txbuilder/createUnsignedRippleTx.ts +45 -26
package/dist/index.cjs
CHANGED
|
@@ -1982,9 +1982,16 @@ async function createUnsignedRippleTx(caip, to, amount, memo, pubkeys, pioneer,
|
|
|
1982
1982
|
accountInfo = accountInfo.data;
|
|
1983
1983
|
const sequence = accountInfo.Sequence.toString();
|
|
1984
1984
|
const ledgerIndexCurrent = parseInt(accountInfo.ledger_index_current);
|
|
1985
|
-
let desttag =
|
|
1986
|
-
if (
|
|
1987
|
-
|
|
1985
|
+
let desttag = undefined;
|
|
1986
|
+
if (memo && memo.trim() !== "") {
|
|
1987
|
+
if (!/^\d+$/.test(memo.trim())) {
|
|
1988
|
+
throw new Error(`XRP destination tag must be numeric. Got: "${memo}"`);
|
|
1989
|
+
}
|
|
1990
|
+
const tagNum = parseInt(memo.trim(), 10);
|
|
1991
|
+
if (isNaN(tagNum) || tagNum < 0 || tagNum > 4294967295) {
|
|
1992
|
+
throw new Error(`XRP destination tag must be 0-4294967295. Got: ${memo}`);
|
|
1993
|
+
}
|
|
1994
|
+
desttag = tagNum.toString();
|
|
1988
1995
|
}
|
|
1989
1996
|
if (isMax) {
|
|
1990
1997
|
amount = Number(accountInfo.Balance) - 1e6 - 1;
|
|
@@ -1993,6 +2000,22 @@ async function createUnsignedRippleTx(caip, to, amount, memo, pubkeys, pioneer,
|
|
|
1993
2000
|
amount = amount * 1e6;
|
|
1994
2001
|
amount = amount.toString();
|
|
1995
2002
|
}
|
|
2003
|
+
const msg = {
|
|
2004
|
+
type: "ripple-sdk/MsgSend",
|
|
2005
|
+
value: {
|
|
2006
|
+
amount: [
|
|
2007
|
+
{
|
|
2008
|
+
amount,
|
|
2009
|
+
denom: "drop"
|
|
2010
|
+
}
|
|
2011
|
+
],
|
|
2012
|
+
from_address: fromAddress,
|
|
2013
|
+
to_address: to
|
|
2014
|
+
}
|
|
2015
|
+
};
|
|
2016
|
+
if (desttag !== undefined) {
|
|
2017
|
+
msg.DestinationTag = desttag;
|
|
2018
|
+
}
|
|
1996
2019
|
let tx = {
|
|
1997
2020
|
type: "auth/StdTx",
|
|
1998
2021
|
value: {
|
|
@@ -2006,36 +2029,24 @@ async function createUnsignedRippleTx(caip, to, amount, memo, pubkeys, pioneer,
|
|
|
2006
2029
|
gas: "28000"
|
|
2007
2030
|
},
|
|
2008
2031
|
memo: memo || "",
|
|
2009
|
-
msg: [
|
|
2010
|
-
{
|
|
2011
|
-
type: "ripple-sdk/MsgSend",
|
|
2012
|
-
DestinationTag: desttag,
|
|
2013
|
-
value: {
|
|
2014
|
-
amount: [
|
|
2015
|
-
{
|
|
2016
|
-
amount,
|
|
2017
|
-
denom: "drop"
|
|
2018
|
-
}
|
|
2019
|
-
],
|
|
2020
|
-
from_address: fromAddress,
|
|
2021
|
-
to_address: to
|
|
2022
|
-
}
|
|
2023
|
-
}
|
|
2024
|
-
],
|
|
2032
|
+
msg: [msg],
|
|
2025
2033
|
signatures: null
|
|
2026
2034
|
}
|
|
2027
2035
|
};
|
|
2036
|
+
const payment = {
|
|
2037
|
+
amount,
|
|
2038
|
+
destination: to
|
|
2039
|
+
};
|
|
2040
|
+
if (desttag !== undefined) {
|
|
2041
|
+
payment.destinationTag = desttag;
|
|
2042
|
+
}
|
|
2028
2043
|
let unsignedTx = {
|
|
2029
2044
|
addressNList: [2147483692, 2147483792, 2147483648, 0, 0],
|
|
2030
2045
|
tx,
|
|
2031
2046
|
flags: undefined,
|
|
2032
2047
|
lastLedgerSequence: (ledgerIndexCurrent + 1000).toString(),
|
|
2033
2048
|
sequence: sequence || "0",
|
|
2034
|
-
payment
|
|
2035
|
-
amount,
|
|
2036
|
-
destination: to,
|
|
2037
|
-
destinationTag: desttag
|
|
2038
|
-
}
|
|
2049
|
+
payment
|
|
2039
2050
|
};
|
|
2040
2051
|
return unsignedTx;
|
|
2041
2052
|
} catch (error) {
|
package/dist/index.es.js
CHANGED
|
@@ -2166,9 +2166,16 @@ async function createUnsignedRippleTx(caip, to, amount, memo, pubkeys, pioneer,
|
|
|
2166
2166
|
accountInfo = accountInfo.data;
|
|
2167
2167
|
const sequence = accountInfo.Sequence.toString();
|
|
2168
2168
|
const ledgerIndexCurrent = parseInt(accountInfo.ledger_index_current);
|
|
2169
|
-
let desttag =
|
|
2170
|
-
if (
|
|
2171
|
-
|
|
2169
|
+
let desttag = undefined;
|
|
2170
|
+
if (memo && memo.trim() !== "") {
|
|
2171
|
+
if (!/^\d+$/.test(memo.trim())) {
|
|
2172
|
+
throw new Error(`XRP destination tag must be numeric. Got: "${memo}"`);
|
|
2173
|
+
}
|
|
2174
|
+
const tagNum = parseInt(memo.trim(), 10);
|
|
2175
|
+
if (isNaN(tagNum) || tagNum < 0 || tagNum > 4294967295) {
|
|
2176
|
+
throw new Error(`XRP destination tag must be 0-4294967295. Got: ${memo}`);
|
|
2177
|
+
}
|
|
2178
|
+
desttag = tagNum.toString();
|
|
2172
2179
|
}
|
|
2173
2180
|
if (isMax) {
|
|
2174
2181
|
amount = Number(accountInfo.Balance) - 1e6 - 1;
|
|
@@ -2177,6 +2184,22 @@ async function createUnsignedRippleTx(caip, to, amount, memo, pubkeys, pioneer,
|
|
|
2177
2184
|
amount = amount * 1e6;
|
|
2178
2185
|
amount = amount.toString();
|
|
2179
2186
|
}
|
|
2187
|
+
const msg = {
|
|
2188
|
+
type: "ripple-sdk/MsgSend",
|
|
2189
|
+
value: {
|
|
2190
|
+
amount: [
|
|
2191
|
+
{
|
|
2192
|
+
amount,
|
|
2193
|
+
denom: "drop"
|
|
2194
|
+
}
|
|
2195
|
+
],
|
|
2196
|
+
from_address: fromAddress,
|
|
2197
|
+
to_address: to
|
|
2198
|
+
}
|
|
2199
|
+
};
|
|
2200
|
+
if (desttag !== undefined) {
|
|
2201
|
+
msg.DestinationTag = desttag;
|
|
2202
|
+
}
|
|
2180
2203
|
let tx = {
|
|
2181
2204
|
type: "auth/StdTx",
|
|
2182
2205
|
value: {
|
|
@@ -2190,36 +2213,24 @@ async function createUnsignedRippleTx(caip, to, amount, memo, pubkeys, pioneer,
|
|
|
2190
2213
|
gas: "28000"
|
|
2191
2214
|
},
|
|
2192
2215
|
memo: memo || "",
|
|
2193
|
-
msg: [
|
|
2194
|
-
{
|
|
2195
|
-
type: "ripple-sdk/MsgSend",
|
|
2196
|
-
DestinationTag: desttag,
|
|
2197
|
-
value: {
|
|
2198
|
-
amount: [
|
|
2199
|
-
{
|
|
2200
|
-
amount,
|
|
2201
|
-
denom: "drop"
|
|
2202
|
-
}
|
|
2203
|
-
],
|
|
2204
|
-
from_address: fromAddress,
|
|
2205
|
-
to_address: to
|
|
2206
|
-
}
|
|
2207
|
-
}
|
|
2208
|
-
],
|
|
2216
|
+
msg: [msg],
|
|
2209
2217
|
signatures: null
|
|
2210
2218
|
}
|
|
2211
2219
|
};
|
|
2220
|
+
const payment = {
|
|
2221
|
+
amount,
|
|
2222
|
+
destination: to
|
|
2223
|
+
};
|
|
2224
|
+
if (desttag !== undefined) {
|
|
2225
|
+
payment.destinationTag = desttag;
|
|
2226
|
+
}
|
|
2212
2227
|
let unsignedTx = {
|
|
2213
2228
|
addressNList: [2147483692, 2147483792, 2147483648, 0, 0],
|
|
2214
2229
|
tx,
|
|
2215
2230
|
flags: undefined,
|
|
2216
2231
|
lastLedgerSequence: (ledgerIndexCurrent + 1000).toString(),
|
|
2217
2232
|
sequence: sequence || "0",
|
|
2218
|
-
payment
|
|
2219
|
-
amount,
|
|
2220
|
-
destination: to,
|
|
2221
|
-
destinationTag: desttag
|
|
2222
|
-
}
|
|
2233
|
+
payment
|
|
2223
2234
|
};
|
|
2224
2235
|
return unsignedTx;
|
|
2225
2236
|
} catch (error) {
|
package/dist/index.js
CHANGED
|
@@ -2166,9 +2166,16 @@ async function createUnsignedRippleTx(caip, to, amount, memo, pubkeys, pioneer,
|
|
|
2166
2166
|
accountInfo = accountInfo.data;
|
|
2167
2167
|
const sequence = accountInfo.Sequence.toString();
|
|
2168
2168
|
const ledgerIndexCurrent = parseInt(accountInfo.ledger_index_current);
|
|
2169
|
-
let desttag =
|
|
2170
|
-
if (
|
|
2171
|
-
|
|
2169
|
+
let desttag = undefined;
|
|
2170
|
+
if (memo && memo.trim() !== "") {
|
|
2171
|
+
if (!/^\d+$/.test(memo.trim())) {
|
|
2172
|
+
throw new Error(`XRP destination tag must be numeric. Got: "${memo}"`);
|
|
2173
|
+
}
|
|
2174
|
+
const tagNum = parseInt(memo.trim(), 10);
|
|
2175
|
+
if (isNaN(tagNum) || tagNum < 0 || tagNum > 4294967295) {
|
|
2176
|
+
throw new Error(`XRP destination tag must be 0-4294967295. Got: ${memo}`);
|
|
2177
|
+
}
|
|
2178
|
+
desttag = tagNum.toString();
|
|
2172
2179
|
}
|
|
2173
2180
|
if (isMax) {
|
|
2174
2181
|
amount = Number(accountInfo.Balance) - 1e6 - 1;
|
|
@@ -2177,6 +2184,22 @@ async function createUnsignedRippleTx(caip, to, amount, memo, pubkeys, pioneer,
|
|
|
2177
2184
|
amount = amount * 1e6;
|
|
2178
2185
|
amount = amount.toString();
|
|
2179
2186
|
}
|
|
2187
|
+
const msg = {
|
|
2188
|
+
type: "ripple-sdk/MsgSend",
|
|
2189
|
+
value: {
|
|
2190
|
+
amount: [
|
|
2191
|
+
{
|
|
2192
|
+
amount,
|
|
2193
|
+
denom: "drop"
|
|
2194
|
+
}
|
|
2195
|
+
],
|
|
2196
|
+
from_address: fromAddress,
|
|
2197
|
+
to_address: to
|
|
2198
|
+
}
|
|
2199
|
+
};
|
|
2200
|
+
if (desttag !== undefined) {
|
|
2201
|
+
msg.DestinationTag = desttag;
|
|
2202
|
+
}
|
|
2180
2203
|
let tx = {
|
|
2181
2204
|
type: "auth/StdTx",
|
|
2182
2205
|
value: {
|
|
@@ -2190,36 +2213,24 @@ async function createUnsignedRippleTx(caip, to, amount, memo, pubkeys, pioneer,
|
|
|
2190
2213
|
gas: "28000"
|
|
2191
2214
|
},
|
|
2192
2215
|
memo: memo || "",
|
|
2193
|
-
msg: [
|
|
2194
|
-
{
|
|
2195
|
-
type: "ripple-sdk/MsgSend",
|
|
2196
|
-
DestinationTag: desttag,
|
|
2197
|
-
value: {
|
|
2198
|
-
amount: [
|
|
2199
|
-
{
|
|
2200
|
-
amount,
|
|
2201
|
-
denom: "drop"
|
|
2202
|
-
}
|
|
2203
|
-
],
|
|
2204
|
-
from_address: fromAddress,
|
|
2205
|
-
to_address: to
|
|
2206
|
-
}
|
|
2207
|
-
}
|
|
2208
|
-
],
|
|
2216
|
+
msg: [msg],
|
|
2209
2217
|
signatures: null
|
|
2210
2218
|
}
|
|
2211
2219
|
};
|
|
2220
|
+
const payment = {
|
|
2221
|
+
amount,
|
|
2222
|
+
destination: to
|
|
2223
|
+
};
|
|
2224
|
+
if (desttag !== undefined) {
|
|
2225
|
+
payment.destinationTag = desttag;
|
|
2226
|
+
}
|
|
2212
2227
|
let unsignedTx = {
|
|
2213
2228
|
addressNList: [2147483692, 2147483792, 2147483648, 0, 0],
|
|
2214
2229
|
tx,
|
|
2215
2230
|
flags: undefined,
|
|
2216
2231
|
lastLedgerSequence: (ledgerIndexCurrent + 1000).toString(),
|
|
2217
2232
|
sequence: sequence || "0",
|
|
2218
|
-
payment
|
|
2219
|
-
amount,
|
|
2220
|
-
destination: to,
|
|
2221
|
-
destinationTag: desttag
|
|
2222
|
-
}
|
|
2233
|
+
payment
|
|
2223
2234
|
};
|
|
2224
2235
|
return unsignedTx;
|
|
2225
2236
|
} catch (error) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"author": "highlander",
|
|
3
3
|
"name": "@pioneer-platform/pioneer-sdk",
|
|
4
|
-
"version": "8.15.
|
|
4
|
+
"version": "8.15.3",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@keepkey/keepkey-sdk": "^0.2.62",
|
|
7
7
|
"@pioneer-platform/loggerdog": "^8.11.0",
|
|
@@ -49,8 +49,6 @@
|
|
|
49
49
|
},
|
|
50
50
|
"react-native": "./src/index.ts",
|
|
51
51
|
"repository": "https://github.com/thorswap/SwapKit.git",
|
|
52
|
-
"type": "module",
|
|
53
|
-
"types": "./dist/index.d.ts",
|
|
54
52
|
"scripts": {
|
|
55
53
|
"build": "bash scripts/build.sh",
|
|
56
54
|
"build:watch": "nodemon --watch src --exec 'bun run build'",
|
|
@@ -58,5 +56,7 @@
|
|
|
58
56
|
"lint": "eslint ./ --ext .ts,.tsx --fix; tsc --noEmit",
|
|
59
57
|
"test": "echo 'vitest --run'",
|
|
60
58
|
"test:coverage": "echo 'vitest run --coverage'"
|
|
61
|
-
}
|
|
62
|
-
|
|
59
|
+
},
|
|
60
|
+
"type": "module",
|
|
61
|
+
"types": "./dist/index.d.ts"
|
|
62
|
+
}
|
|
@@ -50,11 +50,22 @@ export async function createUnsignedRippleTx(
|
|
|
50
50
|
|
|
51
51
|
const sequence = accountInfo.Sequence.toString();
|
|
52
52
|
const ledgerIndexCurrent = parseInt(accountInfo.ledger_index_current);
|
|
53
|
-
|
|
54
|
-
//
|
|
55
|
-
|
|
56
|
-
if (
|
|
57
|
-
|
|
53
|
+
|
|
54
|
+
// XRP Destination Tag Validation (CRITICAL: uint32 range 0-4294967295)
|
|
55
|
+
let desttag: string | undefined = undefined;
|
|
56
|
+
if (memo && memo.trim() !== '') {
|
|
57
|
+
// Must be numeric
|
|
58
|
+
if (!/^\d+$/.test(memo.trim())) {
|
|
59
|
+
throw new Error(`XRP destination tag must be numeric. Got: "${memo}"`);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// Must be in valid range (uint32)
|
|
63
|
+
const tagNum = parseInt(memo.trim(), 10);
|
|
64
|
+
if (isNaN(tagNum) || tagNum < 0 || tagNum > 4294967295) {
|
|
65
|
+
throw new Error(`XRP destination tag must be 0-4294967295. Got: ${memo}`);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
desttag = tagNum.toString();
|
|
58
69
|
}
|
|
59
70
|
|
|
60
71
|
//console.log(tag, 'amount:', amount);
|
|
@@ -68,6 +79,24 @@ export async function createUnsignedRippleTx(
|
|
|
68
79
|
amount = amount.toString();
|
|
69
80
|
}
|
|
70
81
|
|
|
82
|
+
// Build message - only include DestinationTag if provided
|
|
83
|
+
const msg: any = {
|
|
84
|
+
type: 'ripple-sdk/MsgSend',
|
|
85
|
+
value: {
|
|
86
|
+
amount: [
|
|
87
|
+
{
|
|
88
|
+
amount: amount,
|
|
89
|
+
denom: 'drop',
|
|
90
|
+
},
|
|
91
|
+
],
|
|
92
|
+
from_address: fromAddress,
|
|
93
|
+
to_address: to,
|
|
94
|
+
},
|
|
95
|
+
};
|
|
96
|
+
if (desttag !== undefined) {
|
|
97
|
+
msg.DestinationTag = desttag;
|
|
98
|
+
}
|
|
99
|
+
|
|
71
100
|
let tx = {
|
|
72
101
|
type: 'auth/StdTx',
|
|
73
102
|
value: {
|
|
@@ -81,26 +110,20 @@ export async function createUnsignedRippleTx(
|
|
|
81
110
|
gas: '28000',
|
|
82
111
|
},
|
|
83
112
|
memo: memo || '',
|
|
84
|
-
msg: [
|
|
85
|
-
{
|
|
86
|
-
type: 'ripple-sdk/MsgSend',
|
|
87
|
-
DestinationTag: desttag,
|
|
88
|
-
value: {
|
|
89
|
-
amount: [
|
|
90
|
-
{
|
|
91
|
-
amount: amount,
|
|
92
|
-
denom: 'drop',
|
|
93
|
-
},
|
|
94
|
-
],
|
|
95
|
-
from_address: fromAddress,
|
|
96
|
-
to_address: to,
|
|
97
|
-
},
|
|
98
|
-
},
|
|
99
|
-
],
|
|
113
|
+
msg: [msg],
|
|
100
114
|
signatures: null,
|
|
101
115
|
},
|
|
102
116
|
};
|
|
103
117
|
|
|
118
|
+
// Build payment object - only include destinationTag if provided
|
|
119
|
+
const payment: any = {
|
|
120
|
+
amount,
|
|
121
|
+
destination: to,
|
|
122
|
+
};
|
|
123
|
+
if (desttag !== undefined) {
|
|
124
|
+
payment.destinationTag = desttag;
|
|
125
|
+
}
|
|
126
|
+
|
|
104
127
|
//Unsigned TX
|
|
105
128
|
let unsignedTx = {
|
|
106
129
|
addressNList: [2147483692, 2147483792, 2147483648, 0, 0],
|
|
@@ -108,11 +131,7 @@ export async function createUnsignedRippleTx(
|
|
|
108
131
|
flags: undefined,
|
|
109
132
|
lastLedgerSequence: (ledgerIndexCurrent + 1000).toString(), // Add 1000 ledgers (~16 minutes) for transaction validity
|
|
110
133
|
sequence: sequence || '0',
|
|
111
|
-
payment
|
|
112
|
-
amount,
|
|
113
|
-
destination: to,
|
|
114
|
-
destinationTag: desttag,
|
|
115
|
-
},
|
|
134
|
+
payment,
|
|
116
135
|
};
|
|
117
136
|
|
|
118
137
|
return unsignedTx;
|