-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclaim.go
58 lines (55 loc) · 1.09 KB
/
claim.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package eip712
import (
"github.com/ethereum/go-ethereum/common/math"
"github.com/ethereum/go-ethereum/signer/core"
"math/big"
)
var typesClaim = core.Types{
"EIP712Domain": {
{
Name: "name",
Type: "string",
},
{
Name: "version",
Type: "string",
},
{
Name: "chainId",
Type: "uint256",
},
{
Name: "salt",
Type: "string",
},
},
"Claim": {
{
Name: "value",
Type: "uint256",
},
{
Name: "deadline",
Type: "uint256",
},
},
}
// GenClaimTypedData 生成Claim的签名数据
// name 活动名称,业务协商
func GenClaimTypedData(name string, chainId *big.Int, salt string, value *big.Int, deadline int64) core.TypedData {
return core.TypedData{
Types: typesClaim,
PrimaryType: "Claim",
Domain: core.TypedDataDomain{
Name: name,
Version: "1",
ChainId: math.NewHexOrDecimal256(chainId.Int64()),
VerifyingContract: "",
Salt: salt,
},
Message: core.TypedDataMessage{
"value": (*math.HexOrDecimal256)(value),
"deadline": math.NewHexOrDecimal256(deadline),
},
}
}