Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use github actions instead of travis #19

Merged
merged 36 commits into from
Aug 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
bca27d5
lint fixes
denisglotov Aug 18, 2023
aecd236
pylint
denisglotov Aug 18, 2023
13c2864
comment out pylint
denisglotov Aug 18, 2023
3b9f4bc
dev-readme
denisglotov Aug 18, 2023
4129142
lint badge
denisglotov Aug 18, 2023
cd02df7
Auto tests
denisglotov Aug 18, 2023
65fcd2e
fail on error
denisglotov Aug 18, 2023
5997a77
fix of invalid option name
denisglotov Aug 18, 2023
73798ee
ganache timeout
denisglotov Aug 18, 2023
113c8e4
docker ps -a
denisglotov Aug 18, 2023
d42e3ab
docker logs ccff5508797b
denisglotov Aug 18, 2023
eb3f63f
debug
denisglotov Aug 18, 2023
d1f74bc
debug
denisglotov Aug 18, 2023
24c7db9
use actions secrets
denisglotov Aug 19, 2023
b35f29c
web3 usage fix
denisglotov Aug 19, 2023
a517631
Moved to Foundry Anvil
denisglotov Aug 19, 2023
9a04575
debug2
denisglotov Aug 19, 2023
a1192d0
debug3
denisglotov Aug 19, 2023
e12096c
debug4
denisglotov Aug 19, 2023
0a104a5
debug5
denisglotov Aug 19, 2023
e88f788
debug
denisglotov Aug 19, 2023
68f4fb7
debug7
denisglotov Aug 19, 2023
16e853f
debug8
denisglotov Aug 19, 2023
aa818a2
debug9
denisglotov Aug 19, 2023
bc055aa
debug10
denisglotov Aug 19, 2023
ef29061
debug11
denisglotov Aug 19, 2023
df18627
debug12
denisglotov Aug 19, 2023
c680446
debug13
denisglotov Aug 19, 2023
3618436
debug14
denisglotov Aug 19, 2023
e7fc68c
debug15
denisglotov Aug 19, 2023
fd749a2
debug16
denisglotov Aug 19, 2023
5233c8c
debug17
denisglotov Aug 19, 2023
22c9991
debug18
denisglotov Aug 19, 2023
1c6126c
debug19
denisglotov Aug 19, 2023
c8a29e6
badge
denisglotov Aug 19, 2023
4eadbfd
1.2.1
denisglotov Aug 19, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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