starcoinorg / starmask-extension

A blockchain wallet browser extension for starcoin
Apache License 2.0
35 stars 15 forks source link

bug: 执行 state.get_with_proof_by_root_raw 提示不存在 #85

Closed yubing744 closed 2 years ago

yubing744 commented 2 years ago

通过 window.starcoin.request 执行 state.get_with_proof_by_root_raw 报错:

image

参数: access_path: "0x574bc81805e18893aaecdae7e2c55f92/1/0x00000000000000000000000000000001::IdentifierNFT::IdentifierNFT<0x00000000000000000000000000000001::DAOSpace::DAOMember<0x4e375bb50d5b32a965b6e783e55a7cef::TESTDAO::TESTDAO>,0x00000000000000000000000000000001::DAOSpace::DAOMemberBody<0x4e375bb50d5b32a965b6e783e55a7cef::TESTDAO::TESTDAO>>" state_root: "0x495d0430dc40cb608a2fff3e3b26e2b8e21510effe78a22eb6239d962753423e"

yubing744 commented 2 years ago

通过 curl 执行可以成功

image
jolestar commented 2 years ago

通过 window.starcoin.request 执行 state.get_with_proof_by_root_raw 报错:

image

参数: access_path: "0x574bc81805e18893aaecdae7e2c55f92/1/0x00000000000000000000000000000001::IdentifierNFT::IdentifierNFT<0x00000000000000000000000000000001::DAOSpace::DAOMember<0x4e375bb50d5b32a965b6e783e55a7cef::TESTDAO::TESTDAO>,0x00000000000000000000000000000001::DAOSpace::DAOMemberBody<0x4e375bb50d5b32a965b6e783e55a7cef::TESTDAO::TESTDAO>>" state_root: "0x495d0430dc40cb608a2fff3e3b26e2b8e21510effe78a22eb6239d962753423e"

是不是你本地的版本比较旧?

yubing744 commented 2 years ago

我升级一下钱包试一下

yubing744 commented 2 years ago

@jolestar 我试了升级到最新的钱包版本也不行,后来我分析了 starmask-extension 源码,发现他内部有权限控制,配置有一个透传的RPC方法白名单:

https://github.com/starcoinorg/starmask-extension/blob/6bdc25c7627b07ae02bc43793653cb01d1c370d9/app/scripts/controllers/permissions/enums.js#L36-L114

jolestar commented 2 years ago

@jolestar 我试了升级到最新的钱包版本也不行,后来我分析了 starmask-extension 源码,发现他内部有权限控制,配置有一个透传的RPC方法白名单:

https://github.com/starcoinorg/starmask-extension/blob/6bdc25c7627b07ae02bc43793653cb01d1c370d9/app/scripts/controllers/permissions/enums.js#L36-L114

@wk3368 这个白名单是不是没必要?是为了防止恶意请求?

yubing744 commented 2 years ago

@jolestar 我尝试直接使用 starcoin.js 的 JsonRpcProvider 可以调用成功了。

jolestar commented 2 years ago

可以把 https://starcoinorg.github.io/jsonrpcdoc/#/ 中的 Chain API Contract API State API Txpool API

四种接口全部加进去

wk3368 commented 2 years ago

目前的window.starcoin发出的请求都是GET,这个是POST 所以不支持!

最好就是dapp自己用xios来自己发xhr请求。

window.starcoin.chainId = '0xfb'

可以根据下面的map 得到对应的rpcUrl,来发送任意GET/POST 请求

{ providerType: 'main', rpcUrl: 'https://main-seed.starcoin.org', chainId: '0x1'} { providerType: 'barnard', rpcUrl: 'https://barnard-seed.starcoin.org', chainId: '0xfb'} { providerType: 'halley', rpcUrl: 'https://halley-seed.starcoin.org', chainId: '0xfd'} { providerType: 'proxima', rpcUrl: 'https://proxima-seed.starcoin.org', chainId: '0xfc'}

jolestar commented 2 years ago

目前的window.starcoin发出的请求都是GET,这个是POST 所以不支持!

最好就是dapp自己用xios来自己发xhr请求。

window.starcoin.chainId = '0xfb'

可以根据下面的map 得到对应的rpcUrl,来发送任意GET/POST 请求

{ providerType: 'main', rpcUrl: 'https://main-seed.starcoin.org', chainId: '0x1'} { providerType: 'barnard', rpcUrl: 'https://barnard-seed.starcoin.org', chainId: '0xfb'} { providerType: 'halley', rpcUrl: 'https://halley-seed.starcoin.org', chainId: '0xfd'} { providerType: 'proxima', rpcUrl: 'https://proxima-seed.starcoin.org', chainId: '0xfc'}

starcoin 的 RPC 都是 post 呀

wk3368 commented 2 years ago

不好意思,记混了,Aptos那边是GET和POST都有。

wk3368 commented 2 years ago

fixed in 4.8.0