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

Adds Protocol 20 (Soroban) support to the XDR and API. #538

Merged
merged 83 commits into from
Sep 12, 2023
Merged

Conversation

paulbellamy
Copy link
Contributor

@paulbellamy paulbellamy commented Aug 15, 2022

This is a holistic view on the upstream merge. Here are the changelog / release notes:

v10.0.0-beta.0: Protocol 20 Support

Breaking Changes

Node 16 is the new minimum version to use the SDKs.

Major XDR Changes

The XDR has been massively overhauled to support Soroban in Protocol 20, which means new operations, data structures, and a transaction format as well as new overlay features.

The core data structure of Soroban is a generic type called an ScVal (smart contract value, which is a union of types that can basically represent anything (numbers, strings, arrays, maps, contract bytecode, etc.). You should refer to the XDR for details, and you can rely some new APIs to make dealing with these complex values easier:

  • nativeToScVal helps convert native types to their closes Soroban equivalent
  • scValToNative helps find the closest native JavaScript type(s) corresponding to a smart contract value
  • scValToBigInt helps convert numeric ScVals into native bigints
  • ScInt and XdrLargeInt help convert to and from bigints to other types and form sized integer types for smart contract usage

The following are convenience methods for building out certain types of smart contract-related structures:

  • buildInvocationTree and walkInvocationTree are both ways to visualize invocation calling trees better
  • authorizeInvocation helps multiple parties sign invocation calling trees
  • humanizeEvents helps make diagnostic events more readable

Added

The following are new APIs to deal with new Soroban constructs:

  • Address, which helps manage "smart" addresses in the Soroban context. Addresses there (used for auth and identity purposes) can either be contracts (strkey C...) or accounts (strkey G...). This abstraction helps manage them and distinguish between them easily.
  • Contract, which helps manage contract identifiers. The primary purpose is to build invocations of its methods via the generic call(...), but it also provides utilities for converting to an Address or calculating its minimum footprint for state expiration.
  • Three new operations have been added related to Soroban transactions:
    • invokeHostFunction for calling contract code
    • bumpFootprintExpiration for extending the state lifetime of Soroban data
    • restoreFootprint for restoring expired, off-chain state back onto the ledger
  • The TransactionBuilder now takes a sorobanData parameter (and has a corresponding .setSorobanData() builder method) which primarily describes the storage footprint of a Soroban (that is, which parts of the ledger state [in the form of xdr.LedgerKeys] it plans to read and write as part of the transaction).
    • To facilitate building this out, there's a new SorobanDataBuilder factory to set fields individually
  • The TransactionBuilder now has a cloneFrom(tx, opts) constructor method to create an instance from an existing transaction, also allowing parameter overrides via opts.
  • We've added a GHA to track bundle size changes as PRs are made. This protocol upgrade adds +25% to the final, minified bundle size which is significant but unavoidable given the size of the upgrade.

@paulbellamy
Copy link
Contributor Author

Fixes stellar/js-stellar-sdk#787

Shaptic and others added 13 commits September 21, 2022 15:57
* Add FUTURENET network passphrase

* Bump soroban package version
* Update xdr

* Missed a few hash typeof shenanigans

* don't need this export
* Add STANDALONE network passphrase

* bump version
…ded (#557)

* Default to include the contract code footprint, as that is always needed

* 8.0.1-soroban.4
* Update xdr

* Bump the packge version
* Missed removing parameters from the operation builder

* Fix bug in contract.call footprint

* Fixing up tests
* Correctly set `minAccountSequence` in `TransactionBuilder` for large values (#539)

* Bump terser from 4.8.0 to 4.8.1 (#536)

Bumps [terser](https://github.com/terser/terser) from 4.8.0 to 4.8.1.
- [Release notes](https://github.com/terser/terser/releases)
- [Changelog](https://github.com/terser/terser/blob/master/CHANGELOG.md)
- [Commits](https://github.com/terser/terser/commits)

---
updated-dependencies:
- dependency-name: terser
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Release v8.1.0 (#540)

* Add support of CAP40 ed25519SignedPayload signer for SetOptionOp (#542)

* Add TypeScript interfaces for Ed25519SignedPayload signers

* Release v8.2.0 (#545)

* Coalesce all xLM, Xlm, etc. => 'XLM' native asset code (#546)

* Release v8.2.1 (#554)

* make sure sodium is not an empty object in service workers (#567)

* make sure sodium is not an empty object in service workers

* Update CHANGELOG.md

Co-authored-by: George <Shaptic@users.noreply.github.com>

Co-authored-by: George <Shaptic@users.noreply.github.com>

* use next xdr

* First pass at invokeHostFunction

* Fixing test & lint

* Would help if we actually exported the Contract wrapper

* the invokeHostFunctionOp should be useable with transaction builder

* Add sandbox network passphrase

* Push to the soroban tag for PRs to base branch (#547)

* Fix github action to publish soroban tag (#548)

* Have to update package.json to build the soroban tag (#549)

* Add futurenet passphrase for soroban. (#550)

* Add FUTURENET network passphrase

* Bump soroban package version

* Update soroban xdr (#552)

* Update xdr

* Missed a few hash typeof shenanigans

* don't need this export

* Bump soroban package version (#553)

* Include standalone network passphrase (#555)

* Add STANDALONE network passphrase

* bump version

* Default to include the contract code footprint, as that is always needed (#557)

* Default to include the contract code footprint, as that is always needed

* 8.0.1-soroban.4

* Update xdr to 026c9cd (#563)

* Update xdr

* Bump the packge version

* New soroban xdr updates (#566)

* Missed removing parameters from the operation builder

* Fix bug in contract.call footprint

* Fixing up tests

* Soroban auth next updates (#570)

* update xdr for auth-next

* Add auth field to invokeHostFunctionOp

* bump version

* Needed to modify the generated code slightly

* Fix lint

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: Jun Luo <4catcode@gmail.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: George <Shaptic@users.noreply.github.com>
Co-authored-by: OrbitLens <33724849+orbitlens@users.noreply.github.com>
Co-authored-by: Piyal Basu <pbasu235@gmail.com>
@piyalbasu
Copy link
Contributor

@paulbellamy Apologies, I accidentally published a new version of this branch while trying to debug an issue in Freighter. It just created a new version 8.2.2-soroban.8 that is exactly the same as soroban.7. NPM won't allow that version to be unpublished and reused, so the next version will need to be 8.2.2-soroban.9.

Again, sorry about that. The automated pipeline worked a bit too well, it seems 😬

Paul Bellamy and others added 6 commits February 8, 2023 12:51
…ddresses (#572)

* add strkey contract parsing

* Add Address class to help parse & build ScAddresses

* Add static constructors for account & contract addresses from bytes

* bump version to release 8.2.2-soroban.9
* Update soroban xdr

* bump version to release 8.2.2-soroban.10
…ures. (#576)

* Attempting to add an error if you try to sign a transaction that needs contract signatures

* Use the parent class' .operations

---------

Co-authored-by: George Kudrayvtsev <george@stellar.org>
* Update xdr to add ContractAuth preimage nonce

* bump version to 8.2.2-soroban.11
* Add Address.toBuffer method

* need deep equal

* Eugh. no buffer typeof on firefox.
* Update xdr for value overhaul

* Fixing address & contract for new xdr

* 8.2.2-soroban.12
Shaptic and others added 19 commits August 10, 2023 12:18
* Bump version and dependencies
* Unify isValidAmount errors to explain type reqs

* Fixup tests to match new errors

* Add changelog entry
)

* Update to latest curr and next XDRs (testnet final)
* Export curr instead of next!
* Update codebase to match new XDR schemas:
 - function invocation now needs an InvokeContractArgs structure
 - signatureArgs was a 0-elem vec, now an ScVal w/ 0-elem vec
 - bodyType is gone
 - metaDataSizeBytes is gone
 - some minor test stuff has been tweaked for readability
…690)

* Add a way to check for int type descriptors
* Add ability to turn strings into bigint ScVals
* Add string -> address ScVal conversion support
* Amend GHA to push with `--tag beta` and not on Soroban merge

---------

Co-authored-by: shawn <sreuland@users.noreply.github.com>
@Shaptic Shaptic merged commit 4182cca into master Sep 12, 2023
4 checks passed
@Shaptic Shaptic deleted the soroban branch September 12, 2023 16:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants