@aave-dao/aave-helpers-js 1.0.1
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/LICENSE +7 -0
- package/README.md +55 -0
- package/dist/cli.cjs +162 -0
- package/dist/cli.d.cts +1 -0
- package/dist/cli.d.mts +1 -0
- package/dist/cli.mjs +163 -0
- package/dist/index.cjs +7 -0
- package/dist/index.d.cts +301 -0
- package/dist/index.d.mts +301 -0
- package/dist/index.mjs +3 -0
- package/dist/protocol-diff-M_rYNx6y.mjs +1882 -0
- package/dist/protocol-diff-YLEa_C3t.cjs +1939 -0
- package/package.json +46 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
Copyright 2026 BGD Labs
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
4
|
+
|
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
6
|
+
|
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# @aave-dao/aave-helpers-js
|
|
2
|
+
|
|
3
|
+
Snapshot diffing, reporting, and governance utilities for Aave V3.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
pnpm add @aave-dao/aave-helpers-js
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## CLI
|
|
12
|
+
|
|
13
|
+
```sh
|
|
14
|
+
# Diff two snapshot JSON files into a markdown report
|
|
15
|
+
aave-helpers-js diff-snapshots <before.json> <after.json> -o <output.md>
|
|
16
|
+
|
|
17
|
+
# Compute IPFS hash (optionally upload to Pinata + The Graph)
|
|
18
|
+
aave-helpers-js ipfs <file> [-u]
|
|
19
|
+
|
|
20
|
+
# Generate a Tenderly seatbelt report for a payload
|
|
21
|
+
aave-helpers-js seatbelt-report -c <chainId> --pc <payloadsController> [--pi <payloadId>] [--pa <payloadAddress>] [--pb <payloadBytecode>] [-o <output>]
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Library
|
|
25
|
+
|
|
26
|
+
```ts
|
|
27
|
+
import { diffSnapshots } from '@aave-dao/aave-helpers-js';
|
|
28
|
+
|
|
29
|
+
const md = await diffSnapshots(preSnapshot, postSnapshot);
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### Exports
|
|
33
|
+
|
|
34
|
+
- `diffSnapshots(pre, post)` - diff two `AaveV3Snapshot` objects into a markdown report
|
|
35
|
+
- `diff(a, b)` / `isChange()` / `hasChanges()` - generic deep-diff utilities
|
|
36
|
+
- TypeScript types: `AaveV3Snapshot`, `AaveV3Reserve`, `AaveV3Strategy`, `AaveV3Emode`, etc.
|
|
37
|
+
|
|
38
|
+
## Event Database
|
|
39
|
+
|
|
40
|
+
`utils/eventDb.json` is a static collection of Solidity event ABIs used to decode transaction logs in reports. If a report shows raw topics/data instead of a decoded event name, the event ABI is likely missing from this file.
|
|
41
|
+
|
|
42
|
+
To add a missing event, append its ABI entry to the JSON array:
|
|
43
|
+
|
|
44
|
+
```json
|
|
45
|
+
{
|
|
46
|
+
"type": "event",
|
|
47
|
+
"name": "MyEvent",
|
|
48
|
+
"anonymous": false,
|
|
49
|
+
"inputs": [
|
|
50
|
+
{ "name": "param", "type": "uint256", "indexed": false, "internalType": "uint256" }
|
|
51
|
+
]
|
|
52
|
+
}
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
You can extract event ABIs from contract artifacts (`out/` / `artifacts/`) or from block explorers.
|
package/dist/cli.cjs
ADDED
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
const require_protocol_diff = require('./protocol-diff-YLEa_C3t.cjs');
|
|
3
|
+
let _bgd_labs_toolbox = require("@bgd-labs/toolbox");
|
|
4
|
+
let viem = require("viem");
|
|
5
|
+
let fs = require("fs");
|
|
6
|
+
let path = require("path");
|
|
7
|
+
let commander = require("commander");
|
|
8
|
+
let _bgd_labs_aave_address_book_utils = require("@bgd-labs/aave-address-book/utils");
|
|
9
|
+
let viem_actions = require("viem/actions");
|
|
10
|
+
let viem_accounts = require("viem/accounts");
|
|
11
|
+
|
|
12
|
+
//#region cli.ts
|
|
13
|
+
const program = new commander.Command();
|
|
14
|
+
program.name("aave-helpers-js").description("Aave protocol snapshot tooling").version("1.0.0");
|
|
15
|
+
program.command("diff-snapshots").description("Diff two Aave V3 protocol snapshot JSON files and produce a markdown report").argument("<before>", "path to the before snapshot JSON").argument("<after>", "path to the after snapshot JSON").requiredOption("-o, --out <path>", "output path for the markdown report").action(async (beforePath, afterPath, opts) => {
|
|
16
|
+
const md = await require_protocol_diff.diffSnapshots(JSON.parse((0, fs.readFileSync)(beforePath, "utf-8")), JSON.parse((0, fs.readFileSync)(afterPath, "utf-8")));
|
|
17
|
+
(0, fs.mkdirSync)((0, path.dirname)(opts.out), { recursive: true });
|
|
18
|
+
(0, fs.writeFileSync)(opts.out, md, "utf-8");
|
|
19
|
+
});
|
|
20
|
+
async function uploadToPinata(source) {
|
|
21
|
+
const PINATA_KEY = process.env.PINATA_KEY;
|
|
22
|
+
if (!PINATA_KEY) throw new Error("PINATA_KEY env must be set");
|
|
23
|
+
const PINATA_SECRET = process.env.PINATA_SECRET;
|
|
24
|
+
if (!PINATA_SECRET) throw new Error("PINATA_SECRET env must be set");
|
|
25
|
+
const data = new FormData();
|
|
26
|
+
data.append("file", new Blob([source]));
|
|
27
|
+
const res = await fetch("https://api.pinata.cloud/pinning/pinFileToIPFS", {
|
|
28
|
+
method: "POST",
|
|
29
|
+
body: data,
|
|
30
|
+
headers: {
|
|
31
|
+
pinata_api_key: PINATA_KEY,
|
|
32
|
+
pinata_secret_api_key: PINATA_SECRET
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
if (!res.ok) throw Error(await res.text());
|
|
36
|
+
const result = await res.json();
|
|
37
|
+
if (result.error) throw { message: result.error };
|
|
38
|
+
return result;
|
|
39
|
+
}
|
|
40
|
+
async function uploadToTheGraph(source) {
|
|
41
|
+
const data = new FormData();
|
|
42
|
+
data.append("file", new Blob([source]));
|
|
43
|
+
return await (await fetch("https://api.thegraph.com/ipfs/api/v0/add", {
|
|
44
|
+
method: "POST",
|
|
45
|
+
body: data
|
|
46
|
+
})).json();
|
|
47
|
+
}
|
|
48
|
+
program.command("ipfs").description("generates the ipfs hash for specified source").argument("<source>").option("-u, --upload").option("--verbose").action(async (source, { upload, verbose }) => {
|
|
49
|
+
const filePath = (0, path.join)(process.cwd(), source);
|
|
50
|
+
if (!(0, fs.existsSync)(filePath)) throw new Error("FILE_NOT_FOUND");
|
|
51
|
+
const content = (0, fs.readFileSync)(filePath, "utf8");
|
|
52
|
+
(0, _bgd_labs_toolbox.Aip)((0, _bgd_labs_toolbox.parseFrontmatterMd)(content));
|
|
53
|
+
const bs58Hash = (0, _bgd_labs_toolbox.cidV0ToBs58)(await (0, _bgd_labs_toolbox.hash)(content));
|
|
54
|
+
if (upload) {
|
|
55
|
+
const [pinata, thegraph] = await Promise.all([uploadToPinata(content), uploadToTheGraph(content)]);
|
|
56
|
+
if (verbose) {
|
|
57
|
+
console.log("pinata response", pinata);
|
|
58
|
+
console.log("thegraph response", thegraph);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
console.log(bs58Hash);
|
|
62
|
+
});
|
|
63
|
+
function flagAsKnown(value, reference) {
|
|
64
|
+
return `${value} [:ghost:](https://github.com/bgd-labs/aave-address-book "${reference}")`;
|
|
65
|
+
}
|
|
66
|
+
program.command("seatbelt-report").description("generates a seatbelt report for the payload").addOption(new commander.Option("-c,--chainId <number>").makeOptionMandatory()).addOption(new commander.Option("--pi,--payloadId <number>")).addOption(new commander.Option("--pa, --payloadAddress <address>")).addOption(new commander.Option("--pb,--payloadBytecode <hex>")).addOption(new commander.Option("--pcd,--payloadCalldata <hex>")).addOption(new commander.Option("--pc, --payloadsController <address>").makeOptionMandatory()).addOption(new commander.Option("-o, --output <output path>").default("./reports/seatbelt/")).addOption(new commander.Option("-t, --tenderlyAccessToken <string>", "defaults to env.TENDERLY_ACCESS_TOKEN")).addOption(new commander.Option("-a, --tenderlyAccountSlug <string>", "defaults to env.TENDERLY_ACCOUNT_SLUG")).addOption(new commander.Option("-p, --tenderlyProjectSlug <string>", "defaults to env.TENDERLY_PROJECT_SLUG")).addOption(new commander.Option("-e, --etherscanApiKey <string>", "defaults to env.ETHERSCAN_API_KEY")).action(async ({ chainId, tenderlyAccessToken, tenderlyAccountSlug, tenderlyProjectSlug, output, payloadId, payloadAddress, payloadBytecode, payloadCalldata, payloadsController }) => {
|
|
67
|
+
const vnet = await (0, _bgd_labs_toolbox.tenderly_createVnet)({
|
|
68
|
+
baseChainId: Number(chainId),
|
|
69
|
+
forkChainId: 3030,
|
|
70
|
+
slug: `${Math.floor(Math.random() * 1e3)}acli-aave-dao-vnet-${chainId}`,
|
|
71
|
+
displayName: "seatbelt"
|
|
72
|
+
}, {
|
|
73
|
+
accessToken: tenderlyAccessToken || process.env.TENDERLY_ACCESS_TOKEN,
|
|
74
|
+
accountSlug: tenderlyAccountSlug || process.env.TENDERLY_ACCOUNT_SLUG,
|
|
75
|
+
projectSlug: tenderlyProjectSlug || process.env.TENDERLY_PROJECT_SLUG
|
|
76
|
+
});
|
|
77
|
+
const controllerContract = (0, _bgd_labs_toolbox.getPayloadsController)(vnet.walletClient, payloadsController);
|
|
78
|
+
let currentId = 0;
|
|
79
|
+
let sender = viem.zeroAddress;
|
|
80
|
+
try {
|
|
81
|
+
sender = await (0, viem_actions.readContract)(vnet.testClient, {
|
|
82
|
+
address: controllerContract.address,
|
|
83
|
+
abi: (0, viem.parseAbi)(["function payloadsManager() external view returns (address)"]),
|
|
84
|
+
functionName: "payloadsManager"
|
|
85
|
+
});
|
|
86
|
+
} catch (e) {}
|
|
87
|
+
if (payloadId) currentId = Number(payloadId);
|
|
88
|
+
if (payloadBytecode) {
|
|
89
|
+
vnet.testClient.setCode({
|
|
90
|
+
address: "0xBE0eB53F46cd790Cd13851d5EFf43D12404d33E8",
|
|
91
|
+
bytecode: payloadBytecode
|
|
92
|
+
});
|
|
93
|
+
payloadAddress = "0xBE0eB53F46cd790Cd13851d5EFf43D12404d33E8";
|
|
94
|
+
}
|
|
95
|
+
if (payloadCalldata) {
|
|
96
|
+
currentId = await controllerContract.read.getPayloadsCount();
|
|
97
|
+
await vnet.walletClient.sendTransaction({
|
|
98
|
+
account: (0, viem_accounts.toAccount)(sender),
|
|
99
|
+
chain: vnet.walletClient.chain,
|
|
100
|
+
to: payloadsController,
|
|
101
|
+
data: payloadCalldata
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
if (payloadAddress) {
|
|
105
|
+
currentId = await controllerContract.read.getPayloadsCount();
|
|
106
|
+
const payload = {
|
|
107
|
+
target: payloadAddress,
|
|
108
|
+
accessLevel: 1,
|
|
109
|
+
callData: "0x",
|
|
110
|
+
withDelegateCall: true,
|
|
111
|
+
signature: "execute()",
|
|
112
|
+
value: 0n
|
|
113
|
+
};
|
|
114
|
+
await controllerContract.write.createPayload([[payload]], {
|
|
115
|
+
account: (0, viem_accounts.toAccount)(sender),
|
|
116
|
+
chain: vnet.walletClient.chain
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
await (0, _bgd_labs_toolbox.makePayloadExecutableOnTestClient)(vnet.testClient, payloadsController, currentId);
|
|
120
|
+
const simResult = await vnet.simulate({
|
|
121
|
+
network_id: chainId.toString(),
|
|
122
|
+
from: sender,
|
|
123
|
+
to: payloadsController,
|
|
124
|
+
input: (0, viem.encodeFunctionData)({
|
|
125
|
+
abi: _bgd_labs_toolbox.IPayloadsController_ABI,
|
|
126
|
+
functionName: "executePayload",
|
|
127
|
+
args: [currentId]
|
|
128
|
+
}),
|
|
129
|
+
block_number: null,
|
|
130
|
+
transaction_index: 0,
|
|
131
|
+
gas: 3e7,
|
|
132
|
+
gas_price: "0",
|
|
133
|
+
value: "0",
|
|
134
|
+
access_list: [],
|
|
135
|
+
generate_access_list: true,
|
|
136
|
+
save: true,
|
|
137
|
+
source: "dashboard"
|
|
138
|
+
});
|
|
139
|
+
await controllerContract.write.executePayload([currentId], {
|
|
140
|
+
account: (0, viem_accounts.toAccount)(sender),
|
|
141
|
+
chain: vnet.walletClient.chain
|
|
142
|
+
});
|
|
143
|
+
const report = await (0, _bgd_labs_toolbox.renderTenderlyReport)({
|
|
144
|
+
client: vnet.walletClient,
|
|
145
|
+
sim: simResult,
|
|
146
|
+
payloadId: currentId,
|
|
147
|
+
payload: await controllerContract.read.getPayloadById([currentId]),
|
|
148
|
+
onchainLogs: {},
|
|
149
|
+
config: { etherscanApiKey: process.env.ETHERSCAN_API_KEY },
|
|
150
|
+
getContractName: (sim, address) => {
|
|
151
|
+
const references = (0, _bgd_labs_aave_address_book_utils.getAddressBookReferences)(address, Number(sim.simulation.network_id));
|
|
152
|
+
if (references.length > 0) return flagAsKnown((0, _bgd_labs_toolbox.getMdContractName)(sim.contracts, address), references[0]);
|
|
153
|
+
return (0, _bgd_labs_toolbox.getMdContractName)(sim.contracts, address);
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
const filePath = `${output}/${chainId}_${payloadsController}`;
|
|
157
|
+
(0, fs.mkdirSync)(filePath, { recursive: true });
|
|
158
|
+
(0, fs.writeFileSync)(`${filePath}/${currentId}.md`, report.report);
|
|
159
|
+
});
|
|
160
|
+
program.parse();
|
|
161
|
+
|
|
162
|
+
//#endregion
|
package/dist/cli.d.cts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
package/dist/cli.d.mts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
package/dist/cli.mjs
ADDED
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { t as diffSnapshots } from "./protocol-diff-M_rYNx6y.mjs";
|
|
3
|
+
import { Aip, IPayloadsController_ABI, cidV0ToBs58, getMdContractName, getPayloadsController, hash, makePayloadExecutableOnTestClient, parseFrontmatterMd, renderTenderlyReport, tenderly_createVnet } from "@bgd-labs/toolbox";
|
|
4
|
+
import { encodeFunctionData, parseAbi, zeroAddress } from "viem";
|
|
5
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
|
|
6
|
+
import { dirname, join } from "path";
|
|
7
|
+
import { Command, Option } from "commander";
|
|
8
|
+
import { getAddressBookReferences } from "@bgd-labs/aave-address-book/utils";
|
|
9
|
+
import { readContract } from "viem/actions";
|
|
10
|
+
import { toAccount } from "viem/accounts";
|
|
11
|
+
|
|
12
|
+
//#region cli.ts
|
|
13
|
+
const program = new Command();
|
|
14
|
+
program.name("aave-helpers-js").description("Aave protocol snapshot tooling").version("1.0.0");
|
|
15
|
+
program.command("diff-snapshots").description("Diff two Aave V3 protocol snapshot JSON files and produce a markdown report").argument("<before>", "path to the before snapshot JSON").argument("<after>", "path to the after snapshot JSON").requiredOption("-o, --out <path>", "output path for the markdown report").action(async (beforePath, afterPath, opts) => {
|
|
16
|
+
const md = await diffSnapshots(JSON.parse(readFileSync(beforePath, "utf-8")), JSON.parse(readFileSync(afterPath, "utf-8")));
|
|
17
|
+
mkdirSync(dirname(opts.out), { recursive: true });
|
|
18
|
+
writeFileSync(opts.out, md, "utf-8");
|
|
19
|
+
});
|
|
20
|
+
async function uploadToPinata(source) {
|
|
21
|
+
const PINATA_KEY = process.env.PINATA_KEY;
|
|
22
|
+
if (!PINATA_KEY) throw new Error("PINATA_KEY env must be set");
|
|
23
|
+
const PINATA_SECRET = process.env.PINATA_SECRET;
|
|
24
|
+
if (!PINATA_SECRET) throw new Error("PINATA_SECRET env must be set");
|
|
25
|
+
const data = new FormData();
|
|
26
|
+
data.append("file", new Blob([source]));
|
|
27
|
+
const res = await fetch("https://api.pinata.cloud/pinning/pinFileToIPFS", {
|
|
28
|
+
method: "POST",
|
|
29
|
+
body: data,
|
|
30
|
+
headers: {
|
|
31
|
+
pinata_api_key: PINATA_KEY,
|
|
32
|
+
pinata_secret_api_key: PINATA_SECRET
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
if (!res.ok) throw Error(await res.text());
|
|
36
|
+
const result = await res.json();
|
|
37
|
+
if (result.error) throw { message: result.error };
|
|
38
|
+
return result;
|
|
39
|
+
}
|
|
40
|
+
async function uploadToTheGraph(source) {
|
|
41
|
+
const data = new FormData();
|
|
42
|
+
data.append("file", new Blob([source]));
|
|
43
|
+
return await (await fetch("https://api.thegraph.com/ipfs/api/v0/add", {
|
|
44
|
+
method: "POST",
|
|
45
|
+
body: data
|
|
46
|
+
})).json();
|
|
47
|
+
}
|
|
48
|
+
program.command("ipfs").description("generates the ipfs hash for specified source").argument("<source>").option("-u, --upload").option("--verbose").action(async (source, { upload, verbose }) => {
|
|
49
|
+
const filePath = join(process.cwd(), source);
|
|
50
|
+
if (!existsSync(filePath)) throw new Error("FILE_NOT_FOUND");
|
|
51
|
+
const content = readFileSync(filePath, "utf8");
|
|
52
|
+
Aip(parseFrontmatterMd(content));
|
|
53
|
+
const bs58Hash = cidV0ToBs58(await hash(content));
|
|
54
|
+
if (upload) {
|
|
55
|
+
const [pinata, thegraph] = await Promise.all([uploadToPinata(content), uploadToTheGraph(content)]);
|
|
56
|
+
if (verbose) {
|
|
57
|
+
console.log("pinata response", pinata);
|
|
58
|
+
console.log("thegraph response", thegraph);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
console.log(bs58Hash);
|
|
62
|
+
});
|
|
63
|
+
function flagAsKnown(value, reference) {
|
|
64
|
+
return `${value} [:ghost:](https://github.com/bgd-labs/aave-address-book "${reference}")`;
|
|
65
|
+
}
|
|
66
|
+
program.command("seatbelt-report").description("generates a seatbelt report for the payload").addOption(new Option("-c,--chainId <number>").makeOptionMandatory()).addOption(new Option("--pi,--payloadId <number>")).addOption(new Option("--pa, --payloadAddress <address>")).addOption(new Option("--pb,--payloadBytecode <hex>")).addOption(new Option("--pcd,--payloadCalldata <hex>")).addOption(new Option("--pc, --payloadsController <address>").makeOptionMandatory()).addOption(new Option("-o, --output <output path>").default("./reports/seatbelt/")).addOption(new Option("-t, --tenderlyAccessToken <string>", "defaults to env.TENDERLY_ACCESS_TOKEN")).addOption(new Option("-a, --tenderlyAccountSlug <string>", "defaults to env.TENDERLY_ACCOUNT_SLUG")).addOption(new Option("-p, --tenderlyProjectSlug <string>", "defaults to env.TENDERLY_PROJECT_SLUG")).addOption(new Option("-e, --etherscanApiKey <string>", "defaults to env.ETHERSCAN_API_KEY")).action(async ({ chainId, tenderlyAccessToken, tenderlyAccountSlug, tenderlyProjectSlug, output, payloadId, payloadAddress, payloadBytecode, payloadCalldata, payloadsController }) => {
|
|
67
|
+
const vnet = await tenderly_createVnet({
|
|
68
|
+
baseChainId: Number(chainId),
|
|
69
|
+
forkChainId: 3030,
|
|
70
|
+
slug: `${Math.floor(Math.random() * 1e3)}acli-aave-dao-vnet-${chainId}`,
|
|
71
|
+
displayName: "seatbelt"
|
|
72
|
+
}, {
|
|
73
|
+
accessToken: tenderlyAccessToken || process.env.TENDERLY_ACCESS_TOKEN,
|
|
74
|
+
accountSlug: tenderlyAccountSlug || process.env.TENDERLY_ACCOUNT_SLUG,
|
|
75
|
+
projectSlug: tenderlyProjectSlug || process.env.TENDERLY_PROJECT_SLUG
|
|
76
|
+
});
|
|
77
|
+
const controllerContract = getPayloadsController(vnet.walletClient, payloadsController);
|
|
78
|
+
let currentId = 0;
|
|
79
|
+
let sender = zeroAddress;
|
|
80
|
+
try {
|
|
81
|
+
sender = await readContract(vnet.testClient, {
|
|
82
|
+
address: controllerContract.address,
|
|
83
|
+
abi: parseAbi(["function payloadsManager() external view returns (address)"]),
|
|
84
|
+
functionName: "payloadsManager"
|
|
85
|
+
});
|
|
86
|
+
} catch (e) {}
|
|
87
|
+
if (payloadId) currentId = Number(payloadId);
|
|
88
|
+
if (payloadBytecode) {
|
|
89
|
+
vnet.testClient.setCode({
|
|
90
|
+
address: "0xBE0eB53F46cd790Cd13851d5EFf43D12404d33E8",
|
|
91
|
+
bytecode: payloadBytecode
|
|
92
|
+
});
|
|
93
|
+
payloadAddress = "0xBE0eB53F46cd790Cd13851d5EFf43D12404d33E8";
|
|
94
|
+
}
|
|
95
|
+
if (payloadCalldata) {
|
|
96
|
+
currentId = await controllerContract.read.getPayloadsCount();
|
|
97
|
+
await vnet.walletClient.sendTransaction({
|
|
98
|
+
account: toAccount(sender),
|
|
99
|
+
chain: vnet.walletClient.chain,
|
|
100
|
+
to: payloadsController,
|
|
101
|
+
data: payloadCalldata
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
if (payloadAddress) {
|
|
105
|
+
currentId = await controllerContract.read.getPayloadsCount();
|
|
106
|
+
const payload = {
|
|
107
|
+
target: payloadAddress,
|
|
108
|
+
accessLevel: 1,
|
|
109
|
+
callData: "0x",
|
|
110
|
+
withDelegateCall: true,
|
|
111
|
+
signature: "execute()",
|
|
112
|
+
value: 0n
|
|
113
|
+
};
|
|
114
|
+
await controllerContract.write.createPayload([[payload]], {
|
|
115
|
+
account: toAccount(sender),
|
|
116
|
+
chain: vnet.walletClient.chain
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
await makePayloadExecutableOnTestClient(vnet.testClient, payloadsController, currentId);
|
|
120
|
+
const simResult = await vnet.simulate({
|
|
121
|
+
network_id: chainId.toString(),
|
|
122
|
+
from: sender,
|
|
123
|
+
to: payloadsController,
|
|
124
|
+
input: encodeFunctionData({
|
|
125
|
+
abi: IPayloadsController_ABI,
|
|
126
|
+
functionName: "executePayload",
|
|
127
|
+
args: [currentId]
|
|
128
|
+
}),
|
|
129
|
+
block_number: null,
|
|
130
|
+
transaction_index: 0,
|
|
131
|
+
gas: 3e7,
|
|
132
|
+
gas_price: "0",
|
|
133
|
+
value: "0",
|
|
134
|
+
access_list: [],
|
|
135
|
+
generate_access_list: true,
|
|
136
|
+
save: true,
|
|
137
|
+
source: "dashboard"
|
|
138
|
+
});
|
|
139
|
+
await controllerContract.write.executePayload([currentId], {
|
|
140
|
+
account: toAccount(sender),
|
|
141
|
+
chain: vnet.walletClient.chain
|
|
142
|
+
});
|
|
143
|
+
const report = await renderTenderlyReport({
|
|
144
|
+
client: vnet.walletClient,
|
|
145
|
+
sim: simResult,
|
|
146
|
+
payloadId: currentId,
|
|
147
|
+
payload: await controllerContract.read.getPayloadById([currentId]),
|
|
148
|
+
onchainLogs: {},
|
|
149
|
+
config: { etherscanApiKey: process.env.ETHERSCAN_API_KEY },
|
|
150
|
+
getContractName: (sim, address) => {
|
|
151
|
+
const references = getAddressBookReferences(address, Number(sim.simulation.network_id));
|
|
152
|
+
if (references.length > 0) return flagAsKnown(getMdContractName(sim.contracts, address), references[0]);
|
|
153
|
+
return getMdContractName(sim.contracts, address);
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
const filePath = `${output}/${chainId}_${payloadsController}`;
|
|
157
|
+
mkdirSync(filePath, { recursive: true });
|
|
158
|
+
writeFileSync(`${filePath}/${currentId}.md`, report.report);
|
|
159
|
+
});
|
|
160
|
+
program.parse();
|
|
161
|
+
|
|
162
|
+
//#endregion
|
|
163
|
+
export { };
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_protocol_diff = require('./protocol-diff-YLEa_C3t.cjs');
|
|
3
|
+
|
|
4
|
+
exports.diff = require_protocol_diff.diff;
|
|
5
|
+
exports.diffSnapshots = require_protocol_diff.diffSnapshots;
|
|
6
|
+
exports.hasChanges = require_protocol_diff.hasChanges;
|
|
7
|
+
exports.isChange = require_protocol_diff.isChange;
|