@venusprotocol/chains 0.12.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,13 +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
82
  declare const opBnbTestnetFourierForkTimestamp: Date;
78
- declare const chains: { [chainId in ChainId]: Chain };
83
+ declare const chains: Record<ChainId, Chain>;
79
84
  //#endregion
80
85
  //#region src/tokens/underlyingTokens/index.d.ts
81
86
  declare const tokens: { [chainId in ChainId]: Token[] };
@@ -106,4 +111,17 @@ declare const getRpcUrls: ({
106
111
  alchemyApiKey: string;
107
112
  }) => { [chainId in ChainId]: string[] };
108
113
  //#endregion
109
- export { Chain, ChainId, GetTokenInput, IMAGES_DIR_NAME, IMAGES_DIR_PATH, MainnetChainId, NATIVE_TOKEN_ADDRESS, TestnetChainId, Token, VToken, bnb, chains, eth, getRpcUrls, getToken, opBnbTestnetFourierForkTimestamp, 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.4";
64
+ const version = "2.39.3";
64
65
 
65
66
  //#endregion
66
67
  //#region ../../node_modules/viem/_esm/errors/base.js
@@ -1366,7 +1367,7 @@ function serializeAuthorizationList(authorizationList) {
1366
1367
  if (!authorizationList || authorizationList.length === 0) return [];
1367
1368
  const serializedAuthorizationList = [];
1368
1369
  for (const authorization of authorizationList) {
1369
- const { chainId, nonce,...signature } = authorization;
1370
+ const { chainId, nonce, ...signature } = authorization;
1370
1371
  const contractAddress = authorization.address;
1371
1372
  serializedAuthorizationList.push([
1372
1373
  chainId ? toHex(chainId) : "0x",
@@ -1519,6 +1520,10 @@ function createHasher(hashCons) {
1519
1520
 
1520
1521
  //#endregion
1521
1522
  //#region ../../node_modules/@noble/hashes/esm/_md.js
1523
+ /**
1524
+ * Internal Merkle-Damgard hash utils.
1525
+ * @module
1526
+ */
1522
1527
  /** Polyfill for Safari 14. https://caniuse.com/mdn-javascript_builtins_dataview_setbiguint64 */
1523
1528
  function setBigUint64(view, byteOffset, value, isLE$1) {
1524
1529
  if (typeof view.setBigUint64 === "function") return view.setBigUint64(byteOffset, value, isLE$1);
@@ -1680,6 +1685,13 @@ const rotlBL = (h, l, s) => h << s - 32 | l >>> 64 - s;
1680
1685
  //#endregion
1681
1686
  //#region ../../node_modules/@noble/hashes/esm/sha2.js
1682
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
+ /**
1683
1695
  * Round constants:
1684
1696
  * First 32 bits of fractional parts of the cube roots of the first 64 primes 2..311)
1685
1697
  */
@@ -1837,6 +1849,16 @@ const sha256$2 = /* @__PURE__ */ createHasher(() => new SHA256());
1837
1849
 
1838
1850
  //#endregion
1839
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
+ */
1840
1862
  /** @deprecated Use import from `noble/hashes/sha2` module */
1841
1863
  const sha256$1 = sha256$2;
1842
1864
 
@@ -2286,6 +2308,17 @@ var LruMap = class extends Map {
2286
2308
 
2287
2309
  //#endregion
2288
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
+ */
2289
2322
  const _0n = BigInt(0);
2290
2323
  const _1n = BigInt(1);
2291
2324
  const _2n = BigInt(2);
@@ -3540,6 +3573,7 @@ const unichainSepolia$2 = /* @__PURE__ */ defineChain({
3540
3573
  //#region ../../node_modules/viem/_esm/chains/definitions/zksync.js
3541
3574
  const zksync = /* @__PURE__ */ defineChain({
3542
3575
  ...chainConfig,
3576
+ blockTime: 200,
3543
3577
  id: 324,
3544
3578
  name: "ZKsync Era",
3545
3579
  network: "zksync-era",
@@ -3577,6 +3611,7 @@ const zksync = /* @__PURE__ */ defineChain({
3577
3611
  //#region ../../node_modules/viem/_esm/chains/definitions/zksyncSepoliaTestnet.js
3578
3612
  const zksyncSepoliaTestnet = /* @__PURE__ */ defineChain({
3579
3613
  ...chainConfig,
3614
+ blockTime: 200,
3580
3615
  id: 300,
3581
3616
  name: "ZKsync Sepolia Testnet",
3582
3617
  network: "zksync-sepolia-testnet",
@@ -4221,8 +4256,7 @@ const bnb = {
4221
4256
 
4222
4257
  //#endregion
4223
4258
  //#region src/chains/chainMetadata/index.ts
4224
- const opBnbTestnetFourierForkTimestamp = /* @__PURE__ */ new Date("2025-10-06 03:00:00 AM UTC");
4225
- const isPassedOpBnbTestnetFourierFork = /* @__PURE__ */ new Date() >= opBnbTestnetFourierForkTimestamp;
4259
+ const opBnbTestnetFourierForkTimestamp = /* @__PURE__ */ new Date("2025-11-06 03:00:00 AM UTC");
4226
4260
  const chains = {
4227
4261
  [ChainId.BSC_MAINNET]: {
4228
4262
  name: "BNB Chain",
@@ -4230,8 +4264,24 @@ const chains = {
4230
4264
  explorerUrl: "https://bscscan.com",
4231
4265
  layerZeroScanUrl: "https://layerzeroscan.com",
4232
4266
  safeWalletApiUrl: "https://safe-transaction-bsc.safe.global",
4233
- blockTimeMs: 750,
4234
- 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
+ ],
4235
4285
  corePoolComptrollerContractAddress: "0xfD36E2c2a6789Db23113685031d7F16329158384",
4236
4286
  nativeToken: bnb
4237
4287
  },
@@ -4240,8 +4290,24 @@ const chains = {
4240
4290
  iconSrc: iconSrcs$1.bsc,
4241
4291
  explorerUrl: "https://testnet.bscscan.com",
4242
4292
  layerZeroScanUrl: "https://testnet.layerzeroscan.com",
4243
- blockTimeMs: 750,
4244
- 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
+ ],
4245
4311
  corePoolComptrollerContractAddress: "0x94d1820b2D1c7c7452A163983Dc888CEC546b77D",
4246
4312
  nativeToken: bnb
4247
4313
  },
@@ -4250,8 +4316,20 @@ const chains = {
4250
4316
  iconSrc: iconSrcs$1.opBnb,
4251
4317
  explorerUrl: "https://opbnbscan.com",
4252
4318
  layerZeroScanUrl: "https://layerzeroscan.com",
4253
- blockTimeMs: 500,
4254
- 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
+ ],
4255
4333
  corePoolComptrollerContractAddress: "0xD6e3E2A1d8d95caE355D15b3b9f8E5c2511874dd",
4256
4334
  nativeToken: bnb
4257
4335
  },
@@ -4260,8 +4338,20 @@ const chains = {
4260
4338
  iconSrc: iconSrcs$1.opBnb,
4261
4339
  explorerUrl: "https://testnet.opbnbscan.com",
4262
4340
  layerZeroScanUrl: "https://testnet.layerzeroscan.com",
4263
- blockTimeMs: isPassedOpBnbTestnetFourierFork ? 250 : 500,
4264
- blocksPerDay: isPassedOpBnbTestnetFourierFork ? 345600 : 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
+ ],
4265
4355
  corePoolComptrollerContractAddress: "0x2FCABb31E57F010D623D8d68e1E18Aed11d5A388",
4266
4356
  nativeToken: bnb
4267
4357
  },
@@ -4271,8 +4361,10 @@ const chains = {
4271
4361
  explorerUrl: "https://etherscan.io",
4272
4362
  layerZeroScanUrl: "https://layerzeroscan.com",
4273
4363
  safeWalletApiUrl: "https://safe-transaction-mainnet.safe.global",
4274
- blockTimeMs: 12e3,
4275
- blocksPerDay: 7200,
4364
+ hardforks: [{
4365
+ startTimestamp: (/* @__PURE__ */ new Date("2015-07-30 03:26:13 PM UTC")).getTime(),
4366
+ blockTimeMs: 12e3
4367
+ }],
4276
4368
  corePoolComptrollerContractAddress: "0x687a01ecF6d3907658f7A7c714749fAC32336D1B",
4277
4369
  nativeToken: eth
4278
4370
  },
@@ -4282,8 +4374,10 @@ const chains = {
4282
4374
  explorerUrl: "https://sepolia.etherscan.io",
4283
4375
  layerZeroScanUrl: "https://testnet.layerzeroscan.com",
4284
4376
  safeWalletApiUrl: "https://safe-transaction-sepolia.safe.global",
4285
- blockTimeMs: 12e3,
4286
- blocksPerDay: 7200,
4377
+ hardforks: [{
4378
+ startTimestamp: (/* @__PURE__ */ new Date("2015-07-30 03:26:13 PM UTC")).getTime(),
4379
+ blockTimeMs: 12e3
4380
+ }],
4287
4381
  corePoolComptrollerContractAddress: "0x7Aa39ab4BcA897F403425C9C6FDbd0f882Be0D70",
4288
4382
  nativeToken: eth
4289
4383
  },
@@ -6496,12 +6590,6 @@ const bscMainnet = [
6496
6590
  symbol: "vWBNB",
6497
6591
  underlyingToken: tokens[56][42]
6498
6592
  },
6499
- {
6500
- address: "0x6D0cDb3355c93A0cD20071aBbb3622731a95c73E",
6501
- decimals: 8,
6502
- symbol: "vPT-USDe-30OCT2025",
6503
- underlyingToken: tokens[56][66]
6504
- },
6505
6593
  {
6506
6594
  address: "0x89c910Eb8c90df818b4649b508Ba22130Dc73Adc",
6507
6595
  decimals: 8,
@@ -6532,12 +6620,6 @@ const bscMainnet = [
6532
6620
  symbol: "vUSDC",
6533
6621
  underlyingToken: tokens[56][5]
6534
6622
  },
6535
- {
6536
- address: "0x6D0cDb3355c93A0cD20071aBbb3622731a95c73E",
6537
- decimals: 8,
6538
- symbol: "vPT-USDe-30OCT2025",
6539
- underlyingToken: tokens[56][66]
6540
- },
6541
6623
  {
6542
6624
  address: "0x882C173bC7Ff3b7786CA16dfeD3DFFfb9Ee7847B",
6543
6625
  decimals: 8,
@@ -6993,12 +7075,6 @@ const bscTestnet = [
6993
7075
  symbol: "vWBNB",
6994
7076
  underlyingToken: tokens[97][34]
6995
7077
  },
6996
- {
6997
- address: "0x86a94290f2B8295daA3e53bA1286f2Ff21199143",
6998
- decimals: 8,
6999
- symbol: "vPT-USDe-30OCT2025",
7000
- underlyingToken: tokens[97][61]
7001
- },
7002
7078
  {
7003
7079
  address: "0xaB5504A3cde0d8253E8F981D663c7Ff7128B3e56",
7004
7080
  decimals: 8,
@@ -7029,12 +7105,6 @@ const bscTestnet = [
7029
7105
  symbol: "vUSDC",
7030
7106
  underlyingToken: tokens[97][5]
7031
7107
  },
7032
- {
7033
- address: "0x86a94290f2B8295daA3e53bA1286f2Ff21199143",
7034
- decimals: 8,
7035
- symbol: "vPT-USDe-30OCT2025",
7036
- underlyingToken: tokens[97][61]
7037
- },
7038
7108
  {
7039
7109
  address: "0xb6e9322C49FD75a367Fcb17B0Fcd62C5070EbCBe",
7040
7110
  decimals: 8,
@@ -8340,4 +8410,21 @@ const getRpcUrls = ({ nodeRealApiKey, alchemyApiKey }) => {
8340
8410
  };
8341
8411
 
8342
8412
  //#endregion
8343
- export { ChainId, IMAGES_DIR_NAME, IMAGES_DIR_PATH, MainnetChainId, NATIVE_TOKEN_ADDRESS, TestnetChainId, bnb, chains, eth, getRpcUrls, getToken, opBnbTestnetFourierForkTimestamp, 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.12.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"