@injectivelabs/wallet-base 1.16.32 → 1.16.34

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.
@@ -1,6 +1,7 @@
1
- export * from './address.js';
2
1
  export * from './tx.js';
2
+ export * from './viem.js';
3
3
  export * from './wallet.js';
4
- export * from './constants.js';
5
- export * from './alchemy.js';
6
4
  export * from './cosmos.js';
5
+ export * from './address.js';
6
+ export * from './alchemy.js';
7
+ export * from './constants.js';
@@ -14,9 +14,10 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./address.js"), exports);
18
17
  __exportStar(require("./tx.js"), exports);
18
+ __exportStar(require("./viem.js"), exports);
19
19
  __exportStar(require("./wallet.js"), exports);
20
- __exportStar(require("./constants.js"), exports);
21
- __exportStar(require("./alchemy.js"), exports);
22
20
  __exportStar(require("./cosmos.js"), exports);
21
+ __exportStar(require("./address.js"), exports);
22
+ __exportStar(require("./alchemy.js"), exports);
23
+ __exportStar(require("./constants.js"), exports);
@@ -0,0 +1,9 @@
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;
@@ -0,0 +1,114 @@
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: [],
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,6 +1,7 @@
1
- export * from './address.js';
2
1
  export * from './tx.js';
2
+ export * from './viem.js';
3
3
  export * from './wallet.js';
4
- export * from './constants.js';
5
- export * from './alchemy.js';
6
4
  export * from './cosmos.js';
5
+ export * from './address.js';
6
+ export * from './alchemy.js';
7
+ export * from './constants.js';
@@ -1,6 +1,7 @@
1
- export * from './address.js';
2
1
  export * from './tx.js';
2
+ export * from './viem.js';
3
3
  export * from './wallet.js';
4
- export * from './constants.js';
5
- export * from './alchemy.js';
6
4
  export * from './cosmos.js';
5
+ export * from './address.js';
6
+ export * from './alchemy.js';
7
+ export * from './constants.js';
@@ -0,0 +1,9 @@
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;
@@ -0,0 +1,75 @@
1
+ import { injective } from 'viem/chains';
2
+ import * as viemChains from 'viem/chains';
3
+ import { EvmChainId } from '@injectivelabs/ts-types';
4
+ import { http, extractChain, createPublicClient, createWalletClient, } from 'viem';
5
+ export const getEvmChainConfig = (chainId) => {
6
+ if (chainId === EvmChainId.DevnetEvm) {
7
+ return {
8
+ id: EvmChainId.DevnetEvm,
9
+ name: 'Injective EVM Devnet',
10
+ nativeCurrency: injective.nativeCurrency,
11
+ rpcUrls: {
12
+ default: {
13
+ http: [],
14
+ },
15
+ },
16
+ blockExplorers: {
17
+ default: {
18
+ name: '',
19
+ url: '',
20
+ },
21
+ },
22
+ testnet: true,
23
+ };
24
+ }
25
+ try {
26
+ return extractChain({
27
+ id: chainId,
28
+ chains: Object.values(viemChains),
29
+ });
30
+ }
31
+ catch {
32
+ throw new Error(`Unsupported chainId: ${chainId}`);
33
+ }
34
+ };
35
+ export const getViemPublicClient = (chainId, rpcUrl) => {
36
+ const chain = getEvmChainConfig(chainId);
37
+ const chainConfig = rpcUrl
38
+ ? {
39
+ ...chain,
40
+ rpcUrls: {
41
+ default: {
42
+ http: [rpcUrl],
43
+ },
44
+ public: {
45
+ http: [rpcUrl],
46
+ },
47
+ },
48
+ }
49
+ : chain;
50
+ return createPublicClient({
51
+ chain: chainConfig,
52
+ transport: rpcUrl ? http(rpcUrl) : http(),
53
+ });
54
+ };
55
+ export const getViemWalletClient = ({ chainId, account, rpcUrl, }) => {
56
+ const chain = getEvmChainConfig(chainId);
57
+ const chainConfig = rpcUrl
58
+ ? {
59
+ ...chain,
60
+ rpcUrls: {
61
+ default: {
62
+ http: [rpcUrl],
63
+ },
64
+ public: {
65
+ http: [rpcUrl],
66
+ },
67
+ },
68
+ }
69
+ : chain;
70
+ return createWalletClient({
71
+ chain: chainConfig,
72
+ transport: rpcUrl ? http(rpcUrl) : http(),
73
+ account: typeof account === 'string' ? account : account,
74
+ });
75
+ };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@injectivelabs/wallet-base",
3
3
  "description": "Base wallet strategy for use with @injectivelabs/wallet-core.",
4
- "version": "1.16.32",
4
+ "version": "1.16.34",
5
5
  "sideEffects": false,
6
6
  "type": "module",
7
7
  "author": {
@@ -56,14 +56,15 @@
56
56
  "start": "node dist/index.js"
57
57
  },
58
58
  "dependencies": {
59
- "@injectivelabs/exceptions": "1.16.32",
60
- "@injectivelabs/networks": "1.16.32",
61
- "@injectivelabs/sdk-ts": "1.16.32",
62
- "@injectivelabs/ts-types": "1.16.32",
63
- "eip1193-provider": "^1.0.1"
59
+ "@injectivelabs/exceptions": "1.16.34",
60
+ "@injectivelabs/networks": "1.16.34",
61
+ "@injectivelabs/sdk-ts": "1.16.34",
62
+ "@injectivelabs/ts-types": "1.16.34",
63
+ "eip1193-provider": "^1.0.1",
64
+ "viem": "^2.40.3"
64
65
  },
65
66
  "devDependencies": {
66
67
  "shx": "^0.3.3"
67
68
  },
68
- "gitHead": "e4461cec60f6f1255f5cb63194ce855520cbeb2e"
69
+ "gitHead": "a77a9cea69fd19e201c3c5ebf14860c7b54cc76e"
69
70
  }