Skip to content

Commit

Permalink
txnbuild: Complete rename, avoid using XDR types in `TransactionParam…
Browse files Browse the repository at this point in the history
…s`. (#4307)

* Timebounds -> TimeBounds, Ledgerbounds -> LedgerBounds
* Duration -> int64, SignerKey -> string
  • Loading branch information
Shaptic authored Mar 25, 2022
1 parent 9fdd7ff commit 6d0f666
Show file tree
Hide file tree
Showing 38 changed files with 413 additions and 364 deletions.
10 changes: 5 additions & 5 deletions clients/horizonclient/examples_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1100,7 +1100,7 @@ func ExampleClient_SubmitFeeBumpTransaction() {
IncrementSequenceNum: false,
Operations: []txnbuild.Operation{&op},
BaseFee: txnbuild.MinBaseFee,
Preconditions: txnbuild.Preconditions{Timebounds: txnbuild.NewInfiniteTimeout()}, // Use a real timeout in production!
Preconditions: txnbuild.Preconditions{TimeBounds: txnbuild.NewInfiniteTimeout()}, // Use a real timeout in production!
},
)
if err != nil {
Expand Down Expand Up @@ -1154,7 +1154,7 @@ func ExampleClient_SubmitFeeBumpTransactionWithOptions() {
IncrementSequenceNum: false,
Operations: []txnbuild.Operation{&op},
BaseFee: txnbuild.MinBaseFee,
Preconditions: txnbuild.Preconditions{Timebounds: txnbuild.NewInfiniteTimeout()}, // Use a real timeout in production!
Preconditions: txnbuild.Preconditions{TimeBounds: txnbuild.NewInfiniteTimeout()}, // Use a real timeout in production!
},
)
if err != nil {
Expand Down Expand Up @@ -1211,7 +1211,7 @@ func ExampleClient_SubmitTransaction() {
IncrementSequenceNum: false,
Operations: []txnbuild.Operation{&op},
BaseFee: txnbuild.MinBaseFee,
Preconditions: txnbuild.Preconditions{Timebounds: txnbuild.NewInfiniteTimeout()}, // Use a real timeout in production!
Preconditions: txnbuild.Preconditions{TimeBounds: txnbuild.NewInfiniteTimeout()}, // Use a real timeout in production!
},
)
if err != nil {
Expand Down Expand Up @@ -1253,7 +1253,7 @@ func ExampleClient_SubmitTransactionWithOptions() {
IncrementSequenceNum: false,
Operations: []txnbuild.Operation{&op},
BaseFee: txnbuild.MinBaseFee,
Preconditions: txnbuild.Preconditions{Timebounds: txnbuild.NewInfiniteTimeout()}, // Use a real timeout in production!
Preconditions: txnbuild.Preconditions{TimeBounds: txnbuild.NewInfiniteTimeout()}, // Use a real timeout in production!
},
)
if err != nil {
Expand Down Expand Up @@ -1295,7 +1295,7 @@ func ExampleClient_SubmitTransactionWithOptions_skip_memo_required_check() {
IncrementSequenceNum: false,
Operations: []txnbuild.Operation{&op},
BaseFee: txnbuild.MinBaseFee,
Preconditions: txnbuild.Preconditions{Timebounds: txnbuild.NewInfiniteTimeout()}, // Use a real timeout in production!
Preconditions: txnbuild.Preconditions{TimeBounds: txnbuild.NewInfiniteTimeout()}, // Use a real timeout in production!
},
)
if err != nil {
Expand Down
16 changes: 8 additions & 8 deletions clients/horizonclient/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ func TestCheckMemoRequired(t *testing.T) {
IncrementSequenceNum: true,
Operations: tc.operations,
BaseFee: txnbuild.MinBaseFee,
Preconditions: txnbuild.Preconditions{Timebounds: txnbuild.NewTimebounds(0, 10)},
Preconditions: txnbuild.Preconditions{TimeBounds: txnbuild.NewTimebounds(0, 10)},
},
)
tt.NoError(err)
Expand Down Expand Up @@ -878,7 +878,7 @@ func TestSubmitTransactionRequest(t *testing.T) {
IncrementSequenceNum: true,
Operations: []txnbuild.Operation{&payment},
BaseFee: txnbuild.MinBaseFee,
Preconditions: txnbuild.Preconditions{Timebounds: txnbuild.NewTimebounds(0, 10)},
Preconditions: txnbuild.Preconditions{TimeBounds: txnbuild.NewTimebounds(0, 10)},
},
)
assert.NoError(t, err)
Expand Down Expand Up @@ -946,7 +946,7 @@ func TestSubmitTransactionRequestMuxedAccounts(t *testing.T) {
IncrementSequenceNum: true,
Operations: []txnbuild.Operation{&payment},
BaseFee: txnbuild.MinBaseFee,
Preconditions: txnbuild.Preconditions{Timebounds: txnbuild.NewTimebounds(0, 10)},
Preconditions: txnbuild.Preconditions{TimeBounds: txnbuild.NewTimebounds(0, 10)},
},
)
assert.NoError(t, err)
Expand Down Expand Up @@ -1006,7 +1006,7 @@ func TestSubmitFeeBumpTransaction(t *testing.T) {
IncrementSequenceNum: true,
Operations: []txnbuild.Operation{&payment},
BaseFee: txnbuild.MinBaseFee,
Preconditions: txnbuild.Preconditions{Timebounds: txnbuild.NewTimebounds(0, 10)},
Preconditions: txnbuild.Preconditions{TimeBounds: txnbuild.NewTimebounds(0, 10)},
},
)
assert.NoError(t, err)
Expand Down Expand Up @@ -1075,7 +1075,7 @@ func TestSubmitTransactionWithOptionsRequest(t *testing.T) {
IncrementSequenceNum: true,
Operations: []txnbuild.Operation{&payment},
BaseFee: txnbuild.MinBaseFee,
Preconditions: txnbuild.Preconditions{Timebounds: txnbuild.NewTimebounds(0, 10)},
Preconditions: txnbuild.Preconditions{TimeBounds: txnbuild.NewTimebounds(0, 10)},
},
)
assert.NoError(t, err)
Expand Down Expand Up @@ -1168,7 +1168,7 @@ func TestSubmitTransactionWithOptionsRequest(t *testing.T) {
Operations: []txnbuild.Operation{&payment},
BaseFee: txnbuild.MinBaseFee,
Memo: txnbuild.MemoText("HelloWorld"),
Preconditions: txnbuild.Preconditions{Timebounds: txnbuild.NewTimebounds(0, 10)},
Preconditions: txnbuild.Preconditions{TimeBounds: txnbuild.NewTimebounds(0, 10)},
},
)
assert.NoError(t, err)
Expand Down Expand Up @@ -1202,7 +1202,7 @@ func TestSubmitFeeBumpTransactionWithOptions(t *testing.T) {
IncrementSequenceNum: true,
Operations: []txnbuild.Operation{&payment},
BaseFee: txnbuild.MinBaseFee,
Preconditions: txnbuild.Preconditions{Timebounds: txnbuild.NewTimebounds(0, 10)},
Preconditions: txnbuild.Preconditions{TimeBounds: txnbuild.NewTimebounds(0, 10)},
},
)
assert.NoError(t, err)
Expand Down Expand Up @@ -1293,7 +1293,7 @@ func TestSubmitFeeBumpTransactionWithOptions(t *testing.T) {
Operations: []txnbuild.Operation{&payment},
BaseFee: txnbuild.MinBaseFee,
Memo: txnbuild.MemoText("HelloWorld"),
Preconditions: txnbuild.Preconditions{Timebounds: txnbuild.NewTimebounds(0, 10)},
Preconditions: txnbuild.Preconditions{TimeBounds: txnbuild.NewTimebounds(0, 10)},
},
)
assert.NoError(t, err)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ func TestAccountSign_signingAddressAccountAuthenticatedButSigningAddressInvalid(
},
},
BaseFee: txnbuild.MinBaseFee,
Preconditions: txnbuild.Preconditions{Timebounds: txnbuild.NewTimebounds(0, 1)},
Preconditions: txnbuild.Preconditions{TimeBounds: txnbuild.NewTimebounds(0, 1)},
},
)
require.NoError(t, err)
Expand Down Expand Up @@ -412,7 +412,7 @@ func TestAccountSign_signingAddressAccountAuthenticatedOtherSignerSelected(t *te
},
},
BaseFee: txnbuild.MinBaseFee,
Preconditions: txnbuild.Preconditions{Timebounds: txnbuild.NewTimebounds(0, 1)},
Preconditions: txnbuild.Preconditions{TimeBounds: txnbuild.NewTimebounds(0, 1)},
},
)
require.NoError(t, err)
Expand Down Expand Up @@ -478,7 +478,7 @@ func TestAccountSign_signingAddressAccountAuthenticatedTxSourceAccountValid(t *t
},
},
BaseFee: txnbuild.MinBaseFee,
Preconditions: txnbuild.Preconditions{Timebounds: txnbuild.NewTimebounds(0, 1)},
Preconditions: txnbuild.Preconditions{TimeBounds: txnbuild.NewTimebounds(0, 1)},
},
)
require.NoError(t, err)
Expand Down Expand Up @@ -545,7 +545,7 @@ func TestAccountSign_signingAddressAccountAuthenticatedTxAndOpSourceAccountValid
},
},
BaseFee: txnbuild.MinBaseFee,
Preconditions: txnbuild.Preconditions{Timebounds: txnbuild.NewTimebounds(0, 1)},
Preconditions: txnbuild.Preconditions{TimeBounds: txnbuild.NewTimebounds(0, 1)},
},
)
require.NoError(t, err)
Expand Down Expand Up @@ -611,7 +611,7 @@ func TestAccountSign_signingAddressAccountAuthenticatedTxSourceAccountInvalid(t
},
},
BaseFee: txnbuild.MinBaseFee,
Preconditions: txnbuild.Preconditions{Timebounds: txnbuild.NewTimebounds(0, 1)},
Preconditions: txnbuild.Preconditions{TimeBounds: txnbuild.NewTimebounds(0, 1)},
},
)
require.NoError(t, err)
Expand Down Expand Up @@ -674,7 +674,7 @@ func TestAccountSign_signingAddressAccountAuthenticatedOpSourceAccountInvalid(t
},
},
BaseFee: txnbuild.MinBaseFee,
Preconditions: txnbuild.Preconditions{Timebounds: txnbuild.NewTimebounds(0, 1)},
Preconditions: txnbuild.Preconditions{TimeBounds: txnbuild.NewTimebounds(0, 1)},
},
)
require.NoError(t, err)
Expand Down Expand Up @@ -738,7 +738,7 @@ func TestAccountSign_signingAddressAccountAuthenticatedTxAndOpSourceAccountInval
},
},
BaseFee: txnbuild.MinBaseFee,
Preconditions: txnbuild.Preconditions{Timebounds: txnbuild.NewTimebounds(0, 1)},
Preconditions: txnbuild.Preconditions{TimeBounds: txnbuild.NewTimebounds(0, 1)},
},
)
require.NoError(t, err)
Expand Down Expand Up @@ -807,7 +807,7 @@ func TestAccountSign_signingAddressPhoneNumberOwnerAuthenticated(t *testing.T) {
},
},
BaseFee: txnbuild.MinBaseFee,
Preconditions: txnbuild.Preconditions{Timebounds: txnbuild.NewTimebounds(0, 1)},
Preconditions: txnbuild.Preconditions{TimeBounds: txnbuild.NewTimebounds(0, 1)},
},
)
require.NoError(t, err)
Expand Down Expand Up @@ -879,7 +879,7 @@ func TestAccountSign_signingAddressPhoneNumberOtherAuthenticated(t *testing.T) {
},
},
BaseFee: txnbuild.MinBaseFee,
Preconditions: txnbuild.Preconditions{Timebounds: txnbuild.NewTimebounds(0, 1)},
Preconditions: txnbuild.Preconditions{TimeBounds: txnbuild.NewTimebounds(0, 1)},
},
)
require.NoError(t, err)
Expand Down Expand Up @@ -951,7 +951,7 @@ func TestAccountSign_signingAddressEmailOwnerAuthenticated(t *testing.T) {
},
},
BaseFee: txnbuild.MinBaseFee,
Preconditions: txnbuild.Preconditions{Timebounds: txnbuild.NewTimebounds(0, 1)},
Preconditions: txnbuild.Preconditions{TimeBounds: txnbuild.NewTimebounds(0, 1)},
},
)
require.NoError(t, err)
Expand Down Expand Up @@ -1032,7 +1032,7 @@ func TestAccountSign_signingAddressEmailOwnerAuthenticatedOpSourceAccountIsAllow
&txnbuild.EndSponsoringFutureReserves{},
},
BaseFee: txnbuild.MinBaseFee,
Preconditions: txnbuild.Preconditions{Timebounds: txnbuild.NewTimebounds(0, 1)},
Preconditions: txnbuild.Preconditions{TimeBounds: txnbuild.NewTimebounds(0, 1)},
},
)
require.NoError(t, err)
Expand Down Expand Up @@ -1109,7 +1109,7 @@ func TestAccountSign_signingAddressEmailOwnerAuthenticatedOpSourceAccountInvalid
&txnbuild.EndSponsoringFutureReserves{},
},
BaseFee: txnbuild.MinBaseFee,
Preconditions: txnbuild.Preconditions{Timebounds: txnbuild.NewTimebounds(0, 1)},
Preconditions: txnbuild.Preconditions{TimeBounds: txnbuild.NewTimebounds(0, 1)},
},
)
require.NoError(t, err)
Expand Down Expand Up @@ -1176,7 +1176,7 @@ func TestAccountSign_signingAddressEmailOtherAuthenticated(t *testing.T) {
},
},
BaseFee: txnbuild.MinBaseFee,
Preconditions: txnbuild.Preconditions{Timebounds: txnbuild.NewTimebounds(0, 1)},
Preconditions: txnbuild.Preconditions{TimeBounds: txnbuild.NewTimebounds(0, 1)},
},
)
require.NoError(t, err)
Expand Down Expand Up @@ -1282,7 +1282,7 @@ func TestAccountSign_signingAddressRejectsFeeBumpTx(t *testing.T) {
},
},
BaseFee: txnbuild.MinBaseFee,
Preconditions: txnbuild.Preconditions{Timebounds: txnbuild.NewTimebounds(0, 1)},
Preconditions: txnbuild.Preconditions{TimeBounds: txnbuild.NewTimebounds(0, 1)},
},
)
require.NoError(t, err)
Expand Down Expand Up @@ -1352,7 +1352,7 @@ func TestAccountSign_signingAddressValidContentTypeForm(t *testing.T) {
},
},
BaseFee: txnbuild.MinBaseFee,
Preconditions: txnbuild.Preconditions{Timebounds: txnbuild.NewTimebounds(0, 1)},
Preconditions: txnbuild.Preconditions{TimeBounds: txnbuild.NewTimebounds(0, 1)},
},
)
require.NoError(t, err)
Expand Down
2 changes: 1 addition & 1 deletion exp/services/webauth/internal/serve/token_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1139,7 +1139,7 @@ func TestToken_jsonInputNoWebAuthDomainSuccess(t *testing.T) {
BaseFee: txnbuild.MinBaseFee,
Memo: nil,
Preconditions: txnbuild.Preconditions{
Timebounds: txnbuild.NewTimebounds(txMinTimebounds, txMaxTimebounds),
TimeBounds: txnbuild.NewTimebounds(txMinTimebounds, txMaxTimebounds),
},
},
)
Expand Down
2 changes: 1 addition & 1 deletion services/friendbot/init_friendbot.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ func createMinionAccounts(botAccount internal.Account, botKeypair *keypair.Full,
IncrementSequenceNum: true,
Operations: ops,
BaseFee: txnbuild.MinBaseFee,
Preconditions: txnbuild.Preconditions{Timebounds: txnbuild.NewTimeout(300)},
Preconditions: txnbuild.Preconditions{TimeBounds: txnbuild.NewTimeout(300)},
},
)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion services/friendbot/internal/minion.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ func (minion *Minion) makeTx(destAddress string) (string, error) {
IncrementSequenceNum: true,
Operations: []txnbuild.Operation{&createAccountOp},
BaseFee: minion.BaseFee,
Preconditions: txnbuild.Preconditions{Timebounds: txnbuild.NewInfiniteTimeout()},
Preconditions: txnbuild.Preconditions{TimeBounds: txnbuild.NewInfiniteTimeout()},
},
)
if err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func TestNegativeSequenceTxSubmission(t *testing.T) {
SourceAccount: account,
Operations: []txnbuild.Operation{&op2},
BaseFee: txnbuild.MinBaseFee,
Preconditions: txnbuild.Preconditions{Timebounds: txnbuild.NewInfiniteTimeout()},
Preconditions: txnbuild.Preconditions{TimeBounds: txnbuild.NewInfiniteTimeout()},
IncrementSequenceNum: false,
}
tx, err := txnbuild.NewTransaction(txParams)
Expand Down
2 changes: 1 addition & 1 deletion services/horizon/internal/integration/sponsorship_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ func TestSponsorships(t *testing.T) {
SourceAccount: newAccount,
Operations: []txnbuild.Operation{preAuthOp},
BaseFee: txnbuild.MinBaseFee,
Preconditions: txnbuild.Preconditions{Timebounds: txnbuild.NewInfiniteTimeout()},
Preconditions: txnbuild.Preconditions{TimeBounds: txnbuild.NewInfiniteTimeout()},
IncrementSequenceNum: true,
}
preaAuthTx, err := txnbuild.NewTransaction(txParams)
Expand Down
2 changes: 1 addition & 1 deletion services/horizon/internal/test/integration/integration.go
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,7 @@ func (i *Test) CreateSignedTransaction(
SourceAccount: source,
Operations: ops,
BaseFee: txnbuild.MinBaseFee,
Preconditions: txnbuild.Preconditions{Timebounds: txnbuild.NewInfiniteTimeout()},
Preconditions: txnbuild.Preconditions{TimeBounds: txnbuild.NewInfiniteTimeout()},
IncrementSequenceNum: true,
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ func setup(opts Options, hClient horizonclient.ClientInterface) error {
},
},
BaseFee: 300,
Preconditions: txnbuild.Preconditions{Timebounds: txnbuild.NewTimeout(300)},
Preconditions: txnbuild.Preconditions{TimeBounds: txnbuild.NewTimeout(300)},
})
if err != nil {
return errors.Wrap(err, "building transaction")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ func TestAPI_txApprove_revised(t *testing.T) {
},
},
BaseFee: txnbuild.MinBaseFee,
Preconditions: txnbuild.Preconditions{Timebounds: txnbuild.NewInfiniteTimeout()},
Preconditions: txnbuild.Preconditions{TimeBounds: txnbuild.NewInfiniteTimeout()},
},
)
require.NoError(t, err)
Expand Down Expand Up @@ -235,7 +235,7 @@ func TestAPI_txAprove_actionRequired(t *testing.T) {
},
},
BaseFee: txnbuild.MinBaseFee,
Preconditions: txnbuild.Preconditions{Timebounds: txnbuild.NewInfiniteTimeout()},
Preconditions: txnbuild.Preconditions{TimeBounds: txnbuild.NewInfiniteTimeout()},
},
)
require.NoError(t, err)
Expand Down Expand Up @@ -328,7 +328,7 @@ func TestAPI_txAprove_actionRequiredFlow(t *testing.T) {
},
},
BaseFee: txnbuild.MinBaseFee,
Preconditions: txnbuild.Preconditions{Timebounds: txnbuild.NewInfiniteTimeout()},
Preconditions: txnbuild.Preconditions{TimeBounds: txnbuild.NewInfiniteTimeout()},
},
)
require.NoError(t, err)
Expand Down Expand Up @@ -539,7 +539,7 @@ func TestAPI_txApprove_success(t *testing.T) {
},
},
BaseFee: 300,
Preconditions: txnbuild.Preconditions{Timebounds: txnbuild.NewTimeout(300)},
Preconditions: txnbuild.Preconditions{TimeBounds: txnbuild.NewTimeout(300)},
})
require.NoError(t, err)
txe, err := tx.Base64()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ func (h friendbotHandler) topUpAccountWithRegulatedAsset(ctx context.Context, in
},
},
BaseFee: 300,
Preconditions: txnbuild.Preconditions{Timebounds: txnbuild.NewTimeout(300)},
Preconditions: txnbuild.Preconditions{TimeBounds: txnbuild.NewTimeout(300)},
})
if err != nil {
err = errors.Wrap(err, "building transaction")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ func (h txApproveHandler) txApprove(ctx context.Context, in txApproveRequest) (r
IncrementSequenceNum: true,
Operations: revisedOperations,
BaseFee: 300,
Preconditions: txnbuild.Preconditions{Timebounds: txnbuild.NewTimeout(300)},
Preconditions: txnbuild.Preconditions{TimeBounds: txnbuild.NewTimeout(300)},
})
if err != nil {
return nil, errors.Wrap(err, "building transaction")
Expand Down
Loading

0 comments on commit 6d0f666

Please sign in to comment.