Skip to content

Commit

Permalink
feat: add 712 examples (#240)
Browse files Browse the repository at this point in the history
  • Loading branch information
loatheb authored Oct 21, 2024
1 parent 51ed617 commit 71f96ad
Show file tree
Hide file tree
Showing 17 changed files with 731 additions and 779 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import type { IEIP712Params } from '../../types';

export default (params: IEIP712Params) => ({
id: 'signTypedDataV4-bigdata',
name: '默认类型: 大数据模式',
description: 'SignTypedDataV4 BigData',
value: JSON.stringify({
domain: {
name: 'Franklin',
version: '0.0.1',
chainId: params.chainId.toString(),
verifyingContract: '0x0000000000000000000000000000000000000000',
},
primaryType: 'ForwardRequest',
types: {
EIP712Domain: [
{ name: 'name', type: 'string' },
{ name: 'version', type: 'string' },
{ name: 'chainId', type: 'uint256' },
{ name: 'verifyingContract', type: 'address' },
],
ForwardRequest: [
{ name: 'from', type: 'address' },
{ name: 'to', type: 'address' },
{ name: 'value', type: 'uint256' },
{ name: 'gas', type: 'uint256' },
{ name: 'nonce', type: 'uint256' },
{ name: 'data', type: 'bytes' },
],
VerifyWallet: [
{ name: 'contents', type: 'string' },
],
},
message: {
from: '0x0000000000000000000000000000000000000000',
to: '0x0000000000000000000000000000000000000000',
value: 0,
gas: 275755,
nonce: 3,
data: `0x${'01'.repeat(3150)}`,
},
}),
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import normal from './normal';
import nestedArray from './nestedArray';
import bigdata from './bigdata';

import permit from './permit';
import permitSingle from './permitSingle';
import permitBatch from './permitBatch';
import permitTransferFrom from './permitTransferFrom';
import permitBatchTransferFrom from './permitBatchTransferFrom';
import permitWitnessTransferFrom from './permitWitnessTransferFrom';

import order from './order';
import orderComponents from './orderComponents';

import type {IEIP712Params} from '../../types';

export default (params: IEIP712Params) => [
normal(params),
permitWitnessTransferFrom(params),
nestedArray(params),
bigdata(params),
permit(params),
permitSingle(params),
permitBatch(params),
permitTransferFrom(params),
permitBatchTransferFrom(params),
order(params),
orderComponents(params),
];
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import type { IEIP712Params } from '../../types';

export default (params: IEIP712Params) => ({
id: 'signTypedDataV4-Nested-array',
name: '默认类型: 嵌套数组',
description: 'SignTypedDataV4 Nested Array',
value: JSON.stringify({
types: {
EIP712Domain: [
{ name: 'name', type: 'string' },
],
NestedArray: [
{ name: 'nestedItems', type: 'SingleItem[][]' },
],
SingleItem: [
{ name: 'id', type: 'uint256' },
{ name: 'value', type: 'string' },
],
},
primaryType: 'NestedArray',
domain: {
chainId: params.chainId.toString(),
name: 'NestedArray',
verifyingContract: '0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC',
version: '1',
},
message: {
nestedItems: [
[
{
items: [
{ id: 1, value: 'Item1-1' },
{ id: 2, value: 'Item1-2' },
],
},
{
items: [
{ id: 3, value: 'Item2-1' },
{ id: 4, value: 'Item2-2' },
],
},
],
[
{
items: [
{ id: 5, value: 'Item3-1' },
{ id: 6, value: 'Item3-2' },
],
},
{
items: [
{ id: 7, value: 'Item4-1' },
{ id: 8, value: 'Item4-2' },
],
},
],
],
},
}),
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import type { IEIP712Params } from '../../types';

export default (params: IEIP712Params) => ({
id: 'signTypedDataV4',
name: '默认类型: signTypedDataV4',
description: 'SignTypedDataV4 Normal',
value: JSON.stringify({
domain: {
chainId: params.chainId.toString(),
name: 'Ether Mail',
verifyingContract: '0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC',
version: '1',
},
message: {
contents: 'Hello, Bob!',
from: {
name: 'Cow',
wallets: [
'0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826',
'0xDeaDbeefdEAdbeefdEadbEEFdeadbeEFdEaDbeeF',
],
},
to: [
{
name: 'Bob',
wallets: [
'0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB',
'0xB0BdaBea57B0BDABeA57b0bdABEA57b0BDabEa57',
'0xB0B0b0b0b0b0B000000000000000000000000000',
],
},
],
attachment: '0x',
},
primaryType: 'Mail',
types: {
EIP712Domain: [
{ name: 'name', type: 'string' },
{ name: 'version', type: 'string' },
{ name: 'chainId', type: 'uint256' },
{ name: 'verifyingContract', type: 'address' },
],
Group: [
{ name: 'name', type: 'string' },
{ name: 'members', type: 'Person[]' },
],
Mail: [
{ name: 'from', type: 'Person' },
{ name: 'to', type: 'Person[]' },
{ name: 'contents', type: 'string' },
{ name: 'attachment', type: 'bytes' },
],
Person: [
{ name: 'name', type: 'string' },
{ name: 'wallets', type: 'address[]' },
],
},
}),
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import type { IEIP712Params } from '../../types';

export default (params: IEIP712Params) => ({
id: 'signTypedDataV4-order',
name: 'order: Order 方法',
description: 'SignTypedDataV4 Order 方法',
value: JSON.stringify({
types: {
Order: [
{ type: 'uint8', name: 'direction' },
{ type: 'address', name: 'maker' },
{ type: 'address', name: 'taker' },
{ type: 'uint256', name: 'expiry' },
{ type: 'uint256', name: 'nonce' },
{ type: 'address', name: 'erc20Token' },
{ type: 'uint256', name: 'erc20TokenAmount' },
{ type: 'Fee[]', name: 'fees' },
{ type: 'address', name: 'erc721Token' },
{ type: 'uint256', name: 'erc721TokenId' },
{ type: 'Property[]', name: 'erc721TokenProperties' },
],
Fee: [
{ type: 'address', name: 'recipient' },
{ type: 'uint256', name: 'amount' },
{ type: 'bytes', name: 'feeData' },
],
Property: [
{ type: 'address', name: 'propertyValidator' },
{ type: 'bytes', name: 'propertyData' },
],
EIP712Domain: [
{ name: 'name', type: 'string' },
{ name: 'version', type: 'string' },
{ name: 'chainId', type: 'uint256' },
{ name: 'verifyingContract', type: 'address' },
],
},
domain: {
name: 'ZeroEx',
version: '1.0.0',
chainId: params.chainId.toString(),
verifyingContract: '0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC',
},
primaryType: 'Order',
message: {
direction: '0',
maker: '0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc',
taker: '0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826',
expiry: '2524604400',
nonce: '100131415900000000000000000000000000000083840314483690155566137712510085002484',
erc20Token: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
erc20TokenAmount: '42000000000000',
fees: [],
erc721Token: '0x8a90CAb2b38dba80c64b7734e58Ee1dB38B8992e',
erc721TokenId: '2516',
erc721TokenProperties: [],
},
}),
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
import type { IEIP712Params } from '../../types';

export default (params: IEIP712Params) => ({
id: 'signTypedDataV4-orderComponents',
name: 'order: OrderComponents 方法',
description: 'SignTypedDataV4 OrderComponents 方法',
value: JSON.stringify({
types: {
EIP712Domain: [
{ name: 'name', type: 'string' },
{ name: 'version', type: 'string' },
{ name: 'chainId', type: 'uint256' },
{ name: 'verifyingContract', type: 'address' },
],
OrderComponents: [
{ name: 'offerer', type: 'address' },
{ name: 'zone', type: 'address' },
{ name: 'offer', type: 'OfferItem[]' },
{ name: 'consideration', type: 'ConsiderationItem[]' },
{ name: 'orderType', type: 'uint8' },
{ name: 'startTime', type: 'uint256' },
{ name: 'endTime', type: 'uint256' },
{ name: 'zoneHash', type: 'bytes32' },
{ name: 'salt', type: 'uint256' },
{ name: 'conduitKey', type: 'bytes32' },
{ name: 'counter', type: 'uint256' },
],
OfferItem: [
{ name: 'itemType', type: 'uint8' },
{ name: 'token', type: 'address' },
{ name: 'identifierOrCriteria', type: 'uint256' },
{ name: 'startAmount', type: 'uint256' },
{ name: 'endAmount', type: 'uint256' },
],
ConsiderationItem: [
{ name: 'itemType', type: 'uint8' },
{ name: 'token', type: 'address' },
{ name: 'identifierOrCriteria', type: 'uint256' },
{ name: 'startAmount', type: 'uint256' },
{ name: 'endAmount', type: 'uint256' },
{ name: 'recipient', type: 'address' },
],
},
primaryType: 'OrderComponents',
domain: {
name: 'Seaport',
version: '1.1',
chainId: params.chainId.toString(),
verifyingContract: '0x00000000006c3852cbEf3e08E8dF289169EdE581', // Seaport 1.1 contract address
},
message: {
offerer: '0x0000000000000000000000000000000000000000',
zone: '0x0000000000000000000000000000000000000000',
offer: [
{
itemType: 2, // ERC721
token: '0x0000000000000000000000000000000000000000',
identifierOrCriteria: '1',
startAmount: '1',
endAmount: '1',
},
],
consideration: [
{
itemType: 0, // ETH
token: '0x0000000000000000000000000000000000000000',
identifierOrCriteria: '0',
startAmount: '1000000000000000000',
endAmount: '1000000000000000000',
recipient: '0x0000000000000000000000000000000000000000',
},
],
orderType: 0, // FULL_OPEN
startTime: '1640995200', // 2022-01-01 00:00:00 UTC
endTime: '1672531200', // 2023-01-01 00:00:00 UTC
zoneHash: '0x0000000000000000000000000000000000000000000000000000000000000000',
salt: '0',
conduitKey: '0x0000000000000000000000000000000000000000000000000000000000000000',
counter: '0',
},
}),
});
Loading

0 comments on commit 71f96ad

Please sign in to comment.