Public
Edited
Jan 13, 2023
Insert cell
Insert cell
viewof local_file = file({
description: "Only .wasm files are allowed.",
accept: "application/wasm",
multiple: false
})
Insert cell
// testewasmSimpleStorage()
{
const backend = {
backend_api: new cwvm.BasicBackendApi('terra'),
storage: new cwvm.BasicKVIterStorage(),
querier: new cwvm.BasicQuerier(),
};
const vm = new cwvm.VMEInstance(backend);
console.log("vm", vm);
const mockEnv = {
block: {
height: 1337,
time: '2000000000',
chain_id: 'columbus-5',
},
contract: {
address: 'terra14z56l0fp2lsf86zy3hty2z47ezkhnthtr9yq76',
},
};
const mockInfo = {
sender: 'terra1337xewwfv3jdjuz8e0nea9vd8dpugc0k2dcyt3',
funds: [],
};
await vm.build(wasmBytecode);

let result = vm.instantiate(mockEnv, mockInfo, {});
console.log(result);
console.log(vm.backend);
result = vm.execute(mockEnv, mockInfo, { set: {value: 4} });
console.log(result);

// result = vm.query(mockEnv, mockInfo, { get: {} });
// console.log(region.json);
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
mutable wasmBytecode = ""
Insert cell
{
const buff = await local_file.arrayBuffer();
mutable wasmBytecode = new Uint8Array(buff);
}
Insert cell
Insert cell
import {file} from "@jashkenas/inputs"
Insert cell
// cwvm = require('@terran-one/cosmwasm-vm-js@0.2.16/dist/bundle.js')
cwvm = require('http://localhost:8080/bundle.js')
Insert cell
ethers = require('ethers@5.1.4/dist/ethers.umd.js')
Insert cell
Insert cell
Insert cell
// require('ewasm-jsvm/dist/main.js')
// ewasmjsvm = require('https://bundle.run/ewasm-jsvm@0.0.22')
// import('https://cdn.jsdelivr.net/npm/ewasm-jsvm@0.0.22/dist/main.js')
// ewasmjsvm = {
// const ethers = await require('ethers@5.1.4/dist/ethers.umd.js')
// console.log("ethers", ethers)
// window.ethers = ethers
// // const ewasmjsvm = await require('https://cdn.jsdelivr.net/npm/ewasm-jsvm@0.0.22/dist/main.js')
// const ewasmjsvm = await require('https://unpkg.com/ewasm-jsvm@0.0.22/dist/main.js')
// console.log("ewasmjsvm", ewasmjsvm)
// return ewasmjsvm
// }
// import('https://unpkg.com/ewasm-jsvm@0.0.22/dist/main.js')
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more