@trustwallet/wallet-core 4.2.0-dev-rc3 → 4.2.0

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.
@@ -36,7 +36,7 @@ function $a(a,b){var c=M;return sa||"function"!=typeof WebAssembly.instantiateSt
36
36
  function z(a,b){Object.getOwnPropertyDescriptor(g,a)||Object.defineProperty(g,a,{configurable:!0,get:function(){n("Module."+a+" has been replaced with plain "+b+" (the initial value can be provided on Module, but after startup the value is only looked for on a local variable of that name)")}})}
37
37
  function cb(a){return"FS_createPath"===a||"FS_createDataFile"===a||"FS_createPreloadedFile"===a||"FS_unlink"===a||"addRunDependency"===a||"FS_createLazyFile"===a||"FS_createDevice"===a||"removeRunDependency"===a}(function(a,b){"undefined"!==typeof globalThis&&Object.defineProperty(globalThis,a,{configurable:!0,get:function(){ya("`"+a+"` is not longer defined by emscripten. "+b)}})})("buffer","Please use HEAP8.buffer or wasmMemory.buffer");
38
38
  function db(a){Object.getOwnPropertyDescriptor(g,a)||Object.defineProperty(g,a,{configurable:!0,get:function(){var b="'"+a+"' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)";cb(a)&&(b+=". Alternatively, forcing filesystem support (-sFORCE_FILESYSTEM) can export this for you");n(b)}})}
39
- var eb={2114516:()=>{if(void 0===g.fa)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.fa=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.fa=a}catch(e){throw"No secure random number generator found";}}},2115238:()=>g.fa()};
39
+ var eb={2096020:()=>{if(void 0===g.fa)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.fa=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.fa=a}catch(e){throw"No secure random number generator found";}}},2096742:()=>g.fa()};
40
40
  function qa(a){this.name="ExitStatus";this.message="Program terminated with exit("+a+")";this.status=a}function fb(a){for(;0<a.length;)a.shift()(g)}function za(a){assert("number"===typeof a);return"0x"+a.toString(16).padStart(8,"0")}function ya(a){gb||(gb={});gb[a]||(gb[a]=1,w&&(a="warning: "+a),y(a))}var gb,hb=[];function ib(a){var b=hb[a];b||(a>=hb.length&&(hb.length=a+1),hb[a]=b=Ha.get(a));assert(Ha.get(a)==b,"JavaScript-side Wasm function table mirror is out of date!");return b}
41
41
  function jb(a){this.l=a-24;this.Oa=function(b){G[this.l+4>>2]=b};this.Ja=function(b){G[this.l+8>>2]=b};this.Ka=function(){F[this.l>>2]=0};this.Ea=function(){D[this.l+12>>0]=0};this.La=function(){D[this.l+13>>0]=0};this.I=function(b,c){this.Da();this.Oa(b);this.Ja(c);this.Ka();this.Ea();this.La()};this.Da=function(){G[this.l+16>>2]=0}}
42
42
  var kb=0,lb=(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},mb=a=>{var b="/"===a.charAt(0),c="/"===a.substr(-1);(a=lb(a.split("/").filter(d=>!!d),!b).join("/"))||b||(a=".");a&&c&&(a+="/");return(b?"/":"")+a},nb=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},ob=
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) {
@@ -491,6 +491,7 @@ export class EthereumAbi {
491
491
  static decodeOutput(fn: EthereumAbiFunction, encoded: Uint8Array | Buffer): boolean;
492
492
  static decodeCall(data: Uint8Array | Buffer, abi: string): string;
493
493
  static encodeTyped(messageJson: string): Uint8Array;
494
+ static getFunctionSignature(abi: string): string;
494
495
  }
495
496
  export class EthereumAbiFunction {
496
497
  static createWithString(name: string): EthereumAbiFunction;
@@ -786,6 +787,10 @@ export class Hash {
786
787
  export class LiquidStaking {
787
788
  static buildRequest(input: Uint8Array | Buffer): Uint8Array;
788
789
  }
790
+ export class MessageSigner {
791
+ static sign(coin: CoinType, input: Uint8Array | Buffer): Uint8Array;
792
+ static verify(coin: CoinType, input: Uint8Array | Buffer): boolean;
793
+ }
789
794
  export class Mnemonic {
790
795
  static isValid(mnemonic: string): boolean;
791
796
  static isValidWord(word: string): boolean;
@@ -907,6 +912,7 @@ export class SolanaTransaction {
907
912
  static getComputeUnitLimit(encodedTx: string): string;
908
913
  static setComputeUnitPrice(encodedTx: string, price: string): string;
909
914
  static setComputeUnitLimit(encodedTx: string, limit: string): string;
915
+ static setFeePayer(encodedTx: string, feePayer: string): string;
910
916
  }
911
917
  export class StarkExMessageSigner {
912
918
  static signMessage(privateKey: PrivateKey, message: string): string;
@@ -944,8 +950,6 @@ export class StoredKey {
944
950
  static importPrivateKeyWithEncryption(privateKey: Uint8Array | Buffer, name: string, password: Uint8Array | Buffer, coin: CoinType, encryption: StoredKeyEncryption): StoredKey;
945
951
  static importHDWallet(mnemonic: string, name: string, password: Uint8Array | Buffer, coin: CoinType): StoredKey;
946
952
  static importHDWalletWithEncryption(mnemonic: string, name: string, password: Uint8Array | Buffer, coin: CoinType, encryption: StoredKeyEncryption): StoredKey;
947
- static importTONWallet(tonMnemonic: string, name: string, password: Uint8Array | Buffer, coin: CoinType): StoredKey;
948
- static importTONWalletWithEncryption(tonMnemonic: string, name: string, password: Uint8Array | Buffer, coin: CoinType, encryption: StoredKeyEncryption): StoredKey;
949
953
  static importJSON(json: Uint8Array | Buffer): StoredKey;
950
954
  static createLevel(name: string, password: Uint8Array | Buffer, encryptionLevel: StoredKeyEncryptionLevel): StoredKey;
951
955
  static createLevelAndEncryption(name: string, password: Uint8Array | Buffer, encryptionLevel: StoredKeyEncryptionLevel, encryption: StoredKeyEncryption): StoredKey;
@@ -954,7 +958,6 @@ export class StoredKey {
954
958
  identifier(): string;
955
959
  name(): string;
956
960
  isMnemonic(): boolean;
957
- isTONMnemonic(): boolean;
958
961
  accountCount(): number;
959
962
  encryptionParameters(): string;
960
963
  account(index: number): Account;
@@ -968,7 +971,6 @@ export class StoredKey {
968
971
  store(path: string): boolean;
969
972
  decryptPrivateKey(password: Uint8Array | Buffer): Uint8Array;
970
973
  decryptMnemonic(password: Uint8Array | Buffer): string;
971
- decryptTONMnemonic(password: Uint8Array | Buffer): string;
972
974
  privateKey(coin: CoinType, password: Uint8Array | Buffer): PrivateKey;
973
975
  wallet(password: Uint8Array | Buffer): HDWallet;
974
976
  exportJSON(): Uint8Array;
@@ -1002,11 +1004,7 @@ export class TONMessageSigner {
1002
1004
  static signMessage(privateKey: PrivateKey, message: string): string;
1003
1005
  }
1004
1006
  export class TONWallet {
1005
- static isValidMnemonic(mnemonic: string, passphrase: string): boolean;
1006
1007
  static buildV4R2StateInit(publicKey: PublicKey, workchain: number, walletId: number): string;
1007
- static createWithMnemonic(mnemonic: string, passphrase: string): TONWallet;
1008
- getKey(): PrivateKey;
1009
- delete(): void;
1010
1008
  }
1011
1009
  export class TezosMessageSigner {
1012
1010
  static formatMessage(message: string, url: string): string;
@@ -1086,6 +1084,7 @@ export interface WalletCore {
1086
1084
  HRP: typeof HRP;
1087
1085
  Hash: typeof Hash;
1088
1086
  LiquidStaking: typeof LiquidStaking;
1087
+ MessageSigner: typeof MessageSigner;
1089
1088
  Mnemonic: typeof Mnemonic;
1090
1089
  NEARAccount: typeof NEARAccount;
1091
1090
  NervosAddress: typeof NervosAddress;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trustwallet/wallet-core",
3
- "version": "4.2.0-dev-rc3",
3
+ "version": "4.2.0",
4
4
  "description": "wallet core wasm and protobuf models",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",