forked from stellar/go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
builder_inflation.go
32 lines (25 loc) · 914 Bytes
/
builder_inflation.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
package bridge
import (
b "github.com/stellar/go/build"
shared "github.com/stellar/go/services/internal/bridge-compliance-shared"
"github.com/stellar/go/services/internal/bridge-compliance-shared/http/helpers"
)
// InflationOperationBody represents inflation operation
type InflationOperationBody struct {
Source *string
}
// ToTransactionMutator returns go-stellar-base TransactionMutator
func (op InflationOperationBody) ToTransactionMutator() b.TransactionMutator {
var mutators []interface{}
if op.Source != nil {
mutators = append(mutators, b.SourceAccount{*op.Source})
}
return b.Inflation(mutators...)
}
// Validate validates if operation body is valid.
func (op InflationOperationBody) Validate() error {
if op.Source != nil && !shared.IsValidAccountID(*op.Source) {
return helpers.NewInvalidParameterError("source", "Source must be a public key (starting with `G`).")
}
return nil
}