// Populate fills out the details func (res *Transaction) Populate( ctx context.Context, row history.Transaction, ) (err error) { res.ID = row.TransactionHash res.PT = row.PagingToken() res.Hash = row.TransactionHash res.Ledger = row.LedgerSequence res.LedgerCloseTime = row.LedgerCloseTime res.Account = row.Account res.AccountSequence = row.AccountSequence res.FeePaid = row.FeePaid res.OperationCount = row.OperationCount res.EnvelopeXdr = row.TxEnvelope res.ResultXdr = row.TxResult res.ResultMetaXdr = row.TxMeta res.FeeMetaXdr = row.TxFeeMeta res.MemoType = row.MemoType res.Memo = row.Memo.String res.Signatures = strings.Split(row.SignatureString, ",") res.ValidBefore = res.timeString(row.ValidBefore) res.ValidAfter = res.timeString(row.ValidAfter) lb := hal.LinkBuilder{Base: httpx.BaseURL(ctx)} res.Links.Account = lb.Link("/accounts", res.Account) res.Links.Ledger = lb.Link("/ledgers", fmt.Sprintf("%d", res.Ledger)) res.Links.Operations = lb.PagedLink("/transactions", res.ID, "operations") res.Links.Effects = lb.PagedLink("/transactions", res.ID, "effects") res.Links.Self = lb.Link("/transactions", res.ID) res.Links.Succeeds = lb.Linkf("/transactions?order=desc&cursor=%s", res.PT) res.Links.Precedes = lb.Linkf("/transactions?order=asc&cursor=%s", res.PT) return }
func (this *Offer) Populate(ctx context.Context, row db.CoreOfferRecord) { this.ID = row.OfferID this.PT = row.PagingToken() this.Seller = row.SellerID this.Amount = amount.String(row.Amount) this.PriceR.N = row.Pricen this.PriceR.D = row.Priced this.Price = row.PriceAsString() this.Buying = Asset{ Type: assets.MustString(row.BuyingAssetType), Code: row.BuyingAssetCode.String, Issuer: row.BuyingIssuer.String, } this.Selling = Asset{ Type: assets.MustString(row.SellingAssetType), Code: row.SellingAssetCode.String, Issuer: row.SellingIssuer.String, } lb := hal.LinkBuilder{httpx.BaseURL(ctx)} this.Links.Self = lb.Linkf("/offers/%d", row.OfferID) this.Links.OfferMaker = lb.Linkf("/accounts/%s", row.SellerID) return }
func (this *Base) Populate(ctx context.Context, row db.EffectRecord) { this.ID = row.ID() this.PT = row.PagingToken() this.Account = row.Account this.populateType(row) lb := hal.LinkBuilder{httpx.BaseURL(ctx)} this.Links.Operation = lb.Linkf("/operations/%d", row.HistoryOperationID) this.Links.Succeeds = lb.Linkf("/effects?order=desc&cursor=%s", this.PT) this.Links.Precedes = lb.Linkf("/effects?order=asc&cursor=%s", this.PT) }
func (this *Base) Populate(ctx context.Context, row history.Operation) { this.ID = fmt.Sprintf("%d", row.ID) this.PT = row.PagingToken() this.SourceAccount = row.SourceAccount this.populateType(row) lb := hal.LinkBuilder{httpx.BaseURL(ctx)} self := fmt.Sprintf("/operations/%d", row.ID) this.Links.Self = lb.Link(self) this.Links.Succeeds = lb.Linkf("/effects?order=desc&cursor=%s", this.PT) this.Links.Precedes = lb.Linkf("/effects?order=asc&cursor=%s", this.PT) this.Links.Transaction = lb.Linkf("/transactions/%s", row.TransactionHash) this.Links.Effects = lb.Link(self, "effects") }