forked from Carbonable/carbon-protocol
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- create config file at each folder level - create a python file to mutualize hints code
- Loading branch information
Showing
12 changed files
with
107 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import yaml | ||
import collections.abc | ||
from collections import namedtuple | ||
from pathlib import Path | ||
|
||
|
||
class Object(): | ||
pass | ||
|
||
|
||
def update(ref: dict, new: dict) -> dict: | ||
"""Update ref recursively with new.""" | ||
for key, value in new.items(): | ||
if isinstance(value, collections.abc.Mapping): | ||
ref[key] = update(ref.get(key, {}), value) | ||
else: | ||
ref[key] = value | ||
return ref | ||
|
||
|
||
def objectify(parent: object, attributes: dict) -> object: | ||
"""Set attributes recursively to parent object.""" | ||
for key, value in attributes.items(): | ||
if isinstance(value, dict): | ||
value = objectify(Object(), value) | ||
setattr(parent, key, value) | ||
return parent | ||
|
||
|
||
def load(path: str, context: object): | ||
"""Read config files and setup context.""" | ||
# load config | ||
path = Path(path) | ||
config = {} | ||
for parent in path.parents: | ||
config_path = parent / path.name | ||
if not config_path.exists(): | ||
continue | ||
with open(config_path, 'r') as file_instance: | ||
update(config, yaml.safe_load(file_instance)) | ||
|
||
# set up context | ||
context = objectify(context, config) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
signers: | ||
admin: 1000 | ||
anyone: 1001 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
project: | ||
name: Project | ||
symbol: NFT | ||
|
||
token: | ||
name: Token | ||
symbol: TOK | ||
decimals: 6 | ||
initial_supply: 1000000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
mocks: | ||
project_nft_address: 0x056d4ffea4ca664ffe1256af4b029998014471a87dec8036747a927ab3320b46 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,3 @@ | ||
signers: | ||
admin: 1000 | ||
anyone: 1001 | ||
|
||
mocks: | ||
project_nft_address: 0x056d4ffea4ca664ffe1256af4b029998014471a87dec8036747a927ab3320b46 | ||
carbonable_token_address: 0x043eB0d3D84CC1f850D4b6dEe9630cAc35Af99980BAA30577A76adEa72475598 | ||
reward_token_address: 0x073314940630fd6dcda0d772d4c972c4e0a9946bef9dabf4ef84eda8ef542b82 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters