You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The interface txnbuild.Account defines the requirements for an account used by transactions and operations. Often, the workflow is to obtain an account using horizonclient, and then use this to build new transactions.
However, this is not always the case. It would be helpful to provide a minimal implementation SimpleAccount for situations where an account is not coming from a horizonclient call. This functionality is needed in friendbot, and the bridge server, for example. It would also simplify txnbuild test code, which currently has this funky helper method:
@debnil has a minimal implementation here. We could move something like this to txnbuild. Also see the implementation in protocols/horizon:
// GetSequenceNumber returns the sequence number of the account,
// and returns it as a 64-bit integer.
func (a Account) GetSequenceNumber() (xdr.SequenceNumber, error) {
seqNum, err := strconv.ParseUint(a.Sequence, 10, 64)
if err != nil {
return 0, errors.Wrap(err, "Failed to parse account sequence number")
}
return xdr.SequenceNumber(seqNum), nil
}
// IncrementSequenceNumber increments the internal record of the account's sequence
// number by 1. This is typically used after a transaction build so that the next
// transaction to be built will be valid.
func (a *Account) IncrementSequenceNumber() (xdr.SequenceNumber, error) {
seqNum, err := a.GetSequenceNumber()
if err != nil {
return xdr.SequenceNumber(0), err
}
seqNum++
a.Sequence = strconv.FormatInt(int64(seqNum), 10)
return a.GetSequenceNumber()
}
The interface
txnbuild.Account
defines the requirements for an account used by transactions and operations. Often, the workflow is to obtain an account usinghorizonclient
, and then use this to build new transactions.However, this is not always the case. It would be helpful to provide a minimal implementation
SimpleAccount
for situations where an account is not coming from ahorizonclient
call. This functionality is needed in friendbot, and the bridge server, for example. It would also simplifytxnbuild
test code, which currently has this funky helper method:@debnil has a minimal implementation here. We could move something like this to
txnbuild
. Also see the implementation inprotocols/horizon
:The text was updated successfully, but these errors were encountered: