Skip to content

Commit 81e85ed

Browse files
authored
Add EIP-7702 transaction type (#6188)
* feat: ✨ add EIP-7702 transaction types * feat: ✨ update signature types * feat: ✨ add ReceiptV4
1 parent f5cc1b2 commit 81e85ed

File tree

2 files changed

+67
-8
lines changed

2 files changed

+67
-8
lines changed

packages/types/src/interfaces/eth/definitions.ts

Lines changed: 52 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const V0: DefinitionsTypes = {
2424
action: 'EthTransactionAction',
2525
value: 'U256',
2626
input: 'Bytes',
27-
signature: 'EthTransactionSignature'
27+
signature: 'EthLegacyTransactionSignature'
2828
},
2929
TransactionV0: 'LegacyTransaction'
3030
};
@@ -44,9 +44,7 @@ const V1: DefinitionsTypes = {
4444
value: 'U256',
4545
input: 'Bytes',
4646
accessList: 'EthAccessList',
47-
oddYParity: 'bool',
48-
r: 'H256',
49-
s: 'H256'
47+
signature: 'EthTransactionSignature'
5048
},
5149
TransactionV1: {
5250
_enum: {
@@ -72,9 +70,7 @@ const V2: DefinitionsTypes = {
7270
value: 'U256',
7371
input: 'Bytes',
7472
accessList: 'EthAccessList',
75-
oddYParity: 'bool',
76-
r: 'H256',
77-
s: 'H256'
73+
signature: 'EthTransactionSignature'
7874
},
7975
TransactionV2: {
8076
_enum: {
@@ -85,10 +81,40 @@ const V2: DefinitionsTypes = {
8581
}
8682
};
8783

84+
const V3: DefinitionsTypes = {
85+
BlockV3: {
86+
header: 'EthHeader',
87+
transactions: 'Vec<TransactionV3>',
88+
ommers: 'Vec<EthHeader>'
89+
},
90+
EIP7702Transaction: {
91+
chainId: 'u64',
92+
nonce: 'U256',
93+
maxPriorityFeePerGas: 'U256',
94+
maxFeePerGas: 'U256',
95+
gasLimit: 'U256',
96+
destination: 'EthTransactionAction',
97+
value: 'U256',
98+
data: 'Bytes',
99+
accessList: 'EthAccessList',
100+
authorizationList: 'EthAuthorizationList',
101+
signature: 'EthTransactionSignature'
102+
},
103+
TransactionV3: {
104+
_enum: {
105+
Legacy: 'LegacyTransaction',
106+
EIP2930: 'EIP2930Transaction',
107+
EIP1559: 'EIP1559Transaction',
108+
EIP7702: 'EIP7702Transaction'
109+
}
110+
}
111+
};
112+
88113
const types: DefinitionsTypes = {
89114
...V0,
90115
...V1,
91116
...V2,
117+
...V3,
92118
EthereumAccountId: 'GenericEthereumAccountId',
93119
EthereumAddress: 'GenericEthereumAccountId',
94120
EthereumLookupSource: 'GenericEthereumLookupSource',
@@ -98,6 +124,18 @@ const types: DefinitionsTypes = {
98124
slots: 'Vec<H256>'
99125
},
100126
EthAccessList: 'Vec<EthAccessListItem>',
127+
EthAuthorizationList: 'Vec<EthAuthorizationListItem>',
128+
EthAuthorizationListItem: {
129+
chainId: 'u64',
130+
address: 'H160',
131+
nonce: 'U256',
132+
signature: 'EthAuthorizationSignature'
133+
},
134+
EthAuthorizationSignature: {
135+
oddYParity: 'bool',
136+
r: 'H256',
137+
s: 'H256'
138+
},
101139
EthAccount: {
102140
address: 'EthAddress',
103141
balance: 'U256',
@@ -261,6 +299,7 @@ const types: DefinitionsTypes = {
261299
// not convinced, however the original commit matches, so... (maybe V3 is incorrect?)
262300
EthReceiptV0: 'EthReceipt',
263301
EthReceiptV3: 'EthReceipt',
302+
EthReceiptV4: 'EthReceipt',
264303
EthStorageProof: {
265304
key: 'U256',
266305
value: 'U256',
@@ -321,11 +360,16 @@ const types: DefinitionsTypes = {
321360
accessList: 'Option<Vec<EthAccessListItem>>',
322361
transactionType: 'Option<U256>'
323362
},
324-
EthTransactionSignature: {
363+
EthLegacyTransactionSignature: {
325364
v: 'u64',
326365
r: 'H256',
327366
s: 'H256'
328367
},
368+
EthTransactionSignature: {
369+
oddYParity: 'bool',
370+
r: 'H256',
371+
s: 'H256'
372+
},
329373
EthTransactionAction: {
330374
_enum: {
331375
Call: 'H160',

packages/types/src/interfaces/eth/runtime.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,21 @@ export const runtime: DefinitionsCall = {
285285
}
286286
},
287287
version: 2
288+
},
289+
{
290+
methods: {
291+
convert_transaction: {
292+
description: 'Converts an Ethereum-style transaction to Extrinsic',
293+
params: [
294+
{
295+
name: 'transaction',
296+
type: 'TransactionV3'
297+
}
298+
],
299+
type: 'Extrinsic'
300+
}
301+
},
302+
version: 3
288303
}
289304
],
290305
DebugRuntimeApi: [

0 commit comments

Comments
 (0)