tera/Source/dapp/file.js

45 lines
1.1 KiB
JavaScript
Raw Normal View History

2019-02-10 19:53:54 +00:00
/*
* @project: TERA
* @version: Development (beta)
* @license: MIT (not for evil)
* @copyright: Yuriy Ivanov 2017-2019 [progr76@gmail.com]
* Web: https://terafoundation.org
* Twitter: https://twitter.com/terafoundation
* Telegram: https://web.telegram.org/#/im?p=@terafoundation
*/
"use strict";
global.TYPE_TRANSACTION_FILE = 5;
global.FORMAT_FILE_CREATE = "{type:byte,Name:str,ContentType:str,Reserve:arr10,Data:tr}";
const WorkStructRun = {};
class FileApp extends require("./dapp")
{
constructor()
{
super()
}
OnWriteTransaction(Block, Body, BlockNum, TrNum, ContextFrom)
{
return true;
}
GetObjectTransaction(Body)
{
var TR = BufLib.GetObjectFromBuffer(Body, FORMAT_FILE_CREATE, WorkStructRun);
return TR;
}
GetScriptTransaction(Body)
{
var TR = this.GetObjectTransaction(Body);
ConvertBufferToStr(TR)
return JSON.stringify(TR, "", 2);
}
2019-02-16 17:08:41 +00:00
GetVerifyTransaction(Block, BlockNum, TrNum, Body)
2019-02-10 19:53:54 +00:00
{
return 1;
}
};
module.exports = FileApp;
var App = new FileApp;
DApps["File"] = App;
DAppByType[TYPE_TRANSACTION_FILE] = App;