wallaby-cash 1.3.2 → 1.3.4

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.
Files changed (44) hide show
  1. package/dist/base.d.ts +20 -1
  2. package/dist/index.d.ts +1 -1
  3. package/dist/index.esm.js +1 -1
  4. package/dist/index.esm.js.map +1 -1
  5. package/dist/index.js +1 -1
  6. package/dist/index.js.map +1 -1
  7. package/dist/index.umd.js +1 -1
  8. package/dist/index.umd.js.map +1 -1
  9. package/dist/lib/auth/index.d.ts +16 -10
  10. package/dist/lib/transactions/index.d.ts +5 -5
  11. package/dist/lib/utils/index.d.ts +29 -9
  12. package/dist/lib/utils/utils.d.ts +22 -13
  13. package/dist/lib/wallet/index.d.ts +34 -11
  14. package/dist/routes/auth.d.ts +11 -6
  15. package/dist/routes/merchants.d.ts +7 -7
  16. package/dist/routes/system.d.ts +4 -4
  17. package/dist/routes/transactions.d.ts +13 -6
  18. package/dist/routes/wallet.d.ts +15 -10
  19. package/dist/tests/data/user.d.ts +3 -2
  20. package/dist/types/auth.d.ts +5 -10
  21. package/dist/types/common.d.ts +5 -1
  22. package/dist/types/transactions.d.ts +2 -2
  23. package/dist/types/wallet.d.ts +13 -6
  24. package/package.json +2 -2
  25. package/src/base.ts +40 -8
  26. package/src/index.ts +2 -2
  27. package/src/lib/auth/index.ts +49 -24
  28. package/src/lib/transactions/index.ts +7 -7
  29. package/src/lib/utils/index.ts +77 -19
  30. package/src/lib/utils/utils.ts +96 -36
  31. package/src/lib/wallet/index.ts +209 -35
  32. package/src/routes/auth.ts +11 -6
  33. package/src/routes/merchants.ts +7 -7
  34. package/src/routes/system.ts +4 -4
  35. package/src/routes/transactions.ts +23 -6
  36. package/src/routes/wallet.ts +15 -10
  37. package/src/tests/auth.spec.ts +26 -24
  38. package/src/tests/data/user.ts +3 -2
  39. package/src/tests/utils.spec.ts +9 -13
  40. package/src/tests/wallet.spec.ts +12 -7
  41. package/src/types/auth.ts +5 -11
  42. package/src/types/common.ts +6 -1
  43. package/src/types/transactions.ts +2 -2
  44. package/src/types/wallet.ts +14 -6
@@ -1,5 +1,6 @@
1
1
  import { Base } from '../../base';
2
2
  import {
3
+ AuthResponse,
3
4
  QueryUserRequest,
4
5
  CreateWalletRequest,
5
6
  CreateWalletResponse,
@@ -13,14 +14,13 @@ import {
13
14
  UserWalletsResponse,
14
15
  WalletAssetsResponse,
15
16
  WallabyConfig,
16
- SignUpResponse,
17
- SignInResponse,
18
17
  SeedPhraseType,
19
18
  ConvertMnemonicSeedPhraseRequest,
20
19
  ConvertMnemonicSeedPhraseResponse,
21
20
  CreateMultisigAssetRequest,
22
21
  CreateMultisigAssetResponse,
23
- ClearWalletInput,
22
+ ImportWalletRequest,
23
+ ImportWalletResponse,
24
24
  } from '../../types';
25
25
  import { WalletRoutes } from '../../routes';
26
26
  import * as Utils from '../utils/utils';
@@ -37,6 +37,50 @@ export class Wallet extends Base {
37
37
  this.userId = config.userId;
38
38
  }
39
39
 
40
+ /**
41
+ *
42
+ * @public
43
+ * @description Retrieve the user's mnemonic seed phrases
44
+ * @param password User's wallet password
45
+ * @returns { Promise<{standardSeedPhrase: string, algorandSeedPhrase: string}> }
46
+ * It returns the user's standard (24 words) and algorand (25 words) seed phrases
47
+ */
48
+ public async mnemonicSeedPhrase({
49
+ password,
50
+ }: {
51
+ password: string;
52
+ }): Promise<{ standardSeedPhrase: string; algorandSeedPhrase: string }> {
53
+ try {
54
+ const salt = await this.auth.getUserSalt();
55
+ if (!salt) {
56
+ throw new Error('User salt could not be retrieved, Seed phrase could not be decrypted');
57
+ }
58
+
59
+ const standardSeedPhrase = await Utils.getDecryptedSeedPhrase({
60
+ userId: this.userId,
61
+ seedPhraseType: SeedPhraseType.Standard,
62
+ salt,
63
+ password,
64
+ });
65
+
66
+ const algorandSeedPhrase = await Utils.getDecryptedSeedPhrase({
67
+ userId: this.userId,
68
+ seedPhraseType: SeedPhraseType.Algorand,
69
+ salt,
70
+ password,
71
+ });
72
+
73
+ if (!standardSeedPhrase || !algorandSeedPhrase) {
74
+ throw new Error('Seed phrase could not be decrypted');
75
+ }
76
+
77
+ return { standardSeedPhrase, algorandSeedPhrase };
78
+ } catch (error) {
79
+ logger('SDK::Wallet::mnemonicSeedPhrase::error', error);
80
+ return Promise.reject(error);
81
+ }
82
+ }
83
+
40
84
  /**
41
85
  *
42
86
  * @public
@@ -70,15 +114,15 @@ export class Wallet extends Base {
70
114
  * @param {string} firstName The user's first name
71
115
  * @param {string} lastName The user's last name
72
116
  * @param {email} email The user's email
73
- * @param {string} hashKey The user's chosen password
117
+ * @param {string} password The user's chosen password
74
118
  * @returns {CreateWalletResponse} The wallet has been created successfully
75
119
  */
76
120
  async create({
77
121
  firstName,
78
122
  lastName,
79
123
  email,
80
- hashKey,
81
- }: Pick<CreateWalletRequest, 'firstName' | 'lastName' | 'email' | 'hashKey'>): Promise<CreateWalletResponse | WallabyError> {
124
+ password,
125
+ }: Pick<CreateWalletRequest, 'firstName' | 'lastName' | 'email' | 'password'>): Promise<CreateWalletResponse | WallabyError> {
82
126
  // try to fetch user data from localStorage.
83
127
  // If wallabyAuthPubKey exists then call Auth.signIn else call Auth.signUp
84
128
  try {
@@ -86,17 +130,17 @@ export class Wallet extends Base {
86
130
 
87
131
  logger('SDK::Wallet::create::wallabyAuthPubKey', wallabyAuthPubKey);
88
132
 
89
- let authentication: SignInResponse | SignUpResponse | undefined;
133
+ let authentication: AuthResponse | undefined;
90
134
  if (wallabyAuthPubKey) {
91
- authentication = await this.auth.signIn({ hashKey });
135
+ authentication = await this.auth.signIn({ password });
92
136
  } else {
93
- authentication = await this.auth.signUp({ hashKey, firstName, lastName, email });
137
+ authentication = await this.auth.signUp({ password, firstName, lastName, email });
94
138
  }
95
139
 
96
140
  if (!authentication) {
97
141
  throw new Error();
98
142
  }
99
- const signatureMessage = await this.auth.signatureMessage({ hashKey, userId: this.userId });
143
+ const signatureMessage = await this.auth.signatureMessage({ password, userId: this.userId });
100
144
  if (!signatureMessage || signatureMessage.error) {
101
145
  throw new Error(signatureMessage?.error);
102
146
  }
@@ -122,8 +166,23 @@ export class Wallet extends Base {
122
166
  // Decrypt the seedPhrase and retrun as part of response in case it needs to be displayed to the user.
123
167
  decryptedSeedPhrase = await decryptWithPrivateKey(decryptedClientAuthPrivKey, response.encryptedSeed);
124
168
 
169
+ // We need to get the user's salt in order for us to double encrypt the seedphrase before storing
170
+ // in local storage.
171
+ const salt = await this.auth.getUserSalt();
172
+
173
+ if (!salt) {
174
+ throw new Error('User salt could not be retrieved, Wallet creation could not be finished');
175
+ }
176
+
125
177
  // Encrypt again and store seedPhrase in localstorage.
126
- await Utils.setEncryptedSeedPhrase(this.userId, clientAuthPubKey, decryptedSeedPhrase, SeedPhraseType.Standard);
178
+ await Utils.setEncryptedSeedPhrase(
179
+ this.userId,
180
+ clientAuthPubKey,
181
+ decryptedSeedPhrase,
182
+ SeedPhraseType.Standard,
183
+ password,
184
+ salt,
185
+ );
127
186
 
128
187
  // Request must send seedPhrase encrypted with WallabyAuthPubKey
129
188
  if (!wallabyAuthPubKey) {
@@ -132,7 +191,7 @@ export class Wallet extends Base {
132
191
  const encryptedSeedphraseWithWallabyKey = await encryptWithPublicKey(wallabyAuthPubKey, decryptedSeedPhrase);
133
192
 
134
193
  const mnemonicSeedPhrase = await this.convertMnemonicSeedphrase({
135
- hashKey,
194
+ password,
136
195
  // This is the standard seedPhrase from the wallet creation response but encrypted using Wallaby's auth public key
137
196
  encryptedSeedPhrase: encryptedSeedphraseWithWallabyKey,
138
197
  });
@@ -146,7 +205,14 @@ export class Wallet extends Base {
146
205
 
147
206
  decryptedMnemonicSeedphrase = await decryptWithPrivateKey(decryptedClientAuthPrivKey, convertedEncryptedSeed);
148
207
 
149
- await Utils.setEncryptedSeedPhrase(this.userId, clientAuthPubKey, decryptedMnemonicSeedphrase, SeedPhraseType.Algorand);
208
+ await Utils.setEncryptedSeedPhrase(
209
+ this.userId,
210
+ clientAuthPubKey,
211
+ decryptedMnemonicSeedphrase,
212
+ SeedPhraseType.Algorand,
213
+ password,
214
+ salt,
215
+ );
150
216
 
151
217
  return { ...response, decryptedSeedPhrase, decryptedMnemonicSeedphrase };
152
218
  } catch (error) {
@@ -162,15 +228,15 @@ export class Wallet extends Base {
162
228
  * @param {string} firstName The user's first name
163
229
  * @param {string} lastName The user's last name
164
230
  * @param {email} email The user's email
165
- * @param {string} hashKey The user's chosen password
231
+ * @param {string} password The user's chosen password
166
232
  * @returns {CreateWalletResponse} The wallet has been created successfully
167
233
  */
168
234
  async createWithNewAccount({
169
235
  firstName,
170
236
  lastName,
171
237
  email,
172
- hashKey,
173
- }: Pick<CreateWalletRequest, 'firstName' | 'lastName' | 'email' | 'hashKey'>): Promise<CreateWalletResponse | WallabyError> {
238
+ password,
239
+ }: Pick<CreateWalletRequest, 'firstName' | 'lastName' | 'email' | 'password'>): Promise<CreateWalletResponse | WallabyError> {
174
240
  // try to fetch user data from localStorage.
175
241
  // If wallabyAuthPubKey exists then call Auth.signIn else call Auth.signUp
176
242
  try {
@@ -178,12 +244,14 @@ export class Wallet extends Base {
178
244
 
179
245
  logger('SDK::Wallet::create::wallabyAuthPubKey', wallabyAuthPubKey);
180
246
 
181
- const authentication: SignUpResponse | undefined = await this.auth.signUp({ hashKey, firstName, lastName, email });
247
+ const authentication: AuthResponse | undefined = await this.auth.signUp({ password, firstName, lastName, email });
182
248
 
183
249
  if (!authentication) {
184
250
  throw new Error();
185
251
  }
186
- const signatureMessage = await this.auth.signatureMessage({ hashKey, userId: this.userId });
252
+
253
+ const signatureMessage = await this.auth.signatureMessage({ password, userId: this.userId });
254
+
187
255
  if (!signatureMessage || signatureMessage.error) {
188
256
  throw new Error(signatureMessage?.error);
189
257
  }
@@ -209,8 +277,23 @@ export class Wallet extends Base {
209
277
  // Decrypt the seedPhrase and retrun as part of response in case it needs to be displayed to the user.
210
278
  decryptedSeedPhrase = await decryptWithPrivateKey(decryptedClientAuthPrivKey, response.encryptedSeed);
211
279
 
280
+ // We need to get the user's salt in order for us to double encrypt the seedphrase before storing
281
+ // in local storage.
282
+ const salt = await this.auth.getUserSalt();
283
+
284
+ if (!salt) {
285
+ throw new Error('User salt could not be retrieved, Wallet creation could not be finished');
286
+ }
287
+
212
288
  // Encrypt again and store seedPhrase in localstorage.
213
- await Utils.setEncryptedSeedPhrase(this.userId, clientAuthPubKey, decryptedSeedPhrase, SeedPhraseType.Standard);
289
+ await Utils.setEncryptedSeedPhrase(
290
+ this.userId,
291
+ clientAuthPubKey,
292
+ decryptedSeedPhrase,
293
+ SeedPhraseType.Standard,
294
+ password,
295
+ salt,
296
+ );
214
297
 
215
298
  // Request must send seedPhrase encrypted with WallabyAuthPubKey
216
299
  if (!wallabyAuthPubKey) {
@@ -219,7 +302,7 @@ export class Wallet extends Base {
219
302
  const encryptedSeedphraseWithWallabyKey = await encryptWithPublicKey(wallabyAuthPubKey, decryptedSeedPhrase);
220
303
 
221
304
  const mnemonicSeedPhrase = await this.convertMnemonicSeedphrase({
222
- hashKey,
305
+ password,
223
306
  // This is the standard seedPhrase from the wallet creation response but encrypted using Wallaby's auth public key
224
307
  encryptedSeedPhrase: encryptedSeedphraseWithWallabyKey,
225
308
  });
@@ -233,7 +316,14 @@ export class Wallet extends Base {
233
316
 
234
317
  decryptedMnemonicSeedphrase = await decryptWithPrivateKey(decryptedClientAuthPrivKey, convertedEncryptedSeed);
235
318
 
236
- await Utils.setEncryptedSeedPhrase(this.userId, clientAuthPubKey, decryptedMnemonicSeedphrase, SeedPhraseType.Algorand);
319
+ await Utils.setEncryptedSeedPhrase(
320
+ this.userId,
321
+ clientAuthPubKey,
322
+ decryptedMnemonicSeedphrase,
323
+ SeedPhraseType.Algorand,
324
+ password,
325
+ salt,
326
+ );
237
327
 
238
328
  return { ...response, decryptedSeedPhrase, decryptedMnemonicSeedphrase };
239
329
  } catch (error) {
@@ -242,19 +332,87 @@ export class Wallet extends Base {
242
332
  }
243
333
  }
244
334
 
335
+ /**
336
+ *
337
+ * @public
338
+ * @description Import an existing wallet, returns asset list and encrypted seedPhrase
339
+ * @param {string} password The user's chosen password
340
+ * @param {string} seedPhrase The user's seed phrase
341
+ * @returns {ImportWalletResponse} The wallet has been imported successfully
342
+ * The return includes the wallet, wallet assets, and the encrypted seedphrase
343
+ */
344
+ async import({ password, seedPhrase }: ImportWalletRequest): Promise<ImportWalletResponse> {
345
+ // try to fetch user data from localStorage.
346
+ try {
347
+ const wallabyAuthPubKey = Utils.getWallabyAuthPubKey(this.userId);
348
+
349
+ logger('SDK::Wallet::create::wallabyAuthPubKey', wallabyAuthPubKey);
350
+
351
+ let authentication: AuthResponse | undefined;
352
+ if (wallabyAuthPubKey) {
353
+ authentication = await this.auth.signIn({ password });
354
+ } else {
355
+ authentication = await this.auth.signUp({ password, firstName: '', lastName: '', email: '' });
356
+ }
357
+
358
+ if (!authentication) {
359
+ throw new Error('User is not authorized to perform this action');
360
+ }
361
+
362
+ const signatureMessage = await this.auth.signatureMessage({ password, userId: this.userId });
363
+
364
+ if (!signatureMessage || signatureMessage.error) {
365
+ throw new Error(signatureMessage?.error);
366
+ }
367
+
368
+ const { message, signature, clientAuthPubKey, decryptedClientAuthPrivKey } = signatureMessage;
369
+
370
+ const encryptedSeedphraseWithWallabyKey = await encryptWithPublicKey(authentication.user.wallabyAuthPubKey, seedPhrase);
371
+
372
+ const response: ImportWalletResponse = await this.request(WalletRoutes.import, {
373
+ method: WalletRoutes.import.method,
374
+ payload: {
375
+ message,
376
+ signature,
377
+ clientAuthPubKey,
378
+ encryptedSeedphraseWithWallabyKey,
379
+ },
380
+ });
381
+
382
+ if (response.error) {
383
+ throw new Error(response.error);
384
+ }
385
+
386
+ // We need to get the user's salt in order for us to double encrypt the seedphrase before storing
387
+ // in local storage.
388
+ const salt = await this.auth.getUserSalt();
389
+
390
+ if (!salt) {
391
+ throw new Error('User salt could not be retrieved, Wallet creation could not be finished');
392
+ }
393
+
394
+ // Encrypt again and store seedPhrase in localstorage.
395
+ // TODO Add storeSeedPhrase function to replace the below code
396
+ await Utils.setEncryptedSeedPhrase(this.userId, clientAuthPubKey, seedPhrase, SeedPhraseType.Standard, password, salt);
397
+ return response;
398
+ } catch (error) {
399
+ logger('SDK::Wallet::create::error', error);
400
+ return Promise.reject(error);
401
+ }
402
+ }
403
+
245
404
  /**
246
405
  *
247
406
  * @public
248
407
  * @description Removes all Wallaby data from local storage.
249
- * @param {string} userId The user's ID that is associated with their stored keys
250
408
  * @returns {Boolean}
251
409
  */
252
- clearWalletData({ userId }: ClearWalletInput): Boolean {
410
+ clearDevice(): Boolean {
253
411
  try {
254
- Utils.clearLocalStorage(userId);
412
+ Utils.clearLocalStorage(this.device.user.clientUserId);
255
413
  return true;
256
414
  } catch (error) {
257
- logger('SDK::Wallet::clearWalletData::error', error);
415
+ logger('SDK::Wallet::clearDevice::error', error);
258
416
  return false;
259
417
  }
260
418
  }
@@ -263,19 +421,19 @@ export class Wallet extends Base {
263
421
  *
264
422
  * @public
265
423
  * @description Convert BIP39 Standard seed phrase to Algorand fixed 25 words mnemonic phrase
266
- * @param {string} hashKey
424
+ * @param {string} password
267
425
  * @param {Encrypted} encryptedSeedPhrase It needs to be encypted using wallabyAuthPubKey
268
426
  * @returns {ConvertMnemonicSeedPhraseResponse} The mnemonic seed phrase has been converted successfully.
269
427
  */
270
428
  async convertMnemonicSeedphrase({
271
- hashKey,
429
+ password,
272
430
  encryptedSeedPhrase,
273
- }: Pick<ConvertMnemonicSeedPhraseRequest, 'hashKey' | 'encryptedSeedPhrase'>): Promise<
431
+ }: Pick<ConvertMnemonicSeedPhraseRequest, 'password' | 'encryptedSeedPhrase'>): Promise<
274
432
  ConvertMnemonicSeedPhraseResponse | undefined
275
433
  > {
276
434
  try {
277
435
  const reference = uuid();
278
- const signatureMessage = await this.auth.signatureMessage({ hashKey, userId: this.userId });
436
+ const signatureMessage = await this.auth.signatureMessage({ password, userId: this.userId });
279
437
  if (!signatureMessage || signatureMessage.error) {
280
438
  throw new Error(signatureMessage?.error);
281
439
  }
@@ -307,12 +465,12 @@ export class Wallet extends Base {
307
465
  *
308
466
  * @public
309
467
  * @description Recover the lost wallet and its assets.
310
- * @param {string} newHashKey User need to set a new password while recovering the wallet
468
+ * @param {string} newPassword User need to set a new password while recovering the wallet
311
469
  * @param {string} seedPhrase It needs to be encypted using wallabyAuthPubKey
312
470
  * @returns {RecoverWalletResponse} The wallet has been recovered successfully.
313
471
  */
314
472
  async recover({
315
- newHashKey,
473
+ newPassword,
316
474
  seedPhrase,
317
475
  }: Omit<RecoverWalletRequest, 'clientAuthPubKey'>): Promise<RecoverWalletResponse | undefined> {
318
476
  try {
@@ -345,12 +503,21 @@ export class Wallet extends Base {
345
503
 
346
504
  // Store the new keys and seedphrase in the new browswer
347
505
  Utils.setWallabyAuthPubKey(this.userId, wallabyAuthPubKey);
348
- Utils.setEncryptedPrivateKey(this.userId, privateKey, newHashKey);
349
- await Utils.setEncryptedSeedPhrase(this.userId, publicKey, seedPhrase, SeedPhraseType.Standard);
506
+ Utils.setEncryptedPrivateKey(this.userId, privateKey, newPassword);
507
+
508
+ // We need to get the user's salt in order for us to double encrypt the seedphrase before storing
509
+ // in local storage.
510
+ const salt = await this.auth.getUserSalt();
511
+
512
+ if (!salt) {
513
+ throw new Error('User salt could not be retrieved, Wallet recovery could not be finished');
514
+ }
515
+
516
+ await Utils.setEncryptedSeedPhrase(this.userId, publicKey, seedPhrase, SeedPhraseType.Standard, newPassword, salt);
350
517
 
351
518
  // Get Algorand mnemonic seedphrase
352
519
  const mnemonicSeedPhrase = await this.convertMnemonicSeedphrase({
353
- hashKey: newHashKey,
520
+ password: newPassword,
354
521
  // This is the standard seedPhrase from the wallet creation response but encrypted using Wallaby's auth public key
355
522
  encryptedSeedPhrase: encryptedSeedphraseWithWallabyKey,
356
523
  });
@@ -362,7 +529,14 @@ export class Wallet extends Base {
362
529
  // Decrypt the seedPhrase and retrun as part of response in case it needs to be displayed to the user.
363
530
  const { convertedEncryptedSeed } = mnemonicSeedPhrase;
364
531
  const decryptedMnemonicSeedphrase = await decryptWithPrivateKey(privateKey, convertedEncryptedSeed);
365
- await Utils.setEncryptedSeedPhrase(this.userId, publicKey, decryptedMnemonicSeedphrase, SeedPhraseType.Algorand);
532
+ await Utils.setEncryptedSeedPhrase(
533
+ this.userId,
534
+ publicKey,
535
+ decryptedMnemonicSeedphrase,
536
+ SeedPhraseType.Algorand,
537
+ newPassword,
538
+ salt,
539
+ );
366
540
 
367
541
  return { ...response, seedPhrase, decryptedMnemonicSeedphrase };
368
542
  } catch (error) {
@@ -4,31 +4,36 @@ export const AuthRoutes = {
4
4
  signatureMessage: {
5
5
  fullPath: '/auth/signature-message',
6
6
  method: RequestMothod.Post,
7
- accessTokenRequired: false,
7
+ requiresAccessToken: false,
8
8
  },
9
9
  signIn: {
10
10
  fullPath: '/auth/sign-in',
11
11
  method: RequestMothod.Post,
12
- accessTokenRequired: true,
12
+ requiresAccessToken: true,
13
13
  },
14
14
  signUp: {
15
15
  fullPath: '/auth/sign-up',
16
16
  method: RequestMothod.Post,
17
- accessTokenRequired: false,
17
+ requiresAccessToken: false,
18
18
  },
19
19
  refreshAcessToken: {
20
20
  fullPath: '/auth/refresh-access-token',
21
21
  method: RequestMothod.Post,
22
- accessTokenRequired: true,
22
+ requiresAccessToken: true,
23
23
  },
24
24
  clientAuthPubKey: {
25
25
  fullPath: 'auth/client-auth-pubkey',
26
26
  method: RequestMothod.Put,
27
- accessTokenRequired: true,
27
+ requiresAccessToken: true,
28
28
  },
29
29
  wallabyAuthPublicKey: {
30
30
  fullPath: '/auth/wallaby-auth-pubkey',
31
31
  method: RequestMothod.Get,
32
- accessTokenRequired: true,
32
+ requiresAccessToken: true,
33
+ },
34
+ getUserSalt: {
35
+ fullPath: '/users/salt',
36
+ method: RequestMothod.Get,
37
+ requiresAccessToken: true,
33
38
  },
34
39
  };
@@ -4,36 +4,36 @@ export const MerchantsRoutes = {
4
4
  create: {
5
5
  fullPath: '/merchants',
6
6
  method: RequestMothod.Post,
7
- accessTokenRequired: false,
7
+ requiresAccessToken: false,
8
8
  },
9
9
  update: {
10
10
  fullPath: ({ id }: { id: string }) => `/merchants/${id}`,
11
11
  method: RequestMothod.Put,
12
- accessTokenRequired: false,
12
+ requiresAccessToken: false,
13
13
  },
14
14
  getMerchantData: {
15
15
  fullPath: ({ id }: { id: string }) => `/merchants/${id}`,
16
16
  method: RequestMothod.Get,
17
- accessTokenRequired: false,
17
+ requiresAccessToken: false,
18
18
  },
19
19
  list: {
20
20
  fullPath: '/merchants',
21
21
  method: RequestMothod.Get,
22
- accessTokenRequired: false,
22
+ requiresAccessToken: false,
23
23
  },
24
24
  getAssets: {
25
25
  fullPath: ({ id }: { id: string }) => `/merchants/${id}/assets`,
26
26
  method: RequestMothod.Get,
27
- accessTokenRequired: false,
27
+ requiresAccessToken: false,
28
28
  },
29
29
  addAsset: {
30
30
  fullPath: ({ id, configId }: { id: string; configId: string }) => `/merchants/${id}/assets${configId}`,
31
31
  method: RequestMothod.Post,
32
- accessTokenRequired: false,
32
+ requiresAccessToken: false,
33
33
  },
34
34
  deleteAsset: {
35
35
  fullPath: ({ id, configId }: { id: string; configId: string }) => `/merchants/${id}/assets${configId}`,
36
36
  method: RequestMothod.Delete,
37
- accessTokenRequired: false,
37
+ requiresAccessToken: false,
38
38
  },
39
39
  };
@@ -4,21 +4,21 @@ export const SystemRoutes = {
4
4
  getSupportedBlockchains: {
5
5
  fullPath: '/chains',
6
6
  method: RequestMothod.Get,
7
- accessTokenRequired: false,
7
+ requiresAccessToken: false,
8
8
  },
9
9
  getSupportedTokens: {
10
10
  fullPath: '/assets/configurations',
11
11
  method: RequestMothod.Get,
12
- accessTokenRequired: false,
12
+ requiresAccessToken: false,
13
13
  },
14
14
  getUserByExternalUserId: {
15
15
  fullPath: ({ externalUserId }: QueryUserRequest) => `/users/${externalUserId}/externalUserId`,
16
16
  method: RequestMothod.Get,
17
- accessTokenRequired: false,
17
+ requiresAccessToken: false,
18
18
  },
19
19
  getUserData: {
20
20
  fullPath: ({ userId }: QueryUserRequest) => `/users/${userId}`,
21
21
  method: RequestMothod.Get,
22
- accessTokenRequired: false,
22
+ requiresAccessToken: false,
23
23
  },
24
24
  };
@@ -4,26 +4,43 @@ export const TransactionsRoutes = {
4
4
  transfer: {
5
5
  fullPath: '/transactions/transfer',
6
6
  method: RequestMothod.Post,
7
- accessTokenRequired: true,
7
+ requiresAccessToken: true,
8
8
  },
9
9
  createAllowance: {
10
10
  fullPath: '/transactions/create-allowance',
11
11
  method: RequestMothod.Post,
12
- accessTokenRequired: true,
12
+ requiresAccessToken: true,
13
13
  },
14
14
  estimateFee: {
15
- fullPath: '/transactions/estimate-fee',
15
+ fullPath: ({
16
+ assetSymbol,
17
+ originAddress,
18
+ recipientAddress,
19
+ amount,
20
+ transactionType,
21
+ tokenType,
22
+ }: {
23
+ assetSymbol: string;
24
+ originAddress: string;
25
+ recipientAddress: string;
26
+ amount: number;
27
+ transactionType: string;
28
+ tokenType?: string;
29
+ }) =>
30
+ `/transactions/estimate-fee?assetSymbol=${assetSymbol}&originAddress=${originAddress}&recipientAddress=${recipientAddress}&amount=${amount}&transactionType=${transactionType}${
31
+ tokenType ? `&tokenType=${tokenType}` : ''
32
+ }`,
16
33
  method: RequestMothod.Get,
17
- accessTokenRequired: true,
34
+ requiresAccessToken: true,
18
35
  },
19
36
  getTransaction: {
20
37
  fullPath: '/transactions/status',
21
38
  method: RequestMothod.Get,
22
- accessTokenRequired: true,
39
+ requiresAccessToken: true,
23
40
  },
24
41
  getTransactions: {
25
42
  fullPath: '/query/transactions',
26
43
  method: RequestMothod.Get,
27
- accessTokenRequired: true,
44
+ requiresAccessToken: true,
28
45
  },
29
46
  };
@@ -4,17 +4,22 @@ export const WalletRoutes = {
4
4
  create: {
5
5
  fullPath: '/wallets/create',
6
6
  method: RequestMothod.Post,
7
- accessTokenRequired: true,
7
+ requiresAccessToken: true,
8
+ },
9
+ import: {
10
+ fullPath: '/wallets/import-seed-phrase',
11
+ method: RequestMothod.Post,
12
+ requiresAccessToken: true,
8
13
  },
9
14
  initRecoveryFlow: {
10
15
  fullPath: 'wallets/recover/init',
11
16
  method: RequestMothod.Post,
12
- accessTokenRequired: false,
17
+ requiresAccessToken: false,
13
18
  },
14
19
  recover: {
15
20
  fullPath: '/wallets/recover',
16
21
  method: RequestMothod.Post,
17
- accessTokenRequired: false,
22
+ requiresAccessToken: false,
18
23
  },
19
24
  getTokenBalance: {
20
25
  fullPath: ({ address, symbol, tokenStandard }: TokenBalanceRequest) => {
@@ -23,43 +28,43 @@ export const WalletRoutes = {
23
28
  }`;
24
29
  },
25
30
  method: RequestMothod.Get,
26
- accessTokenRequired: false,
31
+ requiresAccessToken: false,
27
32
  },
28
33
  // TODO Move this to transactions module
29
34
  estimateFee: {
30
35
  fullPath: '/transactions/estimate-fee',
31
36
  method: RequestMothod.Get,
32
- accessTokenRequired: true,
37
+ requiresAccessToken: true,
33
38
  },
34
39
  getWalletAssets: {
35
40
  fullPath: ({ walletId }: QueryWalletRequest) => {
36
41
  return `/wallets/${walletId}/assets`;
37
42
  },
38
43
  method: RequestMothod.Get,
39
- accessTokenRequired: true,
44
+ requiresAccessToken: true,
40
45
  },
41
46
  getUserAssets: {
42
47
  fullPath: ({ userId }: QueryUserRequest) => {
43
48
  return `/users/${userId}/assets`;
44
49
  },
45
50
  method: RequestMothod.Get,
46
- accessTokenRequired: true,
51
+ requiresAccessToken: true,
47
52
  },
48
53
  getUserWallets: {
49
54
  fullPath: ({ userId }: QueryUserRequest) => {
50
55
  return `/users/${userId}/wallets`;
51
56
  },
52
57
  method: RequestMothod.Get,
53
- accessTokenRequired: true,
58
+ requiresAccessToken: true,
54
59
  },
55
60
  convertMnemonicSeedphrase: {
56
61
  fullPath: '/wallets/convert-mnemonic-seed',
57
62
  method: RequestMothod.Post,
58
- accessTokenRequired: false,
63
+ requiresAccessToken: false,
59
64
  },
60
65
  createMultisigAsset: {
61
66
  fullPath: '/wallets/create-multisig-asset',
62
67
  method: RequestMothod.Post,
63
- accessTokenRequired: true,
68
+ requiresAccessToken: true,
64
69
  },
65
70
  };