mirror of
https://github.com/FlipsideCrypto/near-bos-vm.git
synced 2026-02-06 11:18:24 +00:00
2.4.1: Fix VM.require
This commit is contained in:
parent
9f8acccced
commit
6fbc54ade6
@ -1,5 +1,9 @@
|
||||
# Changelog
|
||||
|
||||
## 2.4.1
|
||||
|
||||
- FIX: Resolve bug with `VM.require` affected by the introduction of `useState` and `useEffect` hooks.
|
||||
|
||||
## 2.4.0
|
||||
|
||||
- Introduce `useState` and `useEffect`. They should work similarly to the React hooks. Example:
|
||||
|
||||
2
dist/index.js
vendored
2
dist/index.js
vendored
File diff suppressed because one or more lines are too long
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "near-social-vm",
|
||||
"version": "2.4.0",
|
||||
"version": "2.4.1",
|
||||
"description": "Near Social VM",
|
||||
"main": "dist/index.js",
|
||||
"files": [
|
||||
|
||||
@ -1017,6 +1017,9 @@ class VmStack {
|
||||
"Method: useState. The hook can an only be called from the top of the stack"
|
||||
);
|
||||
}
|
||||
if (!this.vm.hooks) {
|
||||
throw new Error("Hooks are unavailable for modules");
|
||||
}
|
||||
if (args.length < 1) {
|
||||
throw new Error(
|
||||
"Method: useState. Required arguments: 'initialState'"
|
||||
@ -1046,6 +1049,9 @@ class VmStack {
|
||||
"Method: useEffect. The hook can an only be called from the top of the stack"
|
||||
);
|
||||
}
|
||||
if (!this.vm.hooks) {
|
||||
throw new Error("Hooks are unavailable for modules");
|
||||
}
|
||||
if (args.length < 1) {
|
||||
throw new Error(
|
||||
"Method: useEffect. Required arguments: 'setup'. Optional: 'dependencies'"
|
||||
@ -2098,7 +2104,7 @@ export default class VM {
|
||||
return "Too deep";
|
||||
}
|
||||
this.gIndex = 0;
|
||||
const { hooks, state } = reactState;
|
||||
const { hooks, state } = reactState ?? {};
|
||||
this.hooks = hooks;
|
||||
this.state = {
|
||||
props: isObject(props) ? Object.assign({}, props) : props,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user