diff --git a/packages/skchain/src/lib/contract/__tests__/vm.spec.ts b/packages/skchain/src/lib/contract/__tests__/vm.spec.ts index a3e47f5..86301f1 100644 --- a/packages/skchain/src/lib/contract/__tests__/vm.spec.ts +++ b/packages/skchain/src/lib/contract/__tests__/vm.spec.ts @@ -13,6 +13,10 @@ describe('vm', () => { expect(res.funcResult).toEqual('2'); expect(res.cuCost.reduce((acc, cur) => acc + Number(cur), 0)).toEqual(38); }); + it('should Date fn ok', async () => { + const res = await evalFunction('() => Date.now()'); + expect(res.funcResult.length).toEqual(13); + }); it('should simple class ok', async () => { const codeStr = ` ${generateBaseContractCode(new Address(testAccounts[0].id))} diff --git a/packages/skvm/Cargo.toml b/packages/skvm/Cargo.toml index ddc588f..dd24821 100644 --- a/packages/skvm/Cargo.toml +++ b/packages/skvm/Cargo.toml @@ -13,6 +13,7 @@ default = ["console_error_panic_hook"] [dependencies] wasm-bindgen = "0.2.84" getrandom = { version = "0.2.8", features = ["js"] } +chrono = { version = "0.4.26", default-features = false, features = ["clock", "std", "wasmbind"] } boa_engine = { path = "./skboa/boa_engine" } wasm-bindgen-test = "0.3.13" js-sys = "0.3.61" diff --git a/packages/skvm/pkg/node/skvm_bg.js b/packages/skvm/pkg/node/skvm_bg.js index cac3287..fc1de8d 100644 --- a/packages/skvm/pkg/node/skvm_bg.js +++ b/packages/skvm/pkg/node/skvm_bg.js @@ -148,7 +148,7 @@ function makeMutClosure(arg0, arg1, dtor, f) { return real; } function __wbg_adapter_28(arg0, arg1, arg2) { - wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h2eb5e7682dd29212(arg0, arg1, addHeapObject(arg2)); + wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h5451c65af4a43c91(arg0, arg1, addHeapObject(arg2)); } /** @@ -274,11 +274,11 @@ export function __wbgtest_console_error(args) { } function __wbg_adapter_80(arg0, arg1, arg2, arg3, arg4) { - wasm.wasm_bindgen__convert__closures__invoke3_mut__h716e9571233e6ab5(arg0, arg1, addHeapObject(arg2), arg3, addHeapObject(arg4)); + wasm.wasm_bindgen__convert__closures__invoke3_mut__h2315033f19a55d71(arg0, arg1, addHeapObject(arg2), arg3, addHeapObject(arg4)); } -function __wbg_adapter_95(arg0, arg1, arg2, arg3) { - wasm.wasm_bindgen__convert__closures__invoke2_mut__h207fa8e2cab371d6(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3)); +function __wbg_adapter_101(arg0, arg1, arg2, arg3) { + wasm.wasm_bindgen__convert__closures__invoke2_mut__h3541220db1e62064(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3)); } /** @@ -605,6 +605,21 @@ export function __wbg_call_9495de66fdbe016b() { return handleError(function (arg return addHeapObject(ret); }, arguments) }; +export function __wbg_getTime_7c59072d1651a3cf(arg0) { + const ret = getObject(arg0).getTime(); + return ret; +}; + +export function __wbg_getTimezoneOffset_2a6b27fb18493a56(arg0) { + const ret = getObject(arg0).getTimezoneOffset(); + return ret; +}; + +export function __wbg_new0_25059e40b1c02766() { + const ret = new Date(); + return addHeapObject(ret); +}; + export function __wbg_new_9d3a9ce4282a18a8(arg0, arg1) { try { var state0 = {a: arg0, b: arg1}; @@ -612,7 +627,7 @@ export function __wbg_new_9d3a9ce4282a18a8(arg0, arg1) { const a = state0.a; state0.a = 0; try { - return __wbg_adapter_95(a, state0.b, arg0, arg1); + return __wbg_adapter_101(a, state0.b, arg0, arg1); } finally { state0.a = a; } @@ -677,7 +692,7 @@ export function __wbindgen_memory() { return addHeapObject(ret); }; -export function __wbindgen_closure_wrapper5102(arg0, arg1, arg2) { +export function __wbindgen_closure_wrapper5109(arg0, arg1, arg2) { const ret = makeMutClosure(arg0, arg1, 1333, __wbg_adapter_28); return addHeapObject(ret); }; diff --git a/packages/skvm/pkg/node/skvm_bg.wasm b/packages/skvm/pkg/node/skvm_bg.wasm index fe826a0..5d4594f 100644 Binary files a/packages/skvm/pkg/node/skvm_bg.wasm and b/packages/skvm/pkg/node/skvm_bg.wasm differ diff --git a/packages/skvm/pkg/node/skvm_bg.wasm.d.ts b/packages/skvm/pkg/node/skvm_bg.wasm.d.ts index d9f7068..ebda129 100644 --- a/packages/skvm/pkg/node/skvm_bg.wasm.d.ts +++ b/packages/skvm/pkg/node/skvm_bg.wasm.d.ts @@ -14,9 +14,9 @@ export function __wbgtest_console_error(a: number): void; export function __wbindgen_malloc(a: number): number; export function __wbindgen_realloc(a: number, b: number, c: number): number; export const __wbindgen_export_2: WebAssembly.Table; -export function _dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h2eb5e7682dd29212(a: number, b: number, c: number): void; +export function _dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h5451c65af4a43c91(a: number, b: number, c: number): void; export function __wbindgen_add_to_stack_pointer(a: number): number; export function __wbindgen_exn_store(a: number): void; export function __wbindgen_free(a: number, b: number): void; -export function wasm_bindgen__convert__closures__invoke3_mut__h716e9571233e6ab5(a: number, b: number, c: number, d: number, e: number): void; -export function wasm_bindgen__convert__closures__invoke2_mut__h207fa8e2cab371d6(a: number, b: number, c: number, d: number): void; +export function wasm_bindgen__convert__closures__invoke3_mut__h2315033f19a55d71(a: number, b: number, c: number, d: number, e: number): void; +export function wasm_bindgen__convert__closures__invoke2_mut__h3541220db1e62064(a: number, b: number, c: number, d: number): void; diff --git a/packages/skvm/pkg/web/skvm.d.ts b/packages/skvm/pkg/web/skvm.d.ts index dabfc2c..0ebba3b 100644 --- a/packages/skvm/pkg/web/skvm.d.ts +++ b/packages/skvm/pkg/web/skvm.d.ts @@ -96,12 +96,12 @@ export interface InitOutput { readonly __wbindgen_malloc: (a: number) => number; readonly __wbindgen_realloc: (a: number, b: number, c: number) => number; readonly __wbindgen_export_2: WebAssembly.Table; - readonly _dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h2eb5e7682dd29212: (a: number, b: number, c: number) => void; + readonly _dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h5451c65af4a43c91: (a: number, b: number, c: number) => void; readonly __wbindgen_add_to_stack_pointer: (a: number) => number; readonly __wbindgen_exn_store: (a: number) => void; readonly __wbindgen_free: (a: number, b: number) => void; - readonly wasm_bindgen__convert__closures__invoke3_mut__h716e9571233e6ab5: (a: number, b: number, c: number, d: number, e: number) => void; - readonly wasm_bindgen__convert__closures__invoke2_mut__h207fa8e2cab371d6: (a: number, b: number, c: number, d: number) => void; + readonly wasm_bindgen__convert__closures__invoke3_mut__h2315033f19a55d71: (a: number, b: number, c: number, d: number, e: number) => void; + readonly wasm_bindgen__convert__closures__invoke2_mut__h3541220db1e62064: (a: number, b: number, c: number, d: number) => void; } export type SyncInitInput = BufferSource | WebAssembly.Module; diff --git a/packages/skvm/pkg/web/skvm.js b/packages/skvm/pkg/web/skvm.js index a633e20..06292b7 100644 --- a/packages/skvm/pkg/web/skvm.js +++ b/packages/skvm/pkg/web/skvm.js @@ -140,7 +140,7 @@ function makeMutClosure(arg0, arg1, dtor, f) { return real; } function __wbg_adapter_28(arg0, arg1, arg2) { - wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h2eb5e7682dd29212(arg0, arg1, addHeapObject(arg2)); + wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h5451c65af4a43c91(arg0, arg1, addHeapObject(arg2)); } /** @@ -266,11 +266,11 @@ export function __wbgtest_console_error(args) { } function __wbg_adapter_80(arg0, arg1, arg2, arg3, arg4) { - wasm.wasm_bindgen__convert__closures__invoke3_mut__h716e9571233e6ab5(arg0, arg1, addHeapObject(arg2), arg3, addHeapObject(arg4)); + wasm.wasm_bindgen__convert__closures__invoke3_mut__h2315033f19a55d71(arg0, arg1, addHeapObject(arg2), arg3, addHeapObject(arg4)); } -function __wbg_adapter_95(arg0, arg1, arg2, arg3) { - wasm.wasm_bindgen__convert__closures__invoke2_mut__h207fa8e2cab371d6(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3)); +function __wbg_adapter_101(arg0, arg1, arg2, arg3) { + wasm.wasm_bindgen__convert__closures__invoke2_mut__h3541220db1e62064(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3)); } /** @@ -588,6 +588,18 @@ function __wbg_get_imports() { const ret = getObject(arg0).call(getObject(arg1), getObject(arg2)); return addHeapObject(ret); }, arguments) }; + imports.wbg.__wbg_getTime_7c59072d1651a3cf = function(arg0) { + const ret = getObject(arg0).getTime(); + return ret; + }; + imports.wbg.__wbg_getTimezoneOffset_2a6b27fb18493a56 = function(arg0) { + const ret = getObject(arg0).getTimezoneOffset(); + return ret; + }; + imports.wbg.__wbg_new0_25059e40b1c02766 = function() { + const ret = new Date(); + return addHeapObject(ret); + }; imports.wbg.__wbg_new_9d3a9ce4282a18a8 = function(arg0, arg1) { try { var state0 = {a: arg0, b: arg1}; @@ -595,7 +607,7 @@ function __wbg_get_imports() { const a = state0.a; state0.a = 0; try { - return __wbg_adapter_95(a, state0.b, arg0, arg1); + return __wbg_adapter_101(a, state0.b, arg0, arg1); } finally { state0.a = a; } @@ -648,7 +660,7 @@ function __wbg_get_imports() { const ret = wasm.memory; return addHeapObject(ret); }; - imports.wbg.__wbindgen_closure_wrapper5102 = function(arg0, arg1, arg2) { + imports.wbg.__wbindgen_closure_wrapper5109 = function(arg0, arg1, arg2) { const ret = makeMutClosure(arg0, arg1, 1333, __wbg_adapter_28); return addHeapObject(ret); }; diff --git a/packages/skvm/pkg/web/skvm_bg.wasm b/packages/skvm/pkg/web/skvm_bg.wasm index 187ec13..7f5c513 100644 Binary files a/packages/skvm/pkg/web/skvm_bg.wasm and b/packages/skvm/pkg/web/skvm_bg.wasm differ diff --git a/packages/skvm/pkg/web/skvm_bg.wasm.d.ts b/packages/skvm/pkg/web/skvm_bg.wasm.d.ts index d9f7068..ebda129 100644 --- a/packages/skvm/pkg/web/skvm_bg.wasm.d.ts +++ b/packages/skvm/pkg/web/skvm_bg.wasm.d.ts @@ -14,9 +14,9 @@ export function __wbgtest_console_error(a: number): void; export function __wbindgen_malloc(a: number): number; export function __wbindgen_realloc(a: number, b: number, c: number): number; export const __wbindgen_export_2: WebAssembly.Table; -export function _dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h2eb5e7682dd29212(a: number, b: number, c: number): void; +export function _dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h5451c65af4a43c91(a: number, b: number, c: number): void; export function __wbindgen_add_to_stack_pointer(a: number): number; export function __wbindgen_exn_store(a: number): void; export function __wbindgen_free(a: number, b: number): void; -export function wasm_bindgen__convert__closures__invoke3_mut__h716e9571233e6ab5(a: number, b: number, c: number, d: number, e: number): void; -export function wasm_bindgen__convert__closures__invoke2_mut__h207fa8e2cab371d6(a: number, b: number, c: number, d: number): void; +export function wasm_bindgen__convert__closures__invoke3_mut__h2315033f19a55d71(a: number, b: number, c: number, d: number, e: number): void; +export function wasm_bindgen__convert__closures__invoke2_mut__h3541220db1e62064(a: number, b: number, c: number, d: number): void; diff --git a/packages/skvm/skboa b/packages/skvm/skboa index c728a68..283dcaa 160000 --- a/packages/skvm/skboa +++ b/packages/skvm/skboa @@ -1 +1 @@ -Subproject commit c728a6879c40319c8cc5048b37541ba337f0823f +Subproject commit 283dcaad8db68cf1b056c0a6424d48f09ab97381 diff --git a/packages/skvm/src/lib.rs b/packages/skvm/src/lib.rs index bc77ac7..8dda0de 100644 --- a/packages/skvm/src/lib.rs +++ b/packages/skvm/src/lib.rs @@ -63,6 +63,7 @@ mod utils; use boa_engine::{Context, Source}; use getrandom as _; +use chrono as _; use js_sys::{Array, Uint8Array}; use proto_rs::eval_result; use protobuf::{Message, SpecialFields};