@injectivelabs/wallet-base 1.17.2-alpha.4 → 1.17.2-alpha.5
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/cjs/index.cjs +34 -1
- package/dist/cjs/index.d.cts +45 -1
- package/dist/esm/index.d.ts +45 -1
- package/dist/esm/index.js +32 -2
- package/package.json +21 -16
package/dist/cjs/index.cjs
CHANGED
|
@@ -34,6 +34,26 @@ let viem = require("viem");
|
|
|
34
34
|
let __injectivelabs_sdk_ts = require("@injectivelabs/sdk-ts");
|
|
35
35
|
let __injectivelabs_sdk_ts_utils = require("@injectivelabs/sdk-ts/utils");
|
|
36
36
|
|
|
37
|
+
//#region src/types/events.ts
|
|
38
|
+
const StrategyEventType = {
|
|
39
|
+
ConnectionEnd: "connection-end",
|
|
40
|
+
ConnectionStart: "connection-start",
|
|
41
|
+
WalletSigningEnd: "wallet-signing-end",
|
|
42
|
+
WalletSigningStart: "wallet-signing-start"
|
|
43
|
+
};
|
|
44
|
+
const WalletConnectStrategyEventType = { WalletConnectSigningWithTxTimeout: "signing-with-tx-timeout" };
|
|
45
|
+
const WalletStrategyEmitterEventType = {
|
|
46
|
+
TransactionFail: "transaction-fail",
|
|
47
|
+
TransactionSigned: "transaction-signed",
|
|
48
|
+
TransactionSignStart: "transaction-sign-start",
|
|
49
|
+
TransactionBroadcastEnd: "transaction-broadcast-end",
|
|
50
|
+
TransactionBroadcastStart: "transaction-broadcast-start",
|
|
51
|
+
TransactionPreparationEnd: "transaction-preparation-end",
|
|
52
|
+
TransactionPreparationStart: "transaction-preparation-start",
|
|
53
|
+
WalletStrategyDisconnect: "wallet-strategy-disconnect"
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
//#endregion
|
|
37
57
|
//#region src/types/enums.ts
|
|
38
58
|
const BroadcastMode = {
|
|
39
59
|
Block: "block",
|
|
@@ -131,7 +151,7 @@ const getEvmChainConfig = (chainId) => {
|
|
|
131
151
|
};
|
|
132
152
|
const getViemPublicClient = (chainId, rpcUrl) => {
|
|
133
153
|
const chain = getEvmChainConfig(chainId);
|
|
134
|
-
if ([__injectivelabs_ts_types.EvmChainId.Mainnet, __injectivelabs_ts_types.EvmChainId.Sepolia].includes(chainId) && rpcUrl && !rpcUrl.includes("
|
|
154
|
+
if ([__injectivelabs_ts_types.EvmChainId.Mainnet, __injectivelabs_ts_types.EvmChainId.Sepolia].includes(chainId) && rpcUrl && !rpcUrl.includes("alchemy")) throw new Error(`An Alchemy RPC URL must be provided for EvmChainId ${chainId}`);
|
|
135
155
|
return (0, viem.createPublicClient)({
|
|
136
156
|
chain: rpcUrl ? {
|
|
137
157
|
...chain,
|
|
@@ -295,13 +315,23 @@ var BaseConcreteStrategy = class {
|
|
|
295
315
|
_defineProperty(this, "evmChainId", void 0);
|
|
296
316
|
_defineProperty(this, "listeners", {});
|
|
297
317
|
_defineProperty(this, "metadata", void 0);
|
|
318
|
+
_defineProperty(this, "emitter", void 0);
|
|
298
319
|
this.evmChainId = "evmOptions" in args && args.evmOptions ? args.evmOptions.evmChainId : void 0;
|
|
299
320
|
this.chainId = args.chainId;
|
|
300
321
|
this.metadata = args.metadata;
|
|
322
|
+
this.emitter = args.emitter;
|
|
301
323
|
}
|
|
302
324
|
setMetadata(metadata) {
|
|
303
325
|
this.metadata = metadata;
|
|
304
326
|
}
|
|
327
|
+
/**
|
|
328
|
+
* Emit an event from this strategy.
|
|
329
|
+
* If emitter was provided from parent, events go directly to parent.
|
|
330
|
+
*/
|
|
331
|
+
emit(event, data) {
|
|
332
|
+
var _this$emitter;
|
|
333
|
+
(_this$emitter = this.emitter) === null || _this$emitter === void 0 || _this$emitter.emit(event, data);
|
|
334
|
+
}
|
|
305
335
|
};
|
|
306
336
|
|
|
307
337
|
//#endregion
|
|
@@ -312,12 +342,15 @@ exports.DEFAULT_BASE_DERIVATION_PATH = DEFAULT_BASE_DERIVATION_PATH;
|
|
|
312
342
|
exports.DEFAULT_NUM_ADDRESSES_TO_FETCH = DEFAULT_NUM_ADDRESSES_TO_FETCH;
|
|
313
343
|
exports.GWEI_IN_WEI = GWEI_IN_WEI;
|
|
314
344
|
exports.MagicProvider = MagicProvider;
|
|
345
|
+
exports.StrategyEventType = StrategyEventType;
|
|
315
346
|
exports.TIP_IN_GWEI = TIP_IN_GWEI;
|
|
316
347
|
exports.TurnkeyProvider = TurnkeyProvider;
|
|
317
348
|
exports.Wallet = Wallet;
|
|
318
349
|
exports.WalletAction = WalletAction;
|
|
350
|
+
exports.WalletConnectStrategyEventType = WalletConnectStrategyEventType;
|
|
319
351
|
exports.WalletDeviceType = WalletDeviceType;
|
|
320
352
|
exports.WalletEventListener = WalletEventListener;
|
|
353
|
+
exports.WalletStrategyEmitterEventType = WalletStrategyEmitterEventType;
|
|
321
354
|
exports.createCosmosSignDocFromSignDoc = createCosmosSignDocFromSignDoc;
|
|
322
355
|
exports.createEip712StdSignDoc = createEip712StdSignDoc;
|
|
323
356
|
exports.getEthereumSignerAddress = getEthereumSignerAddress;
|
package/dist/cjs/index.d.cts
CHANGED
|
@@ -8,6 +8,35 @@ import { Msgs } from "@injectivelabs/sdk-ts/core/modules";
|
|
|
8
8
|
import { Account, Chain, LocalAccount, PublicClient, WalletClient } from "viem";
|
|
9
9
|
import { CosmosTxV1Beta1TxPb } from "@injectivelabs/sdk-ts";
|
|
10
10
|
|
|
11
|
+
//#region src/types/events.d.ts
|
|
12
|
+
declare const StrategyEventType: {
|
|
13
|
+
readonly ConnectionEnd: "connection-end";
|
|
14
|
+
readonly ConnectionStart: "connection-start";
|
|
15
|
+
readonly WalletSigningEnd: "wallet-signing-end";
|
|
16
|
+
readonly WalletSigningStart: "wallet-signing-start";
|
|
17
|
+
};
|
|
18
|
+
declare const WalletConnectStrategyEventType: {
|
|
19
|
+
readonly WalletConnectSigningWithTxTimeout: "signing-with-tx-timeout";
|
|
20
|
+
};
|
|
21
|
+
declare const WalletStrategyEmitterEventType: {
|
|
22
|
+
readonly TransactionFail: "transaction-fail";
|
|
23
|
+
readonly TransactionSigned: "transaction-signed";
|
|
24
|
+
readonly TransactionSignStart: "transaction-sign-start";
|
|
25
|
+
readonly TransactionBroadcastEnd: "transaction-broadcast-end";
|
|
26
|
+
readonly TransactionBroadcastStart: "transaction-broadcast-start";
|
|
27
|
+
readonly TransactionPreparationEnd: "transaction-preparation-end";
|
|
28
|
+
readonly TransactionPreparationStart: "transaction-preparation-start";
|
|
29
|
+
readonly WalletStrategyDisconnect: "wallet-strategy-disconnect";
|
|
30
|
+
};
|
|
31
|
+
type StrategyEventType = (typeof StrategyEventType)[keyof typeof StrategyEventType] | (typeof WalletConnectStrategyEventType)[keyof typeof WalletConnectStrategyEventType];
|
|
32
|
+
type WalletStrategyEmitterEventType = (typeof WalletStrategyEmitterEventType)[keyof typeof WalletStrategyEmitterEventType] | StrategyEventType;
|
|
33
|
+
type WalletStrategyEmitterEvents = { [K in WalletStrategyEmitterEventType]: Record<string, any> };
|
|
34
|
+
interface WalletStrategyEmitter {
|
|
35
|
+
on(event: WalletStrategyEmitterEventType, listener: (...args: any[]) => void): this;
|
|
36
|
+
off(event: WalletStrategyEmitterEventType, listener: (...args: any[]) => void): this;
|
|
37
|
+
emit(event: WalletStrategyEmitterEventType, ...args: any[]): boolean;
|
|
38
|
+
}
|
|
39
|
+
//#endregion
|
|
11
40
|
//#region src/types/enums.d.ts
|
|
12
41
|
declare const BroadcastMode: {
|
|
13
42
|
readonly Block: "block";
|
|
@@ -76,6 +105,9 @@ declare const WalletAction: {
|
|
|
76
105
|
};
|
|
77
106
|
//#endregion
|
|
78
107
|
//#region src/types/strategy.d.ts
|
|
108
|
+
interface StrategyEmitter {
|
|
109
|
+
emit(event: string, data?: Record<string, any>): boolean;
|
|
110
|
+
}
|
|
79
111
|
type onAccountChangeCallback = (account: string | string[]) => void;
|
|
80
112
|
type onChainIdChangeCallback = () => void;
|
|
81
113
|
type Eip1193Provider = {
|
|
@@ -156,6 +188,7 @@ interface WalletMetadata {
|
|
|
156
188
|
interface ConcreteWalletStrategyArgs {
|
|
157
189
|
chainId: ChainId;
|
|
158
190
|
metadata?: WalletMetadata;
|
|
191
|
+
emitter?: StrategyEmitter;
|
|
159
192
|
}
|
|
160
193
|
interface ConcreteEvmWalletStrategyArgs extends ConcreteWalletStrategyArgs {
|
|
161
194
|
evmOptions: WalletStrategyEvmOptions;
|
|
@@ -292,6 +325,7 @@ interface ConcreteWalletStrategy extends Omit<ConcreteCosmosWalletStrategy, 'sen
|
|
|
292
325
|
getEvmTransactionReceipt(txHash: string, evmChainId?: EvmChainId): void;
|
|
293
326
|
onAccountChange?(callback: onAccountChangeCallback): Promise<void> | void;
|
|
294
327
|
onChainIdChange?(callback: onChainIdChangeCallback): Promise<void> | void;
|
|
328
|
+
initStrategy?(): Promise<void> | void;
|
|
295
329
|
disconnect?(): Promise<void> | void;
|
|
296
330
|
getCosmosWallet?(chainId: ChainId): CosmosWalletAbstraction;
|
|
297
331
|
getWalletClient?<T>(): Promise<T>;
|
|
@@ -469,8 +503,18 @@ declare abstract class BaseConcreteStrategy {
|
|
|
469
503
|
protected evmChainId?: EvmChainId;
|
|
470
504
|
protected listeners: Partial<Record<WalletEventListener, any>>;
|
|
471
505
|
metadata?: WalletMetadata;
|
|
506
|
+
/**
|
|
507
|
+
* Optional emitter passed from parent WalletStrategy.
|
|
508
|
+
* When provided, strategies emit events directly on the parent's emitter.
|
|
509
|
+
*/
|
|
510
|
+
protected emitter?: StrategyEmitter;
|
|
472
511
|
constructor(args: ConcreteWalletStrategyArgs | ConcreteEvmWalletStrategyArgs | ConcreteCosmosWalletStrategyArgs);
|
|
473
512
|
setMetadata(metadata?: WalletMetadata): void;
|
|
513
|
+
/**
|
|
514
|
+
* Emit an event from this strategy.
|
|
515
|
+
* If emitter was provided from parent, events go directly to parent.
|
|
516
|
+
*/
|
|
517
|
+
protected emit(event: WalletStrategyEmitterEventType, data?: Record<string, any>): void;
|
|
474
518
|
}
|
|
475
519
|
//#endregion
|
|
476
|
-
export { BaseConcreteStrategy, BroadcastMode, BrowserEip1993Provider, ConcreteCosmosWalletStrategy, ConcreteCosmosWalletStrategyArgs, ConcreteEvmWalletStrategyArgs, ConcreteStrategiesArg, ConcreteWalletStrategy, ConcreteWalletStrategyArgs, CosmosWalletAbstraction, DEFAULT_ADDRESS_SEARCH_LIMIT, DEFAULT_BASE_DERIVATION_PATH, DEFAULT_NUM_ADDRESSES_TO_FETCH, EIP6963AnnounceProviderEvent, EIP6963ProviderDetail, EIP6963ProviderInfo, Eip1193Provider, GWEI_IN_WEI, MagicMetadata, MagicProvider, PrivateKeyMetadata, SendTransactionOptions, type StdSignDoc, TIP_IN_GWEI, TurnkeyMetadata, TurnkeyProvider, TurnkeySession, Wallet, WalletAction, WalletConnectMetadata, WalletDeviceType, WalletEventListener, WalletMetadata, WalletStrategy, WalletStrategyArguments, WalletStrategyEvmOptions, WindowWithEip1193Provider, createCosmosSignDocFromSignDoc, createEip712StdSignDoc, getEthereumSignerAddress, getEvmChainConfig, getInjectiveSignerAddress, getViemPublicClient, getViemPublicClientFromEip1193Provider, getViemWalletClient, isCosmosAminoOnlyWallet, isCosmosBrowserWallet, isCosmosWallet, isEip712V2OnlyWallet, isEvmBrowserWallet, isEvmWallet, onAccountChangeCallback, onChainIdChangeCallback };
|
|
520
|
+
export { BaseConcreteStrategy, BroadcastMode, BrowserEip1993Provider, ConcreteCosmosWalletStrategy, ConcreteCosmosWalletStrategyArgs, ConcreteEvmWalletStrategyArgs, ConcreteStrategiesArg, ConcreteWalletStrategy, ConcreteWalletStrategyArgs, CosmosWalletAbstraction, DEFAULT_ADDRESS_SEARCH_LIMIT, DEFAULT_BASE_DERIVATION_PATH, DEFAULT_NUM_ADDRESSES_TO_FETCH, EIP6963AnnounceProviderEvent, EIP6963ProviderDetail, EIP6963ProviderInfo, Eip1193Provider, GWEI_IN_WEI, MagicMetadata, MagicProvider, PrivateKeyMetadata, SendTransactionOptions, type StdSignDoc, StrategyEmitter, StrategyEventType, TIP_IN_GWEI, TurnkeyMetadata, TurnkeyProvider, TurnkeySession, Wallet, WalletAction, WalletConnectMetadata, WalletConnectStrategyEventType, WalletDeviceType, WalletEventListener, WalletMetadata, WalletStrategy, WalletStrategyArguments, WalletStrategyEmitter, WalletStrategyEmitterEventType, WalletStrategyEmitterEvents, WalletStrategyEvmOptions, WindowWithEip1193Provider, createCosmosSignDocFromSignDoc, createEip712StdSignDoc, getEthereumSignerAddress, getEvmChainConfig, getInjectiveSignerAddress, getViemPublicClient, getViemPublicClientFromEip1193Provider, getViemWalletClient, isCosmosAminoOnlyWallet, isCosmosBrowserWallet, isCosmosWallet, isEip712V2OnlyWallet, isEvmBrowserWallet, isEvmWallet, onAccountChangeCallback, onChainIdChangeCallback };
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -8,6 +8,35 @@ import { AminoSignResponse, DirectSignResponse, TxRaw } from "@injectivelabs/sdk
|
|
|
8
8
|
import { EIP1193Provider } from "eip1193-provider";
|
|
9
9
|
import { Msgs } from "@injectivelabs/sdk-ts/core/modules";
|
|
10
10
|
|
|
11
|
+
//#region src/types/events.d.ts
|
|
12
|
+
declare const StrategyEventType: {
|
|
13
|
+
readonly ConnectionEnd: "connection-end";
|
|
14
|
+
readonly ConnectionStart: "connection-start";
|
|
15
|
+
readonly WalletSigningEnd: "wallet-signing-end";
|
|
16
|
+
readonly WalletSigningStart: "wallet-signing-start";
|
|
17
|
+
};
|
|
18
|
+
declare const WalletConnectStrategyEventType: {
|
|
19
|
+
readonly WalletConnectSigningWithTxTimeout: "signing-with-tx-timeout";
|
|
20
|
+
};
|
|
21
|
+
declare const WalletStrategyEmitterEventType: {
|
|
22
|
+
readonly TransactionFail: "transaction-fail";
|
|
23
|
+
readonly TransactionSigned: "transaction-signed";
|
|
24
|
+
readonly TransactionSignStart: "transaction-sign-start";
|
|
25
|
+
readonly TransactionBroadcastEnd: "transaction-broadcast-end";
|
|
26
|
+
readonly TransactionBroadcastStart: "transaction-broadcast-start";
|
|
27
|
+
readonly TransactionPreparationEnd: "transaction-preparation-end";
|
|
28
|
+
readonly TransactionPreparationStart: "transaction-preparation-start";
|
|
29
|
+
readonly WalletStrategyDisconnect: "wallet-strategy-disconnect";
|
|
30
|
+
};
|
|
31
|
+
type StrategyEventType = (typeof StrategyEventType)[keyof typeof StrategyEventType] | (typeof WalletConnectStrategyEventType)[keyof typeof WalletConnectStrategyEventType];
|
|
32
|
+
type WalletStrategyEmitterEventType = (typeof WalletStrategyEmitterEventType)[keyof typeof WalletStrategyEmitterEventType] | StrategyEventType;
|
|
33
|
+
type WalletStrategyEmitterEvents = { [K in WalletStrategyEmitterEventType]: Record<string, any> };
|
|
34
|
+
interface WalletStrategyEmitter {
|
|
35
|
+
on(event: WalletStrategyEmitterEventType, listener: (...args: any[]) => void): this;
|
|
36
|
+
off(event: WalletStrategyEmitterEventType, listener: (...args: any[]) => void): this;
|
|
37
|
+
emit(event: WalletStrategyEmitterEventType, ...args: any[]): boolean;
|
|
38
|
+
}
|
|
39
|
+
//#endregion
|
|
11
40
|
//#region src/types/enums.d.ts
|
|
12
41
|
declare const BroadcastMode: {
|
|
13
42
|
readonly Block: "block";
|
|
@@ -76,6 +105,9 @@ declare const WalletAction: {
|
|
|
76
105
|
};
|
|
77
106
|
//#endregion
|
|
78
107
|
//#region src/types/strategy.d.ts
|
|
108
|
+
interface StrategyEmitter {
|
|
109
|
+
emit(event: string, data?: Record<string, any>): boolean;
|
|
110
|
+
}
|
|
79
111
|
type onAccountChangeCallback = (account: string | string[]) => void;
|
|
80
112
|
type onChainIdChangeCallback = () => void;
|
|
81
113
|
type Eip1193Provider = {
|
|
@@ -156,6 +188,7 @@ interface WalletMetadata {
|
|
|
156
188
|
interface ConcreteWalletStrategyArgs {
|
|
157
189
|
chainId: ChainId;
|
|
158
190
|
metadata?: WalletMetadata;
|
|
191
|
+
emitter?: StrategyEmitter;
|
|
159
192
|
}
|
|
160
193
|
interface ConcreteEvmWalletStrategyArgs extends ConcreteWalletStrategyArgs {
|
|
161
194
|
evmOptions: WalletStrategyEvmOptions;
|
|
@@ -292,6 +325,7 @@ interface ConcreteWalletStrategy extends Omit<ConcreteCosmosWalletStrategy, 'sen
|
|
|
292
325
|
getEvmTransactionReceipt(txHash: string, evmChainId?: EvmChainId): void;
|
|
293
326
|
onAccountChange?(callback: onAccountChangeCallback): Promise<void> | void;
|
|
294
327
|
onChainIdChange?(callback: onChainIdChangeCallback): Promise<void> | void;
|
|
328
|
+
initStrategy?(): Promise<void> | void;
|
|
295
329
|
disconnect?(): Promise<void> | void;
|
|
296
330
|
getCosmosWallet?(chainId: ChainId): CosmosWalletAbstraction;
|
|
297
331
|
getWalletClient?<T>(): Promise<T>;
|
|
@@ -469,8 +503,18 @@ declare abstract class BaseConcreteStrategy {
|
|
|
469
503
|
protected evmChainId?: EvmChainId;
|
|
470
504
|
protected listeners: Partial<Record<WalletEventListener, any>>;
|
|
471
505
|
metadata?: WalletMetadata;
|
|
506
|
+
/**
|
|
507
|
+
* Optional emitter passed from parent WalletStrategy.
|
|
508
|
+
* When provided, strategies emit events directly on the parent's emitter.
|
|
509
|
+
*/
|
|
510
|
+
protected emitter?: StrategyEmitter;
|
|
472
511
|
constructor(args: ConcreteWalletStrategyArgs | ConcreteEvmWalletStrategyArgs | ConcreteCosmosWalletStrategyArgs);
|
|
473
512
|
setMetadata(metadata?: WalletMetadata): void;
|
|
513
|
+
/**
|
|
514
|
+
* Emit an event from this strategy.
|
|
515
|
+
* If emitter was provided from parent, events go directly to parent.
|
|
516
|
+
*/
|
|
517
|
+
protected emit(event: WalletStrategyEmitterEventType, data?: Record<string, any>): void;
|
|
474
518
|
}
|
|
475
519
|
//#endregion
|
|
476
|
-
export { BaseConcreteStrategy, BroadcastMode, BrowserEip1993Provider, ConcreteCosmosWalletStrategy, ConcreteCosmosWalletStrategyArgs, ConcreteEvmWalletStrategyArgs, ConcreteStrategiesArg, ConcreteWalletStrategy, ConcreteWalletStrategyArgs, CosmosWalletAbstraction, DEFAULT_ADDRESS_SEARCH_LIMIT, DEFAULT_BASE_DERIVATION_PATH, DEFAULT_NUM_ADDRESSES_TO_FETCH, EIP6963AnnounceProviderEvent, EIP6963ProviderDetail, EIP6963ProviderInfo, Eip1193Provider, GWEI_IN_WEI, MagicMetadata, MagicProvider, PrivateKeyMetadata, SendTransactionOptions, type StdSignDoc, TIP_IN_GWEI, TurnkeyMetadata, TurnkeyProvider, TurnkeySession, Wallet, WalletAction, WalletConnectMetadata, WalletDeviceType, WalletEventListener, WalletMetadata, WalletStrategy, WalletStrategyArguments, WalletStrategyEvmOptions, WindowWithEip1193Provider, createCosmosSignDocFromSignDoc, createEip712StdSignDoc, getEthereumSignerAddress, getEvmChainConfig, getInjectiveSignerAddress, getViemPublicClient, getViemPublicClientFromEip1193Provider, getViemWalletClient, isCosmosAminoOnlyWallet, isCosmosBrowserWallet, isCosmosWallet, isEip712V2OnlyWallet, isEvmBrowserWallet, isEvmWallet, onAccountChangeCallback, onChainIdChangeCallback };
|
|
520
|
+
export { BaseConcreteStrategy, BroadcastMode, BrowserEip1993Provider, ConcreteCosmosWalletStrategy, ConcreteCosmosWalletStrategyArgs, ConcreteEvmWalletStrategyArgs, ConcreteStrategiesArg, ConcreteWalletStrategy, ConcreteWalletStrategyArgs, CosmosWalletAbstraction, DEFAULT_ADDRESS_SEARCH_LIMIT, DEFAULT_BASE_DERIVATION_PATH, DEFAULT_NUM_ADDRESSES_TO_FETCH, EIP6963AnnounceProviderEvent, EIP6963ProviderDetail, EIP6963ProviderInfo, Eip1193Provider, GWEI_IN_WEI, MagicMetadata, MagicProvider, PrivateKeyMetadata, SendTransactionOptions, type StdSignDoc, StrategyEmitter, StrategyEventType, TIP_IN_GWEI, TurnkeyMetadata, TurnkeyProvider, TurnkeySession, Wallet, WalletAction, WalletConnectMetadata, WalletConnectStrategyEventType, WalletDeviceType, WalletEventListener, WalletMetadata, WalletStrategy, WalletStrategyArguments, WalletStrategyEmitter, WalletStrategyEmitterEventType, WalletStrategyEmitterEvents, WalletStrategyEvmOptions, WindowWithEip1193Provider, createCosmosSignDocFromSignDoc, createEip712StdSignDoc, getEthereumSignerAddress, getEvmChainConfig, getInjectiveSignerAddress, getViemPublicClient, getViemPublicClientFromEip1193Provider, getViemWalletClient, isCosmosAminoOnlyWallet, isCosmosBrowserWallet, isCosmosWallet, isEip712V2OnlyWallet, isEvmBrowserWallet, isEvmWallet, onAccountChangeCallback, onChainIdChangeCallback };
|
package/dist/esm/index.js
CHANGED
|
@@ -7,6 +7,26 @@ import { createPublicClient, createWalletClient, custom, extractChain, http } fr
|
|
|
7
7
|
import { CosmosTxV1Beta1TxPb } from "@injectivelabs/sdk-ts";
|
|
8
8
|
import { getEthereumAddress, getInjectiveAddress } from "@injectivelabs/sdk-ts/utils";
|
|
9
9
|
|
|
10
|
+
//#region src/types/events.ts
|
|
11
|
+
const StrategyEventType = {
|
|
12
|
+
ConnectionEnd: "connection-end",
|
|
13
|
+
ConnectionStart: "connection-start",
|
|
14
|
+
WalletSigningEnd: "wallet-signing-end",
|
|
15
|
+
WalletSigningStart: "wallet-signing-start"
|
|
16
|
+
};
|
|
17
|
+
const WalletConnectStrategyEventType = { WalletConnectSigningWithTxTimeout: "signing-with-tx-timeout" };
|
|
18
|
+
const WalletStrategyEmitterEventType = {
|
|
19
|
+
TransactionFail: "transaction-fail",
|
|
20
|
+
TransactionSigned: "transaction-signed",
|
|
21
|
+
TransactionSignStart: "transaction-sign-start",
|
|
22
|
+
TransactionBroadcastEnd: "transaction-broadcast-end",
|
|
23
|
+
TransactionBroadcastStart: "transaction-broadcast-start",
|
|
24
|
+
TransactionPreparationEnd: "transaction-preparation-end",
|
|
25
|
+
TransactionPreparationStart: "transaction-preparation-start",
|
|
26
|
+
WalletStrategyDisconnect: "wallet-strategy-disconnect"
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
//#endregion
|
|
10
30
|
//#region src/types/enums.ts
|
|
11
31
|
const BroadcastMode = {
|
|
12
32
|
Block: "block",
|
|
@@ -104,7 +124,7 @@ const getEvmChainConfig = (chainId) => {
|
|
|
104
124
|
};
|
|
105
125
|
const getViemPublicClient = (chainId, rpcUrl) => {
|
|
106
126
|
const chain = getEvmChainConfig(chainId);
|
|
107
|
-
if ([EvmChainId.Mainnet, EvmChainId.Sepolia].includes(chainId) && rpcUrl && !rpcUrl.includes("
|
|
127
|
+
if ([EvmChainId.Mainnet, EvmChainId.Sepolia].includes(chainId) && rpcUrl && !rpcUrl.includes("alchemy")) throw new Error(`An Alchemy RPC URL must be provided for EvmChainId ${chainId}`);
|
|
108
128
|
return createPublicClient({
|
|
109
129
|
chain: rpcUrl ? {
|
|
110
130
|
...chain,
|
|
@@ -268,14 +288,24 @@ var BaseConcreteStrategy = class {
|
|
|
268
288
|
_defineProperty(this, "evmChainId", void 0);
|
|
269
289
|
_defineProperty(this, "listeners", {});
|
|
270
290
|
_defineProperty(this, "metadata", void 0);
|
|
291
|
+
_defineProperty(this, "emitter", void 0);
|
|
271
292
|
this.evmChainId = "evmOptions" in args && args.evmOptions ? args.evmOptions.evmChainId : void 0;
|
|
272
293
|
this.chainId = args.chainId;
|
|
273
294
|
this.metadata = args.metadata;
|
|
295
|
+
this.emitter = args.emitter;
|
|
274
296
|
}
|
|
275
297
|
setMetadata(metadata) {
|
|
276
298
|
this.metadata = metadata;
|
|
277
299
|
}
|
|
300
|
+
/**
|
|
301
|
+
* Emit an event from this strategy.
|
|
302
|
+
* If emitter was provided from parent, events go directly to parent.
|
|
303
|
+
*/
|
|
304
|
+
emit(event, data) {
|
|
305
|
+
var _this$emitter;
|
|
306
|
+
(_this$emitter = this.emitter) === null || _this$emitter === void 0 || _this$emitter.emit(event, data);
|
|
307
|
+
}
|
|
278
308
|
};
|
|
279
309
|
|
|
280
310
|
//#endregion
|
|
281
|
-
export { BaseConcreteStrategy, BroadcastMode, DEFAULT_ADDRESS_SEARCH_LIMIT, DEFAULT_BASE_DERIVATION_PATH, DEFAULT_NUM_ADDRESSES_TO_FETCH, GWEI_IN_WEI, MagicProvider, TIP_IN_GWEI, TurnkeyProvider, Wallet, WalletAction, WalletDeviceType, WalletEventListener, createCosmosSignDocFromSignDoc, createEip712StdSignDoc, getEthereumSignerAddress, getEvmChainConfig, getInjectiveSignerAddress, getViemPublicClient, getViemPublicClientFromEip1193Provider, getViemWalletClient, isCosmosAminoOnlyWallet, isCosmosBrowserWallet, isCosmosWallet, isEip712V2OnlyWallet, isEvmBrowserWallet, isEvmWallet };
|
|
311
|
+
export { BaseConcreteStrategy, BroadcastMode, DEFAULT_ADDRESS_SEARCH_LIMIT, DEFAULT_BASE_DERIVATION_PATH, DEFAULT_NUM_ADDRESSES_TO_FETCH, 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 };
|
package/package.json
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@injectivelabs/wallet-base",
|
|
3
|
-
"version": "1.17.2-alpha.
|
|
3
|
+
"version": "1.17.2-alpha.5",
|
|
4
4
|
"description": "Base wallet strategy for use with @injectivelabs/wallet-core.",
|
|
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": {
|
|
@@ -37,19 +41,6 @@
|
|
|
37
41
|
"files": [
|
|
38
42
|
"dist"
|
|
39
43
|
],
|
|
40
|
-
"dependencies": {
|
|
41
|
-
"eip1193-provider": "^1.0.1",
|
|
42
|
-
"viem": "^2.41.2",
|
|
43
|
-
"@injectivelabs/exceptions": "1.17.2-alpha.4",
|
|
44
|
-
"@injectivelabs/sdk-ts": "1.17.2-alpha.4",
|
|
45
|
-
"@injectivelabs/ts-types": "1.17.2-alpha.4"
|
|
46
|
-
},
|
|
47
|
-
"publishConfig": {
|
|
48
|
-
"access": "public"
|
|
49
|
-
},
|
|
50
|
-
"_moduleAliases": {
|
|
51
|
-
"~wallet-base": "dist"
|
|
52
|
-
},
|
|
53
44
|
"scripts": {
|
|
54
45
|
"build": "pnpm type-check && tsdown",
|
|
55
46
|
"build:fast": "tsdown",
|
|
@@ -64,5 +55,19 @@
|
|
|
64
55
|
"dev": "ts-node -r tsconfig-paths/register src/index.ts",
|
|
65
56
|
"start": "node dist/index.js",
|
|
66
57
|
"lint": "eslint . --ext .ts,.js"
|
|
67
|
-
}
|
|
68
|
-
|
|
58
|
+
},
|
|
59
|
+
"dependencies": {
|
|
60
|
+
"@injectivelabs/exceptions": "1.17.2-alpha.5",
|
|
61
|
+
"@injectivelabs/sdk-ts": "1.17.2-alpha.5",
|
|
62
|
+
"@injectivelabs/ts-types": "1.17.2-alpha.5",
|
|
63
|
+
"eip1193-provider": "catalog:",
|
|
64
|
+
"viem": "catalog:"
|
|
65
|
+
},
|
|
66
|
+
"publishConfig": {
|
|
67
|
+
"access": "public"
|
|
68
|
+
},
|
|
69
|
+
"_moduleAliases": {
|
|
70
|
+
"~wallet-base": "dist"
|
|
71
|
+
},
|
|
72
|
+
"gitHead": "2c4676388410f2e4557b3ba2846c912f52c57224"
|
|
73
|
+
}
|