您正在查看: Surou 发布的文章

EOS js name To Uint64 OR Uint64 to name

源代码仓库地址:
https://github.com/bcskill/eosjs-name

演示地址
Try on run-kit https://npm.runkit.com/eosjs-account-name

测试代码
// name To Uint64

const eosjsAccountName = require("eosjs-account-name")
const n = eosjsAccountName.nameToUint64('eosio');
console.log('eosio to uint64: ' + n);
console.log('uint64 to name: ' + eosjsAccountName.uint64ToName(n));

// Uint64 to name

const uint64 = '6138663577826885632';
const name = eosjsAccountName.uint64ToName(uint64);

EOS 编译 llvmWARshim error

编译EOS2.x版本时,由于使用WSL,或者Windows git 操作过,很容易把软连接丢了,所以报错如下

/eos/libraries/chain/webassembly/eos-vm-oc/llvmWARshim.llvmwar:1:1: error: ‘llvmWARshim’ does not name a type
 llvmWARshim.cpp
 ^~~~~~~~~~~
libraries/chain/CMa

手动修复软连接

cd /eos/libraries/chain/webassembly/eos-vm-oc
rm llvmWARshim.llvmwar
ln -s llvmWARshim.cpp llvmWARshim.llvmwar

修复后ll查看如下

llvmWARshim.llvmwar -> llvmWARshim.cpp*

EOS合约中获取当天本地时间的零点和第二天的零点

获取当前时间所在当天的本地零点时间

time_point contract::last_zeto_time_point(time_point last_do_time_point) {
   uint64_t days_count = (last_do_time_point.time_since_epoch().count() + (8 * one_hour_msec)) / one_day_msec;
   uint64_t days_msec = days_count * one_day_msec;
   days_msec -= (8 * one_hour_msec);
   return time_point(microseconds(days_msec));
}

获取当前时间所在当天的本地第二天的零点时间

time_point contract::next_zeto_time_point(time_point last_do_time_point) {
   return last_zeto_time_point(last_do_time_point) + microseconds(one_day_msec);
}

箭头函数 与 forEach

array.forEach(function(item,index){
}.bind(this));

等同于

array.forEach((item,index) =>{
});

转载:https://www.cnblogs.com/guomengkai/p/11392958.html