Skip to content

Commit a60e972

Browse files
committed
Fix deno compilation warnings
1 parent 47050a0 commit a60e972

File tree

11 files changed

+184
-38
lines changed

11 files changed

+184
-38
lines changed

contracts/MyToken.sol

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// SPDX-License-Identifier: MIT
2+
// Compatible with OpenZeppelin Contracts ^5.0.0
3+
pragma solidity ^0.8.27;
4+
5+
import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
6+
import {ERC20Permit} from "@openzeppelin/contracts/token/ERC20/extensions/ERC20Permit.sol";
7+
8+
contract MyToken is ERC20, ERC20Permit {
9+
constructor(string memory symbol) ERC20("MyToken", symbol) ERC20Permit("MyToken") {}
10+
}

contracts/Storage.sol

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// SPDX-License-Identifier: GPL-3.0
2+
3+
pragma solidity >=0.8.2 <0.9.0;
4+
5+
/**
6+
* @title Storage
7+
* @dev Store & retrieve value in a variable
8+
* @custom:dev-run-script ./scripts/deploy_with_ethers.ts
9+
*/
10+
contract Storage {
11+
uint256 public n1;
12+
uint256 public n2;
13+
14+
constructor() {
15+
n1 = 42;
16+
n2 = 100;
17+
}
18+
19+
/**
20+
* @dev Store value in variable
21+
* @param num value to store
22+
*/
23+
function write_n1_read_n2(uint256 num) public {
24+
n1 = num + n2;
25+
}
26+
27+
function write_n2(uint256 num) public {
28+
n2 = num;
29+
}
30+
31+
function add_funds() external payable {}
32+
33+
}

contracts/gas_tracing.sol

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// SPDX-License-Identifier: MIT
2+
pragma solidity ^0.8.0;
3+
4+
contract ATracing {
5+
address public callee;
6+
7+
constructor(address _callee) {
8+
callee = _callee;
9+
}
10+
11+
function callB() public {
12+
bool success;
13+
bytes memory encodedSignature = abi.encodeWithSignature("callC()");
14+
(success, ) = callee.call(encodedSignature);
15+
require(success, "callB failed");
16+
}
17+
}
18+
19+
contract BTracing {
20+
address public callee;
21+
22+
constructor(address _callee) {
23+
callee = _callee;
24+
}
25+
26+
function callC() external {
27+
bool success;
28+
bytes memory encodedSignature = abi.encodeWithSignature("noop()");
29+
(success, ) = callee.call(encodedSignature);
30+
require(success, "callC failed");
31+
}
32+
}
33+
34+
contract CTracing {
35+
function noop() external {
36+
// noop
37+
}
38+
}

deno.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,6 @@
1616
"description": "Run the dao-hack tracing demo",
1717
"command": "deno --env-file --allow-all src/cli/dao-hack-traces.ts"
1818
}
19-
}
19+
},
20+
"compilerOptions": {}
2021
}

package-lock.json

Lines changed: 20 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@
1717
"react": "^18.3.1",
1818
"react-dom": "^18.3.1",
1919
"viem": "latest",
20-
"wagmi": "latest",
2120
"vite": "^5.4.14",
22-
"vitest": "^3.0.9"
21+
"vitest": "^3.0.9",
22+
"wagmi": "latest"
2323
},
2424
"devDependencies": {
2525
"@openzeppelin/contracts": "^5.2.0",
26-
"@parity/revive": "^0.0.15",
26+
"@parity/resolc": "^0.1.0-dev.16",
2727
"@types/react": "^18.3.18",
2828
"@types/react-dom": "^18.3.5",
2929
"@vitejs/plugin-react": "^4.3.4",
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Run with
22
// deno task build --filter dao
3-
// deno --env-file --allow-all ./cli/playground.ts
3+
// deno --env-file --allow-all ./cli/dao-playground.ts
44
import { env } from '../tools/lib/index.ts'
55
import { abis } from '../codegen/abis.ts'
66
import { Dao, DaoAttacker } from '../codegen/addresses.ts'

src/cli/storage-playground.ts

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// Run with
2+
// deno task build --filter storage
3+
// deno --env-file --allow-all src/cli/storage-playground.ts
4+
import { env } from '../tools/lib/index.ts'
5+
import { abis } from '../codegen/abis.ts'
6+
import { Storage } from '../codegen/addresses.ts'
7+
import { encodeFunctionData } from 'viem'
8+
9+
{
10+
const res = await env.debugClient.traceCall(
11+
{
12+
to: Storage,
13+
data: encodeFunctionData({
14+
abi: abis.Storage,
15+
functionName: 'write_n1_read_n2',
16+
args: [BigInt(Date.now())],
17+
}),
18+
},
19+
'prestateTracer',
20+
{ diffMode: false }
21+
)
22+
console.log(res)
23+
}
24+
// {
25+
// const { request } = await env.wallet.simulateContract({
26+
// address: Storage,
27+
// abi: abis.Storage,
28+
// functionName: 'write_n1_read_n2',
29+
// args: [BigInt(Date.now())],
30+
// })
31+
// const hash = await env.wallet.writeContract(request)
32+
// let receipt = await env.wallet.waitForTransactionReceipt({
33+
// hash,
34+
// })
35+
//
36+
// console.log(receipt)
37+
// const res = await env.debugClient.traceBlock(
38+
// receipt.blockNumber,
39+
// 'prestateTracer',
40+
// { diffMode: false }
41+
// )
42+
// console.log(res)
43+
// }

src/tools/build.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! Call with deno task build [--filter <filter>] [--clean]
22

33
/// <reference path="./solc.d.ts" />
4-
import { compile, SolcOutput, tryResolveImport } from '@parity/revive'
4+
import { compile, SolcOutput, tryResolveImport } from '@parity/resolc'
55
import solc from 'solc'
66
import { format } from 'prettier'
77
import {
@@ -127,8 +127,11 @@ for (const file of input) {
127127
)
128128
)
129129

130-
indexCode.unshift(`import { ${abiName} } from './abi/${name}.ts'`)
131-
indexCode.push(`${name}: ${abiName},`)
130+
const importStatement = `import { ${abiName} } from './abi/${name}.ts'`
131+
if (!indexCode.includes(importStatement)) {
132+
indexCode.unshift(importStatement)
133+
indexCode.push(`${name}: ${abiName},`)
134+
}
132135
}
133136
}
134137
}

src/tools/deploy.ts

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
//! Call with deno task deploy [--filter <filter>]
22

3-
import { parseEther } from 'viem'
43
import { deploy } from './lib/index.ts'
54

65
/**
@@ -12,18 +11,10 @@ import { deploy } from './lib/index.ts'
1211
* await deploy({ name: 'Token', args: ["My Awseome Token", "MAT"] })
1312
* ```
1413
*/
15-
await deploy({ name: 'WagmiMintExample', args: [] })
1614

17-
const daoAddress = await deploy({
18-
name: 'Dao',
19-
value: parseEther('100'),
20-
args: [],
21-
})
15+
// const cAddress = await deploy({ name: 'CTracing', args: [] })
16+
// const bAddress = await deploy({ name: 'BTracing', args: [cAddress] })
17+
// await deploy({ name: 'ATracing', args: [bAddress] })
18+
// await deploy({ name: 'Storage', args: [] })
2219

23-
await deploy({
24-
name: 'DaoAttacker',
25-
args: [daoAddress, 2n],
26-
value: parseEther('1'),
27-
})
28-
29-
await deploy({ name: 'MagicWord', args: [] })
20+
await deploy({ name: 'MyToken', args: ['MTK'] })

0 commit comments

Comments
 (0)