@bgd-labs/toolbox 0.0.4 → 0.0.5

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/index.d.mts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { IPayloadsControllerCore_ABI, IGovernanceCore_ABI } from '@bgd-labs/aave-address-book/abis';
2
2
  import * as viem from 'viem';
3
- import { GetContractReturnType, Client, Hex, TestClient, Address, WalletClient, Abi } from 'viem';
3
+ import { GetContractReturnType, Client, Hex, TestClient, Address, WalletClient, HttpTransportConfig, ClientConfig, Abi } from 'viem';
4
4
 
5
5
  /**
6
6
  * In solidity it is a quite common practice to encode bit variables in bitmaps opposed to bool structs.
@@ -348,6 +348,93 @@ declare function diffFoundryStorageLayout(layoutBefore: FoundryStorage, layoutAf
348
348
 
349
349
  declare const EVENT_DB: readonly [];
350
350
 
351
+ declare const ChainId: {
352
+ readonly celo: 42220;
353
+ readonly mainnet: 1;
354
+ readonly polygon: 137;
355
+ readonly polygon_amoy: 80002;
356
+ readonly avalanche: 43114;
357
+ readonly avalanche_fuji: 43113;
358
+ readonly arbitrum: 42161;
359
+ readonly arbitrum_sepolia: 421614;
360
+ readonly fantom: 250;
361
+ readonly fantom_testnet: 4002;
362
+ readonly optimism: 10;
363
+ readonly optimism_sepolia: 11155420;
364
+ readonly harmony: 1666600000;
365
+ readonly sepolia: 11155111;
366
+ readonly scroll: 534352;
367
+ readonly scroll_sepolia: 534351;
368
+ readonly sonic: 146;
369
+ readonly mantle: 5000;
370
+ readonly metis: 1088;
371
+ readonly base: 8453;
372
+ readonly base_sepolia: 84532;
373
+ readonly bnb: 56;
374
+ readonly gnosis: 100;
375
+ readonly zkEVM: 1101;
376
+ readonly zksync: 324;
377
+ readonly linea: 59144;
378
+ };
379
+
380
+ type SupportedChainIds = (typeof ChainId)[keyof typeof ChainId];
381
+ /**
382
+ * A manually maintained list of public rpcs.
383
+ * These should only be used for prs coming from forks, which should not access secrets like the alchemy api key.
384
+ */
385
+ declare const publicRPCs: {
386
+ readonly 1: "https://eth.llamarpc.com";
387
+ readonly 137: "https://polygon.llamarpc.com";
388
+ readonly 42161: "https://polygon.llamarpc.com";
389
+ readonly 8453: "https://base.llamarpc.com";
390
+ readonly 56: "https://binance.llamarpc.com";
391
+ readonly 1088: "https://andromeda.metis.io/?owner=1088";
392
+ readonly 100: "https://rpc.ankr.com/gnosis";
393
+ readonly 534352: "https://rpc.scroll.io";
394
+ readonly 324: "https://mainnet.era.zksync.io";
395
+ readonly 250: "https://rpc.ftm.tools";
396
+ readonly 43114: "https://api.avax.network/ext/bc/C/rpc";
397
+ readonly 59144: "https://rpc.linea.build";
398
+ };
399
+ declare const alchemySupportedChainIds: (1 | 10 | 56 | 100 | 137 | 146 | 250 | 324 | 1101 | 4002 | 5000 | 8453 | 42161 | 42220 | 43113 | 43114 | 59144 | 80002 | 84532 | 421614 | 534351 | 534352 | 11155111 | 11155420 | 1088 | 1666600000)[];
400
+ declare const getNetworkEnv: (chainId: SupportedChainIds) => "RPC_MAINNET" | "RPC_OPTIMISM" | "RPC_FANTOM" | "RPC_CELO" | "RPC_POLYGON" | "RPC_POLYGON_AMOY" | "RPC_AVALANCHE" | "RPC_AVALANCHE_FUJI" | "RPC_ARBITRUM" | "RPC_ARBITRUM_SEPOLIA" | "RPC_FANTOM_TESTNET" | "RPC_OPTIMISM_SEPOLIA" | "RPC_HARMONY" | "RPC_SEPOLIA" | "RPC_SCROLL" | "RPC_SCROLL_SEPOLIA" | "RPC_SONIC" | "RPC_MANTLE" | "RPC_METIS" | "RPC_BASE" | "RPC_BASE_SEPOLIA" | "RPC_BNB" | "RPC_GNOSIS" | "RPC_ZKEVM" | "RPC_ZKSYNC" | "RPC_LINEA";
401
+ declare function getExplicitRPC(chainId: SupportedChainIds): string;
402
+ declare function getAlchemyRPC(chainId: SupportedChainIds, alchemyKey: string): string;
403
+ declare function getPublicRpc(chainId: SupportedChainIds): "https://eth.llamarpc.com" | "https://polygon.llamarpc.com" | "https://base.llamarpc.com" | "https://binance.llamarpc.com" | "https://andromeda.metis.io/?owner=1088" | "https://rpc.ankr.com/gnosis" | "https://rpc.scroll.io" | "https://mainnet.era.zksync.io" | "https://rpc.ftm.tools" | "https://api.avax.network/ext/bc/C/rpc" | "https://rpc.linea.build";
404
+ declare function getQuickNodeRpc(chainId: SupportedChainIds, options: {
405
+ quicknodeEndpointName: string;
406
+ quicknodeToken: string;
407
+ }): string;
408
+ type GetRPCUrlOptions = {
409
+ alchemyKey?: string;
410
+ quicknodeEndpointName?: string;
411
+ quicknodeToken?: string;
412
+ };
413
+ /**
414
+ * Return a RPC_URL for supported chains.
415
+ * If the RPC_URL environment variable is set, it will be used.
416
+ * Otherwise will construct the URL based on the chain ID and Alchemy API key.
417
+ *
418
+ * @notice This method acts as fall-through and will only revert if the ChainId is strictly not supported.
419
+ * If no RPC_URL is set, and non of the private rpc providers supports the chain, it will return undefined.
420
+ * @param chainId
421
+ * @param alchemyKey
422
+ * @returns the RPC_URL for the given chain ID
423
+ */
424
+ declare const getRPCUrl: (chainId: SupportedChainIds, options?: GetRPCUrlOptions) => string | undefined;
425
+ /**
426
+ * Returns a viem client for the given chain with the supplied config.
427
+ * @param chainId
428
+ * @param param1
429
+ * @returns A viem Client
430
+ */
431
+ declare function getClient(chainId: number, { httpConfig, clientConfig, providerConfig, forceRebuildClient, }: {
432
+ httpConfig?: Partial<HttpTransportConfig>;
433
+ clientConfig?: Partial<ClientConfig>;
434
+ providerConfig: GetRPCUrlOptions;
435
+ forceRebuildClient?: boolean;
436
+ }): Client;
437
+
351
438
  declare const erc1967_ImplementationSlot = "0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc";
352
439
  declare const erc1967_AdminSlot = "0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103";
353
440
 
@@ -387,4 +474,4 @@ declare function renderTenderlyReport({ client, sim, }: RenderTenderlyReportPara
387
474
  emitter: viem.Address;
388
475
  }[]>;
389
476
 
390
- export { EVENT_DB, type ExplorerConfig, type FoundryStorage, type GovernanceContract, HALF_RAY, HALF_WAD, HUMAN_READABLE_PAYLOAD_STATE, HUMAN_READABLE_PROPOSAL_STATE, LTV_PRECISION, PayloadState, type PayloadsControllerContract, ProposalState, RAY, type ReserveConfiguration, SECONDS_PER_YEAR, SelfdestuctCheckState, type Storage, type StorageType, type Tenderly_createVnetParamsResponse, WAD, WAD_RAY_RATIO, bitmapToIndexes, calculateAvailableBorrowsMarketReferenceCurrency, calculateCompoundedInterest, calculateHealthFactorFromBalances, calculateLinearInterest, checkForSelfdestruct, decodeReserveConfiguration, decodeReserveConfigurationV2, decodeUserConfiguration, diffCode, diffFoundryStorageLayout, erc1967_AdminSlot, erc1967_ImplementationSlot, foundry_getStandardJsonInput, foundry_getStorageLayout, getBits, getCurrentDebtBalance, getCurrentLiquidityBalance, getExplorer, getGovernance, getMarketReferenceCurrencyAndUsdBalance, getNonFinalizedPayloads, getNonFinalizedProposals, getNormalizedDebt, getNormalizedIncome, getPayloadsController, getSourceCode, isPayloadFinal, isProposalFinal, makePayloadExecutableOnTestClient, makeProposalExecutableOnTestClient, parseEtherscanStyleSourceCode, parseLogs, rayDiv, rayMul, rayToWad, renderTenderlyReport, setBits, tenderly_createVnet, tenderly_deleteVnet, tenderly_getVnet, tenderly_simVnet, wadDiv, wadToRay };
477
+ export { EVENT_DB, type ExplorerConfig, type FoundryStorage, type GovernanceContract, HALF_RAY, HALF_WAD, HUMAN_READABLE_PAYLOAD_STATE, HUMAN_READABLE_PROPOSAL_STATE, LTV_PRECISION, PayloadState, type PayloadsControllerContract, ProposalState, RAY, type ReserveConfiguration, SECONDS_PER_YEAR, SelfdestuctCheckState, type Storage, type StorageType, type Tenderly_createVnetParamsResponse, WAD, WAD_RAY_RATIO, alchemySupportedChainIds, bitmapToIndexes, calculateAvailableBorrowsMarketReferenceCurrency, calculateCompoundedInterest, calculateHealthFactorFromBalances, calculateLinearInterest, checkForSelfdestruct, decodeReserveConfiguration, decodeReserveConfigurationV2, decodeUserConfiguration, diffCode, diffFoundryStorageLayout, erc1967_AdminSlot, erc1967_ImplementationSlot, foundry_getStandardJsonInput, foundry_getStorageLayout, getAlchemyRPC, getBits, getClient, getCurrentDebtBalance, getCurrentLiquidityBalance, getExplicitRPC, getExplorer, getGovernance, getMarketReferenceCurrencyAndUsdBalance, getNetworkEnv, getNonFinalizedPayloads, getNonFinalizedProposals, getNormalizedDebt, getNormalizedIncome, getPayloadsController, getPublicRpc, getQuickNodeRpc, getRPCUrl, getSourceCode, isPayloadFinal, isProposalFinal, makePayloadExecutableOnTestClient, makeProposalExecutableOnTestClient, parseEtherscanStyleSourceCode, parseLogs, publicRPCs, rayDiv, rayMul, rayToWad, renderTenderlyReport, setBits, tenderly_createVnet, tenderly_deleteVnet, tenderly_getVnet, tenderly_simVnet, wadDiv, wadToRay };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { IPayloadsControllerCore_ABI, IGovernanceCore_ABI } from '@bgd-labs/aave-address-book/abis';
2
2
  import * as viem from 'viem';
3
- import { GetContractReturnType, Client, Hex, TestClient, Address, WalletClient, Abi } from 'viem';
3
+ import { GetContractReturnType, Client, Hex, TestClient, Address, WalletClient, HttpTransportConfig, ClientConfig, Abi } from 'viem';
4
4
 
5
5
  /**
6
6
  * In solidity it is a quite common practice to encode bit variables in bitmaps opposed to bool structs.
@@ -348,6 +348,93 @@ declare function diffFoundryStorageLayout(layoutBefore: FoundryStorage, layoutAf
348
348
 
349
349
  declare const EVENT_DB: readonly [];
350
350
 
351
+ declare const ChainId: {
352
+ readonly celo: 42220;
353
+ readonly mainnet: 1;
354
+ readonly polygon: 137;
355
+ readonly polygon_amoy: 80002;
356
+ readonly avalanche: 43114;
357
+ readonly avalanche_fuji: 43113;
358
+ readonly arbitrum: 42161;
359
+ readonly arbitrum_sepolia: 421614;
360
+ readonly fantom: 250;
361
+ readonly fantom_testnet: 4002;
362
+ readonly optimism: 10;
363
+ readonly optimism_sepolia: 11155420;
364
+ readonly harmony: 1666600000;
365
+ readonly sepolia: 11155111;
366
+ readonly scroll: 534352;
367
+ readonly scroll_sepolia: 534351;
368
+ readonly sonic: 146;
369
+ readonly mantle: 5000;
370
+ readonly metis: 1088;
371
+ readonly base: 8453;
372
+ readonly base_sepolia: 84532;
373
+ readonly bnb: 56;
374
+ readonly gnosis: 100;
375
+ readonly zkEVM: 1101;
376
+ readonly zksync: 324;
377
+ readonly linea: 59144;
378
+ };
379
+
380
+ type SupportedChainIds = (typeof ChainId)[keyof typeof ChainId];
381
+ /**
382
+ * A manually maintained list of public rpcs.
383
+ * These should only be used for prs coming from forks, which should not access secrets like the alchemy api key.
384
+ */
385
+ declare const publicRPCs: {
386
+ readonly 1: "https://eth.llamarpc.com";
387
+ readonly 137: "https://polygon.llamarpc.com";
388
+ readonly 42161: "https://polygon.llamarpc.com";
389
+ readonly 8453: "https://base.llamarpc.com";
390
+ readonly 56: "https://binance.llamarpc.com";
391
+ readonly 1088: "https://andromeda.metis.io/?owner=1088";
392
+ readonly 100: "https://rpc.ankr.com/gnosis";
393
+ readonly 534352: "https://rpc.scroll.io";
394
+ readonly 324: "https://mainnet.era.zksync.io";
395
+ readonly 250: "https://rpc.ftm.tools";
396
+ readonly 43114: "https://api.avax.network/ext/bc/C/rpc";
397
+ readonly 59144: "https://rpc.linea.build";
398
+ };
399
+ declare const alchemySupportedChainIds: (1 | 10 | 56 | 100 | 137 | 146 | 250 | 324 | 1101 | 4002 | 5000 | 8453 | 42161 | 42220 | 43113 | 43114 | 59144 | 80002 | 84532 | 421614 | 534351 | 534352 | 11155111 | 11155420 | 1088 | 1666600000)[];
400
+ declare const getNetworkEnv: (chainId: SupportedChainIds) => "RPC_MAINNET" | "RPC_OPTIMISM" | "RPC_FANTOM" | "RPC_CELO" | "RPC_POLYGON" | "RPC_POLYGON_AMOY" | "RPC_AVALANCHE" | "RPC_AVALANCHE_FUJI" | "RPC_ARBITRUM" | "RPC_ARBITRUM_SEPOLIA" | "RPC_FANTOM_TESTNET" | "RPC_OPTIMISM_SEPOLIA" | "RPC_HARMONY" | "RPC_SEPOLIA" | "RPC_SCROLL" | "RPC_SCROLL_SEPOLIA" | "RPC_SONIC" | "RPC_MANTLE" | "RPC_METIS" | "RPC_BASE" | "RPC_BASE_SEPOLIA" | "RPC_BNB" | "RPC_GNOSIS" | "RPC_ZKEVM" | "RPC_ZKSYNC" | "RPC_LINEA";
401
+ declare function getExplicitRPC(chainId: SupportedChainIds): string;
402
+ declare function getAlchemyRPC(chainId: SupportedChainIds, alchemyKey: string): string;
403
+ declare function getPublicRpc(chainId: SupportedChainIds): "https://eth.llamarpc.com" | "https://polygon.llamarpc.com" | "https://base.llamarpc.com" | "https://binance.llamarpc.com" | "https://andromeda.metis.io/?owner=1088" | "https://rpc.ankr.com/gnosis" | "https://rpc.scroll.io" | "https://mainnet.era.zksync.io" | "https://rpc.ftm.tools" | "https://api.avax.network/ext/bc/C/rpc" | "https://rpc.linea.build";
404
+ declare function getQuickNodeRpc(chainId: SupportedChainIds, options: {
405
+ quicknodeEndpointName: string;
406
+ quicknodeToken: string;
407
+ }): string;
408
+ type GetRPCUrlOptions = {
409
+ alchemyKey?: string;
410
+ quicknodeEndpointName?: string;
411
+ quicknodeToken?: string;
412
+ };
413
+ /**
414
+ * Return a RPC_URL for supported chains.
415
+ * If the RPC_URL environment variable is set, it will be used.
416
+ * Otherwise will construct the URL based on the chain ID and Alchemy API key.
417
+ *
418
+ * @notice This method acts as fall-through and will only revert if the ChainId is strictly not supported.
419
+ * If no RPC_URL is set, and non of the private rpc providers supports the chain, it will return undefined.
420
+ * @param chainId
421
+ * @param alchemyKey
422
+ * @returns the RPC_URL for the given chain ID
423
+ */
424
+ declare const getRPCUrl: (chainId: SupportedChainIds, options?: GetRPCUrlOptions) => string | undefined;
425
+ /**
426
+ * Returns a viem client for the given chain with the supplied config.
427
+ * @param chainId
428
+ * @param param1
429
+ * @returns A viem Client
430
+ */
431
+ declare function getClient(chainId: number, { httpConfig, clientConfig, providerConfig, forceRebuildClient, }: {
432
+ httpConfig?: Partial<HttpTransportConfig>;
433
+ clientConfig?: Partial<ClientConfig>;
434
+ providerConfig: GetRPCUrlOptions;
435
+ forceRebuildClient?: boolean;
436
+ }): Client;
437
+
351
438
  declare const erc1967_ImplementationSlot = "0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc";
352
439
  declare const erc1967_AdminSlot = "0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103";
353
440
 
@@ -387,4 +474,4 @@ declare function renderTenderlyReport({ client, sim, }: RenderTenderlyReportPara
387
474
  emitter: viem.Address;
388
475
  }[]>;
389
476
 
390
- export { EVENT_DB, type ExplorerConfig, type FoundryStorage, type GovernanceContract, HALF_RAY, HALF_WAD, HUMAN_READABLE_PAYLOAD_STATE, HUMAN_READABLE_PROPOSAL_STATE, LTV_PRECISION, PayloadState, type PayloadsControllerContract, ProposalState, RAY, type ReserveConfiguration, SECONDS_PER_YEAR, SelfdestuctCheckState, type Storage, type StorageType, type Tenderly_createVnetParamsResponse, WAD, WAD_RAY_RATIO, bitmapToIndexes, calculateAvailableBorrowsMarketReferenceCurrency, calculateCompoundedInterest, calculateHealthFactorFromBalances, calculateLinearInterest, checkForSelfdestruct, decodeReserveConfiguration, decodeReserveConfigurationV2, decodeUserConfiguration, diffCode, diffFoundryStorageLayout, erc1967_AdminSlot, erc1967_ImplementationSlot, foundry_getStandardJsonInput, foundry_getStorageLayout, getBits, getCurrentDebtBalance, getCurrentLiquidityBalance, getExplorer, getGovernance, getMarketReferenceCurrencyAndUsdBalance, getNonFinalizedPayloads, getNonFinalizedProposals, getNormalizedDebt, getNormalizedIncome, getPayloadsController, getSourceCode, isPayloadFinal, isProposalFinal, makePayloadExecutableOnTestClient, makeProposalExecutableOnTestClient, parseEtherscanStyleSourceCode, parseLogs, rayDiv, rayMul, rayToWad, renderTenderlyReport, setBits, tenderly_createVnet, tenderly_deleteVnet, tenderly_getVnet, tenderly_simVnet, wadDiv, wadToRay };
477
+ export { EVENT_DB, type ExplorerConfig, type FoundryStorage, type GovernanceContract, HALF_RAY, HALF_WAD, HUMAN_READABLE_PAYLOAD_STATE, HUMAN_READABLE_PROPOSAL_STATE, LTV_PRECISION, PayloadState, type PayloadsControllerContract, ProposalState, RAY, type ReserveConfiguration, SECONDS_PER_YEAR, SelfdestuctCheckState, type Storage, type StorageType, type Tenderly_createVnetParamsResponse, WAD, WAD_RAY_RATIO, alchemySupportedChainIds, bitmapToIndexes, calculateAvailableBorrowsMarketReferenceCurrency, calculateCompoundedInterest, calculateHealthFactorFromBalances, calculateLinearInterest, checkForSelfdestruct, decodeReserveConfiguration, decodeReserveConfigurationV2, decodeUserConfiguration, diffCode, diffFoundryStorageLayout, erc1967_AdminSlot, erc1967_ImplementationSlot, foundry_getStandardJsonInput, foundry_getStorageLayout, getAlchemyRPC, getBits, getClient, getCurrentDebtBalance, getCurrentLiquidityBalance, getExplicitRPC, getExplorer, getGovernance, getMarketReferenceCurrencyAndUsdBalance, getNetworkEnv, getNonFinalizedPayloads, getNonFinalizedProposals, getNormalizedDebt, getNormalizedIncome, getPayloadsController, getPublicRpc, getQuickNodeRpc, getRPCUrl, getSourceCode, isPayloadFinal, isProposalFinal, makePayloadExecutableOnTestClient, makeProposalExecutableOnTestClient, parseEtherscanStyleSourceCode, parseLogs, publicRPCs, rayDiv, rayMul, rayToWad, renderTenderlyReport, setBits, tenderly_createVnet, tenderly_deleteVnet, tenderly_getVnet, tenderly_simVnet, wadDiv, wadToRay };