New Release - Run SDK v0.6.38
Today we’re releasing Run SDK v0.6.38. This release adds a new function to load jigs from a prepared state file so that you can safely ship jigs with your app or library, and a few other minor changes too. Install it from NPM or download it here.
Starting in 0.6.38, you can use the new function
Run.util.recreateJigsFromStates(states) to synchronously loads jigs from a state bundle you’ve prepared. This means you can bundle your jigs with your app so that they can be used as soon as your app starts. You can also create libraries that use your on-chain code without needing to
await run.load() them first. We’re already using this too in Run for all the built-in Extras (
Let’s run though an example:
First, find the jigs you wish to load:
Next, get the state bundle for that jig:
A state bundle is a JSON data structure containing an object with all of the states needed to completely load a jig. If a class extends from another class, both classes must be in the bundle. There are multiple ways to get a state bundle. You can use the cache, or Run-DB, but for this example we’ll use the Run State API:
all=1query parameter tells the API to return the complete state bundle instead of just a single jig state. You can save this as the file
states.jsonwhich you would ship with your app
Finally, when your app or library starts call the function with the states:
const jigs = Run.util.recreateJigsFromState(require('./states.json'))
If you see a timeout while loading or syncing a jig, the error message now has the jig location in it that failed:
TimeoutError: load timeout (258594f43ea2623caf8d5109d2027c9b1f303916cfb59672130ba43704269e1c)
Timeouts usually happen when there is a problem with the state indexer (Run State API or Run DB). This improved messaging will make any timeouts much easier to debug.
If you’ve seen a
metadata mismatch error while loading B berries on Safari, this is now fixed.
The Run Extras library now loads deterministically from state files as it should have.
All of the Run Extras classes and functions, like
Run.extra.Token, will only work on mainnet now. You can still use them on testnet but you must use the testnet versions and be explicit. This is safer too! The Token class on testnet is now
Run.extra.test.Token and same for the others.