@@ -12,3 +12,75 @@ test('get CITY network', async (t) => {
1212 t . assert ( network . versions . public === 28 ) ;
1313 t . assert ( network . isProofOfStake === true ) ;
1414} ) ;
15+
16+ test ( 'perform signing request' , async ( t ) => {
17+ let provider = new BlockcoreProvider ( ) ;
18+
19+ const msgParams = JSON . stringify ( {
20+ domain : {
21+ // Defining the chain aka Rinkeby testnet or Ethereum Main Net
22+ chainId : 1 ,
23+ // Give a user friendly name to the specific contract you are signing for.
24+ name : 'Ether Mail' ,
25+ // If name isn't enough add verifying contract to make sure you are establishing contracts with the proper entity
26+ verifyingContract : '0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC' ,
27+ // Just let's you know the latest version. Definitely make sure the field name is correct.
28+ version : '1' ,
29+ } ,
30+
31+ // Defining the message signing data content.
32+ message : {
33+ /*
34+ - Anything you want. Just a JSON Blob that encodes the data you want to send
35+ - No required fields
36+ - This is DApp Specific
37+ - Be as explicit as possible when building out the message schema.
38+ */
39+ contents : 'Hello, Bob!' ,
40+ attachedMoneyInEth : 4.2 ,
41+ from : {
42+ name : 'Cow' ,
43+ wallets : [ '0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826' , '0xDeaDbeefdEAdbeefdEadbEEFdeadbeEFdEaDbeeF' ] ,
44+ } ,
45+ to : [
46+ {
47+ name : 'Bob' ,
48+ wallets : [ '0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB' , '0xB0BdaBea57B0BDABeA57b0bdABEA57b0BDabEa57' , '0xB0B0b0b0b0b0B000000000000000000000000000' ] ,
49+ } ,
50+ ] ,
51+ } ,
52+ // Refers to the keys of the *types* object below.
53+ primaryType : 'Mail' ,
54+ types : {
55+ // TODO: Clarify if EIP712Domain refers to the domain the contract is hosted on
56+ EIP712Domain : [
57+ { name : 'name' , type : 'string' } ,
58+ { name : 'version' , type : 'string' } ,
59+ { name : 'chainId' , type : 'uint256' } ,
60+ { name : 'verifyingContract' , type : 'address' } ,
61+ ] ,
62+ // Not an EIP712Domain definition
63+ Group : [
64+ { name : 'name' , type : 'string' } ,
65+ { name : 'members' , type : 'Person[]' } ,
66+ ] ,
67+ // Refer to PrimaryType
68+ Mail : [
69+ { name : 'from' , type : 'Person' } ,
70+ { name : 'to' , type : 'Person[]' } ,
71+ { name : 'contents' , type : 'string' } ,
72+ ] ,
73+ // Not an EIP712Domain definition
74+ Person : [
75+ { name : 'name' , type : 'string' } ,
76+ { name : 'wallets' , type : 'address[]' } ,
77+ ] ,
78+ } ,
79+ } ) ;
80+
81+ const account = { } ;
82+
83+ const result = await provider . signTypedData ( [ account , msgParams ] ) ;
84+
85+ t . assert ( result != null ) ;
86+ } ) ;
0 commit comments