Skip to content

Commit

Permalink
feat: update seed
Browse files Browse the repository at this point in the history
  • Loading branch information
Sotatek-TanHoang committed Jan 8, 2025
1 parent b200aee commit f23bf44
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/auto-deploy-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ jobs:
with:
node-version: v18.20.4
- run: |
echo "${{ vars.MINA_BRIDGE_BE_TEST }}" >> .env
echo "${{ secrets.MINA_BRIDGE_BE_TEST }}" >> .env
docker build . -t mina-bridge:1.0.0
docker compose -f docker-compose.dev.yaml up -d --remove-orphans
5 changes: 4 additions & 1 deletion src/database/seeds/common_config.seed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { DataSource } from 'typeorm';
import { Seeder } from 'typeorm-extension';

import { COMMOM_CONFIG_TIP, COMMON__CONFIG_DAILY_QUOTA, EAsset } from '../../constants/api.constant.js';
import { ENetworkName } from '../../constants/blockchain.constant.js';
import { ENetworkName, ETokenPairStatus } from '../../constants/blockchain.constant.js';
import { EEnvKey } from '../../constants/env.constant.js';
import { CommonConfig } from '../../modules/crawler/entities/common-config.entity.js';

Expand All @@ -21,12 +21,15 @@ export default class CommonConfigSeeder implements Seeder {
asset: EAsset.ETH,
fromAddress: '0x0000000000000000000000000000000000000000',
toAddress: process.env[EEnvKey.MINA_TOKEN_BRIDGE_ADDRESS],
fromScAddress: process.env[EEnvKey.ETH_BRIDGE_CONTRACT_ADDRESS],
toScAddress: process.env[EEnvKey.MINA_BRIDGE_CONTRACT_ADDRESS],
fromDecimal: 18,
toDecimal: 9,
fromSymbol: 'ETH',
toSymbol: 'WETH',
fromChain: ENetworkName.ETH,
toChain: ENetworkName.MINA,
status:ETokenPairStatus.ENABLE
}),
);
}
Expand Down
2 changes: 1 addition & 1 deletion src/modules/crawler/crawler.evmbridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ export class BlockchainEVMCrawler {
networkFrom: ENetworkName.ETH,
networkReceived: ENetworkName.MINA,
tokenFromName: event.returnValues.tokenName,
tokenReceivedAddress: this.configService.get(EEnvKey.MINA_TOKEN_BRIDGE_ADDRESS),
tokenReceivedAddress: config.toAddress,
txHashLock: event.transactionHash,
receiveAddress: event.returnValues.receipt,
blockNumber: event.blockNumber,
Expand Down
8 changes: 4 additions & 4 deletions src/modules/crawler/crawler.minabridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export class SCBridgeMinaCrawler {
});

// update total weth minted
const currentConfig = await configRepo.findOneBy({});
const currentConfig = await configRepo.findOneBy({ toAddress: event.event.data.tokenAddress.toBase58() });
assert(currentConfig, 'comomn config not exist');
const newTotalEthMinted = new BigNumber(currentConfig.totalWethMinted).plus(existLockTx.amountReceived).toString();

Expand Down Expand Up @@ -142,7 +142,7 @@ export class SCBridgeMinaCrawler {
}
const fromTokenDecimal = this.configService.get(EEnvKey.DECIMAL_TOKEN_MINA),
toTokenDecimal = this.configService.get(EEnvKey.DECIMAL_TOKEN_EVM);
const config = await configRepo.findOneBy({ fromAddress: event.event.data.tokenAddress.toBase58() });
const config = await configRepo.findOneBy({ toAddress: event.event.data.tokenAddress.toBase58() });

assert(!!config?.bridgeFee, 'tip config undefined');

Expand All @@ -162,11 +162,11 @@ export class SCBridgeMinaCrawler {
const eventUnlock: Partial<EventLog> = {
senderAddress: JSON.parse(JSON.stringify(event.event.data.locker)),
amountFrom: inputAmount,
tokenFromAddress: this.configService.get(EEnvKey.MINA_TOKEN_BRIDGE_ADDRESS),
tokenFromAddress: config.fromAddress,
networkFrom: ENetworkName.MINA,
networkReceived: ENetworkName.ETH,
tokenFromName: EAsset.WETH,
tokenReceivedAddress: this.configService.get(EEnvKey.ETH_TOKEN_BRIDGE_ADDRESS),
tokenReceivedAddress: config.toAddress,
txHashLock,
receiveAddress: receiveAddress,
blockNumber: +event.blockHeight.toString(),
Expand Down

0 comments on commit f23bf44

Please sign in to comment.