forked from stellar/go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
builder_account_merge.go
37 lines (29 loc) · 1.08 KB
/
builder_account_merge.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
33
34
35
36
37
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"
)
// AccountMergeOperationBody represents account_merge operation
type AccountMergeOperationBody struct {
Source *string
Destination string
}
// ToTransactionMutator returns stellar/go TransactionMutator
func (op AccountMergeOperationBody) ToTransactionMutator() b.TransactionMutator {
mutators := []interface{}{b.Destination{op.Destination}}
if op.Source != nil {
mutators = append(mutators, b.SourceAccount{*op.Source})
}
return b.AccountMerge(mutators...)
}
// Validate validates if operation body is valid.
func (op AccountMergeOperationBody) Validate() error {
if !shared.IsValidAccountID(op.Destination) {
return helpers.NewInvalidParameterError("destination", "Destination must start with `G`.")
}
if op.Source != nil && !shared.IsValidAccountID(*op.Source) {
return helpers.NewInvalidParameterError("source", "Source must start with `G`.")
}
return nil
}