@trustwallet/wallet-core 4.2.0-dev-rc2 → 4.2.0-dev-rc4
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/generated/core_proto.d.ts +761 -9
- package/dist/generated/core_proto.js +2808 -504
- package/dist/lib/wallet-core.js +151 -147
- package/dist/lib/wallet-core.wasm +0 -0
- package/dist/src/keystore/default-impl.d.ts +0 -1
- package/dist/src/keystore/default-impl.js +3 -33
- package/dist/src/keystore/types.d.ts +1 -3
- package/dist/src/keystore/types.js +0 -1
- package/dist/src/wallet-core.d.ts +23 -8
- package/package.json +1 -1
Binary file
|
@@ -13,7 +13,6 @@ export declare class Default implements Types.IKeyStore {
|
|
13
13
|
importWallet(wallet: Types.Wallet): Promise<void>;
|
14
14
|
import(mnemonic: string, name: string, password: string, coins: CoinType[], encryption: StoredKeyEncryption): Promise<Types.Wallet>;
|
15
15
|
importKey(key: Uint8Array, name: string, password: string, coin: CoinType, encryption: StoredKeyEncryption): Promise<Types.Wallet>;
|
16
|
-
importTON(tonMnemonic: string, name: string, password: string, coin: CoinType, encryption: StoredKeyEncryption): Promise<Types.Wallet>;
|
17
16
|
addAccounts(id: string, password: string, coins: CoinType[]): Promise<Types.Wallet>;
|
18
17
|
getKey(id: string, password: string, account: Types.ActiveAccount): Promise<PrivateKey>;
|
19
18
|
export(id: string, password: string): Promise<string | Uint8Array>;
|
@@ -75,23 +75,6 @@ var Default = /** @class */ (function () {
|
|
75
75
|
.catch(function (error) { return reject(error); });
|
76
76
|
});
|
77
77
|
};
|
78
|
-
Default.prototype.importTON = function (tonMnemonic, name, password, coin, encryption) {
|
79
|
-
var _this = this;
|
80
|
-
return new Promise(function (resolve, reject) {
|
81
|
-
var _a = _this.core, StoredKey = _a.StoredKey, TONWallet = _a.TONWallet;
|
82
|
-
var passphrase = "";
|
83
|
-
if (!TONWallet.isValidMnemonic(tonMnemonic, passphrase)) {
|
84
|
-
throw Types.Error.InvalidMnemonic;
|
85
|
-
}
|
86
|
-
var pass = Buffer.from(password);
|
87
|
-
var storedKey = StoredKey.importTONWalletWithEncryption(tonMnemonic, name, pass, coin, encryption);
|
88
|
-
var wallet = _this.mapWallet(storedKey);
|
89
|
-
storedKey.delete();
|
90
|
-
_this.importWallet(wallet)
|
91
|
-
.then(function () { return resolve(wallet); })
|
92
|
-
.catch(function (error) { return reject(error); });
|
93
|
-
});
|
94
|
-
};
|
95
78
|
Default.prototype.addAccounts = function (id, password, coins) {
|
96
79
|
var _this = this;
|
97
80
|
return this.load(id).then(function (wallet) {
|
@@ -110,21 +93,11 @@ var Default = /** @class */ (function () {
|
|
110
93
|
var _this = this;
|
111
94
|
return this.load(id).then(function (wallet) {
|
112
95
|
var storedKey = _this.mapStoredKey(wallet);
|
96
|
+
var hdWallet = storedKey.wallet(Buffer.from(password));
|
113
97
|
var coin = _this.core.CoinType.values["" + account.coin];
|
114
|
-
var privateKey;
|
115
|
-
switch (wallet.type) {
|
116
|
-
// In case of BIP39 mnemonic, we should use the custom derivation path.
|
117
|
-
case Types.WalletType.Mnemonic:
|
118
|
-
var hdWallet = storedKey.wallet(Buffer.from(password));
|
119
|
-
privateKey = hdWallet.getKey(coin, account.derivationPath);
|
120
|
-
hdWallet.delete();
|
121
|
-
break;
|
122
|
-
// Otherwise, use the default implementation.
|
123
|
-
default:
|
124
|
-
privateKey = storedKey.privateKey(coin, Buffer.from(password));
|
125
|
-
break;
|
126
|
-
}
|
98
|
+
var privateKey = hdWallet.getKey(coin, account.derivationPath);
|
127
99
|
storedKey.delete();
|
100
|
+
hdWallet.delete();
|
128
101
|
return privateKey;
|
129
102
|
});
|
130
103
|
};
|
@@ -140,9 +113,6 @@ var Default = /** @class */ (function () {
|
|
140
113
|
case Types.WalletType.PrivateKey:
|
141
114
|
value = storedKey.decryptPrivateKey(Buffer.from(password));
|
142
115
|
break;
|
143
|
-
case Types.WalletType.TonMnemonic:
|
144
|
-
value = storedKey.decryptTONMnemonic(Buffer.from(password));
|
145
|
-
break;
|
146
116
|
default:
|
147
117
|
throw Types.Error.InvalidJSON;
|
148
118
|
}
|
@@ -3,8 +3,7 @@ export declare enum WalletType {
|
|
3
3
|
Mnemonic = "mnemonic",
|
4
4
|
PrivateKey = "privateKey",
|
5
5
|
WatchOnly = "watchOnly",
|
6
|
-
Hardware = "hardware"
|
7
|
-
TonMnemonic = "ton-mnemonic"
|
6
|
+
Hardware = "hardware"
|
8
7
|
}
|
9
8
|
export declare enum Error {
|
10
9
|
WalletNotFound = "wallet not found",
|
@@ -35,7 +34,6 @@ export interface IKeyStore {
|
|
35
34
|
import(mnemonic: string, name: string, password: string, coins: CoinType[], encryption: StoredKeyEncryption): Promise<Wallet>;
|
36
35
|
importKey(key: Uint8Array, name: string, password: string, coin: CoinType, encryption: StoredKeyEncryption): Promise<Wallet>;
|
37
36
|
importWallet(wallet: Wallet): Promise<void>;
|
38
|
-
importTON(tonMnemonic: string, name: string, password: string, coin: CoinType, encryption: StoredKeyEncryption): Promise<Wallet>;
|
39
37
|
addAccounts(id: string, password: string, coins: CoinType[]): Promise<Wallet>;
|
40
38
|
getKey(id: string, password: string, account: ActiveAccount): Promise<PrivateKey>;
|
41
39
|
delete(id: string, password: string): Promise<void>;
|
@@ -10,7 +10,6 @@ var WalletType;
|
|
10
10
|
WalletType["PrivateKey"] = "privateKey";
|
11
11
|
WalletType["WatchOnly"] = "watchOnly";
|
12
12
|
WalletType["Hardware"] = "hardware";
|
13
|
-
WalletType["TonMnemonic"] = "ton-mnemonic";
|
14
13
|
})(WalletType = exports.WalletType || (exports.WalletType = {}));
|
15
14
|
var Error;
|
16
15
|
(function (Error) {
|
@@ -115,6 +115,12 @@ export class Base64 {
|
|
115
115
|
static encode(data: Uint8Array | Buffer): string;
|
116
116
|
static encodeUrl(data: Uint8Array | Buffer): string;
|
117
117
|
}
|
118
|
+
export class Bech32 {
|
119
|
+
static encode(hrp: string, data: Uint8Array | Buffer): string;
|
120
|
+
static decode(string: string): Uint8Array;
|
121
|
+
static encodeM(hrp: string, data: Uint8Array | Buffer): string;
|
122
|
+
static decodeM(string: string): Uint8Array;
|
123
|
+
}
|
118
124
|
export class BitcoinAddress {
|
119
125
|
static equal(lhs: BitcoinAddress, rhs: BitcoinAddress): boolean;
|
120
126
|
static isValid(data: Uint8Array | Buffer): boolean;
|
@@ -223,6 +229,8 @@ export class Blockchain {
|
|
223
229
|
static internetComputer: Blockchain;
|
224
230
|
static nativeEvmos: Blockchain;
|
225
231
|
static nativeInjective: Blockchain;
|
232
|
+
static bitcoinCash: Blockchain;
|
233
|
+
static pactus: Blockchain;
|
226
234
|
}
|
227
235
|
export class Cardano {
|
228
236
|
static minAdaAmount(tokenBundle: Uint8Array | Buffer): number;
|
@@ -390,6 +398,7 @@ export class CoinType {
|
|
390
398
|
static blast: CoinType;
|
391
399
|
static bounceBit: CoinType;
|
392
400
|
static zkLinkNova: CoinType;
|
401
|
+
static pactus: CoinType;
|
393
402
|
}
|
394
403
|
export class CoinTypeConfiguration {
|
395
404
|
static getSymbol(type: CoinType): string;
|
@@ -448,6 +457,7 @@ export class Derivation {
|
|
448
457
|
static litecoinLegacy: Derivation;
|
449
458
|
static solanaSolana: Derivation;
|
450
459
|
static stratisSegwit: Derivation;
|
460
|
+
static bitcoinTaproot: Derivation;
|
451
461
|
}
|
452
462
|
export class DerivationPath {
|
453
463
|
static create(purpose: Purpose, coin: number, account: number, change: number, address: number): DerivationPath;
|
@@ -719,6 +729,7 @@ export class HRP {
|
|
719
729
|
static harmony: HRP;
|
720
730
|
static cardano: HRP;
|
721
731
|
static qtum: HRP;
|
732
|
+
static pactus: HRP;
|
722
733
|
static stratis: HRP;
|
723
734
|
static nativeInjective: HRP;
|
724
735
|
static osmosis: HRP;
|
@@ -775,6 +786,10 @@ export class Hash {
|
|
775
786
|
export class LiquidStaking {
|
776
787
|
static buildRequest(input: Uint8Array | Buffer): Uint8Array;
|
777
788
|
}
|
789
|
+
export class MessageSigner {
|
790
|
+
static sign(coin: CoinType, input: Uint8Array | Buffer): Uint8Array;
|
791
|
+
static verify(coin: CoinType, input: Uint8Array | Buffer): boolean;
|
792
|
+
}
|
778
793
|
export class Mnemonic {
|
779
794
|
static isValid(mnemonic: string): boolean;
|
780
795
|
static isValidWord(word: string): boolean;
|
@@ -855,6 +870,7 @@ export class Purpose {
|
|
855
870
|
static bip44: Purpose;
|
856
871
|
static bip49: Purpose;
|
857
872
|
static bip84: Purpose;
|
873
|
+
static bip86: Purpose;
|
858
874
|
static bip1852: Purpose;
|
859
875
|
}
|
860
876
|
export class RippleXAddress {
|
@@ -891,6 +907,11 @@ export class SolanaAddress {
|
|
891
907
|
}
|
892
908
|
export class SolanaTransaction {
|
893
909
|
static updateBlockhashAndSign(encodedTx: string, recentBlockhash: string, privateKeys: DataVector): Uint8Array;
|
910
|
+
static getComputeUnitPrice(encodedTx: string): string;
|
911
|
+
static getComputeUnitLimit(encodedTx: string): string;
|
912
|
+
static setComputeUnitPrice(encodedTx: string, price: string): string;
|
913
|
+
static setComputeUnitLimit(encodedTx: string, limit: string): string;
|
914
|
+
static setFeePayer(encodedTx: string, feePayer: string): string;
|
894
915
|
}
|
895
916
|
export class StarkExMessageSigner {
|
896
917
|
static signMessage(privateKey: PrivateKey, message: string): string;
|
@@ -928,8 +949,6 @@ export class StoredKey {
|
|
928
949
|
static importPrivateKeyWithEncryption(privateKey: Uint8Array | Buffer, name: string, password: Uint8Array | Buffer, coin: CoinType, encryption: StoredKeyEncryption): StoredKey;
|
929
950
|
static importHDWallet(mnemonic: string, name: string, password: Uint8Array | Buffer, coin: CoinType): StoredKey;
|
930
951
|
static importHDWalletWithEncryption(mnemonic: string, name: string, password: Uint8Array | Buffer, coin: CoinType, encryption: StoredKeyEncryption): StoredKey;
|
931
|
-
static importTONWallet(tonMnemonic: string, name: string, password: Uint8Array | Buffer, coin: CoinType): StoredKey;
|
932
|
-
static importTONWalletWithEncryption(tonMnemonic: string, name: string, password: Uint8Array | Buffer, coin: CoinType, encryption: StoredKeyEncryption): StoredKey;
|
933
952
|
static importJSON(json: Uint8Array | Buffer): StoredKey;
|
934
953
|
static createLevel(name: string, password: Uint8Array | Buffer, encryptionLevel: StoredKeyEncryptionLevel): StoredKey;
|
935
954
|
static createLevelAndEncryption(name: string, password: Uint8Array | Buffer, encryptionLevel: StoredKeyEncryptionLevel, encryption: StoredKeyEncryption): StoredKey;
|
@@ -938,7 +957,6 @@ export class StoredKey {
|
|
938
957
|
identifier(): string;
|
939
958
|
name(): string;
|
940
959
|
isMnemonic(): boolean;
|
941
|
-
isTONMnemonic(): boolean;
|
942
960
|
accountCount(): number;
|
943
961
|
encryptionParameters(): string;
|
944
962
|
account(index: number): Account;
|
@@ -952,7 +970,6 @@ export class StoredKey {
|
|
952
970
|
store(path: string): boolean;
|
953
971
|
decryptPrivateKey(password: Uint8Array | Buffer): Uint8Array;
|
954
972
|
decryptMnemonic(password: Uint8Array | Buffer): string;
|
955
|
-
decryptTONMnemonic(password: Uint8Array | Buffer): string;
|
956
973
|
privateKey(coin: CoinType, password: Uint8Array | Buffer): PrivateKey;
|
957
974
|
wallet(password: Uint8Array | Buffer): HDWallet;
|
958
975
|
exportJSON(): Uint8Array;
|
@@ -986,11 +1003,7 @@ export class TONMessageSigner {
|
|
986
1003
|
static signMessage(privateKey: PrivateKey, message: string): string;
|
987
1004
|
}
|
988
1005
|
export class TONWallet {
|
989
|
-
static isValidMnemonic(mnemonic: string, passphrase: string): boolean;
|
990
1006
|
static buildV4R2StateInit(publicKey: PublicKey, workchain: number, walletId: number): string;
|
991
|
-
static createWithMnemonic(mnemonic: string, passphrase: string): TONWallet;
|
992
|
-
getKey(): PrivateKey;
|
993
|
-
delete(): void;
|
994
1007
|
}
|
995
1008
|
export class TezosMessageSigner {
|
996
1009
|
static formatMessage(message: string, url: string): string;
|
@@ -1036,6 +1049,7 @@ export interface WalletCore {
|
|
1036
1049
|
Base32: typeof Base32;
|
1037
1050
|
Base58: typeof Base58;
|
1038
1051
|
Base64: typeof Base64;
|
1052
|
+
Bech32: typeof Bech32;
|
1039
1053
|
BitcoinAddress: typeof BitcoinAddress;
|
1040
1054
|
BitcoinMessageSigner: typeof BitcoinMessageSigner;
|
1041
1055
|
BitcoinScript: typeof BitcoinScript;
|
@@ -1069,6 +1083,7 @@ export interface WalletCore {
|
|
1069
1083
|
HRP: typeof HRP;
|
1070
1084
|
Hash: typeof Hash;
|
1071
1085
|
LiquidStaking: typeof LiquidStaking;
|
1086
|
+
MessageSigner: typeof MessageSigner;
|
1072
1087
|
Mnemonic: typeof Mnemonic;
|
1073
1088
|
NEARAccount: typeof NEARAccount;
|
1074
1089
|
NervosAddress: typeof NervosAddress;
|