diff --git a/internal/handlers/ledger.go b/internal/handlers/ledger.go index 1959e3d87..4941814b8 100644 --- a/internal/handlers/ledger.go +++ b/internal/handlers/ledger.go @@ -86,14 +86,6 @@ func (ledger *Ledger) getResultModels(bmd *bigmapdiff.BigMapDiff, bigMapType *as if len(balance) == 0 { return nil, nil } - if balance[0].IsNFT { - if err := ledger.tokenBalances.BurnNft(bmd.Network, bmd.Address, balance[0].TokenID); err != nil { - return nil, err - } - if balance[0].Address == "" { // Burn NFT token - return nil, nil - } - } tb := &tbModel.TokenBalance{ Network: bmd.Network, diff --git a/internal/parsers/tokenbalance/nft_asset.go b/internal/parsers/tokenbalance/nft_asset.go index e39de1531..f31cf67a3 100644 --- a/internal/parsers/tokenbalance/nft_asset.go +++ b/internal/parsers/tokenbalance/nft_asset.go @@ -74,7 +74,6 @@ func (p NftAsset) Parse(data []byte) ([]TokenBalance, error) { Value: balance, Address: address, TokenID: tokenID.Int64(), - IsNFT: true, }) return false, nil }) diff --git a/internal/parsers/tokenbalance/nft_single_asset.go b/internal/parsers/tokenbalance/nft_single_asset.go deleted file mode 100644 index d9b523670..000000000 --- a/internal/parsers/tokenbalance/nft_single_asset.go +++ /dev/null @@ -1,88 +0,0 @@ -package tokenbalance - -import ( - "math/big" - - "github.com/baking-bad/bcdhub/internal/bcd/ast" - "github.com/baking-bad/bcdhub/internal/bcd/forge" - "github.com/baking-bad/bcdhub/internal/bcd/types" -) - -// NftSingleAsset - -type NftSingleAsset struct { - ReturnType *ast.TypedAst -} - -// NewNftSingleAsset - -func NewNftSingleAsset() NftSingleAsset { - node, _ := ast.NewTypedAstFromString(`{"prim":"map","args":[{"prim":"address"},{"prim":"nat"}]}`) - return NftSingleAsset{ - ReturnType: node, - } -} - -// NewNftSingleAssetOption - -func NewNftSingleAssetOption() NftSingleAsset { - node, _ := ast.NewTypedAstFromString(`{"prim":"map","args":[{"prim":"address"},{"prim":"option","args":[{"prim":"nat"}]}]}`) - return NftSingleAsset{ - ReturnType: node, - } -} - -// GetReturnType - -func (p NftSingleAsset) GetReturnType() *ast.TypedAst { - return p.ReturnType -} - -// Parse - -func (p NftSingleAsset) Parse(data []byte) ([]TokenBalance, error) { - m, err := getMap(p.ReturnType, data) - if err != nil { - return nil, err - } - - balances := make([]TokenBalance, 0) - err = m.Data.Range(func(key, value ast.Comparable) (bool, error) { - k := key.(*ast.Address) - var address string - if s, ok := k.Value.(string); ok { - address = forge.DecodeString(s) - } else { - return false, nil - } - - balance := big.NewInt(0) - - switch t := value.(type) { - case *ast.Nat: - if s, ok := t.GetValue().(*types.BigInt); ok { - balance.Set(s.Int) - } else { - return false, nil - } - case *ast.Option: - if t.IsSome() { - val := t.Type.(*ast.Address) - if s, ok := val.GetValue().(*types.BigInt); ok { - balance.Set(s.Int) - } else { - return false, nil - } - } - default: - return false, nil - } - - balances = append(balances, TokenBalance{ - Value: balance, - Address: address, - IsNFT: true, - }) - return false, nil - }) - if err != nil { - return nil, err - } - - return balances, nil -} diff --git a/internal/parsers/tokenbalance/parser.go b/internal/parsers/tokenbalance/parser.go index 0469375c5..59d70435c 100644 --- a/internal/parsers/tokenbalance/parser.go +++ b/internal/parsers/tokenbalance/parser.go @@ -22,7 +22,6 @@ var parsersEvents = map[string][]Parser{ }, NftAssetBalanceUpdates: { NewNftAssetOption(), - NewNftSingleAssetOption(), }, } @@ -37,7 +36,6 @@ var parsersBigMap = map[string][]Parser{ }, NftAssetBalanceUpdates: { NewNftAsset(), - NewNftSingleAsset(), }, } @@ -52,7 +50,6 @@ type TokenBalance struct { Address string TokenID int64 Value *big.Int - IsNFT bool } // GetParserForEvents - diff --git a/internal/parsers/tokenbalance/parsers_test.go b/internal/parsers/tokenbalance/parsers_test.go index a18aa1d02..89188cd54 100644 --- a/internal/parsers/tokenbalance/parsers_test.go +++ b/internal/parsers/tokenbalance/parsers_test.go @@ -105,7 +105,6 @@ func Test_nftParser_Parse(t *testing.T) { Address: "KT1BYYLfMjufYwqFtTSYJND7bzKNyK7mjrjM", TokenID: 1, Value: newBigIntFromString("1"), - IsNFT: true, }, }, }, @@ -136,7 +135,6 @@ func Test_nftOptionParser_Parse(t *testing.T) { Address: "KT1BYYLfMjufYwqFtTSYJND7bzKNyK7mjrjM", TokenID: 1, Value: newBigIntFromString("1"), - IsNFT: true, }, }, }, { @@ -147,7 +145,6 @@ func Test_nftOptionParser_Parse(t *testing.T) { Address: "", TokenID: 1, Value: newBigIntFromString("0"), - IsNFT: true, }, }, },