@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
package/dist/esm/index.js
CHANGED
|
@@ -1,3 +1,278 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { WalletErrorActionModule } from "@injectivelabs/exceptions";
|
|
2
|
+
import { getStdFee, toBigNumber } from "@injectivelabs/utils";
|
|
3
|
+
import * as viemChains from "viem/chains";
|
|
4
|
+
import { injective } from "viem/chains";
|
|
5
|
+
import { EvmChainId } from "@injectivelabs/ts-types";
|
|
6
|
+
import { createPublicClient, createWalletClient, custom, extractChain, http } from "viem";
|
|
7
|
+
import { CosmosTxV1Beta1TxPb } from "@injectivelabs/sdk-ts";
|
|
8
|
+
import { getEthereumAddress, getInjectiveAddress } from "@injectivelabs/sdk-ts/utils";
|
|
9
|
+
|
|
10
|
+
//#region src/types/enums.ts
|
|
11
|
+
const BroadcastMode = {
|
|
12
|
+
Block: "block",
|
|
13
|
+
Sync: "sync",
|
|
14
|
+
Async: "async"
|
|
15
|
+
};
|
|
16
|
+
const Wallet = {
|
|
17
|
+
Leap: "leap",
|
|
18
|
+
Keplr: "keplr",
|
|
19
|
+
Ninji: "ninji",
|
|
20
|
+
Magic: "magic",
|
|
21
|
+
Rabby: "rabby",
|
|
22
|
+
Ledger: "ledger",
|
|
23
|
+
BitGet: "BitGet",
|
|
24
|
+
OWallet: "owallet",
|
|
25
|
+
Phantom: "phantom",
|
|
26
|
+
Rainbow: "rainbow",
|
|
27
|
+
Turnkey: "turnkey",
|
|
28
|
+
Metamask: "metamask",
|
|
29
|
+
KeplrEvm: "keplr-evm",
|
|
30
|
+
OkxWallet: "okx-wallet",
|
|
31
|
+
PrivateKey: "private-key",
|
|
32
|
+
TrustWallet: "trust-wallet",
|
|
33
|
+
TrezorBip32: "trezor-bip32",
|
|
34
|
+
TrezorBip44: "trezor-bip44",
|
|
35
|
+
Cosmostation: "cosmostation",
|
|
36
|
+
LedgerCosmos: "ledger-cosmos",
|
|
37
|
+
LedgerLegacy: "ledger-legacy",
|
|
38
|
+
WalletConnect: "wallet-connect",
|
|
39
|
+
CosmostationEth: "cosmostation-eth"
|
|
40
|
+
};
|
|
41
|
+
const MagicProvider = {
|
|
42
|
+
Email: "email",
|
|
43
|
+
Apple: "apple",
|
|
44
|
+
Github: "github",
|
|
45
|
+
Google: "google",
|
|
46
|
+
Discord: "discord",
|
|
47
|
+
Twitter: "twitter",
|
|
48
|
+
Facebook: "facebook"
|
|
49
|
+
};
|
|
50
|
+
const WalletDeviceType = {
|
|
51
|
+
Mobile: "mobile",
|
|
52
|
+
Other: "other",
|
|
53
|
+
Browser: "browser",
|
|
54
|
+
Hardware: "hardware"
|
|
55
|
+
};
|
|
56
|
+
const WalletEventListener = {
|
|
57
|
+
AccountChange: "account-change",
|
|
58
|
+
ChainIdChange: "chain-id-change"
|
|
59
|
+
};
|
|
60
|
+
const WalletAction = { ...WalletErrorActionModule };
|
|
61
|
+
|
|
62
|
+
//#endregion
|
|
63
|
+
//#region src/types/strategy.ts
|
|
64
|
+
const TurnkeyProvider = {
|
|
65
|
+
Email: "email",
|
|
66
|
+
Google: "google",
|
|
67
|
+
Apple: "apple"
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
//#endregion
|
|
71
|
+
//#region src/utils/tx.ts
|
|
72
|
+
const createEip712StdSignDoc = ({ memo, chainId, accountNumber, timeoutHeight, sequence, gas, msgs }) => ({
|
|
73
|
+
chain_id: chainId,
|
|
74
|
+
timeout_height: timeoutHeight || "",
|
|
75
|
+
account_number: accountNumber.toString(),
|
|
76
|
+
sequence: sequence.toString(),
|
|
77
|
+
fee: getStdFee({ gas }),
|
|
78
|
+
msgs: msgs.map((m) => m.toEip712()),
|
|
79
|
+
memo: memo || ""
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
//#endregion
|
|
83
|
+
//#region src/utils/viem.ts
|
|
84
|
+
const getEvmChainConfig = (chainId) => {
|
|
85
|
+
if (chainId === EvmChainId.DevnetEvm) return {
|
|
86
|
+
id: EvmChainId.DevnetEvm,
|
|
87
|
+
name: "Injective EVM Devnet",
|
|
88
|
+
nativeCurrency: injective.nativeCurrency,
|
|
89
|
+
rpcUrls: { default: { http: ["https://devnet.json-rpc.injective.dev"] } },
|
|
90
|
+
blockExplorers: { default: {
|
|
91
|
+
name: "",
|
|
92
|
+
url: ""
|
|
93
|
+
} },
|
|
94
|
+
testnet: true
|
|
95
|
+
};
|
|
96
|
+
try {
|
|
97
|
+
return extractChain({
|
|
98
|
+
id: chainId,
|
|
99
|
+
chains: Object.values(viemChains)
|
|
100
|
+
});
|
|
101
|
+
} catch (_unused) {
|
|
102
|
+
throw new Error(`Unsupported chainId: ${chainId}`);
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
const getViemPublicClient = (chainId, rpcUrl) => {
|
|
106
|
+
const chain = getEvmChainConfig(chainId);
|
|
107
|
+
if ([EvmChainId.Mainnet, EvmChainId.Sepolia].includes(chainId) && rpcUrl && !rpcUrl.includes("alchemyapi")) throw new Error(`An Alchemy RPC URL must be provided for EvmChainId ${chainId}`);
|
|
108
|
+
return createPublicClient({
|
|
109
|
+
chain: rpcUrl ? {
|
|
110
|
+
...chain,
|
|
111
|
+
rpcUrls: {
|
|
112
|
+
default: { http: [rpcUrl] },
|
|
113
|
+
public: { http: [rpcUrl] }
|
|
114
|
+
}
|
|
115
|
+
} : chain,
|
|
116
|
+
transport: rpcUrl ? http(rpcUrl) : http()
|
|
117
|
+
});
|
|
118
|
+
};
|
|
119
|
+
const getViemWalletClient = ({ chainId, account, rpcUrl }) => {
|
|
120
|
+
const chain = getEvmChainConfig(chainId);
|
|
121
|
+
return createWalletClient({
|
|
122
|
+
chain: rpcUrl ? {
|
|
123
|
+
...chain,
|
|
124
|
+
rpcUrls: {
|
|
125
|
+
default: { http: [rpcUrl] },
|
|
126
|
+
public: { http: [rpcUrl] }
|
|
127
|
+
}
|
|
128
|
+
} : chain,
|
|
129
|
+
transport: rpcUrl ? http(rpcUrl) : http(),
|
|
130
|
+
account: typeof account === "string" ? account : account
|
|
131
|
+
});
|
|
132
|
+
};
|
|
133
|
+
const getViemPublicClientFromEip1193Provider = (chainId, provider) => {
|
|
134
|
+
return createPublicClient({
|
|
135
|
+
chain: getEvmChainConfig(chainId),
|
|
136
|
+
transport: custom(provider)
|
|
137
|
+
});
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
//#endregion
|
|
141
|
+
//#region src/utils/wallet.ts
|
|
142
|
+
const isEvmWallet = (wallet) => [
|
|
143
|
+
Wallet.Magic,
|
|
144
|
+
Wallet.Rabby,
|
|
145
|
+
Wallet.BitGet,
|
|
146
|
+
Wallet.Ledger,
|
|
147
|
+
Wallet.Phantom,
|
|
148
|
+
Wallet.Rainbow,
|
|
149
|
+
Wallet.Turnkey,
|
|
150
|
+
Wallet.Metamask,
|
|
151
|
+
Wallet.KeplrEvm,
|
|
152
|
+
Wallet.OkxWallet,
|
|
153
|
+
Wallet.PrivateKey,
|
|
154
|
+
Wallet.TrezorBip32,
|
|
155
|
+
Wallet.TrezorBip44,
|
|
156
|
+
Wallet.TrustWallet,
|
|
157
|
+
Wallet.LedgerLegacy,
|
|
158
|
+
Wallet.WalletConnect,
|
|
159
|
+
Wallet.CosmostationEth
|
|
160
|
+
].includes(wallet);
|
|
161
|
+
const isCosmosWallet = (wallet) => !isEvmWallet(wallet);
|
|
162
|
+
const isEvmBrowserWallet = (wallet) => [
|
|
163
|
+
Wallet.Rabby,
|
|
164
|
+
Wallet.BitGet,
|
|
165
|
+
Wallet.Phantom,
|
|
166
|
+
Wallet.Rainbow,
|
|
167
|
+
Wallet.Metamask,
|
|
168
|
+
Wallet.KeplrEvm,
|
|
169
|
+
Wallet.OkxWallet,
|
|
170
|
+
Wallet.TrustWallet
|
|
171
|
+
].includes(wallet);
|
|
172
|
+
const isCosmosBrowserWallet = (wallet) => [
|
|
173
|
+
Wallet.Leap,
|
|
174
|
+
Wallet.Keplr,
|
|
175
|
+
Wallet.Ninji,
|
|
176
|
+
Wallet.OWallet,
|
|
177
|
+
Wallet.Cosmostation
|
|
178
|
+
].includes(wallet);
|
|
179
|
+
const isEip712V2OnlyWallet = (wallet) => [
|
|
180
|
+
Wallet.Magic,
|
|
181
|
+
Wallet.Phantom,
|
|
182
|
+
Wallet.Metamask,
|
|
183
|
+
Wallet.WalletConnect
|
|
184
|
+
].includes(wallet);
|
|
185
|
+
const isCosmosAminoOnlyWallet = (wallet) => [Wallet.LedgerCosmos].includes(wallet);
|
|
186
|
+
|
|
187
|
+
//#endregion
|
|
188
|
+
//#region src/utils/cosmos.ts
|
|
189
|
+
const createCosmosSignDocFromSignDoc = (signDoc) => {
|
|
190
|
+
return CosmosTxV1Beta1TxPb.SignDoc.create({
|
|
191
|
+
bodyBytes: signDoc.bodyBytes,
|
|
192
|
+
authInfoBytes: signDoc.authInfoBytes,
|
|
193
|
+
accountNumber: BigInt(signDoc.accountNumber),
|
|
194
|
+
chainId: signDoc.chainId
|
|
195
|
+
});
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
//#endregion
|
|
199
|
+
//#region src/utils/address.ts
|
|
200
|
+
const getInjectiveSignerAddress = (address) => {
|
|
201
|
+
if (!address) return "";
|
|
202
|
+
if (address.startsWith("inj")) return address;
|
|
203
|
+
if (address.startsWith("0x")) return getInjectiveAddress(address);
|
|
204
|
+
return "";
|
|
205
|
+
};
|
|
206
|
+
const getEthereumSignerAddress = (address) => {
|
|
207
|
+
if (!address) return "";
|
|
208
|
+
if (address.startsWith("0x")) return address;
|
|
209
|
+
if (address.startsWith("inj")) return getEthereumAddress(address);
|
|
210
|
+
return "";
|
|
211
|
+
};
|
|
212
|
+
|
|
213
|
+
//#endregion
|
|
214
|
+
//#region src/utils/constants.ts
|
|
215
|
+
const GWEI_IN_WEI = toBigNumber(1e9);
|
|
216
|
+
const TIP_IN_GWEI = toBigNumber(2).times(GWEI_IN_WEI);
|
|
217
|
+
const DEFAULT_BASE_DERIVATION_PATH = "m/44'/60'";
|
|
218
|
+
const DEFAULT_NUM_ADDRESSES_TO_FETCH = 5;
|
|
219
|
+
const DEFAULT_ADDRESS_SEARCH_LIMIT = 100;
|
|
220
|
+
|
|
221
|
+
//#endregion
|
|
222
|
+
//#region \0@oxc-project+runtime@0.98.0/helpers/typeof.js
|
|
223
|
+
function _typeof(o) {
|
|
224
|
+
"@babel/helpers - typeof";
|
|
225
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o$1) {
|
|
226
|
+
return typeof o$1;
|
|
227
|
+
} : function(o$1) {
|
|
228
|
+
return o$1 && "function" == typeof Symbol && o$1.constructor === Symbol && o$1 !== Symbol.prototype ? "symbol" : typeof o$1;
|
|
229
|
+
}, _typeof(o);
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
//#endregion
|
|
233
|
+
//#region \0@oxc-project+runtime@0.98.0/helpers/toPrimitive.js
|
|
234
|
+
function toPrimitive(t, r) {
|
|
235
|
+
if ("object" != _typeof(t) || !t) return t;
|
|
236
|
+
var e = t[Symbol.toPrimitive];
|
|
237
|
+
if (void 0 !== e) {
|
|
238
|
+
var i = e.call(t, r || "default");
|
|
239
|
+
if ("object" != _typeof(i)) return i;
|
|
240
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
241
|
+
}
|
|
242
|
+
return ("string" === r ? String : Number)(t);
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
//#endregion
|
|
246
|
+
//#region \0@oxc-project+runtime@0.98.0/helpers/toPropertyKey.js
|
|
247
|
+
function toPropertyKey(t) {
|
|
248
|
+
var i = toPrimitive(t, "string");
|
|
249
|
+
return "symbol" == _typeof(i) ? i : i + "";
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
//#endregion
|
|
253
|
+
//#region \0@oxc-project+runtime@0.98.0/helpers/defineProperty.js
|
|
254
|
+
function _defineProperty(e, r, t) {
|
|
255
|
+
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
256
|
+
value: t,
|
|
257
|
+
enumerable: !0,
|
|
258
|
+
configurable: !0,
|
|
259
|
+
writable: !0
|
|
260
|
+
}) : e[r] = t, e;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
//#endregion
|
|
264
|
+
//#region src/base.ts
|
|
265
|
+
var BaseConcreteStrategy = class {
|
|
266
|
+
constructor(args) {
|
|
267
|
+
_defineProperty(this, "chainId", void 0);
|
|
268
|
+
_defineProperty(this, "evmChainId", void 0);
|
|
269
|
+
_defineProperty(this, "listeners", {});
|
|
270
|
+
_defineProperty(this, "metadata", void 0);
|
|
271
|
+
this.evmChainId = "evmOptions" in args && args.evmOptions ? args.evmOptions.evmChainId : void 0;
|
|
272
|
+
this.chainId = args.chainId;
|
|
273
|
+
this.metadata = args.metadata;
|
|
274
|
+
}
|
|
275
|
+
};
|
|
276
|
+
|
|
277
|
+
//#endregion
|
|
278
|
+
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 };
|
package/dist/esm/package.json
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
}
|
|
2
|
+
"type": "module"
|
|
3
|
+
}
|
package/package.json
CHANGED
|
@@ -1,70 +1,68 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@injectivelabs/wallet-base",
|
|
3
|
+
"version": "1.16.39-alpha.1",
|
|
3
4
|
"description": "Base wallet strategy for use with @injectivelabs/wallet-core.",
|
|
4
|
-
"
|
|
5
|
-
"sideEffects": false,
|
|
6
|
-
"type": "module",
|
|
5
|
+
"license": "Apache-2.0",
|
|
7
6
|
"author": {
|
|
8
7
|
"name": "InjectiveLabs",
|
|
9
8
|
"email": "admin@injectivelabs.org"
|
|
10
9
|
},
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
-
"main": "dist/cjs/index.js",
|
|
14
|
-
"module": "dist/esm/index.js",
|
|
15
|
-
"files": [
|
|
16
|
-
"dist"
|
|
17
|
-
],
|
|
18
|
-
"_moduleAliases": {
|
|
19
|
-
"~wallet-base": "dist"
|
|
20
|
-
},
|
|
10
|
+
"type": "module",
|
|
11
|
+
"sideEffects": false,
|
|
21
12
|
"exports": {
|
|
22
13
|
".": {
|
|
23
14
|
"react-native": {
|
|
24
15
|
"import": "./dist/esm/index.js",
|
|
25
|
-
"require": "./dist/cjs/index.
|
|
26
|
-
"types": "./dist/cjs/index.d.
|
|
27
|
-
"default": "./dist/cjs/index.
|
|
16
|
+
"require": "./dist/cjs/index.cjs",
|
|
17
|
+
"types": "./dist/cjs/index.d.cts",
|
|
18
|
+
"default": "./dist/cjs/index.cjs"
|
|
28
19
|
},
|
|
29
20
|
"require": {
|
|
30
|
-
"types": "./dist/cjs/index.d.
|
|
31
|
-
"default": "./dist/cjs/index.
|
|
21
|
+
"types": "./dist/cjs/index.d.cts",
|
|
22
|
+
"default": "./dist/cjs/index.cjs"
|
|
32
23
|
},
|
|
33
24
|
"import": {
|
|
34
25
|
"types": "./dist/esm/index.d.ts",
|
|
35
26
|
"default": "./dist/esm/index.js"
|
|
36
27
|
},
|
|
37
28
|
"default": {
|
|
38
|
-
"types": "./dist/cjs/index.d.
|
|
39
|
-
"default": "./dist/cjs/index.
|
|
29
|
+
"types": "./dist/cjs/index.d.cts",
|
|
30
|
+
"default": "./dist/cjs/index.cjs"
|
|
40
31
|
}
|
|
41
32
|
}
|
|
42
33
|
},
|
|
43
|
-
"
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
"
|
|
48
|
-
|
|
49
|
-
"clean": "tsc --build tsconfig.build.json --clean && tsc --build tsconfig.build.esm.json --clean && shx rm -rf coverage *.log junit.xml dist && jest --clearCache && shx mkdir -p dist",
|
|
50
|
-
"test": "jest",
|
|
51
|
-
"test:watch": "jest --watch",
|
|
52
|
-
"test:ci": "jest --coverage --ci --reporters='jest-junit'",
|
|
53
|
-
"coverage": "jest --coverage",
|
|
54
|
-
"coverage:show": "live-server coverage",
|
|
55
|
-
"dev": "ts-node -r tsconfig-paths/register src/index.ts",
|
|
56
|
-
"start": "node dist/index.js"
|
|
57
|
-
},
|
|
34
|
+
"main": "dist/cjs/index.cjs",
|
|
35
|
+
"module": "dist/esm/index.js",
|
|
36
|
+
"types": "dist/cjs/index.d.cts",
|
|
37
|
+
"files": [
|
|
38
|
+
"dist"
|
|
39
|
+
],
|
|
58
40
|
"dependencies": {
|
|
59
|
-
"@injectivelabs/exceptions": "1.16.38",
|
|
60
|
-
"@injectivelabs/networks": "1.16.38",
|
|
61
|
-
"@injectivelabs/sdk-ts": "1.16.38",
|
|
62
|
-
"@injectivelabs/ts-types": "1.16.38",
|
|
63
41
|
"eip1193-provider": "^1.0.1",
|
|
64
|
-
"viem": "^2.
|
|
42
|
+
"viem": "^2.41.2",
|
|
43
|
+
"@injectivelabs/exceptions": "1.16.39-alpha.0",
|
|
44
|
+
"@injectivelabs/sdk-ts": "1.16.39-alpha.1",
|
|
45
|
+
"@injectivelabs/ts-types": "1.16.39-alpha.0"
|
|
65
46
|
},
|
|
66
|
-
"
|
|
67
|
-
"
|
|
47
|
+
"publishConfig": {
|
|
48
|
+
"access": "public"
|
|
68
49
|
},
|
|
69
|
-
"
|
|
70
|
-
|
|
50
|
+
"_moduleAliases": {
|
|
51
|
+
"~wallet-base": "dist"
|
|
52
|
+
},
|
|
53
|
+
"scripts": {
|
|
54
|
+
"build": "pnpm type-check && tsdown",
|
|
55
|
+
"build:fast": "tsdown",
|
|
56
|
+
"build:watch": "tsdown --watch",
|
|
57
|
+
"clean": "shx rm -rf dist coverage *.log junit.xml && shx mkdir -p dist",
|
|
58
|
+
"type-check": "tsc --noEmit",
|
|
59
|
+
"test": "vitest",
|
|
60
|
+
"test:watch": "vitest --watch",
|
|
61
|
+
"test:ci": "vitest run --coverage --reporter=verbose",
|
|
62
|
+
"coverage": "vitest run --coverage",
|
|
63
|
+
"coverage:show": "live-server coverage",
|
|
64
|
+
"dev": "ts-node -r tsconfig-paths/register src/index.ts",
|
|
65
|
+
"start": "node dist/index.js",
|
|
66
|
+
"lint": "eslint . --ext .ts,.js"
|
|
67
|
+
}
|
|
68
|
+
}
|
package/dist/cjs/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/cjs/base.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
class BaseConcreteStrategy {
|
|
4
|
-
chainId;
|
|
5
|
-
evmChainId;
|
|
6
|
-
listeners = {};
|
|
7
|
-
metadata;
|
|
8
|
-
constructor(args) {
|
|
9
|
-
this.evmChainId =
|
|
10
|
-
'evmOptions' in args && args.evmOptions
|
|
11
|
-
? args.evmOptions.evmChainId
|
|
12
|
-
: undefined;
|
|
13
|
-
this.chainId = args.chainId;
|
|
14
|
-
this.metadata = args.metadata;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
exports.default = BaseConcreteStrategy;
|
package/dist/cjs/index.d.ts
DELETED
package/dist/cjs/index.js
DELETED
|
@@ -1,24 +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
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
17
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
|
-
};
|
|
19
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
exports.BaseConcreteStrategy = void 0;
|
|
21
|
-
__exportStar(require("./types/index.js"), exports);
|
|
22
|
-
__exportStar(require("./utils/index.js"), exports);
|
|
23
|
-
var base_js_1 = require("./base.js");
|
|
24
|
-
Object.defineProperty(exports, "BaseConcreteStrategy", { enumerable: true, get: function () { return __importDefault(base_js_1).default; } });
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
export declare const BroadcastMode: {
|
|
2
|
-
readonly Block: "block";
|
|
3
|
-
readonly Sync: "sync";
|
|
4
|
-
readonly Async: "async";
|
|
5
|
-
};
|
|
6
|
-
export type BroadcastMode = (typeof BroadcastMode)[keyof typeof BroadcastMode];
|
|
7
|
-
export declare const Wallet: {
|
|
8
|
-
readonly Leap: "leap";
|
|
9
|
-
readonly Keplr: "keplr";
|
|
10
|
-
readonly Ninji: "ninji";
|
|
11
|
-
readonly Magic: "magic";
|
|
12
|
-
readonly Rabby: "rabby";
|
|
13
|
-
readonly Ledger: "ledger";
|
|
14
|
-
readonly BitGet: "BitGet";
|
|
15
|
-
readonly OWallet: "owallet";
|
|
16
|
-
readonly Phantom: "phantom";
|
|
17
|
-
readonly Rainbow: "rainbow";
|
|
18
|
-
readonly Turnkey: "turnkey";
|
|
19
|
-
readonly Metamask: "metamask";
|
|
20
|
-
readonly OkxWallet: "okx-wallet";
|
|
21
|
-
readonly PrivateKey: "private-key";
|
|
22
|
-
readonly TrustWallet: "trust-wallet";
|
|
23
|
-
readonly TrezorBip32: "trezor-bip32";
|
|
24
|
-
readonly TrezorBip44: "trezor-bip44";
|
|
25
|
-
readonly Cosmostation: "cosmostation";
|
|
26
|
-
readonly LedgerCosmos: "ledger-cosmos";
|
|
27
|
-
readonly LedgerLegacy: "ledger-legacy";
|
|
28
|
-
readonly WalletConnect: "wallet-connect";
|
|
29
|
-
readonly CosmostationEth: "cosmostation-eth";
|
|
30
|
-
};
|
|
31
|
-
export type Wallet = (typeof Wallet)[keyof typeof Wallet];
|
|
32
|
-
export declare const MagicProvider: {
|
|
33
|
-
readonly Email: "email";
|
|
34
|
-
readonly Apple: "apple";
|
|
35
|
-
readonly Github: "github";
|
|
36
|
-
readonly Google: "google";
|
|
37
|
-
readonly Discord: "discord";
|
|
38
|
-
readonly Twitter: "twitter";
|
|
39
|
-
readonly Facebook: "facebook";
|
|
40
|
-
};
|
|
41
|
-
export type MagicProvider = (typeof MagicProvider)[keyof typeof MagicProvider];
|
|
42
|
-
export declare const WalletDeviceType: {
|
|
43
|
-
readonly Mobile: "mobile";
|
|
44
|
-
readonly Other: "other";
|
|
45
|
-
readonly Browser: "browser";
|
|
46
|
-
readonly Hardware: "hardware";
|
|
47
|
-
};
|
|
48
|
-
export type WalletDeviceType = (typeof WalletDeviceType)[keyof typeof WalletDeviceType];
|
|
49
|
-
export declare const WalletEventListener: {
|
|
50
|
-
readonly AccountChange: "account-change";
|
|
51
|
-
readonly ChainIdChange: "chain-id-change";
|
|
52
|
-
};
|
|
53
|
-
export type WalletEventListener = (typeof WalletEventListener)[keyof typeof WalletEventListener];
|
|
54
|
-
export declare const WalletAction: {
|
|
55
|
-
GetChainId: "get-chain-id";
|
|
56
|
-
GetAccounts: "get-accounts";
|
|
57
|
-
GetNetworkId: "get-network-id";
|
|
58
|
-
SignArbitrary: "sign-arbitrary";
|
|
59
|
-
SignTransaction: "sign-transaction";
|
|
60
|
-
SendTransaction: "send-transaction";
|
|
61
|
-
SendEvmTransaction: "send-evm-transaction";
|
|
62
|
-
SignEvmTransaction: "sign-evm-transaction";
|
|
63
|
-
GetEvmTransactionReceipt: "get-evm-transaction-receipt";
|
|
64
|
-
};
|
package/dist/cjs/types/enums.js
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.WalletAction = exports.WalletEventListener = exports.WalletDeviceType = exports.MagicProvider = exports.Wallet = exports.BroadcastMode = void 0;
|
|
4
|
-
const exceptions_1 = require("@injectivelabs/exceptions");
|
|
5
|
-
exports.BroadcastMode = {
|
|
6
|
-
Block: 'block',
|
|
7
|
-
Sync: 'sync',
|
|
8
|
-
Async: 'async',
|
|
9
|
-
};
|
|
10
|
-
exports.Wallet = {
|
|
11
|
-
Leap: 'leap',
|
|
12
|
-
Keplr: 'keplr',
|
|
13
|
-
Ninji: 'ninji',
|
|
14
|
-
Magic: 'magic',
|
|
15
|
-
Rabby: 'rabby',
|
|
16
|
-
Ledger: 'ledger',
|
|
17
|
-
BitGet: 'BitGet',
|
|
18
|
-
OWallet: 'owallet',
|
|
19
|
-
Phantom: 'phantom',
|
|
20
|
-
Rainbow: 'rainbow',
|
|
21
|
-
Turnkey: 'turnkey',
|
|
22
|
-
Metamask: 'metamask',
|
|
23
|
-
OkxWallet: 'okx-wallet',
|
|
24
|
-
PrivateKey: 'private-key',
|
|
25
|
-
TrustWallet: 'trust-wallet',
|
|
26
|
-
TrezorBip32: 'trezor-bip32',
|
|
27
|
-
TrezorBip44: 'trezor-bip44',
|
|
28
|
-
Cosmostation: 'cosmostation',
|
|
29
|
-
LedgerCosmos: 'ledger-cosmos',
|
|
30
|
-
LedgerLegacy: 'ledger-legacy',
|
|
31
|
-
WalletConnect: 'wallet-connect',
|
|
32
|
-
CosmostationEth: 'cosmostation-eth',
|
|
33
|
-
};
|
|
34
|
-
exports.MagicProvider = {
|
|
35
|
-
Email: 'email',
|
|
36
|
-
Apple: 'apple',
|
|
37
|
-
Github: 'github',
|
|
38
|
-
Google: 'google',
|
|
39
|
-
Discord: 'discord',
|
|
40
|
-
Twitter: 'twitter',
|
|
41
|
-
Facebook: 'facebook',
|
|
42
|
-
};
|
|
43
|
-
exports.WalletDeviceType = {
|
|
44
|
-
Mobile: 'mobile',
|
|
45
|
-
Other: 'other',
|
|
46
|
-
Browser: 'browser',
|
|
47
|
-
Hardware: 'hardware',
|
|
48
|
-
};
|
|
49
|
-
exports.WalletEventListener = {
|
|
50
|
-
AccountChange: 'account-change',
|
|
51
|
-
ChainIdChange: 'chain-id-change',
|
|
52
|
-
};
|
|
53
|
-
exports.WalletAction = { ...exceptions_1.WalletErrorActionModule };
|
package/dist/cjs/types/index.js
DELETED
|
@@ -1,18 +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("./enums.js"), exports);
|
|
18
|
-
__exportStar(require("./strategy.js"), exports);
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import type { EIP1193Provider } from 'eip1193-provider';
|
|
2
|
-
export interface BrowserEip1993Provider extends EIP1193Provider {
|
|
3
|
-
removeAllListeners(): void;
|
|
4
|
-
isTrust: boolean;
|
|
5
|
-
isRabby: boolean;
|
|
6
|
-
isRainbow: boolean;
|
|
7
|
-
isPhantom: boolean;
|
|
8
|
-
isMetaMask: boolean;
|
|
9
|
-
isOkxWallet: boolean;
|
|
10
|
-
isTrustWallet: boolean;
|
|
11
|
-
}
|
|
12
|
-
export interface WindowWithEip1193Provider extends Window {
|
|
13
|
-
rainbow: BrowserEip1993Provider;
|
|
14
|
-
rabby: BrowserEip1993Provider;
|
|
15
|
-
ethereum: BrowserEip1993Provider;
|
|
16
|
-
okxwallet: BrowserEip1993Provider;
|
|
17
|
-
providers: BrowserEip1993Provider[];
|
|
18
|
-
trustWallet?: BrowserEip1993Provider;
|
|
19
|
-
bitkeep: {
|
|
20
|
-
ethereum: BrowserEip1993Provider;
|
|
21
|
-
};
|
|
22
|
-
phantom?: {
|
|
23
|
-
ethereum?: BrowserEip1993Provider;
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
export interface EIP6963ProviderInfo {
|
|
27
|
-
rdns: string;
|
|
28
|
-
uuid: string;
|
|
29
|
-
name: string;
|
|
30
|
-
icon: string;
|
|
31
|
-
}
|
|
32
|
-
export interface EIP6963ProviderDetail {
|
|
33
|
-
info: EIP6963ProviderInfo;
|
|
34
|
-
provider: BrowserEip1993Provider;
|
|
35
|
-
}
|
|
36
|
-
export type EIP6963AnnounceProviderEvent = {
|
|
37
|
-
detail: EIP6963ProviderDetail;
|
|
38
|
-
};
|