lbc-team / ethers.js-docs Goto Github PK
View Code? Open in Web Editor NEW本库不再更新,请前往最新的 v5 版本:https://github.com/lbc-team/ethers.js
Home Page: https://learnblockchain.cn/ethers_v5/
本库不再更新,请前往最新的 v5 版本:https://github.com/lbc-team/ethers.js
Home Page: https://learnblockchain.cn/ethers_v5/
虽然工作量很大,但是希望开发者空闲时候可以考虑下对v5的翻译。
我也愿意贡献一点绵薄之力
尊敬的作者,您好!
首先非常感谢平台提供的Ethers库,使得我个人非常便捷的开发web3相关原型;其次向您反馈两个问题,非常希望得到您的回复!
两个问题如下:
一、 Ethers库中钱包wallet加密成JSON串时,耗时有两种情况;1:网页端与微信小程序的模拟器均花费13s左右时间(属于正常现象);2:微信小程序手机体验钱包加密/解密过程时,花费至少5分钟以上(属于不正常现象)
二、Ethers库钱包wallet解密过程也是同“问题一”情况;
问题一源码:
//初始化 - 创建钱包
initWallet() {
let _this = this;
let count = 0
console.time("时长");
function callback(progress) { //加密进度条
parseInt(progress * 100)
// console.log("统计次数=", count++);
_this.setData({ welletProcess: (progress * 100).toFixed(2)})
};
// 创建随机钱包
let wallet = ethers.Wallet.createRandom();
// 使用*密码password* 加密钱包生成加密的JSON钱包文件(keystore)
wallet.encrypt(this.data.form.password2, callback).then( json => {
console.timeEnd("时长");
console.log("json=", json)
wx.setStorage({key: "keystore",data: json})
wx.setStorage({key: "password",data: _this.data.form.password2})
wx.showModal({ title: '提示', content: '密码创建成功', showCancel: false, success (res) {
if (res.confirm) {
_this.doNavigate();
}
}
})
})
},
问题二源码:
loadMnemonic(data) {
let _this = this;
let json = JSON.parse(JSON.stringify(data)); //keystore
let password = this.data.password;
function callback(progress) { //钱包解密进度条
_this.setData({ walletProgress: (progress * 100).toFixed(2) });
}
ethers.Wallet.fromEncryptedJson(json, password, callback).then(function (wallet) {
_this.setData({ showTransition: false, showTransition1: false, privateKey: wallet.privateKey, address: wallet.address });
wx.setStorage({key: "address", data: wallet.address});
wx.setStorage({key: "privateKey", data: wallet.privateKey});
_this.getSignature();
}, err => {
_this.setData({ isShowProgress: false })
Notify('保管箱密码错误,请重新输入!');
});
},
Best Wishes~~
Email: [email protected]
AbiCoder.encode bytes 问题
var dynamicOffset_1 = dynamicWriter.length; coder.encode(dynamicWriter, value);
原本代码 没有赋值就取长度
修复代码
coder.encode(dynamicWriter, value); var dynamicOffset_1 = dynamicWriter.length;
先赋值在取长度
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.