// AccountID returns a new random account id func AccountID() entity.AccountID { kp, err := keypair.Random() if err != nil { panic(err) } return entity.AccountID(kp.Address()) }
func (p *payment) Entity() (ent entity.Payment, err error) { if p.Type == "create_account" { ent.From = entity.AccountID(p.Funder) ent.To = entity.AccountID(p.Account) ent.Asset.Type = "native" ent.Asset.Code = "" ent.Asset.Issuer = "" ent.Amount = entity.MustParseAmount(p.StartingBalance) } else { ent.From = entity.AccountID(p.From) ent.To = entity.AccountID(p.To) ent.Asset.Type = p.AssetType ent.Asset.Code = p.AssetCode ent.Asset.Issuer = p.AssetIssuer ent.Amount = entity.MustParseAmount(p.Amount) } ent.PagingToken = p.PagingToken ent.Memo.Type = p.Memo.Type ent.Memo.Value = p.Memo.Value return }
// WebhookEntity returns a new random valid webhook func WebhookEntity() (result entity.Webhook) { var err error result.URL, err = url.Parse("http://" + fake.DomainName()) if err != nil { panic(err) } kp, err := keypair.Random() if err != nil { panic(err) } result.DestinationFilter = entity.AccountID(kp.Address()) return }
// Entity converts a postgres table row into a core entity func (hook *Webhook) Entity() (result entity.Webhook, err error) { result.ID = &usecase.RepoID{T: "webhook", V: hook.ID} result.URL, err = url.Parse(hook.URL) if err != nil { return } result.DestinationFilter = entity.AccountID(hook.DestinationFilter) if hook.MemoTypeFilter.Valid { result.MemoFilter = &entity.Memo{ Type: hook.MemoTypeFilter.String, Value: hook.MemoFilter.String, } } err = result.Valid() return }
// Entity returns the core entity representation of the webhook func (hook *Webhook) Entity() (result entity.Webhook, err error) { result.URL, err = url.Parse(hook.URL) if err != nil { return } result.DestinationFilter = entity.AccountID(hook.DestinationFilter) if hook.MemoTypeFilter != "" { result.MemoFilter = &entity.Memo{ Type: hook.MemoTypeFilter, Value: hook.MemoFilter, } } err = result.Valid() return }