Skip to content

Commit

Permalink
Rename APIs to match XDR, plus add changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
Shaptic committed Oct 16, 2023
1 parent 83e57c5 commit 67d7936
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 9 deletions.
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,15 @@

## Unreleased

### Breaking Changes
* XDR has been upgraded to the latest stable version ([stellar-xdr@`6a620d1`](https://github.com/stellar/stellar-xdr/tree/6a620d160aab22609c982d54578ff6a63bfcdc01)). This is mostly renames, but it includes the following relevant breaking changes ([]()):
- TODO.
- `Operation.bumpFootprintExpiration` is now `extendFootprintTtl` and its `ledgersToExpire` field is now named `extendTo`, but it serves the same purpose.
- In TypeScript, the `Operation.BumpFootprintExpiration` is now `Operation.ExtendFootprintTTL`
- `xdr.ContractExecutable.contractExecutableToken` is now `contractExecutableStellarAsset`
- `xdr.SorobanTransactionData.refundableFee` is now `resourceFee`
- In turn, `SorobanDataBuilder.setRefundableFee` is now `setResourceFee`
- This new fee encompasses the entirety of the Soroban-related resource fees. Note that this is distinct from the "network-inclusion" fee that you would set on your transaction (i.e. `TransactionBuilder(..., { fee: ... })`).


## [`v10.0.0-beta.3`](https://github.com/stellar/js-stellar-base/compare/v10.0.0-beta.2...v10.0.0-beta.3)

Expand Down
6 changes: 3 additions & 3 deletions src/sorobandata_builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,11 @@ export class SorobanDataBuilder {
}

/**
* Sets the "refundable" fee portion of the Soroban data.
* @param {number | bigint | string} fee the refundable fee to set (int64)
* Sets the resource fee portion of the Soroban data.
* @param {number | bigint | string} fee the resource fee to set (int64)
* @returns {SorobanDataBuilder}
*/
setRefundableFee(fee) {
setResourceFee(fee) {
this._data.resourceFee(new xdr.Int64(fee));
return this;
}
Expand Down
4 changes: 2 additions & 2 deletions test/unit/sorobandata_builder_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ describe('SorobanTransactionData can be built', function () {

it('sets properties as expected', function () {
expect(
new dataBuilder().setResources(1, 2, 3).setRefundableFee(5).build()
new dataBuilder().setResources(1, 2, 3).setResourceFee(5).build()
).to.eql(sentinel);

// this isn't a valid param but we're just checking that setters work
Expand Down Expand Up @@ -73,7 +73,7 @@ describe('SorobanTransactionData can be built', function () {
it('makes copies on build()', function () {
const builder = new dataBuilder();
const first = builder.build();
const second = builder.setRefundableFee(100).build();
const second = builder.setResourceFee(100).build();

expect(first.resourceFee()).to.not.eql(second.resourceFee());
});
Expand Down
6 changes: 3 additions & 3 deletions types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ export namespace OperationType {
type LiquidityPoolDeposit = 'liquidityPoolDeposit';
type LiquidityPoolWithdraw = 'liquidityPoolWithdraw';
type InvokeHostFunction = 'invokeHostFunction';
type ExtendFootprintTTLOp = 'extendFootprintTtlOp';
type ExtendFootprintTTL = 'extendFootprintTtlOp';
type RestoreFootprint = 'restoreFootprint';
}
export type OperationType =
Expand Down Expand Up @@ -398,7 +398,7 @@ export type OperationType =
| OperationType.LiquidityPoolDeposit
| OperationType.LiquidityPoolWithdraw
| OperationType.InvokeHostFunction
| OperationType.ExtendFootprintTTLOp
| OperationType.ExtendFootprintTTL
| OperationType.RestoreFootprint;

export namespace OperationOptions {
Expand Down Expand Up @@ -1145,7 +1145,7 @@ export class SorobanDataBuilder {
constructor(data?: string | Uint8Array | Buffer | xdr.SorobanTransactionData);
static fromXDR(data: Uint8Array | Buffer | string): SorobanDataBuilder;

setRefundableFee(fee: IntLike): SorobanDataBuilder;
setResourceFee(fee: IntLike): SorobanDataBuilder;
setResources(
cpuInstrs: number,
readBytes: number,
Expand Down

0 comments on commit 67d7936

Please sign in to comment.