Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add support for evm_setAccountCode #2636

Merged
merged 6 commits into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 15 additions & 7 deletions pnpm-lock.yaml
saeta-eth marked this conversation as resolved.
Show resolved Hide resolved

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 10 additions & 4 deletions src/actions/test/setCode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,14 @@ export async function setCode<
client: TestClient<TestClientMode, Transport, chain, account, false>,
{ address, bytecode }: SetCodeParameters,
) {
await client.request({
method: `${client.mode}_setCode`,
params: [address, bytecode],
})
if (client.mode === 'ganache')
await client.request({
method: 'evm_setAccountCode',
params: [address, bytecode],
})
else
await client.request({
method: `${client.mode}_setCode`,
params: [address, bytecode],
})
}
14 changes: 14 additions & 0 deletions src/types/eip1193.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1344,6 +1344,20 @@ export type TestRpcSchema<mode extends string> = [
]
ReturnType: void
},
/**
* @description Modifies the bytecode stored at an account's address.
* @link https://ganache.dev/#evm_setAccountCode
*/
{
Method: `evm_setAccountCode`
Parameters: [
/** The address of the contract. */
address: Address,
/** Data bytecode. */
data: string,
]
ReturnType: void
},
/**
* @description Enables or disables, based on the single boolean argument, the automatic mining of new blocks with each new transaction submitted to the network.
* @link https://hardhat.org/hardhat-network/docs/reference#evm_setautomine
Expand Down
Loading