mirror of
https://github.com/chaintool-py/eth-erc20.git
synced 2026-07-09 19:13:02 +02:00
Compare commits
3 Commits
lash/info-
...
lash/ida-c
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
01dcb737a0
|
||
| 5bf187612a | |||
| e811575c33 |
@@ -2,25 +2,41 @@ stages:
|
||||
- test
|
||||
- slither-analyzer
|
||||
|
||||
test:
|
||||
image: registry.gitlab.com/grassrootseconomics/cic-base-images/ci-solc-py-alpine:latest
|
||||
cache:
|
||||
- key:
|
||||
files:
|
||||
- requirements.txt
|
||||
- test_requirements.txt
|
||||
paths:
|
||||
- /root/.cache/pip
|
||||
script:
|
||||
- cd python
|
||||
- pip install --extra-index-url https://pip.grassrootseconomics.net:8433 -r test_requirements.txt
|
||||
- pip install --extra-index-url https://pip.grassrootseconomics.net:8433 -r test_requirements.txt
|
||||
- bash run_tests.sh
|
||||
variables:
|
||||
PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
|
||||
|
||||
cache:
|
||||
paths:
|
||||
- .cache/pip
|
||||
- venv/
|
||||
|
||||
before_script:
|
||||
- python -V # Print out python version for debugging
|
||||
- pip install virtualenv
|
||||
- virtualenv venv
|
||||
- source venv/bin/activate
|
||||
|
||||
test:
|
||||
image: registry.gitlab.com/grassrootseconomics/cic-base-images/ci-solc-python:latest
|
||||
script:
|
||||
# build abi
|
||||
- 'echo "Running Solc Version: $(solc --version)"'
|
||||
- cd solidity
|
||||
- solc --evm-version=byzantium GiftableToken.sol --abi | awk 'NR>3' > GiftableToken.abi.json
|
||||
# build bin
|
||||
- solc GiftableToken.sol --bin | awk 'NR>3' > GiftableToken.bin &&
|
||||
truncate -s "$((`stat -t -c "%s" GiftableToken.bin`-1))" GiftableToken.bin
|
||||
# install test dependencies
|
||||
- cd ../python
|
||||
- export PYTHONPATH=.
|
||||
- pip install --extra-index-url https://pip.grassrootseconomics.net
|
||||
--extra-index-url https://gitlab.com/api/v4/projects/27624814/packages/pypi/simple
|
||||
-r requirements.txt -r test_requirements.txt
|
||||
# run tests
|
||||
- bash run_tests.sh
|
||||
|
||||
slither-analize:
|
||||
image: registry.gitlab.com/grassrootseconomics/cic-base-images/ci-solc-py-alpine:latest
|
||||
image: registry.gitlab.com/grassrootseconomics/cic-base-images/ci-solc-python:latest
|
||||
allow_failure: true
|
||||
script:
|
||||
- pip install slither-analyzer
|
||||
- slither solidity/
|
||||
|
||||
|
||||
33
Dockerfile
33
Dockerfile
@@ -1,33 +0,0 @@
|
||||
FROM ethereum/solc:0.6.12
|
||||
|
||||
FROM python:3.8.6-alpine
|
||||
|
||||
COPY --from=0 /usr/bin/solc /usr/bin/solc
|
||||
|
||||
RUN apk update &&\
|
||||
apk add gcc bash musl-dev libffi-dev openssl-dev autoconf automake build-base \
|
||||
libtool pkgconfig python3-dev cargo
|
||||
|
||||
WORKDIR /usr/src
|
||||
|
||||
# Try to keep everything above here re-usable!
|
||||
|
||||
COPY ./solidity/ /usr/src/giftable_erc20_token/solidity/
|
||||
COPY ./python/ /usr/src/giftable_erc20_token/python/
|
||||
|
||||
RUN chmod +x ./python/run_tests.sh
|
||||
|
||||
RUN cd giftable_erc20_token/solidity && \
|
||||
solc GiftableToken.sol --abi | awk 'NR>3' > GiftableToken.abi.json
|
||||
|
||||
RUN cd giftable_erc20_token/solidity && \
|
||||
solc GiftableToken.sol --bin | awk 'NR>3' > GiftableToken.bin && \
|
||||
truncate -s "$((`stat -t -c "%s" GiftableToken.bin`-1))" GiftableToken.bin
|
||||
|
||||
RUN cd giftable_erc20_token/python && \
|
||||
pip install --extra-index-url https://pip.grassrootseconomics.net:8433 .
|
||||
|
||||
RUN pip install slither-analyzer
|
||||
|
||||
# To deploy:
|
||||
# giftable-token-deploy --contracts-dir giftable_erc20_token/solidity/ <amount>
|
||||
25
README.md
Normal file
25
README.md
Normal file
@@ -0,0 +1,25 @@
|
||||
# ETH-ERC20 Solidity Contract
|
||||
|
||||
|
||||
### solidity
|
||||
|
||||
To generate bytecode and tests install solc 8.x.x and run the solc bits below or execute the following:
|
||||
|
||||
```
|
||||
docker run -v `pwd`:/src registry.gitlab.com/grassrootseconomics/cic-base-images/ci-solc-python:latest solc --evm-version=byzantium solidity/GiftableToken.sol --abi
|
||||
```
|
||||
|
||||
```
|
||||
docker run -v `pwd`:/src registry.gitlab.com/grassrootseconomics/cic-base-images/ci-solc-python:latest solc GiftableToken.sol --bin | awk 'NR>3' > GiftableToken.bin
|
||||
```
|
||||
|
||||
### python unit tests
|
||||
|
||||
```
|
||||
pip install --extra-index-url https://gitlab.com/api/v4/projects/27624814/packages/pypi/simple \
|
||||
--extra-index-url https://pip.grassrootseconomics.net \
|
||||
-r requirements.txt -r test_requirements.txt
|
||||
|
||||
bash python/run_tests.sh
|
||||
|
||||
```
|
||||
@@ -1,81 +0,0 @@
|
||||
#!python3
|
||||
|
||||
"""Token balance query script
|
||||
|
||||
.. moduleauthor:: Louis Holbrook <dev@holbrook.no>
|
||||
.. pgp:: 0826EDA1702D1E87C6E2875121D2E7BB88C2A746
|
||||
|
||||
"""
|
||||
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
# standard imports
|
||||
import sys
|
||||
import os
|
||||
import json
|
||||
import argparse
|
||||
import logging
|
||||
|
||||
# external imports
|
||||
from hexathon import (
|
||||
add_0x,
|
||||
strip_0x,
|
||||
even,
|
||||
)
|
||||
import sha3
|
||||
|
||||
# external imports
|
||||
import chainlib.eth.cli
|
||||
from chainlib.eth.address import to_checksum_address
|
||||
from chainlib.eth.connection import EthHTTPConnection
|
||||
from chainlib.eth.gas import (
|
||||
OverrideGasOracle,
|
||||
balance,
|
||||
)
|
||||
from chainlib.chain import ChainSpec
|
||||
|
||||
# local imports
|
||||
from eth_erc20 import ERC20
|
||||
|
||||
logging.basicConfig(level=logging.WARNING)
|
||||
logg = logging.getLogger()
|
||||
|
||||
arg_flags = chainlib.eth.cli.argflag_std_read | chainlib.eth.cli.Flag.EXEC
|
||||
argparser = chainlib.eth.cli.ArgumentParser(arg_flags)
|
||||
args = argparser.parse_args()
|
||||
config = chainlib.eth.cli.Config.from_args(args, arg_flags)
|
||||
|
||||
rpc = chainlib.eth.cli.Rpc()
|
||||
conn = rpc.connect_by_config(config)
|
||||
|
||||
chain_spec = ChainSpec.from_chain_str(config.get('CHAIN_SPEC'))
|
||||
|
||||
token_address = config.get('_EXEC_ADDRESS')
|
||||
|
||||
|
||||
def main():
|
||||
g = ERC20(chain_spec=chain_spec, gas_oracle=rpc.get_gas_oracle())
|
||||
|
||||
name_o = g.name(token_address)
|
||||
r = conn.do(name_o)
|
||||
token_name = g.parse_name(r)
|
||||
print('Name: {}'.format(token_name))
|
||||
|
||||
symbol_o = g.symbol(token_address)
|
||||
r = conn.do(symbol_o)
|
||||
token_symbol = g.parse_symbol(r)
|
||||
print('Symbol: {}'.format(token_symbol))
|
||||
|
||||
decimals_o = g.decimals(token_address)
|
||||
r = conn.do(decimals_o)
|
||||
decimals = int(strip_0x(r), 16)
|
||||
print('Decimals: {}'.format(decimals))
|
||||
|
||||
supply_o = g.total_supply(token_address)
|
||||
r = conn.do(supply_o)
|
||||
supply = int(strip_0x(r), 16)
|
||||
print('Total supply: {}'.format(supply))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
@@ -1,3 +1,3 @@
|
||||
confini~=0.5.2
|
||||
chainlib-eth~=0.0.14
|
||||
confini~=0.5.3
|
||||
chainlib-eth~=0.0.19
|
||||
potaahto==0.1.0
|
||||
|
||||
0
python/run_tests.sh
Normal file → Executable file
0
python/run_tests.sh
Normal file → Executable file
Reference in New Issue
Block a user