Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

txnbuild: add SequenceNumber func to Transaction #3616

Merged
merged 7 commits into from
May 24, 2021
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions txnbuild/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ file. This project adheres to [Semantic Versioning](http://semver.org/).

## Unreleased

### New features

* Add `SequenceNumber` function to `Transaction`.

## [v7.0.0](https://github.com/stellar/go/releases/tag/horizonclient-v7.0.0) - 2021-05-15

### Breaking changes
Expand Down
5 changes: 5 additions & 0 deletions txnbuild/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,11 @@ func (t *Transaction) SourceAccount() SimpleAccount {
return t.sourceAccount
}

// SequenceNumber returns the sequence number of the transaction.
func (t *Transaction) SequenceNumber() int64 {
return t.sourceAccount.Sequence
}

leighmcculloch marked this conversation as resolved.
Show resolved Hide resolved
// Memo returns the memo configured for this transaction.
func (t *Transaction) Memo() Memo {
return t.memo
Expand Down
2 changes: 2 additions & 0 deletions txnbuild/transaction_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1343,6 +1343,7 @@ func TestFromXDR(t *testing.T) {
assert.Equal(t, int64(100), newTx.BaseFee(), "Base fee should match")
sa := newTx.SourceAccount()
assert.Equal(t, int64(6606179392290817), sa.Sequence, "Sequence number should match")
assert.Equal(t, int64(6606179392290817), newTx.SequenceNumber(), "Sequence number should match")
assert.Equal(t, 1, len(newTx.Operations()), "Operations length should match")
assert.IsType(t, newTx.Operations()[0], &Payment{}, "Operation types should match")
paymentOp, ok1 := newTx.Operations()[0].(*Payment)
Expand All @@ -1363,6 +1364,7 @@ func TestFromXDR(t *testing.T) {
assert.Equal(t, "GBUKBCG5VLRKAVYAIREJRUJHOKLIADZJOICRW43WVJCLES52BDOTCQZU", newTx2.SourceAccount().AccountID, "source accounts should match")
assert.Equal(t, int64(200), newTx2.BaseFee(), "Base fee should match")
assert.Equal(t, int64(14800457302017), newTx2.SourceAccount().Sequence, "Sequence number should match")
assert.Equal(t, int64(14800457302017), newTx2.SequenceNumber(), "Sequence number should match")

memo, ok := newTx2.Memo().(MemoText)
assert.Equal(t, true, ok)
Expand Down