@injectivelabs/wallet-base 1.16.31 → 1.16.33

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,115 @@
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
+ // Use viem's extractChain for all other chainIds (includes mainnet, sepolia, injective, injectiveTestnet, etc.)
62
+ try {
63
+ return (0, viem_1.extractChain)({
64
+ id: chainId,
65
+ chains: Object.values(viemChains),
66
+ });
67
+ }
68
+ catch {
69
+ throw new Error(`Unsupported chainId: ${chainId}`);
70
+ }
71
+ };
72
+ exports.getEvmChainConfig = getEvmChainConfig;
73
+ const getViemPublicClient = (chainId, rpcUrl) => {
74
+ const chain = (0, exports.getEvmChainConfig)(chainId);
75
+ const chainConfig = rpcUrl
76
+ ? {
77
+ ...chain,
78
+ rpcUrls: {
79
+ default: {
80
+ http: [rpcUrl],
81
+ },
82
+ public: {
83
+ http: [rpcUrl],
84
+ },
85
+ },
86
+ }
87
+ : chain;
88
+ return (0, viem_1.createPublicClient)({
89
+ chain: chainConfig,
90
+ transport: rpcUrl ? (0, viem_1.http)(rpcUrl) : (0, viem_1.http)(),
91
+ });
92
+ };
93
+ exports.getViemPublicClient = getViemPublicClient;
94
+ const getViemWalletClient = ({ chainId, account, rpcUrl, }) => {
95
+ const chain = (0, exports.getEvmChainConfig)(chainId);
96
+ const chainConfig = rpcUrl
97
+ ? {
98
+ ...chain,
99
+ rpcUrls: {
100
+ default: {
101
+ http: [rpcUrl],
102
+ },
103
+ public: {
104
+ http: [rpcUrl],
105
+ },
106
+ },
107
+ }
108
+ : chain;
109
+ return (0, viem_1.createWalletClient)({
110
+ chain: chainConfig,
111
+ transport: rpcUrl ? (0, viem_1.http)(rpcUrl) : (0, viem_1.http)(),
112
+ account: typeof account === 'string' ? account : account,
113
+ });
114
+ };
115
+ 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,76 @@
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
+ // Use viem's extractChain for all other chainIds (includes mainnet, sepolia, injective, injectiveTestnet, etc.)
26
+ try {
27
+ return extractChain({
28
+ id: chainId,
29
+ chains: Object.values(viemChains),
30
+ });
31
+ }
32
+ catch {
33
+ throw new Error(`Unsupported chainId: ${chainId}`);
34
+ }
35
+ };
36
+ export const getViemPublicClient = (chainId, rpcUrl) => {
37
+ const chain = getEvmChainConfig(chainId);
38
+ const chainConfig = rpcUrl
39
+ ? {
40
+ ...chain,
41
+ rpcUrls: {
42
+ default: {
43
+ http: [rpcUrl],
44
+ },
45
+ public: {
46
+ http: [rpcUrl],
47
+ },
48
+ },
49
+ }
50
+ : chain;
51
+ return createPublicClient({
52
+ chain: chainConfig,
53
+ transport: rpcUrl ? http(rpcUrl) : http(),
54
+ });
55
+ };
56
+ export const getViemWalletClient = ({ chainId, account, rpcUrl, }) => {
57
+ const chain = getEvmChainConfig(chainId);
58
+ const chainConfig = rpcUrl
59
+ ? {
60
+ ...chain,
61
+ rpcUrls: {
62
+ default: {
63
+ http: [rpcUrl],
64
+ },
65
+ public: {
66
+ http: [rpcUrl],
67
+ },
68
+ },
69
+ }
70
+ : chain;
71
+ return createWalletClient({
72
+ chain: chainConfig,
73
+ transport: rpcUrl ? http(rpcUrl) : http(),
74
+ account: typeof account === 'string' ? account : account,
75
+ });
76
+ };
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.31",
4
+ "version": "1.16.33",
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.31",
60
- "@injectivelabs/networks": "1.16.31",
61
- "@injectivelabs/sdk-ts": "1.16.31",
62
- "@injectivelabs/ts-types": "1.16.31",
63
- "eip1193-provider": "^1.0.1"
59
+ "@injectivelabs/exceptions": "1.16.33",
60
+ "@injectivelabs/networks": "1.16.33",
61
+ "@injectivelabs/sdk-ts": "1.16.33",
62
+ "@injectivelabs/ts-types": "1.16.33",
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": "c41f0041d9b325c8c80204dcbe8644c8509f2d05"
69
+ "gitHead": "7e822b65b56c486c03bede8c0eb024fd34a7657b"
69
70
  }