Skip to content

Commit 68eb96e

Browse files
committed
Update
1 parent 124106f commit 68eb96e

File tree

5 files changed

+32
-81
lines changed

5 files changed

+32
-81
lines changed

benchmark/contracts.ts

Lines changed: 11 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#!/usr/bin/env -S deno run --env-file --allow-all
2-
import { Hex } from 'viem'
32
import { deploy as deployContract, env } from '../tools/lib/index.ts'
4-
import { Abis, abis } from '../codegen/abis.ts'
3+
import { abis } from '../codegen/abis.ts'
54
import { logger } from '../utils/logger.ts'
65
import {
6+
Artifacts,
77
build,
88
deleteChainData,
99
deploy,
@@ -14,37 +14,31 @@ import {
1414
} from './lib.ts'
1515
import { parseArgs } from '@std/cli'
1616

17-
export const contracts = [
17+
export const contracts: Artifacts = [
1818
{
1919
id: 'Fibonacci',
2020
srcs: [
2121
ink('fibonacci'),
2222
rust('fibonacci'),
2323
...solidity('fibonacci.sol', 'Fibonacci'),
2424
],
25-
deploy: async (
26-
id: keyof Abis,
27-
name: string,
28-
bytecode: Hex,
29-
): Promise<Hex> => {
30-
const receipt = await deployContract({
25+
deploy: (id, name, bytecode) => {
26+
return deployContract({
3127
name: { id, name },
3228
bytecode,
3329
args: [],
3430
})
35-
return receipt.transactionHash!
3631
},
3732
calls: [
3833
{
3934
name: 'fib_10',
40-
exec: async (address: Hex): Promise<Hex> => {
41-
const { request } = await env.wallet.simulateContract({
35+
exec: async (address) => {
36+
return await env.wallet.writeContract({
4237
address,
4338
abi: abis.Fibonacci,
4439
functionName: 'fibonacci',
4540
args: [10],
4641
})
47-
return await env.wallet.writeContract(request)
4842
},
4943
},
5044
],
@@ -56,23 +50,18 @@ export const contracts = [
5650
rust('simple_token_no_alloc'),
5751
...solidity('simple_token.sol', 'SimpleToken'),
5852
],
59-
deploy: async (
60-
id: keyof Abis,
61-
name: string,
62-
bytecode: Hex,
63-
): Promise<Hex> => {
64-
const receipt = await deployContract({
53+
deploy: (id, name, bytecode) => {
54+
return deployContract({
6555
name: { id, name },
6656
bytecode,
6757
args: [],
6858
})
69-
return receipt.transactionHash!
7059
},
7160
calls: [
7261
{
7362
name: 'mint',
74-
exec: async (address: Hex): Promise<Hex> => {
75-
const { request } = await env.wallet.simulateContract({
63+
exec: (address) => {
64+
return env.wallet.writeContract({
7665
address,
7766
abi: abis.SimpleToken,
7867
functionName: 'mint',
@@ -81,7 +70,6 @@ export const contracts = [
8170
10_000_000_000_000_000_000_000_000n,
8271
],
8372
})
84-
return await env.wallet.writeContract(request)
8573
},
8674
},
8775
],

benchmark/lib.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Hex } from 'viem'
1+
import { Hex, TransactionReceipt } from 'viem'
22
import { env } from '../tools/lib/index.ts'
33
import { Abis } from '../codegen/abis.ts'
44
import { readBytecode } from '../utils/index.ts'
@@ -149,7 +149,11 @@ export function rust(name: string): ContractInfo {
149149
export type Artifacts = Array<{
150150
id: string
151151
srcs: ContractInfo[]
152-
deploy: (id: keyof Abis, name: string, bytecode: Hex) => Promise<Hex>
152+
deploy: (
153+
id: keyof Abis,
154+
name: string,
155+
bytecode: Hex,
156+
) => Promise<TransactionReceipt>
153157
calls: Array<{
154158
name: string
155159
exec: (address: Hex) => Promise<Hex>
@@ -194,13 +198,18 @@ export async function deploy(contracts: Artifacts) {
194198
const contract = src.getName()
195199
logger.debug(`Deploying ${contract}...`)
196200

197-
const hash = await artifact.deploy(
201+
const receipt = await artifact.deploy(
198202
artifact.id as keyof Abis,
199203
contract,
200204
src.getBytecode(),
201205
)
202206

203-
await updateStats(artifact.id, contract, 'deploy', hash)
207+
await updateStats(
208+
artifact.id,
209+
contract,
210+
'deploy',
211+
receipt.transactionHash,
212+
)
204213
}
205214
}
206215
}

cli/playground.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22

33
import { env } from '../tools/lib/index.ts'
44
import { abis } from '../codegen/abis.ts'
5-
import { EnumTest } from '../codegen/addresses.ts'
5+
import { Storage } from '../codegen/addresses.ts'
66

77
{
8-
const result = await env.wallet.readContract(
8+
const result = await env.wallet.writeContract(
99
{
10-
address: EnumTest,
11-
abi: abis.EnumTest,
12-
functionName: 'callTestEnum',
13-
args: [2],
10+
address: Storage,
11+
abi: abis.Storage,
12+
functionName: 'store',
13+
args: [42n],
1414
},
1515
)
1616

contracts/bug.sol

Lines changed: 0 additions & 36 deletions
This file was deleted.

tools/deploy.ts

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,8 @@ import { deploy } from './lib/index.ts'
2020
// args: [],
2121
// })
2222

23-
// await deploy({
24-
// name: 'Storage',
25-
// args: [],
26-
// bytecodeType: 'polkavm', // Specify `pvm` for PVM bytecode deployment
27-
// })
28-
await deploy({
29-
name: 'EnumTestChild',
30-
args: [],
31-
bytecodeType: 'polkavm', // Specify `pvm` for PVM bytecode deployment
32-
})
3323
await deploy({
34-
name: 'EnumTest',
24+
name: 'Storage',
3525
args: [],
36-
bytecodeType: 'polkavm', // Specify `pvm` for PVM bytecode deployment
26+
// bytecodeType: 'polkavm', // Specify `pvm` for PVM bytecode deployment
3727
})

0 commit comments

Comments
 (0)