Exemplo n.º 1
0
        public byte[] ToByteArray()
        {
            using (var ms = new MemoryStream())
            {
                using (var writer = new NearBinaryWriter(ms))
                {
                    if (Allowance == null)
                    {
                        writer.Write((byte)0);
                    }
                    else
                    {
                        writer.Write((byte)1);
                        writer.Write((UInt128)Allowance);
                    }

                    writer.Write(ReceiverId);

                    writer.Write((uint)MethodNames.Length);

                    foreach (var mn in MethodNames)
                    {
                        writer.Write(mn);
                    }

                    return(ms.ToArray());
                }
            }
        }
Exemplo n.º 2
0
        public byte[] ToByteArray()
        {
            using (var ms = new MemoryStream())
            {
                using (var writer = new NearBinaryWriter(ms))
                {
                    switch (PermissionType)
                    {
                    case AccessKeyPermissionType.FullAccessPermission:
                    {
                        writer.Write((byte)AccessKeyPermissionType.FullAccessPermission);
                        writer.Write(FullAccess.ToByteArray());
                        return(ms.ToArray());
                    }

                    case AccessKeyPermissionType.FunctionCallPermission:
                    {
                        writer.Write((byte)AccessKeyPermissionType.FunctionCallPermission);
                        writer.Write(FunctionCall.ToByteArray());
                        return(ms.ToArray());
                    }

                    default:
                        throw new NotSupportedException("Unsupported access key permission type");
                    }
                }
            }
        }
Exemplo n.º 3
0
 public byte[] ToByteArray()
 {
     using (var ms = new MemoryStream())
     {
         using (var writer = new NearBinaryWriter(ms))
         {
             return(ms.ToArray());
         }
     }
 }
Exemplo n.º 4
0
 public byte[] ToByteArray()
 {
     using (var ms = new MemoryStream())
     {
         using (var writer = new NearBinaryWriter(ms))
         {
             writer.Write(Nonce);
             writer.Write(Permission.ToByteArray());
             return(ms.ToArray());
         }
     }
 }
Exemplo n.º 5
0
 public byte[] ToByteArray()
 {
     using (var ms = new MemoryStream())
     {
         using (var writer = new NearBinaryWriter(ms))
         {
             writer.Write(Transaction.ToByteArray());
             writer.Write(Signature.ToByteArray());
             return(ms.ToArray());
         }
     }
 }
Exemplo n.º 6
0
 public byte[] ToByteArray()
 {
     using (var ms = new MemoryStream())
     {
         using (var writer = new NearBinaryWriter(ms))
         {
             writer.Write((byte)_keyType);
             writer.Write(_data.Buffer);
             return(ms.ToArray());
         }
     }
 }
Exemplo n.º 7
0
        public byte[] ToByteArray()
        {
            using (var ms = new MemoryStream())
            {
                using (var writer = new NearBinaryWriter(ms))
                {
                    writer.Write(SignerId);
                    writer.Write(PublicKey.ToByteArray());
                    writer.Write(Nonce);
                    writer.Write(ReceiverId);
                    writer.Write(BlockHash.Buffer);

                    writer.Write((uint)Actions.Length);
                    foreach (var action in Actions)
                    {
                        writer.Write(action.ToByteArray());
                    }

                    return(ms.ToArray());
                }
            }
        }
Exemplo n.º 8
0
        public byte[] ToByteArray()
        {
            using (var ms = new MemoryStream())
            {
                using (var writer = new NearBinaryWriter(ms))
                {
                    writer.Write((byte)_type);

                    switch (_type)
                    {
                    case ActionType.AddKey:
                    {
                        writer.Write(_args.PublicKey.ToByteArray());
                        writer.Write(_args.AccessKey.ToByteArray());
                        return(ms.ToArray());
                    }

                    case ActionType.DeleteKey:
                    {
                        writer.Write(_args.PublicKey.ToByteArray());
                        return(ms.ToArray());
                    }

                    case ActionType.CreateAccount:
                    {
                        return(ms.ToArray());
                    }

                    case ActionType.DeleteAccount:
                    {
                        writer.Write((string)_args.BeneficiaryId);
                        return(ms.ToArray());
                    }

                    case ActionType.DeployContract:
                    {
                        writer.Write((uint)_args.Code.Length);
                        writer.Write((byte[])_args.Code);
                        return(ms.ToArray());
                    }

                    case ActionType.FunctionCall:
                    {
                        writer.Write((string)_args.MethodName);
                        writer.Write((uint)_args.MethodArgs.Length);
                        writer.Write((byte[])_args.MethodArgs);
                        writer.Write((ulong)_args.Gas);
                        writer.Write((UInt128)_args.Deposit);
                        return(ms.ToArray());
                    }

                    case ActionType.Stake:
                    {
                        writer.Write((UInt128)_args.Stake);
                        writer.Write(_args.PublicKey.ToByteArray());
                        return(ms.ToArray());
                    }

                    case ActionType.Transfer:
                    {
                        writer.Write((UInt128)_args.Deposit);
                        return(ms.ToArray());
                    }

                    default:
                        throw new NotSupportedException("Unsupported action type");
                    }
                }
            }
        }