-
Notifications
You must be signed in to change notification settings - Fork 0
/
account.go
53 lines (44 loc) · 1.3 KB
/
account.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package actions
import (
"context"
"github.com/stellar/go/clients/horizon"
pHorizon "github.com/stellar/go/protocols/horizon"
"github.com/stellar/go/services/horizon/internal/db2/core"
"github.com/stellar/go/services/horizon/internal/resourceadapter"
"github.com/stellar/go/support/errors"
)
// AccountInfo returns the information about an account identified by addr.
func AccountInfo(ctx context.Context, cq *core.Q, addr string) (*pHorizon.Account, error) {
var (
coreRecord core.Account
coreData []core.AccountData
coreSigners []core.Signer
coreTrustlines []core.Trustline
resource horizon.Account
)
err := cq.AccountByAddress(&coreRecord, addr)
if err != nil {
return nil, errors.Wrap(err, "getting core account record")
}
err = cq.AllDataByAddress(&coreData, addr)
if err != nil {
return nil, errors.Wrap(err, "getting core account data")
}
err = cq.SignersByAddress(&coreSigners, addr)
if err != nil {
return nil, errors.Wrap(err, "getting core signer")
}
err = cq.TrustlinesByAddress(&coreTrustlines, addr)
if err != nil {
return nil, errors.Wrap(err, "getting core trustline")
}
err = resourceadapter.PopulateAccount(
ctx,
&resource,
coreRecord,
coreData,
coreSigners,
coreTrustlines,
)
return &resource, errors.Wrap(err, "populating account")
}