Skip to content

Commit

Permalink
fix: patch some related issues
Browse files Browse the repository at this point in the history
  • Loading branch information
sakulstra committed Jan 25, 2024
1 parent 6ffb241 commit 02e275e
Show file tree
Hide file tree
Showing 4 changed files with 2,290 additions and 28 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
"typescript": "^5.3.3",
"vitest": "^1.2.1"
},
"type": "module",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
"exports": {
Expand Down
24 changes: 12 additions & 12 deletions src/commands/fork.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { CHAIN_ID_CLIENT_MAP } from '@bgd-labs/js-utils';
import { findPayloadsController } from '../govv3/utils/checkAddress';
import path from 'path';
import { IPayloadsControllerCore_ABI } from '@bgd-labs/aave-address-book';
import { getTransactionReceipt } from 'viem/actions';

export function addCommand(program: Command) {
program
Expand Down Expand Up @@ -38,8 +39,8 @@ export function addCommand(program: Command) {
alias: getAlias(),
blockNumber: Number(blockNumber),
};
const governance = getGovernance({ address: DEFAULT_GOVERNANCE, client: DEFAULT_GOVERNANCE_CLIENT });
if (proposalId) {
const governance = getGovernance({ address: DEFAULT_GOVERNANCE, client: DEFAULT_GOVERNANCE_CLIENT });
const payload = await governance.getSimulationPayloadForExecution(BigInt(proposalId));
const fork = await tenderly.fork({
...forkConfig,
Expand All @@ -51,10 +52,7 @@ export function addCommand(program: Command) {
if (payloadId == undefined && artifactPath == undefined) throw new Error('you need to specify an id or artifact');
const payloadsControllerAddress = findPayloadsController(forkConfig.chainId);
if (!payloadsControllerAddress) throw new Error('payloadscontroller not found on specified chain');
const payloadsController = getPayloadsController(
payloadsControllerAddress as Hex,
CHAIN_ID_CLIENT_MAP[forkConfig.chainId]
);

if (!payloadId) {
const fork = await tenderly.fork({
...forkConfig,
Expand All @@ -66,12 +64,8 @@ export function addCommand(program: Command) {
chain: { id: fork.forkNetworkId, name: 'tenderly' } as any,
transport: http(fork.forkUrl),
});
const pc = getContract({
abi: IPayloadsControllerCore_ABI,
address: payloadsControllerAddress,
client: { wallet: walletProvider },
});
const payloadId = await pc.write.createPayload(
const payloadsController = getPayloadsController(payloadsControllerAddress as Hex, walletProvider);
const hash = await payloadsController.controllerContract.write.createPayload(
[
[
{
Expand All @@ -86,11 +80,17 @@ export function addCommand(program: Command) {
],
{} as any
);
const tenderlyPayload = await payloadsController.getSimulationPayloadForExecution(Number(payloadId));
const tenderlyPayload = await payloadsController.getSimulationPayloadForExecution(
Number((await payloadsController.controllerContract.read.getPayloadsCount()) - 1)
);
await tenderly.unwrapAndExecuteSimulationPayloadOnFork(fork, tenderlyPayload);
return;
}
if (payloadId != undefined) {
const payloadsController = getPayloadsController(
payloadsControllerAddress as Hex,
CHAIN_ID_CLIENT_MAP[chainId]
);
const payload = await payloadsController.getSimulationPayloadForExecution(Number(payloadId));
const fork = await tenderly.fork({
...forkConfig,
Expand Down
Loading

0 comments on commit 02e275e

Please sign in to comment.