-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
209b474
commit 5ee5ac2
Showing
3 changed files
with
47 additions
and
1 deletion.
There are no files selected for viewing
43 changes: 43 additions & 0 deletions
43
packages/input-scan/src/business/event/centrifuge/minted.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
const { | ||
env: { currentChain }, | ||
consts: { | ||
Modules, | ||
} | ||
} = require("@osn/scan-common"); | ||
|
||
function isNextEventValid(indexer, blockEvents) { | ||
const nextEvent = blockEvents[indexer.eventIndex + 1]; | ||
const { section, method } = nextEvent.event; | ||
return "blockRewards" === section && "NewSession" === method; | ||
} | ||
|
||
function handleBalancesMinted(event, indexer, blockEvents) { | ||
if ("centrifuge" !== currentChain()) { | ||
return; | ||
} | ||
const { section, method, data } = event; | ||
if (section !== Modules.Balances || "Minted" !== method) { | ||
return; | ||
} | ||
|
||
if (!isNextEventValid(indexer, blockEvents)) { | ||
return; | ||
} | ||
|
||
if ("4dpEcgqJRyJK3J8Es6v8ZfVntV7c64Ysgcjd4hYwyGoFPWbg" !== data[0].toString()) { | ||
return; | ||
} | ||
|
||
const obj = { | ||
indexer, | ||
section: "blockRewards", | ||
method: "NewSession", | ||
balance: data[1].toString(), | ||
} | ||
|
||
return data[1].toString(); | ||
} | ||
|
||
module.exports = { | ||
handleBalancesMinted, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters