@provex/utils 1.0.16 → 1.2.4
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/chain.d.ts +446 -0
- package/dist/chain.js +98 -0
- package/dist/chain.test.js +112 -0
- package/dist/contracts.d.ts +206 -0
- package/dist/contracts.js +292 -0
- package/dist/contracts.test.js +243 -0
- package/dist/conversionRates.d.ts +215 -0
- package/dist/{src/conversionRates.js → conversionRates.js} +74 -4
- package/dist/conversionRates.test.js +473 -0
- package/dist/currencies.d.ts +248 -0
- package/dist/{src/currencies.js → currencies.js} +119 -38
- package/dist/currencies.test.js +343 -0
- package/dist/data/countries.json +1099 -0
- package/dist/deposit.d.ts +69 -0
- package/dist/deposit.js +52 -0
- package/dist/depositKeys.d.ts +154 -0
- package/dist/depositKeys.js +104 -0
- package/dist/depositKeys.test.d.ts +1 -0
- package/dist/depositKeys.test.js +231 -0
- package/dist/events.d.ts +41 -0
- package/dist/events.js +92 -0
- package/dist/events.test.d.ts +1 -0
- package/dist/events.test.js +111 -0
- package/dist/fees.d.ts +136 -0
- package/dist/fees.js +178 -0
- package/dist/fees.test.d.ts +1 -0
- package/dist/fees.test.js +165 -0
- package/dist/ids.d.ts +175 -0
- package/dist/ids.js +231 -0
- package/dist/ids.test.d.ts +1 -0
- package/dist/ids.test.js +607 -0
- package/dist/index.d.ts +45 -0
- package/dist/index.js +45 -0
- package/dist/input.d.ts +26 -0
- package/dist/{src/input.js → input.js} +23 -4
- package/dist/intent.d.ts +50 -0
- package/dist/intent.js +28 -0
- package/dist/intent.test.d.ts +1 -0
- package/dist/intent.test.js +119 -0
- package/dist/json.d.ts +55 -0
- package/dist/json.js +80 -0
- package/dist/participants.d.ts +22 -0
- package/dist/participants.js +28 -0
- package/dist/payment.d.ts +481 -0
- package/dist/payment.js +1149 -0
- package/dist/payment.test.d.ts +1 -0
- package/dist/payment.test.js +272 -0
- package/dist/peer-types.d.ts +327 -0
- package/dist/peer-types.js +169 -0
- package/dist/profit.d.ts +49 -0
- package/dist/profit.js +57 -0
- package/dist/profit.test.d.ts +1 -0
- package/dist/profit.test.js +315 -0
- package/dist/reputation.d.ts +125 -0
- package/dist/reputation.js +188 -0
- package/dist/reputation.test.d.ts +1 -0
- package/dist/reputation.test.js +156 -0
- package/dist/sort.d.ts +75 -0
- package/dist/sort.js +70 -0
- package/dist/sort.test.d.ts +1 -0
- package/dist/sort.test.js +216 -0
- package/dist/stateKey.d.ts +35 -0
- package/dist/stateKey.js +36 -0
- package/dist/stats.d.ts +61 -0
- package/dist/stats.js +53 -0
- package/dist/stats.test.d.ts +1 -0
- package/dist/stats.test.js +104 -0
- package/dist/time.d.ts +104 -0
- package/dist/time.js +162 -0
- package/dist/time.test.d.ts +1 -0
- package/dist/time.test.js +231 -0
- package/dist/tokens.d.ts +15502 -0
- package/dist/{src/tokens.js → tokens.js} +98 -17
- package/dist/tokens.test.d.ts +1 -0
- package/dist/tokens.test.js +193 -0
- package/dist/units.d.ts +200 -0
- package/dist/units.js +279 -0
- package/dist/units.test.d.ts +1 -0
- package/dist/units.test.js +327 -0
- package/package.json +119 -29
- package/dist/scripts/convert-svg.js +0 -17
- package/dist/src/chain.d.ts +0 -14
- package/dist/src/chain.js +0 -18
- package/dist/src/contracts.d.ts +0 -30
- package/dist/src/contracts.js +0 -64
- package/dist/src/conversionRates.d.ts +0 -124
- package/dist/src/currencies.d.ts +0 -144
- package/dist/src/data/countries.json +0 -1099
- package/dist/src/deposit.d.ts +0 -1
- package/dist/src/events.d.ts +0 -3
- package/dist/src/events.js +0 -16
- package/dist/src/ids.d.ts +0 -72
- package/dist/src/ids.js +0 -81
- package/dist/src/index.d.ts +0 -16
- package/dist/src/index.js +0 -16
- package/dist/src/input.d.ts +0 -7
- package/dist/src/intent.d.ts +0 -14
- package/dist/src/json.d.ts +0 -18
- package/dist/src/json.js +0 -44
- package/dist/src/participants.d.ts +0 -7
- package/dist/src/participants.js +0 -13
- package/dist/src/payment.d.ts +0 -164
- package/dist/src/payment.js +0 -439
- package/dist/src/profit.d.ts +0 -28
- package/dist/src/profit.js +0 -34
- package/dist/src/sort.d.ts +0 -36
- package/dist/src/sort.js +0 -39
- package/dist/src/stats.d.ts +0 -7
- package/dist/src/stats.js +0 -8
- package/dist/src/time.d.ts +0 -54
- package/dist/src/time.js +0 -106
- package/dist/src/tokens.d.ts +0 -3675
- package/dist/src/units.d.ts +0 -17
- package/dist/src/units.js +0 -79
- package/dist/src/zkp2p-types.d.ts +0 -48
- package/dist/tsconfig.tsbuildinfo +0 -1
- package/scripts/convert-svg.ts +0 -22
- package/src/chain.ts +0 -27
- package/src/contracts.ts +0 -89
- package/src/conversionRates.ts +0 -356
- package/src/currencies.ts +0 -286
- package/src/data/countries.json +0 -1099
- package/src/deposit.ts +0 -2
- package/src/events.ts +0 -21
- package/src/flags/eur.svg +0 -4
- package/src/flags/usd.svg +0 -25
- package/src/flags.ts +0 -4
- package/src/global.d.ts +0 -9
- package/src/ids.ts +0 -137
- package/src/index.ts +0 -16
- package/src/input.ts +0 -35
- package/src/intent.ts +0 -15
- package/src/json.ts +0 -42
- package/src/participants.ts +0 -14
- package/src/payment.ts +0 -573
- package/src/profit.ts +0 -55
- package/src/sort.ts +0 -49
- package/src/stats.ts +0 -10
- package/src/time.ts +0 -123
- package/src/tokens.ts +0 -159
- package/src/units.ts +0 -120
- package/src/zkp2p-types.ts +0 -55
- package/tsconfig.json +0 -18
- /package/dist/{scripts/convert-svg.d.ts → chain.test.d.ts} +0 -0
- /package/dist/{src/deposit.js → contracts.test.d.ts} +0 -0
- /package/dist/{src/intent.js → conversionRates.test.d.ts} +0 -0
- /package/dist/{src/zkp2p-types.js → currencies.test.d.ts} +0 -0
- /package/dist/{src/flags.d.ts → flags.d.ts} +0 -0
- /package/dist/{src/flags.js → flags.js} +0 -0
package/dist/chain.d.ts
ADDED
|
@@ -0,0 +1,446 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Chain configuration and utilities for supported blockchain networks.
|
|
3
|
+
*
|
|
4
|
+
* This module defines the supported chains (Base, Pulsechain) and provides utilities
|
|
5
|
+
* for chain identification, name resolution, and block explorer URL generation.
|
|
6
|
+
*
|
|
7
|
+
* @remarks
|
|
8
|
+
* - Base (chainId: 8453) is the primary network for the V3 escrow contracts
|
|
9
|
+
* - Pulsechain (chainId: 369) supports both V2 and V3 contracts
|
|
10
|
+
*
|
|
11
|
+
* @see {@link contracts} for contract addresses per chain
|
|
12
|
+
*/
|
|
13
|
+
import { type Chain } from 'viem/chains';
|
|
14
|
+
/**
|
|
15
|
+
* Supported blockchain networks for the Provex protocol.
|
|
16
|
+
* Both chains remain in the type system; UI visibility is controlled
|
|
17
|
+
* by SUPPORTED_CHAIN_IDS in ChainFilterContext.
|
|
18
|
+
*/
|
|
19
|
+
export declare const chains: readonly [{
|
|
20
|
+
blockExplorers: {
|
|
21
|
+
readonly default: {
|
|
22
|
+
readonly name: "PulseScan";
|
|
23
|
+
readonly url: "https://ipfs.scan.pulsechain.com";
|
|
24
|
+
readonly apiUrl: "https://api.scan.pulsechain.com/api";
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
blockTime: 10000;
|
|
28
|
+
contracts: {
|
|
29
|
+
readonly ensRegistry: {
|
|
30
|
+
readonly address: "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e";
|
|
31
|
+
};
|
|
32
|
+
readonly multicall3: {
|
|
33
|
+
readonly address: "0xca11bde05977b3631167028862be2a173976ca11";
|
|
34
|
+
readonly blockCreated: 14353601;
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
ensTlds?: readonly string[] | undefined;
|
|
38
|
+
id: 369;
|
|
39
|
+
name: "PulseChain";
|
|
40
|
+
nativeCurrency: {
|
|
41
|
+
readonly name: "Pulse";
|
|
42
|
+
readonly symbol: "PLS";
|
|
43
|
+
readonly decimals: 18;
|
|
44
|
+
};
|
|
45
|
+
experimental_preconfirmationTime?: number | undefined | undefined;
|
|
46
|
+
rpcUrls: {
|
|
47
|
+
readonly default: {
|
|
48
|
+
readonly http: readonly ["https://rpc.pulsechain.com"];
|
|
49
|
+
readonly webSocket: readonly ["wss://ws.pulsechain.com"];
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
sourceId?: number | undefined | undefined;
|
|
53
|
+
testnet: false;
|
|
54
|
+
custom?: Record<string, unknown> | undefined;
|
|
55
|
+
fees?: import("viem").ChainFees<undefined> | undefined;
|
|
56
|
+
formatters?: undefined;
|
|
57
|
+
serializers?: import("viem").ChainSerializers<undefined, import("viem").TransactionSerializable> | undefined;
|
|
58
|
+
}, {
|
|
59
|
+
blockExplorers: {
|
|
60
|
+
readonly default: {
|
|
61
|
+
readonly name: "Basescan";
|
|
62
|
+
readonly url: "https://basescan.org";
|
|
63
|
+
readonly apiUrl: "https://api.basescan.org/api";
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
blockTime: 2000;
|
|
67
|
+
contracts: {
|
|
68
|
+
readonly disputeGameFactory: {
|
|
69
|
+
readonly 1: {
|
|
70
|
+
readonly address: "0x43edB88C4B80fDD2AdFF2412A7BebF9dF42cB40e";
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
readonly l2OutputOracle: {
|
|
74
|
+
readonly 1: {
|
|
75
|
+
readonly address: "0x56315b90c40730925ec5485cf004d835058518A0";
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
readonly multicall3: {
|
|
79
|
+
readonly address: "0xca11bde05977b3631167028862be2a173976ca11";
|
|
80
|
+
readonly blockCreated: 5022;
|
|
81
|
+
};
|
|
82
|
+
readonly portal: {
|
|
83
|
+
readonly 1: {
|
|
84
|
+
readonly address: "0x49048044D57e1C92A77f79988d21Fa8fAF74E97e";
|
|
85
|
+
readonly blockCreated: 17482143;
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
readonly l1StandardBridge: {
|
|
89
|
+
readonly 1: {
|
|
90
|
+
readonly address: "0x3154Cf16ccdb4C6d922629664174b904d80F2C35";
|
|
91
|
+
readonly blockCreated: 17482143;
|
|
92
|
+
};
|
|
93
|
+
};
|
|
94
|
+
readonly gasPriceOracle: {
|
|
95
|
+
readonly address: "0x420000000000000000000000000000000000000F";
|
|
96
|
+
};
|
|
97
|
+
readonly l1Block: {
|
|
98
|
+
readonly address: "0x4200000000000000000000000000000000000015";
|
|
99
|
+
};
|
|
100
|
+
readonly l2CrossDomainMessenger: {
|
|
101
|
+
readonly address: "0x4200000000000000000000000000000000000007";
|
|
102
|
+
};
|
|
103
|
+
readonly l2Erc721Bridge: {
|
|
104
|
+
readonly address: "0x4200000000000000000000000000000000000014";
|
|
105
|
+
};
|
|
106
|
+
readonly l2StandardBridge: {
|
|
107
|
+
readonly address: "0x4200000000000000000000000000000000000010";
|
|
108
|
+
};
|
|
109
|
+
readonly l2ToL1MessagePasser: {
|
|
110
|
+
readonly address: "0x4200000000000000000000000000000000000016";
|
|
111
|
+
};
|
|
112
|
+
};
|
|
113
|
+
ensTlds?: readonly string[] | undefined;
|
|
114
|
+
id: 8453;
|
|
115
|
+
name: "Base";
|
|
116
|
+
nativeCurrency: {
|
|
117
|
+
readonly name: "Ether";
|
|
118
|
+
readonly symbol: "ETH";
|
|
119
|
+
readonly decimals: 18;
|
|
120
|
+
};
|
|
121
|
+
experimental_preconfirmationTime?: number | undefined | undefined;
|
|
122
|
+
rpcUrls: {
|
|
123
|
+
readonly default: {
|
|
124
|
+
readonly http: readonly ["https://mainnet.base.org"];
|
|
125
|
+
};
|
|
126
|
+
};
|
|
127
|
+
sourceId: 1;
|
|
128
|
+
testnet?: boolean | undefined | undefined;
|
|
129
|
+
custom?: Record<string, unknown> | undefined;
|
|
130
|
+
fees?: import("viem").ChainFees<undefined> | undefined;
|
|
131
|
+
formatters: {
|
|
132
|
+
readonly block: {
|
|
133
|
+
exclude: [] | undefined;
|
|
134
|
+
format: (args: import("viem/chains").OpStackRpcBlock, action?: string | undefined) => {
|
|
135
|
+
baseFeePerGas: bigint | null;
|
|
136
|
+
blobGasUsed: bigint;
|
|
137
|
+
difficulty: bigint;
|
|
138
|
+
excessBlobGas: bigint;
|
|
139
|
+
extraData: import("viem").Hex;
|
|
140
|
+
gasLimit: bigint;
|
|
141
|
+
gasUsed: bigint;
|
|
142
|
+
hash: `0x${string}` | null;
|
|
143
|
+
logsBloom: `0x${string}` | null;
|
|
144
|
+
miner: import("viem").Address;
|
|
145
|
+
mixHash: import("viem").Hash;
|
|
146
|
+
nonce: `0x${string}` | null;
|
|
147
|
+
number: bigint | null;
|
|
148
|
+
parentBeaconBlockRoot?: `0x${string}` | undefined;
|
|
149
|
+
parentHash: import("viem").Hash;
|
|
150
|
+
receiptsRoot: import("viem").Hex;
|
|
151
|
+
sealFields: import("viem").Hex[];
|
|
152
|
+
sha3Uncles: import("viem").Hash;
|
|
153
|
+
size: bigint;
|
|
154
|
+
stateRoot: import("viem").Hash;
|
|
155
|
+
timestamp: bigint;
|
|
156
|
+
totalDifficulty: bigint | null;
|
|
157
|
+
transactions: `0x${string}`[] | import("viem/chains").OpStackTransaction<boolean>[];
|
|
158
|
+
transactionsRoot: import("viem").Hash;
|
|
159
|
+
uncles: import("viem").Hash[];
|
|
160
|
+
withdrawals?: import("viem").Withdrawal[] | undefined | undefined;
|
|
161
|
+
withdrawalsRoot?: `0x${string}` | undefined;
|
|
162
|
+
} & {};
|
|
163
|
+
type: "block";
|
|
164
|
+
};
|
|
165
|
+
readonly transaction: {
|
|
166
|
+
exclude: [] | undefined;
|
|
167
|
+
format: (args: import("viem/chains").OpStackRpcTransaction, action?: string | undefined) => ({
|
|
168
|
+
blockHash: `0x${string}` | null;
|
|
169
|
+
blockNumber: bigint | null;
|
|
170
|
+
from: import("viem").Address;
|
|
171
|
+
gas: bigint;
|
|
172
|
+
hash: import("viem").Hash;
|
|
173
|
+
input: import("viem").Hex;
|
|
174
|
+
nonce: number;
|
|
175
|
+
r: import("viem").Hex;
|
|
176
|
+
s: import("viem").Hex;
|
|
177
|
+
to: import("viem").Address | null;
|
|
178
|
+
transactionIndex: number | null;
|
|
179
|
+
typeHex: import("viem").Hex | null;
|
|
180
|
+
v: bigint;
|
|
181
|
+
value: bigint;
|
|
182
|
+
yParity: number;
|
|
183
|
+
gasPrice?: undefined | undefined;
|
|
184
|
+
maxFeePerBlobGas?: undefined | undefined;
|
|
185
|
+
maxFeePerGas: bigint;
|
|
186
|
+
maxPriorityFeePerGas: bigint;
|
|
187
|
+
isSystemTx?: boolean;
|
|
188
|
+
mint?: bigint | undefined | undefined;
|
|
189
|
+
sourceHash: import("viem").Hex;
|
|
190
|
+
type: "deposit";
|
|
191
|
+
} | {
|
|
192
|
+
r: import("viem").Hex;
|
|
193
|
+
s: import("viem").Hex;
|
|
194
|
+
v: bigint;
|
|
195
|
+
value: bigint;
|
|
196
|
+
gas: bigint;
|
|
197
|
+
to: import("viem").Address | null;
|
|
198
|
+
from: import("viem").Address;
|
|
199
|
+
nonce: number;
|
|
200
|
+
blockHash: `0x${string}` | null;
|
|
201
|
+
blockNumber: bigint | null;
|
|
202
|
+
transactionIndex: number | null;
|
|
203
|
+
hash: import("viem").Hash;
|
|
204
|
+
input: import("viem").Hex;
|
|
205
|
+
typeHex: import("viem").Hex | null;
|
|
206
|
+
accessList?: undefined | undefined;
|
|
207
|
+
authorizationList?: undefined | undefined;
|
|
208
|
+
blobVersionedHashes?: undefined | undefined;
|
|
209
|
+
chainId?: number | undefined;
|
|
210
|
+
yParity?: undefined | undefined;
|
|
211
|
+
type: "legacy";
|
|
212
|
+
gasPrice: bigint;
|
|
213
|
+
maxFeePerBlobGas?: undefined | undefined;
|
|
214
|
+
maxFeePerGas?: undefined | undefined;
|
|
215
|
+
maxPriorityFeePerGas?: undefined | undefined;
|
|
216
|
+
isSystemTx?: undefined | undefined;
|
|
217
|
+
mint?: undefined | undefined;
|
|
218
|
+
sourceHash?: undefined | undefined;
|
|
219
|
+
} | {
|
|
220
|
+
blockHash: `0x${string}` | null;
|
|
221
|
+
blockNumber: bigint | null;
|
|
222
|
+
from: import("viem").Address;
|
|
223
|
+
gas: bigint;
|
|
224
|
+
hash: import("viem").Hash;
|
|
225
|
+
input: import("viem").Hex;
|
|
226
|
+
nonce: number;
|
|
227
|
+
r: import("viem").Hex;
|
|
228
|
+
s: import("viem").Hex;
|
|
229
|
+
to: import("viem").Address | null;
|
|
230
|
+
transactionIndex: number | null;
|
|
231
|
+
typeHex: import("viem").Hex | null;
|
|
232
|
+
v: bigint;
|
|
233
|
+
value: bigint;
|
|
234
|
+
yParity: number;
|
|
235
|
+
accessList: import("viem").AccessList;
|
|
236
|
+
authorizationList?: undefined | undefined;
|
|
237
|
+
blobVersionedHashes?: undefined | undefined;
|
|
238
|
+
chainId: number;
|
|
239
|
+
type: "eip2930";
|
|
240
|
+
gasPrice: bigint;
|
|
241
|
+
maxFeePerBlobGas?: undefined | undefined;
|
|
242
|
+
maxFeePerGas?: undefined | undefined;
|
|
243
|
+
maxPriorityFeePerGas?: undefined | undefined;
|
|
244
|
+
isSystemTx?: undefined | undefined;
|
|
245
|
+
mint?: undefined | undefined;
|
|
246
|
+
sourceHash?: undefined | undefined;
|
|
247
|
+
} | {
|
|
248
|
+
blockHash: `0x${string}` | null;
|
|
249
|
+
blockNumber: bigint | null;
|
|
250
|
+
from: import("viem").Address;
|
|
251
|
+
gas: bigint;
|
|
252
|
+
hash: import("viem").Hash;
|
|
253
|
+
input: import("viem").Hex;
|
|
254
|
+
nonce: number;
|
|
255
|
+
r: import("viem").Hex;
|
|
256
|
+
s: import("viem").Hex;
|
|
257
|
+
to: import("viem").Address | null;
|
|
258
|
+
transactionIndex: number | null;
|
|
259
|
+
typeHex: import("viem").Hex | null;
|
|
260
|
+
v: bigint;
|
|
261
|
+
value: bigint;
|
|
262
|
+
yParity: number;
|
|
263
|
+
accessList: import("viem").AccessList;
|
|
264
|
+
authorizationList?: undefined | undefined;
|
|
265
|
+
blobVersionedHashes?: undefined | undefined;
|
|
266
|
+
chainId: number;
|
|
267
|
+
type: "eip1559";
|
|
268
|
+
gasPrice?: undefined | undefined;
|
|
269
|
+
maxFeePerBlobGas?: undefined | undefined;
|
|
270
|
+
maxFeePerGas: bigint;
|
|
271
|
+
maxPriorityFeePerGas: bigint;
|
|
272
|
+
isSystemTx?: undefined | undefined;
|
|
273
|
+
mint?: undefined | undefined;
|
|
274
|
+
sourceHash?: undefined | undefined;
|
|
275
|
+
} | {
|
|
276
|
+
blockHash: `0x${string}` | null;
|
|
277
|
+
blockNumber: bigint | null;
|
|
278
|
+
from: import("viem").Address;
|
|
279
|
+
gas: bigint;
|
|
280
|
+
hash: import("viem").Hash;
|
|
281
|
+
input: import("viem").Hex;
|
|
282
|
+
nonce: number;
|
|
283
|
+
r: import("viem").Hex;
|
|
284
|
+
s: import("viem").Hex;
|
|
285
|
+
to: import("viem").Address | null;
|
|
286
|
+
transactionIndex: number | null;
|
|
287
|
+
typeHex: import("viem").Hex | null;
|
|
288
|
+
v: bigint;
|
|
289
|
+
value: bigint;
|
|
290
|
+
yParity: number;
|
|
291
|
+
accessList: import("viem").AccessList;
|
|
292
|
+
authorizationList?: undefined | undefined;
|
|
293
|
+
blobVersionedHashes: readonly import("viem").Hex[];
|
|
294
|
+
chainId: number;
|
|
295
|
+
type: "eip4844";
|
|
296
|
+
gasPrice?: undefined | undefined;
|
|
297
|
+
maxFeePerBlobGas: bigint;
|
|
298
|
+
maxFeePerGas: bigint;
|
|
299
|
+
maxPriorityFeePerGas: bigint;
|
|
300
|
+
isSystemTx?: undefined | undefined;
|
|
301
|
+
mint?: undefined | undefined;
|
|
302
|
+
sourceHash?: undefined | undefined;
|
|
303
|
+
} | {
|
|
304
|
+
blockHash: `0x${string}` | null;
|
|
305
|
+
blockNumber: bigint | null;
|
|
306
|
+
from: import("viem").Address;
|
|
307
|
+
gas: bigint;
|
|
308
|
+
hash: import("viem").Hash;
|
|
309
|
+
input: import("viem").Hex;
|
|
310
|
+
nonce: number;
|
|
311
|
+
r: import("viem").Hex;
|
|
312
|
+
s: import("viem").Hex;
|
|
313
|
+
to: import("viem").Address | null;
|
|
314
|
+
transactionIndex: number | null;
|
|
315
|
+
typeHex: import("viem").Hex | null;
|
|
316
|
+
v: bigint;
|
|
317
|
+
value: bigint;
|
|
318
|
+
yParity: number;
|
|
319
|
+
accessList: import("viem").AccessList;
|
|
320
|
+
authorizationList: import("viem").SignedAuthorizationList;
|
|
321
|
+
blobVersionedHashes?: undefined | undefined;
|
|
322
|
+
chainId: number;
|
|
323
|
+
type: "eip7702";
|
|
324
|
+
gasPrice?: undefined | undefined;
|
|
325
|
+
maxFeePerBlobGas?: undefined | undefined;
|
|
326
|
+
maxFeePerGas: bigint;
|
|
327
|
+
maxPriorityFeePerGas: bigint;
|
|
328
|
+
isSystemTx?: undefined | undefined;
|
|
329
|
+
mint?: undefined | undefined;
|
|
330
|
+
sourceHash?: undefined | undefined;
|
|
331
|
+
}) & {};
|
|
332
|
+
type: "transaction";
|
|
333
|
+
};
|
|
334
|
+
readonly transactionReceipt: {
|
|
335
|
+
exclude: [] | undefined;
|
|
336
|
+
format: (args: import("viem/chains").OpStackRpcTransactionReceipt, action?: string | undefined) => {
|
|
337
|
+
blobGasPrice?: bigint | undefined;
|
|
338
|
+
blobGasUsed?: bigint | undefined;
|
|
339
|
+
blockHash: import("viem").Hash;
|
|
340
|
+
blockNumber: bigint;
|
|
341
|
+
contractAddress: import("viem").Address | null | undefined;
|
|
342
|
+
cumulativeGasUsed: bigint;
|
|
343
|
+
effectiveGasPrice: bigint;
|
|
344
|
+
from: import("viem").Address;
|
|
345
|
+
gasUsed: bigint;
|
|
346
|
+
logs: import("viem").Log<bigint, number, false>[];
|
|
347
|
+
logsBloom: import("viem").Hex;
|
|
348
|
+
root?: `0x${string}` | undefined;
|
|
349
|
+
status: "success" | "reverted";
|
|
350
|
+
to: import("viem").Address | null;
|
|
351
|
+
transactionHash: import("viem").Hash;
|
|
352
|
+
transactionIndex: number;
|
|
353
|
+
type: import("viem").TransactionType;
|
|
354
|
+
l1GasPrice: bigint | null;
|
|
355
|
+
l1GasUsed: bigint | null;
|
|
356
|
+
l1Fee: bigint | null;
|
|
357
|
+
l1FeeScalar: number | null;
|
|
358
|
+
} & {};
|
|
359
|
+
type: "transactionReceipt";
|
|
360
|
+
};
|
|
361
|
+
};
|
|
362
|
+
serializers: {
|
|
363
|
+
readonly transaction: typeof import("viem/chains").serializeTransactionOpStack;
|
|
364
|
+
};
|
|
365
|
+
}];
|
|
366
|
+
/**
|
|
367
|
+
* Array of supported chain IDs derived from the chains array.
|
|
368
|
+
* Currently: [369 (Pulsechain), 8453 (Base)]
|
|
369
|
+
*/
|
|
370
|
+
export declare const chainIds: (369 | 8453)[];
|
|
371
|
+
/**
|
|
372
|
+
* Union type of all supported chain IDs.
|
|
373
|
+
* Use this type when a function accepts a chain ID parameter.
|
|
374
|
+
*
|
|
375
|
+
* @example
|
|
376
|
+
* ```ts
|
|
377
|
+
* function getContracts(chainId: ChainId) {
|
|
378
|
+
* // chainId is guaranteed to be 369 or 8453
|
|
379
|
+
* }
|
|
380
|
+
* ```
|
|
381
|
+
*/
|
|
382
|
+
export type ChainId = (typeof chainIds)[number];
|
|
383
|
+
/**
|
|
384
|
+
* Human-readable chain names for URL params and display.
|
|
385
|
+
* Maps chain IDs to lowercase slug-style names for URL-safe usage.
|
|
386
|
+
*
|
|
387
|
+
* @example
|
|
388
|
+
* ```ts
|
|
389
|
+
* chainNames[8453] // 'base'
|
|
390
|
+
* chainNames[369] // 'pulsechain'
|
|
391
|
+
* ```
|
|
392
|
+
*/
|
|
393
|
+
export declare const chainNames: {
|
|
394
|
+
readonly 8453: "base";
|
|
395
|
+
readonly 369: "pulsechain";
|
|
396
|
+
};
|
|
397
|
+
export type ChainName = (typeof chainNames)[ChainId];
|
|
398
|
+
/**
|
|
399
|
+
* Reverse mapping from chain name to chain ID
|
|
400
|
+
*/
|
|
401
|
+
export declare const chainNameToId: Record<ChainName, ChainId>;
|
|
402
|
+
/**
|
|
403
|
+
* Get chain name from chain ID for URL params
|
|
404
|
+
* @param chainId - The chain ID
|
|
405
|
+
* @returns The human-readable chain name (e.g., 'base', 'pulsechain')
|
|
406
|
+
*/
|
|
407
|
+
export declare function getChainName(chainId: ChainId): ChainName;
|
|
408
|
+
/**
|
|
409
|
+
* Get chain ID from chain name
|
|
410
|
+
* @param name - The chain name (e.g., 'base', 'pulsechain')
|
|
411
|
+
* @returns The chain ID, or null if invalid name
|
|
412
|
+
*/
|
|
413
|
+
export declare function getChainIdFromName(name: string): ChainId | null;
|
|
414
|
+
/**
|
|
415
|
+
* Check if a string is a valid chain name
|
|
416
|
+
* @param name - The string to check
|
|
417
|
+
* @returns True if the name is a valid chain name
|
|
418
|
+
*/
|
|
419
|
+
export declare function isValidChainName(name: string): name is ChainName;
|
|
420
|
+
/**
|
|
421
|
+
* Get the explorer URL for a given chain, type, and hash
|
|
422
|
+
* @param chain - The chain to get the explorer URL for
|
|
423
|
+
* @param type - The type of explorer to use (tx or address)
|
|
424
|
+
* @param hash - The hash to get the explorer URL for
|
|
425
|
+
* @returns The explorer URL
|
|
426
|
+
*/
|
|
427
|
+
export declare function getExplorerUrl(chain: Chain, type: 'tx' | 'address', hash: string): string;
|
|
428
|
+
/**
|
|
429
|
+
* Map from chain ID to viem Chain object.
|
|
430
|
+
* Provides O(1) lookup of chain configuration by ID.
|
|
431
|
+
*
|
|
432
|
+
* @example
|
|
433
|
+
* ```ts
|
|
434
|
+
* const baseChain = chainIdToChain.get(8453)
|
|
435
|
+
* // baseChain.name === 'Base'
|
|
436
|
+
* ```
|
|
437
|
+
*/
|
|
438
|
+
export declare const chainIdToChain: Map<369 | 8453, Chain>;
|
|
439
|
+
/**
|
|
440
|
+
* Target block time in milliseconds for each supported chain.
|
|
441
|
+
* Used for estimating transaction confirmation times.
|
|
442
|
+
*
|
|
443
|
+
* - Pulsechain (369): ~10 seconds per block
|
|
444
|
+
* - Base (8453): ~2 seconds per block
|
|
445
|
+
*/
|
|
446
|
+
export declare const chainIdToTargetBlockTime: Map<369 | 8453, number>;
|
package/dist/chain.js
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Chain configuration and utilities for supported blockchain networks.
|
|
3
|
+
*
|
|
4
|
+
* This module defines the supported chains (Base, Pulsechain) and provides utilities
|
|
5
|
+
* for chain identification, name resolution, and block explorer URL generation.
|
|
6
|
+
*
|
|
7
|
+
* @remarks
|
|
8
|
+
* - Base (chainId: 8453) is the primary network for the V3 escrow contracts
|
|
9
|
+
* - Pulsechain (chainId: 369) supports both V2 and V3 contracts
|
|
10
|
+
*
|
|
11
|
+
* @see {@link contracts} for contract addresses per chain
|
|
12
|
+
*/
|
|
13
|
+
import { base, pulsechain } from 'viem/chains';
|
|
14
|
+
/**
|
|
15
|
+
* Supported blockchain networks for the Provex protocol.
|
|
16
|
+
* Both chains remain in the type system; UI visibility is controlled
|
|
17
|
+
* by SUPPORTED_CHAIN_IDS in ChainFilterContext.
|
|
18
|
+
*/
|
|
19
|
+
export const chains = [pulsechain, base];
|
|
20
|
+
/**
|
|
21
|
+
* Array of supported chain IDs derived from the chains array.
|
|
22
|
+
* Currently: [369 (Pulsechain), 8453 (Base)]
|
|
23
|
+
*/
|
|
24
|
+
export const chainIds = chains.map((chain) => chain.id);
|
|
25
|
+
/**
|
|
26
|
+
* Human-readable chain names for URL params and display.
|
|
27
|
+
* Maps chain IDs to lowercase slug-style names for URL-safe usage.
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```ts
|
|
31
|
+
* chainNames[8453] // 'base'
|
|
32
|
+
* chainNames[369] // 'pulsechain'
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
export const chainNames = {
|
|
36
|
+
[base.id]: 'base',
|
|
37
|
+
[pulsechain.id]: 'pulsechain',
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Reverse mapping from chain name to chain ID
|
|
41
|
+
*/
|
|
42
|
+
export const chainNameToId = Object.fromEntries(Object.entries(chainNames).map(([id, name]) => [name, Number(id)]));
|
|
43
|
+
/**
|
|
44
|
+
* Get chain name from chain ID for URL params
|
|
45
|
+
* @param chainId - The chain ID
|
|
46
|
+
* @returns The human-readable chain name (e.g., 'base', 'pulsechain')
|
|
47
|
+
*/
|
|
48
|
+
export function getChainName(chainId) {
|
|
49
|
+
return chainNames[chainId];
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Get chain ID from chain name
|
|
53
|
+
* @param name - The chain name (e.g., 'base', 'pulsechain')
|
|
54
|
+
* @returns The chain ID, or null if invalid name
|
|
55
|
+
*/
|
|
56
|
+
export function getChainIdFromName(name) {
|
|
57
|
+
return chainNameToId[name] ?? null;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Check if a string is a valid chain name
|
|
61
|
+
* @param name - The string to check
|
|
62
|
+
* @returns True if the name is a valid chain name
|
|
63
|
+
*/
|
|
64
|
+
export function isValidChainName(name) {
|
|
65
|
+
return name in chainNameToId;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Get the explorer URL for a given chain, type, and hash
|
|
69
|
+
* @param chain - The chain to get the explorer URL for
|
|
70
|
+
* @param type - The type of explorer to use (tx or address)
|
|
71
|
+
* @param hash - The hash to get the explorer URL for
|
|
72
|
+
* @returns The explorer URL
|
|
73
|
+
*/
|
|
74
|
+
export function getExplorerUrl(chain, type, hash) {
|
|
75
|
+
return `${chain.blockExplorers?.default.url}/${type}/${hash}`;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Map from chain ID to viem Chain object.
|
|
79
|
+
* Provides O(1) lookup of chain configuration by ID.
|
|
80
|
+
*
|
|
81
|
+
* @example
|
|
82
|
+
* ```ts
|
|
83
|
+
* const baseChain = chainIdToChain.get(8453)
|
|
84
|
+
* // baseChain.name === 'Base'
|
|
85
|
+
* ```
|
|
86
|
+
*/
|
|
87
|
+
export const chainIdToChain = new Map(chains.map((chain) => [chain.id, chain]));
|
|
88
|
+
/**
|
|
89
|
+
* Target block time in milliseconds for each supported chain.
|
|
90
|
+
* Used for estimating transaction confirmation times.
|
|
91
|
+
*
|
|
92
|
+
* - Pulsechain (369): ~10 seconds per block
|
|
93
|
+
* - Base (8453): ~2 seconds per block
|
|
94
|
+
*/
|
|
95
|
+
export const chainIdToTargetBlockTime = new Map([
|
|
96
|
+
[369, 10_000],
|
|
97
|
+
[8453, 2_000],
|
|
98
|
+
]);
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { describe, it } from 'node:test';
|
|
2
|
+
import assert from 'node:assert/strict';
|
|
3
|
+
import { base, pulsechain } from 'viem/chains';
|
|
4
|
+
import { chains, chainIds, chainNames, chainNameToId, getChainName, getChainIdFromName, isValidChainName, getExplorerUrl, chainIdToChain, chainIdToTargetBlockTime, } from './chain.js';
|
|
5
|
+
describe('chain', () => {
|
|
6
|
+
describe('chains', () => {
|
|
7
|
+
it('should include pulsechain and base', () => {
|
|
8
|
+
assert.ok(chains.includes(pulsechain));
|
|
9
|
+
assert.ok(chains.includes(base));
|
|
10
|
+
});
|
|
11
|
+
it('should have exactly 2 chains', () => {
|
|
12
|
+
assert.equal(chains.length, 2);
|
|
13
|
+
});
|
|
14
|
+
});
|
|
15
|
+
describe('chainIds', () => {
|
|
16
|
+
it('should include correct chain IDs', () => {
|
|
17
|
+
assert.ok(chainIds.includes(369)); // Pulsechain
|
|
18
|
+
assert.ok(chainIds.includes(8453)); // Base
|
|
19
|
+
});
|
|
20
|
+
it('should have same length as chains', () => {
|
|
21
|
+
assert.equal(chainIds.length, chains.length);
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
describe('chainNames', () => {
|
|
25
|
+
it('should map base chain ID to "base"', () => {
|
|
26
|
+
assert.equal(chainNames[8453], 'base');
|
|
27
|
+
});
|
|
28
|
+
it('should map pulsechain chain ID to "pulsechain"', () => {
|
|
29
|
+
assert.equal(chainNames[369], 'pulsechain');
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
describe('chainNameToId', () => {
|
|
33
|
+
it('should map "base" to base chain ID', () => {
|
|
34
|
+
assert.equal(chainNameToId['base'], 8453);
|
|
35
|
+
});
|
|
36
|
+
it('should map "pulsechain" to pulsechain chain ID', () => {
|
|
37
|
+
assert.equal(chainNameToId['pulsechain'], 369);
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
describe('getChainName', () => {
|
|
41
|
+
it('should return "base" for base chain ID', () => {
|
|
42
|
+
assert.equal(getChainName(8453), 'base');
|
|
43
|
+
});
|
|
44
|
+
it('should return "pulsechain" for pulsechain chain ID', () => {
|
|
45
|
+
assert.equal(getChainName(369), 'pulsechain');
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
describe('getChainIdFromName', () => {
|
|
49
|
+
it('should return base chain ID for "base"', () => {
|
|
50
|
+
assert.equal(getChainIdFromName('base'), 8453);
|
|
51
|
+
});
|
|
52
|
+
it('should return pulsechain chain ID for "pulsechain"', () => {
|
|
53
|
+
assert.equal(getChainIdFromName('pulsechain'), 369);
|
|
54
|
+
});
|
|
55
|
+
it('should return null for invalid chain name', () => {
|
|
56
|
+
assert.equal(getChainIdFromName('ethereum'), null);
|
|
57
|
+
assert.equal(getChainIdFromName('invalid'), null);
|
|
58
|
+
assert.equal(getChainIdFromName(''), null);
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
describe('isValidChainName', () => {
|
|
62
|
+
it('should return true for valid chain names', () => {
|
|
63
|
+
assert.equal(isValidChainName('base'), true);
|
|
64
|
+
assert.equal(isValidChainName('pulsechain'), true);
|
|
65
|
+
});
|
|
66
|
+
it('should return false for invalid chain names', () => {
|
|
67
|
+
assert.equal(isValidChainName('ethereum'), false);
|
|
68
|
+
assert.equal(isValidChainName('invalid'), false);
|
|
69
|
+
assert.equal(isValidChainName(''), false);
|
|
70
|
+
assert.equal(isValidChainName('BASE'), false); // Case sensitive
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
describe('getExplorerUrl', () => {
|
|
74
|
+
it('should generate correct tx URL for base', () => {
|
|
75
|
+
const url = getExplorerUrl(base, 'tx', '0x123');
|
|
76
|
+
assert.ok(url.includes('basescan'));
|
|
77
|
+
assert.ok(url.includes('/tx/0x123'));
|
|
78
|
+
});
|
|
79
|
+
it('should generate correct address URL for base', () => {
|
|
80
|
+
const url = getExplorerUrl(base, 'address', '0xabc');
|
|
81
|
+
assert.ok(url.includes('basescan'));
|
|
82
|
+
assert.ok(url.includes('/address/0xabc'));
|
|
83
|
+
});
|
|
84
|
+
it('should generate correct tx URL for pulsechain', () => {
|
|
85
|
+
const url = getExplorerUrl(pulsechain, 'tx', '0x456');
|
|
86
|
+
assert.ok(url.includes('/tx/0x456'));
|
|
87
|
+
});
|
|
88
|
+
it('should generate correct address URL for pulsechain', () => {
|
|
89
|
+
const url = getExplorerUrl(pulsechain, 'address', '0xdef');
|
|
90
|
+
assert.ok(url.includes('/address/0xdef'));
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
describe('chainIdToChain', () => {
|
|
94
|
+
it('should map base chain ID to base chain', () => {
|
|
95
|
+
assert.equal(chainIdToChain.get(8453), base);
|
|
96
|
+
});
|
|
97
|
+
it('should map pulsechain chain ID to pulsechain chain', () => {
|
|
98
|
+
assert.equal(chainIdToChain.get(369), pulsechain);
|
|
99
|
+
});
|
|
100
|
+
it('should return undefined for unknown chain ID', () => {
|
|
101
|
+
assert.equal(chainIdToChain.get(1), undefined);
|
|
102
|
+
});
|
|
103
|
+
});
|
|
104
|
+
describe('chainIdToTargetBlockTime', () => {
|
|
105
|
+
it('should have correct block time for pulsechain (10s)', () => {
|
|
106
|
+
assert.equal(chainIdToTargetBlockTime.get(369), 10_000);
|
|
107
|
+
});
|
|
108
|
+
it('should have correct block time for base (2s)', () => {
|
|
109
|
+
assert.equal(chainIdToTargetBlockTime.get(8453), 2_000);
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
});
|