Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alaya JS SDK与PlatON JS SDK使用同一套代码的相关建议 #62

Open
RileyGe opened this issue Jul 12, 2021 · 2 comments
Open

Alaya JS SDK与PlatON JS SDK使用同一套代码的相关建议 #62

RileyGe opened this issue Jul 12, 2021 · 2 comments
Assignees
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@RileyGe
Copy link
Contributor

RileyGe commented Jul 12, 2021

现在Alaya与PlatON的js sdk基本使用同一套代码,这样可以减少学习和代码迁移成本,是一种各方都有益的事,但在实践中有一定的问题。例如,在使用sdk与Alaya网络交互时,需要进行大量设置,如使用私钥生成账号时:

var act = new AlayaAccounts(web3a.currentProvider, "atp");
act = act.privateKeyToAccount(privateKey);

而且,所有签名都没办法如下方法:

web3.platon.accounts.signTransaction(tx, privateKey);

另外,由于PPOS模块都是直接用chainId来确定hrp的,所以导致在现在的代码下是没有办法使用PPOS模块正常操作alaya网络的内置合约的。

对于以上问题,我有以下建议:

  1. 在web3对象中,增加一个设置全局chainId和hrp的方法,在设置chainId和hrp之后,web3所有的属性及函数都继承此chainId及hrp,在所有操作过程中都能自动填充chainId和hrp。
  2. 将现有的6种网络的信息,如PlatON主网,PlatON开发网,PlatON私有网络默认网络参数,Alaya主网,Alaya开发网和Alaya私有网络默认参数,这6个网络参数当作常量写入到SDK中。其他非常用参数可使用1中的方法单独设置。
  3. 更新PPOS中的方法,使之能够适应解锁账号和非解锁账号的使用。
@biganxin
Copy link

Good
What are the implications of this change?
e.g. PlatON Studio, JS SDK documentation, ATON, etc.

@biganxin
Copy link

Would like to hear your advice
@totaking
@fuzhijing1

@biganxin biganxin added enhancement New feature or request help wanted Extra attention is needed labels Sep 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants