1.代码中引入最新版本 js-conflux-sdk
"dependencies": {
"js-conflux-sdk": "2.0.4"
}
2.全局配置中加入代码
import { Conflux } from 'js-conflux-sdk'
const cfx = new Conflux({url: 'https://main.confluxrpc.com/',networkId: 1029,defaultGasPrice: 1000000,logger: console});
window.confluxJS = cfx;
window.confluxJS.provider = window.conflux;
3.钱包登录方式修改为
const accouts = window.conflux.request({method: "cfx_requestAccounts"})
4.签名方法修改为(注:返回res就是签名,不用取res.result)
const signConfim = async () => {
let params = [format.hexAddress(userAddress), JSON.stringify(typeData)]
await window.conflux.request(
{
method: 'eth_signTypedData_v4',
params
}).then((res:any)=>{
console.log(res)
}).catch((err:any)=>{
console.log(err:any)
})
}
5.获取链id方法修改为
const orderSign = async () => {
const _chainId = await window.conflux.request({method: 'cfx_chainId'});
}
6.合约地址千万不要转成0地址
const getContractForFiexV4 =
window.conflux &&
window.confluxJS.Contract({
address: 'cfx:********',
abi: FixedExchangeV4Abi
})
7.conflux.networkVersion方法替换
const netVersion = async () => {
const _version = await window.conflux.request({method: "cfx_netVersion"});
}
8.其他迁移注意事项参考
https://fluent-wallet.zendesk.com/hc/zh-cn/articles/4410789041307-从-ConfluxPortal-迁移至-Fluent
https://fluent-wallet.zendesk.com/hc/zh-cn/articles/4411936847387