9 Commits

Author SHA1 Message Date
4506cf5ad9 feat: add meta auth
All checks were successful
continuous-integration/drone/pr Build is passing
continuous-integration/drone/push Build is passing
2022-07-04 13:33:33 +03:00
2a98ba3877 Partial Revert "fix: bump deps"
This reverts commit e36ea4bcfb.
2022-07-04 10:27:43 +03:00
semantic-release
c3e5ee3199 0.4.1
All checks were successful
continuous-integration/drone/push Build is passing
Automatically generated by python-semantic-release
2022-06-14 08:05:32 +00:00
e36ea4bcfb fix: bump deps
All checks were successful
continuous-integration/drone/push Build is passing
2022-06-14 10:50:52 +03:00
9ec3c33718 test: remove sink_account from giftable test
All checks were successful
continuous-integration/drone/push Build is passing
2022-04-29 10:53:12 +03:00
semantic-release
fbd4ed6526 0.4.0
All checks were successful
continuous-integration/drone/push Build is passing
Automatically generated by python-semantic-release
2022-04-29 07:51:06 +00:00
b7acbdc4bc feat: add giftable generation
All checks were successful
continuous-integration/drone/push Build is passing
2022-04-29 10:49:35 +03:00
semantic-release
3361f90ae1 0.3.4
All checks were successful
continuous-integration/drone/push Build is passing
Automatically generated by python-semantic-release
2022-04-27 07:26:57 +00:00
37188a60e8 fix: bump deps again
All checks were successful
continuous-integration/drone/push Build is passing
2022-04-27 10:22:58 +03:00
15 changed files with 965 additions and 509 deletions

View File

@@ -59,7 +59,7 @@ confidence=
# #
# Kubeflow disables string-interpolation because we are starting to use f # Kubeflow disables string-interpolation because we are starting to use f
# style strings # style strings
disable=import-star-module-level,old-octal-literal,oct-method,print-statement,unpacking-in-except,parameter-unpacking,backtick,old-raise-syntax,old-ne-operator,long-suffix,dict-view-method,dict-iter-method,metaclass-assignment,next-method-called,raising-string,indexing-exception,raw_input-builtin,long-builtin,file-builtin,execfile-builtin,coerce-builtin,cmp-builtin,buffer-builtin,basestring-builtin,apply-builtin,filter-builtin-not-iterating,using-cmp-argument,useless-suppression,range-builtin-not-iterating,suppressed-message,missing-docstring,no-absolute-import,old-division,cmp-method,reload-builtin,zip-builtin-not-iterating,intern-builtin,unichr-builtin,reduce-builtin,standarderror-builtin,unicode-builtin,xrange-builtin,coerce-method,delslice-method,getslice-method,setslice-method,input-builtin,round-builtin,hex-method,nonzero-method,map-builtin-not-iterating,relative-import,invalid-name,bad-continuation,no-member,locally-disabled,fixme,import-error,too-many-locals,no-name-in-module,too-many-instance-attributes,no-self-use,logging-fstring-interpolation disable=old-octal-literal,oct-method,print-statement,unpacking-in-except,parameter-unpacking,backtick,old-raise-syntax,old-ne-operator,long-suffix,dict-view-method,dict-iter-method,metaclass-assignment,next-method-called,raising-string,indexing-exception,raw_input-builtin,long-builtin,file-builtin,execfile-builtin,coerce-builtin,cmp-builtin,buffer-builtin,basestring-builtin,apply-builtin,filter-builtin-not-iterating,using-cmp-argument,useless-suppression,range-builtin-not-iterating,suppressed-message,missing-docstring,no-absolute-import,old-division,cmp-method,reload-builtin,zip-builtin-not-iterating,intern-builtin,unichr-builtin,reduce-builtin,standarderror-builtin,unicode-builtin,xrange-builtin,coerce-method,delslice-method,getslice-method,setslice-method,input-builtin,round-builtin,hex-method,nonzero-method,map-builtin-not-iterating,relative-import,invalid-name,bad-continuation,no-member,locally-disabled,fixme,import-error,too-many-locals,no-name-in-module,too-many-instance-attributes,no-self-use,logging-fstring-interpolation
[REPORTS] [REPORTS]

View File

@@ -2,6 +2,18 @@
<!--next-version-placeholder--> <!--next-version-placeholder-->
## v0.4.1 (2022-06-14)
### Fix
* Bump deps ([`e36ea4b`](https://git.grassecon.net/cicnet/cic-cli/commit/e36ea4bcfb1c417d1adf2be9455cb20b23323414))
## v0.4.0 (2022-04-29)
### Feature
* Add giftable generation ([`b7acbdc`](https://git.grassecon.net/cicnet/cic-cli/commit/b7acbdc4bc5862752585fecfaee7d2fe70d8dbbe))
## v0.3.4 (2022-04-27)
### Fix
* Bump deps again ([`37188a6`](https://git.grassecon.net/cicnet/cic-cli/commit/37188a60e85d9545acfd950c1c160801c22d2b5b))
## v0.3.3 (2022-04-26) ## v0.3.3 (2022-04-26)
### Fix ### Fix
* It's ok if you already exsist ([`38cfb18`](https://git.grassecon.net/cicnet/cic-cli/commit/38cfb185270fb361ff5d9da9976745e1fecc40f8)) * It's ok if you already exsist ([`38cfb18`](https://git.grassecon.net/cicnet/cic-cli/commit/38cfb185270fb361ff5d9da9976745e1fecc40f8))

View File

@@ -1 +1 @@
__version__ = "0.3.3" __version__ = "0.4.1"

View File

@@ -10,7 +10,7 @@ registry_address = 0xcf60ebc445b636a5ab787f9e8bc465a2a3ef8299
[meta] [meta]
url = http://localhost:63380 url = http://localhost:63380
http_origin = http_origin =
auth_token =
[rpc] [rpc]
provider = http://localhost:63545 provider = http://localhost:63545

View File

@@ -10,6 +10,7 @@ registry_address = 0xcf60ebc445b636a5ab787f9e8bc465a2a3ef8299
[meta] [meta]
url = http://localhost:8000 url = http://localhost:8000
http_origin = http_origin =
auth_token =
[rpc] [rpc]
provider = http://localhost:8545 provider = http://localhost:8545

View File

@@ -10,9 +10,10 @@ registry_address = 0xe3e3431BF25b06166513019Ed7B21598D27d05dC
[meta] [meta]
url = https://meta.sarafu.network url = https://meta.sarafu.network
http_origin = http_origin =
auth_token =
[rpc] [rpc]
provider = http://142.93.38.53:8545 provider = https://rpc.sarafu.network
[auth] [auth]
type = gnupg type = gnupg

View File

@@ -5,23 +5,23 @@ proof_writer = cic.writers.KVWriter
ext_writer = cic.writers.KVWriter ext_writer = cic.writers.KVWriter
[cic] [cic]
registry_address = 0xcf60ebc445b636a5ab787f9e8bc465a2a3ef8299 registry_address = 0x47269C43e4aCcA5CFd09CB4778553B2F69963303
[meta] [meta]
url = https://meta.grassecon.net url = https://meta.sarafu.network
http_origin = http_origin =
auth_token =
[rpc] [rpc]
provider = https://rpc.grassecon.net provider = https://rpc.sarafu.network
[auth] [auth]
type = gnupg type = gnupg
keyfile_path = /home/will/grassroots/cic-internal-integration/apps/cic-ussd/tests/data/pgp/privatekeys_meta.asc keyfile_path =
passphrase = merman passphrase =
[wallet] [wallet]
key_file = /home/will/grassroots/cic-internal-integration/apps/contract-migration/keystore key_file =
passphrase = passphrase =
[chain] [chain]
spec = evm:byzantium:5050:bloxberg spec = evm:kitabu:6060:sarafu

View File

@@ -4,8 +4,12 @@ import logging
import os import os
from typing import List from typing import List
# External imports
from chainlib.chain import ChainSpec from chainlib.chain import ChainSpec
from chainlib.cli.config import Config from chainlib.cli.config import Config
from cic_types.ext.metadata import MetadataRequestsHandler
from cic_types.ext.metadata.signer import Signer as MetadataSigner
# Local Modules # Local Modules
from cic.contract.components.attachment import Attachment from cic.contract.components.attachment import Attachment
from cic.contract.components.meta import Meta from cic.contract.components.meta import Meta
@@ -15,9 +19,7 @@ from cic.contract.helpers import init_writers_from_config
from cic.contract.network import Network from cic.contract.network import Network
from cic.contract.processor import ContractProcessor from cic.contract.processor import ContractProcessor
from cic.writers import HTTPWriter, KeyedWriterFactory, MetadataWriter from cic.writers import HTTPWriter, KeyedWriterFactory, MetadataWriter
# external imports
from cic_types.ext.metadata import MetadataRequestsHandler
from cic_types.ext.metadata.signer import Signer as MetadataSigner
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
@@ -146,9 +148,12 @@ def deploy_contract(
output_writer_path_meta = output_directory output_writer_path_meta = output_directory
metadata_endpoint = config.get("META_URL") metadata_endpoint = config.get("META_URL")
metadata_auth_token = config.get("META_AUTH_TOKEN")
if metadata_endpoint is not None: if metadata_endpoint is not None:
MetadataRequestsHandler.base_url = metadata_endpoint MetadataRequestsHandler.base_url = metadata_endpoint
MetadataRequestsHandler.auth_token = metadata_auth_token
MetadataSigner.gpg_path = "/tmp" MetadataSigner.gpg_path = "/tmp"
MetadataSigner.key_file_path = config.get("AUTH_KEYFILE_PATH") MetadataSigner.key_file_path = config.get("AUTH_KEYFILE_PATH")
MetadataSigner.gpg_passphrase = config.get("AUTH_PASSPHRASE") MetadataSigner.gpg_passphrase = config.get("AUTH_PASSPHRASE")

View File

@@ -11,7 +11,7 @@ from cic.contract.components.attachment import Attachment
from cic.contract.components.meta import Meta from cic.contract.components.meta import Meta
from cic.contract.components.proof import Proof from cic.contract.components.proof import Proof
from cic.contract.components.token import Token from cic.contract.components.token import Token
from cic.contract.constants import DMR_CONTRACT_URL from cic.contract.constants import DMR_CONTRACT_URL, GITABLE_CONTRACT_URL
from cic.contract.contract import Contract from cic.contract.contract import Contract
from cic.contract.helpers import download_file from cic.contract.helpers import download_file
from cic.contract.network import Network from cic.contract.network import Network
@@ -59,7 +59,6 @@ def load_contracts_from_csv(config, directory, csv_path: str) -> List[Contract]:
targets = ["eth"] targets = ["eth"]
os.makedirs(directory) os.makedirs(directory)
contract_rows = [] contract_rows = []
bin_path = os.path.abspath(download_file(DMR_CONTRACT_URL + ".bin"))
with open(csv_path, "rt", encoding="utf-8") as file: with open(csv_path, "rt", encoding="utf-8") as file:
csvreader = csv.reader(file, delimiter=",") csvreader = csv.reader(file, delimiter=",")
for idx, row in enumerate(csvreader): for idx, row in enumerate(csvreader):
@@ -88,22 +87,38 @@ def load_contracts_from_csv(config, directory, csv_path: str) -> List[Contract]:
sink_account = contract_row[CSV_Column.sink_account] sink_account = contract_row[CSV_Column.sink_account]
description = contract_row[CSV_Column.description] description = contract_row[CSV_Column.description]
if token_type != "demurrage": if token_type == "demurrage":
raise Exception( bin_path = os.path.abspath(download_file(DMR_CONTRACT_URL + ".bin"))
f"Only demurrage tokens are supported at this time. {token_type} is not supported" log.info(f"Generating {token_type} contract for {issuer}")
token = Token(
directory,
name=voucher_name,
symbol=symbol,
precision=precision,
supply=supply,
extra_args=[demurrage, period_minutes, sink_account],
extra_args_types=["uint256", "uint256", "address"],
code=bin_path,
) )
elif token_type == "giftable":
bin_path = os.path.abspath(download_file(GITABLE_CONTRACT_URL + ".bin"))
token = Token(
directory,
name=voucher_name,
symbol=symbol,
precision=precision,
supply=supply,
extra_args=[],
extra_args_types=[],
code=bin_path,
)
else:
raise Exception(
f"Only demurrage and gitable contracts currently supported at this time. {token_type} is not supported"
)
if token is None:
raise Exception(f"There was an issue building the contract")
log.info("Generating token")
token = Token(
directory,
name=voucher_name,
symbol=symbol,
precision=precision,
supply=supply,
extra_args=[demurrage, period_minutes, sink_account],
extra_args_types=["uint256", "uint256", "address"],
code=bin_path,
)
token.start() token.start()
log.info("Generating proof") log.info("Generating proof")

View File

@@ -10,7 +10,7 @@ registry_address = 0xe3e3431BF25b06166513019Ed7B21598D27d05dC
[meta] [meta]
url = https://meta.sarafu.network url = https://meta.sarafu.network
http_origin = http_origin =
auth_token =
[auth] [auth]
type = gnupg type = gnupg
keyfile_path = keyfile_path =

View File

@@ -90,7 +90,6 @@ def main():
except Exception as e: except Exception as e:
logg.exception(e) logg.exception(e)
sys.stderr.write("\033[;91m" + str(e) + "\033[;39m\n") sys.stderr.write("\033[;91m" + str(e) + "\033[;39m\n")
argparser.print_help()
sys.exit(1) sys.exit(1)

1272
poetry.lock generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
[tool.poetry] [tool.poetry]
name = "cic-cli" name = "cic-cli"
version = "0.3.3" version = "0.4.1"
description = "Generic cli tooling for the CIC token network" description = "Generic cli tooling for the CIC token network"
authors = [ authors = [
"Louis Holbrook <dev@holbrook.no>", "Louis Holbrook <dev@holbrook.no>",
@@ -32,27 +32,28 @@ cic = 'cic.runnable.cic_cmd:main'
[[tool.poetry.source]] [[tool.poetry.source]]
name = "grassroots_" name = "grassroots_"
url = "https://pip.grassrootseconomics.net/" url = "https://pip.grassrootseconomics.net/"
default = true secondary = true
[[tool.poetry.source]] [[tool.poetry.source]]
name = "pypi_" name = "pypi_"
url = "https://pypi.org/simple/" url = "https://pypi.org/simple/"
secondary = true default = true
[tool.poetry.dependencies] [tool.poetry.dependencies]
python = "^3.8" python = "^3.8"
funga-eth = "^0.5.0" funga-eth = "^0.6.0"
cic-types = "^0.2.0" cic-types = "^0.2.2"
confini = "^0.5.3" confini = "^0.6.0"
chainlib = "*" chainlib = "~0.1.0"
cbor2 = "5.4.1" cbor2 = "~5.4.1"
chainlib-eth = { version = "*", optional = true } chainlib-eth = { version = "~0.1.1", optional = true }
eth-token-index = { version = "^0.2.0", optional = true } eth-token-index = { version = "^0.3.0", optional = true }
eth-address-index = { version = "*", optional = true } eth-address-index = { version = "~0.5.0", optional = true }
okota = { version = "^0.2.0", optional = true } okota = { version = "^0.4.0", optional = true }
cic-eth-registry = { version = "^0.6.0", optional = true } cic-eth-registry = { version = "^0.6.9", optional = true }
cic-contracts = { version = "*", optional = true } cic-contracts = { version = "~0.1.0", optional = true }
[tool.poetry.dev-dependencies] [tool.poetry.dev-dependencies]
@@ -64,6 +65,7 @@ black = { version = "^22.1.0", allow-prereleases = true }
eth_tester = "0.5.0b3" eth_tester = "0.5.0b3"
py-evm = "0.3.0a20" py-evm = "0.3.0a20"
rlp = "2.0.1" rlp = "2.0.1"
mypy = "^0.961"
[tool.poetry.extras] [tool.poetry.extras]
eth = [ eth = [
@@ -93,4 +95,3 @@ build_command = "pip install poetry && poetry build"
hvcs = "gitea" hvcs = "gitea"
hvcs_domain = "git.grassecon.net" hvcs_domain = "git.grassecon.net"
check_build_status = false check_build_status = false

View File

@@ -1,12 +1,12 @@
import os import os
import tempfile import tempfile
import pytest
from cic.contract.csv import load_contract_from_csv from cic.contract.csv import load_contract_from_csv
from tests.base_cic import test_data_dir from tests.base_cic import test_data_dir
@pytest.mark.skip(reason="Public RPC is currently dead")
def test_csv_generate(): def test_csv_generate_demurrage():
outputs_dir = os.path.join(tempfile.mkdtemp(), "outputs") outputs_dir = os.path.join(tempfile.mkdtemp(), "outputs")
test_csv_path = os.path.join(test_data_dir, "voucher", "bondi.csv") test_csv_path = os.path.join(test_data_dir, "voucher", "bondi.csv")
contract = load_contract_from_csv( contract = load_contract_from_csv(
@@ -72,3 +72,67 @@ def test_csv_generate():
assert contract.proof.namespace == "ge" assert contract.proof.namespace == "ge"
assert contract.proof.proofs == [] assert contract.proof.proofs == []
assert contract.proof.version() == 0 assert contract.proof.version() == 0
@pytest.mark.skip(reason="Public RPC is currently dead")
def test_csv_generate_giftable():
outputs_dir = os.path.join(tempfile.mkdtemp(), "outputs")
test_csv_path = os.path.join(test_data_dir, "voucher", "bondi_giftable.csv")
contract = load_contract_from_csv(
{
"WALLET_KEY_FILE": os.path.join(test_data_dir, "keystore", "ok"),
"WALLET_PASSPHRASE": "test",
"CHAIN_SPEC": "evm:kitabu:6060:sarafu",
"RPC_PROVIDER": "http://142.93.38.53:8545",
"CIC_REGISTRY_ADDRESS": "0xe3e3431BF25b06166513019Ed7B21598D27d05dC",
},
outputs_dir,
csv_path=test_csv_path,
)
# assert len(contracts) == 1
# contract = contracts[0]
# Token
assert contract.token.name == "Bondeni"
assert contract.token.extra_args == []
assert contract.token.extra_args_types == []
# assert contract.token.code == os.path.join(test_data_dir, "contracts", "Bondi.bin")
assert contract.token.precision == '6'
assert contract.token.supply == "5025"
assert contract.token.symbol == "BONDE"
# Meta
assert contract.meta.country_code == "KE"
assert contract.meta.location == "Mutitu Kilifi"
assert contract.meta.contact == {
"email": "info@grassecon.org",
"phone": "254797782065",
}
assert contract.meta.name == "Bondeni SHG"
# Network
assert contract.network.resources["eth"]["chain_spec"] == {
"arch": "evm",
"common_name": "sarafu",
"custom": [],
"extra": {},
"fork": "kitabu",
"network_id": 6060,
}
assert contract.network.resources["eth"]["contents"] == {
"address_declarator": {
"key_account": "cc4f82f5dacde395e1e0cfc4d62827c8b8b5688c",
"reference": "f055e83f713DbFF947e923749Af9802eaffFB5f9",
},
"token": {
"key_account": "cc4f82f5dacde395e1e0cfc4d62827c8b8b5688c",
"reference": None,
},
"token_index": {
"key_account": "cc4f82f5dacde395e1e0cfc4d62827c8b8b5688c",
"reference": "5A1EB529438D8b3cA943A45a48744f4c73d1f098",
},
}
assert contract.proof.description == "1 BONDE = 1 itumbe"
assert contract.proof.namespace == "ge"
assert contract.proof.proofs == []
assert contract.proof.version() == 0

View File

@@ -0,0 +1,2 @@
issuer,namespace,voucher_name,symbol,location,country_code,supply,precision,token_type,demurrage,period_minutes,phone_number,email_address,sink_account,description
Bondeni SHG,ge,Bondeni,BONDE,Mutitu Kilifi,KE,5025,6,giftable,,,254797782065,info@grassecon.org,,1 BONDE = 1 itumbe
1 issuer namespace voucher_name symbol location country_code supply precision token_type demurrage period_minutes phone_number email_address sink_account description
2 Bondeni SHG ge Bondeni BONDE Mutitu Kilifi KE 5025 6 giftable 254797782065 info@grassecon.org 1 BONDE = 1 itumbe