@injectivelabs/wallet-base 1.20.16 → 1.20.17

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/dist/esm/index.js CHANGED
@@ -1,4 +1,3 @@
1
- import { _ as WalletConnectStrategyEventType, a as isEip712V2OnlyWallet, c as TurnkeyProvider, d as MagicProvider, f as Wallet, g as StrategyEventType, h as WalletEventListener, i as isCosmosWallet, l as BroadcastMode, m as WalletDeviceType, n as isCosmosAminoOnlyWallet, o as isEvmBrowserWallet, p as WalletAction, r as isCosmosBrowserWallet, s as isEvmWallet, t as BaseConcreteStrategy, u as EvmWalletProviderErrorCode, v as WalletStrategyEmitterEventType } from "./base-CzyhamIP.js";
2
1
  import { getStdFee, toBigNumber } from "@injectivelabs/utils";
3
2
  import * as viemChains from "viem/chains";
4
3
  import { injective } from "viem/chains";
@@ -7,6 +6,106 @@ import { createPublicClient, createWalletClient, custom, extractChain, http } fr
7
6
  import { CosmosTxV1Beta1TxPb } from "@injectivelabs/sdk-ts/proto/cosmos-tx";
8
7
  import { getEthereumAddress, getInjectiveAddress } from "@injectivelabs/sdk-ts/utils";
9
8
 
9
+ //#region src/types/events.ts
10
+ const StrategyEventType = {
11
+ ConnectionEnd: "connection-end",
12
+ ConnectionStart: "connection-start",
13
+ WalletSigningEnd: "wallet-signing-end",
14
+ WalletSigningStart: "wallet-signing-start"
15
+ };
16
+ const WalletConnectStrategyEventType = { WalletConnectSigningWithTxTimeout: "signing-with-tx-timeout" };
17
+ const WalletStrategyEmitterEventType = {
18
+ TransactionFail: "transaction-fail",
19
+ TransactionSigned: "transaction-signed",
20
+ TransactionSignStart: "transaction-sign-start",
21
+ TransactionBroadcastEnd: "transaction-broadcast-end",
22
+ TransactionBroadcastStart: "transaction-broadcast-start",
23
+ TransactionBroadcastSynced: "transaction-broadcast-synced",
24
+ TransactionPreparationEnd: "transaction-preparation-end",
25
+ TransactionPreparationStart: "transaction-preparation-start",
26
+ WalletStrategyDisconnect: "wallet-strategy-disconnect"
27
+ };
28
+
29
+ //#endregion
30
+ //#region src/types/enums.ts
31
+ const BroadcastMode = {
32
+ Block: "block",
33
+ Sync: "sync",
34
+ Async: "async"
35
+ };
36
+ const Wallet = {
37
+ Leap: "leap",
38
+ Keplr: "keplr",
39
+ Ninji: "ninji",
40
+ Magic: "magic",
41
+ Rabby: "rabby",
42
+ Ledger: "ledger",
43
+ BitGet: "BitGet",
44
+ OWallet: "owallet",
45
+ Phantom: "phantom",
46
+ Rainbow: "rainbow",
47
+ Turnkey: "turnkey",
48
+ Metamask: "metamask",
49
+ KeplrEvm: "keplr-evm",
50
+ OkxWallet: "okx-wallet",
51
+ PrivateKey: "private-key",
52
+ TrustWallet: "trust-wallet",
53
+ TrezorBip32: "trezor-bip32",
54
+ TrezorBip44: "trezor-bip44",
55
+ Cosmostation: "cosmostation",
56
+ LedgerCosmos: "ledger-cosmos",
57
+ LedgerLegacy: "ledger-legacy",
58
+ WalletConnect: "wallet-connect",
59
+ CosmostationEth: "cosmostation-eth",
60
+ PrivateKeyCosmos: "private-key-cosmos"
61
+ };
62
+ const MagicProvider = {
63
+ Email: "email",
64
+ Apple: "apple",
65
+ Github: "github",
66
+ Google: "google",
67
+ Discord: "discord",
68
+ Twitter: "twitter",
69
+ Facebook: "facebook"
70
+ };
71
+ const WalletDeviceType = {
72
+ Mobile: "mobile",
73
+ Other: "other",
74
+ Browser: "browser",
75
+ Hardware: "hardware"
76
+ };
77
+ const WalletEventListener = {
78
+ AccountChange: "account-change",
79
+ ChainIdChange: "chain-id-change"
80
+ };
81
+ const EvmWalletProviderErrorCode = {
82
+ InternalError: -32603,
83
+ UserRejectedRequest: 4001,
84
+ UnrecognizedChain: 4902
85
+ };
86
+ const WalletAction = {
87
+ GetChainId: "get-chain-id",
88
+ GetAccounts: "get-accounts",
89
+ GetNetworkId: "get-network-id",
90
+ SignArbitrary: "sign-arbitrary",
91
+ SignTransaction: "sign-transaction",
92
+ SendTransaction: "send-transaction",
93
+ SendEvmTransaction: "send-evm-transaction",
94
+ SignEvmTransaction: "sign-evm-transaction",
95
+ GetEvmTransactionReceipt: "get-evm-transaction-receipt"
96
+ };
97
+
98
+ //#endregion
99
+ //#region src/types/strategy.ts
100
+ const TurnkeyProvider = {
101
+ Sms: "sms",
102
+ Apple: "apple",
103
+ Email: "email",
104
+ Google: "google",
105
+ Twitter: "twitter"
106
+ };
107
+
108
+ //#endregion
10
109
  //#region src/utils/tx.ts
11
110
  const createEip712StdSignDoc = ({ memo, chainId, accountNumber, timeoutHeight, sequence, gas, msgs }) => ({
12
111
  chain_id: chainId,
@@ -87,6 +186,53 @@ const getViemPublicClientFromEip1193Provider = (chainId, provider) => {
87
186
  });
88
187
  };
89
188
 
189
+ //#endregion
190
+ //#region src/utils/wallet.ts
191
+ const isEvmWallet = (wallet) => [
192
+ Wallet.Magic,
193
+ Wallet.Rabby,
194
+ Wallet.BitGet,
195
+ Wallet.Ledger,
196
+ Wallet.Phantom,
197
+ Wallet.Rainbow,
198
+ Wallet.Turnkey,
199
+ Wallet.Metamask,
200
+ Wallet.KeplrEvm,
201
+ Wallet.OkxWallet,
202
+ Wallet.PrivateKey,
203
+ Wallet.TrezorBip32,
204
+ Wallet.TrezorBip44,
205
+ Wallet.TrustWallet,
206
+ Wallet.LedgerLegacy,
207
+ Wallet.WalletConnect,
208
+ Wallet.CosmostationEth
209
+ ].includes(wallet);
210
+ const isCosmosWallet = (wallet) => !isEvmWallet(wallet);
211
+ const isEvmBrowserWallet = (wallet) => [
212
+ Wallet.Rabby,
213
+ Wallet.BitGet,
214
+ Wallet.Phantom,
215
+ Wallet.Rainbow,
216
+ Wallet.Metamask,
217
+ Wallet.KeplrEvm,
218
+ Wallet.OkxWallet,
219
+ Wallet.TrustWallet
220
+ ].includes(wallet);
221
+ const isCosmosBrowserWallet = (wallet) => [
222
+ Wallet.Leap,
223
+ Wallet.Keplr,
224
+ Wallet.Ninji,
225
+ Wallet.OWallet,
226
+ Wallet.Cosmostation
227
+ ].includes(wallet);
228
+ const isEip712V2OnlyWallet = (wallet) => [
229
+ Wallet.Magic,
230
+ Wallet.Phantom,
231
+ Wallet.Metamask,
232
+ Wallet.WalletConnect
233
+ ].includes(wallet);
234
+ const isCosmosAminoOnlyWallet = (wallet) => [Wallet.LedgerCosmos].includes(wallet);
235
+
90
236
  //#endregion
91
237
  //#region src/utils/cosmos.ts
92
238
  const createCosmosSignDocFromSignDoc = (signDoc) => {
@@ -121,5 +267,74 @@ const DEFAULT_BASE_DERIVATION_PATH = "m/44'/60'";
121
267
  const DEFAULT_NUM_ADDRESSES_TO_FETCH = 5;
122
268
  const DEFAULT_ADDRESS_SEARCH_LIMIT = 100;
123
269
 
270
+ //#endregion
271
+ //#region \0@oxc-project+runtime@0.99.0/helpers/typeof.js
272
+ function _typeof(o) {
273
+ "@babel/helpers - typeof";
274
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o$1) {
275
+ return typeof o$1;
276
+ } : function(o$1) {
277
+ return o$1 && "function" == typeof Symbol && o$1.constructor === Symbol && o$1 !== Symbol.prototype ? "symbol" : typeof o$1;
278
+ }, _typeof(o);
279
+ }
280
+
281
+ //#endregion
282
+ //#region \0@oxc-project+runtime@0.99.0/helpers/toPrimitive.js
283
+ function toPrimitive(t, r) {
284
+ if ("object" != _typeof(t) || !t) return t;
285
+ var e = t[Symbol.toPrimitive];
286
+ if (void 0 !== e) {
287
+ var i = e.call(t, r || "default");
288
+ if ("object" != _typeof(i)) return i;
289
+ throw new TypeError("@@toPrimitive must return a primitive value.");
290
+ }
291
+ return ("string" === r ? String : Number)(t);
292
+ }
293
+
294
+ //#endregion
295
+ //#region \0@oxc-project+runtime@0.99.0/helpers/toPropertyKey.js
296
+ function toPropertyKey(t) {
297
+ var i = toPrimitive(t, "string");
298
+ return "symbol" == _typeof(i) ? i : i + "";
299
+ }
300
+
301
+ //#endregion
302
+ //#region \0@oxc-project+runtime@0.99.0/helpers/defineProperty.js
303
+ function _defineProperty(e, r, t) {
304
+ return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
305
+ value: t,
306
+ enumerable: !0,
307
+ configurable: !0,
308
+ writable: !0
309
+ }) : e[r] = t, e;
310
+ }
311
+
312
+ //#endregion
313
+ //#region src/base.ts
314
+ var BaseConcreteStrategy = class {
315
+ constructor(args) {
316
+ _defineProperty(this, "chainId", void 0);
317
+ _defineProperty(this, "evmChainId", void 0);
318
+ _defineProperty(this, "listeners", {});
319
+ _defineProperty(this, "metadata", void 0);
320
+ _defineProperty(this, "emitter", void 0);
321
+ this.evmChainId = "evmOptions" in args && args.evmOptions ? args.evmOptions.evmChainId : void 0;
322
+ this.chainId = args.chainId;
323
+ this.metadata = args.metadata;
324
+ this.emitter = args.emitter;
325
+ }
326
+ setMetadata(metadata) {
327
+ this.metadata = metadata;
328
+ }
329
+ /**
330
+ * Emit an event from this strategy.
331
+ * If emitter was provided from parent, events go directly to parent.
332
+ */
333
+ emit(event, data) {
334
+ var _this$emitter;
335
+ (_this$emitter = this.emitter) === null || _this$emitter === void 0 || _this$emitter.emit(event, data);
336
+ }
337
+ };
338
+
124
339
  //#endregion
125
340
  export { BaseConcreteStrategy, BroadcastMode, DEFAULT_ADDRESS_SEARCH_LIMIT, DEFAULT_BASE_DERIVATION_PATH, DEFAULT_NUM_ADDRESSES_TO_FETCH, EvmWalletProviderErrorCode, GWEI_IN_WEI, MagicProvider, StrategyEventType, TIP_IN_GWEI, TurnkeyProvider, Wallet, WalletAction, WalletConnectStrategyEventType, WalletDeviceType, WalletEventListener, WalletStrategyEmitterEventType, createCosmosSignDocFromSignDoc, createEip712StdSignDoc, getEthereumSignerAddress, getEvmChainConfig, getInjectiveSignerAddress, getViemPublicClient, getViemPublicClientFromEip1193Provider, getViemWalletClient, isCosmosAminoOnlyWallet, isCosmosBrowserWallet, isCosmosWallet, isEip712V2OnlyWallet, isEvmBrowserWallet, isEvmWallet };
@@ -1,4 +1,4 @@
1
- import { C as onAccountChangeCallback, S as WalletStrategyEvmOptions, _ as TurnkeySession, a as ConcreteWalletStrategy, b as WalletStrategy, c as Eip1193Provider, d as SendTransactionOptions, i as ConcreteStrategiesArg, l as MagicMetadata, m as TurnkeyMetadata, n as ConcreteCosmosWalletStrategyArgs, o as ConcreteWalletStrategyArgs, p as StrategyEmitter, r as ConcreteEvmWalletStrategyArgs, s as CosmosWalletAbstraction, t as ConcreteCosmosWalletStrategy, u as PrivateKeyMetadata, v as WalletConnectMetadata, w as onChainIdChangeCallback, x as WalletStrategyArguments, y as WalletMetadata } from "./strategy-C_dU586T.js";
1
+ import { C as onAccountChangeCallback, S as WalletStrategyEvmOptions, _ as TurnkeySession, a as ConcreteWalletStrategy, b as WalletStrategy, c as Eip1193Provider, d as SendTransactionOptions, i as ConcreteStrategiesArg, l as MagicMetadata, m as TurnkeyMetadata, n as ConcreteCosmosWalletStrategyArgs, o as ConcreteWalletStrategyArgs, p as StrategyEmitter, r as ConcreteEvmWalletStrategyArgs, s as CosmosWalletAbstraction, t as ConcreteCosmosWalletStrategy, u as PrivateKeyMetadata, v as WalletConnectMetadata, w as onChainIdChangeCallback, x as WalletStrategyArguments, y as WalletMetadata } from "./strategy-BGAy7FJw.js";
2
2
 
3
3
  //#region src/runtime-light.d.ts
4
4
  declare const BroadcastMode: {
@@ -97,16 +97,17 @@ declare const EvmWalletProviderErrorCode: {
97
97
  };
98
98
  type EvmWalletProviderErrorCode = (typeof EvmWalletProviderErrorCode)[keyof typeof EvmWalletProviderErrorCode];
99
99
  declare const WalletAction: {
100
- GetChainId: "get-chain-id";
101
- GetAccounts: "get-accounts";
102
- GetNetworkId: "get-network-id";
103
- SignArbitrary: "sign-arbitrary";
104
- SignTransaction: "sign-transaction";
105
- SendTransaction: "send-transaction";
106
- SendEvmTransaction: "send-evm-transaction";
107
- SignEvmTransaction: "sign-evm-transaction";
108
- GetEvmTransactionReceipt: "get-evm-transaction-receipt";
100
+ readonly GetChainId: "get-chain-id";
101
+ readonly GetAccounts: "get-accounts";
102
+ readonly GetNetworkId: "get-network-id";
103
+ readonly SignArbitrary: "sign-arbitrary";
104
+ readonly SignTransaction: "sign-transaction";
105
+ readonly SendTransaction: "send-transaction";
106
+ readonly SendEvmTransaction: "send-evm-transaction";
107
+ readonly SignEvmTransaction: "sign-evm-transaction";
108
+ readonly GetEvmTransactionReceipt: "get-evm-transaction-receipt";
109
109
  };
110
+ type WalletAction = (typeof WalletAction)[keyof typeof WalletAction];
110
111
  //#endregion
111
112
  //#region src/types/strategy.d.ts
112
113
  interface StrategyEmitter {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@injectivelabs/wallet-base",
3
- "version": "1.20.16",
3
+ "version": "1.20.17",
4
4
  "description": "Base wallet strategy for use with @injectivelabs/wallet-core.",
5
5
  "license": "Apache-2.0",
6
6
  "author": {
@@ -36,22 +36,22 @@
36
36
  },
37
37
  "./light": {
38
38
  "react-native": {
39
- "import": "./dist/esm/light.js",
40
- "require": "./dist/cjs/light.cjs",
41
- "types": "./dist/cjs/light.d.cts",
42
- "default": "./dist/cjs/light.cjs"
39
+ "import": "./dist/esm/runtime-light.js",
40
+ "require": "./dist/cjs/runtime-light.cjs",
41
+ "types": "./dist/cjs/runtime-light.d.cts",
42
+ "default": "./dist/cjs/runtime-light.cjs"
43
43
  },
44
44
  "require": {
45
- "types": "./dist/cjs/light.d.cts",
46
- "default": "./dist/cjs/light.cjs"
45
+ "types": "./dist/cjs/runtime-light.d.cts",
46
+ "default": "./dist/cjs/runtime-light.cjs"
47
47
  },
48
48
  "import": {
49
- "types": "./dist/esm/light.d.ts",
50
- "default": "./dist/esm/light.js"
49
+ "types": "./dist/esm/runtime-light.d.ts",
50
+ "default": "./dist/esm/runtime-light.js"
51
51
  },
52
52
  "default": {
53
- "types": "./dist/cjs/light.d.cts",
54
- "default": "./dist/cjs/light.cjs"
53
+ "types": "./dist/cjs/runtime-light.d.cts",
54
+ "default": "./dist/cjs/runtime-light.cjs"
55
55
  }
56
56
  },
57
57
  "./runtime-light": {
@@ -84,9 +84,9 @@
84
84
  "dependencies": {
85
85
  "eip1193-provider": "^1.0.1",
86
86
  "viem": "^2.41.2",
87
- "@injectivelabs/exceptions": "1.20.16",
88
- "@injectivelabs/sdk-ts": "1.20.16",
89
- "@injectivelabs/ts-types": "1.20.16"
87
+ "@injectivelabs/exceptions": "1.20.17",
88
+ "@injectivelabs/sdk-ts": "1.20.17",
89
+ "@injectivelabs/ts-types": "1.20.17"
90
90
  },
91
91
  "publishConfig": {
92
92
  "access": "public"
@@ -1,79 +0,0 @@
1
- import { F as WalletStrategyEmitterEventType, O as Wallet, j as WalletEventListener, n as ConcreteCosmosWalletStrategyArgs, o as ConcreteWalletStrategyArgs, p as StrategyEmitter, r as ConcreteEvmWalletStrategyArgs, y as WalletMetadata } from "./strategy-4vrShg5z.cjs";
2
- import { ChainId, CosmosChainId, EvmChainId } from "@injectivelabs/ts-types";
3
- import { EIP1193Provider } from "eip1193-provider";
4
-
5
- //#region src/types/provider.d.ts
6
- interface BrowserEip1993Provider extends EIP1193Provider {
7
- removeAllListeners(): void;
8
- providers?: BrowserEip1993Provider[];
9
- isTrust: boolean;
10
- isKeplr: boolean;
11
- isRabby: boolean;
12
- isRainbow: boolean;
13
- isPhantom: boolean;
14
- isBitGet?: boolean;
15
- isBitKeep?: boolean;
16
- isMetaMask: boolean;
17
- isOkxWallet: boolean;
18
- isTrustWallet: boolean;
19
- }
20
- interface WindowWithEip1193Provider extends Omit<Window, 'ethereum' | 'keplr'> {
21
- rainbow: BrowserEip1993Provider;
22
- rabby: BrowserEip1993Provider;
23
- ethereum: BrowserEip1993Provider;
24
- okxwallet: BrowserEip1993Provider;
25
- providers: BrowserEip1993Provider[];
26
- trustWallet?: BrowserEip1993Provider;
27
- bitkeep: {
28
- ethereum: BrowserEip1993Provider;
29
- };
30
- phantom?: {
31
- ethereum?: BrowserEip1993Provider;
32
- };
33
- keplr?: {
34
- ethereum?: BrowserEip1993Provider;
35
- };
36
- }
37
- interface EIP6963ProviderInfo {
38
- rdns: string;
39
- uuid: string;
40
- name: string;
41
- icon: string;
42
- }
43
- interface EIP6963ProviderDetail {
44
- info: EIP6963ProviderInfo;
45
- provider: BrowserEip1993Provider;
46
- }
47
- type EIP6963AnnounceProviderEvent = {
48
- detail: EIP6963ProviderDetail;
49
- };
50
- //#endregion
51
- //#region src/utils/wallet.d.ts
52
- declare const isEvmWallet: (wallet: Wallet) => boolean;
53
- declare const isCosmosWallet: (wallet: Wallet) => boolean;
54
- declare const isEvmBrowserWallet: (wallet: Wallet) => boolean;
55
- declare const isCosmosBrowserWallet: (wallet: Wallet) => boolean;
56
- declare const isEip712V2OnlyWallet: (wallet: Wallet) => boolean;
57
- declare const isCosmosAminoOnlyWallet: (wallet: Wallet) => boolean;
58
- //#endregion
59
- //#region src/base.d.ts
60
- declare abstract class BaseConcreteStrategy {
61
- protected chainId: ChainId | CosmosChainId;
62
- protected evmChainId?: EvmChainId;
63
- protected listeners: Partial<Record<WalletEventListener, any>>;
64
- metadata?: WalletMetadata;
65
- /**
66
- * Optional emitter passed from parent WalletStrategy.
67
- * When provided, strategies emit events directly on the parent's emitter.
68
- */
69
- protected emitter?: StrategyEmitter;
70
- constructor(args: ConcreteWalletStrategyArgs | ConcreteEvmWalletStrategyArgs | ConcreteCosmosWalletStrategyArgs);
71
- setMetadata(metadata?: WalletMetadata): void;
72
- /**
73
- * Emit an event from this strategy.
74
- * If emitter was provided from parent, events go directly to parent.
75
- */
76
- protected emit(event: WalletStrategyEmitterEventType, data?: Record<string, any>): void;
77
- }
78
- //#endregion
79
- export { isEip712V2OnlyWallet as a, BrowserEip1993Provider as c, EIP6963ProviderInfo as d, WindowWithEip1193Provider as f, isCosmosWallet as i, EIP6963AnnounceProviderEvent as l, isCosmosAminoOnlyWallet as n, isEvmBrowserWallet as o, isCosmosBrowserWallet as r, isEvmWallet as s, BaseConcreteStrategy as t, EIP6963ProviderDetail as u };