コード例 #1
0
        public async Task Pausable_Feature_Test()
        {
            EthNetwork.UseDefaultTestNet();

            var ownerAccount   = new Account(EthNetwork.Instance.PrefundedPrivateKey);
            var holderAccount1 = EthAccountFactory.Create();

            // Create the ERC20 token...
            var contract = new AlgoTokenV1(EthNetwork.Instance.GetWeb3(ownerAccount), EthNetwork.Instance.GasPriceProvider);
            await contract.DeployAsync();

            // Perform a transfer and check the result...
            await contract.TransferAsync(holderAccount1.Address, 2.Algo());

            Assert.Equal(2.Algo(), await contract.BalanceOfAsync(holderAccount1.Address));

            // Pause the contract...
            await contract.PauseAsync();

            // Ensure the contract cannot be used while is in paused state...
            await Assert.ThrowsAsync <TransactionRejectedException>(
                () => contract.TransferAsync(holderAccount1.Address, 2.Algo()));

            // Ensure the balance was not modified...
            Assert.Equal(2.Algo(), await contract.BalanceOfAsync(holderAccount1.Address));

            // Unpause the contract...
            await contract.UnpauseAsync();

            // Try a new transfer and ensure it succeeded...
            await contract.TransferAsync(holderAccount1.Address, 2.Algo());

            Assert.Equal(4.Algo(), await contract.BalanceOfAsync(holderAccount1.Address));
        }
コード例 #2
0
        protected override Task <TransactionReceipt> ExecuteAsync(RuntimeContext context, string contractAddress, Web3 web3)
        {
            var algoToken = new AlgoTokenV1(contractAddress, web3, context.GasPriceProvider);

            return(algoToken.UnpauseAsync());
        }