@bgd-labs/toolbox 0.0.3 → 0.0.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/index.d.mts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { IPayloadsControllerCore_ABI, IGovernanceCore_ABI } from '@bgd-labs/aave-address-book/abis';
2
- import { GetContractReturnType, Client, Hex, TestClient, Address, WalletClient } from 'viem';
2
+ import * as viem from 'viem';
3
+ import { GetContractReturnType, Client, Hex, TestClient, Address, WalletClient, Abi } from 'viem';
3
4
 
4
5
  /**
5
6
  * In solidity it is a quite common practice to encode bit variables in bitmaps opposed to bool structs.
@@ -170,6 +171,7 @@ declare const HUMAN_READABLE_PAYLOAD_STATE: {
170
171
  type PayloadsControllerContract = GetContractReturnType<typeof IPayloadsControllerCore_ABI, Client>;
171
172
  declare function getPayloadsController<T extends Client>(client: T, address: Hex): PayloadsControllerContract;
172
173
  declare function makePayloadExecutableOnTestClient(client: TestClient, payloadsController: Address, payloadId: number): Promise<void>;
174
+ declare function isPayloadFinal(state: PayloadState): boolean;
173
175
  declare function getNonFinalizedPayloads<T extends Client>(client: T, payloadsController: Address): Promise<number[]>;
174
176
 
175
177
  declare enum ProposalState {
@@ -195,8 +197,24 @@ declare const HUMAN_READABLE_PROPOSAL_STATE: {
195
197
  type GovernanceContract = GetContractReturnType<typeof IGovernanceCore_ABI, Client>;
196
198
  declare function getGovernance<T extends Client>(client: T, address: Hex): GovernanceContract;
197
199
  declare function makeProposalExecutableOnTestClient(client: TestClient, governance: Address, proposalId: bigint): Promise<void>;
200
+ declare function isProposalFinal(state: ProposalState): boolean;
198
201
  declare function getNonFinalizedProposals<T extends Client>(client: T, governanceAddress: Address): Promise<bigint[]>;
199
202
 
203
+ type StandardJsonInput = {
204
+ language: string;
205
+ libraries: any;
206
+ settings: {
207
+ evmVersion: string;
208
+ optimizer: {
209
+ enabled: boolean;
210
+ runs: number;
211
+ };
212
+ };
213
+ sources: Record<string, {
214
+ content: string;
215
+ }>;
216
+ };
217
+
200
218
  type ExplorerConfig = {
201
219
  api: string;
202
220
  explorer: string;
@@ -231,20 +249,7 @@ declare function getSourceCode(params: GetSourceCodeParams): Promise<{
231
249
  SimilarMatch: string;
232
250
  SourceCode: string;
233
251
  }>;
234
- declare function parseEtherscanStyleSourceCode(sourceCode: string): {
235
- language: string;
236
- libraries: any;
237
- settings: {
238
- evmVersion: string;
239
- optimizer: {
240
- enabled: boolean;
241
- runs: number;
242
- };
243
- };
244
- sources: Record<string, {
245
- content: string;
246
- }>;
247
- };
252
+ declare function parseEtherscanStyleSourceCode(sourceCode: string): StandardJsonInput;
248
253
 
249
254
  /**
250
255
  * While tenderly is a fenomanal tool for testing, it is not always easy to use as there are minor bugs and small nuances to consider everywhere.
@@ -262,6 +267,7 @@ type Tenderly_createVnetParams = {
262
267
  baseChainId: number;
263
268
  forkChainId: number;
264
269
  blockNumber?: Hex;
270
+ force?: boolean;
265
271
  };
266
272
  type Tenderly_createVnetParamsResponse = {
267
273
  id: string;
@@ -290,17 +296,95 @@ type Tenderly_createVnetParamsResponse = {
290
296
  }
291
297
  ];
292
298
  };
293
- declare function tenderly_createVnet({ slug, displayName, baseChainId, forkChainId, blockNumber, }: Tenderly_createVnetParams, { accessToken, accountSlug, projectSlug }: TenderlyConfig): Promise<{
299
+ declare function tenderly_deleteVnet(vnetId: string, { accountSlug, projectSlug, accessToken }: TenderlyConfig): Promise<Response>;
300
+ declare function tenderly_simVnet(vnetId: string, { accountSlug, projectSlug, accessToken }: TenderlyConfig, body: any): Promise<any>;
301
+ declare function tenderly_getVnet(slug: string, { accountSlug, projectSlug, accessToken }: TenderlyConfig): Promise<{
302
+ id: string;
303
+ slug: string;
304
+ }[]>;
305
+ declare function tenderly_createVnet({ slug, displayName, baseChainId, forkChainId, blockNumber, force, }: Tenderly_createVnetParams, { accessToken, accountSlug, projectSlug }: TenderlyConfig): Promise<{
294
306
  vnet: Tenderly_createVnetParamsResponse;
295
307
  testClient: TestClient;
296
308
  walletClient: WalletClient;
297
- simulate: (body: any) => Promise<Response>;
309
+ simulate: (body: any) => Promise<any>;
298
310
  delete: () => Promise<Response>;
299
311
  }>;
300
312
 
313
+ /**
314
+ * Returns the standardJsonInput format as consumed by most explorers
315
+ * @param input Contract or path:Contract if contract is not unique.
316
+ */
317
+ declare function foundry_getStandardJsonInput(input: string): StandardJsonInput;
318
+ type Storage = {
319
+ astId: string;
320
+ contract: string;
321
+ label: string;
322
+ offset: number;
323
+ slot: number;
324
+ type: string;
325
+ };
326
+ type StorageType = {
327
+ encoding: string;
328
+ label: string;
329
+ numberOfBytes: number;
330
+ base?: string;
331
+ key?: string;
332
+ value?: string;
333
+ members?: {
334
+ astId: string;
335
+ contract: string;
336
+ offset: number;
337
+ slot: number;
338
+ type: string;
339
+ label: string;
340
+ }[];
341
+ };
342
+ type FoundryStorage = {
343
+ storage: Storage[];
344
+ types: Record<string, StorageType>;
345
+ };
346
+ declare function foundry_getStorageLayout(input: string): FoundryStorage;
347
+ declare function diffFoundryStorageLayout(layoutBefore: FoundryStorage, layoutAfter: FoundryStorage): string;
348
+
349
+ declare const EVENT_DB: readonly [];
350
+
301
351
  declare const erc1967_ImplementationSlot = "0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc";
302
352
  declare const erc1967_AdminSlot = "0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103";
303
353
 
304
- declare function diffCode(codeBefore: string, codeAfter: string): Promise<Record<string, string>>;
354
+ declare function diffCode(before: StandardJsonInput, after: StandardJsonInput): Promise<Record<string, string>>;
355
+
356
+ type LogType = {
357
+ topics: [Hex];
358
+ data: Hex;
359
+ emitter: Address;
360
+ };
361
+ interface ParseLogsArgs {
362
+ logs: LogType[];
363
+ eventDb: Abi;
364
+ }
365
+ declare function parseLogs({ logs, eventDb }: ParseLogsArgs): LogType[];
366
+
367
+ declare enum SelfdestuctCheckState {
368
+ TRUSTED = 0,
369
+ EOA = 1,
370
+ EMPTY = 2,
371
+ DELEGATECALL = 3,
372
+ SAFE = 4,
373
+ SELF_DESTRUCT = 5
374
+ }
375
+ declare function checkForSelfdestruct(client: Client, addresses: Address[], trustedAddresses: Address[]): Promise<{
376
+ address: Address;
377
+ state: SelfdestuctCheckState;
378
+ }[]>;
379
+
380
+ type RenderTenderlyReportParams = {
381
+ client: Client;
382
+ sim: any;
383
+ };
384
+ declare function renderTenderlyReport({ client, sim, }: RenderTenderlyReportParams): Promise<{
385
+ topics: [viem.Hex];
386
+ data: viem.Hex;
387
+ emitter: viem.Address;
388
+ }[]>;
305
389
 
306
- export { type ExplorerConfig, 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, type Tenderly_createVnetParamsResponse, WAD, WAD_RAY_RATIO, bitmapToIndexes, calculateAvailableBorrowsMarketReferenceCurrency, calculateCompoundedInterest, calculateHealthFactorFromBalances, calculateLinearInterest, decodeReserveConfiguration, decodeReserveConfigurationV2, decodeUserConfiguration, diffCode, erc1967_AdminSlot, erc1967_ImplementationSlot, getBits, getCurrentDebtBalance, getCurrentLiquidityBalance, getExplorer, getGovernance, getMarketReferenceCurrencyAndUsdBalance, getNonFinalizedPayloads, getNonFinalizedProposals, getNormalizedDebt, getNormalizedIncome, getPayloadsController, getSourceCode, makePayloadExecutableOnTestClient, makeProposalExecutableOnTestClient, parseEtherscanStyleSourceCode, rayDiv, rayMul, rayToWad, setBits, tenderly_createVnet, wadDiv, wadToRay };
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 };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { IPayloadsControllerCore_ABI, IGovernanceCore_ABI } from '@bgd-labs/aave-address-book/abis';
2
- import { GetContractReturnType, Client, Hex, TestClient, Address, WalletClient } from 'viem';
2
+ import * as viem from 'viem';
3
+ import { GetContractReturnType, Client, Hex, TestClient, Address, WalletClient, Abi } from 'viem';
3
4
 
4
5
  /**
5
6
  * In solidity it is a quite common practice to encode bit variables in bitmaps opposed to bool structs.
@@ -170,6 +171,7 @@ declare const HUMAN_READABLE_PAYLOAD_STATE: {
170
171
  type PayloadsControllerContract = GetContractReturnType<typeof IPayloadsControllerCore_ABI, Client>;
171
172
  declare function getPayloadsController<T extends Client>(client: T, address: Hex): PayloadsControllerContract;
172
173
  declare function makePayloadExecutableOnTestClient(client: TestClient, payloadsController: Address, payloadId: number): Promise<void>;
174
+ declare function isPayloadFinal(state: PayloadState): boolean;
173
175
  declare function getNonFinalizedPayloads<T extends Client>(client: T, payloadsController: Address): Promise<number[]>;
174
176
 
175
177
  declare enum ProposalState {
@@ -195,8 +197,24 @@ declare const HUMAN_READABLE_PROPOSAL_STATE: {
195
197
  type GovernanceContract = GetContractReturnType<typeof IGovernanceCore_ABI, Client>;
196
198
  declare function getGovernance<T extends Client>(client: T, address: Hex): GovernanceContract;
197
199
  declare function makeProposalExecutableOnTestClient(client: TestClient, governance: Address, proposalId: bigint): Promise<void>;
200
+ declare function isProposalFinal(state: ProposalState): boolean;
198
201
  declare function getNonFinalizedProposals<T extends Client>(client: T, governanceAddress: Address): Promise<bigint[]>;
199
202
 
203
+ type StandardJsonInput = {
204
+ language: string;
205
+ libraries: any;
206
+ settings: {
207
+ evmVersion: string;
208
+ optimizer: {
209
+ enabled: boolean;
210
+ runs: number;
211
+ };
212
+ };
213
+ sources: Record<string, {
214
+ content: string;
215
+ }>;
216
+ };
217
+
200
218
  type ExplorerConfig = {
201
219
  api: string;
202
220
  explorer: string;
@@ -231,20 +249,7 @@ declare function getSourceCode(params: GetSourceCodeParams): Promise<{
231
249
  SimilarMatch: string;
232
250
  SourceCode: string;
233
251
  }>;
234
- declare function parseEtherscanStyleSourceCode(sourceCode: string): {
235
- language: string;
236
- libraries: any;
237
- settings: {
238
- evmVersion: string;
239
- optimizer: {
240
- enabled: boolean;
241
- runs: number;
242
- };
243
- };
244
- sources: Record<string, {
245
- content: string;
246
- }>;
247
- };
252
+ declare function parseEtherscanStyleSourceCode(sourceCode: string): StandardJsonInput;
248
253
 
249
254
  /**
250
255
  * While tenderly is a fenomanal tool for testing, it is not always easy to use as there are minor bugs and small nuances to consider everywhere.
@@ -262,6 +267,7 @@ type Tenderly_createVnetParams = {
262
267
  baseChainId: number;
263
268
  forkChainId: number;
264
269
  blockNumber?: Hex;
270
+ force?: boolean;
265
271
  };
266
272
  type Tenderly_createVnetParamsResponse = {
267
273
  id: string;
@@ -290,17 +296,95 @@ type Tenderly_createVnetParamsResponse = {
290
296
  }
291
297
  ];
292
298
  };
293
- declare function tenderly_createVnet({ slug, displayName, baseChainId, forkChainId, blockNumber, }: Tenderly_createVnetParams, { accessToken, accountSlug, projectSlug }: TenderlyConfig): Promise<{
299
+ declare function tenderly_deleteVnet(vnetId: string, { accountSlug, projectSlug, accessToken }: TenderlyConfig): Promise<Response>;
300
+ declare function tenderly_simVnet(vnetId: string, { accountSlug, projectSlug, accessToken }: TenderlyConfig, body: any): Promise<any>;
301
+ declare function tenderly_getVnet(slug: string, { accountSlug, projectSlug, accessToken }: TenderlyConfig): Promise<{
302
+ id: string;
303
+ slug: string;
304
+ }[]>;
305
+ declare function tenderly_createVnet({ slug, displayName, baseChainId, forkChainId, blockNumber, force, }: Tenderly_createVnetParams, { accessToken, accountSlug, projectSlug }: TenderlyConfig): Promise<{
294
306
  vnet: Tenderly_createVnetParamsResponse;
295
307
  testClient: TestClient;
296
308
  walletClient: WalletClient;
297
- simulate: (body: any) => Promise<Response>;
309
+ simulate: (body: any) => Promise<any>;
298
310
  delete: () => Promise<Response>;
299
311
  }>;
300
312
 
313
+ /**
314
+ * Returns the standardJsonInput format as consumed by most explorers
315
+ * @param input Contract or path:Contract if contract is not unique.
316
+ */
317
+ declare function foundry_getStandardJsonInput(input: string): StandardJsonInput;
318
+ type Storage = {
319
+ astId: string;
320
+ contract: string;
321
+ label: string;
322
+ offset: number;
323
+ slot: number;
324
+ type: string;
325
+ };
326
+ type StorageType = {
327
+ encoding: string;
328
+ label: string;
329
+ numberOfBytes: number;
330
+ base?: string;
331
+ key?: string;
332
+ value?: string;
333
+ members?: {
334
+ astId: string;
335
+ contract: string;
336
+ offset: number;
337
+ slot: number;
338
+ type: string;
339
+ label: string;
340
+ }[];
341
+ };
342
+ type FoundryStorage = {
343
+ storage: Storage[];
344
+ types: Record<string, StorageType>;
345
+ };
346
+ declare function foundry_getStorageLayout(input: string): FoundryStorage;
347
+ declare function diffFoundryStorageLayout(layoutBefore: FoundryStorage, layoutAfter: FoundryStorage): string;
348
+
349
+ declare const EVENT_DB: readonly [];
350
+
301
351
  declare const erc1967_ImplementationSlot = "0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc";
302
352
  declare const erc1967_AdminSlot = "0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103";
303
353
 
304
- declare function diffCode(codeBefore: string, codeAfter: string): Promise<Record<string, string>>;
354
+ declare function diffCode(before: StandardJsonInput, after: StandardJsonInput): Promise<Record<string, string>>;
355
+
356
+ type LogType = {
357
+ topics: [Hex];
358
+ data: Hex;
359
+ emitter: Address;
360
+ };
361
+ interface ParseLogsArgs {
362
+ logs: LogType[];
363
+ eventDb: Abi;
364
+ }
365
+ declare function parseLogs({ logs, eventDb }: ParseLogsArgs): LogType[];
366
+
367
+ declare enum SelfdestuctCheckState {
368
+ TRUSTED = 0,
369
+ EOA = 1,
370
+ EMPTY = 2,
371
+ DELEGATECALL = 3,
372
+ SAFE = 4,
373
+ SELF_DESTRUCT = 5
374
+ }
375
+ declare function checkForSelfdestruct(client: Client, addresses: Address[], trustedAddresses: Address[]): Promise<{
376
+ address: Address;
377
+ state: SelfdestuctCheckState;
378
+ }[]>;
379
+
380
+ type RenderTenderlyReportParams = {
381
+ client: Client;
382
+ sim: any;
383
+ };
384
+ declare function renderTenderlyReport({ client, sim, }: RenderTenderlyReportParams): Promise<{
385
+ topics: [viem.Hex];
386
+ data: viem.Hex;
387
+ emitter: viem.Address;
388
+ }[]>;
305
389
 
306
- export { type ExplorerConfig, 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, type Tenderly_createVnetParamsResponse, WAD, WAD_RAY_RATIO, bitmapToIndexes, calculateAvailableBorrowsMarketReferenceCurrency, calculateCompoundedInterest, calculateHealthFactorFromBalances, calculateLinearInterest, decodeReserveConfiguration, decodeReserveConfigurationV2, decodeUserConfiguration, diffCode, erc1967_AdminSlot, erc1967_ImplementationSlot, getBits, getCurrentDebtBalance, getCurrentLiquidityBalance, getExplorer, getGovernance, getMarketReferenceCurrencyAndUsdBalance, getNonFinalizedPayloads, getNonFinalizedProposals, getNormalizedDebt, getNormalizedIncome, getPayloadsController, getSourceCode, makePayloadExecutableOnTestClient, makeProposalExecutableOnTestClient, parseEtherscanStyleSourceCode, rayDiv, rayMul, rayToWad, setBits, tenderly_createVnet, wadDiv, wadToRay };
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 };