Beispiel #1
0
        public async Task RetrieveContractAddressOfContractOwner()
        {
            ContractCall contractCall = new ContractCall(opts);
            var          result       = await contractCall.GetContractAddressAsync();

            Assert.Equal("0x08564660169a2559492ef1315fd2fbd17bf84d54", result);
        }
Beispiel #2
0
        private async Task resolveContents(ContractCall call)
        {
            NukeESI.ESIClass        esi      = new ESIClass();
            List <ContractContents> contents = await esi.pullContract(call.contract_id).ConfigureAwait(false);

            this.contents = contents;
        }
Beispiel #3
0
 protected QueryHandlerBase(IEthCall ethCall, string defaultAddressFrom = null, BlockParameter defaultBlockParameter = null)
 {
     EthCall               = ethCall;
     DefaultAddressFrom    = defaultAddressFrom;
     DefaultBlockParameter = defaultBlockParameter ?? BlockParameter.CreateLatest();
     _contractCall         = new ContractCall(EthCall, DefaultBlockParameter);
 }
Beispiel #4
0
        private async Task resolveStructure(ContractCall call)
        {
            NukeESI.ESIClass esi  = new ESIClass();
            ESIStructure     stat = await esi.pullStructure(call.start_location_id).ConfigureAwait(false);

            station = stat;
        }
Beispiel #5
0
        public async Task RetrieveTotalSupplyOfTokens()
        {
            ContractCall contractCall = new ContractCall(opts);
            var          result       = await contractCall.GetTotalSupplyAsync();

            Assert.True(result > 0);
        }
Beispiel #6
0
 public static ContractCallResult DeployContractInfo(ContractCall contractCall)
 {
     if (contractCall == null)
     {
         throw ClientArgumentException.Exception("contract call object is null");
     }
     return(SendPostRequest <ContractCallResult>(Path.PostDeployContractPath, null, null, contractCall));
 }
Beispiel #7
0
        public async Task RetrieveUserAccountMarginBalance()
        {
            string       user         = "******";
            ContractCall contractCall = new ContractCall(opts);
            var          result       = await contractCall.GetUserMarginBalanceAsync(user);

            Assert.True(result > 0);
        }
Beispiel #8
0
        public async Task RetrieveUserAccountBalance()
        {
            string       user         = "******";
            ContractCall contractCall = new ContractCall(opts);
            var          result       = await contractCall.GetUserBalanceAsync(user);

            Assert.True(result > 0);
        }
Beispiel #9
0
        public static ContractCallResult CallContract(ContractCall call, Address contractAddress, Revision revision)
        {
            var currentRevision = revision ?? Revision.BEST;

            var uriParams = Parameters(new string[] { "address" },
                                       new string[] { contractAddress.ToHexString(Prefix.ZeroLowerX) });
            var queryParams = Parameters(new string[] { "revision" },
                                         new string[] { currentRevision.ToString() });

            return(SendPostRequest <ContractCallResult>(Path.PostContractCallPath, uriParams, queryParams, call));
        }
Beispiel #10
0
        public async Task SendFiftyTokensFromUserBackToBalance()
        {
            ContractCall contractCall = new ContractCall(opts);
            var          result       = await contractCall.TransferMargin(RopstenAccount.Chris, RopstenAccount.Chris, 50, (int)MarginMove.MarginToBalance, opts.GasAmount);

            var result2 = await contractCall.TransferMargin(RopstenAccount.Mark, RopstenAccount.Chris, 50, (int)MarginMove.MarginToBalance, opts.GasAmount);

            var balance = await contractCall.GetUserBalanceAsync(RopstenAccount.Chris);

            Assert.True(balance == 1000);
        }
Beispiel #11
0
        public async Task SendOneHundredTokensFromUserMarginToBalance()
        {
            ContractCall contractCall = new ContractCall(opts);
            var          result       = await contractCall.TransferMargin(RopstenAccount.Chris, RopstenAccount.Chris, 100, (int)MarginMove.MarginToBalance, opts.GasAmount);

            var swayBal = await contractCall.GetUserBalanceAsync(RopstenAccount.Chris);

            var balance = await contractCall.GetUserMarginBalanceAsync(RopstenAccount.Chris);

            Assert.True(swayBal == 1000);
            Assert.True(balance == 0);
        }
Beispiel #12
0
        /// <summary>
        /// Get current sponsor from target address. </summary>
        /// <param name="target"> <seealso cref="Address"/> </param>
        /// <param name="revision"> <seealso cref="Revision"/> </param>
        /// <returns> <seealso cref="ContractCallResult"/>
        /// throw ClientIOException network error. </returns>
        public static ContractCallResult GetCurrentSponsor(Address target, Revision revision)
        {
            if (target == null)
            {
                throw ClientArgumentException.Exception("target is null");
            }
            AbiDefinition abi  = ProtoTypeContract.DefaultContract.FindAbiDefinition("currentSponsor");
            ContractCall  call = AbstractContract.BuildCall(abi,
                                                            target.ToHexString(Prefix.ZeroLowerX));

            return(CallContract(call, ProtoTypeContract.ContractAddress, revision));
        }
Beispiel #13
0
        public static ContractCall BuildCall(string caller, AbiDefinition definition, params object[] hexParameters)
        {
            if (definition == null)
            {
                throw new InvalidArgumentException("definition is null");
            }
            string data         = BuildData(definition, hexParameters);
            var    contractCall = new ContractCall();

            contractCall.Data   = data;
            contractCall.Value  = "0x0";
            contractCall.Caller = caller;
            return(contractCall);
        }
Beispiel #14
0
        public async Task SendOneHundredTokensFromUserMarginToMargin()
        {
            ContractCall contractCall = new ContractCall(opts);
            var          result       = await contractCall.TransferMargin(RopstenAccount.Chris, RopstenAccount.Chris, 100, (int)MarginMove.BalanceToMargin, opts.GasAmount);

            var result2 = await contractCall.TransferMargin(RopstenAccount.Chris, RopstenAccount.Mark, 50, (int)MarginMove.MarginToMargin, opts.GasAmount);

            var balance = await contractCall.GetUserMarginBalanceAsync(RopstenAccount.Chris);

            var balance2 = await contractCall.GetUserMarginBalanceAsync(RopstenAccount.Mark);

            Assert.True(balance == 50);
            Assert.True(balance2 == 50);
        }
Beispiel #15
0
        /// <summary>
        /// Get a master address from target address. </summary>
        /// <param name="target"> required <seealso cref="Address"/> target address, means transfer to address. </param>
        /// <param name="revision"> optional can be null <seealso cref="Revision"/> block revision. </param>
        /// <returns> Contract call result <seealso cref="Revision"/> </returns>
        /// <exception cref="ClientIOException"> </exception>
        public static ContractCallResult GetMasterAddress(Address target, Revision revision)
        {
            if (target == null)
            {
                throw new ArgumentNullException(nameof(target), "target is null");
            }
            AbiDefinition abi = ProtoTypeContract.DefaultContract.FindAbiDefinition("master");

            if (abi == null)
            {
                throw new ArgumentNullException(nameof(abi), "Can not find abi master method");
            }
            ContractCall call = AbstractContract.BuildCall(abi, target.ToHexString(Prefix.ZeroLowerX));

            return(CallContract(call, ProtoTypeContract.ContractAddress, revision));
        }
Beispiel #16
0
        /// <summary>
        /// Get boolean value if the sponsor address sponsored the target address. </summary>
        /// <param name="target"> required <seealso cref="Address"/> target address. </param>
        /// <param name="sponsor"> required <seealso cref="Address"/> sponsor </param>
        /// <param name="revision"> optional <seealso cref="Revision"/> block revision </param>
        /// <returns> <seealso cref="ContractCallResult"/>
        /// throw ClientIOException network error. </returns>
        public static ContractCallResult IsSponsor(Address target, Address sponsor, Revision revision)
        {
            if (target == null)
            {
                throw ClientArgumentException.Exception($"{nameof(target)} is null");
            }
            if (sponsor == null)
            {
                throw ClientArgumentException.Exception("sponsor is null");
            }
            AbiDefinition abi  = ProtoTypeContract.DefaultContract.FindAbiDefinition("isSponsor");
            ContractCall  call = AbstractContract.BuildCall(abi,
                                                            target.ToHexString(Prefix.ZeroLowerX),
                                                            sponsor.ToHexString(Prefix.ZeroLowerX));

            return(CallContract(call, ProtoTypeContract.ContractAddress, revision));
        }
Beispiel #17
0
        /// <summary>
        /// Get user credit from target address by some block revision. </summary>
        /// <param name="target"> <seealso cref="Address"/> target address. </param>
        /// <param name="user"> <seealso cref="Address"/> user address. </param>
        /// <param name="revision"> <seealso cref="Revision"/> revision. </param>
        /// <returns> <seealso cref="ContractCallResult"/> </returns>
        /// <exception cref="ClientIOException"> network error. </exception>
        public static ContractCallResult GetUserCredit(Address target, Address user, Revision revision)
        {
            if (target == null)
            {
                throw ClientArgumentException.Exception($"{nameof(target)} address is null");
            }
            if (user == null)
            {
                throw ClientArgumentException.Exception($"{nameof(user)} address is null");
            }

            AbiDefinition abi  = ProtoTypeContract.DefaultContract.FindAbiDefinition("userCredit");
            ContractCall  call = AbstractContract.BuildCall(abi,
                                                            target.ToHexString(Prefix.ZeroLowerX),
                                                            user.ToHexString(Prefix.ZeroLowerX));

            return(CallContract(call, ProtoTypeContract.ContractAddress, revision));
        }
Beispiel #18
0
 public Contract(ContractCall call, int i)
 {
     info  = call;
     index = i;
 }
Beispiel #19
0
 public async Task SendSingleTokenFromUserToUser()
 {
     ContractCall contractCall = new ContractCall(opts);
     var          result       = await contractCall.SendTokensFromAsync(RopstenAccount.Mark, RopstenAccount.Chris, .25, opts.GasAmount);
 }
Beispiel #20
0
 public async Task SendSingleTokenFromContractToUser()
 {
     ContractCall contractCall = new ContractCall(opts);
     var          result       = await contractCall.SendTokensAsync(RopstenAccount.Mark, 1.23, opts.GasAmount);
 }