Skip to content

Commit

Permalink
Merge pull request #1430 from multiversx/development
Browse files Browse the repository at this point in the history
merge development to main
  • Loading branch information
dragos-rebegea authored Jan 15, 2025
2 parents dbec8bd + c38c4fa commit 914e3c9
Show file tree
Hide file tree
Showing 43 changed files with 1,065 additions and 322 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/load-tests.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
name: Load Tests

on:
push:
branches: [main, development]
pull_request:
branches: [main, development]

Expand Down
171 changes: 171 additions & 0 deletions config/config.placeholder.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
network: 'DAPP_CONFIG'
metaChainShardId: 4294967295
api:
public: true
publicPort: 3001
private: true
privatePort: 4001
websocket: true
cron:
cacheWarmer: true
fastWarm: true
queueWorker: true
elasticUpdater: false
flags:
useRequestCaching: true
useKeepAliveAgent: true
useTracing: false
useRequestLogging: false
useVmQueryTracing: false
processNfts: true
collectionPropertiesFromGateway: false
features:
eventsNotifier:
enabled: false
port: 5674
url: 'amqp://guest:[email protected]:5673'
exchange: 'all_events'
queue: 'api-process-logs-and-events'
guestCaching:
enabled: false
hitsThreshold: 100
ttl: 12
transactionPool:
enabled: false
transactionPoolWarmer:
enabled: false
cronExpression: '*/5 * * * * *'
ttlInSeconds: 60
updateCollectionExtraDetails:
enabled: false
updateAccountExtraDetails:
enabled: false
marketplace:
enabled: false
serviceUrl: 'MARKETPLACE_URL'
exchange:
enabled: false
serviceUrl: 'EXCHANGE_URL'
dataApi:
enabled: false
serviceUrl: 'DATAAPI_URL'
assetsFetch:
enabled: true
assetesUrl: 'ASSETSFETCH_URL'
auth:
enabled: false
maxExpirySeconds: 86400
acceptedOrigins:
- ''
admins:
- ''
jwtSecret: ''
stakingV4:
enabled: false
cronExpression: '*/5 * * * * *'
activationEpoch: 1043
nodeEpochsLeft:
enabled: false
transactionProcessor:
enabled: false
maxLookBehind: 100
transactionCompleted:
enabled: false
maxLookBehind: 100
logLevel: 'Error'
transactionBatch:
enabled: true
maxLookBehind: 100
statusChecker:
enabled: false
thresholds:
tokens: 500
nodes: 3000
providers: 10
tokenSupplyCount: 20
tokenAssets: 20
tokenAccounts: 500
tokenTransactions: 500
nodeValidators: 300
nftScamInfo:
enabled: false
processNfts:
enabled: false
nftQueueName: 'api-process-nfts'
deadLetterQueueName: 'api-process-nfts-dlq'
tps:
enabled: false
maxLookBehindNonces: 100
nodesFetch:
enabled: true
serviceUrl: 'NODESFETCH_URL'
tokensFetch:
enabled: true
serviceUrl: 'TOKENSFETCH_URL'
providersFetch:
enabled: true
serviceUrl: 'PROVIDERSFETCH_URL'
image:
width: 600
height: 600
type: 'png'
aws:
s3KeyId: ''
s3Secret: ''
s3Bucket: 'devnet-media.elrond.com'
s3Region: ''
urls:
self: 'https://devnet-api.multiversx.com'
elastic:
- 'ELASTICSEARCH_URL'
gateway:
- 'GATEWAY_URL'
verifier: 'https://play-api.multiversx.com'
redis: 'REDIS_IP'
rabbitmq: 'RABBITMQ_URL'
providers: 'PROVIDERS_URL'
delegation: 'DELEGATION_URL'
media: 'https://devnet-media.elrond.com'
nftThumbnails: 'https://devnet-media.elrond.com/nfts/thumbnail'
tmp: '/tmp'
ipfs: 'https://ipfs.io/ipfs'
socket: 'SOCKET_URL'
maiarId: 'https://devnet-id-api.multiversx.com'
indexer:
type: 'elastic'
maxPagination: 10000
database:
enabled: false
url: 'mongodb://127.0.0.1:27017/api?authSource=admin'
type: 'mysql'
host: 'localhost'
port: 3306
username: 'root'
password: 'root'
database: 'api'
caching:
cacheTtl: 6
processTtl: 600
poolLimit: 50
cacheDuration: 3
keepAliveTimeout:
downstream: 61000
upstream: 60000
contracts:
esdt: 'erd1qqqqqqqqqqqqqqqpqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqzllls8a5w6u'
auction: 'erd1qqqqqqqqqqqqqqqpqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqplllst77y4l'
staking: 'erd1qqqqqqqqqqqqqqqpqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqllls0lczs7'
delegationManager: 'erd1qqqqqqqqqqqqqqqpqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqylllslmq6y6'
delegation: 'erd1qqqqqqqqqqqqqpgq97wezxw6l7lgg7k9rxvycrz66vn92ksh2tssxwf7ep'
metabonding: 'erd1qqqqqqqqqqqqqpgqkg7we73j769ew5we4yyx7uyvnn0nefqgd8ssm6vjc2'
inflation:
- 1952123
- 1746637
- 1541150
- 1335663
- 1130177
- 924690
- 719203
nftProcess:
parallelism: 1
maxRetries: 3
17 changes: 17 additions & 0 deletions config/dapp.config.placeholder.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"id": "PLACEHOLDER_DAPP_id",
"name": "PLACEHOLDER_DAPP_name",
"egldLabel": "PLACEHOLDER_DAPP_egldLabel",
"decimals": "4",
"egldDenomination": "18",
"gasPerDataByte": "1500",
"apiTimeout": "4000",
"walletConnectDeepLink": "https://maiar.page.link/?apn=com.multiversx.maiar.wallet&isi=1519405832&ibi=com.multiversx.maiar.wallet&link=https://maiar.com/",
"walletConnectBridgeAddresses": [
"https://bridge.walletconnect.org"
],
"walletAddress": "PLACEHOLDER_DAPP_walletAddress",
"apiAddress": "PLACEHOLDER_DAPP_apiAddress",
"explorerAddress": "PLACEHOLDER_DAPP_explorerAddress",
"chainId": "PLACEHOLDER_DAPP_chainId"
}
101 changes: 60 additions & 41 deletions entrypoint.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,46 +1,65 @@
#!/bin/sh
# ENV VARIABLES
# MVX_ENV - defines what config to copy (default devnet)
# ELASTICSEARCH_URL - defines custom elasticsearch url - eg https://devnet-index.multiversx.com
# GATEWAY_URL - defines custom gateway url - eg https://devnet-gateway.multiversx.com
# REDIS_IP - defines redis ip - default 127.0.0.1

# CHECK IF ENV IS DEFINED
if [ -n "$MVX_ENV" ] && [ "$MVX_ENV" = "devnet" ]; then
# Copy config file
cp ./config/config.${MVX_ENV}.yaml /app/dist/config/config.yaml

if [ $? -eq 0 ]; then
echo "Config file copied successfully from config/config.${MVX_ENV}.yaml /app/dist/config/config.yaml"
else
echo "Failed to copy the file."
fi

else
cp ./config/config.devnet.yaml /app/dist/config/config.yaml

if [ $? -eq 0 ]; then
echo "Default config file copied successfully from config/config.devnet.yaml /app/dist/config/config.yaml"
else
echo "Failed to copy the file."
fi
fi

# Replaces urls if defined
if [ -n "$REDIS_IP" ]; then
echo "Redis IP defined: ${REDIS_IP}, replacing in config"
sed -i "s|redis: '127.0.0.1'|redis: '${REDIS_IP}'|g" /app/dist/config/config.yaml
fi

if [ -n "$ELASTICSEARCH_URL" ]; then
echo "Elasticsearch url defined: ${ELASTICSEARCH_URL}, replacing in config"
sed -i "/^ elastic:/!b; n; s|.*| - '${ELASTICSEARCH_URL}'|" /app/dist/config/config.yaml
fi

if [ -n "$GATEWAY_URL" ]; then
echo "Gateway url defined: ${GATEWAY_URL}, replacing in config"
sed -i "/^ gateway:/!b; n; s|.*| - '${GATEWAY_URL}'|" /app/dist/config/config.yaml
fi
# MVX_ENV=devnet
# DAPP_CONFIG=devnet
# REDIS_IP=127.0.0.1
# ELASTICSEARCH_URL=https://devnet-index.multiversx.com
# GATEWAY_URL=https://devnet-gateway.multiversx.com
# RABBITMQ_URL=amqp://127.0.0.1:5672
# PROVIDERS_URL=https://devnet-delegation-api.multiversx.com/providers
# DELEGATION_URL=https://devnet-delegation-api.multiversx.com
# SOCKET_URL=devnet-socket-api.multiversx.com
# NODESFETCH_URL= https://devnet-api.multiversx.com
# TOKENSFETCH_URL= https://devnet-api.multiversx.com
# PROVIDERSFETCH_URL= https://devnet-api.multiversx.com
# DATAAPI_URL=https://devnet-data-api.multiversx.com
# EXCHANGE_URL=https://devnet-graph.xexchange.com/graphql
# MARKETPLACE_URL=https://devnet-nfts-graph.multiversx.com/graphql
# ASSETSFETCH_URL=https://tools.multiversx.com/assets-cdn
# PLACEHOLDER_DAPP_id=devnet
# PLACEHOLDER_DAPP_name=Devnet
# PLACEHOLDER_DAPP_egldLabel=xEGLD
# PLACEHOLDER_DAPP_walletAddress=https://devnet-wallet.multiversx.com
# PLACEHOLDER_DAPP_apiAddress=https://devnet-api.multiversx.com
# PLACEHOLDER_DAPP_explorerAddress=http://devnet-explorer.multiversx.com
# PLACEHOLDER_DAPP_chainId=D

env_vars_with_defaults="MVX_ENV=devnet DAPP_CONFIG=devnet REDIS_IP=127.0.0.1 ELASTICSEARCH_URL=https://devnet-index.multiversx.com GATEWAY_URL=https://devnet-gateway.multiversx.com RABBITMQ_URL=amqp://127.0.0.1:5672 PROVIDERS_URL=https://devnet-delegation-api.multiversx.com/providers DATAAPI_URL=https://devnet-data-api.multiversx.com EXCHANGE_URL=https://devnet-graph.xexchange.com/graphql MARKETPLACE_URL=https://devnet-nfts-graph.multiversx.com/graphql ASSETSFETCH_URL=https://tools.multiversx.com/assets-cdn DELEGATION_URL=https://devnet-delegation-api.multiversx.com SOCKET_URL=devnet-socket-api.multiversx.com NODESFETCH_URL=https://devnet-api.multiversx.com TOKENSFETCH_URL=https://devnet-api.multiversx.com PROVIDERSFETCH_URL=https://devnet-api.multiversx.com PLACEHOLDER_DAPP_id=devnet PLACEHOLDER_DAPP_name=Devnet PLACEHOLDER_DAPP_egldLabel=xEGLD PLACEHOLDER_DAPP_walletAddress=https://devnet-wallet.multiversx.com PLACEHOLDER_DAPP_apiAddress=https://devnet-api.multiversx.com PLACEHOLDER_DAPP_explorerAddress=http://devnet-explorer.multiversx.com PLACEHOLDER_DAPP_chainId=D"

replace_placeholder() {
local var_name=$1
local var_value=$2

case $var_name in
PLACEHOLDER_DAPP*)
echo "Var ${var_name} defined, replacing ${var_value} in /app/config/dapp.config.placeholder.json"
sed -i "s|${var_name}|${var_value}|g" /app/config/dapp.config.placeholder.json
;;
*)
echo "Var ${var_name} defined, replacing ${var_value} in /app/dist/config/config.yaml"
sed -i "s|${var_name}|${var_value}|g" /app/dist/config/config.yaml
;;
esac

}

# Loop through each environment variable
for entry in $env_vars_with_defaults; do
# Split the entry into name and value
var_name=$(echo $entry | cut -d= -f1)
default_value=$(echo $entry | cut -d= -f2)

# Use the environment variable value if defined; otherwise, use the default
eval "value=\${$var_name:-$default_value}"

cp ./config/config.placeholder.yaml /app/dist/config/config.yaml
if [ $? -eq 0 ]; then
echo "Config file copied successfully from config/config.placeholder.yaml /app/dist/config/config.yaml"
fi

# Execute the function with the variable name and value
replace_placeholder "$var_name" "$value"

done

exec /usr/local/bin/node dist/src/main.js
7 changes: 4 additions & 3 deletions src/common/data-api/data-api.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,17 +72,18 @@ export class DataApiService {
}

try {
const [cexTokensRaw, xExchangeTokensRaw, hatomTokensRaw] = await Promise.all([
const [cexTokensRaw, xExchangeTokensRaw, hatomTokensRaw, xoxnoTokensRaw] = await Promise.all([
this.apiService.get(`${this.apiConfigService.getDataApiServiceUrl()}/v1/tokens/cex?fields=identifier`),
this.apiService.get(`${this.apiConfigService.getDataApiServiceUrl()}/v1/tokens/xexchange?fields=identifier`),
this.apiService.get(`${this.apiConfigService.getDataApiServiceUrl()}/v1/tokens/hatom?fields=identifier`),
this.apiService.get(`${this.apiConfigService.getDataApiServiceUrl()}/v1/tokens/xoxno?fields=identifier`),
]);

const cexTokens: DataApiToken[] = cexTokensRaw.data.map((token: any) => new DataApiToken({ identifier: token.identifier, market: 'cex' }));
const xExchangeTokens: DataApiToken[] = xExchangeTokensRaw.data.map((token: any) => new DataApiToken({ identifier: token.identifier, market: 'xexchange' }));
const hatomTokens: DataApiToken[] = hatomTokensRaw.data.map((token: any) => new DataApiToken({ identifier: token.identifier, market: 'hatom' }));

const tokens = [...cexTokens, ...xExchangeTokens, ...hatomTokens].toRecord<DataApiToken>(x => x.identifier);
const xoxnoTokens: DataApiToken[] = xoxnoTokensRaw.data.map((token: any) => new DataApiToken({ identifier: token.identifier, market: 'xoxno' }));
const tokens = [...cexTokens, ...xExchangeTokens, ...hatomTokens, ...xoxnoTokens].toRecord<DataApiToken>(x => x.identifier);
return tokens;
} catch (error) {
this.logger.error(`An unexpected error occurred while fetching tokens from Data API.`);
Expand Down
2 changes: 1 addition & 1 deletion src/common/data-api/entities/data-api.token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ export class DataApiToken {
}

identifier: string = '';
market: 'cex' | 'xexchange' | 'hatom' = 'cex';
market: 'cex' | 'xexchange' | 'hatom' | 'xoxno' = 'cex';
}
1 change: 1 addition & 0 deletions src/common/gateway/entities/gateway.component.request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export enum GatewayComponentRequest {
networkEconomics = 'networkEconomics',
networkTotalStaked = 'networkTotalStaked',
addressDetails = 'addressDetails',
addressesBulk = 'addressesBulk',
addressEsdt = 'addressEsdt',
addressEsdtHistorical = 'addressEsdtHistorical',
addressEsdtBalance = 'addressEsdtBalance',
Expand Down
5 changes: 5 additions & 0 deletions src/common/gateway/gateway.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@ export class GatewayService {
return result;
}

async getAccountsBulk(addresses: string[]): Promise<Account[]> {
const result = await this.create('address/bulk', GatewayComponentRequest.addressesBulk, addresses);
return result.accounts;
}

async getEsdtSupply(identifier: string): Promise<EsdtSupply> {
const result = await this.get(`network/esdt/supply/${identifier}`, GatewayComponentRequest.esdtSupply);
return result;
Expand Down
Loading

0 comments on commit 914e3c9

Please sign in to comment.