stellar / js-stellar-sdk

Main Stellar client library for the JavaScript language.
https://stellar.github.io/js-stellar-sdk/
Apache License 2.0
628 stars 311 forks source link

feature: add auto restore functionality for contract client #974

Closed BlaineHeffron closed 3 months ago

BlaineHeffron commented 4 months ago

Adds the ability to set restore to true in contract method invocation options. This will utilize the signTransaction method to sign a restoreFootprint operation when found that it is needed during a simulation.

BlaineHeffron commented 4 months ago

A couple of interesting things I found:

Shaptic commented 4 months ago

The problem I found was that the sequence number increments the first time the AssembledTransaction is built, and since that method call doesn't go through it is then off by 1 for the restoreFootprint operation.

Yeahh this has been a long-standing issue with the Account object. That's why TransactionBuilder.cloneFrom() does this janky -1n workaround. We can definitely make changes to that interface and its implementations, though. See also https://github.com/stellar/js-stellar-base/issues/574 and https://github.com/stellar/js-stellar-base/issues/436 for more stuff related to this. I'm definitely for it!

BlaineHeffron commented 4 months ago

All comments are addressed except regarding the test. I think we can use this test for now until we have a way of using a quickstart image with a short minimum TTL that would be suitable for this type of e2e test. Changelog has been added.

Shaptic commented 3 months ago

@BlaineHeffron if you can resolve the conflicts I can merge this asap!

chadoh commented 3 months ago

@BlaineHeffron is out today! I resolved the conflicts but didn't have permission to push to Blaine's fork, so I made a new PR, if you want to merge that one and close this one, @Shaptic! https://github.com/stellar/js-stellar-sdk/pull/991