Skip to content

Commit

Permalink
Merge pull request #87 from infinitybase/staging
Browse files Browse the repository at this point in the history
Staging
  • Loading branch information
guimroque authored Apr 4, 2024
2 parents a3d3abb + 311cd03 commit e340736
Show file tree
Hide file tree
Showing 39 changed files with 645 additions and 366 deletions.
41 changes: 41 additions & 0 deletions .env.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Database
DATABASE_ENVIRONMENT=test
DATABASE_HOST=127.0.0.1
DATABASE_PORT=5432
DATABASE_USERNAME=postgres
DATABASE_PASSWORD=postgres
DATABASE_NAME=postgres

# App
API_PORT=3334
API_NAME=bsafe-api
API_DOCKERFILE=Dockerfile.stg
API_ENVIRONMENT=development
UI_URL=https://safe.bako.global
API_URL=http://localhost:3333
API_DEFAULT_NETWORK=http://127.0.0.1:4000/graphql
ASSETS_URL=https://besafe-asset.s3.amazonaws.com/icon


# Admin user
APP_ADMIN_EMAIL=admin_user_email
APP_ADMIN_PASSWORD=admin_user_password


# ADMIN USER
APP_ADMIN_EMAIL=admin_user_email
APP_ADMIN_PASSWORD=admin_user_password

# TOKENS
ACCESS_TOKEN_SECRET=access_token_secret
REFRESH_TOKEN_SECRET=refresh_token_secret

# AWS
AWS_SMTP_USER=
AWS_SMTP_PASS=

# EMAIL
EMAIL_FROM="Bako Safe <[email protected]>"
MAIL_TESTING_NOTIFICATIONS=[email protected]


2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,5 @@ pnpm-lock.yaml

# Tests
docker/database/postgresql
docker/database/postgresqltest
docker/database/postgresqldev
2 changes: 0 additions & 2 deletions Dockerfile.stg
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
FROM node:18.18.2


# Create app directory
WORKDIR api

ADD . /api

# Install app dependencies
Expand Down
15 changes: 13 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
prod:
deploy-prod:
sudo docker-compose -f docker-compose.yml --env-file ${env_file} up --build -d

stg:
deploy-stg:
sudo docker-compose -f docker-compose.yml --env-file ${env_file} up --build -d

deploy-test:
sudo docker-compose -f docker-compose.yml --env-file ${env_file} up --build -d

database-init:
sudo docker-compose -f docker/database/docker-compose.yml --env-file ${env_file} up --build -d

database-down:
sudo docker-compose -f docker/database/docker-compose.yml --env-file ${env_file} down

chain-start:
sudo docker-compose -f docker/chain/docker-compose.yml --env-file ${env_file} up --build -d
6 changes: 6 additions & 0 deletions docker/chain/.env.chain
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
PROJECT=bsafe
MIN_GAS_PRICE=1
WALLET_SECRET=0xa449b1ffee0e2205fa924c6740cc48b3b473aa28587df6dab12abc245d1f5298
DISPENSE_AMOUNT=500000000
FUEL_CORE_PORT=4000
FUEL_FAUCET_PORT=4040
17 changes: 17 additions & 0 deletions docker/chain/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
up:
docker compose -p dev --env-file .env.chain up -d --build

up-test:
docker compose -p test --env-file .env.test up -d --build

down:
docker compose -p dev stop

down-test:
docker compose -p test stop

clean:
docker compose -p dev down --rmi local -v --remove-orphans

clean-test:
docker compose -p test down --rmi local -v --remove-orphans
45 changes: 45 additions & 0 deletions docker/chain/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
version: '3'

services:
fuel-core:
platform: linux/amd64
container_name: '${PROJECT:-fuel-node}_fuel-core'
environment:
NETWORK_NAME: '${PROJECT} local'
MIN_GAS_PRICE: ${MIN_GAS_PRICE}
# This is the private key of the consensus.PoA.signing_key in the chainConfig.json
# this key is responsible for validating the transactions
CONSENSUS_KEY: ${WALLET_SECRET}
build: ./fuel-core
ports:
- '${FUEL_CORE_PORT:-4000}:4000'
volumes:
- fuel-core-db:/mnt/db
healthcheck:
test: curl --fail http://localhost:4000/health || exit 1
interval: 1s
timeout: 5s
retries: 20

faucet:
platform: linux/amd64
container_name: '${PROJECT:-fuel-node}_faucet'
environment:
# Other configurations can be found at;
# https://github.com/FuelLabs/faucet#configuration
MIN_GAS_PRICE: ${MIN_GAS_PRICE}
WALLET_SECRET_KEY: ${WALLET_SECRET}
DISPENSE_AMOUNT: ${DISPENSE_AMOUNT}
FUEL_NODE_URL: http://${PROJECT:-fuel-node}_fuel-core:4000/graphql
image: ghcr.io/fuellabs/faucet:v0.6.2
ports:
- '${FUEL_FAUCET_PORT:-4040}:3000'
links:
- fuel-core
depends_on:
fuel-core:
condition: service_healthy

volumes:
fuel-core-db:
name: '${PROJECT:-fuel-node}_fuel-core-db'
18 changes: 18 additions & 0 deletions docker/chain/fuel-core/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM ghcr.io/fuellabs/fuel-core:v0.22.0

ENV MIN_GAS_PRICE="${MIN_GAS_PRICE}"
ENV CONSENSUS_KEY="${CONSENSUS_KEY}"
ENV NETWORK_NAME="${NETWORK_NAME}"

# Install curl to use on
# healthcheck config
RUN apt update
RUN apt install curl -y

WORKDIR /root/

COPY chainConfig.json .
COPY run.sh .
EXPOSE ${PORT}

CMD ["sh", "./run.sh"]
10 changes: 10 additions & 0 deletions docker/chain/fuel-core/accounts.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[
{
"account": "0xc8e615a4089466174459ef19cfd257d2e17adfabff3b8f219dbb5fb4eca87c50",
"privateKey": "0xba9e8401405cd4327119548bccf0cd8b195c3fb716c848d9571c60bb230c6978"
},
{
"account": "0x92dffc873b56f219329ed03bb69bebe8c3d8b041088574882f7a6404f02e2f28",
"privateKey": "0xa349d39f614a3085b7f7f8cef63fd5189136924fc1238e6d25ccdaa43a901cd0"
}
]
212 changes: 212 additions & 0 deletions docker/chain/fuel-core/chainConfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,212 @@
{
"chain_name": "local_testnet",
"consensus": {
"PoA": {
"signing_key": "0x94ffcc53b892684acefaebc8a3d4a595e528a8cf664eeb3ef36f1020b0809d0d"
}
},
"parent_network": {
"type": "LocalTest"
},
"block_gas_limit": 5000000000,
"consensus_parameters": {
"tx_params": {
"max_inputs": 255,
"max_outputs": 255,
"max_witnesses": 255,
"max_gas_per_tx": 10000000,
"max_size": 17825792
},
"predicate_params": {
"max_predicate_length": 1048576,
"max_predicate_data_length": 1048576,
"max_gas_per_predicate": 10000000,
"max_message_data_length": 1048576
},
"script_params": {
"max_script_length": 1048576,
"max_script_data_length": 1048576
},
"contract_params": {
"contract_max_size": 16777216,
"max_storage_slots": 255
},
"fee_params": {
"gas_price_factor": 92,
"gas_per_byte": 4
}
},
"gas_costs": {
"add": 1,
"addi": 1,
"aloc": 1,
"and": 1,
"andi": 1,
"bal": 13,
"bhei": 1,
"bhsh": 1,
"burn": 132,
"cb": 1,
"cfei": 1,
"cfsi": 1,
"croo": 16,
"div": 1,
"divi": 1,
"ecr1": 3000,
"eck1": 951,
"ed19": 3000,
"eq": 1,
"exp": 1,
"expi": 1,
"flag": 1,
"gm": 1,
"gt": 1,
"gtf": 1,
"ji": 1,
"jmp": 1,
"jne": 1,
"jnei": 1,
"jnzi": 1,
"jmpf": 1,
"jmpb": 1,
"jnzf": 1,
"jnzb": 1,
"jnef": 1,
"jneb": 1,
"k256": 11,
"lb": 1,
"log": 9,
"lt": 1,
"lw": 1,
"mcpi": 33,
"mint": 135,
"mlog": 1,
"modOp": 1,
"modi": 1,
"moveOp": 1,
"movi": 1,
"mroo": 2,
"mul": 1,
"muli": 1,
"mldv": 1,
"noop": 1,
"not": 1,
"or": 1,
"ori": 1,
"ret": 13,
"rvrt": 13,
"s256": 2,
"sb": 1,
"scwq": 13,
"sll": 1,
"slli": 1,
"srl": 1,
"srli": 1,
"srw": 12,
"sub": 1,
"subi": 1,
"sw": 1,
"sww": 43,
"swwq": 44,
"time": 1,
"tr": 105,
"tro": 60,
"wdcm": 1,
"wqcm": 1,
"wdop": 1,
"wqop": 1,
"wdml": 1,
"wqml": 1,
"wddv": 1,
"wqdv": 2,
"wdmd": 3,
"wqmd": 4,
"wdam": 2,
"wqam": 3,
"wdmm": 3,
"wqmm": 3,
"xor": 1,
"xori": 1,
"call": {
"base": 144,
"dep_per_unit": 214
},
"ccp": {
"base": 15,
"dep_per_unit": 103
},
"csiz": {
"base": 17,
"dep_per_unit": 790
},
"ldc": {
"base": 15,
"dep_per_unit": 272
},
"logd": {
"base": 26,
"dep_per_unit": 64
},
"mcl": {
"base": 1,
"dep_per_unit": 3333
},
"mcli": {
"base": 1,
"dep_per_unit": 3333
},
"mcp": {
"base": 1,
"dep_per_unit": 2000
},
"meq": {
"base": 1,
"dep_per_unit": 2500
},
"retd": {
"base": 29,
"dep_per_unit": 62
},
"smo": {
"base": 209,
"dep_per_unit": 55
},
"srwq": {
"base": 47,
"dep_per_unit": 5
}
},
"wallet": {
"address": "0x94ffcc53b892684acefaebc8a3d4a595e528a8cf664eeb3ef36f1020b0809d0d",
"privateKey": "0xa449b1ffee0e2205fa924c6740cc48b3b473aa28587df6dab12abc245d1f5298"
},
"initial_state": {
"coins": [
{
"owner": "0x94ffcc53b892684acefaebc8a3d4a595e528a8cf664eeb3ef36f1020b0809d0d",
"amount": "0xFFFFFFFFFFFFFFFF",
"asset_id": "0x0000000000000000000000000000000000000000000000000000000000000000"
},
{
"owner": "0x94ffcc53b892684acefaebc8a3d4a595e528a8cf664eeb3ef36f1020b0809d0d",
"amount": "0xFFFFFFFFFFFFFFFF",
"asset_id": "0x1bdeed96ee1e5eca0bd1d7eeeb51d03b0202c1faf764fec1b276ba27d5d61d89"
},
{
"owner": "0x6684dd7bb61364e1ac458e9241f969178c4a2e302bbc23e143c49d8b6dba701a",
"amount": "0x00000000FFFFFFFF",
"asset_id": "0x0000000000000000000000000000000000000000000000000000000000000000"
},
{
"owner": "0xc8e615a4089466174459ef19cfd257d2e17adfabff3b8f219dbb5fb4eca87c50",
"amount": "0x00000000FFFFFFFF",
"asset_id": "0x0000000000000000000000000000000000000000000000000000000000000000"
},
{
"owner": "0x92dffc873b56f219329ed03bb69bebe8c3d8b041088574882f7a6404f02e2f28",
"amount": "0x00000000FFFFFFFF",
"asset_id": "0x0000000000000000000000000000000000000000000000000000000000000000"
}
]
}
}
Loading

0 comments on commit e340736

Please sign in to comment.