Skip to content

Commit

Permalink
Add support for stable Protocol 20 release (both XDR and RPC schemas) (
Browse files Browse the repository at this point in the history
…#710)

* Upgrade XDR to the final, stable testnet version. (#704, #715)

XDR has been upgraded to the latest stable version. This is mostly renames, but
it includes the following relevant breaking changes:
  - `Operation.bumpFootprintExpiration` is now `extendFootprintTtl` and its
  `ledgersToExpire` field is now named `extendTo`, but it serves the same
  purpose. - `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: ... })`). - In TypeScript, the
  `Operation.BumpFootprintExpiration` is now `Operation.ExtendFootprintTtl`

Commit: stellar/stellar-xdr @ bb54e50

* Add helpful abstractions for common invocation types. (#703)
* Drop incorrect key entry for contract footprint (#709)
* Republish package under @stellar/ scope (#714)
  • Loading branch information
Shaptic committed Dec 5, 2023
1 parent 9145983 commit 5766516
Show file tree
Hide file tree
Showing 52 changed files with 1,241 additions and 1,195 deletions.
13 changes: 11 additions & 2 deletions .github/workflows/npm_publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,16 @@ jobs:
- name: Test & Build
run: yarn preversion

- name: Publish release npm package
run: yarn publish --tag beta
- name: Publish npm package to both places
run: |
yarn publish --tag beta --access public
sed -i -e 's#"@stellar/stellar-base"#"stellar-base"#' package.json
yarn publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Deprecate the old package
run: |
npm deprecate stellar-base@latest "⚠️ This package has moved to @stellar/stellar-base! 🚚"
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,19 @@

## 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 ([#704](https://github.com/stellar/js-stellar-base/pull/704)):
- `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: ... })`).
- `Contract.getFootprint()` now only returns a single result: the ledger key of the deployed instance for the given ID, because the key for the code entry was incorrect (it should not be the ID but rather the WASM hash, which is not calculatable w/o network access) ([#709](https://github.com/stellar/js-stellar-base/pull/709)).


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

### Fixed
- You can now correctly clone transactions (`TransactionBuilder.cloneFrom`) with large sequence numbers ([#711](https://github.com/stellar/js-stellar-base/pull/711)).

Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
XDR_BASE_URL_CURR=https://github.com/stellar/stellar-xdr/raw/9ac02641139e6717924fdad716f6e958d0168491
XDR_BASE_URL_CURR=https://github.com/stellar/stellar-xdr/raw/bb54e505f814386a3f45172e0b7e95b7badbe969
XDR_BASE_LOCAL_CURR=xdr/curr
XDR_FILES_CURR= \
Stellar-SCP.x \
Expand All @@ -14,7 +14,7 @@ XDR_FILES_CURR= \
Stellar-contract-config-setting.x
XDR_FILES_LOCAL_CURR=$(addprefix xdr/curr/,$(XDR_FILES_CURR))

XDR_BASE_URL_NEXT=https://github.com/stellar/stellar-xdr/raw/440dc9512b6e72cf84965641c5eb495d6043ed73
XDR_BASE_URL_NEXT=https://github.com/stellar/stellar-xdr/raw/bb54e505f814386a3f45172e0b7e95b7badbe969
XDR_BASE_LOCAL_NEXT=xdr/next
XDR_FILES_NEXT= \
Stellar-SCP.x \
Expand Down
1 change: 0 additions & 1 deletion config/webpack.config.browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ const config = {
output: {
clean: true,
library: 'StellarBase',
compareBeforeEmit: true,
path: path.resolve(__dirname, '../dist')
},
mode: process.env.NODE_ENV ?? 'development',
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "stellar-base",
"name": "@stellar/stellar-base",
"version": "10.0.0-beta.4",
"description": "Low-level support library for the Stellar network.",
"main": "./lib/index.js",
Expand Down Expand Up @@ -123,7 +123,7 @@
"base32.js": "^0.1.0",
"bignumber.js": "^9.1.2",
"buffer": "^6.0.3",
"js-xdr": "^3.0.0",
"@stellar/js-xdr": "^3.0.1",
"sha.js": "^2.3.6",
"tweetnacl": "^1.0.3"
},
Expand Down
45 changes: 20 additions & 25 deletions src/contract.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,40 +53,35 @@ export class Contract {
*
* @returns {xdr.Operation} an InvokeHostFunctionOp operation to call the
* contract with the given method and parameters
*
* @see Operation.invokeHostFunction
* @see Operation.invokeContractFunction
* @see Operation.createCustomContract
* @see Operation.createStellarAssetContract
* @see Operation.uploadContractWasm
*/
call(method, ...params) {
return Operation.invokeHostFunction({
func: xdr.HostFunction.hostFunctionTypeInvokeContract(
new xdr.InvokeContractArgs({
contractAddress: this.address().toScAddress(),
functionName: method,
args: params
})
),
auth: []
return Operation.invokeContractFunction({
contract: this.address().toString(),
function: method,
args: params
});
}

/**
* Returns the read-only footprint entries necessary for any invocations to
* this contract, for convenience when adding it to your transaction's overall
* footprint or doing bump/restore operations.
* this contract, for convenience when manually adding it to your
* transaction's overall footprint or doing bump/restore operations.
*
* @returns {xdr.LedgerKey[]} the ledger keys containing the contract's code
* (first) and its deployed contract instance (second)
* @returns {xdr.LedgerKey} the ledger key for the deployed contract instance
*/
getFootprint() {
return [
xdr.LedgerKey.contractCode(
new xdr.LedgerKeyContractCode({ hash: this._id })
),
xdr.LedgerKey.contractData(
new xdr.LedgerKeyContractData({
contract: this.address().toScAddress(),
key: xdr.ScVal.scvLedgerKeyContractInstance(),
durability: xdr.ContractDataDurability.persistent()
})
)
];
return xdr.LedgerKey.contractData(
new xdr.LedgerKeyContractData({
contract: this.address().toScAddress(),
key: xdr.ScVal.scvLedgerKeyContractInstance(),
durability: xdr.ContractDataDurability.persistent()
})
);
}
}
Loading

0 comments on commit 5766516

Please sign in to comment.