mirror of
https://github.com/status-im/nft-faucet.git
synced 2025-02-23 12:08:32 +00:00
21 lines
653 B
C#
21 lines
653 B
C#
using Nethereum.ABI.FunctionEncoding;
|
|
using Nethereum.Hex.HexConvertors.Extensions;
|
|
using NftFaucet.Domain.Attributes;
|
|
using NftFaucet.Domain.Extensions;
|
|
|
|
namespace NftFaucet.Domain.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;
|
|
}
|