@okxweb3/coin-xrp 2.4.0 → 2.4.10
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/package.json +4 -3
- package/dist/XrpWallet.d.ts +0 -16
- package/dist/XrpWallet.js +0 -152
- package/dist/XrpWallet.js.map +0 -1
- package/dist/common.d.ts +0 -66
- package/dist/common.js +0 -105
- package/dist/common.js.map +0 -1
- package/dist/const.d.ts +0 -5
- package/dist/const.js +0 -10
- package/dist/const.js.map +0 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -18
- package/dist/index.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@okxweb3/coin-xrp",
|
|
3
|
-
"version": "2.4.
|
|
3
|
+
"version": "2.4.10",
|
|
4
4
|
"description": "An XRP SDK for building Web3 wallets and applications.",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
"build": "run-s clean build:main",
|
|
9
9
|
"build:main": "tsc -p tsconfig.json",
|
|
10
10
|
"clean": "rimraf dist tsconfig.tsbuildinfo",
|
|
11
|
+
"prepublishOnly": "node ../../scripts/dep-version-check.js",
|
|
11
12
|
"test": "jest",
|
|
12
13
|
"test:watch": "jest --watch",
|
|
13
14
|
"test:coverage": "jest --coverage",
|
|
@@ -40,8 +41,8 @@
|
|
|
40
41
|
"nock": "^14.0.4"
|
|
41
42
|
},
|
|
42
43
|
"dependencies": {
|
|
43
|
-
"@okxweb3/coin-base": "2.0.
|
|
44
|
-
"@okxweb3/crypto-lib": "2.0.
|
|
44
|
+
"@okxweb3/coin-base": "^2.0.7",
|
|
45
|
+
"@okxweb3/crypto-lib": "2.0.6",
|
|
45
46
|
"ripple-keypairs": "2.0.0",
|
|
46
47
|
"xrpl": "4.2.5"
|
|
47
48
|
}
|
package/dist/XrpWallet.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { BaseWallet, CalcTxHashParams, GetDerivedPathParam, NewAddressParams, SignCommonMsgParams, SignTxParams, ValidAddressParams, ValidPrivateKeyParams, VerifyMessageParams } from "@okxweb3/coin-base";
|
|
2
|
-
import { DerivePriKeyParams } from "./common";
|
|
3
|
-
export declare class XrpWallet extends BaseWallet {
|
|
4
|
-
getDerivedPath(param: GetDerivedPathParam): Promise<any>;
|
|
5
|
-
getRandomPrivateKey(): Promise<any>;
|
|
6
|
-
getDerivedPrivateKey(param: DerivePriKeyParams): Promise<any>;
|
|
7
|
-
validPrivateKey(param: ValidPrivateKeyParams): Promise<any>;
|
|
8
|
-
checkPrivateKey(privateKey: string): boolean;
|
|
9
|
-
getNewAddress(param: NewAddressParams): Promise<any>;
|
|
10
|
-
signTransaction(param: SignTxParams): Promise<any>;
|
|
11
|
-
validAddress(param: ValidAddressParams): Promise<any>;
|
|
12
|
-
calcTxHash(param: CalcTxHashParams): Promise<string>;
|
|
13
|
-
signMessage(param: SignTxParams): Promise<string>;
|
|
14
|
-
verifyMessage(param: VerifyMessageParams): Promise<boolean>;
|
|
15
|
-
signCommonMsg(params: SignCommonMsgParams): Promise<any>;
|
|
16
|
-
}
|
package/dist/XrpWallet.js
DELETED
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.XrpWallet = void 0;
|
|
4
|
-
const coin_base_1 = require("@okxweb3/coin-base");
|
|
5
|
-
const coin_base_2 = require("@okxweb3/coin-base");
|
|
6
|
-
const xrpl_1 = require("xrpl");
|
|
7
|
-
const common_1 = require("./common");
|
|
8
|
-
const const_1 = require("./const");
|
|
9
|
-
const ripple_keypairs_1 = require("ripple-keypairs");
|
|
10
|
-
class XrpWallet extends coin_base_1.BaseWallet {
|
|
11
|
-
async getDerivedPath(param) {
|
|
12
|
-
return `m/44'/144'/0'/0/${param.index}`;
|
|
13
|
-
}
|
|
14
|
-
async getRandomPrivateKey() {
|
|
15
|
-
try {
|
|
16
|
-
const w = xrpl_1.Wallet.generate();
|
|
17
|
-
return Promise.resolve(w.privateKey);
|
|
18
|
-
}
|
|
19
|
-
catch (e) {
|
|
20
|
-
return Promise.reject(coin_base_1.GenPrivateKeyError);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
async getDerivedPrivateKey(param) {
|
|
24
|
-
try {
|
|
25
|
-
const words = param.mnemonic.split(' ');
|
|
26
|
-
if (words.length < 12) {
|
|
27
|
-
return Promise.reject(coin_base_1.GenPrivateKeyError);
|
|
28
|
-
}
|
|
29
|
-
const w = xrpl_1.Wallet.fromMnemonic(param.mnemonic, {
|
|
30
|
-
derivationPath: param.hdPath,
|
|
31
|
-
masterAddress: param.masterAddress,
|
|
32
|
-
mnemonicEncoding: param.mnemonicEncoding,
|
|
33
|
-
algorithm: param.algorithm,
|
|
34
|
-
});
|
|
35
|
-
return w.privateKey;
|
|
36
|
-
}
|
|
37
|
-
catch (e) {
|
|
38
|
-
return Promise.reject(coin_base_1.GenPrivateKeyError);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
validPrivateKey(param) {
|
|
42
|
-
const data = {
|
|
43
|
-
isValid: this.checkPrivateKey(param.privateKey),
|
|
44
|
-
privateKey: param.privateKey
|
|
45
|
-
};
|
|
46
|
-
return Promise.resolve(data);
|
|
47
|
-
}
|
|
48
|
-
checkPrivateKey(privateKey) {
|
|
49
|
-
if ((0, coin_base_1.isHexStr)(privateKey)) {
|
|
50
|
-
const keyBytes = coin_base_2.base.fromHex(privateKey.toLowerCase());
|
|
51
|
-
if (keyBytes.every(byte => byte === 0)) {
|
|
52
|
-
return false;
|
|
53
|
-
}
|
|
54
|
-
if (keyBytes.length == 33) {
|
|
55
|
-
if (!privateKey.toUpperCase().startsWith(const_1.PREFIX_ED25519) && !privateKey.toUpperCase().startsWith(const_1.PREFIX_SECP256K1)) {
|
|
56
|
-
return false;
|
|
57
|
-
}
|
|
58
|
-
return keyBytes.slice(1).some(b => b !== 0);
|
|
59
|
-
}
|
|
60
|
-
return false;
|
|
61
|
-
}
|
|
62
|
-
else {
|
|
63
|
-
if (privateKey.toLowerCase() == const_1.ZERO_SEED_ED25519.toLowerCase() ||
|
|
64
|
-
privateKey.toLowerCase() == const_1.ZERO_SEED_SECP256.toLowerCase()) {
|
|
65
|
-
return false;
|
|
66
|
-
}
|
|
67
|
-
try {
|
|
68
|
-
const w = xrpl_1.Wallet.fromSeed(privateKey);
|
|
69
|
-
return !(0, common_1.isInValidAddress)(w.address);
|
|
70
|
-
}
|
|
71
|
-
catch (e) {
|
|
72
|
-
return false;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
getNewAddress(param) {
|
|
77
|
-
try {
|
|
78
|
-
if (!this.checkPrivateKey(param.privateKey)) {
|
|
79
|
-
return Promise.reject(coin_base_1.NewAddressError);
|
|
80
|
-
}
|
|
81
|
-
const w = (0, common_1.createWallet)(param.privateKey, param.addressType);
|
|
82
|
-
if ((0, common_1.isInValidAddress)(w.address)) {
|
|
83
|
-
return Promise.reject(coin_base_1.NewAddressError);
|
|
84
|
-
}
|
|
85
|
-
return Promise.resolve({
|
|
86
|
-
address: w.address,
|
|
87
|
-
publicKey: w.publicKey
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
catch (e) {
|
|
91
|
-
return Promise.reject(coin_base_1.NewAddressError);
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
signTransaction(param) {
|
|
95
|
-
const privateKey = param.privateKey;
|
|
96
|
-
const w = (0, common_1.createWallet)(privateKey);
|
|
97
|
-
const xrpParam = param.data;
|
|
98
|
-
const tx = (0, common_1.convertTxParam)(xrpParam, w.address);
|
|
99
|
-
return Promise.resolve(w.sign(tx));
|
|
100
|
-
}
|
|
101
|
-
validAddress(param) {
|
|
102
|
-
let res = {
|
|
103
|
-
isValid: false,
|
|
104
|
-
address: param.address
|
|
105
|
-
};
|
|
106
|
-
let isInValid = (0, common_1.isInValidAddress)(param.address);
|
|
107
|
-
if (isInValid) {
|
|
108
|
-
return Promise.resolve(res);
|
|
109
|
-
}
|
|
110
|
-
res.isValid = (0, xrpl_1.isValidClassicAddress)(param.address) || (0, xrpl_1.isValidXAddress)(param.address);
|
|
111
|
-
return Promise.resolve(res);
|
|
112
|
-
}
|
|
113
|
-
calcTxHash(param) {
|
|
114
|
-
return Promise.resolve(xrpl_1.hashes.hashSignedTx(param.data));
|
|
115
|
-
}
|
|
116
|
-
signMessage(param) {
|
|
117
|
-
if (!this.checkPrivateKey(param.privateKey)) {
|
|
118
|
-
return Promise.reject("Invalid private key");
|
|
119
|
-
}
|
|
120
|
-
const w = (0, common_1.createWallet)(param.privateKey);
|
|
121
|
-
const msg = param.data;
|
|
122
|
-
return Promise.resolve((0, ripple_keypairs_1.sign)((0, common_1.transferMsgPayload)(msg), w.privateKey).toString());
|
|
123
|
-
}
|
|
124
|
-
verifyMessage(param) {
|
|
125
|
-
const msg = param.data;
|
|
126
|
-
return Promise.resolve((0, ripple_keypairs_1.verify)((0, common_1.transferMsgPayload)(msg.message), param.signature, msg.publicKey));
|
|
127
|
-
}
|
|
128
|
-
signCommonMsg(params) {
|
|
129
|
-
const w = (0, common_1.createWallet)(params.privateKey);
|
|
130
|
-
if (w.privateKey.length != 66) {
|
|
131
|
-
return Promise.reject("Invalid private key");
|
|
132
|
-
}
|
|
133
|
-
if ((0, common_1.isEd25519PrivateKey)(w.privateKey)) {
|
|
134
|
-
return super.signCommonMsg({
|
|
135
|
-
privateKey: w.privateKey,
|
|
136
|
-
privateKeyHex: w.privateKey.slice(2),
|
|
137
|
-
message: params.message,
|
|
138
|
-
signType: coin_base_1.SignType.ED25519
|
|
139
|
-
});
|
|
140
|
-
}
|
|
141
|
-
else {
|
|
142
|
-
return super.signCommonMsg({
|
|
143
|
-
privateKey: w.privateKey,
|
|
144
|
-
privateKeyHex: w.privateKey.slice(2),
|
|
145
|
-
message: params.message,
|
|
146
|
-
signType: coin_base_1.SignType.Secp256k1
|
|
147
|
-
});
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
exports.XrpWallet = XrpWallet;
|
|
152
|
-
//# sourceMappingURL=XrpWallet.js.map
|
package/dist/XrpWallet.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"XrpWallet.js","sourceRoot":"","sources":["../src/XrpWallet.ts"],"names":[],"mappings":";;;AAAA,kDAe4B;AAC5B,kDAAwC;AACxC,+BAA4E;AAC5E,qCAUkB;AAClB,mCAA+F;AAC/F,qDAA6C;AAE7C,MAAa,SAAU,SAAQ,sBAAU;IACrC,KAAK,CAAC,cAAc,CAAC,KAA0B;QAC3C,OAAO,mBAAmB,KAAK,CAAC,KAAK,EAAE,CAAC;IAC5C,CAAC;IAED,KAAK,CAAC,mBAAmB;QACrB,IAAI;YACA,MAAM,CAAC,GAAG,aAAM,CAAC,QAAQ,EAAE,CAAA;YAC3B,OAAO,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,UAAU,CAAC,CAAA;SACvC;QAAC,OAAO,CAAC,EAAE;YACR,OAAO,OAAO,CAAC,MAAM,CAAC,8BAAkB,CAAC,CAAC;SAC7C;IACL,CAAC;IAED,KAAK,CAAC,oBAAoB,CAAC,KAAyB;QAChD,IAAI;YACA,MAAM,KAAK,GAAG,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;YACvC,IAAI,KAAK,CAAC,MAAM,GAAG,EAAE,EAAE;gBACnB,OAAO,OAAO,CAAC,MAAM,CAAC,8BAAkB,CAAC,CAAC;aAC7C;YACD,MAAM,CAAC,GAAG,aAAM,CAAC,YAAY,CAAC,KAAK,CAAC,QAAQ,EAAE;gBAC1C,cAAc,EAAE,KAAK,CAAC,MAAM;gBAC5B,aAAa,EAAE,KAAK,CAAC,aAAa;gBAClC,gBAAgB,EAAE,KAAK,CAAC,gBA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AAC,GAAG,CAAC,OAAO,CAAC,EAAE,KAAK,CAAC,SAAS,EAAE,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC;IACpG,CAAC;IAED,aAAa,CAAC,MAA2B;QACrC,MAAM,CAAC,GAAG,IAAA,qBAAY,EAAC,MAAM,CAAC,UAAU,CAAC,CAAA;QACzC,IAAI,CAAC,CAAC,UAAU,CAAC,MAAM,IAAI,EAAE,EAAE;YAC3B,OAAO,OAAO,CAAC,MAAM,CAAC,qBAAqB,CAAC,CAAA;SAC/C;QACD,IAAI,IAAA,4BAAmB,EAAC,CAAC,CAAC,UAAU,CAAC,EAAE;YACnC,OAAO,KAAK,CAAC,aAAa,CAAC;gBACvB,UAAU,EAAE,CAAC,CAAC,UAAU;gBACxB,aAAa,EAAE,CAAC,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC;gBACpC,OAAO,EAAE,MAAM,CAAC,OAAO;gBACvB,QAAQ,EAAE,oBAAQ,CAAC,OAAO;aAC7B,CAAC,CAAA;SACL;aAAM;YACH,OAAO,KAAK,CAAC,aAAa,CAAC;gBACvB,UAAU,EAAE,CAAC,CAAC,UAAU;gBACxB,aAAa,EAAE,CAAC,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC;gBACpC,OAAO,EAAE,MAAM,CAAC,OAAO;gBACvB,QAAQ,EAAE,oBAAQ,CAAC,SAAS;aAC/B,CAAC,CAAA;SACL;IACL,CAAC;CAEJ;AArJD,8BAqJC"}
|
package/dist/common.d.ts
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { TrustSet, Wallet } from "xrpl";
|
|
2
|
-
import { Amount, IssuedCurrencyAmount, Memo, MPTAmount, Path, Signer } from "xrpl/src/models/common";
|
|
3
|
-
import { Payment, PaymentFlagsInterface } from "xrpl/src/models/transactions/payment";
|
|
4
|
-
import { Account, GlobalFlags } from "xrpl/src/models/transactions/common";
|
|
5
|
-
import ECDSA from "xrpl/src/ECDSA";
|
|
6
|
-
export type DerivePriKeyParams = {
|
|
7
|
-
mnemonic: string;
|
|
8
|
-
hdPath: string;
|
|
9
|
-
masterAddress?: string;
|
|
10
|
-
mnemonicEncoding?: 'bip39' | 'rfc1751';
|
|
11
|
-
algorithm?: ECDSA;
|
|
12
|
-
};
|
|
13
|
-
export type XrpParam = {
|
|
14
|
-
type: "transfer" | "TrustSet";
|
|
15
|
-
base: XrpBasePram;
|
|
16
|
-
data: any;
|
|
17
|
-
};
|
|
18
|
-
export type XrpBasePram = {
|
|
19
|
-
account: Account;
|
|
20
|
-
fee: string;
|
|
21
|
-
sequence: number | string;
|
|
22
|
-
accountTxnID?: string;
|
|
23
|
-
flags?: number | GlobalFlags;
|
|
24
|
-
lastLedgerSequence?: number | string;
|
|
25
|
-
memos?: Memo[];
|
|
26
|
-
signers?: Signer[];
|
|
27
|
-
sourceTag?: number;
|
|
28
|
-
signingPubKey?: string;
|
|
29
|
-
ticketSequence?: number;
|
|
30
|
-
txnSignature?: string;
|
|
31
|
-
networkID?: number;
|
|
32
|
-
};
|
|
33
|
-
export type PaymentTxParam = {
|
|
34
|
-
amount: Amount | MPTAmount;
|
|
35
|
-
destination: Account;
|
|
36
|
-
destinationTag?: number;
|
|
37
|
-
invoiceID?: string;
|
|
38
|
-
paths?: Path[];
|
|
39
|
-
sendMax?: Amount | MPTAmount;
|
|
40
|
-
deliverMin?: Amount | MPTAmount;
|
|
41
|
-
credentialIDs?: string[];
|
|
42
|
-
flags?: number | PaymentFlagsInterface;
|
|
43
|
-
};
|
|
44
|
-
export type TrustSetParam = {
|
|
45
|
-
limitAmount: IssuedCurrencyAmount;
|
|
46
|
-
qualityIn?: number;
|
|
47
|
-
qualityOut?: number;
|
|
48
|
-
flags?: number;
|
|
49
|
-
};
|
|
50
|
-
export type SignMessageRequest = {
|
|
51
|
-
messageId: string;
|
|
52
|
-
url: string;
|
|
53
|
-
title: string;
|
|
54
|
-
favicon: string | null | undefined;
|
|
55
|
-
message: string;
|
|
56
|
-
};
|
|
57
|
-
export type VerifyMessageSig = {
|
|
58
|
-
message: SignMessageRequest;
|
|
59
|
-
publicKey: string;
|
|
60
|
-
};
|
|
61
|
-
export declare function isInValidAddress(addr: string): boolean;
|
|
62
|
-
export declare function convertTxParam(xrpParam: XrpParam, account: string): Payment | TrustSet;
|
|
63
|
-
export declare function isSecp256PrivateKey(privateKey: string): boolean;
|
|
64
|
-
export declare function isEd25519PrivateKey(privateKey: string): boolean;
|
|
65
|
-
export declare function createWallet(seedOrPrivate: string, addressType?: string): Wallet;
|
|
66
|
-
export declare function transferMsgPayload(msg: SignMessageRequest): string;
|
package/dist/common.js
DELETED
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.transferMsgPayload = exports.createWallet = exports.isEd25519PrivateKey = exports.isSecp256PrivateKey = exports.convertTxParam = exports.isInValidAddress = void 0;
|
|
4
|
-
const coin_base_1 = require("@okxweb3/coin-base");
|
|
5
|
-
const crypto_lib_1 = require("@okxweb3/crypto-lib");
|
|
6
|
-
const coin_base_2 = require("@okxweb3/coin-base");
|
|
7
|
-
const xrpl_1 = require("xrpl");
|
|
8
|
-
const const_1 = require("./const");
|
|
9
|
-
function isInValidAddress(addr) {
|
|
10
|
-
return const_1.INVALID_ADDRESS.includes(addr);
|
|
11
|
-
}
|
|
12
|
-
exports.isInValidAddress = isInValidAddress;
|
|
13
|
-
function convertTxParam(xrpParam, account) {
|
|
14
|
-
const baseParm = xrpParam.base;
|
|
15
|
-
const tx = convertTxParamInner(xrpParam, account);
|
|
16
|
-
if (baseParm.lastLedgerSequence) {
|
|
17
|
-
tx.LastLedgerSequence = typeof baseParm.lastLedgerSequence == 'string' ? Number(baseParm.lastLedgerSequence) : baseParm.lastLedgerSequence;
|
|
18
|
-
}
|
|
19
|
-
return tx;
|
|
20
|
-
}
|
|
21
|
-
exports.convertTxParam = convertTxParam;
|
|
22
|
-
function convertTxParamInner(xrpParam, account) {
|
|
23
|
-
const baseParm = xrpParam.base;
|
|
24
|
-
const sequence = typeof baseParm.sequence == 'string' ? Number(baseParm.sequence) : baseParm.sequence;
|
|
25
|
-
switch (xrpParam.type) {
|
|
26
|
-
case "transfer": {
|
|
27
|
-
const txP = xrpParam.data;
|
|
28
|
-
const tx = {
|
|
29
|
-
TransactionType: 'Payment',
|
|
30
|
-
Account: account,
|
|
31
|
-
Amount: txP.amount,
|
|
32
|
-
Destination: txP.destination,
|
|
33
|
-
Sequence: sequence,
|
|
34
|
-
Fee: baseParm.fee,
|
|
35
|
-
DestinationTag: txP.destinationTag,
|
|
36
|
-
InvoiceID: txP.invoiceID,
|
|
37
|
-
Paths: txP.paths,
|
|
38
|
-
SendMax: txP.sendMax,
|
|
39
|
-
DeliverMin: txP.deliverMin,
|
|
40
|
-
CredentialIDs: txP.credentialIDs,
|
|
41
|
-
Flags: txP.flags,
|
|
42
|
-
};
|
|
43
|
-
return tx;
|
|
44
|
-
}
|
|
45
|
-
case "TrustSet": {
|
|
46
|
-
const txP = xrpParam.data;
|
|
47
|
-
const tx = {
|
|
48
|
-
TransactionType: 'TrustSet',
|
|
49
|
-
Account: account,
|
|
50
|
-
Sequence: sequence,
|
|
51
|
-
Fee: baseParm.fee,
|
|
52
|
-
LimitAmount: txP.limitAmount,
|
|
53
|
-
QualityIn: txP.qualityIn,
|
|
54
|
-
QualityOut: txP.qualityOut,
|
|
55
|
-
Flags: txP.flags,
|
|
56
|
-
};
|
|
57
|
-
return tx;
|
|
58
|
-
}
|
|
59
|
-
default:
|
|
60
|
-
throw new Error(coin_base_1.SignTxError);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
function isSecp256PrivateKey(privateKey) {
|
|
64
|
-
return (0, coin_base_1.isHexStr)(privateKey) && privateKey.startsWith("00");
|
|
65
|
-
}
|
|
66
|
-
exports.isSecp256PrivateKey = isSecp256PrivateKey;
|
|
67
|
-
function isEd25519PrivateKey(privateKey) {
|
|
68
|
-
return (0, coin_base_1.isHexStr)(privateKey) && (privateKey.startsWith("ED") || privateKey.startsWith("ed"));
|
|
69
|
-
}
|
|
70
|
-
exports.isEd25519PrivateKey = isEd25519PrivateKey;
|
|
71
|
-
function createWallet(seedOrPrivate, addressType) {
|
|
72
|
-
if ((0, coin_base_1.isHexStr)(seedOrPrivate)) {
|
|
73
|
-
let pubKeyHex;
|
|
74
|
-
if (seedOrPrivate.startsWith("00") && seedOrPrivate.length == 66) {
|
|
75
|
-
let pubKey = crypto_lib_1.signUtil.secp256k1.publicKeyCreate(coin_base_2.base.fromHex(seedOrPrivate.slice(2)), true);
|
|
76
|
-
pubKeyHex = coin_base_2.base.toHex(pubKey);
|
|
77
|
-
}
|
|
78
|
-
else if (seedOrPrivate.startsWith("ED") && seedOrPrivate.length == 66) {
|
|
79
|
-
let pubKey = crypto_lib_1.signUtil.ed25519.publicKeyCreate(coin_base_2.base.fromHex(seedOrPrivate.slice(2)));
|
|
80
|
-
pubKeyHex = 'ED' + coin_base_2.base.toHex(pubKey);
|
|
81
|
-
}
|
|
82
|
-
else {
|
|
83
|
-
throw new Error(coin_base_1.NewAddressError);
|
|
84
|
-
}
|
|
85
|
-
return new xrpl_1.Wallet(pubKeyHex.toUpperCase(), seedOrPrivate);
|
|
86
|
-
}
|
|
87
|
-
else {
|
|
88
|
-
return xrpl_1.Wallet.fromSeed(seedOrPrivate);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
exports.createWallet = createWallet;
|
|
92
|
-
function transferMsgPayload(msg) {
|
|
93
|
-
let fullMessage = "";
|
|
94
|
-
fullMessage = fullMessage.concat("messageId: ", msg.messageId);
|
|
95
|
-
fullMessage = fullMessage.concat("\nurl: ", msg.url);
|
|
96
|
-
fullMessage = fullMessage.concat("\ntitle: ", msg.title);
|
|
97
|
-
if (msg.favicon) {
|
|
98
|
-
fullMessage = fullMessage.concat("\nfavicon: ", msg.favicon);
|
|
99
|
-
}
|
|
100
|
-
fullMessage = fullMessage.concat("\nmessage: ", msg.message);
|
|
101
|
-
const textEncoder = new TextEncoder();
|
|
102
|
-
return coin_base_2.base.toHex(Buffer.from(textEncoder.encode(fullMessage)));
|
|
103
|
-
}
|
|
104
|
-
exports.transferMsgPayload = transferMsgPayload;
|
|
105
|
-
//# sourceMappingURL=common.js.map
|
package/dist/common.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"common.js","sourceRoot":"","sources":["../src/common.ts"],"names":[],"mappings":";;;AAAA,kDAA0E;AAC1E,oDAA6C;AAC7C,kDAAwC;AACxC,+BAAsC;AAKtC,mCAAwC;AAuExC,SAAgB,gBAAgB,CAAC,IAAY;IACzC,OAAO,uBAAe,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAA;AACzC,CAAC;AAFD,4CAEC;AAED,SAAgB,cAAc,CAAC,QAAkB,EAAE,OAAe;IAC9D,MAAM,QAAQ,GAAG,QAAQ,CAAC,IAAI,CAAA;IAC9B,MAAM,EAAE,GAAG,mBAAmB,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IAClD,IAAI,QAAQ,CAAC,kBAAkB,EAAE;QAC7B,EAAE,CAAC,kBAAkB,GAAG,OAAO,QAAQ,CAAC,kBAAkB,IAAI,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,kBAAkB,CAAC;KAC9I;IACD,OAAO,EAAE,CAAC;AACd,CAAC;AAPD,wCAOC;AAED,SAAS,mBAAmB,CAAC,QAAkB,EAAE,OAAe;IAC5D,MAAM,QAAQ,GAAG,QAAQ,CAAC,IAAI,CAAA;IAC9B,MAAM,QAAQ,GAAG,OAAO,QAAQ,CAAC,QAAQ,IAAI,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC;IACtG,QAAQ,QAAQ,CAAC,IAAI,EAAE;Q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AAI,WAAW,GAAW,EAAE,CAAC;IAC7B,WAAW,GAAG,WAAW,CAAC,MAAM,CAAC,aAAa,EAAE,GAAG,CAAC,SAAS,CAAC,CAAA;IAC9D,WAAW,GAAG,WAAW,CAAC,MAAM,CAAC,SAAS,EAAE,GAAG,CAAC,GAAG,CAAC,CAAA;IACpD,WAAW,GAAG,WAAW,CAAC,MAAM,CAAC,WAAW,EAAE,GAAG,CAAC,KAAK,CAAC,CAAA;IACxD,IAAI,GAAG,CAAC,OAAO,EAAE;QACb,WAAW,GAAG,WAAW,CAAC,MAAM,CAAC,aAAa,EAAE,GAAG,CAAC,OAAO,CAAC,CAAA;KAC/D;IACD,WAAW,GAAG,WAAW,CAAC,MAAM,CAAC,aAAa,EAAE,GAAG,CAAC,OAAO,CAAC,CAAA;IAC5D,MAAM,WAAW,GAAG,IAAI,WAAW,EAAE,CAAC;IACtC,OAAO,gBAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,CAAA;AACnE,CAAC;AAXD,gDAWC"}
|
package/dist/const.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
export declare const ZERO_SEED_ED25519 = "sEdSJHS4oiAdz7w2X2ni1gFiqtbJHqE";
|
|
2
|
-
export declare const ZERO_SEED_SECP256 = "sp6JS7f14BuwFY8Mw6bTtLKWauoUs";
|
|
3
|
-
export declare const INVALID_ADDRESS: string[];
|
|
4
|
-
export declare const PREFIX_ED25519 = "ED";
|
|
5
|
-
export declare const PREFIX_SECP256K1 = "00";
|
package/dist/const.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PREFIX_SECP256K1 = exports.PREFIX_ED25519 = exports.INVALID_ADDRESS = exports.ZERO_SEED_SECP256 = exports.ZERO_SEED_ED25519 = void 0;
|
|
4
|
-
exports.ZERO_SEED_ED25519 = "sEdSJHS4oiAdz7w2X2ni1gFiqtbJHqE";
|
|
5
|
-
exports.ZERO_SEED_SECP256 = "sp6JS7f14BuwFY8Mw6bTtLKWauoUs";
|
|
6
|
-
exports.INVALID_ADDRESS = ["rrrrrrrrrrrrrrrrrrrrrhoLvTp", "rrrrrrrrrrrrrrrrrrrrBZbvji",
|
|
7
|
-
"rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "rrrrrrrrrrrrrrrrrNAMEtxvNvQ", "rrrrrrrrrrrrrrrrrrrn5RM1rHd"];
|
|
8
|
-
exports.PREFIX_ED25519 = "ED";
|
|
9
|
-
exports.PREFIX_SECP256K1 = "00";
|
|
10
|
-
//# sourceMappingURL=const.js.map
|
package/dist/const.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"const.js","sourceRoot":"","sources":["../src/const.ts"],"names":[],"mappings":";;;AAGa,QAAA,iBAAiB,GAAG,iCAAiC,CAAA;AACrD,QAAA,iBAAiB,GAAG,+BAA+B,CAAA;AAEnD,QAAA,eAAe,GAAG,CAAC,6BAA6B,EAAC,4BAA4B;IACtF,oCAAoC,EAAC,6BAA6B,EAAC,6BAA6B,CAAC,CAAC;AAEzF,QAAA,cAAc,GAAG,IAAI,CAAA;AACrB,QAAA,gBAAgB,GAAG,IAAI,CAAA"}
|
package/dist/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./XrpWallet";
|
package/dist/index.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./XrpWallet"), exports);
|
|
18
|
-
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AACA,8CAA2B"}
|