Skip to content

Commit 0abb1d1

Browse files
authored
feat: add action context to formatters; tweak tx types (#3997)
* feat: add action context to formatters; tweak tx types * up vectors * u * chore: changeset * u * u * u * chore: up * Update seven-dots-double.md
1 parent 3cf7e9f commit 0abb1d1

32 files changed

+244
-181
lines changed

.changeset/seven-dots-double.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"viem": patch
3+
---
4+
5+
Tweaked `TransactionSerializable` & `TransactionRequest` types to be more symmetric.

.changeset/spotty-bats-tell.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"viem": patch
3+
---
4+
5+
Added `action` parameter to formatters.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,8 @@
259259
"on-headers@<1.1.0": "1.1.0",
260260
"tar-fs@>=3.0.0 <3.0.9": "3.0.9",
261261
"vite@>=6.0.0 <=6.3.5": "6.3.6",
262-
"hono@<4.9.7": "4.9.7"
262+
"hono@<4.9.7": "4.9.7",
263+
"tar-fs@>=3.0.0 <3.1.1": ">=3.1.1"
263264
},
264265
"onlyBuiltDependencies": [
265266
"bun",

pnpm-lock.yaml

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

pnpm-workspace.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
auditConfig:
2+
ignoreGhsas:
3+
- GHSA-ffrw-9mx8-89p8
14
catalog:
25
'@types/react': ^19
36
'@types/react-dom': ^19

src/accounts/utils/__snapshots__/signTransaction.test.ts.snap

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

src/accounts/utils/signTransaction.test.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ describe('eip4844', async () => {
7070
blobVersionedHashes,
7171
chainId: 1,
7272
sidecars,
73+
to: '0x0000000000000000000000000000000000000000',
7374
type: 'eip4844',
7475
} as const satisfies TransactionSerializable
7576

@@ -84,7 +85,14 @@ describe('eip4844', async () => {
8485
test('args: blobs + kzg', async () => {
8586
const blobs = toBlobs({ data: stringToHex(blobData) })
8687
const signature = await signTransaction({
87-
transaction: { ...base, blobs, chainId: 1, kzg, type: 'eip4844' },
88+
transaction: {
89+
...base,
90+
blobs,
91+
chainId: 1,
92+
kzg,
93+
to: '0x0000000000000000000000000000000000000000',
94+
type: 'eip4844',
95+
},
8896
privateKey: accounts[0].privateKey,
8997
})
9098
expect(signature).toMatchSnapshot()
@@ -94,7 +102,7 @@ describe('eip4844', async () => {
94102
const blobs = toBlobs({ data: stringToHex(blobData) })
95103
const request = await prepareTransactionRequest(client, {
96104
account: privateKeyToAccount(accounts[0].privateKey),
97-
blobs: blobs,
105+
blobs,
98106
kzg,
99107
maxFeePerBlobGas: parseGwei('20'),
100108
to: '0x0000000000000000000000000000000000000000',

src/actions/public/call.ts

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -226,23 +226,26 @@ export async function call<chain extends Chain | undefined>(
226226
const chainFormat = client.chain?.formatters?.transactionRequest?.format
227227
const format = chainFormat || formatTransactionRequest
228228

229-
const request = format({
230-
// Pick out extra data that might exist on the chain's transaction request type.
231-
...extract(rest, { format: chainFormat }),
232-
from: account?.address,
233-
accessList,
234-
authorizationList,
235-
blobs,
236-
data,
237-
gas,
238-
gasPrice,
239-
maxFeePerBlobGas,
240-
maxFeePerGas,
241-
maxPriorityFeePerGas,
242-
nonce,
243-
to: deploylessCall ? undefined : to,
244-
value,
245-
} as TransactionRequest) as TransactionRequest
229+
const request = format(
230+
{
231+
// Pick out extra data that might exist on the chain's transaction request type.
232+
...extract(rest, { format: chainFormat }),
233+
from: account?.address,
234+
accessList,
235+
authorizationList,
236+
blobs,
237+
data,
238+
gas,
239+
gasPrice,
240+
maxFeePerBlobGas,
241+
maxFeePerGas,
242+
maxPriorityFeePerGas,
243+
nonce,
244+
to: deploylessCall ? undefined : to,
245+
value,
246+
} as TransactionRequest,
247+
'call',
248+
) as TransactionRequest
246249

247250
if (
248251
batch &&

src/actions/public/createAccessList.ts

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -127,20 +127,23 @@ export async function createAccessList<chain extends Chain | undefined>(
127127
const chainFormat = client.chain?.formatters?.transactionRequest?.format
128128
const format = chainFormat || formatTransactionRequest
129129

130-
const request = format({
131-
// Pick out extra data that might exist on the chain's transaction request type.
132-
...extract(rest, { format: chainFormat }),
133-
from: account?.address,
134-
blobs,
135-
data,
136-
gas,
137-
gasPrice,
138-
maxFeePerBlobGas,
139-
maxFeePerGas,
140-
maxPriorityFeePerGas,
141-
to,
142-
value,
143-
} as TransactionRequest) as TransactionRequest
130+
const request = format(
131+
{
132+
// Pick out extra data that might exist on the chain's transaction request type.
133+
...extract(rest, { format: chainFormat }),
134+
from: account?.address,
135+
blobs,
136+
data,
137+
gas,
138+
gasPrice,
139+
maxFeePerBlobGas,
140+
maxFeePerGas,
141+
maxPriorityFeePerGas,
142+
to,
143+
value,
144+
} as TransactionRequest,
145+
'createAccessList',
146+
) as TransactionRequest
144147

145148
const response = await client.request({
146149
method: 'eth_createAccessList',

0 commit comments

Comments
 (0)