Skip to content

Commit

Permalink
Fix the values for asset type string
Browse files Browse the repository at this point in the history
  • Loading branch information
amishas157 committed Jul 19, 2024
1 parent 0e50a22 commit b657484
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 4 additions & 1 deletion internal/transform/trustline.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,15 @@ func TransformTrustline(ledgerChange ingest.Change, header xdr.LedgerHeaderHisto
return TrustlineOutput{}, errors.Wrap(err, fmt.Sprintf("could not create ledger key string for trustline with account %s and asset %s", outputAccountID, asset.ToAsset().StringCanonical()))
}

var assetTypeString string
if asset.Type == xdr.AssetTypeAssetTypePoolShare {
poolID = PoolIDToString(trustEntry.Asset.MustLiquidityPoolId())
assetTypeString = "pool_share"
} else {
if err = asset.Extract(&assetType, &outputAssetCode, &outputAssetIssuer); err != nil {
return TrustlineOutput{}, errors.Wrap(err, fmt.Sprintf("could not parse asset for trustline with account %s", outputAccountID))
}
assetTypeString = assetType
}

outputAssetID := FarmHashAsset(outputAssetCode, outputAssetIssuer, asset.Type.String())
Expand All @@ -61,7 +64,7 @@ func TransformTrustline(ledgerChange ingest.Change, header xdr.LedgerHeaderHisto
transformedTrustline := TrustlineOutput{
LedgerKey: outputLedgerKey,
AccountID: outputAccountID,
AssetType: asset.Type.String(),
AssetType: assetTypeString,
AssetCode: outputAssetCode,
AssetIssuer: outputAssetIssuer,
AssetID: outputAssetID,
Expand Down
4 changes: 2 additions & 2 deletions internal/transform/trustline_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ func makeTrustlineTestOutput() []TrustlineOutput {
{
LedgerKey: "AAAAAQAAAACI4aa0pXFSj6qfJuIObLw/5zyugLRGYwxb7wFSr3B9eAAAAAFFVEgAAAAAAGfMAIZMO4kWjGqv4Lw0cJ7QIcUFcuL5iGE0IggsIily",
AccountID: testAccount1Address,
AssetType: "AssetTypeAssetTypeCreditAlphanum4",
AssetType: "credit_alphanum4",
AssetIssuer: testAccount3Address,
AssetCode: "ETH",
AssetID: -2311386320395871674,
Expand All @@ -146,7 +146,7 @@ func makeTrustlineTestOutput() []TrustlineOutput {
{
LedgerKey: "AAAAAQAAAAAcR0GXGO76pFs4y38vJVAanjnLg4emNun7zAx0pHcDGAAAAAMBAwQFBwkAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==",
AccountID: testAccount2Address,
AssetType: "AssetTypeAssetTypePoolShare",
AssetType: "pool_share",
AssetID: -1967220342708457407,
Balance: 0.5,
TrustlineLimit: 1111111111111111111,
Expand Down

0 comments on commit b657484

Please sign in to comment.