jcc_wallet 1.3.1 → 3.0.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.
- package/package.json +32 -23
- package/dist/jcc-wallet.min.js +0 -78
- package/lib/constant/index.d.ts +0 -8
- package/lib/constant/index.js +0 -18
- package/lib/constant/index.js.map +0 -1
- package/lib/eth/index.d.ts +0 -36
- package/lib/eth/index.js +0 -98
- package/lib/eth/index.js.map +0 -1
- package/lib/hd/constant.d.ts +0 -25
- package/lib/hd/constant.js +0 -54
- package/lib/hd/constant.js.map +0 -1
- package/lib/hd/ethereum.plugin.d.ts +0 -4
- package/lib/hd/ethereum.plugin.js +0 -101
- package/lib/hd/ethereum.plugin.js.map +0 -1
- package/lib/hd/index.d.ts +0 -227
- package/lib/hd/index.js +0 -394
- package/lib/hd/index.js.map +0 -1
- package/lib/hd/plugins.d.ts +0 -1
- package/lib/hd/plugins.js +0 -31
- package/lib/hd/plugins.js.map +0 -1
- package/lib/hd/swtc.plugin.d.ts +0 -5
- package/lib/hd/swtc.plugin.js +0 -72
- package/lib/hd/swtc.plugin.js.map +0 -1
- package/lib/index.d.ts +0 -26
- package/lib/index.js +0 -62
- package/lib/index.js.map +0 -1
- package/lib/jingchangWallet/index.d.ts +0 -272
- package/lib/jingchangWallet/index.js +0 -758
- package/lib/jingchangWallet/index.js.map +0 -1
- package/lib/moac/index.d.ts +0 -28
- package/lib/moac/index.js +0 -58
- package/lib/moac/index.js.map +0 -1
- package/lib/types/index.d.ts +0 -90
- package/lib/types/index.js +0 -1
- package/lib/types/index.js.map +0 -1
- package/lib/util/index.d.ts +0 -21
- package/lib/util/index.js +0 -90
- package/lib/util/index.js.map +0 -1
- package/lib/x-wallet/index.d.ts +0 -21
- package/lib/x-wallet/index.js +0 -84
- package/lib/x-wallet/index.js.map +0 -1
|
@@ -1,272 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* api of jingchang wallet
|
|
3
|
-
*
|
|
4
|
-
* @export
|
|
5
|
-
* @class JingchangWallet
|
|
6
|
-
*/
|
|
7
|
-
export default class JingchangWallet {
|
|
8
|
-
static readonly version = "1.0";
|
|
9
|
-
private static readonly _name;
|
|
10
|
-
private static readonly _walletID;
|
|
11
|
-
private _jingchangWallet;
|
|
12
|
-
/**
|
|
13
|
-
* if the value is true, support save multiple wallet keystore for each type, otherwise only support one.
|
|
14
|
-
*
|
|
15
|
-
* @private
|
|
16
|
-
* @type {boolean}
|
|
17
|
-
* @memberof JingchangWallet
|
|
18
|
-
*/
|
|
19
|
-
private _multiple;
|
|
20
|
-
/**
|
|
21
|
-
* if the value is true, use the default swt keystore's password which be generated in the beginning as password for other type.
|
|
22
|
-
*
|
|
23
|
-
* @private
|
|
24
|
-
* @type {boolean}
|
|
25
|
-
* @memberof JingchangWallet
|
|
26
|
-
*/
|
|
27
|
-
private _samePassword;
|
|
28
|
-
/**
|
|
29
|
-
* Creates an instance of JingchangWallet.
|
|
30
|
-
* @param {IJingchangWalletModel} wallet
|
|
31
|
-
* @param {boolean} [multiple=false] if the value is true, support save multiple wallet keystore for each type, otherwise only support one.
|
|
32
|
-
* @param {boolean} [samePassword=true] if the value is true, use the default swt keystore's password which be generated
|
|
33
|
-
* in the beginning as password for other type.
|
|
34
|
-
* @memberof JingchangWallet
|
|
35
|
-
*/
|
|
36
|
-
constructor(wallet: IJingchangWalletModel, multiple?: boolean, samePassword?: boolean);
|
|
37
|
-
/**
|
|
38
|
-
* check jingchang wallet is valid or not
|
|
39
|
-
*
|
|
40
|
-
* @static
|
|
41
|
-
* @param {*} wallet
|
|
42
|
-
* @returns {boolean} return true if valid.
|
|
43
|
-
* @memberof JingchangWallet
|
|
44
|
-
*/
|
|
45
|
-
static isValid(wallet: any): boolean;
|
|
46
|
-
/**
|
|
47
|
-
* create a jingchang wallet
|
|
48
|
-
*
|
|
49
|
-
* @static
|
|
50
|
-
* @param {string} password password for keystore
|
|
51
|
-
* @param {string} [secret] swtc chain's secret
|
|
52
|
-
* @param {string} [alias] wallet name
|
|
53
|
-
* @returns {Promise<IJingchangWalletModel>} resolve jingchang wallet if success.
|
|
54
|
-
* @memberof JingchangWallet
|
|
55
|
-
*/
|
|
56
|
-
static generate(password: string, secret?: string, alias?: string): Promise<IJingchangWalletModel>;
|
|
57
|
-
/**
|
|
58
|
-
* get jingchang wallet from local storage
|
|
59
|
-
*
|
|
60
|
-
* @static
|
|
61
|
-
* @returns {(IJingchangWalletModel | null)} return jingchang wallet or null
|
|
62
|
-
* @memberof JingchangWallet
|
|
63
|
-
*/
|
|
64
|
-
static get(): IJingchangWalletModel | null;
|
|
65
|
-
/**
|
|
66
|
-
* clear jingchang wallet from local storage
|
|
67
|
-
*
|
|
68
|
-
* @static
|
|
69
|
-
* @memberof JingchangWallet
|
|
70
|
-
*/
|
|
71
|
-
static clear(): void;
|
|
72
|
-
/**
|
|
73
|
-
* save jingchang wallet to local storage.
|
|
74
|
-
*
|
|
75
|
-
* @static
|
|
76
|
-
* @param {IJingchangWalletModel} wallet
|
|
77
|
-
* @memberof JingchangWallet
|
|
78
|
-
*/
|
|
79
|
-
static save(wallet: IJingchangWalletModel): void;
|
|
80
|
-
/**
|
|
81
|
-
* derive key pair with secret
|
|
82
|
-
*
|
|
83
|
-
* @static
|
|
84
|
-
* @param {string} secret
|
|
85
|
-
* @param {string} [chain="swt"]
|
|
86
|
-
* @returns {IKeyPair} for privateKey, it's length should be 64 when call `decryptWithPrivateKey`, but the origin derived
|
|
87
|
-
* privateKey's length is 66 that contains prefix `00` for `secp256k1` or `ED` for `ed25519`, so removed it.
|
|
88
|
-
* @memberof JingchangWallet
|
|
89
|
-
*/
|
|
90
|
-
static deriveKeyPair(secret: string, chain?: string): IKeyPair;
|
|
91
|
-
/**
|
|
92
|
-
* encrypt data with public key
|
|
93
|
-
*
|
|
94
|
-
* @static
|
|
95
|
-
* @param {string} message
|
|
96
|
-
* @param {string} publicKey
|
|
97
|
-
* @returns {Promise<IEncrypt>}
|
|
98
|
-
* @memberof JingchangWallet
|
|
99
|
-
*/
|
|
100
|
-
static encryptWithPublicKey(message: string, publicKey: string): Promise<IEncrypt>;
|
|
101
|
-
/**
|
|
102
|
-
* decrypt data with private key
|
|
103
|
-
*
|
|
104
|
-
* @static
|
|
105
|
-
* @param {IEncrypt} message
|
|
106
|
-
* @param {string} privateKey the privateKey's length should be 64
|
|
107
|
-
* @returns {Promise<string>}
|
|
108
|
-
* @memberof JingchangWallet
|
|
109
|
-
*/
|
|
110
|
-
static decryptWithPrivateKey(message: IEncrypt, privateKey: string): Promise<string>;
|
|
111
|
-
/**
|
|
112
|
-
* get wallets from jingchang wallet
|
|
113
|
-
*
|
|
114
|
-
* @static
|
|
115
|
-
* @param {IJingchangWalletModel} jcWallet
|
|
116
|
-
* @returns {Array<IKeystoreModel>} return wallets if valid, otherwise return empty array.
|
|
117
|
-
* @memberof JingchangWallet
|
|
118
|
-
*/
|
|
119
|
-
static getWallets(keystore: IJingchangWalletModel): Array<IKeystoreModel>;
|
|
120
|
-
/**
|
|
121
|
-
* set property of _jingchangWallet
|
|
122
|
-
*
|
|
123
|
-
* @param {IJingchangWalletModel} wallet
|
|
124
|
-
* @memberof JingchangWallet
|
|
125
|
-
*/
|
|
126
|
-
setJingchangWallet(wallet: IJingchangWalletModel): void;
|
|
127
|
-
/**
|
|
128
|
-
* get default wallet's keystore address for each type
|
|
129
|
-
*
|
|
130
|
-
* @param {string} [type="swt"]
|
|
131
|
-
* @returns {Promise<string>} resolve address if success
|
|
132
|
-
* @memberof JingchangWallet
|
|
133
|
-
*/
|
|
134
|
-
getAddress(type?: string): Promise<string>;
|
|
135
|
-
/**
|
|
136
|
-
* get default wallet keystore with type
|
|
137
|
-
*
|
|
138
|
-
* @param {string} [type="swt"]
|
|
139
|
-
* @returns {Promise<IKeystoreModel>} resolve default wallet keystore if success.
|
|
140
|
-
* @memberof JingchangWallet
|
|
141
|
-
*/
|
|
142
|
-
getWalletWithType(type?: string): Promise<IKeystoreModel>;
|
|
143
|
-
/**
|
|
144
|
-
* get wallet keystore with address
|
|
145
|
-
*
|
|
146
|
-
* @param {string} address
|
|
147
|
-
* @returns {Promise<IKeystoreModel>} resolve wallet keystore if success.
|
|
148
|
-
* @memberof JingchangWallet
|
|
149
|
-
*/
|
|
150
|
-
getWalletWithAddress(address: string): Promise<IKeystoreModel>;
|
|
151
|
-
/**
|
|
152
|
-
* check if has default wallet for each type
|
|
153
|
-
*
|
|
154
|
-
* @param {string} [type="swt"]
|
|
155
|
-
* @returns {boolean} return true if has default
|
|
156
|
-
* @memberof JingchangWallet
|
|
157
|
-
*/
|
|
158
|
-
hasDefault(type?: string): boolean;
|
|
159
|
-
/**
|
|
160
|
-
* get the default wallet keystore's secret with type.
|
|
161
|
-
*
|
|
162
|
-
* @param {string} password
|
|
163
|
-
* @param {string} [type="swt"]
|
|
164
|
-
* @returns {Promise<string>}
|
|
165
|
-
* @memberof JingchangWallet
|
|
166
|
-
*/
|
|
167
|
-
getSecretWithType(password: string, type?: string): Promise<string>;
|
|
168
|
-
/**
|
|
169
|
-
* get the wallet keystore's secret with address.
|
|
170
|
-
*
|
|
171
|
-
* @param {string} password
|
|
172
|
-
* @param {string} address
|
|
173
|
-
* @returns {Promise<string>}
|
|
174
|
-
* @memberof JingchangWallet resolve secret if success.
|
|
175
|
-
*/
|
|
176
|
-
getSecretWithAddress(password: string, address: string): Promise<string>;
|
|
177
|
-
/**
|
|
178
|
-
* change the whole jingchang wallet password, if you set property of _samePassword is false, will throw an error
|
|
179
|
-
*
|
|
180
|
-
* @param {string} oldPassword
|
|
181
|
-
* @param {string} newPassword
|
|
182
|
-
* @returns {Promise<IJingchangWalletModel>} resolve new jingchang wallet if success
|
|
183
|
-
* @memberof JingchangWallet
|
|
184
|
-
*/
|
|
185
|
-
changeWholePassword(oldPassword: string, newPassword: string): Promise<IJingchangWalletModel>;
|
|
186
|
-
/**
|
|
187
|
-
* change the keystore password with address, if you set the property of _samePassword is true, will throw an error
|
|
188
|
-
*
|
|
189
|
-
* @param {string} address
|
|
190
|
-
* @param {string} oldPassword
|
|
191
|
-
* @param {string} newPassword
|
|
192
|
-
* @returns {Promise<IJingchangWalletModel>} resolve new jingchang wallet if success
|
|
193
|
-
* @memberof JingchangWallet
|
|
194
|
-
*/
|
|
195
|
-
changePasswordWithAddress(address: string, oldPassword: string, newPassword: string): Promise<IJingchangWalletModel>;
|
|
196
|
-
/**
|
|
197
|
-
* replace keystore, if forget password
|
|
198
|
-
*
|
|
199
|
-
* @param {string} secret
|
|
200
|
-
* @param {string} password
|
|
201
|
-
* @param {(secret: string) => string} retriveSecret
|
|
202
|
-
* @returns {Promise<IJingchangWalletModel>}
|
|
203
|
-
* @memberof JingchangWallet
|
|
204
|
-
*/
|
|
205
|
-
replaceKeystore(secret: string, password: string, retriveSecret: (secret: string) => string): Promise<IJingchangWalletModel>;
|
|
206
|
-
/**
|
|
207
|
-
* remove default wallet keystore of the given type
|
|
208
|
-
*
|
|
209
|
-
* @param {string} [type="swt"]
|
|
210
|
-
* @returns {Promise<IJingchangWalletModel>} resolve new jingchang wallet if success
|
|
211
|
-
* @memberof JingchangWallet
|
|
212
|
-
*/
|
|
213
|
-
removeWalletWithType(type?: string): Promise<IJingchangWalletModel>;
|
|
214
|
-
/**
|
|
215
|
-
* remove wallet keystore of the given address
|
|
216
|
-
*
|
|
217
|
-
* @param {string} address
|
|
218
|
-
* @returns {Promise<IJingchangWalletModel>} resolve new jingchang wallet if success
|
|
219
|
-
* @memberof JingchangWallet
|
|
220
|
-
*/
|
|
221
|
-
removeWalletWithAddress(address: string): Promise<IJingchangWalletModel>;
|
|
222
|
-
/**
|
|
223
|
-
* set defalut wallet keystore for each type
|
|
224
|
-
*
|
|
225
|
-
* @param {string} address
|
|
226
|
-
* @returns {Promise<IJingchangWalletModel>} resolve new jingchang wallet if success
|
|
227
|
-
* @memberof JingchangWallet
|
|
228
|
-
*/
|
|
229
|
-
setDefaultWallet(address: string): Promise<IJingchangWalletModel>;
|
|
230
|
-
/**
|
|
231
|
-
* import secret
|
|
232
|
-
*
|
|
233
|
-
* @param {string} secret
|
|
234
|
-
* @param {string} password
|
|
235
|
-
* @param {string} type
|
|
236
|
-
* @param {(secret: string) => string} retriveSecret
|
|
237
|
-
* @param {string} [alias] wallet name
|
|
238
|
-
* @returns {Promise<IJingchangWalletModel>} resolve new jingchang wallet if success
|
|
239
|
-
* @memberof JingchangWallet
|
|
240
|
-
*/
|
|
241
|
-
importSecret(secret: string, password: string, type: string, retriveSecret: (secret: string) => string, alias?: string): Promise<IJingchangWalletModel>;
|
|
242
|
-
/**
|
|
243
|
-
* find wallet keystore according to filter function
|
|
244
|
-
*
|
|
245
|
-
* @protected
|
|
246
|
-
* @param {(wallet: IKeystoreModel) => boolean} filter
|
|
247
|
-
* @returns {IKeystoreModel} return wallet keystore if existent, otherwise throw `keystore is invalid` if the jingchang wallet is invalid
|
|
248
|
-
* or throw `wallet is empty` if the wallet isn't existent
|
|
249
|
-
* @memberof JingchangWallet
|
|
250
|
-
*/
|
|
251
|
-
protected findWallet(filter: (wallet: IKeystoreModel) => boolean): IKeystoreModel;
|
|
252
|
-
/**
|
|
253
|
-
* encrypt data
|
|
254
|
-
*
|
|
255
|
-
* @protected
|
|
256
|
-
* @param {string} password
|
|
257
|
-
* @param {IKeypairsModel} keypairs
|
|
258
|
-
* @returns {IKeystoreModel}
|
|
259
|
-
* @memberof JingchangWallet
|
|
260
|
-
*/
|
|
261
|
-
protected getEncryptData(password: string, keypairs: IKeypairsModel): IKeystoreModel;
|
|
262
|
-
/**
|
|
263
|
-
* save wallet keystore to jingchang wallet
|
|
264
|
-
*
|
|
265
|
-
* @private
|
|
266
|
-
* @param {string} password
|
|
267
|
-
* @param {IKeypairsModel} keypairs
|
|
268
|
-
* @returns {Promise<IJingchangWalletModel>} resolve new jingchang wallet if success
|
|
269
|
-
* @memberof JingchangWallet
|
|
270
|
-
*/
|
|
271
|
-
private saveWallet;
|
|
272
|
-
}
|