action

模块 action

action 对象

使用方法:在 fibos 的 js 合约中使用

1
2
var js_code = `exports.hi = v => console.error(action.is_account(action.account), action.is_account("notexists"));`;
fibos.setcodeSync(name, 0, 0, fibos.compileCode(js_code));

静态函数

is_account

判断账户是否存在

1
static Boolean action.is_account(String name);

调用参数:

返回结果:

实例:

1
2
3
4
exports.hi = v => {
if (action.is_account(account)) console.notice("account exists");
else console.error("account notexists")
};

has_recipient

action 执行成后,名为 name 的账号是否会收到通知

1
static Boolean action.has_recipient(String name);

调用参数:

返回结果:

实例:

1
2
3
4
exports.hi = v => {
if (action.has_recipient(receiver)) console.notice("action received")
else console.error("action not received");
};

require_recipient

向通知列表增加特定账号

1
static action.require_recipient(String name);

调用参数:

实例:

1
2
3
exports.hi = v => {
action.require_recipient(action.receiver);
};

has_auth

验证 action 是否需要特定账户的授权

1
static Boolean action.has_auth(String name);

调用参数:

返回结果:

实例:

1
2
3
exports.hi = v => {
if (action.has_auth(account)) console.notice("action be authed")
};

require_auth

向 action 的授权列表中添加特定账户及对应的权限,若添加失败则会抛出异常

1
2
static action.require_auth(String name,
String permission = "");

调用参数:

实例:

1
2
3
exports.hi = v => {
if (action.require_auth(account)) console.notice("auth success")
};

静态属性

name

String, action 名称

1
static readonly String action.name;

实例:

1
2
3
exports.hi = v => {
console.log(action.name)
};

account

String, action 发送者的账户名

1
static readonly String action.account;

实例:

1
2
3
exports.hi = v => {
console.log(action.account)
};

receiver

String, action 接收者

1
static readonly String action.receiver;

实例:

1
2
3
exports.hi = v => {
console.log(action.receiver)
};

publication_time

Long, 返回从1970年1月1日0时0分0秒(UTC,即协调世界时)距离出块时间的毫秒数。

1
static readonly Long action.publication_time;

实例:

1
2
3
exports.hi = v => {
console.log(action.publication_time)
};

authorization

Array, 执行该 action 需要得到数组中所有账户的授权

1
static readonly Array action.authorization;

实例:

1
2
3
exports.hi = v => {
console.log(action.authorization)
};