Skip to content

Commit

Permalink
1.2.1 Use github actions instead of travis (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
denisglotov authored Aug 19, 2023
1 parent 705ac40 commit 4a75136
Show file tree
Hide file tree
Showing 9 changed files with 111 additions and 70 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/pylint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Pylint

on: [push]

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Set up Python 3
uses: actions/setup-python@v3
with:
python-version: "3.11"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pylint flake8
- name: Analysing the code with pylint
run: |
# pylint $(git ls-files '*.py')
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
32 changes: 32 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Tests

on: [push]

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1

- name: Run Anvil
run: |
nohup anvil --auto-impersonate &
more nohup.out
- name: Set up Python 3
uses: actions/setup-python@v3
with:
python-version: "3.11"

- name: Install Dymka
run: |
python -m pip install --upgrade pip
pip install .
- name: Run tests
run: |
tests/test.sh
21 changes: 0 additions & 21 deletions .travis.yml

This file was deleted.

6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Add ERC20 ABI.
- Add EIP1559 support.
- Lint with pylint

## [1.2.1] - 2023-08-19

- Test with Github actions instead of deprecated Travis.
- Testing uses Foundry Anvil insttead of Truffle Ganache.
- Minor fixes found by working tests.


## [1.2.0] - 2023-08-17
Expand Down
29 changes: 29 additions & 0 deletions dev-readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
Developer hints
---------------

Pre

``` shell
python3 -m pip install --upgrade pip flake8 pylint
```

To set up virtual environment

``` shell
PIPENV_VENV_IN_PROJECT=1 pipenv install --dev
```

To run it from there

``` shell
pipenv run ./dymka -V
```

To publish the new version to pypi

``` shell
python3 -m pip install --upgrade setuptools wheel twine
python3 setup.py sdist bdist_wheel
python3 -m twine upload dist/*
```
Taken from https://packaging.python.org/tutorials/packaging-projects/.
10 changes: 5 additions & 5 deletions dymka
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ class Dymka:
@command('balance', 'bal')
def balance(self):
"""Returns balance of all provided arguments and --from account."""
return self.processAccounts(lambda addr: self.w3.eth.get_balance(addr, *opts), self.address_from, args.to)
return self.processAccounts(self.w3.eth.get_balance, self.address_from, args.to)

@command('nonce')
def nonce(self):
Expand Down Expand Up @@ -306,7 +306,7 @@ class Dymka:
processed = False
for evt in contract.events:
try:
logs.append(contract.events[evt.event_name]().processLog(event))
logs.append(contract.events[evt.event_name]().process_log(event))
processed = True
break
except exceptions.MismatchedABI:
Expand Down Expand Up @@ -417,7 +417,7 @@ class Dymka:
"""
contract = self.getContract()
ctor = contract.constructor(*getOptionalArguments(0))
tx = ctor.buildTransaction(self.getOpts())
tx = ctor.build_transaction(self.getOpts())
status = self.transact(tx)
if 'receipt' in status:
address = status['receipt']['contractAddress']
Expand All @@ -430,7 +430,7 @@ class Dymka:
contract = self.getContract(address=self.getContractAddress())
func = contract.functions[function_name]
func_bound = func(*getOptionalArguments(1))
return func_bound.buildTransaction(opts)
return func_bound.build_transaction(opts)

@command('send')
def send(self):
Expand All @@ -457,7 +457,7 @@ if __name__ == "__main__":
print('Please specify a command or "help".')
exit(0)
elif args.version or args.command == 'version':
print(f'Version: 1.2.0, Web3.py: {str(Web3().api)}.')
print(f'Version: 1.2.1, Web3.py: {str(Web3().api)}.')
exit(0)
elif args.command == 'help':
if args.arguments:
Expand Down
30 changes: 2 additions & 28 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
Dymka
=====

[![Build status]](https://travis-ci.org/denisglotov/dymka)
![Build status](https://github.com/denisglotov/dymka/actions/workflows/tests.yml/badge.svg)
![Lint status](https://github.com/denisglotov/dymka/actions/workflows/pylint.yml/badge.svg)
[![Pypi version]](https://pypi.org/project/dymka/)

[Build status]: https://travis-ci.org/denisglotov/dymka.svg?branch=master
[Pypi version]: https://img.shields.io/pypi/v/dymka.svg

Swiss-knife command line tool for interacting with Ethereum-based blockchains.
Expand Down Expand Up @@ -271,32 +271,6 @@ or send a pull request so I try to help and review.
[issue]: https://github.com/denisglotov/dymka/issues/new


Developer hints
---------------

To set up virtual environment

``` shell
PIPENV_VENV_IN_PROJECT=1 pipenv install --dev
```

To run it from there

``` shell
pipenv run ./dymka -V
```

To publish the new version to pypi

``` shell
python3 -m pip install --upgrade pip
python3 -m pip install --user --upgrade setuptools wheel twine
python3 setup.py sdist bdist_wheel
python3 -m twine upload dist/*
```
Taken from https://packaging.python.org/tutorials/packaging-projects/.


Why should I trust dymka
------------------------

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name='dymka',
version='1.2.0',
version='1.2.1',
author='Denis Glotov',
description='Swiss-knife cli for Ethereum-based blockchains',
long_description=long_description,
Expand Down
29 changes: 14 additions & 15 deletions tests/test.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash -x
#!/bin/bash -eux
cd $(dirname $0)

die() {
Expand All @@ -7,21 +7,20 @@ die() {
}

dymka version
dymka id
dymka block
dymka accounts
dymka balance

# From account must be set by travis beforehand.
[ -v WEB3_FROM ] || die "WEB3_FROM must be set for this script to run"
FROM=$(dymka accounts | jq -r ".[0]")
dymka balance $FROM

echo
echo "Deploy Demo contract."
ADDR=$(dymka -c demo deploy | tee /dev/tty | jq -r ".receipt.contractAddress")
ADDR=$(dymka -c demo deploy | jq -r ".receipt.contractAddress")
export WEB3_CONTRACT_DEMO="$ADDR"

echo
echo "Call its value() function."
RES=$(dymka -c demo call value | tee /dev/tty | jq -r ".result")
RES=$(dymka -c demo call value | jq -r ".result")
[ "$RES" == "42" ] || die "Wrong initial value $RES"

echo
Expand All @@ -30,12 +29,12 @@ dymka -c demo send act

echo
echo "Call value() function again. Must be 43."
RES=$(dymka -c demo call value | tee /dev/tty | jq -r ".result")
RES=$(dymka -c demo call value | jq -r ".result")
[ "$RES" == "43" ] || die "Wrong value $RES"

echo
echo "Call compare(45) function."
RES=$(dymka -c demo call compare 45 | tee /dev/tty | jq -r ".result")
RES=$(dymka -c demo call compare 45 | jq -r ".result")
[ $(echo "$RES" | tr -d '[:space:]') == "[false,true]" ] || die "Wrong $RES"

echo
Expand All @@ -48,12 +47,12 @@ RES=$(dymka -j demo.abi.json -c demo call value | jq -r ".result")
[ "$RES" == "100" ] || die "Wrong value $RES"

set +x
LOGS=$(dymka -j demo.abi.json -c demo events 1- | tee /dev/tty)
[ $(echo "$LOGS" | jq -r .[0].event) == "Acted" ] || die "Wrong 1st log name"
[ $(echo "$LOGS" | jq -r .[0].args.who) == "0xB18aE0D7F12105e36a430523721622e5930879cC" ] || die "Wrong 1st log arg"
[ $(echo "$LOGS" | jq -r .[1].event) == "Updated" ] || die "Wrong 2nd log name"
[ $(echo "$LOGS" | jq -r .[1].args.value) == "43" ] || die "Wrong 2nd log arg"
[ $(echo "$LOGS" | jq -r .[2].event) == "Updated" ] || die "Wrong 3rd log name"
LOGS=$(dymka -j demo.abi.json -c demo events 1-)
[ $(echo "$LOGS" | jq -r .[0].event) == "Acted" ] || die "Wrong 1st log name $LOGS"
[ $(echo "$LOGS" | jq -r .[0].args.who) == $FROM ] || die "Wrong 1st log arg $LOGS"
[ $(echo "$LOGS" | jq -r .[1].event) == "Updated" ] || die "Wrong 2nd log name $LOGS"
[ $(echo "$LOGS" | jq -r .[1].args.value) == "43" ] || die "Wrong 2nd log arg $LOGS"
[ $(echo "$LOGS" | jq -r .[2].event) == "Updated" ] || die "Wrong 3rd log name $LOGS"
set -x

echo
Expand Down

0 comments on commit 4a75136

Please sign in to comment.