go-stellar-base
go-stellar-base copied to clipboard
Add build.OperationBuilder interface
Consider the following code:
var operationBuilder interface{}
if !destinationExists {
operationBuilder = b.CreateAccount(mutators...)
} else {
operationBuilder = b.Payment(mutators...)
}
// Check errors here
txBuilder := b.Transaction(
operationBuilder.(b.TransactionMutator)),
)
If we wanted to check if there were errors after applying mutators (Err
field in builders) it's not possible because type assertion works for interfaces only. To solve this we can create an interface:
type OperationBuilder interface {
MutateTransaction(o *TransactionBuilder) error
Mutate(muts ...interface{})
Error() error
}