@venusprotocol/chains 0.11.0 → 0.13.0

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/build/index.d.mts CHANGED
@@ -40,6 +40,10 @@ declare enum TestnetChainId {
40
40
  BASE_SEPOLIA = 84532,
41
41
  UNICHIAN_SEPOLIA = 1301,
42
42
  }
43
+ interface Hardfork {
44
+ startTimestamp: number;
45
+ blockTimeMs: number;
46
+ }
43
47
  interface Chain {
44
48
  name: string;
45
49
  iconSrc: string;
@@ -49,7 +53,7 @@ interface Chain {
49
53
  corePoolComptrollerContractAddress: Address;
50
54
  safeWalletApiUrl?: string;
51
55
  proposalExecutionGracePeriodMs?: number;
52
- blockTimeMs?: number;
56
+ hardforks?: Hardfork[];
53
57
  blocksPerDay?: number;
54
58
  }
55
59
  interface Token {
@@ -69,12 +73,14 @@ interface VToken extends Omit<Token, 'isNative' | 'iconSrc' | 'tokenWrapped'> {
69
73
  declare const NATIVE_TOKEN_ADDRESS: "0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB";
70
74
  declare const IMAGES_DIR_NAME = "images";
71
75
  declare const IMAGES_DIR_PATH = "src/images";
76
+ declare const MS_PER_DAY: number;
72
77
  //#endregion
73
78
  //#region src/chains/viemChains/index.d.ts
74
79
  declare const viemChains: Record<ChainId, Chain$1>;
75
80
  //#endregion
76
81
  //#region src/chains/chainMetadata/index.d.ts
77
- declare const chains: { [chainId in ChainId]: Chain };
82
+ declare const opBnbTestnetFourierForkTimestamp: Date;
83
+ declare const chains: Record<ChainId, Chain>;
78
84
  //#endregion
79
85
  //#region src/tokens/underlyingTokens/index.d.ts
80
86
  declare const tokens: { [chainId in ChainId]: Token[] };
@@ -105,4 +111,17 @@ declare const getRpcUrls: ({
105
111
  alchemyApiKey: string;
106
112
  }) => { [chainId in ChainId]: string[] };
107
113
  //#endregion
108
- export { Chain, ChainId, GetTokenInput, IMAGES_DIR_NAME, IMAGES_DIR_PATH, MainnetChainId, NATIVE_TOKEN_ADDRESS, TestnetChainId, Token, VToken, bnb, chains, eth, getRpcUrls, getToken, tokens, vTokens, viemChains };
114
+ //#region src/utilities/getBlockTimeByChainId/index.d.ts
115
+ declare const getBlockTimeByChainId: ({
116
+ chainId,
117
+ targetTimestamp
118
+ }: {
119
+ chainId: ChainId;
120
+ targetTimestamp?: number;
121
+ }) => {
122
+ startTimestamp: number;
123
+ blockTimeMs: number;
124
+ blocksPerDay: number;
125
+ } | undefined;
126
+ //#endregion
127
+ export { Chain, ChainId, GetTokenInput, Hardfork, IMAGES_DIR_NAME, IMAGES_DIR_PATH, MS_PER_DAY, MainnetChainId, NATIVE_TOKEN_ADDRESS, TestnetChainId, Token, VToken, bnb, chains, eth, getBlockTimeByChainId, getRpcUrls, getToken, opBnbTestnetFourierForkTimestamp, tokens, vTokens, viemChains };
package/build/index.mjs CHANGED
@@ -46,6 +46,7 @@ let TestnetChainId = /* @__PURE__ */ function(TestnetChainId$1) {
46
46
  const NATIVE_TOKEN_ADDRESS = "0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB";
47
47
  const IMAGES_DIR_NAME = "images";
48
48
  const IMAGES_DIR_PATH = `src/${IMAGES_DIR_NAME}`;
49
+ const MS_PER_DAY = 1e3 * 60 * 60 * 24;
49
50
 
50
51
  //#endregion
51
52
  //#region ../../node_modules/viem/_esm/utils/chain/defineChain.js
@@ -60,7 +61,7 @@ function defineChain(chain) {
60
61
 
61
62
  //#endregion
62
63
  //#region ../../node_modules/viem/_esm/errors/version.js
63
- const version = "2.38.3";
64
+ const version = "2.39.3";
64
65
 
65
66
  //#endregion
66
67
  //#region ../../node_modules/viem/_esm/errors/base.js
@@ -804,6 +805,7 @@ function formatTransactionRequest(request, _) {
804
805
  if (typeof request.blobs !== "undefined") if (typeof request.blobs[0] !== "string") rpcRequest.blobs = request.blobs.map((x) => bytesToHex(x));
805
806
  else rpcRequest.blobs = request.blobs;
806
807
  if (typeof request.data !== "undefined") rpcRequest.data = request.data;
808
+ if (request.account) rpcRequest.from = request.account.address;
807
809
  if (typeof request.from !== "undefined") rpcRequest.from = request.from;
808
810
  if (typeof request.gas !== "undefined") rpcRequest.gas = numberToHex(request.gas);
809
811
  if (typeof request.gasPrice !== "undefined") rpcRequest.gasPrice = numberToHex(request.gasPrice);
@@ -1365,7 +1367,7 @@ function serializeAuthorizationList(authorizationList) {
1365
1367
  if (!authorizationList || authorizationList.length === 0) return [];
1366
1368
  const serializedAuthorizationList = [];
1367
1369
  for (const authorization of authorizationList) {
1368
- const { chainId, nonce,...signature } = authorization;
1370
+ const { chainId, nonce, ...signature } = authorization;
1369
1371
  const contractAddress = authorization.address;
1370
1372
  serializedAuthorizationList.push([
1371
1373
  chainId ? toHex(chainId) : "0x",
@@ -1518,6 +1520,10 @@ function createHasher(hashCons) {
1518
1520
 
1519
1521
  //#endregion
1520
1522
  //#region ../../node_modules/@noble/hashes/esm/_md.js
1523
+ /**
1524
+ * Internal Merkle-Damgard hash utils.
1525
+ * @module
1526
+ */
1521
1527
  /** Polyfill for Safari 14. https://caniuse.com/mdn-javascript_builtins_dataview_setbiguint64 */
1522
1528
  function setBigUint64(view, byteOffset, value, isLE$1) {
1523
1529
  if (typeof view.setBigUint64 === "function") return view.setBigUint64(byteOffset, value, isLE$1);
@@ -1679,6 +1685,13 @@ const rotlBL = (h, l, s) => h << s - 32 | l >>> 64 - s;
1679
1685
  //#endregion
1680
1686
  //#region ../../node_modules/@noble/hashes/esm/sha2.js
1681
1687
  /**
1688
+ * SHA2 hash function. A.k.a. sha256, sha384, sha512, sha512_224, sha512_256.
1689
+ * SHA256 is the fastest hash implementable in JS, even faster than Blake3.
1690
+ * Check out [RFC 4634](https://datatracker.ietf.org/doc/html/rfc4634) and
1691
+ * [FIPS 180-4](https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf).
1692
+ * @module
1693
+ */
1694
+ /**
1682
1695
  * Round constants:
1683
1696
  * First 32 bits of fractional parts of the cube roots of the first 64 primes 2..311)
1684
1697
  */
@@ -1836,6 +1849,16 @@ const sha256$2 = /* @__PURE__ */ createHasher(() => new SHA256());
1836
1849
 
1837
1850
  //#endregion
1838
1851
  //#region ../../node_modules/@noble/hashes/esm/sha256.js
1852
+ /**
1853
+ * SHA2-256 a.k.a. sha256. In JS, it is the fastest hash, even faster than Blake3.
1854
+ *
1855
+ * To break sha256 using birthday attack, attackers need to try 2^128 hashes.
1856
+ * BTC network is doing 2^70 hashes/sec (2^95 hashes/year) as per 2025.
1857
+ *
1858
+ * Check out [FIPS 180-4](https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf).
1859
+ * @module
1860
+ * @deprecated
1861
+ */
1839
1862
  /** @deprecated Use import from `noble/hashes/sha2` module */
1840
1863
  const sha256$1 = sha256$2;
1841
1864
 
@@ -2285,6 +2308,17 @@ var LruMap = class extends Map {
2285
2308
 
2286
2309
  //#endregion
2287
2310
  //#region ../../node_modules/@noble/hashes/esm/sha3.js
2311
+ /**
2312
+ * SHA3 (keccak) hash function, based on a new "Sponge function" design.
2313
+ * Different from older hashes, the internal state is bigger than output size.
2314
+ *
2315
+ * Check out [FIPS-202](https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.202.pdf),
2316
+ * [Website](https://keccak.team/keccak.html),
2317
+ * [the differences between SHA-3 and Keccak](https://crypto.stackexchange.com/questions/15727/what-are-the-key-differences-between-the-draft-sha-3-standard-and-the-keccak-sub).
2318
+ *
2319
+ * Check out `sha3-addons` module for cSHAKE, k12, and others.
2320
+ * @module
2321
+ */
2288
2322
  const _0n = BigInt(0);
2289
2323
  const _1n = BigInt(1);
2290
2324
  const _2n = BigInt(2);
@@ -3451,7 +3485,7 @@ const sepolia$2 = /* @__PURE__ */ defineChain({
3451
3485
  symbol: "ETH",
3452
3486
  decimals: 18
3453
3487
  },
3454
- rpcUrls: { default: { http: ["https://sepolia.drpc.org"] } },
3488
+ rpcUrls: { default: { http: ["https://11155111.rpc.thirdweb.com"] } },
3455
3489
  blockExplorers: { default: {
3456
3490
  name: "Etherscan",
3457
3491
  url: "https://sepolia.etherscan.io",
@@ -3539,6 +3573,7 @@ const unichainSepolia$2 = /* @__PURE__ */ defineChain({
3539
3573
  //#region ../../node_modules/viem/_esm/chains/definitions/zksync.js
3540
3574
  const zksync = /* @__PURE__ */ defineChain({
3541
3575
  ...chainConfig,
3576
+ blockTime: 200,
3542
3577
  id: 324,
3543
3578
  name: "ZKsync Era",
3544
3579
  network: "zksync-era",
@@ -3576,6 +3611,7 @@ const zksync = /* @__PURE__ */ defineChain({
3576
3611
  //#region ../../node_modules/viem/_esm/chains/definitions/zksyncSepoliaTestnet.js
3577
3612
  const zksyncSepoliaTestnet = /* @__PURE__ */ defineChain({
3578
3613
  ...chainConfig,
3614
+ blockTime: 200,
3579
3615
  id: 300,
3580
3616
  name: "ZKsync Sepolia Testnet",
3581
3617
  network: "zksync-sepolia-testnet",
@@ -4220,6 +4256,7 @@ const bnb = {
4220
4256
 
4221
4257
  //#endregion
4222
4258
  //#region src/chains/chainMetadata/index.ts
4259
+ const opBnbTestnetFourierForkTimestamp = /* @__PURE__ */ new Date("2025-11-06 03:00:00 AM UTC");
4223
4260
  const chains = {
4224
4261
  [ChainId.BSC_MAINNET]: {
4225
4262
  name: "BNB Chain",
@@ -4227,8 +4264,24 @@ const chains = {
4227
4264
  explorerUrl: "https://bscscan.com",
4228
4265
  layerZeroScanUrl: "https://layerzeroscan.com",
4229
4266
  safeWalletApiUrl: "https://safe-transaction-bsc.safe.global",
4230
- blockTimeMs: 750,
4231
- blocksPerDay: 115200,
4267
+ hardforks: [
4268
+ {
4269
+ startTimestamp: (/* @__PURE__ */ new Date("2020-04-20 01:46:54 PM UTC")).getTime(),
4270
+ blockTimeMs: 3e3
4271
+ },
4272
+ {
4273
+ startTimestamp: (/* @__PURE__ */ new Date("2025-04-29 05:05:00 AM UTC")).getTime(),
4274
+ blockTimeMs: 1500
4275
+ },
4276
+ {
4277
+ startTimestamp: (/* @__PURE__ */ new Date("2025-06-30 02:30:00 AM UTC")).getTime(),
4278
+ blockTimeMs: 750
4279
+ },
4280
+ {
4281
+ startTimestamp: (/* @__PURE__ */ new Date("2026-01-14 02:30:00 AM UTC")).getTime(),
4282
+ blockTimeMs: 450
4283
+ }
4284
+ ],
4232
4285
  corePoolComptrollerContractAddress: "0xfD36E2c2a6789Db23113685031d7F16329158384",
4233
4286
  nativeToken: bnb
4234
4287
  },
@@ -4237,8 +4290,24 @@ const chains = {
4237
4290
  iconSrc: iconSrcs$1.bsc,
4238
4291
  explorerUrl: "https://testnet.bscscan.com",
4239
4292
  layerZeroScanUrl: "https://testnet.layerzeroscan.com",
4240
- blockTimeMs: 750,
4241
- blocksPerDay: 115200,
4293
+ hardforks: [
4294
+ {
4295
+ startTimestamp: (/* @__PURE__ */ new Date("2020-06-09 07:57:19 AM UTC")).getTime(),
4296
+ blockTimeMs: 3e3
4297
+ },
4298
+ {
4299
+ startTimestamp: (/* @__PURE__ */ new Date("2025-04-08 07:33:00 AM UTC")).getTime(),
4300
+ blockTimeMs: 1500
4301
+ },
4302
+ {
4303
+ startTimestamp: (/* @__PURE__ */ new Date("2025-05-26 07:05:00 AM UTC")).getTime(),
4304
+ blockTimeMs: 750
4305
+ },
4306
+ {
4307
+ startTimestamp: (/* @__PURE__ */ new Date("2025-11-10 02:25:00 AM UTC")).getTime(),
4308
+ blockTimeMs: 450
4309
+ }
4310
+ ],
4242
4311
  corePoolComptrollerContractAddress: "0x94d1820b2D1c7c7452A163983Dc888CEC546b77D",
4243
4312
  nativeToken: bnb
4244
4313
  },
@@ -4247,8 +4316,20 @@ const chains = {
4247
4316
  iconSrc: iconSrcs$1.opBnb,
4248
4317
  explorerUrl: "https://opbnbscan.com",
4249
4318
  layerZeroScanUrl: "https://layerzeroscan.com",
4250
- blockTimeMs: 500,
4251
- blocksPerDay: 172800,
4319
+ hardforks: [
4320
+ {
4321
+ startTimestamp: (/* @__PURE__ */ new Date("2023-08-11 11:35:23 AM UTC")).getTime(),
4322
+ blockTimeMs: 1e3
4323
+ },
4324
+ {
4325
+ startTimestamp: (/* @__PURE__ */ new Date("2025-04-21 03:00:00 AM UTC")).getTime(),
4326
+ blockTimeMs: 500
4327
+ },
4328
+ {
4329
+ startTimestamp: (/* @__PURE__ */ new Date("2026-01-07 03:00:00 AM UTC")).getTime(),
4330
+ blockTimeMs: 250
4331
+ }
4332
+ ],
4252
4333
  corePoolComptrollerContractAddress: "0xD6e3E2A1d8d95caE355D15b3b9f8E5c2511874dd",
4253
4334
  nativeToken: bnb
4254
4335
  },
@@ -4257,8 +4338,20 @@ const chains = {
4257
4338
  iconSrc: iconSrcs$1.opBnb,
4258
4339
  explorerUrl: "https://testnet.opbnbscan.com",
4259
4340
  layerZeroScanUrl: "https://testnet.layerzeroscan.com",
4260
- blockTimeMs: 500,
4261
- blocksPerDay: 172800,
4341
+ hardforks: [
4342
+ {
4343
+ startTimestamp: (/* @__PURE__ */ new Date("2023-06-16 01:21:46 AM UTC")).getTime(),
4344
+ blockTimeMs: 1e3
4345
+ },
4346
+ {
4347
+ startTimestamp: (/* @__PURE__ */ new Date("2025-04-02 03:00:00 AM UTC")).getTime(),
4348
+ blockTimeMs: 500
4349
+ },
4350
+ {
4351
+ startTimestamp: (/* @__PURE__ */ new Date("2025-11-06 03:00:00 AM UTC")).getTime(),
4352
+ blockTimeMs: 250
4353
+ }
4354
+ ],
4262
4355
  corePoolComptrollerContractAddress: "0x2FCABb31E57F010D623D8d68e1E18Aed11d5A388",
4263
4356
  nativeToken: bnb
4264
4357
  },
@@ -4268,8 +4361,10 @@ const chains = {
4268
4361
  explorerUrl: "https://etherscan.io",
4269
4362
  layerZeroScanUrl: "https://layerzeroscan.com",
4270
4363
  safeWalletApiUrl: "https://safe-transaction-mainnet.safe.global",
4271
- blockTimeMs: 12e3,
4272
- blocksPerDay: 7200,
4364
+ hardforks: [{
4365
+ startTimestamp: (/* @__PURE__ */ new Date("2015-07-30 03:26:13 PM UTC")).getTime(),
4366
+ blockTimeMs: 12e3
4367
+ }],
4273
4368
  corePoolComptrollerContractAddress: "0x687a01ecF6d3907658f7A7c714749fAC32336D1B",
4274
4369
  nativeToken: eth
4275
4370
  },
@@ -4279,8 +4374,10 @@ const chains = {
4279
4374
  explorerUrl: "https://sepolia.etherscan.io",
4280
4375
  layerZeroScanUrl: "https://testnet.layerzeroscan.com",
4281
4376
  safeWalletApiUrl: "https://safe-transaction-sepolia.safe.global",
4282
- blockTimeMs: 12e3,
4283
- blocksPerDay: 7200,
4377
+ hardforks: [{
4378
+ startTimestamp: (/* @__PURE__ */ new Date("2015-07-30 03:26:13 PM UTC")).getTime(),
4379
+ blockTimeMs: 12e3
4380
+ }],
4284
4381
  corePoolComptrollerContractAddress: "0x7Aa39ab4BcA897F403425C9C6FDbd0f882Be0D70",
4285
4382
  nativeToken: eth
4286
4383
  },
@@ -6493,12 +6590,6 @@ const bscMainnet = [
6493
6590
  symbol: "vWBNB",
6494
6591
  underlyingToken: tokens[56][42]
6495
6592
  },
6496
- {
6497
- address: "0x6D0cDb3355c93A0cD20071aBbb3622731a95c73E",
6498
- decimals: 8,
6499
- symbol: "vPT-USDe-30OCT2025",
6500
- underlyingToken: tokens[56][66]
6501
- },
6502
6593
  {
6503
6594
  address: "0x89c910Eb8c90df818b4649b508Ba22130Dc73Adc",
6504
6595
  decimals: 8,
@@ -6529,12 +6620,6 @@ const bscMainnet = [
6529
6620
  symbol: "vUSDC",
6530
6621
  underlyingToken: tokens[56][5]
6531
6622
  },
6532
- {
6533
- address: "0x6D0cDb3355c93A0cD20071aBbb3622731a95c73E",
6534
- decimals: 8,
6535
- symbol: "vPT-USDe-30OCT2025",
6536
- underlyingToken: tokens[56][66]
6537
- },
6538
6623
  {
6539
6624
  address: "0x882C173bC7Ff3b7786CA16dfeD3DFFfb9Ee7847B",
6540
6625
  decimals: 8,
@@ -6990,12 +7075,6 @@ const bscTestnet = [
6990
7075
  symbol: "vWBNB",
6991
7076
  underlyingToken: tokens[97][34]
6992
7077
  },
6993
- {
6994
- address: "0x86a94290f2B8295daA3e53bA1286f2Ff21199143",
6995
- decimals: 8,
6996
- symbol: "vPT-USDe-30OCT2025",
6997
- underlyingToken: tokens[97][61]
6998
- },
6999
7078
  {
7000
7079
  address: "0xaB5504A3cde0d8253E8F981D663c7Ff7128B3e56",
7001
7080
  decimals: 8,
@@ -7026,12 +7105,6 @@ const bscTestnet = [
7026
7105
  symbol: "vUSDC",
7027
7106
  underlyingToken: tokens[97][5]
7028
7107
  },
7029
- {
7030
- address: "0x86a94290f2B8295daA3e53bA1286f2Ff21199143",
7031
- decimals: 8,
7032
- symbol: "vPT-USDe-30OCT2025",
7033
- underlyingToken: tokens[97][61]
7034
- },
7035
7108
  {
7036
7109
  address: "0xb6e9322C49FD75a367Fcb17B0Fcd62C5070EbCBe",
7037
7110
  decimals: 8,
@@ -8337,4 +8410,21 @@ const getRpcUrls = ({ nodeRealApiKey, alchemyApiKey }) => {
8337
8410
  };
8338
8411
 
8339
8412
  //#endregion
8340
- export { ChainId, IMAGES_DIR_NAME, IMAGES_DIR_PATH, MainnetChainId, NATIVE_TOKEN_ADDRESS, TestnetChainId, bnb, chains, eth, getRpcUrls, getToken, tokens, vTokens, viemChains };
8413
+ //#region src/utilities/getBlockTimeByChainId/index.ts
8414
+ const getBlockTimeByChainId = ({ chainId, targetTimestamp = (/* @__PURE__ */ new Date()).getTime() }) => {
8415
+ const targetChain = chains[chainId];
8416
+ if (!Array.isArray(targetChain.hardforks)) return void 0;
8417
+ let blockTime = targetChain.hardforks[0];
8418
+ if (targetChain.hardforks.length > 1) targetChain.hardforks.forEach((item) => {
8419
+ if (item.startTimestamp <= targetTimestamp) blockTime = item;
8420
+ });
8421
+ const { blockTimeMs, startTimestamp } = blockTime;
8422
+ return {
8423
+ startTimestamp,
8424
+ blockTimeMs,
8425
+ blocksPerDay: blockTime.blockTimeMs !== 0 ? MS_PER_DAY / blockTime.blockTimeMs : 0
8426
+ };
8427
+ };
8428
+
8429
+ //#endregion
8430
+ export { ChainId, IMAGES_DIR_NAME, IMAGES_DIR_PATH, MS_PER_DAY, MainnetChainId, NATIVE_TOKEN_ADDRESS, TestnetChainId, bnb, chains, eth, getBlockTimeByChainId, getRpcUrls, getToken, opBnbTestnetFourierForkTimestamp, tokens, vTokens, viemChains };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@venusprotocol/chains",
3
- "version": "0.11.0",
3
+ "version": "0.13.0",
4
4
  "license": "MIT",
5
5
  "publishConfig": {
6
6
  "access": "public",
@@ -48,7 +48,7 @@
48
48
  "npm-run-all": "^4.1.5",
49
49
  "react": "^19.2.0",
50
50
  "rimraf": "^6.0.1",
51
- "tsdown": "^0.15.6",
51
+ "tsdown": "^0.16.5",
52
52
  "tsx": "^4.20.5",
53
53
  "viem": "^2.23.1",
54
54
  "vitest": "^3.2.4"