ConfluxPortal迁移fluent注意点

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-%E4%BB%8E-ConfluxPortal-%E8%BF%81%E7%A7%BB%E8%87%B3-Fluent

https://fluent-wallet.zendesk.com/hc/zh-cn/articles/4411936847387

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值