@injectivelabs/wallet-base 1.16.38 → 1.16.39-alpha.1
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 +331 -0
- package/dist/cjs/index.d.cts +475 -0
- package/dist/cjs/package.json +2 -2
- package/dist/esm/index.d.ts +475 -3
- package/dist/esm/index.js +278 -3
- package/dist/esm/package.json +2 -2
- package/package.json +42 -44
- package/dist/cjs/base.d.ts +0 -9
- package/dist/cjs/base.js +0 -17
- package/dist/cjs/index.d.ts +0 -3
- package/dist/cjs/index.js +0 -24
- package/dist/cjs/types/enums.d.ts +0 -64
- package/dist/cjs/types/enums.js +0 -53
- package/dist/cjs/types/index.d.ts +0 -3
- package/dist/cjs/types/index.js +0 -18
- package/dist/cjs/types/provider.d.ts +0 -38
- package/dist/cjs/types/provider.js +0 -2
- package/dist/cjs/types/strategy.d.ts +0 -256
- package/dist/cjs/types/strategy.js +0 -8
- package/dist/cjs/utils/address.d.ts +0 -2
- package/dist/cjs/utils/address.js +0 -30
- package/dist/cjs/utils/alchemy.d.ts +0 -1
- package/dist/cjs/utils/alchemy.js +0 -11
- package/dist/cjs/utils/constants.d.ts +0 -6
- package/dist/cjs/utils/constants.js +0 -9
- package/dist/cjs/utils/cosmos.d.ts +0 -2
- package/dist/cjs/utils/cosmos.js +0 -13
- package/dist/cjs/utils/index.d.ts +0 -7
- package/dist/cjs/utils/index.js +0 -23
- package/dist/cjs/utils/tx.d.ts +0 -31
- package/dist/cjs/utils/tx.js +0 -14
- package/dist/cjs/utils/viem.d.ts +0 -9
- package/dist/cjs/utils/viem.js +0 -114
- package/dist/cjs/utils/wallet.d.ts +0 -7
- package/dist/cjs/utils/wallet.js +0 -52
- package/dist/esm/base.d.ts +0 -9
- package/dist/esm/base.js +0 -14
- package/dist/esm/types/enums.d.ts +0 -64
- package/dist/esm/types/enums.js +0 -50
- package/dist/esm/types/index.d.ts +0 -3
- package/dist/esm/types/index.js +0 -2
- package/dist/esm/types/provider.d.ts +0 -38
- package/dist/esm/types/provider.js +0 -1
- package/dist/esm/types/strategy.d.ts +0 -256
- package/dist/esm/types/strategy.js +0 -5
- package/dist/esm/utils/address.d.ts +0 -2
- package/dist/esm/utils/address.js +0 -25
- package/dist/esm/utils/alchemy.d.ts +0 -1
- package/dist/esm/utils/alchemy.js +0 -7
- package/dist/esm/utils/constants.d.ts +0 -6
- package/dist/esm/utils/constants.js +0 -6
- package/dist/esm/utils/cosmos.d.ts +0 -2
- package/dist/esm/utils/cosmos.js +0 -9
- package/dist/esm/utils/index.d.ts +0 -7
- package/dist/esm/utils/index.js +0 -7
- package/dist/esm/utils/tx.d.ts +0 -31
- package/dist/esm/utils/tx.js +0 -10
- package/dist/esm/utils/viem.d.ts +0 -9
- package/dist/esm/utils/viem.js +0 -75
- package/dist/esm/utils/wallet.d.ts +0 -7
- package/dist/esm/utils/wallet.js +0 -43
|
@@ -1,256 +0,0 @@
|
|
|
1
|
-
import type { StdSignDoc } from '@keplr-wallet/types';
|
|
2
|
-
import type { WalletDeviceType, Wallet } from './enums.js';
|
|
3
|
-
import type { OfflineSigner } from '@cosmjs/proto-signing';
|
|
4
|
-
import type { ChainId, EvmChainId, AccountAddress } from '@injectivelabs/ts-types';
|
|
5
|
-
import type { TxRaw, TxResponse, AminoSignResponse, DirectSignResponse } from '@injectivelabs/sdk-ts';
|
|
6
|
-
export type onAccountChangeCallback = (account: string | string[]) => void;
|
|
7
|
-
export type onChainIdChangeCallback = () => void;
|
|
8
|
-
export type Eip1193Provider = {
|
|
9
|
-
request: (args: {
|
|
10
|
-
method: string;
|
|
11
|
-
params: any[];
|
|
12
|
-
}) => Promise<any>;
|
|
13
|
-
on: (event: string, listener: (...args: any[]) => void) => void;
|
|
14
|
-
removeListener: (event: string, listener: (...args: any[]) => void) => void;
|
|
15
|
-
};
|
|
16
|
-
export type CosmosWalletAbstraction = {
|
|
17
|
-
enableGasCheck?(chainId: ChainId): Promise<void> | void;
|
|
18
|
-
disableGasCheck?(chainId: ChainId): Promise<void> | void;
|
|
19
|
-
signEIP712CosmosTx(args: {
|
|
20
|
-
signDoc: StdSignDoc;
|
|
21
|
-
eip712: any;
|
|
22
|
-
}): Promise<AminoSignResponse>;
|
|
23
|
-
};
|
|
24
|
-
export type MagicMetadata = {
|
|
25
|
-
apiKey?: string;
|
|
26
|
-
rpcEndpoint?: string;
|
|
27
|
-
};
|
|
28
|
-
export type PrivateKeyMetadata = {
|
|
29
|
-
privateKey: string;
|
|
30
|
-
};
|
|
31
|
-
export type WalletConnectMetadata = {
|
|
32
|
-
projectId?: string;
|
|
33
|
-
};
|
|
34
|
-
export interface WalletStrategyEvmOptions {
|
|
35
|
-
evmChainId: EvmChainId;
|
|
36
|
-
rpcUrl?: string;
|
|
37
|
-
rpcUrls?: Partial<Record<EvmChainId, string>>;
|
|
38
|
-
}
|
|
39
|
-
export interface SendTransactionOptions {
|
|
40
|
-
address: string;
|
|
41
|
-
chainId: ChainId;
|
|
42
|
-
txTimeout?: number;
|
|
43
|
-
endpoints: {
|
|
44
|
-
rest: string;
|
|
45
|
-
grpc: string;
|
|
46
|
-
tm?: string;
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
export declare const TurnkeyProvider: {
|
|
50
|
-
readonly Email: "email";
|
|
51
|
-
readonly Google: "google";
|
|
52
|
-
readonly Apple: "apple";
|
|
53
|
-
};
|
|
54
|
-
export type TurnkeyProvider = (typeof TurnkeyProvider)[keyof typeof TurnkeyProvider];
|
|
55
|
-
export type TurnkeySession = {
|
|
56
|
-
sessionType: any;
|
|
57
|
-
userId: string;
|
|
58
|
-
organizationId: string;
|
|
59
|
-
expiry: number;
|
|
60
|
-
token: string;
|
|
61
|
-
};
|
|
62
|
-
export interface TurnkeyMetadata {
|
|
63
|
-
apiBaseUrl: string;
|
|
64
|
-
otpInitPath?: string;
|
|
65
|
-
otpVerifyPath?: string;
|
|
66
|
-
googleClientId?: string;
|
|
67
|
-
oauthLoginPath?: string;
|
|
68
|
-
session?: TurnkeySession;
|
|
69
|
-
apiServerEndpoint: string;
|
|
70
|
-
credentialBundle?: string;
|
|
71
|
-
googleRedirectUri?: string;
|
|
72
|
-
expirationSeconds?: string;
|
|
73
|
-
defaultOrganizationId: string;
|
|
74
|
-
}
|
|
75
|
-
export interface WalletMetadata {
|
|
76
|
-
magic?: MagicMetadata;
|
|
77
|
-
turnkey?: Partial<TurnkeyMetadata>;
|
|
78
|
-
walletConnect?: WalletConnectMetadata;
|
|
79
|
-
privateKey?: PrivateKeyMetadata;
|
|
80
|
-
}
|
|
81
|
-
export interface ConcreteWalletStrategyArgs {
|
|
82
|
-
chainId: ChainId;
|
|
83
|
-
metadata?: WalletMetadata;
|
|
84
|
-
}
|
|
85
|
-
export interface ConcreteEvmWalletStrategyArgs extends ConcreteWalletStrategyArgs {
|
|
86
|
-
evmOptions: WalletStrategyEvmOptions;
|
|
87
|
-
}
|
|
88
|
-
export interface ConcreteCosmosWalletStrategyArgs extends ConcreteWalletStrategyArgs {
|
|
89
|
-
wallet?: Wallet;
|
|
90
|
-
}
|
|
91
|
-
export interface ConcreteCosmosWalletStrategy {
|
|
92
|
-
metadata?: WalletMetadata;
|
|
93
|
-
setMetadata?(metadata?: WalletMetadata): void;
|
|
94
|
-
/**
|
|
95
|
-
* The accounts from the wallet (addresses)
|
|
96
|
-
*/
|
|
97
|
-
getAddresses(args?: unknown): Promise<string[]>;
|
|
98
|
-
/**
|
|
99
|
-
* Return the WalletDeviceType connected on the
|
|
100
|
-
* wallet provider (extension, mobile, hardware wallet)
|
|
101
|
-
*/
|
|
102
|
-
getWalletDeviceType(): Promise<WalletDeviceType>;
|
|
103
|
-
/**
|
|
104
|
-
* Get the PubKey from the wallet
|
|
105
|
-
* in base64 for Cosmos native wallets
|
|
106
|
-
*/
|
|
107
|
-
getPubKey(address?: string): Promise<string>;
|
|
108
|
-
/**
|
|
109
|
-
* Perform validations and checks
|
|
110
|
-
* for the wallet (if the chain is supported, etc)
|
|
111
|
-
*/
|
|
112
|
-
enable(args?: unknown): Promise<boolean>;
|
|
113
|
-
/**
|
|
114
|
-
* Sends Cosmos transaction. Returns a transaction hash
|
|
115
|
-
* @param transaction should implement TransactionConfig
|
|
116
|
-
* @param options
|
|
117
|
-
*/
|
|
118
|
-
sendTransaction(transaction: DirectSignResponse | TxRaw, options: SendTransactionOptions): Promise<TxResponse>;
|
|
119
|
-
signCosmosTransaction(transaction: {
|
|
120
|
-
txRaw: TxRaw;
|
|
121
|
-
chainId: string;
|
|
122
|
-
accountNumber: number;
|
|
123
|
-
address: string;
|
|
124
|
-
}): Promise<DirectSignResponse>;
|
|
125
|
-
signAminoTransaction(transaction: {
|
|
126
|
-
stdSignDoc: StdSignDoc;
|
|
127
|
-
address: string;
|
|
128
|
-
}): Promise<AminoSignResponse>;
|
|
129
|
-
}
|
|
130
|
-
export type ConcreteStrategiesArg = {
|
|
131
|
-
[key in Wallet]?: ConcreteWalletStrategy;
|
|
132
|
-
};
|
|
133
|
-
export interface WalletStrategyArguments {
|
|
134
|
-
chainId: ChainId;
|
|
135
|
-
metadata?: WalletMetadata;
|
|
136
|
-
evmOptions?: WalletStrategyEvmOptions;
|
|
137
|
-
disabledWallets?: Wallet[];
|
|
138
|
-
wallet?: Wallet;
|
|
139
|
-
strategies: ConcreteStrategiesArg;
|
|
140
|
-
}
|
|
141
|
-
export interface ConcreteWalletStrategy extends Omit<ConcreteCosmosWalletStrategy, 'sendTransaction' | 'isChainIdSupported' | 'signAminoTransaction'> {
|
|
142
|
-
/**
|
|
143
|
-
* Sends Cosmos transaction. Returns a transaction hash
|
|
144
|
-
* @param transaction should implement TransactionConfig
|
|
145
|
-
* @param options
|
|
146
|
-
*/
|
|
147
|
-
sendTransaction(transaction: DirectSignResponse | TxRaw, options: {
|
|
148
|
-
address: string;
|
|
149
|
-
chainId: ChainId;
|
|
150
|
-
txTimeout?: number;
|
|
151
|
-
endpoints?: {
|
|
152
|
-
rest: string;
|
|
153
|
-
grpc: string;
|
|
154
|
-
tm?: string;
|
|
155
|
-
};
|
|
156
|
-
}): Promise<TxResponse>;
|
|
157
|
-
/**
|
|
158
|
-
* Confirm the address on the wallet
|
|
159
|
-
* @param address address
|
|
160
|
-
*/
|
|
161
|
-
getSessionOrConfirm(address?: string): Promise<string>;
|
|
162
|
-
/**
|
|
163
|
-
* Sends Ethereum transaction. Returns a transaction hash
|
|
164
|
-
* @param transaction should implement TransactionConfig
|
|
165
|
-
* @param options
|
|
166
|
-
*/
|
|
167
|
-
sendEvmTransaction(transaction: unknown, options: {
|
|
168
|
-
address: string;
|
|
169
|
-
evmChainId: EvmChainId;
|
|
170
|
-
}): Promise<string>;
|
|
171
|
-
/**
|
|
172
|
-
* Sign a cosmos transaction using the wallet provider
|
|
173
|
-
*
|
|
174
|
-
* @param transaction
|
|
175
|
-
* @param address - injective address
|
|
176
|
-
*/
|
|
177
|
-
signCosmosTransaction(transaction: {
|
|
178
|
-
txRaw: TxRaw;
|
|
179
|
-
accountNumber: number;
|
|
180
|
-
chainId: string;
|
|
181
|
-
address: string;
|
|
182
|
-
}): Promise<DirectSignResponse>;
|
|
183
|
-
/**
|
|
184
|
-
* Sign an amino sign doc using the wallet provider
|
|
185
|
-
*
|
|
186
|
-
* @param transaction
|
|
187
|
-
* @param address - injective address
|
|
188
|
-
*/
|
|
189
|
-
signAminoCosmosTransaction(transaction: {
|
|
190
|
-
signDoc: StdSignDoc;
|
|
191
|
-
address: string;
|
|
192
|
-
}): Promise<AminoSignResponse>;
|
|
193
|
-
/**
|
|
194
|
-
* Sign EIP712 TypedData using the wallet provider
|
|
195
|
-
* @param eip712TypedData
|
|
196
|
-
* @param address - ethereum address
|
|
197
|
-
*/
|
|
198
|
-
signEip712TypedData(eip712TypedData: string, address: string, options?: {
|
|
199
|
-
txTimeout?: number;
|
|
200
|
-
}): Promise<string>;
|
|
201
|
-
signArbitrary(signer: string, data: string | Uint8Array): Promise<string>;
|
|
202
|
-
getEthereumChainId(): Promise<string>;
|
|
203
|
-
getEvmTransactionReceipt(txHash: string, evmChainId?: EvmChainId): void;
|
|
204
|
-
onAccountChange?(callback: onAccountChangeCallback): Promise<void> | void;
|
|
205
|
-
onChainIdChange?(callback: onChainIdChangeCallback): Promise<void> | void;
|
|
206
|
-
disconnect?(): Promise<void> | void;
|
|
207
|
-
getCosmosWallet?(chainId: ChainId): CosmosWalletAbstraction;
|
|
208
|
-
getWalletClient?<T>(): Promise<T>;
|
|
209
|
-
getEip1193Provider?(): Promise<Eip1193Provider>;
|
|
210
|
-
getOfflineSigner?(chainId: string): Promise<OfflineSigner>;
|
|
211
|
-
}
|
|
212
|
-
export interface WalletStrategy {
|
|
213
|
-
strategies: ConcreteStrategiesArg;
|
|
214
|
-
wallet: Wallet;
|
|
215
|
-
args: WalletStrategyArguments;
|
|
216
|
-
metadata?: WalletMetadata;
|
|
217
|
-
getWallet(): Wallet;
|
|
218
|
-
getWalletClient?<T>(): Promise<T>;
|
|
219
|
-
setWallet(wallet: Wallet): void;
|
|
220
|
-
setMetadata(metadata?: WalletMetadata): void;
|
|
221
|
-
getStrategy(): ConcreteWalletStrategy;
|
|
222
|
-
getAddresses(args?: unknown): Promise<AccountAddress[]>;
|
|
223
|
-
getWalletDeviceType(): Promise<WalletDeviceType>;
|
|
224
|
-
getPubKey(address?: string): Promise<string>;
|
|
225
|
-
enable(args?: unknown): Promise<boolean>;
|
|
226
|
-
enableAndGetAddresses(args?: unknown): Promise<AccountAddress[]>;
|
|
227
|
-
getEthereumChainId(): Promise<string>;
|
|
228
|
-
getEvmTransactionReceipt(txHash: string, evmChainId?: EvmChainId): Promise<void>;
|
|
229
|
-
getSessionOrConfirm(address?: AccountAddress): Promise<string>;
|
|
230
|
-
sendTransaction(tx: DirectSignResponse | TxRaw, options: SendTransactionOptions): Promise<TxResponse>;
|
|
231
|
-
sendEvmTransaction(tx: any, options: {
|
|
232
|
-
address: AccountAddress;
|
|
233
|
-
evmChainId: EvmChainId;
|
|
234
|
-
}): Promise<string>;
|
|
235
|
-
signEip712TypedData(eip712TypedData: string, address: AccountAddress, options?: {
|
|
236
|
-
txTimeout?: number;
|
|
237
|
-
}): Promise<string>;
|
|
238
|
-
signAminoCosmosTransaction(transaction: {
|
|
239
|
-
signDoc: StdSignDoc;
|
|
240
|
-
address: string;
|
|
241
|
-
}): Promise<AminoSignResponse>;
|
|
242
|
-
signCosmosTransaction(transaction: {
|
|
243
|
-
txRaw: TxRaw;
|
|
244
|
-
accountNumber: number;
|
|
245
|
-
chainId: string;
|
|
246
|
-
address: string;
|
|
247
|
-
}): Promise<DirectSignResponse>;
|
|
248
|
-
signArbitrary(signer: string, data: string | Uint8Array): Promise<string | void>;
|
|
249
|
-
onAccountChange(callback: onAccountChangeCallback): Promise<void>;
|
|
250
|
-
onChainIdChange(callback: onChainIdChangeCallback): Promise<void>;
|
|
251
|
-
disconnect(): Promise<void>;
|
|
252
|
-
getCosmosWallet?(chainId: ChainId): CosmosWalletAbstraction;
|
|
253
|
-
getEip1193Provider?(): Promise<Eip1193Provider>;
|
|
254
|
-
getOfflineSigner?(chainId: string): Promise<OfflineSigner>;
|
|
255
|
-
}
|
|
256
|
-
export type { StdSignDoc };
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getEthereumSignerAddress = exports.getInjectiveSignerAddress = void 0;
|
|
4
|
-
const sdk_ts_1 = require("@injectivelabs/sdk-ts");
|
|
5
|
-
const getInjectiveSignerAddress = (address) => {
|
|
6
|
-
if (!address) {
|
|
7
|
-
return '';
|
|
8
|
-
}
|
|
9
|
-
if (address.startsWith('inj')) {
|
|
10
|
-
return address;
|
|
11
|
-
}
|
|
12
|
-
if (address.startsWith('0x')) {
|
|
13
|
-
return (0, sdk_ts_1.getInjectiveAddress)(address);
|
|
14
|
-
}
|
|
15
|
-
return '';
|
|
16
|
-
};
|
|
17
|
-
exports.getInjectiveSignerAddress = getInjectiveSignerAddress;
|
|
18
|
-
const getEthereumSignerAddress = (address) => {
|
|
19
|
-
if (!address) {
|
|
20
|
-
return '';
|
|
21
|
-
}
|
|
22
|
-
if (address.startsWith('0x')) {
|
|
23
|
-
return address;
|
|
24
|
-
}
|
|
25
|
-
if (address.startsWith('inj')) {
|
|
26
|
-
return (0, sdk_ts_1.getEthereumAddress)(address);
|
|
27
|
-
}
|
|
28
|
-
return '';
|
|
29
|
-
};
|
|
30
|
-
exports.getEthereumSignerAddress = getEthereumSignerAddress;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const getKeyFromRpcUrl: (rpcUrl: string) => string;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getKeyFromRpcUrl = void 0;
|
|
4
|
-
const getKeyFromRpcUrl = (rpcUrl) => {
|
|
5
|
-
if (!rpcUrl.includes('alchemyapi.io') && !rpcUrl.includes('alchemy.com')) {
|
|
6
|
-
return rpcUrl;
|
|
7
|
-
}
|
|
8
|
-
const [key] = rpcUrl.split('/').reverse();
|
|
9
|
-
return key;
|
|
10
|
-
};
|
|
11
|
-
exports.getKeyFromRpcUrl = getKeyFromRpcUrl;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { BigNumber } from '@injectivelabs/utils';
|
|
2
|
-
export declare const GWEI_IN_WEI: BigNumber;
|
|
3
|
-
export declare const TIP_IN_GWEI: BigNumber;
|
|
4
|
-
export declare const DEFAULT_BASE_DERIVATION_PATH = "m/44'/60'";
|
|
5
|
-
export declare const DEFAULT_NUM_ADDRESSES_TO_FETCH = 5;
|
|
6
|
-
export declare const DEFAULT_ADDRESS_SEARCH_LIMIT = 100;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DEFAULT_ADDRESS_SEARCH_LIMIT = exports.DEFAULT_NUM_ADDRESSES_TO_FETCH = exports.DEFAULT_BASE_DERIVATION_PATH = exports.TIP_IN_GWEI = exports.GWEI_IN_WEI = void 0;
|
|
4
|
-
const utils_1 = require("@injectivelabs/utils");
|
|
5
|
-
exports.GWEI_IN_WEI = (0, utils_1.toBigNumber)(1000000000);
|
|
6
|
-
exports.TIP_IN_GWEI = (0, utils_1.toBigNumber)(2).times(exports.GWEI_IN_WEI);
|
|
7
|
-
exports.DEFAULT_BASE_DERIVATION_PATH = "m/44'/60'";
|
|
8
|
-
exports.DEFAULT_NUM_ADDRESSES_TO_FETCH = 5;
|
|
9
|
-
exports.DEFAULT_ADDRESS_SEARCH_LIMIT = 100;
|
package/dist/cjs/utils/cosmos.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createCosmosSignDocFromSignDoc = void 0;
|
|
4
|
-
const sdk_ts_1 = require("@injectivelabs/sdk-ts");
|
|
5
|
-
const createCosmosSignDocFromSignDoc = (signDoc) => {
|
|
6
|
-
return sdk_ts_1.CosmosTxV1Beta1Tx.SignDoc.fromPartial({
|
|
7
|
-
bodyBytes: signDoc.bodyBytes,
|
|
8
|
-
authInfoBytes: signDoc.authInfoBytes,
|
|
9
|
-
accountNumber: BigInt(signDoc.accountNumber).toString(),
|
|
10
|
-
chainId: signDoc.chainId,
|
|
11
|
-
});
|
|
12
|
-
};
|
|
13
|
-
exports.createCosmosSignDocFromSignDoc = createCosmosSignDocFromSignDoc;
|
package/dist/cjs/utils/index.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./tx.js"), exports);
|
|
18
|
-
__exportStar(require("./viem.js"), exports);
|
|
19
|
-
__exportStar(require("./wallet.js"), exports);
|
|
20
|
-
__exportStar(require("./cosmos.js"), exports);
|
|
21
|
-
__exportStar(require("./address.js"), exports);
|
|
22
|
-
__exportStar(require("./alchemy.js"), exports);
|
|
23
|
-
__exportStar(require("./constants.js"), exports);
|
package/dist/cjs/utils/tx.d.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import type { Msgs } from '@injectivelabs/sdk-ts';
|
|
2
|
-
import type { ChainId } from '@injectivelabs/ts-types';
|
|
3
|
-
export declare const createEip712StdSignDoc: ({ memo, chainId, accountNumber, timeoutHeight, sequence, gas, msgs, }: {
|
|
4
|
-
memo?: string;
|
|
5
|
-
chainId: ChainId;
|
|
6
|
-
timeoutHeight?: string;
|
|
7
|
-
accountNumber: number;
|
|
8
|
-
sequence: number;
|
|
9
|
-
gas?: string;
|
|
10
|
-
msgs: Msgs[];
|
|
11
|
-
}) => {
|
|
12
|
-
chain_id: ChainId;
|
|
13
|
-
timeout_height: string;
|
|
14
|
-
account_number: string;
|
|
15
|
-
sequence: string;
|
|
16
|
-
fee: {
|
|
17
|
-
amount: {
|
|
18
|
-
denom: string;
|
|
19
|
-
amount: string;
|
|
20
|
-
}[];
|
|
21
|
-
gas: string;
|
|
22
|
-
payer: string | undefined;
|
|
23
|
-
granter: string | undefined;
|
|
24
|
-
feePayer: string | undefined;
|
|
25
|
-
};
|
|
26
|
-
msgs: {
|
|
27
|
-
type: string;
|
|
28
|
-
value: any;
|
|
29
|
-
}[];
|
|
30
|
-
memo: string;
|
|
31
|
-
};
|
package/dist/cjs/utils/tx.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createEip712StdSignDoc = void 0;
|
|
4
|
-
const utils_1 = require("@injectivelabs/utils");
|
|
5
|
-
const createEip712StdSignDoc = ({ memo, chainId, accountNumber, timeoutHeight, sequence, gas, msgs, }) => ({
|
|
6
|
-
chain_id: chainId,
|
|
7
|
-
timeout_height: timeoutHeight || '',
|
|
8
|
-
account_number: accountNumber.toString(),
|
|
9
|
-
sequence: sequence.toString(),
|
|
10
|
-
fee: (0, utils_1.getStdFee)({ gas }),
|
|
11
|
-
msgs: msgs.map((m) => m.toEip712()),
|
|
12
|
-
memo: memo || '',
|
|
13
|
-
});
|
|
14
|
-
exports.createEip712StdSignDoc = createEip712StdSignDoc;
|
package/dist/cjs/utils/viem.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { EvmChainId } from '@injectivelabs/ts-types';
|
|
2
|
-
import type { Chain, Account, LocalAccount, PublicClient, WalletClient } from 'viem';
|
|
3
|
-
export declare const getEvmChainConfig: (chainId: EvmChainId | number) => Chain;
|
|
4
|
-
export declare const getViemPublicClient: (chainId: EvmChainId | number, rpcUrl?: string) => PublicClient;
|
|
5
|
-
export declare const getViemWalletClient: ({ chainId, account, rpcUrl, }: {
|
|
6
|
-
chainId: EvmChainId | number;
|
|
7
|
-
account: Account | LocalAccount | `0x${string}`;
|
|
8
|
-
rpcUrl?: string;
|
|
9
|
-
}) => WalletClient;
|
package/dist/cjs/utils/viem.js
DELETED
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.getViemWalletClient = exports.getViemPublicClient = exports.getEvmChainConfig = void 0;
|
|
37
|
-
const chains_1 = require("viem/chains");
|
|
38
|
-
const viemChains = __importStar(require("viem/chains"));
|
|
39
|
-
const ts_types_1 = require("@injectivelabs/ts-types");
|
|
40
|
-
const viem_1 = require("viem");
|
|
41
|
-
const getEvmChainConfig = (chainId) => {
|
|
42
|
-
if (chainId === ts_types_1.EvmChainId.DevnetEvm) {
|
|
43
|
-
return {
|
|
44
|
-
id: ts_types_1.EvmChainId.DevnetEvm,
|
|
45
|
-
name: 'Injective EVM Devnet',
|
|
46
|
-
nativeCurrency: chains_1.injective.nativeCurrency,
|
|
47
|
-
rpcUrls: {
|
|
48
|
-
default: {
|
|
49
|
-
http: ['https://devnet.json-rpc.injective.dev'],
|
|
50
|
-
},
|
|
51
|
-
},
|
|
52
|
-
blockExplorers: {
|
|
53
|
-
default: {
|
|
54
|
-
name: '',
|
|
55
|
-
url: '',
|
|
56
|
-
},
|
|
57
|
-
},
|
|
58
|
-
testnet: true,
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
try {
|
|
62
|
-
return (0, viem_1.extractChain)({
|
|
63
|
-
id: chainId,
|
|
64
|
-
chains: Object.values(viemChains),
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
catch {
|
|
68
|
-
throw new Error(`Unsupported chainId: ${chainId}`);
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
|
-
exports.getEvmChainConfig = getEvmChainConfig;
|
|
72
|
-
const getViemPublicClient = (chainId, rpcUrl) => {
|
|
73
|
-
const chain = (0, exports.getEvmChainConfig)(chainId);
|
|
74
|
-
const chainConfig = rpcUrl
|
|
75
|
-
? {
|
|
76
|
-
...chain,
|
|
77
|
-
rpcUrls: {
|
|
78
|
-
default: {
|
|
79
|
-
http: [rpcUrl],
|
|
80
|
-
},
|
|
81
|
-
public: {
|
|
82
|
-
http: [rpcUrl],
|
|
83
|
-
},
|
|
84
|
-
},
|
|
85
|
-
}
|
|
86
|
-
: chain;
|
|
87
|
-
return (0, viem_1.createPublicClient)({
|
|
88
|
-
chain: chainConfig,
|
|
89
|
-
transport: rpcUrl ? (0, viem_1.http)(rpcUrl) : (0, viem_1.http)(),
|
|
90
|
-
});
|
|
91
|
-
};
|
|
92
|
-
exports.getViemPublicClient = getViemPublicClient;
|
|
93
|
-
const getViemWalletClient = ({ chainId, account, rpcUrl, }) => {
|
|
94
|
-
const chain = (0, exports.getEvmChainConfig)(chainId);
|
|
95
|
-
const chainConfig = rpcUrl
|
|
96
|
-
? {
|
|
97
|
-
...chain,
|
|
98
|
-
rpcUrls: {
|
|
99
|
-
default: {
|
|
100
|
-
http: [rpcUrl],
|
|
101
|
-
},
|
|
102
|
-
public: {
|
|
103
|
-
http: [rpcUrl],
|
|
104
|
-
},
|
|
105
|
-
},
|
|
106
|
-
}
|
|
107
|
-
: chain;
|
|
108
|
-
return (0, viem_1.createWalletClient)({
|
|
109
|
-
chain: chainConfig,
|
|
110
|
-
transport: rpcUrl ? (0, viem_1.http)(rpcUrl) : (0, viem_1.http)(),
|
|
111
|
-
account: typeof account === 'string' ? account : account,
|
|
112
|
-
});
|
|
113
|
-
};
|
|
114
|
-
exports.getViemWalletClient = getViemWalletClient;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { Wallet } from './../types/enums.js';
|
|
2
|
-
export declare const isEvmWallet: (wallet: Wallet) => boolean;
|
|
3
|
-
export declare const isCosmosWallet: (wallet: Wallet) => boolean;
|
|
4
|
-
export declare const isEvmBrowserWallet: (wallet: Wallet) => boolean;
|
|
5
|
-
export declare const isCosmosBrowserWallet: (wallet: Wallet) => boolean;
|
|
6
|
-
export declare const isEip712V2OnlyWallet: (wallet: Wallet) => boolean;
|
|
7
|
-
export declare const isCosmosAminoOnlyWallet: (wallet: Wallet) => boolean;
|
package/dist/cjs/utils/wallet.js
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isCosmosAminoOnlyWallet = exports.isEip712V2OnlyWallet = exports.isCosmosBrowserWallet = exports.isEvmBrowserWallet = exports.isCosmosWallet = exports.isEvmWallet = void 0;
|
|
4
|
-
const enums_js_1 = require("./../types/enums.js");
|
|
5
|
-
const isEvmWallet = (wallet) => [
|
|
6
|
-
enums_js_1.Wallet.Magic,
|
|
7
|
-
enums_js_1.Wallet.Rabby,
|
|
8
|
-
enums_js_1.Wallet.BitGet,
|
|
9
|
-
enums_js_1.Wallet.Ledger,
|
|
10
|
-
enums_js_1.Wallet.Phantom,
|
|
11
|
-
enums_js_1.Wallet.Rainbow,
|
|
12
|
-
enums_js_1.Wallet.Turnkey,
|
|
13
|
-
enums_js_1.Wallet.Metamask,
|
|
14
|
-
enums_js_1.Wallet.OkxWallet,
|
|
15
|
-
enums_js_1.Wallet.PrivateKey,
|
|
16
|
-
enums_js_1.Wallet.TrezorBip32,
|
|
17
|
-
enums_js_1.Wallet.TrezorBip44,
|
|
18
|
-
enums_js_1.Wallet.TrustWallet,
|
|
19
|
-
enums_js_1.Wallet.LedgerLegacy,
|
|
20
|
-
enums_js_1.Wallet.WalletConnect,
|
|
21
|
-
enums_js_1.Wallet.CosmostationEth,
|
|
22
|
-
].includes(wallet);
|
|
23
|
-
exports.isEvmWallet = isEvmWallet;
|
|
24
|
-
const isCosmosWallet = (wallet) => !(0, exports.isEvmWallet)(wallet);
|
|
25
|
-
exports.isCosmosWallet = isCosmosWallet;
|
|
26
|
-
const isEvmBrowserWallet = (wallet) => [
|
|
27
|
-
enums_js_1.Wallet.Rabby,
|
|
28
|
-
enums_js_1.Wallet.BitGet,
|
|
29
|
-
enums_js_1.Wallet.Phantom,
|
|
30
|
-
enums_js_1.Wallet.Rainbow,
|
|
31
|
-
enums_js_1.Wallet.Metamask,
|
|
32
|
-
enums_js_1.Wallet.OkxWallet,
|
|
33
|
-
enums_js_1.Wallet.TrustWallet,
|
|
34
|
-
].includes(wallet);
|
|
35
|
-
exports.isEvmBrowserWallet = isEvmBrowserWallet;
|
|
36
|
-
const isCosmosBrowserWallet = (wallet) => [
|
|
37
|
-
enums_js_1.Wallet.Leap,
|
|
38
|
-
enums_js_1.Wallet.Keplr,
|
|
39
|
-
enums_js_1.Wallet.Ninji,
|
|
40
|
-
enums_js_1.Wallet.OWallet,
|
|
41
|
-
enums_js_1.Wallet.Cosmostation,
|
|
42
|
-
].includes(wallet);
|
|
43
|
-
exports.isCosmosBrowserWallet = isCosmosBrowserWallet;
|
|
44
|
-
const isEip712V2OnlyWallet = (wallet) => [
|
|
45
|
-
enums_js_1.Wallet.Magic,
|
|
46
|
-
enums_js_1.Wallet.Phantom,
|
|
47
|
-
enums_js_1.Wallet.Metamask,
|
|
48
|
-
enums_js_1.Wallet.WalletConnect,
|
|
49
|
-
].includes(wallet);
|
|
50
|
-
exports.isEip712V2OnlyWallet = isEip712V2OnlyWallet;
|
|
51
|
-
const isCosmosAminoOnlyWallet = (wallet) => [enums_js_1.Wallet.LedgerCosmos].includes(wallet);
|
|
52
|
-
exports.isCosmosAminoOnlyWallet = isCosmosAminoOnlyWallet;
|
package/dist/esm/base.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { ChainId, EvmChainId, CosmosChainId } from '@injectivelabs/ts-types';
|
|
2
|
-
import type { WalletMetadata, WalletEventListener, ConcreteWalletStrategyArgs, ConcreteEvmWalletStrategyArgs, ConcreteCosmosWalletStrategyArgs } from './types/index.js';
|
|
3
|
-
export default abstract class BaseConcreteStrategy {
|
|
4
|
-
protected chainId: ChainId | CosmosChainId;
|
|
5
|
-
protected evmChainId?: EvmChainId;
|
|
6
|
-
protected listeners: Partial<Record<WalletEventListener, any>>;
|
|
7
|
-
metadata?: WalletMetadata;
|
|
8
|
-
constructor(args: ConcreteWalletStrategyArgs | ConcreteEvmWalletStrategyArgs | ConcreteCosmosWalletStrategyArgs);
|
|
9
|
-
}
|
package/dist/esm/base.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export default class BaseConcreteStrategy {
|
|
2
|
-
chainId;
|
|
3
|
-
evmChainId;
|
|
4
|
-
listeners = {};
|
|
5
|
-
metadata;
|
|
6
|
-
constructor(args) {
|
|
7
|
-
this.evmChainId =
|
|
8
|
-
'evmOptions' in args && args.evmOptions
|
|
9
|
-
? args.evmOptions.evmChainId
|
|
10
|
-
: undefined;
|
|
11
|
-
this.chainId = args.chainId;
|
|
12
|
-
this.metadata = args.metadata;
|
|
13
|
-
}
|
|
14
|
-
}
|