@injectivelabs/wallet-base 1.20.8 → 1.20.9
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/base-BGVbNgzY.d.cts +473 -0
- package/dist/cjs/base-CCDH4BFB.cjs +316 -0
- package/dist/cjs/index.cjs +22 -226
- package/dist/cjs/index.d.cts +4 -473
- package/dist/cjs/light.cjs +20 -0
- package/dist/cjs/light.d.cts +2 -0
- package/dist/esm/base-Bek8jyaS.d.ts +473 -0
- package/dist/esm/base-DDrF_yw2.js +208 -0
- package/dist/esm/index.d.ts +4 -473
- package/dist/esm/index.js +2 -207
- package/dist/esm/light.d.ts +2 -0
- package/dist/esm/light.js +3 -0
- package/package.json +24 -4
package/dist/esm/index.js
CHANGED
|
@@ -1,101 +1,12 @@
|
|
|
1
|
-
import {
|
|
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-DDrF_yw2.js";
|
|
2
2
|
import { getStdFee, toBigNumber } from "@injectivelabs/utils";
|
|
3
3
|
import * as viemChains from "viem/chains";
|
|
4
4
|
import { injective } from "viem/chains";
|
|
5
5
|
import { EvmChainId } from "@injectivelabs/ts-types";
|
|
6
6
|
import { createPublicClient, createWalletClient, custom, extractChain, http } from "viem";
|
|
7
|
-
import { CosmosTxV1Beta1TxPb } from "@injectivelabs/sdk-ts";
|
|
7
|
+
import { CosmosTxV1Beta1TxPb } from "@injectivelabs/sdk-ts/proto/cosmos-tx";
|
|
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
|
-
TransactionBroadcastSynced: "transaction-broadcast-synced",
|
|
25
|
-
TransactionPreparationEnd: "transaction-preparation-end",
|
|
26
|
-
TransactionPreparationStart: "transaction-preparation-start",
|
|
27
|
-
WalletStrategyDisconnect: "wallet-strategy-disconnect"
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
//#endregion
|
|
31
|
-
//#region src/types/enums.ts
|
|
32
|
-
const BroadcastMode = {
|
|
33
|
-
Block: "block",
|
|
34
|
-
Sync: "sync",
|
|
35
|
-
Async: "async"
|
|
36
|
-
};
|
|
37
|
-
const Wallet = {
|
|
38
|
-
Leap: "leap",
|
|
39
|
-
Keplr: "keplr",
|
|
40
|
-
Ninji: "ninji",
|
|
41
|
-
Magic: "magic",
|
|
42
|
-
Rabby: "rabby",
|
|
43
|
-
Ledger: "ledger",
|
|
44
|
-
BitGet: "BitGet",
|
|
45
|
-
OWallet: "owallet",
|
|
46
|
-
Phantom: "phantom",
|
|
47
|
-
Rainbow: "rainbow",
|
|
48
|
-
Turnkey: "turnkey",
|
|
49
|
-
Metamask: "metamask",
|
|
50
|
-
KeplrEvm: "keplr-evm",
|
|
51
|
-
OkxWallet: "okx-wallet",
|
|
52
|
-
PrivateKey: "private-key",
|
|
53
|
-
TrustWallet: "trust-wallet",
|
|
54
|
-
TrezorBip32: "trezor-bip32",
|
|
55
|
-
TrezorBip44: "trezor-bip44",
|
|
56
|
-
Cosmostation: "cosmostation",
|
|
57
|
-
LedgerCosmos: "ledger-cosmos",
|
|
58
|
-
LedgerLegacy: "ledger-legacy",
|
|
59
|
-
WalletConnect: "wallet-connect",
|
|
60
|
-
CosmostationEth: "cosmostation-eth"
|
|
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 = { ...WalletErrorActionModule };
|
|
87
|
-
|
|
88
|
-
//#endregion
|
|
89
|
-
//#region src/types/strategy.ts
|
|
90
|
-
const TurnkeyProvider = {
|
|
91
|
-
Sms: "sms",
|
|
92
|
-
Apple: "apple",
|
|
93
|
-
Email: "email",
|
|
94
|
-
Google: "google",
|
|
95
|
-
Twitter: "twitter"
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
//#endregion
|
|
99
10
|
//#region src/utils/tx.ts
|
|
100
11
|
const createEip712StdSignDoc = ({ memo, chainId, accountNumber, timeoutHeight, sequence, gas, msgs }) => ({
|
|
101
12
|
chain_id: chainId,
|
|
@@ -176,53 +87,6 @@ const getViemPublicClientFromEip1193Provider = (chainId, provider) => {
|
|
|
176
87
|
});
|
|
177
88
|
};
|
|
178
89
|
|
|
179
|
-
//#endregion
|
|
180
|
-
//#region src/utils/wallet.ts
|
|
181
|
-
const isEvmWallet = (wallet) => [
|
|
182
|
-
Wallet.Magic,
|
|
183
|
-
Wallet.Rabby,
|
|
184
|
-
Wallet.BitGet,
|
|
185
|
-
Wallet.Ledger,
|
|
186
|
-
Wallet.Phantom,
|
|
187
|
-
Wallet.Rainbow,
|
|
188
|
-
Wallet.Turnkey,
|
|
189
|
-
Wallet.Metamask,
|
|
190
|
-
Wallet.KeplrEvm,
|
|
191
|
-
Wallet.OkxWallet,
|
|
192
|
-
Wallet.PrivateKey,
|
|
193
|
-
Wallet.TrezorBip32,
|
|
194
|
-
Wallet.TrezorBip44,
|
|
195
|
-
Wallet.TrustWallet,
|
|
196
|
-
Wallet.LedgerLegacy,
|
|
197
|
-
Wallet.WalletConnect,
|
|
198
|
-
Wallet.CosmostationEth
|
|
199
|
-
].includes(wallet);
|
|
200
|
-
const isCosmosWallet = (wallet) => !isEvmWallet(wallet);
|
|
201
|
-
const isEvmBrowserWallet = (wallet) => [
|
|
202
|
-
Wallet.Rabby,
|
|
203
|
-
Wallet.BitGet,
|
|
204
|
-
Wallet.Phantom,
|
|
205
|
-
Wallet.Rainbow,
|
|
206
|
-
Wallet.Metamask,
|
|
207
|
-
Wallet.KeplrEvm,
|
|
208
|
-
Wallet.OkxWallet,
|
|
209
|
-
Wallet.TrustWallet
|
|
210
|
-
].includes(wallet);
|
|
211
|
-
const isCosmosBrowserWallet = (wallet) => [
|
|
212
|
-
Wallet.Leap,
|
|
213
|
-
Wallet.Keplr,
|
|
214
|
-
Wallet.Ninji,
|
|
215
|
-
Wallet.OWallet,
|
|
216
|
-
Wallet.Cosmostation
|
|
217
|
-
].includes(wallet);
|
|
218
|
-
const isEip712V2OnlyWallet = (wallet) => [
|
|
219
|
-
Wallet.Magic,
|
|
220
|
-
Wallet.Phantom,
|
|
221
|
-
Wallet.Metamask,
|
|
222
|
-
Wallet.WalletConnect
|
|
223
|
-
].includes(wallet);
|
|
224
|
-
const isCosmosAminoOnlyWallet = (wallet) => [Wallet.LedgerCosmos].includes(wallet);
|
|
225
|
-
|
|
226
90
|
//#endregion
|
|
227
91
|
//#region src/utils/cosmos.ts
|
|
228
92
|
const createCosmosSignDocFromSignDoc = (signDoc) => {
|
|
@@ -257,74 +121,5 @@ const DEFAULT_BASE_DERIVATION_PATH = "m/44'/60'";
|
|
|
257
121
|
const DEFAULT_NUM_ADDRESSES_TO_FETCH = 5;
|
|
258
122
|
const DEFAULT_ADDRESS_SEARCH_LIMIT = 100;
|
|
259
123
|
|
|
260
|
-
//#endregion
|
|
261
|
-
//#region \0@oxc-project+runtime@0.99.0/helpers/typeof.js
|
|
262
|
-
function _typeof(o) {
|
|
263
|
-
"@babel/helpers - typeof";
|
|
264
|
-
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o$1) {
|
|
265
|
-
return typeof o$1;
|
|
266
|
-
} : function(o$1) {
|
|
267
|
-
return o$1 && "function" == typeof Symbol && o$1.constructor === Symbol && o$1 !== Symbol.prototype ? "symbol" : typeof o$1;
|
|
268
|
-
}, _typeof(o);
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
//#endregion
|
|
272
|
-
//#region \0@oxc-project+runtime@0.99.0/helpers/toPrimitive.js
|
|
273
|
-
function toPrimitive(t, r) {
|
|
274
|
-
if ("object" != _typeof(t) || !t) return t;
|
|
275
|
-
var e = t[Symbol.toPrimitive];
|
|
276
|
-
if (void 0 !== e) {
|
|
277
|
-
var i = e.call(t, r || "default");
|
|
278
|
-
if ("object" != _typeof(i)) return i;
|
|
279
|
-
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
280
|
-
}
|
|
281
|
-
return ("string" === r ? String : Number)(t);
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
//#endregion
|
|
285
|
-
//#region \0@oxc-project+runtime@0.99.0/helpers/toPropertyKey.js
|
|
286
|
-
function toPropertyKey(t) {
|
|
287
|
-
var i = toPrimitive(t, "string");
|
|
288
|
-
return "symbol" == _typeof(i) ? i : i + "";
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
//#endregion
|
|
292
|
-
//#region \0@oxc-project+runtime@0.99.0/helpers/defineProperty.js
|
|
293
|
-
function _defineProperty(e, r, t) {
|
|
294
|
-
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
295
|
-
value: t,
|
|
296
|
-
enumerable: !0,
|
|
297
|
-
configurable: !0,
|
|
298
|
-
writable: !0
|
|
299
|
-
}) : e[r] = t, e;
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
//#endregion
|
|
303
|
-
//#region src/base.ts
|
|
304
|
-
var BaseConcreteStrategy = class {
|
|
305
|
-
constructor(args) {
|
|
306
|
-
_defineProperty(this, "chainId", void 0);
|
|
307
|
-
_defineProperty(this, "evmChainId", void 0);
|
|
308
|
-
_defineProperty(this, "listeners", {});
|
|
309
|
-
_defineProperty(this, "metadata", void 0);
|
|
310
|
-
_defineProperty(this, "emitter", void 0);
|
|
311
|
-
this.evmChainId = "evmOptions" in args && args.evmOptions ? args.evmOptions.evmChainId : void 0;
|
|
312
|
-
this.chainId = args.chainId;
|
|
313
|
-
this.metadata = args.metadata;
|
|
314
|
-
this.emitter = args.emitter;
|
|
315
|
-
}
|
|
316
|
-
setMetadata(metadata) {
|
|
317
|
-
this.metadata = metadata;
|
|
318
|
-
}
|
|
319
|
-
/**
|
|
320
|
-
* Emit an event from this strategy.
|
|
321
|
-
* If emitter was provided from parent, events go directly to parent.
|
|
322
|
-
*/
|
|
323
|
-
emit(event, data) {
|
|
324
|
-
var _this$emitter;
|
|
325
|
-
(_this$emitter = this.emitter) === null || _this$emitter === void 0 || _this$emitter.emit(event, data);
|
|
326
|
-
}
|
|
327
|
-
};
|
|
328
|
-
|
|
329
124
|
//#endregion
|
|
330
125
|
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 };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { A as WalletConnectMetadata, B as Wallet, C as SendTransactionOptions, D as TurnkeyOAuthProvider, E as TurnkeyMetadata, F as onAccountChangeCallback, G as WalletConnectStrategyEventType, H as WalletDeviceType, I as onChainIdChangeCallback, J as WalletStrategyEmitterEvents, K as WalletStrategyEmitter, L as BroadcastMode, M as WalletStrategy, N as WalletStrategyArguments, O as TurnkeyProvider, P as WalletStrategyEvmOptions, R as EvmWalletProviderErrorCode, S as PrivateKeyMetadata, T as StrategyEmitter, U as WalletEventListener, V as WalletAction, W as StrategyEventType, _ as ConcreteWalletStrategy, a as isEip712V2OnlyWallet, b as Eip1193Provider, c as BrowserEip1993Provider, d as EIP6963ProviderInfo, f as WindowWithEip1193Provider, g as ConcreteStrategiesArg, h as ConcreteEvmWalletStrategyArgs, i as isCosmosWallet, j as WalletMetadata, k as TurnkeySession, l as EIP6963AnnounceProviderEvent, m as ConcreteCosmosWalletStrategyArgs, n as isCosmosAminoOnlyWallet, o as isEvmBrowserWallet, p as ConcreteCosmosWalletStrategy, q as WalletStrategyEmitterEventType, r as isCosmosBrowserWallet, s as isEvmWallet, t as BaseConcreteStrategy, u as EIP6963ProviderDetail, v as ConcreteWalletStrategyArgs, w as StdSignDoc, x as MagicMetadata, y as CosmosWalletAbstraction, z as MagicProvider } from "./base-Bek8jyaS.js";
|
|
2
|
+
export { BaseConcreteStrategy, BroadcastMode, BrowserEip1993Provider, ConcreteCosmosWalletStrategy, ConcreteCosmosWalletStrategyArgs, ConcreteEvmWalletStrategyArgs, ConcreteStrategiesArg, ConcreteWalletStrategy, ConcreteWalletStrategyArgs, CosmosWalletAbstraction, EIP6963AnnounceProviderEvent, EIP6963ProviderDetail, EIP6963ProviderInfo, Eip1193Provider, EvmWalletProviderErrorCode, MagicMetadata, MagicProvider, PrivateKeyMetadata, SendTransactionOptions, StdSignDoc, StrategyEmitter, StrategyEventType, TurnkeyMetadata, TurnkeyOAuthProvider, TurnkeyProvider, TurnkeySession, Wallet, WalletAction, WalletConnectMetadata, WalletConnectStrategyEventType, WalletDeviceType, WalletEventListener, WalletMetadata, WalletStrategy, WalletStrategyArguments, WalletStrategyEmitter, WalletStrategyEmitterEventType, WalletStrategyEmitterEvents, WalletStrategyEvmOptions, WindowWithEip1193Provider, isCosmosAminoOnlyWallet, isCosmosBrowserWallet, isCosmosWallet, isEip712V2OnlyWallet, isEvmBrowserWallet, isEvmWallet, onAccountChangeCallback, onChainIdChangeCallback };
|
|
@@ -0,0 +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-DDrF_yw2.js";
|
|
2
|
+
|
|
3
|
+
export { BaseConcreteStrategy, BroadcastMode, EvmWalletProviderErrorCode, MagicProvider, StrategyEventType, TurnkeyProvider, Wallet, WalletAction, WalletConnectStrategyEventType, WalletDeviceType, WalletEventListener, WalletStrategyEmitterEventType, isCosmosAminoOnlyWallet, isCosmosBrowserWallet, isCosmosWallet, isEip712V2OnlyWallet, isEvmBrowserWallet, isEvmWallet };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@injectivelabs/wallet-base",
|
|
3
|
-
"version": "1.20.
|
|
3
|
+
"version": "1.20.9",
|
|
4
4
|
"description": "Base wallet strategy for use with @injectivelabs/wallet-core.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": {
|
|
@@ -33,6 +33,26 @@
|
|
|
33
33
|
"types": "./dist/cjs/index.d.cts",
|
|
34
34
|
"default": "./dist/cjs/index.cjs"
|
|
35
35
|
}
|
|
36
|
+
},
|
|
37
|
+
"./light": {
|
|
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"
|
|
43
|
+
},
|
|
44
|
+
"require": {
|
|
45
|
+
"types": "./dist/cjs/light.d.cts",
|
|
46
|
+
"default": "./dist/cjs/light.cjs"
|
|
47
|
+
},
|
|
48
|
+
"import": {
|
|
49
|
+
"types": "./dist/esm/light.d.ts",
|
|
50
|
+
"default": "./dist/esm/light.js"
|
|
51
|
+
},
|
|
52
|
+
"default": {
|
|
53
|
+
"types": "./dist/cjs/light.d.cts",
|
|
54
|
+
"default": "./dist/cjs/light.cjs"
|
|
55
|
+
}
|
|
36
56
|
}
|
|
37
57
|
},
|
|
38
58
|
"main": "dist/cjs/index.cjs",
|
|
@@ -44,9 +64,9 @@
|
|
|
44
64
|
"dependencies": {
|
|
45
65
|
"eip1193-provider": "^1.0.1",
|
|
46
66
|
"viem": "^2.41.2",
|
|
47
|
-
"@injectivelabs/
|
|
48
|
-
"@injectivelabs/
|
|
49
|
-
"@injectivelabs/sdk-ts": "1.20.
|
|
67
|
+
"@injectivelabs/exceptions": "1.20.9",
|
|
68
|
+
"@injectivelabs/ts-types": "1.20.9",
|
|
69
|
+
"@injectivelabs/sdk-ts": "1.20.9"
|
|
50
70
|
},
|
|
51
71
|
"publishConfig": {
|
|
52
72
|
"access": "public"
|