Exemplo n.º 1
0
        private static ExecutionState Runtime_GetBalance(RuntimeVM vm)
        {
            vm.ExpectStackSize(2);

            var source = vm.PopAddress();
            var symbol = vm.PopString("symbol");

            var balance = vm.GetBalance(symbol, source);

            var result = new VMObject();

            result.SetValue(balance);
            vm.Stack.Push(result);

            return(ExecutionState.Running);
        }
Exemplo n.º 2
0
        private static ExecutionState Runtime_TransferBalance(RuntimeVM vm)
        {
            vm.ExpectStackSize(3);

            var source      = vm.PopAddress();
            var destination = vm.PopAddress();

            var symbol = vm.PopString("symbol");

            var token = vm.GetToken(symbol);

            vm.Expect(token.IsFungible(), "must be fungible");

            var amount = vm.GetBalance(symbol, source);

            vm.TransferTokens(symbol, source, destination, amount);

            return(ExecutionState.Running);
        }
Exemplo n.º 3
0
        private static ExecutionState Runtime_TransferBalance(RuntimeVM Runtime)
        {
            ExpectStackSize(Runtime, 3);

            VMObject temp;

            var source      = PopAddress(Runtime);
            var destination = PopAddress(Runtime);

            temp = Runtime.Stack.Pop();
            Runtime.Expect(temp.Type == VMType.String, "expected string for symbol");
            var symbol = temp.AsString();

            var token = Runtime.GetToken(symbol);

            Runtime.Expect(token.IsFungible(), "must be fungible");

            var amount = Runtime.GetBalance(symbol, source);

            Runtime.TransferTokens(symbol, source, destination, amount);

            return(ExecutionState.Running);
        }