Exemplo n.º 1
0
        internal Key(Endorsement endorsement) : this()
        {
            switch (endorsement.Type)
            {
            case KeyType.Ed25519:
                Ed25519 = ByteString.CopyFrom(((Ed25519PublicKeyParameters)endorsement._data).GetEncoded());
                break;

            case KeyType.RSA3072:
                RSA3072 = ByteString.CopyFrom(((ReadOnlyMemory <byte>)endorsement._data).ToArray());
                break;

            case KeyType.ECDSA384:
                ECDSA384 = ByteString.CopyFrom(((ReadOnlyMemory <byte>)endorsement._data).ToArray());
                break;

            case KeyType.Contract:
                ContractID = new ContractID((Address)Abi.DecodeAddressPart((ReadOnlyMemory <byte>)endorsement._data));
                break;

            case KeyType.List:
                ThresholdKey = new ThresholdKey
                {
                    Threshold = endorsement.RequiredCount,
                    Keys      = new KeyList((Endorsement[])endorsement._data)
                };
                break;

            default:
                throw new InvalidOperationException("Endorsement is Empty.");
            }
        }
 internal ContractCallTransactionBody(Hashgraph.CallContractParams callParameters) : this()
 {
     if (callParameters is null)
     {
         throw new ArgumentNullException(nameof(callParameters), "The call parameters are missing. Please check that the argument is not null.");
     }
     ContractID         = new ContractID(callParameters.Contract);
     Gas                = callParameters.Gas;
     Amount             = callParameters.PayableAmount;
     FunctionParameters = ByteString.CopyFrom(Abi.EncodeFunctionWithArguments(callParameters.FunctionName, callParameters.FunctionArgs).Span);
 }
Exemplo n.º 3
0
 internal ContractCallLocalQuery(QueryContractParams queryParameters) : this()
 {
     if (queryParameters is null)
     {
         throw new ArgumentNullException(nameof(queryParameters), "The query parameters are missing. Please check that the argument is not null.");
     }
     ContractID         = new ContractID(queryParameters.Contract);
     Gas                = queryParameters.Gas;
     FunctionParameters = ByteString.CopyFrom(Abi.EncodeFunctionWithArguments(queryParameters.FunctionName, queryParameters.FunctionArgs).Span);
     MaxResultSize      = queryParameters.MaxAllowedReturnSize;
 }
 internal ContractDeleteTransactionBody(Hashgraph.Address contractToDelete, Hashgraph.Address transferToAddress) : this()
 {
     if (contractToDelete is null)
     {
         throw new ArgumentNullException(nameof(contractToDelete), "Contract to Delete is missing. Please check that it is not null.");
     }
     if (transferToAddress is null)
     {
         throw new ArgumentNullException(nameof(transferToAddress), "Transfer address is missing. Please check that it is not null.");
     }
     ContractID        = new ContractID(contractToDelete);
     TransferAccountID = new AccountID(transferToAddress);
 }
Exemplo n.º 5
0
    public void CanCreateContractEndorsementFromProtobufContractKeyType()
    {
        var contract   = new Address(Generator.Integer(0, 100), Generator.Integer(0, 100), Generator.Integer(1000, 20000));
        var contractID = new Proto.ContractID(contract);
        var key        = new Proto.Key {
            ContractID = contractID
        };
        var endorsement = key.ToEndorsement();

        Assert.Equal(KeyType.Contract, endorsement.Type);
        Assert.Empty(endorsement.List);
        Assert.Equal(0U, endorsement.RequiredCount);
        Assert.Equal(contract, endorsement.Contract);
    }
Exemplo n.º 6
0
 internal ContractUpdateTransactionBody(UpdateContractParams updateParameters) : this()
 {
     if (updateParameters is null)
     {
         throw new ArgumentNullException(nameof(updateParameters), "Contract Update Parameters argument is missing. Please check that it is not null.");
     }
     if (updateParameters.Contract is null)
     {
         throw new ArgumentNullException(nameof(updateParameters.Contract), "Contract address is missing. Please check that it is not null.");
     }
     if (updateParameters.Expiration is null &&
         updateParameters.Administrator is null &&
         updateParameters.RenewPeriod is null &&
         updateParameters.File is null &&
         updateParameters.Memo is null)
     {
         throw new ArgumentException("The Contract Updates contains no update properties, it is blank.", nameof(updateParameters));
     }
     ContractID = new ContractID(updateParameters.Contract);
     if (updateParameters.Expiration.HasValue)
     {
         ExpirationTime = new Timestamp(updateParameters.Expiration.Value);
     }
     if (!(updateParameters.Administrator is null))
     {
         AdminKey = new Key(updateParameters.Administrator);
     }
     if (updateParameters.RenewPeriod.HasValue)
     {
         AutoRenewPeriod = new Duration(updateParameters.RenewPeriod.Value);
     }
     if (!(updateParameters.File is null))
     {
         FileID = new FileID(updateParameters.File);
     }
     if (!string.IsNullOrWhiteSpace(updateParameters.Memo))
     {
         MemoWrapper = updateParameters.Memo;
     }
 }
Exemplo n.º 7
0
 internal ContractGetInfoQuery(Address contract) : this()
 {
     ContractID = new ContractID(contract);
 }
Exemplo n.º 8
0
 internal ContractGetBytecodeQuery(Address contract) : this()
 {
     ContractID = new ContractID(contract);
 }
Exemplo n.º 9
0
 internal CreateContractReceipt FillProperties(TransactionID transactionId, CreateContractReceipt receipt)
 {
     FillCommonProperties(transactionId, receipt);
     receipt.Contract = ContractID.ToAddress();
     return(receipt);
 }
Exemplo n.º 10
0
 internal Endorsement ToEndorsement()
 {
     return(KeyCase switch
     {
         KeyOneofCase.Ed25519 => new Endorsement(KeyType.Ed25519, new ReadOnlyMemory <byte>(Ed25519Util.publicKeyPrefix.Concat(Ed25519.ToByteArray()).ToArray())),
         KeyOneofCase.RSA3072 => new Endorsement(KeyType.RSA3072, RSA3072.ToByteArray()),
         KeyOneofCase.ECDSA384 => new Endorsement(KeyType.ECDSA384, ECDSA384.ToByteArray()),
         KeyOneofCase.ContractID => new Endorsement(KeyType.Contract, Abi.EncodeAddressPart(ContractID.ToAddress())),
         KeyOneofCase.ThresholdKey => ThresholdKey.Keys.Keys.Count == 0 ? Endorsement.None : new Endorsement(ThresholdKey.Threshold, ThresholdKey.Keys.ToEndorsements()),
         KeyOneofCase.KeyList => KeyList.Keys.Count == 0 ? Endorsement.None : new Endorsement(KeyList.ToEndorsements()),
         _ => throw new InvalidOperationException($"Unknown Key Type {KeyCase}.  Do we have a network/library version mismatch?"),
     });
Exemplo n.º 11
0
 internal ContractGetRecordsQuery(Address contract) : this()
 {
     ContractID = new ContractID(contract);
 }