-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCancelAllOrders.cs
More file actions
50 lines (43 loc) · 1.55 KB
/
CancelAllOrders.cs
File metadata and controls
50 lines (43 loc) · 1.55 KB
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
using Nethereum.Signer.EIP712;
using Nethereum.ABI.FunctionEncoding.Attributes;
using Nethereum.Signer;
using Nethereum.ABI.EIP712;
using System.Numerics;
namespace SigningExampleNethereum
{
public static class CancelAllOrders
{
private static readonly Eip712TypedDataSigner _signer = new Eip712TypedDataSigner();
//Message types for easier input
private class Details
{
[Parameter("uint256", "timestamp", 1)]
public BigInteger Timestamp { get; set; }
}
//The generic Typed schema defintion for this message
private static TypedData<SaltDomain> getTypedDefinition(byte[] salt, BigInteger chainId)
{
return new TypedData<SaltDomain>
{
Domain = new SaltDomain
{
Name = "CancelAllOrdersSportX",
Version = "1.0",
ChainId = chainId,
Salt = salt
},
Types = MemberDescriptionFactory.GetTypesMemberDescription(typeof(SaltDomain), typeof(Details)),
PrimaryType = nameof(Details),
};
}
public static string GetCancelAllOrdersEIP712Payload(BigInteger chainId, BigInteger timestamp, EthECKey key, byte[] salt)
{
var typedData = getTypedDefinition(salt, chainId);
var details = new Details
{
Timestamp = timestamp
};
return _signer.SignTypedDataV4(details, typedData, key);
}
}
}