-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added handleDepositFinalized event, renamed acre-bitcoin depositor to…
… bitcoin-depositor, added deploy information to readme.md
- Loading branch information
Showing
14 changed files
with
524 additions
and
242 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
module.exports = { | ||
...require("../.prettierrc.js"), | ||
...require("../.prettierrc.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
This file was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
[ | ||
{ | ||
"anonymous": false, | ||
"inputs": [ | ||
{ | ||
"indexed": true, | ||
"internalType": "uint256", | ||
"name": "depositKey", | ||
"type": "uint256" | ||
}, | ||
{ | ||
"indexed": true, | ||
"internalType": "address", | ||
"name": "caller", | ||
"type": "address" | ||
}, | ||
{ | ||
"indexed": true, | ||
"internalType": "address", | ||
"name": "depositOwner", | ||
"type": "address" | ||
}, | ||
{ | ||
"indexed": true, | ||
"internalType": "uint16", | ||
"name": "referral", | ||
"type": "uint16" | ||
}, | ||
{ | ||
"indexed": false, | ||
"internalType": "uint256", | ||
"name": "initialAmount", | ||
"type": "uint256" | ||
}, | ||
{ | ||
"indexed": false, | ||
"internalType": "uint256", | ||
"name": "bridgedAmount", | ||
"type": "uint256" | ||
}, | ||
{ | ||
"indexed": false, | ||
"internalType": "uint256", | ||
"name": "depositorFee", | ||
"type": "uint256" | ||
} | ||
], | ||
"name": "DepositFinalized", | ||
"type": "event" | ||
}, | ||
{ | ||
"anonymous": false, | ||
"inputs": [ | ||
{ | ||
"indexed": true, | ||
"internalType": "uint256", | ||
"name": "depositKey", | ||
"type": "uint256" | ||
}, | ||
{ | ||
"indexed": true, | ||
"internalType": "address", | ||
"name": "caller", | ||
"type": "address" | ||
}, | ||
{ | ||
"indexed": true, | ||
"internalType": "address", | ||
"name": "depositOwner", | ||
"type": "address" | ||
}, | ||
{ | ||
"indexed": false, | ||
"internalType": "uint256", | ||
"name": "initialAmount", | ||
"type": "uint256" | ||
} | ||
], | ||
"name": "DepositInitialized", | ||
"type": "event" | ||
} | ||
] |
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 was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
import { | ||
DepositInitialized as DepositInitializedEvent, | ||
DepositFinalized as DepositFinalizedEvent, | ||
} from "../generated/BitcoinDepositor/BitcoinDepositor" | ||
import { | ||
getOrCreateDepositOwner, | ||
getOrCreateDeposit, | ||
getOrCreateLog, | ||
} from "./utils" | ||
|
||
// eslint-disable-next-line import/prefer-default-export | ||
export function handleDepositInitialized(event: DepositInitializedEvent): void { | ||
const depositOwnerEntity = getOrCreateDepositOwner(event.params.depositOwner) | ||
const depositEntity = getOrCreateDeposit( | ||
event.params.depositKey.toHexString(), | ||
) | ||
|
||
depositEntity.depositOwner = depositOwnerEntity.id | ||
depositEntity.initialDepositAmountSatoshi = event.params.initialAmount | ||
|
||
const logDataBtc = getOrCreateLog( | ||
`${event.transaction.hash.toHexString()}btc`, | ||
) | ||
const logDataEth = getOrCreateLog( | ||
`${event.transaction.hash.toHexString()}eth`, | ||
) | ||
|
||
logDataBtc.activity = depositEntity.id | ||
|
||
// This timestamp may be different than the actual time | ||
// when the BTC transaction took place: | ||
// It indicates when Ethereum received event about this BTC deposit, | ||
// not when the BTC transaction happened. | ||
logDataBtc.timestamp = event.block.timestamp | ||
logDataBtc.chain = "Bitcoin" | ||
logDataBtc.amount = event.params.initialAmount | ||
|
||
logDataEth.activity = depositEntity.id | ||
logDataEth.timestamp = event.block.timestamp | ||
logDataEth.chain = "Ethereum" | ||
logDataEth.amount = event.params.initialAmount | ||
|
||
depositOwnerEntity.save() | ||
depositEntity.save() | ||
logDataBtc.save() | ||
logDataEth.save() | ||
} | ||
|
||
export function handleDepositFinalized(event: DepositFinalizedEvent): void { | ||
const depositOwnerEntity = getOrCreateDepositOwner(event.params.depositOwner) | ||
const depositEntity = getOrCreateDeposit( | ||
event.params.depositKey.toHexString(), | ||
) | ||
|
||
depositEntity.depositOwner = depositOwnerEntity.id | ||
depositEntity.initialDepositAmountSatoshi = event.params.initialAmount | ||
depositEntity.amountToDepositStBtc = event.params.bridgedAmount | ||
|
||
const logDataBtc = getOrCreateLog( | ||
`${event.transaction.hash.toHexString()}btc`, | ||
) | ||
const logDataEth = getOrCreateLog( | ||
`${event.transaction.hash.toHexString()}eth`, | ||
) | ||
|
||
logDataBtc.activity = depositEntity.id | ||
|
||
// This timestamp may be different than the actual time | ||
// when the BTC transaction took place: | ||
// It indicates when Ethereum received event about this BTC deposit, | ||
// not when the BTC transaction happened. | ||
logDataBtc.timestamp = event.block.timestamp | ||
logDataBtc.chain = "Bitcoin" | ||
logDataBtc.amount = event.params.initialAmount | ||
|
||
logDataEth.activity = depositEntity.id | ||
logDataEth.timestamp = event.block.timestamp | ||
logDataEth.chain = "Ethereum" | ||
logDataEth.amount = event.params.initialAmount | ||
|
||
depositOwnerEntity.save() | ||
depositEntity.save() | ||
logDataBtc.save() | ||
logDataEth.save() | ||
} |
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
Oops, something went wrong.