Compare commits

..

2 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
8 changed files with 2088 additions and 2209 deletions

View File

@ -2,30 +2,6 @@
<!--next-version-placeholder--> <!--next-version-placeholder-->
## v0.5.5 (2023-03-24)
### Fix
* Lock erc20-demurrage-token ([`3cde79e`](https://git.grassecon.net/cicnet/cic-cli/commit/3cde79ef8fb77a6b03454e675568834e0ab4ba80))
## v0.5.4 (2022-07-05)
### Fix
* Pass headers through KeyedWriterFactory ([`de78753`](https://git.grassecon.net/cicnet/cic-cli/commit/de78753675242dd253359a5a5601d9062d81f0ee))
## v0.5.3 (2022-07-05)
### Fix
* Add auth headers to HTTPWriter ([`4eda0fb`](https://git.grassecon.net/cicnet/cic-cli/commit/4eda0fb5cc2c41a735619dc3e34f21c4e27fd112))
## v0.5.2 (2022-07-05)
### Fix
* Bump cic-types ([`15ae114`](https://git.grassecon.net/cicnet/cic-cli/commit/15ae1143a5230078219072d096741546ebcc3d07))
## v0.5.1 (2022-07-05)
### Fix
* Upgrade cic-types to support meta auth ([`22b3062`](https://git.grassecon.net/cicnet/cic-cli/commit/22b3062c4909400664bd2a50ca36d5ee737531a1))
## v0.5.0 (2022-07-04)
### Feature
* Add meta-auth ([#4](https://git.grassecon.net/cicnet/cic-cli/issues/4)) ([`bfe7086`](https://git.grassecon.net/cicnet/cic-cli/commit/bfe7086178f3fc2743dd68cc20c5459ca466ae8e))
## v0.4.1 (2022-06-14) ## v0.4.1 (2022-06-14)
### Fix ### Fix
* Bump deps ([`e36ea4b`](https://git.grassecon.net/cicnet/cic-cli/commit/e36ea4bcfb1c417d1adf2be9455cb20b23323414)) * Bump deps ([`e36ea4b`](https://git.grassecon.net/cicnet/cic-cli/commit/e36ea4bcfb1c417d1adf2be9455cb20b23323414))

View File

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

View File

@ -1,5 +1,5 @@
GITABLE_CONTRACT_URL = "https://gitlab.com/cicnet/eth-erc20/-/raw/master/python/giftable_erc20_token/data/GiftableToken" GITABLE_CONTRACT_URL = "https://gitlab.com/cicnet/eth-erc20/-/raw/master/python/giftable_erc20_token/data/GiftableToken"
DMR_CONTRACT_URL = "https://gitlab.com/cicnet/erc20-demurrage-token/-/raw/v0.1.1/python/erc20_demurrage_token/data/DemurrageTokenSingleNocap" DMR_CONTRACT_URL = "https://gitlab.com/cicnet/erc20-demurrage-token/-/raw/master/python/erc20_demurrage_token/data/DemurrageTokenSingleNocap"
CONTRACT_URLS = [ CONTRACT_URLS = [
{ {

View File

@ -7,6 +7,8 @@ from typing import List
# External imports # 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
@ -17,8 +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
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__)
@ -148,7 +149,7 @@ def deploy_contract(
metadata_endpoint = config.get("META_URL") metadata_endpoint = config.get("META_URL")
metadata_auth_token = config.get("META_AUTH_TOKEN") metadata_auth_token = config.get("META_AUTH_TOKEN")
headers = {"Authorization": f"Basic {metadata_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 MetadataRequestsHandler.auth_token = metadata_auth_token
@ -167,12 +168,12 @@ def deploy_contract(
) )
ca = Attachment( ca = Attachment(
path=contract_directory, path=contract_directory,
writer=writers["attachment"](path=output_writer_path_meta, headers=headers), writer=writers["attachment"](path=output_writer_path_meta),
) )
cp = Proof( cp = Proof(
path=contract_directory, path=contract_directory,
attachments=ca, attachments=ca,
writer=writers["proof"](path=output_writer_path_meta, headers=headers), writer=writers["proof"](path=output_writer_path_meta),
) )
cn = Network(path=contract_directory) cn = Network(path=contract_directory)

View File

@ -84,7 +84,6 @@ class ContractProcessor:
if a is None: if a is None:
logg.debug(f'skipping missing task receiver "{task}"') logg.debug(f'skipping missing task receiver "{task}"')
continue continue
logg.debug(f'Processing "{ext}:{task}"')
v = a.process( v = a.process(
token_address=token_address, token_address=token_address,
token_symbol=token_symbol, token_symbol=token_symbol,

View File

@ -5,7 +5,7 @@ import logging
import os import os
import sys import sys
import urllib.request import urllib.request
from typing import Dict, Type, Union from typing import Type, Union
from cic_types.ext.metadata import MetadataPointer, MetadataRequestsHandler from cic_types.ext.metadata import MetadataPointer, MetadataRequestsHandler
@ -33,7 +33,6 @@ class KVWriter(OutputWriter):
os.makedirs(path) os.makedirs(path)
self.path = path self.path = path
super().__init__(*args, **kwargs) super().__init__(*args, **kwargs)
def write(self, k, v): def write(self, k, v):
fp = os.path.join(self.path, str(k)) fp = os.path.join(self.path, str(k))
logg.debug(f"path write {fp} {str(v)}") logg.debug(f"path write {fp} {str(v)}")
@ -43,17 +42,16 @@ class KVWriter(OutputWriter):
class HTTPWriter(OutputWriter): class HTTPWriter(OutputWriter):
def __init__(self, path=None, headers: Dict[str, str] = None, *args, **kwargs): def __init__(self, path=None, *args, **kwargs):
super(HTTPWriter, self).__init__(*args, **kwargs) super(HTTPWriter, self).__init__(*args, **kwargs)
self.path = path self.path = path
self.headers = headers
def write(self, k, v): def write(self, k, v):
path = self.path path = self.path
if k is not None: if k is not None:
path = os.path.join(path, k) path = os.path.join(path, k)
logg.debug(f"HTTPWriter POST {path} data: {v}, headers: {self.headers}") logg.debug(f"http writer post {path} \n key: {k}, value: {v}")
rq = urllib.request.Request(path, method="POST", data=v, headers=self.headers) rq = urllib.request.Request(path, method="POST", data=v)
r = urllib.request.urlopen(rq) r = urllib.request.urlopen(rq)
logg.info(f"http writer submitted at {r.read()}") logg.info(f"http writer submitted at {r.read()}")
@ -85,15 +83,13 @@ class KeyedWriterFactory:
logg.debug(f"adding key {k} t keyed writer factory") logg.debug(f"adding key {k} t keyed writer factory")
self.x[k] = v self.x[k] = v
def new(self, path=None, headers: Dict[str, str] = None, *_args, **_kwargs): def new(self, path=None, *_args, **_kwargs):
writer_keyed = None writer_keyed = None
writer_immutable = None writer_immutable = None
if self.key_writer_constructor is not None: if self.key_writer_constructor is not None:
writer_keyed = self.key_writer_constructor(path, **self.x) writer_keyed = self.key_writer_constructor(path, **self.x)
if self.immutable_writer_constructor is not None: if self.immutable_writer_constructor is not None:
writer_immutable = self.immutable_writer_constructor( writer_immutable = self.immutable_writer_constructor(path, **self.x)
path, headers, **self.x
)
return KeyedWriter(writer_keyed, writer_immutable) return KeyedWriter(writer_keyed, writer_immutable)

4235
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.5.5" 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,20 +32,18 @@ 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 = false
secondary = true secondary = true
[[tool.poetry.source]] [[tool.poetry.source]]
name = "pypi_" name = "pypi_"
url = "https://pypi.org/simple/" url = "https://pypi.org/simple/"
default = true default = true
secondary = false
[tool.poetry.dependencies] [tool.poetry.dependencies]
python = "^3.8" python = "^3.8"
funga-eth = "^0.6.0" funga-eth = "^0.6.0"
cic-types = "^0.2.7" cic-types = "^0.2.2"
confini = "^0.6.0" confini = "^0.6.0"
chainlib = "~0.1.0" chainlib = "~0.1.0"
cbor2 = "~5.4.1" cbor2 = "~5.4.1"