crossbario / autobahn-python

WebSocket and WAMP in Python for Twisted and asyncio
https://crossbar.io/autobahn
MIT License
2.48k stars 767 forks source link

Complete first release of XBR CLI #1367

Open oberstet opened 4 years ago

oberstet commented 4 years ago

XBR CLI:

oberstet commented 4 years ago

partially landed via https://github.com/crossbario/autobahn-python/pull/1366https://github.com/crossbario/autobahn-python/pull/1366

also see https://autobahn.readthedocs.io/en/latest/xbr-cli.html

one issue to address? do we need that (write access to the chain) anyways?

https://github.com/crossbario/autobahn-python/blob/1e55d82d58bf6245fa24d552b88fa346c7eb63cb/autobahn/xbr/_cli.py#L58

oberstet commented 4 years ago

one issue: the entrypoint https://github.com/crossbario/autobahn-python/blob/1e55d82d58bf6245fa24d552b88fa346c7eb63cb/setup.py#L263 should only be added for install flavor xbr https://github.com/crossbario/autobahn-python/blob/1e55d82d58bf6245fa24d552b88fa346c7eb63cb/setup.py#L120

meejah commented 4 years ago

It looks like it is possible to declare that an entry-point depends on some extra .. and this will produce an error-message if you don't have that extra. I can't see a way to not install the entry-point at all if you didn't install the extra, though :/

I did try this, and it is ... not great. You don't get a nice error message (e.g. "need [xbr] extra") but instead get a big traceback about some dependency you don't have installed (in my case it was py-multisig but it probably depends on some arbitrary order).

So, I think the best we can do is some try/except in autobahn.xbr._cli and print an error to the user. All that said, though, even after installing pip install -e .[xbr] I still can't make the CLI work so .. a bit more digging still needed.

meejah commented 4 years ago

Oh, it's because I don't have the contracts (there's no autobahn/xbr/contracts/ directory at all)

jameshilliard commented 4 years ago

I can't see a way to not install the entry-point at all if you didn't install the extra, though :/

1369 fixes this.

oberstet commented 4 years ago

Oh, it's because I don't have the contracts

the ABI JSON files in autobahn/xbr/contractsare

to manually get the files, eg to do a pip install -e .[all] locally, do:

make abi_files 

looks like:

(cpy382_1) oberstet@intel-nuci7:~/scm/crossbario/autobahn-python$ make abi_files 
curl -s https://xbr.network/lib/abi/xbr-protocol-latest.zip -o /tmp/xbr-protocol-latest.zip
unzip -t /tmp/xbr-protocol-latest.zip
Archive:  /tmp/xbr-protocol-latest.zip
    testing: Context.json             OK
    testing: ECDSA.json               OK
    testing: ERC20.json               OK
    testing: ERC20Detailed.json       OK
    testing: IERC20.json              OK
    testing: Migrations.json          OK
    testing: Roles.json               OK
    testing: SafeMath.json            OK
    testing: XBRCatalog.json          OK
    testing: XBRChannel.json          OK
    testing: XBRMaintained.json       OK
    testing: XBRMarket.json           OK
    testing: XBRNetwork.json          OK
    testing: XBRNetworkProxy.json     OK
    testing: XBRTest.json             OK
    testing: XBRToken.json            OK
    testing: XBRTypes.json            OK
No errors detected in compressed data of /tmp/xbr-protocol-latest.zip.
rm -rf /home/oberstet/scm/crossbario/autobahn-python/autobahn/xbr/contracts
unzip /tmp/xbr-protocol-latest.zip -d /home/oberstet/scm/crossbario/autobahn-python/autobahn/xbr/contracts
Archive:  /tmp/xbr-protocol-latest.zip
  inflating: /home/oberstet/scm/crossbario/autobahn-python/autobahn/xbr/contracts/Context.json  
  inflating: /home/oberstet/scm/crossbario/autobahn-python/autobahn/xbr/contracts/ECDSA.json  
  inflating: /home/oberstet/scm/crossbario/autobahn-python/autobahn/xbr/contracts/ERC20.json  
  inflating: /home/oberstet/scm/crossbario/autobahn-python/autobahn/xbr/contracts/ERC20Detailed.json  
  inflating: /home/oberstet/scm/crossbario/autobahn-python/autobahn/xbr/contracts/IERC20.json  
  inflating: /home/oberstet/scm/crossbario/autobahn-python/autobahn/xbr/contracts/Migrations.json  
  inflating: /home/oberstet/scm/crossbario/autobahn-python/autobahn/xbr/contracts/Roles.json  
  inflating: /home/oberstet/scm/crossbario/autobahn-python/autobahn/xbr/contracts/SafeMath.json  
  inflating: /home/oberstet/scm/crossbario/autobahn-python/autobahn/xbr/contracts/XBRCatalog.json  
  inflating: /home/oberstet/scm/crossbario/autobahn-python/autobahn/xbr/contracts/XBRChannel.json  
  inflating: /home/oberstet/scm/crossbario/autobahn-python/autobahn/xbr/contracts/XBRMaintained.json  
  inflating: /home/oberstet/scm/crossbario/autobahn-python/autobahn/xbr/contracts/XBRMarket.json  
  inflating: /home/oberstet/scm/crossbario/autobahn-python/autobahn/xbr/contracts/XBRNetwork.json  
  inflating: /home/oberstet/scm/crossbario/autobahn-python/autobahn/xbr/contracts/XBRNetworkProxy.json  
  inflating: /home/oberstet/scm/crossbario/autobahn-python/autobahn/xbr/contracts/XBRTest.json  
  inflating: /home/oberstet/scm/crossbario/autobahn-python/autobahn/xbr/contracts/XBRToken.json  
  inflating: /home/oberstet/scm/crossbario/autobahn-python/autobahn/xbr/contracts/XBRTypes.json  
(cpy382_1) oberstet@intel-nuci7:~/scm/crossbario/autobahn-python$