@keplr-wallet/background 0.10.9 → 0.10.10

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 (63) hide show
  1. package/build/chains/service.d.ts +15 -3
  2. package/build/chains/service.js +37 -38
  3. package/build/chains/service.js.map +1 -1
  4. package/build/chains/types.js +1 -1
  5. package/build/chains/types.js.map +1 -1
  6. package/build/index.d.ts +5 -3
  7. package/build/index.js +24 -47
  8. package/build/index.js.map +1 -1
  9. package/build/interaction/service.d.ts +1 -0
  10. package/build/interaction/service.js +5 -22
  11. package/build/interaction/service.js.map +1 -1
  12. package/build/keyring/crypto.d.ts +1 -2
  13. package/build/keyring/crypto.js +3 -3
  14. package/build/keyring/crypto.js.map +1 -1
  15. package/build/keyring/keyring.d.ts +5 -7
  16. package/build/keyring/keyring.js +23 -27
  17. package/build/keyring/keyring.js.map +1 -1
  18. package/build/keyring/service.d.ts +8 -7
  19. package/build/keyring/service.js +20 -47
  20. package/build/keyring/service.js.map +1 -1
  21. package/build/keyring/types.d.ts +2 -0
  22. package/build/ledger/service.d.ts +3 -2
  23. package/build/ledger/service.js +6 -26
  24. package/build/ledger/service.js.map +1 -1
  25. package/build/permission/service.d.ts +5 -4
  26. package/build/permission/service.js +13 -39
  27. package/build/permission/service.js.map +1 -1
  28. package/build/persistent-memory/service.d.ts +1 -0
  29. package/build/persistent-memory/service.js +5 -12
  30. package/build/persistent-memory/service.js.map +1 -1
  31. package/build/secret-wasm/service.d.ts +5 -4
  32. package/build/secret-wasm/service.js +8 -33
  33. package/build/secret-wasm/service.js.map +1 -1
  34. package/build/tokens/service.d.ts +6 -5
  35. package/build/tokens/service.js +15 -44
  36. package/build/tokens/service.js.map +1 -1
  37. package/build/tx/service.d.ts +4 -3
  38. package/build/tx/service.js +9 -32
  39. package/build/tx/service.js.map +1 -1
  40. package/build/updater/service.d.ts +3 -2
  41. package/build/updater/service.js +6 -26
  42. package/build/updater/service.js.map +1 -1
  43. package/package.json +11 -13
  44. package/src/chains/service.ts +51 -17
  45. package/src/chains/types.ts +3 -1
  46. package/src/index.ts +71 -63
  47. package/src/interaction/service.ts +5 -6
  48. package/src/keyring/crypto.ts +3 -4
  49. package/src/keyring/keyring.ts +22 -33
  50. package/src/keyring/service.ts +57 -33
  51. package/src/keyring/types.ts +3 -0
  52. package/src/ledger/service.ts +6 -8
  53. package/src/permission/service.ts +14 -12
  54. package/src/persistent-memory/service.ts +4 -3
  55. package/src/secret-wasm/service.ts +14 -14
  56. package/src/tokens/service.ts +17 -15
  57. package/src/tx/service.ts +9 -12
  58. package/src/updater/service.ts +7 -9
  59. package/tsconfig.json +1 -2
  60. package/build/types.d.ts +0 -19
  61. package/build/types.js +0 -23
  62. package/build/types.js.map +0 -1
  63. package/src/types.ts +0 -33
@@ -3,7 +3,6 @@ import {
3
3
  Mnemonic,
4
4
  PrivKeySecp256k1,
5
5
  PubKeySecp256k1,
6
- RNG,
7
6
  } from "@keplr-wallet/crypto";
8
7
  import { KVStore } from "@keplr-wallet/common";
9
8
  import { LedgerService } from "../ledger";
@@ -73,7 +72,6 @@ export class KeyRing {
73
72
  private readonly embedChainInfos: ChainInfo[],
74
73
  private readonly kvStore: KVStore,
75
74
  private readonly ledgerKeeper: LedgerService,
76
- private readonly rng: RNG,
77
75
  private readonly crypto: CommonCrypto
78
76
  ) {
79
77
  this.loaded = false;
@@ -173,8 +171,15 @@ export class KeyRing {
173
171
  ];
174
172
  }
175
173
 
176
- public getKey(chainId: string, defaultCoinType: number): Key {
177
- return this.loadKey(this.computeKeyStoreCoinType(chainId, defaultCoinType));
174
+ public getKey(
175
+ chainId: string,
176
+ defaultCoinType: number,
177
+ useEthereumAddress: boolean
178
+ ): Key {
179
+ return this.loadKey(
180
+ this.computeKeyStoreCoinType(chainId, defaultCoinType),
181
+ useEthereumAddress
182
+ );
178
183
  }
179
184
 
180
185
  public getKeyStoreMeta(key: string): string {
@@ -200,8 +205,11 @@ export class KeyRing {
200
205
  : defaultCoinType;
201
206
  }
202
207
 
203
- public getKeyFromCoinType(coinType: number): Key {
204
- return this.loadKey(coinType);
208
+ public getKeyFromCoinType(
209
+ coinType: number,
210
+ useEthereumAddress: boolean
211
+ ): Key {
212
+ return this.loadKey(coinType, useEthereumAddress);
205
213
  }
206
214
 
207
215
  public async createMnemonicKey(
@@ -224,7 +232,6 @@ export class KeyRing {
224
232
 
225
233
  this.mnemonicMasterSeed = Mnemonic.generateMasterSeedFromMnemonic(mnemonic);
226
234
  this.keyStore = await KeyRing.CreateMnemonicKeyStore(
227
- this.rng,
228
235
  this.crypto,
229
236
  kdf,
230
237
  mnemonic,
@@ -262,7 +269,6 @@ export class KeyRing {
262
269
 
263
270
  this.privateKey = privateKey;
264
271
  this.keyStore = await KeyRing.CreatePrivateKeyStore(
265
- this.rng,
266
272
  this.crypto,
267
273
  kdf,
268
274
  privateKey,
@@ -305,7 +311,6 @@ export class KeyRing {
305
311
  );
306
312
 
307
313
  const keyStore = await KeyRing.CreateLedgerKeyStore(
308
- this.rng,
309
314
  this.crypto,
310
315
  kdf,
311
316
  this.ledgerPublicKey,
@@ -586,7 +591,7 @@ export class KeyRing {
586
591
  return this.getMultiKeyStoreInfo();
587
592
  }
588
593
 
589
- private loadKey(coinType: number): Key {
594
+ private loadKey(coinType: number, useEthereumAddress: boolean = false): Key {
590
595
  if (this.status !== KeyRingStatus.UNLOCKED) {
591
596
  throw new KeplrError("keyring", 143, "Key ring is not unlocked");
592
597
  }
@@ -600,7 +605,7 @@ export class KeyRing {
600
605
  throw new KeplrError("keyring", 150, "Ledger public key not set");
601
606
  }
602
607
 
603
- if (coinType === 60) {
608
+ if (useEthereumAddress) {
604
609
  throw new KeplrError(
605
610
  "keyring",
606
611
  152,
@@ -620,7 +625,7 @@ export class KeyRing {
620
625
  const privKey = this.loadPrivKey(coinType);
621
626
  const pubKey = privKey.getPubKey();
622
627
 
623
- if (coinType === 60) {
628
+ if (useEthereumAddress) {
624
629
  // For Ethereum Key-Gen Only:
625
630
  const wallet = new Wallet(privKey.toBytes());
626
631
  const ethereumAddress = ETH.decoder(wallet.address);
@@ -697,7 +702,8 @@ export class KeyRing {
697
702
  env: Env,
698
703
  chainId: string,
699
704
  defaultCoinType: number,
700
- message: Uint8Array
705
+ message: Uint8Array,
706
+ useEthereumSigning: boolean
701
707
  ): Promise<Uint8Array> {
702
708
  if (this.status !== KeyRingStatus.UNLOCKED) {
703
709
  throw new KeplrError("keyring", 143, "Key ring is not unlocked");
@@ -708,8 +714,7 @@ export class KeyRing {
708
714
  }
709
715
 
710
716
  // Sign with Evmos/Ethereum
711
- const coinType = this.computeKeyStoreCoinType(chainId, defaultCoinType);
712
- if (coinType === 60) {
717
+ if (useEthereumSigning) {
713
718
  return this.signEthereum(chainId, defaultCoinType, message);
714
719
  }
715
720
 
@@ -746,7 +751,7 @@ export class KeyRing {
746
751
  }
747
752
  }
748
753
 
749
- public async signEthereum(
754
+ private async signEthereum(
750
755
  chainId: string,
751
756
  defaultCoinType: number,
752
757
  message: Uint8Array
@@ -768,14 +773,7 @@ export class KeyRing {
768
773
  );
769
774
  } else {
770
775
  const coinType = this.computeKeyStoreCoinType(chainId, defaultCoinType);
771
- if (coinType !== 60) {
772
- throw new KeplrError(
773
- "keyring",
774
- 111,
775
- "Invalid coin type passed in to Ethereum signing (expected 60)"
776
- );
777
- }
778
-
776
+ // Allow signing with Ethereum for chains with coinType !== 60
779
777
  const privKey = this.loadPrivKey(coinType);
780
778
 
781
779
  // Use ether js to sign Ethereum tx
@@ -841,7 +839,6 @@ export class KeyRing {
841
839
  }
842
840
 
843
841
  const keyStore = await KeyRing.CreateMnemonicKeyStore(
844
- this.rng,
845
842
  this.crypto,
846
843
  kdf,
847
844
  mnemonic,
@@ -873,7 +870,6 @@ export class KeyRing {
873
870
  }
874
871
 
875
872
  const keyStore = await KeyRing.CreatePrivateKeyStore(
876
- this.rng,
877
873
  this.crypto,
878
874
  kdf,
879
875
  privateKey,
@@ -908,7 +904,6 @@ export class KeyRing {
908
904
  const publicKey = await this.ledgerKeeper.getPublicKey(env, bip44HDPath);
909
905
 
910
906
  const keyStore = await KeyRing.CreateLedgerKeyStore(
911
- this.rng,
912
907
  this.crypto,
913
908
  kdf,
914
909
  publicKey,
@@ -1041,7 +1036,6 @@ export class KeyRing {
1041
1036
  }
1042
1037
 
1043
1038
  private static async CreateMnemonicKeyStore(
1044
- rng: RNG,
1045
1039
  crypto: CommonCrypto,
1046
1040
  kdf: "scrypt" | "sha256" | "pbkdf2",
1047
1041
  mnemonic: string,
@@ -1050,7 +1044,6 @@ export class KeyRing {
1050
1044
  bip44HDPath: BIP44HDPath
1051
1045
  ): Promise<KeyStore> {
1052
1046
  return await Crypto.encrypt(
1053
- rng,
1054
1047
  crypto,
1055
1048
  kdf,
1056
1049
  "mnemonic",
@@ -1062,7 +1055,6 @@ export class KeyRing {
1062
1055
  }
1063
1056
 
1064
1057
  private static async CreatePrivateKeyStore(
1065
- rng: RNG,
1066
1058
  crypto: CommonCrypto,
1067
1059
  kdf: "scrypt" | "sha256" | "pbkdf2",
1068
1060
  privateKey: Uint8Array,
@@ -1070,7 +1062,6 @@ export class KeyRing {
1070
1062
  meta: Record<string, string>
1071
1063
  ): Promise<KeyStore> {
1072
1064
  return await Crypto.encrypt(
1073
- rng,
1074
1065
  crypto,
1075
1066
  kdf,
1076
1067
  "privateKey",
@@ -1081,7 +1072,6 @@ export class KeyRing {
1081
1072
  }
1082
1073
 
1083
1074
  private static async CreateLedgerKeyStore(
1084
- rng: RNG,
1085
1075
  crypto: CommonCrypto,
1086
1076
  kdf: "scrypt" | "sha256" | "pbkdf2",
1087
1077
  publicKey: Uint8Array,
@@ -1090,7 +1080,6 @@ export class KeyRing {
1090
1080
  bip44HDPath: BIP44HDPath
1091
1081
  ): Promise<KeyStore> {
1092
1082
  return await Crypto.encrypt(
1093
- rng,
1094
1083
  crypto,
1095
1084
  kdf,
1096
1085
  "ledger",
@@ -1,6 +1,3 @@
1
- import { delay, inject, singleton } from "tsyringe";
2
- import { TYPES } from "../types";
3
-
4
1
  import {
5
2
  Key,
6
3
  KeyRing,
@@ -34,39 +31,38 @@ import {
34
31
  } from "@cosmjs/launchpad";
35
32
  import { DirectSignResponse, makeSignBytes } from "@cosmjs/proto-signing";
36
33
 
37
- import { RNG } from "@keplr-wallet/crypto";
38
34
  import { SignDoc } from "@keplr-wallet/proto-types/cosmos/tx/v1beta1/tx";
39
35
  import Long from "long";
40
36
  import { Buffer } from "buffer/";
41
37
 
42
- @singleton()
43
38
  export class KeyRingService {
44
- private readonly keyRing: KeyRing;
39
+ private keyRing!: KeyRing;
40
+
41
+ protected interactionService!: InteractionService;
42
+ public chainsService!: ChainsService;
43
+ public permissionService!: PermissionService;
45
44
 
46
45
  constructor(
47
- @inject(TYPES.KeyRingStore)
48
- kvStore: KVStore,
49
- @inject(TYPES.ChainsEmbedChainInfos)
50
- embedChainInfos: ChainInfo[],
51
- @inject(delay(() => InteractionService))
52
- protected readonly interactionService: InteractionService,
53
- @inject(delay(() => ChainsService))
54
- public readonly chainsService: ChainsService,
55
- @inject(delay(() => PermissionService))
56
- public readonly permissionService: PermissionService,
57
- @inject(LedgerService)
58
- ledgerService: LedgerService,
59
- @inject(TYPES.RNG)
60
- protected readonly rng: RNG,
61
- @inject(TYPES.CommonCrypto)
46
+ protected readonly kvStore: KVStore,
47
+ protected readonly embedChainInfos: ChainInfo[],
62
48
  protected readonly crypto: CommonCrypto
49
+ ) {}
50
+
51
+ init(
52
+ interactionService: InteractionService,
53
+ chainsService: ChainsService,
54
+ permissionService: PermissionService,
55
+ ledgerService: LedgerService
63
56
  ) {
57
+ this.interactionService = interactionService;
58
+ this.chainsService = chainsService;
59
+ this.permissionService = permissionService;
60
+
64
61
  this.keyRing = new KeyRing(
65
- embedChainInfos,
66
- kvStore,
62
+ this.embedChainInfos,
63
+ this.kvStore,
67
64
  ledgerService,
68
- rng,
69
- crypto
65
+ this.crypto
70
66
  );
71
67
  }
72
68
 
@@ -210,7 +206,8 @@ export class KeyRingService {
210
206
  async getKey(chainId: string): Promise<Key> {
211
207
  return this.keyRing.getKey(
212
208
  chainId,
213
- await this.chainsService.getChainCoinType(chainId)
209
+ await this.chainsService.getChainCoinType(chainId),
210
+ (await this.chainsService.getChainEthereumKeyFeatures(chainId)).address
214
211
  );
215
212
  }
216
213
 
@@ -234,8 +231,15 @@ export class KeyRingService {
234
231
  }
235
232
  ): Promise<AminoSignResponse> {
236
233
  const coinType = await this.chainsService.getChainCoinType(chainId);
234
+ const ethereumKeyFeatures = await this.chainsService.getChainEthereumKeyFeatures(
235
+ chainId
236
+ );
237
237
 
238
- const key = await this.keyRing.getKey(chainId, coinType);
238
+ const key = await this.keyRing.getKey(
239
+ chainId,
240
+ coinType,
241
+ ethereumKeyFeatures.address
242
+ );
239
243
  const bech32Prefix = (await this.chainsService.getChainInfo(chainId))
240
244
  .bech32Config.bech32PrefixAccAddr;
241
245
  const bech32Address = new Bech32Address(key.address).toBech32(bech32Prefix);
@@ -301,7 +305,8 @@ export class KeyRingService {
301
305
  env,
302
306
  chainId,
303
307
  coinType,
304
- serializeSignDoc(newSignDoc)
308
+ serializeSignDoc(newSignDoc),
309
+ ethereumKeyFeatures.signing
305
310
  );
306
311
 
307
312
  return {
@@ -322,8 +327,15 @@ export class KeyRingService {
322
327
  signOptions: KeplrSignOptions
323
328
  ): Promise<DirectSignResponse> {
324
329
  const coinType = await this.chainsService.getChainCoinType(chainId);
330
+ const ethereumKeyFeatures = await this.chainsService.getChainEthereumKeyFeatures(
331
+ chainId
332
+ );
325
333
 
326
- const key = await this.keyRing.getKey(chainId, coinType);
334
+ const key = await this.keyRing.getKey(
335
+ chainId,
336
+ coinType,
337
+ ethereumKeyFeatures.address
338
+ );
327
339
  const bech32Address = new Bech32Address(key.address).toBech32(
328
340
  (await this.chainsService.getChainInfo(chainId)).bech32Config
329
341
  .bech32PrefixAccAddr
@@ -361,7 +373,8 @@ export class KeyRingService {
361
373
  env,
362
374
  chainId,
363
375
  coinType,
364
- makeSignBytes(cosmJSSignDoc)
376
+ makeSignBytes(cosmJSSignDoc),
377
+ ethereumKeyFeatures.signing
365
378
  );
366
379
 
367
380
  return {
@@ -380,8 +393,15 @@ export class KeyRingService {
380
393
  signature: StdSignature
381
394
  ): Promise<boolean> {
382
395
  const coinType = await this.chainsService.getChainCoinType(chainId);
396
+ const ethereumKeyFeatures = await this.chainsService.getChainEthereumKeyFeatures(
397
+ chainId
398
+ );
383
399
 
384
- const key = await this.keyRing.getKey(chainId, coinType);
400
+ const key = await this.keyRing.getKey(
401
+ chainId,
402
+ coinType,
403
+ ethereumKeyFeatures.address
404
+ );
385
405
  const bech32Prefix = (await this.chainsService.getChainInfo(chainId))
386
406
  .bech32Config.bech32PrefixAccAddr;
387
407
  const bech32Address = new Bech32Address(key.address).toBech32(bech32Prefix);
@@ -420,7 +440,8 @@ export class KeyRingService {
420
440
  env,
421
441
  chainId,
422
442
  await this.chainsService.getChainCoinType(chainId),
423
- message
443
+ message,
444
+ (await this.chainsService.getChainEthereumKeyFeatures(chainId)).signing
424
445
  );
425
446
  }
426
447
 
@@ -513,7 +534,10 @@ export class KeyRingService {
513
534
  const chainInfo = await this.chainsService.getChainInfo(chainId);
514
535
 
515
536
  for (const path of paths) {
516
- const key = await this.keyRing.getKeyFromCoinType(path.coinType);
537
+ const key = await this.keyRing.getKeyFromCoinType(
538
+ path.coinType,
539
+ (await this.chainsService.getChainEthereumKeyFeatures(chainId)).address
540
+ );
517
541
  const bech32Address = new Bech32Address(key.address).toBech32(
518
542
  chainInfo.bech32Config.bech32PrefixAccAddr
519
543
  );
@@ -1,3 +1,5 @@
1
+ import { RNG } from "@keplr-wallet/crypto";
2
+
1
3
  export type CoinTypeForChain = {
2
4
  [identifier: string]: number;
3
5
  };
@@ -9,6 +11,7 @@ export type BIP44HDPath = {
9
11
  };
10
12
 
11
13
  export interface CommonCrypto {
14
+ rng: RNG;
12
15
  scrypt: (text: string, params: ScryptParams) => Promise<Uint8Array>;
13
16
  }
14
17
 
@@ -1,6 +1,3 @@
1
- import { delay as diDelay, inject, singleton } from "tsyringe";
2
- import { TYPES } from "../types";
3
-
4
1
  import { Ledger, LedgerWebHIDIniter, LedgerWebUSBIniter } from "./ledger";
5
2
 
6
3
  import delay from "delay";
@@ -12,18 +9,15 @@ import { InteractionService } from "../interaction";
12
9
  import { LedgerOptions } from "./options";
13
10
  import { Buffer } from "buffer/";
14
11
 
15
- @singleton()
16
12
  export class LedgerService {
17
13
  private previousInitAborter: ((e: Error) => void) | undefined;
18
14
 
19
15
  protected options: LedgerOptions;
20
16
 
17
+ protected interactionService!: InteractionService;
18
+
21
19
  constructor(
22
- @inject(TYPES.LedgerStore)
23
20
  protected readonly kvStore: KVStore,
24
- @inject(diDelay(() => InteractionService))
25
- protected readonly interactionService: InteractionService,
26
- @inject(TYPES.LedgerOptions)
27
21
  options: Partial<LedgerOptions>
28
22
  ) {
29
23
  this.options = {
@@ -39,6 +33,10 @@ export class LedgerService {
39
33
  }
40
34
  }
41
35
 
36
+ init(interactionService: InteractionService) {
37
+ this.interactionService = interactionService;
38
+ }
39
+
42
40
  async getPublicKey(env: Env, bip44HDPath: BIP44HDPath): Promise<Uint8Array> {
43
41
  return await this.useLedger(env, async (ledger, retryCount) => {
44
42
  try {
@@ -1,6 +1,3 @@
1
- import { delay, inject, singleton } from "tsyringe";
2
- import { TYPES } from "../types";
3
-
4
1
  import { InteractionService } from "../interaction";
5
2
  import { Env, KeplrError } from "@keplr-wallet/router";
6
3
  import {
@@ -13,7 +10,6 @@ import { ChainsService } from "../chains";
13
10
  import { KeyRingService } from "../keyring";
14
11
  import { ChainIdHelper } from "@keplr-wallet/cosmos";
15
12
 
16
- @singleton()
17
13
  export class PermissionService {
18
14
  protected permissionMap: {
19
15
  [chainIdentifier: string]:
@@ -29,16 +25,12 @@ export class PermissionService {
29
25
 
30
26
  protected privilegedOrigins: Map<string, boolean> = new Map();
31
27
 
28
+ protected interactionService!: InteractionService;
29
+ protected chainsService!: ChainsService;
30
+ protected keyRingService!: KeyRingService;
31
+
32
32
  constructor(
33
- @inject(TYPES.PermissionStore)
34
33
  protected readonly kvStore: KVStore,
35
- @inject(delay(() => InteractionService))
36
- protected readonly interactionService: InteractionService,
37
- @inject(ChainsService)
38
- protected readonly chainsService: ChainsService,
39
- @inject(delay(() => KeyRingService))
40
- protected readonly keyRingService: KeyRingService,
41
- @inject(TYPES.PermissionServicePrivilegedOrigins)
42
34
  privilegedOrigins: string[]
43
35
  ) {
44
36
  for (const origin of privilegedOrigins) {
@@ -46,6 +38,16 @@ export class PermissionService {
46
38
  }
47
39
 
48
40
  this.restore();
41
+ }
42
+
43
+ init(
44
+ interactionService: InteractionService,
45
+ chainsService: ChainsService,
46
+ keyRingService: KeyRingService
47
+ ) {
48
+ this.interactionService = interactionService;
49
+ this.chainsService = chainsService;
50
+ this.keyRingService = keyRingService;
49
51
 
50
52
  this.chainsService.addChainRemovedHandler(this.onChainRemoved);
51
53
  }
@@ -1,9 +1,10 @@
1
- import { singleton } from "tsyringe";
2
-
3
- @singleton()
4
1
  export class PersistentMemoryService {
5
2
  data: any = {};
6
3
 
4
+ init() {
5
+ // noop
6
+ }
7
+
7
8
  set(data: any) {
8
9
  this.data = { ...this.data, ...data };
9
10
  }
@@ -1,6 +1,3 @@
1
- import { delay, inject, singleton } from "tsyringe";
2
- import { TYPES } from "../types";
3
-
4
1
  import { EnigmaUtils } from "secretjs";
5
2
  import { KeyRingService } from "../keyring";
6
3
  import { ChainsService } from "../chains";
@@ -10,10 +7,8 @@ import { KVStore, Debouncer } from "@keplr-wallet/common";
10
7
  import { ChainInfo } from "@keplr-wallet/types";
11
8
  import { Bech32Address } from "@keplr-wallet/cosmos";
12
9
  import { Env, KeplrError } from "@keplr-wallet/router";
13
-
14
10
  import { Buffer } from "buffer/";
15
11
 
16
- @singleton()
17
12
  export class SecretWasmService {
18
13
  protected debouncerMap: Map<
19
14
  string,
@@ -26,16 +21,21 @@ export class SecretWasmService {
26
21
 
27
22
  protected cacheEnigmaUtils: Map<string, EnigmaUtils> = new Map();
28
23
 
29
- constructor(
30
- @inject(TYPES.SecretWasmStore)
31
- protected readonly kvStore: KVStore,
32
- @inject(ChainsService)
33
- protected readonly chainsService: ChainsService,
34
- @inject(delay(() => KeyRingService))
35
- protected readonly keyRingService: KeyRingService,
36
- @inject(delay(() => PermissionService))
37
- public readonly permissionService: PermissionService
24
+ protected chainsService!: ChainsService;
25
+ protected keyRingService!: KeyRingService;
26
+ public permissionService!: PermissionService;
27
+
28
+ constructor(protected readonly kvStore: KVStore) {}
29
+
30
+ init(
31
+ chainsService: ChainsService,
32
+ keyRingService: KeyRingService,
33
+ permissionService: PermissionService
38
34
  ) {
35
+ this.chainsService = chainsService;
36
+ this.keyRingService = keyRingService;
37
+ this.permissionService = permissionService;
38
+
39
39
  this.chainsService.addChainRemovedHandler(this.onChainRemoved);
40
40
  }
41
41
 
@@ -1,6 +1,3 @@
1
- import { delay, inject, singleton } from "tsyringe";
2
- import { TYPES } from "../types";
3
-
4
1
  import { Env, KeplrError } from "@keplr-wallet/router";
5
2
  import {
6
3
  ChainInfo,
@@ -25,20 +22,25 @@ import { Buffer } from "buffer/";
25
22
  import { SuggestTokenMsg } from "./messages";
26
23
  import { getSecret20ViewingKeyPermissionType } from "./types";
27
24
 
28
- @singleton()
29
25
  export class TokensService {
30
- constructor(
31
- @inject(TYPES.TokensStore)
32
- protected readonly kvStore: KVStore,
33
- @inject(delay(() => InteractionService))
34
- protected readonly interactionService: InteractionService,
35
- @inject(delay(() => PermissionService))
36
- public readonly permissionService: PermissionService,
37
- @inject(ChainsService)
38
- protected readonly chainsService: ChainsService,
39
- @inject(delay(() => KeyRingService))
40
- protected readonly keyRingService: KeyRingService
26
+ protected interactionService!: InteractionService;
27
+ public permissionService!: PermissionService;
28
+ protected chainsService!: ChainsService;
29
+ protected keyRingService!: KeyRingService;
30
+
31
+ constructor(protected readonly kvStore: KVStore) {}
32
+
33
+ init(
34
+ interactionService: InteractionService,
35
+ permissionService: PermissionService,
36
+ chainsService: ChainsService,
37
+ keyRingService: KeyRingService
41
38
  ) {
39
+ this.interactionService = interactionService;
40
+ this.permissionService = permissionService;
41
+ this.chainsService = chainsService;
42
+ this.keyRingService = keyRingService;
43
+
42
44
  this.chainsService.addChainRemovedHandler(this.onChainRemoved);
43
45
  }
44
46
 
package/src/tx/service.ts CHANGED
@@ -1,6 +1,3 @@
1
- import { delay, inject, singleton } from "tsyringe";
2
- import { TYPES } from "../types";
3
-
4
1
  import Axios from "axios";
5
2
  import { ChainsService } from "../chains";
6
3
  import { PermissionService } from "../permission";
@@ -22,16 +19,16 @@ interface ABCIMessageLog {
22
19
  // Events StringEvents
23
20
  }
24
21
 
25
- @singleton()
26
22
  export class BackgroundTxService {
27
- constructor(
28
- @inject(delay(() => ChainsService))
29
- protected readonly chainsService: ChainsService,
30
- @inject(delay(() => PermissionService))
31
- public readonly permissionService: PermissionService,
32
- @inject(TYPES.Notification)
33
- protected readonly notification: Notification
34
- ) {}
23
+ protected chainsService!: ChainsService;
24
+ public permissionService!: PermissionService;
25
+
26
+ constructor(protected readonly notification: Notification) {}
27
+
28
+ init(chainsService: ChainsService, permissionService: PermissionService) {
29
+ this.chainsService = chainsService;
30
+ this.permissionService = permissionService;
31
+ }
35
32
 
36
33
  async sendTx(
37
34
  chainId: string,
@@ -1,19 +1,17 @@
1
- import { inject, singleton, delay } from "tsyringe";
2
- import { TYPES } from "../types";
3
-
4
1
  import { ChainInfo } from "@keplr-wallet/types";
5
2
  import Axios from "axios";
6
3
  import { KVStore } from "@keplr-wallet/common";
7
4
  import { ChainIdHelper } from "@keplr-wallet/cosmos";
8
5
  import { ChainsService } from "../chains";
9
6
 
10
- @singleton()
11
7
  export class ChainUpdaterService {
12
- constructor(
13
- @inject(TYPES.UpdaterStore) protected readonly kvStore: KVStore,
14
- @inject(delay(() => ChainsService))
15
- protected readonly chainsService: ChainsService
16
- ) {}
8
+ protected chainsService!: ChainsService;
9
+
10
+ constructor(protected readonly kvStore: KVStore) {}
11
+
12
+ init(chainsService: ChainsService) {
13
+ this.chainsService = chainsService;
14
+ }
17
15
 
18
16
  async putUpdatedPropertyToChainInfo(
19
17
  chainInfo: ChainInfo
package/tsconfig.json CHANGED
@@ -4,7 +4,6 @@
4
4
  "baseUrl": ".",
5
5
  "outDir": "build",
6
6
  "declaration": true,
7
- "rootDir": "src",
8
- "emitDecoratorMetadata": true
7
+ "rootDir": "src"
9
8
  }
10
9
  }
package/build/types.d.ts DELETED
@@ -1,19 +0,0 @@
1
- export declare const TYPES: {
2
- ChainsStore: symbol;
3
- ChainsEmbedChainInfos: symbol;
4
- InteractionStore: symbol;
5
- KeyRingStore: symbol;
6
- LedgerStore: symbol;
7
- LedgerOptions: symbol;
8
- PermissionStore: symbol;
9
- PermissionServicePrivilegedOrigins: symbol;
10
- PersistentMemoryStore: symbol;
11
- SecretWasmStore: symbol;
12
- TokensStore: symbol;
13
- TxStore: symbol;
14
- UpdaterStore: symbol;
15
- EventMsgRequester: symbol;
16
- RNG: symbol;
17
- CommonCrypto: symbol;
18
- Notification: symbol;
19
- };