@octaflowlabs/onchain-sdk 1.3.6 → 1.3.8
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/README.md +92 -40
- package/dist/blockchain/getProvider.d.ts +0 -3
- package/dist/blockchain/getProvider.js +0 -3
- package/dist/cjs/blockchain/getProvider.d.ts +0 -3
- package/dist/cjs/blockchain/getProvider.js +1 -5
- package/dist/cjs/constants/NETWORKS_REGISTRY.d.ts +6 -13
- package/dist/cjs/constants/NETWORKS_REGISTRY.js +65 -69
- package/dist/cjs/index.d.ts +2 -2
- package/dist/cjs/index.js +2 -4
- package/dist/constants/NETWORKS_REGISTRY.d.ts +6 -13
- package/dist/constants/NETWORKS_REGISTRY.js +64 -67
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,69 +1,121 @@
|
|
|
1
1
|
# onchain-sdk
|
|
2
2
|
|
|
3
3
|
Lightweight TypeScript SDK for EVM onchain utilities. It provides helpers for
|
|
4
|
-
balances, transaction building, broadcasting, gas estimation,
|
|
5
|
-
|
|
4
|
+
balances, transaction building, broadcasting, gas estimation, wallet derivation,
|
|
5
|
+
and amount formatting.
|
|
6
6
|
|
|
7
7
|
## Install
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
```bash
|
|
10
|
+
npm install @octaflowlabs/onchain-sdk
|
|
11
|
+
# or
|
|
12
|
+
yarn add @octaflowlabs/onchain-sdk
|
|
13
|
+
```
|
|
10
14
|
|
|
11
15
|
## How to use
|
|
12
16
|
|
|
13
|
-
|
|
17
|
+
```ts
|
|
18
|
+
import {
|
|
19
|
+
getProvider,
|
|
20
|
+
getBalance,
|
|
21
|
+
buildUnsignedTransferTx,
|
|
22
|
+
broadcastTransaction,
|
|
23
|
+
} from '@octaflowlabs/onchain-sdk'
|
|
24
|
+
```
|
|
25
|
+
|
|
14
26
|
- Provide a valid RPC URL (public or private) and the target chain ID.
|
|
15
27
|
- Call the balance, transaction, or signing helpers based on your flow.
|
|
16
28
|
- Handle errors at the call site and decide how often to poll or refresh.
|
|
17
29
|
|
|
18
|
-
##
|
|
30
|
+
## API reference
|
|
31
|
+
|
|
32
|
+
### Balances
|
|
33
|
+
|
|
34
|
+
| Export | Signature | Description |
|
|
35
|
+
|---|---|---|
|
|
36
|
+
| `getBalance` | `(params: GetBalanceParams) => Promise<bigint \| undefined>` | Fetch native or ERC-20 balance for a single token on one chain. |
|
|
37
|
+
| `getBalances` | `(params: GetBalancesParams) => Promise<GetBalanceResult>` | Batch-fetch balances across multiple chains using Multicall3 aggregation with automatic fallback to individual calls. |
|
|
38
|
+
|
|
39
|
+
### Transactions
|
|
40
|
+
|
|
41
|
+
| Export | Signature | Description |
|
|
42
|
+
|---|---|---|
|
|
43
|
+
| `buildBaseUnsignedTransferTx` | `(params: BuildBaseUnsignedTransferTxParams) => { to, data, value }` | Build the core `to`/`data`/`value` fields for a native or ERC-20 transfer. |
|
|
44
|
+
| `buildUnsignedTransferTx` | `(options: BuildUnsignedTransferTxOptions) => Promise<PrepareTransactionResult>` | Build a complete unsigned transfer transaction with gas estimation. |
|
|
45
|
+
| `buildMaxNativeTransferTx` | `(options: BuildMaxNativeTransferTxOptions) => Promise<string>` | Calculate the maximum sendable native amount after reserving gas. |
|
|
46
|
+
| `estimateGasLimitFromProvider` | `(props: EstimateGasLimitFromProviderProps) => Promise<GasEstimateResult>` | Estimate gas limit with dynamic congestion-based buffering (5–30%). |
|
|
47
|
+
| `estimateTransaction` | `(options: EstimateTransactionOptions) => Promise<EstimateTransactionResult>` | Estimate total transaction cost including gas reserve. |
|
|
48
|
+
| `prepareTransaction` | `(params: PrepareTransactionParams) => Promise<PrepareTransactionResult>` | Full transaction preparation: estimation + nonce + fee data, ready for signing. |
|
|
49
|
+
| `broadcastTransaction` | `(options: BroadcastTransactionOptions) => Promise<string>` | Broadcast a signed transaction and optionally wait for confirmations. Returns the tx hash. |
|
|
50
|
+
| `txStatus` | `(options: TxStatusOptions) => Promise<TxStatusResponse>` | Check transaction status and retrieve the receipt. |
|
|
51
|
+
|
|
52
|
+
### Provider
|
|
19
53
|
|
|
20
|
-
|
|
54
|
+
| Export | Signature | Description |
|
|
55
|
+
|---|---|---|
|
|
56
|
+
| `getProvider` | `(rpcUrl: string, chainId?: number) => JsonRpcProvider \| undefined` | Create an ethers `JsonRpcProvider` with optional static network. |
|
|
57
|
+
| `getDefaultRpc` | `(networkId: NetworkId) => string` | Return the default RPC URL for a registered network. |
|
|
21
58
|
|
|
22
|
-
|
|
23
|
-
- Fetch ERC-20 token balances for an address.
|
|
24
|
-
- Fetch multiple token balances across multiple chains with multicall batching.
|
|
59
|
+
### Wallet and signing
|
|
25
60
|
|
|
26
|
-
|
|
61
|
+
| Export | Signature | Description |
|
|
62
|
+
|---|---|---|
|
|
63
|
+
| `EvmWalletService` | `class` | HD wallet service: generate wallets, derive from mnemonic or private key, find next available index, sign messages, validate mnemonics. Accepts an `EntropySource` for randomness. |
|
|
64
|
+
| `createWallet` | `(privateKey: string, rpcUrl?: string) => Wallet` | Create an ethers `Wallet` instance from a private key. |
|
|
65
|
+
| `signMessage` | `(privateKey: string, message: string) => Promise<string>` | Sign an arbitrary message. |
|
|
66
|
+
| `signTransaction` | `(privateKey: string, tx: TransactionRequest, rpcUrl?: string) => Promise<string>` | Sign a transaction and return the serialized signed payload. |
|
|
27
67
|
|
|
28
|
-
|
|
29
|
-
- Estimate gas limits and fee data from a provider.
|
|
30
|
-
- Broadcast signed transactions.
|
|
31
|
-
- Check transaction status and receipt confirmation.
|
|
68
|
+
### Utilities
|
|
32
69
|
|
|
33
|
-
|
|
70
|
+
| Export | Signature | Description |
|
|
71
|
+
|---|---|---|
|
|
72
|
+
| `formattedAmountForDisplay` | `(amount, decimals, options?) => string` | Locale-aware formatting with group separators, scientific notation for large numbers, and threshold display for tiny amounts. |
|
|
73
|
+
| `parsedAmount` | `(amount: string, decimals: number) => bigint` | Parse a human-readable amount string into its smallest-unit `bigint`. |
|
|
74
|
+
| `normalizeAddress` | `(address: string) => string` | Validate and checksum an Ethereum address. |
|
|
75
|
+
| `getShortenTransactionHashOrAddress` | `(value, first?, last?) => string` | Shorten a tx hash or address (e.g. `0xAbCd…1234`). |
|
|
76
|
+
| `getShortenData` | `(data, first?, last?) => string` | Shorten arbitrary hex data. |
|
|
77
|
+
| `transformBigInt` | `(obj: ContractTransaction) => object` | Convert all `bigint` properties to strings for JSON serialization. |
|
|
78
|
+
| `handleErrorMessages` | `(options: { e, message }) => void` | Log structured ethers errors with detailed context. |
|
|
34
79
|
|
|
35
|
-
|
|
36
|
-
- Sign messages and transactions.
|
|
80
|
+
### Constants
|
|
37
81
|
|
|
38
|
-
|
|
82
|
+
| Export | Description |
|
|
83
|
+
|---|---|
|
|
84
|
+
| `GAS_LIMIT_PER_TX_TYPE` | Default gas limits: native transfer (`21 000n`), ERC-20 transfer (`65 000n`), approval (`100 000n`). |
|
|
85
|
+
| `MULTICALL3_ADDRESS` | Canonical Multicall3 contract address. |
|
|
86
|
+
| `ERC20_TOKEN_CONTRACT_ABI` | Standard ERC-20 ABI (`balanceOf`, `transfer`, `approve`, `allowance`, `decimals`, etc.). |
|
|
87
|
+
| `NATIVE_TOKENS` | Native token metadata by chain (ETH, BNB, POL). |
|
|
39
88
|
|
|
40
|
-
|
|
41
|
-
- Normalize addresses and shorten hashes.
|
|
42
|
-
- Transform bigint values for UI use.
|
|
89
|
+
### Networks registry
|
|
43
90
|
|
|
44
|
-
|
|
91
|
+
The SDK ships a built-in networks registry (`NETWORKS`) covering Ethereum, BSC, Polygon, Arbitrum, and Sepolia.
|
|
45
92
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
93
|
+
| Export | Description |
|
|
94
|
+
|---|---|
|
|
95
|
+
| `NETWORKS` | `Record<NetworkId, NetworkField>` — full network config map. |
|
|
96
|
+
| `getNetworksByCategory` | `(category: NetworkCategory) => NetworkField[]` — filter by `popular`, `custom`, or `testnet`. |
|
|
49
97
|
|
|
50
|
-
|
|
98
|
+
Each `NetworkField` entry includes `id`, `name`, `chainId`, `rpcUrl`, optional `failoverRpcUrl`, `explorerUrl`, `iconUrl`, and `symbol`.
|
|
51
99
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
- This registry is useful for network selection UIs, chain metadata lookup, and RPC fallback handling.
|
|
64
|
-
- You can use `chainId` with SDK helpers and pass `rpcUrl` (or `failoverRpcUrl`) to provider-based calls.
|
|
100
|
+
### Tokens registry
|
|
101
|
+
|
|
102
|
+
| Export | Description |
|
|
103
|
+
|---|---|
|
|
104
|
+
| `BASIC_TOKENS_BY_CHAIN` | Hardcoded ERC-20 token metadata (USDC, USDT, etc.) grouped by chain ID for Ethereum, BSC, Polygon, and Arbitrum. |
|
|
105
|
+
|
|
106
|
+
### Types
|
|
107
|
+
|
|
108
|
+
All interfaces and type aliases are exported for consumer use:
|
|
109
|
+
|
|
110
|
+
`BroadcastTransactionOptions`, `BuildMaxNativeTransferTxOptions`, `BuildUnsignedTransferTxOptions`, `BuildBaseUnsignedTransferTxParams`, `EstimateGasLimitFromProviderProps`, `GasEstimateResult`, `EstimateTransactionOptions`, `EstimateTransactionResult`, `PrepareTransactionParams`, `PrepareTransactionResult`, `TxStatusOptions`, `TxStatusResponse`, `FormatAmountOptions`, `TransactionRequest`, `GetBalanceParams`, `GetBalancesParams`, `GetBalancesChainRequest`, `GetBalanceResult`, `ChainBalances`, `TokenBalance`, `ChainGroup`, `NetworkField`, `NetworkId`, `NetworkCategory`, `BasicTokenData`, `BasicTokenSymbol`, `ChainTokenDataMap`, `EvmGeneratedWallet`, `EvmDerivedWallet`, `EntropySource`.
|
|
65
111
|
|
|
66
112
|
## Design notes
|
|
67
113
|
|
|
68
114
|
- The SDK is stateless and transport-agnostic. It expects a caller-provided RPC URL.
|
|
69
|
-
-
|
|
115
|
+
- Multicall3 is used automatically for batched balance queries with per-call failure handling and fallback.
|
|
116
|
+
- Gas estimation applies dynamic congestion-aware buffering (5–30%) based on current fee data.
|
|
117
|
+
- Caching, polling, and background jobs should be handled by the consumer app or backend.
|
|
118
|
+
|
|
119
|
+
## License
|
|
120
|
+
|
|
121
|
+
MIT
|
|
@@ -1,6 +1,3 @@
|
|
|
1
1
|
/** npm imports */
|
|
2
2
|
import { JsonRpcProvider } from 'ethers';
|
|
3
|
-
/** local imports */
|
|
4
|
-
import { NetworkId } from '../constants/NETWORKS_REGISTRY';
|
|
5
3
|
export declare const getProvider: (rpcUrl: string, chainId?: number) => JsonRpcProvider | undefined;
|
|
6
|
-
export declare const getDefaultRpc: (networkId: NetworkId) => string;
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
/** npm imports */
|
|
2
2
|
import { JsonRpcProvider, Network } from 'ethers';
|
|
3
|
-
/** local imports */
|
|
4
|
-
import { NETWORKS } from '../constants/NETWORKS_REGISTRY';
|
|
5
3
|
export const getProvider = (rpcUrl, chainId) => {
|
|
6
4
|
try {
|
|
7
5
|
if (!chainId)
|
|
@@ -13,4 +11,3 @@ export const getProvider = (rpcUrl, chainId) => {
|
|
|
13
11
|
console.warn('Could not create provider with chainId, falling back to rpcUrl only:', error);
|
|
14
12
|
}
|
|
15
13
|
};
|
|
16
|
-
export const getDefaultRpc = (networkId) => NETWORKS[networkId].rpcUrl;
|
|
@@ -1,6 +1,3 @@
|
|
|
1
1
|
/** npm imports */
|
|
2
2
|
import { JsonRpcProvider } from 'ethers';
|
|
3
|
-
/** local imports */
|
|
4
|
-
import { NetworkId } from '../constants/NETWORKS_REGISTRY';
|
|
5
3
|
export declare const getProvider: (rpcUrl: string, chainId?: number) => JsonRpcProvider | undefined;
|
|
6
|
-
export declare const getDefaultRpc: (networkId: NetworkId) => string;
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.getProvider = void 0;
|
|
4
4
|
/** npm imports */
|
|
5
5
|
const ethers_1 = require("ethers");
|
|
6
|
-
/** local imports */
|
|
7
|
-
const NETWORKS_REGISTRY_1 = require("../constants/NETWORKS_REGISTRY");
|
|
8
6
|
const getProvider = (rpcUrl, chainId) => {
|
|
9
7
|
try {
|
|
10
8
|
if (!chainId)
|
|
@@ -17,5 +15,3 @@ const getProvider = (rpcUrl, chainId) => {
|
|
|
17
15
|
}
|
|
18
16
|
};
|
|
19
17
|
exports.getProvider = getProvider;
|
|
20
|
-
const getDefaultRpc = (networkId) => NETWORKS_REGISTRY_1.NETWORKS[networkId].rpcUrl;
|
|
21
|
-
exports.getDefaultRpc = getDefaultRpc;
|
|
@@ -1,15 +1,5 @@
|
|
|
1
|
-
export declare const NETWORK_IDS: {
|
|
2
|
-
readonly ETHEREUM_MAINNET: "ethereum-mainnet";
|
|
3
|
-
readonly BNB_SMART_CHAIN: "bnb-smart-chain";
|
|
4
|
-
readonly POLYGON_MAINNET: "polygon-mainnet";
|
|
5
|
-
readonly ARBITRUM_MAINNET: "arbitrum-mainnet";
|
|
6
|
-
readonly SEPOLIA_ETH: "sepolia-eth";
|
|
7
|
-
};
|
|
8
|
-
export type NetworkId = (typeof NETWORK_IDS)[keyof typeof NETWORK_IDS];
|
|
9
|
-
export type NetworkCategory = 'popular' | 'custom' | 'testnet';
|
|
10
1
|
export interface NetworkField {
|
|
11
|
-
id:
|
|
12
|
-
category: NetworkCategory;
|
|
2
|
+
id: string;
|
|
13
3
|
name: string;
|
|
14
4
|
nameForDisplay: string;
|
|
15
5
|
chainId: number;
|
|
@@ -19,5 +9,8 @@ export interface NetworkField {
|
|
|
19
9
|
symbol: string;
|
|
20
10
|
failoverRpcUrl?: string;
|
|
21
11
|
}
|
|
22
|
-
export
|
|
23
|
-
|
|
12
|
+
export interface NetworkRegistry {
|
|
13
|
+
category: string;
|
|
14
|
+
networks: NetworkField[];
|
|
15
|
+
}
|
|
16
|
+
export declare const NETWORKS_REGISTRY: NetworkRegistry[];
|
|
@@ -1,74 +1,70 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.
|
|
5
|
-
|
|
6
|
-
BNB_SMART_CHAIN: 'bnb-smart-chain',
|
|
7
|
-
POLYGON_MAINNET: 'polygon-mainnet',
|
|
8
|
-
ARBITRUM_MAINNET: 'arbitrum-mainnet',
|
|
9
|
-
SEPOLIA_ETH: 'sepolia-eth',
|
|
10
|
-
};
|
|
11
|
-
exports.NETWORKS = {
|
|
12
|
-
[exports.NETWORK_IDS.ETHEREUM_MAINNET]: {
|
|
13
|
-
id: exports.NETWORK_IDS.ETHEREUM_MAINNET,
|
|
3
|
+
exports.NETWORKS_REGISTRY = void 0;
|
|
4
|
+
exports.NETWORKS_REGISTRY = [
|
|
5
|
+
{
|
|
14
6
|
category: 'popular',
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
7
|
+
networks: [
|
|
8
|
+
{
|
|
9
|
+
id: 'ethereum-mainnet',
|
|
10
|
+
name: 'eth-mainnet',
|
|
11
|
+
nameForDisplay: 'Ethereum Mainnet',
|
|
12
|
+
chainId: 1,
|
|
13
|
+
rpcUrl: 'https://ethereum-rpc.publicnode.com',
|
|
14
|
+
explorerUrl: 'https://etherscan.io',
|
|
15
|
+
iconUrl: 'https://assets.coingecko.com/coins/images/279/large/ethereum.png',
|
|
16
|
+
symbol: 'ETH',
|
|
17
|
+
failoverRpcUrl: 'https://eth.llamarpc.com',
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
id: 'bnb-smart-chain',
|
|
21
|
+
name: 'bnb-mainnet',
|
|
22
|
+
nameForDisplay: 'BNB Smart Chain',
|
|
23
|
+
chainId: 56,
|
|
24
|
+
rpcUrl: 'https://bsc-dataseed.bnbchain.org',
|
|
25
|
+
explorerUrl: 'https://bscscan.com/',
|
|
26
|
+
iconUrl: 'https://assets.coingecko.com/coins/images/825/large/bnb-icon2_2x.png',
|
|
27
|
+
symbol: 'BNB',
|
|
28
|
+
failoverRpcUrl: 'https://bsc.llamarpc.com',
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
id: 'polygon-mainnet',
|
|
32
|
+
name: 'polygon-mainnet',
|
|
33
|
+
nameForDisplay: 'Polygon Mainnet',
|
|
34
|
+
iconUrl: 'https://assets.coingecko.com/coins/images/4713/large/matic-token-icon.png',
|
|
35
|
+
chainId: 137,
|
|
36
|
+
rpcUrl: 'https://polygon.publicnode.com',
|
|
37
|
+
explorerUrl: 'https://polygonscan.com',
|
|
38
|
+
symbol: 'POL',
|
|
39
|
+
failoverRpcUrl: 'https://polygon.llamarpc.com',
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
id: 'arbitrum-mainnet',
|
|
43
|
+
name: 'arb-mainnet',
|
|
44
|
+
nameForDisplay: 'Arbitrum Mainnet',
|
|
45
|
+
chainId: 42161,
|
|
46
|
+
rpcUrl: 'https://public-arb-mainnet.fastnode.io',
|
|
47
|
+
explorerUrl: 'https://arbiscan.io',
|
|
48
|
+
iconUrl: 'https://assets.coingecko.com/coins/images/16547/large/photo_2023-03-29_21.47.00.jpeg',
|
|
49
|
+
symbol: 'ARB',
|
|
50
|
+
failoverRpcUrl: 'https://arb.llamarpc.com',
|
|
51
|
+
},
|
|
52
|
+
],
|
|
23
53
|
},
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
name: 'polygon-mainnet',
|
|
40
|
-
nameForDisplay: 'Polygon Mainnet',
|
|
41
|
-
chainId: 137,
|
|
42
|
-
rpcUrl: 'https://polygon.publicnode.com',
|
|
43
|
-
explorerUrl: 'https://polygonscan.com',
|
|
44
|
-
iconUrl: 'https://assets.coingecko.com/coins/images/4713/large/matic-token-icon.png',
|
|
45
|
-
symbol: 'POL',
|
|
46
|
-
failoverRpcUrl: 'https://polygon.llamarpc.com',
|
|
47
|
-
},
|
|
48
|
-
[exports.NETWORK_IDS.ARBITRUM_MAINNET]: {
|
|
49
|
-
id: exports.NETWORK_IDS.ARBITRUM_MAINNET,
|
|
50
|
-
category: 'popular',
|
|
51
|
-
name: 'arb-mainnet',
|
|
52
|
-
nameForDisplay: 'Arbitrum Mainnet',
|
|
53
|
-
chainId: 42161,
|
|
54
|
-
rpcUrl: 'https://public-arb-mainnet.fastnode.io',
|
|
55
|
-
explorerUrl: 'https://arbiscan.io',
|
|
56
|
-
iconUrl: 'https://assets.coingecko.com/coins/images/16547/large/photo_2023-03-29_21.47.00.jpeg',
|
|
57
|
-
symbol: 'ARB',
|
|
58
|
-
failoverRpcUrl: 'https://arb.llamarpc.com',
|
|
59
|
-
},
|
|
60
|
-
[exports.NETWORK_IDS.SEPOLIA_ETH]: {
|
|
61
|
-
id: exports.NETWORK_IDS.SEPOLIA_ETH,
|
|
62
|
-
category: 'testnet',
|
|
63
|
-
name: 'eth-sepolia',
|
|
64
|
-
nameForDisplay: 'ETH Sepolia Testnet',
|
|
65
|
-
chainId: 11155111,
|
|
66
|
-
rpcUrl: 'https://ethereum-sepolia-rpc.publicnode.com',
|
|
67
|
-
explorerUrl: 'https://sepolia.etherscan.io',
|
|
68
|
-
iconUrl: 'https://assets.coingecko.com/coins/images/279/large/ethereum.png',
|
|
69
|
-
symbol: 'ETH',
|
|
70
|
-
failoverRpcUrl: 'https://eth-sepolia.llamarpc.com',
|
|
54
|
+
{
|
|
55
|
+
category: 'custom',
|
|
56
|
+
networks: [
|
|
57
|
+
{
|
|
58
|
+
id: 'sepolia-eth',
|
|
59
|
+
name: 'eth-sepolia',
|
|
60
|
+
nameForDisplay: 'ETH Sepolia Testnet',
|
|
61
|
+
chainId: 11155111,
|
|
62
|
+
rpcUrl: 'https://ethereum-sepolia-rpc.publicnode.com',
|
|
63
|
+
explorerUrl: 'https://sepolia.etherscan.io',
|
|
64
|
+
iconUrl: 'https://assets.coingecko.com/coins/images/279/large/ethereum.png',
|
|
65
|
+
symbol: 'ETH',
|
|
66
|
+
failoverRpcUrl: 'https://eth-sepolia.llamarpc.com',
|
|
67
|
+
},
|
|
68
|
+
],
|
|
71
69
|
},
|
|
72
|
-
|
|
73
|
-
const getNetworksByCategory = (category) => Object.values(exports.NETWORKS).filter((n) => n.category === category);
|
|
74
|
-
exports.getNetworksByCategory = getNetworksByCategory;
|
|
70
|
+
];
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -3,13 +3,13 @@ import ERC20_TOKEN_CONTRACT_ABI from './ABIs/ERC20_TOKEN_CONTRACT_ABI';
|
|
|
3
3
|
export { ERC20_TOKEN_CONTRACT_ABI };
|
|
4
4
|
/** constants exports */
|
|
5
5
|
export { GAS_LIMIT_PER_TX_TYPE, MULTICALL3_ADDRESS } from './constants/constants';
|
|
6
|
-
export { NetworkField,
|
|
6
|
+
export { NetworkField, NetworkRegistry, NETWORKS_REGISTRY, } from './constants/NETWORKS_REGISTRY';
|
|
7
7
|
export { BASIC_TOKENS_BY_CHAIN, BasicTokenData, BasicTokenSymbol, ChainTokenDataMap, } from './constants/BASIC_TOKENS_REGISTRY';
|
|
8
8
|
/** basic blockchain exports */
|
|
9
9
|
export { buildBaseUnsignedTransferTx, buildMaxNativeTransferTx, buildUnsignedTransferTx, } from './blockchain/buildUnsignedTransferTx';
|
|
10
10
|
export { broadcastTransaction } from './blockchain/broadcastTransaction';
|
|
11
11
|
export { estimateGasLimitFromProvider } from './blockchain/estimateGasLimitFromProvider';
|
|
12
|
-
export { getProvider
|
|
12
|
+
export { getProvider } from './blockchain/getProvider';
|
|
13
13
|
export { txStatus } from './blockchain/txStatus';
|
|
14
14
|
export { getBalance, getBalances } from './blockchain/getBalances';
|
|
15
15
|
export { estimateTransaction } from './blockchain/estimateTransaction';
|
package/dist/cjs/index.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.normalizeAddress = exports.errorMessagesForGasLimitEstimation = exports.errorMessagesForBroadcast = exports.handleErrorMessages = exports.parsedAmount = exports.formattedAmountForDisplay = exports.NATIVE_TOKENS = exports.transformBigInt = exports.getShortenData = exports.getShortenTransactionHashOrAddress = exports.signTransaction = exports.signMessage = exports.createWallet = exports.EvmWalletService = exports.prepareTransaction = exports.estimateTransaction = exports.getBalances = exports.getBalance = exports.txStatus = exports.
|
|
6
|
+
exports.normalizeAddress = exports.errorMessagesForGasLimitEstimation = exports.errorMessagesForBroadcast = exports.handleErrorMessages = exports.parsedAmount = exports.formattedAmountForDisplay = exports.NATIVE_TOKENS = exports.transformBigInt = exports.getShortenData = exports.getShortenTransactionHashOrAddress = exports.signTransaction = exports.signMessage = exports.createWallet = exports.EvmWalletService = exports.prepareTransaction = exports.estimateTransaction = exports.getBalances = exports.getBalance = exports.txStatus = exports.getProvider = exports.estimateGasLimitFromProvider = exports.broadcastTransaction = exports.buildUnsignedTransferTx = exports.buildMaxNativeTransferTx = exports.buildBaseUnsignedTransferTx = exports.BASIC_TOKENS_BY_CHAIN = exports.NETWORKS_REGISTRY = exports.MULTICALL3_ADDRESS = exports.GAS_LIMIT_PER_TX_TYPE = exports.ERC20_TOKEN_CONTRACT_ABI = void 0;
|
|
7
7
|
/** ABIs exports */
|
|
8
8
|
const ERC20_TOKEN_CONTRACT_ABI_1 = __importDefault(require("./ABIs/ERC20_TOKEN_CONTRACT_ABI"));
|
|
9
9
|
exports.ERC20_TOKEN_CONTRACT_ABI = ERC20_TOKEN_CONTRACT_ABI_1.default;
|
|
@@ -12,8 +12,7 @@ var constants_1 = require("./constants/constants");
|
|
|
12
12
|
Object.defineProperty(exports, "GAS_LIMIT_PER_TX_TYPE", { enumerable: true, get: function () { return constants_1.GAS_LIMIT_PER_TX_TYPE; } });
|
|
13
13
|
Object.defineProperty(exports, "MULTICALL3_ADDRESS", { enumerable: true, get: function () { return constants_1.MULTICALL3_ADDRESS; } });
|
|
14
14
|
var NETWORKS_REGISTRY_1 = require("./constants/NETWORKS_REGISTRY");
|
|
15
|
-
Object.defineProperty(exports, "
|
|
16
|
-
Object.defineProperty(exports, "getNetworksByCategory", { enumerable: true, get: function () { return NETWORKS_REGISTRY_1.getNetworksByCategory; } });
|
|
15
|
+
Object.defineProperty(exports, "NETWORKS_REGISTRY", { enumerable: true, get: function () { return NETWORKS_REGISTRY_1.NETWORKS_REGISTRY; } });
|
|
17
16
|
var BASIC_TOKENS_REGISTRY_1 = require("./constants/BASIC_TOKENS_REGISTRY");
|
|
18
17
|
Object.defineProperty(exports, "BASIC_TOKENS_BY_CHAIN", { enumerable: true, get: function () { return BASIC_TOKENS_REGISTRY_1.BASIC_TOKENS_BY_CHAIN; } });
|
|
19
18
|
/** basic blockchain exports */
|
|
@@ -27,7 +26,6 @@ var estimateGasLimitFromProvider_1 = require("./blockchain/estimateGasLimitFromP
|
|
|
27
26
|
Object.defineProperty(exports, "estimateGasLimitFromProvider", { enumerable: true, get: function () { return estimateGasLimitFromProvider_1.estimateGasLimitFromProvider; } });
|
|
28
27
|
var getProvider_1 = require("./blockchain/getProvider");
|
|
29
28
|
Object.defineProperty(exports, "getProvider", { enumerable: true, get: function () { return getProvider_1.getProvider; } });
|
|
30
|
-
Object.defineProperty(exports, "getDefaultRpc", { enumerable: true, get: function () { return getProvider_1.getDefaultRpc; } });
|
|
31
29
|
var txStatus_1 = require("./blockchain/txStatus");
|
|
32
30
|
Object.defineProperty(exports, "txStatus", { enumerable: true, get: function () { return txStatus_1.txStatus; } });
|
|
33
31
|
var getBalances_1 = require("./blockchain/getBalances");
|
|
@@ -1,15 +1,5 @@
|
|
|
1
|
-
export declare const NETWORK_IDS: {
|
|
2
|
-
readonly ETHEREUM_MAINNET: "ethereum-mainnet";
|
|
3
|
-
readonly BNB_SMART_CHAIN: "bnb-smart-chain";
|
|
4
|
-
readonly POLYGON_MAINNET: "polygon-mainnet";
|
|
5
|
-
readonly ARBITRUM_MAINNET: "arbitrum-mainnet";
|
|
6
|
-
readonly SEPOLIA_ETH: "sepolia-eth";
|
|
7
|
-
};
|
|
8
|
-
export type NetworkId = (typeof NETWORK_IDS)[keyof typeof NETWORK_IDS];
|
|
9
|
-
export type NetworkCategory = 'popular' | 'custom' | 'testnet';
|
|
10
1
|
export interface NetworkField {
|
|
11
|
-
id:
|
|
12
|
-
category: NetworkCategory;
|
|
2
|
+
id: string;
|
|
13
3
|
name: string;
|
|
14
4
|
nameForDisplay: string;
|
|
15
5
|
chainId: number;
|
|
@@ -19,5 +9,8 @@ export interface NetworkField {
|
|
|
19
9
|
symbol: string;
|
|
20
10
|
failoverRpcUrl?: string;
|
|
21
11
|
}
|
|
22
|
-
export
|
|
23
|
-
|
|
12
|
+
export interface NetworkRegistry {
|
|
13
|
+
category: string;
|
|
14
|
+
networks: NetworkField[];
|
|
15
|
+
}
|
|
16
|
+
export declare const NETWORKS_REGISTRY: NetworkRegistry[];
|
|
@@ -1,70 +1,67 @@
|
|
|
1
|
-
export const
|
|
2
|
-
|
|
3
|
-
BNB_SMART_CHAIN: 'bnb-smart-chain',
|
|
4
|
-
POLYGON_MAINNET: 'polygon-mainnet',
|
|
5
|
-
ARBITRUM_MAINNET: 'arbitrum-mainnet',
|
|
6
|
-
SEPOLIA_ETH: 'sepolia-eth',
|
|
7
|
-
};
|
|
8
|
-
export const NETWORKS = {
|
|
9
|
-
[NETWORK_IDS.ETHEREUM_MAINNET]: {
|
|
10
|
-
id: NETWORK_IDS.ETHEREUM_MAINNET,
|
|
1
|
+
export const NETWORKS_REGISTRY = [
|
|
2
|
+
{
|
|
11
3
|
category: 'popular',
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
4
|
+
networks: [
|
|
5
|
+
{
|
|
6
|
+
id: 'ethereum-mainnet',
|
|
7
|
+
name: 'eth-mainnet',
|
|
8
|
+
nameForDisplay: 'Ethereum Mainnet',
|
|
9
|
+
chainId: 1,
|
|
10
|
+
rpcUrl: 'https://ethereum-rpc.publicnode.com',
|
|
11
|
+
explorerUrl: 'https://etherscan.io',
|
|
12
|
+
iconUrl: 'https://assets.coingecko.com/coins/images/279/large/ethereum.png',
|
|
13
|
+
symbol: 'ETH',
|
|
14
|
+
failoverRpcUrl: 'https://eth.llamarpc.com',
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
id: 'bnb-smart-chain',
|
|
18
|
+
name: 'bnb-mainnet',
|
|
19
|
+
nameForDisplay: 'BNB Smart Chain',
|
|
20
|
+
chainId: 56,
|
|
21
|
+
rpcUrl: 'https://bsc-dataseed.bnbchain.org',
|
|
22
|
+
explorerUrl: 'https://bscscan.com/',
|
|
23
|
+
iconUrl: 'https://assets.coingecko.com/coins/images/825/large/bnb-icon2_2x.png',
|
|
24
|
+
symbol: 'BNB',
|
|
25
|
+
failoverRpcUrl: 'https://bsc.llamarpc.com',
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
id: 'polygon-mainnet',
|
|
29
|
+
name: 'polygon-mainnet',
|
|
30
|
+
nameForDisplay: 'Polygon Mainnet',
|
|
31
|
+
iconUrl: 'https://assets.coingecko.com/coins/images/4713/large/matic-token-icon.png',
|
|
32
|
+
chainId: 137,
|
|
33
|
+
rpcUrl: 'https://polygon.publicnode.com',
|
|
34
|
+
explorerUrl: 'https://polygonscan.com',
|
|
35
|
+
symbol: 'POL',
|
|
36
|
+
failoverRpcUrl: 'https://polygon.llamarpc.com',
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
id: 'arbitrum-mainnet',
|
|
40
|
+
name: 'arb-mainnet',
|
|
41
|
+
nameForDisplay: 'Arbitrum Mainnet',
|
|
42
|
+
chainId: 42161,
|
|
43
|
+
rpcUrl: 'https://public-arb-mainnet.fastnode.io',
|
|
44
|
+
explorerUrl: 'https://arbiscan.io',
|
|
45
|
+
iconUrl: 'https://assets.coingecko.com/coins/images/16547/large/photo_2023-03-29_21.47.00.jpeg',
|
|
46
|
+
symbol: 'ARB',
|
|
47
|
+
failoverRpcUrl: 'https://arb.llamarpc.com',
|
|
48
|
+
},
|
|
49
|
+
],
|
|
20
50
|
},
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
name: 'polygon-mainnet',
|
|
37
|
-
nameForDisplay: 'Polygon Mainnet',
|
|
38
|
-
chainId: 137,
|
|
39
|
-
rpcUrl: 'https://polygon.publicnode.com',
|
|
40
|
-
explorerUrl: 'https://polygonscan.com',
|
|
41
|
-
iconUrl: 'https://assets.coingecko.com/coins/images/4713/large/matic-token-icon.png',
|
|
42
|
-
symbol: 'POL',
|
|
43
|
-
failoverRpcUrl: 'https://polygon.llamarpc.com',
|
|
44
|
-
},
|
|
45
|
-
[NETWORK_IDS.ARBITRUM_MAINNET]: {
|
|
46
|
-
id: NETWORK_IDS.ARBITRUM_MAINNET,
|
|
47
|
-
category: 'popular',
|
|
48
|
-
name: 'arb-mainnet',
|
|
49
|
-
nameForDisplay: 'Arbitrum Mainnet',
|
|
50
|
-
chainId: 42161,
|
|
51
|
-
rpcUrl: 'https://public-arb-mainnet.fastnode.io',
|
|
52
|
-
explorerUrl: 'https://arbiscan.io',
|
|
53
|
-
iconUrl: 'https://assets.coingecko.com/coins/images/16547/large/photo_2023-03-29_21.47.00.jpeg',
|
|
54
|
-
symbol: 'ARB',
|
|
55
|
-
failoverRpcUrl: 'https://arb.llamarpc.com',
|
|
56
|
-
},
|
|
57
|
-
[NETWORK_IDS.SEPOLIA_ETH]: {
|
|
58
|
-
id: NETWORK_IDS.SEPOLIA_ETH,
|
|
59
|
-
category: 'testnet',
|
|
60
|
-
name: 'eth-sepolia',
|
|
61
|
-
nameForDisplay: 'ETH Sepolia Testnet',
|
|
62
|
-
chainId: 11155111,
|
|
63
|
-
rpcUrl: 'https://ethereum-sepolia-rpc.publicnode.com',
|
|
64
|
-
explorerUrl: 'https://sepolia.etherscan.io',
|
|
65
|
-
iconUrl: 'https://assets.coingecko.com/coins/images/279/large/ethereum.png',
|
|
66
|
-
symbol: 'ETH',
|
|
67
|
-
failoverRpcUrl: 'https://eth-sepolia.llamarpc.com',
|
|
51
|
+
{
|
|
52
|
+
category: 'custom',
|
|
53
|
+
networks: [
|
|
54
|
+
{
|
|
55
|
+
id: 'sepolia-eth',
|
|
56
|
+
name: 'eth-sepolia',
|
|
57
|
+
nameForDisplay: 'ETH Sepolia Testnet',
|
|
58
|
+
chainId: 11155111,
|
|
59
|
+
rpcUrl: 'https://ethereum-sepolia-rpc.publicnode.com',
|
|
60
|
+
explorerUrl: 'https://sepolia.etherscan.io',
|
|
61
|
+
iconUrl: 'https://assets.coingecko.com/coins/images/279/large/ethereum.png',
|
|
62
|
+
symbol: 'ETH',
|
|
63
|
+
failoverRpcUrl: 'https://eth-sepolia.llamarpc.com',
|
|
64
|
+
},
|
|
65
|
+
],
|
|
68
66
|
},
|
|
69
|
-
|
|
70
|
-
export const getNetworksByCategory = (category) => Object.values(NETWORKS).filter((n) => n.category === category);
|
|
67
|
+
];
|
package/dist/index.d.ts
CHANGED
|
@@ -3,13 +3,13 @@ import ERC20_TOKEN_CONTRACT_ABI from './ABIs/ERC20_TOKEN_CONTRACT_ABI';
|
|
|
3
3
|
export { ERC20_TOKEN_CONTRACT_ABI };
|
|
4
4
|
/** constants exports */
|
|
5
5
|
export { GAS_LIMIT_PER_TX_TYPE, MULTICALL3_ADDRESS } from './constants/constants';
|
|
6
|
-
export { NetworkField,
|
|
6
|
+
export { NetworkField, NetworkRegistry, NETWORKS_REGISTRY, } from './constants/NETWORKS_REGISTRY';
|
|
7
7
|
export { BASIC_TOKENS_BY_CHAIN, BasicTokenData, BasicTokenSymbol, ChainTokenDataMap, } from './constants/BASIC_TOKENS_REGISTRY';
|
|
8
8
|
/** basic blockchain exports */
|
|
9
9
|
export { buildBaseUnsignedTransferTx, buildMaxNativeTransferTx, buildUnsignedTransferTx, } from './blockchain/buildUnsignedTransferTx';
|
|
10
10
|
export { broadcastTransaction } from './blockchain/broadcastTransaction';
|
|
11
11
|
export { estimateGasLimitFromProvider } from './blockchain/estimateGasLimitFromProvider';
|
|
12
|
-
export { getProvider
|
|
12
|
+
export { getProvider } from './blockchain/getProvider';
|
|
13
13
|
export { txStatus } from './blockchain/txStatus';
|
|
14
14
|
export { getBalance, getBalances } from './blockchain/getBalances';
|
|
15
15
|
export { estimateTransaction } from './blockchain/estimateTransaction';
|
package/dist/index.js
CHANGED
|
@@ -3,13 +3,13 @@ import ERC20_TOKEN_CONTRACT_ABI from './ABIs/ERC20_TOKEN_CONTRACT_ABI';
|
|
|
3
3
|
export { ERC20_TOKEN_CONTRACT_ABI };
|
|
4
4
|
/** constants exports */
|
|
5
5
|
export { GAS_LIMIT_PER_TX_TYPE, MULTICALL3_ADDRESS } from './constants/constants';
|
|
6
|
-
export {
|
|
6
|
+
export { NETWORKS_REGISTRY, } from './constants/NETWORKS_REGISTRY';
|
|
7
7
|
export { BASIC_TOKENS_BY_CHAIN, } from './constants/BASIC_TOKENS_REGISTRY';
|
|
8
8
|
/** basic blockchain exports */
|
|
9
9
|
export { buildBaseUnsignedTransferTx, buildMaxNativeTransferTx, buildUnsignedTransferTx, } from './blockchain/buildUnsignedTransferTx';
|
|
10
10
|
export { broadcastTransaction } from './blockchain/broadcastTransaction';
|
|
11
11
|
export { estimateGasLimitFromProvider } from './blockchain/estimateGasLimitFromProvider';
|
|
12
|
-
export { getProvider
|
|
12
|
+
export { getProvider } from './blockchain/getProvider';
|
|
13
13
|
export { txStatus } from './blockchain/txStatus';
|
|
14
14
|
export { getBalance, getBalances } from './blockchain/getBalances';
|
|
15
15
|
export { estimateTransaction } from './blockchain/estimateTransaction';
|