Skip to content

Commit

Permalink
docs: adds comments for epxorted methods
Browse files Browse the repository at this point in the history
  • Loading branch information
wregulski committed Jul 10, 2023
1 parent fdcfbd0 commit 0c9825c
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 0 deletions.
1 change: 1 addition & 0 deletions mappings/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
buxmodels "github.com/BuxOrg/bux-models"
)

// MapToAdminStatsContract will map the model from bux to the bux-models contract
func MapToAdminStatsContract(s *bux.AdminStats) *buxmodels.AdminStats {
return &buxmodels.AdminStats{
Balance: s.Balance,
Expand Down
1 change: 1 addition & 0 deletions mappings/common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ 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 {
return &bux.Model{
CreatedAt: m.CreatedAt,
Expand Down
2 changes: 2 additions & 0 deletions mappings/destination.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"github.com/BuxOrg/bux-server/mappings/common"
)

// MapToDestinationContract will map the bux destination model to the bux-models contract
func MapToDestinationContract(d *bux.Destination) *buxmodels.Destination {
return &buxmodels.Destination{
Model: *common.MapToContract(&d.Model),
Expand All @@ -21,6 +22,7 @@ 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 {
return &bux.Destination{
Model: *common.MapToModel(&d.Model),
Expand Down
2 changes: 2 additions & 0 deletions mappings/fee_unit.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ import (
"github.com/BuxOrg/bux/utils"
)

// MapToFeeUnitContract will map the fee-unit model from bux to the bux-models contract
func MapToFeeUnitContract(fu *utils.FeeUnit) (fc *buxmodels.FeeUnit) {
return &buxmodels.FeeUnit{
Satoshis: fu.Satoshis,
Bytes: fu.Bytes,
}
}

// MapToFeeUnitBux will map the fee-unit model from bux-models to the bux contract
func MapToFeeUnitBux(fu *buxmodels.FeeUnit) (fc *utils.FeeUnit) {
return &utils.FeeUnit{
Satoshis: fu.Satoshis,
Expand Down
3 changes: 3 additions & 0 deletions mappings/paymail_address.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"github.com/BuxOrg/bux-server/mappings/common"
)

// MapToPaymailContract will map the bux paymail-address model to the bux-models contract
func MapToPaymailContract(pa *bux.PaymailAddress) *buxmodels.PaymailAddress {
return &buxmodels.PaymailAddress{
Model: *common.MapToContract(&pa.Model),
Expand All @@ -19,6 +20,7 @@ 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 {
return &buxmodels.PaymailP4{
Alias: p.Alias,
Expand All @@ -32,6 +34,7 @@ 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 {
return &bux.PaymailP4{
Alias: p.Alias,
Expand Down
2 changes: 2 additions & 0 deletions mappings/script_output.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
buxmodels "github.com/BuxOrg/bux-models"
)

// MapToScriptOutputContract will map the script-output model from bux to the bux-models contract
func MapToScriptOutputContract(so *bux.ScriptOutput) (sc *buxmodels.ScriptOutput) {
return &buxmodels.ScriptOutput{
Address: so.Address,
Expand All @@ -14,6 +15,7 @@ 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) {
return &bux.ScriptOutput{
Address: so.Address,
Expand Down
2 changes: 2 additions & 0 deletions mappings/sync_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
buxmodels "github.com/BuxOrg/bux-models"
)

// MapToSyncConfigContract will map the sync-config model from bux to the bux-models contract
func MapToSyncConfigContract(sc *bux.SyncConfig) *buxmodels.SyncConfig {
return &buxmodels.SyncConfig{
Broadcast: sc.Broadcast,
Expand All @@ -14,6 +15,7 @@ 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 {
return &bux.SyncConfig{
Broadcast: sc.Broadcast,
Expand Down
13 changes: 13 additions & 0 deletions mappings/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"github.com/BuxOrg/bux-server/mappings/common"
)

// MapToTransactionContract will map the model from bux to the bux-models contract
func MapToTransactionContract(t *bux.Transaction) *buxmodels.Transaction {
return &buxmodels.Transaction{
Model: *common.MapToContract(&t.Model),
Expand All @@ -26,6 +27,7 @@ func MapToTransactionContract(t *bux.Transaction) *buxmodels.Transaction {
}
}

// MapToTransactionBux will map the model from bux-models to the bux contract
func MapToTransactionBux(t *buxmodels.Transaction) *bux.Transaction {
return &bux.Transaction{
Model: *common.MapToModel(&t.Model),
Expand All @@ -45,6 +47,7 @@ func MapToTransactionBux(t *buxmodels.Transaction) *bux.Transaction {
}
}

// MapToTransactionConfigBux will map the transaction-config model from bux to the bux-models contract
func MapToTransactionConfigBux(tx *buxmodels.TransactionConfig) *bux.TransactionConfig {
destinations := make([]*bux.Destination, 0)
for _, destination := range tx.ChangeDestinations {
Expand Down Expand Up @@ -89,6 +92,7 @@ func MapToTransactionConfigBux(tx *buxmodels.TransactionConfig) *bux.Transaction
}
}

// MapToTransactionConfigContract will map the transaction-config model from bux-models to the bux contract
func MapToTransactionConfigContract(tx *bux.TransactionConfig) *buxmodels.TransactionConfig {
destinations := make([]*buxmodels.Destination, 0)
for _, destination := range tx.ChangeDestinations {
Expand Down Expand Up @@ -132,6 +136,7 @@ func MapToTransactionConfigContract(tx *bux.TransactionConfig) *buxmodels.Transa
}
}

// MapToDraftTransactionContract will map the transaction-output model from bux to the bux-models contract
func MapToDraftTransactionContract(tx *bux.DraftTransaction) *buxmodels.DraftTransaction {
return &buxmodels.DraftTransaction{
Model: *common.MapToContract(&tx.Model),
Expand All @@ -143,20 +148,23 @@ func MapToDraftTransactionContract(tx *bux.DraftTransaction) *buxmodels.DraftTra
}
}

// MapToTransactionInputContract will map the transaction-output model from bux-models to the bux contract
func MapToTransactionInputContract(inp *bux.TransactionInput) *buxmodels.TransactionInput {
return &buxmodels.TransactionInput{
Utxo: *MapToUtxoContract(&inp.Utxo),
Destination: *MapToDestinationContract(&inp.Destination),
}
}

// MapToTransactionInputBux will map the transaction-output model from bux to the bux-models contract
func MapToTransactionInputBux(inp *buxmodels.TransactionInput) *bux.TransactionInput {
return &bux.TransactionInput{
Utxo: *MapToUtxoBux(&inp.Utxo),
Destination: *MapToDestinationBux(&inp.Destination),
}
}

// MapToTransactionOutputContract will map the transaction-output model from bux to the bux-models contract
func MapToTransactionOutputContract(out *bux.TransactionOutput) *buxmodels.TransactionOutput {
scriptOutputs := make([]*buxmodels.ScriptOutput, 0)
for _, scriptOutput := range out.Scripts {
Expand All @@ -174,6 +182,7 @@ func MapToTransactionOutputContract(out *bux.TransactionOutput) *buxmodels.Trans
}
}

// MapToTransactionOutputBux will map the transaction-output model from bux-models to the bux contract
func MapToTransactionOutputBux(out *buxmodels.TransactionOutput) *bux.TransactionOutput {
scriptOutputs := make([]*bux.ScriptOutput, 0)
for _, scriptOutput := range out.Scripts {
Expand All @@ -191,6 +200,7 @@ func MapToTransactionOutputBux(out *buxmodels.TransactionOutput) *bux.Transactio
}
}

// MapToMapProtocolContract will map the transaction-output model from bux to the bux-models contract
func MapToMapProtocolContract(mp *bux.MapProtocol) *buxmodels.MapProtocol {
return &buxmodels.MapProtocol{
App: mp.App,
Expand All @@ -199,6 +209,7 @@ func MapToMapProtocolContract(mp *bux.MapProtocol) *buxmodels.MapProtocol {
}
}

// MapToMapProtocolBux will map the transaction-output model from bux-models to the bux contract
func MapToMapProtocolBux(mp *buxmodels.MapProtocol) *bux.MapProtocol {
return &bux.MapProtocol{
App: mp.App,
Expand All @@ -207,6 +218,7 @@ func MapToMapProtocolBux(mp *buxmodels.MapProtocol) *bux.MapProtocol {
}
}

// MapToOpReturnContract will map the transaction-output model from bux to the bux-models contract
func MapToOpReturnContract(op *bux.OpReturn) *buxmodels.OpReturn {
return &buxmodels.OpReturn{
Hex: op.Hex,
Expand All @@ -216,6 +228,7 @@ func MapToOpReturnContract(op *bux.OpReturn) *buxmodels.OpReturn {
}
}

// MapToOpReturnBux will map the op-return model from bux-models to the bux contract
func MapToOpReturnBux(op *buxmodels.OpReturn) *bux.OpReturn {
return &bux.OpReturn{
Hex: op.Hex,
Expand Down
4 changes: 4 additions & 0 deletions mappings/utxo.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,23 @@ import (
customtypes "github.com/mrz1836/go-datastore/custom_types"
)

// MapToUtxoPointer will map the utxo-pointer model from bux to the bux-models contract
func MapToUtxoPointer(u *bux.UtxoPointer) *buxmodels.UtxoPointer {
return &buxmodels.UtxoPointer{
TransactionID: u.TransactionID,
OutputIndex: u.OutputIndex,
}
}

// MapToUtxoPointerBux will map the utxo-pointer model from bux-models to the bux contract
func MapToUtxoPointerBux(u *buxmodels.UtxoPointer) *bux.UtxoPointer {
return &bux.UtxoPointer{
TransactionID: u.TransactionID,
OutputIndex: u.OutputIndex,
}
}

// MapToUtxoContract will map the utxo model from bux to the bux-models contract
func MapToUtxoContract(u *bux.Utxo) *buxmodels.Utxo {
return &buxmodels.Utxo{
Model: *common.MapToContract(&u.Model),
Expand All @@ -36,6 +39,7 @@ func MapToUtxoContract(u *bux.Utxo) *buxmodels.Utxo {
}
}

// MapToUtxoBux will map the utxo model from bux-models to the bux contract
func MapToUtxoBux(u *buxmodels.Utxo) *bux.Utxo {
var draftID customtypes.NullString
draftID.String = u.DraftID
Expand Down
1 change: 1 addition & 0 deletions mappings/xpub.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"github.com/BuxOrg/bux-server/mappings/common"
)

// MapToXpubContract will map the xpub model from bux to the bux-models contract
func MapToXpubContract(xpub *bux.Xpub) *buxmodels.Xpub {
return &buxmodels.Xpub{
Model: *common.MapToContract(&xpub.Model),
Expand Down

0 comments on commit 0c9825c

Please sign in to comment.