Skip to content

Commit

Permalink
Merge pull request #257 from wregulski/feat-27-remove-bux-deps
Browse files Browse the repository at this point in the history
feat(BUX-27): adds mapping methods for bux-models contracts
  • Loading branch information
mergify[bot] authored Jul 12, 2023
2 parents c425268 + d422489 commit eded11c
Show file tree
Hide file tree
Showing 33 changed files with 307 additions and 80 deletions.
2 changes: 1 addition & 1 deletion actions/access_keys/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,5 @@ func (a *Action) create(w http.ResponseWriter, req *http.Request, _ httprouter.P
contract := mappings.MapToAccessKeyContract(accessKey)

// Return response
apirouter.ReturnResponse(w, req, http.StatusCreated, bux.DisplayModels(contract))
apirouter.ReturnResponse(w, req, http.StatusCreated, contract)
}
2 changes: 1 addition & 1 deletion actions/access_keys/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,5 @@ func (a *Action) get(w http.ResponseWriter, req *http.Request, _ httprouter.Para
contract := mappings.MapToAccessKeyContract(accessKey)

// Return response
apirouter.ReturnResponse(w, req, http.StatusOK, bux.DisplayModels(contract))
apirouter.ReturnResponse(w, req, http.StatusOK, contract)
}
2 changes: 1 addition & 1 deletion actions/access_keys/revoke.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,5 @@ func (a *Action) revoke(w http.ResponseWriter, req *http.Request, _ httprouter.P
contract := mappings.MapToAccessKeyContract(accessKey)

// Return response
apirouter.ReturnResponse(w, req, http.StatusCreated, bux.DisplayModels(contract))
apirouter.ReturnResponse(w, req, http.StatusCreated, contract)
}
2 changes: 1 addition & 1 deletion actions/access_keys/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,5 @@ func (a *Action) search(w http.ResponseWriter, req *http.Request, _ httprouter.P
}

// Return response
apirouter.ReturnResponse(w, req, http.StatusOK, bux.DisplayModels(accessKeyContracts))
apirouter.ReturnResponse(w, req, http.StatusOK, accessKeyContracts)
}
2 changes: 1 addition & 1 deletion actions/admin/record.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,5 @@ func (a *Action) transactionRecord(w http.ResponseWriter, req *http.Request, _ h
contract := mappings.MapToTransactionContract(transaction)

// Return response
apirouter.ReturnResponse(w, req, http.StatusCreated, bux.DisplayModels(contract))
apirouter.ReturnResponse(w, req, http.StatusCreated, contract)
}
2 changes: 1 addition & 1 deletion actions/destinations/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,5 +76,5 @@ func (a *Action) create(w http.ResponseWriter, req *http.Request, _ httprouter.P
contract := mappings.MapToDestinationContract(destination)

// Return response
apirouter.ReturnResponse(w, req, http.StatusCreated, bux.DisplayModels(contract))
apirouter.ReturnResponse(w, req, http.StatusCreated, contract)
}
2 changes: 1 addition & 1 deletion actions/destinations/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,5 @@ func (a *Action) get(w http.ResponseWriter, req *http.Request, _ httprouter.Para
contract := mappings.MapToDestinationContract(destination)

// Return response
apirouter.ReturnResponse(w, req, http.StatusOK, bux.DisplayModels(contract))
apirouter.ReturnResponse(w, req, http.StatusOK, contract)
}
2 changes: 1 addition & 1 deletion actions/destinations/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,5 @@ func (a *Action) search(w http.ResponseWriter, req *http.Request, _ httprouter.P
}

// Return response
apirouter.ReturnResponse(w, req, http.StatusOK, bux.DisplayModels(contracts))
apirouter.ReturnResponse(w, req, http.StatusOK, contracts)
}
2 changes: 1 addition & 1 deletion actions/destinations/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,5 @@ func (a *Action) update(w http.ResponseWriter, req *http.Request, _ httprouter.P
contract := mappings.MapToDestinationContract(destination)

// Return response
apirouter.ReturnResponse(w, req, http.StatusOK, bux.DisplayModels(contract))
apirouter.ReturnResponse(w, req, http.StatusOK, contract)
}
2 changes: 1 addition & 1 deletion actions/paymail/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,5 @@ func (a *Action) create(w http.ResponseWriter, req *http.Request, _ httprouter.P
contract := mappings.MapToPaymailContract(paymailAddress)

// Return response
apirouter.ReturnResponse(w, req, http.StatusCreated, bux.DisplayModels(contract))
apirouter.ReturnResponse(w, req, http.StatusCreated, contract)
}
2 changes: 1 addition & 1 deletion actions/transactions/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,5 @@ func (a *Action) get(w http.ResponseWriter, req *http.Request, _ httprouter.Para
contract := mappings.MapToTransactionContract(transaction)

// Return response
apirouter.ReturnResponse(w, req, http.StatusOK, bux.DisplayModels(contract))
apirouter.ReturnResponse(w, req, http.StatusOK, contract)
}
2 changes: 1 addition & 1 deletion actions/transactions/new.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,5 +82,5 @@ func (a *Action) newTransaction(w http.ResponseWriter, req *http.Request, _ http
contract := mappings.MapToDraftTransactionContract(transaction)

// Return response
apirouter.ReturnResponse(w, req, http.StatusCreated, bux.DisplayModels(contract))
apirouter.ReturnResponse(w, req, http.StatusCreated, contract)
}
2 changes: 1 addition & 1 deletion actions/transactions/record.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,5 @@ func (a *Action) record(w http.ResponseWriter, req *http.Request, _ httprouter.P
contract := mappings.MapToTransactionContract(transaction)

// Return response
apirouter.ReturnResponse(w, req, http.StatusCreated, bux.DisplayModels(contract))
apirouter.ReturnResponse(w, req, http.StatusCreated, contract)
}
2 changes: 1 addition & 1 deletion actions/transactions/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,5 @@ func (a *Action) search(w http.ResponseWriter, req *http.Request, _ httprouter.P
}

// Return response
apirouter.ReturnResponse(w, req, http.StatusOK, bux.DisplayModels(contracts))
apirouter.ReturnResponse(w, req, http.StatusOK, contracts)
}
2 changes: 1 addition & 1 deletion actions/transactions/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,5 @@ func (a *Action) update(w http.ResponseWriter, req *http.Request, _ httprouter.P
contract := mappings.MapToTransactionContract(transaction)

// Return response
apirouter.ReturnResponse(w, req, http.StatusOK, bux.DisplayModels(contract))
apirouter.ReturnResponse(w, req, http.StatusOK, contract)
}
2 changes: 1 addition & 1 deletion actions/utxos/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,5 @@ func (a *Action) get(w http.ResponseWriter, req *http.Request, _ httprouter.Para
contract := mappings.MapToUtxoContract(utxo)

// Return response
apirouter.ReturnResponse(w, req, http.StatusOK, bux.DisplayModels(contract))
apirouter.ReturnResponse(w, req, http.StatusOK, contract)
}
2 changes: 1 addition & 1 deletion actions/utxos/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,5 @@ func (a *Action) search(w http.ResponseWriter, req *http.Request, _ httprouter.P
}

// Return response
apirouter.ReturnResponse(w, req, http.StatusOK, bux.DisplayModels(contracts))
apirouter.ReturnResponse(w, req, http.StatusOK, contracts)
}
2 changes: 1 addition & 1 deletion actions/xpubs/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,5 @@ func (a *Action) create(w http.ResponseWriter, req *http.Request, _ httprouter.P
contract := mappings.MapToXpubContract(xPub)

// Return response
apirouter.ReturnResponse(w, req, http.StatusCreated, bux.DisplayModels(contract))
apirouter.ReturnResponse(w, req, http.StatusCreated, contract)
}
2 changes: 1 addition & 1 deletion actions/xpubs/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,5 @@ func (a *Action) get(w http.ResponseWriter, req *http.Request, _ httprouter.Para
contract := mappings.MapToXpubContract(xPub)

// Return response
apirouter.ReturnResponse(w, req, http.StatusOK, bux.DisplayModels(contract))
apirouter.ReturnResponse(w, req, http.StatusOK, contract)
}
2 changes: 1 addition & 1 deletion actions/xpubs/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,5 @@ func (a *Action) update(w http.ResponseWriter, req *http.Request, _ httprouter.P
contract := mappings.MapToXpubContract(xPub)

// Return response
apirouter.ReturnResponse(w, req, http.StatusOK, bux.DisplayModels(contract))
apirouter.ReturnResponse(w, req, http.StatusOK, contract)
}
6 changes: 3 additions & 3 deletions go.mod

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions mappings/access_keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ import (

// MapToAccessKeyContract will map the access key to the bux-models contract
func MapToAccessKeyContract(ac *bux.AccessKey) *buxmodels.AccessKey {
if ac == nil {
return nil
}

return &buxmodels.AccessKey{
Model: *common.MapToContract(&ac.Model),
ID: ac.ID,
Expand Down
4 changes: 4 additions & 0 deletions mappings/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ import (

// MapToAdminStatsContract will map the model from bux to the bux-models contract
func MapToAdminStatsContract(s *bux.AdminStats) *buxmodels.AdminStats {
if s == nil {
return nil
}

return &buxmodels.AdminStats{
Balance: s.Balance,
Destinations: s.Destinations,
Expand Down
8 changes: 8 additions & 0 deletions mappings/common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ import (

// MapToContract will map the common model to the bux-models contract
func MapToContract(m *bux.Model) *common.Model {
if m == nil {
return nil
}

return &common.Model{
CreatedAt: m.CreatedAt,
UpdatedAt: m.UpdatedAt,
Expand All @@ -18,6 +22,10 @@ func MapToContract(m *bux.Model) *common.Model {

// MapToModel will map the bux-models contract to the common bux model
func MapToModel(m *common.Model) *bux.Model {
if m == nil {
return nil
}

return &bux.Model{
CreatedAt: m.CreatedAt,
UpdatedAt: m.UpdatedAt,
Expand Down
8 changes: 8 additions & 0 deletions mappings/destination.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ import (

// MapToDestinationContract will map the bux destination model to the bux-models contract
func MapToDestinationContract(d *bux.Destination) *buxmodels.Destination {
if d == nil {
return nil
}

return &buxmodels.Destination{
Model: *common.MapToContract(&d.Model),
ID: d.ID,
Expand All @@ -24,6 +28,10 @@ func MapToDestinationContract(d *bux.Destination) *buxmodels.Destination {

// MapToDestinationBux will map the bux-models destination contract to the bux destination model
func MapToDestinationBux(d *buxmodels.Destination) *bux.Destination {
if d == nil {
return nil
}

return &bux.Destination{
Model: *common.MapToModel(&d.Model),
ID: d.ID,
Expand Down
8 changes: 8 additions & 0 deletions mappings/fee_unit.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ import (

// MapToFeeUnitContract will map the fee-unit model from bux to the bux-models contract
func MapToFeeUnitContract(fu *utils.FeeUnit) (fc *buxmodels.FeeUnit) {
if fu == nil {
return nil
}

return &buxmodels.FeeUnit{
Satoshis: fu.Satoshis,
Bytes: fu.Bytes,
Expand All @@ -15,6 +19,10 @@ func MapToFeeUnitContract(fu *utils.FeeUnit) (fc *buxmodels.FeeUnit) {

// MapToFeeUnitBux will map the fee-unit model from bux-models to the bux contract
func MapToFeeUnitBux(fu *buxmodels.FeeUnit) (fc *utils.FeeUnit) {
if fu == nil {
return nil
}

return &utils.FeeUnit{
Satoshis: fu.Satoshis,
Bytes: fu.Bytes,
Expand Down
12 changes: 12 additions & 0 deletions mappings/paymail_address.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ import (

// MapToPaymailContract will map the bux paymail-address model to the bux-models contract
func MapToPaymailContract(pa *bux.PaymailAddress) *buxmodels.PaymailAddress {
if pa == nil {
return nil
}

return &buxmodels.PaymailAddress{
Model: *common.MapToContract(&pa.Model),
ID: pa.ID,
Expand All @@ -22,6 +26,10 @@ func MapToPaymailContract(pa *bux.PaymailAddress) *buxmodels.PaymailAddress {

// MapToPaymailP4Contract will map the bux-models paymail-address contract to the bux paymail-address model
func MapToPaymailP4Contract(p *bux.PaymailP4) *buxmodels.PaymailP4 {
if p == nil {
return nil
}

return &buxmodels.PaymailP4{
Alias: p.Alias,
Domain: p.Domain,
Expand All @@ -36,6 +44,10 @@ func MapToPaymailP4Contract(p *bux.PaymailP4) *buxmodels.PaymailP4 {

// MapToPaymailP4Bux will map the bux-models paymail-address contract to the bux paymail-address model
func MapToPaymailP4Bux(p *buxmodels.PaymailP4) *bux.PaymailP4 {
if p == nil {
return nil
}

return &bux.PaymailP4{
Alias: p.Alias,
Domain: p.Domain,
Expand Down
8 changes: 8 additions & 0 deletions mappings/script_output.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ import (

// MapToScriptOutputContract will map the script-output model from bux to the bux-models contract
func MapToScriptOutputContract(so *bux.ScriptOutput) (sc *buxmodels.ScriptOutput) {
if so == nil {
return nil
}

return &buxmodels.ScriptOutput{
Address: so.Address,
Satoshis: so.Satoshis,
Expand All @@ -17,6 +21,10 @@ func MapToScriptOutputContract(so *bux.ScriptOutput) (sc *buxmodels.ScriptOutput

// MapToScriptOutputBux will map the script-output model from bux-models to the bux contract
func MapToScriptOutputBux(so *buxmodels.ScriptOutput) (sc *bux.ScriptOutput) {
if so == nil {
return nil
}

return &bux.ScriptOutput{
Address: so.Address,
Satoshis: so.Satoshis,
Expand Down
8 changes: 8 additions & 0 deletions mappings/sync_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ import (

// MapToSyncConfigContract will map the sync-config model from bux to the bux-models contract
func MapToSyncConfigContract(sc *bux.SyncConfig) *buxmodels.SyncConfig {
if sc == nil {
return nil
}

return &buxmodels.SyncConfig{
Broadcast: sc.Broadcast,
BroadcastInstant: sc.BroadcastInstant,
Expand All @@ -17,6 +21,10 @@ func MapToSyncConfigContract(sc *bux.SyncConfig) *buxmodels.SyncConfig {

// MapToSyncConfigBux will map the sync-config model from bux-models to the bux contract
func MapToSyncConfigBux(sc *buxmodels.SyncConfig) *bux.SyncConfig {
if sc == nil {
return nil
}

return &bux.SyncConfig{
Broadcast: sc.Broadcast,
BroadcastInstant: sc.BroadcastInstant,
Expand Down
Loading

0 comments on commit eded11c

Please sign in to comment.