Skip to content

Commit

Permalink
Merge branch 'add-ersn-info' into 'dev'
Browse files Browse the repository at this point in the history
Add eRSN token info to database and apis

Closes #261

See merge request ergo/rosen-bridge/watcher!310
  • Loading branch information
zargarzadehm committed Oct 19, 2024
2 parents 18a9777 + e84d1d8 commit ac094e4
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/empty-ladybugs-attack.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@rosen-bridge/watcher': patch
---

Add eRSN token info to assets and revenue apis
3 changes: 3 additions & 0 deletions src/api/address.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ addressRouter.get('/assets', async (req: Request, res: Response) => {
if (!tokens.some((item) => item.tokenId === getConfig().rosen.RSN)) {
tokens.push({ amount: 0n, tokenId: getConfig().rosen.RSN });
}
if (!tokens.some((item) => item.tokenId === getConfig().rosen.eRSN)) {
tokens.push({ amount: 0n, tokenId: getConfig().rosen.eRSN });
}
tokens = await ErgoUtils.fillTokensDetails(tokens);
tokens.push({
amount: balance.nanoErgs,
Expand Down
1 change: 1 addition & 0 deletions src/jobs/tokenName.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export const tokenNameJobFunction = async (
const boxesTokenIds = ErgoUtils.getBoxAssetsSum(newErgoBoxes).map(
(token) => token.tokenId
);
boxesTokenIds.push(getConfig().rosen.eRSN);
const tokensInfo = await watcherDatabase.getTokenEntity(boxesTokenIds);
const tokensInfoMap = new Map<string, string>();
tokensInfo.forEach((token) => {
Expand Down
1 change: 1 addition & 0 deletions tests/config/contracts-ergo-mainnet.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"RepoNFT": "a29d9bb0d622eb8b4f83a34c4ab1b7d3f18aaaabc3aa6876912a3ebaf0da1018",
"GuardNFT": "a6ac381e6fa99929fd1477b3ba9499790a775e91d4c14c5aa86e9a118dfac853",
"RSN": "a2a6c892c38d508a659caf857dbe29da4343371e597efd42e40f9bc99099a516",
"ERSN": "a2a6c892c38d508a659caf857dbe29da4343371e597efd42e40f9bc99099a516",
"RSNRatioNFT": "c597eac4db28f62419eab5639122f2bc4955dfedf958e7cdba5248ba2a81210a",
"CleanupNFT": "5b81c74b04b7eed17bd1e3d37c990003183601951f22a3360a8bc5c848a32006",
"RWTId": "497287b9a1eff643791277744a74b7d598b834dc613f2ebc972e33767c61ac2b",
Expand Down
2 changes: 2 additions & 0 deletions tests/database/mockedData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -738,6 +738,8 @@ export const generalInfo = {
address: '9eYicprScbobMdmWYRHwbYiM3g19EQ3iAK24FconvXFVfaEooVH',
rsnTokenId:
'a2a6c892c38d508a659caf857dbe29da4343371e597efd42e40f9bc99099a516',
eRsnTokenId:
'a2a6c892c38d508a659caf857dbe29da4343371e597efd42e40f9bc99099a516',
collateral: {
erg: 20,
rsn: 10,
Expand Down
1 change: 1 addition & 0 deletions tests/database/watcherDatabase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ export const fillORM = async (
firstPermit,
secondPermit,
]);
await ORM.tokenRepo.save(validRSNTokenRecord);
const UTXOArray = [plainBox, spentPlainBox];
if (pushExtraUtxo) UTXOArray.push(addressValidBox);
await ORM.boxRepo.save(UTXOArray);
Expand Down

0 comments on commit ac094e4

Please sign in to comment.