Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions dipdup.mainnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ contracts:
address: KT1WvzYHCNBvDSdwafTHv7nJ1dWmZ8GCYuuC
typename: objkt_marketplace_v2

fxhash_v1_mainnet:
address: KT1Xo5B7PNBAeynZPmca4bRh6LQow4og1Zb9
typename: fxhash_marketplace_v1

indexes:
hen_actions:
kind: operation
Expand Down Expand Up @@ -80,6 +84,30 @@ indexes:
- destination: objkt_v2_mainnet
entrypoint: fulfill_ask

fxhash_v1_actions:
kind: operation
datasource: tzkt_mainnet
contracts:
- fxhash_v1_mainnet
handlers:
- callback: fxhash_v1_order_list
pattern:
- type: transaction
destination: fxhash_v1_mainnet
entrypoint: offer

- callback: fxhash_v1_order_cancel_list
pattern:
- type: transaction
destination: fxhash_v1_mainnet
entrypoint: cancel_offer

- callback: fxhash_v1_order_match
pattern:
- type: transaction
destination: fxhash_v1_mainnet
entrypoint: collect

token_ransfers:
kind: token_transfer
datasource: tzkt_mainnet
Expand Down
74 changes: 74 additions & 0 deletions rarible_marketplace_indexer/event/fxhash_v1_action.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
from dipdup.datasources.tzkt.datasource import TzktDatasource
from dipdup.models import Transaction

from rarible_marketplace_indexer.event.abstract_action import AbstractOrderCancelEvent
from rarible_marketplace_indexer.event.abstract_action import AbstractOrderListEvent
from rarible_marketplace_indexer.event.abstract_action import AbstractOrderMatchEvent
from rarible_marketplace_indexer.event.dto import CancelDto
from rarible_marketplace_indexer.event.dto import ListDto
from rarible_marketplace_indexer.event.dto import MakeDto
from rarible_marketplace_indexer.event.dto import MatchDto
from rarible_marketplace_indexer.event.dto import TakeDto
from rarible_marketplace_indexer.models import PlatformEnum
from rarible_marketplace_indexer.types.fxhash_marketplace_v1.parameter.offer import OfferParameter
from rarible_marketplace_indexer.types.fxhash_marketplace_v1.parameter.cancel_offer import CancelOfferParameter
from rarible_marketplace_indexer.types.fxhash_marketplace_v1.parameter.collect import CollectParameter
from rarible_marketplace_indexer.types.fxhash_marketplace_v1.storage import FxhashMarketplaceV1Storage
from rarible_marketplace_indexer.types.rarible_api_objects.asset.enum import AssetClassEnum
from rarible_marketplace_indexer.types.tezos_objects.asset_value.asset_value import AssetValue
from rarible_marketplace_indexer.types.tezos_objects.asset_value.xtz_value import Xtz
from rarible_marketplace_indexer.types.tezos_objects.tezos_object_hash import ImplicitAccountAddress
from rarible_marketplace_indexer.types.tezos_objects.tezos_object_hash import OriginatedAccountAddress


class FxhashV1OrderListEvent(AbstractOrderListEvent):
platform = PlatformEnum.FXHASH_V1
FxhashListTransaction = Transaction[OfferParameter, FxhashMarketplaceV1Storage]

@staticmethod
def _get_list_dto(
transaction: FxhashListTransaction,
datasource: TzktDatasource,
) -> ListDto:
make_value = AssetValue(1)
make_price = Xtz.from_u_tezos(transaction.parameter.price)

return ListDto(
internal_order_id=str(int(transaction.storage.counter) - 1),
maker=ImplicitAccountAddress(transaction.data.sender_address),
make_price=make_price,
make=MakeDto(
asset_class=AssetClassEnum.MULTI_TOKEN,
contract=OriginatedAccountAddress(transaction.storage.objkts),
token_id=int(transaction.parameter.objkt_id),
value=make_value,
),
take=TakeDto(
asset_class=AssetClassEnum.XTZ,
contract=None,
token_id=None,
value=Xtz(make_value * make_price),
),
)


class FxhashV1OrderCancelEvent(AbstractOrderCancelEvent):
platform = PlatformEnum.FXHASH_V1
FxhashCancelTransaction = Transaction[CancelOfferParameter, FxhashMarketplaceV1Storage]

@staticmethod
def _get_cancel_dto(transaction: FxhashCancelTransaction, datasource: TzktDatasource) -> CancelDto:
return CancelDto(internal_order_id=transaction.parameter.__root__)


class FxhashV1OrderMatchEvent(AbstractOrderMatchEvent):
platform = PlatformEnum.FXHASH_V1
FxhashMatchTransaction = Transaction[CollectParameter, FxhashMarketplaceV1Storage]

@staticmethod
def _get_match_dto(transaction: FxhashMatchTransaction, datasource: TzktDatasource) -> MatchDto:
return MatchDto(
internal_order_id=transaction.parameter.__root__,
match_amount=AssetValue(1),
match_timestamp=transaction.data.timestamp,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from dipdup.context import HandlerContext
from dipdup.models import Transaction

from rarible_marketplace_indexer.event.fxhash_v1_action import FxhashV1OrderCancelEvent
from rarible_marketplace_indexer.types.fxhash_marketplace_v1.parameter.cancel_offer import CancelOfferParameter
from rarible_marketplace_indexer.types.fxhash_marketplace_v1.storage import FxhashMarketplaceV1Storage

async def fxhash_v1_order_cancel_list(
ctx: HandlerContext,
cancel_offer: Transaction[CancelOfferParameter, FxhashMarketplaceV1Storage],
) -> None:
await FxhashV1OrderCancelEvent.handle(cancel_offer, ctx.datasource)
12 changes: 12 additions & 0 deletions rarible_marketplace_indexer/handlers/fxhash_v1_order_list.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from dipdup.context import HandlerContext
from dipdup.models import Transaction

from rarible_marketplace_indexer.event.fxhash_v1_action import FxhashV1OrderListEvent
from rarible_marketplace_indexer.types.fxhash_marketplace_v1.parameter.offer import OfferParameter
from rarible_marketplace_indexer.types.fxhash_marketplace_v1.storage import FxhashMarketplaceV1Storage

async def fxhash_v1_order_list(
ctx: HandlerContext,
offer: Transaction[OfferParameter, FxhashMarketplaceV1Storage],
) -> None:
await FxhashV1OrderListEvent.handle(offer, ctx.datasource)
12 changes: 12 additions & 0 deletions rarible_marketplace_indexer/handlers/fxhash_v1_order_match.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from dipdup.context import HandlerContext
from dipdup.models import Transaction

from rarible_marketplace_indexer.event.fxhash_v1_action import FxhashV1OrderMatchEvent
from rarible_marketplace_indexer.types.fxhash_marketplace_v1.storage import FxhashMarketplaceV1Storage
from rarible_marketplace_indexer.types.fxhash_marketplace_v1.parameter.collect import CollectParameter

async def fxhash_v1_order_match(
ctx: HandlerContext,
collect: Transaction[CollectParameter, FxhashMarketplaceV1Storage],
) -> None:
await FxhashV1OrderMatchEvent.handle(collect, ctx.datasource)
1 change: 1 addition & 0 deletions rarible_marketplace_indexer/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class PlatformEnum(str, Enum):
OBJKT: _StrEnumValue = 'Objkt'
OBJKT_V2: _StrEnumValue = 'Objkt_v2'
RARIBLE: _StrEnumValue = 'Rarible'
FXHASH_V1: _StrEnumValue = 'Fxhash_v1'


class ActivityModel(Model):
Expand Down
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# generated by datamodel-codegen:
# filename: cancel_offer.json

from __future__ import annotations

from pydantic import BaseModel


class CancelOfferParameter(BaseModel):
__root__: str
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# generated by datamodel-codegen:
# filename: collect.json

from __future__ import annotations

from pydantic import BaseModel


class CollectParameter(BaseModel):
__root__: str
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# generated by datamodel-codegen:
# filename: offer.json

from __future__ import annotations

from pydantic import BaseModel
from pydantic import Extra


class OfferParameter(BaseModel):
class Config:
extra = Extra.forbid

creator: str
objkt_id: str
price: str
royalties: str
35 changes: 35 additions & 0 deletions rarible_marketplace_indexer/types/fxhash_marketplace_v1/storage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# generated by datamodel-codegen:
# filename: storage.json

from __future__ import annotations

from typing import Dict

from pydantic import BaseModel
from pydantic import Extra


class Offers(BaseModel):
class Config:
extra = Extra.forbid

creator: str
issuer: str
objkt_amount: str
objkt_id: str
price: str
royalties: str


class FxhashMarketplaceV1Storage(BaseModel):
class Config:
extra = Extra.forbid

admin: str
counter: str
enabled: bool
fees: str
metadata: Dict[str, str]
objkts: str
offers: Dict[str, Offers]
treasury: str