public static bool init(byte[] _payRegistryHash, byte[] _celerWalletHash)
        {
            BasicMethods.assert(BasicMethods._isLegalAddress(_payRegistryHash), "Pay registry contract hash illegal");
            BasicMethods.assert(BasicMethods._isLegalAddress(_celerWalletHash), "celer wallet contract hash illegal");

            LedgerStruct.Ledger ledger = new LedgerStruct.Ledger();
            ledger.payRegistry = _payRegistryHash;
            ledger.celerWallet = _celerWalletHash;
            setLedger(ledger);
            LedgerBalanceLimit.enableBalanceLimitsInner();
            return(true);
        }
Exemple #2
0
 public void InputContactName(IWebElement ContactName, String contactname)
 {
     if (!string.IsNullOrEmpty(ContactPhone.Text))
     {
         BasicMethods.EnterText(ContactName, contactname);
         DriverUtils.driver.FindElement(By.XPath("//*[@id='txtSupplierContactName-list']//li[contains(text(),'Usha D')]")).Click();
     }
     else
     {
         BasicMethods.EnterText(ContactName, contactname);
     }
 }
        public static bool refreshRouter(byte[] invoker)
        {
            BasicMethods.assert(BasicMethods._isLegalAddress(invoker), "invoker is illegal");
            BasicMethods.assert(Runtime.CheckWitness(invoker), "Checkwitness failed");
            BasicMethods.assert(Storage.Get(Storage.CurrentContext, routerInfoPrefix.Concat(invoker)).AsBigInteger() != 0, "Router address does not exist");
            Storage.Put(Storage.CurrentContext, routerInfoPrefix.Concat(invoker), Blockchain.GetHeight());

            RouterOperation operation = getRouterOperation();

            RouterUpdated(operation.Refresh, invoker);
            return(true);
        }
        public static byte[] getProposedNewOperator(byte[] walletId)
        {
            BasicMethods.assert(BasicMethods._isByte32(walletId), "walletId illegal");
            Wallet w = new Wallet();

            byte[] walletBs = Storage.Get(Storage.CurrentContext, WalletsPrefix.Concat(walletId));
            if (walletBs.Length > 0)
            {
                w = Helper.Deserialize(walletBs) as Wallet;
            }
            return(w.theOperator);
        }
        //Transfer NEP5 for a specified addresses
        private static bool _transfer(byte[] from, byte[] to, BigInteger value)
        {
            Storage.Put(Storage.CurrentContext, BalancePrefix.Concat(from), balanceOf(from) - value);

            byte[] nep5Hash             = Storage.Get(Storage.CurrentContext, NEP5HashKey);
            DynamicCallContract dyncall = (DynamicCallContract)nep5Hash.ToDelegate();

            BasicMethods.assert((bool)dyncall("transfer", new object[] { ExecutionEngine.ExecutingScriptHash, to, value }), "transfer NEP5 token to the to as the withdrawer'd like to failed");

            Transferred(from, to, value);
            return(true);
        }
        public static object depositNEO(byte[] walletId)
        {
            BasicMethods.assert(BasicMethods._isByte32(walletId), "walletId is not byte32");
            PbEntity.TokenType token = PbEntity.getStandardTokenType();
            BigInteger         value = LedgerStruct.getTransactionValue(token.NEO, ExecutionEngine.ExecutingScriptHash);

            BasicMethods.assert(value >= 0, "amount is less than zero");
            _whenNotPaused();
            BasicMethods.assert(_updateBalance(walletId, LedgerStruct.NeoAddress, value, getStandardMathOperation().add), "updateBalance failed");

            DepositToWallet(walletId, LedgerStruct.NeoAddress, value);
            return(true);
        }
        private static void _changeOperator(byte[] _walletId, byte[] _newOperator)
        {
            BasicMethods.assert(BasicMethods._isLegalAddress(_newOperator), "new operator is illegal");
            Wallet w = getWallet(_walletId);

            byte[] oldOperator = w.theOperator;
            BasicMethods.assert(BasicMethods._isLegalAddress(oldOperator), "old operator is not legal");

            w.theOperator = _newOperator;

            Storage.Put(Storage.CurrentContext, WalletsPrefix.Concat(_walletId), Helper.Serialize(w));
            ChangeOperator(_walletId, oldOperator, _newOperator);
        }
    public static LedgerStruct.Channel _addWithdrawal(LedgerStruct.Channel _c, byte[] _receiver, BigInteger _amount)
    {
        BasicMethods.assert(BasicMethods._isLegalAddress(_receiver), "_receiver is illegal");
        BasicMethods.assert(_amount >= 0, "_amount is negative");
        byte rid = _getPeerId(_c, _receiver);

        LedgerStruct.PeerProfile[] peerProfiles = _c.peerProfiles;
        LedgerStruct.PeerProfile   peerProfile  = peerProfiles[rid];
        peerProfile.withdrawal = peerProfile.withdrawal + _amount;
        peerProfiles[rid]      = peerProfile;
        BasicMethods.assert(getTotalBalanceInner(_c) >= 0, "Total balance is negative");
        return(_c);
    }
Exemple #9
0
        public void ActiveUserTest()
        {
            test = extent.CreateTest(TestContext.CurrentContext.Test.Name, "ActiveUserTest");
            var LoginPage  = new LoginPage();
            var ManageUser = new ManageUsersPage();
            var HomePage   = new HomePage();

            LoginPage.Login(LoginPage.UserName, "*****@*****.**", LoginPage.Password, "July012018", LoginPage.LoginInBtn, LoginPage.Last10RequestsTitle);
            ManageUser.IsActiveUserTrueTest("durga", ManageUser.UserEmailTextBox, "*****@*****.**");
            Validations.validateTitle("Manage Users - Chemical Ordering Tool");
            BasicMethods.ClickBtn(HomePage.LogOffBtn);
            LoginPage.Login(LoginPage.UserName, "*****@*****.**", LoginPage.Password, "Lost4now", LoginPage.LoginInBtn, LoginPage.Last10RequestsTitle);
        }
        public static object setPayDeadlines(byte[][] invokers, byte[][] payHashs, BigInteger[] deadlines)
        {
            BigInteger arrayLen = invokers.Length;

            BasicMethods.assert(arrayLen == payHashs.Length, "length does not match");
            BasicMethods.assert(arrayLen == deadlines.Length, "length does not match");

            for (var i = 0; i < arrayLen; i++)
            {
                BasicMethods.assert((bool)setPayDeadline(invokers[i], payHashs[i], deadlines[i]), "error");
            }
            return(true);
        }
        public static BigInteger getBalance(byte[] walletId, byte[] tokenAddress)
        {
            BasicMethods.assert(BasicMethods._isByte32(walletId), "walletId illegal");
            BasicMethods.assert(BasicMethods._isLegalAddress(tokenAddress), "tokenAddress is illegal");
            byte[] wBalanceBs = Storage.Get(Storage.CurrentContext, WalletsPrefix.Concat(WalletsBalancesPrefix).Concat(walletId));
            Map <byte[], BigInteger> wBalanceMap = Helper.Deserialize(wBalanceBs) as Map <byte[], BigInteger>;

            if (wBalanceMap.HasKey(tokenAddress))
            {
                return(wBalanceMap[tokenAddress]);
            }
            return(0);
        }
        public static object increaseAllowance(byte[] owner, byte[] spender, BigInteger addValue)
        {
            BasicMethods.assert(BasicMethods._isLegalAddress(owner), "owner address is illegal");
            BasicMethods.assert(BasicMethods._isLegalAddress(spender), "spender address is illegal");
            BasicMethods.assert(addValue >= 0, "addValue is less than zero");

            BasicMethods.assert(Runtime.CheckWitness(owner), "Checkwitness failed");

            Storage.Put(Storage.CurrentContext, ApprovePrefix.Concat(owner).Concat(spender), allowance(owner, spender) + addValue);

            Approved(owner, spender, allowance(owner, spender));

            return(true);
        }
Exemple #13
0
        public void Testcase2()
        {
            test = extent.CreateTest(TestContext.CurrentContext.Test.Name, "Test Hide/Show functionality");
            var LoginPage    = new LoginPage();
            var ManageOrders = new ManageOrdersPage();

            LoginPage.Login(LoginPage.UserName, "*****@*****.**", LoginPage.Password, "July012018", LoginPage.LoginInBtn, LoginPage.Last10RequestsTitle);
            BasicMethods.ClickBtn(ManageOrders.ManageOrdersTab);
            BasicMethods.ClickBtn(ManageOrders.HideShowBtn);
            ManageOrders.Testcheckbox();
            //ManageOrders.HideShowFuncTest();
            // ManageOrders.HideShowFuncTest();
            Console.WriteLine("Expected text" + "\t" + ManageOrders.Table.Text);
        }
        public static bool depositInBatch(byte[][] _senders, byte[][] _channelIds, byte[][] _receivers, BigInteger[] _transferFromAmounts)
        {
            BasicMethods.assert(
                _channelIds.Length == _receivers.Length && _receivers.Length == _transferFromAmounts.Length && _transferFromAmounts.Length == _senders.Length,
                "Lengths do not match"
                );
            bool balanceLimited = LedgerBalanceLimit.getBalanceLimitsEnabledInner();

            for (int i = 0; i < _channelIds.Length; i++)
            {
                LedgerOperation.depositInner(_senders[i], getLedger(), _channelIds[i], _receivers[i], _transferFromAmounts[i], balanceLimited);
            }
            return(true);
        }
Exemple #15
0
 public void CreateUserFunc(IWebElement UserEmailTextBox, String value, IWebElement UserRole, IWebElement UserRoleOptions, int ddloption, IWebElement FirstName, String fnamevalue, IWebElement LastName, String lnamevalue, IWebElement CreateBtn)
 {
     DriverUtils.LaunchBrowser("http://cos-test.psr.rd.hpicorp.net/COSWeb/ManageUser/UserManagement");
     CreateNewUserBtn.Click();
     UserEmailTextBox.EnterText(value);
     BasicMethods.DropDownFunction(UserRole, UserRoleOptions, ddloption);
     FirstName.EnterText(fnamevalue);
     LastName.EnterText(lnamevalue);
     //IsUserActiveFlag.Click();
     //Validations.validateElementIsEnabled(CreateUserBtn);
     CreateUserBtn.Click();
     Thread.Sleep(5000);
     // CreateUserCloseBtn.Click();
 }
        public static BigInteger[] getPayInfo(byte[] payId)
        {
            BasicMethods.assert(BasicMethods._isByte32(payId), "payId invalid");
            byte[]  payInfoBs = Storage.Get(Storage.CurrentContext, PayInfoPrefix.Concat(payId));
            PayInfo payInfo   = new PayInfo();

            if (payInfoBs.Length > 0)
            {
                payInfo = Helper.Deserialize(payInfoBs) as PayInfo;
            }
            return(new BigInteger[2] {
                payInfo.amount, payInfo.resolveDeadline
            });
        }
Exemple #17
0
        public void EmailFieldErrorValidation()
        {
            test = extent.CreateTest(TestContext.CurrentContext.Test.Name, "Error validation in email field in create user popup message");
            var LoginPage  = new LoginPage();
            var ManageUser = new ManageUsersPage();

            LoginPage.Login(LoginPage.UserName, "*****@*****.**", LoginPage.Password, "July012018", LoginPage.LoginInBtn, LoginPage.Last10RequestsTitle);
            ManageUser.CreateUserFunc(ManageUser.UserEmailTextBox, "!@#$%^&*()", ManageUser.UserRole, ManageUser.UserRoleOptions, 1, ManageUser.FirstNameField, "Kumaresh", ManageUser.LastNameField, "Govindan", ManageUser.CreateUserBtn);
            BasicMethods.VerifyText(ManageUser.userEmailErrorMsg, "Please provide a valid email address");
            ManageUser.CreateUserFunc(ManageUser.UserEmailTextBox, "*****@*****.**", ManageUser.UserRole, ManageUser.UserRoleOptions, 1, ManageUser.FirstNameField, "Kumaresh", ManageUser.LastNameField, "Govindan", ManageUser.CreateUserBtn);
            BasicMethods.VerifyText(ManageUser.userEmailErrorMsg, "Please enter a valid HP Email Id.");
            ManageUser.CreateUserFunc(ManageUser.UserEmailTextBox, "*****@*****.**", ManageUser.UserRole, ManageUser.UserRoleOptions, 1, ManageUser.FirstNameField, "Kumaresh", ManageUser.LastNameField, "Govindan", ManageUser.CreateUserBtn);
            BasicMethods.VerifyText(ManageUser.GeneralErrorMsg, "Email is already exists.");
        }
        private static BigInteger _calculateBooleanOrPayment(PbEntity.ConditionalPay _pay, byte[][] _preimages)
        {
            int  j = 0;
            bool hasContractCond     = false;
            bool hasTrueContractCond = false;

            PbEntity.ConditionType ConditionType = PbEntity.getConditionType();
            PbEntity.Condition[]   conditions    = _pay.conditions;
            for (var i = 0; i < conditions.Length; i++)
            {
                PbEntity.Condition cond = _pay.conditions[i];
                if (cond.conditionType == ConditionType.HASH_LOCK)
                {
                    BasicMethods.assert(SmartContract.Sha256(_preimages[j]) == cond.hashLock, "wrong preimage");
                    j++;
                }
                else if (
                    cond.conditionType == ConditionType.DEPLOYED_CONTRACT ||
                    cond.conditionType == ConditionType.VIRTUAL_CONTRACT
                    )
                {
                    byte[] booleanCondHash      = _getCondAddress(cond);
                    DynamicCallContract dyncall = (DynamicCallContract)booleanCondHash.ToDelegate();
                    BasicMethods.assert((bool)dyncall("isFinalized", new object[] { cond.argsQueryFinalization }), "Condition is not finalized");
                    hasContractCond = true;

                    bool outcome = (bool)dyncall("getOutcome", new object[] { cond.argsQueryOutcome });
                    if (outcome)
                    {
                        hasTrueContractCond = true;
                    }
                }
                else
                {
                    BasicMethods.assert(false, "condition type error");
                }
            }
            if (!hasContractCond || hasTrueContractCond)
            {
                PbEntity.TransferFunction transferFunction = _pay.transferFunc;
                PbEntity.TokenTransfer    tokenTransfer    = transferFunction.maxTransfer;
                PbEntity.AccountAmtPair   accountAmtPair   = tokenTransfer.receiver;
                return(accountAmtPair.amt);
            }
            else
            {
                return(0);
            }
        }
 public static Object Main(string operation, params object[] args)
 {
     if (Runtime.Trigger == TriggerType.Verification)
     {
         return(true);
     }
     else if (Runtime.Trigger == TriggerType.Application)
     {
         if (operation == "init")
         {
             return(init());
         }
         if (operation == "symbol")
         {
             return(symbol());
         }
         if (operation == "name")
         {
             return(name());
         }
         if (operation == "decimals")
         {
             return(decimals());
         }
         if (operation == "totalSupply")
         {
             return(totalSupply());
         }
         if (operation == "balanceOf")
         {
             BasicMethods.assert(args.Length == 1, "NEP5 parameter error");
             byte[] address = (byte[])args[0];
             return(balanceOf(address));
         }
         if (operation == "transfer")
         {
             BasicMethods.assert(args.Length == 3, "NEP5 parameter error");
             byte[]     from   = (byte[])args[0];
             byte[]     to     = (byte[])args[1];
             BigInteger amount = (BigInteger)args[2];
             return(transfer(from, to, amount));
         }
         if (operation == "transferMulti")
         {
             return(transferMulti(args));
         }
     }
     return(false);
 }
    public static SimplexPaymentChannel decSimplexPaymentChannel(byte[] raw)
    {
        SimplexPaymentChannel spc = new SimplexPaymentChannel();
        int seek = 0;
        int len  = 0;

        len   = (int)(raw.Range(seek, 2).AsBigInteger());
        seek += 2;
        BasicMethods.assert(len == 32, "channelId should be 32 bytes");
        spc.channelId = raw.Range(seek, len);
        seek         += len;

        len   = (int)raw.Range(seek, 2).AsBigInteger();
        seek += 2;
        BasicMethods.assert(BasicMethods._isLegalLength(len), "peerFrom illegal");
        spc.peerFrom = raw.Range(seek, len);
        seek        += len;

        len = (int)raw.Range(seek, 2).AsBigInteger();
        BasicMethods.assert(len >= 0, "seqNum illegal");
        seek      += 2;
        spc.seqNum = raw.Range(seek, len).AsBigInteger();
        seek      += len;

        len   = (int)raw.Range(seek, 2).AsBigInteger();
        seek += 2;
        spc.transferToPeer = decTokenTransfer(raw.Range(seek, len));
        seek += len;

        len   = (int)raw.Range(seek, 2).AsBigInteger();
        seek += 2;
        spc.pendingPayIds = decPayIdList(raw.Range(seek, len));
        seek += len;

        len = (int)raw.Range(seek, 2).AsBigInteger();
        BasicMethods.assert(len >= 0, "lastPayResolveDeadline illegal");
        seek += 2;
        spc.lastPayResolveDeadline = raw.Range(seek, len).AsBigInteger();
        seek += len;

        len = (int)raw.Range(seek, 2).AsBigInteger();
        BasicMethods.assert(len >= 0, "totalPendingAmount illegal");
        seek += 2;
        spc.totalPendingAmount = raw.Range(seek, len).AsBigInteger();
        seek += len;

        BasicMethods.assert(raw.Length == seek, "decSimplexPaymentChannel raw data illegal");
        return(spc);
    }
        public static object drainToken(byte[] invoker, byte[] tokenAddress, byte[] receiver, BigInteger amount)
        {
            BasicMethods.assert(Runtime.CheckWitness(invoker), "CheckWitness failed");
            BasicMethods.assert(BasicMethods._isLegalAddress(tokenAddress), "tokenAddress is illegal");
            BasicMethods.assert(BasicMethods._isLegalAddress(receiver), "receiver address is illegal");
            BasicMethods.assert(amount >= 0, "amount is less than zero");

            _whenPaused();
            _onlyPauser(invoker);

            BasicMethods.assert(_withdrawToken(tokenAddress, receiver, amount), "withdrawToken failed");

            DrainToken(tokenAddress, receiver, amount);
            return(true);
        }
Exemple #22
0
        public void TestThirdPartyToolsLink(IWebElement element, string title)
        {
            string BaseWindow = DriverUtils.driver.CurrentWindowHandle;

            BasicMethods.ClickBtn(element);
            //switch to new window.
            DriverUtils.driver.SwitchTo().Window(DriverUtils.driver.WindowHandles.Last());
            Thread.Sleep(3000);
            DriverUtils.driver.Manage().Window.Maximize();
            Validations.validateTitle(title);
            DriverUtils.driver.Close();
            //if you want to switch back to your first window
            DriverUtils.driver.SwitchTo().Window(DriverUtils.driver.WindowHandles.First());
            Console.WriteLine("In home page now");
        }
Exemple #23
0
        public void LastNameFieldErrorValidation()
        {
            test = extent.CreateTest(TestContext.CurrentContext.Test.Name, "Error validation in lastname field in create user popup message");
            var LoginPage  = new LoginPage();
            var ManageUser = new ManageUsersPage();

            LoginPage.Login(LoginPage.UserName, "*****@*****.**", LoginPage.Password, "July012018", LoginPage.LoginInBtn, LoginPage.Last10RequestsTitle);
            ManageUser.CreateUserFunc(ManageUser.UserEmailTextBox, "*****@*****.**", ManageUser.UserRole, ManageUser.UserRoleOptions, 1, ManageUser.FirstNameField, "Kumaresh", ManageUser.LastNameField, "", ManageUser.CreateUserBtn);
            BasicMethods.VerifyText(ManageUser.lastnameerrormsg, "Last Name should not be empty.");
            ManageUser.CreateUserFunc(ManageUser.UserEmailTextBox, "*****@*****.**", ManageUser.UserRole, ManageUser.UserRoleOptions, 1, ManageUser.FirstNameField, "Kumaresh", ManageUser.LastNameField, "$$$$@#@", ManageUser.CreateUserBtn);
            BasicMethods.VerifyText(ManageUser.lastnameerrormsg, "Last Name should not contain anything except letters and spaces.");
            ManageUser.CreateUserFunc(ManageUser.UserEmailTextBox, "*****@*****.**", ManageUser.UserRole, ManageUser.UserRoleOptions, 1, ManageUser.FirstNameField, "Kumaresh", ManageUser.LastNameField, "*****", ManageUser.CreateUserBtn);
            BasicMethods.VerifyText(ManageUser.userEmailErrorMsg, "Please enter a valid HP Email Id.");
            BasicMethods.VerifyText(ManageUser.lastnameerrormsg, "Last Name should not contain anything except letters and spaces.");
        }
        public static object init(byte[] reversedNEP5Hash, BigInteger decimals, byte[] reversedCelerWalletHash)
        {
            BasicMethods.assert(BasicMethods._isLegalAddress(reversedNEP5Hash), "nep5 contract hash illegal");
            BasicMethods.assert(decimals >= 0, "decimals is less than 0");
            BasicMethods.assert(BasicMethods._isLegalAddress(reversedCelerWalletHash), "celer wallet contract hash illegal");

            BasicMethods.assert(Runtime.CheckWitness(Admin), "is not initialized by admin");

            Storage.Put(Storage.CurrentContext, NEP5HashKey, reversedNEP5Hash);
            Storage.Put(Storage.CurrentContext, DecimalsKey, decimals);
            Storage.Put(Storage.CurrentContext, CelerWalletHashKey, reversedCelerWalletHash);

            //TODO notify the event
            return(true);
        }
Exemple #25
0
        public void InActiveUserTest()
        {
            test = extent.CreateTest(TestContext.CurrentContext.Test.Name, "Inactive user test");
            var LoginPage  = new LoginPage();
            var ManageUser = new ManageUsersPage();
            var HomePage   = new HomePage();

            LoginPage.Login(LoginPage.UserName, "*****@*****.**", LoginPage.Password, "July012018", LoginPage.LoginInBtn, LoginPage.Last10RequestsTitle);
            ManageUser.IsActiveUserFalseTest("durga", ManageUser.UserEmailTextBox, "*****@*****.**");
            Validations.validateTitle("Manage Users - Chemical Ordering Tool");
            BasicMethods.ClickBtn(HomePage.LogOffBtn);
            LoginPage.Login(LoginPage.UserName, "*****@*****.**", LoginPage.Password, "Lost4now", LoginPage.LoginInBtn, LoginPage.Welcometitle);
            BasicMethods.VerifyText(LoginPage.BlankErrorMsg, "Sorry, you are not an active user for this website.");
            LoginPage.Login(LoginPage.UserName, "*****@*****.**", LoginPage.Password, "July012018", LoginPage.LoginInBtn, LoginPage.Last10RequestsTitle);
            ManageUser.IsActiveUserTrueTest("durga", ManageUser.UserEmailTextBox, "*****@*****.**");
        }
Exemple #26
0
        public void BlankValuesTest()
        {
            test = extent.CreateTest(TestContext.CurrentContext.Test.Name, "Test error messages with blank values in create user popup message");
            var LoginPage  = new LoginPage();
            var ManageUser = new ManageUsersPage();

            LoginPage.Login(LoginPage.UserName, "*****@*****.**", LoginPage.Password, "July012018", LoginPage.LoginInBtn, LoginPage.Last10RequestsTitle);
            ManageUser.SelectManageUsersTab();
            Validations.validateTitle("Manage Users - Chemical Ordering Tool");
            ManageUser.CreateNewUserBtn.Click();
            ManageUser.CreateUserBtn.Click();
            BasicMethods.VerifyText(ManageUser.userEmailErrorMsg, "Email should not be empty.");
            BasicMethods.VerifyText(ManageUser.firstnameerrormsg, "First Name should not be empty.");
            BasicMethods.VerifyText(ManageUser.lastnameerrormsg, "Last Name should not be empty.");
            ManageUser.CreateUserCloseBtn.Click();
        }
    public static LedgerStruct.Channel _importChannelMigrationArgs(LedgerStruct.Channel _c, byte[] _fromLedgerAddr, byte[] _channelId)
    {
        BasicMethods.assert(BasicMethods._isLegalAddress(_fromLedgerAddr), "invalid contract address");
        BasicMethods.assert(BasicMethods._isByte32(_channelId), "invalid _channelId");

        DynamicCallContract dyncall = (DynamicCallContract)_fromLedgerAddr.ToDelegate();

        LedgerStruct.ChannelMigrationArgs args = (LedgerStruct.ChannelMigrationArgs)dyncall("getChannelMigrationArgs", new object[] { _channelId });
        _c.disputeTimeout = args.disputeTimeout;
        PbEntity.TokenInfo token = new PbEntity.TokenInfo();
        token.tokenType = args.tokenType;
        token.address   = args.tokenAddress;
        _c.token        = token;
        _c.cooperativeWithdrawSeqNum = args.cooperativeWithdrawSeqNum;
        return(_c);
    }
        public static object withdraw(byte[] withdrawer, BigInteger value)
        {
            BasicMethods.assert(BasicMethods._isLegalAddress(withdrawer), "withdrawer address is illegal");
            BasicMethods.assert(value >= 0, "amount is less than zero");

            BasicMethods.assert(Runtime.CheckWitness(withdrawer), "Checkwitness failed");

            byte[] nep5Hash             = Storage.Get(Storage.CurrentContext, NEP5HashKey);
            DynamicCallContract dyncall = (DynamicCallContract)nep5Hash.ToDelegate();

            BasicMethods.assert((BigInteger)dyncall("balanceOf", new object[] { ExecutionEngine.ExecutingScriptHash }) >= value, "the contract accout nep5 balance not enough");
            BasicMethods.assert(balanceOf(withdrawer) >= value, "withdrawer does not have enough balance");

            BasicMethods.assert(_transfer(withdrawer, withdrawer, value), "withdraw nep5 token failed");
            return(true);
        }
        public static bool getProposalVote(byte[] walletId, byte[] owner)
        {
            BasicMethods.assert(BasicMethods._isByte32(walletId), "walletId illegal");
            BasicMethods.assert(BasicMethods._isLegalAddress(owner), "owner address is not length of 20 bytes");
            _onlyWalletOwner(walletId, owner);
            // wpvBs means Wallet Proposal Votes ByteS
            byte[]             wpvBs = Storage.Get(Storage.CurrentContext, WalletsProposalVotesPrefix.Concat(walletId));
            Map <byte[], bool> wpv   = new Map <byte[], bool>();

            if (wpvBs.Length > 0)
            {
                wpv = Helper.Deserialize(wpvBs) as Map <byte[], bool>;
                return(wpv[owner]);
            }
            return(false);
        }
        public static object approve(byte[] owner, byte[] spender, BigInteger value)
        {
            BasicMethods.assert(BasicMethods._isLegalAddress(owner), "owner address is illegal");
            BasicMethods.assert(BasicMethods._isLegalAddress(spender), "spender address is illegal");
            BasicMethods.assert(value >= 0, "amount is less than zero");

            BasicMethods.assert(Runtime.CheckWitness(owner), "Checkwitness failed");

            BasicMethods.assert(value <= balanceOf(owner), "value is greater than balance of owner");

            Storage.Put(Storage.CurrentContext, ApprovePrefix.Concat(owner).Concat(spender), value);

            Approved(owner, spender, value);

            return(true);
        }