Skip to content
Snippets Groups Projects
Commit 0c7b7fdc authored by Konrad Botor's avatar Konrad Botor Committed by Jakub Lachór
Browse files

Made `hiveBlogAddress` configurable

parent 28f22dba
No related branches found
No related tags found
1 merge request!131Composefile and readme
...@@ -39,6 +39,8 @@ docker-build: ...@@ -39,6 +39,8 @@ docker-build:
echo -e "\e[0Ksection_start:$(date +%s):build[collapsed=true]\r\e[0KBaking image "$CI_REGISTRY_IMAGE:$TAG"..." echo -e "\e[0Ksection_start:$(date +%s):build[collapsed=true]\r\e[0KBaking image "$CI_REGISTRY_IMAGE:$TAG"..."
scripts/build_instance.sh --progress=plain "$CI_PROJECT_DIR" scripts/build_instance.sh --progress=plain "$CI_PROJECT_DIR"
echo "IMAGE_NAME=$CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA" > docker-build.env echo "IMAGE_NAME=$CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA" > docker-build.env
echo "Unique image tag:"
cat docker-build.env
echo -e "\e[0Ksection_end:$(date +%s):build\r\e[0K" echo -e "\e[0Ksection_end:$(date +%s):build\r\e[0K"
artifacts: artifacts:
reports: reports:
...@@ -96,6 +98,7 @@ lint: ...@@ -96,6 +98,7 @@ lint:
scripts/run_instance.sh \ scripts/run_instance.sh \
--image="$IMAGE_NAME" \ --image="$IMAGE_NAME" \
--api-endpoint="$API_ENDPOINT" \ --api-endpoint="$API_ENDPOINT" \
--hive-blog-api-endpoint="$HIVE_BLOG_API_ENDPOINT" \
--port=$PORT \ --port=$PORT \
--name=$CONTAINER_NAME \ --name=$CONTAINER_NAME \
--detach --detach
...@@ -111,6 +114,7 @@ staging:deploy: ...@@ -111,6 +114,7 @@ staging:deploy:
variables: variables:
PORT: 5000 PORT: 5000
API_ENDPOINT: http://192.168.4.250:3000 API_ENDPOINT: http://192.168.4.250:3000
HIVE_BLOG_API_ENDPOINT: https://api.hive.blog
CONTAINER_NAME: block-explorer-ui CONTAINER_NAME: block-explorer-ui
environment: environment:
name: staging name: staging
...@@ -122,6 +126,7 @@ test:deploy: ...@@ -122,6 +126,7 @@ test:deploy:
variables: variables:
PORT: 5001 PORT: 5001
API_ENDPOINT: http://192.168.6.7:3000 API_ENDPOINT: http://192.168.6.7:3000
HIVE_BLOG_API_ENDPOINT: https://api.hive.blog
CONTAINER_NAME: block-explorer-ui-2 CONTAINER_NAME: block-explorer-ui-2
environment: environment:
name: test name: test
......
import env from "@beam-australia/react-env" import env from "@beam-australia/react-env"
export const config = { export const config = {
hiveBlogAdress: "https://api.hive.blog", hiveBlogAddress: `${env('HIVE_BLOG_API_ADDRESS') ? env('HIVE_BLOG_API_ADDRESS') : 'https://api.hive.blog'}`,
// apiAdress: process.env.NEXT_PUBLIC_API_ADDRESS ? process.env.NEXT_PUBLIC_API_ADDRESS : "http://192.168.4.250:3000", apiAddress: `${env('API_ADDRESS') ? env('API_ADDRESS') : 'http://192.168.4.250:3000'}`,
apiAdress: `${env('API_ADDRESS') ? env('API_ADDRESS') : 'http://192.168.4.250:3000'}`,
baseMomentTimeFormat: "YYYY/MM/DD hh:mm:ss", baseMomentTimeFormat: "YYYY/MM/DD hh:mm:ss",
gitHash: process.env.NEXT_PUBLIC_COMMIT_HASH, gitHash: process.env.NEXT_PUBLIC_COMMIT_HASH,
opsBodyLimit: 100000, opsBodyLimit: 100000,
......
PORT=5000 PORT=5000
REACT_APP_API_ADDRESS=http://192.168.4.250:3000 REACT_APP_API_ADDRESS=http://192.168.4.250:3000
\ No newline at end of file REACT_APP_HIVE_BLOG_API_ADDRESS=https://api.deathwing.me
\ No newline at end of file
...@@ -5,5 +5,6 @@ services: ...@@ -5,5 +5,6 @@ services:
environment: environment:
PORT: PORT:
REACT_APP_API_ADDRESS: REACT_APP_API_ADDRESS:
REACT_APP_HIVE_BLOG_API_ADDRESS:
ports: ports:
- "${PORT}:${PORT}" - "${PORT}:${PORT}"
\ No newline at end of file
...@@ -8,18 +8,20 @@ Usage: $0 [OPTION[=VALUE]]... ...@@ -8,18 +8,20 @@ Usage: $0 [OPTION[=VALUE]]...
Run a Block Explorer UI Docker instance Run a Block Explorer UI Docker instance
OPTIONS: OPTIONS:
--image=IMAGE Docker image to run (default: 'registry.gitlab.syncad.com/hive/block_explorer_ui:latest') --image=IMAGE Docker image to run (default: 'registry.gitlab.syncad.com/hive/block_explorer_ui:latest')
--api-endpoint=URL API endpoint to be used by the new instance (default: 'http://192.168.4.250:3000') --api-endpoint=URL API endpoint to be used by the new instance (default: 'http://192.168.4.250:3000')
--port=PORT Port to be exposed (default: 5000) --hive-blog-api-endpoint=URL Hive Blog API endpoint to be used by the new instance (default: 'https://api.hive.blog')
--name=NAME Container name to be used (default: block_explorer_ui) --port=PORT Port to be exposed (default: 5000)
--detach Run in detached mode --name=NAME Container name to be used (default: block_explorer_ui)
--help|-h|-? Display this help screen and exit --detach Run in detached mode
--help|-h|-? Display this help screen and exit
EOF EOF
} }
IMAGE=${IMAGE:-"registry.gitlab.syncad.com/hive/block_explorer_ui:latest"} IMAGE=${IMAGE:-"registry.gitlab.syncad.com/hive/block_explorer_ui:latest"}
PORT=${PORT:-"5000"} PORT=${PORT:-"5000"}
API_ENDPOINT=${API_ENDPOINT:-"http://192.168.4.250:3000"} API_ENDPOINT=${API_ENDPOINT:-"http://192.168.4.250:3000"}
HIVE_BLOG_API_ENDPOINT=${HIVE_BLOG_API_ENDPOINT:-"https://api.hive.blog"}
CONTAINER_NAME=${CONTAINER_NAME:-"block_explorer_ui"} CONTAINER_NAME=${CONTAINER_NAME:-"block_explorer_ui"}
DETACH=${DETACH:-false} DETACH=${DETACH:-false}
...@@ -33,6 +35,10 @@ while [ $# -gt 0 ]; do ...@@ -33,6 +35,10 @@ while [ $# -gt 0 ]; do
arg="${1#*=}" arg="${1#*=}"
API_ENDPOINT="$arg" API_ENDPOINT="$arg"
;; ;;
--hive-blog-api-endpoint=*)
arg="${1#*=}"
HIVE_BLOG_API_ENDPOINT="$arg"
;;
--port=*) --port=*)
arg="${1#*=}" arg="${1#*=}"
PORT="$arg" PORT="$arg"
...@@ -65,6 +71,7 @@ RUN_OPTIONS=( ...@@ -65,6 +71,7 @@ RUN_OPTIONS=(
"--publish" "$PORT:$PORT" "--publish" "$PORT:$PORT"
"--env" "PORT=$PORT" "--env" "PORT=$PORT"
"--env" "REACT_APP_API_ADDRESS=$API_ENDPOINT" "--env" "REACT_APP_API_ADDRESS=$API_ENDPOINT"
"--env" "REACT_APP_HIVE_BLOG_API_ADDRESS=$HIVE_BLOG_API_ENDPOINT"
"--name" "$CONTAINER_NAME" "--name" "$CONTAINER_NAME"
) )
......
...@@ -18,31 +18,31 @@ class FetchingService { ...@@ -18,31 +18,31 @@ class FetchingService {
} }
async getHeadBlockNum(): Promise<number> { async getHeadBlockNum(): Promise<number> {
const url = `${config.apiAdress}/rpc/get_head_block_num`; const url = `${config.apiAddress}/rpc/get_head_block_num`;
return await this.makePostRequest(url, {}); return await this.makePostRequest(url, {});
} }
async getBlock(blockNumber: number): Promise<Hive.BlockDetails> { async getBlock(blockNumber: number): Promise<Hive.BlockDetails> {
const requestBody: Hive.GetBlockProps = { _block_num: blockNumber }; const requestBody: Hive.GetBlockProps = { _block_num: blockNumber };
const url = `${config.apiAdress}/rpc/get_block`; const url = `${config.apiAddress}/rpc/get_block`;
return await this.makePostRequest(url, requestBody); return await this.makePostRequest(url, requestBody);
} }
async getLastBlocks(limit: number): Promise<Hive.LastBlocksTypeResponse[]> { async getLastBlocks(limit: number): Promise<Hive.LastBlocksTypeResponse[]> {
const requestBody: Hive.GetLatestBlocksProps = { _limit: limit }; const requestBody: Hive.GetLatestBlocksProps = { _limit: limit };
const url = `${config.apiAdress}/rpc/get_latest_blocks `; const url = `${config.apiAddress}/rpc/get_latest_blocks `;
return await this.makePostRequest(url, requestBody); return await this.makePostRequest(url, requestBody);
} }
async getInputType(input: string): Promise<Hive.InputTypeResponse> { async getInputType(input: string): Promise<Hive.InputTypeResponse> {
const requestBody: Hive.GetInputTypeProps = { _input: input }; const requestBody: Hive.GetInputTypeProps = { _input: input };
const url = `${config.apiAdress}/rpc/get_input_type`; const url = `${config.apiAddress}/rpc/get_input_type`;
return await this.makePostRequest(url, requestBody); return await this.makePostRequest(url, requestBody);
} }
async getBlockOpTypes(blockNumber: number): Promise<Hive.OperationTypes[]> { async getBlockOpTypes(blockNumber: number): Promise<Hive.OperationTypes[]> {
const requestBody: Hive.GetBlockOpTypesProps = { _block_num: blockNumber }; const requestBody: Hive.GetBlockOpTypesProps = { _block_num: blockNumber };
const url = `${config.apiAdress}/rpc/get_block_op_types`; const url = `${config.apiAddress}/rpc/get_block_op_types`;
return await this.makePostRequest(url, requestBody); return await this.makePostRequest(url, requestBody);
} }
...@@ -55,7 +55,7 @@ class FetchingService { ...@@ -55,7 +55,7 @@ class FetchingService {
_filter: filter, _filter: filter,
_body_limit: config.opsBodyLimit _body_limit: config.opsBodyLimit
}; };
const url = `${config.apiAdress}/rpc/get_ops_by_block`; const url = `${config.apiAddress}/rpc/get_ops_by_block`;
return await this.makePostRequest(url, requestBody); return await this.makePostRequest(url, requestBody);
} }
async getTransaction( async getTransaction(
...@@ -64,7 +64,7 @@ class FetchingService { ...@@ -64,7 +64,7 @@ class FetchingService {
const requestBody: Hive.GetTransactionProps = { const requestBody: Hive.GetTransactionProps = {
_trx_hash: transactionHash, _trx_hash: transactionHash,
}; };
const url = `${config.apiAdress}/rpc/get_transaction`; const url = `${config.apiAddress}/rpc/get_transaction`;
return await this.makePostRequest(url, requestBody); return await this.makePostRequest(url, requestBody);
} }
...@@ -74,7 +74,7 @@ class FetchingService { ...@@ -74,7 +74,7 @@ class FetchingService {
method: "database_api.get_reward_funds", method: "database_api.get_reward_funds",
id: 1, id: 1,
}; };
const url = `${config.hiveBlogAdress}`; const url = `${config.hiveBlogAddress}`;
return await this.makePostRequest(url, requestBody); return await this.makePostRequest(url, requestBody);
} }
...@@ -84,7 +84,7 @@ class FetchingService { ...@@ -84,7 +84,7 @@ class FetchingService {
method: "database_api.get_dynamic_global_properties", method: "database_api.get_dynamic_global_properties",
id: 1, id: 1,
}; };
const url = `${config.hiveBlogAdress}`; const url = `${config.hiveBlogAddress}`;
return await this.makePostRequest(url, requestBody); return await this.makePostRequest(url, requestBody);
} }
...@@ -94,13 +94,13 @@ class FetchingService { ...@@ -94,13 +94,13 @@ class FetchingService {
method: "database_api.get_current_price_feed", method: "database_api.get_current_price_feed",
id: 1, id: 1,
}; };
const url = `${config.hiveBlogAdress}`; const url = `${config.hiveBlogAddress}`;
return await this.makePostRequest(url, requestBody); return await this.makePostRequest(url, requestBody);
} }
async getAccOpTypes(account: string): Promise<unknown> { async getAccOpTypes(account: string): Promise<unknown> {
const requestBody: Hive.GetAccOpTypesProps = { _account: account }; const requestBody: Hive.GetAccOpTypesProps = { _account: account };
const url = `${config.apiAdress}/rpc/get_acc_op_types`; const url = `${config.apiAddress}/rpc/get_acc_op_types`;
return await this.makePostRequest(url, requestBody); return await this.makePostRequest(url, requestBody);
} }
...@@ -118,7 +118,7 @@ class FetchingService { ...@@ -118,7 +118,7 @@ class FetchingService {
_date_end: accountOperationsProps.endDate, _date_end: accountOperationsProps.endDate,
_body_limit: config.opsBodyLimit _body_limit: config.opsBodyLimit
}; };
const url = `${config.apiAdress}/rpc/get_ops_by_account`; const url = `${config.apiAddress}/rpc/get_ops_by_account`;
return await this.makePostRequest(url, requestBody); return await this.makePostRequest(url, requestBody);
} }
...@@ -130,13 +130,13 @@ class FetchingService { ...@@ -130,13 +130,13 @@ class FetchingService {
_account: account, _account: account,
_operations: operations, _operations: operations,
}; };
const url = `${config.apiAdress}/rpc/get_account_operations_count`; const url = `${config.apiAddress}/rpc/get_account_operations_count`;
return await this.makePostRequest(url, requestBody); return await this.makePostRequest(url, requestBody);
} }
async getAccount(account: string): Promise<unknown> { async getAccount(account: string): Promise<unknown> {
const requestBody: Hive.GetAccountProps = { _account: account }; const requestBody: Hive.GetAccountProps = { _account: account };
const url = `${config.apiAdress}/rpc/get_account`; const url = `${config.apiAddress}/rpc/get_account`;
return await this.makePostRequest(url, requestBody); return await this.makePostRequest(url, requestBody);
} }
...@@ -144,7 +144,7 @@ class FetchingService { ...@@ -144,7 +144,7 @@ class FetchingService {
const requestBody: Hive.GetAccountResourceCreditsProps = { const requestBody: Hive.GetAccountResourceCreditsProps = {
_account: account, _account: account,
}; };
const url = `${config.apiAdress}/rpc/get_account_resource_credits`; const url = `${config.apiAddress}/rpc/get_account_resource_credits`;
return await this.makePostRequest(url, requestBody); return await this.makePostRequest(url, requestBody);
} }
...@@ -152,7 +152,7 @@ class FetchingService { ...@@ -152,7 +152,7 @@ class FetchingService {
const requestBody: Hive.GetBtrackerAccountBalanceProps = { const requestBody: Hive.GetBtrackerAccountBalanceProps = {
_account: account, _account: account,
}; };
const url = `${config.apiAdress}/rpc/get_btracker_account_balance`; const url = `${config.apiAddress}/rpc/get_btracker_account_balance`;
return await this.makePostRequest(url, requestBody); return await this.makePostRequest(url, requestBody);
} }
...@@ -168,13 +168,13 @@ class FetchingService { ...@@ -168,13 +168,13 @@ class FetchingService {
_order_by: orderBy, _order_by: orderBy,
_order_is: orderIs, _order_is: orderIs,
}; };
const url = `${config.apiAdress}/rpc/get_witnesses`; const url = `${config.apiAddress}/rpc/get_witnesses`;
return await this.makePostRequest(url, requestBody); return await this.makePostRequest(url, requestBody);
} }
async getWitnessesVotersNum(witness: string): Promise<unknown> { async getWitnessesVotersNum(witness: string): Promise<unknown> {
const requestBody: Hive.GetWitnessVotersNumProps = { _witness: witness }; const requestBody: Hive.GetWitnessVotersNumProps = { _witness: witness };
const url = `${config.apiAdress}/rpc/get_witness_voters_num`; const url = `${config.apiAddress}/rpc/get_witness_voters_num`;
return await this.makePostRequest(url, requestBody); return await this.makePostRequest(url, requestBody);
} }
...@@ -190,7 +190,7 @@ class FetchingService { ...@@ -190,7 +190,7 @@ class FetchingService {
_order_is: orderIs, _order_is: orderIs,
}; };
if (limit) requestBody._limit = limit; if (limit) requestBody._limit = limit;
const url = `${config.apiAdress}/rpc/get_witness_voters`; const url = `${config.apiAddress}/rpc/get_witness_voters`;
return await this.makePostRequest(url, requestBody); return await this.makePostRequest(url, requestBody);
} }
...@@ -200,7 +200,7 @@ class FetchingService { ...@@ -200,7 +200,7 @@ class FetchingService {
const requestBody: Hive.GetOperationTypesProps = { const requestBody: Hive.GetOperationTypesProps = {
_operation_type_pattern: operation_type_pattern, _operation_type_pattern: operation_type_pattern,
}; };
const url = `${config.apiAdress}/rpc/get_matching_operation_types`; const url = `${config.apiAddress}/rpc/get_matching_operation_types`;
return await this.makePostRequest(url, requestBody); return await this.makePostRequest(url, requestBody);
} }
...@@ -208,7 +208,7 @@ class FetchingService { ...@@ -208,7 +208,7 @@ class FetchingService {
const requestBody: Hive.GetWitnessProps = { const requestBody: Hive.GetWitnessProps = {
_account: witnessName, _account: witnessName,
}; };
const url = `${config.apiAdress}/rpc/get_witness`; const url = `${config.apiAddress}/rpc/get_witness`;
return await this.makePostRequest(url, requestBody); return await this.makePostRequest(url, requestBody);
} }
...@@ -216,7 +216,7 @@ class FetchingService { ...@@ -216,7 +216,7 @@ class FetchingService {
const requestBody: Hive.GetBlockByTimeProps = { const requestBody: Hive.GetBlockByTimeProps = {
_timestamp: date, _timestamp: date,
}; };
const url = `${config.apiAdress}/rpc/get_block_by_time`; const url = `${config.apiAddress}/rpc/get_block_by_time`;
return await this.makePostRequest(url, requestBody); return await this.makePostRequest(url, requestBody);
} }
...@@ -224,7 +224,7 @@ class FetchingService { ...@@ -224,7 +224,7 @@ class FetchingService {
const requestBody: Hive.GetOperationKeysProps = { const requestBody: Hive.GetOperationKeysProps = {
_op_type_id: operationTypeId, _op_type_id: operationTypeId,
} }
const url = `${config.apiAdress}/rpc/get_operation_keys `; const url = `${config.apiAddress}/rpc/get_operation_keys `;
return await this.makePostRequest(url, requestBody); return await this.makePostRequest(url, requestBody);
} }
...@@ -243,7 +243,7 @@ class FetchingService { ...@@ -243,7 +243,7 @@ class FetchingService {
_key_content: blockSearchProps.deepProps.content ? [blockSearchProps.deepProps.content] : undefined, _key_content: blockSearchProps.deepProps.content ? [blockSearchProps.deepProps.content] : undefined,
_setof_keys: blockSearchProps.deepProps.keys ? [blockSearchProps.deepProps.keys] : undefined _setof_keys: blockSearchProps.deepProps.keys ? [blockSearchProps.deepProps.keys] : undefined
}; };
const url = `${config.apiAdress}/rpc/get_block_by_op `; const url = `${config.apiAddress}/rpc/get_block_by_op `;
return await this.makePostRequest(url, requestBody); return await this.makePostRequest(url, requestBody);
} }
...@@ -263,7 +263,7 @@ class FetchingService { ...@@ -263,7 +263,7 @@ class FetchingService {
_from_time: fromTime, _from_time: fromTime,
_to_time: toTime, _to_time: toTime,
}; };
const url = `${config.apiAdress}/rpc/get_witness_votes_history `; const url = `${config.apiAddress}/rpc/get_witness_votes_history `;
return await this.makePostRequest(url, requestBody); return await this.makePostRequest(url, requestBody);
} }
...@@ -273,7 +273,7 @@ class FetchingService { ...@@ -273,7 +273,7 @@ class FetchingService {
const requestBody: Hive.GetOperationProps = { const requestBody: Hive.GetOperationProps = {
_operation_id: operationId _operation_id: operationId
}; };
const url = `${config.apiAdress}/rpc/get_operation` const url = `${config.apiAddress}/rpc/get_operation`
return await this.makePostRequest(url, requestBody); return await this.makePostRequest(url, requestBody);
} }
...@@ -292,13 +292,13 @@ class FetchingService { ...@@ -292,13 +292,13 @@ class FetchingService {
_body_limit: config.opsBodyLimit, _body_limit: config.opsBodyLimit,
_page_size: config.standardPaginationSize _page_size: config.standardPaginationSize
}; };
const url = `${config.apiAdress}/rpc/get_comment_operations` const url = `${config.apiAddress}/rpc/get_comment_operations`
return await this.makePostRequest(url, requestBody); return await this.makePostRequest(url, requestBody);
} }
async getHafbeVersion(): Promise<string> { async getHafbeVersion(): Promise<string> {
const requestBody = {}; const requestBody = {};
const url = `${config.apiAdress}/rpc/get_hafbe_version`; const url = `${config.apiAddress}/rpc/get_hafbe_version`;
return await this.makePostRequest(url, requestBody); return await this.makePostRequest(url, requestBody);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment