Skip to content

Commit da88ddf

Browse files
committed
ethcoder: eip712 additional test cases
1 parent 0d8f8a3 commit da88ddf

File tree

1 file changed

+161
-1
lines changed

1 file changed

+161
-1
lines changed

ethcoder/typed_data_test.go

Lines changed: 161 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ func TestTypedDataFromJSONPart4(t *testing.T) {
417417
require.True(t, valid)
418418
}
419419

420-
func TypedDataFromJSONPart5(t *testing.T) {
420+
func TestTypedDataFromJSONPart5(t *testing.T) {
421421
typedDataJson := `{
422422
"types": {
423423
"EIP712Domain": [
@@ -454,3 +454,163 @@ func TypedDataFromJSONPart5(t *testing.T) {
454454

455455
require.Equal(t, typedData.Domain.ChainID.Int64(), int64(15))
456456
}
457+
458+
func TestTypedDataFromJSONPart6(t *testing.T) {
459+
typedDataJson := `{
460+
"domain": {
461+
"name": "Seaport",
462+
"version": "1.5",
463+
"chainId": 80002,
464+
"verifyingContract": "0x00000000000000adc04c56bf30ac9d3c0aaf14dc"
465+
},
466+
"message": {
467+
"conduitKey": "0xf3d63166f0ca56c3c1a3508fce03ff0cf3fb691e000000000000000000000000",
468+
"consideration": [
469+
{
470+
"endAmount": "1",
471+
"identifierOrCriteria": "1",
472+
"itemType": 3,
473+
"recipient": "0x033ccc543501e462a2d50b579845709ff21f2eb6",
474+
"startAmount": "1",
475+
"token": "0xb7d432df27ab7b2a1be636bd945e6cb63bc84feb"
476+
}
477+
],
478+
"counter": "0",
479+
"endTime": 1735219168,
480+
"offer": [
481+
{
482+
"endAmount": "1",
483+
"identifierOrCriteria": "0",
484+
"itemType": 1,
485+
"startAmount": "1",
486+
"token": "0x41e94eb019c0762f9bfcf9fb1e58725bfb0e7582"
487+
}
488+
],
489+
"offerer": "0x033ccc543501e462a2d50b579845709ff21f2eb6",
490+
"orderType": 1,
491+
"salt": "0x634abebe1d4da48b0000000000000000f6dad44ce6d8c81dcbf213906d353f0c",
492+
"startTime": 1734614365,
493+
"zone": "0x0000000000000000000000000000000000000000",
494+
"zoneHash": "0x0000000000000000000000000000000000000000000000000000000000000000"
495+
},
496+
"primaryType": "OrderComponents",
497+
"types": {
498+
"EIP712Domain": [
499+
{
500+
"name": "name",
501+
"type": "string"
502+
},
503+
{
504+
"name": "version",
505+
"type": "string"
506+
},
507+
{
508+
"name": "chainId",
509+
"type": "uint256"
510+
},
511+
{
512+
"name": "verifyingContract",
513+
"type": "address"
514+
}
515+
],
516+
"ConsiderationItem": [
517+
{
518+
"name": "itemType",
519+
"type": "uint8"
520+
},
521+
{
522+
"name": "token",
523+
"type": "address"
524+
},
525+
{
526+
"name": "identifierOrCriteria",
527+
"type": "uint256"
528+
},
529+
{
530+
"name": "startAmount",
531+
"type": "uint256"
532+
},
533+
{
534+
"name": "endAmount",
535+
"type": "uint256"
536+
},
537+
{
538+
"name": "recipient",
539+
"type": "address"
540+
}
541+
],
542+
"OfferItem": [
543+
{
544+
"name": "itemType",
545+
"type": "uint8"
546+
},
547+
{
548+
"name": "token",
549+
"type": "address"
550+
},
551+
{
552+
"name": "identifierOrCriteria",
553+
"type": "uint256"
554+
},
555+
{
556+
"name": "startAmount",
557+
"type": "uint256"
558+
},
559+
{
560+
"name": "endAmount",
561+
"type": "uint256"
562+
}
563+
],
564+
"OrderComponents": [
565+
{
566+
"name": "offerer",
567+
"type": "address"
568+
},
569+
{
570+
"name": "zone",
571+
"type": "address"
572+
},
573+
{
574+
"name": "offer",
575+
"type": "OfferItem[]"
576+
},
577+
{
578+
"name": "consideration",
579+
"type": "ConsiderationItem[]"
580+
},
581+
{
582+
"name": "orderType",
583+
"type": "uint8"
584+
},
585+
{
586+
"name": "startTime",
587+
"type": "uint256"
588+
},
589+
{
590+
"name": "endTime",
591+
"type": "uint256"
592+
},
593+
{
594+
"name": "zoneHash",
595+
"type": "bytes32"
596+
},
597+
{
598+
"name": "salt",
599+
"type": "uint256"
600+
},
601+
{
602+
"name": "conduitKey",
603+
"type": "bytes32"
604+
},
605+
{
606+
"name": "counter",
607+
"type": "uint256"
608+
}
609+
]
610+
}
611+
}`
612+
613+
typedData, err := ethcoder.TypedDataFromJSON(typedDataJson)
614+
require.NoError(t, err)
615+
require.NotNil(t, typedData)
616+
}

0 commit comments

Comments
 (0)