Skip to content

Commit

Permalink
Use built-in registries when available
Browse files Browse the repository at this point in the history
  • Loading branch information
droserasprout committed Oct 23, 2024
1 parent 4da75a0 commit 55f5ce3
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/dipdup/runtimes.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,16 @@ def extract_args_name(description: str) -> list[str]:
def get_type_registry(name_or_path: str | Path) -> 'RuntimeConfigurationObject':
from scalecodec.type_registry import load_type_registry_preset # type: ignore[import-untyped]

if isinstance(name_or_path, str) and Path(name_or_path).is_file():
name_or_path = Path(name_or_path)
if isinstance(name_or_path, str):
# NOTE: User path has higher priority
for path in (
Path(f'type_registries/{name_or_path}.json'),
Path(name_or_path),
):
if not path.is_file():
continue
name_or_path = path

if isinstance(name_or_path, Path):
return orjson.loads(name_or_path.read_bytes())
return load_type_registry_preset(name_or_path)
Expand Down
57 changes: 57 additions & 0 deletions src/dipdup/type_registries/hydradx.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{
"types": {
"AssetPair": {
"asset_in": "AssetId",
"asset_out": "AssetId"
},
"Amount": "i128",
"AmountOf": "Amount",
"Address": "AccountId",
"OrmlAccountData": {
"free": "Balance",
"frozen": "Balance",
"reserved": "Balance"
},
"Fee": {
"numerator": "u32",
"denominator": "u32"
},
"BalanceInfo": {
"amount": "Balance",
"assetId": "AssetId"
},
"Currency": "AssetId",
"CurrencyId": "AssetId",
"CurrencyIdOf": "AssetId",
"Intention": {
"who": "AccountId",
"asset_sell": "AssetId",
"asset_buy": "AssetId",
"amount": "Balance",
"discount": "bool",
"sell_or_buy": "IntentionType"
},
"IntentionId": "u128",
"IntentionType": {
"_enum": [
"SELL",
"BUY"
]
},
"LookupSource": "AccountId",
"OrderedSet": "Vec<AssetId>",
"Price": "Balance",
"Chain": {
"genesisHash": "Vec<u8>",
"lastBlockHash": "Vec<u8>"
}
},
"typesAlias": {
"tokens": {
"AccountData": "OrmlAccountData"
}
},
"signedExtensions": {
"ValidateClaim": "Null"
}
}

0 comments on commit 55f5ce3

Please sign in to comment.