Skip to content

Commit

Permalink
🚧 More changes that didn't get committed
Browse files Browse the repository at this point in the history
  • Loading branch information
roninjin10 committed Oct 15, 2024
1 parent 6d4f6a0 commit f03d6c8
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 19 deletions.
2 changes: 1 addition & 1 deletion packages/actions/src/Call/callHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ export const callHandler =
})
}

const stateOverrideResult = await handleStateOverrides(client, params)
const stateOverrideResult = await handleStateOverrides(client, params.stateOverrideSet)
if (stateOverrideResult.errors) {
return maybeThrowOnFail(_params.throwOnFail ?? defaultThrowOnFail, {
errors: stateOverrideResult.errors,
Expand Down
14 changes: 0 additions & 14 deletions packages/actions/src/Call/callHandlerOpts.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,20 +224,6 @@ describe('callHandlerOpts', () => {
expect(() => result.data?.block?.header.cliqueSigner()).toThrowError()
})

it('should handle invalid state overrides', async () => {
const stateOverrideSet = {
[`0x${'1'.repeat(40)}` as const]: {
nonce: 1n,
balance: 1000000000n,
code: 'invalid_code' as const as any,
},
}
const result = await callHandlerOpts(client, { stateOverrideSet })
expect(result.errors).toBeDefined()
expect(result.errors).toHaveLength(1)
expect(result.errors).toMatchSnapshot()
})

it('should throw error for transaction creation on past blocks', async () => {
const client = createTevmNode()

Expand Down
1 change: 1 addition & 0 deletions packages/actions/src/Call/callProcedure.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ describe('callProcedure', () => {
}

const response = await callProcedure(client)(request)
console.log(response.error)
expect(response.error).toBeUndefined()
expect(response.result).toBeDefined()
expect(response.method).toBe('tevm_call')
Expand Down
9 changes: 5 additions & 4 deletions packages/actions/src/Call/handleStateOverrides.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ import { setAccountHandler } from '../SetAccount/setAccountHandler.js'
/**
* Handles state overrides for the given client and parameters.
* @param {import('@tevm/node').TevmNode} client
* @param {import('./CallParams.js').CallParams} params
* @param {import('./CallParams.js').CallParams['stateOverrideSet']} stateOverrideSet
* @returns {Promise<{errors?: Array<HandleStateOverridesError>}>}
*/
export async function handleStateOverrides(client, params) {
if (params.stateOverrideSet) {
for (const [address, state] of Object.entries(params.stateOverrideSet)) {
export async function handleStateOverrides(client, stateOverrideSet) {
if (stateOverrideSet) {
for (const [address, state] of Object.entries(stateOverrideSet)) {
console.log('setting state', address, state)
const res = await setAccountHandler(client)({
address: /** @type import('@tevm/utils').Address*/ (address),
...(state.nonce !== undefined ? { nonce: state.nonce } : {}),
Expand Down

0 comments on commit f03d6c8

Please sign in to comment.