-
Notifications
You must be signed in to change notification settings - Fork 0
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
d53bb9d
commit 3038d94
Showing
11 changed files
with
136 additions
and
19 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
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,50 @@ | ||
from datetime import datetime | ||
from datetime import timezone | ||
|
||
from dipdup.context import HandlerContext | ||
from dipdup.models import Index | ||
from dipdup.models import IndexStatus | ||
from dipdup.models.evm_node import EvmNodeTransactionData | ||
from dipdup.models.evm_subsquid import SubsquidTransactionData | ||
|
||
from bridge_indexer.handlers.bridge_matcher import BridgeMatcher | ||
from bridge_indexer.models import EtherlinkDepositEvent | ||
from bridge_indexer.models import EtherlinkToken | ||
|
||
|
||
async def on_xtz_deposit( | ||
ctx: HandlerContext, | ||
transaction: SubsquidTransactionData | EvmNodeTransactionData, | ||
) -> None: | ||
validators = [ | ||
transaction.value > 0, | ||
transaction.from_ == '0x0000000000000000000000000000000000000000', | ||
transaction.to != transaction.from_, | ||
transaction.input == '0x', | ||
transaction.sighash == '0x', | ||
transaction.data is None, | ||
] | ||
if not all(validators): | ||
return | ||
|
||
etherlink_token = await EtherlinkToken.get(id='xtz') | ||
|
||
await EtherlinkDepositEvent.create( | ||
timestamp=datetime.fromtimestamp(transaction.timestamp, tz=timezone.utc), | ||
level=transaction.level, | ||
address=transaction.from_[-40:], | ||
log_index=0, | ||
transaction_hash=transaction.hash[-64:], | ||
transaction_index=transaction.transaction_index, | ||
l2_account=transaction.to[-40:], | ||
l2_token=etherlink_token, | ||
amount=transaction.value, | ||
inbox_message=None, | ||
) | ||
|
||
ctx.logger.info(f'Deposit Transaction registered: {transaction}') | ||
|
||
sync_level = ctx.datasources['etherlink_node']._subscriptions._subscriptions[None] | ||
status = await Index.get(name='etherlink_kernel_events').only('status').values_list('status', flat=True) | ||
if status == IndexStatus.realtime or sync_level - transaction.level < 5: | ||
await BridgeMatcher.check_pending_etherlink_deposits() |
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
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 |
---|---|---|
@@ -1,2 +1,19 @@ | ||
insert into tezos_token (id, contract_address, token_id, name, symbol, decimals, type) | ||
values ('xtz', 'KT1000000000000000000000000000000000', '0', 'Tezos', 'XTZ', 6, 'native'); | ||
|
||
insert into tezos_ticket (id, ticketer_address, ticket_id, ticket_hash, token_id) | ||
values ( | ||
'KT1Q6aNZ9aGro4DvBKwhKvVdia2UmVGsS9zE_0', | ||
'KT1Q6aNZ9aGro4DvBKwhKvVdia2UmVGsS9zE', | ||
'0', | ||
'10666650643273303508566200220257708314889526103361559239516955374962850039068', | ||
'xtz' | ||
); | ||
|
||
insert into etherlink_token (id, name, tezos_ticket_hash, tezos_ticket_id) | ||
values ( | ||
'xtz', | ||
'ethXTZ', | ||
'10666650643273303508566200220257708314889526103361559239516955374962850039068', | ||
'KT1Q6aNZ9aGro4DvBKwhKvVdia2UmVGsS9zE_0' | ||
); |
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,12 @@ | ||
from __future__ import annotations | ||
|
||
from pydantic import BaseModel | ||
from pydantic import Extra | ||
|
||
|
||
class Transfer(BaseModel): | ||
class Config: | ||
extra = Extra.forbid | ||
|
||
to: str | ||
amount: int |