Skip to content

Commit

Permalink
Rename filds (#17)
Browse files Browse the repository at this point in the history
* - rename

* Update README.md

* - update version

* Update README.md

* Update README.md
  • Loading branch information
ArdenHide authored Jan 28, 2025
1 parent 9f77b6c commit f80711f
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 38 deletions.
45 changes: 22 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ For signing we use EIP-712 standart.

We build the scheme dynamically, based on the presence or absence of **Refund**.
> **Note:** It is also important to note that EIP-712 does not support nullable/optional parameters, so in `schedules` for `finishTime` we set `0` if it is missing.
If **Refund** is available, the diagram will look like this:
```js
const typedData = {
Expand All @@ -22,24 +21,24 @@ const typedData = {
SignMessage: [
{ name: "chainId", type: "uint256" },
{ name: "poolId", type: "uint256" },
{ name: "schedules", type: "Schedule[]" },
{ name: "users", type: "User[]" },
{ name: "refund", type: "Refund" },
{ name: "schedules", type: "schedules[]" },
{ name: "users", type: "users[]" },
{ name: "refund", type: "refund" },
],
Schedule: [
schedules: [
{ name: "providerAddress", type: "address" },
{ name: "ratio", type: "uint256" },
{ name: "weiRatio", type: "string" },
{ name: "startTime", type: "uint256" },
{ name: "finishTime", type: "uint256" },
],
User: [
users: [
{ name: "userAddress", type: "address" },
{ name: "weiAmount", type: "uint256" },
{ name: "weiAmount", type: "string" },
],
Refund: [
refund: [
{ name: "chainId", type: "uint256" },
{ name: "poolId", type: "uint256" },
{ name: "ratio", type: "uint256" },
{ name: "weiRatio", type: "string" },
{ name: "dealProvider", type: "address" },
{ name: "finishTime", type: "uint256" },
],
Expand All @@ -54,19 +53,19 @@ const typedData = {
schedules: [
{
providerAddress: "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF",
ratio: "500000000000000000",
weiRatio: "500000000000000000",
startTime: 1763486000,
finishTime: 0,
},
{
providerAddress: "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF",
ratio: "300000000000000000",
weiRatio: "300000000000000000",
startTime: 1763586000,
finishTime: 0,
},
{
providerAddress: "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF",
ratio: "200000000000000000",
weiRatio: "200000000000000000",
startTime: 1763486000,
finishTime: 1763758800,
},
Expand All @@ -84,7 +83,7 @@ const typedData = {
refund: {
chainId: 56,
poolId: 1,
ratio: "800000000000000000",
weiRatio: "800000000000000000",
dealProvider: "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF",
finishTime: 1763544530,
},
Expand All @@ -101,18 +100,18 @@ const typedData = {
SignMessage: [
{ name: "chainId", type: "uint256" },
{ name: "poolId", type: "uint256" },
{ name: "schedules", type: "Schedule[]" },
{ name: "users", type: "User[]" },
{ name: "schedules", type: "schedules[]" },
{ name: "users", type: "users[]" },
],
Schedule: [
schedules: [
{ name: "providerAddress", type: "address" },
{ name: "ratio", type: "uint256" },
{ name: "weiRatio", type: "string" },
{ name: "startTime", type: "uint256" },
{ name: "finishTime", type: "uint256" },
],
User: [
users: [
{ name: "userAddress", type: "address" },
{ name: "weiAmount", type: "uint256" },
{ name: "weiAmount", type: "string" },
],
},
primaryType: "SignMessage",
Expand All @@ -125,19 +124,19 @@ const typedData = {
schedules: [
{
providerAddress: "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF",
ratio: "500000000000000000",
weiRatio: "500000000000000000",
startTime: 1763486000,
finishTime: 0,
},
{
providerAddress: "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF",
ratio: "300000000000000000",
weiRatio: "300000000000000000",
startTime: 1763586000,
finishTime: 0,
},
{
providerAddress: "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF",
ratio: "200000000000000000",
weiRatio: "200000000000000000",
startTime: 1763486000,
finishTime: 1763758800,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<PackageId>DispenserProvider.MessageTemplate</PackageId>
<Version>1.0.2</Version>
<Version>1.0.3</Version>
<Company>The-Poolz</Company>
<Product>DispenserProvider.MessageTemplate</Product>
<Authors>ArdenHide, Lomet</Authors>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ public class CreateMessage(long chainId, long poolId, IEnumerable<Schedule> sche
[Parameter(type: "uint256", name: "poolId", order: 2)]
public BigInteger PoolId { get; } = poolId;

[Parameter(type: "tuple[]", name: "schedules", order: 3, structTypeName: "Schedule[]")]
[Parameter(type: "tuple[]", name: "schedules", order: 3, structTypeName: "schedules[]")]
public Schedule[] Schedules { get; } = schedules.ToArray();

[Parameter(type: "tuple[]", name: "users", order: 4, structTypeName: "User[]")]
[Parameter(type: "tuple[]", name: "users", order: 4, structTypeName: "users[]")]
public User[] Users { get; } = users.ToArray();

protected override bool IsCreate => true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace DispenserProvider.MessageTemplate.Models.Create;
public class CreateMessageWithRefund(long chainId, long poolId, IEnumerable<Schedule> schedules, IEnumerable<User> users, Refund refund)
: CreateMessage(chainId, poolId, schedules, users)
{
[Parameter(type: "tuple", name: "refund", order: 5, structTypeName: "Refund")]
[Parameter(type: "tuple", name: "refund", order: 5, structTypeName: "refund")]
public Refund Refund { get; } = refund;

protected override Type[] MembersDescriptionTypes => [typeof(CreateMessageWithRefund), typeof(Schedule), typeof(User), typeof(Refund)];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace DispenserProvider.MessageTemplate.Models.Create;

[Struct(name: "Refund")]
[Struct(name: "refund")]
public class Refund(long chainId, long poolId, string ratio, EthereumAddress dealProvider, long finishTime)
{
public Refund(long chainId, long poolId, string ratio, EthereumAddress dealProvider, DateTime finishTime)
Expand All @@ -18,8 +18,8 @@ public Refund(long chainId, long poolId, string ratio, EthereumAddress dealProvi
[Parameter(type: "uint256", name: "poolId", order: 2)]
public BigInteger PoolId { get; } = poolId;

[Parameter(type: "uint256", name: "ratio", order: 3)]
public BigInteger Ratio { get; } = BigInteger.Parse(ratio);
[Parameter(type: "string", name: "weiRatio", order: 3)]
public string Ratio { get; } = ratio;

[Parameter(type: "address", name: "dealProvider", order: 4)]
public string DealProvider { get; } = dealProvider;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace DispenserProvider.MessageTemplate.Models.Create;

[Struct(name: "Schedule")]
[Struct(name: "schedules")]
public class Schedule(EthereumAddress providerAddress, string ratio, long startDate, long finishDate)
{
public Schedule(EthereumAddress providerAddress, string ratio, DateTime startDate, DateTime finishDate)
Expand All @@ -15,8 +15,8 @@ public Schedule(EthereumAddress providerAddress, string ratio, DateTime startDat
[Parameter(type: "address", name: "providerAddress", order: 1)]
public string ProviderAddress { get; } = providerAddress;

[Parameter(type: "uint256", name: "ratio", order: 2)]
public BigInteger Ratio { get; } = BigInteger.Parse(ratio);
[Parameter(type: "string", name: "weiRatio", order: 2)]
public string Ratio { get; } = ratio;

[Parameter(type: "uint256", name: "startTime", order: 3)]
public BigInteger StartDate { get; } = startDate;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
using System.Numerics;
using Net.Web3.EthereumWallet;
using Net.Web3.EthereumWallet;
using Nethereum.ABI.FunctionEncoding.Attributes;

namespace DispenserProvider.MessageTemplate.Models.Create;

[Struct(name: "User")]
[Struct(name: "users")]
public class User(EthereumAddress userAddress, string weiAmount)
{
[Parameter(type: "address", name: "userAddress", order: 1)]
public string UserAddress { get; } = userAddress;

[Parameter(type: "uint256", name: "weiAmount", order: 2)]
public BigInteger WeiAmount { get; } = BigInteger.Parse(weiAmount);
[Parameter(type: "string", name: "weiAmount", order: 2)]
public string WeiAmount { get; } = weiAmount;
}

0 comments on commit f80711f

Please sign in to comment.