This repository has been archived by the owner on May 19, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
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
Leandro Yalet
committed
May 18, 2020
1 parent
03162b9
commit a5aaefe
Showing
5 changed files
with
67 additions
and
0 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import Utils from 'web3-utils' | ||
import abiDecoder from 'abi-decoder' | ||
|
||
import Domain from './models/domain.model' | ||
|
||
abiDecoder.addABI([ | ||
{ | ||
"constant": false, | ||
"inputs": [ | ||
{ | ||
"name": "_to", | ||
"type": "address" | ||
}, | ||
{ | ||
"name": "_value", | ||
"type": "uint256" | ||
}, | ||
{ | ||
"name": "_data", | ||
"type": "bytes" | ||
} | ||
], | ||
"name": "transferAndCall", | ||
"outputs": [ | ||
{ | ||
"name": "", | ||
"type": "bool" | ||
} | ||
], | ||
"payable": false, | ||
"stateMutability": "nonpayable", | ||
"type": "function" | ||
} | ||
]); | ||
|
||
export default async function processRskOwner(eth: Eth, contractAbi: Utils.AbiItem[], rskOwnerAddresses: string, fifsAddrAddress: string) { | ||
const rskOwner = new eth.Contract(contractAbi, rskOwnerAddresses) | ||
const rskOwnerEvents = await rskOwner.getPastEvents('Transfer', { | ||
filter: { from: fifsAddrAddress }, | ||
fromBlock: 0 | ||
}); | ||
for (const rskOwnerEvent of rskOwnerEvents) { | ||
const transaction = await eth.getTransaction(rskOwnerEvent.transactionHash) | ||
const decodedData = abiDecoder.decodeMethod(transaction.input) | ||
const name = Utils.hexToAscii("0x" + decodedData.params[2].value.slice(218, decodedData.params[2].value.length)) | ||
const tokenId = Utils.sha3(name) | ||
const ownerAddress = rskOwnerEvent.returnValues.to.toLowerCase() | ||
const req = new Domain({tokenId, name, ownerAddress}) | ||
await req.save() | ||
}; | ||
} |