Tue Sep 3 09:01:40 CST 2019 Source Update...
This commit is contained in:
		@@ -973,7 +973,7 @@ class AccountApp extends require("./dapp")
 | 
			
		||||
        var Count = 0;
 | 
			
		||||
        for(var num = 0; true; num++)
 | 
			
		||||
        {
 | 
			
		||||
            if(this.IsHole(num) || HiddenMap[num] !== undefined)
 | 
			
		||||
            if(this.IsHole(num) || (HiddenMap && HiddenMap[num] !== undefined))
 | 
			
		||||
                continue;
 | 
			
		||||
            var Data = this.ReadState(num);
 | 
			
		||||
            if(!Data)
 | 
			
		||||
@@ -1002,7 +1002,9 @@ class AccountApp extends require("./dapp")
 | 
			
		||||
                Data.WN = map[key]
 | 
			
		||||
                Data.Name = NormalizeName(Data.Name)
 | 
			
		||||
                if(Data.Currency)
 | 
			
		||||
                    Data.CurrencyObj = DApps.Smart.ReadSimple(Data.Currency)
 | 
			
		||||
                {
 | 
			
		||||
                    Data.CurrencyObj = DApps.Smart.ReadSimple(Data.Currency, 1)
 | 
			
		||||
                }
 | 
			
		||||
                if(Data.Value.Smart)
 | 
			
		||||
                {
 | 
			
		||||
                    Data.SmartObj = DApps.Smart.ReadSimple(Data.Value.Smart)
 | 
			
		||||
@@ -1093,7 +1095,7 @@ class AccountApp extends require("./dapp")
 | 
			
		||||
            if(bGetState)
 | 
			
		||||
            {
 | 
			
		||||
                if(Data.Currency)
 | 
			
		||||
                    Data.CurrencyObj = DApps.Smart.ReadSimple(Data.Currency)
 | 
			
		||||
                    Data.CurrencyObj = DApps.Smart.ReadSimple(Data.Currency, 1)
 | 
			
		||||
                if(Data.Value.Smart)
 | 
			
		||||
                {
 | 
			
		||||
                    Data.SmartObj = DApps.Smart.ReadSimple(Data.Value.Smart)
 | 
			
		||||
 
 | 
			
		||||
@@ -28,7 +28,9 @@ global.FORMAT_SMART_CREATE = "{\
 | 
			
		||||
    Category1:byte,\
 | 
			
		||||
    Category2:byte,\
 | 
			
		||||
    Category3:byte,\
 | 
			
		||||
    Reserve:arr20,\
 | 
			
		||||
    Fixed:byte,\
 | 
			
		||||
    CentName:str5,\
 | 
			
		||||
    Reserve:arr14,\
 | 
			
		||||
    IconBlockNum:uint,\
 | 
			
		||||
    IconTrNum:uint16,\
 | 
			
		||||
    ShortName:str5,\
 | 
			
		||||
@@ -82,7 +84,9 @@ class SmartApp extends require("./dapp")
 | 
			
		||||
            Category2:byte,\
 | 
			
		||||
            Category3:byte,\
 | 
			
		||||
            Owner:uint,\
 | 
			
		||||
            Reserve:arr20,\
 | 
			
		||||
            Fixed:byte,\
 | 
			
		||||
            CentName:str5,\
 | 
			
		||||
            Reserve:arr14,\
 | 
			
		||||
            StateFormat:str,\
 | 
			
		||||
            Description:str,\
 | 
			
		||||
            Code:str,\
 | 
			
		||||
@@ -238,7 +242,6 @@ class SmartApp extends require("./dapp")
 | 
			
		||||
        Smart.Zip = 0
 | 
			
		||||
        Smart.BlockNum = BlockNum
 | 
			
		||||
        Smart.TrNum = TrNum
 | 
			
		||||
        Smart.Reserve = []
 | 
			
		||||
        Smart.Num = undefined
 | 
			
		||||
        Smart.Owner = ContextFrom.FromID
 | 
			
		||||
        this.DBSmart.CheckNewNum(Smart)
 | 
			
		||||
@@ -275,6 +278,10 @@ class SmartApp extends require("./dapp")
 | 
			
		||||
            this.DBSmart.DeleteMap("EVAL" + Smart.Num)
 | 
			
		||||
            return e;
 | 
			
		||||
        }
 | 
			
		||||
        if(BlockNum < global.UPDATE_CODE_2)
 | 
			
		||||
        {
 | 
			
		||||
            Smart.Reserve = []
 | 
			
		||||
        }
 | 
			
		||||
        this.DBSmartWrite(Smart)
 | 
			
		||||
        return true;
 | 
			
		||||
    }
 | 
			
		||||
@@ -502,7 +509,7 @@ class SmartApp extends require("./dapp")
 | 
			
		||||
        }
 | 
			
		||||
        return Smart;
 | 
			
		||||
    }
 | 
			
		||||
    ReadSimple(Num)
 | 
			
		||||
    ReadSimple(Num, bTokenDescription)
 | 
			
		||||
    {
 | 
			
		||||
        var Smart = this.DBSmart.GetMap("SIMPLE" + Num);
 | 
			
		||||
        if(!Smart)
 | 
			
		||||
@@ -512,14 +519,70 @@ class SmartApp extends require("./dapp")
 | 
			
		||||
            {
 | 
			
		||||
                Smart.CodeLength = Smart.Code.length
 | 
			
		||||
                Smart.HTMLLength = Smart.HTML.length
 | 
			
		||||
                Smart.Code = undefined
 | 
			
		||||
                Smart.HTML = undefined
 | 
			
		||||
                Smart.Description = undefined
 | 
			
		||||
                Object.defineProperties(Smart, {Reserve:{configurable:true, enumerable:false}})
 | 
			
		||||
                Object.defineProperties(Smart, {Code:{configurable:true, enumerable:false}})
 | 
			
		||||
                Object.defineProperties(Smart, {HTML:{configurable:true, enumerable:false}})
 | 
			
		||||
                Object.defineProperties(Smart, {Description:{configurable:true, enumerable:false}})
 | 
			
		||||
                this.DBSmart.SetMap("SIMPLE" + Num, Smart)
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        if(bTokenDescription)
 | 
			
		||||
            this.AddCurrencyTokenDescription(Smart)
 | 
			
		||||
        return Smart;
 | 
			
		||||
    }
 | 
			
		||||
    AddCurrencyTokenDescription(Smart)
 | 
			
		||||
    {
 | 
			
		||||
        if(!Smart.Num)
 | 
			
		||||
            return ;
 | 
			
		||||
        if(!this.MapTokenDescription)
 | 
			
		||||
            this.MapTokenDescription = {}
 | 
			
		||||
        var Item = this.MapTokenDescription[Smart.Num];
 | 
			
		||||
        var Time = Date.now();
 | 
			
		||||
        if(!Item)
 | 
			
		||||
        {
 | 
			
		||||
            Item = {Time:Time, Description:""}
 | 
			
		||||
            this.MapTokenDescription[Smart.Num] = Item
 | 
			
		||||
        }
 | 
			
		||||
        if(Time - Item.Time > 5 * 1000)
 | 
			
		||||
        {
 | 
			
		||||
            Item.Time = Time
 | 
			
		||||
            var Params = undefined;
 | 
			
		||||
            var BlockNum = GetCurrentBlockNumByTime();
 | 
			
		||||
            if(BlockNum < UPDATE_CODE_2)
 | 
			
		||||
            {
 | 
			
		||||
                try
 | 
			
		||||
                {
 | 
			
		||||
                    var Account = DApps.Accounts.ReadState(Smart.Account);
 | 
			
		||||
                    if(Smart.StateFormat)
 | 
			
		||||
                    {
 | 
			
		||||
                        var State = BufLib.GetObjectFromBuffer(Account.Value.Data, Smart.StateFormat, {}, 1);
 | 
			
		||||
                        Params = {State:State, PayCur:GET_SMART(DApps.Smart.ReadSmart(State.PayCurrency)), OpnCur:GET_SMART(DApps.Smart.ReadSmart(State.Currency)),
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
                catch(e)
 | 
			
		||||
                {
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            else
 | 
			
		||||
            {
 | 
			
		||||
                Params = {}
 | 
			
		||||
            }
 | 
			
		||||
            var Result;
 | 
			
		||||
            if(Params)
 | 
			
		||||
                Result = RunStaticSmartMethod(Smart.Account, "GetTokenDescription", Params)
 | 
			
		||||
            if(Result && Result.result)
 | 
			
		||||
            {
 | 
			
		||||
                Item.TokenDescription = Result.RetValue
 | 
			
		||||
            }
 | 
			
		||||
            else
 | 
			
		||||
            {
 | 
			
		||||
                Item.TokenDescription = ""
 | 
			
		||||
                Item.Time = Time + 1000 * 1000
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        Smart.TokenDescription = Item.TokenDescription
 | 
			
		||||
    }
 | 
			
		||||
    InitHole()
 | 
			
		||||
    {
 | 
			
		||||
        if(global.LOCAL_RUN || global.TEST_NETWORK)
 | 
			
		||||
@@ -628,7 +691,7 @@ function RunSmartMethod(Block,SmartOrSmartID,Account,BlockNum,TrNum,PayContext,M
 | 
			
		||||
        if(PayContext.Value)
 | 
			
		||||
            context.Value = {SumCOIN:PayContext.Value.SumCOIN, SumCENT:PayContext.Value.SumCENT};
 | 
			
		||||
    }
 | 
			
		||||
    if(BlockNum === 0)
 | 
			
		||||
    if(Block.BlockNum === 0)
 | 
			
		||||
    {
 | 
			
		||||
        context.GetBlockHeader = StaticGetBlockHeader;
 | 
			
		||||
        context.GetBlockNumDB = StaticGetBlockNumDB;
 | 
			
		||||
@@ -653,6 +716,32 @@ function RunSmartMethod(Block,SmartOrSmartID,Account,BlockNum,TrNum,PayContext,M
 | 
			
		||||
    }
 | 
			
		||||
    return RetValue;
 | 
			
		||||
};
 | 
			
		||||
var glBlock0;
 | 
			
		||||
global.RunStaticSmartMethod = RunStaticSmartMethod;
 | 
			
		||||
 | 
			
		||||
function RunStaticSmartMethod(AccountNum,MethodName,Params)
 | 
			
		||||
{
 | 
			
		||||
    DApps.Accounts.BeginBlock();
 | 
			
		||||
    DApps.Accounts.BeginTransaction();
 | 
			
		||||
    global.TickCounter = 100000;
 | 
			
		||||
    var Account = DApps.Accounts.ReadStateTR(AccountNum);
 | 
			
		||||
    if(!Account)
 | 
			
		||||
    {
 | 
			
		||||
        return {result:0, RetValue:"Error account Num: " + AccountNum};
 | 
			
		||||
    }
 | 
			
		||||
    if(!glBlock0)
 | 
			
		||||
        glBlock0 = SERVER.ReadBlockHeaderDB(0);
 | 
			
		||||
    try
 | 
			
		||||
    {
 | 
			
		||||
        var BlockNum = GetCurrentBlockNumByTime();
 | 
			
		||||
        var RetValue = RunSmartMethod(glBlock0, Account.Value.Smart, Account, BlockNum, 0, undefined, MethodName, Params, 1);
 | 
			
		||||
        return {result:1, RetValue:RetValue};
 | 
			
		||||
    }
 | 
			
		||||
    catch(e)
 | 
			
		||||
    {
 | 
			
		||||
        return {result:0, RetValue:"" + e};
 | 
			
		||||
    }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
function GET_ACCOUNT(Obj)
 | 
			
		||||
{
 | 
			
		||||
@@ -739,6 +828,15 @@ function GET_SMART(Obj)
 | 
			
		||||
        }, get HTML()
 | 
			
		||||
        {
 | 
			
		||||
            return Data.HTML;
 | 
			
		||||
        }, get Fixed()
 | 
			
		||||
        {
 | 
			
		||||
            return Data.Fixed;
 | 
			
		||||
        }, get CoinName()
 | 
			
		||||
        {
 | 
			
		||||
            return Data.ShortName;
 | 
			
		||||
        }, get CentName()
 | 
			
		||||
        {
 | 
			
		||||
            return Data.CentName;
 | 
			
		||||
        }, };
 | 
			
		||||
    return GET_PROP;
 | 
			
		||||
};
 | 
			
		||||
@@ -937,6 +1035,7 @@ function InitEval()
 | 
			
		||||
    Object.freeze($GetHexFromArr);
 | 
			
		||||
    Object.freeze($GetArrFromHex);
 | 
			
		||||
    Object.freeze($sha);
 | 
			
		||||
    Object.freeze($ReadSmart);
 | 
			
		||||
    Object.freeze($isFinite);
 | 
			
		||||
    Object.freeze($isNaN);
 | 
			
		||||
    Object.freeze($parseFloat);
 | 
			
		||||
@@ -1083,6 +1182,7 @@ function $SetValue(ID,CoinSum)
 | 
			
		||||
    {
 | 
			
		||||
        CoinSum = COIN_FROM_FLOAT(CoinSum);
 | 
			
		||||
    }
 | 
			
		||||
    CHECKSUM(CoinSum);
 | 
			
		||||
    if(CoinSum.SumCENT >= 1e9)
 | 
			
		||||
    {
 | 
			
		||||
        throw "ERROR SumCENT>=1e9";
 | 
			
		||||
@@ -1119,7 +1219,7 @@ function $Send(ToID,CoinSum,Description)
 | 
			
		||||
    }
 | 
			
		||||
    if(RunContext.Account.Currency !== ToData.Currency)
 | 
			
		||||
    {
 | 
			
		||||
        throw "Different currencies";
 | 
			
		||||
        throw "Different currencies. Accounts: " + RunContext.Account.Num + " and " + ToID;
 | 
			
		||||
    }
 | 
			
		||||
    DApps.Accounts.SendMoneyTR(RunContext.Block, RunContext.Account.Num, ToID, CoinSum, RunContext.BlockNum, RunContext.TrNum,
 | 
			
		||||
    Description, Description, 1);
 | 
			
		||||
@@ -1142,7 +1242,7 @@ function $Move(FromID,ToID,CoinSum,Description)
 | 
			
		||||
    }
 | 
			
		||||
    if(FromData.Currency !== ToData.Currency)
 | 
			
		||||
    {
 | 
			
		||||
        throw "Different currencies";
 | 
			
		||||
        throw "Different currencies. Accounts: " + FromID + " and " + ToID;
 | 
			
		||||
    }
 | 
			
		||||
    if(FromData.Value.Smart !== RunContext.Smart.Num)
 | 
			
		||||
    {
 | 
			
		||||
@@ -1190,6 +1290,20 @@ function $ReadAccount(ID)
 | 
			
		||||
    return GET_ACCOUNT(Account);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
function $ReadSmart(ID)
 | 
			
		||||
{
 | 
			
		||||
    if(RunContext.BlockNum < global.UPDATE_CODE_2)
 | 
			
		||||
    {
 | 
			
		||||
        throw "Method call not available";
 | 
			
		||||
    }
 | 
			
		||||
    DO(900);
 | 
			
		||||
    ID = ParseNum(ID);
 | 
			
		||||
    var Smart = DApps.Smart.ReadSmart(ID);
 | 
			
		||||
    if(!Smart)
 | 
			
		||||
        throw "Error smart ID: " + ID;
 | 
			
		||||
    return GET_SMART(Smart);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
function $ReadState(ID)
 | 
			
		||||
{
 | 
			
		||||
    DO(900);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user