Esempio n. 1
0
        public VakacoinRpc(string endPointUrl, string chainId = null)
        {
            try
            {
                EndPointUrl = endPointUrl;

                var vakaConfig = new VakaConfigurator()
                {
                    HttpEndpoint = EndPointUrl,
                };
                DefaultApi = new VakaApi(vakaConfig);

                if (string.IsNullOrEmpty(chainId))
                {
                    var getInfoResult = DefaultApi.GetInfo().Result;
                    chainId = getInfoResult.ChainId;
                }

                ChainId = chainId;
                DefaultApi.Config.ChainId = ChainId;
            }
            catch (Exception e)
            {
                Logger.Error(e);
                throw;
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Client wrapper to interact with vaka blockchains.
        /// </summary>
        /// <param name="config">Configures client parameters</param>
        public Vaka(VakaConfigurator config)
        {
            VakaConfig = config;
            if (VakaConfig == null)
            {
                throw new ArgumentNullException("config");
            }

            Api           = new VakaApi(VakaConfig);
            AbiSerializer = new AbiSerializationProvider(Api);
        }
        public AbiSerializationProvider(VakaApi api)
        {
            Api = api;

            TypeWriters = new Dictionary <string, Action <MemoryStream, object> >()
            {
                { "int8", WriteByte },
                { "uint8", WriteByte },
                { "int16", WriteUint16 },
                { "uint16", WriteUint16 },
                { "int32", WriteUint32 },
                { "uint32", WriteUint32 },
                { "int64", WriteInt64 },
                { "uint64", WriteUint64 },
                { "int128", WriteInt128 },
                { "uint128", WriteUInt128 },
                { "varuint32", WriteVarUint32 },
                { "varint32", WriteVarInt32 },
                { "float32", WriteFloat32 },
                { "float64", WriteFloat64 },
                { "float128", WriteFloat128 },
                { "bytes", WriteBytes },
                { "bool", WriteBool },
                { "string", WriteString },
                { "name", WriteName },
                { "asset", WriteAsset },
                { "time_point", WriteTimePoint },
                { "time_point_sec", WriteTimePointSec },
                { "block_timestamp_type", WriteBlockTimestampType },
                { "symbol_code", WriteSymbolCode },
                { "symbol", WriteSymbolString },
                { "checksum160", WriteChecksum160 },
                { "checksum256", WriteChecksum256 },
                { "checksum512", WriteChecksum512 },
                { "public_key", WritePublicKey },
                { "private_key", WritePrivateKey },
                { "signature", WriteSignature },
                { "extended_asset", WriteExtendedAsset }
            };

            TypeReaders = new Dictionary <string, ReaderDelegate>()
            {
                { "int8", ReadByte },
                { "uint8", ReadByte },
                { "int16", ReadUint16 },
                { "uint16", ReadUint16 },
                { "int32", ReadUint32 },
                { "uint32", ReadUint32 },
                { "int64", ReadInt64 },
                { "uint64", ReadUint64 },
                { "int128", ReadInt128 },
                { "uint128", ReadUInt128 },
                { "varuint32", ReadVarUint32 },
                { "varint32", ReadVarInt32 },
                { "float32", ReadFloat32 },
                { "float64", ReadFloat64 },
                { "float128", ReadFloat128 },
                { "bytes", ReadBytes },
                { "bool", ReadBool },
                { "string", ReadString },
                { "name", ReadName },
                { "asset", ReadAsset },
                { "time_point", ReadTimePoint },
                { "time_point_sec", ReadTimePointSec },
                { "block_timestamp_type", ReadBlockTimestampType },
                { "symbol_code", ReadSymbolCode },
                { "symbol", ReadSymbolString },
                { "checksum160", ReadChecksum160 },
                { "checksum256", ReadChecksum256 },
                { "checksum512", ReadChecksum512 },
                { "public_key", ReadPublicKey },
                { "private_key", ReadPrivateKey },
                { "signature", ReadSignature },
                { "extended_asset", ReadExtendedAsset }
            };
        }