@trustwallet/wallet-core 4.1.8-rc1 → 4.1.8

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.
@@ -34,7 +34,7 @@ function Ra(){H++;g.monitorRunDependencies&&g.monitorRunDependencies(H);assert(!
34
34
  function Sa(){return K.startsWith("data:application/octet-stream;base64,")}function ma(a){return a.startsWith("file://")}function M(a){return function(){var b=g.asm;assert(Na,"native function `"+a+"` called before runtime initialization");b[a]||assert(b[a],"exported native function `"+a+"` not found");return b[a].apply(null,arguments)}}var K;K="wallet-core.wasm";if(!Sa()){var Ta=K;K=g.locateFile?g.locateFile(Ta,x):x+Ta}
35
35
  function Ua(){var a=K;try{if(a==K&&qa)return new Uint8Array(qa);if(ka)return ka(a);throw"both async and sync fetching of the wasm failed";}catch(b){n(b)}}
36
36
  function Va(){if(!qa&&(ea||fa)){if("function"==typeof fetch&&!ma(K))return fetch(K,{credentials:"same-origin"}).then(function(a){if(!a.ok)throw"failed to load wasm binary file at '"+K+"'";return a.arrayBuffer()}).catch(function(){return Ua()});if(ja)return new Promise(function(a,b){ja(K,function(c){a(new Uint8Array(c))},b)})}return Promise.resolve().then(function(){return Ua()})}
37
- var Wa,Xa,Ya={2106900:()=>{if(void 0===g.ea)try{var a="object"===typeof window?window:self,b="undefined"!==typeof a.crypto?a.crypto:a.msCrypto;a=function(){var d=new Uint32Array(1);b.getRandomValues(d);return d[0]>>>0};a();g.ea=a}catch(d){try{var c=require("crypto");a=function(){var e=c.randomBytes(4);return(e[0]<<24|e[1]<<16|e[2]<<8|e[3])>>>0};a();g.ea=a}catch(e){throw"No secure random number generator found";}}},2107622:()=>g.ea()};function Za(a){for(;0<a.length;)a.shift()(g)}
37
+ var Wa,Xa,Ya={2081492:()=>{if(void 0===g.ea)try{var a="object"===typeof window?window:self,b="undefined"!==typeof a.crypto?a.crypto:a.msCrypto;a=function(){var d=new Uint32Array(1);b.getRandomValues(d);return d[0]>>>0};a();g.ea=a}catch(d){try{var c=require("crypto");a=function(){var e=c.randomBytes(4);return(e[0]<<24|e[1]<<16|e[2]<<8|e[3])>>>0};a();g.ea=a}catch(e){throw"No secure random number generator found";}}},2082214:()=>g.ea()};function Za(a){for(;0<a.length;)a.shift()(g)}
38
38
  function va(a){assert("number"===typeof a);return"0x"+a.toString(16).padStart(8,"0")}function pa(a){$a||($a={});$a[a]||($a[a]=1,v&&(a="warning: "+a),y(a))}var $a;function ab(a){this.l=a-24;this.Na=function(b){G[this.l+4>>2]=b};this.Ia=function(b){G[this.l+8>>2]=b};this.Ja=function(){F[this.l>>2]=0};this.Ea=function(){D[this.l+12>>0]=0};this.Ka=function(){D[this.l+13>>0]=0};this.I=function(b,c){this.Da();this.Na(b);this.Ia(c);this.Ja();this.Ea();this.Ka()};this.Da=function(){G[this.l+16>>2]=0}}
39
39
  var bb=0,cb=(a,b)=>{for(var c=0,d=a.length-1;0<=d;d--){var e=a[d];"."===e?a.splice(d,1):".."===e?(a.splice(d,1),c++):c&&(a.splice(d,1),c--)}if(b)for(;c;c--)a.unshift("..");return a},db=a=>{var b="/"===a.charAt(0),c="/"===a.substr(-1);(a=cb(a.split("/").filter(d=>!!d),!b).join("/"))||b||(a=".");a&&c&&(a+="/");return(b?"/":"")+a},eb=a=>{var b=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/.exec(a).slice(1);a=b[0];b=b[1];if(!a&&!b)return".";b&&(b=b.substr(0,b.length-1));return a+b},fb=
40
40
  a=>{if("/"===a)return"/";a=db(a);a=a.replace(/\/$/,"");var b=a.lastIndexOf("/");return-1===b?a:a.substr(b+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) {
@@ -131,6 +131,10 @@ export class BitcoinMessageSigner {
131
131
  static signMessage(privateKey: PrivateKey, address: string, message: string): string;
132
132
  static verifyMessage(address: string, message: string, signature: string): boolean;
133
133
  }
134
+ export class BitcoinPsbt {
135
+ static sign(input: Uint8Array | Buffer, coin: CoinType): Uint8Array;
136
+ static plan(input: Uint8Array | Buffer, coin: CoinType): Uint8Array;
137
+ }
134
138
  export class BitcoinScript {
135
139
  static equal(lhs: BitcoinScript, rhs: BitcoinScript): boolean;
136
140
  static buildPayToPublicKey(pubkey: Uint8Array | Buffer): BitcoinScript;
@@ -928,8 +932,6 @@ export class StoredKey {
928
932
  static importPrivateKeyWithEncryption(privateKey: Uint8Array | Buffer, name: string, password: Uint8Array | Buffer, coin: CoinType, encryption: StoredKeyEncryption): StoredKey;
929
933
  static importHDWallet(mnemonic: string, name: string, password: Uint8Array | Buffer, coin: CoinType): StoredKey;
930
934
  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
935
  static importJSON(json: Uint8Array | Buffer): StoredKey;
934
936
  static createLevel(name: string, password: Uint8Array | Buffer, encryptionLevel: StoredKeyEncryptionLevel): StoredKey;
935
937
  static createLevelAndEncryption(name: string, password: Uint8Array | Buffer, encryptionLevel: StoredKeyEncryptionLevel, encryption: StoredKeyEncryption): StoredKey;
@@ -938,7 +940,6 @@ export class StoredKey {
938
940
  identifier(): string;
939
941
  name(): string;
940
942
  isMnemonic(): boolean;
941
- isTONMnemonic(): boolean;
942
943
  accountCount(): number;
943
944
  encryptionParameters(): string;
944
945
  account(index: number): Account;
@@ -952,7 +953,6 @@ export class StoredKey {
952
953
  store(path: string): boolean;
953
954
  decryptPrivateKey(password: Uint8Array | Buffer): Uint8Array;
954
955
  decryptMnemonic(password: Uint8Array | Buffer): string;
955
- decryptTONMnemonic(password: Uint8Array | Buffer): string;
956
956
  privateKey(coin: CoinType, password: Uint8Array | Buffer): PrivateKey;
957
957
  wallet(password: Uint8Array | Buffer): HDWallet;
958
958
  exportJSON(): Uint8Array;
@@ -986,11 +986,7 @@ export class TONMessageSigner {
986
986
  static signMessage(privateKey: PrivateKey, message: string): string;
987
987
  }
988
988
  export class TONWallet {
989
- static isValidMnemonic(mnemonic: string, passphrase: string): boolean;
990
989
  static buildV4R2StateInit(publicKey: PublicKey, workchain: number, walletId: number): string;
991
- static createWithMnemonic(mnemonic: string, passphrase: string): TONWallet;
992
- getKey(): PrivateKey;
993
- delete(): void;
994
990
  }
995
991
  export class TezosMessageSigner {
996
992
  static formatMessage(message: string, url: string): string;
@@ -1038,6 +1034,7 @@ export interface WalletCore {
1038
1034
  Base64: typeof Base64;
1039
1035
  BitcoinAddress: typeof BitcoinAddress;
1040
1036
  BitcoinMessageSigner: typeof BitcoinMessageSigner;
1037
+ BitcoinPsbt: typeof BitcoinPsbt;
1041
1038
  BitcoinScript: typeof BitcoinScript;
1042
1039
  BitcoinSigHashType: typeof BitcoinSigHashType;
1043
1040
  Blockchain: typeof Blockchain;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trustwallet/wallet-core",
3
- "version": "4.1.8-rc1",
3
+ "version": "4.1.8",
4
4
  "description": "wallet core wasm and protobuf models",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",