Skip to content

Commit 04c5975

Browse files
authored
feat: support pre-signed authorization in evm 7702 (#552)
- 7702 这边只支持自签名,authorizationList 的地址要和 to 的地址一致,我这边在 sdk 层做了检测。 - 添加了测试用例 - 支持pre-signed平铺
1 parent 33aa9a5 commit 04c5975

File tree

7 files changed

+656
-121
lines changed

7 files changed

+656
-121
lines changed

packages/connect-examples/expo-example/src/data/ethereum.ts

Lines changed: 123 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,129 @@ const api: PlaygroundProps[] = [
295295
},
296296
},
297297
},
298+
{
299+
title: 'EIP-7702 Simple7702Account',
300+
value: {
301+
path: "m/44'/60'/0'/0/0",
302+
transaction: {
303+
to: '0x4Cd241E8d1510e30b2076397afc7508Ae59C66c9',
304+
value: '0x0',
305+
data: '0x', // empty data for code authorization only
306+
chainId: 1,
307+
nonce: '0x0',
308+
gasLimit: '0x5208',
309+
maxFeePerGas: '0xbebc200',
310+
maxPriorityFeePerGas: '0x9502f900',
311+
accessList: [],
312+
authorizationList: [
313+
{
314+
chainId: 1,
315+
address: '0x4Cd241E8d1510e30b2076397afc7508Ae59C66c9',
316+
nonce: '0x1',
317+
},
318+
],
319+
},
320+
},
321+
},
322+
{
323+
title: 'EIP-7702 MetaMask Account',
324+
value: {
325+
path: "m/44'/60'/0'/0/0",
326+
transaction: {
327+
to: '0x63c0c19a282a1B52b07dD5a65b58948A07DAE32B',
328+
value: '0x0',
329+
data: '0x', // empty data for code authorization only
330+
chainId: 1,
331+
nonce: '0x1',
332+
gasLimit: '0x5208',
333+
maxFeePerGas: '0xbebc200',
334+
maxPriorityFeePerGas: '0x9502f900',
335+
accessList: [],
336+
authorizationList: [
337+
{
338+
chainId: 1,
339+
address: '0x63c0c19a282a1B52b07dD5a65b58948A07DAE32B',
340+
nonce: '0x2',
341+
},
342+
],
343+
},
344+
},
345+
},
346+
{
347+
title: 'EIP-7702 OKX WalletCore',
348+
value: {
349+
path: "m/44'/60'/0'/0/0",
350+
transaction: {
351+
to: '0x80296FF8D1ED46f8e3C7992664D13B833504c2Bb',
352+
value: '0x0',
353+
data: '0x8129fc1c', // initialize() function selector
354+
chainId: 1,
355+
nonce: '0x2',
356+
gasLimit: '0x5208',
357+
maxFeePerGas: '0xbebc200',
358+
maxPriorityFeePerGas: '0x9502f900',
359+
accessList: [],
360+
authorizationList: [
361+
{
362+
chainId: 1,
363+
address: '0x80296FF8D1ED46f8e3C7992664D13B833504c2Bb',
364+
nonce: '0x3',
365+
},
366+
],
367+
},
368+
},
369+
},
370+
{
371+
title: 'EIP-7702 Revoke Authorization',
372+
value: {
373+
path: "m/44'/60'/0'/0/0",
374+
transaction: {
375+
to: '0x0000000000000000000000000000000000000000',
376+
value: '0x0',
377+
data: '0x', // empty data for revoke
378+
chainId: 1,
379+
nonce: '0x3',
380+
gasLimit: '0x5208',
381+
maxFeePerGas: '0xbebc200',
382+
maxPriorityFeePerGas: '0x9502f900',
383+
accessList: [],
384+
authorizationList: [
385+
{
386+
chainId: 1,
387+
address: '0x0000000000000000000000000000000000000000',
388+
nonce: '0x4',
389+
},
390+
],
391+
},
392+
},
393+
},
394+
{
395+
title: 'EIP-7702 With Pre-signed Authorization (Flattened Structure)',
396+
value: {
397+
path: "m/44'/60'/0'/0/0",
398+
transaction: {
399+
to: '0x4Cd241E8d1510e30b2076397afc7508Ae59C66c9',
400+
value: '0x0',
401+
data: '0x', // empty data for authorization only
402+
chainId: 1,
403+
nonce: '0x5',
404+
gasLimit: '0x7530',
405+
maxFeePerGas: '0xbebc200',
406+
maxPriorityFeePerGas: '0x9502f900',
407+
accessList: [],
408+
authorizationList: [
409+
{
410+
chainId: 1,
411+
address: '0x4Cd241E8d1510e30b2076397afc7508Ae59C66c9',
412+
nonce: '0x5',
413+
yParity: 0,
414+
r: '0x7f209007aa8d29b5fb1c6cc2667e7cf10004ce251303621dea9ea36820abcdef',
415+
s: '0x1594e46e321822ae718a12ad4ee0d249a93e24b134ba5379bd038368a7f51cad',
416+
},
417+
],
418+
},
419+
},
420+
},
298421
],
299422
},
300423
{
@@ -682,108 +805,6 @@ const api: PlaygroundProps[] = [
682805
},
683806
],
684807
},
685-
{
686-
method: 'evmSignTransaction',
687-
description: 'Sign an EIP-7702 transaction with your EVM account.',
688-
presupposes: [
689-
{
690-
title: 'EIP-7702 Simple7702Account',
691-
value: {
692-
path: "m/44'/60'/0'/0/0",
693-
transaction: {
694-
to: '0x4Cd241E8d1510e30b2076397afc7508Ae59C66c9',
695-
value: '0x0',
696-
data: '0x', // empty data for code authorization only
697-
chainId: 1,
698-
nonce: '0x0',
699-
gasLimit: '0x5208',
700-
maxFeePerGas: '0xbebc200',
701-
maxPriorityFeePerGas: '0x9502f900',
702-
accessList: [],
703-
authorizationList: [
704-
{
705-
chainId: 1,
706-
address: '0x4Cd241E8d1510e30b2076397afc7508Ae59C66c9',
707-
nonce: '0x1',
708-
},
709-
],
710-
},
711-
},
712-
},
713-
{
714-
title: 'EIP-7702 MetaMask Account',
715-
value: {
716-
path: "m/44'/60'/0'/0/0",
717-
transaction: {
718-
to: '0x63c0c19a282a1B52b07dD5a65b58948A07DAE32B',
719-
value: '0x0',
720-
data: '0x', // empty data for code authorization only
721-
chainId: 1,
722-
nonce: '0x1',
723-
gasLimit: '0x5208',
724-
maxFeePerGas: '0xbebc200',
725-
maxPriorityFeePerGas: '0x9502f900',
726-
accessList: [],
727-
authorizationList: [
728-
{
729-
chainId: 1,
730-
address: '0x63c0c19a282a1B52b07dD5a65b58948A07DAE32B',
731-
nonce: '0x2',
732-
},
733-
],
734-
},
735-
},
736-
},
737-
{
738-
title: 'EIP-7702 OKX WalletCore',
739-
value: {
740-
path: "m/44'/60'/0'/0/0",
741-
transaction: {
742-
to: '0x80296FF8D1ED46f8e3C7992664D13B833504c2Bb',
743-
value: '0x0',
744-
data: '0x8129fc1c', // initialize() function selector
745-
chainId: 1,
746-
nonce: '0x2',
747-
gasLimit: '0x5208',
748-
maxFeePerGas: '0xbebc200',
749-
maxPriorityFeePerGas: '0x9502f900',
750-
accessList: [],
751-
authorizationList: [
752-
{
753-
chainId: 1,
754-
address: '0x80296FF8D1ED46f8e3C7992664D13B833504c2Bb',
755-
nonce: '0x3',
756-
},
757-
],
758-
},
759-
},
760-
},
761-
{
762-
title: 'EIP-7702 Revoke Authorization',
763-
value: {
764-
path: "m/44'/60'/0'/0/0",
765-
transaction: {
766-
to: '0x0000000000000000000000000000000000000000',
767-
value: '0x0',
768-
data: '0x', // empty data for revoke
769-
chainId: 1,
770-
nonce: '0x3',
771-
gasLimit: '0x5208',
772-
maxFeePerGas: '0xbebc200',
773-
maxPriorityFeePerGas: '0x9502f900',
774-
accessList: [],
775-
authorizationList: [
776-
{
777-
chainId: 1,
778-
address: '0x0000000000000000000000000000000000000000',
779-
nonce: '0x4',
780-
},
781-
],
782-
},
783-
},
784-
},
785-
],
786-
},
787808
{
788809
method: 'evmVerifyMessage',
789810
description: 'Verify a message with your EVM account.',

packages/connect-examples/expo-example/src/testTools/chainMethodTest/data/eth.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,33 @@ const ethData: PlaygroundProps[] = [
249249
},
250250
},
251251
},
252+
{
253+
title: 'EIP-7702 With Pre-signed Authorization (Test)',
254+
value: {
255+
path: "m/44'/60'/0'/0/0",
256+
transaction: {
257+
to: '0x4Cd241E8d1510e30b2076397afc7508Ae59C66c9',
258+
value: '0x0',
259+
data: '0x', // empty data for authorization only
260+
chainId: 1,
261+
nonce: '0x5',
262+
gasLimit: '0x7530',
263+
maxFeePerGas: '0xbebc200',
264+
maxPriorityFeePerGas: '0x9502f900',
265+
accessList: [],
266+
authorizationList: [
267+
{
268+
chainId: 1,
269+
address: '0x4Cd241E8d1510e30b2076397afc7508Ae59C66c9',
270+
nonce: '0x5',
271+
yParity: 1,
272+
r: '0xdeadbeef1234567890abcdef1234567890abcdef1234567890abcdef123456789',
273+
s: '0xcafebabe567890abcdef1234567890abcdef1234567890abcdef1234567890abc',
274+
},
275+
],
276+
},
277+
},
278+
},
252279
],
253280
},
254281
{

packages/connect-examples/expo-playground/app/data/methods/ethereum.ts

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -705,6 +705,47 @@ const api: UnifiedMethodConfig[] = [
705705
},
706706
],
707707
},
708+
{
709+
title: 'EIP-7702 With Pre-signed Authorization (Flattened)',
710+
parameters: [
711+
{
712+
name: 'path',
713+
type: 'string',
714+
required: true,
715+
label: 'Derivation Path',
716+
description: 'BIP32 derivation path',
717+
value: "m/44'/60'/0'/0/0",
718+
},
719+
{
720+
name: 'transaction',
721+
type: 'textarea',
722+
required: true,
723+
label: 'Transaction',
724+
description: 'EIP7702 transaction with pre-signed authorization using flattened yParity,r,s structure',
725+
value: {
726+
to: '0x4Cd241E8d1510e30b2076397afc7508Ae59C66c9',
727+
value: '0x0',
728+
data: '0x', // empty data for authorization only
729+
chainId: 1,
730+
nonce: '0x5',
731+
gasLimit: '0x7530',
732+
maxFeePerGas: '0xbebc200',
733+
maxPriorityFeePerGas: '0x9502f900',
734+
accessList: [],
735+
authorizationList: [
736+
{
737+
chainId: 1,
738+
address: '0x4Cd241E8d1510e30b2076397afc7508Ae59C66c9',
739+
nonce: '0x5',
740+
yParity: 0,
741+
r: '0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef',
742+
s: '0xfedcba0987654321fedcba0987654321fedcba0987654321fedcba0987654321',
743+
},
744+
],
745+
},
746+
},
747+
],
748+
},
708749
],
709750
},
710751
{

0 commit comments

Comments
 (0)