@bgd-labs/toolbox 0.0.8 → 0.0.9
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 +48 -1
- package/dist/index.d.ts +48 -1
- package/dist/index.js +60 -19
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +58 -19
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -173,6 +173,10 @@ declare const HUMAN_READABLE_PAYLOAD_STATE: {
|
|
|
173
173
|
};
|
|
174
174
|
type PayloadsControllerContract = GetContractReturnType<typeof IPayloadsControllerCore_ABI, Client>;
|
|
175
175
|
declare function getPayloadsController<T extends Client>(client: T, address: Hex): PayloadsControllerContract;
|
|
176
|
+
declare function getPayloadStorageOverrides(client: TestClient, payloadsController: Address, payloadId: number): Promise<{
|
|
177
|
+
slot: `0x${string}`;
|
|
178
|
+
value: `0x${string}`;
|
|
179
|
+
}[]>;
|
|
176
180
|
declare function makePayloadExecutableOnTestClient(client: TestClient, payloadsController: Address, payloadId: number): Promise<void>;
|
|
177
181
|
declare function isPayloadFinal(state: PayloadState): boolean;
|
|
178
182
|
declare function getNonFinalizedPayloads<T extends Client>(client: T, payloadsController: Address): Promise<number[]>;
|
|
@@ -312,6 +316,49 @@ declare function tenderly_createVnet({ slug, displayName, baseChainId, forkChain
|
|
|
312
316
|
simulate: (body: object) => Promise<any>;
|
|
313
317
|
delete: () => Promise<Response>;
|
|
314
318
|
}>;
|
|
319
|
+
type StateObject = {
|
|
320
|
+
balance?: string;
|
|
321
|
+
code?: string;
|
|
322
|
+
storage?: Record<Hex, Hex>;
|
|
323
|
+
};
|
|
324
|
+
type ContractObject = {
|
|
325
|
+
contractName: string;
|
|
326
|
+
source: string;
|
|
327
|
+
sourcePath: string;
|
|
328
|
+
compiler: {
|
|
329
|
+
name: "solc";
|
|
330
|
+
version: string;
|
|
331
|
+
};
|
|
332
|
+
networks: Record<string, {
|
|
333
|
+
events?: Record<string, string>;
|
|
334
|
+
links?: Record<string, string>;
|
|
335
|
+
address: string;
|
|
336
|
+
transactionHash?: string;
|
|
337
|
+
}>;
|
|
338
|
+
};
|
|
339
|
+
type TenderlySimRequest = {
|
|
340
|
+
network_id: string;
|
|
341
|
+
block_number?: number;
|
|
342
|
+
transaction_index?: number;
|
|
343
|
+
from: Hex;
|
|
344
|
+
to: Hex;
|
|
345
|
+
input: Hex;
|
|
346
|
+
gas?: number;
|
|
347
|
+
gas_price?: string;
|
|
348
|
+
value?: string;
|
|
349
|
+
simulation_type?: "full" | "quick";
|
|
350
|
+
save?: boolean;
|
|
351
|
+
save_if_fails?: boolean;
|
|
352
|
+
state_objects?: Record<Hex, StateObject>;
|
|
353
|
+
contracts?: ContractObject[];
|
|
354
|
+
block_header?: {
|
|
355
|
+
number?: Hex;
|
|
356
|
+
timestamp?: Hex;
|
|
357
|
+
};
|
|
358
|
+
generate_access_list?: boolean;
|
|
359
|
+
root?: string;
|
|
360
|
+
};
|
|
361
|
+
declare function tenderly_sim({ accountSlug, projectSlug, accessToken }: TenderlyConfig, body: TenderlySimRequest): Promise<any>;
|
|
315
362
|
|
|
316
363
|
/**
|
|
317
364
|
* Returns the standardJsonInput format as consumed by most explorers
|
|
@@ -4945,4 +4992,4 @@ declare function renderTenderlyReport({ client, sim, }: RenderTenderlyReportPara
|
|
|
4945
4992
|
emitter: viem.Address;
|
|
4946
4993
|
}[]>;
|
|
4947
4994
|
|
|
4948
|
-
export { ChainId, ChainList, 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, alchemyNetworkMap, alchemySupportedChainIds, bitmapToIndexes, calculateAvailableBorrowsMarketReferenceCurrency, calculateCompoundedInterest, calculateHealthFactorFromBalances, calculateLinearInterest, checkForSelfdestruct, decodeReserveConfiguration, decodeReserveConfigurationV2, decodeUserConfiguration, diffCode, diffFoundryStorageLayout, erc1967_AdminSlot, erc1967_ImplementationSlot, etherscanExplorers, 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, quicknodeNetworkMap, rayDiv, rayMul, rayToWad, renderTenderlyReport, routescanExplorers, setBits, tenderly_createVnet, tenderly_deleteVnet, tenderly_getVnet, tenderly_simVnet, wadDiv, wadToRay };
|
|
4995
|
+
export { ChainId, ChainList, type ContractObject, 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 StateObject, type Storage, type StorageType, type TenderlySimRequest, type Tenderly_createVnetParamsResponse, WAD, WAD_RAY_RATIO, alchemyNetworkMap, alchemySupportedChainIds, bitmapToIndexes, calculateAvailableBorrowsMarketReferenceCurrency, calculateCompoundedInterest, calculateHealthFactorFromBalances, calculateLinearInterest, checkForSelfdestruct, decodeReserveConfiguration, decodeReserveConfigurationV2, decodeUserConfiguration, diffCode, diffFoundryStorageLayout, erc1967_AdminSlot, erc1967_ImplementationSlot, etherscanExplorers, foundry_getStandardJsonInput, foundry_getStorageLayout, getAlchemyRPC, getBits, getClient, getCurrentDebtBalance, getCurrentLiquidityBalance, getExplicitRPC, getExplorer, getGovernance, getMarketReferenceCurrencyAndUsdBalance, getNetworkEnv, getNonFinalizedPayloads, getNonFinalizedProposals, getNormalizedDebt, getNormalizedIncome, getPayloadStorageOverrides, getPayloadsController, getPublicRpc, getQuicknodeRpc, getRPCUrl, getSourceCode, isPayloadFinal, isProposalFinal, makePayloadExecutableOnTestClient, makeProposalExecutableOnTestClient, parseEtherscanStyleSourceCode, parseLogs, publicRPCs, quicknodeNetworkMap, rayDiv, rayMul, rayToWad, renderTenderlyReport, routescanExplorers, setBits, tenderly_createVnet, tenderly_deleteVnet, tenderly_getVnet, tenderly_sim, tenderly_simVnet, wadDiv, wadToRay };
|
package/dist/index.d.ts
CHANGED
|
@@ -173,6 +173,10 @@ declare const HUMAN_READABLE_PAYLOAD_STATE: {
|
|
|
173
173
|
};
|
|
174
174
|
type PayloadsControllerContract = GetContractReturnType<typeof IPayloadsControllerCore_ABI, Client>;
|
|
175
175
|
declare function getPayloadsController<T extends Client>(client: T, address: Hex): PayloadsControllerContract;
|
|
176
|
+
declare function getPayloadStorageOverrides(client: TestClient, payloadsController: Address, payloadId: number): Promise<{
|
|
177
|
+
slot: `0x${string}`;
|
|
178
|
+
value: `0x${string}`;
|
|
179
|
+
}[]>;
|
|
176
180
|
declare function makePayloadExecutableOnTestClient(client: TestClient, payloadsController: Address, payloadId: number): Promise<void>;
|
|
177
181
|
declare function isPayloadFinal(state: PayloadState): boolean;
|
|
178
182
|
declare function getNonFinalizedPayloads<T extends Client>(client: T, payloadsController: Address): Promise<number[]>;
|
|
@@ -312,6 +316,49 @@ declare function tenderly_createVnet({ slug, displayName, baseChainId, forkChain
|
|
|
312
316
|
simulate: (body: object) => Promise<any>;
|
|
313
317
|
delete: () => Promise<Response>;
|
|
314
318
|
}>;
|
|
319
|
+
type StateObject = {
|
|
320
|
+
balance?: string;
|
|
321
|
+
code?: string;
|
|
322
|
+
storage?: Record<Hex, Hex>;
|
|
323
|
+
};
|
|
324
|
+
type ContractObject = {
|
|
325
|
+
contractName: string;
|
|
326
|
+
source: string;
|
|
327
|
+
sourcePath: string;
|
|
328
|
+
compiler: {
|
|
329
|
+
name: "solc";
|
|
330
|
+
version: string;
|
|
331
|
+
};
|
|
332
|
+
networks: Record<string, {
|
|
333
|
+
events?: Record<string, string>;
|
|
334
|
+
links?: Record<string, string>;
|
|
335
|
+
address: string;
|
|
336
|
+
transactionHash?: string;
|
|
337
|
+
}>;
|
|
338
|
+
};
|
|
339
|
+
type TenderlySimRequest = {
|
|
340
|
+
network_id: string;
|
|
341
|
+
block_number?: number;
|
|
342
|
+
transaction_index?: number;
|
|
343
|
+
from: Hex;
|
|
344
|
+
to: Hex;
|
|
345
|
+
input: Hex;
|
|
346
|
+
gas?: number;
|
|
347
|
+
gas_price?: string;
|
|
348
|
+
value?: string;
|
|
349
|
+
simulation_type?: "full" | "quick";
|
|
350
|
+
save?: boolean;
|
|
351
|
+
save_if_fails?: boolean;
|
|
352
|
+
state_objects?: Record<Hex, StateObject>;
|
|
353
|
+
contracts?: ContractObject[];
|
|
354
|
+
block_header?: {
|
|
355
|
+
number?: Hex;
|
|
356
|
+
timestamp?: Hex;
|
|
357
|
+
};
|
|
358
|
+
generate_access_list?: boolean;
|
|
359
|
+
root?: string;
|
|
360
|
+
};
|
|
361
|
+
declare function tenderly_sim({ accountSlug, projectSlug, accessToken }: TenderlyConfig, body: TenderlySimRequest): Promise<any>;
|
|
315
362
|
|
|
316
363
|
/**
|
|
317
364
|
* Returns the standardJsonInput format as consumed by most explorers
|
|
@@ -4945,4 +4992,4 @@ declare function renderTenderlyReport({ client, sim, }: RenderTenderlyReportPara
|
|
|
4945
4992
|
emitter: viem.Address;
|
|
4946
4993
|
}[]>;
|
|
4947
4994
|
|
|
4948
|
-
export { ChainId, ChainList, 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, alchemyNetworkMap, alchemySupportedChainIds, bitmapToIndexes, calculateAvailableBorrowsMarketReferenceCurrency, calculateCompoundedInterest, calculateHealthFactorFromBalances, calculateLinearInterest, checkForSelfdestruct, decodeReserveConfiguration, decodeReserveConfigurationV2, decodeUserConfiguration, diffCode, diffFoundryStorageLayout, erc1967_AdminSlot, erc1967_ImplementationSlot, etherscanExplorers, 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, quicknodeNetworkMap, rayDiv, rayMul, rayToWad, renderTenderlyReport, routescanExplorers, setBits, tenderly_createVnet, tenderly_deleteVnet, tenderly_getVnet, tenderly_simVnet, wadDiv, wadToRay };
|
|
4995
|
+
export { ChainId, ChainList, type ContractObject, 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 StateObject, type Storage, type StorageType, type TenderlySimRequest, type Tenderly_createVnetParamsResponse, WAD, WAD_RAY_RATIO, alchemyNetworkMap, alchemySupportedChainIds, bitmapToIndexes, calculateAvailableBorrowsMarketReferenceCurrency, calculateCompoundedInterest, calculateHealthFactorFromBalances, calculateLinearInterest, checkForSelfdestruct, decodeReserveConfiguration, decodeReserveConfigurationV2, decodeUserConfiguration, diffCode, diffFoundryStorageLayout, erc1967_AdminSlot, erc1967_ImplementationSlot, etherscanExplorers, foundry_getStandardJsonInput, foundry_getStorageLayout, getAlchemyRPC, getBits, getClient, getCurrentDebtBalance, getCurrentLiquidityBalance, getExplicitRPC, getExplorer, getGovernance, getMarketReferenceCurrencyAndUsdBalance, getNetworkEnv, getNonFinalizedPayloads, getNonFinalizedProposals, getNormalizedDebt, getNormalizedIncome, getPayloadStorageOverrides, getPayloadsController, getPublicRpc, getQuicknodeRpc, getRPCUrl, getSourceCode, isPayloadFinal, isProposalFinal, makePayloadExecutableOnTestClient, makeProposalExecutableOnTestClient, parseEtherscanStyleSourceCode, parseLogs, publicRPCs, quicknodeNetworkMap, rayDiv, rayMul, rayToWad, renderTenderlyReport, routescanExplorers, setBits, tenderly_createVnet, tenderly_deleteVnet, tenderly_getVnet, tenderly_sim, tenderly_simVnet, wadDiv, wadToRay };
|
package/dist/index.js
CHANGED
|
@@ -77,6 +77,7 @@ __export(index_exports, {
|
|
|
77
77
|
getNonFinalizedProposals: () => getNonFinalizedProposals,
|
|
78
78
|
getNormalizedDebt: () => getNormalizedDebt,
|
|
79
79
|
getNormalizedIncome: () => getNormalizedIncome,
|
|
80
|
+
getPayloadStorageOverrides: () => getPayloadStorageOverrides,
|
|
80
81
|
getPayloadsController: () => getPayloadsController,
|
|
81
82
|
getPublicRpc: () => getPublicRpc,
|
|
82
83
|
getQuicknodeRpc: () => getQuicknodeRpc,
|
|
@@ -99,6 +100,7 @@ __export(index_exports, {
|
|
|
99
100
|
tenderly_createVnet: () => tenderly_createVnet,
|
|
100
101
|
tenderly_deleteVnet: () => tenderly_deleteVnet,
|
|
101
102
|
tenderly_getVnet: () => tenderly_getVnet,
|
|
103
|
+
tenderly_sim: () => tenderly_sim,
|
|
102
104
|
tenderly_simVnet: () => tenderly_simVnet,
|
|
103
105
|
wadDiv: () => wadDiv,
|
|
104
106
|
wadToRay: () => wadToRay
|
|
@@ -1961,28 +1963,43 @@ function getPayloadsController(client, address) {
|
|
|
1961
1963
|
address
|
|
1962
1964
|
});
|
|
1963
1965
|
}
|
|
1964
|
-
async function
|
|
1966
|
+
async function getPayloadStorageOverrides(client, payloadsController, payloadId) {
|
|
1965
1967
|
const controllerContract = getPayloadsController(client, payloadsController);
|
|
1966
1968
|
const payload = await controllerContract.read.getPayloadById([payloadId]);
|
|
1967
1969
|
const currentBlock = await (0, import_actions.getBlock)(client);
|
|
1968
|
-
return
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1970
|
+
return [
|
|
1971
|
+
{
|
|
1972
|
+
slot: getSolidityStorageSlotUint(3n, BigInt(payloadId)),
|
|
1973
|
+
value: (0, import_viem2.encodePacked)(
|
|
1974
|
+
["uint40", "uint40", "uint8", "uint8", "address"],
|
|
1975
|
+
[
|
|
1976
|
+
// we subtract 240n(4min), as tenderly might have been fallen behind
|
|
1977
|
+
// therefore using block_number -1 (latest on tenderly) and a 4min margin should give a save margin
|
|
1978
|
+
Number(currentBlock.timestamp - BigInt(payload.delay) - 1n - 240n),
|
|
1979
|
+
// altering queued time so can be executed in current block
|
|
1980
|
+
payload.createdAt,
|
|
1981
|
+
2 /* Queued */,
|
|
1982
|
+
payload.maximumAccessLevelRequired,
|
|
1983
|
+
payload.creator
|
|
1984
|
+
]
|
|
1985
|
+
)
|
|
1986
|
+
}
|
|
1987
|
+
];
|
|
1988
|
+
}
|
|
1989
|
+
async function makePayloadExecutableOnTestClient(client, payloadsController, payloadId) {
|
|
1990
|
+
const overrides = await getPayloadStorageOverrides(
|
|
1991
|
+
client,
|
|
1992
|
+
payloadsController,
|
|
1993
|
+
payloadId
|
|
1994
|
+
);
|
|
1995
|
+
for (const { slot, value } of overrides) {
|
|
1996
|
+
await client.setStorageAt({
|
|
1997
|
+
address: payloadsController,
|
|
1998
|
+
// 3 is the slot of the payloads mapping
|
|
1999
|
+
index: slot,
|
|
2000
|
+
value
|
|
2001
|
+
});
|
|
2002
|
+
}
|
|
1986
2003
|
}
|
|
1987
2004
|
function isPayloadFinal(state) {
|
|
1988
2005
|
return ![2 /* Queued */, 1 /* Created */].includes(state);
|
|
@@ -3098,6 +3115,28 @@ async function tenderly_createVnet({
|
|
|
3098
3115
|
})
|
|
3099
3116
|
};
|
|
3100
3117
|
}
|
|
3118
|
+
async function tenderly_sim({ accountSlug, projectSlug, accessToken }, body) {
|
|
3119
|
+
const response = await fetch(
|
|
3120
|
+
// Note: this is subject to change and currently uses the internal api of tenderly
|
|
3121
|
+
`${TENDERLY_BASE_URL}/account/${accountSlug}/project/${projectSlug}/simulate`,
|
|
3122
|
+
{
|
|
3123
|
+
method: "POST",
|
|
3124
|
+
body: JSON.stringify({
|
|
3125
|
+
generate_access_list: true,
|
|
3126
|
+
save: true,
|
|
3127
|
+
gas_price: "0",
|
|
3128
|
+
gas: 3e7,
|
|
3129
|
+
force_import_contracts: true,
|
|
3130
|
+
...body
|
|
3131
|
+
}),
|
|
3132
|
+
headers: new Headers({
|
|
3133
|
+
"Content-Type": "application/json",
|
|
3134
|
+
"X-Access-Key": accessToken
|
|
3135
|
+
})
|
|
3136
|
+
}
|
|
3137
|
+
);
|
|
3138
|
+
return response.json();
|
|
3139
|
+
}
|
|
3101
3140
|
|
|
3102
3141
|
// src/ecosystem/foundry.ts
|
|
3103
3142
|
var import_node_child_process = require("child_process");
|
|
@@ -3752,6 +3791,7 @@ async function renderTenderlyReport({
|
|
|
3752
3791
|
getNonFinalizedProposals,
|
|
3753
3792
|
getNormalizedDebt,
|
|
3754
3793
|
getNormalizedIncome,
|
|
3794
|
+
getPayloadStorageOverrides,
|
|
3755
3795
|
getPayloadsController,
|
|
3756
3796
|
getPublicRpc,
|
|
3757
3797
|
getQuicknodeRpc,
|
|
@@ -3774,6 +3814,7 @@ async function renderTenderlyReport({
|
|
|
3774
3814
|
tenderly_createVnet,
|
|
3775
3815
|
tenderly_deleteVnet,
|
|
3776
3816
|
tenderly_getVnet,
|
|
3817
|
+
tenderly_sim,
|
|
3777
3818
|
tenderly_simVnet,
|
|
3778
3819
|
wadDiv,
|
|
3779
3820
|
wadToRay
|