Skip to content

Commit 33df7e5

Browse files
committed
chore: tempo auth tweaks
1 parent 0861c0d commit 33df7e5

File tree

4 files changed

+35
-37
lines changed

4 files changed

+35
-37
lines changed

src/ox/Transaction.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import * as Hex from 'ox/Hex'
55
import * as Signature from 'ox/Signature'
66
import * as ox_Transaction from 'ox/Transaction'
77
import type { Compute, OneOf, UnionCompute } from '../internal/types.js'
8-
import type * as AuthorizationTempo from './AuthorizationTempo.js'
8+
import * as AuthorizationTempo from './AuthorizationTempo.js'
99
import * as KeyAuthorization from './KeyAuthorization.js'
1010
import * as SignatureEnvelope from './SignatureEnvelope.js'
1111
import type { Call } from './TransactionEnvelopeTempo.js'
@@ -95,8 +95,9 @@ export type Tempo<
9595
export type TempoRpc<pending extends boolean = false> = Compute<
9696
Omit<
9797
Tempo<pending, Hex.Hex, Hex.Hex, ToRpcType['tempo']>,
98-
'calls' | 'keyAuthorization' | 'signature'
98+
'authorizationList' | 'calls' | 'keyAuthorization' | 'signature'
9999
> & {
100+
aaAuthorizationList?: AuthorizationTempo.ListRpc | undefined
100101
calls:
101102
| readonly {
102103
input?: Hex.Hex | undefined
@@ -191,6 +192,12 @@ export function fromRpc<
191192

192193
transaction_.type = fromRpcType[transaction.type as keyof typeof fromRpcType]
193194

195+
if (transaction.aaAuthorizationList) {
196+
transaction_.authorizationList = AuthorizationTempo.fromRpcList(
197+
transaction.aaAuthorizationList,
198+
)
199+
delete (transaction_ as any).aaAuthorizationList
200+
}
194201
if (transaction.calls)
195202
transaction_.calls = transaction.calls.map((call) => ({
196203
to: call.to,
@@ -285,6 +292,10 @@ export function toRpc<pending extends boolean = false>(
285292

286293
rpc.type = toRpcType[transaction.type as keyof typeof toRpcType]
287294

295+
if (transaction.authorizationList)
296+
rpc.aaAuthorizationList = AuthorizationTempo.toRpcList(
297+
transaction.authorizationList as AuthorizationTempo.ListSigned,
298+
)
288299
if (transaction.calls)
289300
rpc.calls = transaction.calls.map((call) => ({
290301
to: call.to,

src/ox/e2e.test.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,8 @@ test('behavior: default (secp256k1)', async () => {
101101
expect(transactionIndex).toBeDefined()
102102
expect(rest).toMatchInlineSnapshot(`
103103
{
104-
"aaAuthorizationList": [],
105104
"accessList": [],
105+
"authorizationList": [],
106106
"calls": [
107107
{
108108
"data": "0x",
@@ -308,8 +308,8 @@ test('behavior: default (p256)', async () => {
308308
expect(transactionIndex).toBeDefined()
309309
expect(rest).toMatchInlineSnapshot(`
310310
{
311-
"aaAuthorizationList": [],
312311
"accessList": [],
312+
"authorizationList": [],
313313
"calls": [
314314
{
315315
"data": "0x",
@@ -447,8 +447,8 @@ test('behavior: default (p256 - webcrypto)', async () => {
447447
expect(transactionIndex).toBeDefined()
448448
expect(rest).toMatchInlineSnapshot(`
449449
{
450-
"aaAuthorizationList": [],
451450
"accessList": [],
451+
"authorizationList": [],
452452
"calls": [
453453
{
454454
"data": "0x",
@@ -593,8 +593,8 @@ test('behavior: default (webauthn)', async () => {
593593
expect(transactionIndex).toBeDefined()
594594
expect(rest).toMatchInlineSnapshot(`
595595
{
596-
"aaAuthorizationList": [],
597596
"accessList": [],
597+
"authorizationList": [],
598598
"calls": [
599599
{
600600
"data": "0x",
@@ -890,8 +890,8 @@ describe('behavior: keyAuthorization', () => {
890890
expect(transactionIndex).toBeDefined()
891891
expect(rest).toMatchInlineSnapshot(`
892892
{
893-
"aaAuthorizationList": [],
894893
"accessList": [],
894+
"authorizationList": [],
895895
"calls": [
896896
{
897897
"data": "0x",
@@ -1103,8 +1103,8 @@ describe('behavior: keyAuthorization', () => {
11031103
expect(transactionIndex).toBeDefined()
11041104
expect(rest).toMatchInlineSnapshot(`
11051105
{
1106-
"aaAuthorizationList": [],
11071106
"accessList": [],
1107+
"authorizationList": [],
11081108
"calls": [
11091109
{
11101110
"data": "0x",
@@ -1318,8 +1318,8 @@ describe('behavior: keyAuthorization', () => {
13181318
expect(transactionIndex).toBeDefined()
13191319
expect(rest).toMatchInlineSnapshot(`
13201320
{
1321-
"aaAuthorizationList": [],
13221321
"accessList": [],
1322+
"authorizationList": [],
13231323
"calls": [
13241324
{
13251325
"data": "0x",

src/viem/Chain.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ function config<const chain extends Chain>(chain: chain) {
5555
},
5656
formatters: {
5757
transaction: defineTransaction({
58+
exclude: ['aaAuthorizationList' as never],
5859
format: Formatters.formatTransaction,
5960
}),
6061
transactionReceipt: defineTransactionReceipt({

src/viem/e2e.test.ts

Lines changed: 14 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,8 @@ describe('sendTransaction', () => {
6868
expect(transactionIndex).toBeDefined()
6969
expect(transaction).toMatchInlineSnapshot(`
7070
{
71-
"aaAuthorizationList": [],
7271
"accessList": [],
73-
"authorizationList": undefined,
72+
"authorizationList": [],
7473
"calls": [
7574
{
7675
"data": "0xdeadbeef",
@@ -145,9 +144,8 @@ describe('sendTransaction', () => {
145144
expect(transactionIndex).toBeDefined()
146145
expect(transaction).toMatchInlineSnapshot(`
147146
{
148-
"aaAuthorizationList": [],
149147
"accessList": [],
150-
"authorizationList": undefined,
148+
"authorizationList": [],
151149
"data": undefined,
152150
"feePayerSignature": undefined,
153151
"feeToken": "0x20c0000000000000000000000000000000000001",
@@ -210,9 +208,8 @@ describe('sendTransaction', () => {
210208
expect(transactionIndex).toBeDefined()
211209
expect(transaction).toMatchInlineSnapshot(`
212210
{
213-
"aaAuthorizationList": [],
214211
"accessList": [],
215-
"authorizationList": undefined,
212+
"authorizationList": [],
216213
"calls": [
217214
{
218215
"data": "0x",
@@ -325,9 +322,8 @@ describe('sendTransaction', () => {
325322
expect(transactionIndex).toBeDefined()
326323
expect(transaction).toMatchInlineSnapshot(`
327324
{
328-
"aaAuthorizationList": [],
329325
"accessList": [],
330-
"authorizationList": undefined,
326+
"authorizationList": [],
331327
"calls": [
332328
{
333329
"data": "0xdeadbeef",
@@ -410,9 +406,8 @@ describe('sendTransaction', () => {
410406
expect(transactionIndex).toBeDefined()
411407
expect(transaction).toMatchInlineSnapshot(`
412408
{
413-
"aaAuthorizationList": [],
414409
"accessList": [],
415-
"authorizationList": undefined,
410+
"authorizationList": [],
416411
"data": undefined,
417412
"feePayerSignature": undefined,
418413
"feeToken": "0x20c0000000000000000000000000000000000001",
@@ -478,9 +473,8 @@ describe('sendTransaction', () => {
478473
expect(transactionIndex).toBeDefined()
479474
expect(transaction).toMatchInlineSnapshot(`
480475
{
481-
"aaAuthorizationList": [],
482476
"accessList": [],
483-
"authorizationList": undefined,
477+
"authorizationList": [],
484478
"calls": [
485479
{
486480
"data": "0x",
@@ -608,9 +602,8 @@ describe('sendTransaction', () => {
608602
expect(transactionIndex).toBeDefined()
609603
expect(transaction).toMatchInlineSnapshot(`
610604
{
611-
"aaAuthorizationList": [],
612605
"accessList": [],
613-
"authorizationList": undefined,
606+
"authorizationList": [],
614607
"calls": [
615608
{
616609
"data": "0xdeadbeef",
@@ -814,9 +807,8 @@ describe('sendTransaction', () => {
814807
expect(transactionIndex).toBeDefined()
815808
expect(transaction).toMatchInlineSnapshot(`
816809
{
817-
"aaAuthorizationList": [],
818810
"accessList": [],
819-
"authorizationList": undefined,
811+
"authorizationList": [],
820812
"calls": [
821813
{
822814
"data": "0xdeadbeef",
@@ -903,9 +895,8 @@ describe('sendTransaction', () => {
903895
expect(transactionIndex).toBeDefined()
904896
expect(transaction).toMatchInlineSnapshot(`
905897
{
906-
"aaAuthorizationList": [],
907898
"accessList": [],
908-
"authorizationList": undefined,
899+
"authorizationList": [],
909900
"data": undefined,
910901
"feePayerSignature": undefined,
911902
"feeToken": "0x20c0000000000000000000000000000000000001",
@@ -975,9 +966,8 @@ describe('sendTransaction', () => {
975966
expect(transactionIndex).toBeDefined()
976967
expect(transaction).toMatchInlineSnapshot(`
977968
{
978-
"aaAuthorizationList": [],
979969
"accessList": [],
980-
"authorizationList": undefined,
970+
"authorizationList": [],
981971
"calls": [
982972
{
983973
"data": "0x",
@@ -1153,9 +1143,8 @@ describe('signTransaction', () => {
11531143
expect(transactionIndex).toBeDefined()
11541144
expect(transaction2).toMatchInlineSnapshot(`
11551145
{
1156-
"aaAuthorizationList": [],
11571146
"accessList": [],
1158-
"authorizationList": undefined,
1147+
"authorizationList": [],
11591148
"calls": [
11601149
{
11611150
"data": "0xdeadbeef",
@@ -1326,9 +1315,8 @@ describe('relay', () => {
13261315
expect(transactionIndex).toBeDefined()
13271316
expect(transaction).toMatchInlineSnapshot(`
13281317
{
1329-
"aaAuthorizationList": [],
13301318
"accessList": [],
1331-
"authorizationList": undefined,
1319+
"authorizationList": [],
13321320
"calls": [
13331321
{
13341322
"data": "0xe789744400000000000000000000000020c0000000000000000000000000000000000001",
@@ -1457,9 +1445,8 @@ describe('relay', () => {
14571445
expect(transactionIndex).toBeDefined()
14581446
expect(transaction).toMatchInlineSnapshot(`
14591447
{
1460-
"aaAuthorizationList": [],
14611448
"accessList": [],
1462-
"authorizationList": undefined,
1449+
"authorizationList": [],
14631450
"calls": [
14641451
{
14651452
"data": "0xe789744400000000000000000000000020c0000000000000000000000000000000000001",
@@ -1569,9 +1556,8 @@ describe('relay', () => {
15691556
expect(transactionIndex).toBeDefined()
15701557
expect(transaction).toMatchInlineSnapshot(`
15711558
{
1572-
"aaAuthorizationList": [],
15731559
"accessList": [],
1574-
"authorizationList": undefined,
1560+
"authorizationList": [],
15751561
"calls": [
15761562
{
15771563
"data": "0xe789744400000000000000000000000020c0000000000000000000000000000000000001",

0 commit comments

Comments
 (0)