mirror of
https://github.com/status-im/nft-faucet.git
synced 2025-02-24 12:38:30 +00:00
21 lines
639 B
C#
21 lines
639 B
C#
|
using Nethereum.ABI.FunctionEncoding;
|
||
|
using Nethereum.Hex.HexConvertors.Extensions;
|
||
|
using NftFaucet.Attributes;
|
||
|
using NftFaucet.Extensions;
|
||
|
|
||
|
namespace NftFaucet.Models.Function;
|
||
|
|
||
|
public abstract class Function
|
||
|
{
|
||
|
public string Encode()
|
||
|
{
|
||
|
var hash = GetHash().EnsureHexPrefix();
|
||
|
var encoder = new FunctionCallEncoder();
|
||
|
var encodedParameters = encoder.EncodeParametersFromTypeAttributes(GetType(), this);
|
||
|
var encodedCall = encoder.EncodeRequest(hash, encodedParameters.ToHex());
|
||
|
return encodedCall;
|
||
|
}
|
||
|
|
||
|
public string GetHash() => GetType().GetAttribute<FunctionHashAttribute>().Hash;
|
||
|
}
|