Skip to content

Commit

Permalink
Update config generation
Browse files Browse the repository at this point in the history
  • Loading branch information
DmytroNazarenko committed Apr 3, 2022
1 parent 56708ab commit 3bec77b
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 3 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ artifacts.json

# Dependency directories
node_modules/
venv/

# Idea files
.idea/
Expand Down
32 changes: 32 additions & 0 deletions scripts/generate_config.py
Original file line number Diff line number Diff line change
@@ -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))
5 changes: 2 additions & 3 deletions scripts/generate_config.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 3bec77b

Please sign in to comment.