From 3d6567229be1f6312709f7fb46df993036927c3c Mon Sep 17 00:00:00 2001 From: Maksim Strebkov <257byte@gmail.com> Date: Mon, 13 May 2024 15:53:25 +0300 Subject: [PATCH] Add non-root ledgers support --- Tzkt.Sync/Protocols/Helpers/BigMaps.cs | 37 ++++++++++++-------------- 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/Tzkt.Sync/Protocols/Helpers/BigMaps.cs b/Tzkt.Sync/Protocols/Helpers/BigMaps.cs index 88339b2c3..9f236d2a8 100644 --- a/Tzkt.Sync/Protocols/Helpers/BigMaps.cs +++ b/Tzkt.Sync/Protocols/Helpers/BigMaps.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Numerics; +using System.Numerics; using System.Text.Json; using Netezos.Contracts; using Netezos.Encoding; @@ -13,35 +10,35 @@ static class BigMaps { public static BigMapTag GetTags(Contract contract, TreeView bigmap) { + var schema = bigmap.Schema as BigMapSchema; var tags = BigMapTag.None; + if (IsPersistent(bigmap)) { tags |= BigMapTag.Persistent; - var schema = bigmap.Schema as BigMapSchema; if (schema.Field == "metadata") { if (schema.Key is StringSchema && schema.Value is BytesSchema) tags |= BigMapTag.Metadata; } - else if (contract.Kind == ContractKind.Asset) + else if (contract.Kind == ContractKind.Asset && schema.Field == "token_metadata") { - if (schema.Field == "token_metadata") - { - if (schema.Key is NatSchema && - schema.Value is PairSchema pair && - pair.Left is NatSchema && - pair.Right is MapSchema map && - map.Key is StringSchema && - map.Value is BytesSchema) - tags |= BigMapTag.TokenMetadata; - } - else if (schema.Field == "ledger") - { - tags |= GetLedgerType(schema); - } + if (schema.Key is NatSchema && + schema.Value is PairSchema pair && + pair.Left is NatSchema && + pair.Right is MapSchema map && + map.Key is StringSchema && + map.Value is BytesSchema) + tags |= BigMapTag.TokenMetadata; } } + + if (contract.Kind == ContractKind.Asset && schema.Field == "ledger") + { + tags |= GetLedgerType(schema); + } + return tags; }