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

Allow submitTransaction to receive FeeBumpTransaction. #548

Merged
merged 1 commit into from
May 13, 2020
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ A breaking change will get clearly marked in this log.

## Unreleased

- Allow submitTransaction to receive a FeeBumpTransaction ([#548](https://github.com/stellar/js-stellar-sdk/pull/548)).

## [v5.0.1](https://github.com/stellar/js-stellar-sdk/compare/v5.0.0...v5.0.1)

### Update
Expand Down
4 changes: 2 additions & 2 deletions src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ export class Server {
*
* @see [Post
* Transaction](https://www.stellar.org/developers/horizon/reference/endpoints/transactions-create.html)
* @param {Transaction} transaction - The transaction to submit.
* @param {Transaction|FeeBumpTransaction} transaction - The transaction to submit.
* @param {object} [opts] Options object
* @param {boolean} [opts.skipMemoRequiredCheck] - Allow skipping memo
* required check, default: `false`. See
Expand All @@ -290,7 +290,7 @@ export class Server {
* horizon.
*/
public async submitTransaction(
transaction: Transaction,
transaction: Transaction | FeeBumpTransaction,
opts: Server.SubmitTransactionOptions = { skipMemoRequiredCheck: false },
): Promise<Horizon.SubmitTransactionResponse> {
// only check for memo required if skipMemoRequiredCheck is false and the transaction doesn't include a memo.
Expand Down
35 changes: 34 additions & 1 deletion test/unit/server_transaction_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ describe('server.js transaction tests', function() {
this.axiosMock = sinon.mock(HorizonAxiosClient);
let transaction = new StellarSdk.TransactionBuilder(account, {
fee: 100,
networkPassphrase: StellarSdk.Networks.TESTNET
networkPassphrase: StellarSdk.Networks.TESTNET,
v1: true
})
.addOperation(
StellarSdk.Operation.payment({
Expand Down Expand Up @@ -351,4 +352,36 @@ describe('server.js transaction tests', function() {
done(err);
});
});
it('submits fee bump transactions', function(done) {
const feeBumpTx = StellarSdk.TransactionBuilder.buildFeeBumpTransaction(
keypair,
'200',
this.transaction,
StellarSdk.Networks.TESTNET
);

this.blob = encodeURIComponent(
feeBumpTx
.toEnvelope()
.toXDR()
.toString('base64')
);

this.axiosMock
.expects('post')
.withArgs(
'https://horizon-live.stellar.org:1337/transactions',
`tx=${this.blob}`
)
.returns(Promise.resolve({ data: {} }));

this.server
.submitTransaction(feeBumpTx, {skipMemoRequiredCheck: true})
.then(function() {
done();
})
.catch(function(err) {
done(err);
});
});
});