From 3bec77baca7fe82fe59c76f71eebe974dd01be5e Mon Sep 17 00:00:00 2001 From: DmytroNazarenko Date: Mon, 4 Apr 2022 00:07:22 +0300 Subject: [PATCH] Update config generation --- .github/workflows/test.yml | 6 ++++++ .gitignore | 1 + scripts/generate_config.py | 32 ++++++++++++++++++++++++++++++++ scripts/generate_config.sh | 5 ++--- 4 files changed, 41 insertions(+), 3 deletions(-) create mode 100644 scripts/generate_config.py diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 62076bc..ce74288 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -24,6 +24,12 @@ jobs: uses: actions/setup-node@v1 with: node-version: ${{ matrix.node }} + + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: 3.8 + - name: Install dependencies run: | npm i diff --git a/.gitignore b/.gitignore index c2587d0..2a8f5cc 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,7 @@ artifacts.json # Dependency directories node_modules/ +venv/ # Idea files .idea/ diff --git a/scripts/generate_config.py b/scripts/generate_config.py new file mode 100644 index 0000000..a065789 --- /dev/null +++ b/scripts/generate_config.py @@ -0,0 +1,32 @@ +import json +import os + +from predeployed_generator.openzeppelin.proxy_admin_generator import ProxyAdminGenerator +from filestorage_predeployed import (UpgradeableFileStorageGenerator, FILESTORAGE_ADDRESS, + FILESTORAGE_IMPLEMENTATION_ADDRESS, + FILESTORAGE_ADMIN_ADDRESS) + +DIR_PATH = os.path.join(os.path.dirname(os.path.realpath(__file__)), '..', 'test') +BASE_CONFIG_PATH = os.path.join(DIR_PATH, 'data', 'base_config.json') +CONFIG_PATH = os.path.join(DIR_PATH, 'data', 'config.json') + +if __name__ == '__main__': + with open(BASE_CONFIG_PATH, 'r') as f: + raw_config = f.read() + config = json.loads(raw_config) + schain_owner = config['skaleConfig']['sChain']['schainOwner'] + proxy_admin = ProxyAdminGenerator().generate_allocation( + contract_address=FILESTORAGE_ADMIN_ADDRESS, + owner_address=schain_owner + ) + filestorage_upgradeable = UpgradeableFileStorageGenerator().generate_allocation( + contract_address=FILESTORAGE_ADDRESS, + proxy_admin_address=FILESTORAGE_ADMIN_ADDRESS, + implementation_address=FILESTORAGE_IMPLEMENTATION_ADDRESS, + allocated_storage=10000000, + schain_owner=schain_owner + ) + config['accounts'].update(proxy_admin) + config['accounts'].update(filestorage_upgradeable) + with open(CONFIG_PATH, 'w') as f: + f.write(json.dumps(config, indent=4)) diff --git a/scripts/generate_config.sh b/scripts/generate_config.sh index 19026ba..09516d8 100644 --- a/scripts/generate_config.sh +++ b/scripts/generate_config.sh @@ -1,6 +1,5 @@ VERSION=$(node -p "require('@skalenetwork/filestorage/package.json').version") ARTIFACTS_PATH=$PWD/test/data/artifacts.json -curl -LJO https://github.com/skalenetwork/filestorage/releases/download/$VERSION/artifacts.json -mv artifacts.json $ARTIFACTS_PATH -node -e 'require("./test/utils/helper.js").generateConfig()' +pip install filestorage-predeployed==$VERSION +python scripts/generate_config.py