Skip to content

Commit 38828fa

Browse files
committed
createAccessList pending default
1 parent ac1e944 commit 38828fa

4 files changed

Lines changed: 18 additions & 15 deletions

File tree

src/components/@molecules/TransactionDialogManager/stage/TransactionStageModal.test.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { useAddRecentTransaction } from '@app/hooks/transactions/useAddRecentTra
1414
import { useRecentTransactions } from '@app/hooks/transactions/useRecentTransactions'
1515
import { useIsSafeApp } from '@app/hooks/useIsSafeApp'
1616
import { GenericTransaction } from '@app/transaction-flow/types'
17-
import { getAccessList } from '@app/utils/query/getAccessList'
17+
import { createAccessList } from '@app/utils/query/createAccessList'
1818
import { checkIsSafeApp } from '@app/utils/safe'
1919

2020
import { makeMockIntersectionObserver } from '../../../../../test/mock/makeMockIntersectionObserver'
@@ -29,7 +29,7 @@ vi.mock('@app/hooks/transactions/useAddRecentTransaction')
2929
vi.mock('@app/hooks/transactions/useRecentTransactions')
3030
vi.mock('@app/hooks/chain/useInvalidateOnBlock')
3131
vi.mock('@app/utils/safe')
32-
vi.mock('@app/utils/query/getAccessList')
32+
vi.mock('@app/utils/query/createAccessList')
3333
vi.mock('@wagmi/core', async () => {
3434
const actual = await vi.importActual('@wagmi/core')
3535
return {
@@ -81,7 +81,7 @@ const mockUseClient = mockFunction(useClient)
8181
const mockUseConnectorClient = mockFunction(useConnectorClient)
8282

8383
const mockEstimateGas = mockFunction(estimateGas)
84-
const mockGetAccessList = getAccessList as MockedFunctionDeep<typeof getAccessList>
84+
const mockCreateAccessList = createAccessList as MockedFunctionDeep<typeof createAccessList>
8585
const mockPrepareTransactionRequest = prepareTransactionRequest as MockedFunctionDeep<
8686
typeof prepareTransactionRequest
8787
>
@@ -211,7 +211,7 @@ describe('TransactionStageModal', () => {
211211
})
212212

213213
it('should disable confirm button and re-estimate gas if a unique identifier is changed', async () => {
214-
mockGetAccessList.mockResolvedValue({ accessList: [], gasUsed: '0x64' })
214+
mockCreateAccessList.mockResolvedValue({ accessList: [], gasUsed: '0x64' })
215215
mockEstimateGas.mockResolvedValue(1n)
216216
mockUseIsSafeApp.mockReturnValue({ data: false })
217217
mockUseSendTransaction.mockReturnValue({
@@ -240,7 +240,7 @@ describe('TransactionStageModal', () => {
240240
})
241241

242242
it('should only show confirm button as enabled if gas is estimated and sendTransaction func is defined', async () => {
243-
mockGetAccessList.mockResolvedValue({ accessList: [], gasUsed: '0x64' })
243+
mockCreateAccessList.mockResolvedValue({ accessList: [], gasUsed: '0x64' })
244244
mockEstimateGas.mockResolvedValue(1n)
245245
mockUseSendTransaction.mockReturnValue({
246246
sendTransaction: () => Promise.resolve(),
@@ -251,7 +251,7 @@ describe('TransactionStageModal', () => {
251251
)
252252
})
253253
it('should run set sendTransaction on action click', async () => {
254-
mockGetAccessList.mockResolvedValue({ accessList: [], gasUsed: '0x64' })
254+
mockCreateAccessList.mockResolvedValue({ accessList: [], gasUsed: '0x64' })
255255
mockEstimateGas.mockResolvedValue(1n)
256256
const mockSendTransaction = vi.fn()
257257
mockUseSendTransaction.mockReturnValue({
@@ -292,7 +292,7 @@ describe('TransactionStageModal', () => {
292292
})
293293
it('should pass the request to send transaction', async () => {
294294
mockUseIsSafeApp.mockReturnValue({ data: false })
295-
mockGetAccessList.mockResolvedValue({ accessList: [], gasUsed: '0x64' })
295+
mockCreateAccessList.mockResolvedValue({ accessList: [], gasUsed: '0x64' })
296296
mockEstimateGas.mockResolvedValue(1n)
297297
const mockSendTransaction = vi.fn()
298298
mockUseSendTransaction.mockReturnValue({
@@ -525,7 +525,7 @@ describe('calculateGasLimit', () => {
525525

526526
it('should calculate gas limit', async () => {
527527
mockEstimateGas.mockResolvedValueOnce(100000n)
528-
mockGetAccessList.mockResolvedValueOnce(mockAccessListResponse)
528+
mockCreateAccessList.mockResolvedValueOnce(mockAccessListResponse)
529529
const result = await calculateGasLimit({
530530
txWithZeroGas: mockTxWithZeroGas,
531531
transactionName: mockTransactionName,

src/components/@molecules/TransactionDialogManager/stage/query.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import {
2424
CreateQueryKey,
2525
} from '@app/types'
2626
import { getReadableError } from '@app/utils/errors'
27-
import { getAccessList } from '@app/utils/query/getAccessList'
27+
import { createAccessList } from '@app/utils/query/createAccessList'
2828
import { wagmiConfig } from '@app/utils/query/wagmi'
2929
import { hasParaConnection } from '@app/utils/utils'
3030

@@ -111,7 +111,7 @@ export const calculateGasLimit = async ({
111111
txWithZeroGas: BasicTransactionRequest
112112
transactionName: TransactionName
113113
}) => {
114-
const accessListResponse = await getAccessList(client, {
114+
const accessListResponse = await createAccessList(client, {
115115
to: txWithZeroGas.to,
116116
data: txWithZeroGas.data,
117117
from: connectorClient.account!.address,

src/hooks/chain/useEstimateGasWithStateOverride.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import {
3333
import { emptyAddress } from '@app/utils/constants'
3434
import { getIsCachedData } from '@app/utils/getIsCachedData'
3535
import { prepareQueryOptions } from '@app/utils/prepareQueryOptions'
36-
import { getAccessList } from '@app/utils/query/getAccessList'
36+
import { createAccessList } from '@app/utils/query/createAccessList'
3737
import { useQuery } from '@app/utils/query/useQuery'
3838

3939
import { useGasPrice } from './useGasPrice'
@@ -176,7 +176,7 @@ const estimateIndividualGas = async <TName extends TransactionName>({
176176
// To get the access list, we're executing the bytecode of this Yul code: https://gist.github.com/TateB/777287c9a63d5f02fcd905232ce5748a
177177
// (note: 0xed3869F3020315C839b2f4E9a73bEbE9a9670534 is replaced with `connectorClient.account.address`)
178178
// It does a simple transfer, and accesses any storage slot that would be accessed by any other transfer.
179-
const accessList = await getAccessList(client, {
179+
const accessList = await createAccessList(client, {
180180
from: emptyAddress,
181181
data: concatHex(['0x5f808080600173', connectorClient.account.address, '0x5af100']),
182182
value: '0x1',
Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,13 @@ type AccessListResponse = {
88
gasUsed: Hex
99
}
1010

11-
export const getAccessList = async (
11+
export const createAccessList = async (
1212
client: Client,
13-
tx: TransactionRequest<Hex>,
13+
tx: TransactionRequest<Hex> & {
14+
blockTag?: BlockTag
15+
},
1416
): Promise<AccessListResponse> => {
17+
const blockTag = tx.blockTag ?? 'pending'
1518
const accessListResponse = await client.request<{
1619
Method: 'eth_createAccessList'
1720
Parameters: [tx: TransactionRequest<Hex>, blockTag: BlockTag]
@@ -25,7 +28,7 @@ export const getAccessList = async (
2528
from: tx.from,
2629
value: tx.value,
2730
},
28-
'latest',
31+
blockTag,
2932
],
3033
})
3134

0 commit comments

Comments
 (0)