Skip to content

Add TransactionBuilder.setFootprint() method to prepare footprint easily - #660

Merged
Shaptic merged 8 commits into
sorobanfrom
restore-builder
Jul 28, 2023
Merged

Shaptic merged 8 commits into
sorobanfrom
restore-builder

Conversation

@Shaptic

@Shaptic Shaptic commented Jul 27, 2023

Copy link
Copy Markdown
Contributor

This is much better than creating an entire, mostly-empty xdr.SorobanTransactionData and using setSorobanData() when you want to create a bump or restore operation.

@github-actions

github-actions Bot commented Jul 27, 2023 •

Copy link
Copy Markdown

Size Change: +30.1 kB (+1%)

Total Size: 3.01 MB

Filename Size Change
dist/stellar-base.js 2.21 MB +22.6 kB (+1%)
dist/stellar-base.min.js 800 kB +7.56 kB (+1%)

compressed-size-action

Comment thread src/resources.js Outdated
return sorobanDataFromFootprint([], []);
}

export function sorobanDataFromFootprint(readOnly, readWrite) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so for my use case I think I needed to keep the rest of the resources, so I set it like this

const sorobanTxData = xdr.SorobanTransactionData.fromXDR(
    simulation.transactionData,
    "base64",
  );
  sorobanTxData.resources().footprint(footprint);
  txnBuilder.setSorobanData(sorobanTxData);

so basically I merged a new simulation's resources with an old footprint, would I still be able to do that if sorobanDataFromFootprint 0s out the other keys of the SorobanResources?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah so you wouldn't want to use these. instead, you'd want this:

txnBuilder
  .setSorobanData(sorobanTxData)
  .setFootprint(footprint.readOnly(), footprint.readWrite());

for this: the latter call will leave the existing fields alone.

@Shaptic Shaptic Jul 27, 2023 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After the refactor based on @sreuland's comment, this would now be:

txnBuilder.setSorobanData(
  new SorobanDataBuilder(sorobanTxData)
    .setReadOnly(footprint.readOnly())
    .setReadWrite(footprint.readWrite())
    // or, equivalently: setFootprint(footprint.readOnly(), footprint.readWrite())
    .build()
);

Comment thread src/transaction_builder.js Resolved
@Shaptic
Shaptic force-pushed the restore-builder branch 2 times, most recently from 40376ec to 2689388 Compare July 28, 2023 00:08
Shaptic added a commit to stellar-deprecated/soroban-docs that referenced this pull request Jul 28, 2023
@Shaptic
Shaptic merged commit 634f9d5 into soroban Jul 28, 2023
@Shaptic
Shaptic deleted the restore-builder branch July 28, 2023 06:21
kalepail pushed a commit to stellar-deprecated/soroban-docs that referenced this pull request Sep 5, 2023
* Add initial skeleton to state-exp tutorial

* I hate this prettier config but so be it 🤷

* Add untested code around restoring state

* Add snippet on building a restore tx

* Fixup headers: single # is hidden

* Add explanation around filtering entries

* Clean up code

* Keep code on pace with stellar/js-stellar-base#660

* fmt fixup

* Some code/doc/markdown fixups

* Add a link

* Add simulation error check

* Doc fixup

* Update tutorial to match latest Soroban RPC / client schemas

* Add details, switch to await-based code

* Formatting fixup

* Add cross-ref links to each example

* Remove extraneous instructions

* Update copy after self-review

* Code compilation fixups

* Incorporate easy PR feedback

* Clean up language based on feedback

* couple grammar nits

* Fixup the s -> server rename

* Fixup sentence wording

* Be number-specific

Co-authored-by: Leigh McCulloch <[email protected]>

---------

Co-authored-by: Bri Wylde <[email protected]>
Co-authored-by: Leigh McCulloch <[email protected]>
Shaptic added a commit that referenced this pull request Sep 12, 2023
* Correctly set `minAccountSequence` in `TransactionBuilder` for large values (#539)
* Add support of CAP40 ed25519SignedPayload signer for SetOptionOp (#542)
* Add TypeScript interfaces for Ed25519SignedPayload signers
* Coalesce all xLM, Xlm, etc. => 'XLM' native asset code (#546)
* make sure sodium is not an empty object in service workers (#567)
* Add futurenet passphrase for soroban. (#550)
* Include standalone network passphrase (#555)
* Soroban auth next updates (#570)
* Add strkey parsing for contracts, and Address helper for building ScAddresses (#572)
* Update xdr to include HashIdPreimageContractAuth.nonce (#577)
* Add Address.toBuffer method (#578)
* Soroban value overhaul (#582)
* Update generated XDR to latest version. (#587)
* Update XDR and contract invocations to conform to the latest version (Preview 9). (#601)
* added soroban transaction data as tx builder param (#604)
* Add Contract support for strkey-style contract IDs (#612)
* Add Contract.address() method (#614)
* Add wrappers to easily deal with the myriad of `ScVal` integer types. (#620)
* Upgrade `js-xdr` to v3.0.0 to support `bigint` encoding.
* Add wrappers to easily convert between `ScVal` and native types. (#630)
* Update XDR to support Preview 10 (#633)
* Fix TypeScript definition for `invokeHostFunction` options (#635)
* Add fully-qualified `Operation` type to XDR type definitions. (#591)
* Adds Operation.isValidAmount jsdoc (#609)
* Removes the dependency on `crc` by calculating checksum in strkey (#621)
* Improve type flexibility when building `ScVal`s from native types (#638)
* Fix Preview 10 contract invoke & release `v10.0.0-soroban.3` (#642)
* Add GitHub Action that compares before-and-after bundle sizes. (#644)
* Make opinionated judgements about string/symbol decoding (#645)
* Make Node 16 the minimum version. (#651)
* Add standalone/futurenet passphrases to jsdoc (#654)
* Clean up unnecessary dependency entries (#652)
* Add `SorobanDataBuilder` builder pattern to prepare transactions easier (#660)
* Adds a way to create a `TransactionBuilder` from an existing transaction. (#656)
* Add basic contract event parsing into a human-readable structure (#659)
* Drop support for deprecated hex contract IDs (#658)
* Add helpers method to build authorization entries. (#663)
* Fix TypeScript definition for new static `TransactionBuilder` constructor (#665)
* Add ability to clear out operations from the transaction builder (#670)
* Add an existing method to XdrLargeInt, jsdoc/types fixup (#668)
* Expand contract footprint with contract code ledger key. (#662)
* Decode base64-encoded strings in new SorobanDataBuilder (#673)
* Add ability to modify and retrieve the resource footprint (#680)
* Fixes error messages for required amount parameters (#679)
* Add `Asset.contractId()` helper to predict contract IDs (#684)
* Upgrade dependencies to their latest minor/patch version (#685)
* Improves `SorobanDataBuilder` construction and adds a getter (#686)
* Add JSON-ification of Soroban invocation trees. (#669)
* Add utilities for formatting token amounts (`formatTokenAmount` & `parseTokenAmount`) (#667)
* Merges the final Protocol 20 XDR (i.e. for testnet) into `soroban` (#688)
* Add support to convert strings to large integer and address `ScVal`s (#690)

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: Paul Bellamy <[email protected]>
Co-authored-by: George <[email protected]>
Co-authored-by: Jun Luo <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: OrbitLens <[email protected]>
Co-authored-by: Piyal Basu <[email protected]>
Co-authored-by: George Kudrayvtsev <[email protected]>
Co-authored-by: shawn <[email protected]>
Co-authored-by: Silence <[email protected]>
Co-authored-by: Chad Ostrowski <[email protected]>
Co-authored-by: jeesun 지선 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants