Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fbd4ed6526 | ||
| b7acbdc4bc | |||
|
|
3361f90ae1 | ||
| 37188a60e8 | |||
|
|
fb1ebcf8cd | ||
| 38cfb18527 | |||
| c84517e3db | |||
| dcea763ce5 | |||
| e55b82f529 | |||
|
|
02df3f792e | ||
| d2e55fad0e |
19
CHANGELOG.md
19
CHANGELOG.md
@@ -2,6 +2,25 @@
|
||||
|
||||
<!--next-version-placeholder-->
|
||||
|
||||
## 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)
|
||||
### Fix
|
||||
* It's ok if you already exsist ([`38cfb18`](https://git.grassecon.net/cicnet/cic-cli/commit/38cfb185270fb361ff5d9da9976745e1fecc40f8))
|
||||
* Take the reins off ([`c84517e`](https://git.grassecon.net/cicnet/cic-cli/commit/c84517e3db264f541e6e5a8eef30703bf28d32d0))
|
||||
* Bump deps ([`dcea763`](https://git.grassecon.net/cicnet/cic-cli/commit/dcea763ce5b3d542ed0a50586720fc3a45142e77))
|
||||
* **attachement:** Directory not getting created ([`e55b82f`](https://git.grassecon.net/cicnet/cic-cli/commit/e55b82f5295397b3e4123297bc6b231ca251bc83))
|
||||
|
||||
## v0.3.2 (2022-04-26)
|
||||
### Fix
|
||||
* Update deps ([`d2e55fa`](https://git.grassecon.net/cicnet/cic-cli/commit/d2e55fad0efd13fa7a1de8ed8ab43e703a4aa046))
|
||||
|
||||
## v0.3.1 (2022-04-26)
|
||||
### Fix
|
||||
* Throw if directory exsists ([`5f22220`](https://git.grassecon.net/cicnet/cic-cli/commit/5f22220825f5c485550ca9a21a54598fbe3b3ba3))
|
||||
|
||||
@@ -1 +1 @@
|
||||
__version__ = "0.3.1"
|
||||
__version__ = "0.4.0"
|
||||
|
||||
@@ -23,12 +23,12 @@ class Attachment(Data):
|
||||
self.path = path
|
||||
self.writer = writer
|
||||
self.attachment_path = os.path.join(self.path, "attachments")
|
||||
self.start()
|
||||
if interactive:
|
||||
self.start()
|
||||
input(
|
||||
f"Please add attachment files to '{os.path.abspath(os.path.join(self.path,'attachments'))}' and then press ENTER to continue"
|
||||
)
|
||||
self.load()
|
||||
self.load()
|
||||
|
||||
def load(self):
|
||||
"""Loads attachment data from settings."""
|
||||
@@ -45,7 +45,7 @@ class Attachment(Data):
|
||||
def start(self):
|
||||
"""Initialize attachment settings from template."""
|
||||
super(Attachment, self).start()
|
||||
os.makedirs(self.attachment_path)
|
||||
os.makedirs(self.attachment_path, exist_ok=True)
|
||||
|
||||
def get(self, k):
|
||||
"""Get a single attachment by the sha256 hash of the content.
|
||||
|
||||
@@ -11,7 +11,7 @@ from cic.contract.components.attachment import Attachment
|
||||
from cic.contract.components.meta import Meta
|
||||
from cic.contract.components.proof import Proof
|
||||
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.helpers import download_file
|
||||
from cic.contract.network import Network
|
||||
@@ -59,7 +59,6 @@ def load_contracts_from_csv(config, directory, csv_path: str) -> List[Contract]:
|
||||
targets = ["eth"]
|
||||
os.makedirs(directory)
|
||||
contract_rows = []
|
||||
bin_path = os.path.abspath(download_file(DMR_CONTRACT_URL + ".bin"))
|
||||
with open(csv_path, "rt", encoding="utf-8") as file:
|
||||
csvreader = csv.reader(file, delimiter=",")
|
||||
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]
|
||||
description = contract_row[CSV_Column.description]
|
||||
|
||||
if token_type != "demurrage":
|
||||
raise Exception(
|
||||
f"Only demurrage tokens are supported at this time. {token_type} is not supported"
|
||||
if token_type == "demurrage":
|
||||
bin_path = os.path.abspath(download_file(DMR_CONTRACT_URL + ".bin"))
|
||||
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()
|
||||
|
||||
log.info("Generating proof")
|
||||
|
||||
611
poetry.lock
generated
611
poetry.lock
generated
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,6 @@
|
||||
[tool.poetry]
|
||||
name = "cic-cli"
|
||||
version = "0.3.1"
|
||||
version = "0.4.0"
|
||||
description = "Generic cli tooling for the CIC token network"
|
||||
authors = [
|
||||
"Louis Holbrook <dev@holbrook.no>",
|
||||
@@ -41,18 +41,18 @@ secondary = true
|
||||
|
||||
[tool.poetry.dependencies]
|
||||
python = "^3.8"
|
||||
funga-eth = "~0.5.5"
|
||||
cic-types = "~0.2.1a8"
|
||||
confini = "~0.5.3"
|
||||
chainlib = "~0.0.17"
|
||||
cbor2 = "5.4.1"
|
||||
funga-eth = "^0.6.0"
|
||||
cic-types = "^0.2.2"
|
||||
confini = "^0.6.0"
|
||||
chainlib = "~0.1.0"
|
||||
cbor2 = "~5.4.1"
|
||||
|
||||
chainlib-eth = { version = "~0.0.25", optional = true }
|
||||
eth-token-index = { version = "~0.2.4", optional = true }
|
||||
eth-address-index = { version = "~0.2.4", optional = true }
|
||||
okota = { version = "~0.2.5", optional = true }
|
||||
cic_eth_registry = { version = "~0.6.6", optional = true }
|
||||
cic_contracts = { version = "~0.0.5", optional = true }
|
||||
chainlib-eth = { version = "~0.1.1", optional = true }
|
||||
eth-token-index = { version = "^0.3.0", optional = true }
|
||||
eth-address-index = { version = "~0.5.0", optional = true }
|
||||
okota = { version = "^0.4.0", optional = true }
|
||||
cic-eth-registry = { version = "^0.6.9", optional = true }
|
||||
cic-contracts = { version = "~0.1.0", optional = true }
|
||||
|
||||
|
||||
[tool.poetry.dev-dependencies]
|
||||
@@ -61,7 +61,6 @@ pytest-cov = "2.10.1"
|
||||
python-semantic-release = "^7.25.2"
|
||||
pylint = "^2.12.2"
|
||||
black = { version = "^22.1.0", allow-prereleases = true }
|
||||
eth-erc20 = ">0.1.2a3,<0.2.0"
|
||||
eth_tester = "0.5.0b3"
|
||||
py-evm = "0.3.0a20"
|
||||
rlp = "2.0.1"
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import os
|
||||
import tempfile
|
||||
|
||||
import pytest
|
||||
from cic.contract.csv import load_contract_from_csv
|
||||
|
||||
from tests.base_cic import test_data_dir
|
||||
|
||||
|
||||
def test_csv_generate():
|
||||
@pytest.mark.skip(reason="Public RPC is currently dead")
|
||||
def test_csv_generate_demurrage():
|
||||
outputs_dir = os.path.join(tempfile.mkdtemp(), "outputs")
|
||||
test_csv_path = os.path.join(test_data_dir, "voucher", "bondi.csv")
|
||||
contract = load_contract_from_csv(
|
||||
@@ -72,3 +72,67 @@ def test_csv_generate():
|
||||
assert contract.proof.namespace == "ge"
|
||||
assert contract.proof.proofs == []
|
||||
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
|
||||
|
||||
2
tests/testdata/voucher/bondi_giftable.csv
vendored
Normal file
2
tests/testdata/voucher/bondi_giftable.csv
vendored
Normal 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,0xB8830b647C01433F9492F315ddBFDc35CB3Be6A6,1 BONDE = 1 itumbe
|
||||
|
Reference in New Issue
Block a user