From e03565ccf0789ab0d6931afa8ffb55766800f7c7 Mon Sep 17 00:00:00 2001 From: Cayod Date: Wed, 11 Oct 2023 11:11:15 -0300 Subject: [PATCH 1/4] fixed history_trade and liquidity_pool asset_id field --- internal/transform/liquidity_pool.go | 8 ++++---- internal/transform/trade.go | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/internal/transform/liquidity_pool.go b/internal/transform/liquidity_pool.go index e6a34a0f..5cd66674 100644 --- a/internal/transform/liquidity_pool.go +++ b/internal/transform/liquidity_pool.go @@ -36,15 +36,15 @@ func TransformPool(ledgerChange ingest.Change) (PoolOutput, error) { } var assetAType, assetACode, assetAIssuer string - err = cp.Params.AssetA.Extract(&assetAType, &assetACode, &assetAIssuer) + err = cp.Params.AssetA.Extract(&assetACode, &assetAIssuer, &assetAType) if err != nil { return PoolOutput{}, err } - assetAID := FarmHashAsset(assetAType, assetACode, assetAIssuer) + assetAID := FarmHashAsset(assetACode, assetAIssuer, assetAType) var assetBType, assetBCode, assetBIssuer string - err = cp.Params.AssetB.Extract(&assetBType, &assetBCode, &assetBIssuer) - assetBID := FarmHashAsset(assetBType, assetBCode, assetBIssuer) + err = cp.Params.AssetB.Extract(&assetBCode, &assetBIssuer, &assetBType) + assetBID := FarmHashAsset(assetBCode, assetBIssuer, assetBType) transformedPool := PoolOutput{ PoolID: PoolIDToString(lp.LiquidityPoolId), diff --git a/internal/transform/trade.go b/internal/transform/trade.go index 57bb07ab..27dfc0da 100644 --- a/internal/transform/trade.go +++ b/internal/transform/trade.go @@ -46,7 +46,7 @@ func TransformTrade(operationIndex int32, operationID int64, transaction ingest. if err != nil { return []TradeOutput{}, err } - outputSellingAssetID := FarmHashAsset(outputSellingAssetType, outputSellingAssetCode, outputSellingAssetIssuer) + outputSellingAssetID := FarmHashAsset(outputSellingAssetCode, outputSellingAssetIssuer, outputSellingAssetType) outputSellingAmount := claimOffer.AmountSold() if outputSellingAmount < 0 { @@ -58,7 +58,7 @@ func TransformTrade(operationIndex int32, operationID int64, transaction ingest. if err != nil { return []TradeOutput{}, err } - outputBuyingAssetID := FarmHashAsset(outputBuyingAssetType, outputBuyingAssetCode, outputBuyingAssetIssuer) + outputBuyingAssetID := FarmHashAsset(outputBuyingAssetCode, outputBuyingAssetIssuer, outputBuyingAssetType) outputBuyingAmount := int64(claimOffer.AmountBought()) if outputBuyingAmount < 0 { From 63016b3a5c7439226aab6755152b6a79ec5a387b Mon Sep 17 00:00:00 2001 From: Cayod Date: Wed, 11 Oct 2023 11:50:42 -0300 Subject: [PATCH 2/4] update trade and liquidity test --- internal/transform/liquidity_pool.go | 4 ++-- internal/transform/liquidity_pool_test.go | 2 +- internal/transform/trade_test.go | 14 +++++++------- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/internal/transform/liquidity_pool.go b/internal/transform/liquidity_pool.go index 5cd66674..6ee41209 100644 --- a/internal/transform/liquidity_pool.go +++ b/internal/transform/liquidity_pool.go @@ -36,14 +36,14 @@ func TransformPool(ledgerChange ingest.Change) (PoolOutput, error) { } var assetAType, assetACode, assetAIssuer string - err = cp.Params.AssetA.Extract(&assetACode, &assetAIssuer, &assetAType) + err = cp.Params.AssetA.Extract(&assetAType, &assetACode, &assetAIssuer) if err != nil { return PoolOutput{}, err } assetAID := FarmHashAsset(assetACode, assetAIssuer, assetAType) var assetBType, assetBCode, assetBIssuer string - err = cp.Params.AssetB.Extract(&assetBCode, &assetBIssuer, &assetBType) + err = cp.Params.AssetB.Extract(&assetBType, &assetBCode, &assetBIssuer) assetBID := FarmHashAsset(assetBCode, assetBIssuer, assetBType) transformedPool := PoolOutput{ diff --git a/internal/transform/liquidity_pool_test.go b/internal/transform/liquidity_pool_test.go index 27a37e7b..3664da3f 100644 --- a/internal/transform/liquidity_pool_test.go +++ b/internal/transform/liquidity_pool_test.go @@ -110,7 +110,7 @@ func makePoolTestOutput() PoolOutput { AssetAReserve: 0.0000105, AssetBType: "credit_alphanum4", AssetBCode: lpAssetB.GetCode(), - AssetBID: -9138108998176092786, + AssetBID: 6690054458235693884, AssetBIssuer: lpAssetB.GetIssuer(), AssetBReserve: 0.0000010, LastModifiedLedger: 30705278, diff --git a/internal/transform/trade_test.go b/internal/transform/trade_test.go index d0f9ee5d..8e963366 100644 --- a/internal/transform/trade_test.go +++ b/internal/transform/trade_test.go @@ -727,13 +727,13 @@ func makeTradeTestOutput() [][]TradeOutput { SellingAssetCode: "ETH", SellingAssetIssuer: testAccount3Address, SellingAssetType: "credit_alphanum4", - SellingAssetID: 7452978348057887059, + SellingAssetID: 4476940172956910889, SellingAmount: 13300347 * 0.0000001, BuyingAccountAddress: testAccount3Address, BuyingAssetCode: "USDT", BuyingAssetIssuer: testAccount4Address, BuyingAssetType: "credit_alphanum4", - BuyingAssetID: 4483110387055733902, + BuyingAssetID: -8205667356306085451, BuyingAmount: 12634 * 0.0000001, PriceN: 12634, PriceD: 13300347, @@ -749,7 +749,7 @@ func makeTradeTestOutput() [][]TradeOutput { SellingAssetCode: "USDT", SellingAssetIssuer: testAccount4Address, SellingAssetType: "credit_alphanum4", - SellingAssetID: 4483110387055733902, + SellingAssetID: -8205667356306085451, SellingAmount: 500 * 0.0000001, BuyingAccountAddress: testAccount3Address, BuyingAssetCode: "", @@ -771,13 +771,13 @@ func makeTradeTestOutput() [][]TradeOutput { SellingAssetCode: "WER", SellingAssetIssuer: testAccount4Address, SellingAssetType: "credit_alphanum4", - SellingAssetID: -7191734819702017351, + SellingAssetID: -7615773297180926952, SellingAmount: 123 * 0.0000001, BuyingAccountAddress: testAccount3Address, BuyingAssetCode: "NIJ", BuyingAssetIssuer: testAccount1Address, BuyingAssetType: "credit_alphanum4", - BuyingAssetID: 4209855448155423050, + BuyingAssetID: -8061435944444096568, BuyingAmount: 456 * 0.0000001, PriceN: 456, PriceD: 123, @@ -796,13 +796,13 @@ func makeTradeTestOutput() [][]TradeOutput { SellingAssetCode: "HAH", SellingAssetIssuer: testAccount1Address, SellingAssetType: "credit_alphanum4", - SellingAssetID: 1757348098415471193, + SellingAssetID: -6231594281606355691, SellingAmount: 1 * 0.0000001, BuyingAccountAddress: testAccount3Address, BuyingAssetCode: "WHO", BuyingAssetIssuer: testAccount4Address, BuyingAssetType: "credit_alphanum4", - BuyingAssetID: -1343268855198636280, + BuyingAssetID: -680582465233747022, BuyingAmount: 1 * 0.0000001, PriceN: 1, PriceD: 1, From bafe18e28b750aece15e2a12f193e987e1c3ca65 Mon Sep 17 00:00:00 2001 From: Cayod Date: Wed, 11 Oct 2023 13:43:26 -0300 Subject: [PATCH 3/4] fixes proposed changes --- internal/transform/asset.go | 4 ++-- internal/transform/schema.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/internal/transform/asset.go b/internal/transform/asset.go index cbe60395..2117fdc5 100644 --- a/internal/transform/asset.go +++ b/internal/transform/asset.go @@ -50,8 +50,8 @@ func transformSingleAsset(asset xdr.Asset) (AssetOutput, error) { AssetCode: outputAssetCode, AssetIssuer: outputAssetIssuer, AssetType: outputAssetType, - AssetID: outputAssetID, - ID: farmAssetID, + AssetID: farmAssetID, + ID: outputAssetID, }, nil } diff --git a/internal/transform/schema.go b/internal/transform/schema.go index 7713b188..f70c53cd 100644 --- a/internal/transform/schema.go +++ b/internal/transform/schema.go @@ -188,8 +188,8 @@ type AssetOutput struct { AssetCode string `json:"asset_code"` AssetIssuer string `json:"asset_issuer"` AssetType string `json:"asset_type"` - AssetID uint64 `json:"id"` - ID int64 `json:"asset_id"` + AssetID int64 `json:"asset_id"` + ID uint64 `json:"id"` } // TrustlineOutput is a representation of a trustline that aligns with the BigQuery table trust_lines From 835d5093fca48b34db919504fde880b4ac12c411 Mon Sep 17 00:00:00 2001 From: Cayod Date: Wed, 11 Oct 2023 13:45:56 -0300 Subject: [PATCH 4/4] change id to asset_id --- internal/transform/asset_test.go | 9 +++++---- internal/transform/claimable_balance.go | 2 +- internal/transform/offer.go | 4 ++-- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/internal/transform/asset_test.go b/internal/transform/asset_test.go index cc1da7c9..3270c7b7 100644 --- a/internal/transform/asset_test.go +++ b/internal/transform/asset_test.go @@ -103,15 +103,16 @@ func makeAssetTestOutput() (transformedAssets []AssetOutput) { AssetCode: "USDT", AssetIssuer: "GBVVRXLMNCJQW3IDDXC3X6XCH35B5Q7QXNMMFPENSOGUPQO7WO7HGZPA", AssetType: "credit_alphanum4", - AssetID: 1229977787683536144, - ID: -8205667356306085451, + AssetID: -8205667356306085451, + + ID: 1229977787683536144, }, AssetOutput{ AssetCode: "", AssetIssuer: "", AssetType: "native", - AssetID: 12638146518625398189, - ID: -5706705804583548011, + AssetID: -5706705804583548011, + ID: 12638146518625398189, }, } return diff --git a/internal/transform/claimable_balance.go b/internal/transform/claimable_balance.go index 7db3ef8f..d7c6d1ab 100644 --- a/internal/transform/claimable_balance.go +++ b/internal/transform/claimable_balance.go @@ -50,7 +50,7 @@ func TransformClaimableBalance(ledgerChange ingest.Change) (ClaimableBalanceOutp AssetCode: outputAsset.AssetCode, AssetIssuer: outputAsset.AssetIssuer, AssetType: outputAsset.AssetType, - AssetID: outputAsset.ID, + AssetID: outputAsset.AssetID, Claimants: outputClaimants, AssetAmount: float64(outputAmount) / 1.0e7, Sponsor: ledgerEntrySponsorToNullString(ledgerEntry), diff --git a/internal/transform/offer.go b/internal/transform/offer.go index c0cc787e..5f44a3c9 100644 --- a/internal/transform/offer.go +++ b/internal/transform/offer.go @@ -74,11 +74,11 @@ func TransformOffer(ledgerChange ingest.Change) (OfferOutput, error) { SellingAssetType: outputSellingAsset.AssetType, SellingAssetCode: outputSellingAsset.AssetCode, SellingAssetIssuer: outputSellingAsset.AssetIssuer, - SellingAssetID: outputSellingAsset.ID, + SellingAssetID: outputSellingAsset.AssetID, BuyingAssetType: outputBuyingAsset.AssetType, BuyingAssetCode: outputBuyingAsset.AssetCode, BuyingAssetIssuer: outputBuyingAsset.AssetIssuer, - BuyingAssetID: outputBuyingAsset.ID, + BuyingAssetID: outputBuyingAsset.AssetID, Amount: utils.ConvertStroopValueToReal(outputAmount), PriceN: outputPriceN, PriceD: outputPriceD,