Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

5551/xdrill operations #5604

Open
wants to merge 48 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
a1f0f73
xdrill for ledgerCloseMeta
chowbao Jan 8, 2025
f1f97a9
go mod tidy
chowbao Jan 8, 2025
36cfcbc
Move util functions from ledger.go to utils.go
chowbao Jan 9, 2025
d064296
change some return values to pointers
chowbao Jan 9, 2025
15fe1e5
Change ledger to Ledger
chowbao Jan 9, 2025
d45b0fd
Remove Ledger struct; pass lcm as param
chowbao Jan 10, 2025
e9de99c
xdrill transaction helper functions
chowbao Jan 9, 2025
40d5057
Move xdrill ledger functions to ingest as subpackage
chowbao Jan 10, 2025
8942168
Change Ledger to use lcm as param instead
chowbao Jan 10, 2025
b5feb2c
Move xdrill ledger functions to ingest as subpackage
chowbao Jan 10, 2025
4aedfdb
Change Ledger to use lcm as param instead
chowbao Jan 10, 2025
a5bd927
Move transaction helper functions to ingest
chowbao Jan 10, 2025
0b62fe2
xdrill transaction helper functions
chowbao Jan 9, 2025
cce0cfe
Move xdrill ledger functions to ingest as subpackage
chowbao Jan 10, 2025
dab3bd9
Move transaction helper functions to ingest
chowbao Jan 10, 2025
219391d
Merge remote-tracking branch 'origin/5550/xdrill-transactions' into 5…
chowbao Jan 10, 2025
58fcfe2
fix merge issues
chowbao Jan 10, 2025
18dd712
fix merge errors
chowbao Jan 10, 2025
314b605
xdrill for operations
chowbao Jan 10, 2025
d385526
Merge branch 'master' into 5549/xdrill-ledgers
chowbao Jan 21, 2025
be020c9
address comments
chowbao Jan 21, 2025
e2ce9bd
Merge branch '5549/xdrill-ledgers' into 5550/xdrill-transactions
chowbao Jan 21, 2025
69f9bf2
Change count to uint32
chowbao Jan 21, 2025
44e627f
Merge branch '5549/xdrill-ledgers' into 5550/xdrill-transactions
chowbao Jan 21, 2025
10b4031
wip
chowbao Jan 21, 2025
93f9639
add txEnvelope OperationsCount()
chowbao Jan 21, 2025
b890631
Merge branch '5549/xdrill-ledgers' into 5550/xdrill-transactions
chowbao Jan 21, 2025
47ecec8
update timebound
chowbao Jan 21, 2025
c2a3616
add InclusionFee()
chowbao Jan 21, 2025
019a3fd
rename to InclusionFeeCharged
chowbao Jan 21, 2025
ee153f8
fix tests
chowbao Jan 21, 2025
16d94ff
Merge branch '5549/xdrill-ledgers' into 5550/xdrill-transactions
chowbao Jan 21, 2025
e9d5511
Merge branch '5550/xdrill-transactions' into 5551/xdrill-operations
chowbao Jan 21, 2025
3bc82f4
update tests
chowbao Jan 21, 2025
21dd54e
address comments
chowbao Jan 21, 2025
b6851fc
Merge branch '5549/xdrill-ledgers' into 5550/xdrill-transactions
chowbao Jan 21, 2025
3d7876c
Merge branch '5550/xdrill-transactions' into 5551/xdrill-operations
chowbao Jan 21, 2025
c68cd9a
updates from comments
chowbao Jan 23, 2025
86d5d78
Add structs for each operation
chowbao Feb 3, 2025
b7c0737
Update marshalbase64
chowbao Feb 3, 2025
a3846f2
Fix typos
chowbao Feb 3, 2025
fc6b854
fix ci/cd
chowbao Feb 3, 2025
875c995
fix tests
chowbao Feb 4, 2025
5c68c65
Update hash.go
chowbao Feb 4, 2025
cc6d49d
add string for js
chowbao Feb 6, 2025
0258c83
make createcontract better
chowbao Feb 6, 2025
52353e1
address comments
chowbao Feb 14, 2025
f73350b
Merge branch 'master' into 5551/xdrill-operations
chowbao Feb 14, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ require (
github.com/docker/docker v27.3.1+incompatible
github.com/docker/go-connections v0.5.0
github.com/fsouza/fake-gcs-server v1.49.2
github.com/stellar/go-stellar-xdr-json v0.0.0-20250203230501-c6fa0788fe99
)

require (
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,8 @@ github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
github.com/spf13/viper v1.17.0 h1:I5txKw7MJasPL/BrfkbA0Jyo/oELqVmux4pR/UxOMfI=
github.com/spf13/viper v1.17.0/go.mod h1:BmMMMLQXSbcHK6KAOiFLz0l5JHrU89OdIRHvsk0+yVI=
github.com/stellar/go-stellar-xdr-json v0.0.0-20250203230501-c6fa0788fe99 h1:m6P+35IPHoxYjAnEgZOgSiDXwEnFCIOpXdwNt8tZ/cw=
github.com/stellar/go-stellar-xdr-json v0.0.0-20250203230501-c6fa0788fe99/go.mod h1:BQ9LWqVJ14qa7ctsyLmjEHSx3Pi7r/8A0mbKzib4cgs=
github.com/stellar/go-xdr v0.0.0-20231122183749-b53fb00bcac2 h1:OzCVd0SV5qE3ZcDeSFCmOWLZfEWZ3Oe8KtmSOYKEVWE=
github.com/stellar/go-xdr v0.0.0-20231122183749-b53fb00bcac2/go.mod h1:yoxyU/M8nl9LKeWIoBrbDPQ7Cy+4jxRcWcOayZ4BMps=
github.com/stellar/throttled v2.2.3-0.20190823235211-89d75816f59d+incompatible h1:jMXXAcz6xTarGDQ4VtVbtERogcmDQw4RaE85Cr9CgoQ=
Expand Down
47 changes: 47 additions & 0 deletions ingest/account_merge_details.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package ingest

import "fmt"

type AccountMergeDetail struct {
Account string `json:"account"`
AccountMuxed string `json:"account_muxed"`
AccountMuxedID uint64 `json:"account_muxed_id,string"`
Into string `json:"into"`
IntoMuxed string `json:"into_muxed"`
IntoMuxedID uint64 `json:"into_muxed_id,string"`
}

func (o *LedgerOperation) AccountMergeDetails() (AccountMergeDetail, error) {
destinationAccount, ok := o.Operation.Body.GetDestination()
if !ok {
return AccountMergeDetail{}, fmt.Errorf("could not access Destination info for this operation (index %d)", o.OperationIndex)
}

accountMergeDetail := AccountMergeDetail{
Account: o.SourceAccount(),
Into: destinationAccount.Address(),
}

var err error
var accountMuxed string
var accountMuxedID uint64
accountMuxed, accountMuxedID, err = getMuxedAccountDetails(o.sourceAccountXDR())
if err != nil {
return AccountMergeDetail{}, err
}

accountMergeDetail.AccountMuxed = accountMuxed
accountMergeDetail.AccountMuxedID = accountMuxedID

var intoMuxed string
var intoMuxedID uint64
intoMuxed, intoMuxedID, err = getMuxedAccountDetails(destinationAccount)
if err != nil {
return AccountMergeDetail{}, err
}

accountMergeDetail.IntoMuxed = intoMuxed
accountMergeDetail.IntoMuxedID = intoMuxedID

return accountMergeDetail, nil
}
58 changes: 58 additions & 0 deletions ingest/allow_trust_details.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package ingest

import (
"fmt"

"github.com/stellar/go/xdr"
)

type AllowTrustDetail struct {
AssetCode string `json:"asset_code"`
AssetIssuer string `json:"asset_issuer"`
AssetType string `json:"asset_type"`
Trustor string `json:"trustor"`
Trustee string `json:"trustee"`
TrusteeMuxed string `json:"trustee_muxed"`
TrusteeMuxedID uint64 `json:"trustee_muxed_id,string"`
Authorize bool `json:"authorize"`
AuthorizeToMaintainLiabilities bool `json:"authorize_to_maintain_liabilities"`
ClawbackEnabled bool `json:"clawback_enabled"`
}

func (o *LedgerOperation) AllowTrustDetails() (AllowTrustDetail, error) {
op, ok := o.Operation.Body.GetAllowTrustOp()
if !ok {
return AllowTrustDetail{}, fmt.Errorf("could not access AllowTrust info for this operation (index %d)", o.OperationIndex)
}

allowTrustDetail := AllowTrustDetail{
Trustor: op.Trustor.Address(),
Trustee: o.SourceAccount(),
Authorize: xdr.TrustLineFlags(op.Authorize).IsAuthorized(),
AuthorizeToMaintainLiabilities: xdr.TrustLineFlags(op.Authorize).IsAuthorizedToMaintainLiabilitiesFlag(),
ClawbackEnabled: xdr.TrustLineFlags(op.Authorize).IsClawbackEnabledFlag(),
}

var err error
var assetCode, assetIssuer, assetType string
err = op.Asset.ToAsset(o.sourceAccountXDR().ToAccountId()).Extract(&assetType, &assetCode, &assetIssuer)
if err != nil {
return AllowTrustDetail{}, err
}

allowTrustDetail.AssetCode = assetCode
allowTrustDetail.AssetIssuer = assetIssuer
allowTrustDetail.AssetType = assetType

var trusteeMuxed string
var trusteeMuxedID uint64
trusteeMuxed, trusteeMuxedID, err = getMuxedAccountDetails(o.sourceAccountXDR())
if err != nil {
return AllowTrustDetail{}, err
}

allowTrustDetail.TrusteeMuxed = trusteeMuxed
allowTrustDetail.TrusteeMuxedID = trusteeMuxedID

return allowTrustDetail, nil
}
18 changes: 18 additions & 0 deletions ingest/begin_sponsoring_future_reserve_details.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package ingest

import "fmt"

type BeginSponsoringFutureReservesDetail struct {
SponsoredID string `json:"sponsored_id"`
}

func (o *LedgerOperation) BeginSponsoringFutureReservesDetails() (BeginSponsoringFutureReservesDetail, error) {
op, ok := o.Operation.Body.GetBeginSponsoringFutureReservesOp()
if !ok {
return BeginSponsoringFutureReservesDetail{}, fmt.Errorf("could not access BeginSponsoringFutureReserves info for this operation (index %d)", o.OperationIndex)
}

return BeginSponsoringFutureReservesDetail{
SponsoredID: op.SponsoredId.Address(),
}, nil
}
18 changes: 18 additions & 0 deletions ingest/bump_sequence_details.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package ingest

import "fmt"

type BumpSequenceDetails struct {
BumpTo int64 `json:"bump_to,string"`
}

func (o *LedgerOperation) BumpSequenceDetails() (BumpSequenceDetails, error) {
op, ok := o.Operation.Body.GetBumpSequenceOp()
if !ok {
return BumpSequenceDetails{}, fmt.Errorf("could not access BumpSequence info for this operation (index %d)", o.OperationIndex)
}

return BumpSequenceDetails{
BumpTo: int64(op.BumpTo),
}, nil
}
85 changes: 85 additions & 0 deletions ingest/change_trust_details.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
package ingest

import (
"fmt"

"github.com/stellar/go/xdr"
)

type ChangeTrustDetail struct {
AssetCode string `json:"asset_code"`
AssetIssuer string `json:"asset_issuer"`
AssetType string `json:"asset_type"`
LiquidityPoolID string `json:"liquidity_pool_id"`
Limit int64 `json:"limit,string"`
Trustee string `json:"trustee"`
Trustor string `json:"trustor"`
TrustorMuxed string `json:"trustor_muxed"`
TrustorMuxedID uint64 `json:"trustor_muxed_id,string"`
}

func (o *LedgerOperation) ChangeTrustDetails() (ChangeTrustDetail, error) {
op, ok := o.Operation.Body.GetChangeTrustOp()
if !ok {
return ChangeTrustDetail{}, fmt.Errorf("could not access GetChangeTrust info for this operation (index %d)", o.OperationIndex)
}

var err error
changeTrustDetail := ChangeTrustDetail{
Trustor: o.SourceAccount(),
Limit: int64(op.Limit),
}

if op.Line.Type == xdr.AssetTypeAssetTypePoolShare {
changeTrustDetail.AssetType, changeTrustDetail.LiquidityPoolID, err = getLiquidityPoolAssetDetails(*op.Line.LiquidityPool)
if err != nil {
return ChangeTrustDetail{}, err
}
} else {
var assetCode, assetIssuer, assetType string
err = op.Line.ToAsset().Extract(&assetType, &assetCode, &assetIssuer)
if err != nil {
return ChangeTrustDetail{}, err
}

changeTrustDetail.AssetCode = assetCode
changeTrustDetail.AssetIssuer = assetIssuer
changeTrustDetail.AssetType = assetType
changeTrustDetail.Trustee = assetIssuer
}

var trustorMuxed string
var trustorMuxedID uint64
trustorMuxed, trustorMuxedID, err = getMuxedAccountDetails(o.sourceAccountXDR())
if err != nil {
return ChangeTrustDetail{}, err
}

changeTrustDetail.TrustorMuxed = trustorMuxed
changeTrustDetail.TrustorMuxedID = trustorMuxedID

return changeTrustDetail, nil
}

func getLiquidityPoolAssetDetails(lpp xdr.LiquidityPoolParameters) (string, string, error) {
if lpp.Type != xdr.LiquidityPoolTypeLiquidityPoolConstantProduct {
return "", "", fmt.Errorf("unknown liquidity pool type %d", lpp.Type)
}

cp := lpp.ConstantProduct

var err error
var poolID xdr.PoolId
var poolIDString string
poolID, err = xdr.NewPoolId(cp.AssetA, cp.AssetB, cp.Fee)
if err != nil {
return "", "", err
}

poolIDString, err = PoolIDToString(poolID)
if err != nil {
return "", "", err
}

return "liquidity_pool_shares", poolIDString, nil
}
46 changes: 46 additions & 0 deletions ingest/claim_claimable_balance_details.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package ingest

import (
"fmt"

"github.com/stellar/go/xdr"
)

type ClaimClaimableBalanceDetail struct {
BalanceID string `json:"balance_id"`
Claimant string `json:"claimant"`
ClaimantMuxed string `json:"claimant_muxed"`
ClaimantMuxedID uint64 `json:"claimant_muxed_id,string"`
}

func (o *LedgerOperation) ClaimClaimableBalanceDetails() (ClaimClaimableBalanceDetail, error) {
op, ok := o.Operation.Body.GetClaimClaimableBalanceOp()
if !ok {
return ClaimClaimableBalanceDetail{}, fmt.Errorf("could not access ClaimClaimableBalance info for this operation (index %d)", o.OperationIndex)
}

claimClaimableBalanceDetail := ClaimClaimableBalanceDetail{
Claimant: o.SourceAccount(),
}

var err error
var balanceID string
balanceID, err = xdr.MarshalBase64(op.BalanceId)
if err != nil {
return ClaimClaimableBalanceDetail{}, err
}

claimClaimableBalanceDetail.BalanceID = balanceID

var claimantMuxed string
var claimantMuxedID uint64
claimantMuxed, claimantMuxedID, err = getMuxedAccountDetails(o.sourceAccountXDR())
if err != nil {
return ClaimClaimableBalanceDetail{}, err
}

claimClaimableBalanceDetail.ClaimantMuxed = claimantMuxed
claimClaimableBalanceDetail.ClaimantMuxedID = claimantMuxedID

return claimClaimableBalanceDetail, nil
}
25 changes: 25 additions & 0 deletions ingest/clawback_claimable_balance_details.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package ingest

import (
"fmt"

"github.com/stellar/go/xdr"
)

type ClawbackClaimableBalanceDetail struct {
BalanceID string `json:"balance_id"`
}

func (o *LedgerOperation) ClawbackClaimableBalanceDetails() (ClawbackClaimableBalanceDetail, error) {
op, ok := o.Operation.Body.GetClawbackClaimableBalanceOp()
if !ok {
return ClawbackClaimableBalanceDetail{}, fmt.Errorf("could not access ClawbackClaimableBalance info for this operation (index %d)", o.OperationIndex)
}

balanceID, err := xdr.MarshalBase64(op.BalanceId)
if err != nil {
return ClawbackClaimableBalanceDetail{}, err
}

return ClawbackClaimableBalanceDetail{BalanceID: balanceID}, nil
}
48 changes: 48 additions & 0 deletions ingest/clawback_details.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package ingest

import "fmt"

type ClawbackDetail struct {
AssetCode string `json:"asset_code"`
AssetIssuer string `json:"asset_issuer"`
AssetType string `json:"asset_type"`
From string `json:"from"`
FromMuxed string `json:"from_muxed"`
FromMuxedID uint64 `json:"from_muxed_id,string"`
Amount int64 `json:"amount,string"`
}

func (o *LedgerOperation) ClawbackDetails() (ClawbackDetail, error) {
op, ok := o.Operation.Body.GetClawbackOp()
if !ok {
return ClawbackDetail{}, fmt.Errorf("could not access Clawback info for this operation (index %d)", o.OperationIndex)
}

clawbackDetail := ClawbackDetail{
Amount: int64(op.Amount),
From: op.From.Address(),
}

var err error
var assetCode, assetIssuer, assetType string
err = op.Asset.Extract(&assetType, &assetCode, &assetIssuer)
if err != nil {
return ClawbackDetail{}, err
}

clawbackDetail.AssetCode = assetCode
clawbackDetail.AssetIssuer = assetIssuer
clawbackDetail.AssetType = assetType

var fromMuxed string
var fromMuxedID uint64
fromMuxed, fromMuxedID, err = getMuxedAccountDetails(op.From)
if err != nil {
return ClawbackDetail{}, err
}

clawbackDetail.FromMuxed = fromMuxed
clawbackDetail.FromMuxedID = fromMuxedID

return clawbackDetail, nil
}
Loading
Loading