@injectivelabs/wallet-strategy 1.17.2-alpha.1 → 1.17.2-alpha.11

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.
@@ -2,6 +2,61 @@ let __injectivelabs_exceptions = require("@injectivelabs/exceptions");
2
2
  let __injectivelabs_wallet_core = require("@injectivelabs/wallet-core");
3
3
  let __injectivelabs_wallet_base = require("@injectivelabs/wallet-base");
4
4
 
5
+ //#region src/strategy/loaders.ts
6
+ let cachedEvmStrategy = null;
7
+ let cachedCosmosStrategy = null;
8
+ let cachedLedgerStrategies = null;
9
+ let cachedTrezorStrategies = null;
10
+ let cachedPrivateKeyStrategy = null;
11
+ let cachedTurnkeyStrategy = null;
12
+ let cachedMagicStrategy = null;
13
+ let cachedWalletConnectStrategy = null;
14
+ const loadEvmStrategy = async () => {
15
+ if (!cachedEvmStrategy) cachedEvmStrategy = (await import("@injectivelabs/wallet-evm")).EvmWalletStrategy;
16
+ return cachedEvmStrategy;
17
+ };
18
+ const loadCosmosStrategy = async () => {
19
+ if (!cachedCosmosStrategy) cachedCosmosStrategy = (await import("@injectivelabs/wallet-cosmos")).CosmosWalletStrategy;
20
+ return cachedCosmosStrategy;
21
+ };
22
+ const loadLedgerStrategies = async () => {
23
+ if (!cachedLedgerStrategies) {
24
+ const m = await import("@injectivelabs/wallet-ledger");
25
+ cachedLedgerStrategies = {
26
+ LedgerLiveStrategy: m.LedgerLiveStrategy,
27
+ LedgerLegacyStrategy: m.LedgerLegacyStrategy
28
+ };
29
+ }
30
+ return cachedLedgerStrategies;
31
+ };
32
+ const loadTrezorStrategies = async () => {
33
+ if (!cachedTrezorStrategies) {
34
+ const m = await import("@injectivelabs/wallet-trezor");
35
+ cachedTrezorStrategies = {
36
+ TrezorBip32Strategy: m.TrezorBip32Strategy,
37
+ TrezorBip44Strategy: m.TrezorBip44Strategy
38
+ };
39
+ }
40
+ return cachedTrezorStrategies;
41
+ };
42
+ const loadPrivateKeyStrategy = async () => {
43
+ if (!cachedPrivateKeyStrategy) cachedPrivateKeyStrategy = (await import("@injectivelabs/wallet-private-key")).PrivateKeyWalletStrategy;
44
+ return cachedPrivateKeyStrategy;
45
+ };
46
+ const loadTurnkeyStrategy = async () => {
47
+ if (!cachedTurnkeyStrategy) cachedTurnkeyStrategy = (await import("@injectivelabs/wallet-turnkey")).TurnkeyWalletStrategy;
48
+ return cachedTurnkeyStrategy;
49
+ };
50
+ const loadMagicStrategy = async () => {
51
+ if (!cachedMagicStrategy) cachedMagicStrategy = (await import("@injectivelabs/wallet-magic")).MagicStrategy;
52
+ return cachedMagicStrategy;
53
+ };
54
+ const loadWalletConnectStrategy = async () => {
55
+ if (!cachedWalletConnectStrategy) cachedWalletConnectStrategy = (await import("@injectivelabs/wallet-wallet-connect")).WalletConnectStrategy;
56
+ return cachedWalletConnectStrategy;
57
+ };
58
+
59
+ //#endregion
5
60
  //#region \0@oxc-project+runtime@0.98.0/helpers/typeof.js
6
61
  function _typeof(o) {
7
62
  "@babel/helpers - typeof";
@@ -45,21 +100,6 @@ function _defineProperty(e, r, t) {
45
100
 
46
101
  //#endregion
47
102
  //#region src/strategy/index.ts
48
- const loadEvmStrategy = () => import("@injectivelabs/wallet-evm").then((m) => m.EvmWalletStrategy);
49
- const loadCosmosStrategy = () => import("@injectivelabs/wallet-cosmos").then((m) => m.CosmosWalletStrategy);
50
- const loadCosmostationStrategy = () => import("@injectivelabs/wallet-cosmostation").then((m) => m.CosmostationWalletStrategy);
51
- const loadLedgerStrategies = () => import("@injectivelabs/wallet-ledger").then((m) => ({
52
- LedgerLiveStrategy: m.LedgerLiveStrategy,
53
- LedgerLegacyStrategy: m.LedgerLegacyStrategy
54
- }));
55
- const loadTrezorStrategies = () => import("@injectivelabs/wallet-trezor").then((m) => ({
56
- TrezorBip32Strategy: m.TrezorBip32Strategy,
57
- TrezorBip44Strategy: m.TrezorBip44Strategy
58
- }));
59
- const loadPrivateKeyStrategy = () => import("@injectivelabs/wallet-private-key").then((m) => m.PrivateKeyWalletStrategy);
60
- const loadTurnkeyStrategy = () => import("@injectivelabs/wallet-turnkey").then((m) => m.TurnkeyWalletStrategy);
61
- const loadMagicStrategy = () => import("@injectivelabs/wallet-magic").then((m) => m.MagicStrategy);
62
- const loadWalletConnectStrategy = () => import("@injectivelabs/wallet-wallet-connect").then((m) => m.WalletConnectStrategy);
63
103
  const ethereumWalletsDisabled = (args) => {
64
104
  const { evmOptions } = args;
65
105
  if (!evmOptions) return true;
@@ -67,7 +107,7 @@ const ethereumWalletsDisabled = (args) => {
67
107
  if (!evmChainId) return true;
68
108
  return false;
69
109
  };
70
- const createStrategy = async ({ args, wallet }) => {
110
+ const createStrategy = async ({ args, wallet, emitter }) => {
71
111
  /**
72
112
  * If we only want to use Cosmos Native Wallets
73
113
  * We are not creating strategies for Ethereum Native Wallets
@@ -79,7 +119,12 @@ const createStrategy = async ({ args, wallet }) => {
79
119
  const ethWalletArgs = {
80
120
  ...args,
81
121
  chainId: args.chainId,
82
- evmOptions: args.evmOptions
122
+ evmOptions: args.evmOptions,
123
+ emitter
124
+ };
125
+ const cosmosWalletArgs = {
126
+ ...args,
127
+ emitter
83
128
  };
84
129
  switch (wallet) {
85
130
  case __injectivelabs_wallet_base.Wallet.Metamask:
@@ -95,11 +140,11 @@ const createStrategy = async ({ args, wallet }) => {
95
140
  case __injectivelabs_wallet_base.Wallet.Keplr:
96
141
  case __injectivelabs_wallet_base.Wallet.Leap:
97
142
  case __injectivelabs_wallet_base.Wallet.Ninji:
98
- case __injectivelabs_wallet_base.Wallet.OWallet: return new (await (loadCosmosStrategy()))({
99
- ...args,
143
+ case __injectivelabs_wallet_base.Wallet.OWallet:
144
+ case __injectivelabs_wallet_base.Wallet.Cosmostation: return new (await (loadCosmosStrategy()))({
145
+ ...cosmosWalletArgs,
100
146
  wallet
101
147
  });
102
- case __injectivelabs_wallet_base.Wallet.Cosmostation: return new (await (loadCosmostationStrategy()))({ ...args });
103
148
  case __injectivelabs_wallet_base.Wallet.Ledger: {
104
149
  const { LedgerLiveStrategy } = await loadLedgerStrategies();
105
150
  return new LedgerLiveStrategy(ethWalletArgs);
@@ -124,7 +169,7 @@ const createStrategy = async ({ args, wallet }) => {
124
169
  case __injectivelabs_wallet_base.Wallet.Magic:
125
170
  var _args$metadata2, _args$metadata3;
126
171
  if (!((_args$metadata2 = args.metadata) === null || _args$metadata2 === void 0 || (_args$metadata2 = _args$metadata2.magic) === null || _args$metadata2 === void 0 ? void 0 : _args$metadata2.apiKey) || !((_args$metadata3 = args.metadata) === null || _args$metadata3 === void 0 || (_args$metadata3 = _args$metadata3.magic) === null || _args$metadata3 === void 0 ? void 0 : _args$metadata3.rpcEndpoint)) return;
127
- return new (await (loadMagicStrategy()))(args);
172
+ return new (await (loadMagicStrategy()))(cosmosWalletArgs);
128
173
  case __injectivelabs_wallet_base.Wallet.WalletConnect:
129
174
  var _args$metadata4;
130
175
  if (!((_args$metadata4 = args.metadata) === null || _args$metadata4 === void 0 || (_args$metadata4 = _args$metadata4.walletConnect) === null || _args$metadata4 === void 0 ? void 0 : _args$metadata4.projectId)) return;
@@ -149,8 +194,10 @@ var WalletStrategy = class extends __injectivelabs_wallet_core.BaseWalletStrateg
149
194
  * @throws GeneralException if the wallet strategy cannot be loaded
150
195
  */
151
196
  async setWallet(wallet) {
197
+ var _strategy$initStrateg;
152
198
  this.wallet = wallet;
153
- await this.loadStrategy(wallet);
199
+ const strategy = await this.loadStrategy(wallet);
200
+ await (strategy === null || strategy === void 0 || (_strategy$initStrateg = strategy.initStrategy) === null || _strategy$initStrateg === void 0 ? void 0 : _strategy$initStrateg.call(strategy));
154
201
  }
155
202
  /**
156
203
  * This method is used to set the metadata for the wallet strategies.
@@ -186,7 +233,8 @@ var WalletStrategy = class extends __injectivelabs_wallet_core.BaseWalletStrateg
186
233
  ...metadata
187
234
  }
188
235
  },
189
- wallet: walletEnum
236
+ wallet: walletEnum,
237
+ emitter: this.getEmitter()
190
238
  });
191
239
  continue;
192
240
  }
@@ -218,7 +266,8 @@ var WalletStrategy = class extends __injectivelabs_wallet_core.BaseWalletStrateg
218
266
  if (existingLoad) return existingLoad;
219
267
  const loadPromise = createStrategy({
220
268
  args: this.args,
221
- wallet
269
+ wallet,
270
+ emitter: this.getEmitter()
222
271
  });
223
272
  this.loadingStrategies.set(wallet, loadPromise);
224
273
  try {
package/dist/esm/index.js CHANGED
@@ -2,6 +2,61 @@ import { GeneralException } from "@injectivelabs/exceptions";
2
2
  import { BaseWalletStrategy } from "@injectivelabs/wallet-core";
3
3
  import { Wallet, isEvmWallet } from "@injectivelabs/wallet-base";
4
4
 
5
+ //#region src/strategy/loaders.ts
6
+ let cachedEvmStrategy = null;
7
+ let cachedCosmosStrategy = null;
8
+ let cachedLedgerStrategies = null;
9
+ let cachedTrezorStrategies = null;
10
+ let cachedPrivateKeyStrategy = null;
11
+ let cachedTurnkeyStrategy = null;
12
+ let cachedMagicStrategy = null;
13
+ let cachedWalletConnectStrategy = null;
14
+ const loadEvmStrategy = async () => {
15
+ if (!cachedEvmStrategy) cachedEvmStrategy = (await import("@injectivelabs/wallet-evm")).EvmWalletStrategy;
16
+ return cachedEvmStrategy;
17
+ };
18
+ const loadCosmosStrategy = async () => {
19
+ if (!cachedCosmosStrategy) cachedCosmosStrategy = (await import("@injectivelabs/wallet-cosmos")).CosmosWalletStrategy;
20
+ return cachedCosmosStrategy;
21
+ };
22
+ const loadLedgerStrategies = async () => {
23
+ if (!cachedLedgerStrategies) {
24
+ const m = await import("@injectivelabs/wallet-ledger");
25
+ cachedLedgerStrategies = {
26
+ LedgerLiveStrategy: m.LedgerLiveStrategy,
27
+ LedgerLegacyStrategy: m.LedgerLegacyStrategy
28
+ };
29
+ }
30
+ return cachedLedgerStrategies;
31
+ };
32
+ const loadTrezorStrategies = async () => {
33
+ if (!cachedTrezorStrategies) {
34
+ const m = await import("@injectivelabs/wallet-trezor");
35
+ cachedTrezorStrategies = {
36
+ TrezorBip32Strategy: m.TrezorBip32Strategy,
37
+ TrezorBip44Strategy: m.TrezorBip44Strategy
38
+ };
39
+ }
40
+ return cachedTrezorStrategies;
41
+ };
42
+ const loadPrivateKeyStrategy = async () => {
43
+ if (!cachedPrivateKeyStrategy) cachedPrivateKeyStrategy = (await import("@injectivelabs/wallet-private-key")).PrivateKeyWalletStrategy;
44
+ return cachedPrivateKeyStrategy;
45
+ };
46
+ const loadTurnkeyStrategy = async () => {
47
+ if (!cachedTurnkeyStrategy) cachedTurnkeyStrategy = (await import("@injectivelabs/wallet-turnkey")).TurnkeyWalletStrategy;
48
+ return cachedTurnkeyStrategy;
49
+ };
50
+ const loadMagicStrategy = async () => {
51
+ if (!cachedMagicStrategy) cachedMagicStrategy = (await import("@injectivelabs/wallet-magic")).MagicStrategy;
52
+ return cachedMagicStrategy;
53
+ };
54
+ const loadWalletConnectStrategy = async () => {
55
+ if (!cachedWalletConnectStrategy) cachedWalletConnectStrategy = (await import("@injectivelabs/wallet-wallet-connect")).WalletConnectStrategy;
56
+ return cachedWalletConnectStrategy;
57
+ };
58
+
59
+ //#endregion
5
60
  //#region \0@oxc-project+runtime@0.98.0/helpers/typeof.js
6
61
  function _typeof(o) {
7
62
  "@babel/helpers - typeof";
@@ -45,21 +100,6 @@ function _defineProperty(e, r, t) {
45
100
 
46
101
  //#endregion
47
102
  //#region src/strategy/index.ts
48
- const loadEvmStrategy = () => import("@injectivelabs/wallet-evm").then((m) => m.EvmWalletStrategy);
49
- const loadCosmosStrategy = () => import("@injectivelabs/wallet-cosmos").then((m) => m.CosmosWalletStrategy);
50
- const loadCosmostationStrategy = () => import("@injectivelabs/wallet-cosmostation").then((m) => m.CosmostationWalletStrategy);
51
- const loadLedgerStrategies = () => import("@injectivelabs/wallet-ledger").then((m) => ({
52
- LedgerLiveStrategy: m.LedgerLiveStrategy,
53
- LedgerLegacyStrategy: m.LedgerLegacyStrategy
54
- }));
55
- const loadTrezorStrategies = () => import("@injectivelabs/wallet-trezor").then((m) => ({
56
- TrezorBip32Strategy: m.TrezorBip32Strategy,
57
- TrezorBip44Strategy: m.TrezorBip44Strategy
58
- }));
59
- const loadPrivateKeyStrategy = () => import("@injectivelabs/wallet-private-key").then((m) => m.PrivateKeyWalletStrategy);
60
- const loadTurnkeyStrategy = () => import("@injectivelabs/wallet-turnkey").then((m) => m.TurnkeyWalletStrategy);
61
- const loadMagicStrategy = () => import("@injectivelabs/wallet-magic").then((m) => m.MagicStrategy);
62
- const loadWalletConnectStrategy = () => import("@injectivelabs/wallet-wallet-connect").then((m) => m.WalletConnectStrategy);
63
103
  const ethereumWalletsDisabled = (args) => {
64
104
  const { evmOptions } = args;
65
105
  if (!evmOptions) return true;
@@ -67,7 +107,7 @@ const ethereumWalletsDisabled = (args) => {
67
107
  if (!evmChainId) return true;
68
108
  return false;
69
109
  };
70
- const createStrategy = async ({ args, wallet }) => {
110
+ const createStrategy = async ({ args, wallet, emitter }) => {
71
111
  /**
72
112
  * If we only want to use Cosmos Native Wallets
73
113
  * We are not creating strategies for Ethereum Native Wallets
@@ -79,7 +119,12 @@ const createStrategy = async ({ args, wallet }) => {
79
119
  const ethWalletArgs = {
80
120
  ...args,
81
121
  chainId: args.chainId,
82
- evmOptions: args.evmOptions
122
+ evmOptions: args.evmOptions,
123
+ emitter
124
+ };
125
+ const cosmosWalletArgs = {
126
+ ...args,
127
+ emitter
83
128
  };
84
129
  switch (wallet) {
85
130
  case Wallet.Metamask:
@@ -95,11 +140,11 @@ const createStrategy = async ({ args, wallet }) => {
95
140
  case Wallet.Keplr:
96
141
  case Wallet.Leap:
97
142
  case Wallet.Ninji:
98
- case Wallet.OWallet: return new (await (loadCosmosStrategy()))({
99
- ...args,
143
+ case Wallet.OWallet:
144
+ case Wallet.Cosmostation: return new (await (loadCosmosStrategy()))({
145
+ ...cosmosWalletArgs,
100
146
  wallet
101
147
  });
102
- case Wallet.Cosmostation: return new (await (loadCosmostationStrategy()))({ ...args });
103
148
  case Wallet.Ledger: {
104
149
  const { LedgerLiveStrategy } = await loadLedgerStrategies();
105
150
  return new LedgerLiveStrategy(ethWalletArgs);
@@ -124,7 +169,7 @@ const createStrategy = async ({ args, wallet }) => {
124
169
  case Wallet.Magic:
125
170
  var _args$metadata2, _args$metadata3;
126
171
  if (!((_args$metadata2 = args.metadata) === null || _args$metadata2 === void 0 || (_args$metadata2 = _args$metadata2.magic) === null || _args$metadata2 === void 0 ? void 0 : _args$metadata2.apiKey) || !((_args$metadata3 = args.metadata) === null || _args$metadata3 === void 0 || (_args$metadata3 = _args$metadata3.magic) === null || _args$metadata3 === void 0 ? void 0 : _args$metadata3.rpcEndpoint)) return;
127
- return new (await (loadMagicStrategy()))(args);
172
+ return new (await (loadMagicStrategy()))(cosmosWalletArgs);
128
173
  case Wallet.WalletConnect:
129
174
  var _args$metadata4;
130
175
  if (!((_args$metadata4 = args.metadata) === null || _args$metadata4 === void 0 || (_args$metadata4 = _args$metadata4.walletConnect) === null || _args$metadata4 === void 0 ? void 0 : _args$metadata4.projectId)) return;
@@ -149,8 +194,10 @@ var WalletStrategy = class extends BaseWalletStrategy {
149
194
  * @throws GeneralException if the wallet strategy cannot be loaded
150
195
  */
151
196
  async setWallet(wallet) {
197
+ var _strategy$initStrateg;
152
198
  this.wallet = wallet;
153
- await this.loadStrategy(wallet);
199
+ const strategy = await this.loadStrategy(wallet);
200
+ await (strategy === null || strategy === void 0 || (_strategy$initStrateg = strategy.initStrategy) === null || _strategy$initStrateg === void 0 ? void 0 : _strategy$initStrateg.call(strategy));
154
201
  }
155
202
  /**
156
203
  * This method is used to set the metadata for the wallet strategies.
@@ -186,7 +233,8 @@ var WalletStrategy = class extends BaseWalletStrategy {
186
233
  ...metadata
187
234
  }
188
235
  },
189
- wallet: walletEnum
236
+ wallet: walletEnum,
237
+ emitter: this.getEmitter()
190
238
  });
191
239
  continue;
192
240
  }
@@ -218,7 +266,8 @@ var WalletStrategy = class extends BaseWalletStrategy {
218
266
  if (existingLoad) return existingLoad;
219
267
  const loadPromise = createStrategy({
220
268
  args: this.args,
221
- wallet
269
+ wallet,
270
+ emitter: this.getEmitter()
222
271
  });
223
272
  this.loadingStrategies.set(wallet, loadPromise);
224
273
  try {
package/package.json CHANGED
@@ -1,12 +1,16 @@
1
1
  {
2
2
  "name": "@injectivelabs/wallet-strategy",
3
- "version": "1.17.2-alpha.1",
3
+ "version": "1.17.2-alpha.11",
4
4
  "description": "Wallet strategy with instantiated wallets",
5
5
  "license": "Apache-2.0",
6
6
  "author": {
7
7
  "name": "InjectiveLabs",
8
8
  "email": "admin@injectivelabs.org"
9
9
  },
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "https://github.com/InjectiveLabs/injective-ts"
13
+ },
10
14
  "type": "module",
11
15
  "sideEffects": false,
12
16
  "exports": {
@@ -38,18 +42,17 @@
38
42
  "dist"
39
43
  ],
40
44
  "dependencies": {
41
- "@injectivelabs/wallet-core": "1.17.2-alpha.1",
42
- "@injectivelabs/wallet-base": "1.17.2-alpha.1",
43
- "@injectivelabs/wallet-cosmostation": "1.17.2-alpha.1",
44
- "@injectivelabs/exceptions": "1.17.2-alpha.1",
45
- "@injectivelabs/wallet-evm": "1.17.2-alpha.1",
46
- "@injectivelabs/wallet-cosmos": "1.17.2-alpha.1",
47
- "@injectivelabs/wallet-ledger": "1.17.2-alpha.1",
48
- "@injectivelabs/wallet-magic": "1.17.2-alpha.1",
49
- "@injectivelabs/wallet-private-key": "1.17.2-alpha.1",
50
- "@injectivelabs/wallet-wallet-connect": "1.17.2-alpha.1",
51
- "@injectivelabs/wallet-turnkey": "1.17.2-alpha.1",
52
- "@injectivelabs/wallet-trezor": "1.17.2-alpha.1"
45
+ "@injectivelabs/wallet-base": "1.17.2-alpha.11",
46
+ "@injectivelabs/wallet-core": "1.17.2-alpha.11",
47
+ "@injectivelabs/wallet-cosmos": "1.17.2-alpha.11",
48
+ "@injectivelabs/wallet-evm": "1.17.2-alpha.11",
49
+ "@injectivelabs/wallet-ledger": "1.17.2-alpha.11",
50
+ "@injectivelabs/exceptions": "1.17.2-alpha.11",
51
+ "@injectivelabs/wallet-magic": "1.17.2-alpha.11",
52
+ "@injectivelabs/wallet-trezor": "1.17.2-alpha.11",
53
+ "@injectivelabs/wallet-private-key": "1.17.2-alpha.11",
54
+ "@injectivelabs/wallet-turnkey": "1.17.2-alpha.11",
55
+ "@injectivelabs/wallet-wallet-connect": "1.17.2-alpha.11"
53
56
  },
54
57
  "publishConfig": {
55
58
  "access": "public"