From 0440dd7f8c3d9e46261544c8422772f7cf7c34bb Mon Sep 17 00:00:00 2001 From: Luke Thorne Date: Wed, 15 Dec 2021 08:24:12 -0500 Subject: [PATCH 001/111] update wasp config --- .../wasm/fairroulette/frontend/waypoint.hcl | 2 +- tools/evm-server/waypoint.hcl | 2 +- wasp.nomad.tpl | 392 ++++++++++-------- 3 files changed, 210 insertions(+), 186 deletions(-) diff --git a/contracts/wasm/fairroulette/frontend/waypoint.hcl b/contracts/wasm/fairroulette/frontend/waypoint.hcl index d0b5e41d96..5a8b4635f0 100644 --- a/contracts/wasm/fairroulette/frontend/waypoint.hcl +++ b/contracts/wasm/fairroulette/frontend/waypoint.hcl @@ -18,7 +18,7 @@ variable "goshimmer_url" { variable "chainid" { type = string - default = "be1j1GwB971eEAVfDmNFUtUfQ7rHEEF43Mz7yTP2bdkH" + default = "mjNp2do4hTL5pnW5Fo8z6ncoSCB3543MEwTgGuVy9tsS" } variable "adminWhitelist" { diff --git a/tools/evm-server/waypoint.hcl b/tools/evm-server/waypoint.hcl index b9b464d5ed..581a9c3700 100644 --- a/tools/evm-server/waypoint.hcl +++ b/tools/evm-server/waypoint.hcl @@ -8,7 +8,7 @@ labels = { "team" = "iscp" } variable "chainid" { type = string - default = "jiCuv7Z4bYqAU8baSyCJP6HAxw8wC1YUYi722GibYPWW" + default = "oBrnaPHdo2J6bV4oebfbExCoLtbSrU6fRwaHLtAo4akh" } variable "wallet_seed" { diff --git a/wasp.nomad.tpl b/wasp.nomad.tpl index ad3f8c113d..e2f91e3f4e 100644 --- a/wasp.nomad.tpl +++ b/wasp.nomad.tpl @@ -1,5 +1,5 @@ variable "wasp_config" { - default = < Date: Wed, 12 Jan 2022 08:12:30 -0800 Subject: [PATCH 002/111] Update to wasmtime 0.33.1 --- go.mod | 2 +- go.sum | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 3033a7f605..ff4660d23f 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ require ( github.com/PuerkitoBio/goquery v1.6.1 github.com/anthdm/hbbft v0.0.0-20190702061856-0826ffdcf567 github.com/bygui86/multi-profile/v2 v2.1.0 - github.com/bytecodealliance/wasmtime-go v0.32.0 + github.com/bytecodealliance/wasmtime-go v0.33.1 github.com/wasmerio/wasmer-go v1.0.4 github.com/second-state/WasmEdge-go v0.9.0 // indirect github.com/ethereum/go-ethereum v1.10.10 diff --git a/go.sum b/go.sum index 3f37349bad..8d79bed862 100644 --- a/go.sum +++ b/go.sum @@ -157,6 +157,10 @@ github.com/bytecodealliance/wasmtime-go v0.31.0 h1:AbMdV1pwjw/0Ito5yARcGzY366cq5 github.com/bytecodealliance/wasmtime-go v0.31.0/go.mod h1:q320gUxqyI8yB+ZqRuaJOEnGkAnHh6WtJjMaT2CW4wI= github.com/bytecodealliance/wasmtime-go v0.32.0 h1:/GsrnJz2bfULAIZygN4vUElLYliQrx/o/1opP9X7Gck= github.com/bytecodealliance/wasmtime-go v0.32.0/go.mod h1:q320gUxqyI8yB+ZqRuaJOEnGkAnHh6WtJjMaT2CW4wI= +github.com/bytecodealliance/wasmtime-go v0.33.0 h1:lRhyaHpBKx+5swZKHc5uTxCPWtDRAAYope5sQPfi7Tw= +github.com/bytecodealliance/wasmtime-go v0.33.0/go.mod h1:q320gUxqyI8yB+ZqRuaJOEnGkAnHh6WtJjMaT2CW4wI= +github.com/bytecodealliance/wasmtime-go v0.33.1 h1:TFep11LiqCy1B6QUIAtqH3KZTbZcKasm89/AF9sqLnA= +github.com/bytecodealliance/wasmtime-go v0.33.1/go.mod h1:q320gUxqyI8yB+ZqRuaJOEnGkAnHh6WtJjMaT2CW4wI= github.com/c-bata/go-prompt v0.2.2/go.mod h1:VzqtzE2ksDBcdln8G7mk2RX9QyGjH+OVqOCSiVIqS34= github.com/capossele/asset-registry v0.0.0-20210521112927-c9d6e74574e8/go.mod h1:BXwVCA0+rgYcMKC3vVkfjF+2nXYIYq3h/HndbaCuw08= github.com/casbin/casbin/v2 v2.1.2/go.mod h1:YcPU1XXisHhLzuxH9coDNf2FbKpjGlbCg3n9yuLkIJQ= From de2b000b1078a0cef37f10bc7cfccd17bf569704 Mon Sep 17 00:00:00 2001 From: Eric Hop Date: Wed, 12 Jan 2022 20:38:18 -0800 Subject: [PATCH 003/111] Better implementation of TS event handler. Go will follow. --- contracts/wasm/core_build.cmd | 1 + .../ts/testwasmlibclient/events.ts | 21 +++++++++--- .../ts/testwasmlibclient/service.ts | 14 ++++---- packages/vm/wasmlib/ts/wasmclient/index.ts | 1 + packages/vm/wasmlib/ts/wasmclient/service.ts | 34 +++++++++++-------- tools/schema/generator/clientbase.go | 24 ++----------- .../goclienttemplates/alltemplates.go | 1 - .../generator/goclienttemplates/events.go | 7 ++++ .../generator/goclienttemplates/funcs.go | 15 -------- .../tsclienttemplates/alltemplates.go | 1 - .../generator/tsclienttemplates/events.go | 25 +++++++++++--- .../generator/tsclienttemplates/funcs.go | 16 --------- 12 files changed, 76 insertions(+), 84 deletions(-) delete mode 100644 tools/schema/generator/goclienttemplates/funcs.go delete mode 100644 tools/schema/generator/tsclienttemplates/funcs.go diff --git a/contracts/wasm/core_build.cmd b/contracts/wasm/core_build.cmd index b6c208ba50..1ae6c16ad8 100644 --- a/contracts/wasm/core_build.cmd +++ b/contracts/wasm/core_build.cmd @@ -1,4 +1,5 @@ @echo off +go install ../../tools/schema cd ..\..\packages\vm\wasmlib schema -core -go -rust -ts -client -force del /s /q d:\work\node_modules\wasmlib\*.* >nul: diff --git a/contracts/wasm/testwasmlib/ts/testwasmlibclient/events.ts b/contracts/wasm/testwasmlib/ts/testwasmlibclient/events.ts index 6d066c0cf0..668b2a0ef5 100644 --- a/contracts/wasm/testwasmlib/ts/testwasmlibclient/events.ts +++ b/contracts/wasm/testwasmlib/ts/testwasmlibclient/events.ts @@ -6,11 +6,24 @@ // Change the json schema instead import * as wasmclient from "wasmclient" -import * as app from "./testwasmlib" -export const eventHandlers: wasmclient.EventHandlers = new Map([ - ["testwasmlib.test", (msg: string[]) => app.onTestWasmLibTest(new EventTest(msg))], -]); +type TestWasmLibHandlers = Map void>; + +export class TestWasmLibEvents implements wasmclient.IEventHandler { + private eventHandlers: TestWasmLibHandlers = new Map([ + ["testwasmlib.test", (evt: TestWasmLibEvents, msg: string[]) => evt.onTestWasmLibTest(new EventTest(msg))], + ]); + + public callHandler(topic: string, params: string[]): void { + const handler = this.eventHandlers.get(topic); + if (handler !== undefined) { + handler(this, params); + } + } + + public onTestWasmLibTest(event: EventTest): void { + } +} export class EventTest extends wasmclient.Event { public readonly address: wasmclient.Address; diff --git a/contracts/wasm/testwasmlib/ts/testwasmlibclient/service.ts b/contracts/wasm/testwasmlib/ts/testwasmlibclient/service.ts index f738825fd4..cffde6f794 100644 --- a/contracts/wasm/testwasmlib/ts/testwasmlibclient/service.ts +++ b/contracts/wasm/testwasmlib/ts/testwasmlibclient/service.ts @@ -277,7 +277,7 @@ export class ArrayLengthView extends wasmclient.ClientView { public async call(): Promise { this.args.mandatory(ArgName); - const res = new ArrayLengthResults(); + const res = new ArrayLengthResults(); await this.callView("arrayLength", this.args, res); return res; } @@ -306,7 +306,7 @@ export class ArrayValueView extends wasmclient.ClientView { public async call(): Promise { this.args.mandatory(ArgIndex); this.args.mandatory(ArgName); - const res = new ArrayValueResults(); + const res = new ArrayValueResults(); await this.callView("arrayValue", this.args, res); return res; } @@ -335,7 +335,7 @@ export class BlockRecordView extends wasmclient.ClientView { public async call(): Promise { this.args.mandatory(ArgBlockIndex); this.args.mandatory(ArgRecordIndex); - const res = new BlockRecordResults(); + const res = new BlockRecordResults(); await this.callView("blockRecord", this.args, res); return res; } @@ -359,7 +359,7 @@ export class BlockRecordsView extends wasmclient.ClientView { public async call(): Promise { this.args.mandatory(ArgBlockIndex); - const res = new BlockRecordsResults(); + const res = new BlockRecordsResults(); await this.callView("blockRecords", this.args, res); return res; } @@ -377,7 +377,7 @@ export class BlockRecordsResults extends wasmclient.Results { export class GetRandomView extends wasmclient.ClientView { public async call(): Promise { - const res = new GetRandomResults(); + const res = new GetRandomResults(); await this.callView("getRandom", null, res); return res; } @@ -395,7 +395,7 @@ export class GetRandomResults extends wasmclient.Results { export class IotaBalanceView extends wasmclient.ClientView { public async call(): Promise { - const res = new IotaBalanceResults(); + const res = new IotaBalanceResults(); await this.callView("iotaBalance", null, res); return res; } @@ -424,7 +424,7 @@ export class MapValueView extends wasmclient.ClientView { public async call(): Promise { this.args.mandatory(ArgKey); this.args.mandatory(ArgName); - const res = new MapValueResults(); + const res = new MapValueResults(); await this.callView("mapValue", this.args, res); return res; } diff --git a/packages/vm/wasmlib/ts/wasmclient/index.ts b/packages/vm/wasmlib/ts/wasmclient/index.ts index d09441a314..83ed0405c6 100644 --- a/packages/vm/wasmlib/ts/wasmclient/index.ts +++ b/packages/vm/wasmlib/ts/wasmclient/index.ts @@ -7,6 +7,7 @@ export * from "./clientview"; export * from "./decoder"; export * from "./encoder"; export * from "./event"; +export * from "./eventhandler"; export * from "./results"; export * from "./service"; export * from "./serviceclient"; diff --git a/packages/vm/wasmlib/ts/wasmclient/service.ts b/packages/vm/wasmlib/ts/wasmclient/service.ts index efb029f008..53fb557d29 100644 --- a/packages/vm/wasmlib/ts/wasmclient/service.ts +++ b/packages/vm/wasmlib/ts/wasmclient/service.ts @@ -7,22 +7,22 @@ import {IOnLedger} from "./goshimmer/models/on_ledger"; import {Colors} from "./colors"; import {Buffer} from './buffer'; -export type EventHandlers = Map void>; +export interface IEventHandler { + callHandler(topic: string, params: string[]): void; +} export class Service { private serviceClient: wasmclient.ServiceClient; private webSocket: WebSocket | null = null; public keyPair: IKeyPair | null = null; - private eventHandlers: EventHandlers | null = null; + private eventHandlers: Array = new Array(); public scHname: wasmclient.Hname; private waspWebSocketUrl: string = ""; - constructor(client: wasmclient.ServiceClient, scHname: wasmclient.Hname, eventHandlers: EventHandlers) { + constructor(client: wasmclient.ServiceClient, scHname: wasmclient.Hname) { this.serviceClient = client; this.scHname = scHname; - if (eventHandlers.size != 0) { - this.configureWebSocketsEventHandlers(eventHandlers); - } + this.configureWebSocketsEventHandlers(); } public async callView(viewName: string, args: wasmclient.Arguments, res: wasmclient.Results): Promise { @@ -62,6 +62,15 @@ export class Service { return transactionID; } + public register(handler: IEventHandler): void { + this.eventHandlers.push(handler); + } + + public unregister(handler: IEventHandler): void { + // remove handler + this.eventHandlers = this.eventHandlers.filter(h => h !== handler); + } + // overrides default contract name public serviceContractName(contractName: string): void { this.scHname = Hash.from(Buffer.from(contractName)).readUInt32LE(0) @@ -71,9 +80,7 @@ export class Service { await this.serviceClient.waspClient.waitRequest(this.serviceClient.configuration.chainId, reqID); } - private configureWebSocketsEventHandlers(eventHandlers: EventHandlers) { - this.eventHandlers = eventHandlers; - + private configureWebSocketsEventHandlers() { if ( this.serviceClient.configuration.waspWebSocketUrl.startsWith("wss://") || this.serviceClient.configuration.waspWebSocketUrl.startsWith("ws://") @@ -83,7 +90,7 @@ export class Service { this.waspWebSocketUrl = this.waspWebSocketUrl.replace("%chainId", this.serviceClient.configuration.chainId); - if (this.eventHandlers.size > 1) this.connectWebSocket(); + this.connectWebSocket(); } private connectWebSocket(): void { @@ -102,10 +109,9 @@ export class Service { } const topics = msg[3].split("|"); const topic = topics[0]; - if (this.eventHandlers && this.eventHandlers.has(topic)) { - const eventHandler = this.eventHandlers.get(topic)!; - const eventHandlerMsg = topics.slice(1); - eventHandler(eventHandlerMsg); + const params = topics.slice(1); + for (let i = 0; i < this.eventHandlers.length; i++) { + this.eventHandlers[i].callHandler(topic, params); } } } diff --git a/tools/schema/generator/clientbase.go b/tools/schema/generator/clientbase.go index 4ccbf673c2..8a67aa3b8b 100644 --- a/tools/schema/generator/clientbase.go +++ b/tools/schema/generator/clientbase.go @@ -3,8 +3,6 @@ package generator import ( "fmt" "os" - - "github.com/iotaledger/wasp/tools/schema/model" ) type ClientBase struct { @@ -31,27 +29,9 @@ func (g *ClientBase) Generate() error { } func (g *ClientBase) generateCode() error { - err := g.createSourceFile("events", !g.s.CoreContracts) - if err != nil { - return err - } - err = g.createSourceFile("service", true) + err := g.createSourceFile("events", len(g.s.Events) != 0) if err != nil { return err } - if !g.s.CoreContracts { - return g.generateFuncs(g.appendEvents) - } - return nil -} - -func (g *ClientBase) appendEvents(existing model.StringMap) { - for _, g.currentEvent = range g.s.Events { - name := g.s.ContractName + capitalize(g.currentEvent.Name) - if existing[name] == "" { - g.log("currentEvent: " + g.currentEvent.Name) - g.setMultiKeyValues("evtName", g.currentEvent.Name) - g.emit("funcSignature") - } - } + return g.createSourceFile("service", true) } diff --git a/tools/schema/generator/goclienttemplates/alltemplates.go b/tools/schema/generator/goclienttemplates/alltemplates.go index 351de3f721..baffd0d584 100644 --- a/tools/schema/generator/goclienttemplates/alltemplates.go +++ b/tools/schema/generator/goclienttemplates/alltemplates.go @@ -13,7 +13,6 @@ var Templates = []map[string]string{ config, // always first one common, eventsGo, - funcsGo, serviceGo, } diff --git a/tools/schema/generator/goclienttemplates/events.go b/tools/schema/generator/goclienttemplates/events.go index feabf1b3d1..670f829b5a 100644 --- a/tools/schema/generator/goclienttemplates/events.go +++ b/tools/schema/generator/goclienttemplates/events.go @@ -6,9 +6,16 @@ var eventsGo = map[string]string{ $#emit clientHeader var EventHandlers = map[string]func([]string) { +$#each events funcSignature $#each events eventHandler } $#each events eventClass +`, + // ******************************* + "funcSignature": ` + +func On$PkgName$EvtName(event *Event$EvtName) { +} `, // ******************************* "eventHandler": ` diff --git a/tools/schema/generator/goclienttemplates/funcs.go b/tools/schema/generator/goclienttemplates/funcs.go deleted file mode 100644 index ca29c3d132..0000000000 --- a/tools/schema/generator/goclienttemplates/funcs.go +++ /dev/null @@ -1,15 +0,0 @@ -package goclienttemplates - -var funcsGo = map[string]string{ - // ******************************* - "funcs.go": ` -$#emit clientHeader -$#each events funcSignature -`, - // ******************************* - "funcSignature": ` - -func On$PkgName$EvtName(event *Event$EvtName) { -} -`, -} diff --git a/tools/schema/generator/tsclienttemplates/alltemplates.go b/tools/schema/generator/tsclienttemplates/alltemplates.go index fb9cfbe3b4..2016b81be6 100644 --- a/tools/schema/generator/tsclienttemplates/alltemplates.go +++ b/tools/schema/generator/tsclienttemplates/alltemplates.go @@ -13,7 +13,6 @@ var Templates = []map[string]string{ config, // always first one common, eventsTs, - funcsTs, indexTs, serviceTs, } diff --git a/tools/schema/generator/tsclienttemplates/events.go b/tools/schema/generator/tsclienttemplates/events.go index b7bef5f608..ee04379ede 100644 --- a/tools/schema/generator/tsclienttemplates/events.go +++ b/tools/schema/generator/tsclienttemplates/events.go @@ -4,16 +4,33 @@ var eventsTs = map[string]string{ // ******************************* "events.ts": ` $#emit importWasmLib -import * as app from "./$package" -export const eventHandlers: wasmclient.EventHandlers = new Map([ +type $PkgName$+Handlers = Map void>; + +export class $PkgName$+Events implements wasmclient.IEventHandler { + private eventHandlers: $PkgName$+Handlers = new Map([ $#each events eventHandler -]); + ]); + + public callHandler(topic: string, params: string[]): void { + const handler = this.eventHandlers.get(topic); + if (handler !== undefined) { + handler(this, params); + } + } +$#each events funcSignature +} $#each events eventClass `, // ******************************* "eventHandler": ` - ["$package.$evtName", (msg: string[]) => app.on$PkgName$EvtName(new Event$EvtName(msg))], + ["$package.$evtName", (evt: $PkgName$+Events, msg: string[]) => evt.on$PkgName$EvtName(new Event$EvtName(msg))], +`, + // ******************************* + "funcSignature": ` + + public on$PkgName$EvtName(event: Event$EvtName): void { + } `, // ******************************* "eventClass": ` diff --git a/tools/schema/generator/tsclienttemplates/funcs.go b/tools/schema/generator/tsclienttemplates/funcs.go deleted file mode 100644 index 02e361eaf3..0000000000 --- a/tools/schema/generator/tsclienttemplates/funcs.go +++ /dev/null @@ -1,16 +0,0 @@ -package tsclienttemplates - -var funcsTs = map[string]string{ - // ******************************* - "funcs.ts": ` -$#emit importEvents -$#emit importService -$#each events funcSignature -`, - // ******************************* - "funcSignature": ` - -export function on$PkgName$EvtName(event: events.Event$EvtName): void { -} -`, -} From d035e2f21b7b45aaf975984685f5e5fa44338b3c Mon Sep 17 00:00:00 2001 From: Eric Hop Date: Thu, 13 Jan 2022 07:22:55 -0800 Subject: [PATCH 004/111] Changed event handlers --- .../go/testwasmlibclient/events.go | 26 ++++++++-- .../go/testwasmlibclient/service.go | 6 ++- .../test/testwasmlib_client_test.go | 13 +++-- .../ts/testwasmlibclient/events.ts | 13 ++--- .../ts/testwasmlibclient/service.ts | 6 ++- .../go/wasmclient/coreaccounts/service.go | 2 +- .../wasmlib/go/wasmclient/coreblob/service.go | 2 +- .../go/wasmclient/coreblocklog/service.go | 2 +- .../go/wasmclient/coregovernance/service.go | 2 +- .../wasmlib/go/wasmclient/coreroot/service.go | 2 +- packages/vm/wasmlib/go/wasmclient/service.go | 48 +++++++++++++------ .../ts/wasmclient/coreaccounts/service.ts | 7 ++- .../wasmlib/ts/wasmclient/coreblob/service.ts | 7 ++- .../ts/wasmclient/coreblocklog/service.ts | 7 ++- .../ts/wasmclient/coregovernance/service.ts | 7 ++- .../wasmlib/ts/wasmclient/coreroot/service.ts | 7 ++- packages/vm/wasmlib/ts/wasmclient/service.ts | 5 ++ .../generator/goclienttemplates/events.go | 31 +++++++++--- .../generator/goclienttemplates/service.go | 16 ++++--- .../generator/tsclienttemplates/events.go | 19 +++++--- .../generator/tsclienttemplates/service.go | 18 +++---- 21 files changed, 178 insertions(+), 68 deletions(-) diff --git a/contracts/wasm/testwasmlib/go/testwasmlibclient/events.go b/contracts/wasm/testwasmlib/go/testwasmlibclient/events.go index e0c3faf93c..6f7c526768 100644 --- a/contracts/wasm/testwasmlib/go/testwasmlibclient/events.go +++ b/contracts/wasm/testwasmlib/go/testwasmlibclient/events.go @@ -9,8 +9,23 @@ package testwasmlibclient import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmclient" -var EventHandlers = map[string]func([]string){ - "testwasmlib.test": onTestWasmLibTestThunk, +var testWasmLibHandlers = map[string]func(*TestWasmLibEvents, []string){ + "testwasmlib.test": func(evt *TestWasmLibEvents, msg []string) { evt.onTestWasmLibTestThunk(msg) }, +} + +type TestWasmLibEvents struct { + test func(e *EventTest) +} + +func (h *TestWasmLibEvents) CallHandler(topic string, params []string) { + handler := testWasmLibHandlers[topic] + if handler != nil { + handler(h, params) + } +} + +func (h *TestWasmLibEvents) OnTestWasmLibTest(handler func(e *EventTest)) { + h.test = handler } type EventTest struct { @@ -19,10 +34,13 @@ type EventTest struct { Name string } -func onTestWasmLibTestThunk(message []string) { +func (h *TestWasmLibEvents) onTestWasmLibTestThunk(message []string) { + if h.test == nil { + return + } e := &EventTest{} e.Init(message) e.Address = e.NextAddress() e.Name = e.NextString() - OnTestWasmLibTest(e) + h.test(e) } diff --git a/contracts/wasm/testwasmlib/go/testwasmlibclient/service.go b/contracts/wasm/testwasmlib/go/testwasmlibclient/service.go index 60b4dbd9fb..c770434319 100644 --- a/contracts/wasm/testwasmlib/go/testwasmlibclient/service.go +++ b/contracts/wasm/testwasmlib/go/testwasmlibclient/service.go @@ -464,10 +464,14 @@ type TestWasmLibService struct { func NewTestWasmLibService(cl *wasmclient.ServiceClient, chainID string) (*TestWasmLibService, error) { s := &TestWasmLibService{} - err := s.Service.Init(cl, chainID, 0x89703a45, EventHandlers) + err := s.Service.Init(cl, chainID, 0x89703a45) return s, err } +func (s *TestWasmLibService) NewEventHandler() *TestWasmLibEvents { + return &TestWasmLibEvents{} +} + func (s *TestWasmLibService) ArrayClear() ArrayClearFunc { return ArrayClearFunc{ClientFunc: s.AsClientFunc()} } diff --git a/contracts/wasm/testwasmlib/test/testwasmlib_client_test.go b/contracts/wasm/testwasmlib/test/testwasmlib_client_test.go index f96da7f4b4..b41677eed6 100644 --- a/contracts/wasm/testwasmlib/test/testwasmlib_client_test.go +++ b/contracts/wasm/testwasmlib/test/testwasmlib_client_test.go @@ -15,7 +15,7 @@ import ( // the contract has already been deployed in some way, so // these values are usually available from elsewhere const ( - myChainID = "tRA59jhoDG9QpXi7NcQ3phuQaaPqgXRBgXxK2Sy1FPGf" + myChainID = "pDtVgzXtTwc2B9bnrf2RbpWuexynqNiGU7waLknsgjWf" mySeed = "6C6tRksZDWeDTCzX4Q7R2hbpyFV86cSGLVxdkFKSB3sv" ) @@ -40,6 +40,11 @@ func setupClient(t *testing.T) *testwasmlibclient.TestWasmLibService { func TestClientEvents(t *testing.T) { svc := setupClient(t) + events := svc.NewEventHandler() + events.OnTestWasmLibTest(func(e *testwasmlibclient.EventTest) { + fmt.Printf("Name is %s\n", e.Name) + }) + svc.Register(events) // get new triggerEvent interface, pass params, and post the request f := svc.TriggerEvent() @@ -48,8 +53,8 @@ func TestClientEvents(t *testing.T) { req1 := f.Post() require.NoError(t, req1.Error()) - // err := svc.WaitRequest(req1) - // require.NoError(t, err) + err := svc.WaitRequest(req1) + require.NoError(t, err) // get new triggerEvent interface, pass params, and post the request f = svc.TriggerEvent() @@ -58,7 +63,7 @@ func TestClientEvents(t *testing.T) { req2 := f.Post() require.NoError(t, req2.Error()) - err := svc.WaitRequest(req2) + err = svc.WaitRequest(req2) require.NoError(t, err) } diff --git a/contracts/wasm/testwasmlib/ts/testwasmlibclient/events.ts b/contracts/wasm/testwasmlib/ts/testwasmlibclient/events.ts index 668b2a0ef5..e08edc7a31 100644 --- a/contracts/wasm/testwasmlib/ts/testwasmlibclient/events.ts +++ b/contracts/wasm/testwasmlib/ts/testwasmlibclient/events.ts @@ -7,21 +7,22 @@ import * as wasmclient from "wasmclient" -type TestWasmLibHandlers = Map void>; +const testWasmLibHandlers = new Map void>([ + ["testwasmlib.test", (evt: TestWasmLibEvents, msg: string[]) => evt.test(new EventTest(msg))], +]); export class TestWasmLibEvents implements wasmclient.IEventHandler { - private eventHandlers: TestWasmLibHandlers = new Map([ - ["testwasmlib.test", (evt: TestWasmLibEvents, msg: string[]) => evt.onTestWasmLibTest(new EventTest(msg))], - ]); + test: (EventTest) => void = () => {}; public callHandler(topic: string, params: string[]): void { - const handler = this.eventHandlers.get(topic); + const handler = testWasmLibHandlers.get(topic); if (handler !== undefined) { handler(this, params); } } - public onTestWasmLibTest(event: EventTest): void { + public onTestWasmLibTest(handler: (EventTest) => void): void { + this.test = handler; } } diff --git a/contracts/wasm/testwasmlib/ts/testwasmlibclient/service.ts b/contracts/wasm/testwasmlib/ts/testwasmlibclient/service.ts index cffde6f794..58e3f5982b 100644 --- a/contracts/wasm/testwasmlib/ts/testwasmlibclient/service.ts +++ b/contracts/wasm/testwasmlib/ts/testwasmlibclient/service.ts @@ -442,7 +442,11 @@ export class MapValueResults extends wasmclient.Results { export class TestWasmLibService extends wasmclient.Service { public constructor(cl: wasmclient.ServiceClient) { - super(cl, 0x89703a45, events.eventHandlers); + super(cl, 0x89703a45); + } + + public newEventHandler(): events.TestWasmLibEvents { + return new events.TestWasmLibEvents(); } public arrayClear(): ArrayClearFunc { diff --git a/packages/vm/wasmlib/go/wasmclient/coreaccounts/service.go b/packages/vm/wasmlib/go/wasmclient/coreaccounts/service.go index 269b5a35ed..9cae8217e0 100644 --- a/packages/vm/wasmlib/go/wasmclient/coreaccounts/service.go +++ b/packages/vm/wasmlib/go/wasmclient/coreaccounts/service.go @@ -171,7 +171,7 @@ type CoreAccountsService struct { func NewCoreAccountsService(cl *wasmclient.ServiceClient, chainID string) (*CoreAccountsService, error) { s := &CoreAccountsService{} - err := s.Service.Init(cl, chainID, 0x3c4b5e02, nil) + err := s.Service.Init(cl, chainID, 0x3c4b5e02) return s, err } diff --git a/packages/vm/wasmlib/go/wasmclient/coreblob/service.go b/packages/vm/wasmlib/go/wasmclient/coreblob/service.go index 208046b63e..337132ad48 100644 --- a/packages/vm/wasmlib/go/wasmclient/coreblob/service.go +++ b/packages/vm/wasmlib/go/wasmclient/coreblob/service.go @@ -124,7 +124,7 @@ type CoreBlobService struct { func NewCoreBlobService(cl *wasmclient.ServiceClient, chainID string) (*CoreBlobService, error) { s := &CoreBlobService{} - err := s.Service.Init(cl, chainID, 0xfd91bc63, nil) + err := s.Service.Init(cl, chainID, 0xfd91bc63) return s, err } diff --git a/packages/vm/wasmlib/go/wasmclient/coreblocklog/service.go b/packages/vm/wasmlib/go/wasmclient/coreblocklog/service.go index ff8101b85f..99fce49453 100644 --- a/packages/vm/wasmlib/go/wasmclient/coreblocklog/service.go +++ b/packages/vm/wasmlib/go/wasmclient/coreblocklog/service.go @@ -301,7 +301,7 @@ type CoreBlockLogService struct { func NewCoreBlockLogService(cl *wasmclient.ServiceClient, chainID string) (*CoreBlockLogService, error) { s := &CoreBlockLogService{} - err := s.Service.Init(cl, chainID, 0xf538ef2b, nil) + err := s.Service.Init(cl, chainID, 0xf538ef2b) return s, err } diff --git a/packages/vm/wasmlib/go/wasmclient/coregovernance/service.go b/packages/vm/wasmlib/go/wasmclient/coregovernance/service.go index a3f5add5f3..921306a07b 100644 --- a/packages/vm/wasmlib/go/wasmclient/coregovernance/service.go +++ b/packages/vm/wasmlib/go/wasmclient/coregovernance/service.go @@ -321,7 +321,7 @@ type CoreGovernanceService struct { func NewCoreGovernanceService(cl *wasmclient.ServiceClient, chainID string) (*CoreGovernanceService, error) { s := &CoreGovernanceService{} - err := s.Service.Init(cl, chainID, 0x17cf909f, nil) + err := s.Service.Init(cl, chainID, 0x17cf909f) return s, err } diff --git a/packages/vm/wasmlib/go/wasmclient/coreroot/service.go b/packages/vm/wasmlib/go/wasmclient/coreroot/service.go index 735d0e0968..5b1cf896b7 100644 --- a/packages/vm/wasmlib/go/wasmclient/coreroot/service.go +++ b/packages/vm/wasmlib/go/wasmclient/coreroot/service.go @@ -138,7 +138,7 @@ type CoreRootService struct { func NewCoreRootService(cl *wasmclient.ServiceClient, chainID string) (*CoreRootService, error) { s := &CoreRootService{} - err := s.Service.Init(cl, chainID, 0xcebf5908, nil) + err := s.Service.Init(cl, chainID, 0xcebf5908) return s, err } diff --git a/packages/vm/wasmlib/go/wasmclient/service.go b/packages/vm/wasmlib/go/wasmclient/service.go index fbd0a6778b..57937b25f2 100644 --- a/packages/vm/wasmlib/go/wasmclient/service.go +++ b/packages/vm/wasmlib/go/wasmclient/service.go @@ -36,25 +36,26 @@ func (m ResMap) Get(key string) []byte { return m[kv.Key(key)] } +type IEventHandler interface { + CallHandler(topic string, params []string) +} + type Service struct { - chainID *iscp.ChainID - keyPair *ed25519.KeyPair - scHname iscp.Hname - waspClient *client.WaspClient + chainID *iscp.ChainID + eventHandlers []IEventHandler + keyPair *ed25519.KeyPair + scHname iscp.Hname + waspClient *client.WaspClient } -func (s *Service) Init(svcClient *ServiceClient, chainID string, scHname uint32, eventHandlers map[string]func([]string)) (err error) { +func (s *Service) Init(svcClient *ServiceClient, chainID string, scHname uint32) (err error) { s.waspClient = svcClient.waspClient s.scHname = iscp.Hname(scHname) s.chainID, err = iscp.ChainIDFromString(chainID) if err != nil { return err } - if len(eventHandlers) != 0 { - // TODO allow user to specify event handlers for core contracts? - return s.startEventHandlers(svcClient.eventPort, eventHandlers) - } - return nil + return s.startEventHandlers(svcClient.eventPort) } func (s *Service) AsClientFunc() ClientFunc { @@ -103,6 +104,15 @@ func (s *Service) postRequestOnLedger(hFuncName uint32, args requestargs.Request return Request{} } +func (s *Service) Register(handler IEventHandler) { + for _, h := range s.eventHandlers { + if h == handler { + return + } + } + s.eventHandlers = append(s.eventHandlers, handler) +} + // overrides default contract name func (s *Service) ServiceContractName(contractName string) { s.scHname = iscp.Hn(contractName) @@ -112,11 +122,20 @@ func (s *Service) SignRequests(keyPair *ed25519.KeyPair) { s.keyPair = keyPair } +func (s *Service) Unegister(handler IEventHandler) { + for i, h := range s.eventHandlers { + if h == handler { + s.eventHandlers = append(s.eventHandlers[:i], s.eventHandlers[i+1:]...) + return + } + } +} + func (s *Service) WaitRequest(req Request) error { return s.waspClient.WaitUntilRequestProcessed(s.chainID, *req.id, 1*time.Minute) } -func (s *Service) startEventHandlers(eventPort string, handlers map[string]func([]string)) error { +func (s *Service) startEventHandlers(eventPort string) error { chMsg := make(chan []string, 20) chDone := make(chan bool) err := subscribe.Subscribe(eventPort, chMsg, chDone, true, "") @@ -130,9 +149,10 @@ func (s *Service) startEventHandlers(eventPort string, handlers map[string]func( fmt.Printf("%s\n", event) if msgSplit[0] == "vmmsg" { msg := strings.Split(msgSplit[3], "|") - handler, ok := handlers[msg[0]] - if ok { - handler(msg[1:]) + topic := msg[0] + params := msg[1:] + for _, handler := range s.eventHandlers { + handler.CallHandler(topic, params) } } } diff --git a/packages/vm/wasmlib/ts/wasmclient/coreaccounts/service.ts b/packages/vm/wasmlib/ts/wasmclient/coreaccounts/service.ts index a3a39405b0..b09a886d92 100644 --- a/packages/vm/wasmlib/ts/wasmclient/coreaccounts/service.ts +++ b/packages/vm/wasmlib/ts/wasmclient/coreaccounts/service.ts @@ -6,6 +6,7 @@ // Change the json schema instead import * as wasmclient from "wasmclient" +import * as events from "./events" const ArgAgentID = "a"; const ArgWithdrawAmount = "m"; @@ -157,7 +158,11 @@ export class TotalAssetsResults extends wasmclient.Results { export class CoreAccountsService extends wasmclient.Service { public constructor(cl: wasmclient.ServiceClient) { - super(cl, 0x3c4b5e02, new Map()); + super(cl, 0x3c4b5e02); + } + + public newEventHandlers(): events.CoreAccountsEvents { + return new events.CoreAccountsEvents(); } public deposit(): DepositFunc { diff --git a/packages/vm/wasmlib/ts/wasmclient/coreblob/service.ts b/packages/vm/wasmlib/ts/wasmclient/coreblob/service.ts index 265fe35f9e..d1b3609991 100644 --- a/packages/vm/wasmlib/ts/wasmclient/coreblob/service.ts +++ b/packages/vm/wasmlib/ts/wasmclient/coreblob/service.ts @@ -6,6 +6,7 @@ // Change the json schema instead import * as wasmclient from "wasmclient" +import * as events from "./events" const ArgBlobs = "this"; const ArgField = "field"; @@ -120,7 +121,11 @@ export class ListBlobsResults extends wasmclient.Results { export class CoreBlobService extends wasmclient.Service { public constructor(cl: wasmclient.ServiceClient) { - super(cl, 0xfd91bc63, new Map()); + super(cl, 0xfd91bc63); + } + + public newEventHandlers(): events.CoreBlobEvents { + return new events.CoreBlobEvents(); } public storeBlob(): StoreBlobFunc { diff --git a/packages/vm/wasmlib/ts/wasmclient/coreblocklog/service.ts b/packages/vm/wasmlib/ts/wasmclient/coreblocklog/service.ts index abe2db5dc9..77c80ccbbf 100644 --- a/packages/vm/wasmlib/ts/wasmclient/coreblocklog/service.ts +++ b/packages/vm/wasmlib/ts/wasmclient/coreblocklog/service.ts @@ -6,6 +6,7 @@ // Change the json schema instead import * as wasmclient from "wasmclient" +import * as events from "./events" const ArgBlockIndex = "n"; const ArgContractHname = "h"; @@ -284,7 +285,11 @@ export class IsRequestProcessedResults extends wasmclient.Results { export class CoreBlockLogService extends wasmclient.Service { public constructor(cl: wasmclient.ServiceClient) { - super(cl, 0xf538ef2b, new Map()); + super(cl, 0xf538ef2b); + } + + public newEventHandlers(): events.CoreBlockLogEvents { + return new events.CoreBlockLogEvents(); } public controlAddresses(): ControlAddressesView { diff --git a/packages/vm/wasmlib/ts/wasmclient/coregovernance/service.ts b/packages/vm/wasmlib/ts/wasmclient/coregovernance/service.ts index f30da2d644..138f8bfa1b 100644 --- a/packages/vm/wasmlib/ts/wasmclient/coregovernance/service.ts +++ b/packages/vm/wasmlib/ts/wasmclient/coregovernance/service.ts @@ -6,6 +6,7 @@ // Change the json schema instead import * as wasmclient from "wasmclient" +import * as events from "./events" const ArgChainOwner = "oi"; const ArgFeeColor = "fc"; @@ -302,7 +303,11 @@ export class GetMaxBlobSizeResults extends wasmclient.Results { export class CoreGovernanceService extends wasmclient.Service { public constructor(cl: wasmclient.ServiceClient) { - super(cl, 0x17cf909f, new Map()); + super(cl, 0x17cf909f); + } + + public newEventHandlers(): events.CoreGovernanceEvents { + return new events.CoreGovernanceEvents(); } public addAllowedStateControllerAddress(): AddAllowedStateControllerAddressFunc { diff --git a/packages/vm/wasmlib/ts/wasmclient/coreroot/service.ts b/packages/vm/wasmlib/ts/wasmclient/coreroot/service.ts index b00ab43f67..bc46ac0c16 100644 --- a/packages/vm/wasmlib/ts/wasmclient/coreroot/service.ts +++ b/packages/vm/wasmlib/ts/wasmclient/coreroot/service.ts @@ -6,6 +6,7 @@ // Change the json schema instead import * as wasmclient from "wasmclient" +import * as events from "./events" const ArgDeployer = "dp"; const ArgDescription = "ds"; @@ -126,7 +127,11 @@ export class GetContractRecordsResults extends wasmclient.Results { export class CoreRootService extends wasmclient.Service { public constructor(cl: wasmclient.ServiceClient) { - super(cl, 0xcebf5908, new Map()); + super(cl, 0xcebf5908); + } + + public newEventHandlers(): events.CoreRootEvents { + return new events.CoreRootEvents(); } public deployContract(): DeployContractFunc { diff --git a/packages/vm/wasmlib/ts/wasmclient/service.ts b/packages/vm/wasmlib/ts/wasmclient/service.ts index 53fb557d29..92b15f39b5 100644 --- a/packages/vm/wasmlib/ts/wasmclient/service.ts +++ b/packages/vm/wasmlib/ts/wasmclient/service.ts @@ -63,6 +63,11 @@ export class Service { } public register(handler: IEventHandler): void { + for (let i = 0; i < this.eventHandlers.length; i++) { + if (this.eventHandlers[i] === handler) { + return; + } + } this.eventHandlers.push(handler); } diff --git a/tools/schema/generator/goclienttemplates/events.go b/tools/schema/generator/goclienttemplates/events.go index 670f829b5a..efc5279c42 100644 --- a/tools/schema/generator/goclienttemplates/events.go +++ b/tools/schema/generator/goclienttemplates/events.go @@ -5,21 +5,37 @@ var eventsGo = map[string]string{ "events.go": ` $#emit clientHeader -var EventHandlers = map[string]func([]string) { -$#each events funcSignature +var $pkgName$+Handlers = map[string]func(*$PkgName$+Events, []string) { $#each events eventHandler } + +type $PkgName$+Events struct { +$#each events eventHandlerMember +} + +func (h *$PkgName$+Events) CallHandler(topic string, params []string) { + handler := $pkgName$+Handlers[topic] + if handler != nil { + handler(h, params) + } +} +$#each events funcSignature $#each events eventClass +`, + // ******************************* + "eventHandlerMember": ` + $evtName func(e *Event$EvtName) `, // ******************************* "funcSignature": ` -func On$PkgName$EvtName(event *Event$EvtName) { +func (h *$PkgName$+Events) On$PkgName$EvtName(handler func(e *Event$EvtName)) { + h.$evtName = handler } `, // ******************************* "eventHandler": ` - "$package.$evtName": on$PkgName$EvtName$+Thunk, + "$package.$evtName": func(evt *$PkgName$+Events, msg []string) { evt.on$PkgName$EvtName$+Thunk(msg) }, `, // ******************************* "eventClass": ` @@ -29,11 +45,14 @@ type Event$EvtName struct { $#each event eventClassField } -func on$PkgName$EvtName$+Thunk(message []string) { +func (h *$PkgName$+Events) on$PkgName$EvtName$+Thunk(message []string) { + if h.$evtName == nil { + return + } e := &Event$EvtName{} e.Init(message) $#each event eventHandlerField - On$PkgName$EvtName(e) + h.$evtName(e) } `, // ******************************* diff --git a/tools/schema/generator/goclienttemplates/service.go b/tools/schema/generator/goclienttemplates/service.go index 9dc96e37d6..84cdeb8713 100644 --- a/tools/schema/generator/goclienttemplates/service.go +++ b/tools/schema/generator/goclienttemplates/service.go @@ -20,16 +20,11 @@ type $PkgName$+Service struct { func New$PkgName$+Service(cl *wasmclient.ServiceClient, chainID string) (*$PkgName$+Service, error) { s := &$PkgName$+Service{} -$#set eventHandlers EventHandlers -$#if core noEventHandlers - err := s.Service.Init(cl, chainID, 0x$hscName, $eventHandlers) + err := s.Service.Init(cl, chainID, 0x$hscName) return s, err } +$#if events newEventHandler $#each func serviceFunction -`, - // ******************************* - "noEventHandlers": ` -$#set eventHandlers nil `, // ******************************* "constArg": ` @@ -38,6 +33,13 @@ $#set eventHandlers nil // ******************************* "constRes": ` Res$FldName = "$fldAlias" +`, + // ******************************* + "newEventHandler": ` + +func (s *$PkgName$+Service) NewEventHandler() *$PkgName$+Events { + return &$PkgName$+Events{} +} `, // ******************************* "funcStruct": ` diff --git a/tools/schema/generator/tsclienttemplates/events.go b/tools/schema/generator/tsclienttemplates/events.go index ee04379ede..d6f83fef30 100644 --- a/tools/schema/generator/tsclienttemplates/events.go +++ b/tools/schema/generator/tsclienttemplates/events.go @@ -5,15 +5,15 @@ var eventsTs = map[string]string{ "events.ts": ` $#emit importWasmLib -type $PkgName$+Handlers = Map void>; +const $pkgName$+Handlers = new Map void>([ +$#each events eventHandler +]); export class $PkgName$+Events implements wasmclient.IEventHandler { - private eventHandlers: $PkgName$+Handlers = new Map([ -$#each events eventHandler - ]); +$#each events eventHandlerMember public callHandler(topic: string, params: string[]): void { - const handler = this.eventHandlers.get(topic); + const handler = $pkgName$+Handlers.get(topic); if (handler !== undefined) { handler(this, params); } @@ -24,12 +24,17 @@ $#each events eventClass `, // ******************************* "eventHandler": ` - ["$package.$evtName", (evt: $PkgName$+Events, msg: string[]) => evt.on$PkgName$EvtName(new Event$EvtName(msg))], + ["$package.$evtName", (evt: $PkgName$+Events, msg: string[]) => evt.$evtName(new Event$EvtName(msg))], +`, + // ******************************* + "eventHandlerMember": ` + $evtName: (Event$EvtName) => void = () => {}; `, // ******************************* "funcSignature": ` - public on$PkgName$EvtName(event: Event$EvtName): void { + public on$PkgName$EvtName(handler: (Event$EvtName) => void): void { + this.$evtName = handler; } `, // ******************************* diff --git a/tools/schema/generator/tsclienttemplates/service.go b/tools/schema/generator/tsclienttemplates/service.go index e27327d93d..7efd103e7f 100644 --- a/tools/schema/generator/tsclienttemplates/service.go +++ b/tools/schema/generator/tsclienttemplates/service.go @@ -4,7 +4,7 @@ var serviceTs = map[string]string{ // ******************************* "service.ts": ` $#emit importWasmLib -$#if core else importEvents +$#if events importEvents $#each params constArg @@ -16,16 +16,11 @@ $#each func funcStruct export class $PkgName$+Service extends wasmclient.Service { public constructor(cl: wasmclient.ServiceClient) { -$#set eventHandlers events.eventHandlers -$#if core noEventHandlers - super(cl, 0x$hscName, $eventHandlers); + super(cl, 0x$hscName); } +$#if events newEventHandler $#each func serviceFunction } -`, - // ******************************* - "noEventHandlers": ` -$#set eventHandlers new Map() `, // ******************************* "constArg": ` @@ -34,6 +29,13 @@ const Arg$FldName = "$fldAlias"; // ******************************* "constRes": ` const Res$FldName = "$fldAlias"; +`, + // ******************************* + "newEventHandler": ` + + public newEventHandler(): events.$PkgName$+Events { + return new events.$PkgName$+Events(); + } `, // ******************************* "funcStruct": ` From 05654f4d30e12ef063ef18e9ba511ae588db15b0 Mon Sep 17 00:00:00 2001 From: Eric Hop Date: Thu, 13 Jan 2022 07:29:48 -0800 Subject: [PATCH 005/111] removed obsolete reference in index --- packages/vm/wasmlib/ts/wasmclient/index.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/vm/wasmlib/ts/wasmclient/index.ts b/packages/vm/wasmlib/ts/wasmclient/index.ts index 83ed0405c6..d09441a314 100644 --- a/packages/vm/wasmlib/ts/wasmclient/index.ts +++ b/packages/vm/wasmlib/ts/wasmclient/index.ts @@ -7,7 +7,6 @@ export * from "./clientview"; export * from "./decoder"; export * from "./encoder"; export * from "./event"; -export * from "./eventhandler"; export * from "./results"; export * from "./service"; export * from "./serviceclient"; From 135bc258a6c3e62edb2aebf575a66a138277a9b8 Mon Sep 17 00:00:00 2001 From: Eric Hop Date: Thu, 13 Jan 2022 11:24:23 -0800 Subject: [PATCH 006/111] Remove events artifact from TS core contracts --- packages/vm/wasmlib/ts/wasmclient/coreaccounts/service.ts | 5 ----- packages/vm/wasmlib/ts/wasmclient/coreblob/service.ts | 5 ----- packages/vm/wasmlib/ts/wasmclient/coreblocklog/service.ts | 5 ----- packages/vm/wasmlib/ts/wasmclient/coregovernance/service.ts | 5 ----- packages/vm/wasmlib/ts/wasmclient/coreroot/service.ts | 5 ----- 5 files changed, 25 deletions(-) diff --git a/packages/vm/wasmlib/ts/wasmclient/coreaccounts/service.ts b/packages/vm/wasmlib/ts/wasmclient/coreaccounts/service.ts index b09a886d92..57a728ea96 100644 --- a/packages/vm/wasmlib/ts/wasmclient/coreaccounts/service.ts +++ b/packages/vm/wasmlib/ts/wasmclient/coreaccounts/service.ts @@ -6,7 +6,6 @@ // Change the json schema instead import * as wasmclient from "wasmclient" -import * as events from "./events" const ArgAgentID = "a"; const ArgWithdrawAmount = "m"; @@ -161,10 +160,6 @@ export class CoreAccountsService extends wasmclient.Service { super(cl, 0x3c4b5e02); } - public newEventHandlers(): events.CoreAccountsEvents { - return new events.CoreAccountsEvents(); - } - public deposit(): DepositFunc { return new DepositFunc(this); } diff --git a/packages/vm/wasmlib/ts/wasmclient/coreblob/service.ts b/packages/vm/wasmlib/ts/wasmclient/coreblob/service.ts index d1b3609991..e49aea04be 100644 --- a/packages/vm/wasmlib/ts/wasmclient/coreblob/service.ts +++ b/packages/vm/wasmlib/ts/wasmclient/coreblob/service.ts @@ -6,7 +6,6 @@ // Change the json schema instead import * as wasmclient from "wasmclient" -import * as events from "./events" const ArgBlobs = "this"; const ArgField = "field"; @@ -124,10 +123,6 @@ export class CoreBlobService extends wasmclient.Service { super(cl, 0xfd91bc63); } - public newEventHandlers(): events.CoreBlobEvents { - return new events.CoreBlobEvents(); - } - public storeBlob(): StoreBlobFunc { return new StoreBlobFunc(this); } diff --git a/packages/vm/wasmlib/ts/wasmclient/coreblocklog/service.ts b/packages/vm/wasmlib/ts/wasmclient/coreblocklog/service.ts index 77c80ccbbf..71dd2c889c 100644 --- a/packages/vm/wasmlib/ts/wasmclient/coreblocklog/service.ts +++ b/packages/vm/wasmlib/ts/wasmclient/coreblocklog/service.ts @@ -6,7 +6,6 @@ // Change the json schema instead import * as wasmclient from "wasmclient" -import * as events from "./events" const ArgBlockIndex = "n"; const ArgContractHname = "h"; @@ -288,10 +287,6 @@ export class CoreBlockLogService extends wasmclient.Service { super(cl, 0xf538ef2b); } - public newEventHandlers(): events.CoreBlockLogEvents { - return new events.CoreBlockLogEvents(); - } - public controlAddresses(): ControlAddressesView { return new ControlAddressesView(this); } diff --git a/packages/vm/wasmlib/ts/wasmclient/coregovernance/service.ts b/packages/vm/wasmlib/ts/wasmclient/coregovernance/service.ts index 138f8bfa1b..6c1c87bb33 100644 --- a/packages/vm/wasmlib/ts/wasmclient/coregovernance/service.ts +++ b/packages/vm/wasmlib/ts/wasmclient/coregovernance/service.ts @@ -6,7 +6,6 @@ // Change the json schema instead import * as wasmclient from "wasmclient" -import * as events from "./events" const ArgChainOwner = "oi"; const ArgFeeColor = "fc"; @@ -306,10 +305,6 @@ export class CoreGovernanceService extends wasmclient.Service { super(cl, 0x17cf909f); } - public newEventHandlers(): events.CoreGovernanceEvents { - return new events.CoreGovernanceEvents(); - } - public addAllowedStateControllerAddress(): AddAllowedStateControllerAddressFunc { return new AddAllowedStateControllerAddressFunc(this); } diff --git a/packages/vm/wasmlib/ts/wasmclient/coreroot/service.ts b/packages/vm/wasmlib/ts/wasmclient/coreroot/service.ts index bc46ac0c16..d38b2318f4 100644 --- a/packages/vm/wasmlib/ts/wasmclient/coreroot/service.ts +++ b/packages/vm/wasmlib/ts/wasmclient/coreroot/service.ts @@ -6,7 +6,6 @@ // Change the json schema instead import * as wasmclient from "wasmclient" -import * as events from "./events" const ArgDeployer = "dp"; const ArgDescription = "ds"; @@ -130,10 +129,6 @@ export class CoreRootService extends wasmclient.Service { super(cl, 0xcebf5908); } - public newEventHandlers(): events.CoreRootEvents { - return new events.CoreRootEvents(); - } - public deployContract(): DeployContractFunc { return new DeployContractFunc(this); } From ab9e827602cd32021e3c65fe14ba5725de48c892 Mon Sep 17 00:00:00 2001 From: Eric Hop Date: Thu, 13 Jan 2022 14:52:36 -0800 Subject: [PATCH 007/111] Allow empty transfers --- packages/vm/wasmproc/sctransfer.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/vm/wasmproc/sctransfer.go b/packages/vm/wasmproc/sctransfer.go index 30ff36e3c4..980ba13d10 100644 --- a/packages/vm/wasmproc/sctransfer.go +++ b/packages/vm/wasmproc/sctransfer.go @@ -60,8 +60,10 @@ func (o *ScTransferInfo) Invoke(balances int32) { transfer.Set(col, amount) return true }) - if !o.wc.ctx.Send(o.address, transfer, nil) { - o.Panicf("failed to send to %s", o.address.Base58()) + if len(transfer) != 0 { + if !o.wc.ctx.Send(o.address, transfer, nil) { + o.Panicf("failed to send to %s", o.address.Base58()) + } } } From ab9cbac5d3348d74b6dc77a8057712dbecc0ca87 Mon Sep 17 00:00:00 2001 From: "Bruno A. dos Santos" Date: Sat, 15 Jan 2022 06:56:17 +0100 Subject: [PATCH 008/111] strict compiler options conformity --- packages/vm/wasmlib/ts/wasmclient/results.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/vm/wasmlib/ts/wasmclient/results.ts b/packages/vm/wasmlib/ts/wasmclient/results.ts index 0472c92112..fdcde72012 100644 --- a/packages/vm/wasmlib/ts/wasmclient/results.ts +++ b/packages/vm/wasmlib/ts/wasmclient/results.ts @@ -13,7 +13,7 @@ export class Results extends wasmclient.Decoder { protected forEach(keyValue: (key: Buffer, val: Buffer) => void): void { this.res.forEach((val, key) => { - let keyBuf = this.keys.get(key); + const keyBuf = this.keys.get(key); if (keyBuf === undefined) { wasmclient.panic("missing key"); return; From d6b3e3b8759e2a09cf882ff85f60184b76b44e70 Mon Sep 17 00:00:00 2001 From: shawkyz Date: Sat, 15 Jan 2022 14:17:46 +0100 Subject: [PATCH 009/111] explictly import type Encoder to use as base class --- .../vm/wasmlib/ts/wasmclient/arguments.ts | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/packages/vm/wasmlib/ts/wasmclient/arguments.ts b/packages/vm/wasmlib/ts/wasmclient/arguments.ts index b181bde558..ee877e4b7b 100644 --- a/packages/vm/wasmlib/ts/wasmclient/arguments.ts +++ b/packages/vm/wasmlib/ts/wasmclient/arguments.ts @@ -1,30 +1,30 @@ // Copyright 2020 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 -import * as wasmclient from "./index" +import {Bytes, Int32, panic, Items, Item} from "." +import {Encoder} from "./encoder" import {Buffer} from "./buffer"; // The Arguments struct is used to gather all arguments for this smart // contract function call and encode it into this deterministic byte array -export class Arguments extends wasmclient.Encoder { - private args = new Map(); - +export class Arguments extends Encoder { + private args = new Map(); // get(key: string): wasmclient.Bytes { // const bytes = this.args.get(key); // return bytes ?? Buffer.alloc(0); // } - public set(key: string, val: wasmclient.Bytes): void { + public set(key: string, val: Bytes): void { this.args.set(key, val); } - public indexedKey(key: string, index: wasmclient.Int32): string { + public indexedKey(key: string, index: Int32): string { return key + "." + index.toString(); } public mandatory(key: string): void { if (!this.args.has(key)) { - wasmclient.panic("missing mandatory " + key) + panic("missing mandatory " + key) } } @@ -34,7 +34,7 @@ export class Arguments extends wasmclient.Encoder { // be 100% deterministic). Then emit the 4-byte argument count. // Next for each argument emit the 2-byte key length, the key prepended // with the minus sign, the 4-byte value length, and then the value bytes. - public encode(): wasmclient.Bytes { + public encode(): Bytes { const keys = new Array(); for (const key of this.args.keys()) { keys.push(key); @@ -58,12 +58,12 @@ export class Arguments extends wasmclient.Encoder { return buf; } - public encodeCall(): wasmclient.Items { - let items = new wasmclient.Items() + public encodeCall(): Items { + const items = new Items() for (const [key, val] of this.args) { const k = Buffer.from(key).toString("base64"); const v = val.toString("base64"); - items.Items.push(new wasmclient.Item(k, v)) + items.Items.push(new Item(k, v)) } return items; } From de2cf770889c7a4f4cde6368852a060ac81ec965 Mon Sep 17 00:00:00 2001 From: shawkyz Date: Sat, 15 Jan 2022 14:37:05 +0100 Subject: [PATCH 010/111] added missing semicolon --- tools/schema/generator/tsclienttemplates/events.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/schema/generator/tsclienttemplates/events.go b/tools/schema/generator/tsclienttemplates/events.go index d6f83fef30..238f809dbf 100644 --- a/tools/schema/generator/tsclienttemplates/events.go +++ b/tools/schema/generator/tsclienttemplates/events.go @@ -44,7 +44,7 @@ export class Event$EvtName extends wasmclient.Event { $#each event eventClassField public constructor(msg: string[]) { - super(msg) + super(msg); $#each event eventHandlerField } } From d8cc1dc409f41e1f4624a57fd7e6c80e73827bac Mon Sep 17 00:00:00 2001 From: shawkyz Date: Sat, 15 Jan 2022 14:37:33 +0100 Subject: [PATCH 011/111] added getIOTABalanceInChain --- .../wasmclient/goshimmer/goshimmerclient.ts | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/packages/vm/wasmlib/ts/wasmclient/goshimmer/goshimmerclient.ts b/packages/vm/wasmlib/ts/wasmclient/goshimmer/goshimmerclient.ts index 48aeb971e4..f9cdb6e109 100644 --- a/packages/vm/wasmlib/ts/wasmclient/goshimmer/goshimmerclient.ts +++ b/packages/vm/wasmlib/ts/wasmclient/goshimmer/goshimmerclient.ts @@ -171,12 +171,27 @@ export class GoShimmerClient { ); } - public async depositIOTAToAccountInChain(keypair: IKeyPair, destinationAgentID: AgentID, amount: bigint) { + public async depositIOTAToAccountInChain(keypair: IKeyPair, destinationAgentID: AgentID, amount: bigint): Promise { const depositfunc = this.coreAccountsService.deposit(); depositfunc.agentID(destinationAgentID); + depositfunc.onLedgerRequest(true); depositfunc.transfer(Transfer.iotas(amount)); depositfunc.sign(keypair); - depositfunc.onLedgerRequest(true); - await depositfunc.post(); + const depositRequestID = await depositfunc.post(); + const success = depositRequestID.length > 0; + return success; + } + + public async getIOTABalanceInChain(agentID: AgentID): Promise { + const balanceView = this.coreAccountsService.balance(); + balanceView.agentID(agentID); + const result = await balanceView.call(); + const balances = result.balances(); + const iotaBalance = balances.has(Colors.IOTA_COLOR_STRING) + ? balances.get(Colors.IOTA_COLOR_STRING)! + : balances.has(Colors.IOTA_COLOR) + ? balances.get(Colors.IOTA_COLOR)! + : 0n; + return iotaBalance; } } From a2cbadd3c57d2da236e1ede8e94b46828007e8c7 Mon Sep 17 00:00:00 2001 From: shawkyz Date: Sat, 15 Jan 2022 14:42:14 +0100 Subject: [PATCH 012/111] missing semicolon --- packages/vm/wasmlib/ts/wasmclient/service.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/vm/wasmlib/ts/wasmclient/service.ts b/packages/vm/wasmlib/ts/wasmclient/service.ts index 92b15f39b5..29d9cad572 100644 --- a/packages/vm/wasmlib/ts/wasmclient/service.ts +++ b/packages/vm/wasmlib/ts/wasmclient/service.ts @@ -78,7 +78,7 @@ export class Service { // overrides default contract name public serviceContractName(contractName: string): void { - this.scHname = Hash.from(Buffer.from(contractName)).readUInt32LE(0) + this.scHname = Hash.from(Buffer.from(contractName)).readUInt32LE(0); } public async waitRequest(reqID: wasmclient.RequestID): Promise { From 3635e3fddceed82197135dc50bd46ff445e46869 Mon Sep 17 00:00:00 2001 From: Eric Hop Date: Sat, 15 Jan 2022 18:02:23 -0800 Subject: [PATCH 013/111] New Wasm VM --- packages/vm/wasmhost/wasmvm.go | 65 +++++ packages/vm/wasmproc/sccontext.go | 52 +--- packages/vm/wasmproc/wasmcontext.go | 17 +- packages/vm/wasmproc/wasmtosandbox.go | 314 +++++++++++++++++++++ packages/vm/wasmproc/wasmtosandboxutils.go | 74 +++++ packages/vm/wasmvmhost/host.go | 85 +++++- 6 files changed, 558 insertions(+), 49 deletions(-) create mode 100644 packages/vm/wasmproc/wasmtosandbox.go create mode 100644 packages/vm/wasmproc/wasmtosandboxutils.go diff --git a/packages/vm/wasmhost/wasmvm.go b/packages/vm/wasmhost/wasmvm.go index 57055f451a..dc7e721b51 100644 --- a/packages/vm/wasmhost/wasmvm.go +++ b/packages/vm/wasmhost/wasmvm.go @@ -14,9 +14,11 @@ const ( defaultTimeout = 5 * time.Second FuncAbort = "abort" FuncFdWrite = "fd_write" + FuncHostGet = "hostGet" FuncHostGetBytes = "hostGetBytes" FuncHostGetKeyID = "hostGetKeyID" FuncHostGetObjectID = "hostGetObjectID" + FuncHostSet = "hostSet" FuncHostSetBytes = "hostSetBytes" ModuleEnv = "env" ModuleWasi1 = "wasi_unstable" @@ -52,9 +54,19 @@ type WasmVM interface { VMSetBytes(offset int32, size int32, bytes []byte) int32 } +// TODO implement this in WasmContext? +type SandboxContext interface { + CallSandbox(funcNr int32, params []byte) []byte + StateDelete(key []byte) + StateExists(key []byte) bool + StateGet(key []byte) []byte + StateSet(key []byte, value []byte) +} + type WasmVMBase struct { impl WasmVM host *WasmHost + ctx SandboxContext panicErr error result []byte resultKeyID int32 @@ -217,6 +229,59 @@ func (vm *WasmVMBase) HostSetBytes(objID, keyID, typeID, stringRef, size int32) host.SetBytes(objID, keyID, typeID, bytes) } +func (vm *WasmVMBase) HostStateGet(keyRef, keyLen, valRef, valLen int32) int32 { + defer vm.catchPanicMessage() + + host := vm.getKvStore(0) + host.TraceAllf("HostStateGet(k(%d,%d),v(%d,s%d))", keyRef, keyLen, valRef, valLen) + + // only check for existence ? + if valLen < 0 { + key := vm.impl.VMGetBytes(keyRef, keyLen) + if vm.ctx.StateExists(key) { + return 0 + } + // missing key is indicated by -1 + return -1 + } + + // get value for key request, or get cached result request (keyLen == 0) + if keyLen >= 0 { + if keyLen > 0 { + // retrieve value associated with key + key := vm.impl.VMGetBytes(keyRef, keyLen) + vm.result = vm.ctx.StateGet(key) + } + if vm.result == nil { + return -1 + } + return vm.impl.VMSetBytes(valRef, valLen, vm.result) + } + + // sandbox func call request, keyLen is func nr + params := vm.impl.VMGetBytes(valRef, valLen) + vm.result = vm.ctx.CallSandbox(keyLen, params) + return int32(len(vm.result)) +} + +func (vm *WasmVMBase) HostStateSet(keyRef, keyLen, valRef, valLen int32) { + defer vm.catchPanicMessage() + + host := vm.getKvStore(0) + host.TraceAllf("HostStateSet(k(%d,%d),v(%d,s%d))", keyRef, keyLen, valRef, valLen) + + key := vm.impl.VMGetBytes(keyRef, keyLen) + + // delete key ? + if valLen < 0 { + vm.ctx.StateDelete(key) + return + } + + value := vm.impl.VMGetBytes(valRef, valLen) + vm.ctx.StateSet(key, value) +} + func (vm *WasmVMBase) Instantiate() error { return errors.New("cannot be cloned") } diff --git a/packages/vm/wasmproc/sccontext.go b/packages/vm/wasmproc/sccontext.go index c0556303aa..9d7e1ad457 100644 --- a/packages/vm/wasmproc/sccontext.go +++ b/packages/vm/wasmproc/sccontext.go @@ -73,53 +73,27 @@ func (o *ScContext) GetBytes(keyID, typeID int32) []byte { if o.wc == nil { o.Panicf("missing context") } - ctx := o.wc.ctx - if ctx == nil { - return o.getBytesForView(keyID, typeID) - } switch keyID { + // common functionality case wasmhost.KeyAccountID: - return ctx.AccountID().Bytes() - case wasmhost.KeyCaller: - return ctx.Caller().Bytes() + return o.wc.common.AccountID().Bytes() case wasmhost.KeyChainID: - return ctx.ChainID().Bytes() + return o.wc.common.ChainID().Bytes() case wasmhost.KeyChainOwnerID: - return ctx.ChainOwnerID().Bytes() + return o.wc.common.ChainOwnerID().Bytes() case wasmhost.KeyContract: - return ctx.Contract().Bytes() + return o.wc.common.Contract().Bytes() case wasmhost.KeyContractCreator: - return ctx.ContractCreator().Bytes() + return o.wc.common.ContractCreator().Bytes() + case wasmhost.KeyTimestamp: + return codec.EncodeInt64(o.wc.common.GetTimestamp()) + // ctx-only functionality + case wasmhost.KeyCaller: + return o.wc.ctx.Caller().Bytes() case wasmhost.KeyRandom: - return ctx.GetEntropy().Bytes() + return o.wc.ctx.GetEntropy().Bytes() case wasmhost.KeyRequestID: - return ctx.Request().ID().Bytes() - case wasmhost.KeyTimestamp: - return codec.EncodeInt64(ctx.GetTimestamp()) - } - o.InvalidKey(keyID) - return nil -} - -//nolint:unparam -func (o *ScContext) getBytesForView(keyID, typeID int32) []byte { - ctx := o.wc.ctxView - if ctx == nil { - o.Panicf("missing context") - } - switch keyID { - case wasmhost.KeyAccountID: - return ctx.AccountID().Bytes() - case wasmhost.KeyChainID: - return ctx.ChainID().Bytes() - case wasmhost.KeyChainOwnerID: - return ctx.ChainOwnerID().Bytes() - case wasmhost.KeyContract: - return ctx.Contract().Bytes() - case wasmhost.KeyContractCreator: - return ctx.ContractCreator().Bytes() - case wasmhost.KeyTimestamp: - return codec.EncodeInt64(ctx.GetTimestamp()) + return o.wc.ctx.Request().ID().Bytes() } o.InvalidKey(keyID) return nil diff --git a/packages/vm/wasmproc/wasmcontext.go b/packages/vm/wasmproc/wasmcontext.go index 20b416e657..f11d4bf5b1 100644 --- a/packages/vm/wasmproc/wasmcontext.go +++ b/packages/vm/wasmproc/wasmcontext.go @@ -14,6 +14,7 @@ const ( type WasmContext struct { wasmhost.KvStoreHost + common iscp.SandboxBase ctx iscp.Sandbox ctxView iscp.SandboxView function string @@ -70,8 +71,12 @@ func (wc *WasmContext) Call(ctx interface{}) (dict.Dict, error) { switch tctx := ctx.(type) { case iscp.Sandbox: + wc.common = tctx wc.ctx = tctx + wc.ctxView = nil case iscp.SandboxView: + wc.common = tctx + wc.ctx = nil wc.ctxView = tctx default: panic(iscp.ErrWrongTypeEntryPoint) @@ -118,20 +123,14 @@ func (wc *WasmContext) IsView() bool { } func (wc *WasmContext) log() iscp.LogInterface { - if wc.ctx != nil { - return wc.ctx.Log() - } - if wc.ctxView != nil { - return wc.ctxView.Log() + if wc.common != nil { + return wc.common.Log() } return wc.proc.log } func (wc *WasmContext) params() dict.Dict { - if wc.ctx != nil { - return wc.ctx.Params() - } - return wc.ctxView.Params() + return wc.common.Params() } func (wc *WasmContext) state() kv.KVStore { diff --git a/packages/vm/wasmproc/wasmtosandbox.go b/packages/vm/wasmproc/wasmtosandbox.go new file mode 100644 index 0000000000..fb4b441242 --- /dev/null +++ b/packages/vm/wasmproc/wasmtosandbox.go @@ -0,0 +1,314 @@ +package wasmproc + +import ( + "time" + + "github.com/iotaledger/goshimmer/packages/ledgerstate" + "github.com/iotaledger/wasp/packages/hashing" + "github.com/iotaledger/wasp/packages/iscp" + "github.com/iotaledger/wasp/packages/iscp/colored" + "github.com/iotaledger/wasp/packages/kv/codec" + "github.com/iotaledger/wasp/packages/kv/dict" +) + +const ( + FnAccountID = int32(-1) + FnBalance = int32(-2) + FnBalances = int32(-3) + FnBlockContext = int32(-4) + FnCall = int32(-5) + FnCaller = int32(-6) + FnChainID = int32(-7) + FnChainOwnerID = int32(-8) + FnContract = int32(-9) + FnContractCreator = int32(-10) + FnDeployContract = int32(-11) + FnEvent = int32(-12) + FnGetEntropy = int32(-13) + FnGetTimestamp = int32(-14) + FnIncomingTransfer = int32(-15) + FnLog = int32(-16) + FnMinted = int32(-17) + FnParams = int32(-18) + FnRequest = int32(-19) + FnSend = int32(-20) + FnDebug = int32(-21) + FnStateAnchor = int32(-22) + FnPanic = int32(-23) + FnUtilsBase58Decode = int32(-24) + FnUtilsBase58Encode = int32(-25) + FnUtilsBlsAddress = int32(-26) + FnUtilsBlsAggregate = int32(-27) + FnUtilsBlsValid = int32(-28) + FnUtilsEd25519Address = int32(-29) + FnUtilsEd25519Valid = int32(-30) + FnUtilsHashBlake2b = int32(-31) + FnUtilsHashName = int32(-32) + FnUtilsHashSha3 = int32(-33) + + // FnColor = int32(-13) + // FnExports = int32(-20) + // FnLength = int32(-25) + // FnMaps = int32(-27) + // FnPanic = int32(-29) + // FnPost = int32(-31) + // FnRandom = int32(-32) + // FnResults = int32(-34) + // FnReturn = int32(-35) + // FnTrace = int32(-38) + // FnTransfers = int32(-39) +) + +var sandboxFunctions = []func(*WasmToSandbox, []byte) []byte{ + nil, + (*WasmToSandbox).fnAccountID, + (*WasmToSandbox).fnBalance, + (*WasmToSandbox).fnBalances, + (*WasmToSandbox).fnBlockContext, + (*WasmToSandbox).fnCall, + (*WasmToSandbox).fnCaller, + (*WasmToSandbox).fnChainID, + (*WasmToSandbox).fnChainOwnerID, + (*WasmToSandbox).fnContract, + (*WasmToSandbox).fnContractCreator, + (*WasmToSandbox).fnDeployContract, + (*WasmToSandbox).fnEvent, + (*WasmToSandbox).fnGetEntropy, + (*WasmToSandbox).fnGetTimestamp, + (*WasmToSandbox).fnIncomingTransfer, + (*WasmToSandbox).fnLog, + (*WasmToSandbox).fnMinted, + (*WasmToSandbox).fnParams, + (*WasmToSandbox).fnRequest, + (*WasmToSandbox).fnSend, + (*WasmToSandbox).fnDebug, + (*WasmToSandbox).fnStateAnchor, + (*WasmToSandbox).fnPanic, + (*WasmToSandbox).fnUtilsBase58Decode, + (*WasmToSandbox).fnUtilsBase58Encode, + (*WasmToSandbox).fnUtilsBlsAddress, + (*WasmToSandbox).fnUtilsBlsAggregate, + (*WasmToSandbox).fnUtilsBlsValid, + (*WasmToSandbox).fnUtilsEd25519Address, + (*WasmToSandbox).fnUtilsEd25519Valid, + (*WasmToSandbox).fnUtilsHashBlake2b, + (*WasmToSandbox).fnUtilsHashName, + (*WasmToSandbox).fnUtilsHashSha3, +} + +type WasmToSandbox struct { + common iscp.SandboxBase + ctx iscp.Sandbox + ctxView iscp.SandboxView + wc WasmContext +} + +func (f *WasmToSandbox) Call(funcNr int32, args []byte) []byte { + return sandboxFunctions[-funcNr](f, args) +} + +func (f *WasmToSandbox) checkErr(err error) { + if err != nil { + f.Panicf(err.Error()) + } +} + +func (f *WasmToSandbox) Panicf(format string, args ...interface{}) { + f.common.Log().Panicf(format, args...) +} + +//////////////////// sandbox functions \\\\\\\\\\\\\\\\\\\\ + +func (f *WasmToSandbox) fnAccountID(args []byte) []byte { + return f.common.AccountID().Bytes() +} + +func (f *WasmToSandbox) fnBalance(args []byte) []byte { + color, err := colored.ColorFromBytes(args) + f.checkErr(err) + return codec.EncodeUint64(f.ctx.Balance(color)) +} + +func (f *WasmToSandbox) fnBalances(args []byte) []byte { + return f.common.Balances().Bytes() +} + +func (f *WasmToSandbox) fnBlockContext(args []byte) []byte { + // TODO + return nil +} + +func (f *WasmToSandbox) fnCall(args []byte) []byte { + decode := NewBytesDecoder(args) + contract, err := iscp.HnameFromBytes(decode.Bytes()) + f.checkErr(err) + function, err := iscp.HnameFromBytes(decode.Bytes()) + f.checkErr(err) + params, err := dict.FromBytes(decode.Bytes()) + f.checkErr(err) + transfer, err := colored.BalancesFromBytes(decode.Bytes()) + f.checkErr(err) + // o.Tracef("CALL c'%s' f'%s'", contract.String(), function.String()) + results, err := f.callUnlocked(contract, function, params, transfer) + f.checkErr(err) + return results.Bytes() +} + +func (f *WasmToSandbox) callUnlocked(contract, function iscp.Hname, params dict.Dict, transfer colored.Balances) (dict.Dict, error) { + f.wc.proc.instanceLock.Unlock() + defer f.wc.proc.instanceLock.Lock() + + if f.ctx != nil { + return f.ctx.Call(contract, function, params, transfer) + } + return f.ctxView.Call(contract, function, params) +} + +func (f *WasmToSandbox) fnCaller(args []byte) []byte { + return f.ctx.Caller().Bytes() +} + +func (f *WasmToSandbox) fnChainID(args []byte) []byte { + return f.common.ChainID().Bytes() +} + +func (f *WasmToSandbox) fnChainOwnerID(args []byte) []byte { + return f.common.ChainOwnerID().Bytes() +} + +func (f *WasmToSandbox) fnContract(args []byte) []byte { + return f.common.Contract().Bytes() +} + +func (f *WasmToSandbox) fnContractCreator(args []byte) []byte { + return f.common.ContractCreator().Bytes() +} + +func (f *WasmToSandbox) fnDebug(args []byte) []byte { + f.common.Log().Debugf(string(args)) + return nil +} + +func (f *WasmToSandbox) fnDeployContract(args []byte) []byte { + decode := NewBytesDecoder(args) + programHash, err := hashing.HashValueFromBytes(decode.Bytes()) + f.checkErr(err) + name := string(decode.Bytes()) + description := string(decode.Bytes()) + params, err := dict.FromBytes(decode.Bytes()) + f.checkErr(err) + // o.Tracef("DEPLOY c'%s' f'%s'", name, description) + err = f.deployUnlocked(programHash, name, description, params) + f.checkErr(err) + return nil +} + +func (f *WasmToSandbox) deployUnlocked(programHash hashing.HashValue, name, description string, params dict.Dict) error { + f.wc.proc.instanceLock.Unlock() + defer f.wc.proc.instanceLock.Lock() + + return f.ctx.DeployContract(programHash, name, description, params) +} + +func (f *WasmToSandbox) fnEvent(args []byte) []byte { + f.ctx.Event(string(args)) + return nil +} + +func (f *WasmToSandbox) fnGetEntropy(args []byte) []byte { + return f.ctx.GetEntropy().Bytes() +} + +func (f *WasmToSandbox) fnGetTimestamp(args []byte) []byte { + return codec.EncodeInt64(f.common.GetTimestamp()) +} + +func (f *WasmToSandbox) fnIncomingTransfer(args []byte) []byte { + return f.ctx.IncomingTransfer().Bytes() +} + +func (f *WasmToSandbox) fnLog(args []byte) []byte { + f.common.Log().Infof(string(args)) + return nil +} + +func (f *WasmToSandbox) fnMinted(args []byte) []byte { + return f.ctx.Minted().Bytes() +} + +func (f *WasmToSandbox) fnPanic(args []byte) []byte { + f.common.Log().Panicf(string(args)) + return nil +} + +func (f *WasmToSandbox) fnParams(args []byte) []byte { + return f.common.Params().Bytes() +} + +func (f *WasmToSandbox) fnRequest(args []byte) []byte { + return f.ctx.Request().Bytes() +} + +// post request to SC +func (f *WasmToSandbox) fnPost(args []byte) []byte { + decode := NewBytesDecoder(args) + chainID, err := iscp.ChainIDFromBytes(decode.Bytes()) + f.checkErr(err) + contract, err := iscp.HnameFromBytes(decode.Bytes()) + f.checkErr(err) + function, err := iscp.HnameFromBytes(decode.Bytes()) + f.checkErr(err) + // o.Tracef("POST c'%s' f'%s'", contract.String(), function.String()) + params, err := dict.FromBytes(decode.Bytes()) + f.checkErr(err) + transfer, err := colored.BalancesFromBytes(decode.Bytes()) + f.checkErr(err) + if len(transfer) == 0 { + f.Panicf("transfer is required for post") + } + metadata := &iscp.SendMetadata{ + TargetContract: contract, + EntryPoint: function, + Args: params, + } + delay := decode.Int32() + if delay == 0 { + if !f.ctx.Send(chainID.AsAddress(), transfer, metadata) { + f.Panicf("failed to send to %s", chainID.AsAddress().String()) + } + return nil + } + + if delay < 0 { + f.Panicf("invalid delay: %d", delay) + } + + timeLock := time.Unix(0, f.ctx.GetTimestamp()) + timeLock = timeLock.Add(time.Duration(delay) * time.Second) + options := iscp.SendOptions{ + TimeLock: uint32(timeLock.Unix()), + } + if !f.ctx.Send(chainID.AsAddress(), transfer, metadata, options) { + f.Panicf("failed to send to %s", chainID.AsAddress().String()) + } + return nil +} + +// transfer tokens to address +func (f *WasmToSandbox) fnSend(args []byte) []byte { + decode := NewBytesDecoder(args) + address, _, err := ledgerstate.AddressFromBytes(decode.Bytes()) + f.checkErr(err) + transfer, err := colored.BalancesFromBytes(decode.Bytes()) + f.checkErr(err) + if len(transfer) != 0 { + if !f.ctx.Send(address, transfer, nil) { + f.Panicf("failed to send to %s", address.String()) + } + } + return nil +} + +func (f *WasmToSandbox) fnStateAnchor(args []byte) []byte { + return nil +} diff --git a/packages/vm/wasmproc/wasmtosandboxutils.go b/packages/vm/wasmproc/wasmtosandboxutils.go new file mode 100644 index 0000000000..cbedb9e951 --- /dev/null +++ b/packages/vm/wasmproc/wasmtosandboxutils.go @@ -0,0 +1,74 @@ +package wasmproc + +import ( + "github.com/iotaledger/wasp/packages/kv/codec" +) + +func (f WasmToSandbox) fnUtilsBase58Decode(args []byte) []byte { + bytes, err := f.common.Utils().Base58().Decode(string(args)) + f.checkErr(err) + return bytes +} + +func (f WasmToSandbox) fnUtilsBase58Encode(args []byte) []byte { + return []byte(f.common.Utils().Base58().Encode(args)) +} + +func (f WasmToSandbox) fnUtilsBlsAddress(args []byte) []byte { + address, err := f.common.Utils().BLS().AddressFromPublicKey(args) + f.checkErr(err) + return address.Bytes() +} + +func (f WasmToSandbox) fnUtilsBlsAggregate(args []byte) []byte { + decode := NewBytesDecoder(args) + count := int(decode.Int32()) + pubKeysBin := make([][]byte, count) + for i := 0; i < count; i++ { + pubKeysBin[i] = decode.Bytes() + } + count = int(decode.Int32()) + sigsBin := make([][]byte, count) + for i := 0; i < count; i++ { + sigsBin[i] = decode.Bytes() + } + pubKeyBin, sigBin, err := f.common.Utils().BLS().AggregateBLSSignatures(pubKeysBin, sigsBin) + f.checkErr(err) + return NewBytesEncoder().Bytes(pubKeyBin).Bytes(sigBin).Data() +} + +func (f WasmToSandbox) fnUtilsBlsValid(args []byte) []byte { + decode := NewBytesDecoder(args) + data := decode.Bytes() + pubKey := decode.Bytes() + signature := decode.Bytes() + valid := f.common.Utils().BLS().ValidSignature(data, pubKey, signature) + return codec.EncodeBool(valid) +} + +func (f WasmToSandbox) fnUtilsEd25519Address(args []byte) []byte { + address, err := f.common.Utils().ED25519().AddressFromPublicKey(args) + f.checkErr(err) + return address.Bytes() +} + +func (f WasmToSandbox) fnUtilsEd25519Valid(args []byte) []byte { + decode := NewBytesDecoder(args) + data := decode.Bytes() + pubKey := decode.Bytes() + signature := decode.Bytes() + valid := f.common.Utils().ED25519().ValidSignature(data, pubKey, signature) + return codec.EncodeBool(valid) +} + +func (f WasmToSandbox) fnUtilsHashBlake2b(args []byte) []byte { + return f.common.Utils().Hashing().Blake2b(args).Bytes() +} + +func (f WasmToSandbox) fnUtilsHashName(args []byte) []byte { + return codec.EncodeHname(f.common.Utils().Hashing().Hname(string(args))) +} + +func (f WasmToSandbox) fnUtilsHashSha3(args []byte) []byte { + return f.common.Utils().Hashing().Sha3(args).Bytes() +} diff --git a/packages/vm/wasmvmhost/host.go b/packages/vm/wasmvmhost/host.go index 9b48bed8fd..c26388453e 100644 --- a/packages/vm/wasmvmhost/host.go +++ b/packages/vm/wasmvmhost/host.go @@ -1,6 +1,7 @@ // Copyright 2020 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 +//go:build wasm // +build wasm package wasmvmhost @@ -25,7 +26,7 @@ func hostSetBytes(objID, keyID, typeID int32, value *byte, size int32) // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -type WasmVMHost struct{ +type WasmVMHost struct { funcs []wasmlib.ScFuncContextFunction views []wasmlib.ScViewContextFunction } @@ -140,3 +141,85 @@ func (w *WasmVMHost) SetBytes(objID, keyID, typeID int32, value []byte) { } hostSetBytes(objID, keyID, typeID, &value[0], size) } + +func (w *WasmVMHost) Sandbox(funcNr int32, params []byte) []byte { + // ¶ms[0] will panic on zero length slice, so use nil instead + par := []byte(nil) + size := int32(len(params)) + if size != 0 { + par = ¶ms[0] + } + + // call sandbox function, result value will be cached by host + // always negative funcNr as keyLen indicates sandbox call + // this removes the need for a separate hostSandbox function + size = hostStateGet(nil, funcNr, par, size) + + // zero length, no need to retrieve cached value + if size == 0 { + return []byte{} + } + + // retrieve cached result value from host + result := make([]byte, size) + _ = hostStateGet(nil, 0, &result, size) + return result +} + +func (w *WasmVMHost) StateDel(key []byte) { + // value size -1 means delete key + // this removes the need for a separate hostStateDel function + hostStateSet(&key[0], int32(len(key)), nil, -1) +} + +func (w *WasmVMHost) StateExists(key []byte) bool { + // value size -1 means only test for existence + // returned size -1 indicates keyID not found (or error) + // this removes the need for a separate hostStateExists function + return hostStateGet(&key[0], int32(len(key)), nil, -1) >= 0 +} + +func (w *WasmVMHost) StateGet(key []byte, value []byte) []byte { + size := int32(len(value)) + if size != 0 { + // size known in advance, just get the data + _ = hostStateGet(&key[0], int32(len(key)), &value, size) + return value + } + + // variable sized result expected, + // query size first by passing zero length buffer + // value will be cached by host + size = hostStateGet(&key[0], int32(len(key)), nil, 0) + + // -1 means non-existent + if size < 0 { + return []byte(nil) + } + + // zero length, no need to retrieve cached value + if size == 0 { + return []byte{} + } + + // retrieve cached value from host + value = make([]byte, size) + _ = hostStateGet(nil, 0, &value, size) + return value +} + +func (w *WasmVMHost) StateSet(key []byte, value []byte) { + // &value[0] will panic on zero length slice, so use nil instead + val := []byte(nil) + size := int32(len(value)) + if size != 0 { + val = &value[0] + } + hostStateSet(&key[0], int32(len(key)), val, size) +} + +func hostStateGet(key *byte, keyLen int32, val *byte, valLen int32) int32 { +} + +func hostStateSet(key *byte, keyLen int32, val *byte, valLen int32) { +} From 7e65abfe2e054b6408555e6c3ee5cc2226c570e6 Mon Sep 17 00:00:00 2001 From: shawkyz Date: Sun, 16 Jan 2022 20:58:37 +0100 Subject: [PATCH 014/111] move getIOTABalanceInChain to waspclient --- .../wasmclient/goshimmer/goshimmerclient.ts | 13 ------------- .../vm/wasmlib/ts/wasmclient/serviceclient.ts | 2 +- .../vm/wasmlib/ts/wasmclient/waspclient.ts | 19 ++++++++++++++++++- 3 files changed, 19 insertions(+), 15 deletions(-) diff --git a/packages/vm/wasmlib/ts/wasmclient/goshimmer/goshimmerclient.ts b/packages/vm/wasmlib/ts/wasmclient/goshimmer/goshimmerclient.ts index f9cdb6e109..f66c8be61c 100644 --- a/packages/vm/wasmlib/ts/wasmclient/goshimmer/goshimmerclient.ts +++ b/packages/vm/wasmlib/ts/wasmclient/goshimmer/goshimmerclient.ts @@ -181,17 +181,4 @@ export class GoShimmerClient { const success = depositRequestID.length > 0; return success; } - - public async getIOTABalanceInChain(agentID: AgentID): Promise { - const balanceView = this.coreAccountsService.balance(); - balanceView.agentID(agentID); - const result = await balanceView.call(); - const balances = result.balances(); - const iotaBalance = balances.has(Colors.IOTA_COLOR_STRING) - ? balances.get(Colors.IOTA_COLOR_STRING)! - : balances.has(Colors.IOTA_COLOR) - ? balances.get(Colors.IOTA_COLOR)! - : 0n; - return iotaBalance; - } } diff --git a/packages/vm/wasmlib/ts/wasmclient/serviceclient.ts b/packages/vm/wasmlib/ts/wasmclient/serviceclient.ts index 66e93df086..2bcb81a278 100644 --- a/packages/vm/wasmlib/ts/wasmclient/serviceclient.ts +++ b/packages/vm/wasmlib/ts/wasmclient/serviceclient.ts @@ -12,8 +12,8 @@ export class ServiceClient { constructor(configuration: Configuration) { this.configuration = configuration; - this.waspClient = new wasmclient.WaspClient(configuration.waspApiUrl); const accountsService = new CoreAccountsService(this); + this.waspClient = new wasmclient.WaspClient(configuration.waspApiUrl, accountsService); this.goShimmerClient = new wasmclient.GoShimmerClient(configuration, accountsService); } diff --git a/packages/vm/wasmlib/ts/wasmclient/waspclient.ts b/packages/vm/wasmlib/ts/wasmclient/waspclient.ts index 0e34996400..49c0067e13 100644 --- a/packages/vm/wasmlib/ts/wasmclient/waspclient.ts +++ b/packages/vm/wasmlib/ts/wasmclient/waspclient.ts @@ -6,6 +6,8 @@ import { Buffer } from "./buffer"; import { IResponse } from "./api_common/response_models"; import * as requestSender from "./api_common/request_sender"; import { Base58, ED25519, Hash, IKeyPair } from "./crypto"; +import { Colors } from "./colors"; +import { CoreAccountsService } from "./coreaccounts/service"; interface ICallViewResponse extends IResponse { Items: [{ Key: string; Value: string }]; @@ -31,10 +33,12 @@ export class Items { export class WaspClient { private waspAPI: string; + private coreAccountsService: CoreAccountsService; - constructor(waspAPI: string) { + constructor(waspAPI: string, coreAccountsService: CoreAccountsService) { if (waspAPI.startsWith("https://") || waspAPI.startsWith("http://")) this.waspAPI = waspAPI; else this.waspAPI = "http://" + waspAPI; + this.coreAccountsService = coreAccountsService; } public async callView(chainID: string, contractHName: string, entryPoint: string, args: Items, res: wasmclient.Results): Promise { @@ -89,4 +93,17 @@ export class WaspClient { return Base58.encode(requestID); } + + public async getIOTABalanceInChain(agentID: wasmclient.AgentID): Promise { + const balanceView = this.coreAccountsService.balance(); + balanceView.agentID(agentID); + const result = await balanceView.call(); + const balances = result.balances(); + const iotaBalance = balances.has(Colors.IOTA_COLOR_STRING) + ? balances.get(Colors.IOTA_COLOR_STRING)! + : balances.has(Colors.IOTA_COLOR) + ? balances.get(Colors.IOTA_COLOR)! + : 0n; + return iotaBalance; + } } From 128ed7535bf720fd8cd8c8c4f8055a633d60d801 Mon Sep 17 00:00:00 2001 From: Eric Hop Date: Sun, 16 Jan 2022 12:01:28 -0800 Subject: [PATCH 015/111] VM refactoring preparations --- packages/vm/wasmhost/kvstorehost.go | 20 +++ packages/vm/wasmhost/wasmedgevm.go | 29 ++- packages/vm/wasmhost/wasmervm.go | 24 ++- packages/vm/wasmhost/wasmtimevm.go | 10 ++ packages/vm/wasmhost/wasmvm.go | 4 +- packages/vm/wasmlib/go/wasmlib/host.go | 25 +++ packages/vm/wasmlib/go/wasmlib/inithost.go | 20 +++ packages/vm/wasmlib/go/wasmlib/sandbox.go | 169 ++++++++++++++++++ .../vm/wasmlib/go/wasmlib/sandboxtypes.go | 117 ++++++++++++ .../vm/wasmlib/go/wasmlib/sandboxutils.go | 59 ++++++ packages/vm/wasmproc/wasmtosandbox.go | 134 +++++++------- packages/vm/wasmproc/wasmtosandboxutils.go | 3 + packages/vm/wasmvmhost/host.go | 44 +++-- .../tsclienttemplates/alltemplates.go | 2 +- .../generator/tsclienttemplates/events.go | 2 +- .../generator/tsclienttemplates/index.go | 1 - .../generator/tsclienttemplates/service.go | 2 +- 17 files changed, 567 insertions(+), 98 deletions(-) create mode 100644 packages/vm/wasmlib/go/wasmlib/sandbox.go create mode 100644 packages/vm/wasmlib/go/wasmlib/sandboxtypes.go create mode 100644 packages/vm/wasmlib/go/wasmlib/sandboxutils.go diff --git a/packages/vm/wasmhost/kvstorehost.go b/packages/vm/wasmhost/kvstorehost.go index 98a2cd25da..b9f57f36c3 100644 --- a/packages/vm/wasmhost/kvstorehost.go +++ b/packages/vm/wasmhost/kvstorehost.go @@ -319,3 +319,23 @@ func (h *KvStoreHost) TypeCheck(typeID int32, bytes []byte) { } } } + +func (h *KvStoreHost) Sandbox(funcNr int32, params []byte) []byte { + panic("implement me") +} + +func (h *KvStoreHost) StateDelete(key []byte) { + panic("implement me") +} + +func (h *KvStoreHost) StateExists(key []byte) bool { + panic("implement me") +} + +func (h *KvStoreHost) StateGet(key []byte) []byte { + panic("implement me") +} + +func (h *KvStoreHost) StateSet(key, value []byte) { + panic("implement me") +} diff --git a/packages/vm/wasmhost/wasmedgevm.go b/packages/vm/wasmhost/wasmedgevm.go index d66ca04ba8..1a6388d091 100644 --- a/packages/vm/wasmhost/wasmedgevm.go +++ b/packages/vm/wasmhost/wasmedgevm.go @@ -13,7 +13,7 @@ import ( type WasmEdgeVM struct { WasmVMBase - edge *wasmedge.VM + edge *wasmedge.VM memory *wasmedge.Memory module *wasmedge.ImportObject store *wasmedge.Store @@ -67,9 +67,12 @@ func (vm *WasmEdgeVM) LinkHost(impl WasmVM, host *WasmHost) error { vm.importModule(ModuleWasmLib) vm.importFunc(5, 1, FuncHostGetBytes, vm.exportHostGetBytes) - vm.importFunc(2, 1,FuncHostGetKeyID, vm.exportHostGetKeyID) + vm.importFunc(2, 1, FuncHostGetKeyID, vm.exportHostGetKeyID) vm.importFunc(3, 1, FuncHostGetObjectID, vm.exportHostGetObjectID) vm.importFunc(5, 0, FuncHostSetBytes, vm.exportHostSetBytes) + + vm.importFunc(4, 1, FuncHostStateGet, vm.exportHostStateGet) + vm.importFunc(4, 0, FuncHostStateSet, vm.exportHostStateSet) err := vm.edge.RegisterImport(vm.module) if err != nil { return err @@ -121,7 +124,7 @@ func (vm *WasmEdgeVM) Instantiate() error { func (vm *WasmEdgeVM) RunFunction(functionName string, args ...interface{}) error { return vm.Run(func() (err error) { - _,err = vm.edge.Execute(functionName, args...) + _, err = vm.edge.Execute(functionName, args...) return err }) } @@ -131,7 +134,7 @@ func (vm *WasmEdgeVM) RunScFunction(index int32) error { defer vm.PostCall(frame) return vm.Run(func() (err error) { - _,err = vm.edge.Execute("on_call", index) + _, err = vm.edge.Execute("on_call", index) return err }) } @@ -215,3 +218,21 @@ func (vm *WasmEdgeVM) exportHostSetBytes(args []interface{}) []interface{} { vm.HostSetBytes(objID, keyID, typeID, stringRef, size) return nil } + +func (vm *WasmEdgeVM) exportHostStateGet(args []interface{}) []interface{} { + keyRef := args[0].(int32) + keyLen := args[1].(int32) + valRef := args[2].(int32) + valLen := args[3].(int32) + ret := vm.HostStateGet(keyRef, keyLen, valRef, valLen) + return []interface{}{ret} +} + +func (vm *WasmEdgeVM) exportHostStateSet(args []interface{}) []interface{} { + keyRef := args[0].(int32) + keyLen := args[1].(int32) + valRef := args[2].(int32) + valLen := args[3].(int32) + vm.HostStateSet(keyRef, keyLen, valRef, valLen) + return nil +} diff --git a/packages/vm/wasmhost/wasmervm.go b/packages/vm/wasmhost/wasmervm.go index 8afb66c419..d40639f39d 100644 --- a/packages/vm/wasmhost/wasmervm.go +++ b/packages/vm/wasmhost/wasmervm.go @@ -27,7 +27,7 @@ func NewWasmerVM() WasmVM { } func (vm *WasmerVM) NewInstance() WasmVM { - return &WasmerVM{ store: vm.store } + return &WasmerVM{store: vm.store} } //TODO @@ -44,6 +44,10 @@ func (vm *WasmerVM) LinkHost(impl WasmVM, host *WasmHost) error { FuncHostGetKeyID: vm.importFunc(2, 1, vm.exportHostGetKeyID), FuncHostGetObjectID: vm.importFunc(3, 1, vm.exportHostGetObjectID), FuncHostSetBytes: vm.importFunc(5, 0, vm.exportHostSetBytes), + + // new Wasm VM interface + FuncHostStateGet: vm.importFunc(4, 1, vm.exportHostStateGet), + FuncHostStateSet: vm.importFunc(4, 0, vm.exportHostStateSet), } vm.linker.Register(ModuleWasmLib, funcs) @@ -163,3 +167,21 @@ func (vm *WasmerVM) exportHostSetBytes(args []wasmer.Value) ([]wasmer.Value, err vm.HostSetBytes(objID, keyID, typeID, stringRef, size) return nil, nil } + +func (vm *WasmerVM) exportHostStateGet(args []wasmer.Value) ([]wasmer.Value, error) { + keyRef := args[0].I32() + keyLen := args[1].I32() + valRef := args[2].I32() + valLen := args[3].I32() + ret := vm.HostStateGet(keyRef, keyLen, valRef, valLen) + return []wasmer.Value{wasmer.NewI32(ret)}, nil +} + +func (vm *WasmerVM) exportHostStateSet(args []wasmer.Value) ([]wasmer.Value, error) { + keyRef := args[0].I32() + keyLen := args[1].I32() + valRef := args[2].I32() + valLen := args[3].I32() + vm.HostStateSet(keyRef, keyLen, valRef, valLen) + return nil, nil +} diff --git a/packages/vm/wasmhost/wasmtimevm.go b/packages/vm/wasmhost/wasmtimevm.go index 79ee641033..9dc9823c2d 100644 --- a/packages/vm/wasmhost/wasmtimevm.go +++ b/packages/vm/wasmhost/wasmtimevm.go @@ -63,6 +63,16 @@ func (vm *WasmTimeVM) LinkHost(impl WasmVM, host *WasmHost) (err error) { return err } + // new Wasm VM interface + err = vm.linker.DefineFunc(vm.store, ModuleWasmLib, FuncHostStateGet, vm.HostStateGet) + if err != nil { + return err + } + err = vm.linker.DefineFunc(vm.store, ModuleWasmLib, FuncHostStateSet, vm.HostStateSet) + if err != nil { + return err + } + // AssemblyScript Wasm versions uses this one to write panic message to console err = vm.linker.DefineFunc(vm.store, ModuleEnv, FuncAbort, vm.HostAbort) if err != nil { diff --git a/packages/vm/wasmhost/wasmvm.go b/packages/vm/wasmhost/wasmvm.go index dc7e721b51..487f895a2f 100644 --- a/packages/vm/wasmhost/wasmvm.go +++ b/packages/vm/wasmhost/wasmvm.go @@ -14,12 +14,12 @@ const ( defaultTimeout = 5 * time.Second FuncAbort = "abort" FuncFdWrite = "fd_write" - FuncHostGet = "hostGet" FuncHostGetBytes = "hostGetBytes" FuncHostGetKeyID = "hostGetKeyID" FuncHostGetObjectID = "hostGetObjectID" - FuncHostSet = "hostSet" FuncHostSetBytes = "hostSetBytes" + FuncHostStateGet = "hostStateGet" + FuncHostStateSet = "hostStateSet" ModuleEnv = "env" ModuleWasi1 = "wasi_unstable" ModuleWasi2 = "wasi_snapshot_preview1" diff --git a/packages/vm/wasmlib/go/wasmlib/host.go b/packages/vm/wasmlib/go/wasmlib/host.go index 8955e1401a..8927bd0919 100644 --- a/packages/vm/wasmlib/go/wasmlib/host.go +++ b/packages/vm/wasmlib/go/wasmlib/host.go @@ -53,6 +53,11 @@ type ( GetKeyIDFromString(key string) int32 GetObjectID(objID, keyID, typeID int32) int32 SetBytes(objID, keyID, typeID int32, value []byte) + Sandbox(funcNr int32, params []byte) []byte + StateDelete(key []byte) + StateExists(key []byte) bool + StateGet(key []byte) []byte + StateSet(key, value []byte) } ) @@ -136,3 +141,23 @@ func SetBytes(objID int32, keyID Key32, typeID int32, value []byte) { func Trace(text string) { SetBytes(1, KeyTrace, TYPE_STRING, []byte(text)) } + +func Sandbox(funcNr int32, params []byte) []byte { + return host.Sandbox(funcNr, params) +} + +func StateDelete(key []byte) { + host.StateDelete(key) +} + +func StateExists(key []byte) bool { + return host.StateExists(key) +} + +func StateGet(key []byte) []byte { + return host.StateGet(key) +} + +func StateSet(key, value []byte) { + host.StateSet(key, value) +} diff --git a/packages/vm/wasmlib/go/wasmlib/inithost.go b/packages/vm/wasmlib/go/wasmlib/inithost.go index 8b34c0b1fa..764cb92561 100644 --- a/packages/vm/wasmlib/go/wasmlib/inithost.go +++ b/packages/vm/wasmlib/go/wasmlib/inithost.go @@ -89,3 +89,23 @@ func (h InitHost) SetBytes(objID, keyID, typeID int32, value []byte) { } Panic("InitHost::SetBytes") } + +func (h InitHost) Sandbox(funcNr int32, params []byte) []byte { + panic("implement me") +} + +func (h InitHost) StateDelete(key []byte) { + panic("implement me") +} + +func (h InitHost) StateExists(key []byte) bool { + panic("implement me") +} + +func (h InitHost) StateGet(key []byte) []byte { + panic("implement me") +} + +func (h InitHost) StateSet(key, value []byte) { + panic("implement me") +} diff --git a/packages/vm/wasmlib/go/wasmlib/sandbox.go b/packages/vm/wasmlib/go/wasmlib/sandbox.go new file mode 100644 index 0000000000..a62f79d601 --- /dev/null +++ b/packages/vm/wasmlib/go/wasmlib/sandbox.go @@ -0,0 +1,169 @@ +// Copyright 2020 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +package wasmlib + +import ( + "github.com/iotaledger/wasp/packages/iscp" +) + +const ( + FnAccountID = int32(-1) + FnBalance = int32(-2) + FnBalances = int32(-3) + FnBlockContext = int32(-4) + FnCall = int32(-5) + FnCaller = int32(-6) + FnChainID = int32(-7) + FnChainOwnerID = int32(-8) + FnContract = int32(-9) + FnContractCreator = int32(-10) + FnDeployContract = int32(-11) + FnEntropy = int32(-12) + FnEvent = int32(-13) + FnIncomingTransfer = int32(-14) + FnLog = int32(-15) + FnMinted = int32(-16) + FnPanic = int32(-17) + FnParams = int32(-18) + FnPost = int32(-19) + FnRequest = int32(-20) + FnRequestID = int32(-21) + FnSend = int32(-22) + FnStateAnchor = int32(-23) + FnTimestamp = int32(-24) + FnTrace = int32(-25) + FnUtilsBase58Decode = int32(-26) + FnUtilsBase58Encode = int32(-27) + FnUtilsBlsAddress = int32(-28) + FnUtilsBlsAggregate = int32(-29) + FnUtilsBlsValid = int32(-30) + FnUtilsEd25519Address = int32(-31) + FnUtilsEd25519Valid = int32(-32) + FnUtilsHashBlake2b = int32(-33) + FnUtilsHashName = int32(-34) + FnUtilsHashSha3 = int32(-35) + FnZzzLastItem = int32(-36) +) + +type ScSandbox struct{} + +func (s ScSandbox) AccountID() ScAgentID { + return NewScAgentIDFromBytes(Sandbox(FnAccountID, nil)) +} + +func (s ScSandbox) Balance(color ScColor) uint64 { + return NewUint64FromBytes(Sandbox(FnBalance, color.Bytes())) +} + +func (s ScSandbox) Balances() ScAssets { + return NewScAssetsFromBytes(Sandbox(FnBalances, nil)) +} + +func (s ScSandbox) BlockContext(construct func(sandbox iscp.Sandbox) interface{}, onClose func(interface{})) interface{} { + panic("implement me") +} + +func (s ScSandbox) Call(contract, function ScHname, params ScDict, transfer ScAssets) ScDict { + enc := NewBytesEncoder() + enc.Hname(contract) + enc.Hname(function) + enc.Bytes(params.Bytes()) + enc.Bytes(transfer.Bytes()) + return NewScDictFromBytes(Sandbox(FnCall, enc.Data())) +} + +func (s ScSandbox) Caller() ScAgentID { + return NewScAgentIDFromBytes(Sandbox(FnCaller, nil)) +} + +func (s ScSandbox) ChainID() ScChainID { + return NewScChainIDFromBytes(Sandbox(FnChainID, nil)) +} + +func (s ScSandbox) ChainOwnerID() ScAgentID { + return NewScAgentIDFromBytes(Sandbox(FnChainOwnerID, nil)) +} + +func (s ScSandbox) Contract() ScHname { + return NewScHnameFromBytes(Sandbox(FnContract, nil)) +} + +func (s ScSandbox) ContractCreator() ScAgentID { + return NewScAgentIDFromBytes(Sandbox(FnContractCreator, nil)) +} + +func (s ScSandbox) DeployContract(programHash ScHash, name, description string, initParams ScDict) { + enc := NewBytesEncoder() + enc.Hash(programHash) + enc.String(name) + enc.String(description) + enc.Bytes(initParams.Bytes()) + Sandbox(FnDeployContract, enc.Data()) +} + +func (s ScSandbox) Entropy() ScHash { + return NewScHashFromBytes(Sandbox(FnEntropy, nil)) +} + +func (s ScSandbox) Event(msg string) { + Sandbox(FnEvent, []byte(msg)) +} + +func (s ScSandbox) IncomingTransfer() ScAssets { + return NewScAssetsFromBytes(Sandbox(FnIncomingTransfer, nil)) +} + +func (s ScSandbox) Log(text string) { + Sandbox(FnLog, []byte(text)) +} + +func (s ScSandbox) Minted() ScAssets { + return NewScAssetsFromBytes(Sandbox(FnMinted, nil)) +} + +func (s ScSandbox) Panic(text string) { + Sandbox(FnPanic, []byte(text)) +} + +func (s ScSandbox) Params() ScDict { + return NewScDictFromBytes(Sandbox(FnParams, nil)) +} + +func (s ScSandbox) Post(chainID ScChainID, contract, function ScHname, params ScDict, transfer ScAssets, delay uint32) { + enc := NewBytesEncoder() + enc.ChainID(chainID) + enc.Hname(contract) + enc.Hname(function) + enc.Bytes(params.Bytes()) + enc.Bytes(transfer.Bytes()) + enc.Uint32(delay) + Sandbox(FnSend, enc.Data()) +} + +//func (s ScSandbox) Request() ScRequest { +// panic("implement me") +//} + +func (s ScSandbox) RequestID() ScRequestID { + return NewScRequestIDFromBytes(Sandbox(FnRequestID, nil)) +} + +func (s ScSandbox) Send(target ScAddress, tokens ScAssets) { + enc := NewBytesEncoder() + enc.Address(target) + enc.Bytes(tokens.Bytes()) + Sandbox(FnSend, enc.Data()) +} + +func (s ScSandbox) StateAnchor() iscp.StateAnchor { + panic("implement me") +} + +func (s ScSandbox) Timestamp() int64 { + return NewInt64FromBytes(Sandbox(FnTimestamp, nil)) +} + +func (s ScSandbox) Trace(text string) { + Sandbox(FnTrace, []byte(text)) +} diff --git a/packages/vm/wasmlib/go/wasmlib/sandboxtypes.go b/packages/vm/wasmlib/go/wasmlib/sandboxtypes.go new file mode 100644 index 0000000000..15500f125c --- /dev/null +++ b/packages/vm/wasmlib/go/wasmlib/sandboxtypes.go @@ -0,0 +1,117 @@ +// Copyright 2020 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +package wasmlib + +import ( + "encoding/binary" + "sort" +) + +type ScAssets map[ScColor]uint64 + +func NewScAssetsFromBytes(buf []byte) ScAssets { + dict := make(ScAssets) + size := NewUint32FromBytes(buf[:4]) + buf = buf[4:] + for i := uint32(0); i < size; i++ { + k := buf[:32] + buf = buf[32:] + v := NewUint64FromBytes(buf[:8]) + buf = buf[8:] + dict[NewScColorFromBytes(k)] = v + } + return dict +} + +func (a ScAssets) Bytes() []byte { + keys := make([]ScColor, 0, len(a)) + for key := range a { + keys = append(keys, key) + } + sort.Slice(keys, func(i, j int) bool { + return string(keys[i].id[:]) < string(keys[j].id[:]) + }) + buf := make([]byte, 4) + binary.LittleEndian.PutUint32(buf, uint32(len(keys))) + for _, k := range keys { + v := a[k] + val := make([]byte, 8) + binary.LittleEndian.PutUint64(val, v) + buf = append(buf, k.Bytes()...) + buf = append(buf, val...) + } + return buf +} + +type ScDict map[string][]byte + +func NewScDictFromBytes(buf []byte) ScDict { + dict := make(ScDict) + size := NewUint32FromBytes(buf[:4]) + buf = buf[4:] + for i := uint32(0); i < size; i++ { + k := NewUint16FromBytes(buf[:2]) + buf = buf[2:] + key := buf[:k] + buf = buf[k:] + v := NewUint32FromBytes(buf[:4]) + buf = buf[4:] + val := buf[:v] + buf = buf[v:] + dict[string(key)] = val + } + return dict +} + +func (d ScDict) Bytes() []byte { + keys := make([]string, 0, len(d)) + for key := range d { + keys = append(keys, key) + } + sort.Slice(keys, func(i, j int) bool { + return keys[i] < keys[j] + }) + buf := make([]byte, 4) + binary.LittleEndian.PutUint32(buf, uint32(len(keys))) + for _, k := range keys { + v := d[k] + keyLen := make([]byte, 2) + binary.LittleEndian.PutUint16(keyLen, uint16(len(k))) + valLen := make([]byte, 4) + binary.LittleEndian.PutUint32(valLen, uint32(len(v))) + buf = append(buf, keyLen...) + buf = append(buf, []byte(k)...) + buf = append(buf, valLen...) + buf = append(buf, v...) + } + return buf +} + +func NewBoolFromBytes(bytes []byte) bool { + return bytes[0] != 0 +} + +func NewInt16FromBytes(bytes []byte) int16 { + return int16(binary.LittleEndian.Uint16(bytes)) +} + +func NewInt32FromBytes(bytes []byte) int32 { + return int32(binary.LittleEndian.Uint32(bytes)) +} + +func NewInt64FromBytes(bytes []byte) int64 { + return int64(binary.LittleEndian.Uint64(bytes)) +} + +func NewUint16FromBytes(bytes []byte) uint16 { + return binary.LittleEndian.Uint16(bytes) +} + +func NewUint32FromBytes(bytes []byte) uint32 { + return binary.LittleEndian.Uint32(bytes) +} + +func NewUint64FromBytes(bytes []byte) uint64 { + return binary.LittleEndian.Uint64(bytes) +} diff --git a/packages/vm/wasmlib/go/wasmlib/sandboxutils.go b/packages/vm/wasmlib/go/wasmlib/sandboxutils.go new file mode 100644 index 0000000000..4c1328fa0b --- /dev/null +++ b/packages/vm/wasmlib/go/wasmlib/sandboxutils.go @@ -0,0 +1,59 @@ +// Copyright 2020 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +package wasmlib + +type ScSandboxUtils struct{} + +func (u ScSandboxUtils) Base58Decode(value string) []byte { + return Sandbox(FnUtilsBase58Decode, []byte(value)) +} + +func (u ScSandboxUtils) Base58Encode(bytes []byte) string { + return string(Sandbox(FnUtilsBase58Encode, bytes)) +} + +func (u ScSandboxUtils) BlsAddress(pubKey []byte) ScAddress { + return NewScAddressFromBytes(Sandbox(FnUtilsBlsAddress, pubKey)) +} + +func (u ScSandboxUtils) BlsAggregate(pubKeys, sigs [][]byte) ([]byte, []byte) { + encode := NewBytesEncoder() + encode.Int32(int32(len(pubKeys))) + for _, pubKey := range pubKeys { + encode.Bytes(pubKey) + } + encode.Int32(int32(len(sigs))) + for _, sig := range sigs { + encode.Bytes(sig) + } + result := Sandbox(FnUtilsBlsAggregate, encode.Data()) + decode := NewBytesDecoder(result) + return decode.Bytes(), decode.Bytes() +} + +func (u ScSandboxUtils) BlsValid(data, pubKey, signature []byte) bool { + encode := NewBytesEncoder().Bytes(data).Bytes(pubKey).Bytes(signature) + return NewBoolFromBytes(Sandbox(FnUtilsBlsValid, encode.Data())) +} + +func (u ScSandboxUtils) Ed25519Address(pubKey []byte) ScAddress { + return NewScAddressFromBytes(Sandbox(FnUtilsEd25519Address, pubKey)) +} + +func (u ScSandboxUtils) Ed25519Valid(data, pubKey, signature []byte) bool { + encode := NewBytesEncoder().Bytes(data).Bytes(pubKey).Bytes(signature) + return NewBoolFromBytes(Sandbox(FnUtilsEd25519Valid, encode.Data())) +} + +func (u ScSandboxUtils) HashBlake2b(value []byte) ScHash { + return NewScHashFromBytes(Sandbox(FnUtilsHashBlake2b, value)) +} + +func (u ScSandboxUtils) HashName(value string) ScHname { + return NewScHnameFromBytes(Sandbox(FnUtilsHashName, []byte(value))) +} + +func (u ScSandboxUtils) HashSha3(value []byte) ScHash { + return NewScHashFromBytes(Sandbox(FnUtilsHashSha3, value)) +} diff --git a/packages/vm/wasmproc/wasmtosandbox.go b/packages/vm/wasmproc/wasmtosandbox.go index fb4b441242..e445a77688 100644 --- a/packages/vm/wasmproc/wasmtosandbox.go +++ b/packages/vm/wasmproc/wasmtosandbox.go @@ -1,3 +1,6 @@ +// Copyright 2020 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + package wasmproc import ( @@ -23,43 +26,34 @@ const ( FnContract = int32(-9) FnContractCreator = int32(-10) FnDeployContract = int32(-11) - FnEvent = int32(-12) - FnGetEntropy = int32(-13) - FnGetTimestamp = int32(-14) - FnIncomingTransfer = int32(-15) - FnLog = int32(-16) - FnMinted = int32(-17) + FnEntropy = int32(-12) + FnEvent = int32(-13) + FnIncomingTransfer = int32(-14) + FnLog = int32(-15) + FnMinted = int32(-16) + FnPanic = int32(-17) FnParams = int32(-18) - FnRequest = int32(-19) - FnSend = int32(-20) - FnDebug = int32(-21) - FnStateAnchor = int32(-22) - FnPanic = int32(-23) - FnUtilsBase58Decode = int32(-24) - FnUtilsBase58Encode = int32(-25) - FnUtilsBlsAddress = int32(-26) - FnUtilsBlsAggregate = int32(-27) - FnUtilsBlsValid = int32(-28) - FnUtilsEd25519Address = int32(-29) - FnUtilsEd25519Valid = int32(-30) - FnUtilsHashBlake2b = int32(-31) - FnUtilsHashName = int32(-32) - FnUtilsHashSha3 = int32(-33) - - // FnColor = int32(-13) - // FnExports = int32(-20) - // FnLength = int32(-25) - // FnMaps = int32(-27) - // FnPanic = int32(-29) - // FnPost = int32(-31) - // FnRandom = int32(-32) - // FnResults = int32(-34) - // FnReturn = int32(-35) - // FnTrace = int32(-38) - // FnTransfers = int32(-39) + FnPost = int32(-19) + FnRequest = int32(-20) + FnRequestID = int32(-21) + FnSend = int32(-22) + FnStateAnchor = int32(-23) + FnTimestamp = int32(-24) + FnTrace = int32(-25) + FnUtilsBase58Decode = int32(-26) + FnUtilsBase58Encode = int32(-27) + FnUtilsBlsAddress = int32(-28) + FnUtilsBlsAggregate = int32(-29) + FnUtilsBlsValid = int32(-30) + FnUtilsEd25519Address = int32(-31) + FnUtilsEd25519Valid = int32(-32) + FnUtilsHashBlake2b = int32(-33) + FnUtilsHashName = int32(-34) + FnUtilsHashSha3 = int32(-35) + FnZzzLastItem = int32(-36) ) -var sandboxFunctions = []func(*WasmToSandbox, []byte) []byte{ +var sandboxFunctions = [-FnZzzLastItem]func(*WasmToSandbox, []byte) []byte{ nil, (*WasmToSandbox).fnAccountID, (*WasmToSandbox).fnBalance, @@ -72,18 +66,20 @@ var sandboxFunctions = []func(*WasmToSandbox, []byte) []byte{ (*WasmToSandbox).fnContract, (*WasmToSandbox).fnContractCreator, (*WasmToSandbox).fnDeployContract, + (*WasmToSandbox).fnEntropy, (*WasmToSandbox).fnEvent, - (*WasmToSandbox).fnGetEntropy, - (*WasmToSandbox).fnGetTimestamp, (*WasmToSandbox).fnIncomingTransfer, (*WasmToSandbox).fnLog, (*WasmToSandbox).fnMinted, + (*WasmToSandbox).fnPanic, (*WasmToSandbox).fnParams, + (*WasmToSandbox).fnPost, (*WasmToSandbox).fnRequest, + (*WasmToSandbox).fnRequestID, (*WasmToSandbox).fnSend, - (*WasmToSandbox).fnDebug, (*WasmToSandbox).fnStateAnchor, - (*WasmToSandbox).fnPanic, + (*WasmToSandbox).fnTimestamp, + (*WasmToSandbox).fnTrace, (*WasmToSandbox).fnUtilsBase58Decode, (*WasmToSandbox).fnUtilsBase58Encode, (*WasmToSandbox).fnUtilsBlsAddress, @@ -117,6 +113,10 @@ func (f *WasmToSandbox) Panicf(format string, args ...interface{}) { f.common.Log().Panicf(format, args...) } +func (f *WasmToSandbox) Tracef(format string, args ...interface{}) { + f.common.Log().Debugf(format, args...) +} + //////////////////// sandbox functions \\\\\\\\\\\\\\\\\\\\ func (f *WasmToSandbox) fnAccountID(args []byte) []byte { @@ -134,8 +134,7 @@ func (f *WasmToSandbox) fnBalances(args []byte) []byte { } func (f *WasmToSandbox) fnBlockContext(args []byte) []byte { - // TODO - return nil + panic("implement me") } func (f *WasmToSandbox) fnCall(args []byte) []byte { @@ -148,7 +147,7 @@ func (f *WasmToSandbox) fnCall(args []byte) []byte { f.checkErr(err) transfer, err := colored.BalancesFromBytes(decode.Bytes()) f.checkErr(err) - // o.Tracef("CALL c'%s' f'%s'", contract.String(), function.String()) + f.Tracef("CALL c'%s' f'%s'", contract.String(), function.String()) results, err := f.callUnlocked(contract, function, params, transfer) f.checkErr(err) return results.Bytes() @@ -184,21 +183,16 @@ func (f *WasmToSandbox) fnContractCreator(args []byte) []byte { return f.common.ContractCreator().Bytes() } -func (f *WasmToSandbox) fnDebug(args []byte) []byte { - f.common.Log().Debugf(string(args)) - return nil -} - func (f *WasmToSandbox) fnDeployContract(args []byte) []byte { decode := NewBytesDecoder(args) programHash, err := hashing.HashValueFromBytes(decode.Bytes()) f.checkErr(err) name := string(decode.Bytes()) description := string(decode.Bytes()) - params, err := dict.FromBytes(decode.Bytes()) + initParams, err := dict.FromBytes(decode.Bytes()) f.checkErr(err) - // o.Tracef("DEPLOY c'%s' f'%s'", name, description) - err = f.deployUnlocked(programHash, name, description, params) + f.Tracef("DEPLOY c'%s' f'%s'", name, description) + err = f.deployUnlocked(programHash, name, description, initParams) f.checkErr(err) return nil } @@ -210,17 +204,13 @@ func (f *WasmToSandbox) deployUnlocked(programHash hashing.HashValue, name, desc return f.ctx.DeployContract(programHash, name, description, params) } -func (f *WasmToSandbox) fnEvent(args []byte) []byte { - f.ctx.Event(string(args)) - return nil -} - -func (f *WasmToSandbox) fnGetEntropy(args []byte) []byte { +func (f *WasmToSandbox) fnEntropy(args []byte) []byte { return f.ctx.GetEntropy().Bytes() } -func (f *WasmToSandbox) fnGetTimestamp(args []byte) []byte { - return codec.EncodeInt64(f.common.GetTimestamp()) +func (f *WasmToSandbox) fnEvent(args []byte) []byte { + f.ctx.Event(string(args)) + return nil } func (f *WasmToSandbox) fnIncomingTransfer(args []byte) []byte { @@ -245,11 +235,6 @@ func (f *WasmToSandbox) fnParams(args []byte) []byte { return f.common.Params().Bytes() } -func (f *WasmToSandbox) fnRequest(args []byte) []byte { - return f.ctx.Request().Bytes() -} - -// post request to SC func (f *WasmToSandbox) fnPost(args []byte) []byte { decode := NewBytesDecoder(args) chainID, err := iscp.ChainIDFromBytes(decode.Bytes()) @@ -258,7 +243,7 @@ func (f *WasmToSandbox) fnPost(args []byte) []byte { f.checkErr(err) function, err := iscp.HnameFromBytes(decode.Bytes()) f.checkErr(err) - // o.Tracef("POST c'%s' f'%s'", contract.String(), function.String()) + f.Tracef("POST c'%s' f'%s'", contract.String(), function.String()) params, err := dict.FromBytes(decode.Bytes()) f.checkErr(err) transfer, err := colored.BalancesFromBytes(decode.Bytes()) @@ -271,7 +256,7 @@ func (f *WasmToSandbox) fnPost(args []byte) []byte { EntryPoint: function, Args: params, } - delay := decode.Int32() + delay := decode.Uint32() if delay == 0 { if !f.ctx.Send(chainID.AsAddress(), transfer, metadata) { f.Panicf("failed to send to %s", chainID.AsAddress().String()) @@ -279,10 +264,6 @@ func (f *WasmToSandbox) fnPost(args []byte) []byte { return nil } - if delay < 0 { - f.Panicf("invalid delay: %d", delay) - } - timeLock := time.Unix(0, f.ctx.GetTimestamp()) timeLock = timeLock.Add(time.Duration(delay) * time.Second) options := iscp.SendOptions{ @@ -294,6 +275,14 @@ func (f *WasmToSandbox) fnPost(args []byte) []byte { return nil } +func (f *WasmToSandbox) fnRequest(args []byte) []byte { + return f.ctx.Request().Bytes() +} + +func (f *WasmToSandbox) fnRequestID(args []byte) []byte { + return f.ctx.Request().ID().Bytes() +} + // transfer tokens to address func (f *WasmToSandbox) fnSend(args []byte) []byte { decode := NewBytesDecoder(args) @@ -312,3 +301,12 @@ func (f *WasmToSandbox) fnSend(args []byte) []byte { func (f *WasmToSandbox) fnStateAnchor(args []byte) []byte { return nil } + +func (f *WasmToSandbox) fnTimestamp(args []byte) []byte { + return codec.EncodeInt64(f.common.GetTimestamp()) +} + +func (f *WasmToSandbox) fnTrace(args []byte) []byte { + f.common.Log().Debugf(string(args)) + return nil +} diff --git a/packages/vm/wasmproc/wasmtosandboxutils.go b/packages/vm/wasmproc/wasmtosandboxutils.go index cbedb9e951..08cae61a0f 100644 --- a/packages/vm/wasmproc/wasmtosandboxutils.go +++ b/packages/vm/wasmproc/wasmtosandboxutils.go @@ -1,3 +1,6 @@ +// Copyright 2020 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + package wasmproc import ( diff --git a/packages/vm/wasmvmhost/host.go b/packages/vm/wasmvmhost/host.go index c26388453e..a358997f8d 100644 --- a/packages/vm/wasmvmhost/host.go +++ b/packages/vm/wasmvmhost/host.go @@ -24,6 +24,16 @@ func hostGetObjectID(objID, keyID, typeID int32) int32 //export hostSetBytes func hostSetBytes(objID, keyID, typeID int32, value *byte, size int32) +// new Wasm VM + +//go:wasm-module WasmLib +//export hostStateGet +func hostStateGet(keyRef *byte, keyLen int32, valRef *byte, valLen int32) int32 + +//go:wasm-module WasmLib +//export hostStateSet +func hostStateSet(keyRef *byte, keyLen int32, valRef *byte, valLen int32) + // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ type WasmVMHost struct { @@ -144,7 +154,7 @@ func (w *WasmVMHost) SetBytes(objID, keyID, typeID int32, value []byte) { func (w *WasmVMHost) Sandbox(funcNr int32, params []byte) []byte { // ¶ms[0] will panic on zero length slice, so use nil instead - par := []byte(nil) + par := (*byte)(nil) size := int32(len(params)) if size != 0 { par = ¶ms[0] @@ -162,11 +172,11 @@ func (w *WasmVMHost) Sandbox(funcNr int32, params []byte) []byte { // retrieve cached result value from host result := make([]byte, size) - _ = hostStateGet(nil, 0, &result, size) + _ = hostStateGet(nil, 0, &result[0], size) return result } -func (w *WasmVMHost) StateDel(key []byte) { +func (w *WasmVMHost) StateDelete(key []byte) { // value size -1 means delete key // this removes the need for a separate hostStateDel function hostStateSet(&key[0], int32(len(key)), nil, -1) @@ -179,13 +189,15 @@ func (w *WasmVMHost) StateExists(key []byte) bool { return hostStateGet(&key[0], int32(len(key)), nil, -1) >= 0 } -func (w *WasmVMHost) StateGet(key []byte, value []byte) []byte { - size := int32(len(value)) - if size != 0 { - // size known in advance, just get the data - _ = hostStateGet(&key[0], int32(len(key)), &value, size) - return value - } +func (w *WasmVMHost) StateGet(key []byte) []byte { + //TODO optimize when type size is known in advance? + // or maybe pass in a larger buffer that will fit most rsults? + //size := int32(len(value)) + //if size != 0 { + // // size known in advance, just get the data + // _ = hostStateGet(&key[0], int32(len(key)), &value[0], size) + // return value + //} // variable sized result expected, // query size first by passing zero length buffer @@ -203,23 +215,17 @@ func (w *WasmVMHost) StateGet(key []byte, value []byte) []byte { } // retrieve cached value from host - value = make([]byte, size) - _ = hostStateGet(nil, 0, &value, size) + value := make([]byte, size) + _ = hostStateGet(nil, 0, &value[0], size) return value } func (w *WasmVMHost) StateSet(key []byte, value []byte) { // &value[0] will panic on zero length slice, so use nil instead - val := []byte(nil) + val := (*byte)(nil) size := int32(len(value)) if size != 0 { val = &value[0] } hostStateSet(&key[0], int32(len(key)), val, size) } - -func hostStateGet(key *byte, keyLen int32, val *byte, valLen int32) int32 { -} - -func hostStateSet(key *byte, keyLen int32, val *byte, valLen int32) { -} diff --git a/tools/schema/generator/tsclienttemplates/alltemplates.go b/tools/schema/generator/tsclienttemplates/alltemplates.go index 2016b81be6..09daa056cf 100644 --- a/tools/schema/generator/tsclienttemplates/alltemplates.go +++ b/tools/schema/generator/tsclienttemplates/alltemplates.go @@ -102,7 +102,7 @@ import * as events from "./events" import * as service from "./service" `, // ******************************* - "importWasmLib": ` + "importWasmClient": ` import * as wasmclient from "wasmclient" `, } diff --git a/tools/schema/generator/tsclienttemplates/events.go b/tools/schema/generator/tsclienttemplates/events.go index d6f83fef30..08fc72ea56 100644 --- a/tools/schema/generator/tsclienttemplates/events.go +++ b/tools/schema/generator/tsclienttemplates/events.go @@ -3,7 +3,7 @@ package tsclienttemplates var eventsTs = map[string]string{ // ******************************* "events.ts": ` -$#emit importWasmLib +$#emit importWasmClient const $pkgName$+Handlers = new Map void>([ $#each events eventHandler diff --git a/tools/schema/generator/tsclienttemplates/index.go b/tools/schema/generator/tsclienttemplates/index.go index 5c075efe59..33431528a6 100644 --- a/tools/schema/generator/tsclienttemplates/index.go +++ b/tools/schema/generator/tsclienttemplates/index.go @@ -3,7 +3,6 @@ package tsclienttemplates var indexTs = map[string]string{ // ******************************* "index.ts": ` -export * from "./$package"; export * from "./events"; export * from "./service"; `, diff --git a/tools/schema/generator/tsclienttemplates/service.go b/tools/schema/generator/tsclienttemplates/service.go index 7efd103e7f..b4fe200e0b 100644 --- a/tools/schema/generator/tsclienttemplates/service.go +++ b/tools/schema/generator/tsclienttemplates/service.go @@ -3,7 +3,7 @@ package tsclienttemplates var serviceTs = map[string]string{ // ******************************* "service.ts": ` -$#emit importWasmLib +$#emit importWasmClient $#if events importEvents $#each params constArg From bc4cd7411e830d5fee483f5920de3de1d288ff5f Mon Sep 17 00:00:00 2001 From: shawkyz Date: Sun, 16 Jan 2022 22:00:25 +0100 Subject: [PATCH 016/111] add evt argument to events --- tools/schema/generator/tsclienttemplates/events.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/schema/generator/tsclienttemplates/events.go b/tools/schema/generator/tsclienttemplates/events.go index 8761fb1934..44a4dd3b15 100644 --- a/tools/schema/generator/tsclienttemplates/events.go +++ b/tools/schema/generator/tsclienttemplates/events.go @@ -28,12 +28,12 @@ $#each events eventClass `, // ******************************* "eventHandlerMember": ` - $evtName: (Event$EvtName) => void = () => {}; + $evtName: (evt: Event$EvtName) => void = () => {}; `, // ******************************* "funcSignature": ` - public on$PkgName$EvtName(handler: (Event$EvtName) => void): void { + public on$PkgName$EvtName(handler: (evt: Event$EvtName) => void): void { this.$evtName = handler; } `, From d93d925113442b3a07da7bf5251d5d9521d6b9b7 Mon Sep 17 00:00:00 2001 From: shawkyz Date: Sun, 16 Jan 2022 22:45:44 +0100 Subject: [PATCH 017/111] simplify handler check if statement --- tools/schema/generator/tsclienttemplates/events.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/schema/generator/tsclienttemplates/events.go b/tools/schema/generator/tsclienttemplates/events.go index 44a4dd3b15..93bf4d792f 100644 --- a/tools/schema/generator/tsclienttemplates/events.go +++ b/tools/schema/generator/tsclienttemplates/events.go @@ -14,7 +14,7 @@ $#each events eventHandlerMember public callHandler(topic: string, params: string[]): void { const handler = $pkgName$+Handlers.get(topic); - if (handler !== undefined) { + if (handler) { handler(this, params); } } From 3ba7b19c7e556b707a527f1938727f426cf76cc2 Mon Sep 17 00:00:00 2001 From: shawkyz Date: Sun, 16 Jan 2022 22:47:39 +0100 Subject: [PATCH 018/111] add missing semicolon --- packages/vm/wasmlib/ts/wasmclient/results.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/vm/wasmlib/ts/wasmclient/results.ts b/packages/vm/wasmlib/ts/wasmclient/results.ts index fdcde72012..49f28cf6c8 100644 --- a/packages/vm/wasmlib/ts/wasmclient/results.ts +++ b/packages/vm/wasmlib/ts/wasmclient/results.ts @@ -19,7 +19,7 @@ export class Results extends wasmclient.Decoder { return; } keyValue(keyBuf, val); - }) + }); } protected get(key: string): Buffer | undefined { From 3c581e1937c75342d2d4892c5faccee0023d3890 Mon Sep 17 00:00:00 2001 From: shawkyz Date: Sun, 16 Jan 2022 23:51:01 +0100 Subject: [PATCH 019/111] configureWebSocketsEventHandlers only if we have events --- packages/vm/wasmlib/ts/wasmclient/service.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/vm/wasmlib/ts/wasmclient/service.ts b/packages/vm/wasmlib/ts/wasmclient/service.ts index 29d9cad572..4290f62de5 100644 --- a/packages/vm/wasmlib/ts/wasmclient/service.ts +++ b/packages/vm/wasmlib/ts/wasmclient/service.ts @@ -22,7 +22,6 @@ export class Service { constructor(client: wasmclient.ServiceClient, scHname: wasmclient.Hname) { this.serviceClient = client; this.scHname = scHname; - this.configureWebSocketsEventHandlers(); } public async callView(viewName: string, args: wasmclient.Arguments, res: wasmclient.Results): Promise { @@ -63,6 +62,9 @@ export class Service { } public register(handler: IEventHandler): void { + if(this.eventHandlers.length === 0) + this.configureWebSocketsEventHandlers(); + for (let i = 0; i < this.eventHandlers.length; i++) { if (this.eventHandlers[i] === handler) { return; From 7e930560686bda8525e6c998ba5305543e7bcf73 Mon Sep 17 00:00:00 2001 From: shawkyz Date: Mon, 17 Jan 2022 23:08:25 +0100 Subject: [PATCH 020/111] delete unused const --- packages/vm/wasmlib/ts/wasmclient/goshimmer/wallet/wallet.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/vm/wasmlib/ts/wasmclient/goshimmer/wallet/wallet.ts b/packages/vm/wasmlib/ts/wasmclient/goshimmer/wallet/wallet.ts index fb7f51e719..5bcad3dcfe 100644 --- a/packages/vm/wasmlib/ts/wasmclient/goshimmer/wallet/wallet.ts +++ b/packages/vm/wasmlib/ts/wasmclient/goshimmer/wallet/wallet.ts @@ -109,7 +109,6 @@ export class Wallet { if (!outputsByColor[destinationAddress][Colors.IOTA_COLOR_STRING]) { outputsByColor[destinationAddress][Colors.IOTA_COLOR_STRING] = 0n; } - const t = outputsByColor[destinationAddress][Colors.IOTA_COLOR_STRING]; outputsByColor[destinationAddress][Colors.IOTA_COLOR_STRING] += iotas; consumedFunds[Colors.IOTA_COLOR_STRING] = BigInt(consumedFunds[Colors.IOTA_COLOR_STRING] ?? 0n) - iotas; From ce71bb45459e981d3e69f9173b2460c2af6891b6 Mon Sep 17 00:00:00 2001 From: shawkyz Date: Mon, 17 Jan 2022 23:12:42 +0100 Subject: [PATCH 021/111] delete unsued argument --- .../vm/wasmlib/ts/wasmclient/goshimmer/models/transaction.ts | 2 +- packages/vm/wasmlib/ts/wasmclient/goshimmer/wallet/wallet.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/vm/wasmlib/ts/wasmclient/goshimmer/models/transaction.ts b/packages/vm/wasmlib/ts/wasmclient/goshimmer/models/transaction.ts index 479b745f3d..3250322afa 100644 --- a/packages/vm/wasmlib/ts/wasmclient/goshimmer/models/transaction.ts +++ b/packages/vm/wasmlib/ts/wasmclient/goshimmer/models/transaction.ts @@ -81,7 +81,7 @@ export class Transaction { * @param tx The tx to get the essence for. * @returns The essence of the transaction. */ - public static essence(tx: ITransaction, payload: Buffer = Buffer.alloc(0)): Buffer { + public static essence(tx: ITransaction): Buffer { const essenceBuffer = new SimpleBufferCursor(); essenceBuffer.writeInt8(tx.version); diff --git a/packages/vm/wasmlib/ts/wasmclient/goshimmer/wallet/wallet.ts b/packages/vm/wasmlib/ts/wasmclient/goshimmer/wallet/wallet.ts index 5bcad3dcfe..4d0b9e30bc 100644 --- a/packages/vm/wasmlib/ts/wasmclient/goshimmer/wallet/wallet.ts +++ b/packages/vm/wasmlib/ts/wasmclient/goshimmer/wallet/wallet.ts @@ -190,7 +190,7 @@ export class Wallet { builtInputs: string[] ): Array { const unlockBlocks: IUnlockBlock[] = []; - const txEssence = Transaction.essence(tx, Buffer.alloc(0)); + const txEssence = Transaction.essence(tx); const addressByOutputID: { [outputID: string]: string } = {}; for (const address in consumedOutputs) { From d646d0da8bb3968cc96b9895580b3b6c00995862 Mon Sep 17 00:00:00 2001 From: shawkyz Date: Mon, 17 Jan 2022 23:17:23 +0100 Subject: [PATCH 022/111] close websocket connection when no handlers exist --- packages/vm/wasmlib/ts/wasmclient/service.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/vm/wasmlib/ts/wasmclient/service.ts b/packages/vm/wasmlib/ts/wasmclient/service.ts index 4290f62de5..18c208a73e 100644 --- a/packages/vm/wasmlib/ts/wasmclient/service.ts +++ b/packages/vm/wasmlib/ts/wasmclient/service.ts @@ -76,6 +76,8 @@ export class Service { public unregister(handler: IEventHandler): void { // remove handler this.eventHandlers = this.eventHandlers.filter(h => h !== handler); + if(this.eventHandlers.length === 0) + this.webSocket?.close(); } // overrides default contract name From c5d8c2a3a57ee9e5c6dcda50b74b6955f3e38b5f Mon Sep 17 00:00:00 2001 From: shawkyz Date: Mon, 17 Jan 2022 23:22:25 +0100 Subject: [PATCH 023/111] es-lint compliance --- packages/vm/wasmlib/ts/wasmclient/service.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/vm/wasmlib/ts/wasmclient/service.ts b/packages/vm/wasmlib/ts/wasmclient/service.ts index 18c208a73e..9512b37ca6 100644 --- a/packages/vm/wasmlib/ts/wasmclient/service.ts +++ b/packages/vm/wasmlib/ts/wasmclient/service.ts @@ -15,7 +15,7 @@ export class Service { private serviceClient: wasmclient.ServiceClient; private webSocket: WebSocket | null = null; public keyPair: IKeyPair | null = null; - private eventHandlers: Array = new Array(); + private eventHandlers: Array = []; public scHname: wasmclient.Hname; private waspWebSocketUrl: string = ""; From cd59d2dfda178194d8fe23006e8b86f43d115e0a Mon Sep 17 00:00:00 2001 From: Eric Hop Date: Mon, 17 Jan 2022 20:35:25 -0800 Subject: [PATCH 024/111] Improved encoding/decoding into bytes, reducing size --- .../test/donatewithfeedback_bg.wasm | Bin 36670 -> 36885 bytes .../wasm/fairauction/test/fairauction_bg.wasm | Bin 42971 -> 43244 bytes .../fairroulette/test/fairroulette_bg.wasm | Bin 40322 -> 40291 bytes .../wasm/inccounter/go/inccounter/consts.go | 7 + .../wasm/inccounter/go/inccounter/contract.go | 12 + .../inccounter/go/inccounter/inccounter.go | 23 ++ .../wasm/inccounter/go/inccounter/keys.go | 20 +- .../wasm/inccounter/go/inccounter/lib.go | 25 ++ .../wasm/inccounter/go/inccounter/params.go | 16 + .../wasm/inccounter/go/inccounter/results.go | 40 +++ contracts/wasm/inccounter/schema.yaml | 8 + contracts/wasm/inccounter/src/consts.rs | 7 + contracts/wasm/inccounter/src/contract.rs | 16 + contracts/wasm/inccounter/src/inccounter.rs | 22 ++ contracts/wasm/inccounter/src/keys.rs | 20 +- contracts/wasm/inccounter/src/lib.rs | 25 ++ contracts/wasm/inccounter/src/params.rs | 22 ++ contracts/wasm/inccounter/src/results.rs | 46 +++ .../wasm/inccounter/test/inccounter_bg.wasm | Bin 37085 -> 38792 bytes .../wasm/inccounter/test/inccounter_test.go | 18 ++ .../wasm/inccounter/ts/inccounter/consts.ts | 7 + .../wasm/inccounter/ts/inccounter/contract.ts | 18 ++ .../inccounter/ts/inccounter/inccounter.ts | 22 +- .../wasm/inccounter/ts/inccounter/keys.ts | 18 +- .../wasm/inccounter/ts/inccounter/lib.ts | 12 + .../wasm/inccounter/ts/inccounter/params.ts | 12 + .../wasm/inccounter/ts/inccounter/results.ts | 36 +++ contracts/wasm/testcore/test/testcore_bg.wasm | Bin 53613 -> 53819 bytes .../wasm/testwasmlib/test/testwasmlib_bg.wasm | Bin 44734 -> 44768 bytes .../tokenregistry/test/tokenregistry_bg.wasm | Bin 32083 -> 32223 bytes .../sbtests/sbtestsc/testcore_bg.wasm | Bin 53613 -> 53819 bytes packages/vm/wasmlib/go/wasmlib/bytes.go | 220 +++++++++----- packages/vm/wasmlib/go/wasmlib/sandbox.go | 14 +- .../vm/wasmlib/go/wasmlib/sandboxtypes.go | 202 ++++++++++--- .../vm/wasmlib/go/wasmlib/sandboxutils.go | 6 +- packages/vm/wasmlib/src/bytes.rs | 281 ++++++++++------- packages/vm/wasmlib/src/host.rs | 2 +- packages/vm/wasmlib/ts/wasmlib/bytes.ts | 284 +++++++++++------- packages/vm/wasmproc/bytes.go | 166 ---------- packages/vm/wasmproc/sccontext.go | 19 +- packages/vm/wasmproc/scutility.go | 9 +- packages/vm/wasmproc/wasmtosandbox.go | 23 +- packages/vm/wasmproc/wasmtosandboxutils.go | 9 +- packages/vm/wasmsolo/solosccontext.go | 15 +- packages/vm/wasmvmhost/host.go | 2 +- tools/cluster/tests/wasm/inccounter_bg.wasm | Bin 37085 -> 38792 bytes 46 files changed, 1132 insertions(+), 572 deletions(-) delete mode 100644 packages/vm/wasmproc/bytes.go diff --git a/contracts/wasm/donatewithfeedback/test/donatewithfeedback_bg.wasm b/contracts/wasm/donatewithfeedback/test/donatewithfeedback_bg.wasm index 742ef0a8bc768622cfeba0f0c8b1790aafb227fb..f0016f184e0b0eaaac7d08459d17cfbce1e40631 100644 GIT binary patch delta 10492 zcmbta3v^Z0nLhiRb05jgO->*QkPve2A>=_IP+lP*PG!38(={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INEE+1b#-?o`%(9x zJp&p0r5dw$+VCu-7=1BSgxW*hvbu47y{KgK)t=}e=Vw?^rQXP9sQ?{W;w|_!i z-g_wc`;$FZWSm;vo~yRE4@MUGRC^K1bM2#7UrTkZJOJ*&Z!ms|{-bEqc%r}awtg%6 zglS?vcH4Y?VqVSNSC-kFhR_rvJ5Uo^J?i+r(!pKmrK9%`s2$XApr$MIsH^)bqKP#h zVzdaO1JYe9jCu&_poSX1e{|+t^a|1IgCB8ZZg=bccp&<2Ki4Wow-!ID6aD+pCIsH? V&N|#`_n|;I!W{Z6 diff --git a/contracts/wasm/fairauction/test/fairauction_bg.wasm b/contracts/wasm/fairauction/test/fairauction_bg.wasm index e2ded07e63fd10a941fd9c35f6ee585b487a33a7..db1f3cd4cdfb47634df551c48587d5d62b298b6f 100644 GIT binary patch delta 13639 zcmbtb33ye-y+3o#xl3}hOduf}A#*QFLc$U;>?)Z+*dw?jDElHehz28~NN(5>P>?}( z5UeezQ1Jl@6>W-Id9S>$^p(D1wUxeNOVxhTr)~NA+VXz?nRAlMV*B+g`R+Mqmh+$g zzRVmx{Gt8%kL>le#de~RB_>PU`(c-1X#tBl z!C-`0Rxl6=T8?97Sd0ZjA=hE9V}-&Fh64C!1sG#az{#{M%XTa`XxXV4up*YlGgJ*L z?P9x(1uO@EEZ4TPL;Yvk+T3Fj|T08JgvsMh3vGNpf<^E$h;`EKG!~KEP+{Q6g>hkx zD)eZwfiM0NbOnr$T#-0;RHIy*9umRy77B=fP!a(?6Bs|jgj*MN1mi@BTjgj5P-n~* z4tVK|h}nghUR>x35w`LXt zT)@-3NhXR^$s(F?xeiSvUjnSY3Kl@dnV}xVM6U>91Diuj}n2@-Ahg?bFtbAY8c z$H5Z_Cy59*&Phvbqa_Ta`+qHrhO&)ttK@lgI+T}yGFf#%kxVD!k3TfnXBh4D<-z7Xo z6PDJhSC|M7B|8FSZ8T|aq($-&F!7anSP|~T0NKI-tP(Y>(0!y4V1niW#2+Na7*#YZ z)hK!_On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VzrgmE4SW4!xsP;7bw1L;VUpFaxW6;{$JOP*)9%M}4LwmeqxJB_M_9)1 z*2D9kb$!Gx+OVROYF6av(w+KQO#i#0W0q&J35@J|o(o)&-SL5FXz&I%mAW2K7_ ze#y$-;U_%Ef}__`v_4QmaKSaJx&m>ZUsXJm0ca!`(O$u~j%?z%azM%v z&&;^Y=EQ7!M(?L&N6211fR{9}{yKt}URcQQVYdM|2r7lFqvSPj^Bx>ryuYS6UOezn$NUyP30;kpl^YQm;tG+I z9e~Vq^?U9sfbC!)RX-H!!gzSYs2S>|MvThyM&-ZbS8g6SOMS|H*b2+#j=9BBGu4ZH z7m1}Xo1N4M-v$Qs83uF1w`WsM=9<^U>7EID%Uqi;_R^rWOYq#c_TH3t`P-AeVKL;B zl(BBSxQ*^xw?6YD4aSJBl?Tf>X5?!6dR-oFrZOL%#6mG3pCu3H$BWNC{6FGZ+Oa<0 zJiCLAtUo56qz7WlkrRI&YfRiA!tFtbIzp=(MgUU7*wP~mSFe-ly@t}1i#TIdy1Igw zTuP}M`ofXahIvC<{HPg6lw;(i3&Y^a$SrWsf-8eiIDwZE(h4V{fb2qc(^`y~C|+vb+xQ1TE4S?Eav?z)Rfb_ah+h_d@%lcLi|Fz1ZR+w^qBKULR*YW< z{NnZdP|l{}EpF$pW7 zIALB%qI;i2o}WaUyw|}eA4>lOk=tmjmXBWwexJ~wtuLpaN|r`v)V=_pd3c|qzii!< zIXcB_%{C1qfYv#^dKsH(>r-Wkjp*TjC+LHx#wK1w%|Xp3ciZsv!c?!;7cCL|3Tf50 zVdA;wH@9^Z;#K-!`|zUkY0_wiu0P}L;=N+-(uFln&C>bK;-&Lz9(3>@9}M2$&opR9 zNn!>4)&0x0f], hex[b&0x0f])) + } + e := wasmlib.NewBytesDecoder(buf) + x := e.Int64() + str += " - " + strconv.FormatInt(x, 10) + f.Results.N().SetValue(n) + f.Results.X().SetValue(x) + f.Results.Str().SetValue(str) + f.Results.Buf().SetValue(buf) +} diff --git a/contracts/wasm/inccounter/go/inccounter/keys.go b/contracts/wasm/inccounter/go/inccounter/keys.go index 1741cdd8f9..9d7fe5ee44 100644 --- a/contracts/wasm/inccounter/go/inccounter/keys.go +++ b/contracts/wasm/inccounter/go/inccounter/keys.go @@ -13,22 +13,32 @@ const ( IdxParamCounter = 0 IdxParamDelay = 1 IdxParamDummy = 2 - IdxParamNumRepeats = 3 + IdxParamN = 3 + IdxParamNumRepeats = 4 - IdxResultCounter = 4 + IdxResultBuf = 5 + IdxResultCounter = 6 + IdxResultN = 7 + IdxResultStr = 8 + IdxResultX = 9 - IdxStateCounter = 5 - IdxStateNumRepeats = 6 + IdxStateCounter = 10 + IdxStateNumRepeats = 11 ) -const keyMapLen = 7 +const keyMapLen = 12 var keyMap = [keyMapLen]wasmlib.Key{ ParamCounter, ParamDelay, ParamDummy, + ParamN, ParamNumRepeats, + ResultBuf, ResultCounter, + ResultN, + ResultStr, + ResultX, StateCounter, StateNumRepeats, } diff --git a/contracts/wasm/inccounter/go/inccounter/lib.go b/contracts/wasm/inccounter/go/inccounter/lib.go index 944556592f..3c4b573e05 100644 --- a/contracts/wasm/inccounter/go/inccounter/lib.go +++ b/contracts/wasm/inccounter/go/inccounter/lib.go @@ -25,6 +25,7 @@ func OnLoad() { exports.AddFunc(FuncTestLeb128, funcTestLeb128Thunk) exports.AddFunc(FuncWhenMustIncrement, funcWhenMustIncrementThunk) exports.AddView(ViewGetCounter, viewGetCounterThunk) + exports.AddView(ViewGetVli, viewGetVliThunk) for i, key := range keyMap { idxMap[i] = key.KeyID() @@ -261,3 +262,27 @@ func viewGetCounterThunk(ctx wasmlib.ScViewContext) { viewGetCounter(ctx, f) ctx.Log("inccounter.viewGetCounter ok") } + +type GetVliContext struct { + Params ImmutableGetVliParams + Results MutableGetVliResults + State ImmutableIncCounterState +} + +func viewGetVliThunk(ctx wasmlib.ScViewContext) { + ctx.Log("inccounter.viewGetVli") + f := &GetVliContext{ + Params: ImmutableGetVliParams{ + id: wasmlib.OBJ_ID_PARAMS, + }, + Results: MutableGetVliResults{ + id: wasmlib.OBJ_ID_RESULTS, + }, + State: ImmutableIncCounterState{ + id: wasmlib.OBJ_ID_STATE, + }, + } + ctx.Require(f.Params.N().Exists(), "missing mandatory n") + viewGetVli(ctx, f) + ctx.Log("inccounter.viewGetVli ok") +} diff --git a/contracts/wasm/inccounter/go/inccounter/params.go b/contracts/wasm/inccounter/go/inccounter/params.go index c9c340257e..8e69f15ac9 100644 --- a/contracts/wasm/inccounter/go/inccounter/params.go +++ b/contracts/wasm/inccounter/go/inccounter/params.go @@ -72,3 +72,19 @@ type MutableWhenMustIncrementParams struct { func (s MutableWhenMustIncrementParams) Dummy() wasmlib.ScMutableInt64 { return wasmlib.NewScMutableInt64(s.id, wasmlib.KeyID(ParamDummy)) } + +type ImmutableGetVliParams struct { + id int32 +} + +func (s ImmutableGetVliParams) N() wasmlib.ScImmutableInt64 { + return wasmlib.NewScImmutableInt64(s.id, wasmlib.KeyID(ParamN)) +} + +type MutableGetVliParams struct { + id int32 +} + +func (s MutableGetVliParams) N() wasmlib.ScMutableInt64 { + return wasmlib.NewScMutableInt64(s.id, wasmlib.KeyID(ParamN)) +} diff --git a/contracts/wasm/inccounter/go/inccounter/results.go b/contracts/wasm/inccounter/go/inccounter/results.go index 585f59b62f..5ced4a0c79 100644 --- a/contracts/wasm/inccounter/go/inccounter/results.go +++ b/contracts/wasm/inccounter/go/inccounter/results.go @@ -24,3 +24,43 @@ type MutableGetCounterResults struct { func (s MutableGetCounterResults) Counter() wasmlib.ScMutableInt64 { return wasmlib.NewScMutableInt64(s.id, wasmlib.KeyID(ResultCounter)) } + +type ImmutableGetVliResults struct { + id int32 +} + +func (s ImmutableGetVliResults) Buf() wasmlib.ScImmutableBytes { + return wasmlib.NewScImmutableBytes(s.id, wasmlib.KeyID(ResultBuf)) +} + +func (s ImmutableGetVliResults) N() wasmlib.ScImmutableInt64 { + return wasmlib.NewScImmutableInt64(s.id, wasmlib.KeyID(ResultN)) +} + +func (s ImmutableGetVliResults) Str() wasmlib.ScImmutableString { + return wasmlib.NewScImmutableString(s.id, wasmlib.KeyID(ResultStr)) +} + +func (s ImmutableGetVliResults) X() wasmlib.ScImmutableInt64 { + return wasmlib.NewScImmutableInt64(s.id, wasmlib.KeyID(ResultX)) +} + +type MutableGetVliResults struct { + id int32 +} + +func (s MutableGetVliResults) Buf() wasmlib.ScMutableBytes { + return wasmlib.NewScMutableBytes(s.id, wasmlib.KeyID(ResultBuf)) +} + +func (s MutableGetVliResults) N() wasmlib.ScMutableInt64 { + return wasmlib.NewScMutableInt64(s.id, wasmlib.KeyID(ResultN)) +} + +func (s MutableGetVliResults) Str() wasmlib.ScMutableString { + return wasmlib.NewScMutableString(s.id, wasmlib.KeyID(ResultStr)) +} + +func (s MutableGetVliResults) X() wasmlib.ScMutableInt64 { + return wasmlib.NewScMutableInt64(s.id, wasmlib.KeyID(ResultX)) +} diff --git a/contracts/wasm/inccounter/schema.yaml b/contracts/wasm/inccounter/schema.yaml index 587b65366b..da9705a56c 100644 --- a/contracts/wasm/inccounter/schema.yaml +++ b/contracts/wasm/inccounter/schema.yaml @@ -31,3 +31,11 @@ views: getCounter: results: counter: Int64 + getVli: + params: + n: Int64 + results: + n: Int64 + x: Int64 + buf: Bytes + str: String diff --git a/contracts/wasm/inccounter/src/consts.rs b/contracts/wasm/inccounter/src/consts.rs index e1590fc5ba..b9e2a2c857 100644 --- a/contracts/wasm/inccounter/src/consts.rs +++ b/contracts/wasm/inccounter/src/consts.rs @@ -16,9 +16,14 @@ pub const HSC_NAME : ScHname = ScHname(0xaf2438e9); pub const PARAM_COUNTER : &str = "counter"; pub const PARAM_DELAY : &str = "delay"; pub const PARAM_DUMMY : &str = "dummy"; +pub const PARAM_N : &str = "n"; pub const PARAM_NUM_REPEATS : &str = "numRepeats"; +pub const RESULT_BUF : &str = "buf"; pub const RESULT_COUNTER : &str = "counter"; +pub const RESULT_N : &str = "n"; +pub const RESULT_STR : &str = "str"; +pub const RESULT_X : &str = "x"; pub const STATE_COUNTER : &str = "counter"; pub const STATE_NUM_REPEATS : &str = "numRepeats"; @@ -37,6 +42,7 @@ pub const FUNC_REPEAT_MANY : &str = "repeatMany"; pub const FUNC_TEST_LEB128 : &str = "testLeb128"; pub const FUNC_WHEN_MUST_INCREMENT : &str = "whenMustIncrement"; pub const VIEW_GET_COUNTER : &str = "getCounter"; +pub const VIEW_GET_VLI : &str = "getVli"; pub const HFUNC_CALL_INCREMENT : ScHname = ScHname(0xeb5dcacd); pub const HFUNC_CALL_INCREMENT_RECURSE5X : ScHname = ScHname(0x8749fbff); @@ -52,3 +58,4 @@ pub const HFUNC_REPEAT_MANY : ScHname = ScHname(0x4ff450d3); pub const HFUNC_TEST_LEB128 : ScHname = ScHname(0xd8364cb9); pub const HFUNC_WHEN_MUST_INCREMENT : ScHname = ScHname(0xb4c3e7a6); pub const HVIEW_GET_COUNTER : ScHname = ScHname(0xb423e607); +pub const HVIEW_GET_VLI : ScHname = ScHname(0x0ee16f89); diff --git a/contracts/wasm/inccounter/src/contract.rs b/contracts/wasm/inccounter/src/contract.rs index 5f5c59845c..f7cb751442 100644 --- a/contracts/wasm/inccounter/src/contract.rs +++ b/contracts/wasm/inccounter/src/contract.rs @@ -76,6 +76,12 @@ pub struct GetCounterCall { pub results: ImmutableGetCounterResults, } +pub struct GetVliCall { + pub func: ScView, + pub params: MutableGetVliParams, + pub results: ImmutableGetVliResults, +} + pub struct ScFuncs { } @@ -178,4 +184,14 @@ impl ScFuncs { f.func.set_ptrs(ptr::null_mut(), &mut f.results.id); f } + + pub fn get_vli(_ctx: & dyn ScViewCallContext) -> GetVliCall { + let mut f = GetVliCall { + func: ScView::new(HSC_NAME, HVIEW_GET_VLI), + params: MutableGetVliParams { id: 0 }, + results: ImmutableGetVliResults { id: 0 }, + }; + f.func.set_ptrs(&mut f.params.id, &mut f.results.id); + f + } } diff --git a/contracts/wasm/inccounter/src/inccounter.rs b/contracts/wasm/inccounter/src/inccounter.rs index a7fef760ca..64b227266c 100644 --- a/contracts/wasm/inccounter/src/inccounter.rs +++ b/contracts/wasm/inccounter/src/inccounter.rs @@ -174,3 +174,25 @@ fn when_must_increment_state(ctx: &ScFuncContext, state: &MutableIncCounterState let counter = state.counter(); counter.set_value(counter.value() + 1); } + +const HEX : &str = "0123456789abcdef"; + +pub fn view_get_vli(_ctx: &ScViewContext, f: &GetVliContext) { + let mut d = BytesEncoder::new(); + let n = f.params.n().value(); + d.int64(n); + let mut str = n.to_string() + " -"; + let buf = d.data(); + for b in &buf { + let h1 = ((b >> 4) & 0x0f) as usize; + let h2 = (b & 0x0f) as usize; + str += &(" ".to_string() + &HEX[h1..h1+1] + &HEX[h2..h2+1]); + } + let mut e = BytesDecoder::new(&buf); + let x = e.int64(); + str += &(" - ".to_string() + &x.to_string()); + f.results.n().set_value(n); + f.results.x().set_value(x); + f.results.str().set_value(&str); + f.results.buf().set_value(&buf); +} diff --git a/contracts/wasm/inccounter/src/keys.rs b/contracts/wasm/inccounter/src/keys.rs index cdbc2c396b..9ce7fc737d 100644 --- a/contracts/wasm/inccounter/src/keys.rs +++ b/contracts/wasm/inccounter/src/keys.rs @@ -14,21 +14,31 @@ use crate::*; pub(crate) const IDX_PARAM_COUNTER : usize = 0; pub(crate) const IDX_PARAM_DELAY : usize = 1; pub(crate) const IDX_PARAM_DUMMY : usize = 2; -pub(crate) const IDX_PARAM_NUM_REPEATS : usize = 3; +pub(crate) const IDX_PARAM_N : usize = 3; +pub(crate) const IDX_PARAM_NUM_REPEATS : usize = 4; -pub(crate) const IDX_RESULT_COUNTER : usize = 4; +pub(crate) const IDX_RESULT_BUF : usize = 5; +pub(crate) const IDX_RESULT_COUNTER : usize = 6; +pub(crate) const IDX_RESULT_N : usize = 7; +pub(crate) const IDX_RESULT_STR : usize = 8; +pub(crate) const IDX_RESULT_X : usize = 9; -pub(crate) const IDX_STATE_COUNTER : usize = 5; -pub(crate) const IDX_STATE_NUM_REPEATS : usize = 6; +pub(crate) const IDX_STATE_COUNTER : usize = 10; +pub(crate) const IDX_STATE_NUM_REPEATS : usize = 11; -pub const KEY_MAP_LEN: usize = 7; +pub const KEY_MAP_LEN: usize = 12; pub const KEY_MAP: [&str; KEY_MAP_LEN] = [ PARAM_COUNTER, PARAM_DELAY, PARAM_DUMMY, + PARAM_N, PARAM_NUM_REPEATS, + RESULT_BUF, RESULT_COUNTER, + RESULT_N, + RESULT_STR, + RESULT_X, STATE_COUNTER, STATE_NUM_REPEATS, ]; diff --git a/contracts/wasm/inccounter/src/lib.rs b/contracts/wasm/inccounter/src/lib.rs index e29777eda3..66e6ae8602 100644 --- a/contracts/wasm/inccounter/src/lib.rs +++ b/contracts/wasm/inccounter/src/lib.rs @@ -43,6 +43,7 @@ fn on_load() { exports.add_func(FUNC_TEST_LEB128, func_test_leb128_thunk); exports.add_func(FUNC_WHEN_MUST_INCREMENT, func_when_must_increment_thunk); exports.add_view(VIEW_GET_COUNTER, view_get_counter_thunk); + exports.add_view(VIEW_GET_VLI, view_get_vli_thunk); unsafe { for i in 0..KEY_MAP_LEN { @@ -281,3 +282,27 @@ fn view_get_counter_thunk(ctx: &ScViewContext) { view_get_counter(ctx, &f); ctx.log("inccounter.viewGetCounter ok"); } + +pub struct GetVliContext { + params: ImmutableGetVliParams, + results: MutableGetVliResults, + state: ImmutableIncCounterState, +} + +fn view_get_vli_thunk(ctx: &ScViewContext) { + ctx.log("inccounter.viewGetVli"); + let f = GetVliContext { + params: ImmutableGetVliParams { + id: OBJ_ID_PARAMS, + }, + results: MutableGetVliResults { + id: OBJ_ID_RESULTS, + }, + state: ImmutableIncCounterState { + id: OBJ_ID_STATE, + }, + }; + ctx.require(f.params.n().exists(), "missing mandatory n"); + view_get_vli(ctx, &f); + ctx.log("inccounter.viewGetVli ok"); +} diff --git a/contracts/wasm/inccounter/src/params.rs b/contracts/wasm/inccounter/src/params.rs index 27d5a8ff01..a9c3651799 100644 --- a/contracts/wasm/inccounter/src/params.rs +++ b/contracts/wasm/inccounter/src/params.rs @@ -101,3 +101,25 @@ impl MutableWhenMustIncrementParams { ScMutableInt64::new(self.id, PARAM_DUMMY.get_key_id()) } } + +#[derive(Clone, Copy)] +pub struct ImmutableGetVliParams { + pub(crate) id: i32, +} + +impl ImmutableGetVliParams { + pub fn n(&self) -> ScImmutableInt64 { + ScImmutableInt64::new(self.id, PARAM_N.get_key_id()) + } +} + +#[derive(Clone, Copy)] +pub struct MutableGetVliParams { + pub(crate) id: i32, +} + +impl MutableGetVliParams { + pub fn n(&self) -> ScMutableInt64 { + ScMutableInt64::new(self.id, PARAM_N.get_key_id()) + } +} diff --git a/contracts/wasm/inccounter/src/results.rs b/contracts/wasm/inccounter/src/results.rs index 4106744dcb..eea66aa61d 100644 --- a/contracts/wasm/inccounter/src/results.rs +++ b/contracts/wasm/inccounter/src/results.rs @@ -35,3 +35,49 @@ impl MutableGetCounterResults { ScMutableInt64::new(self.id, RESULT_COUNTER.get_key_id()) } } + +#[derive(Clone, Copy)] +pub struct ImmutableGetVliResults { + pub(crate) id: i32, +} + +impl ImmutableGetVliResults { + pub fn buf(&self) -> ScImmutableBytes { + ScImmutableBytes::new(self.id, RESULT_BUF.get_key_id()) + } + + pub fn n(&self) -> ScImmutableInt64 { + ScImmutableInt64::new(self.id, RESULT_N.get_key_id()) + } + + pub fn str(&self) -> ScImmutableString { + ScImmutableString::new(self.id, RESULT_STR.get_key_id()) + } + + pub fn x(&self) -> ScImmutableInt64 { + ScImmutableInt64::new(self.id, RESULT_X.get_key_id()) + } +} + +#[derive(Clone, Copy)] +pub struct MutableGetVliResults { + pub(crate) id: i32, +} + +impl MutableGetVliResults { + pub fn buf(&self) -> ScMutableBytes { + ScMutableBytes::new(self.id, RESULT_BUF.get_key_id()) + } + + pub fn n(&self) -> ScMutableInt64 { + ScMutableInt64::new(self.id, RESULT_N.get_key_id()) + } + + pub fn str(&self) -> ScMutableString { + ScMutableString::new(self.id, RESULT_STR.get_key_id()) + } + + pub fn x(&self) -> ScMutableInt64 { + ScMutableInt64::new(self.id, RESULT_X.get_key_id()) + } +} diff --git a/contracts/wasm/inccounter/test/inccounter_bg.wasm b/contracts/wasm/inccounter/test/inccounter_bg.wasm index 8f2f783f823869861ca1a1735e9f2f5197584f2e..d4f74848bd55265dee241c68f6187e1fc33f9401 100644 GIT binary patch delta 15817 zcmbt*3wTvUmhP_F`<#<-^4L5R2#|eFcqBX{!~_r_6+uBn5#I{RBjIs^fk238D<=v9 z-A%WVLK_V>U^5b@rNItL)Yi##`}O7aI6d|Z^IdO`bH#4IzT6pR+U}w6Fb<#0|JUC8 zs#Sljz4`k?a@R50J~8g3@nd2^`A1D!FB7Xf3#Czgdk!t*&Sa-+6P3t!_Z``!1W${tbdQ==m)r9xN*!RRE z?}_Kch+F;)1>X_wt?!B_#qcr94~RDL4yOBk@v@lR|4+pWsD4)zl->TCNZxir^!wXC zpz!dzz4;IJtPwk}pEs?bHt+*%V=F7O+)vYhs zBiEc1i3s>hAik}PjN&$oXL*i$M0gR;cH0GN+9XR!4$YHs6xgjvq3jmb_6DR(L}glC z@I^>Ug~_)hMKc;i%VkcUh@(z#b*g9V5^;12@%$ZY;WluR!n{bZ_&uL89o-k8)YHiHRFHB0$hWhRKNm&90 z%M%_l0@Z<%pe67)F4Ticw}i^6GosDUkD#T|j%Bn1O&YP1(5r)G@2i=ZYWJ%X5l-Xh zktyk2R2dgGs&Y)qv_Ie>5nL~Mhq7ekKxT_ZowR5zv0iIQ#3p)FoEOD}P1n>06>jDm zH73;*o0v9CkUn6tk%MJ%Z9OLi4I%3roPdhLf4#DL&U~j3(ajt02-25nWIf*>AkK!ZmB>R~>>QhN5*i!pZ zV}96#wufgy32XNHg3N_=A4E1`8I$c4Ue1l&*67%5;XEfEm{r)D8yQ7dJm3kXa;XcUR76GqfDCZH@Y$FpuLnTwHG z>g8Z6an(&BE|qdxudy_bxx>u$V~+DPoN71rgRw>y?7L5(k4CrWv*qBszl{rWv*$kvJaIFwL;NPog`hVXD$0-v^|6f-0sNzEjyX zr%AAc)B7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11)AyM@MlhQUQS0T2-E zcagfvUJwyG&aHZ7XnL1DpxG?D(cLCW`lH>=oO;9 zu1ex#alSKNow~M5_tEyytNNq0c}~h-k(uf^aot9MNX&VON%&TP*EunD0IH?fG0 z0fpZ7cqzXuWixjy(VhC_<8_5axb>mK8S9s0^p(da74w{n({pBVY;w7OM*#+FrL2 zXXe&*F5a)MTPFXxL(BDp2DUM^?rpp;>H9dtJV`0ROo>-x1~oBsa#q*G{S zi0?jzw-eE^Cx?p(y7tLB`BPlVKRL2jEZ)n|V3O2I+F7gr|C80Y_y6saBb{FOM1=Xk zV$6k0t)8->yvN#jZ#1eaFX;z2j88?;U$t+6Q1qI1J+AJoI8!T*7*oQTtu+|NC~nu5K%R#~BK znelLnM-;?`bX32yacO?Xm=I3O$c^LwlHcimwO;7XO@A}*frlSk)6%$hMdPaF>sLIs zdiDA>kFCDF@sY;mEst83C8c9UQT9L?Mp@vOy;0`n-~+ne`j4549*cqP3+(95Wa}OF zu-qZKxSPSOULecI6T;Kmvh?UJQ}p1r@(Gv2jx_^qBQclZ_-{8Xaa<32VELLg54X5R zSa-Sm!17hAtUlM_aJsEr9**b>ZK=fJh-2Lfk_i%wbj8+@2}+h7Qdexbdq7*%v8JMR z9iC!50el$sY8~IaHBlXNtZ9Jm$5WzT*_`UX5?Xtxajo0(@Wbw^+p=n=~$R0_r%N zSvTsRJUc}GCZR7q+mPoLctegU(DmDk@>T$(v;gnhJ~XclAXj@|f!@7+usl_uPj9d7 z^&e=BqxG_nJsa1d9Yag2dOB7Cnrl&V%!w$;3+Nd;CZ>X3tI$mS??Op^??V~!$PVrp z(d#{cg8*_XatYt-*?DotrtsuNeI2t*v(U!n3gAVkQ^Wwi9rc^=> 4) & 0x0f] + hex[d.buf[j] & 0x0f]; + // txt += " " + hex.charAt((b >> 4) & 0x0f) + hex.charAt(b & 0x0f); // } - let e = new wasmlib.BytesDecoder(d.buf); + let e = new wasmlib.BytesDecoder(d.data()); let v = e.int64(); // txt += " - " + v.toString(); // ctx.log(txt); @@ -177,3 +177,21 @@ function whenMustIncrementState(ctx: wasmlib.ScFuncContext, state: sc.MutableInc counter.setValue(counter.value() + 1); ctx.log("whenMustIncrement incremented"); } + +export function viewGetVli(ctx: wasmlib.ScViewContext, f: sc.GetVliContext): void { + let d = new wasmlib.BytesEncoder(); + let n = f.params.n().value(); + d = d.int64(n); + let str = n.toString() + " -"; + for (let j = 0; j < d.buf.length; j++) { + let b = d.buf[j]; + str += " " + hex.charAt((b >> 4) & 0x0f) + hex.charAt(b & 0x0f); + } + let e = new wasmlib.BytesDecoder(d.data()); + let x = e.int64(); + str += " - " + x.toString(); + f.results.n().setValue(n); + f.results.x().setValue(x); + f.results.str().setValue(str); + f.results.buf().setValue(d.buf); +} diff --git a/contracts/wasm/inccounter/ts/inccounter/keys.ts b/contracts/wasm/inccounter/ts/inccounter/keys.ts index 94e03bd1c1..d8c8beedba 100644 --- a/contracts/wasm/inccounter/ts/inccounter/keys.ts +++ b/contracts/wasm/inccounter/ts/inccounter/keys.ts @@ -11,19 +11,29 @@ import * as sc from "./index"; export const IdxParamCounter = 0; export const IdxParamDelay = 1; export const IdxParamDummy = 2; -export const IdxParamNumRepeats = 3; +export const IdxParamN = 3; +export const IdxParamNumRepeats = 4; -export const IdxResultCounter = 4; +export const IdxResultBuf = 5; +export const IdxResultCounter = 6; +export const IdxResultN = 7; +export const IdxResultStr = 8; +export const IdxResultX = 9; -export const IdxStateCounter = 5; -export const IdxStateNumRepeats = 6; +export const IdxStateCounter = 10; +export const IdxStateNumRepeats = 11; export let keyMap: string[] = [ sc.ParamCounter, sc.ParamDelay, sc.ParamDummy, + sc.ParamN, sc.ParamNumRepeats, + sc.ResultBuf, sc.ResultCounter, + sc.ResultN, + sc.ResultStr, + sc.ResultX, sc.StateCounter, sc.StateNumRepeats, ]; diff --git a/contracts/wasm/inccounter/ts/inccounter/lib.ts b/contracts/wasm/inccounter/ts/inccounter/lib.ts index 59d72dbea3..db2d01d62f 100644 --- a/contracts/wasm/inccounter/ts/inccounter/lib.ts +++ b/contracts/wasm/inccounter/ts/inccounter/lib.ts @@ -28,6 +28,7 @@ export function on_load(): void { exports.addFunc(sc.FuncTestLeb128, funcTestLeb128Thunk); exports.addFunc(sc.FuncWhenMustIncrement, funcWhenMustIncrementThunk); exports.addView(sc.ViewGetCounter, viewGetCounterThunk); + exports.addView(sc.ViewGetVli, viewGetVliThunk); for (let i = 0; i < sc.keyMap.length; i++) { sc.idxMap[i] = wasmlib.Key32.fromString(sc.keyMap[i]); @@ -151,3 +152,14 @@ function viewGetCounterThunk(ctx: wasmlib.ScViewContext): void { sc.viewGetCounter(ctx, f); ctx.log("inccounter.viewGetCounter ok"); } + +function viewGetVliThunk(ctx: wasmlib.ScViewContext): void { + ctx.log("inccounter.viewGetVli"); + let f = new sc.GetVliContext(); + f.params.mapID = wasmlib.OBJ_ID_PARAMS; + f.results.mapID = wasmlib.OBJ_ID_RESULTS; + f.state.mapID = wasmlib.OBJ_ID_STATE; + ctx.require(f.params.n().exists(), "missing mandatory n"); + sc.viewGetVli(ctx, f); + ctx.log("inccounter.viewGetVli ok"); +} diff --git a/contracts/wasm/inccounter/ts/inccounter/params.ts b/contracts/wasm/inccounter/ts/inccounter/params.ts index b12f5f1fa0..58ab759076 100644 --- a/contracts/wasm/inccounter/ts/inccounter/params.ts +++ b/contracts/wasm/inccounter/ts/inccounter/params.ts @@ -55,3 +55,15 @@ export class MutableWhenMustIncrementParams extends wasmlib.ScMapID { return new wasmlib.ScMutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ParamDummy)); } } + +export class ImmutableGetVliParams extends wasmlib.ScMapID { + n(): wasmlib.ScImmutableInt64 { + return new wasmlib.ScImmutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ParamN)); + } +} + +export class MutableGetVliParams extends wasmlib.ScMapID { + n(): wasmlib.ScMutableInt64 { + return new wasmlib.ScMutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ParamN)); + } +} diff --git a/contracts/wasm/inccounter/ts/inccounter/results.ts b/contracts/wasm/inccounter/ts/inccounter/results.ts index dbb6323dcd..bdfd077f87 100644 --- a/contracts/wasm/inccounter/ts/inccounter/results.ts +++ b/contracts/wasm/inccounter/ts/inccounter/results.ts @@ -19,3 +19,39 @@ export class MutableGetCounterResults extends wasmlib.ScMapID { return new wasmlib.ScMutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ResultCounter)); } } + +export class ImmutableGetVliResults extends wasmlib.ScMapID { + buf(): wasmlib.ScImmutableBytes { + return new wasmlib.ScImmutableBytes(this.mapID, wasmlib.Key32.fromString(sc.ResultBuf)); + } + + n(): wasmlib.ScImmutableInt64 { + return new wasmlib.ScImmutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ResultN)); + } + + str(): wasmlib.ScImmutableString { + return new wasmlib.ScImmutableString(this.mapID, wasmlib.Key32.fromString(sc.ResultStr)); + } + + x(): wasmlib.ScImmutableInt64 { + return new wasmlib.ScImmutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ResultX)); + } +} + +export class MutableGetVliResults extends wasmlib.ScMapID { + buf(): wasmlib.ScMutableBytes { + return new wasmlib.ScMutableBytes(this.mapID, wasmlib.Key32.fromString(sc.ResultBuf)); + } + + n(): wasmlib.ScMutableInt64 { + return new wasmlib.ScMutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ResultN)); + } + + str(): wasmlib.ScMutableString { + return new wasmlib.ScMutableString(this.mapID, wasmlib.Key32.fromString(sc.ResultStr)); + } + + x(): wasmlib.ScMutableInt64 { + return new wasmlib.ScMutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ResultX)); + } +} diff --git a/contracts/wasm/testcore/test/testcore_bg.wasm b/contracts/wasm/testcore/test/testcore_bg.wasm index 4c5b2af5841994a57b929dcc5c3929997b2ad39b..dcd2246ddbdbf599898624805a74c5c348c22218 100644 GIT binary patch delta 17576 zcmbt*34ByVw)d@jJKcd!CpRHvh2(aVkgx>8B4H4rE36J;f-DLsDvC(Q0i#i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tc B$I1Wz diff --git a/contracts/wasm/testwasmlib/test/testwasmlib_bg.wasm b/contracts/wasm/testwasmlib/test/testwasmlib_bg.wasm index 39e10ae7242ee578d24ecbaf4232e0779f9347d1..ed31dc6e3c5d79916491c97d25d9dd4da79cfdd2 100644 GIT binary patch delta 4836 zcmai14Nz6b6~4Rgz6bJnavvh{r|i3+LGWQr6*ND{V!5`UCfM54jHGJE$(Rlkdd|J~AxWGD=I-t} zd-j~&@BHk(6Bl{cMSjf194=P`3}6YWqA~^}*=KAzgz|;#eOSg<^Q|3lkHnnU@ zP=pCpI@ailOf1*=8r>xw<+&)W%KDS0j_IBd;qoxK)mEwGB16$mvSpH2O58xexhl<; z)mg4b6^!&@Qz@+tg~$d=mCs4WRo6X3>S?F6L6;0QdoC1|hUu<2jv}S5tlJ_ETZCC6 zCtPtMw0BbVxywH)Xj;KdE7nQwWZ47-#)k|g{f~zD1?@?=GPq(MRB#*#hjyO%9N{h# zq?QnWxGAJqLU1u8)!S!Hs8iK!x$7jvgcfGEkS=!$SM@MSV?0?vXSD1Uq|Am6s|Y-U zVEOSh(`3ozBDAe=I5d$roP;x>vC(8w+9pj+KH4GtH&hQNH z_;o}Ohltw##4aLgjlJ&SY|||ociU3b%gZ)V{T>oGZG!qfv8^=IW6x0ECss!@HQ10% z>ifiM`_CvCCpyNZ)(W47r*n(~wiA)WnS#q%KfNcZgSt}eE zxYI-PXl61x9|L1*#O%HV*%vW0ycY2c__&n-JrQPt#b_B`S|vhg6J(A;d7-A?XGXlq zrDzKl0igzT!bF5%>c7f_(@GTFjBVRD0He5FJ3?5j@DdhVyi*?Pe=gw>n)U|_c2qkO zG4YClnAoz-A~R9ITCux?oGE24}%=ZmK5`lavDK1?U;shjLm3x=3uy(7@b z0hr4serEW52S0Ar1KbQl{30yegehmEZ)ytq!@S5EmT~Lq^VIhFp@liJDu*~xJpZ&b+=tgO|IN199TiumZPWL zxK&QBwk(;aGYe5&a*WHYE2rQ{vTl2VSH>;dqxIlG{hVF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9t9oEfu&%2qN1N9HZW#vJy% zcza_uBJZhBc)kZ|~WgwUE?!y$q}D9oJ% z1?0FSIGGnCizJO3n*-gjn9|j;HT-9A=sZx+A^!j zdK_${iPwnlw)FRIgNRIx?|2?$)%Y<90KLFJC>4$ced4CAePYg4p*^0LQKC>THgD~L z=<@B>N7!p(d}VTrOS{mjn~`p}BqJ?r>2}c|n#skA%5iLG)%nUU33^$w`1;)*Ra4%6 zk%`vtv=O7Wn)VR>Qt&rReDcmh{dA%j`|ii=8!2fxGR?<4Yell=W~ zPZr=m?rDeLjOq>XGm=fMKghH37lXeU;^XSA@ncg=tvSAaV49YR=UB1ey+h0;hQD6| zpZxCoJyFcQ{QeMDECzqjrOBW)6F8bSS1kEpV3SIGS@=32{`^7jgmd;+2S7adJC`Q9 z>>bSRty-`*nX%bo{U3Vg?PzXl321vCPcNR+CQh9)*_u4{4(slzcT9fBss)@zcwa>A zYuzNVg{dXsD_`{3x5&8|H~!rn#nF9f;?zEe_+ei%PR@<}tyq7NzrRcTtPGTofn1I! z5e*X4_P0*mg|AqA?ZeZ7=ZARG0E5IE`>*!|Xf6TT3Q%vRsk!jX$I~gX5)QPBABC@$ z_=>_GE!C*1;RpN?-ZR-IZ5p(J_@igw`xd+t181_U{&Dzi!%czL%^b4Y{MOOO{s*Tc B$I1Wz diff --git a/packages/vm/wasmlib/go/wasmlib/bytes.go b/packages/vm/wasmlib/go/wasmlib/bytes.go index cb7fd62f4e..9a81cf7139 100644 --- a/packages/vm/wasmlib/go/wasmlib/bytes.go +++ b/packages/vm/wasmlib/go/wasmlib/bytes.go @@ -15,11 +15,11 @@ func NewBytesDecoder(data []byte) *BytesDecoder { } func (d *BytesDecoder) Address() ScAddress { - return NewScAddressFromBytes(d.Bytes()) + return NewScAddressFromBytes(d.FixedBytes(uint32(TypeSizes[TYPE_ADDRESS]))) } func (d *BytesDecoder) AgentID() ScAgentID { - return NewScAgentIDFromBytes(d.Bytes()) + return NewScAgentIDFromBytes(d.FixedBytes(uint32(TypeSizes[TYPE_AGENT_ID]))) } func (d *BytesDecoder) Bool() bool { @@ -27,21 +27,12 @@ func (d *BytesDecoder) Bool() bool { } func (d *BytesDecoder) Bytes() []byte { - size := d.Uint32() - if uint32(len(d.data)) < size { - panic("insufficient bytes") - } - value := d.data[:size] - d.data = d.data[size:] - return value + length := d.Uint32() + return d.FixedBytes(length) } func (d *BytesDecoder) ChainID() ScChainID { - return NewScChainIDFromBytes(d.Bytes()) -} - -func (d *BytesDecoder) Color() ScColor { - return NewScColorFromBytes(d.Bytes()) + return NewScChainIDFromBytes(d.FixedBytes(uint32(TypeSizes[TYPE_CHAIN_ID]))) } func (d *BytesDecoder) Close() { @@ -50,12 +41,25 @@ func (d *BytesDecoder) Close() { } } +func (d *BytesDecoder) Color() ScColor { + return NewScColorFromBytes(d.FixedBytes(uint32(TypeSizes[TYPE_COLOR]))) +} + +func (d *BytesDecoder) FixedBytes(size uint32) []byte { + if uint32(len(d.data)) < size { + panic("insufficient bytes") + } + value := d.data[:size] + d.data = d.data[size:] + return value +} + func (d *BytesDecoder) Hash() ScHash { - return NewScHashFromBytes(d.Bytes()) + return NewScHashFromBytes(d.FixedBytes(uint32(TypeSizes[TYPE_HASH]))) } func (d *BytesDecoder) Hname() ScHname { - return NewScHnameFromBytes(d.Bytes()) + return NewScHnameFromBytes(d.FixedBytes(uint32(TypeSizes[TYPE_HNAME]))) } func (d *BytesDecoder) Int8() int8 { @@ -63,48 +67,19 @@ func (d *BytesDecoder) Int8() int8 { } func (d *BytesDecoder) Int16() int16 { - return int16(d.leb128Decode(16)) + return int16(d.vliDecode(16)) } func (d *BytesDecoder) Int32() int32 { - return int32(d.leb128Decode(32)) + return int32(d.vliDecode(32)) } func (d *BytesDecoder) Int64() int64 { - return d.leb128Decode(64) -} - -// leb128 decoder -func (d *BytesDecoder) leb128Decode(bits int) int64 { - val := int64(0) - s := 0 - for { - if len(d.data) == 0 { - panic("insufficient bytes") - } - b := int8(d.data[0]) - d.data = d.data[1:] - val |= int64(b&0x7f) << s - if (b & -0x80) == 0 { - if int8(val>>s)&0x7f != b&0x7f { - panic("integer too large") - } - - // extend int7 sign to int8 - b |= (b & 0x40) << 1 - - // extend int8 sign to int64 - return val | (int64(b) << s) - } - s += 7 - if s >= bits { - panic("integer representation too long") - } - } + return d.vliDecode(64) } func (d *BytesDecoder) RequestID() ScRequestID { - return NewScRequestIDFromBytes(d.Bytes()) + return NewScRequestIDFromBytes(d.FixedBytes(uint32(TypeSizes[TYPE_REQUEST_ID]))) } func (d *BytesDecoder) String() string { @@ -121,15 +96,66 @@ func (d *BytesDecoder) Uint8() uint8 { } func (d *BytesDecoder) Uint16() uint16 { - return uint16(d.Int16()) + return uint16(d.vluDecode(16)) } func (d *BytesDecoder) Uint32() uint32 { - return uint32(d.Int32()) + return uint32(d.vluDecode(32)) } func (d *BytesDecoder) Uint64() uint64 { - return uint64(d.Int64()) + return d.vluDecode(64) +} + +// vli (variable length integer) decoder +func (d *BytesDecoder) vliDecode(bits int) (value int64) { + b := d.Uint8() + sign := b & 0x40 + + // first group of 6 bits + value = int64(b & 0x3f) + s := 6 + + // while continuation bit is set + for (b & 0x80) != 0 { + if s >= bits { + panic("integer representation too long") + } + + // next group of 7 bits + b = d.Uint8() + value |= int64(b&0x7f) << s + s += 7 + } + + if sign == 0 { + // positive, sign bits are already zero + return value + } + + // negative, extend sign bits + return value | (int64(-1) << s) +} + +// vlu (variable length unsigned) decoder +func (d *BytesDecoder) vluDecode(bits int) uint64 { + // first group of 7 bits + b := d.Uint8() + value := uint64(b & 0x7f) + s := 7 + + // while continuation bit is set + for (b & 0x80) != 0 { + if s >= bits { + panic("integer representation too long") + } + + // next group of 7 bits + b = d.Uint8() + value |= uint64(b&0x7f) << s + s += 7 + } + return value } // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ @@ -143,11 +169,11 @@ func NewBytesEncoder() *BytesEncoder { } func (e *BytesEncoder) Address(value ScAddress) *BytesEncoder { - return e.Bytes(value.Bytes()) + return e.FixedBytes(value.Bytes(), uint32(TypeSizes[TYPE_ADDRESS])) } func (e *BytesEncoder) AgentID(value ScAgentID) *BytesEncoder { - return e.Bytes(value.Bytes()) + return e.FixedBytes(value.Bytes(), uint32(TypeSizes[TYPE_AGENT_ID])) } func (e *BytesEncoder) Bool(value bool) *BytesEncoder { @@ -158,29 +184,38 @@ func (e *BytesEncoder) Bool(value bool) *BytesEncoder { } func (e *BytesEncoder) Bytes(value []byte) *BytesEncoder { - e.Uint32(uint32(len(value))) - e.data = append(e.data, value...) + length := uint32(len(value)) + e.Uint32(length) + e.FixedBytes(value, length) return e } func (e *BytesEncoder) ChainID(value ScChainID) *BytesEncoder { - return e.Bytes(value.Bytes()) + return e.FixedBytes(value.Bytes(), uint32(TypeSizes[TYPE_CHAIN_ID])) } func (e *BytesEncoder) Color(value ScColor) *BytesEncoder { - return e.Bytes(value.Bytes()) + return e.FixedBytes(value.Bytes(), uint32(TypeSizes[TYPE_COLOR])) } func (e *BytesEncoder) Data() []byte { return e.data } +func (e *BytesEncoder) FixedBytes(value []byte, length uint32) *BytesEncoder { + if len(value) != int(length) { + panic("invalid fixed bytes length") + } + e.data = append(e.data, value...) + return e +} + func (e *BytesEncoder) Hash(value ScHash) *BytesEncoder { - return e.Bytes(value.Bytes()) + return e.FixedBytes(value.Bytes(), uint32(TypeSizes[TYPE_HASH])) } func (e *BytesEncoder) Hname(value ScHname) *BytesEncoder { - return e.Bytes(value.Bytes()) + return e.FixedBytes(value.Bytes(), uint32(TypeSizes[TYPE_HNAME])) } func (e *BytesEncoder) Int8(value int8) *BytesEncoder { @@ -188,33 +223,45 @@ func (e *BytesEncoder) Int8(value int8) *BytesEncoder { } func (e *BytesEncoder) Int16(value int16) *BytesEncoder { - return e.leb128Encode(int64(value)) + return e.Int64(int64(value)) } func (e *BytesEncoder) Int32(value int32) *BytesEncoder { - return e.leb128Encode(int64(value)) + return e.Int64(int64(value)) } +// vli (variable length integer) encoder func (e *BytesEncoder) Int64(value int64) *BytesEncoder { - return e.leb128Encode(value) -} + // first group of 6 bits + // 1st byte encodes 0 as positive in bit 6 + b := byte(value) & 0x3f + value >>= 6 + + finalValue := int64(0) + if value < 0 { + // encode negative value + // 1st byte encodes 1 as negative in bit 6 + b |= 0x40 + finalValue = -1 + } -// leb128 encoder -func (e *BytesEncoder) leb128Encode(value int64) *BytesEncoder { - for { - b := byte(value) - s := b & 0x40 - value >>= 7 - if (value == 0 && s == 0) || (value == -1 && s != 0) { - e.data = append(e.data, b&0x7f) - return e - } + // keep shifting until all bits are done + for value != finalValue { + // emit with continuation bit e.data = append(e.data, b|0x80) + + // next group of 7 bits + b = byte(value) & 0x7f + value >>= 7 } + + // emit without continuation bit + e.data = append(e.data, b) + return e } func (e *BytesEncoder) RequestID(value ScRequestID) *BytesEncoder { - return e.Bytes(value.Bytes()) + return e.FixedBytes(value.Bytes(), uint32(TypeSizes[TYPE_REQUEST_ID])) } func (e *BytesEncoder) String(value string) *BytesEncoder { @@ -227,13 +274,30 @@ func (e *BytesEncoder) Uint8(value uint8) *BytesEncoder { } func (e *BytesEncoder) Uint16(value uint16) *BytesEncoder { - return e.Int16(int16(value)) + return e.Uint64(uint64(value)) } func (e *BytesEncoder) Uint32(value uint32) *BytesEncoder { - return e.Int32(int32(value)) + return e.Uint64(uint64(value)) } +// vlu (variable length unsigned) encoder func (e *BytesEncoder) Uint64(value uint64) *BytesEncoder { - return e.Int64(int64(value)) + // first group of 7 bits + b := byte(value) + value >>= 7 + + // keep shifting until all bits are done + for value != 0 { + // emit with continuation bit + e.data = append(e.data, b|0x80) + + // next group of 7 bits + b = byte(value) + value >>= 7 + } + + // emit without continuation bit + e.data = append(e.data, b) + return e } diff --git a/packages/vm/wasmlib/go/wasmlib/sandbox.go b/packages/vm/wasmlib/go/wasmlib/sandbox.go index a62f79d601..ead5274dab 100644 --- a/packages/vm/wasmlib/go/wasmlib/sandbox.go +++ b/packages/vm/wasmlib/go/wasmlib/sandbox.go @@ -3,10 +3,6 @@ package wasmlib -import ( - "github.com/iotaledger/wasp/packages/iscp" -) - const ( FnAccountID = int32(-1) FnBalance = int32(-2) @@ -53,14 +49,15 @@ func (s ScSandbox) AccountID() ScAgentID { } func (s ScSandbox) Balance(color ScColor) uint64 { - return NewUint64FromBytes(Sandbox(FnBalance, color.Bytes())) + bal, _ := ExtractUint64(Sandbox(FnBalance, color.Bytes())) + return bal } func (s ScSandbox) Balances() ScAssets { return NewScAssetsFromBytes(Sandbox(FnBalances, nil)) } -func (s ScSandbox) BlockContext(construct func(sandbox iscp.Sandbox) interface{}, onClose func(interface{})) interface{} { +func (s ScSandbox) BlockContext(construct func(sandbox ScSandbox) interface{}, onClose func(interface{})) interface{} { panic("implement me") } @@ -156,12 +153,13 @@ func (s ScSandbox) Send(target ScAddress, tokens ScAssets) { Sandbox(FnSend, enc.Data()) } -func (s ScSandbox) StateAnchor() iscp.StateAnchor { +func (s ScSandbox) StateAnchor() interface{} { panic("implement me") } func (s ScSandbox) Timestamp() int64 { - return NewInt64FromBytes(Sandbox(FnTimestamp, nil)) + ts, _ := ExtractInt64(Sandbox(FnTimestamp, nil)) + return ts } func (s ScSandbox) Trace(text string) { diff --git a/packages/vm/wasmlib/go/wasmlib/sandboxtypes.go b/packages/vm/wasmlib/go/wasmlib/sandboxtypes.go index 15500f125c..206a811c5d 100644 --- a/packages/vm/wasmlib/go/wasmlib/sandboxtypes.go +++ b/packages/vm/wasmlib/go/wasmlib/sandboxtypes.go @@ -8,17 +8,23 @@ import ( "sort" ) +type Map interface { + Delete(key []byte) + Exists(key []byte) bool + Get(key []byte) []byte + Set(key, value []byte) +} + type ScAssets map[ScColor]uint64 func NewScAssetsFromBytes(buf []byte) ScAssets { dict := make(ScAssets) - size := NewUint32FromBytes(buf[:4]) - buf = buf[4:] + size, buf := ExtractUint32(buf) + var k []byte + var v uint64 for i := uint32(0); i < size; i++ { - k := buf[:32] - buf = buf[32:] - v := NewUint64FromBytes(buf[:8]) - buf = buf[8:] + k, buf = ExtractBytes(buf, 32) + v, buf = ExtractUint64(buf) dict[NewScColorFromBytes(k)] = v } return dict @@ -32,34 +38,36 @@ func (a ScAssets) Bytes() []byte { sort.Slice(keys, func(i, j int) bool { return string(keys[i].id[:]) < string(keys[j].id[:]) }) - buf := make([]byte, 4) - binary.LittleEndian.PutUint32(buf, uint32(len(keys))) + buf := AppendUint32(nil, uint32(len(keys))) for _, k := range keys { v := a[k] - val := make([]byte, 8) - binary.LittleEndian.PutUint64(val, v) - buf = append(buf, k.Bytes()...) - buf = append(buf, val...) + buf = AppendBytes(buf, k.Bytes()) + buf = AppendUint64(buf, v) } return buf } type ScDict map[string][]byte +var _ Map = new(ScDict) + +func NewScDict() ScDict { + return make(ScDict) +} + func NewScDictFromBytes(buf []byte) ScDict { - dict := make(ScDict) - size := NewUint32FromBytes(buf[:4]) - buf = buf[4:] + size, buf := ExtractUint32(buf) + dict := make(ScDict, size) + var k uint16 + var v uint32 + var key []byte + var val []byte for i := uint32(0); i < size; i++ { - k := NewUint16FromBytes(buf[:2]) - buf = buf[2:] - key := buf[:k] - buf = buf[k:] - v := NewUint32FromBytes(buf[:4]) - buf = buf[4:] - val := buf[:v] - buf = buf[v:] - dict[string(key)] = val + k, buf = ExtractUint16(buf) + key, buf = ExtractBytes(buf, int(k)) + v, buf = ExtractUint32(buf) + val, buf = ExtractBytes(buf, int(v)) + dict.Set(key, val) } return dict } @@ -72,46 +80,144 @@ func (d ScDict) Bytes() []byte { sort.Slice(keys, func(i, j int) bool { return keys[i] < keys[j] }) - buf := make([]byte, 4) - binary.LittleEndian.PutUint32(buf, uint32(len(keys))) + buf := AppendUint32(nil, uint32(len(keys))) for _, k := range keys { v := d[k] - keyLen := make([]byte, 2) - binary.LittleEndian.PutUint16(keyLen, uint16(len(k))) - valLen := make([]byte, 4) - binary.LittleEndian.PutUint32(valLen, uint32(len(v))) - buf = append(buf, keyLen...) - buf = append(buf, []byte(k)...) - buf = append(buf, valLen...) - buf = append(buf, v...) + buf = AppendUint16(buf, uint16(len(k))) + buf = AppendBytes(buf, []byte(k)) + buf = AppendUint32(buf, uint32(len(v))) + buf = AppendBytes(buf, v) } return buf } -func NewBoolFromBytes(bytes []byte) bool { - return bytes[0] != 0 +func (d ScDict) Delete(key []byte) { + delete(d, string(key)) +} + +func (d ScDict) Exists(key []byte) bool { + return d[string(key)] != nil +} + +func (d ScDict) Get(key []byte) []byte { + return d[string(key)] +} + +func (d ScDict) Set(key, value []byte) { + d[string(key)] = value +} + +///////////////////////////////////////////////// + +type ScState struct{} + +var _ Map = new(ScState) + +func (d ScState) Delete(key []byte) { + StateDelete(key) +} + +func (d ScState) Exists(key []byte) bool { + return StateExists(key) +} + +func (d ScState) Get(key []byte) []byte { + return StateGet(key) +} + +func (d ScState) Set(key, value []byte) { + StateSet(key, value) +} + +///////////////////////////////////////////////// + +func ExtractBool(buf []byte) (bool, []byte) { + return buf[0] != 0, buf[1:] +} + +func ExtractBytes(buf []byte, n int) ([]byte, []byte) { + return buf[:n], buf[n:] +} + +func ExtractInt8(buf []byte) (int8, []byte) { + return int8(buf[0]), buf[1:] +} + +func ExtractInt16(buf []byte) (int16, []byte) { + return int16(binary.LittleEndian.Uint16(buf)), buf[2:] +} + +func ExtractInt32(buf []byte) (int32, []byte) { + return int32(binary.LittleEndian.Uint32(buf)), buf[4:] +} + +func ExtractInt64(buf []byte) (int64, []byte) { + return int64(binary.LittleEndian.Uint64(buf)), buf[8:] +} + +func ExtractUint8(buf []byte) (uint8, []byte) { + return buf[0], buf[1:] +} + +func ExtractUint16(buf []byte) (uint16, []byte) { + return binary.LittleEndian.Uint16(buf), buf[2:] +} + +func ExtractUint32(buf []byte) (uint32, []byte) { + return binary.LittleEndian.Uint32(buf), buf[4:] +} + +func ExtractUint64(buf []byte) (uint64, []byte) { + return binary.LittleEndian.Uint64(buf), buf[8:] +} + +//////////////////////////////////// + +func AppendBool(buf []byte, value bool) []byte { + if value { + return AppendUint8(buf, 1) + } + return AppendUint8(buf, 0) +} + +func AppendBytes(buf, value []byte) []byte { + return append(buf, value...) +} + +func AppendInt8(buf []byte, value int8) []byte { + return AppendUint8(buf, uint8(value)) +} + +func AppendInt16(buf []byte, value int16) []byte { + return AppendUint16(buf, uint16(value)) } -func NewInt16FromBytes(bytes []byte) int16 { - return int16(binary.LittleEndian.Uint16(bytes)) +func AppendInt32(buf []byte, value int32) []byte { + return AppendUint32(buf, uint32(value)) } -func NewInt32FromBytes(bytes []byte) int32 { - return int32(binary.LittleEndian.Uint32(bytes)) +func AppendInt64(buf []byte, value int64) []byte { + return AppendUint64(buf, uint64(value)) } -func NewInt64FromBytes(bytes []byte) int64 { - return int64(binary.LittleEndian.Uint64(bytes)) +func AppendUint8(buf []byte, value uint8) []byte { + return append(buf, value) } -func NewUint16FromBytes(bytes []byte) uint16 { - return binary.LittleEndian.Uint16(bytes) +func AppendUint16(buf []byte, value uint16) []byte { + tmp := make([]byte, 2) + binary.LittleEndian.PutUint16(tmp, value) + return append(buf, tmp...) } -func NewUint32FromBytes(bytes []byte) uint32 { - return binary.LittleEndian.Uint32(bytes) +func AppendUint32(buf []byte, value uint32) []byte { + tmp := make([]byte, 4) + binary.LittleEndian.PutUint32(tmp, value) + return append(buf, tmp...) } -func NewUint64FromBytes(bytes []byte) uint64 { - return binary.LittleEndian.Uint64(bytes) +func AppendUint64(buf []byte, value uint64) []byte { + tmp := make([]byte, 8) + binary.LittleEndian.PutUint64(tmp, value) + return append(buf, tmp...) } diff --git a/packages/vm/wasmlib/go/wasmlib/sandboxutils.go b/packages/vm/wasmlib/go/wasmlib/sandboxutils.go index 4c1328fa0b..82582e4683 100644 --- a/packages/vm/wasmlib/go/wasmlib/sandboxutils.go +++ b/packages/vm/wasmlib/go/wasmlib/sandboxutils.go @@ -34,7 +34,8 @@ func (u ScSandboxUtils) BlsAggregate(pubKeys, sigs [][]byte) ([]byte, []byte) { func (u ScSandboxUtils) BlsValid(data, pubKey, signature []byte) bool { encode := NewBytesEncoder().Bytes(data).Bytes(pubKey).Bytes(signature) - return NewBoolFromBytes(Sandbox(FnUtilsBlsValid, encode.Data())) + valid, _ := ExtractBool(Sandbox(FnUtilsBlsValid, encode.Data())) + return valid } func (u ScSandboxUtils) Ed25519Address(pubKey []byte) ScAddress { @@ -43,7 +44,8 @@ func (u ScSandboxUtils) Ed25519Address(pubKey []byte) ScAddress { func (u ScSandboxUtils) Ed25519Valid(data, pubKey, signature []byte) bool { encode := NewBytesEncoder().Bytes(data).Bytes(pubKey).Bytes(signature) - return NewBoolFromBytes(Sandbox(FnUtilsEd25519Valid, encode.Data())) + valid, _ := ExtractBool(Sandbox(FnUtilsEd25519Valid, encode.Data())) + return valid } func (u ScSandboxUtils) HashBlake2b(value []byte) ScHash { diff --git a/packages/vm/wasmlib/src/bytes.rs b/packages/vm/wasmlib/src/bytes.rs index e93f11ee54..34227fc94a 100644 --- a/packages/vm/wasmlib/src/bytes.rs +++ b/packages/vm/wasmlib/src/bytes.rs @@ -20,12 +20,12 @@ impl BytesDecoder<'_> { // decodes an ScAddress from the byte buffer pub fn address(&mut self) -> ScAddress { - ScAddress::from_bytes(self.bytes()) + ScAddress::from_bytes(self.fixed_bytes(TYPE_SIZES[TYPE_ADDRESS as usize] as usize)) } // decodes an ScAgentID from the byte buffer pub fn agent_id(&mut self) -> ScAgentID { - ScAgentID::from_bytes(self.bytes()) + ScAgentID::from_bytes(self.fixed_bytes(TYPE_SIZES[TYPE_AGENT_ID as usize] as usize)) } // decodes a bool from the byte buffer @@ -33,35 +33,40 @@ impl BytesDecoder<'_> { self.uint8() != 0 } - // decodes the next substring of bytes from the byte buffer + // decodes the next variable length substring of bytes from the byte buffer pub fn bytes(&mut self) -> &[u8] { - let size = self.uint32() as usize; - if self.buf.len() < size { - panic("insufficient bytes"); - } - let value = &self.buf[..size]; - self.buf = &self.buf[size..]; - value + let length = self.uint32(); + self.fixed_bytes(length as usize) } // decodes an ScChainID from the byte buffer pub fn chain_id(&mut self) -> ScChainID { - ScChainID::from_bytes(self.bytes()) + ScChainID::from_bytes(self.fixed_bytes(TYPE_SIZES[TYPE_CHAIN_ID as usize] as usize)) } // decodes an ScColor from the byte buffer pub fn color(&mut self) -> ScColor { - ScColor::from_bytes(self.bytes()) + ScColor::from_bytes(self.fixed_bytes(TYPE_SIZES[TYPE_COLOR as usize] as usize)) + } + + // decodes the next fixed length substring of bytes from the byte buffer + pub fn fixed_bytes(&mut self, size: usize) -> &[u8] { + if self.buf.len() < size { + panic("insufficient bytes"); + } + let value = &self.buf[..size]; + self.buf = &self.buf[size..]; + value } // decodes an ScHash from the byte buffer pub fn hash(&mut self) -> ScHash { - ScHash::from_bytes(self.bytes()) + ScHash::from_bytes(self.fixed_bytes(TYPE_SIZES[TYPE_HASH as usize] as usize)) } // decodes an ScHname from the byte buffer pub fn hname(&mut self) -> ScHname { - ScHname::from_bytes(self.bytes()) + ScHname::from_bytes(self.fixed_bytes(TYPE_SIZES[TYPE_HNAME as usize] as usize)) } // decodes an int8 from the byte buffer @@ -70,57 +75,26 @@ impl BytesDecoder<'_> { } // decodes an int16 from the byte buffer - // note that these are encoded using leb128 encoding to conserve space + // note that these are encoded using vli encoding to conserve space pub fn int16(&mut self) -> i16 { - self.leb128_decode(16) as i16 + self.vli_decode(16) as i16 } // decodes an int32 from the byte buffer - // note that these are encoded using leb128 encoding to conserve space + // note that these are encoded using vli encoding to conserve space pub fn int32(&mut self) -> i32 { - self.leb128_decode(32) as i32 + self.vli_decode(32) as i32 } // decodes an int64 from the byte buffer - // note that these are encoded using leb128 encoding to conserve space + // note that these are encoded using vli encoding to conserve space pub fn int64(&mut self) -> i64 { - self.leb128_decode(64) - } - - // leb128 decoder - fn leb128_decode(&mut self, bits: i32) -> i64 { - let mut val = 0_i64; - let mut s = 0; - loop { - if self.buf.len() == 0 { - panic("insufficient bytes"); - } - let mut b = self.buf[0] as i8; - self.buf = &self.buf[1..]; - val |= ((b & 0x7f) as i64) << s; - - // termination bit set? - if (b & -0x80) == 0 { - if ((val >> s) as i8) & 0x7f != b & 0x7f { - panic("integer too large"); - } - - // extend int7 sign to int8 - b |= (b & 0x40) << 1; - - // extend int8 sign to int64 - return val | ((b as i64) << s); - } - s += 7; - if s >= bits { - panic("integer representation too long"); - } - } + self.vli_decode(64) } // decodes an ScRequestID from the byte buffer pub fn request_id(&mut self) -> ScRequestID { - ScRequestID::from_bytes(self.bytes()) + ScRequestID::from_bytes(self.fixed_bytes(TYPE_SIZES[TYPE_REQUEST_ID as usize] as usize)) } // decodes an UTF-8 text string from the byte buffer @@ -133,27 +107,79 @@ impl BytesDecoder<'_> { if self.buf.len() == 0 { panic("insufficient bytes"); } - let val = self.buf[0]; + let value = self.buf[0]; self.buf = &self.buf[1..]; - val + value } // decodes an uint16 from the byte buffer - // note that these are encoded using leb128 encoding to conserve space + // note that these are encoded using vli encoding to conserve space pub fn uint16(&mut self) -> u16 { - self.int16() as u16 + self.vlu_decode(16) as u16 } // decodes an uint32 from the byte buffer - // note that these are encoded using leb128 encoding to conserve space + // note that these are encoded using vli encoding to conserve space pub fn uint32(&mut self) -> u32 { - self.int32() as u32 + self.vlu_decode(32) as u32 } // decodes an uint64 from the byte buffer - // note that these are encoded using leb128 encoding to conserve space + // note that these are encoded using vli encoding to conserve space pub fn uint64(&mut self) -> u64 { - self.int64() as u64 + self.vlu_decode(64) + } + + // vli (variable length integer) decoder + fn vli_decode(&mut self, bits: i32) -> i64 { + let mut b = self.uint8(); + let sign = b & 0x40; + + // first group of 6 bits + let mut value = (b & 0x3f) as i64; + let mut s = 6; + + // while continuation bit is set + while (b & 0x80) != 0 { + if s >= bits { + panic("integer representation too long"); + } + + // next group of 7 bits + b = self.uint8(); + value |= ((b & 0x7f) as i64) << s; + s += 7; + } + + if sign == 0 { + // positive, sign bits are already zero + return value; + } + + // negative, extend sign bits + value | (-1_i64 << s) + } + + // vlu (variable length unsigned) decoder + fn vlu_decode(&mut self, bits: i32) -> u64 { + // first group of 6 bits + let mut b = self.uint8(); + let mut value = (b & 0x3f) as u64; + let mut s = 7; + + // while continuation bit is set + while (b & 0x80) != 0 { + if s >= bits { + panic("integer representation too long"); + } + + // next group of 7 bits + b = self.uint8(); + value |= ((b & 0x7f) as u64) << s; + s += 7; + } + + value } } @@ -180,34 +206,34 @@ impl BytesEncoder { // encodes an ScAddress into the byte buffer pub fn address(&mut self, value: &ScAddress) -> &BytesEncoder { - self.bytes(value.to_bytes()) + self.fixed_bytes(value.to_bytes(), TYPE_SIZES[TYPE_ADDRESS as usize] as usize) } // encodes an ScAgentID into the byte buffer pub fn agent_id(&mut self, value: &ScAgentID) -> &BytesEncoder { - self.bytes(value.to_bytes()) + self.fixed_bytes(value.to_bytes(), TYPE_SIZES[TYPE_AGENT_ID as usize] as usize) } // encodes a bool into the byte buffer - pub fn bool(&mut self, val: bool) -> &BytesEncoder { - self.uint8(val as u8) + pub fn bool(&mut self, value: bool) -> &BytesEncoder { + self.uint8(value as u8) } - // encodes a substring of bytes into the byte buffer + // encodes a variable sized substring of bytes into the byte buffer pub fn bytes(&mut self, value: &[u8]) -> &BytesEncoder { - self.uint32(value.len() as u32); - self.buf.extend_from_slice(value); - self + let length = value.len(); + self.uint32(length as u32); + self.fixed_bytes(value, length) } // encodes an ScChainID into the byte buffer pub fn chain_id(&mut self, value: &ScChainID) -> &BytesEncoder { - self.bytes(value.to_bytes()) + self.fixed_bytes(value.to_bytes(), TYPE_SIZES[TYPE_CHAIN_ID as usize] as usize) } // encodes an ScColor into the byte buffer pub fn color(&mut self, value: &ScColor) -> &BytesEncoder { - self.bytes(value.to_bytes()) + self.fixed_bytes(value.to_bytes(), TYPE_SIZES[TYPE_COLOR as usize] as usize) } // retrieve the encoded byte buffer @@ -215,56 +241,77 @@ impl BytesEncoder { self.buf.clone() } + // encodes a fixed sized substring of bytes into the byte buffer + pub fn fixed_bytes(&mut self, value: &[u8], length: usize) -> &BytesEncoder { + if value.len() != length as usize { + panic("invalid fixed bytes length"); + } + self.buf.extend_from_slice(value); + self + } + // encodes an ScHash into the byte buffer pub fn hash(&mut self, value: &ScHash) -> &BytesEncoder { - self.bytes(value.to_bytes()) + self.fixed_bytes(value.to_bytes(), TYPE_SIZES[TYPE_HASH as usize] as usize) } // encodes an ScHname into the byte buffer pub fn hname(&mut self, value: ScHname) -> &BytesEncoder { - self.bytes(&value.to_bytes()) + self.fixed_bytes(&value.to_bytes(), TYPE_SIZES[TYPE_HNAME as usize] as usize) } // encodes an int8 into the byte buffer - pub fn int8(&mut self, val: i8) -> &BytesEncoder { - self.uint8(val as u8) + pub fn int8(&mut self, value: i8) -> &BytesEncoder { + self.uint8(value as u8) } // encodes an int16 into the byte buffer - // note that these are encoded using leb128 encoding to conserve space - pub fn int16(&mut self, val: i16) -> &BytesEncoder { - self.leb128_encode(val as i64) + // note that these are encoded using vli encoding to conserve space + pub fn int16(&mut self, value: i16) -> &BytesEncoder { + self.int64(value as i64) } // encodes an int32 into the byte buffer - // note that these are encoded using leb128 encoding to conserve space - pub fn int32(&mut self, val: i32) -> &BytesEncoder { - self.leb128_encode(val as i64) + // note that these are encoded using vli encoding to conserve space + pub fn int32(&mut self, value: i32) -> &BytesEncoder { + self.int64(value as i64) } // encodes an int64 into the byte buffer - // note that these are encoded using leb128 encoding to conserve space - pub fn int64(&mut self, val: i64) -> &BytesEncoder { - self.leb128_encode(val) - } - - // leb128 encoder - fn leb128_encode(&mut self, mut val: i64) -> &BytesEncoder { - loop { - let b = val as u8; - let s = b & 0x40; - val >>= 7; - if (val == 0 && s == 0) || (val == -1 && s != 0) { - self.buf.push(b & 0x7f); - return self; - } - self.buf.push(b | 0x80); + // note that these are encoded using vli encoding to conserve space + // vli (variable length integer) encoder + pub fn int64(&mut self, mut value: i64) -> &BytesEncoder { + // first group of 6 bits + // 1st byte encodes 0 as positive in bit 6 + let mut b = value as u8 & 0x3f; + value >>= 6; + + let mut final_value = 0_i64; + if value < 0 { + // encode negative value + // 1st byte encodes 1 as negative in bit 6 + b |= 0x40; + final_value = -1_i64; } + + // keep shifting until all bits are done + while value != final_value { + // emit with continuation bit + self.buf.push(b|0x80); + + // next group of 7 bits + b = value as u8 & 0x7f; + value >>= 7; + } + + // emit without continuation bit + self.buf.push(b); + self } // encodes an ScRequestID into the byte buffer pub fn request_id(&mut self, value: &ScRequestID) -> &BytesEncoder { - self.bytes(value.to_bytes()) + self.fixed_bytes(value.to_bytes(), TYPE_SIZES[TYPE_REQUEST_ID as usize] as usize) } // encodes an UTF-8 text string into the byte buffer @@ -273,26 +320,44 @@ impl BytesEncoder { } // encodes an uint8 into the byte buffer - pub fn uint8(&mut self, val: u8) -> &BytesEncoder { - self.buf.push(val); + pub fn uint8(&mut self, value: u8) -> &BytesEncoder { + self.buf.push(value); self } // encodes an uint16 into the byte buffer - // note that these are encoded using leb128 encoding to conserve space - pub fn uint16(&mut self, val: u16) -> &BytesEncoder { - self.int16(val as i16) + // note that these are encoded using vlu encoding to conserve space + pub fn uint16(&mut self, value: u16) -> &BytesEncoder { + self.uint64(value as u64) } // encodes an uint32 into the byte buffer - // note that these are encoded using leb128 encoding to conserve space - pub fn uint32(&mut self, val: u32) -> &BytesEncoder { - self.int32(val as i32) + // note that these are encoded using vlu encoding to conserve space + pub fn uint32(&mut self, value: u32) -> &BytesEncoder { + self.uint64(value as u64) } // encodes an uint64 into the byte buffer - // note that these are encoded using leb128 encoding to conserve space - pub fn uint64(&mut self, val: u64) -> &BytesEncoder { - self.int64(val as i64) + // note that these are encoded using vlu encoding to conserve space + // vlu (variable length unsigned) encoder + pub fn uint64(&mut self, mut value: u64) -> &BytesEncoder { + // first group of 7 bits + // 1st byte encodes 0 as positive in bit 6 + let mut b = value as u8; + value >>= 7; + + // keep shifting until all bits are done + while value != 0 { + // emit with continuation bit + self.buf.push(b|0x80); + + // next group of 7 bits + b = value as u8; + value >>= 7; + } + + // emit without continuation bit + self.buf.push(b); + self } } diff --git a/packages/vm/wasmlib/src/host.rs b/packages/vm/wasmlib/src/host.rs index 72cac67eea..2f15844fc3 100644 --- a/packages/vm/wasmlib/src/host.rs +++ b/packages/vm/wasmlib/src/host.rs @@ -36,7 +36,7 @@ pub const OBJ_ID_PARAMS: i32 = 3; pub const OBJ_ID_RESULTS: i32 = 4; // size in bytes of predefined types, indexed by the TYPE_* consts -const TYPE_SIZES: &[u8] = &[0, 33, 37, 1, 0, 33, 32, 32, 4, 1, 2, 4, 8, 0, 34, 0]; +pub const TYPE_SIZES: &[u8] = &[0, 33, 37, 1, 0, 33, 32, 32, 4, 1, 2, 4, 8, 0, 34, 0]; // These 4 external functions are funneling the entire WasmLib functionality // to their counterparts on the host. diff --git a/packages/vm/wasmlib/ts/wasmlib/bytes.ts b/packages/vm/wasmlib/ts/wasmlib/bytes.ts index 0cf37a1eb5..a2eeb684a0 100644 --- a/packages/vm/wasmlib/ts/wasmlib/bytes.ts +++ b/packages/vm/wasmlib/ts/wasmlib/bytes.ts @@ -3,6 +3,7 @@ import {Convert} from "./convert"; import {ScAddress, ScAgentID, ScChainID, ScColor, ScHash, ScHname, ScRequestID} from "./hashtypes"; +import * as host from "./host"; import {panic} from "./host"; // decodes separate entities from a byte buffer @@ -19,12 +20,12 @@ export class BytesDecoder { // decodes an ScAddress from the byte buffer address(): ScAddress { - return ScAddress.fromBytes(this.bytes()); + return ScAddress.fromBytes(this.fixedBytes(host.TYPE_SIZES[host.TYPE_ADDRESS])); } // decodes an ScAgentID from the byte buffer agentID(): ScAgentID { - return ScAgentID.fromBytes(this.bytes()); + return ScAgentID.fromBytes(this.fixedBytes(host.TYPE_SIZES[host.TYPE_AGENT_ID])); } // decodes a bool from the byte buffer @@ -34,33 +35,44 @@ export class BytesDecoder { // decodes the next substring of bytes from the byte buffer bytes(): u8[] { - let size = this.uint32(); - if (u32(this.buf.length) < size) { - panic("insufficient bytes"); - } - let value = this.buf.slice(0, size); - this.buf = this.buf.slice(size); - return value; + const length = this.uint32(); + return this.fixedBytes(length); } // decodes an ScChainID from the byte buffer chainID(): ScChainID { - return ScChainID.fromBytes(this.bytes()); + return ScChainID.fromBytes(this.fixedBytes(host.TYPE_SIZES[host.TYPE_CHAIN_ID])); + } + + close(): void { + if (this.buf.length != 0) { + panic("extra bytes"); + } } // decodes an ScColor from the byte buffer color(): ScColor { - return ScColor.fromBytes(this.bytes()); + return ScColor.fromBytes(this.fixedBytes(host.TYPE_SIZES[host.TYPE_COLOR])); + } + + // decodes the next substring of bytes from the byte buffer + fixedBytes(length: u32): u8[] { + if (u32(this.buf.length) < length) { + panic("insufficient bytes"); + } + let value = this.buf.slice(0, length); + this.buf = this.buf.slice(length); + return value; } // decodes an ScHash from the byte buffer hash(): ScHash { - return ScHash.fromBytes(this.bytes()); + return ScHash.fromBytes(this.fixedBytes(host.TYPE_SIZES[host.TYPE_HASH])); } // decodes an ScHname from the byte buffer hname(): ScHname { - return ScHname.fromBytes(this.bytes()); + return ScHname.fromBytes(this.fixedBytes(host.TYPE_SIZES[host.TYPE_HNAME])); } // decodes an int8 from the byte buffer @@ -69,58 +81,26 @@ export class BytesDecoder { } // decodes an int16 from the byte buffer - // note that these are encoded using leb128 encoding to conserve space + // note that these are encoded using vli encoding to conserve space int16(): i16 { - return this.leb128Decode(16) as i16; + return this.vliDecode(16) as i16; } // decodes an int32 from the byte buffer - // note that these are encoded using leb128 encoding to conserve space + // note that these are encoded using vli encoding to conserve space int32(): i32 { - return this.leb128Decode(32) as i32; + return this.vliDecode(32) as i32; } // decodes an int64 from the byte buffer - // note that these are encoded using leb128 encoding to conserve space + // note that these are encoded using vli encoding to conserve space int64(): i64 { - return this.leb128Decode(64); - } - - // leb128 decoder - leb128Decode(bits: i32): i64 { - let val: i64 = 0; - let s = 0; - for (; ;) { - if (this.buf.length == 0) { - panic("leb128Decode: insufficient bytes"); - } - let b = this.buf.shift() as i8; - val |= ((b & 0x7f) as i64) << s; - - // termination bit set? - if ((b & -0x80) == 0) { - if ((((val >> s) as i8) & 0x7f) != (b & 0x7f)) { - panic("integer too large"); - } - - // extend int7 sign to int8 - b |= (b & 0x40) << 1; - - // extend int8 sign to int64 - val |= ((b as i64) << s); - break; - } - s += 7; - if (s >= bits) { - panic("integer representation too long"); - } - } - return val; + return this.vliDecode(64); } // decodes an ScRequestID from the byte buffer requestID(): ScRequestID { - return ScRequestID.fromBytes(this.bytes()); + return ScRequestID.fromBytes(this.fixedBytes(host.TYPE_SIZES[host.TYPE_REQUEST_ID])); } // decodes an UTF-8 text string from the byte buffer @@ -130,31 +110,80 @@ export class BytesDecoder { // decodes an uint8 from the byte buffer uint8(): u8 { + if (this.buf.length == 0) { + panic("insufficient bytes"); + } return this.buf.shift(); } // decodes an uint16 from the byte buffer - // note that these are encoded using leb128 encoding to conserve space + // note that these are encoded using vlu encoding to conserve space uint16(): u16 { - return this.int16() as u16; + return this.vluDecode(16) as u16; } // decodes an uint32 from the byte buffer - // note that these are encoded using leb128 encoding to conserve space + // note that these are encoded using vlu encoding to conserve space uint32(): u32 { - return this.int32() as u32; + return this.vluDecode(32) as u32; } // decodes an uint64 from the byte buffer - // note that these are encoded using leb128 encoding to conserve space + // note that these are encoded using vlu encoding to conserve space uint64(): u64 { - return this.int64() as u64; + return this.vluDecode(64); } - close(): void { - if (this.buf.length != 0) { - panic("extra bytes"); + // vli (variable length integer) decoder + vliDecode(bits: i32): i64 { + let b = this.uint8(); + const sign = b & 0x40; + + // first group of 6 bits + let value = (b & 0x3f) as i64; + let s = 6; + + // while continuation bit is set + while ((b & 0x80) != 0) { + if (s >= bits) { + panic("integer representation too long"); + } + + // next group of 7 bits + b = this.uint8(); + value |= ((b & 0x7f) as i64) << s; + s += 7; + } + + if (sign == 0) { + // positive, sign bits are already zero + return value; + } + + // negative, extend sign bits + return value | ((-1 as i64) << s); + } + + // vlu decoder + vluDecode(bits: i32): u64 { + // first group of 7 bits + let b = this.uint8(); + let value = (b & 0x7f) as u64; + let s = 7; + + // while continuation bit is set + while ((b & 0x80) != 0) { + if (s >= bits) { + panic("integer representation too long"); + } + + // next group of 7 bits + b = this.uint8(); + value |= ((b & 0x7f) as u64) << s; + s += 7; } + + return value; } } @@ -171,36 +200,34 @@ export class BytesEncoder { // encodes an ScAddress into the byte buffer address(value: ScAddress): BytesEncoder { - return this.bytes(value.toBytes()); + return this.fixedBytes(value.toBytes(), host.TYPE_SIZES[host.TYPE_ADDRESS]); } // encodes an ScAgentID into the byte buffer agentID(value: ScAgentID): BytesEncoder { - return this.bytes(value.toBytes()); + return this.fixedBytes(value.toBytes(), host.TYPE_SIZES[host.TYPE_AGENT_ID]); } // encodes a bool into the byte buffer - bool(val: boolean): BytesEncoder { - return this.int8(val ? 1 : 0); + bool(value: boolean): BytesEncoder { + return this.uint8(value ? 1 : 0); } // encodes a substring of bytes into the byte buffer bytes(value: u8[]): BytesEncoder { - this.uint32(value.length); - for (let i = 0; i < value.length; i++) { - this.buf.push(value[i]); - } - return this; + const length = value.length; + this.uint32(length); + return this.fixedBytes(value, length); } // encodes an ScChainID into the byte buffer chainID(value: ScChainID): BytesEncoder { - return this.bytes(value.toBytes()); + return this.fixedBytes(value.toBytes(), host.TYPE_SIZES[host.TYPE_CHAIN_ID]); } // encodes an ScColor into the byte buffer color(value: ScColor): BytesEncoder { - return this.bytes(value.toBytes()); + return this.fixedBytes(value.toBytes(), host.TYPE_SIZES[host.TYPE_COLOR]); } // retrieve the encoded byte buffer @@ -208,57 +235,79 @@ export class BytesEncoder { return this.buf; } + // encodes a substring of bytes into the byte buffer + fixedBytes(value: u8[], length: u32): BytesEncoder { + if (value.length != length) { + panic("invalid fixed bytes length"); + } + for (let i: u32 = 0; i < length; i++) { + this.buf.push(value[i]); + } + return this; + } + // encodes an ScHash into the byte buffer hash(value: ScHash): BytesEncoder { - return this.bytes(value.toBytes()); + return this.fixedBytes(value.toBytes(), host.TYPE_SIZES[host.TYPE_HASH]); } // encodes an ScHname into the byte buffer hname(value: ScHname): BytesEncoder { - return this.bytes(value.toBytes()); + return this.fixedBytes(value.toBytes(), host.TYPE_SIZES[host.TYPE_HNAME]); } // encodes an int8 into the byte buffer - int8(val: i8): BytesEncoder { - return this.uint8(val as u8); + int8(value: i8): BytesEncoder { + return this.uint8(value as u8); } // encodes an int16 into the byte buffer - // note that these are encoded using leb128 encoding to conserve space - int16(val: i16): BytesEncoder { - return this.leb128Encode(val as i64); + // note that these are encoded using vli encoding to conserve space + int16(value: i16): BytesEncoder { + return this.int64(value as i64); } // encodes an int32 into the byte buffer - // note that these are encoded using leb128 encoding to conserve space - int32(val: i32): BytesEncoder { - return this.leb128Encode(val as i64); + // note that these are encoded using vli encoding to conserve space + int32(value: i32): BytesEncoder { + return this.int64(value as i64); } // encodes an int64 into the byte buffer - // note that these are encoded using leb128 encoding to conserve space - int64(val: i64): BytesEncoder { - return this.leb128Encode(val); - } - - // leb128 encoder - leb128Encode(val: i64): BytesEncoder { - for (; ;) { - let b = val as u8; - let s = b & 0x40; - val >>= 7; - if ((val == 0 && s == 0) || (val == -1 && s != 0)) { - this.buf.push(b & 0x7f); - break; - } + // note that these are encoded using vli encoding to conserve space + // vli (variable length integer) encoder + int64(value: i64): BytesEncoder { + // first group of 6 bits + // 1st byte encodes 0 as positive in bit 6 + let b = (value as u8) & 0x3f; + value >>= 6; + + let finalValue: i64 = 0; + if (value < 0) { + // encode negative value + // 1st byte encodes 1 as negative in bit 6 + b |= 0x40; + finalValue = -1; + } + + // keep shifting until all bits are done + while (value != finalValue) { + // emit with continuation bit this.buf.push(b | 0x80); + + // next group of 7 bits + b = (value as u8) & 0x7f; + value >>= 7; } + + // emit without continuation bit + this.buf.push(b); return this; } // encodes an ScRequestID into the byte buffer requestID(value: ScRequestID): BytesEncoder { - return this.bytes(value.toBytes()); + return this.fixedBytes(value.toBytes(), host.TYPE_SIZES[host.TYPE_REQUEST_ID]); } // encodes an UTF-8 text string into the byte buffer @@ -267,26 +316,43 @@ export class BytesEncoder { } // encodes an uint8 into the byte buffer - uint8(val: u8): BytesEncoder { - this.buf.push(val); + uint8(value: u8): BytesEncoder { + this.buf.push(value); return this; } // encodes an uint16 into the byte buffer - // note that these are encoded using leb128 encoding to conserve space - uint16(val: u16): BytesEncoder { - return this.int16(val as i16); + // note that these are encoded using vlu encoding to conserve space + uint16(value: u16): BytesEncoder { + return this.uint64(value as u64); } // encodes an uint32 into the byte buffer - // note that these are encoded using leb128 encoding to conserve space - uint32(val: u32): BytesEncoder { - return this.int32(val as i32); + // note that these are encoded using vlu encoding to conserve space + uint32(value: u32): BytesEncoder { + return this.uint64(value as u64); } // encodes an uint64 into the byte buffer - // note that these are encoded using leb128 encoding to conserve space - uint64(val: u64): BytesEncoder { - return this.int64(val as i64); + // note that these are encoded using vlu encoding to conserve space + // vlu (variable length unsigned) encoder + uint64(value: u64): BytesEncoder { + // first group of 7 bits + let b = (value as u8) & 0x7f; + value >>= 7; + + // keep shifting until all bits are done + while (value != 0) { + // emit with continuation bit + this.buf.push(b | 0x80); + + // next group of 7 bits + b = (value as u8) & 0x7f; + value >>= 7; + } + + // emit without continuation bit + this.buf.push(b); + return this; } } diff --git a/packages/vm/wasmproc/bytes.go b/packages/vm/wasmproc/bytes.go deleted file mode 100644 index e05b2a6488..0000000000 --- a/packages/vm/wasmproc/bytes.go +++ /dev/null @@ -1,166 +0,0 @@ -// Copyright 2020 IOTA Stiftung -// SPDX-License-Identifier: Apache-2.0 - -package wasmproc - -type BytesDecoder struct { - data []byte -} - -func NewBytesDecoder(data []byte) *BytesDecoder { - return &BytesDecoder{data: data} -} - -func (d *BytesDecoder) Bool() bool { - return d.Int8() != 0 -} - -func (d *BytesDecoder) Bytes() []byte { - size := int(d.Int32()) - if len(d.data) < size { - panic("insufficient bytes") - } - value := d.data[:size] - d.data = d.data[size:] - return value -} - -func (d *BytesDecoder) Int8() int8 { - if len(d.data) == 0 { - panic("insufficient bytes") - } - value := d.data[0] - d.data = d.data[1:] - return int8(value) -} - -func (d *BytesDecoder) Int16() int16 { - return int16(d.leb128Decode(16)) -} - -func (d *BytesDecoder) Int32() int32 { - return int32(d.leb128Decode(32)) -} - -func (d *BytesDecoder) Int64() int64 { - return d.leb128Decode(64) -} - -// leb128 decoder -func (d *BytesDecoder) leb128Decode(bits int) int64 { - val := int64(0) - s := 0 - for { - if len(d.data) == 0 { - panic("insufficient bytes") - } - b := int8(d.data[0]) - d.data = d.data[1:] - val |= int64(b&0x7f) << s - if (b & -0x80) == 0 { - if int8(val>>s)&0x7f != b&0x7f { - panic("integer too large") - } - - // extend int7 sign to int8 - b |= (b & 0x40) << 1 - - // extend int8 sign to int64 - return val | (int64(b) << s) - } - s += 7 - if s >= bits { - panic("integer representation too long") - } - } -} - -func (d *BytesDecoder) Uint8() uint8 { - return uint8(d.Int8()) -} - -func (d *BytesDecoder) Uint16() uint16 { - return uint16(d.Int16()) -} - -func (d *BytesDecoder) Uint32() uint32 { - return uint32(d.Int32()) -} - -func (d *BytesDecoder) Uint64() uint64 { - return uint64(d.Int64()) -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -type BytesEncoder struct { - data []byte -} - -func NewBytesEncoder() *BytesEncoder { - return &BytesEncoder{data: make([]byte, 0, 128)} -} - -func (e *BytesEncoder) Bool(value bool) *BytesEncoder { - if value { - return e.Int8(1) - } - return e.Int8(0) -} - -func (e *BytesEncoder) Bytes(value []byte) *BytesEncoder { - e.Int32(int32(len(value))) - e.data = append(e.data, value...) - return e -} - -func (e *BytesEncoder) Data() []byte { - return e.data -} - -func (e *BytesEncoder) Int8(value int8) *BytesEncoder { - e.data = append(e.data, byte(value)) - return e -} - -func (e *BytesEncoder) Int16(value int16) *BytesEncoder { - return e.leb128Encode(int64(value)) -} - -func (e *BytesEncoder) Int32(value int32) *BytesEncoder { - return e.leb128Encode(int64(value)) -} - -func (e *BytesEncoder) Int64(value int64) *BytesEncoder { - return e.leb128Encode(value) -} - -// leb128 encoder -func (e *BytesEncoder) leb128Encode(value int64) *BytesEncoder { - for { - b := byte(value) - s := b & 0x40 - value >>= 7 - if (value == 0 && s == 0) || (value == -1 && s != 0) { - e.data = append(e.data, b&0x7f) - return e - } - e.data = append(e.data, b|0x80) - } -} - -func (e *BytesEncoder) Uint8(value uint8) *BytesEncoder { - return e.Int8(int8(value)) -} - -func (e *BytesEncoder) Uint16(value uint16) *BytesEncoder { - return e.Int16(int16(value)) -} - -func (e *BytesEncoder) Uint32(value uint32) *BytesEncoder { - return e.Int32(int32(value)) -} - -func (e *BytesEncoder) Uint64(value uint64) *BytesEncoder { - return e.Int64(int64(value)) -} diff --git a/packages/vm/wasmproc/sccontext.go b/packages/vm/wasmproc/sccontext.go index 9d7e1ad457..176c8f93ec 100644 --- a/packages/vm/wasmproc/sccontext.go +++ b/packages/vm/wasmproc/sccontext.go @@ -7,6 +7,7 @@ import ( "time" "github.com/iotaledger/wasp/packages/iscp/colored" + "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" "github.com/iotaledger/wasp/packages/hashing" "github.com/iotaledger/wasp/packages/iscp" @@ -147,12 +148,12 @@ func (o *ScContext) SetBytes(keyID, typeID int32, bytes []byte) { } func (o *ScContext) processCall(bytes []byte) { - decode := NewBytesDecoder(bytes) - contract, err := iscp.HnameFromBytes(decode.Bytes()) + decode := wasmlib.NewBytesDecoder(bytes) + contract, err := iscp.HnameFromBytes(decode.Hname().Bytes()) if err != nil { o.Panicf(err.Error()) } - function, err := iscp.HnameFromBytes(decode.Bytes()) + function, err := iscp.HnameFromBytes(decode.Hname().Bytes()) if err != nil { o.Panicf(err.Error()) } @@ -179,8 +180,8 @@ func (o *ScContext) processCallUnlocked(contract, function iscp.Hname, params di } func (o *ScContext) processDeploy(bytes []byte) { - decode := NewBytesDecoder(bytes) - programHash, err := hashing.HashValueFromBytes(decode.Bytes()) + decode := wasmlib.NewBytesDecoder(bytes) + programHash, err := hashing.HashValueFromBytes(decode.Hash().Bytes()) if err != nil { o.Panicf(err.Error()) } @@ -202,16 +203,16 @@ func (o *ScContext) processDeployUnlocked(programHash hashing.HashValue, name, d } func (o *ScContext) processPost(bytes []byte) { - decode := NewBytesDecoder(bytes) - chainID, err := iscp.ChainIDFromBytes(decode.Bytes()) + decode := wasmlib.NewBytesDecoder(bytes) + chainID, err := iscp.ChainIDFromBytes(decode.ChainID().Bytes()) if err != nil { o.Panicf(err.Error()) } - contract, err := iscp.HnameFromBytes(decode.Bytes()) + contract, err := iscp.HnameFromBytes(decode.Hname().Bytes()) if err != nil { o.Panicf(err.Error()) } - function, err := iscp.HnameFromBytes(decode.Bytes()) + function, err := iscp.HnameFromBytes(decode.Hname().Bytes()) if err != nil { o.Panicf(err.Error()) } diff --git a/packages/vm/wasmproc/scutility.go b/packages/vm/wasmproc/scutility.go index 2cf6c16d4a..8f31e78581 100644 --- a/packages/vm/wasmproc/scutility.go +++ b/packages/vm/wasmproc/scutility.go @@ -8,6 +8,7 @@ import ( "github.com/iotaledger/wasp/packages/kv/codec" "github.com/iotaledger/wasp/packages/vm/sandbox/sandbox_utils" "github.com/iotaledger/wasp/packages/vm/wasmhost" + "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" ) type ScUtility struct { @@ -85,7 +86,7 @@ func (o *ScUtility) GetTypeID(keyID int32) int32 { } func (o *ScUtility) aggregateBLSSignatures(bytes []byte) []byte { - decode := NewBytesDecoder(bytes) + decode := wasmlib.NewBytesDecoder(bytes) count := int(decode.Int32()) pubKeysBin := make([][]byte, count) for i := 0; i < count; i++ { @@ -100,11 +101,11 @@ func (o *ScUtility) aggregateBLSSignatures(bytes []byte) []byte { if err != nil { o.Panicf(err.Error()) } - return NewBytesEncoder().Bytes(pubKeyBin).Bytes(sigBin).Data() + return wasmlib.NewBytesEncoder().Bytes(pubKeyBin).Bytes(sigBin).Data() } func (o *ScUtility) validBLSSignature(bytes []byte) bool { - decode := NewBytesDecoder(bytes) + decode := wasmlib.NewBytesDecoder(bytes) data := decode.Bytes() pubKey := decode.Bytes() signature := decode.Bytes() @@ -112,7 +113,7 @@ func (o *ScUtility) validBLSSignature(bytes []byte) bool { } func (o *ScUtility) validED25519Signature(bytes []byte) bool { - decode := NewBytesDecoder(bytes) + decode := wasmlib.NewBytesDecoder(bytes) data := decode.Bytes() pubKey := decode.Bytes() signature := decode.Bytes() diff --git a/packages/vm/wasmproc/wasmtosandbox.go b/packages/vm/wasmproc/wasmtosandbox.go index e445a77688..7ff3d1572e 100644 --- a/packages/vm/wasmproc/wasmtosandbox.go +++ b/packages/vm/wasmproc/wasmtosandbox.go @@ -12,6 +12,7 @@ import ( "github.com/iotaledger/wasp/packages/iscp/colored" "github.com/iotaledger/wasp/packages/kv/codec" "github.com/iotaledger/wasp/packages/kv/dict" + "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" ) const ( @@ -138,10 +139,10 @@ func (f *WasmToSandbox) fnBlockContext(args []byte) []byte { } func (f *WasmToSandbox) fnCall(args []byte) []byte { - decode := NewBytesDecoder(args) - contract, err := iscp.HnameFromBytes(decode.Bytes()) + decode := wasmlib.NewBytesDecoder(args) + contract, err := iscp.HnameFromBytes(decode.Hname().Bytes()) f.checkErr(err) - function, err := iscp.HnameFromBytes(decode.Bytes()) + function, err := iscp.HnameFromBytes(decode.Hname().Bytes()) f.checkErr(err) params, err := dict.FromBytes(decode.Bytes()) f.checkErr(err) @@ -184,8 +185,8 @@ func (f *WasmToSandbox) fnContractCreator(args []byte) []byte { } func (f *WasmToSandbox) fnDeployContract(args []byte) []byte { - decode := NewBytesDecoder(args) - programHash, err := hashing.HashValueFromBytes(decode.Bytes()) + decode := wasmlib.NewBytesDecoder(args) + programHash, err := hashing.HashValueFromBytes(decode.Hash().Bytes()) f.checkErr(err) name := string(decode.Bytes()) description := string(decode.Bytes()) @@ -236,12 +237,12 @@ func (f *WasmToSandbox) fnParams(args []byte) []byte { } func (f *WasmToSandbox) fnPost(args []byte) []byte { - decode := NewBytesDecoder(args) - chainID, err := iscp.ChainIDFromBytes(decode.Bytes()) + decode := wasmlib.NewBytesDecoder(args) + chainID, err := iscp.ChainIDFromBytes(decode.ChainID().Bytes()) f.checkErr(err) - contract, err := iscp.HnameFromBytes(decode.Bytes()) + contract, err := iscp.HnameFromBytes(decode.Hname().Bytes()) f.checkErr(err) - function, err := iscp.HnameFromBytes(decode.Bytes()) + function, err := iscp.HnameFromBytes(decode.Hname().Bytes()) f.checkErr(err) f.Tracef("POST c'%s' f'%s'", contract.String(), function.String()) params, err := dict.FromBytes(decode.Bytes()) @@ -285,8 +286,8 @@ func (f *WasmToSandbox) fnRequestID(args []byte) []byte { // transfer tokens to address func (f *WasmToSandbox) fnSend(args []byte) []byte { - decode := NewBytesDecoder(args) - address, _, err := ledgerstate.AddressFromBytes(decode.Bytes()) + decode := wasmlib.NewBytesDecoder(args) + address, _, err := ledgerstate.AddressFromBytes(decode.Address().Bytes()) f.checkErr(err) transfer, err := colored.BalancesFromBytes(decode.Bytes()) f.checkErr(err) diff --git a/packages/vm/wasmproc/wasmtosandboxutils.go b/packages/vm/wasmproc/wasmtosandboxutils.go index 08cae61a0f..1968fbd9d6 100644 --- a/packages/vm/wasmproc/wasmtosandboxutils.go +++ b/packages/vm/wasmproc/wasmtosandboxutils.go @@ -5,6 +5,7 @@ package wasmproc import ( "github.com/iotaledger/wasp/packages/kv/codec" + "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" ) func (f WasmToSandbox) fnUtilsBase58Decode(args []byte) []byte { @@ -24,7 +25,7 @@ func (f WasmToSandbox) fnUtilsBlsAddress(args []byte) []byte { } func (f WasmToSandbox) fnUtilsBlsAggregate(args []byte) []byte { - decode := NewBytesDecoder(args) + decode := wasmlib.NewBytesDecoder(args) count := int(decode.Int32()) pubKeysBin := make([][]byte, count) for i := 0; i < count; i++ { @@ -37,11 +38,11 @@ func (f WasmToSandbox) fnUtilsBlsAggregate(args []byte) []byte { } pubKeyBin, sigBin, err := f.common.Utils().BLS().AggregateBLSSignatures(pubKeysBin, sigsBin) f.checkErr(err) - return NewBytesEncoder().Bytes(pubKeyBin).Bytes(sigBin).Data() + return wasmlib.NewBytesEncoder().Bytes(pubKeyBin).Bytes(sigBin).Data() } func (f WasmToSandbox) fnUtilsBlsValid(args []byte) []byte { - decode := NewBytesDecoder(args) + decode := wasmlib.NewBytesDecoder(args) data := decode.Bytes() pubKey := decode.Bytes() signature := decode.Bytes() @@ -56,7 +57,7 @@ func (f WasmToSandbox) fnUtilsEd25519Address(args []byte) []byte { } func (f WasmToSandbox) fnUtilsEd25519Valid(args []byte) []byte { - decode := NewBytesDecoder(args) + decode := wasmlib.NewBytesDecoder(args) data := decode.Bytes() pubKey := decode.Bytes() signature := decode.Bytes() diff --git a/packages/vm/wasmsolo/solosccontext.go b/packages/vm/wasmsolo/solosccontext.go index b355b0232f..b976ad334d 100644 --- a/packages/vm/wasmsolo/solosccontext.go +++ b/packages/vm/wasmsolo/solosccontext.go @@ -12,6 +12,7 @@ import ( "github.com/iotaledger/wasp/packages/kv/dict" "github.com/iotaledger/wasp/packages/solo" "github.com/iotaledger/wasp/packages/vm/wasmhost" + "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" "github.com/iotaledger/wasp/packages/vm/wasmproc" ) @@ -71,12 +72,12 @@ func (o *SoloScContext) SetBytes(keyID, typeID int32, bytes []byte) { } func (o *SoloScContext) processCall(bytes []byte) { - decode := wasmproc.NewBytesDecoder(bytes) - contract, err := iscp.HnameFromBytes(decode.Bytes()) + decode := wasmlib.NewBytesDecoder(bytes) + contract, err := iscp.HnameFromBytes(decode.Hname().Bytes()) if err != nil { o.Panicf(err.Error()) } - function, err := iscp.HnameFromBytes(decode.Bytes()) + function, err := iscp.HnameFromBytes(decode.Hname().Bytes()) if err != nil { o.Panicf(err.Error()) } @@ -107,19 +108,19 @@ func (o *SoloScContext) processCall(bytes []byte) { } func (o *SoloScContext) processPost(bytes []byte) { - decode := wasmproc.NewBytesDecoder(bytes) - chainID, err := iscp.ChainIDFromBytes(decode.Bytes()) + decode := wasmlib.NewBytesDecoder(bytes) + chainID, err := iscp.ChainIDFromBytes(decode.ChainID().Bytes()) if err != nil { o.Panicf(err.Error()) } if !chainID.Equals(o.ctx.Chain.ChainID) { o.Panicf("invalid chainID") } - contract, err := iscp.HnameFromBytes(decode.Bytes()) + contract, err := iscp.HnameFromBytes(decode.Hname().Bytes()) if err != nil { o.Panicf(err.Error()) } - function, err := iscp.HnameFromBytes(decode.Bytes()) + function, err := iscp.HnameFromBytes(decode.Hname().Bytes()) if err != nil { o.Panicf(err.Error()) } diff --git a/packages/vm/wasmvmhost/host.go b/packages/vm/wasmvmhost/host.go index a358997f8d..94d045c78f 100644 --- a/packages/vm/wasmvmhost/host.go +++ b/packages/vm/wasmvmhost/host.go @@ -202,7 +202,7 @@ func (w *WasmVMHost) StateGet(key []byte) []byte { // variable sized result expected, // query size first by passing zero length buffer // value will be cached by host - size = hostStateGet(&key[0], int32(len(key)), nil, 0) + size := hostStateGet(&key[0], int32(len(key)), nil, 0) // -1 means non-existent if size < 0 { diff --git a/tools/cluster/tests/wasm/inccounter_bg.wasm b/tools/cluster/tests/wasm/inccounter_bg.wasm index 8f2f783f823869861ca1a1735e9f2f5197584f2e..d4f74848bd55265dee241c68f6187e1fc33f9401 100644 GIT binary patch delta 15817 zcmbt*3wTvUmhP_F`<#<-^4L5R2#|eFcqBX{!~_r_6+uBn5#I{RBjIs^fk238D<=v9 z-A%WVLK_V>U^5b@rNItL)Yi##`}O7aI6d|Z^IdO`bH#4IzT6pR+U}w6Fb<#0|JUC8 zs#Sljz4`k?a@R50J~8g3@nd2^`A1D!FB7Xf3#Czgdk!t*&Sa-+6P3t!_Z``!1W${tbdQ==m)r9xN*!RRE z?}_Kch+F;)1>X_wt?!B_#qcr94~RDL4yOBk@v@lR|4+pWsD4)zl->TCNZxir^!wXC zpz!dzz4;IJtPwk}pEs?bHt+*%V=F7O+)vYhs zBiEc1i3s>hAik}PjN&$oXL*i$M0gR;cH0GN+9XR!4$YHs6xgjvq3jmb_6DR(L}glC z@I^>Ug~_)hMKc;i%VkcUh@(z#b*g9V5^;12@%$ZY;WluR!n{bZ_&uL89o-k8)YHiHRFHB0$hWhRKNm&90 z%M%_l0@Z<%pe67)F4Ticw}i^6GosDUkD#T|j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NtZ9Jm$5WzT*_`UX5?Xtxajo0(@Wbw^+p=n=~$R0_r%N zSvTsRJUc}GCZR7q+mPoLctegU(DmDk@>T$(v;gnhJ~XclAXj@|f!@7+usl_uPj9d7 z^&e=BqxG_nJsa1d9Yag2dOB7Cnrl&V%!w$;3+Nd;CZ>X3tI$mS??Op^??V~!$PVrp z(d#{cg8*_XatYt-*?DotrtsuNeI2t*v(U!n3gAVkQ^Wwi9rc^= Date: Tue, 18 Jan 2022 10:24:02 -0800 Subject: [PATCH 025/111] remove temporary TS-only test --- contracts/wasm/inccounter/test/inccounter_test.go | 1 - 1 file changed, 1 deletion(-) diff --git a/contracts/wasm/inccounter/test/inccounter_test.go b/contracts/wasm/inccounter/test/inccounter_test.go index df42fb1f66..116003bea3 100644 --- a/contracts/wasm/inccounter/test/inccounter_test.go +++ b/contracts/wasm/inccounter/test/inccounter_test.go @@ -157,7 +157,6 @@ func TestLeb128(t *testing.T) { } func TestVli(t *testing.T) { - *wasmsolo.TsWasm = true wasmhost.DisableWasmTimeout = true ctx := setupTest(t) wasmhost.DisableWasmTimeout = false From 7549cc18c17e3350e3e98bdf159061efc3f8155d Mon Sep 17 00:00:00 2001 From: Eric Hop Date: Tue, 18 Jan 2022 13:20:37 -0800 Subject: [PATCH 026/111] Added tests and fixed bugs --- .../test/donatewithfeedback_bg.wasm | Bin 36885 -> 36886 bytes .../wasm/fairauction/test/fairauction_bg.wasm | Bin 43244 -> 43245 bytes .../wasm/inccounter/go/inccounter/consts.go | 17 +- .../wasm/inccounter/go/inccounter/contract.go | 26 ++- .../inccounter/go/inccounter/inccounter.go | 168 +++++++++++----- .../wasm/inccounter/go/inccounter/keys.go | 36 ++-- .../wasm/inccounter/go/inccounter/lib.go | 57 +++++- .../wasm/inccounter/go/inccounter/params.go | 24 ++- .../wasm/inccounter/go/inccounter/results.go | 56 +++++- contracts/wasm/inccounter/schema.yaml | 17 +- contracts/wasm/inccounter/src/consts.rs | 17 +- contracts/wasm/inccounter/src/contract.rs | 34 +++- contracts/wasm/inccounter/src/inccounter.rs | 161 ++++++++++----- contracts/wasm/inccounter/src/keys.rs | 32 +-- contracts/wasm/inccounter/src/lib.rs | 57 +++++- contracts/wasm/inccounter/src/params.rs | 30 ++- contracts/wasm/inccounter/src/results.rs | 62 +++++- .../wasm/inccounter/test/inccounter_bg.wasm | Bin 38792 -> 42133 bytes .../wasm/inccounter/test/inccounter_test.go | 38 +++- .../wasm/inccounter/ts/inccounter/consts.ts | 17 +- .../wasm/inccounter/ts/inccounter/contract.ts | 40 +++- .../inccounter/ts/inccounter/inccounter.ts | 186 +++++++++++++----- .../wasm/inccounter/ts/inccounter/keys.ts | 30 +-- .../wasm/inccounter/ts/inccounter/lib.ts | 35 +++- .../wasm/inccounter/ts/inccounter/params.ts | 20 +- .../wasm/inccounter/ts/inccounter/results.ts | 52 ++++- packages/vm/wasmlib/src/bytes.rs | 2 +- tools/cluster/tests/wasm/inccounter_bg.wasm | Bin 38792 -> 42133 bytes 28 files changed, 921 insertions(+), 293 deletions(-) diff --git a/contracts/wasm/donatewithfeedback/test/donatewithfeedback_bg.wasm b/contracts/wasm/donatewithfeedback/test/donatewithfeedback_bg.wasm index f0016f184e0b0eaaac7d08459d17cfbce1e40631..33d073d8315aed7757f404bf972740bd134b2133 100644 GIT binary patch delta 38 ucmbQbfN9zSrVZa18Q*OF&Nv}iAcu*mp0Q4WK_EzpajnyThRxGb>$LzP#tsSq delta 37 tcmbQXfNAOirVZa18DDSy&Nv~NKbwiEp0Q4WK_Ezpajld6=IN>RS^yGO4M+e0 diff --git a/contracts/wasm/fairauction/test/fairauction_bg.wasm b/contracts/wasm/fairauction/test/fairauction_bg.wasm index db1f3cd4cdfb47634df551c48587d5d62b298b6f..c884a18b34a29349648138b2088fc6e44712c017 100644 GIT binary patch delta 38 ucmaEJk?HM4rVT1gjIEnhnV8E3a+sLv8S4}n1d@~(*E;=Y*lb?8RUZHY;tZGo delta 37 tcmaERk?GAvrVT1gj4hj0nV8G@vzeIc8S4}n1d@~(*E-p6wy4~y4*>MV3)TPt diff --git a/contracts/wasm/inccounter/go/inccounter/consts.go b/contracts/wasm/inccounter/go/inccounter/consts.go index 448ea6200d..d719837956 100644 --- a/contracts/wasm/inccounter/go/inccounter/consts.go +++ b/contracts/wasm/inccounter/go/inccounter/consts.go @@ -19,16 +19,19 @@ const ( ParamCounter = "counter" ParamDelay = "delay" ParamDummy = "dummy" - ParamN = "n" + ParamNi64 = "ni64" + ParamNu64 = "nu64" ParamNumRepeats = "numRepeats" ) const ( ResultBuf = "buf" ResultCounter = "counter" - ResultN = "n" + ResultNi64 = "ni64" + ResultNu64 = "nu64" ResultStr = "str" - ResultX = "x" + ResultXi64 = "xi64" + ResultXu64 = "xu64" ) const ( @@ -48,10 +51,12 @@ const ( FuncLocalStateSandboxCall = "localStateSandboxCall" FuncPostIncrement = "postIncrement" FuncRepeatMany = "repeatMany" - FuncTestLeb128 = "testLeb128" + FuncTestVliCodec = "testVliCodec" + FuncTestVluCodec = "testVluCodec" FuncWhenMustIncrement = "whenMustIncrement" ViewGetCounter = "getCounter" ViewGetVli = "getVli" + ViewGetVlu = "getVlu" ) const ( @@ -66,8 +71,10 @@ const ( HFuncLocalStateSandboxCall = wasmlib.ScHname(0x7bd22c53) HFuncPostIncrement = wasmlib.ScHname(0x81c772f5) HFuncRepeatMany = wasmlib.ScHname(0x4ff450d3) - HFuncTestLeb128 = wasmlib.ScHname(0xd8364cb9) + HFuncTestVliCodec = wasmlib.ScHname(0xd5356012) + HFuncTestVluCodec = wasmlib.ScHname(0x9f7f63e6) HFuncWhenMustIncrement = wasmlib.ScHname(0xb4c3e7a6) HViewGetCounter = wasmlib.ScHname(0xb423e607) HViewGetVli = wasmlib.ScHname(0x0ee16f89) + HViewGetVlu = wasmlib.ScHname(0x54d624e6) ) diff --git a/contracts/wasm/inccounter/go/inccounter/contract.go b/contracts/wasm/inccounter/go/inccounter/contract.go index 52c5b9a79b..3cec4024ef 100644 --- a/contracts/wasm/inccounter/go/inccounter/contract.go +++ b/contracts/wasm/inccounter/go/inccounter/contract.go @@ -56,7 +56,11 @@ type RepeatManyCall struct { Params MutableRepeatManyParams } -type TestLeb128Call struct { +type TestVliCodecCall struct { + Func *wasmlib.ScFunc +} + +type TestVluCodecCall struct { Func *wasmlib.ScFunc } @@ -76,6 +80,12 @@ type GetVliCall struct { Results ImmutableGetVliResults } +type GetVluCall struct { + Func *wasmlib.ScView + Params MutableGetVluParams + Results ImmutableGetVluResults +} + type Funcs struct{} var ScFuncs Funcs @@ -130,8 +140,12 @@ func (sc Funcs) RepeatMany(ctx wasmlib.ScFuncCallContext) *RepeatManyCall { return f } -func (sc Funcs) TestLeb128(ctx wasmlib.ScFuncCallContext) *TestLeb128Call { - return &TestLeb128Call{Func: wasmlib.NewScFunc(ctx, HScName, HFuncTestLeb128)} +func (sc Funcs) TestVliCodec(ctx wasmlib.ScFuncCallContext) *TestVliCodecCall { + return &TestVliCodecCall{Func: wasmlib.NewScFunc(ctx, HScName, HFuncTestVliCodec)} +} + +func (sc Funcs) TestVluCodec(ctx wasmlib.ScFuncCallContext) *TestVluCodecCall { + return &TestVluCodecCall{Func: wasmlib.NewScFunc(ctx, HScName, HFuncTestVluCodec)} } func (sc Funcs) WhenMustIncrement(ctx wasmlib.ScFuncCallContext) *WhenMustIncrementCall { @@ -151,3 +165,9 @@ func (sc Funcs) GetVli(ctx wasmlib.ScViewCallContext) *GetVliCall { f.Func.SetPtrs(&f.Params.id, &f.Results.id) return f } + +func (sc Funcs) GetVlu(ctx wasmlib.ScViewCallContext) *GetVluCall { + f := &GetVluCall{Func: wasmlib.NewScView(ctx, HScName, HViewGetVlu)} + f.Func.SetPtrs(&f.Params.id, &f.Results.id) + return f +} diff --git a/contracts/wasm/inccounter/go/inccounter/inccounter.go b/contracts/wasm/inccounter/go/inccounter/inccounter.go index 819d434c13..99b69b561b 100644 --- a/contracts/wasm/inccounter/go/inccounter/inccounter.go +++ b/contracts/wasm/inccounter/go/inccounter/inccounter.go @@ -9,6 +9,8 @@ import ( "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" ) +const hex = "0123456789abcdef" + var LocalStateMustIncrement = false func funcInit(ctx wasmlib.ScFuncContext, f *InitContext) { @@ -49,6 +51,12 @@ func funcIncrement(ctx wasmlib.ScFuncContext, f *IncrementContext) { counter.SetValue(counter.Value() + 1) } +func funcIncrementWithDelay(ctx wasmlib.ScFuncContext, f *IncrementWithDelayContext) { + delay := f.Params.Delay().Value() + inc := ScFuncs.CallIncrement(ctx) + inc.Func.Delay(delay).TransferIotas(1).Post() +} + func funcLocalStateInternalCall(ctx wasmlib.ScFuncContext, f *LocalStateInternalCallContext) { LocalStateMustIncrement = false whenMustIncrementState(ctx, f.State) @@ -104,13 +112,52 @@ func funcRepeatMany(ctx wasmlib.ScFuncContext, f *RepeatManyContext) { ScFuncs.RepeatMany(ctx).Func.TransferIotas(1).Post() } +//nolint:unparam +func funcTestVliCodec(ctx wasmlib.ScFuncContext, f *TestVliCodecContext) { + vliSave(ctx, "v-129", -129) + vliSave(ctx, "v-128", -128) + vliSave(ctx, "v-127", -127) + vliSave(ctx, "v-126", -126) + vliSave(ctx, "v-65", -65) + vliSave(ctx, "v-64", -64) + vliSave(ctx, "v-63", -63) + vliSave(ctx, "v-62", -62) + vliSave(ctx, "v-2", -2) + vliSave(ctx, "v-1", -1) + vliSave(ctx, "v 0", 0) + vliSave(ctx, "v+1", 1) + vliSave(ctx, "v+2", 2) + vliSave(ctx, "v+62", 62) + vliSave(ctx, "v+63", 63) + vliSave(ctx, "v+64", 64) + vliSave(ctx, "v+65", 65) + vliSave(ctx, "v+126", 126) + vliSave(ctx, "v+127", 127) + vliSave(ctx, "v+128", 128) + vliSave(ctx, "v+129", 129) +} + +//nolint:unparam +func funcTestVluCodec(ctx wasmlib.ScFuncContext, f *TestVluCodecContext) { + vluSave(ctx, "v 0", 0) + vluSave(ctx, "v+1", 1) + vluSave(ctx, "v+2", 2) + vluSave(ctx, "v+62", 62) + vluSave(ctx, "v+63", 63) + vluSave(ctx, "v+64", 64) + vluSave(ctx, "v+65", 65) + vluSave(ctx, "v+126", 126) + vluSave(ctx, "v+127", 127) + vluSave(ctx, "v+128", 128) + vluSave(ctx, "v+129", 129) +} + func funcWhenMustIncrement(ctx wasmlib.ScFuncContext, f *WhenMustIncrementContext) { whenMustIncrementState(ctx, f.State) } -// note that get_counter mirrors the state of the 'counter' state variable +// note that getCounter mirrors the state of the 'counter' state variable // which means that if the state variable was not present it also will not be present in the result - func viewGetCounter(ctx wasmlib.ScViewContext, f *GetCounterContext) { counter := f.State.Counter() if counter.Exists() { @@ -118,24 +165,60 @@ func viewGetCounter(ctx wasmlib.ScViewContext, f *GetCounterContext) { } } -//nolint:unparam -func funcTestLeb128(ctx wasmlib.ScFuncContext, f *TestLeb128Context) { - leb128Save(ctx, "v-1", -1) - leb128Save(ctx, "v-2", -2) - leb128Save(ctx, "v-126", -126) - leb128Save(ctx, "v-127", -127) - leb128Save(ctx, "v-128", -128) - leb128Save(ctx, "v-129", -129) - leb128Save(ctx, "v0", 0) - leb128Save(ctx, "v+1", 1) - leb128Save(ctx, "v+2", 2) - leb128Save(ctx, "v+126", 126) - leb128Save(ctx, "v+127", 127) - leb128Save(ctx, "v+128", 128) - leb128Save(ctx, "v+129", 129) -} - -func leb128Save(ctx wasmlib.ScFuncContext, name string, value int64) { +//nolint:dupl +func viewGetVli(ctx wasmlib.ScViewContext, f *GetVliContext) { + enc := wasmlib.NewBytesEncoder() + n := f.Params.Ni64().Value() + enc = enc.Int64(n) + buf := enc.Data() + dec := wasmlib.NewBytesDecoder(buf) + x := dec.Int64() + + str := strconv.FormatInt(n, 10) + " -" + for j := 0; j < len(buf); j++ { + b := buf[j] + str += " " + string(append([]byte(nil), hex[(b>>4)&0x0f], hex[b&0x0f])) + } + str += " - " + strconv.FormatInt(x, 10) + + f.Results.Ni64().SetValue(n) + f.Results.Xi64().SetValue(x) + f.Results.Str().SetValue(str) + f.Results.Buf().SetValue(buf) +} + +//nolint:dupl +func viewGetVlu(ctx wasmlib.ScViewContext, f *GetVluContext) { + enc := wasmlib.NewBytesEncoder() + n := f.Params.Nu64().Value() + enc = enc.Uint64(n) + buf := enc.Data() + dec := wasmlib.NewBytesDecoder(buf) + x := dec.Uint64() + + str := strconv.FormatUint(n, 10) + " -" + for j := 0; j < len(buf); j++ { + b := buf[j] + str += " " + string(append([]byte(nil), hex[(b>>4)&0x0f], hex[b&0x0f])) + } + str += " - " + strconv.FormatUint(x, 10) + + f.Results.Nu64().SetValue(n) + f.Results.Xu64().SetValue(x) + f.Results.Str().SetValue(str) + f.Results.Buf().SetValue(buf) +} + +//////////////////////////////// util funcs \\\\\\\\\\\\\\\\\\\\\\\\\\\\\ + +func localStatePost(ctx wasmlib.ScFuncContext, nr int64) { + // note: we add a dummy parameter here to prevent "duplicate outputs not allowed" error + f := ScFuncs.WhenMustIncrement(ctx) + f.Params.Dummy().SetValue(nr) + f.Func.TransferIotas(1).Post() +} + +func vliSave(ctx wasmlib.ScFuncContext, name string, value int64) { encoder := wasmlib.NewBytesEncoder() encoder.Int64(value) spot := ctx.State().GetBytes(wasmlib.Key(name)) @@ -150,11 +233,19 @@ func leb128Save(ctx wasmlib.ScFuncContext, name string, value int64) { } } -func localStatePost(ctx wasmlib.ScFuncContext, nr int64) { - // note: we add a dummy parameter here to prevent "duplicate outputs not allowed" error - f := ScFuncs.WhenMustIncrement(ctx) - f.Params.Dummy().SetValue(nr) - f.Func.TransferIotas(1).Post() +func vluSave(ctx wasmlib.ScFuncContext, name string, value uint64) { + encoder := wasmlib.NewBytesEncoder() + encoder.Uint64(value) + spot := ctx.State().GetBytes(wasmlib.Key(name)) + spot.SetValue(encoder.Data()) + + bytes := spot.Value() + decoder := wasmlib.NewBytesDecoder(bytes) + retrieved := decoder.Uint64() + if retrieved != value { + ctx.Log(name + " in : " + ctx.Utility().String(int64(value))) + ctx.Log(name + " out: " + ctx.Utility().String(int64(retrieved))) + } } func whenMustIncrementState(ctx wasmlib.ScFuncContext, state MutableIncCounterState) { @@ -165,30 +256,3 @@ func whenMustIncrementState(ctx wasmlib.ScFuncContext, state MutableIncCounterSt counter := state.Counter() counter.SetValue(counter.Value() + 1) } - -func funcIncrementWithDelay(ctx wasmlib.ScFuncContext, f *IncrementWithDelayContext) { - delay := f.Params.Delay().Value() - inc := ScFuncs.CallIncrement(ctx) - inc.Func.Delay(delay).TransferIotas(1).Post() -} - -const hex = "0123456789abcdef" - -func viewGetVli(ctx wasmlib.ScViewContext, f *GetVliContext) { - d := wasmlib.NewBytesEncoder() - n := f.Params.N().Value() - d = d.Int64(n) - buf := d.Data() - str := strconv.FormatInt(n, 10) + " -" - for j := 0; j < len(buf); j++ { - b := buf[j] - str += " " + string(append([]byte(nil), hex[(b>>4)&0x0f], hex[b&0x0f])) - } - e := wasmlib.NewBytesDecoder(buf) - x := e.Int64() - str += " - " + strconv.FormatInt(x, 10) - f.Results.N().SetValue(n) - f.Results.X().SetValue(x) - f.Results.Str().SetValue(str) - f.Results.Buf().SetValue(buf) -} diff --git a/contracts/wasm/inccounter/go/inccounter/keys.go b/contracts/wasm/inccounter/go/inccounter/keys.go index 9d7fe5ee44..610bac8cf6 100644 --- a/contracts/wasm/inccounter/go/inccounter/keys.go +++ b/contracts/wasm/inccounter/go/inccounter/keys.go @@ -13,32 +13,38 @@ const ( IdxParamCounter = 0 IdxParamDelay = 1 IdxParamDummy = 2 - IdxParamN = 3 - IdxParamNumRepeats = 4 - - IdxResultBuf = 5 - IdxResultCounter = 6 - IdxResultN = 7 - IdxResultStr = 8 - IdxResultX = 9 - - IdxStateCounter = 10 - IdxStateNumRepeats = 11 + IdxParamNi64 = 3 + IdxParamNu64 = 4 + IdxParamNumRepeats = 5 + + IdxResultBuf = 6 + IdxResultCounter = 7 + IdxResultNi64 = 8 + IdxResultNu64 = 9 + IdxResultStr = 10 + IdxResultXi64 = 11 + IdxResultXu64 = 12 + + IdxStateCounter = 13 + IdxStateNumRepeats = 14 ) -const keyMapLen = 12 +const keyMapLen = 15 var keyMap = [keyMapLen]wasmlib.Key{ ParamCounter, ParamDelay, ParamDummy, - ParamN, + ParamNi64, + ParamNu64, ParamNumRepeats, ResultBuf, ResultCounter, - ResultN, + ResultNi64, + ResultNu64, ResultStr, - ResultX, + ResultXi64, + ResultXu64, StateCounter, StateNumRepeats, } diff --git a/contracts/wasm/inccounter/go/inccounter/lib.go b/contracts/wasm/inccounter/go/inccounter/lib.go index 3c4b573e05..e1760a0dd6 100644 --- a/contracts/wasm/inccounter/go/inccounter/lib.go +++ b/contracts/wasm/inccounter/go/inccounter/lib.go @@ -22,10 +22,12 @@ func OnLoad() { exports.AddFunc(FuncLocalStateSandboxCall, funcLocalStateSandboxCallThunk) exports.AddFunc(FuncPostIncrement, funcPostIncrementThunk) exports.AddFunc(FuncRepeatMany, funcRepeatManyThunk) - exports.AddFunc(FuncTestLeb128, funcTestLeb128Thunk) + exports.AddFunc(FuncTestVliCodec, funcTestVliCodecThunk) + exports.AddFunc(FuncTestVluCodec, funcTestVluCodecThunk) exports.AddFunc(FuncWhenMustIncrement, funcWhenMustIncrementThunk) exports.AddView(ViewGetCounter, viewGetCounterThunk) exports.AddView(ViewGetVli, viewGetVliThunk) + exports.AddView(ViewGetVlu, viewGetVluThunk) for i, key := range keyMap { idxMap[i] = key.KeyID() @@ -210,19 +212,34 @@ func funcRepeatManyThunk(ctx wasmlib.ScFuncContext) { ctx.Log("inccounter.funcRepeatMany ok") } -type TestLeb128Context struct { +type TestVliCodecContext struct { State MutableIncCounterState } -func funcTestLeb128Thunk(ctx wasmlib.ScFuncContext) { - ctx.Log("inccounter.funcTestLeb128") - f := &TestLeb128Context{ +func funcTestVliCodecThunk(ctx wasmlib.ScFuncContext) { + ctx.Log("inccounter.funcTestVliCodec") + f := &TestVliCodecContext{ State: MutableIncCounterState{ id: wasmlib.OBJ_ID_STATE, }, } - funcTestLeb128(ctx, f) - ctx.Log("inccounter.funcTestLeb128 ok") + funcTestVliCodec(ctx, f) + ctx.Log("inccounter.funcTestVliCodec ok") +} + +type TestVluCodecContext struct { + State MutableIncCounterState +} + +func funcTestVluCodecThunk(ctx wasmlib.ScFuncContext) { + ctx.Log("inccounter.funcTestVluCodec") + f := &TestVluCodecContext{ + State: MutableIncCounterState{ + id: wasmlib.OBJ_ID_STATE, + }, + } + funcTestVluCodec(ctx, f) + ctx.Log("inccounter.funcTestVluCodec ok") } type WhenMustIncrementContext struct { @@ -282,7 +299,31 @@ func viewGetVliThunk(ctx wasmlib.ScViewContext) { id: wasmlib.OBJ_ID_STATE, }, } - ctx.Require(f.Params.N().Exists(), "missing mandatory n") + ctx.Require(f.Params.Ni64().Exists(), "missing mandatory ni64") viewGetVli(ctx, f) ctx.Log("inccounter.viewGetVli ok") } + +type GetVluContext struct { + Params ImmutableGetVluParams + Results MutableGetVluResults + State ImmutableIncCounterState +} + +func viewGetVluThunk(ctx wasmlib.ScViewContext) { + ctx.Log("inccounter.viewGetVlu") + f := &GetVluContext{ + Params: ImmutableGetVluParams{ + id: wasmlib.OBJ_ID_PARAMS, + }, + Results: MutableGetVluResults{ + id: wasmlib.OBJ_ID_RESULTS, + }, + State: ImmutableIncCounterState{ + id: wasmlib.OBJ_ID_STATE, + }, + } + ctx.Require(f.Params.Nu64().Exists(), "missing mandatory nu64") + viewGetVlu(ctx, f) + ctx.Log("inccounter.viewGetVlu ok") +} diff --git a/contracts/wasm/inccounter/go/inccounter/params.go b/contracts/wasm/inccounter/go/inccounter/params.go index 8e69f15ac9..a6eb77a0e6 100644 --- a/contracts/wasm/inccounter/go/inccounter/params.go +++ b/contracts/wasm/inccounter/go/inccounter/params.go @@ -77,14 +77,30 @@ type ImmutableGetVliParams struct { id int32 } -func (s ImmutableGetVliParams) N() wasmlib.ScImmutableInt64 { - return wasmlib.NewScImmutableInt64(s.id, wasmlib.KeyID(ParamN)) +func (s ImmutableGetVliParams) Ni64() wasmlib.ScImmutableInt64 { + return wasmlib.NewScImmutableInt64(s.id, wasmlib.KeyID(ParamNi64)) } type MutableGetVliParams struct { id int32 } -func (s MutableGetVliParams) N() wasmlib.ScMutableInt64 { - return wasmlib.NewScMutableInt64(s.id, wasmlib.KeyID(ParamN)) +func (s MutableGetVliParams) Ni64() wasmlib.ScMutableInt64 { + return wasmlib.NewScMutableInt64(s.id, wasmlib.KeyID(ParamNi64)) +} + +type ImmutableGetVluParams struct { + id int32 +} + +func (s ImmutableGetVluParams) Nu64() wasmlib.ScImmutableUint64 { + return wasmlib.NewScImmutableUint64(s.id, wasmlib.KeyID(ParamNu64)) +} + +type MutableGetVluParams struct { + id int32 +} + +func (s MutableGetVluParams) Nu64() wasmlib.ScMutableUint64 { + return wasmlib.NewScMutableUint64(s.id, wasmlib.KeyID(ParamNu64)) } diff --git a/contracts/wasm/inccounter/go/inccounter/results.go b/contracts/wasm/inccounter/go/inccounter/results.go index 5ced4a0c79..adef8f3c81 100644 --- a/contracts/wasm/inccounter/go/inccounter/results.go +++ b/contracts/wasm/inccounter/go/inccounter/results.go @@ -33,16 +33,16 @@ func (s ImmutableGetVliResults) Buf() wasmlib.ScImmutableBytes { return wasmlib.NewScImmutableBytes(s.id, wasmlib.KeyID(ResultBuf)) } -func (s ImmutableGetVliResults) N() wasmlib.ScImmutableInt64 { - return wasmlib.NewScImmutableInt64(s.id, wasmlib.KeyID(ResultN)) +func (s ImmutableGetVliResults) Ni64() wasmlib.ScImmutableInt64 { + return wasmlib.NewScImmutableInt64(s.id, wasmlib.KeyID(ResultNi64)) } func (s ImmutableGetVliResults) Str() wasmlib.ScImmutableString { return wasmlib.NewScImmutableString(s.id, wasmlib.KeyID(ResultStr)) } -func (s ImmutableGetVliResults) X() wasmlib.ScImmutableInt64 { - return wasmlib.NewScImmutableInt64(s.id, wasmlib.KeyID(ResultX)) +func (s ImmutableGetVliResults) Xi64() wasmlib.ScImmutableInt64 { + return wasmlib.NewScImmutableInt64(s.id, wasmlib.KeyID(ResultXi64)) } type MutableGetVliResults struct { @@ -53,14 +53,54 @@ func (s MutableGetVliResults) Buf() wasmlib.ScMutableBytes { return wasmlib.NewScMutableBytes(s.id, wasmlib.KeyID(ResultBuf)) } -func (s MutableGetVliResults) N() wasmlib.ScMutableInt64 { - return wasmlib.NewScMutableInt64(s.id, wasmlib.KeyID(ResultN)) +func (s MutableGetVliResults) Ni64() wasmlib.ScMutableInt64 { + return wasmlib.NewScMutableInt64(s.id, wasmlib.KeyID(ResultNi64)) } func (s MutableGetVliResults) Str() wasmlib.ScMutableString { return wasmlib.NewScMutableString(s.id, wasmlib.KeyID(ResultStr)) } -func (s MutableGetVliResults) X() wasmlib.ScMutableInt64 { - return wasmlib.NewScMutableInt64(s.id, wasmlib.KeyID(ResultX)) +func (s MutableGetVliResults) Xi64() wasmlib.ScMutableInt64 { + return wasmlib.NewScMutableInt64(s.id, wasmlib.KeyID(ResultXi64)) +} + +type ImmutableGetVluResults struct { + id int32 +} + +func (s ImmutableGetVluResults) Buf() wasmlib.ScImmutableBytes { + return wasmlib.NewScImmutableBytes(s.id, wasmlib.KeyID(ResultBuf)) +} + +func (s ImmutableGetVluResults) Nu64() wasmlib.ScImmutableUint64 { + return wasmlib.NewScImmutableUint64(s.id, wasmlib.KeyID(ResultNu64)) +} + +func (s ImmutableGetVluResults) Str() wasmlib.ScImmutableString { + return wasmlib.NewScImmutableString(s.id, wasmlib.KeyID(ResultStr)) +} + +func (s ImmutableGetVluResults) Xu64() wasmlib.ScImmutableUint64 { + return wasmlib.NewScImmutableUint64(s.id, wasmlib.KeyID(ResultXu64)) +} + +type MutableGetVluResults struct { + id int32 +} + +func (s MutableGetVluResults) Buf() wasmlib.ScMutableBytes { + return wasmlib.NewScMutableBytes(s.id, wasmlib.KeyID(ResultBuf)) +} + +func (s MutableGetVluResults) Nu64() wasmlib.ScMutableUint64 { + return wasmlib.NewScMutableUint64(s.id, wasmlib.KeyID(ResultNu64)) +} + +func (s MutableGetVluResults) Str() wasmlib.ScMutableString { + return wasmlib.NewScMutableString(s.id, wasmlib.KeyID(ResultStr)) +} + +func (s MutableGetVluResults) Xu64() wasmlib.ScMutableUint64 { + return wasmlib.NewScMutableUint64(s.id, wasmlib.KeyID(ResultXu64)) } diff --git a/contracts/wasm/inccounter/schema.yaml b/contracts/wasm/inccounter/schema.yaml index da9705a56c..9779881237 100644 --- a/contracts/wasm/inccounter/schema.yaml +++ b/contracts/wasm/inccounter/schema.yaml @@ -23,7 +23,8 @@ funcs: repeatMany: params: numRepeats: Int64? // number of times to recursively call myself - testLeb128: {} + testVliCodec: {} + testVluCodec: {} whenMustIncrement: params: dummy: Int64? // dummy param to prevent 'duplicate outputs not allowed' @@ -33,9 +34,17 @@ views: counter: Int64 getVli: params: - n: Int64 + ni64: Int64 results: - n: Int64 - x: Int64 + ni64: Int64 + xi64: Int64 + buf: Bytes + str: String + getVlu: + params: + nu64: Uint64 + results: + nu64: Uint64 + xu64: Uint64 buf: Bytes str: String diff --git a/contracts/wasm/inccounter/src/consts.rs b/contracts/wasm/inccounter/src/consts.rs index b9e2a2c857..2011b76b66 100644 --- a/contracts/wasm/inccounter/src/consts.rs +++ b/contracts/wasm/inccounter/src/consts.rs @@ -16,14 +16,17 @@ pub const HSC_NAME : ScHname = ScHname(0xaf2438e9); pub const PARAM_COUNTER : &str = "counter"; pub const PARAM_DELAY : &str = "delay"; pub const PARAM_DUMMY : &str = "dummy"; -pub const PARAM_N : &str = "n"; +pub const PARAM_NI64 : &str = "ni64"; +pub const PARAM_NU64 : &str = "nu64"; pub const PARAM_NUM_REPEATS : &str = "numRepeats"; pub const RESULT_BUF : &str = "buf"; pub const RESULT_COUNTER : &str = "counter"; -pub const RESULT_N : &str = "n"; +pub const RESULT_NI64 : &str = "ni64"; +pub const RESULT_NU64 : &str = "nu64"; pub const RESULT_STR : &str = "str"; -pub const RESULT_X : &str = "x"; +pub const RESULT_XI64 : &str = "xi64"; +pub const RESULT_XU64 : &str = "xu64"; pub const STATE_COUNTER : &str = "counter"; pub const STATE_NUM_REPEATS : &str = "numRepeats"; @@ -39,10 +42,12 @@ pub const FUNC_LOCAL_STATE_POST : &str = "localStatePost"; pub const FUNC_LOCAL_STATE_SANDBOX_CALL : &str = "localStateSandboxCall"; pub const FUNC_POST_INCREMENT : &str = "postIncrement"; pub const FUNC_REPEAT_MANY : &str = "repeatMany"; -pub const FUNC_TEST_LEB128 : &str = "testLeb128"; +pub const FUNC_TEST_VLI_CODEC : &str = "testVliCodec"; +pub const FUNC_TEST_VLU_CODEC : &str = "testVluCodec"; pub const FUNC_WHEN_MUST_INCREMENT : &str = "whenMustIncrement"; pub const VIEW_GET_COUNTER : &str = "getCounter"; pub const VIEW_GET_VLI : &str = "getVli"; +pub const VIEW_GET_VLU : &str = "getVlu"; pub const HFUNC_CALL_INCREMENT : ScHname = ScHname(0xeb5dcacd); pub const HFUNC_CALL_INCREMENT_RECURSE5X : ScHname = ScHname(0x8749fbff); @@ -55,7 +60,9 @@ pub const HFUNC_LOCAL_STATE_POST : ScHname = ScHname(0x3fd54d13); pub const HFUNC_LOCAL_STATE_SANDBOX_CALL : ScHname = ScHname(0x7bd22c53); pub const HFUNC_POST_INCREMENT : ScHname = ScHname(0x81c772f5); pub const HFUNC_REPEAT_MANY : ScHname = ScHname(0x4ff450d3); -pub const HFUNC_TEST_LEB128 : ScHname = ScHname(0xd8364cb9); +pub const HFUNC_TEST_VLI_CODEC : ScHname = ScHname(0xd5356012); +pub const HFUNC_TEST_VLU_CODEC : ScHname = ScHname(0x9f7f63e6); pub const HFUNC_WHEN_MUST_INCREMENT : ScHname = ScHname(0xb4c3e7a6); pub const HVIEW_GET_COUNTER : ScHname = ScHname(0xb423e607); pub const HVIEW_GET_VLI : ScHname = ScHname(0x0ee16f89); +pub const HVIEW_GET_VLU : ScHname = ScHname(0x54d624e6); diff --git a/contracts/wasm/inccounter/src/contract.rs b/contracts/wasm/inccounter/src/contract.rs index f7cb751442..56934259db 100644 --- a/contracts/wasm/inccounter/src/contract.rs +++ b/contracts/wasm/inccounter/src/contract.rs @@ -62,7 +62,11 @@ pub struct RepeatManyCall { pub params: MutableRepeatManyParams, } -pub struct TestLeb128Call { +pub struct TestVliCodecCall { + pub func: ScFunc, +} + +pub struct TestVluCodecCall { pub func: ScFunc, } @@ -82,6 +86,12 @@ pub struct GetVliCall { pub results: ImmutableGetVliResults, } +pub struct GetVluCall { + pub func: ScView, + pub params: MutableGetVluParams, + pub results: ImmutableGetVluResults, +} + pub struct ScFuncs { } @@ -161,9 +171,15 @@ impl ScFuncs { f } - pub fn test_leb128(_ctx: & dyn ScFuncCallContext) -> TestLeb128Call { - TestLeb128Call { - func: ScFunc::new(HSC_NAME, HFUNC_TEST_LEB128), + pub fn test_vli_codec(_ctx: & dyn ScFuncCallContext) -> TestVliCodecCall { + TestVliCodecCall { + func: ScFunc::new(HSC_NAME, HFUNC_TEST_VLI_CODEC), + } + } + + pub fn test_vlu_codec(_ctx: & dyn ScFuncCallContext) -> TestVluCodecCall { + TestVluCodecCall { + func: ScFunc::new(HSC_NAME, HFUNC_TEST_VLU_CODEC), } } @@ -194,4 +210,14 @@ impl ScFuncs { f.func.set_ptrs(&mut f.params.id, &mut f.results.id); f } + + pub fn get_vlu(_ctx: & dyn ScViewCallContext) -> GetVluCall { + let mut f = GetVluCall { + func: ScView::new(HSC_NAME, HVIEW_GET_VLU), + params: MutableGetVluParams { id: 0 }, + results: ImmutableGetVluResults { id: 0 }, + }; + f.func.set_ptrs(&mut f.params.id, &mut f.results.id); + f + } } diff --git a/contracts/wasm/inccounter/src/inccounter.rs b/contracts/wasm/inccounter/src/inccounter.rs index 64b227266c..a86fc3c75b 100644 --- a/contracts/wasm/inccounter/src/inccounter.rs +++ b/contracts/wasm/inccounter/src/inccounter.rs @@ -6,8 +6,17 @@ use wasmlib::*; use crate::*; use crate::contract::*; +const HEX: &str = "0123456789abcdef"; + static mut LOCAL_STATE_MUST_INCREMENT: bool = false; +pub fn func_init(_ctx: &ScFuncContext, f: &InitContext) { + if f.params.counter().exists() { + let counter = f.params.counter().value(); + f.state.counter().set_value(counter); + } +} + pub fn func_call_increment(ctx: &ScFuncContext, f: &CallIncrementContext) { let counter = f.state.counter(); let value = counter.value(); @@ -41,13 +50,6 @@ pub fn func_increment_with_delay(ctx: &ScFuncContext, f: &IncrementWithDelayCont inc.func.delay(delay).transfer_iotas(1).post(); } -pub fn func_init(_ctx: &ScFuncContext, f: &InitContext) { - if f.params.counter().exists() { - let counter = f.params.counter().value(); - f.state.counter().set_value(counter); - } -} - pub fn func_local_state_internal_call(ctx: &ScFuncContext, f: &LocalStateInternalCallContext) { unsafe { LOCAL_STATE_MUST_INCREMENT = false; @@ -113,20 +115,42 @@ pub fn func_repeat_many(ctx: &ScFuncContext, f: &RepeatManyContext) { ScFuncs::repeat_many(ctx).func.transfer_iotas(1).post(); } -pub fn func_test_leb128(ctx: &ScFuncContext, _f: &TestLeb128Context) { - leb128_save(ctx, "v-1", -1); - leb128_save(ctx, "v-2", -2); - leb128_save(ctx, "v-126", -126); - leb128_save(ctx, "v-127", -127); - leb128_save(ctx, "v-128", -128); - leb128_save(ctx, "v-129", -129); - leb128_save(ctx, "v0", 0); - leb128_save(ctx, "v+1", 1); - leb128_save(ctx, "v+2", 2); - leb128_save(ctx, "v+126", 126); - leb128_save(ctx, "v+127", 127); - leb128_save(ctx, "v+128", 128); - leb128_save(ctx, "v+129", 129); +pub fn func_test_vli_codec(ctx: &ScFuncContext, _f: &TestVliCodecContext) { + vli_save(ctx, "v-129", -129); + vli_save(ctx, "v-128", -128); + vli_save(ctx, "v-127", -127); + vli_save(ctx, "v-126", -126); + vli_save(ctx, "v-65", -65); + vli_save(ctx, "v-64", -64); + vli_save(ctx, "v-63", -63); + vli_save(ctx, "v-62", -62); + vli_save(ctx, "v-2", -2); + vli_save(ctx, "v-1", -1); + vli_save(ctx, "v 0", 0); + vli_save(ctx, "v+1", 1); + vli_save(ctx, "v+2", 2); + vli_save(ctx, "v+62", 62); + vli_save(ctx, "v+63", 63); + vli_save(ctx, "v+64", 64); + vli_save(ctx, "v+65", 65); + vli_save(ctx, "v+126", 126); + vli_save(ctx, "v+127", 127); + vli_save(ctx, "v+128", 128); + vli_save(ctx, "v+129", 129); +} + +pub fn func_test_vlu_codec(ctx: &ScFuncContext, _f: &TestVluCodecContext) { + vlu_save(ctx, "v 0", 0); + vlu_save(ctx, "v+1", 1); + vlu_save(ctx, "v+2", 2); + vlu_save(ctx, "v+62", 62); + vlu_save(ctx, "v+63", 63); + vlu_save(ctx, "v+64", 64); + vlu_save(ctx, "v+65", 65); + vlu_save(ctx, "v+126", 126); + vlu_save(ctx, "v+127", 127); + vlu_save(ctx, "v+128", 128); + vlu_save(ctx, "v+129", 129); } pub fn func_when_must_increment(ctx: &ScFuncContext, f: &WhenMustIncrementContext) { @@ -142,7 +166,60 @@ pub fn view_get_counter(_ctx: &ScViewContext, f: &GetCounterContext) { } } -fn leb128_save(ctx: &ScFuncContext, name: &str, value: i64) { +pub fn view_get_vli(_ctx: &ScViewContext, f: &GetVliContext) { + let mut enc = BytesEncoder::new(); + let n = f.params.ni64().value(); + enc.int64(n); + let buf = enc.data(); + let mut dec = BytesDecoder::new(&buf); + let x = dec.int64(); + + let mut str = n.to_string() + " -"; + for b in &buf { + let h1 = ((b >> 4) & 0x0f) as usize; + let h2 = (b & 0x0f) as usize; + str += &(" ".to_string() + &HEX[h1..h1+1] + &HEX[h2..h2+1]); + } + str += &(" - ".to_string() + &x.to_string()); + + f.results.ni64().set_value(n); + f.results.xi64().set_value(x); + f.results.str().set_value(&str); + f.results.buf().set_value(&buf); +} + +pub fn view_get_vlu(_ctx: &ScViewContext, f: &GetVluContext) { + let mut enc = BytesEncoder::new(); + let n = f.params.nu64().value(); + enc.uint64(n); + let buf = enc.data(); + let mut dec = BytesDecoder::new(&buf); + let x = dec.uint64(); + + let mut str = n.to_string() + " -"; + for b in &buf { + let h1 = ((b >> 4) & 0x0f) as usize; + let h2 = (b & 0x0f) as usize; + str += &(" ".to_string() + &HEX[h1..h1+1] + &HEX[h2..h2+1]); + } + str += &(" - ".to_string() + &x.to_string()); + + f.results.nu64().set_value(n); + f.results.xu64().set_value(x); + f.results.str().set_value(&str); + f.results.buf().set_value(&buf); +} + +//////////////////////////////// util funcs \\\\\\\\\\\\\\\\\\\\\\\\\\\\\ + +fn local_state_post(ctx: &ScFuncContext, nr: i64) { + //note: we add a dummy parameter here to prevent "duplicate outputs not allowed" error + let f = ScFuncs::when_must_increment(ctx); + f.params.dummy().set_value(nr); + f.func.transfer_iotas(1).post(); +} + +fn vli_save(ctx: &ScFuncContext, name: &str, value: i64) { let mut encoder = BytesEncoder::new(); encoder.int64(value); let spot = ctx.state().get_bytes(name); @@ -157,11 +234,19 @@ fn leb128_save(ctx: &ScFuncContext, name: &str, value: i64) { } } -fn local_state_post(ctx: &ScFuncContext, nr: i64) { - //note: we add a dummy parameter here to prevent "duplicate outputs not allowed" error - let f = ScFuncs::when_must_increment(ctx); - f.params.dummy().set_value(nr); - f.func.transfer_iotas(1).post(); +fn vlu_save(ctx: &ScFuncContext, name: &str, value: u64) { + let mut encoder = BytesEncoder::new(); + encoder.uint64(value); + let spot = ctx.state().get_bytes(name); + spot.set_value(&encoder.data()); + + let bytes = spot.value(); + let mut decoder = BytesDecoder::new(&bytes); + let retrieved = decoder.uint64(); + if retrieved != value { + ctx.log(&(name.to_string() + " in : " + &value.to_string())); + ctx.log(&(name.to_string() + " out: " + &retrieved.to_string())); + } } fn when_must_increment_state(ctx: &ScFuncContext, state: &MutableIncCounterState) { @@ -174,25 +259,3 @@ fn when_must_increment_state(ctx: &ScFuncContext, state: &MutableIncCounterState let counter = state.counter(); counter.set_value(counter.value() + 1); } - -const HEX : &str = "0123456789abcdef"; - -pub fn view_get_vli(_ctx: &ScViewContext, f: &GetVliContext) { - let mut d = BytesEncoder::new(); - let n = f.params.n().value(); - d.int64(n); - let mut str = n.to_string() + " -"; - let buf = d.data(); - for b in &buf { - let h1 = ((b >> 4) & 0x0f) as usize; - let h2 = (b & 0x0f) as usize; - str += &(" ".to_string() + &HEX[h1..h1+1] + &HEX[h2..h2+1]); - } - let mut e = BytesDecoder::new(&buf); - let x = e.int64(); - str += &(" - ".to_string() + &x.to_string()); - f.results.n().set_value(n); - f.results.x().set_value(x); - f.results.str().set_value(&str); - f.results.buf().set_value(&buf); -} diff --git a/contracts/wasm/inccounter/src/keys.rs b/contracts/wasm/inccounter/src/keys.rs index 9ce7fc737d..00e4860fe4 100644 --- a/contracts/wasm/inccounter/src/keys.rs +++ b/contracts/wasm/inccounter/src/keys.rs @@ -14,31 +14,37 @@ use crate::*; pub(crate) const IDX_PARAM_COUNTER : usize = 0; pub(crate) const IDX_PARAM_DELAY : usize = 1; pub(crate) const IDX_PARAM_DUMMY : usize = 2; -pub(crate) const IDX_PARAM_N : usize = 3; -pub(crate) const IDX_PARAM_NUM_REPEATS : usize = 4; +pub(crate) const IDX_PARAM_NI64 : usize = 3; +pub(crate) const IDX_PARAM_NU64 : usize = 4; +pub(crate) const IDX_PARAM_NUM_REPEATS : usize = 5; -pub(crate) const IDX_RESULT_BUF : usize = 5; -pub(crate) const IDX_RESULT_COUNTER : usize = 6; -pub(crate) const IDX_RESULT_N : usize = 7; -pub(crate) const IDX_RESULT_STR : usize = 8; -pub(crate) const IDX_RESULT_X : usize = 9; +pub(crate) const IDX_RESULT_BUF : usize = 6; +pub(crate) const IDX_RESULT_COUNTER : usize = 7; +pub(crate) const IDX_RESULT_NI64 : usize = 8; +pub(crate) const IDX_RESULT_NU64 : usize = 9; +pub(crate) const IDX_RESULT_STR : usize = 10; +pub(crate) const IDX_RESULT_XI64 : usize = 11; +pub(crate) const IDX_RESULT_XU64 : usize = 12; -pub(crate) const IDX_STATE_COUNTER : usize = 10; -pub(crate) const IDX_STATE_NUM_REPEATS : usize = 11; +pub(crate) const IDX_STATE_COUNTER : usize = 13; +pub(crate) const IDX_STATE_NUM_REPEATS : usize = 14; -pub const KEY_MAP_LEN: usize = 12; +pub const KEY_MAP_LEN: usize = 15; pub const KEY_MAP: [&str; KEY_MAP_LEN] = [ PARAM_COUNTER, PARAM_DELAY, PARAM_DUMMY, - PARAM_N, + PARAM_NI64, + PARAM_NU64, PARAM_NUM_REPEATS, RESULT_BUF, RESULT_COUNTER, - RESULT_N, + RESULT_NI64, + RESULT_NU64, RESULT_STR, - RESULT_X, + RESULT_XI64, + RESULT_XU64, STATE_COUNTER, STATE_NUM_REPEATS, ]; diff --git a/contracts/wasm/inccounter/src/lib.rs b/contracts/wasm/inccounter/src/lib.rs index 66e6ae8602..38d8a76fc8 100644 --- a/contracts/wasm/inccounter/src/lib.rs +++ b/contracts/wasm/inccounter/src/lib.rs @@ -40,10 +40,12 @@ fn on_load() { exports.add_func(FUNC_LOCAL_STATE_SANDBOX_CALL, func_local_state_sandbox_call_thunk); exports.add_func(FUNC_POST_INCREMENT, func_post_increment_thunk); exports.add_func(FUNC_REPEAT_MANY, func_repeat_many_thunk); - exports.add_func(FUNC_TEST_LEB128, func_test_leb128_thunk); + exports.add_func(FUNC_TEST_VLI_CODEC, func_test_vli_codec_thunk); + exports.add_func(FUNC_TEST_VLU_CODEC, func_test_vlu_codec_thunk); exports.add_func(FUNC_WHEN_MUST_INCREMENT, func_when_must_increment_thunk); exports.add_view(VIEW_GET_COUNTER, view_get_counter_thunk); exports.add_view(VIEW_GET_VLI, view_get_vli_thunk); + exports.add_view(VIEW_GET_VLU, view_get_vlu_thunk); unsafe { for i in 0..KEY_MAP_LEN { @@ -230,19 +232,34 @@ fn func_repeat_many_thunk(ctx: &ScFuncContext) { ctx.log("inccounter.funcRepeatMany ok"); } -pub struct TestLeb128Context { +pub struct TestVliCodecContext { state: MutableIncCounterState, } -fn func_test_leb128_thunk(ctx: &ScFuncContext) { - ctx.log("inccounter.funcTestLeb128"); - let f = TestLeb128Context { +fn func_test_vli_codec_thunk(ctx: &ScFuncContext) { + ctx.log("inccounter.funcTestVliCodec"); + let f = TestVliCodecContext { state: MutableIncCounterState { id: OBJ_ID_STATE, }, }; - func_test_leb128(ctx, &f); - ctx.log("inccounter.funcTestLeb128 ok"); + func_test_vli_codec(ctx, &f); + ctx.log("inccounter.funcTestVliCodec ok"); +} + +pub struct TestVluCodecContext { + state: MutableIncCounterState, +} + +fn func_test_vlu_codec_thunk(ctx: &ScFuncContext) { + ctx.log("inccounter.funcTestVluCodec"); + let f = TestVluCodecContext { + state: MutableIncCounterState { + id: OBJ_ID_STATE, + }, + }; + func_test_vlu_codec(ctx, &f); + ctx.log("inccounter.funcTestVluCodec ok"); } pub struct WhenMustIncrementContext { @@ -302,7 +319,31 @@ fn view_get_vli_thunk(ctx: &ScViewContext) { id: OBJ_ID_STATE, }, }; - ctx.require(f.params.n().exists(), "missing mandatory n"); + ctx.require(f.params.ni64().exists(), "missing mandatory ni64"); view_get_vli(ctx, &f); ctx.log("inccounter.viewGetVli ok"); } + +pub struct GetVluContext { + params: ImmutableGetVluParams, + results: MutableGetVluResults, + state: ImmutableIncCounterState, +} + +fn view_get_vlu_thunk(ctx: &ScViewContext) { + ctx.log("inccounter.viewGetVlu"); + let f = GetVluContext { + params: ImmutableGetVluParams { + id: OBJ_ID_PARAMS, + }, + results: MutableGetVluResults { + id: OBJ_ID_RESULTS, + }, + state: ImmutableIncCounterState { + id: OBJ_ID_STATE, + }, + }; + ctx.require(f.params.nu64().exists(), "missing mandatory nu64"); + view_get_vlu(ctx, &f); + ctx.log("inccounter.viewGetVlu ok"); +} diff --git a/contracts/wasm/inccounter/src/params.rs b/contracts/wasm/inccounter/src/params.rs index a9c3651799..3c90233bd7 100644 --- a/contracts/wasm/inccounter/src/params.rs +++ b/contracts/wasm/inccounter/src/params.rs @@ -108,8 +108,8 @@ pub struct ImmutableGetVliParams { } impl ImmutableGetVliParams { - pub fn n(&self) -> ScImmutableInt64 { - ScImmutableInt64::new(self.id, PARAM_N.get_key_id()) + pub fn ni64(&self) -> ScImmutableInt64 { + ScImmutableInt64::new(self.id, PARAM_NI64.get_key_id()) } } @@ -119,7 +119,29 @@ pub struct MutableGetVliParams { } impl MutableGetVliParams { - pub fn n(&self) -> ScMutableInt64 { - ScMutableInt64::new(self.id, PARAM_N.get_key_id()) + pub fn ni64(&self) -> ScMutableInt64 { + ScMutableInt64::new(self.id, PARAM_NI64.get_key_id()) + } +} + +#[derive(Clone, Copy)] +pub struct ImmutableGetVluParams { + pub(crate) id: i32, +} + +impl ImmutableGetVluParams { + pub fn nu64(&self) -> ScImmutableUint64 { + ScImmutableUint64::new(self.id, PARAM_NU64.get_key_id()) + } +} + +#[derive(Clone, Copy)] +pub struct MutableGetVluParams { + pub(crate) id: i32, +} + +impl MutableGetVluParams { + pub fn nu64(&self) -> ScMutableUint64 { + ScMutableUint64::new(self.id, PARAM_NU64.get_key_id()) } } diff --git a/contracts/wasm/inccounter/src/results.rs b/contracts/wasm/inccounter/src/results.rs index eea66aa61d..e881f488a0 100644 --- a/contracts/wasm/inccounter/src/results.rs +++ b/contracts/wasm/inccounter/src/results.rs @@ -46,16 +46,16 @@ impl ImmutableGetVliResults { ScImmutableBytes::new(self.id, RESULT_BUF.get_key_id()) } - pub fn n(&self) -> ScImmutableInt64 { - ScImmutableInt64::new(self.id, RESULT_N.get_key_id()) + pub fn ni64(&self) -> ScImmutableInt64 { + ScImmutableInt64::new(self.id, RESULT_NI64.get_key_id()) } pub fn str(&self) -> ScImmutableString { ScImmutableString::new(self.id, RESULT_STR.get_key_id()) } - pub fn x(&self) -> ScImmutableInt64 { - ScImmutableInt64::new(self.id, RESULT_X.get_key_id()) + pub fn xi64(&self) -> ScImmutableInt64 { + ScImmutableInt64::new(self.id, RESULT_XI64.get_key_id()) } } @@ -69,15 +69,61 @@ impl MutableGetVliResults { ScMutableBytes::new(self.id, RESULT_BUF.get_key_id()) } - pub fn n(&self) -> ScMutableInt64 { - ScMutableInt64::new(self.id, RESULT_N.get_key_id()) + pub fn ni64(&self) -> ScMutableInt64 { + ScMutableInt64::new(self.id, RESULT_NI64.get_key_id()) } pub fn str(&self) -> ScMutableString { ScMutableString::new(self.id, RESULT_STR.get_key_id()) } - pub fn x(&self) -> ScMutableInt64 { - ScMutableInt64::new(self.id, RESULT_X.get_key_id()) + pub fn xi64(&self) -> ScMutableInt64 { + ScMutableInt64::new(self.id, RESULT_XI64.get_key_id()) + } +} + +#[derive(Clone, Copy)] +pub struct ImmutableGetVluResults { + pub(crate) id: i32, +} + +impl ImmutableGetVluResults { + pub fn buf(&self) -> ScImmutableBytes { + ScImmutableBytes::new(self.id, RESULT_BUF.get_key_id()) + } + + pub fn nu64(&self) -> ScImmutableUint64 { + ScImmutableUint64::new(self.id, RESULT_NU64.get_key_id()) + } + + pub fn str(&self) -> ScImmutableString { + ScImmutableString::new(self.id, RESULT_STR.get_key_id()) + } + + pub fn xu64(&self) -> ScImmutableUint64 { + ScImmutableUint64::new(self.id, RESULT_XU64.get_key_id()) + } +} + +#[derive(Clone, Copy)] +pub struct MutableGetVluResults { + pub(crate) id: i32, +} + +impl MutableGetVluResults { + pub fn buf(&self) -> ScMutableBytes { + ScMutableBytes::new(self.id, RESULT_BUF.get_key_id()) + } + + pub fn nu64(&self) -> ScMutableUint64 { + ScMutableUint64::new(self.id, RESULT_NU64.get_key_id()) + } + + pub fn str(&self) -> ScMutableString { + ScMutableString::new(self.id, RESULT_STR.get_key_id()) + } + + pub fn xu64(&self) -> ScMutableUint64 { + ScMutableUint64::new(self.id, RESULT_XU64.get_key_id()) } } diff --git a/contracts/wasm/inccounter/test/inccounter_bg.wasm b/contracts/wasm/inccounter/test/inccounter_bg.wasm index d4f74848bd55265dee241c68f6187e1fc33f9401..17a9b75f301da132c42d5c306d77d69b15ef615d 100644 GIT binary patch delta 18130 zcmdUX4RlpSmhP!@&dm+Exo`p@AqkLkF98C903jxTD5>!OD=LZ#G(Q5$4L=3~q98YD z1X`g*3R^%_Xyadtf}(*qMeE?%2*Ugk^**D`XfUQid#H}!eyx8d5ZoV+2h}66%-W8vTouYpEYhuM64J%jOyZXNS*DP6k+wF(N zy2Iiy8V7tP`g|smpNVHg@lD53u}5^A_P64@qI>DxKNOq9F%a-=@v0cr=`Habn*UZf zJ*OWMC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); + ctx.require(i == v, "coder value mismatch") + } + + vliSave(ctx, "v-129", -129); + vliSave(ctx, "v-128", -128); + vliSave(ctx, "v-127", -127); + vliSave(ctx, "v-126", -126); + vliSave(ctx, "v-65", -65); + vliSave(ctx, "v-64", -64); + vliSave(ctx, "v-63", -63); + vliSave(ctx, "v-62", -62); + vliSave(ctx, "v-2", -2); + vliSave(ctx, "v-1", -1); + vliSave(ctx, "v 0", 0); + vliSave(ctx, "v+1", 1); + vliSave(ctx, "v+2", 2); + vliSave(ctx, "v+62", 62); + vliSave(ctx, "v+63", 63); + vliSave(ctx, "v+64", 64); + vliSave(ctx, "v+65", 65); + vliSave(ctx, "v+126", 126); + vliSave(ctx, "v+127", 127); + vliSave(ctx, "v+128", 128); + vliSave(ctx, "v+129", 129); +} + +export function funcTestVluCodec(ctx: wasmlib.ScFuncContext, f: sc.TestVluCodecContext): void { + for (let i: u64 = 0; i < 2000000; i++) { + let enc = new wasmlib.BytesEncoder(); + enc.uint64(i); + let buf = enc.data(); // let txt = i.toString() + " -"; - // for (let j = 0; j < d.buf.length; j++) { - // let b = d.buf[j]; + // for (let j = 0; j < buf.length; j++) { + // let b = buf[j]; // txt += " " + hex.charAt((b >> 4) & 0x0f) + hex.charAt(b & 0x0f); // } - let e = new wasmlib.BytesDecoder(d.data()); - let v = e.int64(); + let dec = new wasmlib.BytesDecoder(buf); + let v = dec.uint64(); // txt += " - " + v.toString(); // ctx.log(txt); ctx.require(i == v, "coder value mismatch") } - leb128Save(ctx, "v-1", -1); - leb128Save(ctx, "v-2", -2); - leb128Save(ctx, "v-126", -126); - leb128Save(ctx, "v-127", -127); - leb128Save(ctx, "v-128", -128); - leb128Save(ctx, "v-129", -129); - leb128Save(ctx, "v0", 0); - leb128Save(ctx, "v+1", 1); - leb128Save(ctx, "v+2", 2); - leb128Save(ctx, "v+126", 126); - leb128Save(ctx, "v+127", 127); - leb128Save(ctx, "v+128", 128); - leb128Save(ctx, "v+129", 129); + vluSave(ctx, "v 0", 0); + vluSave(ctx, "v+1", 1); + vluSave(ctx, "v+2", 2); + vluSave(ctx, "v+62", 62); + vluSave(ctx, "v+63", 63); + vluSave(ctx, "v+64", 64); + vluSave(ctx, "v+65", 65); + vluSave(ctx, "v+126", 126); + vluSave(ctx, "v+127", 127); + vluSave(ctx, "v+128", 128); + vluSave(ctx, "v+129", 129); } export function funcWhenMustIncrement(ctx: wasmlib.ScFuncContext, f: sc.WhenMustIncrementContext): void { @@ -146,7 +185,58 @@ export function viewGetCounter(ctx: wasmlib.ScViewContext, f: sc.GetCounterConte } } -function leb128Save(ctx: wasmlib.ScFuncContext, name: string, value: i64): void { +export function viewGetVli(ctx: wasmlib.ScViewContext, f: sc.GetVliContext): void { + let enc = new wasmlib.BytesEncoder(); + let n = f.params.ni64().value(); + enc = enc.int64(n); + let buf = enc.data(); + let dec = new wasmlib.BytesDecoder(buf); + let x = dec.int64(); + + let str = n.toString() + " -"; + for (let j = 0; j < buf.length; j++) { + let b = buf[j]; + str += " " + hex.charAt((b >> 4) & 0x0f) + hex.charAt(b & 0x0f); + } + str += " - " + x.toString(); + + f.results.ni64().setValue(n); + f.results.xi64().setValue(x); + f.results.str().setValue(str); + f.results.buf().setValue(buf); +} + +export function viewGetVlu(ctx: wasmlib.ScViewContext, f: sc.GetVluContext): void { + let enc = new wasmlib.BytesEncoder(); + let n = f.params.nu64().value(); + enc = enc.uint64(n); + let buf = enc.data(); + let dec = new wasmlib.BytesDecoder(buf); + let x = dec.uint64(); + + let str = n.toString() + " -"; + for (let j = 0; j < buf.length; j++) { + let b = buf[j]; + str += " " + hex.charAt((b >> 4) & 0x0f) + hex.charAt(b & 0x0f); + } + str += " - " + x.toString(); + + f.results.nu64().setValue(n); + f.results.xu64().setValue(x); + f.results.str().setValue(str); + f.results.buf().setValue(buf); +} + +//////////////////////////////// util funcs \\\\\\\\\\\\\\\\\\\\\\\\\\\\\ + +function localStatePost(ctx: wasmlib.ScFuncContext, nr: i64): void { + //note: we add a dummy parameter here to prevent "duplicate outputs not allowed" error + let f = sc.ScFuncs.whenMustIncrement(ctx); + f.params.dummy().setValue(nr); + f.func.transferIotas(1).post(); +} + +function vliSave(ctx: wasmlib.ScFuncContext, name: string, value: i64): void { let encoder = new wasmlib.BytesEncoder(); encoder.int64(value); let spot = ctx.state().getBytes(wasmlib.Key32.fromString(name)); @@ -161,11 +251,19 @@ function leb128Save(ctx: wasmlib.ScFuncContext, name: string, value: i64): void } } -function localStatePost(ctx: wasmlib.ScFuncContext, nr: i64): void { - //note: we add a dummy parameter here to prevent "duplicate outputs not allowed" error - let f = sc.ScFuncs.whenMustIncrement(ctx); - f.params.dummy().setValue(nr); - f.func.transferIotas(1).post(); +function vluSave(ctx: wasmlib.ScFuncContext, name: string, value: u64): void { + let encoder = new wasmlib.BytesEncoder(); + encoder.uint64(value); + let spot = ctx.state().getBytes(wasmlib.Key32.fromString(name)); + spot.setValue(encoder.data()); + + let bytes = spot.value(); + let decoder = new wasmlib.BytesDecoder(bytes); + let retrieved = decoder.uint64(); + if (retrieved != value) { + ctx.log(name.toString() + " in : " + value.toString()); + ctx.log(name.toString() + " out: " + retrieved.toString()); + } } function whenMustIncrementState(ctx: wasmlib.ScFuncContext, state: sc.MutableIncCounterState): void { @@ -177,21 +275,3 @@ function whenMustIncrementState(ctx: wasmlib.ScFuncContext, state: sc.MutableInc counter.setValue(counter.value() + 1); ctx.log("whenMustIncrement incremented"); } - -export function viewGetVli(ctx: wasmlib.ScViewContext, f: sc.GetVliContext): void { - let d = new wasmlib.BytesEncoder(); - let n = f.params.n().value(); - d = d.int64(n); - let str = n.toString() + " -"; - for (let j = 0; j < d.buf.length; j++) { - let b = d.buf[j]; - str += " " + hex.charAt((b >> 4) & 0x0f) + hex.charAt(b & 0x0f); - } - let e = new wasmlib.BytesDecoder(d.data()); - let x = e.int64(); - str += " - " + x.toString(); - f.results.n().setValue(n); - f.results.x().setValue(x); - f.results.str().setValue(str); - f.results.buf().setValue(d.buf); -} diff --git a/contracts/wasm/inccounter/ts/inccounter/keys.ts b/contracts/wasm/inccounter/ts/inccounter/keys.ts index d8c8beedba..39f44e0192 100644 --- a/contracts/wasm/inccounter/ts/inccounter/keys.ts +++ b/contracts/wasm/inccounter/ts/inccounter/keys.ts @@ -11,29 +11,35 @@ import * as sc from "./index"; export const IdxParamCounter = 0; export const IdxParamDelay = 1; export const IdxParamDummy = 2; -export const IdxParamN = 3; -export const IdxParamNumRepeats = 4; +export const IdxParamNi64 = 3; +export const IdxParamNu64 = 4; +export const IdxParamNumRepeats = 5; -export const IdxResultBuf = 5; -export const IdxResultCounter = 6; -export const IdxResultN = 7; -export const IdxResultStr = 8; -export const IdxResultX = 9; +export const IdxResultBuf = 6; +export const IdxResultCounter = 7; +export const IdxResultNi64 = 8; +export const IdxResultNu64 = 9; +export const IdxResultStr = 10; +export const IdxResultXi64 = 11; +export const IdxResultXu64 = 12; -export const IdxStateCounter = 10; -export const IdxStateNumRepeats = 11; +export const IdxStateCounter = 13; +export const IdxStateNumRepeats = 14; export let keyMap: string[] = [ sc.ParamCounter, sc.ParamDelay, sc.ParamDummy, - sc.ParamN, + sc.ParamNi64, + sc.ParamNu64, sc.ParamNumRepeats, sc.ResultBuf, sc.ResultCounter, - sc.ResultN, + sc.ResultNi64, + sc.ResultNu64, sc.ResultStr, - sc.ResultX, + sc.ResultXi64, + sc.ResultXu64, sc.StateCounter, sc.StateNumRepeats, ]; diff --git a/contracts/wasm/inccounter/ts/inccounter/lib.ts b/contracts/wasm/inccounter/ts/inccounter/lib.ts index db2d01d62f..8c96a4479a 100644 --- a/contracts/wasm/inccounter/ts/inccounter/lib.ts +++ b/contracts/wasm/inccounter/ts/inccounter/lib.ts @@ -25,10 +25,12 @@ export function on_load(): void { exports.addFunc(sc.FuncLocalStateSandboxCall, funcLocalStateSandboxCallThunk); exports.addFunc(sc.FuncPostIncrement, funcPostIncrementThunk); exports.addFunc(sc.FuncRepeatMany, funcRepeatManyThunk); - exports.addFunc(sc.FuncTestLeb128, funcTestLeb128Thunk); + exports.addFunc(sc.FuncTestVliCodec, funcTestVliCodecThunk); + exports.addFunc(sc.FuncTestVluCodec, funcTestVluCodecThunk); exports.addFunc(sc.FuncWhenMustIncrement, funcWhenMustIncrementThunk); exports.addView(sc.ViewGetCounter, viewGetCounterThunk); exports.addView(sc.ViewGetVli, viewGetVliThunk); + exports.addView(sc.ViewGetVlu, viewGetVluThunk); for (let i = 0; i < sc.keyMap.length; i++) { sc.idxMap[i] = wasmlib.Key32.fromString(sc.keyMap[i]); @@ -127,12 +129,20 @@ function funcRepeatManyThunk(ctx: wasmlib.ScFuncContext): void { ctx.log("inccounter.funcRepeatMany ok"); } -function funcTestLeb128Thunk(ctx: wasmlib.ScFuncContext): void { - ctx.log("inccounter.funcTestLeb128"); - let f = new sc.TestLeb128Context(); +function funcTestVliCodecThunk(ctx: wasmlib.ScFuncContext): void { + ctx.log("inccounter.funcTestVliCodec"); + let f = new sc.TestVliCodecContext(); f.state.mapID = wasmlib.OBJ_ID_STATE; - sc.funcTestLeb128(ctx, f); - ctx.log("inccounter.funcTestLeb128 ok"); + sc.funcTestVliCodec(ctx, f); + ctx.log("inccounter.funcTestVliCodec ok"); +} + +function funcTestVluCodecThunk(ctx: wasmlib.ScFuncContext): void { + ctx.log("inccounter.funcTestVluCodec"); + let f = new sc.TestVluCodecContext(); + f.state.mapID = wasmlib.OBJ_ID_STATE; + sc.funcTestVluCodec(ctx, f); + ctx.log("inccounter.funcTestVluCodec ok"); } function funcWhenMustIncrementThunk(ctx: wasmlib.ScFuncContext): void { @@ -159,7 +169,18 @@ function viewGetVliThunk(ctx: wasmlib.ScViewContext): void { f.params.mapID = wasmlib.OBJ_ID_PARAMS; f.results.mapID = wasmlib.OBJ_ID_RESULTS; f.state.mapID = wasmlib.OBJ_ID_STATE; - ctx.require(f.params.n().exists(), "missing mandatory n"); + ctx.require(f.params.ni64().exists(), "missing mandatory ni64"); sc.viewGetVli(ctx, f); ctx.log("inccounter.viewGetVli ok"); } + +function viewGetVluThunk(ctx: wasmlib.ScViewContext): void { + ctx.log("inccounter.viewGetVlu"); + let f = new sc.GetVluContext(); + f.params.mapID = wasmlib.OBJ_ID_PARAMS; + f.results.mapID = wasmlib.OBJ_ID_RESULTS; + f.state.mapID = wasmlib.OBJ_ID_STATE; + ctx.require(f.params.nu64().exists(), "missing mandatory nu64"); + sc.viewGetVlu(ctx, f); + ctx.log("inccounter.viewGetVlu ok"); +} diff --git a/contracts/wasm/inccounter/ts/inccounter/params.ts b/contracts/wasm/inccounter/ts/inccounter/params.ts index 58ab759076..3670ea1fab 100644 --- a/contracts/wasm/inccounter/ts/inccounter/params.ts +++ b/contracts/wasm/inccounter/ts/inccounter/params.ts @@ -57,13 +57,25 @@ export class MutableWhenMustIncrementParams extends wasmlib.ScMapID { } export class ImmutableGetVliParams extends wasmlib.ScMapID { - n(): wasmlib.ScImmutableInt64 { - return new wasmlib.ScImmutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ParamN)); + ni64(): wasmlib.ScImmutableInt64 { + return new wasmlib.ScImmutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ParamNi64)); } } export class MutableGetVliParams extends wasmlib.ScMapID { - n(): wasmlib.ScMutableInt64 { - return new wasmlib.ScMutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ParamN)); + ni64(): wasmlib.ScMutableInt64 { + return new wasmlib.ScMutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ParamNi64)); + } +} + +export class ImmutableGetVluParams extends wasmlib.ScMapID { + nu64(): wasmlib.ScImmutableUint64 { + return new wasmlib.ScImmutableUint64(this.mapID, wasmlib.Key32.fromString(sc.ParamNu64)); + } +} + +export class MutableGetVluParams extends wasmlib.ScMapID { + nu64(): wasmlib.ScMutableUint64 { + return new wasmlib.ScMutableUint64(this.mapID, wasmlib.Key32.fromString(sc.ParamNu64)); } } diff --git a/contracts/wasm/inccounter/ts/inccounter/results.ts b/contracts/wasm/inccounter/ts/inccounter/results.ts index bdfd077f87..6b3cdfd082 100644 --- a/contracts/wasm/inccounter/ts/inccounter/results.ts +++ b/contracts/wasm/inccounter/ts/inccounter/results.ts @@ -25,16 +25,16 @@ export class ImmutableGetVliResults extends wasmlib.ScMapID { return new wasmlib.ScImmutableBytes(this.mapID, wasmlib.Key32.fromString(sc.ResultBuf)); } - n(): wasmlib.ScImmutableInt64 { - return new wasmlib.ScImmutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ResultN)); + ni64(): wasmlib.ScImmutableInt64 { + return new wasmlib.ScImmutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ResultNi64)); } str(): wasmlib.ScImmutableString { return new wasmlib.ScImmutableString(this.mapID, wasmlib.Key32.fromString(sc.ResultStr)); } - x(): wasmlib.ScImmutableInt64 { - return new wasmlib.ScImmutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ResultX)); + xi64(): wasmlib.ScImmutableInt64 { + return new wasmlib.ScImmutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ResultXi64)); } } @@ -43,15 +43,51 @@ export class MutableGetVliResults extends wasmlib.ScMapID { return new wasmlib.ScMutableBytes(this.mapID, wasmlib.Key32.fromString(sc.ResultBuf)); } - n(): wasmlib.ScMutableInt64 { - return new wasmlib.ScMutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ResultN)); + ni64(): wasmlib.ScMutableInt64 { + return new wasmlib.ScMutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ResultNi64)); } str(): wasmlib.ScMutableString { return new wasmlib.ScMutableString(this.mapID, wasmlib.Key32.fromString(sc.ResultStr)); } - x(): wasmlib.ScMutableInt64 { - return new wasmlib.ScMutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ResultX)); + xi64(): wasmlib.ScMutableInt64 { + return new wasmlib.ScMutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ResultXi64)); + } +} + +export class ImmutableGetVluResults extends wasmlib.ScMapID { + buf(): wasmlib.ScImmutableBytes { + return new wasmlib.ScImmutableBytes(this.mapID, wasmlib.Key32.fromString(sc.ResultBuf)); + } + + nu64(): wasmlib.ScImmutableUint64 { + return new wasmlib.ScImmutableUint64(this.mapID, wasmlib.Key32.fromString(sc.ResultNu64)); + } + + str(): wasmlib.ScImmutableString { + return new wasmlib.ScImmutableString(this.mapID, wasmlib.Key32.fromString(sc.ResultStr)); + } + + xu64(): wasmlib.ScImmutableUint64 { + return new wasmlib.ScImmutableUint64(this.mapID, wasmlib.Key32.fromString(sc.ResultXu64)); + } +} + +export class MutableGetVluResults extends wasmlib.ScMapID { + buf(): wasmlib.ScMutableBytes { + return new wasmlib.ScMutableBytes(this.mapID, wasmlib.Key32.fromString(sc.ResultBuf)); + } + + nu64(): wasmlib.ScMutableUint64 { + return new wasmlib.ScMutableUint64(this.mapID, wasmlib.Key32.fromString(sc.ResultNu64)); + } + + str(): wasmlib.ScMutableString { + return new wasmlib.ScMutableString(this.mapID, wasmlib.Key32.fromString(sc.ResultStr)); + } + + xu64(): wasmlib.ScMutableUint64 { + return new wasmlib.ScMutableUint64(this.mapID, wasmlib.Key32.fromString(sc.ResultXu64)); } } diff --git a/packages/vm/wasmlib/src/bytes.rs b/packages/vm/wasmlib/src/bytes.rs index 34227fc94a..591a5c45ab 100644 --- a/packages/vm/wasmlib/src/bytes.rs +++ b/packages/vm/wasmlib/src/bytes.rs @@ -164,7 +164,7 @@ impl BytesDecoder<'_> { fn vlu_decode(&mut self, bits: i32) -> u64 { // first group of 6 bits let mut b = self.uint8(); - let mut value = (b & 0x3f) as u64; + let mut value = (b & 0x7f) as u64; let mut s = 7; // while continuation bit is set diff --git a/tools/cluster/tests/wasm/inccounter_bg.wasm b/tools/cluster/tests/wasm/inccounter_bg.wasm index d4f74848bd55265dee241c68f6187e1fc33f9401..17a9b75f301da132c42d5c306d77d69b15ef615d 100644 GIT binary patch delta 18130 zcmdUX4RlpSmhP!@&dm+Exo`p@AqkLkF98C903jxTD5>!OD=LZ#G(Q5$4L=3~q98YD z1X`g*3R^%_Xyadtf}(*qMeE?%2*Ugk^**D`Xf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5zRs$k1E~18FiAFZqG-35`NjNxTf>iq1)^zqui*V M Date: Tue, 18 Jan 2022 15:17:16 -0800 Subject: [PATCH 027/111] Minor fixes --- contracts/wasm/dividend/test/dividend_bg.wasm | Bin 32407 -> 32407 bytes .../test/donatewithfeedback_bg.wasm | Bin 36886 -> 36882 bytes contracts/wasm/erc20/test/erc20_bg.wasm | Bin 35584 -> 35584 bytes contracts/wasm/erc721/test/erc721_bg.wasm | Bin 40104 -> 40104 bytes .../wasm/fairauction/test/fairauction_bg.wasm | Bin 43245 -> 43245 bytes .../fairroulette/test/fairroulette_bg.wasm | Bin 40291 -> 40291 bytes .../wasm/inccounter/test/inccounter_bg.wasm | Bin 42133 -> 42133 bytes contracts/wasm/testcore/test/testcore_bg.wasm | Bin 53819 -> 53815 bytes .../wasm/testwasmlib/test/testwasmlib_bg.wasm | Bin 44768 -> 44764 bytes .../wasm/timestamp/test/timestamp_bg.wasm | Bin 28192 -> 28192 bytes .../tokenregistry/test/tokenregistry_bg.wasm | Bin 32223 -> 32223 bytes .../test/example_tutorial_bg.wasm | Bin 16802 -> 16810 bytes .../sbtests/sbtestsc/testcore_bg.wasm | Bin 53819 -> 53815 bytes packages/vm/wasmlib/src/host.rs | 83 ++++++++++++++++-- packages/vm/wasmlib/ts/wasmlib/host.ts | 67 ++++++++++++-- packages/vm/wasmvmhost/host.go | 36 +++----- tools/cluster/tests/wasm/inccounter_bg.wasm | Bin 42133 -> 42133 bytes 17 files changed, 150 insertions(+), 36 deletions(-) diff --git a/contracts/wasm/dividend/test/dividend_bg.wasm b/contracts/wasm/dividend/test/dividend_bg.wasm index d7848e5e3c9529d4cf4f3111d38d1f64d5d705ab..db94fc27811e7bec8a4490d8518f287538fccc65 100644 GIT binary patch delta 629 zcmYjOUr1A76#ve*6}olj<%+f`)eSP8{iCOH1^HQyF`BjElsmH^1Y_zQ6unfCL1WWh zx8OWn2z!vAKj1^~At(s#G0LEfdh)S)=%J^O0tcPX75KsLoZs(!-}#-xy>1QM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1XX9o1`6p?$Ao3`4V(`O&o%a)`pDI%_l$Y$CK=X4b%9i&Co+DArilTq3z|2}L9i{|}MgDyp+r^jk}db9S)Zyp@a22gNG#+3Rb#(qx) zDerzLzlT)vVX3 z-m+U&&uebEXIl*)Q02vKtqB_(no_DL%5;nrj13O?-1cd5*^UXSqIhIUL$zM+)RYpC zwqT@UMB#3%$79G3w{He>pDf!kGb;uN`ePWe7+wPKN3c)6u%kMw*`+D-0ny0E@MAda z5huUhx+)>tttqzxGsdQ7yJciswj6Az4V(ih6X|Yt`SH$M*gHn@u2GEr zMNZs3cf7}|DG4B@;~T>Ffy#~5ReIIN)%v=PtE;x?<-pSc>GIj#;h6P+$d9|^pLg$Z zebL^pcyE%GO=+^W$tfRh8iiL)Yf~=f-!@IIJn7SvEMmq;!-&E^#hUO@c>6VQJz&x{ zN{?JauZq%T*&{`PDnI%&FtzxSYJKv+BjL18KyiS6jW4oU1+d~|Z47|>XvVo+3yjk-r0oWT=`nvw@_0S0}e@KUTvffGicrCyDt O;_@;F-K+cd?fxIy(Lw+K diff --git a/contracts/wasm/erc20/test/erc20_bg.wasm b/contracts/wasm/erc20/test/erc20_bg.wasm index cfb81b91db4c394dfbc389d35e378c0bc6eccca6..6131d1b1f60a4735607c604380c2fe42f5c25733 100644 GIT binary patch delta 867 zcmYLG-%Ha`6urwl6UB|CRtr3>fY`#I-xKlgLbom^m(3vBHg zWo81`X~Z_LOo1*_-!iS2Z|F%c&4b0)WzSQ7muggOkObG|W#6+BEO-M=IL87FC-%$D zSXE573AsDS9mZ8lX!}ry#{qv?fn7ter1xOymxcNBA81~VUHHtLKklp(;nmE-nh=XQ z+;7X#&fk>HXCM(gTs@z`l#>&iprT*cITPk{<`x74!Xc2e6pSe9Zt%EcGP_RrSz;?( zy_1nmU9A*vPIWinywvSC8d0$MeDC#E!>59U))+6);cs`(q5ZaDhlq!f8k4v=g#0jjo62M+7v6O%YquxZjwDy50`xaE8uM`guBMLfy?Dce3QDSW|4gmtyU()n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NH{qRrq(-*B}G}odp)7t+> z+o0S_(%se*%DEF1djB4J*|fhL*qX+~{>XnKZaNyOM6|eL4c!kp79Sn=o21!LDUR;6 zd1*(RYf-e4zHYO;DAcS^j-ulgs?__Tb%i$ocZHEb#KJCa|2u{A0^H7N=yP%$DLUVN zD4lgP@TZWI4s^(7Qym9^&pN8`rT4%QlVd0ewH*V&yNt_s8BdBEAGXWExH~mqU8eyY zo%ieMbwgfhCZ10p7*2Se?gBAj{JFucBkh$)wP`9+_5UriQ;)X0-T~ zZTRFRS;x~IOJhEri51X;?z&~HCbq+I_KG#+k`9xUsQG1fqI zY^|-qs>nOy0g0+Y>};5%~<}r0d5H^EatFu~jPomrLd>ggGU_lKfQ|&Gz`{ zaiWA<>3O2`HET{L@k1Py!q&i0BW*?Ws3&B<3B^uC*1>GBn>n$aUE diff --git a/contracts/wasm/fairauction/test/fairauction_bg.wasm b/contracts/wasm/fairauction/test/fairauction_bg.wasm index c884a18b34a29349648138b2088fc6e44712c017..98028d9cac436506461c3a05ed11509397c5ba49 100644 GIT binary patch delta 1138 zcmZuvTS(JU82_L1-}17Se>R)TZvX7!wXz3g)k}xADHS9Zlo7L18_lHbYAsl)MRU`Y z-=+(C>E446)-fo^3nAEr!a%}O=t6`K z4iQB#d8VmUoFCNTul03Nf8DcEEh>H zAF$|knEuV?ynpBYdy=2xyr8p|;OY+R8sx?(Kd`Pw`=fOma)GS?xgyG!Y(npe+MlC5 z&n{Ls+VfV#8;oWpZ1%J&W$zpDK9ZDv?zMk0(@`JPRo)WQ8^>~9v~RskNBwZL>Ir7b ztDZDYU%}{nRl|~9?Dkc(C$8}Pnklk$+=q@qk#vl(1Nd%~$t9Xi=v1*ZHtqxFTu5

|#Bl{B%2vHI%~Z`V!g|;HG0B8^5-SPB5qHViQ<{O}E0+lWya)M17={Z#lJq z(02i-Io)i$3>cgLcVCaNyMi!t+J@B~=a;9-Y^n)0{5Wu=p(5T0-b1{R3)loW&b-4t zMQ3x7E6;u~v?ca@A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320c86b9fe223637e12e2be58d7bed3c59a2e289..90a2ccf970e57d12a6b45654b5690a59e95a521f 100644 GIT binary patch delta 460 zcmccroALf{#tj=7d8aXkwJ}a()SAYq+QztfFQct9)1B7Ie_R#=sm%*r?O2%Zv~7Oq zIgL^1L&pIIM{NZbM~*DVIh{cEgUy}ZKN#g7v;x^e0u0=ajE+f;yaG&)%Ku)qF zzvF|}$qRg?nSj(@-$)Q8;it-frtJWOfHecR0)qmh(z5&vp z4UuT+2D1NjZ%&RhXB28fH)+Ar#P4C8A8 z*_=QeR9akOXwX`6kEZq$@086<}}$ Xiq!zI1Q5gcYk+K!!#01+d&dU=AgO`V delta 460 zcmccroALf{#tj=7dD|G<7^g96O=DD@#u&DFFQct9)1R)%e_R#=sm%*r?O2%pbZ>s> zIgL@Mqw@fRqqYKzBS)6w77+W#=1%V)jPecLK(>$o1GgiiW0E7U0FxuLJBtI5lkCXv z*w8(Bfv+?ZklO1T38EzYRQcZkbqH89a4RqF diff --git a/documentation/tutorial-examples/test/example_tutorial_bg.wasm b/documentation/tutorial-examples/test/example_tutorial_bg.wasm index ad488b5f96aed522cd5bbdfde37517613da9a981..55f6570a7a5a6592c2a846291122ce3f90eec7e8 100644 GIT binary patch delta 2914 zcma)8U1%KF6`pfvW@p#Cv$~e`XUUT8jCQ^2NU|l%lJ#S)_F9r1NtPp3Q8togtI))5 zW=o4fkPy2_NuX{^pmA>=45hJK8Ulfav|B=70xG31rH14!v>_#>f%KuYeJLq^Xuo@B zW#Tj`MXc`3nYrhl^L^hrXMX$wz5W8dH15*&mo4k&)Q!H28#deLkVTYbNsC#oWm(K) zuE%hLTVkF?PAZvjE&t{}x||eIQXQaER8&jU+_HH|?h7xT+~3qUJ91&;{NkmH``&nF zLtUfp*0qoX$s{jTWmCLxy{Mm2b4N+Ctty@~L316#TJ)K)q!XFvAJXLmr)2llt-zC3 zKz5mxg~gZEI(vHHw0!5ru2p2#)zF&tZP*|FDqP9;zq4yaFdJ*y#s)!V6WIYxs2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~Bn5!JLgkh0tdy!7=oI?e>#&~P_@Zq#( z+O?}FrjLUg3;jaDy?KKEbJuNgoj!Vc6<(-Es<)~=r)g$&B3-Utf;W8hGnp>qwLc`3 z!_^O~?IB_Ubw2Yjtoi8aB#PVp2%6Bs-Ivtc%@n`qJZ|u{JwfbSh`R%yZb>>{RbIV!_M7L{erN!ZMpkuWd z99%JZZac`xDx+#d- zrMlmuTt5H&6wyZQ&z}`<1=s&r2yvP={$!gtM}PduG8BWU^~cp)&Gh^Ft#~4`5A1i< zL5_@;O?3IdaisLxgQFp&`e23at67fV=Lg>xF@5l_`(5o0{(Xb*D}40kp;{t3*NHeHx^WFraUL04f4WG zyhia@glIrF2;%_50Ve=D0n;rw-GWFkV|^ANE0$})`4%j&U?CvyUkwEqF1PRy|C0ue z6E|SOmaYyK(7)Qr-!NU|(-RG|>4k>EiM8RHk`Ll0p(qmpL-=Ok;rQQyBXI5SCX>5y zro$jnL1Q^}HYP{&rc`_$e6K}72n{qQi^&vu>~&E_oyS&F((&bhEqRu>#Z1Jrvn7{-?F}V$My}yo1fZImAQQf4AamN&jWlG-f|OQPODI$+^)57Ir^Y zeE15e_GFHDJ9zozXd$jq@5^&1E3um51<4EO2i(4{VpEA;QURA&Y%HnPAH_N!;HCUi z>ERoJ#RJ<-&z_oupGPgHvZMb6Yn;K?Em|uLoJvn{#c4_uR^tIV%@P4wPAg4odBhjm zQ-D>@ukC;?z}hT@a34Za@oQ1 USF3FiT*%zQuHbk1muL6=FHTyAEC2ui diff --git a/contracts/wasm/testwasmlib/test/testwasmlib_client_test.go b/contracts/wasm/testwasmlib/test/testwasmlib_client_test.go index 674bd2ecc9..4159dd79a2 100644 --- a/contracts/wasm/testwasmlib/test/testwasmlib_client_test.go +++ b/contracts/wasm/testwasmlib/test/testwasmlib_client_test.go @@ -5,8 +5,8 @@ import ( "testing" "github.com/iotaledger/wasp/contracts/wasm/testwasmlib/go/testwasmlibclient" - wasmclient2 "github.com/iotaledger/wasp/packages/wasmvm/wasmlib/go/wasmclient" - "github.com/iotaledger/wasp/packages/wasmvm/wasmlib/go/wasmclient/coreaccounts" + "github.com/iotaledger/wasp/packages/wasmvm/wasmlib/go/wasmclient" + coreaccountsclient "github.com/iotaledger/wasp/packages/wasmvm/wasmlib/go/wasmclient/coreaccounts" "github.com/stretchr/testify/require" ) @@ -23,18 +23,18 @@ func setupClient(t *testing.T) *testwasmlibclient.TestWasmLibService { // for now skip client tests t.SkipNow() - require.True(t, wasmclient2.SeedIsValid(mySeed)) - require.True(t, wasmclient2.ChainIsValid(myChainID)) + require.True(t, wasmclient.SeedIsValid(mySeed)) + require.True(t, wasmclient.ChainIsValid(myChainID)) // we're testing against wasp-cluster, so defaults will do - svcClient := wasmclient2.DefaultServiceClient() + svcClient := wasmclient.DefaultServiceClient() // create the service for the testwasmlib smart contract svc, err := testwasmlibclient.NewTestWasmLibService(svcClient, myChainID) require.NoError(t, err) // we'll use the first address in the seed to sign requests - svc.SignRequests(wasmclient2.SeedToKeyPair(mySeed, 0)) + svc.SignRequests(wasmclient.SeedToKeyPair(mySeed, 0)) return svc } @@ -49,7 +49,7 @@ func TestClientEvents(t *testing.T) { // get new triggerEvent interface, pass params, and post the request f := svc.TriggerEvent() f.Name("Lala") - f.Address(wasmclient2.SeedToAddress(mySeed, 0)) + f.Address(wasmclient.SeedToAddress(mySeed, 0)) req1 := f.Post() require.NoError(t, req1.Error()) @@ -59,7 +59,7 @@ func TestClientEvents(t *testing.T) { // get new triggerEvent interface, pass params, and post the request f = svc.TriggerEvent() f.Name("Trala") - f.Address(wasmclient2.SeedToAddress(mySeed, 1)) + f.Address(wasmclient.SeedToAddress(mySeed, 1)) req2 := f.Post() require.NoError(t, req2.Error()) @@ -129,17 +129,17 @@ func TestAccountBalance(t *testing.T) { t.SkipNow() // we're testing against wasp-cluster, so defaults will do - svcClient := wasmclient2.DefaultServiceClient() + svcClient := wasmclient.DefaultServiceClient() // create the service for the testwasmlib smart contract svc, err := coreaccountsclient.NewCoreAccountsService(svcClient, myChainID) require.NoError(t, err) // we'll use the first address in the seed to sign requests - svc.SignRequests(wasmclient2.SeedToKeyPair(mySeed, 0)) + svc.SignRequests(wasmclient.SeedToKeyPair(mySeed, 0)) bal := svc.Balance() - agendID := wasmclient2.SeedToAgentID(mySeed, 0) + agendID := wasmclient.SeedToAgentID(mySeed, 0) bal.AgentID(agendID) res := bal.Call() require.NoError(t, bal.Error()) diff --git a/contracts/wasm/testwasmlib/test/testwasmlib_test.go b/contracts/wasm/testwasmlib/test/testwasmlib_test.go index 5a21deddef..a3c102d407 100644 --- a/contracts/wasm/testwasmlib/test/testwasmlib_test.go +++ b/contracts/wasm/testwasmlib/test/testwasmlib_test.go @@ -9,7 +9,7 @@ import ( "github.com/iotaledger/goshimmer/packages/ledgerstate" "github.com/iotaledger/wasp/contracts/wasm/testwasmlib/go/testwasmlib" "github.com/iotaledger/wasp/packages/solo" - "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" + "github.com/iotaledger/wasp/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes" "github.com/iotaledger/wasp/packages/wasmvm/wasmsolo" "github.com/stretchr/testify/require" ) diff --git a/contracts/wasm/timestamp/Cargo.toml b/contracts/wasm/timestamp/Cargo.toml index d9e528cb77..7370467cfd 100644 --- a/contracts/wasm/timestamp/Cargo.toml +++ b/contracts/wasm/timestamp/Cargo.toml @@ -14,7 +14,7 @@ crate-type = ["cdylib", "rlib"] default = ["console_error_panic_hook"] [dependencies] -wasmlib = { path = "../../../wasmvm/wasmlib" } +wasmlib = { path = "../../../packages/wasmvm/wasmlib" } #wasmlib = { git = "https://github.com/iotaledger/wasp", branch = "develop" } console_error_panic_hook = { version = "0.1.6", optional = true } wee_alloc = { version = "0.4.5", optional = true } diff --git a/contracts/wasm/timestamp/go/main.go b/contracts/wasm/timestamp/go/main.go index 1d75f182d8..e1ecfbd1e1 100644 --- a/contracts/wasm/timestamp/go/main.go +++ b/contracts/wasm/timestamp/go/main.go @@ -9,7 +9,7 @@ package main -import "github.com/iotaledger/wasp/packages/vm/wasmvmhost" +import "github.com/iotaledger/wasp/packages/wasmvm/wasmvmhost" import "github.com/iotaledger/wasp/contracts/wasm/timestamp/go/timestamp" diff --git a/contracts/wasm/timestamp/go/timestamp/consts.go b/contracts/wasm/timestamp/go/timestamp/consts.go index 620ce3115f..bd40a8f418 100644 --- a/contracts/wasm/timestamp/go/timestamp/consts.go +++ b/contracts/wasm/timestamp/go/timestamp/consts.go @@ -7,7 +7,7 @@ package timestamp -import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" +import "github.com/iotaledger/wasp/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes" const ( ScName = "timestamp" diff --git a/contracts/wasm/timestamp/go/timestamp/contract.go b/contracts/wasm/timestamp/go/timestamp/contract.go index a5a5e483b5..223d2f266f 100644 --- a/contracts/wasm/timestamp/go/timestamp/contract.go +++ b/contracts/wasm/timestamp/go/timestamp/contract.go @@ -7,7 +7,7 @@ package timestamp -import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib" +import "github.com/iotaledger/wasp/packages/wasmvm/wasmlib/go/wasmlib" type NowCall struct { Func *wasmlib.ScFunc diff --git a/contracts/wasm/timestamp/go/timestamp/lib.go b/contracts/wasm/timestamp/go/timestamp/lib.go index 17961a49d5..e9f2f8ca4e 100644 --- a/contracts/wasm/timestamp/go/timestamp/lib.go +++ b/contracts/wasm/timestamp/go/timestamp/lib.go @@ -7,7 +7,7 @@ package timestamp -import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib" +import "github.com/iotaledger/wasp/packages/wasmvm/wasmlib/go/wasmlib" func OnLoad() { exports := wasmlib.NewScExports() diff --git a/contracts/wasm/timestamp/go/timestamp/results.go b/contracts/wasm/timestamp/go/timestamp/results.go index 52146d74bd..532bf93bab 100644 --- a/contracts/wasm/timestamp/go/timestamp/results.go +++ b/contracts/wasm/timestamp/go/timestamp/results.go @@ -7,7 +7,7 @@ package timestamp -import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" +import "github.com/iotaledger/wasp/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes" type ImmutableGetTimestampResults struct { proxy wasmtypes.Proxy diff --git a/contracts/wasm/timestamp/go/timestamp/state.go b/contracts/wasm/timestamp/go/timestamp/state.go index 60b58fc68b..10998f42aa 100644 --- a/contracts/wasm/timestamp/go/timestamp/state.go +++ b/contracts/wasm/timestamp/go/timestamp/state.go @@ -7,7 +7,7 @@ package timestamp -import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" +import "github.com/iotaledger/wasp/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes" type ImmutabletimestampState struct { proxy wasmtypes.Proxy diff --git a/contracts/wasm/timestamp/go/timestamp/timestamp.go b/contracts/wasm/timestamp/go/timestamp/timestamp.go index 950e2ec072..e84a4ad822 100644 --- a/contracts/wasm/timestamp/go/timestamp/timestamp.go +++ b/contracts/wasm/timestamp/go/timestamp/timestamp.go @@ -3,7 +3,7 @@ package timestamp -import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib" +import "github.com/iotaledger/wasp/packages/wasmvm/wasmlib/go/wasmlib" func funcNow(ctx wasmlib.ScFuncContext, f *NowContext) { f.State.Timestamp().SetValue(ctx.Timestamp()) diff --git a/contracts/wasm/timestamp/test/timestamp_bg.wasm b/contracts/wasm/timestamp/test/timestamp_bg.wasm index 932fe7b91e6c1452c35a8962202d231f5ebe44ed..fafa3e7bbf9f5670ae5a79613dfb7b6c6e82c991 100644 GIT binary patch delta 4028 zcmai1eQ;FO6@T}=-OZBSP2L6)vTR81z7R;r2M`((5F{5(Vn{-Q8YO%PAxXtW!C-1y zaU^P$RQwn`v}g-ctcWO7!)&HfO*O;BPCA1ve=s(kreoUTNF{A!CyvgPmj2FryAfJC zlG%6fx%b?2&-tC-J@@j%QSthy=u6kdY0A*oiXqyjADVgk=%ALbYn_%>6)>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sf~}Me@2!}8UEH62uw>taF2=` z8CSmzZ>6YAK%wXA=M$vCeW1?M zwYq7GdwHY$!89eJI28%dK5m1+&_5eVvckby`+mw5<0fe%VaH?wp>f zjymq}{@%9=R{)DxC(ZyrIc-t(Buos~K6Q-F)t7<&zph^cWM{3oM|?uNR(wxfB2U8; z8K;@WxKlt-yUwXo)ZI`m`eX41&~`k7LS3P*Re6-Ls`bB>FJ|;GxRbGG8CCB+hyHoW zZh9u;ofpu}aMWXf22?xM)C5X?+B64O^NiJn;ux)5y%F!OQ>!1#;JbXjo-OrdqFVQ3 zM|~7-epsBR?&inEd-PfJ-Ro@O44#~ zjeyCK`>N}%CX*S~)mS2lg0I|B2q5}Am9Plo3B)>N34xJiWn;;sNOSuAC3WMxfUA*- zu9zIQtAqu+N)pC#Wk0id6c|2x{}2GEU)M&TFG-_|>$^~b?M!G}(R$HF(RysF&Fyo7#~>9#O2v<%ITkzKzRw*lN;9=$h>iGho0K0! ZpBGmYTO8eLq%xy?!lmIgclvA3{|B1tgMk15 diff --git a/contracts/wasm/tokenregistry/Cargo.toml b/contracts/wasm/tokenregistry/Cargo.toml index 5dcd05a552..bf2dd6ea95 100644 --- a/contracts/wasm/tokenregistry/Cargo.toml +++ b/contracts/wasm/tokenregistry/Cargo.toml @@ -17,7 +17,7 @@ crate-type = ["cdylib", "rlib"] default = ["console_error_panic_hook"] [dependencies] -wasmlib = { path = "../../../wasmvm/wasmlib" } +wasmlib = { path = "../../../packages/wasmvm/wasmlib" } #wasmlib = { git = "https://github.com/iotaledger/wasp", branch = "develop" } # The `console_error_panic_hook` crate provides better debugging of panics by diff --git a/contracts/wasm/tokenregistry/go/main.go b/contracts/wasm/tokenregistry/go/main.go index be160c7c43..3cf2aacc4a 100644 --- a/contracts/wasm/tokenregistry/go/main.go +++ b/contracts/wasm/tokenregistry/go/main.go @@ -9,7 +9,7 @@ package main -import "github.com/iotaledger/wasp/packages/vm/wasmvmhost" +import "github.com/iotaledger/wasp/packages/wasmvm/wasmvmhost" import "github.com/iotaledger/wasp/contracts/wasm/tokenregistry/go/tokenregistry" diff --git a/contracts/wasm/tokenregistry/go/tokenregistry/consts.go b/contracts/wasm/tokenregistry/go/tokenregistry/consts.go index a3e614caa3..9d4bad073b 100644 --- a/contracts/wasm/tokenregistry/go/tokenregistry/consts.go +++ b/contracts/wasm/tokenregistry/go/tokenregistry/consts.go @@ -7,7 +7,7 @@ package tokenregistry -import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" +import "github.com/iotaledger/wasp/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes" const ( ScName = "tokenregistry" diff --git a/contracts/wasm/tokenregistry/go/tokenregistry/contract.go b/contracts/wasm/tokenregistry/go/tokenregistry/contract.go index 3ecf964449..c2c04115a0 100644 --- a/contracts/wasm/tokenregistry/go/tokenregistry/contract.go +++ b/contracts/wasm/tokenregistry/go/tokenregistry/contract.go @@ -7,7 +7,7 @@ package tokenregistry -import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib" +import "github.com/iotaledger/wasp/packages/wasmvm/wasmlib/go/wasmlib" type MintSupplyCall struct { Func *wasmlib.ScFunc diff --git a/contracts/wasm/tokenregistry/go/tokenregistry/lib.go b/contracts/wasm/tokenregistry/go/tokenregistry/lib.go index d5b196db03..c4e731dbda 100644 --- a/contracts/wasm/tokenregistry/go/tokenregistry/lib.go +++ b/contracts/wasm/tokenregistry/go/tokenregistry/lib.go @@ -7,7 +7,7 @@ package tokenregistry -import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib" +import "github.com/iotaledger/wasp/packages/wasmvm/wasmlib/go/wasmlib" func OnLoad() { exports := wasmlib.NewScExports() diff --git a/contracts/wasm/tokenregistry/go/tokenregistry/params.go b/contracts/wasm/tokenregistry/go/tokenregistry/params.go index a171f74e0e..38abcb8bb3 100644 --- a/contracts/wasm/tokenregistry/go/tokenregistry/params.go +++ b/contracts/wasm/tokenregistry/go/tokenregistry/params.go @@ -7,7 +7,7 @@ package tokenregistry -import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" +import "github.com/iotaledger/wasp/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes" type ImmutableMintSupplyParams struct { proxy wasmtypes.Proxy diff --git a/contracts/wasm/tokenregistry/go/tokenregistry/state.go b/contracts/wasm/tokenregistry/go/tokenregistry/state.go index b78d68e423..46674f7be9 100644 --- a/contracts/wasm/tokenregistry/go/tokenregistry/state.go +++ b/contracts/wasm/tokenregistry/go/tokenregistry/state.go @@ -7,7 +7,7 @@ package tokenregistry -import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" +import "github.com/iotaledger/wasp/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes" type ArrayOfImmutableColor struct { proxy wasmtypes.Proxy diff --git a/contracts/wasm/tokenregistry/go/tokenregistry/structs.go b/contracts/wasm/tokenregistry/go/tokenregistry/structs.go index 36a28ce60a..45d9e7ca71 100644 --- a/contracts/wasm/tokenregistry/go/tokenregistry/structs.go +++ b/contracts/wasm/tokenregistry/go/tokenregistry/structs.go @@ -7,7 +7,7 @@ package tokenregistry -import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" +import "github.com/iotaledger/wasp/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes" type Token struct { Created uint64 // creation timestamp diff --git a/contracts/wasm/tokenregistry/go/tokenregistry/tokenregistry.go b/contracts/wasm/tokenregistry/go/tokenregistry/tokenregistry.go index 22ce73ae8e..849a1d66e3 100644 --- a/contracts/wasm/tokenregistry/go/tokenregistry/tokenregistry.go +++ b/contracts/wasm/tokenregistry/go/tokenregistry/tokenregistry.go @@ -4,7 +4,7 @@ package tokenregistry import ( - "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib" + "github.com/iotaledger/wasp/packages/wasmvm/wasmlib/go/wasmlib" ) func funcMintSupply(ctx wasmlib.ScFuncContext, f *MintSupplyContext) { diff --git a/contracts/wasm/tokenregistry/test/tokenregistry_bg.wasm b/contracts/wasm/tokenregistry/test/tokenregistry_bg.wasm index d047c482ebfd87d1514070e3dbda6ee0094d3020..f1b0f91374765b0672ece508bf02f7a722955d0f 100644 GIT binary patch delta 4202 zcmai1eNgNN$VG@ zrWzGf^m1Zs{XqOUM5D%Ttaz#|8g0`ywH!ar;T)}pKd7Z9o{&?tIZ8u+^WIy6#$(y@ zX6DY^xpU`te{*Me`fK*u*X(G6%0_9Wx{8fcpZYl3)mk#ztF@&lAJ^7hI(B$a2?kth zrx-yiPgM+6FwQy**6yh0t~}N4Wgam?+_9aF(1Q*>d;Ey0SMQ7BE*}%4_B5pi9g2SY zHlcQiaeCj;f)%cErX*S`M2U0OynqwdwmPp&8J8=|1zo~z)+$%T7#($HV4;)FiVF&w zt-wr$ELVn0`U*2uuFDE+cMJvYDni?1py&`6Eh;xi2VGgP{i>@dTROvC^HoL2`CLVd zYkD^eXkM4xt{PS3F?AGEhsvYo=+i54$1+E?n4p`Z8ahKSV!9_!br>;1wy~k0!Q`ZU zkjz5vQQ>f&v*j6bWYR*S2I%dFQb5t*x*lTOz0{|1m~b14Pw{vio@vm44R^E{Oz6U` zx5(wCcS4CX-Lvckuo=46ZFtNrnLeDOPIq?0W0qe)M&WL*G-T9ZzU<^~O!tUh>FHFq zG}R+}y|UFMTQRaFeKa-2goJ&J0?|(w9(f+kUKCP8*5Z&Y9Fs!7Ey!B*(pk(HkQ<#v#Sop1&Mz(PD1vv$U)RMIrvW3%97_kLePpgfYBgDPsY=YK#)7d2L z_13UM^rqK9d&KLnn6U9;kw_ps3W9Ga5?rpd7>a&?fv8dufr|;sK217d8k>Cxh=@=q zBr*1?9!t*(kg0@e(0tNYm?Kd(p|(iimiU__KqDp?kOZJJKJwa>sFi`G1F@?j4F5-L zgU8~sYBKn(czHUS<4ScogGb5bq?cf0UtErEQr7I08~`0Yip!4J4n$+IhxO+!F?Z#Z zyV6>?tA(pAoV6HEYkP0&HP_AD9`|uw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lFRe# z0hfMw1G@16ku&9m4%l8^+{oG^_uiAs5=PsxP#!W5@IUf2+C%irlHG96wX~L0XdxQl-I8Q*mWw$q?oi2|A7;6AuWVt|IpXV=hXM$cOm5c2X7Qkb^~PYQj8rpQIO6z|z4nxjpeqqybytUpq^Jdv?K(Tb{V39p(lIdrbO*E`y;Q{rZEui{km#oo2<2~P(HkN z3Vpn`oc_GlOD~`m#s8^6S5^v_K_ znD8gxd)gg_p@@2;!c`^>=FE?-WJe8}-=W)N{xf03Q(y7wf(4A}%{Udb$ z^qq}$yVmb$-1^`Hbvs%%)NR_mt+}OjM?uRDMfptCl|_o8Wa0DSGi7?bp@xPU@|}-p zx^fRCY<&Xh_3+kxl+_q?o^?pwy2ebqwYPCE=}rDg-A-L8#|)3)OTlN#G^gp|_1RrYISx>*@Wbr~H>~tzT6XC$#q$6e!tIx}s83Q$g%34pkOJ`BzKFo0mj~A#q4Y z>00yr_;a>&7c>EU=V;lsxhxpz*fyE5g>-!T{M_Bqx{`pdeW(r8E$f>$Z{nMpHu49X zHg4L@&q6O3*hdL1c`=tDB}4iwnkrhRGM$=QX2h4rAg4iDg<5uI(a&4*{9#D3kUCI1 zP(O=WPLxI0T1o=rW6nW4721zcyHS6J+GSd;+EEzKJ-U(&DF&YeherAI2w iaS1+IkISpkmJXbX6n(!{^GFJMm;*lmd+5za9{(?4@$b|C diff --git a/documentation/docs/guide/schema/events.mdx b/documentation/docs/guide/schema/events.mdx index 9b90342f50..cce5e03f72 100644 --- a/documentation/docs/guide/schema/events.mdx +++ b/documentation/docs/guide/schema/events.mdx @@ -118,7 +118,7 @@ FairRouletteEvents struct: ```go package fairroulette -import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib" +import "github.com/iotaledger/wasp/packages/wasmvm/wasmlib/go/wasmlib" type FairRouletteEvents struct{} diff --git a/documentation/docs/guide/schema/funcdesc.mdx b/documentation/docs/guide/schema/funcdesc.mdx index ca28b2ad76..bf27f3f601 100644 --- a/documentation/docs/guide/schema/funcdesc.mdx +++ b/documentation/docs/guide/schema/funcdesc.mdx @@ -37,7 +37,7 @@ in `contract.xx`: ```go package dividend -import "github.com/iotaledger/wasp/wasmvm/wasmlib" +import "github.com/iotaledger/wasp/packages/wasmvm/wasmlib" type DivideCall struct { Func *wasmlib.ScFunc diff --git a/documentation/docs/guide/schema/init.mdx b/documentation/docs/guide/schema/init.mdx index 2b9763ea0d..f2798f391f 100644 --- a/documentation/docs/guide/schema/init.mdx +++ b/documentation/docs/guide/schema/init.mdx @@ -57,7 +57,7 @@ first part of the Rust code that implements it, which contains the `'`init`'` fu //nolint:revive package dividend -import "github.com/iotaledger/wasp/wasmvm/wasmlib" +import "github.com/iotaledger/wasp/packages/wasmvm/wasmlib" // 'init' is used as a way to initialize a smart contract. It is an optional // function that will automatically be called upon contract deployment. In this diff --git a/documentation/docs/guide/schema/structs.mdx b/documentation/docs/guide/schema/structs.mdx index d595b40b1d..f239b95296 100644 --- a/documentation/docs/guide/schema/structs.mdx +++ b/documentation/docs/guide/schema/structs.mdx @@ -86,7 +86,7 @@ struct: ```go package betting -import "github.com/iotaledger/wasp/wasmvm/wasmlib" +import "github.com/iotaledger/wasp/packages/wasmvm/wasmlib" type Bet struct { Amount int64 // bet amount @@ -311,7 +311,7 @@ The generated code in `state.xx` that implements the state interface is shown he ```go package betting -import "github.com/iotaledger/wasp/wasmvm/wasmlib" +import "github.com/iotaledger/wasp/packages/wasmvm/wasmlib" type ArrayOfImmutableBet struct { objID int32 diff --git a/documentation/docs/guide/schema/typedefs.mdx b/documentation/docs/guide/schema/typedefs.mdx index ec676372b1..744654ae50 100644 --- a/documentation/docs/guide/schema/typedefs.mdx +++ b/documentation/docs/guide/schema/typedefs.mdx @@ -76,7 +76,7 @@ The schema tool will generate the following proxies in `typedefs.xx`: ```go package betting -import "github.com/iotaledger/wasp/wasmvm/wasmlib" +import "github.com/iotaledger/wasp/packages/wasmvm/wasmlib" type ImmutableBettingRound = ArrayOfImmutableBet @@ -227,7 +227,7 @@ definition in `state.xx`: ```go package betting -import "github.com/iotaledger/wasp/wasmvm/wasmlib" +import "github.com/iotaledger/wasp/packages/wasmvm/wasmlib" type ArrayOfImmutableBettingRound struct { objID int32 diff --git a/documentation/docs/guide/schema/usage.mdx b/documentation/docs/guide/schema/usage.mdx index c211d81b32..63ce83227b 100644 --- a/documentation/docs/guide/schema/usage.mdx +++ b/documentation/docs/guide/schema/usage.mdx @@ -252,7 +252,7 @@ looks like this before you even start modifying it: ```go package mysmartcontract -import "github.com/iotaledger/wasp/wasmvm/wasmlib" +import "github.com/iotaledger/wasp/packages/wasmvm/wasmlib" func funcInit(ctx wasmlib.ScFuncContext, f *InitContext) { diff --git a/documentation/tutorial-examples/Cargo.toml b/documentation/tutorial-examples/Cargo.toml index 98838db21f..04d37ce45d 100644 --- a/documentation/tutorial-examples/Cargo.toml +++ b/documentation/tutorial-examples/Cargo.toml @@ -17,7 +17,7 @@ crate-type = ["cdylib", "rlib"] default = ["console_error_panic_hook"] [dependencies] -wasmlib = { path = "../../wasmvm/wasmlib" } +wasmlib = { path = "../../packages/wasmvm/wasmlib" } #wasmlib = { git = "https://github.com/iotaledger/wasp", branch = "develop" } # The `console_error_panic_hook` crate provides better debugging of panics by diff --git a/documentation/tutorial-examples/test/example_tutorial_bg.wasm b/documentation/tutorial-examples/test/example_tutorial_bg.wasm index f0223e484d8665fa65f2cb8a4232b5a2d680e65a..7ff582a07c37c08e38c1bea2f22e8b212a9d7423 100644 GIT binary patch delta 825 zcmX|8O-NKx6u#&B#-EV|pXRWD9TivLlQUUi18uvvkLANOz6+SN{t29-wa3~)Yrl2U7q{nFkTY>C!VQB- zBT5$&=roC|R@nQJ($Xgm>Efu1E@4e|xA!}twT$g$%m7&!l|LN2y2%4^=Xu>cr|o7# zFYFu|bea7`cBF(GTou|`jOcm4>g46D7<8G$%&x8ZPwr5!1o}c|sX7Xi>4s|X5W7RS z^fW;czQxdF8b5@lxNYNbV}0G48nBcGB+g(o$V{z6W)!w9i%s8lr;rKT`Pw)OkjAla z2!7*YxEem=dUyhs@Ih0}<{^6H`j8dxEH=Fcc!a4v_q&oCLQF14asr@>`XuOLfGCr> z3X|(DMm!{!6iOc9%*~R-zDUK1Q8ihSVEP5%19HP5&Gg84j#yK~$|gf2;#`I4(f?cL zQN%``B34;B8nWN}oEsCK#pVYzn^$ifroYd!-hyx!bNe#|zX z_b21ZTrK;U>H8sXAV73|ez2IRCEY1J*mA?auA0=#nHc>}z51OXFZAbi(!{yU0)A_G zrKfXjT&A68`=$Ysc&YVl;T*xzD?j4f*5%5(1san!&8MeeEtAQtP<)~IOMx#A3>T=6 z)8{?d+t#UFJ9qUmjo*XYc}#r$YOA91NZJKTpm>Sb%XRCQK8g z8Rw0Kym~^Lp{Va!VjiU5IH?P6g=H- z?8gJcBQA4*$xfFEQ>cr7?ztG#i$SI26W~Q%W+-=XSMl^+)=HBjW#vZe^w2abA!woj)%e0I^{Qo?a5==ygxacv_Cb?Av!b} zjo?>Wiq_zJ`W>CZ1$xw6yJKc6hrD@vsrfD96pbH#(4E;bVhMRazc#U(b<(^s(WsDx z8L@kN!V8 zk0LgU6tOy$!}fZt0vod`Ji`E!JBkUf3DO&v2_>gXG(zs)2b#cdqlSOh` z-{?+(O-RRnc{Gcdp=)iIOI|Z9eR74C+t$6wZ5p`!>1m{en|7ew|CLw_G(`b0ED>8xR$_x9$Ic6^G%=udl~tH0M$HC&_Krsn)IvVZ0QZ5;sD4{ RU+3y}m8p&_nx=Z0`Ukz!^Zx(< diff --git a/packages/solo/solo.go b/packages/solo/solo.go index 93ef6096c1..0330d31c27 100644 --- a/packages/solo/solo.go +++ b/packages/solo/solo.go @@ -33,7 +33,7 @@ import ( "github.com/iotaledger/wasp/packages/vm/runvm" _ "github.com/iotaledger/wasp/packages/vm/sandbox" "github.com/iotaledger/wasp/packages/vm/vmtypes" - "github.com/iotaledger/wasp/packages/vm/wasmhost" + "github.com/iotaledger/wasp/packages/wasmvm/wasmhost" "github.com/stretchr/testify/require" "go.uber.org/atomic" "go.uber.org/zap/zapcore" diff --git a/packages/vm/core/testcore/sbtests/sbtestsc/testcore_bg.wasm b/packages/vm/core/testcore/sbtests/sbtestsc/testcore_bg.wasm index 76c1881f70e60ea277e9cae13931323a61b8daa8..3409520077719e2851c41081681f8c41eb1107d1 100644 GIT binary patch delta 7531 zcmb7I33yaRw!U?H$RXy zI(2Rz+-&>nW?RD`o2a9~wlSiC*4Um&syo%BNpvVm^44~58T z``xa3i1@uuwM5pgaHNV_N^?Ajw!)!zY&dPq9_bF#oo*p5WvnZ#t*(=fhdNuLJ~7yB z*M+pr^Pwr0rt&bk*VN>7$Xa^9*%M3GI^)ufQJ*r@K0sG>rMDWTE4tcS4UZBo$enN& zKrSXM&eujx1m#3f4(3C6Xjr%0pbZN2DQp6o-!Or9O0{7bqL%iBb<1SabZ2i>kvyN* zS9F`UK=s<9oNPu^csG|J0|OyLgTr&R&`P>}n03|BRctU_J16w;A$(prYPe5vE3PQJE963WO1Brm zy_yWyP6%F~&6ApGpQ+HxmQIPtav6IvjMz(65#CW}%yFM06+K*6Mx_qMd@PnQ65c zrXjI!m^o{WFqN&;*Y%*Nq#9T9(CYU9RH9*xb<8lrOl@0c8#9dXNPSyoH#7Bth^P*t zWaazlm!n}Rrn1yxYM80C7^WeyI%cY^5vC!rZOqhKBTPeL^=(HK1e4FkhediK{91 z(yn&5IBWS}YAI41oo!r4ugdobAnOqlF0-={W83aock7z=5Azarg1=() zXc_L8$Dtl<99s}|pg8DdBc<%gv>@SwGVl&%YhlHDLAL%wXs{e-XJ5y!sR%hKy z*zs{Hh`S)Zr>^mH#O}bx_!B}c-$%uXHzMJ^o_J?6I|zOq>K3{{LXoyv(l*qs!c#qy z#s`n0Dk=9C%W1mc94dl20`rWnZp69iV^gE9nkfnP3GE%x&ShjEQ_eb|=;Y)qYkgfA zg7Y`#8=4rF+;hnmx+%FAg0wVwLWkh~9l9NP9Fb7u_xn_KMes~Hs(wx$7H3IHK054g zB(~H-6H`V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&-&Z8C2~I62=6?8K6D&8483^9rSW)`ns(H%Q?P%>W^K+`6PioXS328_<2G=W-Hk|ER+fNmaoGk|2XB?l#rDgx zLv+yHQySrhaW)fu7!2H5oO`g#Gm5~)OR)QtaS37y*z~$*NUpvd{Uo1UhftNu zeG0y^r2}s#wMf>%JYQPaxFCb6*|N@m(DxT^@4#}5&v1;x02Cgc%|~0|=;3ep7p+iV zmw+ehtP@z$->v%@I{~|&dXjzOzx7ly!+m*K674c6 ziXH1YlRog(m)T!kWTq<7quAf_->!Gqz}9fLYq_E*pD;y9#@|qgbNidHqG1iRHAF`o zv#AP6=d}Y}~xBdRvvZvPy{xQI%|X2;Ro0Z%pGcc%^Zn zrQVKfz)<7UQ2tz0#BztKWZ{Yj@SBRCM#Gusz!mLOl^EoFhI@&{J{r=WKN8VqaHF`Q zSdjau*Q*Rd|MMxq11O=tDG<}NGI(jIig8kujj*d}nagKT^O57m&j(kU()hna{g&oP z#yG^ZEStSRRh4j*Wn=HbzOtzN@oi#T`BqU}zIEGPu^0KYLN?U5Bn3Ak6^T?QTyB|# z7t~Noii^3htRv5XJ;?@O?y01xrAUP$wE}xH_N%ZbI|H!m)Dm}Kjt{vrk^6J(ZP<5W zZ`HJVPt9}nBb9(u2!7;~e!t^%t;JnBMO6}!T!|m`0eU@-X#=JHj<&s~5XuQVLzr}f IxBc*c0Zo&Fw*UYD diff --git a/tools/schema/generator/goclienttemplates/alltemplates.go b/tools/schema/generator/goclienttemplates/alltemplates.go index 1627458c96..3bef0ca64d 100644 --- a/tools/schema/generator/goclienttemplates/alltemplates.go +++ b/tools/schema/generator/goclienttemplates/alltemplates.go @@ -162,6 +162,6 @@ var common = map[string]string{ "clientHeader": ` package $package$+client -import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmclient" +import "github.com/iotaledger/wasp/packages/wasmvm/wasmlib/go/wasmclient" `, } diff --git a/tools/schema/generator/goclienttemplates/service.go b/tools/schema/generator/goclienttemplates/service.go index bb304d5aab..694c2df338 100644 --- a/tools/schema/generator/goclienttemplates/service.go +++ b/tools/schema/generator/goclienttemplates/service.go @@ -9,7 +9,7 @@ $#if funcs emitContract // ******************************* "emitContract": ` -import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmclient" +import "github.com/iotaledger/wasp/packages/wasmvm/wasmlib/go/wasmclient" const ( $#each params constArg diff --git a/tools/schema/generator/gotemplates/alltemplates.go b/tools/schema/generator/gotemplates/alltemplates.go index 796fe51513..3d7cf7b52d 100644 --- a/tools/schema/generator/gotemplates/alltemplates.go +++ b/tools/schema/generator/gotemplates/alltemplates.go @@ -57,11 +57,11 @@ package $package `, // ******************************* "importWasmLib": ` -import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib" +import "github.com/iotaledger/wasp/packages/wasmvm/wasmlib/go/wasmlib" `, // ******************************* "importWasmTypes": ` -import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" +import "github.com/iotaledger/wasp/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes" `, // ******************************* "goHeader": ` diff --git a/tools/schema/generator/gotemplates/main.go b/tools/schema/generator/gotemplates/main.go index 9a2798990b..318e3d6f36 100644 --- a/tools/schema/generator/gotemplates/main.go +++ b/tools/schema/generator/gotemplates/main.go @@ -7,7 +7,7 @@ var mainGo = map[string]string{ package main -import "github.com/iotaledger/wasp/packages/vm/wasmvmhost" +import "github.com/iotaledger/wasp/packages/wasmvm/wasmvmhost" import "$module/go/$package" diff --git a/tools/schema/generator/templates.go b/tools/schema/generator/templates.go index 6302094177..99e01d0a7f 100644 --- a/tools/schema/generator/templates.go +++ b/tools/schema/generator/templates.go @@ -36,7 +36,7 @@ import ( "testing" "$module/go/$package" - "github.com/iotaledger/wasp/packages/vm/wasmsolo" + "github.com/iotaledger/wasp/packages/wasmvm/wasmsolo" "github.com/stretchr/testify/require" ) From d304cc28169c62b6af7a6d1ec1d0beb17300c9ff Mon Sep 17 00:00:00 2001 From: Eric Hop Date: Sat, 29 Jan 2022 19:58:54 -0800 Subject: [PATCH 051/111] TypeScript refactoring almost complete --- contracts/wasm/dividend/go/dividend/lib.go | 4 +- contracts/wasm/dividend/go/dividend/state.go | 4 +- contracts/wasm/dividend/ts/dividend/consts.ts | 16 +- .../wasm/dividend/ts/dividend/contract.ts | 58 +- .../wasm/dividend/ts/dividend/dividend.ts | 13 +- contracts/wasm/dividend/ts/dividend/index.ts | 1 - contracts/wasm/dividend/ts/dividend/keys.ts | 24 - contracts/wasm/dividend/ts/dividend/lib.ts | 31 +- contracts/wasm/dividend/ts/dividend/params.ts | 57 +- .../wasm/dividend/ts/dividend/results.ts | 25 +- contracts/wasm/dividend/ts/dividend/state.ts | 91 +- .../go/donatewithfeedback/lib.go | 4 +- .../go/donatewithfeedback/structs.go | 20 +- .../ts/donatewithfeedback/consts.ts | 12 +- .../ts/donatewithfeedback/contract.ts | 46 +- .../donatewithfeedback/donatewithfeedback.ts | 7 +- .../ts/donatewithfeedback/index.ts | 1 - .../ts/donatewithfeedback/keys.ts | 34 - .../ts/donatewithfeedback/lib.ts | 22 +- .../ts/donatewithfeedback/params.ts | 37 +- .../ts/donatewithfeedback/results.ts | 73 +- .../ts/donatewithfeedback/state.ts | 57 +- .../ts/donatewithfeedback/structs.ts | 65 +- contracts/wasm/erc20/go/erc20/lib.go | 6 +- contracts/wasm/erc20/go/erc20/state.go | 4 +- contracts/wasm/erc20/go/erc20/typedefs.go | 4 +- contracts/wasm/erc20/ts/erc20/consts.ts | 18 +- contracts/wasm/erc20/ts/erc20/contract.ts | 81 +- contracts/wasm/erc20/ts/erc20/events.ts | 25 +- contracts/wasm/erc20/ts/erc20/index.ts | 1 - contracts/wasm/erc20/ts/erc20/keys.ts | 25 - contracts/wasm/erc20/ts/erc20/lib.ts | 30 +- contracts/wasm/erc20/ts/erc20/params.ts | 121 +-- contracts/wasm/erc20/ts/erc20/results.ts | 37 +- contracts/wasm/erc20/ts/erc20/state.ts | 55 +- contracts/wasm/erc20/ts/erc20/typedefs.ts | 25 +- contracts/wasm/erc721/go/erc721/lib.go | 14 +- contracts/wasm/erc721/go/erc721/state.go | 16 +- contracts/wasm/erc721/go/erc721/typedefs.go | 4 +- contracts/wasm/erc721/ts/erc721/consts.ts | 32 +- contracts/wasm/erc721/ts/erc721/contract.ts | 166 ++-- contracts/wasm/erc721/ts/erc721/erc721.ts | 7 +- contracts/wasm/erc721/ts/erc721/events.ts | 57 +- contracts/wasm/erc721/ts/erc721/index.ts | 1 - contracts/wasm/erc721/ts/erc721/keys.ts | 48 - contracts/wasm/erc721/ts/erc721/lib.ts | 59 +- contracts/wasm/erc721/ts/erc721/params.ts | 225 ++--- contracts/wasm/erc721/ts/erc721/results.ts | 85 +- contracts/wasm/erc721/ts/erc721/state.ts | 153 +-- contracts/wasm/erc721/ts/erc721/typedefs.ts | 25 +- .../wasm/fairauction/go/fairauction/lib.go | 2 +- .../wasm/fairauction/go/fairauction/state.go | 12 +- .../fairauction/go/fairauction/structs.go | 56 +- .../fairauction/go/fairauction/typedefs.go | 4 +- .../wasm/fairauction/ts/fairauction/consts.ts | 14 +- .../fairauction/ts/fairauction/contract.ts | 56 +- .../fairauction/ts/fairauction/fairauction.ts | 21 +- .../wasm/fairauction/ts/fairauction/index.ts | 1 - .../wasm/fairauction/ts/fairauction/keys.ts | 46 - .../wasm/fairauction/ts/fairauction/lib.ts | 23 +- .../wasm/fairauction/ts/fairauction/params.ts | 85 +- .../fairauction/ts/fairauction/results.ts | 101 +- .../wasm/fairauction/ts/fairauction/state.ts | 111 +-- .../fairauction/ts/fairauction/structs.ts | 147 ++- .../fairauction/ts/fairauction/typedefs.ts | 55 +- .../wasm/fairroulette/go/fairroulette/lib.go | 8 +- .../fairroulette/go/fairroulette/structs.go | 12 +- .../fairroulette/ts/fairroulette/consts.ts | 22 +- .../fairroulette/ts/fairroulette/contract.ts | 67 +- .../fairroulette/ts/fairroulette/events.ts | 43 +- .../ts/fairroulette/fairroulette.ts | 8 +- .../fairroulette/ts/fairroulette/index.ts | 1 - .../wasm/fairroulette/ts/fairroulette/keys.ts | 31 - .../wasm/fairroulette/ts/fairroulette/lib.ts | 40 +- .../fairroulette/ts/fairroulette/params.ts | 25 +- .../fairroulette/ts/fairroulette/results.ts | 49 +- .../fairroulette/ts/fairroulette/state.ts | 81 +- .../fairroulette/ts/fairroulette/structs.ts | 57 +- .../wasm/helloworld/go/helloworld/lib.go | 2 +- .../wasm/helloworld/ts/helloworld/consts.ts | 8 +- .../wasm/helloworld/ts/helloworld/contract.ts | 13 +- .../wasm/helloworld/ts/helloworld/index.ts | 1 - .../wasm/helloworld/ts/helloworld/keys.ts | 11 - .../wasm/helloworld/ts/helloworld/lib.ts | 11 +- .../wasm/helloworld/ts/helloworld/results.ts | 13 +- .../wasm/helloworld/ts/helloworld/state.ts | 9 +- .../inccounter/go/inccounter/inccounter.go | 22 +- .../wasm/inccounter/go/inccounter/lib.go | 6 +- .../wasm/inccounter/ts/inccounter/consts.ts | 38 +- .../wasm/inccounter/ts/inccounter/contract.ts | 101 +- .../inccounter/ts/inccounter/inccounter.ts | 70 +- .../wasm/inccounter/ts/inccounter/index.ts | 1 - .../wasm/inccounter/ts/inccounter/keys.ts | 33 - .../wasm/inccounter/ts/inccounter/lib.ts | 40 +- .../wasm/inccounter/ts/inccounter/params.ts | 73 +- .../wasm/inccounter/ts/inccounter/results.ts | 85 +- .../wasm/inccounter/ts/inccounter/state.ts | 25 +- contracts/wasm/testcore/go/testcore/lib.go | 20 +- .../wasm/testcore/go/testcore/results.go | 8 +- .../wasm/testcore/go/testcore/testcore.go | 11 +- contracts/wasm/testcore/test/testcore_test.go | 18 +- contracts/wasm/testcore/ts/testcore/consts.ts | 68 +- .../wasm/testcore/ts/testcore/contract.ts | 250 ++--- contracts/wasm/testcore/ts/testcore/index.ts | 1 - contracts/wasm/testcore/ts/testcore/keys.ts | 57 -- contracts/wasm/testcore/ts/testcore/lib.ts | 94 +- contracts/wasm/testcore/ts/testcore/params.ts | 421 ++++---- .../wasm/testcore/ts/testcore/results.ts | 169 ++-- contracts/wasm/testcore/ts/testcore/state.ts | 47 +- .../wasm/testcore/ts/testcore/testcore.ts | 40 +- .../wasm/testwasmlib/go/testwasmlib/lib.go | 14 +- .../wasm/testwasmlib/go/testwasmlib/params.go | 4 +- .../wasm/testwasmlib/go/testwasmlib/state.go | 8 +- .../testwasmlib/go/testwasmlib/structs.go | 248 ----- .../testwasmlib/go/testwasmlib/typedefs.go | 4 +- .../wasm/testwasmlib/ts/testwasmlib/consts.ts | 34 +- .../testwasmlib/ts/testwasmlib/contract.ts | 168 ++-- .../wasm/testwasmlib/ts/testwasmlib/events.ts | 11 +- .../wasm/testwasmlib/ts/testwasmlib/index.ts | 1 - .../wasm/testwasmlib/ts/testwasmlib/keys.ts | 52 - .../wasm/testwasmlib/ts/testwasmlib/lib.ts | 60 +- .../wasm/testwasmlib/ts/testwasmlib/params.ts | 381 ++++---- .../testwasmlib/ts/testwasmlib/results.ts | 85 +- .../wasm/testwasmlib/ts/testwasmlib/state.ts | 73 +- .../testwasmlib/ts/testwasmlib/testwasmlib.ts | 13 +- .../testwasmlib/ts/testwasmlib/typedefs.ts | 55 +- contracts/wasm/timestamp/go/timestamp/lib.go | 2 +- .../wasm/timestamp/ts/timestamp/consts.ts | 8 +- .../wasm/timestamp/ts/timestamp/contract.ts | 13 +- .../wasm/timestamp/ts/timestamp/index.ts | 1 - contracts/wasm/timestamp/ts/timestamp/keys.ts | 13 - contracts/wasm/timestamp/ts/timestamp/lib.ts | 11 +- .../wasm/timestamp/ts/timestamp/results.ts | 13 +- .../wasm/timestamp/ts/timestamp/state.ts | 17 +- .../tokenregistry/go/tokenregistry/state.go | 4 +- .../tokenregistry/go/tokenregistry/structs.go | 28 +- .../tokenregistry/ts/tokenregistry/consts.ts | 12 +- .../ts/tokenregistry/contract.ts | 41 +- .../tokenregistry/ts/tokenregistry/index.ts | 1 - .../tokenregistry/ts/tokenregistry/keys.ts | 16 - .../tokenregistry/ts/tokenregistry/lib.ts | 17 +- .../tokenregistry/ts/tokenregistry/params.ts | 57 +- .../tokenregistry/ts/tokenregistry/state.ts | 75 +- .../tokenregistry/ts/tokenregistry/structs.ts | 75 +- .../ts/tokenregistry/tokenregistry.ts | 6 +- .../wasmvm/wasmhost/wasmtosandboxtrace.go | 60 ++ .../wasmvm/wasmhost/wasmtosandboxutils.go | 4 +- packages/wasmvm/wasmhost/wasmvm.go | 117 ++- packages/wasmvm/wasmlib/go/wasmlib/assets.go | 19 +- packages/wasmvm/wasmlib/go/wasmlib/context.go | 3 +- .../wasmvm/wasmlib/go/wasmlib/contract.go | 6 +- .../go/wasmlib/coreaccounts/results.go | 8 +- .../wasmlib/go/wasmlib/coreblob/params.go | 4 +- .../wasmlib/go/wasmlib/coreblob/results.go | 8 +- .../wasmlib/go/wasmlib/coreroot/results.go | 4 +- packages/wasmvm/wasmlib/go/wasmlib/dict.go | 79 +- packages/wasmvm/wasmlib/go/wasmlib/host.go | 8 - packages/wasmvm/wasmlib/go/wasmlib/sandbox.go | 52 +- .../wasmvm/wasmlib/go/wasmlib/sandboxutils.go | 4 +- .../go/wasmlib/wasmrequests/structs.go | 64 +- .../wasmlib/go/wasmlib/wasmtypes/codec.go | 64 +- .../wasmlib/go/wasmlib/wasmtypes/proxy.go | 14 +- .../wasmtypes/{address.go => scaddress.go} | 38 +- .../wasmtypes/{agentid.go => scagentid.go} | 48 +- .../wasmlib/wasmtypes/{bool.go => scbool.go} | 28 +- .../wasmtypes/{bytes.go => scbytes.go} | 14 +- .../wasmtypes/{chainid.go => scchainid.go} | 38 +- .../wasmtypes/{color.go => sccolor.go} | 38 +- .../wasmlib/wasmtypes/{hash.go => schash.go} | 38 +- .../wasmtypes/{hname.go => schname.go} | 39 +- .../wasmtypes/{int16.go => scint16.go} | 19 +- .../wasmtypes/{int32.go => scint32.go} | 15 +- .../wasmtypes/{int64.go => scint64.go} | 14 +- .../wasmlib/wasmtypes/{int8.go => scint8.go} | 12 +- .../{requestid.go => screquestid.go} | 38 +- .../wasmtypes/{string.go => scstring.go} | 8 +- .../wasmtypes/{uint16.go => scuint16.go} | 13 +- .../wasmtypes/{uint32.go => scuint32.go} | 12 +- .../wasmtypes/{uint64.go => scuint64.go} | 12 +- .../wasmtypes/{uint8.go => scuint8.go} | 12 +- packages/wasmvm/wasmlib/ts/wasmlib/assets.ts | 94 ++ packages/wasmvm/wasmlib/ts/wasmlib/bytes.ts | 358 ------- packages/wasmvm/wasmlib/ts/wasmlib/context.ts | 363 +------ .../wasmvm/wasmlib/ts/wasmlib/contract.ts | 198 ++-- packages/wasmvm/wasmlib/ts/wasmlib/convert.ts | 97 -- .../wasmlib/ts/wasmlib/coreaccounts/consts.ts | 18 +- .../ts/wasmlib/coreaccounts/contract.ts | 43 +- .../wasmlib/ts/wasmlib/coreaccounts/params.ts | 57 +- .../ts/wasmlib/coreaccounts/results.ts | 85 +- .../wasmlib/ts/wasmlib/coreblob/consts.ts | 12 +- .../wasmlib/ts/wasmlib/coreblob/contract.ts | 34 +- .../wasmlib/ts/wasmlib/coreblob/params.ts | 65 +- .../wasmlib/ts/wasmlib/coreblob/results.ts | 89 +- .../wasmlib/ts/wasmlib/coreblocklog/consts.ts | 24 +- .../ts/wasmlib/coreblocklog/contract.ts | 85 +- .../wasmlib/ts/wasmlib/coreblocklog/params.ts | 113 +-- .../ts/wasmlib/coreblocklog/results.ts | 211 ++-- .../ts/wasmlib/coregovernance/consts.ts | 28 +- .../ts/wasmlib/coregovernance/contract.ts | 70 +- .../ts/wasmlib/coregovernance/params.ts | 169 ++-- .../ts/wasmlib/coregovernance/results.ts | 157 ++- .../wasmlib/ts/wasmlib/coreroot/consts.ts | 14 +- .../wasmlib/ts/wasmlib/coreroot/contract.ts | 34 +- .../wasmlib/ts/wasmlib/coreroot/params.ts | 65 +- .../wasmlib/ts/wasmlib/coreroot/results.ts | 55 +- packages/wasmvm/wasmlib/ts/wasmlib/dict.ts | 113 +++ packages/wasmvm/wasmlib/ts/wasmlib/events.ts | 103 +- packages/wasmvm/wasmlib/ts/wasmlib/exports.ts | 25 +- .../wasmvm/wasmlib/ts/wasmlib/hashtypes.ts | 337 ------- packages/wasmvm/wasmlib/ts/wasmlib/host.ts | 192 +--- .../wasmvm/wasmlib/ts/wasmlib/immutable.ts | 717 -------------- packages/wasmvm/wasmlib/ts/wasmlib/index.ts | 14 +- packages/wasmvm/wasmlib/ts/wasmlib/keys.ts | 75 -- packages/wasmvm/wasmlib/ts/wasmlib/mutable.ts | 917 ------------------ packages/wasmvm/wasmlib/ts/wasmlib/sandbox.ts | 299 ++++++ .../wasmvm/wasmlib/ts/wasmlib/sandboxutils.ts | 66 ++ packages/wasmvm/wasmlib/ts/wasmlib/state.ts | 42 + .../wasmlib/ts/wasmlib/wasmrequests/consts.ts | 4 +- .../ts/wasmlib/wasmrequests/contract.ts | 1 + .../wasmlib/ts/wasmlib/wasmrequests/index.ts | 1 + .../ts/wasmlib/wasmrequests/structs.ts | 249 ++--- .../wasmlib/ts/wasmlib/wasmtypes/codec.ts | 216 +++++ .../wasmlib/ts/wasmlib/wasmtypes/index.ts | 24 + .../wasmlib/ts/wasmlib/wasmtypes/package.json | 12 + .../wasmlib/ts/wasmlib/wasmtypes/proxy.ts | 154 +++ .../wasmlib/ts/wasmlib/wasmtypes/scaddress.ts | 109 +++ .../wasmlib/ts/wasmlib/wasmtypes/scagentid.ts | 125 +++ .../wasmlib/ts/wasmlib/wasmtypes/scbool.ts | 78 ++ .../wasmlib/ts/wasmlib/wasmtypes/scbytes.ts | 71 ++ .../wasmlib/ts/wasmlib/wasmtypes/scchainid.ts | 107 ++ .../wasmlib/ts/wasmlib/wasmtypes/sccolor.ts | 107 ++ .../wasmlib/ts/wasmlib/wasmtypes/schash.ts | 98 ++ .../wasmlib/ts/wasmlib/wasmtypes/schname.ts | 104 ++ .../wasmlib/ts/wasmlib/wasmtypes/scint16.ts | 74 ++ .../wasmlib/ts/wasmlib/wasmtypes/scint32.ts | 78 ++ .../wasmlib/ts/wasmlib/wasmtypes/scint64.ts | 86 ++ .../wasmlib/ts/wasmlib/wasmtypes/scint8.ts | 70 ++ .../ts/wasmlib/wasmtypes/screquestid.ts | 103 ++ .../wasmlib/ts/wasmlib/wasmtypes/scstring.ts | 67 ++ .../wasmlib/ts/wasmlib/wasmtypes/scuint16.ts | 74 ++ .../wasmlib/ts/wasmlib/wasmtypes/scuint32.ts | 78 ++ .../wasmlib/ts/wasmlib/wasmtypes/scuint64.ts | 86 ++ .../wasmlib/ts/wasmlib/wasmtypes/scuint8.ts | 70 ++ .../ts/wasmlib/wasmtypes/tsconfig.json | 6 + packages/wasmvm/wasmsolo/solocontext.go | 5 +- packages/wasmvm/wasmsolo/solosandboxutils.go | 4 +- packages/wasmvm/wasmvmhost/host.go | 9 +- tools/schema/generator/emitter.go | 2 +- .../generator/goclienttemplates/service.go | 2 +- .../generator/gotemplates/alltemplates.go | 8 +- tools/schema/generator/gotemplates/lib.go | 2 +- tools/schema/generator/gotemplates/proxy.go | 8 +- tools/schema/generator/gotemplates/structs.go | 4 +- .../schema/generator/gotemplates/typedefs.go | 6 +- tools/schema/generator/rstemplates/proxy.go | 8 +- .../schema/generator/rstemplates/typedefs.go | 2 +- .../generator/tsclienttemplates/service.go | 2 +- .../generator/tstemplates/alltemplates.go | 90 +- tools/schema/generator/tstemplates/consts.go | 6 +- .../schema/generator/tstemplates/contract.go | 29 +- tools/schema/generator/tstemplates/events.go | 7 +- tools/schema/generator/tstemplates/index.go | 13 +- tools/schema/generator/tstemplates/keys.go | 25 +- tools/schema/generator/tstemplates/lib.go | 23 +- tools/schema/generator/tstemplates/params.go | 2 +- tools/schema/generator/tstemplates/proxy.go | 35 +- tools/schema/generator/tstemplates/results.go | 2 +- tools/schema/generator/tstemplates/state.go | 6 +- tools/schema/generator/tstemplates/structs.go | 34 +- .../schema/generator/tstemplates/typedefs.go | 79 +- 270 files changed, 6993 insertions(+), 8655 deletions(-) delete mode 100644 contracts/wasm/testwasmlib/go/testwasmlib/structs.go create mode 100644 packages/wasmvm/wasmhost/wasmtosandboxtrace.go rename packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/{address.go => scaddress.go} (75%) rename packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/{agentid.go => scagentid.go} (75%) rename packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/{bool.go => scbool.go} (75%) rename packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/{bytes.go => scbytes.go} (81%) rename packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/{chainid.go => scchainid.go} (75%) rename packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/{color.go => sccolor.go} (74%) rename packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/{hash.go => schash.go} (72%) rename packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/{hname.go => schname.go} (69%) rename packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/{int16.go => scint16.go} (78%) rename packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/{int32.go => scint32.go} (84%) rename packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/{int64.go => scint64.go} (84%) rename packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/{int8.go => scint8.go} (85%) rename packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/{requestid.go => screquestid.go} (74%) rename packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/{string.go => scstring.go} (87%) rename packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/{uint16.go => scuint16.go} (88%) rename packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/{uint32.go => scuint32.go} (89%) rename packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/{uint64.go => scuint64.go} (89%) rename packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/{uint8.go => scuint8.go} (88%) create mode 100644 packages/wasmvm/wasmlib/ts/wasmlib/assets.ts delete mode 100644 packages/wasmvm/wasmlib/ts/wasmlib/bytes.ts delete mode 100644 packages/wasmvm/wasmlib/ts/wasmlib/convert.ts create mode 100644 packages/wasmvm/wasmlib/ts/wasmlib/dict.ts delete mode 100644 packages/wasmvm/wasmlib/ts/wasmlib/hashtypes.ts delete mode 100644 packages/wasmvm/wasmlib/ts/wasmlib/immutable.ts delete mode 100644 packages/wasmvm/wasmlib/ts/wasmlib/keys.ts delete mode 100644 packages/wasmvm/wasmlib/ts/wasmlib/mutable.ts create mode 100644 packages/wasmvm/wasmlib/ts/wasmlib/sandbox.ts create mode 100644 packages/wasmvm/wasmlib/ts/wasmlib/sandboxutils.ts create mode 100644 packages/wasmvm/wasmlib/ts/wasmlib/state.ts create mode 100644 packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/codec.ts create mode 100644 packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/index.ts create mode 100644 packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/package.json create mode 100644 packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/proxy.ts create mode 100644 packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/scaddress.ts create mode 100644 packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/scagentid.ts create mode 100644 packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/scbool.ts create mode 100644 packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/scbytes.ts create mode 100644 packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/scchainid.ts create mode 100644 packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/sccolor.ts create mode 100644 packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/schash.ts create mode 100644 packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/schname.ts create mode 100644 packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/scint16.ts create mode 100644 packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/scint32.ts create mode 100644 packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/scint64.ts create mode 100644 packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/scint8.ts create mode 100644 packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/screquestid.ts create mode 100644 packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/scstring.ts create mode 100644 packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/scuint16.ts create mode 100644 packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/scuint32.ts create mode 100644 packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/scuint64.ts create mode 100644 packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/scuint8.ts create mode 100644 packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/tsconfig.json diff --git a/contracts/wasm/dividend/go/dividend/lib.go b/contracts/wasm/dividend/go/dividend/lib.go index 6196d7a900..c9a484b290 100644 --- a/contracts/wasm/dividend/go/dividend/lib.go +++ b/contracts/wasm/dividend/go/dividend/lib.go @@ -128,8 +128,8 @@ func viewGetFactorThunk(ctx wasmlib.ScViewContext) { } ctx.Require(f.Params.Address().Exists(), "missing mandatory address") viewGetFactor(ctx, f) - ctx.Log("dividend.viewGetFactor ok") ctx.Results(results) + ctx.Log("dividend.viewGetFactor ok") } type GetOwnerContext struct { @@ -149,6 +149,6 @@ func viewGetOwnerThunk(ctx wasmlib.ScViewContext) { }, } viewGetOwner(ctx, f) - ctx.Log("dividend.viewGetOwner ok") ctx.Results(results) + ctx.Log("dividend.viewGetOwner ok") } diff --git a/contracts/wasm/dividend/go/dividend/state.go b/contracts/wasm/dividend/go/dividend/state.go index 9d5ad8cbb8..8473370307 100644 --- a/contracts/wasm/dividend/go/dividend/state.go +++ b/contracts/wasm/dividend/go/dividend/state.go @@ -26,7 +26,7 @@ type MapAddressToImmutableUint64 struct { } func (m MapAddressToImmutableUint64) GetUint64(key wasmtypes.ScAddress) wasmtypes.ScImmutableUint64 { - return wasmtypes.NewScImmutableUint64(m.proxy.Key(wasmtypes.BytesFromAddress(key))) + return wasmtypes.NewScImmutableUint64(m.proxy.Key(wasmtypes.AddressToBytes(key))) } type ImmutableDividendState struct { @@ -78,7 +78,7 @@ func (m MapAddressToMutableUint64) Clear() { } func (m MapAddressToMutableUint64) GetUint64(key wasmtypes.ScAddress) wasmtypes.ScMutableUint64 { - return wasmtypes.NewScMutableUint64(m.proxy.Key(wasmtypes.BytesFromAddress(key))) + return wasmtypes.NewScMutableUint64(m.proxy.Key(wasmtypes.AddressToBytes(key))) } type MutableDividendState struct { diff --git a/contracts/wasm/dividend/ts/dividend/consts.ts b/contracts/wasm/dividend/ts/dividend/consts.ts index 4368c1405e..1d3cf98eee 100644 --- a/contracts/wasm/dividend/ts/dividend/consts.ts +++ b/contracts/wasm/dividend/ts/dividend/consts.ts @@ -5,11 +5,11 @@ // >>>> DO NOT CHANGE THIS FILE! <<<< // Change the json schema instead -import * as wasmlib from "wasmlib"; +import * as wasmtypes from "wasmlib/wasmtypes"; export const ScName = "dividend"; export const ScDescription = "Simple dividend smart contract"; -export const HScName = new wasmlib.ScHname(0xcce2e239); +export const HScName = new wasmtypes.ScHname(0xcce2e239); export const ParamAddress = "address"; export const ParamFactor = "factor"; @@ -30,9 +30,9 @@ export const FuncSetOwner = "setOwner"; export const ViewGetFactor = "getFactor"; export const ViewGetOwner = "getOwner"; -export const HFuncDivide = new wasmlib.ScHname(0xc7878107); -export const HFuncInit = new wasmlib.ScHname(0x1f44d644); -export const HFuncMember = new wasmlib.ScHname(0xc07da2cb); -export const HFuncSetOwner = new wasmlib.ScHname(0x2a15fe7b); -export const HViewGetFactor = new wasmlib.ScHname(0x0ee668fe); -export const HViewGetOwner = new wasmlib.ScHname(0x137107a6); +export const HFuncDivide = new wasmtypes.ScHname(0xc7878107); +export const HFuncInit = new wasmtypes.ScHname(0x1f44d644); +export const HFuncMember = new wasmtypes.ScHname(0xc07da2cb); +export const HFuncSetOwner = new wasmtypes.ScHname(0x2a15fe7b); +export const HViewGetFactor = new wasmtypes.ScHname(0x0ee668fe); +export const HViewGetOwner = new wasmtypes.ScHname(0x137107a6); diff --git a/contracts/wasm/dividend/ts/dividend/contract.ts b/contracts/wasm/dividend/ts/dividend/contract.ts index 929d85e4ac..3a88624118 100644 --- a/contracts/wasm/dividend/ts/dividend/contract.ts +++ b/contracts/wasm/dividend/ts/dividend/contract.ts @@ -6,6 +6,7 @@ // Change the json schema instead import * as wasmlib from "wasmlib"; +import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; export class DivideCall { @@ -13,59 +14,59 @@ export class DivideCall { } export class DivideContext { - state: sc.MutableDividendState = new sc.MutableDividendState(); + state: sc.MutableDividendState = new sc.MutableDividendState(wasmlib.ScState.proxy()); } export class InitCall { func: wasmlib.ScInitFunc = new wasmlib.ScInitFunc(sc.HScName, sc.HFuncInit); - params: sc.MutableInitParams = new sc.MutableInitParams(); + params: sc.MutableInitParams = new sc.MutableInitParams(wasmlib.ScView.nilProxy); } export class InitContext { - params: sc.ImmutableInitParams = new sc.ImmutableInitParams(); - state: sc.MutableDividendState = new sc.MutableDividendState(); + params: sc.ImmutableInitParams = new sc.ImmutableInitParams(wasmlib.paramsProxy()); + state: sc.MutableDividendState = new sc.MutableDividendState(wasmlib.ScState.proxy()); } export class MemberCall { func: wasmlib.ScFunc = new wasmlib.ScFunc(sc.HScName, sc.HFuncMember); - params: sc.MutableMemberParams = new sc.MutableMemberParams(); + params: sc.MutableMemberParams = new sc.MutableMemberParams(wasmlib.ScView.nilProxy); } export class MemberContext { - params: sc.ImmutableMemberParams = new sc.ImmutableMemberParams(); - state: sc.MutableDividendState = new sc.MutableDividendState(); + params: sc.ImmutableMemberParams = new sc.ImmutableMemberParams(wasmlib.paramsProxy()); + state: sc.MutableDividendState = new sc.MutableDividendState(wasmlib.ScState.proxy()); } export class SetOwnerCall { func: wasmlib.ScFunc = new wasmlib.ScFunc(sc.HScName, sc.HFuncSetOwner); - params: sc.MutableSetOwnerParams = new sc.MutableSetOwnerParams(); + params: sc.MutableSetOwnerParams = new sc.MutableSetOwnerParams(wasmlib.ScView.nilProxy); } export class SetOwnerContext { - params: sc.ImmutableSetOwnerParams = new sc.ImmutableSetOwnerParams(); - state: sc.MutableDividendState = new sc.MutableDividendState(); + params: sc.ImmutableSetOwnerParams = new sc.ImmutableSetOwnerParams(wasmlib.paramsProxy()); + state: sc.MutableDividendState = new sc.MutableDividendState(wasmlib.ScState.proxy()); } export class GetFactorCall { func: wasmlib.ScView = new wasmlib.ScView(sc.HScName, sc.HViewGetFactor); - params: sc.MutableGetFactorParams = new sc.MutableGetFactorParams(); - results: sc.ImmutableGetFactorResults = new sc.ImmutableGetFactorResults(); + params: sc.MutableGetFactorParams = new sc.MutableGetFactorParams(wasmlib.ScView.nilProxy); + results: sc.ImmutableGetFactorResults = new sc.ImmutableGetFactorResults(wasmlib.ScView.nilProxy); } export class GetFactorContext { - params: sc.ImmutableGetFactorParams = new sc.ImmutableGetFactorParams(); - results: sc.MutableGetFactorResults = new sc.MutableGetFactorResults(); - state: sc.ImmutableDividendState = new sc.ImmutableDividendState(); + params: sc.ImmutableGetFactorParams = new sc.ImmutableGetFactorParams(wasmlib.paramsProxy()); + results: sc.MutableGetFactorResults = new sc.MutableGetFactorResults(wasmlib.ScView.nilProxy); + state: sc.ImmutableDividendState = new sc.ImmutableDividendState(wasmlib.ScState.proxy()); } export class GetOwnerCall { func: wasmlib.ScView = new wasmlib.ScView(sc.HScName, sc.HViewGetOwner); - results: sc.ImmutableGetOwnerResults = new sc.ImmutableGetOwnerResults(); + results: sc.ImmutableGetOwnerResults = new sc.ImmutableGetOwnerResults(wasmlib.ScView.nilProxy); } export class GetOwnerContext { - results: sc.MutableGetOwnerResults = new sc.MutableGetOwnerResults(); - state: sc.ImmutableDividendState = new sc.ImmutableDividendState(); + results: sc.MutableGetOwnerResults = new sc.MutableGetOwnerResults(wasmlib.ScView.nilProxy); + state: sc.ImmutableDividendState = new sc.ImmutableDividendState(wasmlib.ScState.proxy()); } export class ScFuncs { @@ -74,32 +75,33 @@ export class ScFuncs { } static init(ctx: wasmlib.ScFuncCallContext): InitCall { - let f = new InitCall(); - f.func.setPtrs(f.params, null); + const f = new InitCall(); + f.params = new sc.MutableInitParams(wasmlib.newCallParamsProxy(f.func)); return f; } static member(ctx: wasmlib.ScFuncCallContext): MemberCall { - let f = new MemberCall(); - f.func.setPtrs(f.params, null); + const f = new MemberCall(); + f.params = new sc.MutableMemberParams(wasmlib.newCallParamsProxy(f.func)); return f; } static setOwner(ctx: wasmlib.ScFuncCallContext): SetOwnerCall { - let f = new SetOwnerCall(); - f.func.setPtrs(f.params, null); + const f = new SetOwnerCall(); + f.params = new sc.MutableSetOwnerParams(wasmlib.newCallParamsProxy(f.func)); return f; } static getFactor(ctx: wasmlib.ScViewCallContext): GetFactorCall { - let f = new GetFactorCall(); - f.func.setPtrs(f.params, f.results); + const f = new GetFactorCall(); + f.params = new sc.MutableGetFactorParams(wasmlib.newCallParamsProxy(f.func)); + f.results = new sc.ImmutableGetFactorResults(wasmlib.newCallResultsProxy(f.func)); return f; } static getOwner(ctx: wasmlib.ScViewCallContext): GetOwnerCall { - let f = new GetOwnerCall(); - f.func.setPtrs(null, f.results); + const f = new GetOwnerCall(); + f.results = new sc.ImmutableGetOwnerResults(wasmlib.newCallResultsProxy(f.func)); return f; } } diff --git a/contracts/wasm/dividend/ts/dividend/dividend.ts b/contracts/wasm/dividend/ts/dividend/dividend.ts index 6996a878da..11cbc72322 100644 --- a/contracts/wasm/dividend/ts/dividend/dividend.ts +++ b/contracts/wasm/dividend/ts/dividend/dividend.ts @@ -89,12 +89,9 @@ export function funcMember(ctx: wasmlib.ScFuncContext, f: sc.MemberContext): voi let memberList: sc.ArrayOfMutableAddress = f.state.memberList(); // Now we will append the new address to the memberList array. - // First we determine the current length of the array. - let length: u32 = memberList.length(); - - // Next we create an ScMutableAddress proxy to the address value that lives - // at that index in the memberList array (no value, since we're appending). - let newAddress: wasmlib.ScMutableAddress = memberList.getAddress(length); + // We create an ScMutableAddress proxy to an address value that lives + // at the end of the memberList array (no value yet, since we're appending). + let newAddress: wasmlib.ScMutableAddress = memberList.appendAddress(); // And finally we append the new address to the array by telling the proxy // to update the value it refers to with the 'address' parameter. @@ -142,7 +139,7 @@ export function funcDivide(ctx: wasmlib.ScFuncContext, f: sc.DivideContext): voi let balances: wasmlib.ScBalances = ctx.balances(); // Retrieve the amount of plain iota tokens from the account balance. - let amount: u64 = balances.balance(wasmlib.ScColor.IOTA); + let amount: u64 = balances.balance(wasmlib.IOTA); // Retrieve the pre-calculated totalFactor value from the state storage. let totalFactor: u64 = f.state.totalFactor().value(); @@ -182,7 +179,7 @@ export function funcDivide(ctx: wasmlib.ScFuncContext, f: sc.DivideContext): voi // member address. The transferToAddress() method receives the address // value and the proxy to the new transfers map on the host, and will // call the corresponding host sandbox function with these values. - ctx.transferToAddress(address, transfers); + ctx.send(address, transfers); } } } diff --git a/contracts/wasm/dividend/ts/dividend/index.ts b/contracts/wasm/dividend/ts/dividend/index.ts index cf9a259fc4..f9071d3503 100644 --- a/contracts/wasm/dividend/ts/dividend/index.ts +++ b/contracts/wasm/dividend/ts/dividend/index.ts @@ -9,7 +9,6 @@ export * from "./dividend"; export * from "./consts"; export * from "./contract"; -export * from "./keys"; export * from "./lib"; export * from "./params"; export * from "./results"; diff --git a/contracts/wasm/dividend/ts/dividend/keys.ts b/contracts/wasm/dividend/ts/dividend/keys.ts index 8f3a026043..7a229a25ef 100644 --- a/contracts/wasm/dividend/ts/dividend/keys.ts +++ b/contracts/wasm/dividend/ts/dividend/keys.ts @@ -5,31 +5,7 @@ // >>>> DO NOT CHANGE THIS FILE! <<<< // Change the json schema instead -import * as wasmlib from "wasmlib"; -import * as sc from "./index"; export const IdxParamAddress = 0; export const IdxParamFactor = 1; export const IdxParamOwner = 2; - -export const IdxResultFactor = 3; -export const IdxResultOwner = 4; - -export const IdxStateMemberList = 5; -export const IdxStateMembers = 6; -export const IdxStateOwner = 7; -export const IdxStateTotalFactor = 8; - -export let keyMap: string[] = [ - sc.ParamAddress, - sc.ParamFactor, - sc.ParamOwner, - sc.ResultFactor, - sc.ResultOwner, - sc.StateMemberList, - sc.StateMembers, - sc.StateOwner, - sc.StateTotalFactor, -]; - -export let idxMap: wasmlib.Key32[] = new Array(keyMap.length); diff --git a/contracts/wasm/dividend/ts/dividend/lib.ts b/contracts/wasm/dividend/ts/dividend/lib.ts index 6d2710649e..04083b5d0f 100644 --- a/contracts/wasm/dividend/ts/dividend/lib.ts +++ b/contracts/wasm/dividend/ts/dividend/lib.ts @@ -6,6 +6,7 @@ // Change the json schema instead import * as wasmlib from "wasmlib"; +import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; export function on_call(index: i32): void { @@ -20,16 +21,11 @@ export function on_load(): void { exports.addFunc(sc.FuncSetOwner, funcSetOwnerThunk); exports.addView(sc.ViewGetFactor, viewGetFactorThunk); exports.addView(sc.ViewGetOwner, viewGetOwnerThunk); - - for (let i = 0; i < sc.keyMap.length; i++) { - sc.idxMap[i] = wasmlib.Key32.fromString(sc.keyMap[i]); - } } function funcDivideThunk(ctx: wasmlib.ScFuncContext): void { ctx.log("dividend.funcDivide"); let f = new sc.DivideContext(); - f.state.mapID = wasmlib.OBJ_ID_STATE; sc.funcDivide(ctx, f); ctx.log("dividend.funcDivide ok"); } @@ -37,23 +33,19 @@ function funcDivideThunk(ctx: wasmlib.ScFuncContext): void { function funcInitThunk(ctx: wasmlib.ScFuncContext): void { ctx.log("dividend.funcInit"); let f = new sc.InitContext(); - f.params.mapID = wasmlib.OBJ_ID_PARAMS; - f.state.mapID = wasmlib.OBJ_ID_STATE; sc.funcInit(ctx, f); ctx.log("dividend.funcInit ok"); } function funcMemberThunk(ctx: wasmlib.ScFuncContext): void { ctx.log("dividend.funcMember"); + let f = new sc.MemberContext(); // only defined owner of contract can add members - let access = ctx.state().getAgentID(wasmlib.Key32.fromString("owner")); + const access = f.state.owner(); ctx.require(access.exists(), "access not set: owner"); ctx.require(ctx.caller().equals(access.value()), "no permission"); - let f = new sc.MemberContext(); - f.params.mapID = wasmlib.OBJ_ID_PARAMS; - f.state.mapID = wasmlib.OBJ_ID_STATE; ctx.require(f.params.address().exists(), "missing mandatory address"); ctx.require(f.params.factor().exists(), "missing mandatory factor"); sc.funcMember(ctx, f); @@ -62,15 +54,13 @@ function funcMemberThunk(ctx: wasmlib.ScFuncContext): void { function funcSetOwnerThunk(ctx: wasmlib.ScFuncContext): void { ctx.log("dividend.funcSetOwner"); + let f = new sc.SetOwnerContext(); // only defined owner of contract can change owner - let access = ctx.state().getAgentID(wasmlib.Key32.fromString("owner")); + const access = f.state.owner(); ctx.require(access.exists(), "access not set: owner"); ctx.require(ctx.caller().equals(access.value()), "no permission"); - let f = new sc.SetOwnerContext(); - f.params.mapID = wasmlib.OBJ_ID_PARAMS; - f.state.mapID = wasmlib.OBJ_ID_STATE; ctx.require(f.params.owner().exists(), "missing mandatory owner"); sc.funcSetOwner(ctx, f); ctx.log("dividend.funcSetOwner ok"); @@ -79,19 +69,20 @@ function funcSetOwnerThunk(ctx: wasmlib.ScFuncContext): void { function viewGetFactorThunk(ctx: wasmlib.ScViewContext): void { ctx.log("dividend.viewGetFactor"); let f = new sc.GetFactorContext(); - f.params.mapID = wasmlib.OBJ_ID_PARAMS; - f.results.mapID = wasmlib.OBJ_ID_RESULTS; - f.state.mapID = wasmlib.OBJ_ID_STATE; + const results = new wasmlib.ScDict([]); + f.results = new sc.MutableGetFactorResults(results.asProxy()); ctx.require(f.params.address().exists(), "missing mandatory address"); sc.viewGetFactor(ctx, f); + ctx.results(results); ctx.log("dividend.viewGetFactor ok"); } function viewGetOwnerThunk(ctx: wasmlib.ScViewContext): void { ctx.log("dividend.viewGetOwner"); let f = new sc.GetOwnerContext(); - f.results.mapID = wasmlib.OBJ_ID_RESULTS; - f.state.mapID = wasmlib.OBJ_ID_STATE; + const results = new wasmlib.ScDict([]); + f.results = new sc.MutableGetOwnerResults(results.asProxy()); sc.viewGetOwner(ctx, f); + ctx.results(results); ctx.log("dividend.viewGetOwner ok"); } diff --git a/contracts/wasm/dividend/ts/dividend/params.ts b/contracts/wasm/dividend/ts/dividend/params.ts index 7a6334d72f..391c91ed62 100644 --- a/contracts/wasm/dividend/ts/dividend/params.ts +++ b/contracts/wasm/dividend/ts/dividend/params.ts @@ -6,60 +6,61 @@ // Change the json schema instead import * as wasmlib from "wasmlib"; +import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; -export class ImmutableInitParams extends wasmlib.ScMapID { - owner(): wasmlib.ScImmutableAgentID { - return new wasmlib.ScImmutableAgentID(this.mapID, sc.idxMap[sc.IdxParamOwner]); +export class ImmutableInitParams extends wasmtypes.ScProxy { + owner(): wasmtypes.ScImmutableAgentID { + return new wasmtypes.ScImmutableAgentID(this.proxy.root(sc.ParamOwner)); } } -export class MutableInitParams extends wasmlib.ScMapID { - owner(): wasmlib.ScMutableAgentID { - return new wasmlib.ScMutableAgentID(this.mapID, sc.idxMap[sc.IdxParamOwner]); +export class MutableInitParams extends wasmtypes.ScProxy { + owner(): wasmtypes.ScMutableAgentID { + return new wasmtypes.ScMutableAgentID(this.proxy.root(sc.ParamOwner)); } } -export class ImmutableMemberParams extends wasmlib.ScMapID { - address(): wasmlib.ScImmutableAddress { - return new wasmlib.ScImmutableAddress(this.mapID, wasmlib.Key32.fromString(sc.ParamAddress)); +export class ImmutableMemberParams extends wasmtypes.ScProxy { + address(): wasmtypes.ScImmutableAddress { + return new wasmtypes.ScImmutableAddress(this.proxy.root(sc.ParamAddress)); } - factor(): wasmlib.ScImmutableUint64 { - return new wasmlib.ScImmutableUint64(this.mapID, wasmlib.Key32.fromString(sc.ParamFactor)); + factor(): wasmtypes.ScImmutableUint64 { + return new wasmtypes.ScImmutableUint64(this.proxy.root(sc.ParamFactor)); } } -export class MutableMemberParams extends wasmlib.ScMapID { - address(): wasmlib.ScMutableAddress { - return new wasmlib.ScMutableAddress(this.mapID, wasmlib.Key32.fromString(sc.ParamAddress)); +export class MutableMemberParams extends wasmtypes.ScProxy { + address(): wasmtypes.ScMutableAddress { + return new wasmtypes.ScMutableAddress(this.proxy.root(sc.ParamAddress)); } - factor(): wasmlib.ScMutableUint64 { - return new wasmlib.ScMutableUint64(this.mapID, wasmlib.Key32.fromString(sc.ParamFactor)); + factor(): wasmtypes.ScMutableUint64 { + return new wasmtypes.ScMutableUint64(this.proxy.root(sc.ParamFactor)); } } -export class ImmutableSetOwnerParams extends wasmlib.ScMapID { - owner(): wasmlib.ScImmutableAgentID { - return new wasmlib.ScImmutableAgentID(this.mapID, wasmlib.Key32.fromString(sc.ParamOwner)); +export class ImmutableSetOwnerParams extends wasmtypes.ScProxy { + owner(): wasmtypes.ScImmutableAgentID { + return new wasmtypes.ScImmutableAgentID(this.proxy.root(sc.ParamOwner)); } } -export class MutableSetOwnerParams extends wasmlib.ScMapID { - owner(): wasmlib.ScMutableAgentID { - return new wasmlib.ScMutableAgentID(this.mapID, wasmlib.Key32.fromString(sc.ParamOwner)); +export class MutableSetOwnerParams extends wasmtypes.ScProxy { + owner(): wasmtypes.ScMutableAgentID { + return new wasmtypes.ScMutableAgentID(this.proxy.root(sc.ParamOwner)); } } -export class ImmutableGetFactorParams extends wasmlib.ScMapID { - address(): wasmlib.ScImmutableAddress { - return new wasmlib.ScImmutableAddress(this.mapID, wasmlib.Key32.fromString(sc.ParamAddress)); +export class ImmutableGetFactorParams extends wasmtypes.ScProxy { + address(): wasmtypes.ScImmutableAddress { + return new wasmtypes.ScImmutableAddress(this.proxy.root(sc.ParamAddress)); } } -export class MutableGetFactorParams extends wasmlib.ScMapID { - address(): wasmlib.ScMutableAddress { - return new wasmlib.ScMutableAddress(this.mapID, wasmlib.Key32.fromString(sc.ParamAddress)); +export class MutableGetFactorParams extends wasmtypes.ScProxy { + address(): wasmtypes.ScMutableAddress { + return new wasmtypes.ScMutableAddress(this.proxy.root(sc.ParamAddress)); } } diff --git a/contracts/wasm/dividend/ts/dividend/results.ts b/contracts/wasm/dividend/ts/dividend/results.ts index afdd4d83e1..84accfd03a 100644 --- a/contracts/wasm/dividend/ts/dividend/results.ts +++ b/contracts/wasm/dividend/ts/dividend/results.ts @@ -6,28 +6,29 @@ // Change the json schema instead import * as wasmlib from "wasmlib"; +import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; -export class ImmutableGetFactorResults extends wasmlib.ScMapID { - factor(): wasmlib.ScImmutableUint64 { - return new wasmlib.ScImmutableUint64(this.mapID, wasmlib.Key32.fromString(sc.ResultFactor)); +export class ImmutableGetFactorResults extends wasmtypes.ScProxy { + factor(): wasmtypes.ScImmutableUint64 { + return new wasmtypes.ScImmutableUint64(this.proxy.root(sc.ResultFactor)); } } -export class MutableGetFactorResults extends wasmlib.ScMapID { - factor(): wasmlib.ScMutableUint64 { - return new wasmlib.ScMutableUint64(this.mapID, wasmlib.Key32.fromString(sc.ResultFactor)); +export class MutableGetFactorResults extends wasmtypes.ScProxy { + factor(): wasmtypes.ScMutableUint64 { + return new wasmtypes.ScMutableUint64(this.proxy.root(sc.ResultFactor)); } } -export class ImmutableGetOwnerResults extends wasmlib.ScMapID { - owner(): wasmlib.ScImmutableAgentID { - return new wasmlib.ScImmutableAgentID(this.mapID, wasmlib.Key32.fromString(sc.ResultOwner)); +export class ImmutableGetOwnerResults extends wasmtypes.ScProxy { + owner(): wasmtypes.ScImmutableAgentID { + return new wasmtypes.ScImmutableAgentID(this.proxy.root(sc.ResultOwner)); } } -export class MutableGetOwnerResults extends wasmlib.ScMapID { - owner(): wasmlib.ScMutableAgentID { - return new wasmlib.ScMutableAgentID(this.mapID, wasmlib.Key32.fromString(sc.ResultOwner)); +export class MutableGetOwnerResults extends wasmtypes.ScProxy { + owner(): wasmtypes.ScMutableAgentID { + return new wasmtypes.ScMutableAgentID(this.proxy.root(sc.ResultOwner)); } } diff --git a/contracts/wasm/dividend/ts/dividend/state.ts b/contracts/wasm/dividend/ts/dividend/state.ts index 92a0981f41..d05a26a58a 100644 --- a/contracts/wasm/dividend/ts/dividend/state.ts +++ b/contracts/wasm/dividend/ts/dividend/state.ts @@ -6,114 +6,93 @@ // Change the json schema instead import * as wasmlib from "wasmlib"; +import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; -export class ArrayOfImmutableAddress { - objID: i32; - - constructor(objID: i32) { - this.objID = objID; - } +export class ArrayOfImmutableAddress extends wasmtypes.ScProxy { length(): u32 { - return wasmlib.getLength(this.objID); + return this.proxy.length(); } - getAddress(index: u32): wasmlib.ScImmutableAddress { - return new wasmlib.ScImmutableAddress(this.objID, new wasmlib.Key32(index as i32)); + getAddress(index: u32): wasmtypes.ScImmutableAddress { + return new wasmtypes.ScImmutableAddress(this.proxy.index(index)); } } -export class MapAddressToImmutableUint64 { - objID: i32; - - constructor(objID: i32) { - this.objID = objID; - } +export class MapAddressToImmutableUint64 extends wasmtypes.ScProxy { - getUint64(key: wasmlib.ScAddress): wasmlib.ScImmutableUint64 { - return new wasmlib.ScImmutableUint64(this.objID, key.getKeyID()); + getUint64(key: wasmtypes.ScAddress): wasmtypes.ScImmutableUint64 { + return new wasmtypes.ScImmutableUint64(this.proxy.key(wasmtypes.addressToBytes(key))); } } -export class ImmutableDividendState extends wasmlib.ScMapID { +export class ImmutableDividendState extends wasmtypes.ScProxy { memberList(): sc.ArrayOfImmutableAddress { - let arrID = wasmlib.getObjectID(this.mapID, wasmlib.Key32.fromString(sc.StateMemberList), wasmlib.TYPE_ARRAY|wasmlib.TYPE_ADDRESS); - return new sc.ArrayOfImmutableAddress(arrID); + return new sc.ArrayOfImmutableAddress(this.proxy.root(sc.StateMemberList)); } members(): sc.MapAddressToImmutableUint64 { - let mapID = wasmlib.getObjectID(this.mapID, wasmlib.Key32.fromString(sc.StateMembers), wasmlib.TYPE_MAP); - return new sc.MapAddressToImmutableUint64(mapID); + return new sc.MapAddressToImmutableUint64(this.proxy.root(sc.StateMembers)); } - owner(): wasmlib.ScImmutableAgentID { - return new wasmlib.ScImmutableAgentID(this.mapID, wasmlib.Key32.fromString(sc.StateOwner)); + owner(): wasmtypes.ScImmutableAgentID { + return new wasmtypes.ScImmutableAgentID(this.proxy.root(sc.StateOwner)); } - totalFactor(): wasmlib.ScImmutableUint64 { - return new wasmlib.ScImmutableUint64(this.mapID, wasmlib.Key32.fromString(sc.StateTotalFactor)); + totalFactor(): wasmtypes.ScImmutableUint64 { + return new wasmtypes.ScImmutableUint64(this.proxy.root(sc.StateTotalFactor)); } } -export class ArrayOfMutableAddress { - objID: i32; +export class ArrayOfMutableAddress extends wasmtypes.ScProxy { - constructor(objID: i32) { - this.objID = objID; - } + appendAddress(): wasmtypes.ScMutableAddress { + return new wasmtypes.ScMutableAddress(this.proxy.append()); + } clear(): void { - wasmlib.clear(this.objID); + this.proxy.clearArray(); } length(): u32 { - return wasmlib.getLength(this.objID); + return this.proxy.length(); } - getAddress(index: u32): wasmlib.ScMutableAddress { - return new wasmlib.ScMutableAddress(this.objID, new wasmlib.Key32(index as i32)); + getAddress(index: u32): wasmtypes.ScMutableAddress { + return new wasmtypes.ScMutableAddress(this.proxy.index(index)); } } -export class MapAddressToMutableUint64 { - objID: i32; - - constructor(objID: i32) { - this.objID = objID; - } +export class MapAddressToMutableUint64 extends wasmtypes.ScProxy { clear(): void { - wasmlib.clear(this.objID); + this.proxy.clearMap(); } - getUint64(key: wasmlib.ScAddress): wasmlib.ScMutableUint64 { - return new wasmlib.ScMutableUint64(this.objID, key.getKeyID()); + getUint64(key: wasmtypes.ScAddress): wasmtypes.ScMutableUint64 { + return new wasmtypes.ScMutableUint64(this.proxy.key(wasmtypes.addressToBytes(key))); } } -export class MutableDividendState extends wasmlib.ScMapID { +export class MutableDividendState extends wasmtypes.ScProxy { asImmutable(): sc.ImmutableDividendState { - const imm = new sc.ImmutableDividendState(); - imm.mapID = this.mapID; - return imm; + return new sc.ImmutableDividendState(this.proxy); } memberList(): sc.ArrayOfMutableAddress { - let arrID = wasmlib.getObjectID(this.mapID, wasmlib.Key32.fromString(sc.StateMemberList), wasmlib.TYPE_ARRAY|wasmlib.TYPE_ADDRESS); - return new sc.ArrayOfMutableAddress(arrID); + return new sc.ArrayOfMutableAddress(this.proxy.root(sc.StateMemberList)); } members(): sc.MapAddressToMutableUint64 { - let mapID = wasmlib.getObjectID(this.mapID, wasmlib.Key32.fromString(sc.StateMembers), wasmlib.TYPE_MAP); - return new sc.MapAddressToMutableUint64(mapID); + return new sc.MapAddressToMutableUint64(this.proxy.root(sc.StateMembers)); } - owner(): wasmlib.ScMutableAgentID { - return new wasmlib.ScMutableAgentID(this.mapID, wasmlib.Key32.fromString(sc.StateOwner)); + owner(): wasmtypes.ScMutableAgentID { + return new wasmtypes.ScMutableAgentID(this.proxy.root(sc.StateOwner)); } - totalFactor(): wasmlib.ScMutableUint64 { - return new wasmlib.ScMutableUint64(this.mapID, wasmlib.Key32.fromString(sc.StateTotalFactor)); + totalFactor(): wasmtypes.ScMutableUint64 { + return new wasmtypes.ScMutableUint64(this.proxy.root(sc.StateTotalFactor)); } } diff --git a/contracts/wasm/donatewithfeedback/go/donatewithfeedback/lib.go b/contracts/wasm/donatewithfeedback/go/donatewithfeedback/lib.go index 3f9c5b8023..51d7677a52 100644 --- a/contracts/wasm/donatewithfeedback/go/donatewithfeedback/lib.go +++ b/contracts/wasm/donatewithfeedback/go/donatewithfeedback/lib.go @@ -81,8 +81,8 @@ func viewDonationThunk(ctx wasmlib.ScViewContext) { } ctx.Require(f.Params.Nr().Exists(), "missing mandatory nr") viewDonation(ctx, f) - ctx.Log("donatewithfeedback.viewDonation ok") ctx.Results(results) + ctx.Log("donatewithfeedback.viewDonation ok") } type DonationInfoContext struct { @@ -102,6 +102,6 @@ func viewDonationInfoThunk(ctx wasmlib.ScViewContext) { }, } viewDonationInfo(ctx, f) - ctx.Log("donatewithfeedback.viewDonationInfo ok") ctx.Results(results) + ctx.Log("donatewithfeedback.viewDonationInfo ok") } diff --git a/contracts/wasm/donatewithfeedback/go/donatewithfeedback/structs.go b/contracts/wasm/donatewithfeedback/go/donatewithfeedback/structs.go index 84f733fc31..82ac1341f0 100644 --- a/contracts/wasm/donatewithfeedback/go/donatewithfeedback/structs.go +++ b/contracts/wasm/donatewithfeedback/go/donatewithfeedback/structs.go @@ -20,22 +20,22 @@ type Donation struct { func NewDonationFromBytes(buf []byte) *Donation { dec := wasmtypes.NewWasmDecoder(buf) data := &Donation{} - data.Amount = wasmtypes.DecodeUint64(dec) - data.Donator = wasmtypes.DecodeAgentID(dec) - data.Error = wasmtypes.DecodeString(dec) - data.Feedback = wasmtypes.DecodeString(dec) - data.Timestamp = wasmtypes.DecodeUint64(dec) + data.Amount = wasmtypes.Uint64Decode(dec) + data.Donator = wasmtypes.AgentIDDecode(dec) + data.Error = wasmtypes.StringDecode(dec) + data.Feedback = wasmtypes.StringDecode(dec) + data.Timestamp = wasmtypes.Uint64Decode(dec) dec.Close() return data } func (o *Donation) Bytes() []byte { enc := wasmtypes.NewWasmEncoder() - wasmtypes.EncodeUint64(enc, o.Amount) - wasmtypes.EncodeAgentID(enc, o.Donator) - wasmtypes.EncodeString(enc, o.Error) - wasmtypes.EncodeString(enc, o.Feedback) - wasmtypes.EncodeUint64(enc, o.Timestamp) + wasmtypes.Uint64Encode(enc, o.Amount) + wasmtypes.AgentIDEncode(enc, o.Donator) + wasmtypes.StringEncode(enc, o.Error) + wasmtypes.StringEncode(enc, o.Feedback) + wasmtypes.Uint64Encode(enc, o.Timestamp) return enc.Buf() } diff --git a/contracts/wasm/donatewithfeedback/ts/donatewithfeedback/consts.ts b/contracts/wasm/donatewithfeedback/ts/donatewithfeedback/consts.ts index c95c4a93f6..d6d0f9a74c 100644 --- a/contracts/wasm/donatewithfeedback/ts/donatewithfeedback/consts.ts +++ b/contracts/wasm/donatewithfeedback/ts/donatewithfeedback/consts.ts @@ -5,11 +5,11 @@ // >>>> DO NOT CHANGE THIS FILE! <<<< // Change the json schema instead -import * as wasmlib from "wasmlib"; +import * as wasmtypes from "wasmlib/wasmtypes"; export const ScName = "donatewithfeedback"; export const ScDescription = ""; -export const HScName = new wasmlib.ScHname(0x696d7f66); +export const HScName = new wasmtypes.ScHname(0x696d7f66); export const ParamAmount = "amount"; export const ParamFeedback = "feedback"; @@ -33,7 +33,7 @@ export const FuncWithdraw = "withdraw"; export const ViewDonation = "donation"; export const ViewDonationInfo = "donationInfo"; -export const HFuncDonate = new wasmlib.ScHname(0xdc9b133a); -export const HFuncWithdraw = new wasmlib.ScHname(0x9dcc0f41); -export const HViewDonation = new wasmlib.ScHname(0xbdb245ba); -export const HViewDonationInfo = new wasmlib.ScHname(0xc8f7c726); +export const HFuncDonate = new wasmtypes.ScHname(0xdc9b133a); +export const HFuncWithdraw = new wasmtypes.ScHname(0x9dcc0f41); +export const HViewDonation = new wasmtypes.ScHname(0xbdb245ba); +export const HViewDonationInfo = new wasmtypes.ScHname(0xc8f7c726); diff --git a/contracts/wasm/donatewithfeedback/ts/donatewithfeedback/contract.ts b/contracts/wasm/donatewithfeedback/ts/donatewithfeedback/contract.ts index c3d9d5a0eb..0656179cdb 100644 --- a/contracts/wasm/donatewithfeedback/ts/donatewithfeedback/contract.ts +++ b/contracts/wasm/donatewithfeedback/ts/donatewithfeedback/contract.ts @@ -6,72 +6,74 @@ // Change the json schema instead import * as wasmlib from "wasmlib"; +import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; export class DonateCall { func: wasmlib.ScFunc = new wasmlib.ScFunc(sc.HScName, sc.HFuncDonate); - params: sc.MutableDonateParams = new sc.MutableDonateParams(); + params: sc.MutableDonateParams = new sc.MutableDonateParams(wasmlib.ScView.nilProxy); } export class DonateContext { - params: sc.ImmutableDonateParams = new sc.ImmutableDonateParams(); - state: sc.MutableDonateWithFeedbackState = new sc.MutableDonateWithFeedbackState(); + params: sc.ImmutableDonateParams = new sc.ImmutableDonateParams(wasmlib.paramsProxy()); + state: sc.MutableDonateWithFeedbackState = new sc.MutableDonateWithFeedbackState(wasmlib.ScState.proxy()); } export class WithdrawCall { func: wasmlib.ScFunc = new wasmlib.ScFunc(sc.HScName, sc.HFuncWithdraw); - params: sc.MutableWithdrawParams = new sc.MutableWithdrawParams(); + params: sc.MutableWithdrawParams = new sc.MutableWithdrawParams(wasmlib.ScView.nilProxy); } export class WithdrawContext { - params: sc.ImmutableWithdrawParams = new sc.ImmutableWithdrawParams(); - state: sc.MutableDonateWithFeedbackState = new sc.MutableDonateWithFeedbackState(); + params: sc.ImmutableWithdrawParams = new sc.ImmutableWithdrawParams(wasmlib.paramsProxy()); + state: sc.MutableDonateWithFeedbackState = new sc.MutableDonateWithFeedbackState(wasmlib.ScState.proxy()); } export class DonationCall { func: wasmlib.ScView = new wasmlib.ScView(sc.HScName, sc.HViewDonation); - params: sc.MutableDonationParams = new sc.MutableDonationParams(); - results: sc.ImmutableDonationResults = new sc.ImmutableDonationResults(); + params: sc.MutableDonationParams = new sc.MutableDonationParams(wasmlib.ScView.nilProxy); + results: sc.ImmutableDonationResults = new sc.ImmutableDonationResults(wasmlib.ScView.nilProxy); } export class DonationContext { - params: sc.ImmutableDonationParams = new sc.ImmutableDonationParams(); - results: sc.MutableDonationResults = new sc.MutableDonationResults(); - state: sc.ImmutableDonateWithFeedbackState = new sc.ImmutableDonateWithFeedbackState(); + params: sc.ImmutableDonationParams = new sc.ImmutableDonationParams(wasmlib.paramsProxy()); + results: sc.MutableDonationResults = new sc.MutableDonationResults(wasmlib.ScView.nilProxy); + state: sc.ImmutableDonateWithFeedbackState = new sc.ImmutableDonateWithFeedbackState(wasmlib.ScState.proxy()); } export class DonationInfoCall { func: wasmlib.ScView = new wasmlib.ScView(sc.HScName, sc.HViewDonationInfo); - results: sc.ImmutableDonationInfoResults = new sc.ImmutableDonationInfoResults(); + results: sc.ImmutableDonationInfoResults = new sc.ImmutableDonationInfoResults(wasmlib.ScView.nilProxy); } export class DonationInfoContext { - results: sc.MutableDonationInfoResults = new sc.MutableDonationInfoResults(); - state: sc.ImmutableDonateWithFeedbackState = new sc.ImmutableDonateWithFeedbackState(); + results: sc.MutableDonationInfoResults = new sc.MutableDonationInfoResults(wasmlib.ScView.nilProxy); + state: sc.ImmutableDonateWithFeedbackState = new sc.ImmutableDonateWithFeedbackState(wasmlib.ScState.proxy()); } export class ScFuncs { static donate(ctx: wasmlib.ScFuncCallContext): DonateCall { - let f = new DonateCall(); - f.func.setPtrs(f.params, null); + const f = new DonateCall(); + f.params = new sc.MutableDonateParams(wasmlib.newCallParamsProxy(f.func)); return f; } static withdraw(ctx: wasmlib.ScFuncCallContext): WithdrawCall { - let f = new WithdrawCall(); - f.func.setPtrs(f.params, null); + const f = new WithdrawCall(); + f.params = new sc.MutableWithdrawParams(wasmlib.newCallParamsProxy(f.func)); return f; } static donation(ctx: wasmlib.ScViewCallContext): DonationCall { - let f = new DonationCall(); - f.func.setPtrs(f.params, f.results); + const f = new DonationCall(); + f.params = new sc.MutableDonationParams(wasmlib.newCallParamsProxy(f.func)); + f.results = new sc.ImmutableDonationResults(wasmlib.newCallResultsProxy(f.func)); return f; } static donationInfo(ctx: wasmlib.ScViewCallContext): DonationInfoCall { - let f = new DonationInfoCall(); - f.func.setPtrs(null, f.results); + const f = new DonationInfoCall(); + f.results = new sc.ImmutableDonationInfoResults(wasmlib.newCallResultsProxy(f.func)); return f; } } diff --git a/contracts/wasm/donatewithfeedback/ts/donatewithfeedback/donatewithfeedback.ts b/contracts/wasm/donatewithfeedback/ts/donatewithfeedback/donatewithfeedback.ts index 465d98f9fb..a821861169 100644 --- a/contracts/wasm/donatewithfeedback/ts/donatewithfeedback/donatewithfeedback.ts +++ b/contracts/wasm/donatewithfeedback/ts/donatewithfeedback/donatewithfeedback.ts @@ -2,11 +2,12 @@ // SPDX-License-Identifier: Apache-2.0 import * as wasmlib from "wasmlib" +import * as wasmtypes from "wasmlib/wasmtypes" import * as sc from "./index"; export function funcDonate(ctx: wasmlib.ScFuncContext, f: sc.DonateContext): void { let donation = new sc.Donation(); - donation.amount = ctx.incoming().balance(wasmlib.ScColor.IOTA); + donation.amount = ctx.incoming().balance(wasmtypes.IOTA); donation.donator = ctx.caller(); donation.error = ""; donation.feedback = f.params.feedback().value(); @@ -19,7 +20,7 @@ export function funcDonate(ctx: wasmlib.ScFuncContext, f: sc.DonateContext): voi } } let log = f.state.log(); - log.getDonation(log.length()).setValue(donation); + log.appendDonation().setValue(donation); let largestDonation = f.state.maxDonation(); let totalDonated = f.state.totalDonation(); @@ -30,7 +31,7 @@ export function funcDonate(ctx: wasmlib.ScFuncContext, f: sc.DonateContext): voi } export function funcWithdraw(ctx: wasmlib.ScFuncContext, f: sc.WithdrawContext): void { - let balance = ctx.balances().balance(wasmlib.ScColor.IOTA); + let balance = ctx.balances().balance(wasmtypes.IOTA); let amount = f.params.amount().value(); if (amount == 0 || amount > balance) { amount = balance; diff --git a/contracts/wasm/donatewithfeedback/ts/donatewithfeedback/index.ts b/contracts/wasm/donatewithfeedback/ts/donatewithfeedback/index.ts index e5bfe68faa..3eabebcf92 100644 --- a/contracts/wasm/donatewithfeedback/ts/donatewithfeedback/index.ts +++ b/contracts/wasm/donatewithfeedback/ts/donatewithfeedback/index.ts @@ -9,7 +9,6 @@ export * from "./donatewithfeedback"; export * from "./consts"; export * from "./contract"; -export * from "./keys"; export * from "./lib"; export * from "./params"; export * from "./results"; diff --git a/contracts/wasm/donatewithfeedback/ts/donatewithfeedback/keys.ts b/contracts/wasm/donatewithfeedback/ts/donatewithfeedback/keys.ts index 16ce9ceed1..f7b1b1466c 100644 --- a/contracts/wasm/donatewithfeedback/ts/donatewithfeedback/keys.ts +++ b/contracts/wasm/donatewithfeedback/ts/donatewithfeedback/keys.ts @@ -5,41 +5,7 @@ // >>>> DO NOT CHANGE THIS FILE! <<<< // Change the json schema instead -import * as wasmlib from "wasmlib"; -import * as sc from "./index"; export const IdxParamAmount = 0; export const IdxParamFeedback = 1; export const IdxParamNr = 2; - -export const IdxResultAmount = 3; -export const IdxResultCount = 4; -export const IdxResultDonator = 5; -export const IdxResultError = 6; -export const IdxResultFeedback = 7; -export const IdxResultMaxDonation = 8; -export const IdxResultTimestamp = 9; -export const IdxResultTotalDonation = 10; - -export const IdxStateLog = 11; -export const IdxStateMaxDonation = 12; -export const IdxStateTotalDonation = 13; - -export let keyMap: string[] = [ - sc.ParamAmount, - sc.ParamFeedback, - sc.ParamNr, - sc.ResultAmount, - sc.ResultCount, - sc.ResultDonator, - sc.ResultError, - sc.ResultFeedback, - sc.ResultMaxDonation, - sc.ResultTimestamp, - sc.ResultTotalDonation, - sc.StateLog, - sc.StateMaxDonation, - sc.StateTotalDonation, -]; - -export let idxMap: wasmlib.Key32[] = new Array(keyMap.length); diff --git a/contracts/wasm/donatewithfeedback/ts/donatewithfeedback/lib.ts b/contracts/wasm/donatewithfeedback/ts/donatewithfeedback/lib.ts index ea6080bb30..ee7ec5bdc7 100644 --- a/contracts/wasm/donatewithfeedback/ts/donatewithfeedback/lib.ts +++ b/contracts/wasm/donatewithfeedback/ts/donatewithfeedback/lib.ts @@ -6,6 +6,7 @@ // Change the json schema instead import * as wasmlib from "wasmlib"; +import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; export function on_call(index: i32): void { @@ -18,30 +19,22 @@ export function on_load(): void { exports.addFunc(sc.FuncWithdraw, funcWithdrawThunk); exports.addView(sc.ViewDonation, viewDonationThunk); exports.addView(sc.ViewDonationInfo, viewDonationInfoThunk); - - for (let i = 0; i < sc.keyMap.length; i++) { - sc.idxMap[i] = wasmlib.Key32.fromString(sc.keyMap[i]); - } } function funcDonateThunk(ctx: wasmlib.ScFuncContext): void { ctx.log("donatewithfeedback.funcDonate"); let f = new sc.DonateContext(); - f.params.mapID = wasmlib.OBJ_ID_PARAMS; - f.state.mapID = wasmlib.OBJ_ID_STATE; sc.funcDonate(ctx, f); ctx.log("donatewithfeedback.funcDonate ok"); } function funcWithdrawThunk(ctx: wasmlib.ScFuncContext): void { ctx.log("donatewithfeedback.funcWithdraw"); + let f = new sc.WithdrawContext(); // only SC creator can withdraw donated funds ctx.require(ctx.caller().equals(ctx.contractCreator()), "no permission"); - let f = new sc.WithdrawContext(); - f.params.mapID = wasmlib.OBJ_ID_PARAMS; - f.state.mapID = wasmlib.OBJ_ID_STATE; sc.funcWithdraw(ctx, f); ctx.log("donatewithfeedback.funcWithdraw ok"); } @@ -49,19 +42,20 @@ function funcWithdrawThunk(ctx: wasmlib.ScFuncContext): void { function viewDonationThunk(ctx: wasmlib.ScViewContext): void { ctx.log("donatewithfeedback.viewDonation"); let f = new sc.DonationContext(); - f.params.mapID = wasmlib.OBJ_ID_PARAMS; - f.results.mapID = wasmlib.OBJ_ID_RESULTS; - f.state.mapID = wasmlib.OBJ_ID_STATE; + const results = new wasmlib.ScDict([]); + f.results = new sc.MutableDonationResults(results.asProxy()); ctx.require(f.params.nr().exists(), "missing mandatory nr"); sc.viewDonation(ctx, f); + ctx.results(results); ctx.log("donatewithfeedback.viewDonation ok"); } function viewDonationInfoThunk(ctx: wasmlib.ScViewContext): void { ctx.log("donatewithfeedback.viewDonationInfo"); let f = new sc.DonationInfoContext(); - f.results.mapID = wasmlib.OBJ_ID_RESULTS; - f.state.mapID = wasmlib.OBJ_ID_STATE; + const results = new wasmlib.ScDict([]); + f.results = new sc.MutableDonationInfoResults(results.asProxy()); sc.viewDonationInfo(ctx, f); + ctx.results(results); ctx.log("donatewithfeedback.viewDonationInfo ok"); } diff --git a/contracts/wasm/donatewithfeedback/ts/donatewithfeedback/params.ts b/contracts/wasm/donatewithfeedback/ts/donatewithfeedback/params.ts index d07a82a5a9..5f2f7b4c0e 100644 --- a/contracts/wasm/donatewithfeedback/ts/donatewithfeedback/params.ts +++ b/contracts/wasm/donatewithfeedback/ts/donatewithfeedback/params.ts @@ -6,40 +6,41 @@ // Change the json schema instead import * as wasmlib from "wasmlib"; +import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; -export class ImmutableDonateParams extends wasmlib.ScMapID { - feedback(): wasmlib.ScImmutableString { - return new wasmlib.ScImmutableString(this.mapID, wasmlib.Key32.fromString(sc.ParamFeedback)); +export class ImmutableDonateParams extends wasmtypes.ScProxy { + feedback(): wasmtypes.ScImmutableString { + return new wasmtypes.ScImmutableString(this.proxy.root(sc.ParamFeedback)); } } -export class MutableDonateParams extends wasmlib.ScMapID { - feedback(): wasmlib.ScMutableString { - return new wasmlib.ScMutableString(this.mapID, wasmlib.Key32.fromString(sc.ParamFeedback)); +export class MutableDonateParams extends wasmtypes.ScProxy { + feedback(): wasmtypes.ScMutableString { + return new wasmtypes.ScMutableString(this.proxy.root(sc.ParamFeedback)); } } -export class ImmutableWithdrawParams extends wasmlib.ScMapID { - amount(): wasmlib.ScImmutableUint64 { - return new wasmlib.ScImmutableUint64(this.mapID, wasmlib.Key32.fromString(sc.ParamAmount)); +export class ImmutableWithdrawParams extends wasmtypes.ScProxy { + amount(): wasmtypes.ScImmutableUint64 { + return new wasmtypes.ScImmutableUint64(this.proxy.root(sc.ParamAmount)); } } -export class MutableWithdrawParams extends wasmlib.ScMapID { - amount(): wasmlib.ScMutableUint64 { - return new wasmlib.ScMutableUint64(this.mapID, wasmlib.Key32.fromString(sc.ParamAmount)); +export class MutableWithdrawParams extends wasmtypes.ScProxy { + amount(): wasmtypes.ScMutableUint64 { + return new wasmtypes.ScMutableUint64(this.proxy.root(sc.ParamAmount)); } } -export class ImmutableDonationParams extends wasmlib.ScMapID { - nr(): wasmlib.ScImmutableUint32 { - return new wasmlib.ScImmutableUint32(this.mapID, wasmlib.Key32.fromString(sc.ParamNr)); +export class ImmutableDonationParams extends wasmtypes.ScProxy { + nr(): wasmtypes.ScImmutableUint32 { + return new wasmtypes.ScImmutableUint32(this.proxy.root(sc.ParamNr)); } } -export class MutableDonationParams extends wasmlib.ScMapID { - nr(): wasmlib.ScMutableUint32 { - return new wasmlib.ScMutableUint32(this.mapID, wasmlib.Key32.fromString(sc.ParamNr)); +export class MutableDonationParams extends wasmtypes.ScProxy { + nr(): wasmtypes.ScMutableUint32 { + return new wasmtypes.ScMutableUint32(this.proxy.root(sc.ParamNr)); } } diff --git a/contracts/wasm/donatewithfeedback/ts/donatewithfeedback/results.ts b/contracts/wasm/donatewithfeedback/ts/donatewithfeedback/results.ts index c2e188f273..b8999a4769 100644 --- a/contracts/wasm/donatewithfeedback/ts/donatewithfeedback/results.ts +++ b/contracts/wasm/donatewithfeedback/ts/donatewithfeedback/results.ts @@ -6,76 +6,77 @@ // Change the json schema instead import * as wasmlib from "wasmlib"; +import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; -export class ImmutableDonationResults extends wasmlib.ScMapID { - amount(): wasmlib.ScImmutableUint64 { - return new wasmlib.ScImmutableUint64(this.mapID, wasmlib.Key32.fromString(sc.ResultAmount)); +export class ImmutableDonationResults extends wasmtypes.ScProxy { + amount(): wasmtypes.ScImmutableUint64 { + return new wasmtypes.ScImmutableUint64(this.proxy.root(sc.ResultAmount)); } - donator(): wasmlib.ScImmutableAgentID { - return new wasmlib.ScImmutableAgentID(this.mapID, wasmlib.Key32.fromString(sc.ResultDonator)); + donator(): wasmtypes.ScImmutableAgentID { + return new wasmtypes.ScImmutableAgentID(this.proxy.root(sc.ResultDonator)); } - error(): wasmlib.ScImmutableString { - return new wasmlib.ScImmutableString(this.mapID, wasmlib.Key32.fromString(sc.ResultError)); + error(): wasmtypes.ScImmutableString { + return new wasmtypes.ScImmutableString(this.proxy.root(sc.ResultError)); } - feedback(): wasmlib.ScImmutableString { - return new wasmlib.ScImmutableString(this.mapID, wasmlib.Key32.fromString(sc.ResultFeedback)); + feedback(): wasmtypes.ScImmutableString { + return new wasmtypes.ScImmutableString(this.proxy.root(sc.ResultFeedback)); } - timestamp(): wasmlib.ScImmutableUint64 { - return new wasmlib.ScImmutableUint64(this.mapID, wasmlib.Key32.fromString(sc.ResultTimestamp)); + timestamp(): wasmtypes.ScImmutableUint64 { + return new wasmtypes.ScImmutableUint64(this.proxy.root(sc.ResultTimestamp)); } } -export class MutableDonationResults extends wasmlib.ScMapID { - amount(): wasmlib.ScMutableUint64 { - return new wasmlib.ScMutableUint64(this.mapID, wasmlib.Key32.fromString(sc.ResultAmount)); +export class MutableDonationResults extends wasmtypes.ScProxy { + amount(): wasmtypes.ScMutableUint64 { + return new wasmtypes.ScMutableUint64(this.proxy.root(sc.ResultAmount)); } - donator(): wasmlib.ScMutableAgentID { - return new wasmlib.ScMutableAgentID(this.mapID, wasmlib.Key32.fromString(sc.ResultDonator)); + donator(): wasmtypes.ScMutableAgentID { + return new wasmtypes.ScMutableAgentID(this.proxy.root(sc.ResultDonator)); } - error(): wasmlib.ScMutableString { - return new wasmlib.ScMutableString(this.mapID, wasmlib.Key32.fromString(sc.ResultError)); + error(): wasmtypes.ScMutableString { + return new wasmtypes.ScMutableString(this.proxy.root(sc.ResultError)); } - feedback(): wasmlib.ScMutableString { - return new wasmlib.ScMutableString(this.mapID, wasmlib.Key32.fromString(sc.ResultFeedback)); + feedback(): wasmtypes.ScMutableString { + return new wasmtypes.ScMutableString(this.proxy.root(sc.ResultFeedback)); } - timestamp(): wasmlib.ScMutableUint64 { - return new wasmlib.ScMutableUint64(this.mapID, wasmlib.Key32.fromString(sc.ResultTimestamp)); + timestamp(): wasmtypes.ScMutableUint64 { + return new wasmtypes.ScMutableUint64(this.proxy.root(sc.ResultTimestamp)); } } -export class ImmutableDonationInfoResults extends wasmlib.ScMapID { - count(): wasmlib.ScImmutableUint32 { - return new wasmlib.ScImmutableUint32(this.mapID, wasmlib.Key32.fromString(sc.ResultCount)); +export class ImmutableDonationInfoResults extends wasmtypes.ScProxy { + count(): wasmtypes.ScImmutableUint32 { + return new wasmtypes.ScImmutableUint32(this.proxy.root(sc.ResultCount)); } - maxDonation(): wasmlib.ScImmutableUint64 { - return new wasmlib.ScImmutableUint64(this.mapID, wasmlib.Key32.fromString(sc.ResultMaxDonation)); + maxDonation(): wasmtypes.ScImmutableUint64 { + return new wasmtypes.ScImmutableUint64(this.proxy.root(sc.ResultMaxDonation)); } - totalDonation(): wasmlib.ScImmutableUint64 { - return new wasmlib.ScImmutableUint64(this.mapID, wasmlib.Key32.fromString(sc.ResultTotalDonation)); + totalDonation(): wasmtypes.ScImmutableUint64 { + return new wasmtypes.ScImmutableUint64(this.proxy.root(sc.ResultTotalDonation)); } } -export class MutableDonationInfoResults extends wasmlib.ScMapID { - count(): wasmlib.ScMutableUint32 { - return new wasmlib.ScMutableUint32(this.mapID, wasmlib.Key32.fromString(sc.ResultCount)); +export class MutableDonationInfoResults extends wasmtypes.ScProxy { + count(): wasmtypes.ScMutableUint32 { + return new wasmtypes.ScMutableUint32(this.proxy.root(sc.ResultCount)); } - maxDonation(): wasmlib.ScMutableUint64 { - return new wasmlib.ScMutableUint64(this.mapID, wasmlib.Key32.fromString(sc.ResultMaxDonation)); + maxDonation(): wasmtypes.ScMutableUint64 { + return new wasmtypes.ScMutableUint64(this.proxy.root(sc.ResultMaxDonation)); } - totalDonation(): wasmlib.ScMutableUint64 { - return new wasmlib.ScMutableUint64(this.mapID, wasmlib.Key32.fromString(sc.ResultTotalDonation)); + totalDonation(): wasmtypes.ScMutableUint64 { + return new wasmtypes.ScMutableUint64(this.proxy.root(sc.ResultTotalDonation)); } } diff --git a/contracts/wasm/donatewithfeedback/ts/donatewithfeedback/state.ts b/contracts/wasm/donatewithfeedback/ts/donatewithfeedback/state.ts index 7603bfb78d..d15aefad92 100644 --- a/contracts/wasm/donatewithfeedback/ts/donatewithfeedback/state.ts +++ b/contracts/wasm/donatewithfeedback/ts/donatewithfeedback/state.ts @@ -6,76 +6,67 @@ // Change the json schema instead import * as wasmlib from "wasmlib"; +import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; -export class ArrayOfImmutableDonation { - objID: i32; - - constructor(objID: i32) { - this.objID = objID; - } +export class ArrayOfImmutableDonation extends wasmtypes.ScProxy { length(): u32 { - return wasmlib.getLength(this.objID); + return this.proxy.length(); } getDonation(index: u32): sc.ImmutableDonation { - return new sc.ImmutableDonation(this.objID, new wasmlib.Key32(index as i32)); + return new sc.ImmutableDonation(this.proxy.index(index)); } } -export class ImmutableDonateWithFeedbackState extends wasmlib.ScMapID { +export class ImmutableDonateWithFeedbackState extends wasmtypes.ScProxy { log(): sc.ArrayOfImmutableDonation { - let arrID = wasmlib.getObjectID(this.mapID, wasmlib.Key32.fromString(sc.StateLog), wasmlib.TYPE_ARRAY|wasmlib.TYPE_BYTES); - return new sc.ArrayOfImmutableDonation(arrID); + return new sc.ArrayOfImmutableDonation(this.proxy.root(sc.StateLog)); } - maxDonation(): wasmlib.ScImmutableUint64 { - return new wasmlib.ScImmutableUint64(this.mapID, wasmlib.Key32.fromString(sc.StateMaxDonation)); + maxDonation(): wasmtypes.ScImmutableUint64 { + return new wasmtypes.ScImmutableUint64(this.proxy.root(sc.StateMaxDonation)); } - totalDonation(): wasmlib.ScImmutableUint64 { - return new wasmlib.ScImmutableUint64(this.mapID, wasmlib.Key32.fromString(sc.StateTotalDonation)); + totalDonation(): wasmtypes.ScImmutableUint64 { + return new wasmtypes.ScImmutableUint64(this.proxy.root(sc.StateTotalDonation)); } } -export class ArrayOfMutableDonation { - objID: i32; +export class ArrayOfMutableDonation extends wasmtypes.ScProxy { - constructor(objID: i32) { - this.objID = objID; - } + appendDonation(): sc.MutableDonation { + return new sc.MutableDonation(this.proxy.append()); + } clear(): void { - wasmlib.clear(this.objID); + this.proxy.clearArray(); } length(): u32 { - return wasmlib.getLength(this.objID); + return this.proxy.length(); } getDonation(index: u32): sc.MutableDonation { - return new sc.MutableDonation(this.objID, new wasmlib.Key32(index as i32)); + return new sc.MutableDonation(this.proxy.index(index)); } } -export class MutableDonateWithFeedbackState extends wasmlib.ScMapID { +export class MutableDonateWithFeedbackState extends wasmtypes.ScProxy { asImmutable(): sc.ImmutableDonateWithFeedbackState { - const imm = new sc.ImmutableDonateWithFeedbackState(); - imm.mapID = this.mapID; - return imm; + return new sc.ImmutableDonateWithFeedbackState(this.proxy); } log(): sc.ArrayOfMutableDonation { - let arrID = wasmlib.getObjectID(this.mapID, wasmlib.Key32.fromString(sc.StateLog), wasmlib.TYPE_ARRAY|wasmlib.TYPE_BYTES); - return new sc.ArrayOfMutableDonation(arrID); + return new sc.ArrayOfMutableDonation(this.proxy.root(sc.StateLog)); } - maxDonation(): wasmlib.ScMutableUint64 { - return new wasmlib.ScMutableUint64(this.mapID, wasmlib.Key32.fromString(sc.StateMaxDonation)); + maxDonation(): wasmtypes.ScMutableUint64 { + return new wasmtypes.ScMutableUint64(this.proxy.root(sc.StateMaxDonation)); } - totalDonation(): wasmlib.ScMutableUint64 { - return new wasmlib.ScMutableUint64(this.mapID, wasmlib.Key32.fromString(sc.StateTotalDonation)); + totalDonation(): wasmtypes.ScMutableUint64 { + return new wasmtypes.ScMutableUint64(this.proxy.root(sc.StateTotalDonation)); } } diff --git a/contracts/wasm/donatewithfeedback/ts/donatewithfeedback/structs.ts b/contracts/wasm/donatewithfeedback/ts/donatewithfeedback/structs.ts index 5f5e490869..2e569735c4 100644 --- a/contracts/wasm/donatewithfeedback/ts/donatewithfeedback/structs.ts +++ b/contracts/wasm/donatewithfeedback/ts/donatewithfeedback/structs.ts @@ -6,77 +6,64 @@ // Change the json schema instead import * as wasmlib from "wasmlib"; +import * as wasmtypes from "wasmlib/wasmtypes"; export class Donation { amount : u64 = 0; // amount donated - donator : wasmlib.ScAgentID = new wasmlib.ScAgentID(); // who donated + donator : wasmtypes.ScAgentID = wasmtypes.agentIDFromBytes(null); // who donated error : string = ""; // error to be reported to donator if anything goes wrong feedback : string = ""; // the feedback for the person donated to timestamp : u64 = 0; // when the donation took place - static fromBytes(bytes: u8[]): Donation { - let decode = new wasmlib.BytesDecoder(bytes); - let data = new Donation(); - data.amount = decode.uint64(); - data.donator = decode.agentID(); - data.error = decode.string(); - data.feedback = decode.string(); - data.timestamp = decode.uint64(); - decode.close(); + static fromBytes(buf: u8[]|null): Donation { + const dec = new wasmtypes.WasmDecoder(buf); + const data = new Donation(); + data.amount = wasmtypes.uint64Decode(dec); + data.donator = wasmtypes.agentIDDecode(dec); + data.error = wasmtypes.stringDecode(dec); + data.feedback = wasmtypes.stringDecode(dec); + data.timestamp = wasmtypes.uint64Decode(dec); + dec.close(); return data; } bytes(): u8[] { - return new wasmlib.BytesEncoder(). - uint64(this.amount). - agentID(this.donator). - string(this.error). - string(this.feedback). - uint64(this.timestamp). - data(); + const enc = new wasmtypes.WasmEncoder(); + wasmtypes.uint64Encode(enc, this.amount); + wasmtypes.agentIDEncode(enc, this.donator); + wasmtypes.stringEncode(enc, this.error); + wasmtypes.stringEncode(enc, this.feedback); + wasmtypes.uint64Encode(enc, this.timestamp); + return enc.buf(); } } -export class ImmutableDonation { - objID: i32; - keyID: wasmlib.Key32; - - constructor(objID: i32, keyID: wasmlib.Key32) { - this.objID = objID; - this.keyID = keyID; - } +export class ImmutableDonation extends wasmtypes.ScProxy { exists(): boolean { - return wasmlib.exists(this.objID, this.keyID, wasmlib.TYPE_BYTES); + return this.proxy.exists(); } value(): Donation { - return Donation.fromBytes(wasmlib.getBytes(this.objID, this.keyID, wasmlib.TYPE_BYTES)); + return Donation.fromBytes(this.proxy.get()); } } -export class MutableDonation { - objID: i32; - keyID: wasmlib.Key32; - - constructor(objID: i32, keyID: wasmlib.Key32) { - this.objID = objID; - this.keyID = keyID; - } +export class MutableDonation extends wasmtypes.ScProxy { delete(): void { - wasmlib.delKey(this.objID, this.keyID, wasmlib.TYPE_BYTES); + this.proxy.delete(); } exists(): boolean { - return wasmlib.exists(this.objID, this.keyID, wasmlib.TYPE_BYTES); + return this.proxy.exists(); } setValue(value: Donation): void { - wasmlib.setBytes(this.objID, this.keyID, wasmlib.TYPE_BYTES, value.bytes()); + this.proxy.set(value.bytes()); } value(): Donation { - return Donation.fromBytes(wasmlib.getBytes(this.objID, this.keyID, wasmlib.TYPE_BYTES)); + return Donation.fromBytes(this.proxy.get()); } } diff --git a/contracts/wasm/erc20/go/erc20/lib.go b/contracts/wasm/erc20/go/erc20/lib.go index 158396f17b..ff058c5581 100644 --- a/contracts/wasm/erc20/go/erc20/lib.go +++ b/contracts/wasm/erc20/go/erc20/lib.go @@ -132,8 +132,8 @@ func viewAllowanceThunk(ctx wasmlib.ScViewContext) { ctx.Require(f.Params.Account().Exists(), "missing mandatory account") ctx.Require(f.Params.Delegation().Exists(), "missing mandatory delegation") viewAllowance(ctx, f) - ctx.Log("erc20.viewAllowance ok") ctx.Results(results) + ctx.Log("erc20.viewAllowance ok") } type BalanceOfContext struct { @@ -158,8 +158,8 @@ func viewBalanceOfThunk(ctx wasmlib.ScViewContext) { } ctx.Require(f.Params.Account().Exists(), "missing mandatory account") viewBalanceOf(ctx, f) - ctx.Log("erc20.viewBalanceOf ok") ctx.Results(results) + ctx.Log("erc20.viewBalanceOf ok") } type TotalSupplyContext struct { @@ -179,6 +179,6 @@ func viewTotalSupplyThunk(ctx wasmlib.ScViewContext) { }, } viewTotalSupply(ctx, f) - ctx.Log("erc20.viewTotalSupply ok") ctx.Results(results) + ctx.Log("erc20.viewTotalSupply ok") } diff --git a/contracts/wasm/erc20/go/erc20/state.go b/contracts/wasm/erc20/go/erc20/state.go index 8ed002ffe8..8bbdfdf1dc 100644 --- a/contracts/wasm/erc20/go/erc20/state.go +++ b/contracts/wasm/erc20/go/erc20/state.go @@ -14,7 +14,7 @@ type MapAgentIDToImmutableAllowancesForAgent struct { } func (m MapAgentIDToImmutableAllowancesForAgent) GetAllowancesForAgent(key wasmtypes.ScAgentID) ImmutableAllowancesForAgent { - return ImmutableAllowancesForAgent{proxy: m.proxy.Key(wasmtypes.BytesFromAgentID(key))} + return ImmutableAllowancesForAgent{proxy: m.proxy.Key(wasmtypes.AgentIDToBytes(key))} } type ImmutableErc20State struct { @@ -42,7 +42,7 @@ func (m MapAgentIDToMutableAllowancesForAgent) Clear() { } func (m MapAgentIDToMutableAllowancesForAgent) GetAllowancesForAgent(key wasmtypes.ScAgentID) MutableAllowancesForAgent { - return MutableAllowancesForAgent{proxy: m.proxy.Key(wasmtypes.BytesFromAgentID(key))} + return MutableAllowancesForAgent{proxy: m.proxy.Key(wasmtypes.AgentIDToBytes(key))} } type MutableErc20State struct { diff --git a/contracts/wasm/erc20/go/erc20/typedefs.go b/contracts/wasm/erc20/go/erc20/typedefs.go index cf93e072b5..effb2c2047 100644 --- a/contracts/wasm/erc20/go/erc20/typedefs.go +++ b/contracts/wasm/erc20/go/erc20/typedefs.go @@ -14,7 +14,7 @@ type MapAgentIDToImmutableUint64 struct { } func (m MapAgentIDToImmutableUint64) GetUint64(key wasmtypes.ScAgentID) wasmtypes.ScImmutableUint64 { - return wasmtypes.NewScImmutableUint64(m.proxy.Key(wasmtypes.BytesFromAgentID(key))) + return wasmtypes.NewScImmutableUint64(m.proxy.Key(wasmtypes.AgentIDToBytes(key))) } type ImmutableAllowancesForAgent = MapAgentIDToImmutableUint64 @@ -28,7 +28,7 @@ func (m MapAgentIDToMutableUint64) Clear() { } func (m MapAgentIDToMutableUint64) GetUint64(key wasmtypes.ScAgentID) wasmtypes.ScMutableUint64 { - return wasmtypes.NewScMutableUint64(m.proxy.Key(wasmtypes.BytesFromAgentID(key))) + return wasmtypes.NewScMutableUint64(m.proxy.Key(wasmtypes.AgentIDToBytes(key))) } type MutableAllowancesForAgent = MapAgentIDToMutableUint64 diff --git a/contracts/wasm/erc20/ts/erc20/consts.ts b/contracts/wasm/erc20/ts/erc20/consts.ts index 6912a924b5..d46d38ecad 100644 --- a/contracts/wasm/erc20/ts/erc20/consts.ts +++ b/contracts/wasm/erc20/ts/erc20/consts.ts @@ -5,11 +5,11 @@ // >>>> DO NOT CHANGE THIS FILE! <<<< // Change the json schema instead -import * as wasmlib from "wasmlib"; +import * as wasmtypes from "wasmlib/wasmtypes"; export const ScName = "erc20"; export const ScDescription = "ERC-20 PoC for IOTA Smart Contracts"; -export const HScName = new wasmlib.ScHname(0x200e3733); +export const HScName = new wasmtypes.ScHname(0x200e3733); export const ParamAccount = "ac"; export const ParamAmount = "am"; @@ -33,10 +33,10 @@ export const ViewAllowance = "allowance"; export const ViewBalanceOf = "balanceOf"; export const ViewTotalSupply = "totalSupply"; -export const HFuncApprove = new wasmlib.ScHname(0xa0661268); -export const HFuncInit = new wasmlib.ScHname(0x1f44d644); -export const HFuncTransfer = new wasmlib.ScHname(0xa15da184); -export const HFuncTransferFrom = new wasmlib.ScHname(0xd5e0a602); -export const HViewAllowance = new wasmlib.ScHname(0x5e16006a); -export const HViewBalanceOf = new wasmlib.ScHname(0x67ef8df4); -export const HViewTotalSupply = new wasmlib.ScHname(0x9505e6ca); +export const HFuncApprove = new wasmtypes.ScHname(0xa0661268); +export const HFuncInit = new wasmtypes.ScHname(0x1f44d644); +export const HFuncTransfer = new wasmtypes.ScHname(0xa15da184); +export const HFuncTransferFrom = new wasmtypes.ScHname(0xd5e0a602); +export const HViewAllowance = new wasmtypes.ScHname(0x5e16006a); +export const HViewBalanceOf = new wasmtypes.ScHname(0x67ef8df4); +export const HViewTotalSupply = new wasmtypes.ScHname(0x9505e6ca); diff --git a/contracts/wasm/erc20/ts/erc20/contract.ts b/contracts/wasm/erc20/ts/erc20/contract.ts index d04ec0afa0..1fab6fec87 100644 --- a/contracts/wasm/erc20/ts/erc20/contract.ts +++ b/contracts/wasm/erc20/ts/erc20/contract.ts @@ -6,126 +6,129 @@ // Change the json schema instead import * as wasmlib from "wasmlib"; +import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; export class ApproveCall { func: wasmlib.ScFunc = new wasmlib.ScFunc(sc.HScName, sc.HFuncApprove); - params: sc.MutableApproveParams = new sc.MutableApproveParams(); + params: sc.MutableApproveParams = new sc.MutableApproveParams(wasmlib.ScView.nilProxy); } export class ApproveContext { events: sc.Erc20Events = new sc.Erc20Events(); - params: sc.ImmutableApproveParams = new sc.ImmutableApproveParams(); - state: sc.MutableErc20State = new sc.MutableErc20State(); + params: sc.ImmutableApproveParams = new sc.ImmutableApproveParams(wasmlib.paramsProxy()); + state: sc.MutableErc20State = new sc.MutableErc20State(wasmlib.ScState.proxy()); } export class InitCall { func: wasmlib.ScInitFunc = new wasmlib.ScInitFunc(sc.HScName, sc.HFuncInit); - params: sc.MutableInitParams = new sc.MutableInitParams(); + params: sc.MutableInitParams = new sc.MutableInitParams(wasmlib.ScView.nilProxy); } export class InitContext { events: sc.Erc20Events = new sc.Erc20Events(); - params: sc.ImmutableInitParams = new sc.ImmutableInitParams(); - state: sc.MutableErc20State = new sc.MutableErc20State(); + params: sc.ImmutableInitParams = new sc.ImmutableInitParams(wasmlib.paramsProxy()); + state: sc.MutableErc20State = new sc.MutableErc20State(wasmlib.ScState.proxy()); } export class TransferCall { func: wasmlib.ScFunc = new wasmlib.ScFunc(sc.HScName, sc.HFuncTransfer); - params: sc.MutableTransferParams = new sc.MutableTransferParams(); + params: sc.MutableTransferParams = new sc.MutableTransferParams(wasmlib.ScView.nilProxy); } export class TransferContext { events: sc.Erc20Events = new sc.Erc20Events(); - params: sc.ImmutableTransferParams = new sc.ImmutableTransferParams(); - state: sc.MutableErc20State = new sc.MutableErc20State(); + params: sc.ImmutableTransferParams = new sc.ImmutableTransferParams(wasmlib.paramsProxy()); + state: sc.MutableErc20State = new sc.MutableErc20State(wasmlib.ScState.proxy()); } export class TransferFromCall { func: wasmlib.ScFunc = new wasmlib.ScFunc(sc.HScName, sc.HFuncTransferFrom); - params: sc.MutableTransferFromParams = new sc.MutableTransferFromParams(); + params: sc.MutableTransferFromParams = new sc.MutableTransferFromParams(wasmlib.ScView.nilProxy); } export class TransferFromContext { events: sc.Erc20Events = new sc.Erc20Events(); - params: sc.ImmutableTransferFromParams = new sc.ImmutableTransferFromParams(); - state: sc.MutableErc20State = new sc.MutableErc20State(); + params: sc.ImmutableTransferFromParams = new sc.ImmutableTransferFromParams(wasmlib.paramsProxy()); + state: sc.MutableErc20State = new sc.MutableErc20State(wasmlib.ScState.proxy()); } export class AllowanceCall { func: wasmlib.ScView = new wasmlib.ScView(sc.HScName, sc.HViewAllowance); - params: sc.MutableAllowanceParams = new sc.MutableAllowanceParams(); - results: sc.ImmutableAllowanceResults = new sc.ImmutableAllowanceResults(); + params: sc.MutableAllowanceParams = new sc.MutableAllowanceParams(wasmlib.ScView.nilProxy); + results: sc.ImmutableAllowanceResults = new sc.ImmutableAllowanceResults(wasmlib.ScView.nilProxy); } export class AllowanceContext { - params: sc.ImmutableAllowanceParams = new sc.ImmutableAllowanceParams(); - results: sc.MutableAllowanceResults = new sc.MutableAllowanceResults(); - state: sc.ImmutableErc20State = new sc.ImmutableErc20State(); + params: sc.ImmutableAllowanceParams = new sc.ImmutableAllowanceParams(wasmlib.paramsProxy()); + results: sc.MutableAllowanceResults = new sc.MutableAllowanceResults(wasmlib.ScView.nilProxy); + state: sc.ImmutableErc20State = new sc.ImmutableErc20State(wasmlib.ScState.proxy()); } export class BalanceOfCall { func: wasmlib.ScView = new wasmlib.ScView(sc.HScName, sc.HViewBalanceOf); - params: sc.MutableBalanceOfParams = new sc.MutableBalanceOfParams(); - results: sc.ImmutableBalanceOfResults = new sc.ImmutableBalanceOfResults(); + params: sc.MutableBalanceOfParams = new sc.MutableBalanceOfParams(wasmlib.ScView.nilProxy); + results: sc.ImmutableBalanceOfResults = new sc.ImmutableBalanceOfResults(wasmlib.ScView.nilProxy); } export class BalanceOfContext { - params: sc.ImmutableBalanceOfParams = new sc.ImmutableBalanceOfParams(); - results: sc.MutableBalanceOfResults = new sc.MutableBalanceOfResults(); - state: sc.ImmutableErc20State = new sc.ImmutableErc20State(); + params: sc.ImmutableBalanceOfParams = new sc.ImmutableBalanceOfParams(wasmlib.paramsProxy()); + results: sc.MutableBalanceOfResults = new sc.MutableBalanceOfResults(wasmlib.ScView.nilProxy); + state: sc.ImmutableErc20State = new sc.ImmutableErc20State(wasmlib.ScState.proxy()); } export class TotalSupplyCall { func: wasmlib.ScView = new wasmlib.ScView(sc.HScName, sc.HViewTotalSupply); - results: sc.ImmutableTotalSupplyResults = new sc.ImmutableTotalSupplyResults(); + results: sc.ImmutableTotalSupplyResults = new sc.ImmutableTotalSupplyResults(wasmlib.ScView.nilProxy); } export class TotalSupplyContext { - results: sc.MutableTotalSupplyResults = new sc.MutableTotalSupplyResults(); - state: sc.ImmutableErc20State = new sc.ImmutableErc20State(); + results: sc.MutableTotalSupplyResults = new sc.MutableTotalSupplyResults(wasmlib.ScView.nilProxy); + state: sc.ImmutableErc20State = new sc.ImmutableErc20State(wasmlib.ScState.proxy()); } export class ScFuncs { static approve(ctx: wasmlib.ScFuncCallContext): ApproveCall { - let f = new ApproveCall(); - f.func.setPtrs(f.params, null); + const f = new ApproveCall(); + f.params = new sc.MutableApproveParams(wasmlib.newCallParamsProxy(f.func)); return f; } static init(ctx: wasmlib.ScFuncCallContext): InitCall { - let f = new InitCall(); - f.func.setPtrs(f.params, null); + const f = new InitCall(); + f.params = new sc.MutableInitParams(wasmlib.newCallParamsProxy(f.func)); return f; } static transfer(ctx: wasmlib.ScFuncCallContext): TransferCall { - let f = new TransferCall(); - f.func.setPtrs(f.params, null); + const f = new TransferCall(); + f.params = new sc.MutableTransferParams(wasmlib.newCallParamsProxy(f.func)); return f; } static transferFrom(ctx: wasmlib.ScFuncCallContext): TransferFromCall { - let f = new TransferFromCall(); - f.func.setPtrs(f.params, null); + const f = new TransferFromCall(); + f.params = new sc.MutableTransferFromParams(wasmlib.newCallParamsProxy(f.func)); return f; } static allowance(ctx: wasmlib.ScViewCallContext): AllowanceCall { - let f = new AllowanceCall(); - f.func.setPtrs(f.params, f.results); + const f = new AllowanceCall(); + f.params = new sc.MutableAllowanceParams(wasmlib.newCallParamsProxy(f.func)); + f.results = new sc.ImmutableAllowanceResults(wasmlib.newCallResultsProxy(f.func)); return f; } static balanceOf(ctx: wasmlib.ScViewCallContext): BalanceOfCall { - let f = new BalanceOfCall(); - f.func.setPtrs(f.params, f.results); + const f = new BalanceOfCall(); + f.params = new sc.MutableBalanceOfParams(wasmlib.newCallParamsProxy(f.func)); + f.results = new sc.ImmutableBalanceOfResults(wasmlib.newCallResultsProxy(f.func)); return f; } static totalSupply(ctx: wasmlib.ScViewCallContext): TotalSupplyCall { - let f = new TotalSupplyCall(); - f.func.setPtrs(null, f.results); + const f = new TotalSupplyCall(); + f.results = new sc.ImmutableTotalSupplyResults(wasmlib.newCallResultsProxy(f.func)); return f; } } diff --git a/contracts/wasm/erc20/ts/erc20/events.ts b/contracts/wasm/erc20/ts/erc20/events.ts index cf030a0464..6bff67427c 100644 --- a/contracts/wasm/erc20/ts/erc20/events.ts +++ b/contracts/wasm/erc20/ts/erc20/events.ts @@ -6,22 +6,23 @@ // Change the json schema instead import * as wasmlib from "wasmlib"; +import * as wasmtypes from "wasmlib/wasmtypes"; export class Erc20Events { - approval(amount: u64, owner: wasmlib.ScAgentID, spender: wasmlib.ScAgentID): void { - new wasmlib.EventEncoder("erc20.approval"). - uint64(amount). - agentID(owner). - agentID(spender). - emit(); + approval(amount: u64, owner: wasmtypes.ScAgentID, spender: wasmtypes.ScAgentID): void { + const evt = new wasmlib.EventEncoder("erc20.approval"); + evt.encode(wasmtypes.uint64ToString(amount)); + evt.encode(wasmtypes.agentIDToString(owner)); + evt.encode(wasmtypes.agentIDToString(spender)); + evt.emit(); } - transfer(amount: u64, from: wasmlib.ScAgentID, to: wasmlib.ScAgentID): void { - new wasmlib.EventEncoder("erc20.transfer"). - uint64(amount). - agentID(from). - agentID(to). - emit(); + transfer(amount: u64, from: wasmtypes.ScAgentID, to: wasmtypes.ScAgentID): void { + const evt = new wasmlib.EventEncoder("erc20.transfer"); + evt.encode(wasmtypes.uint64ToString(amount)); + evt.encode(wasmtypes.agentIDToString(from)); + evt.encode(wasmtypes.agentIDToString(to)); + evt.emit(); } } diff --git a/contracts/wasm/erc20/ts/erc20/index.ts b/contracts/wasm/erc20/ts/erc20/index.ts index 9411e9de15..6e1f5116e4 100644 --- a/contracts/wasm/erc20/ts/erc20/index.ts +++ b/contracts/wasm/erc20/ts/erc20/index.ts @@ -10,7 +10,6 @@ export * from "./erc20"; export * from "./consts"; export * from "./contract"; export * from "./events"; -export * from "./keys"; export * from "./lib"; export * from "./params"; export * from "./results"; diff --git a/contracts/wasm/erc20/ts/erc20/keys.ts b/contracts/wasm/erc20/ts/erc20/keys.ts index 217222f5ce..e7e0aa9c37 100644 --- a/contracts/wasm/erc20/ts/erc20/keys.ts +++ b/contracts/wasm/erc20/ts/erc20/keys.ts @@ -5,8 +5,6 @@ // >>>> DO NOT CHANGE THIS FILE! <<<< // Change the json schema instead -import * as wasmlib from "wasmlib"; -import * as sc from "./index"; export const IdxParamAccount = 0; export const IdxParamAmount = 1; @@ -14,26 +12,3 @@ export const IdxParamCreator = 2; export const IdxParamDelegation = 3; export const IdxParamRecipient = 4; export const IdxParamSupply = 5; - -export const IdxResultAmount = 6; -export const IdxResultSupply = 7; - -export const IdxStateAllAllowances = 8; -export const IdxStateBalances = 9; -export const IdxStateSupply = 10; - -export let keyMap: string[] = [ - sc.ParamAccount, - sc.ParamAmount, - sc.ParamCreator, - sc.ParamDelegation, - sc.ParamRecipient, - sc.ParamSupply, - sc.ResultAmount, - sc.ResultSupply, - sc.StateAllAllowances, - sc.StateBalances, - sc.StateSupply, -]; - -export let idxMap: wasmlib.Key32[] = new Array(keyMap.length); diff --git a/contracts/wasm/erc20/ts/erc20/lib.ts b/contracts/wasm/erc20/ts/erc20/lib.ts index 7b15f7fde9..b1b0d22bd0 100644 --- a/contracts/wasm/erc20/ts/erc20/lib.ts +++ b/contracts/wasm/erc20/ts/erc20/lib.ts @@ -6,6 +6,7 @@ // Change the json schema instead import * as wasmlib from "wasmlib"; +import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; export function on_call(index: i32): void { @@ -21,17 +22,11 @@ export function on_load(): void { exports.addView(sc.ViewAllowance, viewAllowanceThunk); exports.addView(sc.ViewBalanceOf, viewBalanceOfThunk); exports.addView(sc.ViewTotalSupply, viewTotalSupplyThunk); - - for (let i = 0; i < sc.keyMap.length; i++) { - sc.idxMap[i] = wasmlib.Key32.fromString(sc.keyMap[i]); - } } function funcApproveThunk(ctx: wasmlib.ScFuncContext): void { ctx.log("erc20.funcApprove"); let f = new sc.ApproveContext(); - f.params.mapID = wasmlib.OBJ_ID_PARAMS; - f.state.mapID = wasmlib.OBJ_ID_STATE; ctx.require(f.params.amount().exists(), "missing mandatory amount"); ctx.require(f.params.delegation().exists(), "missing mandatory delegation"); sc.funcApprove(ctx, f); @@ -41,8 +36,6 @@ function funcApproveThunk(ctx: wasmlib.ScFuncContext): void { function funcInitThunk(ctx: wasmlib.ScFuncContext): void { ctx.log("erc20.funcInit"); let f = new sc.InitContext(); - f.params.mapID = wasmlib.OBJ_ID_PARAMS; - f.state.mapID = wasmlib.OBJ_ID_STATE; ctx.require(f.params.creator().exists(), "missing mandatory creator"); ctx.require(f.params.supply().exists(), "missing mandatory supply"); sc.funcInit(ctx, f); @@ -52,8 +45,6 @@ function funcInitThunk(ctx: wasmlib.ScFuncContext): void { function funcTransferThunk(ctx: wasmlib.ScFuncContext): void { ctx.log("erc20.funcTransfer"); let f = new sc.TransferContext(); - f.params.mapID = wasmlib.OBJ_ID_PARAMS; - f.state.mapID = wasmlib.OBJ_ID_STATE; ctx.require(f.params.account().exists(), "missing mandatory account"); ctx.require(f.params.amount().exists(), "missing mandatory amount"); sc.funcTransfer(ctx, f); @@ -63,8 +54,6 @@ function funcTransferThunk(ctx: wasmlib.ScFuncContext): void { function funcTransferFromThunk(ctx: wasmlib.ScFuncContext): void { ctx.log("erc20.funcTransferFrom"); let f = new sc.TransferFromContext(); - f.params.mapID = wasmlib.OBJ_ID_PARAMS; - f.state.mapID = wasmlib.OBJ_ID_STATE; ctx.require(f.params.account().exists(), "missing mandatory account"); ctx.require(f.params.amount().exists(), "missing mandatory amount"); ctx.require(f.params.recipient().exists(), "missing mandatory recipient"); @@ -75,31 +64,32 @@ function funcTransferFromThunk(ctx: wasmlib.ScFuncContext): void { function viewAllowanceThunk(ctx: wasmlib.ScViewContext): void { ctx.log("erc20.viewAllowance"); let f = new sc.AllowanceContext(); - f.params.mapID = wasmlib.OBJ_ID_PARAMS; - f.results.mapID = wasmlib.OBJ_ID_RESULTS; - f.state.mapID = wasmlib.OBJ_ID_STATE; + const results = new wasmlib.ScDict([]); + f.results = new sc.MutableAllowanceResults(results.asProxy()); ctx.require(f.params.account().exists(), "missing mandatory account"); ctx.require(f.params.delegation().exists(), "missing mandatory delegation"); sc.viewAllowance(ctx, f); + ctx.results(results); ctx.log("erc20.viewAllowance ok"); } function viewBalanceOfThunk(ctx: wasmlib.ScViewContext): void { ctx.log("erc20.viewBalanceOf"); let f = new sc.BalanceOfContext(); - f.params.mapID = wasmlib.OBJ_ID_PARAMS; - f.results.mapID = wasmlib.OBJ_ID_RESULTS; - f.state.mapID = wasmlib.OBJ_ID_STATE; + const results = new wasmlib.ScDict([]); + f.results = new sc.MutableBalanceOfResults(results.asProxy()); ctx.require(f.params.account().exists(), "missing mandatory account"); sc.viewBalanceOf(ctx, f); + ctx.results(results); ctx.log("erc20.viewBalanceOf ok"); } function viewTotalSupplyThunk(ctx: wasmlib.ScViewContext): void { ctx.log("erc20.viewTotalSupply"); let f = new sc.TotalSupplyContext(); - f.results.mapID = wasmlib.OBJ_ID_RESULTS; - f.state.mapID = wasmlib.OBJ_ID_STATE; + const results = new wasmlib.ScDict([]); + f.results = new sc.MutableTotalSupplyResults(results.asProxy()); sc.viewTotalSupply(ctx, f); + ctx.results(results); ctx.log("erc20.viewTotalSupply ok"); } diff --git a/contracts/wasm/erc20/ts/erc20/params.ts b/contracts/wasm/erc20/ts/erc20/params.ts index 15b05bdcc6..6ec5bab74b 100644 --- a/contracts/wasm/erc20/ts/erc20/params.ts +++ b/contracts/wasm/erc20/ts/erc20/params.ts @@ -6,124 +6,125 @@ // Change the json schema instead import * as wasmlib from "wasmlib"; +import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; -export class ImmutableApproveParams extends wasmlib.ScMapID { - amount(): wasmlib.ScImmutableUint64 { - return new wasmlib.ScImmutableUint64(this.mapID, wasmlib.Key32.fromString(sc.ParamAmount)); +export class ImmutableApproveParams extends wasmtypes.ScProxy { + amount(): wasmtypes.ScImmutableUint64 { + return new wasmtypes.ScImmutableUint64(this.proxy.root(sc.ParamAmount)); } - delegation(): wasmlib.ScImmutableAgentID { - return new wasmlib.ScImmutableAgentID(this.mapID, wasmlib.Key32.fromString(sc.ParamDelegation)); + delegation(): wasmtypes.ScImmutableAgentID { + return new wasmtypes.ScImmutableAgentID(this.proxy.root(sc.ParamDelegation)); } } -export class MutableApproveParams extends wasmlib.ScMapID { - amount(): wasmlib.ScMutableUint64 { - return new wasmlib.ScMutableUint64(this.mapID, wasmlib.Key32.fromString(sc.ParamAmount)); +export class MutableApproveParams extends wasmtypes.ScProxy { + amount(): wasmtypes.ScMutableUint64 { + return new wasmtypes.ScMutableUint64(this.proxy.root(sc.ParamAmount)); } - delegation(): wasmlib.ScMutableAgentID { - return new wasmlib.ScMutableAgentID(this.mapID, wasmlib.Key32.fromString(sc.ParamDelegation)); + delegation(): wasmtypes.ScMutableAgentID { + return new wasmtypes.ScMutableAgentID(this.proxy.root(sc.ParamDelegation)); } } -export class ImmutableInitParams extends wasmlib.ScMapID { - creator(): wasmlib.ScImmutableAgentID { - return new wasmlib.ScImmutableAgentID(this.mapID, sc.idxMap[sc.IdxParamCreator]); +export class ImmutableInitParams extends wasmtypes.ScProxy { + creator(): wasmtypes.ScImmutableAgentID { + return new wasmtypes.ScImmutableAgentID(this.proxy.root(sc.ParamCreator)); } - supply(): wasmlib.ScImmutableUint64 { - return new wasmlib.ScImmutableUint64(this.mapID, sc.idxMap[sc.IdxParamSupply]); + supply(): wasmtypes.ScImmutableUint64 { + return new wasmtypes.ScImmutableUint64(this.proxy.root(sc.ParamSupply)); } } -export class MutableInitParams extends wasmlib.ScMapID { - creator(): wasmlib.ScMutableAgentID { - return new wasmlib.ScMutableAgentID(this.mapID, sc.idxMap[sc.IdxParamCreator]); +export class MutableInitParams extends wasmtypes.ScProxy { + creator(): wasmtypes.ScMutableAgentID { + return new wasmtypes.ScMutableAgentID(this.proxy.root(sc.ParamCreator)); } - supply(): wasmlib.ScMutableUint64 { - return new wasmlib.ScMutableUint64(this.mapID, sc.idxMap[sc.IdxParamSupply]); + supply(): wasmtypes.ScMutableUint64 { + return new wasmtypes.ScMutableUint64(this.proxy.root(sc.ParamSupply)); } } -export class ImmutableTransferParams extends wasmlib.ScMapID { - account(): wasmlib.ScImmutableAgentID { - return new wasmlib.ScImmutableAgentID(this.mapID, wasmlib.Key32.fromString(sc.ParamAccount)); +export class ImmutableTransferParams extends wasmtypes.ScProxy { + account(): wasmtypes.ScImmutableAgentID { + return new wasmtypes.ScImmutableAgentID(this.proxy.root(sc.ParamAccount)); } - amount(): wasmlib.ScImmutableUint64 { - return new wasmlib.ScImmutableUint64(this.mapID, wasmlib.Key32.fromString(sc.ParamAmount)); + amount(): wasmtypes.ScImmutableUint64 { + return new wasmtypes.ScImmutableUint64(this.proxy.root(sc.ParamAmount)); } } -export class MutableTransferParams extends wasmlib.ScMapID { - account(): wasmlib.ScMutableAgentID { - return new wasmlib.ScMutableAgentID(this.mapID, wasmlib.Key32.fromString(sc.ParamAccount)); +export class MutableTransferParams extends wasmtypes.ScProxy { + account(): wasmtypes.ScMutableAgentID { + return new wasmtypes.ScMutableAgentID(this.proxy.root(sc.ParamAccount)); } - amount(): wasmlib.ScMutableUint64 { - return new wasmlib.ScMutableUint64(this.mapID, wasmlib.Key32.fromString(sc.ParamAmount)); + amount(): wasmtypes.ScMutableUint64 { + return new wasmtypes.ScMutableUint64(this.proxy.root(sc.ParamAmount)); } } -export class ImmutableTransferFromParams extends wasmlib.ScMapID { - account(): wasmlib.ScImmutableAgentID { - return new wasmlib.ScImmutableAgentID(this.mapID, wasmlib.Key32.fromString(sc.ParamAccount)); +export class ImmutableTransferFromParams extends wasmtypes.ScProxy { + account(): wasmtypes.ScImmutableAgentID { + return new wasmtypes.ScImmutableAgentID(this.proxy.root(sc.ParamAccount)); } - amount(): wasmlib.ScImmutableUint64 { - return new wasmlib.ScImmutableUint64(this.mapID, wasmlib.Key32.fromString(sc.ParamAmount)); + amount(): wasmtypes.ScImmutableUint64 { + return new wasmtypes.ScImmutableUint64(this.proxy.root(sc.ParamAmount)); } - recipient(): wasmlib.ScImmutableAgentID { - return new wasmlib.ScImmutableAgentID(this.mapID, wasmlib.Key32.fromString(sc.ParamRecipient)); + recipient(): wasmtypes.ScImmutableAgentID { + return new wasmtypes.ScImmutableAgentID(this.proxy.root(sc.ParamRecipient)); } } -export class MutableTransferFromParams extends wasmlib.ScMapID { - account(): wasmlib.ScMutableAgentID { - return new wasmlib.ScMutableAgentID(this.mapID, wasmlib.Key32.fromString(sc.ParamAccount)); +export class MutableTransferFromParams extends wasmtypes.ScProxy { + account(): wasmtypes.ScMutableAgentID { + return new wasmtypes.ScMutableAgentID(this.proxy.root(sc.ParamAccount)); } - amount(): wasmlib.ScMutableUint64 { - return new wasmlib.ScMutableUint64(this.mapID, wasmlib.Key32.fromString(sc.ParamAmount)); + amount(): wasmtypes.ScMutableUint64 { + return new wasmtypes.ScMutableUint64(this.proxy.root(sc.ParamAmount)); } - recipient(): wasmlib.ScMutableAgentID { - return new wasmlib.ScMutableAgentID(this.mapID, wasmlib.Key32.fromString(sc.ParamRecipient)); + recipient(): wasmtypes.ScMutableAgentID { + return new wasmtypes.ScMutableAgentID(this.proxy.root(sc.ParamRecipient)); } } -export class ImmutableAllowanceParams extends wasmlib.ScMapID { - account(): wasmlib.ScImmutableAgentID { - return new wasmlib.ScImmutableAgentID(this.mapID, wasmlib.Key32.fromString(sc.ParamAccount)); +export class ImmutableAllowanceParams extends wasmtypes.ScProxy { + account(): wasmtypes.ScImmutableAgentID { + return new wasmtypes.ScImmutableAgentID(this.proxy.root(sc.ParamAccount)); } - delegation(): wasmlib.ScImmutableAgentID { - return new wasmlib.ScImmutableAgentID(this.mapID, wasmlib.Key32.fromString(sc.ParamDelegation)); + delegation(): wasmtypes.ScImmutableAgentID { + return new wasmtypes.ScImmutableAgentID(this.proxy.root(sc.ParamDelegation)); } } -export class MutableAllowanceParams extends wasmlib.ScMapID { - account(): wasmlib.ScMutableAgentID { - return new wasmlib.ScMutableAgentID(this.mapID, wasmlib.Key32.fromString(sc.ParamAccount)); +export class MutableAllowanceParams extends wasmtypes.ScProxy { + account(): wasmtypes.ScMutableAgentID { + return new wasmtypes.ScMutableAgentID(this.proxy.root(sc.ParamAccount)); } - delegation(): wasmlib.ScMutableAgentID { - return new wasmlib.ScMutableAgentID(this.mapID, wasmlib.Key32.fromString(sc.ParamDelegation)); + delegation(): wasmtypes.ScMutableAgentID { + return new wasmtypes.ScMutableAgentID(this.proxy.root(sc.ParamDelegation)); } } -export class ImmutableBalanceOfParams extends wasmlib.ScMapID { - account(): wasmlib.ScImmutableAgentID { - return new wasmlib.ScImmutableAgentID(this.mapID, wasmlib.Key32.fromString(sc.ParamAccount)); +export class ImmutableBalanceOfParams extends wasmtypes.ScProxy { + account(): wasmtypes.ScImmutableAgentID { + return new wasmtypes.ScImmutableAgentID(this.proxy.root(sc.ParamAccount)); } } -export class MutableBalanceOfParams extends wasmlib.ScMapID { - account(): wasmlib.ScMutableAgentID { - return new wasmlib.ScMutableAgentID(this.mapID, wasmlib.Key32.fromString(sc.ParamAccount)); +export class MutableBalanceOfParams extends wasmtypes.ScProxy { + account(): wasmtypes.ScMutableAgentID { + return new wasmtypes.ScMutableAgentID(this.proxy.root(sc.ParamAccount)); } } diff --git a/contracts/wasm/erc20/ts/erc20/results.ts b/contracts/wasm/erc20/ts/erc20/results.ts index e2e03d5909..98d97c9930 100644 --- a/contracts/wasm/erc20/ts/erc20/results.ts +++ b/contracts/wasm/erc20/ts/erc20/results.ts @@ -6,40 +6,41 @@ // Change the json schema instead import * as wasmlib from "wasmlib"; +import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; -export class ImmutableAllowanceResults extends wasmlib.ScMapID { - amount(): wasmlib.ScImmutableUint64 { - return new wasmlib.ScImmutableUint64(this.mapID, wasmlib.Key32.fromString(sc.ResultAmount)); +export class ImmutableAllowanceResults extends wasmtypes.ScProxy { + amount(): wasmtypes.ScImmutableUint64 { + return new wasmtypes.ScImmutableUint64(this.proxy.root(sc.ResultAmount)); } } -export class MutableAllowanceResults extends wasmlib.ScMapID { - amount(): wasmlib.ScMutableUint64 { - return new wasmlib.ScMutableUint64(this.mapID, wasmlib.Key32.fromString(sc.ResultAmount)); +export class MutableAllowanceResults extends wasmtypes.ScProxy { + amount(): wasmtypes.ScMutableUint64 { + return new wasmtypes.ScMutableUint64(this.proxy.root(sc.ResultAmount)); } } -export class ImmutableBalanceOfResults extends wasmlib.ScMapID { - amount(): wasmlib.ScImmutableUint64 { - return new wasmlib.ScImmutableUint64(this.mapID, wasmlib.Key32.fromString(sc.ResultAmount)); +export class ImmutableBalanceOfResults extends wasmtypes.ScProxy { + amount(): wasmtypes.ScImmutableUint64 { + return new wasmtypes.ScImmutableUint64(this.proxy.root(sc.ResultAmount)); } } -export class MutableBalanceOfResults extends wasmlib.ScMapID { - amount(): wasmlib.ScMutableUint64 { - return new wasmlib.ScMutableUint64(this.mapID, wasmlib.Key32.fromString(sc.ResultAmount)); +export class MutableBalanceOfResults extends wasmtypes.ScProxy { + amount(): wasmtypes.ScMutableUint64 { + return new wasmtypes.ScMutableUint64(this.proxy.root(sc.ResultAmount)); } } -export class ImmutableTotalSupplyResults extends wasmlib.ScMapID { - supply(): wasmlib.ScImmutableUint64 { - return new wasmlib.ScImmutableUint64(this.mapID, wasmlib.Key32.fromString(sc.ResultSupply)); +export class ImmutableTotalSupplyResults extends wasmtypes.ScProxy { + supply(): wasmtypes.ScImmutableUint64 { + return new wasmtypes.ScImmutableUint64(this.proxy.root(sc.ResultSupply)); } } -export class MutableTotalSupplyResults extends wasmlib.ScMapID { - supply(): wasmlib.ScMutableUint64 { - return new wasmlib.ScMutableUint64(this.mapID, wasmlib.Key32.fromString(sc.ResultSupply)); +export class MutableTotalSupplyResults extends wasmtypes.ScProxy { + supply(): wasmtypes.ScMutableUint64 { + return new wasmtypes.ScMutableUint64(this.proxy.root(sc.ResultSupply)); } } diff --git a/contracts/wasm/erc20/ts/erc20/state.ts b/contracts/wasm/erc20/ts/erc20/state.ts index 8a4742b78e..4cd3a8dafc 100644 --- a/contracts/wasm/erc20/ts/erc20/state.ts +++ b/contracts/wasm/erc20/ts/erc20/state.ts @@ -6,72 +6,55 @@ // Change the json schema instead import * as wasmlib from "wasmlib"; +import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; -export class MapAgentIDToImmutableAllowancesForAgent { - objID: i32; +export class MapAgentIDToImmutableAllowancesForAgent extends wasmtypes.ScProxy { - constructor(objID: i32) { - this.objID = objID; - } - - getAllowancesForAgent(key: wasmlib.ScAgentID): sc.ImmutableAllowancesForAgent { - let subID = wasmlib.getObjectID(this.objID, key.getKeyID(), wasmlib.TYPE_MAP); - return new sc.ImmutableAllowancesForAgent(subID); + getAllowancesForAgent(key: wasmtypes.ScAgentID): sc.ImmutableAllowancesForAgent { + return new sc.ImmutableAllowancesForAgent(this.proxy.key(wasmtypes.agentIDToBytes(key))); } } -export class ImmutableErc20State extends wasmlib.ScMapID { +export class ImmutableErc20State extends wasmtypes.ScProxy { allAllowances(): sc.MapAgentIDToImmutableAllowancesForAgent { - let mapID = wasmlib.getObjectID(this.mapID, wasmlib.Key32.fromString(sc.StateAllAllowances), wasmlib.TYPE_MAP); - return new sc.MapAgentIDToImmutableAllowancesForAgent(mapID); + return new sc.MapAgentIDToImmutableAllowancesForAgent(this.proxy.root(sc.StateAllAllowances)); } balances(): sc.MapAgentIDToImmutableUint64 { - let mapID = wasmlib.getObjectID(this.mapID, wasmlib.Key32.fromString(sc.StateBalances), wasmlib.TYPE_MAP); - return new sc.MapAgentIDToImmutableUint64(mapID); + return new sc.MapAgentIDToImmutableUint64(this.proxy.root(sc.StateBalances)); } - supply(): wasmlib.ScImmutableUint64 { - return new wasmlib.ScImmutableUint64(this.mapID, wasmlib.Key32.fromString(sc.StateSupply)); + supply(): wasmtypes.ScImmutableUint64 { + return new wasmtypes.ScImmutableUint64(this.proxy.root(sc.StateSupply)); } } -export class MapAgentIDToMutableAllowancesForAgent { - objID: i32; - - constructor(objID: i32) { - this.objID = objID; - } +export class MapAgentIDToMutableAllowancesForAgent extends wasmtypes.ScProxy { clear(): void { - wasmlib.clear(this.objID); + this.proxy.clearMap(); } - getAllowancesForAgent(key: wasmlib.ScAgentID): sc.MutableAllowancesForAgent { - let subID = wasmlib.getObjectID(this.objID, key.getKeyID(), wasmlib.TYPE_MAP); - return new sc.MutableAllowancesForAgent(subID); + getAllowancesForAgent(key: wasmtypes.ScAgentID): sc.MutableAllowancesForAgent { + return new sc.MutableAllowancesForAgent(this.proxy.key(wasmtypes.agentIDToBytes(key))); } } -export class MutableErc20State extends wasmlib.ScMapID { +export class MutableErc20State extends wasmtypes.ScProxy { asImmutable(): sc.ImmutableErc20State { - const imm = new sc.ImmutableErc20State(); - imm.mapID = this.mapID; - return imm; + return new sc.ImmutableErc20State(this.proxy); } allAllowances(): sc.MapAgentIDToMutableAllowancesForAgent { - let mapID = wasmlib.getObjectID(this.mapID, wasmlib.Key32.fromString(sc.StateAllAllowances), wasmlib.TYPE_MAP); - return new sc.MapAgentIDToMutableAllowancesForAgent(mapID); + return new sc.MapAgentIDToMutableAllowancesForAgent(this.proxy.root(sc.StateAllAllowances)); } balances(): sc.MapAgentIDToMutableUint64 { - let mapID = wasmlib.getObjectID(this.mapID, wasmlib.Key32.fromString(sc.StateBalances), wasmlib.TYPE_MAP); - return new sc.MapAgentIDToMutableUint64(mapID); + return new sc.MapAgentIDToMutableUint64(this.proxy.root(sc.StateBalances)); } - supply(): wasmlib.ScMutableUint64 { - return new wasmlib.ScMutableUint64(this.mapID, wasmlib.Key32.fromString(sc.StateSupply)); + supply(): wasmtypes.ScMutableUint64 { + return new wasmtypes.ScMutableUint64(this.proxy.root(sc.StateSupply)); } } diff --git a/contracts/wasm/erc20/ts/erc20/typedefs.ts b/contracts/wasm/erc20/ts/erc20/typedefs.ts index ad2dfc36e0..9daabad509 100644 --- a/contracts/wasm/erc20/ts/erc20/typedefs.ts +++ b/contracts/wasm/erc20/ts/erc20/typedefs.ts @@ -6,36 +6,27 @@ // Change the json schema instead import * as wasmlib from "wasmlib"; +import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; -export class MapAgentIDToImmutableUint64 { - objID: i32; +export class MapAgentIDToImmutableUint64 extends wasmtypes.ScProxy { - constructor(objID: i32) { - this.objID = objID; - } - - getUint64(key: wasmlib.ScAgentID): wasmlib.ScImmutableUint64 { - return new wasmlib.ScImmutableUint64(this.objID, key.getKeyID()); + getUint64(key: wasmtypes.ScAgentID): wasmtypes.ScImmutableUint64 { + return new wasmtypes.ScImmutableUint64(this.proxy.key(wasmtypes.agentIDToBytes(key))); } } export class ImmutableAllowancesForAgent extends MapAgentIDToImmutableUint64 { }; -export class MapAgentIDToMutableUint64 { - objID: i32; - - constructor(objID: i32) { - this.objID = objID; - } +export class MapAgentIDToMutableUint64 extends wasmtypes.ScProxy { clear(): void { - wasmlib.clear(this.objID); + this.proxy.clearMap(); } - getUint64(key: wasmlib.ScAgentID): wasmlib.ScMutableUint64 { - return new wasmlib.ScMutableUint64(this.objID, key.getKeyID()); + getUint64(key: wasmtypes.ScAgentID): wasmtypes.ScMutableUint64 { + return new wasmtypes.ScMutableUint64(this.proxy.key(wasmtypes.agentIDToBytes(key))); } } diff --git a/contracts/wasm/erc721/go/erc721/lib.go b/contracts/wasm/erc721/go/erc721/lib.go index ec7e5d7da2..86fc3a9107 100644 --- a/contracts/wasm/erc721/go/erc721/lib.go +++ b/contracts/wasm/erc721/go/erc721/lib.go @@ -202,8 +202,8 @@ func viewBalanceOfThunk(ctx wasmlib.ScViewContext) { } ctx.Require(f.Params.Owner().Exists(), "missing mandatory owner") viewBalanceOf(ctx, f) - ctx.Log("erc721.viewBalanceOf ok") ctx.Results(results) + ctx.Log("erc721.viewBalanceOf ok") } type GetApprovedContext struct { @@ -228,8 +228,8 @@ func viewGetApprovedThunk(ctx wasmlib.ScViewContext) { } ctx.Require(f.Params.TokenID().Exists(), "missing mandatory tokenID") viewGetApproved(ctx, f) - ctx.Log("erc721.viewGetApproved ok") ctx.Results(results) + ctx.Log("erc721.viewGetApproved ok") } type IsApprovedForAllContext struct { @@ -255,8 +255,8 @@ func viewIsApprovedForAllThunk(ctx wasmlib.ScViewContext) { ctx.Require(f.Params.Operator().Exists(), "missing mandatory operator") ctx.Require(f.Params.Owner().Exists(), "missing mandatory owner") viewIsApprovedForAll(ctx, f) - ctx.Log("erc721.viewIsApprovedForAll ok") ctx.Results(results) + ctx.Log("erc721.viewIsApprovedForAll ok") } type NameContext struct { @@ -276,8 +276,8 @@ func viewNameThunk(ctx wasmlib.ScViewContext) { }, } viewName(ctx, f) - ctx.Log("erc721.viewName ok") ctx.Results(results) + ctx.Log("erc721.viewName ok") } type OwnerOfContext struct { @@ -302,8 +302,8 @@ func viewOwnerOfThunk(ctx wasmlib.ScViewContext) { } ctx.Require(f.Params.TokenID().Exists(), "missing mandatory tokenID") viewOwnerOf(ctx, f) - ctx.Log("erc721.viewOwnerOf ok") ctx.Results(results) + ctx.Log("erc721.viewOwnerOf ok") } type SymbolContext struct { @@ -323,8 +323,8 @@ func viewSymbolThunk(ctx wasmlib.ScViewContext) { }, } viewSymbol(ctx, f) - ctx.Log("erc721.viewSymbol ok") ctx.Results(results) + ctx.Log("erc721.viewSymbol ok") } type TokenURIContext struct { @@ -349,6 +349,6 @@ func viewTokenURIThunk(ctx wasmlib.ScViewContext) { } ctx.Require(f.Params.TokenID().Exists(), "missing mandatory tokenID") viewTokenURI(ctx, f) - ctx.Log("erc721.viewTokenURI ok") ctx.Results(results) + ctx.Log("erc721.viewTokenURI ok") } diff --git a/contracts/wasm/erc721/go/erc721/state.go b/contracts/wasm/erc721/go/erc721/state.go index 884610fa40..12f7c29189 100644 --- a/contracts/wasm/erc721/go/erc721/state.go +++ b/contracts/wasm/erc721/go/erc721/state.go @@ -14,7 +14,7 @@ type MapHashToImmutableAgentID struct { } func (m MapHashToImmutableAgentID) GetAgentID(key wasmtypes.ScHash) wasmtypes.ScImmutableAgentID { - return wasmtypes.NewScImmutableAgentID(m.proxy.Key(wasmtypes.BytesFromHash(key))) + return wasmtypes.NewScImmutableAgentID(m.proxy.Key(wasmtypes.HashToBytes(key))) } type MapAgentIDToImmutableOperators struct { @@ -22,7 +22,7 @@ type MapAgentIDToImmutableOperators struct { } func (m MapAgentIDToImmutableOperators) GetOperators(key wasmtypes.ScAgentID) ImmutableOperators { - return ImmutableOperators{proxy: m.proxy.Key(wasmtypes.BytesFromAgentID(key))} + return ImmutableOperators{proxy: m.proxy.Key(wasmtypes.AgentIDToBytes(key))} } type MapAgentIDToImmutableUint64 struct { @@ -30,7 +30,7 @@ type MapAgentIDToImmutableUint64 struct { } func (m MapAgentIDToImmutableUint64) GetUint64(key wasmtypes.ScAgentID) wasmtypes.ScImmutableUint64 { - return wasmtypes.NewScImmutableUint64(m.proxy.Key(wasmtypes.BytesFromAgentID(key))) + return wasmtypes.NewScImmutableUint64(m.proxy.Key(wasmtypes.AgentIDToBytes(key))) } type MapHashToImmutableString struct { @@ -38,7 +38,7 @@ type MapHashToImmutableString struct { } func (m MapHashToImmutableString) GetString(key wasmtypes.ScHash) wasmtypes.ScImmutableString { - return wasmtypes.NewScImmutableString(m.proxy.Key(wasmtypes.BytesFromHash(key))) + return wasmtypes.NewScImmutableString(m.proxy.Key(wasmtypes.HashToBytes(key))) } type ImmutableErc721State struct { @@ -82,7 +82,7 @@ func (m MapHashToMutableAgentID) Clear() { } func (m MapHashToMutableAgentID) GetAgentID(key wasmtypes.ScHash) wasmtypes.ScMutableAgentID { - return wasmtypes.NewScMutableAgentID(m.proxy.Key(wasmtypes.BytesFromHash(key))) + return wasmtypes.NewScMutableAgentID(m.proxy.Key(wasmtypes.HashToBytes(key))) } type MapAgentIDToMutableOperators struct { @@ -94,7 +94,7 @@ func (m MapAgentIDToMutableOperators) Clear() { } func (m MapAgentIDToMutableOperators) GetOperators(key wasmtypes.ScAgentID) MutableOperators { - return MutableOperators{proxy: m.proxy.Key(wasmtypes.BytesFromAgentID(key))} + return MutableOperators{proxy: m.proxy.Key(wasmtypes.AgentIDToBytes(key))} } type MapAgentIDToMutableUint64 struct { @@ -106,7 +106,7 @@ func (m MapAgentIDToMutableUint64) Clear() { } func (m MapAgentIDToMutableUint64) GetUint64(key wasmtypes.ScAgentID) wasmtypes.ScMutableUint64 { - return wasmtypes.NewScMutableUint64(m.proxy.Key(wasmtypes.BytesFromAgentID(key))) + return wasmtypes.NewScMutableUint64(m.proxy.Key(wasmtypes.AgentIDToBytes(key))) } type MapHashToMutableString struct { @@ -118,7 +118,7 @@ func (m MapHashToMutableString) Clear() { } func (m MapHashToMutableString) GetString(key wasmtypes.ScHash) wasmtypes.ScMutableString { - return wasmtypes.NewScMutableString(m.proxy.Key(wasmtypes.BytesFromHash(key))) + return wasmtypes.NewScMutableString(m.proxy.Key(wasmtypes.HashToBytes(key))) } type MutableErc721State struct { diff --git a/contracts/wasm/erc721/go/erc721/typedefs.go b/contracts/wasm/erc721/go/erc721/typedefs.go index 25811e6af9..d27d05ac01 100644 --- a/contracts/wasm/erc721/go/erc721/typedefs.go +++ b/contracts/wasm/erc721/go/erc721/typedefs.go @@ -14,7 +14,7 @@ type MapAgentIDToImmutableBool struct { } func (m MapAgentIDToImmutableBool) GetBool(key wasmtypes.ScAgentID) wasmtypes.ScImmutableBool { - return wasmtypes.NewScImmutableBool(m.proxy.Key(wasmtypes.BytesFromAgentID(key))) + return wasmtypes.NewScImmutableBool(m.proxy.Key(wasmtypes.AgentIDToBytes(key))) } type ImmutableOperators = MapAgentIDToImmutableBool @@ -28,7 +28,7 @@ func (m MapAgentIDToMutableBool) Clear() { } func (m MapAgentIDToMutableBool) GetBool(key wasmtypes.ScAgentID) wasmtypes.ScMutableBool { - return wasmtypes.NewScMutableBool(m.proxy.Key(wasmtypes.BytesFromAgentID(key))) + return wasmtypes.NewScMutableBool(m.proxy.Key(wasmtypes.AgentIDToBytes(key))) } type MutableOperators = MapAgentIDToMutableBool diff --git a/contracts/wasm/erc721/ts/erc721/consts.ts b/contracts/wasm/erc721/ts/erc721/consts.ts index e32306cfa0..ce4dd6ae97 100644 --- a/contracts/wasm/erc721/ts/erc721/consts.ts +++ b/contracts/wasm/erc721/ts/erc721/consts.ts @@ -5,11 +5,11 @@ // >>>> DO NOT CHANGE THIS FILE! <<<< // Change the json schema instead -import * as wasmlib from "wasmlib"; +import * as wasmtypes from "wasmlib/wasmtypes"; export const ScName = "erc721"; export const ScDescription = "ERC-721 NFT PoC for IOTA Smart Contracts"; -export const HScName = new wasmlib.ScHname(0xd967c216); +export const HScName = new wasmtypes.ScHname(0xd967c216); export const ParamApproval = "approval"; export const ParamApproved = "approved"; @@ -54,17 +54,17 @@ export const ViewOwnerOf = "ownerOf"; export const ViewSymbol = "symbol"; export const ViewTokenURI = "tokenURI"; -export const HFuncApprove = new wasmlib.ScHname(0xa0661268); -export const HFuncBurn = new wasmlib.ScHname(0x7bc1efb1); -export const HFuncInit = new wasmlib.ScHname(0x1f44d644); -export const HFuncMint = new wasmlib.ScHname(0xa29addcf); -export const HFuncSafeTransferFrom = new wasmlib.ScHname(0x130ce158); -export const HFuncSetApprovalForAll = new wasmlib.ScHname(0xb8d8c776); -export const HFuncTransferFrom = new wasmlib.ScHname(0xd5e0a602); -export const HViewBalanceOf = new wasmlib.ScHname(0x67ef8df4); -export const HViewGetApproved = new wasmlib.ScHname(0xbe34b6ba); -export const HViewIsApprovedForAll = new wasmlib.ScHname(0x3251b0f0); -export const HViewName = new wasmlib.ScHname(0x0df7da3a); -export const HViewOwnerOf = new wasmlib.ScHname(0x1246f5ad); -export const HViewSymbol = new wasmlib.ScHname(0x3e93d19b); -export const HViewTokenURI = new wasmlib.ScHname(0x4e1a7397); +export const HFuncApprove = new wasmtypes.ScHname(0xa0661268); +export const HFuncBurn = new wasmtypes.ScHname(0x7bc1efb1); +export const HFuncInit = new wasmtypes.ScHname(0x1f44d644); +export const HFuncMint = new wasmtypes.ScHname(0xa29addcf); +export const HFuncSafeTransferFrom = new wasmtypes.ScHname(0x130ce158); +export const HFuncSetApprovalForAll = new wasmtypes.ScHname(0xb8d8c776); +export const HFuncTransferFrom = new wasmtypes.ScHname(0xd5e0a602); +export const HViewBalanceOf = new wasmtypes.ScHname(0x67ef8df4); +export const HViewGetApproved = new wasmtypes.ScHname(0xbe34b6ba); +export const HViewIsApprovedForAll = new wasmtypes.ScHname(0x3251b0f0); +export const HViewName = new wasmtypes.ScHname(0x0df7da3a); +export const HViewOwnerOf = new wasmtypes.ScHname(0x1246f5ad); +export const HViewSymbol = new wasmtypes.ScHname(0x3e93d19b); +export const HViewTokenURI = new wasmtypes.ScHname(0x4e1a7397); diff --git a/contracts/wasm/erc721/ts/erc721/contract.ts b/contracts/wasm/erc721/ts/erc721/contract.ts index e14506cc23..26b5462bdc 100644 --- a/contracts/wasm/erc721/ts/erc721/contract.ts +++ b/contracts/wasm/erc721/ts/erc721/contract.ts @@ -6,247 +6,253 @@ // Change the json schema instead import * as wasmlib from "wasmlib"; +import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; export class ApproveCall { func: wasmlib.ScFunc = new wasmlib.ScFunc(sc.HScName, sc.HFuncApprove); - params: sc.MutableApproveParams = new sc.MutableApproveParams(); + params: sc.MutableApproveParams = new sc.MutableApproveParams(wasmlib.ScView.nilProxy); } export class ApproveContext { events: sc.Erc721Events = new sc.Erc721Events(); - params: sc.ImmutableApproveParams = new sc.ImmutableApproveParams(); - state: sc.MutableErc721State = new sc.MutableErc721State(); + params: sc.ImmutableApproveParams = new sc.ImmutableApproveParams(wasmlib.paramsProxy()); + state: sc.MutableErc721State = new sc.MutableErc721State(wasmlib.ScState.proxy()); } export class BurnCall { func: wasmlib.ScFunc = new wasmlib.ScFunc(sc.HScName, sc.HFuncBurn); - params: sc.MutableBurnParams = new sc.MutableBurnParams(); + params: sc.MutableBurnParams = new sc.MutableBurnParams(wasmlib.ScView.nilProxy); } export class BurnContext { events: sc.Erc721Events = new sc.Erc721Events(); - params: sc.ImmutableBurnParams = new sc.ImmutableBurnParams(); - state: sc.MutableErc721State = new sc.MutableErc721State(); + params: sc.ImmutableBurnParams = new sc.ImmutableBurnParams(wasmlib.paramsProxy()); + state: sc.MutableErc721State = new sc.MutableErc721State(wasmlib.ScState.proxy()); } export class InitCall { func: wasmlib.ScInitFunc = new wasmlib.ScInitFunc(sc.HScName, sc.HFuncInit); - params: sc.MutableInitParams = new sc.MutableInitParams(); + params: sc.MutableInitParams = new sc.MutableInitParams(wasmlib.ScView.nilProxy); } export class InitContext { events: sc.Erc721Events = new sc.Erc721Events(); - params: sc.ImmutableInitParams = new sc.ImmutableInitParams(); - state: sc.MutableErc721State = new sc.MutableErc721State(); + params: sc.ImmutableInitParams = new sc.ImmutableInitParams(wasmlib.paramsProxy()); + state: sc.MutableErc721State = new sc.MutableErc721State(wasmlib.ScState.proxy()); } export class MintCall { func: wasmlib.ScFunc = new wasmlib.ScFunc(sc.HScName, sc.HFuncMint); - params: sc.MutableMintParams = new sc.MutableMintParams(); + params: sc.MutableMintParams = new sc.MutableMintParams(wasmlib.ScView.nilProxy); } export class MintContext { events: sc.Erc721Events = new sc.Erc721Events(); - params: sc.ImmutableMintParams = new sc.ImmutableMintParams(); - state: sc.MutableErc721State = new sc.MutableErc721State(); + params: sc.ImmutableMintParams = new sc.ImmutableMintParams(wasmlib.paramsProxy()); + state: sc.MutableErc721State = new sc.MutableErc721State(wasmlib.ScState.proxy()); } export class SafeTransferFromCall { func: wasmlib.ScFunc = new wasmlib.ScFunc(sc.HScName, sc.HFuncSafeTransferFrom); - params: sc.MutableSafeTransferFromParams = new sc.MutableSafeTransferFromParams(); + params: sc.MutableSafeTransferFromParams = new sc.MutableSafeTransferFromParams(wasmlib.ScView.nilProxy); } export class SafeTransferFromContext { events: sc.Erc721Events = new sc.Erc721Events(); - params: sc.ImmutableSafeTransferFromParams = new sc.ImmutableSafeTransferFromParams(); - state: sc.MutableErc721State = new sc.MutableErc721State(); + params: sc.ImmutableSafeTransferFromParams = new sc.ImmutableSafeTransferFromParams(wasmlib.paramsProxy()); + state: sc.MutableErc721State = new sc.MutableErc721State(wasmlib.ScState.proxy()); } export class SetApprovalForAllCall { func: wasmlib.ScFunc = new wasmlib.ScFunc(sc.HScName, sc.HFuncSetApprovalForAll); - params: sc.MutableSetApprovalForAllParams = new sc.MutableSetApprovalForAllParams(); + params: sc.MutableSetApprovalForAllParams = new sc.MutableSetApprovalForAllParams(wasmlib.ScView.nilProxy); } export class SetApprovalForAllContext { events: sc.Erc721Events = new sc.Erc721Events(); - params: sc.ImmutableSetApprovalForAllParams = new sc.ImmutableSetApprovalForAllParams(); - state: sc.MutableErc721State = new sc.MutableErc721State(); + params: sc.ImmutableSetApprovalForAllParams = new sc.ImmutableSetApprovalForAllParams(wasmlib.paramsProxy()); + state: sc.MutableErc721State = new sc.MutableErc721State(wasmlib.ScState.proxy()); } export class TransferFromCall { func: wasmlib.ScFunc = new wasmlib.ScFunc(sc.HScName, sc.HFuncTransferFrom); - params: sc.MutableTransferFromParams = new sc.MutableTransferFromParams(); + params: sc.MutableTransferFromParams = new sc.MutableTransferFromParams(wasmlib.ScView.nilProxy); } export class TransferFromContext { events: sc.Erc721Events = new sc.Erc721Events(); - params: sc.ImmutableTransferFromParams = new sc.ImmutableTransferFromParams(); - state: sc.MutableErc721State = new sc.MutableErc721State(); + params: sc.ImmutableTransferFromParams = new sc.ImmutableTransferFromParams(wasmlib.paramsProxy()); + state: sc.MutableErc721State = new sc.MutableErc721State(wasmlib.ScState.proxy()); } export class BalanceOfCall { func: wasmlib.ScView = new wasmlib.ScView(sc.HScName, sc.HViewBalanceOf); - params: sc.MutableBalanceOfParams = new sc.MutableBalanceOfParams(); - results: sc.ImmutableBalanceOfResults = new sc.ImmutableBalanceOfResults(); + params: sc.MutableBalanceOfParams = new sc.MutableBalanceOfParams(wasmlib.ScView.nilProxy); + results: sc.ImmutableBalanceOfResults = new sc.ImmutableBalanceOfResults(wasmlib.ScView.nilProxy); } export class BalanceOfContext { - params: sc.ImmutableBalanceOfParams = new sc.ImmutableBalanceOfParams(); - results: sc.MutableBalanceOfResults = new sc.MutableBalanceOfResults(); - state: sc.ImmutableErc721State = new sc.ImmutableErc721State(); + params: sc.ImmutableBalanceOfParams = new sc.ImmutableBalanceOfParams(wasmlib.paramsProxy()); + results: sc.MutableBalanceOfResults = new sc.MutableBalanceOfResults(wasmlib.ScView.nilProxy); + state: sc.ImmutableErc721State = new sc.ImmutableErc721State(wasmlib.ScState.proxy()); } export class GetApprovedCall { func: wasmlib.ScView = new wasmlib.ScView(sc.HScName, sc.HViewGetApproved); - params: sc.MutableGetApprovedParams = new sc.MutableGetApprovedParams(); - results: sc.ImmutableGetApprovedResults = new sc.ImmutableGetApprovedResults(); + params: sc.MutableGetApprovedParams = new sc.MutableGetApprovedParams(wasmlib.ScView.nilProxy); + results: sc.ImmutableGetApprovedResults = new sc.ImmutableGetApprovedResults(wasmlib.ScView.nilProxy); } export class GetApprovedContext { - params: sc.ImmutableGetApprovedParams = new sc.ImmutableGetApprovedParams(); - results: sc.MutableGetApprovedResults = new sc.MutableGetApprovedResults(); - state: sc.ImmutableErc721State = new sc.ImmutableErc721State(); + params: sc.ImmutableGetApprovedParams = new sc.ImmutableGetApprovedParams(wasmlib.paramsProxy()); + results: sc.MutableGetApprovedResults = new sc.MutableGetApprovedResults(wasmlib.ScView.nilProxy); + state: sc.ImmutableErc721State = new sc.ImmutableErc721State(wasmlib.ScState.proxy()); } export class IsApprovedForAllCall { func: wasmlib.ScView = new wasmlib.ScView(sc.HScName, sc.HViewIsApprovedForAll); - params: sc.MutableIsApprovedForAllParams = new sc.MutableIsApprovedForAllParams(); - results: sc.ImmutableIsApprovedForAllResults = new sc.ImmutableIsApprovedForAllResults(); + params: sc.MutableIsApprovedForAllParams = new sc.MutableIsApprovedForAllParams(wasmlib.ScView.nilProxy); + results: sc.ImmutableIsApprovedForAllResults = new sc.ImmutableIsApprovedForAllResults(wasmlib.ScView.nilProxy); } export class IsApprovedForAllContext { - params: sc.ImmutableIsApprovedForAllParams = new sc.ImmutableIsApprovedForAllParams(); - results: sc.MutableIsApprovedForAllResults = new sc.MutableIsApprovedForAllResults(); - state: sc.ImmutableErc721State = new sc.ImmutableErc721State(); + params: sc.ImmutableIsApprovedForAllParams = new sc.ImmutableIsApprovedForAllParams(wasmlib.paramsProxy()); + results: sc.MutableIsApprovedForAllResults = new sc.MutableIsApprovedForAllResults(wasmlib.ScView.nilProxy); + state: sc.ImmutableErc721State = new sc.ImmutableErc721State(wasmlib.ScState.proxy()); } export class NameCall { func: wasmlib.ScView = new wasmlib.ScView(sc.HScName, sc.HViewName); - results: sc.ImmutableNameResults = new sc.ImmutableNameResults(); + results: sc.ImmutableNameResults = new sc.ImmutableNameResults(wasmlib.ScView.nilProxy); } export class NameContext { - results: sc.MutableNameResults = new sc.MutableNameResults(); - state: sc.ImmutableErc721State = new sc.ImmutableErc721State(); + results: sc.MutableNameResults = new sc.MutableNameResults(wasmlib.ScView.nilProxy); + state: sc.ImmutableErc721State = new sc.ImmutableErc721State(wasmlib.ScState.proxy()); } export class OwnerOfCall { func: wasmlib.ScView = new wasmlib.ScView(sc.HScName, sc.HViewOwnerOf); - params: sc.MutableOwnerOfParams = new sc.MutableOwnerOfParams(); - results: sc.ImmutableOwnerOfResults = new sc.ImmutableOwnerOfResults(); + params: sc.MutableOwnerOfParams = new sc.MutableOwnerOfParams(wasmlib.ScView.nilProxy); + results: sc.ImmutableOwnerOfResults = new sc.ImmutableOwnerOfResults(wasmlib.ScView.nilProxy); } export class OwnerOfContext { - params: sc.ImmutableOwnerOfParams = new sc.ImmutableOwnerOfParams(); - results: sc.MutableOwnerOfResults = new sc.MutableOwnerOfResults(); - state: sc.ImmutableErc721State = new sc.ImmutableErc721State(); + params: sc.ImmutableOwnerOfParams = new sc.ImmutableOwnerOfParams(wasmlib.paramsProxy()); + results: sc.MutableOwnerOfResults = new sc.MutableOwnerOfResults(wasmlib.ScView.nilProxy); + state: sc.ImmutableErc721State = new sc.ImmutableErc721State(wasmlib.ScState.proxy()); } export class SymbolCall { func: wasmlib.ScView = new wasmlib.ScView(sc.HScName, sc.HViewSymbol); - results: sc.ImmutableSymbolResults = new sc.ImmutableSymbolResults(); + results: sc.ImmutableSymbolResults = new sc.ImmutableSymbolResults(wasmlib.ScView.nilProxy); } export class SymbolContext { - results: sc.MutableSymbolResults = new sc.MutableSymbolResults(); - state: sc.ImmutableErc721State = new sc.ImmutableErc721State(); + results: sc.MutableSymbolResults = new sc.MutableSymbolResults(wasmlib.ScView.nilProxy); + state: sc.ImmutableErc721State = new sc.ImmutableErc721State(wasmlib.ScState.proxy()); } export class TokenURICall { func: wasmlib.ScView = new wasmlib.ScView(sc.HScName, sc.HViewTokenURI); - params: sc.MutableTokenURIParams = new sc.MutableTokenURIParams(); - results: sc.ImmutableTokenURIResults = new sc.ImmutableTokenURIResults(); + params: sc.MutableTokenURIParams = new sc.MutableTokenURIParams(wasmlib.ScView.nilProxy); + results: sc.ImmutableTokenURIResults = new sc.ImmutableTokenURIResults(wasmlib.ScView.nilProxy); } export class TokenURIContext { - params: sc.ImmutableTokenURIParams = new sc.ImmutableTokenURIParams(); - results: sc.MutableTokenURIResults = new sc.MutableTokenURIResults(); - state: sc.ImmutableErc721State = new sc.ImmutableErc721State(); + params: sc.ImmutableTokenURIParams = new sc.ImmutableTokenURIParams(wasmlib.paramsProxy()); + results: sc.MutableTokenURIResults = new sc.MutableTokenURIResults(wasmlib.ScView.nilProxy); + state: sc.ImmutableErc721State = new sc.ImmutableErc721State(wasmlib.ScState.proxy()); } export class ScFuncs { static approve(ctx: wasmlib.ScFuncCallContext): ApproveCall { - let f = new ApproveCall(); - f.func.setPtrs(f.params, null); + const f = new ApproveCall(); + f.params = new sc.MutableApproveParams(wasmlib.newCallParamsProxy(f.func)); return f; } static burn(ctx: wasmlib.ScFuncCallContext): BurnCall { - let f = new BurnCall(); - f.func.setPtrs(f.params, null); + const f = new BurnCall(); + f.params = new sc.MutableBurnParams(wasmlib.newCallParamsProxy(f.func)); return f; } static init(ctx: wasmlib.ScFuncCallContext): InitCall { - let f = new InitCall(); - f.func.setPtrs(f.params, null); + const f = new InitCall(); + f.params = new sc.MutableInitParams(wasmlib.newCallParamsProxy(f.func)); return f; } static mint(ctx: wasmlib.ScFuncCallContext): MintCall { - let f = new MintCall(); - f.func.setPtrs(f.params, null); + const f = new MintCall(); + f.params = new sc.MutableMintParams(wasmlib.newCallParamsProxy(f.func)); return f; } static safeTransferFrom(ctx: wasmlib.ScFuncCallContext): SafeTransferFromCall { - let f = new SafeTransferFromCall(); - f.func.setPtrs(f.params, null); + const f = new SafeTransferFromCall(); + f.params = new sc.MutableSafeTransferFromParams(wasmlib.newCallParamsProxy(f.func)); return f; } static setApprovalForAll(ctx: wasmlib.ScFuncCallContext): SetApprovalForAllCall { - let f = new SetApprovalForAllCall(); - f.func.setPtrs(f.params, null); + const f = new SetApprovalForAllCall(); + f.params = new sc.MutableSetApprovalForAllParams(wasmlib.newCallParamsProxy(f.func)); return f; } static transferFrom(ctx: wasmlib.ScFuncCallContext): TransferFromCall { - let f = new TransferFromCall(); - f.func.setPtrs(f.params, null); + const f = new TransferFromCall(); + f.params = new sc.MutableTransferFromParams(wasmlib.newCallParamsProxy(f.func)); return f; } static balanceOf(ctx: wasmlib.ScViewCallContext): BalanceOfCall { - let f = new BalanceOfCall(); - f.func.setPtrs(f.params, f.results); + const f = new BalanceOfCall(); + f.params = new sc.MutableBalanceOfParams(wasmlib.newCallParamsProxy(f.func)); + f.results = new sc.ImmutableBalanceOfResults(wasmlib.newCallResultsProxy(f.func)); return f; } static getApproved(ctx: wasmlib.ScViewCallContext): GetApprovedCall { - let f = new GetApprovedCall(); - f.func.setPtrs(f.params, f.results); + const f = new GetApprovedCall(); + f.params = new sc.MutableGetApprovedParams(wasmlib.newCallParamsProxy(f.func)); + f.results = new sc.ImmutableGetApprovedResults(wasmlib.newCallResultsProxy(f.func)); return f; } static isApprovedForAll(ctx: wasmlib.ScViewCallContext): IsApprovedForAllCall { - let f = new IsApprovedForAllCall(); - f.func.setPtrs(f.params, f.results); + const f = new IsApprovedForAllCall(); + f.params = new sc.MutableIsApprovedForAllParams(wasmlib.newCallParamsProxy(f.func)); + f.results = new sc.ImmutableIsApprovedForAllResults(wasmlib.newCallResultsProxy(f.func)); return f; } static name(ctx: wasmlib.ScViewCallContext): NameCall { - let f = new NameCall(); - f.func.setPtrs(null, f.results); + const f = new NameCall(); + f.results = new sc.ImmutableNameResults(wasmlib.newCallResultsProxy(f.func)); return f; } static ownerOf(ctx: wasmlib.ScViewCallContext): OwnerOfCall { - let f = new OwnerOfCall(); - f.func.setPtrs(f.params, f.results); + const f = new OwnerOfCall(); + f.params = new sc.MutableOwnerOfParams(wasmlib.newCallParamsProxy(f.func)); + f.results = new sc.ImmutableOwnerOfResults(wasmlib.newCallResultsProxy(f.func)); return f; } static symbol(ctx: wasmlib.ScViewCallContext): SymbolCall { - let f = new SymbolCall(); - f.func.setPtrs(null, f.results); + const f = new SymbolCall(); + f.results = new sc.ImmutableSymbolResults(wasmlib.newCallResultsProxy(f.func)); return f; } static tokenURI(ctx: wasmlib.ScViewCallContext): TokenURICall { - let f = new TokenURICall(); - f.func.setPtrs(f.params, f.results); + const f = new TokenURICall(); + f.params = new sc.MutableTokenURIParams(wasmlib.newCallParamsProxy(f.func)); + f.results = new sc.ImmutableTokenURIResults(wasmlib.newCallResultsProxy(f.func)); return f; } } diff --git a/contracts/wasm/erc721/ts/erc721/erc721.ts b/contracts/wasm/erc721/ts/erc721/erc721.ts index 3a0612f769..23576dc46c 100644 --- a/contracts/wasm/erc721/ts/erc721/erc721.ts +++ b/contracts/wasm/erc721/ts/erc721/erc721.ts @@ -2,6 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 import * as wasmlib from "wasmlib"; +import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; // Follows ERC-721 standard as closely as possible @@ -16,12 +17,12 @@ import * as sc from "./index"; // set the required base URI, to which the base58 encoded token ID will be concatenated const BASE_URI = "my/special/base/uri/"; -const ZERO = new wasmlib.ScAgentID() +const ZERO = wasmtypes.agentIDFromBytes(null); /////////////////////////// HELPER FUNCTIONS //////////////////////////// // checks if caller is owner, or one of its delegated operators -function canOperate(state: sc.MutableErc721State, caller: wasmlib.ScAgentID, owner: wasmlib.ScAgentID): boolean { +function canOperate(state: sc.MutableErc721State, caller: wasmlib.ScAgentID, owner: wasmlib.ScAgentID): bool { if (caller.equals(owner)) { return true; } @@ -31,7 +32,7 @@ function canOperate(state: sc.MutableErc721State, caller: wasmlib.ScAgentID, own } // checks if caller is owner, or one of its delegated operators, or approved account for tokenID -function canTransfer(state: sc.MutableErc721State, caller: wasmlib.ScAgentID, owner: wasmlib.ScAgentID, tokenID: wasmlib.ScHash): boolean { +function canTransfer(state: sc.MutableErc721State, caller: wasmlib.ScAgentID, owner: wasmlib.ScAgentID, tokenID: wasmlib.ScHash): bool { if (canOperate(state, caller, owner)) { return true; } diff --git a/contracts/wasm/erc721/ts/erc721/events.ts b/contracts/wasm/erc721/ts/erc721/events.ts index 6407257600..dfed76da6f 100644 --- a/contracts/wasm/erc721/ts/erc721/events.ts +++ b/contracts/wasm/erc721/ts/erc721/events.ts @@ -6,45 +6,46 @@ // Change the json schema instead import * as wasmlib from "wasmlib"; +import * as wasmtypes from "wasmlib/wasmtypes"; export class Erc721Events { - approval(approved: wasmlib.ScAgentID, owner: wasmlib.ScAgentID, tokenID: wasmlib.ScHash): void { - new wasmlib.EventEncoder("erc721.approval"). - agentID(approved). - agentID(owner). - hash(tokenID). - emit(); + approval(approved: wasmtypes.ScAgentID, owner: wasmtypes.ScAgentID, tokenID: wasmtypes.ScHash): void { + const evt = new wasmlib.EventEncoder("erc721.approval"); + evt.encode(wasmtypes.agentIDToString(approved)); + evt.encode(wasmtypes.agentIDToString(owner)); + evt.encode(wasmtypes.hashToString(tokenID)); + evt.emit(); } - approvalForAll(approval: bool, operator: wasmlib.ScAgentID, owner: wasmlib.ScAgentID): void { - new wasmlib.EventEncoder("erc721.approvalForAll"). - bool(approval). - agentID(operator). - agentID(owner). - emit(); + approvalForAll(approval: bool, operator: wasmtypes.ScAgentID, owner: wasmtypes.ScAgentID): void { + const evt = new wasmlib.EventEncoder("erc721.approvalForAll"); + evt.encode(wasmtypes.boolToString(approval)); + evt.encode(wasmtypes.agentIDToString(operator)); + evt.encode(wasmtypes.agentIDToString(owner)); + evt.emit(); } init(name: string, symbol: string): void { - new wasmlib.EventEncoder("erc721.init"). - string(name). - string(symbol). - emit(); + const evt = new wasmlib.EventEncoder("erc721.init"); + evt.encode(wasmtypes.stringToString(name)); + evt.encode(wasmtypes.stringToString(symbol)); + evt.emit(); } - mint(balance: u64, owner: wasmlib.ScAgentID, tokenID: wasmlib.ScHash): void { - new wasmlib.EventEncoder("erc721.mint"). - uint64(balance). - agentID(owner). - hash(tokenID). - emit(); + mint(balance: u64, owner: wasmtypes.ScAgentID, tokenID: wasmtypes.ScHash): void { + const evt = new wasmlib.EventEncoder("erc721.mint"); + evt.encode(wasmtypes.uint64ToString(balance)); + evt.encode(wasmtypes.agentIDToString(owner)); + evt.encode(wasmtypes.hashToString(tokenID)); + evt.emit(); } - transfer(from: wasmlib.ScAgentID, to: wasmlib.ScAgentID, tokenID: wasmlib.ScHash): void { - new wasmlib.EventEncoder("erc721.transfer"). - agentID(from). - agentID(to). - hash(tokenID). - emit(); + transfer(from: wasmtypes.ScAgentID, to: wasmtypes.ScAgentID, tokenID: wasmtypes.ScHash): void { + const evt = new wasmlib.EventEncoder("erc721.transfer"); + evt.encode(wasmtypes.agentIDToString(from)); + evt.encode(wasmtypes.agentIDToString(to)); + evt.encode(wasmtypes.hashToString(tokenID)); + evt.emit(); } } diff --git a/contracts/wasm/erc721/ts/erc721/index.ts b/contracts/wasm/erc721/ts/erc721/index.ts index 11f170837f..0e8f70153c 100644 --- a/contracts/wasm/erc721/ts/erc721/index.ts +++ b/contracts/wasm/erc721/ts/erc721/index.ts @@ -10,7 +10,6 @@ export * from "./erc721"; export * from "./consts"; export * from "./contract"; export * from "./events"; -export * from "./keys"; export * from "./lib"; export * from "./params"; export * from "./results"; diff --git a/contracts/wasm/erc721/ts/erc721/keys.ts b/contracts/wasm/erc721/ts/erc721/keys.ts index fc32f134a8..3a0f8fb33b 100644 --- a/contracts/wasm/erc721/ts/erc721/keys.ts +++ b/contracts/wasm/erc721/ts/erc721/keys.ts @@ -5,8 +5,6 @@ // >>>> DO NOT CHANGE THIS FILE! <<<< // Change the json schema instead -import * as wasmlib from "wasmlib"; -import * as sc from "./index"; export const IdxParamApproval = 0; export const IdxParamApproved = 1; @@ -19,49 +17,3 @@ export const IdxParamSymbol = 7; export const IdxParamTo = 8; export const IdxParamTokenID = 9; export const IdxParamTokenURI = 10; - -export const IdxResultAmount = 11; -export const IdxResultApproval = 12; -export const IdxResultApproved = 13; -export const IdxResultName = 14; -export const IdxResultOwner = 15; -export const IdxResultSymbol = 16; -export const IdxResultTokenURI = 17; - -export const IdxStateApprovedAccounts = 18; -export const IdxStateApprovedOperators = 19; -export const IdxStateBalances = 20; -export const IdxStateName = 21; -export const IdxStateOwners = 22; -export const IdxStateSymbol = 23; -export const IdxStateTokenURIs = 24; - -export let keyMap: string[] = [ - sc.ParamApproval, - sc.ParamApproved, - sc.ParamData, - sc.ParamFrom, - sc.ParamName, - sc.ParamOperator, - sc.ParamOwner, - sc.ParamSymbol, - sc.ParamTo, - sc.ParamTokenID, - sc.ParamTokenURI, - sc.ResultAmount, - sc.ResultApproval, - sc.ResultApproved, - sc.ResultName, - sc.ResultOwner, - sc.ResultSymbol, - sc.ResultTokenURI, - sc.StateApprovedAccounts, - sc.StateApprovedOperators, - sc.StateBalances, - sc.StateName, - sc.StateOwners, - sc.StateSymbol, - sc.StateTokenURIs, -]; - -export let idxMap: wasmlib.Key32[] = new Array(keyMap.length); diff --git a/contracts/wasm/erc721/ts/erc721/lib.ts b/contracts/wasm/erc721/ts/erc721/lib.ts index ba6a48b663..ba3529d2c3 100644 --- a/contracts/wasm/erc721/ts/erc721/lib.ts +++ b/contracts/wasm/erc721/ts/erc721/lib.ts @@ -6,6 +6,7 @@ // Change the json schema instead import * as wasmlib from "wasmlib"; +import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; export function on_call(index: i32): void { @@ -28,17 +29,11 @@ export function on_load(): void { exports.addView(sc.ViewOwnerOf, viewOwnerOfThunk); exports.addView(sc.ViewSymbol, viewSymbolThunk); exports.addView(sc.ViewTokenURI, viewTokenURIThunk); - - for (let i = 0; i < sc.keyMap.length; i++) { - sc.idxMap[i] = wasmlib.Key32.fromString(sc.keyMap[i]); - } } function funcApproveThunk(ctx: wasmlib.ScFuncContext): void { ctx.log("erc721.funcApprove"); let f = new sc.ApproveContext(); - f.params.mapID = wasmlib.OBJ_ID_PARAMS; - f.state.mapID = wasmlib.OBJ_ID_STATE; ctx.require(f.params.tokenID().exists(), "missing mandatory tokenID"); sc.funcApprove(ctx, f); ctx.log("erc721.funcApprove ok"); @@ -47,8 +42,6 @@ function funcApproveThunk(ctx: wasmlib.ScFuncContext): void { function funcBurnThunk(ctx: wasmlib.ScFuncContext): void { ctx.log("erc721.funcBurn"); let f = new sc.BurnContext(); - f.params.mapID = wasmlib.OBJ_ID_PARAMS; - f.state.mapID = wasmlib.OBJ_ID_STATE; ctx.require(f.params.tokenID().exists(), "missing mandatory tokenID"); sc.funcBurn(ctx, f); ctx.log("erc721.funcBurn ok"); @@ -57,8 +50,6 @@ function funcBurnThunk(ctx: wasmlib.ScFuncContext): void { function funcInitThunk(ctx: wasmlib.ScFuncContext): void { ctx.log("erc721.funcInit"); let f = new sc.InitContext(); - f.params.mapID = wasmlib.OBJ_ID_PARAMS; - f.state.mapID = wasmlib.OBJ_ID_STATE; ctx.require(f.params.name().exists(), "missing mandatory name"); ctx.require(f.params.symbol().exists(), "missing mandatory symbol"); sc.funcInit(ctx, f); @@ -68,8 +59,6 @@ function funcInitThunk(ctx: wasmlib.ScFuncContext): void { function funcMintThunk(ctx: wasmlib.ScFuncContext): void { ctx.log("erc721.funcMint"); let f = new sc.MintContext(); - f.params.mapID = wasmlib.OBJ_ID_PARAMS; - f.state.mapID = wasmlib.OBJ_ID_STATE; ctx.require(f.params.tokenID().exists(), "missing mandatory tokenID"); sc.funcMint(ctx, f); ctx.log("erc721.funcMint ok"); @@ -78,8 +67,6 @@ function funcMintThunk(ctx: wasmlib.ScFuncContext): void { function funcSafeTransferFromThunk(ctx: wasmlib.ScFuncContext): void { ctx.log("erc721.funcSafeTransferFrom"); let f = new sc.SafeTransferFromContext(); - f.params.mapID = wasmlib.OBJ_ID_PARAMS; - f.state.mapID = wasmlib.OBJ_ID_STATE; ctx.require(f.params.from().exists(), "missing mandatory from"); ctx.require(f.params.to().exists(), "missing mandatory to"); ctx.require(f.params.tokenID().exists(), "missing mandatory tokenID"); @@ -90,8 +77,6 @@ function funcSafeTransferFromThunk(ctx: wasmlib.ScFuncContext): void { function funcSetApprovalForAllThunk(ctx: wasmlib.ScFuncContext): void { ctx.log("erc721.funcSetApprovalForAll"); let f = new sc.SetApprovalForAllContext(); - f.params.mapID = wasmlib.OBJ_ID_PARAMS; - f.state.mapID = wasmlib.OBJ_ID_STATE; ctx.require(f.params.approval().exists(), "missing mandatory approval"); ctx.require(f.params.operator().exists(), "missing mandatory operator"); sc.funcSetApprovalForAll(ctx, f); @@ -101,8 +86,6 @@ function funcSetApprovalForAllThunk(ctx: wasmlib.ScFuncContext): void { function funcTransferFromThunk(ctx: wasmlib.ScFuncContext): void { ctx.log("erc721.funcTransferFrom"); let f = new sc.TransferFromContext(); - f.params.mapID = wasmlib.OBJ_ID_PARAMS; - f.state.mapID = wasmlib.OBJ_ID_STATE; ctx.require(f.params.from().exists(), "missing mandatory from"); ctx.require(f.params.to().exists(), "missing mandatory to"); ctx.require(f.params.tokenID().exists(), "missing mandatory tokenID"); @@ -113,73 +96,75 @@ function funcTransferFromThunk(ctx: wasmlib.ScFuncContext): void { function viewBalanceOfThunk(ctx: wasmlib.ScViewContext): void { ctx.log("erc721.viewBalanceOf"); let f = new sc.BalanceOfContext(); - f.params.mapID = wasmlib.OBJ_ID_PARAMS; - f.results.mapID = wasmlib.OBJ_ID_RESULTS; - f.state.mapID = wasmlib.OBJ_ID_STATE; + const results = new wasmlib.ScDict([]); + f.results = new sc.MutableBalanceOfResults(results.asProxy()); ctx.require(f.params.owner().exists(), "missing mandatory owner"); sc.viewBalanceOf(ctx, f); + ctx.results(results); ctx.log("erc721.viewBalanceOf ok"); } function viewGetApprovedThunk(ctx: wasmlib.ScViewContext): void { ctx.log("erc721.viewGetApproved"); let f = new sc.GetApprovedContext(); - f.params.mapID = wasmlib.OBJ_ID_PARAMS; - f.results.mapID = wasmlib.OBJ_ID_RESULTS; - f.state.mapID = wasmlib.OBJ_ID_STATE; + const results = new wasmlib.ScDict([]); + f.results = new sc.MutableGetApprovedResults(results.asProxy()); ctx.require(f.params.tokenID().exists(), "missing mandatory tokenID"); sc.viewGetApproved(ctx, f); + ctx.results(results); ctx.log("erc721.viewGetApproved ok"); } function viewIsApprovedForAllThunk(ctx: wasmlib.ScViewContext): void { ctx.log("erc721.viewIsApprovedForAll"); let f = new sc.IsApprovedForAllContext(); - f.params.mapID = wasmlib.OBJ_ID_PARAMS; - f.results.mapID = wasmlib.OBJ_ID_RESULTS; - f.state.mapID = wasmlib.OBJ_ID_STATE; + const results = new wasmlib.ScDict([]); + f.results = new sc.MutableIsApprovedForAllResults(results.asProxy()); ctx.require(f.params.operator().exists(), "missing mandatory operator"); ctx.require(f.params.owner().exists(), "missing mandatory owner"); sc.viewIsApprovedForAll(ctx, f); + ctx.results(results); ctx.log("erc721.viewIsApprovedForAll ok"); } function viewNameThunk(ctx: wasmlib.ScViewContext): void { ctx.log("erc721.viewName"); let f = new sc.NameContext(); - f.results.mapID = wasmlib.OBJ_ID_RESULTS; - f.state.mapID = wasmlib.OBJ_ID_STATE; + const results = new wasmlib.ScDict([]); + f.results = new sc.MutableNameResults(results.asProxy()); sc.viewName(ctx, f); + ctx.results(results); ctx.log("erc721.viewName ok"); } function viewOwnerOfThunk(ctx: wasmlib.ScViewContext): void { ctx.log("erc721.viewOwnerOf"); let f = new sc.OwnerOfContext(); - f.params.mapID = wasmlib.OBJ_ID_PARAMS; - f.results.mapID = wasmlib.OBJ_ID_RESULTS; - f.state.mapID = wasmlib.OBJ_ID_STATE; + const results = new wasmlib.ScDict([]); + f.results = new sc.MutableOwnerOfResults(results.asProxy()); ctx.require(f.params.tokenID().exists(), "missing mandatory tokenID"); sc.viewOwnerOf(ctx, f); + ctx.results(results); ctx.log("erc721.viewOwnerOf ok"); } function viewSymbolThunk(ctx: wasmlib.ScViewContext): void { ctx.log("erc721.viewSymbol"); let f = new sc.SymbolContext(); - f.results.mapID = wasmlib.OBJ_ID_RESULTS; - f.state.mapID = wasmlib.OBJ_ID_STATE; + const results = new wasmlib.ScDict([]); + f.results = new sc.MutableSymbolResults(results.asProxy()); sc.viewSymbol(ctx, f); + ctx.results(results); ctx.log("erc721.viewSymbol ok"); } function viewTokenURIThunk(ctx: wasmlib.ScViewContext): void { ctx.log("erc721.viewTokenURI"); let f = new sc.TokenURIContext(); - f.params.mapID = wasmlib.OBJ_ID_PARAMS; - f.results.mapID = wasmlib.OBJ_ID_RESULTS; - f.state.mapID = wasmlib.OBJ_ID_STATE; + const results = new wasmlib.ScDict([]); + f.results = new sc.MutableTokenURIResults(results.asProxy()); ctx.require(f.params.tokenID().exists(), "missing mandatory tokenID"); sc.viewTokenURI(ctx, f); + ctx.results(results); ctx.log("erc721.viewTokenURI ok"); } diff --git a/contracts/wasm/erc721/ts/erc721/params.ts b/contracts/wasm/erc721/ts/erc721/params.ts index 509be4795f..436b9d3c76 100644 --- a/contracts/wasm/erc721/ts/erc721/params.ts +++ b/contracts/wasm/erc721/ts/erc721/params.ts @@ -6,228 +6,229 @@ // Change the json schema instead import * as wasmlib from "wasmlib"; +import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; -export class ImmutableApproveParams extends wasmlib.ScMapID { - approved(): wasmlib.ScImmutableAgentID { - return new wasmlib.ScImmutableAgentID(this.mapID, wasmlib.Key32.fromString(sc.ParamApproved)); +export class ImmutableApproveParams extends wasmtypes.ScProxy { + approved(): wasmtypes.ScImmutableAgentID { + return new wasmtypes.ScImmutableAgentID(this.proxy.root(sc.ParamApproved)); } - tokenID(): wasmlib.ScImmutableHash { - return new wasmlib.ScImmutableHash(this.mapID, wasmlib.Key32.fromString(sc.ParamTokenID)); + tokenID(): wasmtypes.ScImmutableHash { + return new wasmtypes.ScImmutableHash(this.proxy.root(sc.ParamTokenID)); } } -export class MutableApproveParams extends wasmlib.ScMapID { - approved(): wasmlib.ScMutableAgentID { - return new wasmlib.ScMutableAgentID(this.mapID, wasmlib.Key32.fromString(sc.ParamApproved)); +export class MutableApproveParams extends wasmtypes.ScProxy { + approved(): wasmtypes.ScMutableAgentID { + return new wasmtypes.ScMutableAgentID(this.proxy.root(sc.ParamApproved)); } - tokenID(): wasmlib.ScMutableHash { - return new wasmlib.ScMutableHash(this.mapID, wasmlib.Key32.fromString(sc.ParamTokenID)); + tokenID(): wasmtypes.ScMutableHash { + return new wasmtypes.ScMutableHash(this.proxy.root(sc.ParamTokenID)); } } -export class ImmutableBurnParams extends wasmlib.ScMapID { - tokenID(): wasmlib.ScImmutableHash { - return new wasmlib.ScImmutableHash(this.mapID, wasmlib.Key32.fromString(sc.ParamTokenID)); +export class ImmutableBurnParams extends wasmtypes.ScProxy { + tokenID(): wasmtypes.ScImmutableHash { + return new wasmtypes.ScImmutableHash(this.proxy.root(sc.ParamTokenID)); } } -export class MutableBurnParams extends wasmlib.ScMapID { - tokenID(): wasmlib.ScMutableHash { - return new wasmlib.ScMutableHash(this.mapID, wasmlib.Key32.fromString(sc.ParamTokenID)); +export class MutableBurnParams extends wasmtypes.ScProxy { + tokenID(): wasmtypes.ScMutableHash { + return new wasmtypes.ScMutableHash(this.proxy.root(sc.ParamTokenID)); } } -export class ImmutableInitParams extends wasmlib.ScMapID { - name(): wasmlib.ScImmutableString { - return new wasmlib.ScImmutableString(this.mapID, sc.idxMap[sc.IdxParamName]); +export class ImmutableInitParams extends wasmtypes.ScProxy { + name(): wasmtypes.ScImmutableString { + return new wasmtypes.ScImmutableString(this.proxy.root(sc.ParamName)); } - symbol(): wasmlib.ScImmutableString { - return new wasmlib.ScImmutableString(this.mapID, sc.idxMap[sc.IdxParamSymbol]); + symbol(): wasmtypes.ScImmutableString { + return new wasmtypes.ScImmutableString(this.proxy.root(sc.ParamSymbol)); } } -export class MutableInitParams extends wasmlib.ScMapID { - name(): wasmlib.ScMutableString { - return new wasmlib.ScMutableString(this.mapID, sc.idxMap[sc.IdxParamName]); +export class MutableInitParams extends wasmtypes.ScProxy { + name(): wasmtypes.ScMutableString { + return new wasmtypes.ScMutableString(this.proxy.root(sc.ParamName)); } - symbol(): wasmlib.ScMutableString { - return new wasmlib.ScMutableString(this.mapID, sc.idxMap[sc.IdxParamSymbol]); + symbol(): wasmtypes.ScMutableString { + return new wasmtypes.ScMutableString(this.proxy.root(sc.ParamSymbol)); } } -export class ImmutableMintParams extends wasmlib.ScMapID { - tokenID(): wasmlib.ScImmutableHash { - return new wasmlib.ScImmutableHash(this.mapID, wasmlib.Key32.fromString(sc.ParamTokenID)); +export class ImmutableMintParams extends wasmtypes.ScProxy { + tokenID(): wasmtypes.ScImmutableHash { + return new wasmtypes.ScImmutableHash(this.proxy.root(sc.ParamTokenID)); } - tokenURI(): wasmlib.ScImmutableString { - return new wasmlib.ScImmutableString(this.mapID, wasmlib.Key32.fromString(sc.ParamTokenURI)); + tokenURI(): wasmtypes.ScImmutableString { + return new wasmtypes.ScImmutableString(this.proxy.root(sc.ParamTokenURI)); } } -export class MutableMintParams extends wasmlib.ScMapID { - tokenID(): wasmlib.ScMutableHash { - return new wasmlib.ScMutableHash(this.mapID, wasmlib.Key32.fromString(sc.ParamTokenID)); +export class MutableMintParams extends wasmtypes.ScProxy { + tokenID(): wasmtypes.ScMutableHash { + return new wasmtypes.ScMutableHash(this.proxy.root(sc.ParamTokenID)); } - tokenURI(): wasmlib.ScMutableString { - return new wasmlib.ScMutableString(this.mapID, wasmlib.Key32.fromString(sc.ParamTokenURI)); + tokenURI(): wasmtypes.ScMutableString { + return new wasmtypes.ScMutableString(this.proxy.root(sc.ParamTokenURI)); } } -export class ImmutableSafeTransferFromParams extends wasmlib.ScMapID { - data(): wasmlib.ScImmutableBytes { - return new wasmlib.ScImmutableBytes(this.mapID, wasmlib.Key32.fromString(sc.ParamData)); +export class ImmutableSafeTransferFromParams extends wasmtypes.ScProxy { + data(): wasmtypes.ScImmutableBytes { + return new wasmtypes.ScImmutableBytes(this.proxy.root(sc.ParamData)); } - from(): wasmlib.ScImmutableAgentID { - return new wasmlib.ScImmutableAgentID(this.mapID, wasmlib.Key32.fromString(sc.ParamFrom)); + from(): wasmtypes.ScImmutableAgentID { + return new wasmtypes.ScImmutableAgentID(this.proxy.root(sc.ParamFrom)); } - to(): wasmlib.ScImmutableAgentID { - return new wasmlib.ScImmutableAgentID(this.mapID, wasmlib.Key32.fromString(sc.ParamTo)); + to(): wasmtypes.ScImmutableAgentID { + return new wasmtypes.ScImmutableAgentID(this.proxy.root(sc.ParamTo)); } - tokenID(): wasmlib.ScImmutableHash { - return new wasmlib.ScImmutableHash(this.mapID, wasmlib.Key32.fromString(sc.ParamTokenID)); + tokenID(): wasmtypes.ScImmutableHash { + return new wasmtypes.ScImmutableHash(this.proxy.root(sc.ParamTokenID)); } } -export class MutableSafeTransferFromParams extends wasmlib.ScMapID { - data(): wasmlib.ScMutableBytes { - return new wasmlib.ScMutableBytes(this.mapID, wasmlib.Key32.fromString(sc.ParamData)); +export class MutableSafeTransferFromParams extends wasmtypes.ScProxy { + data(): wasmtypes.ScMutableBytes { + return new wasmtypes.ScMutableBytes(this.proxy.root(sc.ParamData)); } - from(): wasmlib.ScMutableAgentID { - return new wasmlib.ScMutableAgentID(this.mapID, wasmlib.Key32.fromString(sc.ParamFrom)); + from(): wasmtypes.ScMutableAgentID { + return new wasmtypes.ScMutableAgentID(this.proxy.root(sc.ParamFrom)); } - to(): wasmlib.ScMutableAgentID { - return new wasmlib.ScMutableAgentID(this.mapID, wasmlib.Key32.fromString(sc.ParamTo)); + to(): wasmtypes.ScMutableAgentID { + return new wasmtypes.ScMutableAgentID(this.proxy.root(sc.ParamTo)); } - tokenID(): wasmlib.ScMutableHash { - return new wasmlib.ScMutableHash(this.mapID, wasmlib.Key32.fromString(sc.ParamTokenID)); + tokenID(): wasmtypes.ScMutableHash { + return new wasmtypes.ScMutableHash(this.proxy.root(sc.ParamTokenID)); } } -export class ImmutableSetApprovalForAllParams extends wasmlib.ScMapID { - approval(): wasmlib.ScImmutableBool { - return new wasmlib.ScImmutableBool(this.mapID, wasmlib.Key32.fromString(sc.ParamApproval)); +export class ImmutableSetApprovalForAllParams extends wasmtypes.ScProxy { + approval(): wasmtypes.ScImmutableBool { + return new wasmtypes.ScImmutableBool(this.proxy.root(sc.ParamApproval)); } - operator(): wasmlib.ScImmutableAgentID { - return new wasmlib.ScImmutableAgentID(this.mapID, wasmlib.Key32.fromString(sc.ParamOperator)); + operator(): wasmtypes.ScImmutableAgentID { + return new wasmtypes.ScImmutableAgentID(this.proxy.root(sc.ParamOperator)); } } -export class MutableSetApprovalForAllParams extends wasmlib.ScMapID { - approval(): wasmlib.ScMutableBool { - return new wasmlib.ScMutableBool(this.mapID, wasmlib.Key32.fromString(sc.ParamApproval)); +export class MutableSetApprovalForAllParams extends wasmtypes.ScProxy { + approval(): wasmtypes.ScMutableBool { + return new wasmtypes.ScMutableBool(this.proxy.root(sc.ParamApproval)); } - operator(): wasmlib.ScMutableAgentID { - return new wasmlib.ScMutableAgentID(this.mapID, wasmlib.Key32.fromString(sc.ParamOperator)); + operator(): wasmtypes.ScMutableAgentID { + return new wasmtypes.ScMutableAgentID(this.proxy.root(sc.ParamOperator)); } } -export class ImmutableTransferFromParams extends wasmlib.ScMapID { - from(): wasmlib.ScImmutableAgentID { - return new wasmlib.ScImmutableAgentID(this.mapID, wasmlib.Key32.fromString(sc.ParamFrom)); +export class ImmutableTransferFromParams extends wasmtypes.ScProxy { + from(): wasmtypes.ScImmutableAgentID { + return new wasmtypes.ScImmutableAgentID(this.proxy.root(sc.ParamFrom)); } - to(): wasmlib.ScImmutableAgentID { - return new wasmlib.ScImmutableAgentID(this.mapID, wasmlib.Key32.fromString(sc.ParamTo)); + to(): wasmtypes.ScImmutableAgentID { + return new wasmtypes.ScImmutableAgentID(this.proxy.root(sc.ParamTo)); } - tokenID(): wasmlib.ScImmutableHash { - return new wasmlib.ScImmutableHash(this.mapID, wasmlib.Key32.fromString(sc.ParamTokenID)); + tokenID(): wasmtypes.ScImmutableHash { + return new wasmtypes.ScImmutableHash(this.proxy.root(sc.ParamTokenID)); } } -export class MutableTransferFromParams extends wasmlib.ScMapID { - from(): wasmlib.ScMutableAgentID { - return new wasmlib.ScMutableAgentID(this.mapID, wasmlib.Key32.fromString(sc.ParamFrom)); +export class MutableTransferFromParams extends wasmtypes.ScProxy { + from(): wasmtypes.ScMutableAgentID { + return new wasmtypes.ScMutableAgentID(this.proxy.root(sc.ParamFrom)); } - to(): wasmlib.ScMutableAgentID { - return new wasmlib.ScMutableAgentID(this.mapID, wasmlib.Key32.fromString(sc.ParamTo)); + to(): wasmtypes.ScMutableAgentID { + return new wasmtypes.ScMutableAgentID(this.proxy.root(sc.ParamTo)); } - tokenID(): wasmlib.ScMutableHash { - return new wasmlib.ScMutableHash(this.mapID, wasmlib.Key32.fromString(sc.ParamTokenID)); + tokenID(): wasmtypes.ScMutableHash { + return new wasmtypes.ScMutableHash(this.proxy.root(sc.ParamTokenID)); } } -export class ImmutableBalanceOfParams extends wasmlib.ScMapID { - owner(): wasmlib.ScImmutableAgentID { - return new wasmlib.ScImmutableAgentID(this.mapID, wasmlib.Key32.fromString(sc.ParamOwner)); +export class ImmutableBalanceOfParams extends wasmtypes.ScProxy { + owner(): wasmtypes.ScImmutableAgentID { + return new wasmtypes.ScImmutableAgentID(this.proxy.root(sc.ParamOwner)); } } -export class MutableBalanceOfParams extends wasmlib.ScMapID { - owner(): wasmlib.ScMutableAgentID { - return new wasmlib.ScMutableAgentID(this.mapID, wasmlib.Key32.fromString(sc.ParamOwner)); +export class MutableBalanceOfParams extends wasmtypes.ScProxy { + owner(): wasmtypes.ScMutableAgentID { + return new wasmtypes.ScMutableAgentID(this.proxy.root(sc.ParamOwner)); } } -export class ImmutableGetApprovedParams extends wasmlib.ScMapID { - tokenID(): wasmlib.ScImmutableHash { - return new wasmlib.ScImmutableHash(this.mapID, wasmlib.Key32.fromString(sc.ParamTokenID)); +export class ImmutableGetApprovedParams extends wasmtypes.ScProxy { + tokenID(): wasmtypes.ScImmutableHash { + return new wasmtypes.ScImmutableHash(this.proxy.root(sc.ParamTokenID)); } } -export class MutableGetApprovedParams extends wasmlib.ScMapID { - tokenID(): wasmlib.ScMutableHash { - return new wasmlib.ScMutableHash(this.mapID, wasmlib.Key32.fromString(sc.ParamTokenID)); +export class MutableGetApprovedParams extends wasmtypes.ScProxy { + tokenID(): wasmtypes.ScMutableHash { + return new wasmtypes.ScMutableHash(this.proxy.root(sc.ParamTokenID)); } } -export class ImmutableIsApprovedForAllParams extends wasmlib.ScMapID { - operator(): wasmlib.ScImmutableAgentID { - return new wasmlib.ScImmutableAgentID(this.mapID, wasmlib.Key32.fromString(sc.ParamOperator)); +export class ImmutableIsApprovedForAllParams extends wasmtypes.ScProxy { + operator(): wasmtypes.ScImmutableAgentID { + return new wasmtypes.ScImmutableAgentID(this.proxy.root(sc.ParamOperator)); } - owner(): wasmlib.ScImmutableAgentID { - return new wasmlib.ScImmutableAgentID(this.mapID, wasmlib.Key32.fromString(sc.ParamOwner)); + owner(): wasmtypes.ScImmutableAgentID { + return new wasmtypes.ScImmutableAgentID(this.proxy.root(sc.ParamOwner)); } } -export class MutableIsApprovedForAllParams extends wasmlib.ScMapID { - operator(): wasmlib.ScMutableAgentID { - return new wasmlib.ScMutableAgentID(this.mapID, wasmlib.Key32.fromString(sc.ParamOperator)); +export class MutableIsApprovedForAllParams extends wasmtypes.ScProxy { + operator(): wasmtypes.ScMutableAgentID { + return new wasmtypes.ScMutableAgentID(this.proxy.root(sc.ParamOperator)); } - owner(): wasmlib.ScMutableAgentID { - return new wasmlib.ScMutableAgentID(this.mapID, wasmlib.Key32.fromString(sc.ParamOwner)); + owner(): wasmtypes.ScMutableAgentID { + return new wasmtypes.ScMutableAgentID(this.proxy.root(sc.ParamOwner)); } } -export class ImmutableOwnerOfParams extends wasmlib.ScMapID { - tokenID(): wasmlib.ScImmutableHash { - return new wasmlib.ScImmutableHash(this.mapID, wasmlib.Key32.fromString(sc.ParamTokenID)); +export class ImmutableOwnerOfParams extends wasmtypes.ScProxy { + tokenID(): wasmtypes.ScImmutableHash { + return new wasmtypes.ScImmutableHash(this.proxy.root(sc.ParamTokenID)); } } -export class MutableOwnerOfParams extends wasmlib.ScMapID { - tokenID(): wasmlib.ScMutableHash { - return new wasmlib.ScMutableHash(this.mapID, wasmlib.Key32.fromString(sc.ParamTokenID)); +export class MutableOwnerOfParams extends wasmtypes.ScProxy { + tokenID(): wasmtypes.ScMutableHash { + return new wasmtypes.ScMutableHash(this.proxy.root(sc.ParamTokenID)); } } -export class ImmutableTokenURIParams extends wasmlib.ScMapID { - tokenID(): wasmlib.ScImmutableHash { - return new wasmlib.ScImmutableHash(this.mapID, wasmlib.Key32.fromString(sc.ParamTokenID)); +export class ImmutableTokenURIParams extends wasmtypes.ScProxy { + tokenID(): wasmtypes.ScImmutableHash { + return new wasmtypes.ScImmutableHash(this.proxy.root(sc.ParamTokenID)); } } -export class MutableTokenURIParams extends wasmlib.ScMapID { - tokenID(): wasmlib.ScMutableHash { - return new wasmlib.ScMutableHash(this.mapID, wasmlib.Key32.fromString(sc.ParamTokenID)); +export class MutableTokenURIParams extends wasmtypes.ScProxy { + tokenID(): wasmtypes.ScMutableHash { + return new wasmtypes.ScMutableHash(this.proxy.root(sc.ParamTokenID)); } } diff --git a/contracts/wasm/erc721/ts/erc721/results.ts b/contracts/wasm/erc721/ts/erc721/results.ts index 30edca4097..dc29deb69c 100644 --- a/contracts/wasm/erc721/ts/erc721/results.ts +++ b/contracts/wasm/erc721/ts/erc721/results.ts @@ -6,88 +6,89 @@ // Change the json schema instead import * as wasmlib from "wasmlib"; +import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; -export class ImmutableBalanceOfResults extends wasmlib.ScMapID { - amount(): wasmlib.ScImmutableUint64 { - return new wasmlib.ScImmutableUint64(this.mapID, wasmlib.Key32.fromString(sc.ResultAmount)); +export class ImmutableBalanceOfResults extends wasmtypes.ScProxy { + amount(): wasmtypes.ScImmutableUint64 { + return new wasmtypes.ScImmutableUint64(this.proxy.root(sc.ResultAmount)); } } -export class MutableBalanceOfResults extends wasmlib.ScMapID { - amount(): wasmlib.ScMutableUint64 { - return new wasmlib.ScMutableUint64(this.mapID, wasmlib.Key32.fromString(sc.ResultAmount)); +export class MutableBalanceOfResults extends wasmtypes.ScProxy { + amount(): wasmtypes.ScMutableUint64 { + return new wasmtypes.ScMutableUint64(this.proxy.root(sc.ResultAmount)); } } -export class ImmutableGetApprovedResults extends wasmlib.ScMapID { - approved(): wasmlib.ScImmutableAgentID { - return new wasmlib.ScImmutableAgentID(this.mapID, wasmlib.Key32.fromString(sc.ResultApproved)); +export class ImmutableGetApprovedResults extends wasmtypes.ScProxy { + approved(): wasmtypes.ScImmutableAgentID { + return new wasmtypes.ScImmutableAgentID(this.proxy.root(sc.ResultApproved)); } } -export class MutableGetApprovedResults extends wasmlib.ScMapID { - approved(): wasmlib.ScMutableAgentID { - return new wasmlib.ScMutableAgentID(this.mapID, wasmlib.Key32.fromString(sc.ResultApproved)); +export class MutableGetApprovedResults extends wasmtypes.ScProxy { + approved(): wasmtypes.ScMutableAgentID { + return new wasmtypes.ScMutableAgentID(this.proxy.root(sc.ResultApproved)); } } -export class ImmutableIsApprovedForAllResults extends wasmlib.ScMapID { - approval(): wasmlib.ScImmutableBool { - return new wasmlib.ScImmutableBool(this.mapID, wasmlib.Key32.fromString(sc.ResultApproval)); +export class ImmutableIsApprovedForAllResults extends wasmtypes.ScProxy { + approval(): wasmtypes.ScImmutableBool { + return new wasmtypes.ScImmutableBool(this.proxy.root(sc.ResultApproval)); } } -export class MutableIsApprovedForAllResults extends wasmlib.ScMapID { - approval(): wasmlib.ScMutableBool { - return new wasmlib.ScMutableBool(this.mapID, wasmlib.Key32.fromString(sc.ResultApproval)); +export class MutableIsApprovedForAllResults extends wasmtypes.ScProxy { + approval(): wasmtypes.ScMutableBool { + return new wasmtypes.ScMutableBool(this.proxy.root(sc.ResultApproval)); } } -export class ImmutableNameResults extends wasmlib.ScMapID { - name(): wasmlib.ScImmutableString { - return new wasmlib.ScImmutableString(this.mapID, wasmlib.Key32.fromString(sc.ResultName)); +export class ImmutableNameResults extends wasmtypes.ScProxy { + name(): wasmtypes.ScImmutableString { + return new wasmtypes.ScImmutableString(this.proxy.root(sc.ResultName)); } } -export class MutableNameResults extends wasmlib.ScMapID { - name(): wasmlib.ScMutableString { - return new wasmlib.ScMutableString(this.mapID, wasmlib.Key32.fromString(sc.ResultName)); +export class MutableNameResults extends wasmtypes.ScProxy { + name(): wasmtypes.ScMutableString { + return new wasmtypes.ScMutableString(this.proxy.root(sc.ResultName)); } } -export class ImmutableOwnerOfResults extends wasmlib.ScMapID { - owner(): wasmlib.ScImmutableAgentID { - return new wasmlib.ScImmutableAgentID(this.mapID, wasmlib.Key32.fromString(sc.ResultOwner)); +export class ImmutableOwnerOfResults extends wasmtypes.ScProxy { + owner(): wasmtypes.ScImmutableAgentID { + return new wasmtypes.ScImmutableAgentID(this.proxy.root(sc.ResultOwner)); } } -export class MutableOwnerOfResults extends wasmlib.ScMapID { - owner(): wasmlib.ScMutableAgentID { - return new wasmlib.ScMutableAgentID(this.mapID, wasmlib.Key32.fromString(sc.ResultOwner)); +export class MutableOwnerOfResults extends wasmtypes.ScProxy { + owner(): wasmtypes.ScMutableAgentID { + return new wasmtypes.ScMutableAgentID(this.proxy.root(sc.ResultOwner)); } } -export class ImmutableSymbolResults extends wasmlib.ScMapID { - symbol(): wasmlib.ScImmutableString { - return new wasmlib.ScImmutableString(this.mapID, wasmlib.Key32.fromString(sc.ResultSymbol)); +export class ImmutableSymbolResults extends wasmtypes.ScProxy { + symbol(): wasmtypes.ScImmutableString { + return new wasmtypes.ScImmutableString(this.proxy.root(sc.ResultSymbol)); } } -export class MutableSymbolResults extends wasmlib.ScMapID { - symbol(): wasmlib.ScMutableString { - return new wasmlib.ScMutableString(this.mapID, wasmlib.Key32.fromString(sc.ResultSymbol)); +export class MutableSymbolResults extends wasmtypes.ScProxy { + symbol(): wasmtypes.ScMutableString { + return new wasmtypes.ScMutableString(this.proxy.root(sc.ResultSymbol)); } } -export class ImmutableTokenURIResults extends wasmlib.ScMapID { - tokenURI(): wasmlib.ScImmutableString { - return new wasmlib.ScImmutableString(this.mapID, wasmlib.Key32.fromString(sc.ResultTokenURI)); +export class ImmutableTokenURIResults extends wasmtypes.ScProxy { + tokenURI(): wasmtypes.ScImmutableString { + return new wasmtypes.ScImmutableString(this.proxy.root(sc.ResultTokenURI)); } } -export class MutableTokenURIResults extends wasmlib.ScMapID { - tokenURI(): wasmlib.ScMutableString { - return new wasmlib.ScMutableString(this.mapID, wasmlib.Key32.fromString(sc.ResultTokenURI)); +export class MutableTokenURIResults extends wasmtypes.ScProxy { + tokenURI(): wasmtypes.ScMutableString { + return new wasmtypes.ScMutableString(this.proxy.root(sc.ResultTokenURI)); } } diff --git a/contracts/wasm/erc721/ts/erc721/state.ts b/contracts/wasm/erc721/ts/erc721/state.ts index b16ed14851..c92539f251 100644 --- a/contracts/wasm/erc721/ts/erc721/state.ts +++ b/contracts/wasm/erc721/ts/erc721/state.ts @@ -6,194 +6,141 @@ // Change the json schema instead import * as wasmlib from "wasmlib"; +import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; -export class MapHashToImmutableAgentID { - objID: i32; +export class MapHashToImmutableAgentID extends wasmtypes.ScProxy { - constructor(objID: i32) { - this.objID = objID; - } - - getAgentID(key: wasmlib.ScHash): wasmlib.ScImmutableAgentID { - return new wasmlib.ScImmutableAgentID(this.objID, key.getKeyID()); + getAgentID(key: wasmtypes.ScHash): wasmtypes.ScImmutableAgentID { + return new wasmtypes.ScImmutableAgentID(this.proxy.key(wasmtypes.hashToBytes(key))); } } -export class MapAgentIDToImmutableOperators { - objID: i32; - - constructor(objID: i32) { - this.objID = objID; - } +export class MapAgentIDToImmutableOperators extends wasmtypes.ScProxy { - getOperators(key: wasmlib.ScAgentID): sc.ImmutableOperators { - let subID = wasmlib.getObjectID(this.objID, key.getKeyID(), wasmlib.TYPE_MAP); - return new sc.ImmutableOperators(subID); + getOperators(key: wasmtypes.ScAgentID): sc.ImmutableOperators { + return new sc.ImmutableOperators(this.proxy.key(wasmtypes.agentIDToBytes(key))); } } -export class MapAgentIDToImmutableUint64 { - objID: i32; +export class MapAgentIDToImmutableUint64 extends wasmtypes.ScProxy { - constructor(objID: i32) { - this.objID = objID; - } - - getUint64(key: wasmlib.ScAgentID): wasmlib.ScImmutableUint64 { - return new wasmlib.ScImmutableUint64(this.objID, key.getKeyID()); + getUint64(key: wasmtypes.ScAgentID): wasmtypes.ScImmutableUint64 { + return new wasmtypes.ScImmutableUint64(this.proxy.key(wasmtypes.agentIDToBytes(key))); } } -export class MapHashToImmutableString { - objID: i32; - - constructor(objID: i32) { - this.objID = objID; - } +export class MapHashToImmutableString extends wasmtypes.ScProxy { - getString(key: wasmlib.ScHash): wasmlib.ScImmutableString { - return new wasmlib.ScImmutableString(this.objID, key.getKeyID()); + getString(key: wasmtypes.ScHash): wasmtypes.ScImmutableString { + return new wasmtypes.ScImmutableString(this.proxy.key(wasmtypes.hashToBytes(key))); } } -export class ImmutableErc721State extends wasmlib.ScMapID { +export class ImmutableErc721State extends wasmtypes.ScProxy { approvedAccounts(): sc.MapHashToImmutableAgentID { - let mapID = wasmlib.getObjectID(this.mapID, wasmlib.Key32.fromString(sc.StateApprovedAccounts), wasmlib.TYPE_MAP); - return new sc.MapHashToImmutableAgentID(mapID); + return new sc.MapHashToImmutableAgentID(this.proxy.root(sc.StateApprovedAccounts)); } approvedOperators(): sc.MapAgentIDToImmutableOperators { - let mapID = wasmlib.getObjectID(this.mapID, wasmlib.Key32.fromString(sc.StateApprovedOperators), wasmlib.TYPE_MAP); - return new sc.MapAgentIDToImmutableOperators(mapID); + return new sc.MapAgentIDToImmutableOperators(this.proxy.root(sc.StateApprovedOperators)); } balances(): sc.MapAgentIDToImmutableUint64 { - let mapID = wasmlib.getObjectID(this.mapID, wasmlib.Key32.fromString(sc.StateBalances), wasmlib.TYPE_MAP); - return new sc.MapAgentIDToImmutableUint64(mapID); + return new sc.MapAgentIDToImmutableUint64(this.proxy.root(sc.StateBalances)); } - name(): wasmlib.ScImmutableString { - return new wasmlib.ScImmutableString(this.mapID, wasmlib.Key32.fromString(sc.StateName)); + name(): wasmtypes.ScImmutableString { + return new wasmtypes.ScImmutableString(this.proxy.root(sc.StateName)); } owners(): sc.MapHashToImmutableAgentID { - let mapID = wasmlib.getObjectID(this.mapID, wasmlib.Key32.fromString(sc.StateOwners), wasmlib.TYPE_MAP); - return new sc.MapHashToImmutableAgentID(mapID); + return new sc.MapHashToImmutableAgentID(this.proxy.root(sc.StateOwners)); } - symbol(): wasmlib.ScImmutableString { - return new wasmlib.ScImmutableString(this.mapID, wasmlib.Key32.fromString(sc.StateSymbol)); + symbol(): wasmtypes.ScImmutableString { + return new wasmtypes.ScImmutableString(this.proxy.root(sc.StateSymbol)); } tokenURIs(): sc.MapHashToImmutableString { - let mapID = wasmlib.getObjectID(this.mapID, wasmlib.Key32.fromString(sc.StateTokenURIs), wasmlib.TYPE_MAP); - return new sc.MapHashToImmutableString(mapID); + return new sc.MapHashToImmutableString(this.proxy.root(sc.StateTokenURIs)); } } -export class MapHashToMutableAgentID { - objID: i32; - - constructor(objID: i32) { - this.objID = objID; - } +export class MapHashToMutableAgentID extends wasmtypes.ScProxy { clear(): void { - wasmlib.clear(this.objID); + this.proxy.clearMap(); } - getAgentID(key: wasmlib.ScHash): wasmlib.ScMutableAgentID { - return new wasmlib.ScMutableAgentID(this.objID, key.getKeyID()); + getAgentID(key: wasmtypes.ScHash): wasmtypes.ScMutableAgentID { + return new wasmtypes.ScMutableAgentID(this.proxy.key(wasmtypes.hashToBytes(key))); } } -export class MapAgentIDToMutableOperators { - objID: i32; - - constructor(objID: i32) { - this.objID = objID; - } +export class MapAgentIDToMutableOperators extends wasmtypes.ScProxy { clear(): void { - wasmlib.clear(this.objID); + this.proxy.clearMap(); } - getOperators(key: wasmlib.ScAgentID): sc.MutableOperators { - let subID = wasmlib.getObjectID(this.objID, key.getKeyID(), wasmlib.TYPE_MAP); - return new sc.MutableOperators(subID); + getOperators(key: wasmtypes.ScAgentID): sc.MutableOperators { + return new sc.MutableOperators(this.proxy.key(wasmtypes.agentIDToBytes(key))); } } -export class MapAgentIDToMutableUint64 { - objID: i32; - - constructor(objID: i32) { - this.objID = objID; - } +export class MapAgentIDToMutableUint64 extends wasmtypes.ScProxy { clear(): void { - wasmlib.clear(this.objID); + this.proxy.clearMap(); } - getUint64(key: wasmlib.ScAgentID): wasmlib.ScMutableUint64 { - return new wasmlib.ScMutableUint64(this.objID, key.getKeyID()); + getUint64(key: wasmtypes.ScAgentID): wasmtypes.ScMutableUint64 { + return new wasmtypes.ScMutableUint64(this.proxy.key(wasmtypes.agentIDToBytes(key))); } } -export class MapHashToMutableString { - objID: i32; - - constructor(objID: i32) { - this.objID = objID; - } +export class MapHashToMutableString extends wasmtypes.ScProxy { clear(): void { - wasmlib.clear(this.objID); + this.proxy.clearMap(); } - getString(key: wasmlib.ScHash): wasmlib.ScMutableString { - return new wasmlib.ScMutableString(this.objID, key.getKeyID()); + getString(key: wasmtypes.ScHash): wasmtypes.ScMutableString { + return new wasmtypes.ScMutableString(this.proxy.key(wasmtypes.hashToBytes(key))); } } -export class MutableErc721State extends wasmlib.ScMapID { +export class MutableErc721State extends wasmtypes.ScProxy { asImmutable(): sc.ImmutableErc721State { - const imm = new sc.ImmutableErc721State(); - imm.mapID = this.mapID; - return imm; + return new sc.ImmutableErc721State(this.proxy); } approvedAccounts(): sc.MapHashToMutableAgentID { - let mapID = wasmlib.getObjectID(this.mapID, wasmlib.Key32.fromString(sc.StateApprovedAccounts), wasmlib.TYPE_MAP); - return new sc.MapHashToMutableAgentID(mapID); + return new sc.MapHashToMutableAgentID(this.proxy.root(sc.StateApprovedAccounts)); } approvedOperators(): sc.MapAgentIDToMutableOperators { - let mapID = wasmlib.getObjectID(this.mapID, wasmlib.Key32.fromString(sc.StateApprovedOperators), wasmlib.TYPE_MAP); - return new sc.MapAgentIDToMutableOperators(mapID); + return new sc.MapAgentIDToMutableOperators(this.proxy.root(sc.StateApprovedOperators)); } balances(): sc.MapAgentIDToMutableUint64 { - let mapID = wasmlib.getObjectID(this.mapID, wasmlib.Key32.fromString(sc.StateBalances), wasmlib.TYPE_MAP); - return new sc.MapAgentIDToMutableUint64(mapID); + return new sc.MapAgentIDToMutableUint64(this.proxy.root(sc.StateBalances)); } - name(): wasmlib.ScMutableString { - return new wasmlib.ScMutableString(this.mapID, wasmlib.Key32.fromString(sc.StateName)); + name(): wasmtypes.ScMutableString { + return new wasmtypes.ScMutableString(this.proxy.root(sc.StateName)); } owners(): sc.MapHashToMutableAgentID { - let mapID = wasmlib.getObjectID(this.mapID, wasmlib.Key32.fromString(sc.StateOwners), wasmlib.TYPE_MAP); - return new sc.MapHashToMutableAgentID(mapID); + return new sc.MapHashToMutableAgentID(this.proxy.root(sc.StateOwners)); } - symbol(): wasmlib.ScMutableString { - return new wasmlib.ScMutableString(this.mapID, wasmlib.Key32.fromString(sc.StateSymbol)); + symbol(): wasmtypes.ScMutableString { + return new wasmtypes.ScMutableString(this.proxy.root(sc.StateSymbol)); } tokenURIs(): sc.MapHashToMutableString { - let mapID = wasmlib.getObjectID(this.mapID, wasmlib.Key32.fromString(sc.StateTokenURIs), wasmlib.TYPE_MAP); - return new sc.MapHashToMutableString(mapID); + return new sc.MapHashToMutableString(this.proxy.root(sc.StateTokenURIs)); } } diff --git a/contracts/wasm/erc721/ts/erc721/typedefs.ts b/contracts/wasm/erc721/ts/erc721/typedefs.ts index a058931ce3..8248b4511f 100644 --- a/contracts/wasm/erc721/ts/erc721/typedefs.ts +++ b/contracts/wasm/erc721/ts/erc721/typedefs.ts @@ -6,36 +6,27 @@ // Change the json schema instead import * as wasmlib from "wasmlib"; +import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; -export class MapAgentIDToImmutableBool { - objID: i32; +export class MapAgentIDToImmutableBool extends wasmtypes.ScProxy { - constructor(objID: i32) { - this.objID = objID; - } - - getBool(key: wasmlib.ScAgentID): wasmlib.ScImmutableBool { - return new wasmlib.ScImmutableBool(this.objID, key.getKeyID()); + getBool(key: wasmtypes.ScAgentID): wasmtypes.ScImmutableBool { + return new wasmtypes.ScImmutableBool(this.proxy.key(wasmtypes.agentIDToBytes(key))); } } export class ImmutableOperators extends MapAgentIDToImmutableBool { }; -export class MapAgentIDToMutableBool { - objID: i32; - - constructor(objID: i32) { - this.objID = objID; - } +export class MapAgentIDToMutableBool extends wasmtypes.ScProxy { clear(): void { - wasmlib.clear(this.objID); + this.proxy.clearMap(); } - getBool(key: wasmlib.ScAgentID): wasmlib.ScMutableBool { - return new wasmlib.ScMutableBool(this.objID, key.getKeyID()); + getBool(key: wasmtypes.ScAgentID): wasmtypes.ScMutableBool { + return new wasmtypes.ScMutableBool(this.proxy.key(wasmtypes.agentIDToBytes(key))); } } diff --git a/contracts/wasm/fairauction/go/fairauction/lib.go b/contracts/wasm/fairauction/go/fairauction/lib.go index b9ca55aa13..0afb488d54 100644 --- a/contracts/wasm/fairauction/go/fairauction/lib.go +++ b/contracts/wasm/fairauction/go/fairauction/lib.go @@ -129,6 +129,6 @@ func viewGetInfoThunk(ctx wasmlib.ScViewContext) { } ctx.Require(f.Params.Color().Exists(), "missing mandatory color") viewGetInfo(ctx, f) - ctx.Log("fairauction.viewGetInfo ok") ctx.Results(results) + ctx.Log("fairauction.viewGetInfo ok") } diff --git a/contracts/wasm/fairauction/go/fairauction/state.go b/contracts/wasm/fairauction/go/fairauction/state.go index 9d47517beb..0dde9484fd 100644 --- a/contracts/wasm/fairauction/go/fairauction/state.go +++ b/contracts/wasm/fairauction/go/fairauction/state.go @@ -14,7 +14,7 @@ type MapColorToImmutableAuction struct { } func (m MapColorToImmutableAuction) GetAuction(key wasmtypes.ScColor) ImmutableAuction { - return ImmutableAuction{proxy: m.proxy.Key(wasmtypes.BytesFromColor(key))} + return ImmutableAuction{proxy: m.proxy.Key(wasmtypes.ColorToBytes(key))} } type MapColorToImmutableBidderList struct { @@ -22,7 +22,7 @@ type MapColorToImmutableBidderList struct { } func (m MapColorToImmutableBidderList) GetBidderList(key wasmtypes.ScColor) ImmutableBidderList { - return ImmutableBidderList{proxy: m.proxy.Key(wasmtypes.BytesFromColor(key))} + return ImmutableBidderList{proxy: m.proxy.Key(wasmtypes.ColorToBytes(key))} } type MapColorToImmutableBids struct { @@ -30,7 +30,7 @@ type MapColorToImmutableBids struct { } func (m MapColorToImmutableBids) GetBids(key wasmtypes.ScColor) ImmutableBids { - return ImmutableBids{proxy: m.proxy.Key(wasmtypes.BytesFromColor(key))} + return ImmutableBids{proxy: m.proxy.Key(wasmtypes.ColorToBytes(key))} } type ImmutableFairAuctionState struct { @@ -62,7 +62,7 @@ func (m MapColorToMutableAuction) Clear() { } func (m MapColorToMutableAuction) GetAuction(key wasmtypes.ScColor) MutableAuction { - return MutableAuction{proxy: m.proxy.Key(wasmtypes.BytesFromColor(key))} + return MutableAuction{proxy: m.proxy.Key(wasmtypes.ColorToBytes(key))} } type MapColorToMutableBidderList struct { @@ -74,7 +74,7 @@ func (m MapColorToMutableBidderList) Clear() { } func (m MapColorToMutableBidderList) GetBidderList(key wasmtypes.ScColor) MutableBidderList { - return MutableBidderList{proxy: m.proxy.Key(wasmtypes.BytesFromColor(key))} + return MutableBidderList{proxy: m.proxy.Key(wasmtypes.ColorToBytes(key))} } type MapColorToMutableBids struct { @@ -86,7 +86,7 @@ func (m MapColorToMutableBids) Clear() { } func (m MapColorToMutableBids) GetBids(key wasmtypes.ScColor) MutableBids { - return MutableBids{proxy: m.proxy.Key(wasmtypes.BytesFromColor(key))} + return MutableBids{proxy: m.proxy.Key(wasmtypes.ColorToBytes(key))} } type MutableFairAuctionState struct { diff --git a/contracts/wasm/fairauction/go/fairauction/structs.go b/contracts/wasm/fairauction/go/fairauction/structs.go index 5545691541..a53661f4a6 100644 --- a/contracts/wasm/fairauction/go/fairauction/structs.go +++ b/contracts/wasm/fairauction/go/fairauction/structs.go @@ -26,34 +26,34 @@ type Auction struct { func NewAuctionFromBytes(buf []byte) *Auction { dec := wasmtypes.NewWasmDecoder(buf) data := &Auction{} - data.Color = wasmtypes.DecodeColor(dec) - data.Creator = wasmtypes.DecodeAgentID(dec) - data.Deposit = wasmtypes.DecodeUint64(dec) - data.Description = wasmtypes.DecodeString(dec) - data.Duration = wasmtypes.DecodeUint32(dec) - data.HighestBid = wasmtypes.DecodeUint64(dec) - data.HighestBidder = wasmtypes.DecodeAgentID(dec) - data.MinimumBid = wasmtypes.DecodeUint64(dec) - data.NumTokens = wasmtypes.DecodeUint64(dec) - data.OwnerMargin = wasmtypes.DecodeUint64(dec) - data.WhenStarted = wasmtypes.DecodeUint64(dec) + data.Color = wasmtypes.ColorDecode(dec) + data.Creator = wasmtypes.AgentIDDecode(dec) + data.Deposit = wasmtypes.Uint64Decode(dec) + data.Description = wasmtypes.StringDecode(dec) + data.Duration = wasmtypes.Uint32Decode(dec) + data.HighestBid = wasmtypes.Uint64Decode(dec) + data.HighestBidder = wasmtypes.AgentIDDecode(dec) + data.MinimumBid = wasmtypes.Uint64Decode(dec) + data.NumTokens = wasmtypes.Uint64Decode(dec) + data.OwnerMargin = wasmtypes.Uint64Decode(dec) + data.WhenStarted = wasmtypes.Uint64Decode(dec) dec.Close() return data } func (o *Auction) Bytes() []byte { enc := wasmtypes.NewWasmEncoder() - wasmtypes.EncodeColor(enc, o.Color) - wasmtypes.EncodeAgentID(enc, o.Creator) - wasmtypes.EncodeUint64(enc, o.Deposit) - wasmtypes.EncodeString(enc, o.Description) - wasmtypes.EncodeUint32(enc, o.Duration) - wasmtypes.EncodeUint64(enc, o.HighestBid) - wasmtypes.EncodeAgentID(enc, o.HighestBidder) - wasmtypes.EncodeUint64(enc, o.MinimumBid) - wasmtypes.EncodeUint64(enc, o.NumTokens) - wasmtypes.EncodeUint64(enc, o.OwnerMargin) - wasmtypes.EncodeUint64(enc, o.WhenStarted) + wasmtypes.ColorEncode(enc, o.Color) + wasmtypes.AgentIDEncode(enc, o.Creator) + wasmtypes.Uint64Encode(enc, o.Deposit) + wasmtypes.StringEncode(enc, o.Description) + wasmtypes.Uint32Encode(enc, o.Duration) + wasmtypes.Uint64Encode(enc, o.HighestBid) + wasmtypes.AgentIDEncode(enc, o.HighestBidder) + wasmtypes.Uint64Encode(enc, o.MinimumBid) + wasmtypes.Uint64Encode(enc, o.NumTokens) + wasmtypes.Uint64Encode(enc, o.OwnerMargin) + wasmtypes.Uint64Encode(enc, o.WhenStarted) return enc.Buf() } @@ -98,18 +98,18 @@ type Bid struct { func NewBidFromBytes(buf []byte) *Bid { dec := wasmtypes.NewWasmDecoder(buf) data := &Bid{} - data.Amount = wasmtypes.DecodeUint64(dec) - data.Index = wasmtypes.DecodeUint32(dec) - data.Timestamp = wasmtypes.DecodeUint64(dec) + data.Amount = wasmtypes.Uint64Decode(dec) + data.Index = wasmtypes.Uint32Decode(dec) + data.Timestamp = wasmtypes.Uint64Decode(dec) dec.Close() return data } func (o *Bid) Bytes() []byte { enc := wasmtypes.NewWasmEncoder() - wasmtypes.EncodeUint64(enc, o.Amount) - wasmtypes.EncodeUint32(enc, o.Index) - wasmtypes.EncodeUint64(enc, o.Timestamp) + wasmtypes.Uint64Encode(enc, o.Amount) + wasmtypes.Uint32Encode(enc, o.Index) + wasmtypes.Uint64Encode(enc, o.Timestamp) return enc.Buf() } diff --git a/contracts/wasm/fairauction/go/fairauction/typedefs.go b/contracts/wasm/fairauction/go/fairauction/typedefs.go index 5b3f9f9549..9cfe81f2b9 100644 --- a/contracts/wasm/fairauction/go/fairauction/typedefs.go +++ b/contracts/wasm/fairauction/go/fairauction/typedefs.go @@ -50,7 +50,7 @@ type MapAgentIDToImmutableBid struct { } func (m MapAgentIDToImmutableBid) GetBid(key wasmtypes.ScAgentID) ImmutableBid { - return ImmutableBid{proxy: m.proxy.Key(wasmtypes.BytesFromAgentID(key))} + return ImmutableBid{proxy: m.proxy.Key(wasmtypes.AgentIDToBytes(key))} } type ImmutableBids = MapAgentIDToImmutableBid @@ -64,7 +64,7 @@ func (m MapAgentIDToMutableBid) Clear() { } func (m MapAgentIDToMutableBid) GetBid(key wasmtypes.ScAgentID) MutableBid { - return MutableBid{proxy: m.proxy.Key(wasmtypes.BytesFromAgentID(key))} + return MutableBid{proxy: m.proxy.Key(wasmtypes.AgentIDToBytes(key))} } type MutableBids = MapAgentIDToMutableBid diff --git a/contracts/wasm/fairauction/ts/fairauction/consts.ts b/contracts/wasm/fairauction/ts/fairauction/consts.ts index e4b544c88d..da2894b4cc 100644 --- a/contracts/wasm/fairauction/ts/fairauction/consts.ts +++ b/contracts/wasm/fairauction/ts/fairauction/consts.ts @@ -5,11 +5,11 @@ // >>>> DO NOT CHANGE THIS FILE! <<<< // Change the json schema instead -import * as wasmlib from "wasmlib"; +import * as wasmtypes from "wasmlib/wasmtypes"; export const ScName = "fairauction"; export const ScDescription = "Decentralized auction to securely sell tokens to the highest bidder"; -export const HScName = new wasmlib.ScHname(0x1b5c43b1); +export const HScName = new wasmtypes.ScHname(0x1b5c43b1); export const ParamColor = "color"; export const ParamDescription = "description"; @@ -41,8 +41,8 @@ export const FuncSetOwnerMargin = "setOwnerMargin"; export const FuncStartAuction = "startAuction"; export const ViewGetInfo = "getInfo"; -export const HFuncFinalizeAuction = new wasmlib.ScHname(0x8d534ddc); -export const HFuncPlaceBid = new wasmlib.ScHname(0x9bd72fa9); -export const HFuncSetOwnerMargin = new wasmlib.ScHname(0x1774461a); -export const HFuncStartAuction = new wasmlib.ScHname(0xd5b7bacb); -export const HViewGetInfo = new wasmlib.ScHname(0xcfedba5f); +export const HFuncFinalizeAuction = new wasmtypes.ScHname(0x8d534ddc); +export const HFuncPlaceBid = new wasmtypes.ScHname(0x9bd72fa9); +export const HFuncSetOwnerMargin = new wasmtypes.ScHname(0x1774461a); +export const HFuncStartAuction = new wasmtypes.ScHname(0xd5b7bacb); +export const HViewGetInfo = new wasmtypes.ScHname(0xcfedba5f); diff --git a/contracts/wasm/fairauction/ts/fairauction/contract.ts b/contracts/wasm/fairauction/ts/fairauction/contract.ts index 56b06394f3..df5087c256 100644 --- a/contracts/wasm/fairauction/ts/fairauction/contract.ts +++ b/contracts/wasm/fairauction/ts/fairauction/contract.ts @@ -6,88 +6,90 @@ // Change the json schema instead import * as wasmlib from "wasmlib"; +import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; export class FinalizeAuctionCall { func: wasmlib.ScFunc = new wasmlib.ScFunc(sc.HScName, sc.HFuncFinalizeAuction); - params: sc.MutableFinalizeAuctionParams = new sc.MutableFinalizeAuctionParams(); + params: sc.MutableFinalizeAuctionParams = new sc.MutableFinalizeAuctionParams(wasmlib.ScView.nilProxy); } export class FinalizeAuctionContext { - params: sc.ImmutableFinalizeAuctionParams = new sc.ImmutableFinalizeAuctionParams(); - state: sc.MutableFairAuctionState = new sc.MutableFairAuctionState(); + params: sc.ImmutableFinalizeAuctionParams = new sc.ImmutableFinalizeAuctionParams(wasmlib.paramsProxy()); + state: sc.MutableFairAuctionState = new sc.MutableFairAuctionState(wasmlib.ScState.proxy()); } export class PlaceBidCall { func: wasmlib.ScFunc = new wasmlib.ScFunc(sc.HScName, sc.HFuncPlaceBid); - params: sc.MutablePlaceBidParams = new sc.MutablePlaceBidParams(); + params: sc.MutablePlaceBidParams = new sc.MutablePlaceBidParams(wasmlib.ScView.nilProxy); } export class PlaceBidContext { - params: sc.ImmutablePlaceBidParams = new sc.ImmutablePlaceBidParams(); - state: sc.MutableFairAuctionState = new sc.MutableFairAuctionState(); + params: sc.ImmutablePlaceBidParams = new sc.ImmutablePlaceBidParams(wasmlib.paramsProxy()); + state: sc.MutableFairAuctionState = new sc.MutableFairAuctionState(wasmlib.ScState.proxy()); } export class SetOwnerMarginCall { func: wasmlib.ScFunc = new wasmlib.ScFunc(sc.HScName, sc.HFuncSetOwnerMargin); - params: sc.MutableSetOwnerMarginParams = new sc.MutableSetOwnerMarginParams(); + params: sc.MutableSetOwnerMarginParams = new sc.MutableSetOwnerMarginParams(wasmlib.ScView.nilProxy); } export class SetOwnerMarginContext { - params: sc.ImmutableSetOwnerMarginParams = new sc.ImmutableSetOwnerMarginParams(); - state: sc.MutableFairAuctionState = new sc.MutableFairAuctionState(); + params: sc.ImmutableSetOwnerMarginParams = new sc.ImmutableSetOwnerMarginParams(wasmlib.paramsProxy()); + state: sc.MutableFairAuctionState = new sc.MutableFairAuctionState(wasmlib.ScState.proxy()); } export class StartAuctionCall { func: wasmlib.ScFunc = new wasmlib.ScFunc(sc.HScName, sc.HFuncStartAuction); - params: sc.MutableStartAuctionParams = new sc.MutableStartAuctionParams(); + params: sc.MutableStartAuctionParams = new sc.MutableStartAuctionParams(wasmlib.ScView.nilProxy); } export class StartAuctionContext { - params: sc.ImmutableStartAuctionParams = new sc.ImmutableStartAuctionParams(); - state: sc.MutableFairAuctionState = new sc.MutableFairAuctionState(); + params: sc.ImmutableStartAuctionParams = new sc.ImmutableStartAuctionParams(wasmlib.paramsProxy()); + state: sc.MutableFairAuctionState = new sc.MutableFairAuctionState(wasmlib.ScState.proxy()); } export class GetInfoCall { func: wasmlib.ScView = new wasmlib.ScView(sc.HScName, sc.HViewGetInfo); - params: sc.MutableGetInfoParams = new sc.MutableGetInfoParams(); - results: sc.ImmutableGetInfoResults = new sc.ImmutableGetInfoResults(); + params: sc.MutableGetInfoParams = new sc.MutableGetInfoParams(wasmlib.ScView.nilProxy); + results: sc.ImmutableGetInfoResults = new sc.ImmutableGetInfoResults(wasmlib.ScView.nilProxy); } export class GetInfoContext { - params: sc.ImmutableGetInfoParams = new sc.ImmutableGetInfoParams(); - results: sc.MutableGetInfoResults = new sc.MutableGetInfoResults(); - state: sc.ImmutableFairAuctionState = new sc.ImmutableFairAuctionState(); + params: sc.ImmutableGetInfoParams = new sc.ImmutableGetInfoParams(wasmlib.paramsProxy()); + results: sc.MutableGetInfoResults = new sc.MutableGetInfoResults(wasmlib.ScView.nilProxy); + state: sc.ImmutableFairAuctionState = new sc.ImmutableFairAuctionState(wasmlib.ScState.proxy()); } export class ScFuncs { static finalizeAuction(ctx: wasmlib.ScFuncCallContext): FinalizeAuctionCall { - let f = new FinalizeAuctionCall(); - f.func.setPtrs(f.params, null); + const f = new FinalizeAuctionCall(); + f.params = new sc.MutableFinalizeAuctionParams(wasmlib.newCallParamsProxy(f.func)); return f; } static placeBid(ctx: wasmlib.ScFuncCallContext): PlaceBidCall { - let f = new PlaceBidCall(); - f.func.setPtrs(f.params, null); + const f = new PlaceBidCall(); + f.params = new sc.MutablePlaceBidParams(wasmlib.newCallParamsProxy(f.func)); return f; } static setOwnerMargin(ctx: wasmlib.ScFuncCallContext): SetOwnerMarginCall { - let f = new SetOwnerMarginCall(); - f.func.setPtrs(f.params, null); + const f = new SetOwnerMarginCall(); + f.params = new sc.MutableSetOwnerMarginParams(wasmlib.newCallParamsProxy(f.func)); return f; } static startAuction(ctx: wasmlib.ScFuncCallContext): StartAuctionCall { - let f = new StartAuctionCall(); - f.func.setPtrs(f.params, null); + const f = new StartAuctionCall(); + f.params = new sc.MutableStartAuctionParams(wasmlib.newCallParamsProxy(f.func)); return f; } static getInfo(ctx: wasmlib.ScViewCallContext): GetInfoCall { - let f = new GetInfoCall(); - f.func.setPtrs(f.params, f.results); + const f = new GetInfoCall(); + f.params = new sc.MutableGetInfoParams(wasmlib.newCallParamsProxy(f.func)); + f.results = new sc.ImmutableGetInfoResults(wasmlib.newCallResultsProxy(f.func)); return f; } } diff --git a/contracts/wasm/fairauction/ts/fairauction/fairauction.ts b/contracts/wasm/fairauction/ts/fairauction/fairauction.ts index 4f9bf15c1a..96a3914c70 100644 --- a/contracts/wasm/fairauction/ts/fairauction/fairauction.ts +++ b/contracts/wasm/fairauction/ts/fairauction/fairauction.ts @@ -2,6 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 import * as wasmlib from "wasmlib" +import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; const DURATION_DEFAULT: u32 = 60; @@ -24,9 +25,9 @@ export function funcFinalizeAuction(ctx: wasmlib.ScFuncContext, f: sc.FinalizeAu ownerFee = 1; } // finalizeAuction request token was probably not confirmed yet - transferTokens(ctx, ctx.contractCreator(), wasmlib.ScColor.IOTA, ownerFee - 1); + transferTokens(ctx, ctx.contractCreator(), wasmtypes.IOTA, ownerFee - 1); transferTokens(ctx, auction.creator, auction.color, auction.numTokens); - transferTokens(ctx, auction.creator, wasmlib.ScColor.IOTA, auction.deposit - ownerFee); + transferTokens(ctx, auction.creator, wasmtypes.IOTA, auction.deposit - ownerFee); return; } @@ -43,18 +44,18 @@ export function funcFinalizeAuction(ctx: wasmlib.ScFuncContext, f: sc.FinalizeAu let loser = bidderList.getAgentID(i).value(); if (loser != auction.highestBidder) { let bid = bids.getBid(loser).value(); - transferTokens(ctx, loser, wasmlib.ScColor.IOTA, bid.amount); + transferTokens(ctx, loser, wasmtypes.IOTA, bid.amount); } } // finalizeAuction request token was probably not confirmed yet - transferTokens(ctx, ctx.contractCreator(), wasmlib.ScColor.IOTA, ownerFee - 1); + transferTokens(ctx, ctx.contractCreator(), wasmtypes.IOTA, ownerFee - 1); transferTokens(ctx, auction.highestBidder, auction.color, auction.numTokens); - transferTokens(ctx, auction.creator, wasmlib.ScColor.IOTA, auction.deposit + auction.highestBid - ownerFee); + transferTokens(ctx, auction.creator, wasmtypes.IOTA, auction.deposit + auction.highestBid - ownerFee); } export function funcPlaceBid(ctx: wasmlib.ScFuncContext, f: sc.PlaceBidContext): void { - let bidAmount = ctx.incoming().balance(wasmlib.ScColor.IOTA); + let bidAmount = ctx.incoming().balance(wasmtypes.IOTA); ctx.require(bidAmount > 0, "Missing bid amount"); let color = f.params.color().value(); @@ -77,7 +78,7 @@ export function funcPlaceBid(ctx: wasmlib.ScFuncContext, f: sc.PlaceBidContext): ctx.require(bidAmount >= auction.minimumBid, "Insufficient bid amount"); ctx.log("New bid from: " + caller.toString()); let index = bidderList.length(); - bidderList.getAgentID(index).setValue(caller); + bidderList.appendAgentID().setValue(caller); let bid = new sc.Bid(); bid.index = index; bid.amount = bidAmount; @@ -105,7 +106,7 @@ export function funcSetOwnerMargin(ctx: wasmlib.ScFuncContext, f: sc.SetOwnerMar export function funcStartAuction(ctx: wasmlib.ScFuncContext, f: sc.StartAuctionContext): void { let color = f.params.color().value(); - if (color == wasmlib.ScColor.IOTA || color == wasmlib.ScColor.MINT) { + if (color == wasmtypes.IOTA || color == wasmtypes.MINT) { ctx.panic("Reserved auction token color"); } let numTokens = ctx.incoming().balance(color); @@ -145,7 +146,7 @@ export function funcStartAuction(ctx: wasmlib.ScFuncContext, f: sc.StartAuctionC if (margin == 0) { margin = 1; } - let deposit = ctx.incoming().balance(wasmlib.ScColor.IOTA); + let deposit = ctx.incoming().balance(wasmtypes.IOTA); if (deposit < margin) { ctx.panic("Insufficient deposit"); } @@ -162,7 +163,7 @@ export function funcStartAuction(ctx: wasmlib.ScFuncContext, f: sc.StartAuctionC auction.description = description; auction.duration = duration; auction.highestBid = 0; - auction.highestBidder = new wasmlib.ScAgentID(); + auction.highestBidder = wasmtypes.agentIDFromBytes(null); auction.minimumBid = minimumBid; auction.numTokens = numTokens; auction.ownerMargin = ownerMargin; diff --git a/contracts/wasm/fairauction/ts/fairauction/index.ts b/contracts/wasm/fairauction/ts/fairauction/index.ts index e8011fbe09..f4705cc7cf 100644 --- a/contracts/wasm/fairauction/ts/fairauction/index.ts +++ b/contracts/wasm/fairauction/ts/fairauction/index.ts @@ -9,7 +9,6 @@ export * from "./fairauction"; export * from "./consts"; export * from "./contract"; -export * from "./keys"; export * from "./lib"; export * from "./params"; export * from "./results"; diff --git a/contracts/wasm/fairauction/ts/fairauction/keys.ts b/contracts/wasm/fairauction/ts/fairauction/keys.ts index b4d09d3c3a..d582c31633 100644 --- a/contracts/wasm/fairauction/ts/fairauction/keys.ts +++ b/contracts/wasm/fairauction/ts/fairauction/keys.ts @@ -5,55 +5,9 @@ // >>>> DO NOT CHANGE THIS FILE! <<<< // Change the json schema instead -import * as wasmlib from "wasmlib"; -import * as sc from "./index"; export const IdxParamColor = 0; export const IdxParamDescription = 1; export const IdxParamDuration = 2; export const IdxParamMinimumBid = 3; export const IdxParamOwnerMargin = 4; - -export const IdxResultBidders = 5; -export const IdxResultColor = 6; -export const IdxResultCreator = 7; -export const IdxResultDeposit = 8; -export const IdxResultDescription = 9; -export const IdxResultDuration = 10; -export const IdxResultHighestBid = 11; -export const IdxResultHighestBidder = 12; -export const IdxResultMinimumBid = 13; -export const IdxResultNumTokens = 14; -export const IdxResultOwnerMargin = 15; -export const IdxResultWhenStarted = 16; - -export const IdxStateAuctions = 17; -export const IdxStateBidderList = 18; -export const IdxStateBids = 19; -export const IdxStateOwnerMargin = 20; - -export let keyMap: string[] = [ - sc.ParamColor, - sc.ParamDescription, - sc.ParamDuration, - sc.ParamMinimumBid, - sc.ParamOwnerMargin, - sc.ResultBidders, - sc.ResultColor, - sc.ResultCreator, - sc.ResultDeposit, - sc.ResultDescription, - sc.ResultDuration, - sc.ResultHighestBid, - sc.ResultHighestBidder, - sc.ResultMinimumBid, - sc.ResultNumTokens, - sc.ResultOwnerMargin, - sc.ResultWhenStarted, - sc.StateAuctions, - sc.StateBidderList, - sc.StateBids, - sc.StateOwnerMargin, -]; - -export let idxMap: wasmlib.Key32[] = new Array(keyMap.length); diff --git a/contracts/wasm/fairauction/ts/fairauction/lib.ts b/contracts/wasm/fairauction/ts/fairauction/lib.ts index 2f7ea11525..59e151bcda 100644 --- a/contracts/wasm/fairauction/ts/fairauction/lib.ts +++ b/contracts/wasm/fairauction/ts/fairauction/lib.ts @@ -6,6 +6,7 @@ // Change the json schema instead import * as wasmlib from "wasmlib"; +import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; export function on_call(index: i32): void { @@ -19,21 +20,15 @@ export function on_load(): void { exports.addFunc(sc.FuncSetOwnerMargin, funcSetOwnerMarginThunk); exports.addFunc(sc.FuncStartAuction, funcStartAuctionThunk); exports.addView(sc.ViewGetInfo, viewGetInfoThunk); - - for (let i = 0; i < sc.keyMap.length; i++) { - sc.idxMap[i] = wasmlib.Key32.fromString(sc.keyMap[i]); - } } function funcFinalizeAuctionThunk(ctx: wasmlib.ScFuncContext): void { ctx.log("fairauction.funcFinalizeAuction"); + let f = new sc.FinalizeAuctionContext(); // only SC itself can invoke this function ctx.require(ctx.caller().equals(ctx.accountID()), "no permission"); - let f = new sc.FinalizeAuctionContext(); - f.params.mapID = wasmlib.OBJ_ID_PARAMS; - f.state.mapID = wasmlib.OBJ_ID_STATE; ctx.require(f.params.color().exists(), "missing mandatory color"); sc.funcFinalizeAuction(ctx, f); ctx.log("fairauction.funcFinalizeAuction ok"); @@ -42,8 +37,6 @@ function funcFinalizeAuctionThunk(ctx: wasmlib.ScFuncContext): void { function funcPlaceBidThunk(ctx: wasmlib.ScFuncContext): void { ctx.log("fairauction.funcPlaceBid"); let f = new sc.PlaceBidContext(); - f.params.mapID = wasmlib.OBJ_ID_PARAMS; - f.state.mapID = wasmlib.OBJ_ID_STATE; ctx.require(f.params.color().exists(), "missing mandatory color"); sc.funcPlaceBid(ctx, f); ctx.log("fairauction.funcPlaceBid ok"); @@ -51,13 +44,11 @@ function funcPlaceBidThunk(ctx: wasmlib.ScFuncContext): void { function funcSetOwnerMarginThunk(ctx: wasmlib.ScFuncContext): void { ctx.log("fairauction.funcSetOwnerMargin"); + let f = new sc.SetOwnerMarginContext(); // only SC creator can set owner margin ctx.require(ctx.caller().equals(ctx.contractCreator()), "no permission"); - let f = new sc.SetOwnerMarginContext(); - f.params.mapID = wasmlib.OBJ_ID_PARAMS; - f.state.mapID = wasmlib.OBJ_ID_STATE; ctx.require(f.params.ownerMargin().exists(), "missing mandatory ownerMargin"); sc.funcSetOwnerMargin(ctx, f); ctx.log("fairauction.funcSetOwnerMargin ok"); @@ -66,8 +57,6 @@ function funcSetOwnerMarginThunk(ctx: wasmlib.ScFuncContext): void { function funcStartAuctionThunk(ctx: wasmlib.ScFuncContext): void { ctx.log("fairauction.funcStartAuction"); let f = new sc.StartAuctionContext(); - f.params.mapID = wasmlib.OBJ_ID_PARAMS; - f.state.mapID = wasmlib.OBJ_ID_STATE; ctx.require(f.params.color().exists(), "missing mandatory color"); ctx.require(f.params.minimumBid().exists(), "missing mandatory minimumBid"); sc.funcStartAuction(ctx, f); @@ -77,10 +66,10 @@ function funcStartAuctionThunk(ctx: wasmlib.ScFuncContext): void { function viewGetInfoThunk(ctx: wasmlib.ScViewContext): void { ctx.log("fairauction.viewGetInfo"); let f = new sc.GetInfoContext(); - f.params.mapID = wasmlib.OBJ_ID_PARAMS; - f.results.mapID = wasmlib.OBJ_ID_RESULTS; - f.state.mapID = wasmlib.OBJ_ID_STATE; + const results = new wasmlib.ScDict([]); + f.results = new sc.MutableGetInfoResults(results.asProxy()); ctx.require(f.params.color().exists(), "missing mandatory color"); sc.viewGetInfo(ctx, f); + ctx.results(results); ctx.log("fairauction.viewGetInfo ok"); } diff --git a/contracts/wasm/fairauction/ts/fairauction/params.ts b/contracts/wasm/fairauction/ts/fairauction/params.ts index 34d1eca8dd..72c8191161 100644 --- a/contracts/wasm/fairauction/ts/fairauction/params.ts +++ b/contracts/wasm/fairauction/ts/fairauction/params.ts @@ -6,88 +6,89 @@ // Change the json schema instead import * as wasmlib from "wasmlib"; +import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; -export class ImmutableFinalizeAuctionParams extends wasmlib.ScMapID { - color(): wasmlib.ScImmutableColor { - return new wasmlib.ScImmutableColor(this.mapID, wasmlib.Key32.fromString(sc.ParamColor)); +export class ImmutableFinalizeAuctionParams extends wasmtypes.ScProxy { + color(): wasmtypes.ScImmutableColor { + return new wasmtypes.ScImmutableColor(this.proxy.root(sc.ParamColor)); } } -export class MutableFinalizeAuctionParams extends wasmlib.ScMapID { - color(): wasmlib.ScMutableColor { - return new wasmlib.ScMutableColor(this.mapID, wasmlib.Key32.fromString(sc.ParamColor)); +export class MutableFinalizeAuctionParams extends wasmtypes.ScProxy { + color(): wasmtypes.ScMutableColor { + return new wasmtypes.ScMutableColor(this.proxy.root(sc.ParamColor)); } } -export class ImmutablePlaceBidParams extends wasmlib.ScMapID { - color(): wasmlib.ScImmutableColor { - return new wasmlib.ScImmutableColor(this.mapID, wasmlib.Key32.fromString(sc.ParamColor)); +export class ImmutablePlaceBidParams extends wasmtypes.ScProxy { + color(): wasmtypes.ScImmutableColor { + return new wasmtypes.ScImmutableColor(this.proxy.root(sc.ParamColor)); } } -export class MutablePlaceBidParams extends wasmlib.ScMapID { - color(): wasmlib.ScMutableColor { - return new wasmlib.ScMutableColor(this.mapID, wasmlib.Key32.fromString(sc.ParamColor)); +export class MutablePlaceBidParams extends wasmtypes.ScProxy { + color(): wasmtypes.ScMutableColor { + return new wasmtypes.ScMutableColor(this.proxy.root(sc.ParamColor)); } } -export class ImmutableSetOwnerMarginParams extends wasmlib.ScMapID { - ownerMargin(): wasmlib.ScImmutableUint64 { - return new wasmlib.ScImmutableUint64(this.mapID, wasmlib.Key32.fromString(sc.ParamOwnerMargin)); +export class ImmutableSetOwnerMarginParams extends wasmtypes.ScProxy { + ownerMargin(): wasmtypes.ScImmutableUint64 { + return new wasmtypes.ScImmutableUint64(this.proxy.root(sc.ParamOwnerMargin)); } } -export class MutableSetOwnerMarginParams extends wasmlib.ScMapID { - ownerMargin(): wasmlib.ScMutableUint64 { - return new wasmlib.ScMutableUint64(this.mapID, wasmlib.Key32.fromString(sc.ParamOwnerMargin)); +export class MutableSetOwnerMarginParams extends wasmtypes.ScProxy { + ownerMargin(): wasmtypes.ScMutableUint64 { + return new wasmtypes.ScMutableUint64(this.proxy.root(sc.ParamOwnerMargin)); } } -export class ImmutableStartAuctionParams extends wasmlib.ScMapID { - color(): wasmlib.ScImmutableColor { - return new wasmlib.ScImmutableColor(this.mapID, wasmlib.Key32.fromString(sc.ParamColor)); +export class ImmutableStartAuctionParams extends wasmtypes.ScProxy { + color(): wasmtypes.ScImmutableColor { + return new wasmtypes.ScImmutableColor(this.proxy.root(sc.ParamColor)); } - description(): wasmlib.ScImmutableString { - return new wasmlib.ScImmutableString(this.mapID, wasmlib.Key32.fromString(sc.ParamDescription)); + description(): wasmtypes.ScImmutableString { + return new wasmtypes.ScImmutableString(this.proxy.root(sc.ParamDescription)); } - duration(): wasmlib.ScImmutableUint32 { - return new wasmlib.ScImmutableUint32(this.mapID, wasmlib.Key32.fromString(sc.ParamDuration)); + duration(): wasmtypes.ScImmutableUint32 { + return new wasmtypes.ScImmutableUint32(this.proxy.root(sc.ParamDuration)); } - minimumBid(): wasmlib.ScImmutableUint64 { - return new wasmlib.ScImmutableUint64(this.mapID, wasmlib.Key32.fromString(sc.ParamMinimumBid)); + minimumBid(): wasmtypes.ScImmutableUint64 { + return new wasmtypes.ScImmutableUint64(this.proxy.root(sc.ParamMinimumBid)); } } -export class MutableStartAuctionParams extends wasmlib.ScMapID { - color(): wasmlib.ScMutableColor { - return new wasmlib.ScMutableColor(this.mapID, wasmlib.Key32.fromString(sc.ParamColor)); +export class MutableStartAuctionParams extends wasmtypes.ScProxy { + color(): wasmtypes.ScMutableColor { + return new wasmtypes.ScMutableColor(this.proxy.root(sc.ParamColor)); } - description(): wasmlib.ScMutableString { - return new wasmlib.ScMutableString(this.mapID, wasmlib.Key32.fromString(sc.ParamDescription)); + description(): wasmtypes.ScMutableString { + return new wasmtypes.ScMutableString(this.proxy.root(sc.ParamDescription)); } - duration(): wasmlib.ScMutableUint32 { - return new wasmlib.ScMutableUint32(this.mapID, wasmlib.Key32.fromString(sc.ParamDuration)); + duration(): wasmtypes.ScMutableUint32 { + return new wasmtypes.ScMutableUint32(this.proxy.root(sc.ParamDuration)); } - minimumBid(): wasmlib.ScMutableUint64 { - return new wasmlib.ScMutableUint64(this.mapID, wasmlib.Key32.fromString(sc.ParamMinimumBid)); + minimumBid(): wasmtypes.ScMutableUint64 { + return new wasmtypes.ScMutableUint64(this.proxy.root(sc.ParamMinimumBid)); } } -export class ImmutableGetInfoParams extends wasmlib.ScMapID { - color(): wasmlib.ScImmutableColor { - return new wasmlib.ScImmutableColor(this.mapID, wasmlib.Key32.fromString(sc.ParamColor)); +export class ImmutableGetInfoParams extends wasmtypes.ScProxy { + color(): wasmtypes.ScImmutableColor { + return new wasmtypes.ScImmutableColor(this.proxy.root(sc.ParamColor)); } } -export class MutableGetInfoParams extends wasmlib.ScMapID { - color(): wasmlib.ScMutableColor { - return new wasmlib.ScMutableColor(this.mapID, wasmlib.Key32.fromString(sc.ParamColor)); +export class MutableGetInfoParams extends wasmtypes.ScProxy { + color(): wasmtypes.ScMutableColor { + return new wasmtypes.ScMutableColor(this.proxy.root(sc.ParamColor)); } } diff --git a/contracts/wasm/fairauction/ts/fairauction/results.ts b/contracts/wasm/fairauction/ts/fairauction/results.ts index 7aa0227bf4..05e66d893b 100644 --- a/contracts/wasm/fairauction/ts/fairauction/results.ts +++ b/contracts/wasm/fairauction/ts/fairauction/results.ts @@ -6,104 +6,105 @@ // Change the json schema instead import * as wasmlib from "wasmlib"; +import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; -export class ImmutableGetInfoResults extends wasmlib.ScMapID { - bidders(): wasmlib.ScImmutableUint32 { - return new wasmlib.ScImmutableUint32(this.mapID, wasmlib.Key32.fromString(sc.ResultBidders)); +export class ImmutableGetInfoResults extends wasmtypes.ScProxy { + bidders(): wasmtypes.ScImmutableUint32 { + return new wasmtypes.ScImmutableUint32(this.proxy.root(sc.ResultBidders)); } - color(): wasmlib.ScImmutableColor { - return new wasmlib.ScImmutableColor(this.mapID, wasmlib.Key32.fromString(sc.ResultColor)); + color(): wasmtypes.ScImmutableColor { + return new wasmtypes.ScImmutableColor(this.proxy.root(sc.ResultColor)); } - creator(): wasmlib.ScImmutableAgentID { - return new wasmlib.ScImmutableAgentID(this.mapID, wasmlib.Key32.fromString(sc.ResultCreator)); + creator(): wasmtypes.ScImmutableAgentID { + return new wasmtypes.ScImmutableAgentID(this.proxy.root(sc.ResultCreator)); } - deposit(): wasmlib.ScImmutableUint64 { - return new wasmlib.ScImmutableUint64(this.mapID, wasmlib.Key32.fromString(sc.ResultDeposit)); + deposit(): wasmtypes.ScImmutableUint64 { + return new wasmtypes.ScImmutableUint64(this.proxy.root(sc.ResultDeposit)); } - description(): wasmlib.ScImmutableString { - return new wasmlib.ScImmutableString(this.mapID, wasmlib.Key32.fromString(sc.ResultDescription)); + description(): wasmtypes.ScImmutableString { + return new wasmtypes.ScImmutableString(this.proxy.root(sc.ResultDescription)); } - duration(): wasmlib.ScImmutableUint32 { - return new wasmlib.ScImmutableUint32(this.mapID, wasmlib.Key32.fromString(sc.ResultDuration)); + duration(): wasmtypes.ScImmutableUint32 { + return new wasmtypes.ScImmutableUint32(this.proxy.root(sc.ResultDuration)); } - highestBid(): wasmlib.ScImmutableUint64 { - return new wasmlib.ScImmutableUint64(this.mapID, wasmlib.Key32.fromString(sc.ResultHighestBid)); + highestBid(): wasmtypes.ScImmutableUint64 { + return new wasmtypes.ScImmutableUint64(this.proxy.root(sc.ResultHighestBid)); } - highestBidder(): wasmlib.ScImmutableAgentID { - return new wasmlib.ScImmutableAgentID(this.mapID, wasmlib.Key32.fromString(sc.ResultHighestBidder)); + highestBidder(): wasmtypes.ScImmutableAgentID { + return new wasmtypes.ScImmutableAgentID(this.proxy.root(sc.ResultHighestBidder)); } - minimumBid(): wasmlib.ScImmutableUint64 { - return new wasmlib.ScImmutableUint64(this.mapID, wasmlib.Key32.fromString(sc.ResultMinimumBid)); + minimumBid(): wasmtypes.ScImmutableUint64 { + return new wasmtypes.ScImmutableUint64(this.proxy.root(sc.ResultMinimumBid)); } - numTokens(): wasmlib.ScImmutableUint64 { - return new wasmlib.ScImmutableUint64(this.mapID, wasmlib.Key32.fromString(sc.ResultNumTokens)); + numTokens(): wasmtypes.ScImmutableUint64 { + return new wasmtypes.ScImmutableUint64(this.proxy.root(sc.ResultNumTokens)); } - ownerMargin(): wasmlib.ScImmutableUint64 { - return new wasmlib.ScImmutableUint64(this.mapID, wasmlib.Key32.fromString(sc.ResultOwnerMargin)); + ownerMargin(): wasmtypes.ScImmutableUint64 { + return new wasmtypes.ScImmutableUint64(this.proxy.root(sc.ResultOwnerMargin)); } - whenStarted(): wasmlib.ScImmutableUint64 { - return new wasmlib.ScImmutableUint64(this.mapID, wasmlib.Key32.fromString(sc.ResultWhenStarted)); + whenStarted(): wasmtypes.ScImmutableUint64 { + return new wasmtypes.ScImmutableUint64(this.proxy.root(sc.ResultWhenStarted)); } } -export class MutableGetInfoResults extends wasmlib.ScMapID { - bidders(): wasmlib.ScMutableUint32 { - return new wasmlib.ScMutableUint32(this.mapID, wasmlib.Key32.fromString(sc.ResultBidders)); +export class MutableGetInfoResults extends wasmtypes.ScProxy { + bidders(): wasmtypes.ScMutableUint32 { + return new wasmtypes.ScMutableUint32(this.proxy.root(sc.ResultBidders)); } - color(): wasmlib.ScMutableColor { - return new wasmlib.ScMutableColor(this.mapID, wasmlib.Key32.fromString(sc.ResultColor)); + color(): wasmtypes.ScMutableColor { + return new wasmtypes.ScMutableColor(this.proxy.root(sc.ResultColor)); } - creator(): wasmlib.ScMutableAgentID { - return new wasmlib.ScMutableAgentID(this.mapID, wasmlib.Key32.fromString(sc.ResultCreator)); + creator(): wasmtypes.ScMutableAgentID { + return new wasmtypes.ScMutableAgentID(this.proxy.root(sc.ResultCreator)); } - deposit(): wasmlib.ScMutableUint64 { - return new wasmlib.ScMutableUint64(this.mapID, wasmlib.Key32.fromString(sc.ResultDeposit)); + deposit(): wasmtypes.ScMutableUint64 { + return new wasmtypes.ScMutableUint64(this.proxy.root(sc.ResultDeposit)); } - description(): wasmlib.ScMutableString { - return new wasmlib.ScMutableString(this.mapID, wasmlib.Key32.fromString(sc.ResultDescription)); + description(): wasmtypes.ScMutableString { + return new wasmtypes.ScMutableString(this.proxy.root(sc.ResultDescription)); } - duration(): wasmlib.ScMutableUint32 { - return new wasmlib.ScMutableUint32(this.mapID, wasmlib.Key32.fromString(sc.ResultDuration)); + duration(): wasmtypes.ScMutableUint32 { + return new wasmtypes.ScMutableUint32(this.proxy.root(sc.ResultDuration)); } - highestBid(): wasmlib.ScMutableUint64 { - return new wasmlib.ScMutableUint64(this.mapID, wasmlib.Key32.fromString(sc.ResultHighestBid)); + highestBid(): wasmtypes.ScMutableUint64 { + return new wasmtypes.ScMutableUint64(this.proxy.root(sc.ResultHighestBid)); } - highestBidder(): wasmlib.ScMutableAgentID { - return new wasmlib.ScMutableAgentID(this.mapID, wasmlib.Key32.fromString(sc.ResultHighestBidder)); + highestBidder(): wasmtypes.ScMutableAgentID { + return new wasmtypes.ScMutableAgentID(this.proxy.root(sc.ResultHighestBidder)); } - minimumBid(): wasmlib.ScMutableUint64 { - return new wasmlib.ScMutableUint64(this.mapID, wasmlib.Key32.fromString(sc.ResultMinimumBid)); + minimumBid(): wasmtypes.ScMutableUint64 { + return new wasmtypes.ScMutableUint64(this.proxy.root(sc.ResultMinimumBid)); } - numTokens(): wasmlib.ScMutableUint64 { - return new wasmlib.ScMutableUint64(this.mapID, wasmlib.Key32.fromString(sc.ResultNumTokens)); + numTokens(): wasmtypes.ScMutableUint64 { + return new wasmtypes.ScMutableUint64(this.proxy.root(sc.ResultNumTokens)); } - ownerMargin(): wasmlib.ScMutableUint64 { - return new wasmlib.ScMutableUint64(this.mapID, wasmlib.Key32.fromString(sc.ResultOwnerMargin)); + ownerMargin(): wasmtypes.ScMutableUint64 { + return new wasmtypes.ScMutableUint64(this.proxy.root(sc.ResultOwnerMargin)); } - whenStarted(): wasmlib.ScMutableUint64 { - return new wasmlib.ScMutableUint64(this.mapID, wasmlib.Key32.fromString(sc.ResultWhenStarted)); + whenStarted(): wasmtypes.ScMutableUint64 { + return new wasmtypes.ScMutableUint64(this.proxy.root(sc.ResultWhenStarted)); } } diff --git a/contracts/wasm/fairauction/ts/fairauction/state.ts b/contracts/wasm/fairauction/ts/fairauction/state.ts index 0f07971c70..1942ba6ff2 100644 --- a/contracts/wasm/fairauction/ts/fairauction/state.ts +++ b/contracts/wasm/fairauction/ts/fairauction/state.ts @@ -6,140 +6,99 @@ // Change the json schema instead import * as wasmlib from "wasmlib"; +import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; -export class MapColorToImmutableAuction { - objID: i32; +export class MapColorToImmutableAuction extends wasmtypes.ScProxy { - constructor(objID: i32) { - this.objID = objID; - } - - getAuction(key: wasmlib.ScColor): sc.ImmutableAuction { - return new sc.ImmutableAuction(this.objID, key.getKeyID()); + getAuction(key: wasmtypes.ScColor): sc.ImmutableAuction { + return new sc.ImmutableAuction(this.proxy.key(wasmtypes.colorToBytes(key))); } } -export class MapColorToImmutableBidderList { - objID: i32; - - constructor(objID: i32) { - this.objID = objID; - } +export class MapColorToImmutableBidderList extends wasmtypes.ScProxy { - getBidderList(key: wasmlib.ScColor): sc.ImmutableBidderList { - let subID = wasmlib.getObjectID(this.objID, key.getKeyID(), wasmlib.TYPE_ARRAY|wasmlib.TYPE_AGENT_ID); - return new sc.ImmutableBidderList(subID); + getBidderList(key: wasmtypes.ScColor): sc.ImmutableBidderList { + return new sc.ImmutableBidderList(this.proxy.key(wasmtypes.colorToBytes(key))); } } -export class MapColorToImmutableBids { - objID: i32; - - constructor(objID: i32) { - this.objID = objID; - } +export class MapColorToImmutableBids extends wasmtypes.ScProxy { - getBids(key: wasmlib.ScColor): sc.ImmutableBids { - let subID = wasmlib.getObjectID(this.objID, key.getKeyID(), wasmlib.TYPE_MAP); - return new sc.ImmutableBids(subID); + getBids(key: wasmtypes.ScColor): sc.ImmutableBids { + return new sc.ImmutableBids(this.proxy.key(wasmtypes.colorToBytes(key))); } } -export class ImmutableFairAuctionState extends wasmlib.ScMapID { +export class ImmutableFairAuctionState extends wasmtypes.ScProxy { auctions(): sc.MapColorToImmutableAuction { - let mapID = wasmlib.getObjectID(this.mapID, wasmlib.Key32.fromString(sc.StateAuctions), wasmlib.TYPE_MAP); - return new sc.MapColorToImmutableAuction(mapID); + return new sc.MapColorToImmutableAuction(this.proxy.root(sc.StateAuctions)); } bidderList(): sc.MapColorToImmutableBidderList { - let mapID = wasmlib.getObjectID(this.mapID, wasmlib.Key32.fromString(sc.StateBidderList), wasmlib.TYPE_MAP); - return new sc.MapColorToImmutableBidderList(mapID); + return new sc.MapColorToImmutableBidderList(this.proxy.root(sc.StateBidderList)); } bids(): sc.MapColorToImmutableBids { - let mapID = wasmlib.getObjectID(this.mapID, wasmlib.Key32.fromString(sc.StateBids), wasmlib.TYPE_MAP); - return new sc.MapColorToImmutableBids(mapID); + return new sc.MapColorToImmutableBids(this.proxy.root(sc.StateBids)); } - ownerMargin(): wasmlib.ScImmutableUint64 { - return new wasmlib.ScImmutableUint64(this.mapID, wasmlib.Key32.fromString(sc.StateOwnerMargin)); + ownerMargin(): wasmtypes.ScImmutableUint64 { + return new wasmtypes.ScImmutableUint64(this.proxy.root(sc.StateOwnerMargin)); } } -export class MapColorToMutableAuction { - objID: i32; - - constructor(objID: i32) { - this.objID = objID; - } +export class MapColorToMutableAuction extends wasmtypes.ScProxy { clear(): void { - wasmlib.clear(this.objID); + this.proxy.clearMap(); } - getAuction(key: wasmlib.ScColor): sc.MutableAuction { - return new sc.MutableAuction(this.objID, key.getKeyID()); + getAuction(key: wasmtypes.ScColor): sc.MutableAuction { + return new sc.MutableAuction(this.proxy.key(wasmtypes.colorToBytes(key))); } } -export class MapColorToMutableBidderList { - objID: i32; - - constructor(objID: i32) { - this.objID = objID; - } +export class MapColorToMutableBidderList extends wasmtypes.ScProxy { clear(): void { - wasmlib.clear(this.objID); + this.proxy.clearMap(); } - getBidderList(key: wasmlib.ScColor): sc.MutableBidderList { - let subID = wasmlib.getObjectID(this.objID, key.getKeyID(), wasmlib.TYPE_ARRAY|wasmlib.TYPE_AGENT_ID); - return new sc.MutableBidderList(subID); + getBidderList(key: wasmtypes.ScColor): sc.MutableBidderList { + return new sc.MutableBidderList(this.proxy.key(wasmtypes.colorToBytes(key))); } } -export class MapColorToMutableBids { - objID: i32; - - constructor(objID: i32) { - this.objID = objID; - } +export class MapColorToMutableBids extends wasmtypes.ScProxy { clear(): void { - wasmlib.clear(this.objID); + this.proxy.clearMap(); } - getBids(key: wasmlib.ScColor): sc.MutableBids { - let subID = wasmlib.getObjectID(this.objID, key.getKeyID(), wasmlib.TYPE_MAP); - return new sc.MutableBids(subID); + getBids(key: wasmtypes.ScColor): sc.MutableBids { + return new sc.MutableBids(this.proxy.key(wasmtypes.colorToBytes(key))); } } -export class MutableFairAuctionState extends wasmlib.ScMapID { +export class MutableFairAuctionState extends wasmtypes.ScProxy { asImmutable(): sc.ImmutableFairAuctionState { - const imm = new sc.ImmutableFairAuctionState(); - imm.mapID = this.mapID; - return imm; + return new sc.ImmutableFairAuctionState(this.proxy); } auctions(): sc.MapColorToMutableAuction { - let mapID = wasmlib.getObjectID(this.mapID, wasmlib.Key32.fromString(sc.StateAuctions), wasmlib.TYPE_MAP); - return new sc.MapColorToMutableAuction(mapID); + return new sc.MapColorToMutableAuction(this.proxy.root(sc.StateAuctions)); } bidderList(): sc.MapColorToMutableBidderList { - let mapID = wasmlib.getObjectID(this.mapID, wasmlib.Key32.fromString(sc.StateBidderList), wasmlib.TYPE_MAP); - return new sc.MapColorToMutableBidderList(mapID); + return new sc.MapColorToMutableBidderList(this.proxy.root(sc.StateBidderList)); } bids(): sc.MapColorToMutableBids { - let mapID = wasmlib.getObjectID(this.mapID, wasmlib.Key32.fromString(sc.StateBids), wasmlib.TYPE_MAP); - return new sc.MapColorToMutableBids(mapID); + return new sc.MapColorToMutableBids(this.proxy.root(sc.StateBids)); } - ownerMargin(): wasmlib.ScMutableUint64 { - return new wasmlib.ScMutableUint64(this.mapID, wasmlib.Key32.fromString(sc.StateOwnerMargin)); + ownerMargin(): wasmtypes.ScMutableUint64 { + return new wasmtypes.ScMutableUint64(this.proxy.root(sc.StateOwnerMargin)); } } diff --git a/contracts/wasm/fairauction/ts/fairauction/structs.ts b/contracts/wasm/fairauction/ts/fairauction/structs.ts index ea4d18fd7d..6b3321c4ed 100644 --- a/contracts/wasm/fairauction/ts/fairauction/structs.ts +++ b/contracts/wasm/fairauction/ts/fairauction/structs.ts @@ -6,96 +6,83 @@ // Change the json schema instead import * as wasmlib from "wasmlib"; +import * as wasmtypes from "wasmlib/wasmtypes"; export class Auction { - color : wasmlib.ScColor = new wasmlib.ScColor(0); // color of tokens for sale - creator : wasmlib.ScAgentID = new wasmlib.ScAgentID(); // issuer of start_auction transaction + color : wasmtypes.ScColor = new wasmtypes.ScColor(0); // color of tokens for sale + creator : wasmtypes.ScAgentID = wasmtypes.agentIDFromBytes(null); // issuer of start_auction transaction deposit : u64 = 0; // deposit by auction owner to cover the SC fees description : string = ""; // auction description duration : u32 = 0; // auction duration in minutes highestBid : u64 = 0; // the current highest bid amount - highestBidder : wasmlib.ScAgentID = new wasmlib.ScAgentID(); // the current highest bidder + highestBidder : wasmtypes.ScAgentID = wasmtypes.agentIDFromBytes(null); // the current highest bidder minimumBid : u64 = 0; // minimum bid amount numTokens : u64 = 0; // number of tokens for sale ownerMargin : u64 = 0; // auction owner's margin in promilles whenStarted : u64 = 0; // timestamp when auction started - static fromBytes(bytes: u8[]): Auction { - let decode = new wasmlib.BytesDecoder(bytes); - let data = new Auction(); - data.color = decode.color(); - data.creator = decode.agentID(); - data.deposit = decode.uint64(); - data.description = decode.string(); - data.duration = decode.uint32(); - data.highestBid = decode.uint64(); - data.highestBidder = decode.agentID(); - data.minimumBid = decode.uint64(); - data.numTokens = decode.uint64(); - data.ownerMargin = decode.uint64(); - data.whenStarted = decode.uint64(); - decode.close(); + static fromBytes(buf: u8[]|null): Auction { + const dec = new wasmtypes.WasmDecoder(buf); + const data = new Auction(); + data.color = wasmtypes.colorDecode(dec); + data.creator = wasmtypes.agentIDDecode(dec); + data.deposit = wasmtypes.uint64Decode(dec); + data.description = wasmtypes.stringDecode(dec); + data.duration = wasmtypes.uint32Decode(dec); + data.highestBid = wasmtypes.uint64Decode(dec); + data.highestBidder = wasmtypes.agentIDDecode(dec); + data.minimumBid = wasmtypes.uint64Decode(dec); + data.numTokens = wasmtypes.uint64Decode(dec); + data.ownerMargin = wasmtypes.uint64Decode(dec); + data.whenStarted = wasmtypes.uint64Decode(dec); + dec.close(); return data; } bytes(): u8[] { - return new wasmlib.BytesEncoder(). - color(this.color). - agentID(this.creator). - uint64(this.deposit). - string(this.description). - uint32(this.duration). - uint64(this.highestBid). - agentID(this.highestBidder). - uint64(this.minimumBid). - uint64(this.numTokens). - uint64(this.ownerMargin). - uint64(this.whenStarted). - data(); + const enc = new wasmtypes.WasmEncoder(); + wasmtypes.colorEncode(enc, this.color); + wasmtypes.agentIDEncode(enc, this.creator); + wasmtypes.uint64Encode(enc, this.deposit); + wasmtypes.stringEncode(enc, this.description); + wasmtypes.uint32Encode(enc, this.duration); + wasmtypes.uint64Encode(enc, this.highestBid); + wasmtypes.agentIDEncode(enc, this.highestBidder); + wasmtypes.uint64Encode(enc, this.minimumBid); + wasmtypes.uint64Encode(enc, this.numTokens); + wasmtypes.uint64Encode(enc, this.ownerMargin); + wasmtypes.uint64Encode(enc, this.whenStarted); + return enc.buf(); } } -export class ImmutableAuction { - objID: i32; - keyID: wasmlib.Key32; - - constructor(objID: i32, keyID: wasmlib.Key32) { - this.objID = objID; - this.keyID = keyID; - } +export class ImmutableAuction extends wasmtypes.ScProxy { exists(): boolean { - return wasmlib.exists(this.objID, this.keyID, wasmlib.TYPE_BYTES); + return this.proxy.exists(); } value(): Auction { - return Auction.fromBytes(wasmlib.getBytes(this.objID, this.keyID, wasmlib.TYPE_BYTES)); + return Auction.fromBytes(this.proxy.get()); } } -export class MutableAuction { - objID: i32; - keyID: wasmlib.Key32; - - constructor(objID: i32, keyID: wasmlib.Key32) { - this.objID = objID; - this.keyID = keyID; - } +export class MutableAuction extends wasmtypes.ScProxy { delete(): void { - wasmlib.delKey(this.objID, this.keyID, wasmlib.TYPE_BYTES); + this.proxy.delete(); } exists(): boolean { - return wasmlib.exists(this.objID, this.keyID, wasmlib.TYPE_BYTES); + return this.proxy.exists(); } setValue(value: Auction): void { - wasmlib.setBytes(this.objID, this.keyID, wasmlib.TYPE_BYTES, value.bytes()); + this.proxy.set(value.bytes()); } value(): Auction { - return Auction.fromBytes(wasmlib.getBytes(this.objID, this.keyID, wasmlib.TYPE_BYTES)); + return Auction.fromBytes(this.proxy.get()); } } @@ -104,65 +91,51 @@ export class Bid { index : u32 = 0; // index of bidder in bidder list timestamp : u64 = 0; // timestamp of most recent bid - static fromBytes(bytes: u8[]): Bid { - let decode = new wasmlib.BytesDecoder(bytes); - let data = new Bid(); - data.amount = decode.uint64(); - data.index = decode.uint32(); - data.timestamp = decode.uint64(); - decode.close(); + static fromBytes(buf: u8[]|null): Bid { + const dec = new wasmtypes.WasmDecoder(buf); + const data = new Bid(); + data.amount = wasmtypes.uint64Decode(dec); + data.index = wasmtypes.uint32Decode(dec); + data.timestamp = wasmtypes.uint64Decode(dec); + dec.close(); return data; } bytes(): u8[] { - return new wasmlib.BytesEncoder(). - uint64(this.amount). - uint32(this.index). - uint64(this.timestamp). - data(); + const enc = new wasmtypes.WasmEncoder(); + wasmtypes.uint64Encode(enc, this.amount); + wasmtypes.uint32Encode(enc, this.index); + wasmtypes.uint64Encode(enc, this.timestamp); + return enc.buf(); } } -export class ImmutableBid { - objID: i32; - keyID: wasmlib.Key32; - - constructor(objID: i32, keyID: wasmlib.Key32) { - this.objID = objID; - this.keyID = keyID; - } +export class ImmutableBid extends wasmtypes.ScProxy { exists(): boolean { - return wasmlib.exists(this.objID, this.keyID, wasmlib.TYPE_BYTES); + return this.proxy.exists(); } value(): Bid { - return Bid.fromBytes(wasmlib.getBytes(this.objID, this.keyID, wasmlib.TYPE_BYTES)); + return Bid.fromBytes(this.proxy.get()); } } -export class MutableBid { - objID: i32; - keyID: wasmlib.Key32; - - constructor(objID: i32, keyID: wasmlib.Key32) { - this.objID = objID; - this.keyID = keyID; - } +export class MutableBid extends wasmtypes.ScProxy { delete(): void { - wasmlib.delKey(this.objID, this.keyID, wasmlib.TYPE_BYTES); + this.proxy.delete(); } exists(): boolean { - return wasmlib.exists(this.objID, this.keyID, wasmlib.TYPE_BYTES); + return this.proxy.exists(); } setValue(value: Bid): void { - wasmlib.setBytes(this.objID, this.keyID, wasmlib.TYPE_BYTES, value.bytes()); + this.proxy.set(value.bytes()); } value(): Bid { - return Bid.fromBytes(wasmlib.getBytes(this.objID, this.keyID, wasmlib.TYPE_BYTES)); + return Bid.fromBytes(this.proxy.get()); } } diff --git a/contracts/wasm/fairauction/ts/fairauction/typedefs.ts b/contracts/wasm/fairauction/ts/fairauction/typedefs.ts index c642ed281a..4c1da8a0b7 100644 --- a/contracts/wasm/fairauction/ts/fairauction/typedefs.ts +++ b/contracts/wasm/fairauction/ts/fairauction/typedefs.ts @@ -6,78 +6,63 @@ // Change the json schema instead import * as wasmlib from "wasmlib"; +import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; -export class ArrayOfImmutableAgentID { - objID: i32; - - constructor(objID: i32) { - this.objID = objID; - } +export class ArrayOfImmutableAgentID extends wasmtypes.ScProxy { length(): u32 { - return wasmlib.getLength(this.objID); + return this.proxy.length(); } - getAgentID(index: u32): wasmlib.ScImmutableAgentID { - return new wasmlib.ScImmutableAgentID(this.objID, new wasmlib.Key32(index as i32)); + getAgentID(index: u32): wasmtypes.ScImmutableAgentID { + return new wasmtypes.ScImmutableAgentID(this.proxy.index(index)); } } export class ImmutableBidderList extends ArrayOfImmutableAgentID { }; -export class ArrayOfMutableAgentID { - objID: i32; +export class ArrayOfMutableAgentID extends wasmtypes.ScProxy { - constructor(objID: i32) { - this.objID = objID; - } + appendAgentID(): wasmtypes.ScMutableAgentID { + return new wasmtypes.ScMutableAgentID(this.proxy.append()); + } clear(): void { - wasmlib.clear(this.objID); + this.proxy.clearArray(); } length(): u32 { - return wasmlib.getLength(this.objID); + return this.proxy.length(); } - getAgentID(index: u32): wasmlib.ScMutableAgentID { - return new wasmlib.ScMutableAgentID(this.objID, new wasmlib.Key32(index as i32)); + getAgentID(index: u32): wasmtypes.ScMutableAgentID { + return new wasmtypes.ScMutableAgentID(this.proxy.index(index)); } } export class MutableBidderList extends ArrayOfMutableAgentID { }; -export class MapAgentIDToImmutableBid { - objID: i32; +export class MapAgentIDToImmutableBid extends wasmtypes.ScProxy { - constructor(objID: i32) { - this.objID = objID; - } - - getBid(key: wasmlib.ScAgentID): sc.ImmutableBid { - return new sc.ImmutableBid(this.objID, key.getKeyID()); + getBid(key: wasmtypes.ScAgentID): sc.ImmutableBid { + return new sc.ImmutableBid(this.proxy.key(wasmtypes.agentIDToBytes(key))); } } export class ImmutableBids extends MapAgentIDToImmutableBid { }; -export class MapAgentIDToMutableBid { - objID: i32; - - constructor(objID: i32) { - this.objID = objID; - } +export class MapAgentIDToMutableBid extends wasmtypes.ScProxy { clear(): void { - wasmlib.clear(this.objID); + this.proxy.clearMap(); } - getBid(key: wasmlib.ScAgentID): sc.MutableBid { - return new sc.MutableBid(this.objID, key.getKeyID()); + getBid(key: wasmtypes.ScAgentID): sc.MutableBid { + return new sc.MutableBid(this.proxy.key(wasmtypes.agentIDToBytes(key))); } } diff --git a/contracts/wasm/fairroulette/go/fairroulette/lib.go b/contracts/wasm/fairroulette/go/fairroulette/lib.go index d8950efd3d..0234a835bd 100644 --- a/contracts/wasm/fairroulette/go/fairroulette/lib.go +++ b/contracts/wasm/fairroulette/go/fairroulette/lib.go @@ -145,8 +145,8 @@ func viewLastWinningNumberThunk(ctx wasmlib.ScViewContext) { }, } viewLastWinningNumber(ctx, f) - ctx.Log("fairroulette.viewLastWinningNumber ok") ctx.Results(results) + ctx.Log("fairroulette.viewLastWinningNumber ok") } type RoundNumberContext struct { @@ -166,8 +166,8 @@ func viewRoundNumberThunk(ctx wasmlib.ScViewContext) { }, } viewRoundNumber(ctx, f) - ctx.Log("fairroulette.viewRoundNumber ok") ctx.Results(results) + ctx.Log("fairroulette.viewRoundNumber ok") } type RoundStartedAtContext struct { @@ -187,8 +187,8 @@ func viewRoundStartedAtThunk(ctx wasmlib.ScViewContext) { }, } viewRoundStartedAt(ctx, f) - ctx.Log("fairroulette.viewRoundStartedAt ok") ctx.Results(results) + ctx.Log("fairroulette.viewRoundStartedAt ok") } type RoundStatusContext struct { @@ -208,6 +208,6 @@ func viewRoundStatusThunk(ctx wasmlib.ScViewContext) { }, } viewRoundStatus(ctx, f) - ctx.Log("fairroulette.viewRoundStatus ok") ctx.Results(results) + ctx.Log("fairroulette.viewRoundStatus ok") } diff --git a/contracts/wasm/fairroulette/go/fairroulette/structs.go b/contracts/wasm/fairroulette/go/fairroulette/structs.go index fa92b9f25e..2f3e20f0d2 100644 --- a/contracts/wasm/fairroulette/go/fairroulette/structs.go +++ b/contracts/wasm/fairroulette/go/fairroulette/structs.go @@ -18,18 +18,18 @@ type Bet struct { func NewBetFromBytes(buf []byte) *Bet { dec := wasmtypes.NewWasmDecoder(buf) data := &Bet{} - data.Amount = wasmtypes.DecodeUint64(dec) - data.Better = wasmtypes.DecodeAgentID(dec) - data.Number = wasmtypes.DecodeUint16(dec) + data.Amount = wasmtypes.Uint64Decode(dec) + data.Better = wasmtypes.AgentIDDecode(dec) + data.Number = wasmtypes.Uint16Decode(dec) dec.Close() return data } func (o *Bet) Bytes() []byte { enc := wasmtypes.NewWasmEncoder() - wasmtypes.EncodeUint64(enc, o.Amount) - wasmtypes.EncodeAgentID(enc, o.Better) - wasmtypes.EncodeUint16(enc, o.Number) + wasmtypes.Uint64Encode(enc, o.Amount) + wasmtypes.AgentIDEncode(enc, o.Better) + wasmtypes.Uint16Encode(enc, o.Number) return enc.Buf() } diff --git a/contracts/wasm/fairroulette/ts/fairroulette/consts.ts b/contracts/wasm/fairroulette/ts/fairroulette/consts.ts index d930b586af..6ec19d299e 100644 --- a/contracts/wasm/fairroulette/ts/fairroulette/consts.ts +++ b/contracts/wasm/fairroulette/ts/fairroulette/consts.ts @@ -5,11 +5,11 @@ // >>>> DO NOT CHANGE THIS FILE! <<<< // Change the json schema instead -import * as wasmlib from "wasmlib"; +import * as wasmtypes from "wasmlib/wasmtypes"; export const ScName = "fairroulette"; export const ScDescription = ""; -export const HScName = new wasmlib.ScHname(0xdf79d138); +export const HScName = new wasmtypes.ScHname(0xdf79d138); export const ParamNumber = "number"; export const ParamPlayPeriod = "playPeriod"; @@ -36,12 +36,12 @@ export const ViewRoundNumber = "roundNumber"; export const ViewRoundStartedAt = "roundStartedAt"; export const ViewRoundStatus = "roundStatus"; -export const HFuncForcePayout = new wasmlib.ScHname(0x555a4c4f); -export const HFuncForceReset = new wasmlib.ScHname(0xa331951e); -export const HFuncPayWinners = new wasmlib.ScHname(0xfb2b0144); -export const HFuncPlaceBet = new wasmlib.ScHname(0xdfba7d1b); -export const HFuncPlayPeriod = new wasmlib.ScHname(0xcb94b293); -export const HViewLastWinningNumber = new wasmlib.ScHname(0x2f5f09fe); -export const HViewRoundNumber = new wasmlib.ScHname(0x0dcfe520); -export const HViewRoundStartedAt = new wasmlib.ScHname(0x725de8b4); -export const HViewRoundStatus = new wasmlib.ScHname(0x145053b5); +export const HFuncForcePayout = new wasmtypes.ScHname(0x555a4c4f); +export const HFuncForceReset = new wasmtypes.ScHname(0xa331951e); +export const HFuncPayWinners = new wasmtypes.ScHname(0xfb2b0144); +export const HFuncPlaceBet = new wasmtypes.ScHname(0xdfba7d1b); +export const HFuncPlayPeriod = new wasmtypes.ScHname(0xcb94b293); +export const HViewLastWinningNumber = new wasmtypes.ScHname(0x2f5f09fe); +export const HViewRoundNumber = new wasmtypes.ScHname(0x0dcfe520); +export const HViewRoundStartedAt = new wasmtypes.ScHname(0x725de8b4); +export const HViewRoundStatus = new wasmtypes.ScHname(0x145053b5); diff --git a/contracts/wasm/fairroulette/ts/fairroulette/contract.ts b/contracts/wasm/fairroulette/ts/fairroulette/contract.ts index 7b9b6e4bc2..6dc14c6451 100644 --- a/contracts/wasm/fairroulette/ts/fairroulette/contract.ts +++ b/contracts/wasm/fairroulette/ts/fairroulette/contract.ts @@ -6,6 +6,7 @@ // Change the json schema instead import * as wasmlib from "wasmlib"; +import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; export class ForcePayoutCall { @@ -14,7 +15,7 @@ export class ForcePayoutCall { export class ForcePayoutContext { events: sc.FairRouletteEvents = new sc.FairRouletteEvents(); - state: sc.MutableFairRouletteState = new sc.MutableFairRouletteState(); + state: sc.MutableFairRouletteState = new sc.MutableFairRouletteState(wasmlib.ScState.proxy()); } export class ForceResetCall { @@ -23,7 +24,7 @@ export class ForceResetCall { export class ForceResetContext { events: sc.FairRouletteEvents = new sc.FairRouletteEvents(); - state: sc.MutableFairRouletteState = new sc.MutableFairRouletteState(); + state: sc.MutableFairRouletteState = new sc.MutableFairRouletteState(wasmlib.ScState.proxy()); } export class PayWinnersCall { @@ -32,69 +33,69 @@ export class PayWinnersCall { export class PayWinnersContext { events: sc.FairRouletteEvents = new sc.FairRouletteEvents(); - state: sc.MutableFairRouletteState = new sc.MutableFairRouletteState(); + state: sc.MutableFairRouletteState = new sc.MutableFairRouletteState(wasmlib.ScState.proxy()); } export class PlaceBetCall { func: wasmlib.ScFunc = new wasmlib.ScFunc(sc.HScName, sc.HFuncPlaceBet); - params: sc.MutablePlaceBetParams = new sc.MutablePlaceBetParams(); + params: sc.MutablePlaceBetParams = new sc.MutablePlaceBetParams(wasmlib.ScView.nilProxy); } export class PlaceBetContext { events: sc.FairRouletteEvents = new sc.FairRouletteEvents(); - params: sc.ImmutablePlaceBetParams = new sc.ImmutablePlaceBetParams(); - state: sc.MutableFairRouletteState = new sc.MutableFairRouletteState(); + params: sc.ImmutablePlaceBetParams = new sc.ImmutablePlaceBetParams(wasmlib.paramsProxy()); + state: sc.MutableFairRouletteState = new sc.MutableFairRouletteState(wasmlib.ScState.proxy()); } export class PlayPeriodCall { func: wasmlib.ScFunc = new wasmlib.ScFunc(sc.HScName, sc.HFuncPlayPeriod); - params: sc.MutablePlayPeriodParams = new sc.MutablePlayPeriodParams(); + params: sc.MutablePlayPeriodParams = new sc.MutablePlayPeriodParams(wasmlib.ScView.nilProxy); } export class PlayPeriodContext { events: sc.FairRouletteEvents = new sc.FairRouletteEvents(); - params: sc.ImmutablePlayPeriodParams = new sc.ImmutablePlayPeriodParams(); - state: sc.MutableFairRouletteState = new sc.MutableFairRouletteState(); + params: sc.ImmutablePlayPeriodParams = new sc.ImmutablePlayPeriodParams(wasmlib.paramsProxy()); + state: sc.MutableFairRouletteState = new sc.MutableFairRouletteState(wasmlib.ScState.proxy()); } export class LastWinningNumberCall { func: wasmlib.ScView = new wasmlib.ScView(sc.HScName, sc.HViewLastWinningNumber); - results: sc.ImmutableLastWinningNumberResults = new sc.ImmutableLastWinningNumberResults(); + results: sc.ImmutableLastWinningNumberResults = new sc.ImmutableLastWinningNumberResults(wasmlib.ScView.nilProxy); } export class LastWinningNumberContext { - results: sc.MutableLastWinningNumberResults = new sc.MutableLastWinningNumberResults(); - state: sc.ImmutableFairRouletteState = new sc.ImmutableFairRouletteState(); + results: sc.MutableLastWinningNumberResults = new sc.MutableLastWinningNumberResults(wasmlib.ScView.nilProxy); + state: sc.ImmutableFairRouletteState = new sc.ImmutableFairRouletteState(wasmlib.ScState.proxy()); } export class RoundNumberCall { func: wasmlib.ScView = new wasmlib.ScView(sc.HScName, sc.HViewRoundNumber); - results: sc.ImmutableRoundNumberResults = new sc.ImmutableRoundNumberResults(); + results: sc.ImmutableRoundNumberResults = new sc.ImmutableRoundNumberResults(wasmlib.ScView.nilProxy); } export class RoundNumberContext { - results: sc.MutableRoundNumberResults = new sc.MutableRoundNumberResults(); - state: sc.ImmutableFairRouletteState = new sc.ImmutableFairRouletteState(); + results: sc.MutableRoundNumberResults = new sc.MutableRoundNumberResults(wasmlib.ScView.nilProxy); + state: sc.ImmutableFairRouletteState = new sc.ImmutableFairRouletteState(wasmlib.ScState.proxy()); } export class RoundStartedAtCall { func: wasmlib.ScView = new wasmlib.ScView(sc.HScName, sc.HViewRoundStartedAt); - results: sc.ImmutableRoundStartedAtResults = new sc.ImmutableRoundStartedAtResults(); + results: sc.ImmutableRoundStartedAtResults = new sc.ImmutableRoundStartedAtResults(wasmlib.ScView.nilProxy); } export class RoundStartedAtContext { - results: sc.MutableRoundStartedAtResults = new sc.MutableRoundStartedAtResults(); - state: sc.ImmutableFairRouletteState = new sc.ImmutableFairRouletteState(); + results: sc.MutableRoundStartedAtResults = new sc.MutableRoundStartedAtResults(wasmlib.ScView.nilProxy); + state: sc.ImmutableFairRouletteState = new sc.ImmutableFairRouletteState(wasmlib.ScState.proxy()); } export class RoundStatusCall { func: wasmlib.ScView = new wasmlib.ScView(sc.HScName, sc.HViewRoundStatus); - results: sc.ImmutableRoundStatusResults = new sc.ImmutableRoundStatusResults(); + results: sc.ImmutableRoundStatusResults = new sc.ImmutableRoundStatusResults(wasmlib.ScView.nilProxy); } export class RoundStatusContext { - results: sc.MutableRoundStatusResults = new sc.MutableRoundStatusResults(); - state: sc.ImmutableFairRouletteState = new sc.ImmutableFairRouletteState(); + results: sc.MutableRoundStatusResults = new sc.MutableRoundStatusResults(wasmlib.ScView.nilProxy); + state: sc.ImmutableFairRouletteState = new sc.ImmutableFairRouletteState(wasmlib.ScState.proxy()); } export class ScFuncs { @@ -111,38 +112,38 @@ export class ScFuncs { } static placeBet(ctx: wasmlib.ScFuncCallContext): PlaceBetCall { - let f = new PlaceBetCall(); - f.func.setPtrs(f.params, null); + const f = new PlaceBetCall(); + f.params = new sc.MutablePlaceBetParams(wasmlib.newCallParamsProxy(f.func)); return f; } static playPeriod(ctx: wasmlib.ScFuncCallContext): PlayPeriodCall { - let f = new PlayPeriodCall(); - f.func.setPtrs(f.params, null); + const f = new PlayPeriodCall(); + f.params = new sc.MutablePlayPeriodParams(wasmlib.newCallParamsProxy(f.func)); return f; } static lastWinningNumber(ctx: wasmlib.ScViewCallContext): LastWinningNumberCall { - let f = new LastWinningNumberCall(); - f.func.setPtrs(null, f.results); + const f = new LastWinningNumberCall(); + f.results = new sc.ImmutableLastWinningNumberResults(wasmlib.newCallResultsProxy(f.func)); return f; } static roundNumber(ctx: wasmlib.ScViewCallContext): RoundNumberCall { - let f = new RoundNumberCall(); - f.func.setPtrs(null, f.results); + const f = new RoundNumberCall(); + f.results = new sc.ImmutableRoundNumberResults(wasmlib.newCallResultsProxy(f.func)); return f; } static roundStartedAt(ctx: wasmlib.ScViewCallContext): RoundStartedAtCall { - let f = new RoundStartedAtCall(); - f.func.setPtrs(null, f.results); + const f = new RoundStartedAtCall(); + f.results = new sc.ImmutableRoundStartedAtResults(wasmlib.newCallResultsProxy(f.func)); return f; } static roundStatus(ctx: wasmlib.ScViewCallContext): RoundStatusCall { - let f = new RoundStatusCall(); - f.func.setPtrs(null, f.results); + const f = new RoundStatusCall(); + f.results = new sc.ImmutableRoundStatusResults(wasmlib.newCallResultsProxy(f.func)); return f; } } diff --git a/contracts/wasm/fairroulette/ts/fairroulette/events.ts b/contracts/wasm/fairroulette/ts/fairroulette/events.ts index 7c544d63bd..64a405c213 100644 --- a/contracts/wasm/fairroulette/ts/fairroulette/events.ts +++ b/contracts/wasm/fairroulette/ts/fairroulette/events.ts @@ -6,43 +6,44 @@ // Change the json schema instead import * as wasmlib from "wasmlib"; +import * as wasmtypes from "wasmlib/wasmtypes"; export class FairRouletteEvents { - bet(address: wasmlib.ScAddress, amount: u64, number: u16): void { - new wasmlib.EventEncoder("fairroulette.bet"). - address(address). - uint64(amount). - uint16(number). - emit(); + bet(address: wasmtypes.ScAddress, amount: u64, number: u16): void { + const evt = new wasmlib.EventEncoder("fairroulette.bet"); + evt.encode(wasmtypes.addressToString(address)); + evt.encode(wasmtypes.uint64ToString(amount)); + evt.encode(wasmtypes.uint16ToString(number)); + evt.emit(); } - payout(address: wasmlib.ScAddress, amount: u64): void { - new wasmlib.EventEncoder("fairroulette.payout"). - address(address). - uint64(amount). - emit(); + payout(address: wasmtypes.ScAddress, amount: u64): void { + const evt = new wasmlib.EventEncoder("fairroulette.payout"); + evt.encode(wasmtypes.addressToString(address)); + evt.encode(wasmtypes.uint64ToString(amount)); + evt.emit(); } round(number: u32): void { - new wasmlib.EventEncoder("fairroulette.round"). - uint32(number). - emit(); + const evt = new wasmlib.EventEncoder("fairroulette.round"); + evt.encode(wasmtypes.uint32ToString(number)); + evt.emit(); } start(): void { - new wasmlib.EventEncoder("fairroulette.start"). - emit(); + const evt = new wasmlib.EventEncoder("fairroulette.start"); + evt.emit(); } stop(): void { - new wasmlib.EventEncoder("fairroulette.stop"). - emit(); + const evt = new wasmlib.EventEncoder("fairroulette.stop"); + evt.emit(); } winner(number: u16): void { - new wasmlib.EventEncoder("fairroulette.winner"). - uint16(number). - emit(); + const evt = new wasmlib.EventEncoder("fairroulette.winner"); + evt.encode(wasmtypes.uint16ToString(number)); + evt.emit(); } } diff --git a/contracts/wasm/fairroulette/ts/fairroulette/fairroulette.ts b/contracts/wasm/fairroulette/ts/fairroulette/fairroulette.ts index 860b5f05f0..653fbae2f0 100644 --- a/contracts/wasm/fairroulette/ts/fairroulette/fairroulette.ts +++ b/contracts/wasm/fairroulette/ts/fairroulette/fairroulette.ts @@ -8,6 +8,7 @@ // through a minimal implementation and not to come up with a complete real-world solution. import * as wasmlib from "wasmlib" +import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; // Define some default configuration parameters. @@ -36,7 +37,8 @@ export function funcPlaceBet(ctx: wasmlib.ScFuncContext, f: sc.PlaceBetContext): // Get the array of current bets from state storage. let bets: sc.ArrayOfMutableBet = f.state.bets(); - for (let i: u32 = 0; i < bets.length(); i++) { + const nrBets = bets.length(); + for (let i: u32 = 0; i < nrBets; i++) { let bet: sc.Bet = bets.getBet(i).value(); if (bet.better.address() == ctx.caller().address()) { @@ -57,7 +59,7 @@ export function funcPlaceBet(ctx: wasmlib.ScFuncContext, f: sc.PlaceBetContext): let incoming: wasmlib.ScBalances = ctx.incoming(); // Retrieve the amount of plain iota tokens that are part of the incoming balance. - let amount: u64 = incoming.balance(wasmlib.ScColor.IOTA); + let amount: u64 = incoming.balance(wasmtypes.IOTA); // Require that there are actually some plain iotas there ctx.require(amount > 0, "empty bet"); @@ -75,7 +77,7 @@ export function funcPlaceBet(ctx: wasmlib.ScFuncContext, f: sc.PlaceBetContext): // Append the bet data to the bets array. The bet array will automatically take care // of serializing the bet struct into a bytes representation. - bets.getBet(betNr).setValue(bet); + bets.appendBet().setValue(bet); f.events.bet(bet.better.address(), bet.amount, bet.number); diff --git a/contracts/wasm/fairroulette/ts/fairroulette/index.ts b/contracts/wasm/fairroulette/ts/fairroulette/index.ts index a14f6af431..31dc75a2bc 100644 --- a/contracts/wasm/fairroulette/ts/fairroulette/index.ts +++ b/contracts/wasm/fairroulette/ts/fairroulette/index.ts @@ -10,7 +10,6 @@ export * from "./fairroulette"; export * from "./consts"; export * from "./contract"; export * from "./events"; -export * from "./keys"; export * from "./lib"; export * from "./params"; export * from "./results"; diff --git a/contracts/wasm/fairroulette/ts/fairroulette/keys.ts b/contracts/wasm/fairroulette/ts/fairroulette/keys.ts index 46895b797f..300e156672 100644 --- a/contracts/wasm/fairroulette/ts/fairroulette/keys.ts +++ b/contracts/wasm/fairroulette/ts/fairroulette/keys.ts @@ -5,37 +5,6 @@ // >>>> DO NOT CHANGE THIS FILE! <<<< // Change the json schema instead -import * as wasmlib from "wasmlib"; -import * as sc from "./index"; export const IdxParamNumber = 0; export const IdxParamPlayPeriod = 1; - -export const IdxResultLastWinningNumber = 2; -export const IdxResultRoundNumber = 3; -export const IdxResultRoundStartedAt = 4; -export const IdxResultRoundStatus = 5; - -export const IdxStateBets = 6; -export const IdxStateLastWinningNumber = 7; -export const IdxStatePlayPeriod = 8; -export const IdxStateRoundNumber = 9; -export const IdxStateRoundStartedAt = 10; -export const IdxStateRoundStatus = 11; - -export let keyMap: string[] = [ - sc.ParamNumber, - sc.ParamPlayPeriod, - sc.ResultLastWinningNumber, - sc.ResultRoundNumber, - sc.ResultRoundStartedAt, - sc.ResultRoundStatus, - sc.StateBets, - sc.StateLastWinningNumber, - sc.StatePlayPeriod, - sc.StateRoundNumber, - sc.StateRoundStartedAt, - sc.StateRoundStatus, -]; - -export let idxMap: wasmlib.Key32[] = new Array(keyMap.length); diff --git a/contracts/wasm/fairroulette/ts/fairroulette/lib.ts b/contracts/wasm/fairroulette/ts/fairroulette/lib.ts index e19135eaba..744c8d2c39 100644 --- a/contracts/wasm/fairroulette/ts/fairroulette/lib.ts +++ b/contracts/wasm/fairroulette/ts/fairroulette/lib.ts @@ -6,6 +6,7 @@ // Change the json schema instead import * as wasmlib from "wasmlib"; +import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; export function on_call(index: i32): void { @@ -23,44 +24,37 @@ export function on_load(): void { exports.addView(sc.ViewRoundNumber, viewRoundNumberThunk); exports.addView(sc.ViewRoundStartedAt, viewRoundStartedAtThunk); exports.addView(sc.ViewRoundStatus, viewRoundStatusThunk); - - for (let i = 0; i < sc.keyMap.length; i++) { - sc.idxMap[i] = wasmlib.Key32.fromString(sc.keyMap[i]); - } } function funcForcePayoutThunk(ctx: wasmlib.ScFuncContext): void { ctx.log("fairroulette.funcForcePayout"); + let f = new sc.ForcePayoutContext(); // only SC creator can restart the round forcefully ctx.require(ctx.caller().equals(ctx.contractCreator()), "no permission"); - let f = new sc.ForcePayoutContext(); - f.state.mapID = wasmlib.OBJ_ID_STATE; sc.funcForcePayout(ctx, f); ctx.log("fairroulette.funcForcePayout ok"); } function funcForceResetThunk(ctx: wasmlib.ScFuncContext): void { ctx.log("fairroulette.funcForceReset"); + let f = new sc.ForceResetContext(); // only SC creator can restart the round forcefully ctx.require(ctx.caller().equals(ctx.contractCreator()), "no permission"); - let f = new sc.ForceResetContext(); - f.state.mapID = wasmlib.OBJ_ID_STATE; sc.funcForceReset(ctx, f); ctx.log("fairroulette.funcForceReset ok"); } function funcPayWinnersThunk(ctx: wasmlib.ScFuncContext): void { ctx.log("fairroulette.funcPayWinners"); + let f = new sc.PayWinnersContext(); // only SC itself can invoke this function ctx.require(ctx.caller().equals(ctx.accountID()), "no permission"); - let f = new sc.PayWinnersContext(); - f.state.mapID = wasmlib.OBJ_ID_STATE; sc.funcPayWinners(ctx, f); ctx.log("fairroulette.funcPayWinners ok"); } @@ -68,8 +62,6 @@ function funcPayWinnersThunk(ctx: wasmlib.ScFuncContext): void { function funcPlaceBetThunk(ctx: wasmlib.ScFuncContext): void { ctx.log("fairroulette.funcPlaceBet"); let f = new sc.PlaceBetContext(); - f.params.mapID = wasmlib.OBJ_ID_PARAMS; - f.state.mapID = wasmlib.OBJ_ID_STATE; ctx.require(f.params.number().exists(), "missing mandatory number"); sc.funcPlaceBet(ctx, f); ctx.log("fairroulette.funcPlaceBet ok"); @@ -77,13 +69,11 @@ function funcPlaceBetThunk(ctx: wasmlib.ScFuncContext): void { function funcPlayPeriodThunk(ctx: wasmlib.ScFuncContext): void { ctx.log("fairroulette.funcPlayPeriod"); + let f = new sc.PlayPeriodContext(); // only SC creator can update the play period ctx.require(ctx.caller().equals(ctx.contractCreator()), "no permission"); - let f = new sc.PlayPeriodContext(); - f.params.mapID = wasmlib.OBJ_ID_PARAMS; - f.state.mapID = wasmlib.OBJ_ID_STATE; ctx.require(f.params.playPeriod().exists(), "missing mandatory playPeriod"); sc.funcPlayPeriod(ctx, f); ctx.log("fairroulette.funcPlayPeriod ok"); @@ -92,35 +82,39 @@ function funcPlayPeriodThunk(ctx: wasmlib.ScFuncContext): void { function viewLastWinningNumberThunk(ctx: wasmlib.ScViewContext): void { ctx.log("fairroulette.viewLastWinningNumber"); let f = new sc.LastWinningNumberContext(); - f.results.mapID = wasmlib.OBJ_ID_RESULTS; - f.state.mapID = wasmlib.OBJ_ID_STATE; + const results = new wasmlib.ScDict([]); + f.results = new sc.MutableLastWinningNumberResults(results.asProxy()); sc.viewLastWinningNumber(ctx, f); + ctx.results(results); ctx.log("fairroulette.viewLastWinningNumber ok"); } function viewRoundNumberThunk(ctx: wasmlib.ScViewContext): void { ctx.log("fairroulette.viewRoundNumber"); let f = new sc.RoundNumberContext(); - f.results.mapID = wasmlib.OBJ_ID_RESULTS; - f.state.mapID = wasmlib.OBJ_ID_STATE; + const results = new wasmlib.ScDict([]); + f.results = new sc.MutableRoundNumberResults(results.asProxy()); sc.viewRoundNumber(ctx, f); + ctx.results(results); ctx.log("fairroulette.viewRoundNumber ok"); } function viewRoundStartedAtThunk(ctx: wasmlib.ScViewContext): void { ctx.log("fairroulette.viewRoundStartedAt"); let f = new sc.RoundStartedAtContext(); - f.results.mapID = wasmlib.OBJ_ID_RESULTS; - f.state.mapID = wasmlib.OBJ_ID_STATE; + const results = new wasmlib.ScDict([]); + f.results = new sc.MutableRoundStartedAtResults(results.asProxy()); sc.viewRoundStartedAt(ctx, f); + ctx.results(results); ctx.log("fairroulette.viewRoundStartedAt ok"); } function viewRoundStatusThunk(ctx: wasmlib.ScViewContext): void { ctx.log("fairroulette.viewRoundStatus"); let f = new sc.RoundStatusContext(); - f.results.mapID = wasmlib.OBJ_ID_RESULTS; - f.state.mapID = wasmlib.OBJ_ID_STATE; + const results = new wasmlib.ScDict([]); + f.results = new sc.MutableRoundStatusResults(results.asProxy()); sc.viewRoundStatus(ctx, f); + ctx.results(results); ctx.log("fairroulette.viewRoundStatus ok"); } diff --git a/contracts/wasm/fairroulette/ts/fairroulette/params.ts b/contracts/wasm/fairroulette/ts/fairroulette/params.ts index 0fd690ffc8..027f894572 100644 --- a/contracts/wasm/fairroulette/ts/fairroulette/params.ts +++ b/contracts/wasm/fairroulette/ts/fairroulette/params.ts @@ -6,28 +6,29 @@ // Change the json schema instead import * as wasmlib from "wasmlib"; +import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; -export class ImmutablePlaceBetParams extends wasmlib.ScMapID { - number(): wasmlib.ScImmutableUint16 { - return new wasmlib.ScImmutableUint16(this.mapID, wasmlib.Key32.fromString(sc.ParamNumber)); +export class ImmutablePlaceBetParams extends wasmtypes.ScProxy { + number(): wasmtypes.ScImmutableUint16 { + return new wasmtypes.ScImmutableUint16(this.proxy.root(sc.ParamNumber)); } } -export class MutablePlaceBetParams extends wasmlib.ScMapID { - number(): wasmlib.ScMutableUint16 { - return new wasmlib.ScMutableUint16(this.mapID, wasmlib.Key32.fromString(sc.ParamNumber)); +export class MutablePlaceBetParams extends wasmtypes.ScProxy { + number(): wasmtypes.ScMutableUint16 { + return new wasmtypes.ScMutableUint16(this.proxy.root(sc.ParamNumber)); } } -export class ImmutablePlayPeriodParams extends wasmlib.ScMapID { - playPeriod(): wasmlib.ScImmutableUint32 { - return new wasmlib.ScImmutableUint32(this.mapID, wasmlib.Key32.fromString(sc.ParamPlayPeriod)); +export class ImmutablePlayPeriodParams extends wasmtypes.ScProxy { + playPeriod(): wasmtypes.ScImmutableUint32 { + return new wasmtypes.ScImmutableUint32(this.proxy.root(sc.ParamPlayPeriod)); } } -export class MutablePlayPeriodParams extends wasmlib.ScMapID { - playPeriod(): wasmlib.ScMutableUint32 { - return new wasmlib.ScMutableUint32(this.mapID, wasmlib.Key32.fromString(sc.ParamPlayPeriod)); +export class MutablePlayPeriodParams extends wasmtypes.ScProxy { + playPeriod(): wasmtypes.ScMutableUint32 { + return new wasmtypes.ScMutableUint32(this.proxy.root(sc.ParamPlayPeriod)); } } diff --git a/contracts/wasm/fairroulette/ts/fairroulette/results.ts b/contracts/wasm/fairroulette/ts/fairroulette/results.ts index 8482f00d34..8fe98adab7 100644 --- a/contracts/wasm/fairroulette/ts/fairroulette/results.ts +++ b/contracts/wasm/fairroulette/ts/fairroulette/results.ts @@ -6,52 +6,53 @@ // Change the json schema instead import * as wasmlib from "wasmlib"; +import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; -export class ImmutableLastWinningNumberResults extends wasmlib.ScMapID { - lastWinningNumber(): wasmlib.ScImmutableUint16 { - return new wasmlib.ScImmutableUint16(this.mapID, wasmlib.Key32.fromString(sc.ResultLastWinningNumber)); +export class ImmutableLastWinningNumberResults extends wasmtypes.ScProxy { + lastWinningNumber(): wasmtypes.ScImmutableUint16 { + return new wasmtypes.ScImmutableUint16(this.proxy.root(sc.ResultLastWinningNumber)); } } -export class MutableLastWinningNumberResults extends wasmlib.ScMapID { - lastWinningNumber(): wasmlib.ScMutableUint16 { - return new wasmlib.ScMutableUint16(this.mapID, wasmlib.Key32.fromString(sc.ResultLastWinningNumber)); +export class MutableLastWinningNumberResults extends wasmtypes.ScProxy { + lastWinningNumber(): wasmtypes.ScMutableUint16 { + return new wasmtypes.ScMutableUint16(this.proxy.root(sc.ResultLastWinningNumber)); } } -export class ImmutableRoundNumberResults extends wasmlib.ScMapID { - roundNumber(): wasmlib.ScImmutableUint32 { - return new wasmlib.ScImmutableUint32(this.mapID, wasmlib.Key32.fromString(sc.ResultRoundNumber)); +export class ImmutableRoundNumberResults extends wasmtypes.ScProxy { + roundNumber(): wasmtypes.ScImmutableUint32 { + return new wasmtypes.ScImmutableUint32(this.proxy.root(sc.ResultRoundNumber)); } } -export class MutableRoundNumberResults extends wasmlib.ScMapID { - roundNumber(): wasmlib.ScMutableUint32 { - return new wasmlib.ScMutableUint32(this.mapID, wasmlib.Key32.fromString(sc.ResultRoundNumber)); +export class MutableRoundNumberResults extends wasmtypes.ScProxy { + roundNumber(): wasmtypes.ScMutableUint32 { + return new wasmtypes.ScMutableUint32(this.proxy.root(sc.ResultRoundNumber)); } } -export class ImmutableRoundStartedAtResults extends wasmlib.ScMapID { - roundStartedAt(): wasmlib.ScImmutableUint32 { - return new wasmlib.ScImmutableUint32(this.mapID, wasmlib.Key32.fromString(sc.ResultRoundStartedAt)); +export class ImmutableRoundStartedAtResults extends wasmtypes.ScProxy { + roundStartedAt(): wasmtypes.ScImmutableUint32 { + return new wasmtypes.ScImmutableUint32(this.proxy.root(sc.ResultRoundStartedAt)); } } -export class MutableRoundStartedAtResults extends wasmlib.ScMapID { - roundStartedAt(): wasmlib.ScMutableUint32 { - return new wasmlib.ScMutableUint32(this.mapID, wasmlib.Key32.fromString(sc.ResultRoundStartedAt)); +export class MutableRoundStartedAtResults extends wasmtypes.ScProxy { + roundStartedAt(): wasmtypes.ScMutableUint32 { + return new wasmtypes.ScMutableUint32(this.proxy.root(sc.ResultRoundStartedAt)); } } -export class ImmutableRoundStatusResults extends wasmlib.ScMapID { - roundStatus(): wasmlib.ScImmutableUint16 { - return new wasmlib.ScImmutableUint16(this.mapID, wasmlib.Key32.fromString(sc.ResultRoundStatus)); +export class ImmutableRoundStatusResults extends wasmtypes.ScProxy { + roundStatus(): wasmtypes.ScImmutableUint16 { + return new wasmtypes.ScImmutableUint16(this.proxy.root(sc.ResultRoundStatus)); } } -export class MutableRoundStatusResults extends wasmlib.ScMapID { - roundStatus(): wasmlib.ScMutableUint16 { - return new wasmlib.ScMutableUint16(this.mapID, wasmlib.Key32.fromString(sc.ResultRoundStatus)); +export class MutableRoundStatusResults extends wasmtypes.ScProxy { + roundStatus(): wasmtypes.ScMutableUint16 { + return new wasmtypes.ScMutableUint16(this.proxy.root(sc.ResultRoundStatus)); } } diff --git a/contracts/wasm/fairroulette/ts/fairroulette/state.ts b/contracts/wasm/fairroulette/ts/fairroulette/state.ts index 90bfaee63b..29f44c82ae 100644 --- a/contracts/wasm/fairroulette/ts/fairroulette/state.ts +++ b/contracts/wasm/fairroulette/ts/fairroulette/state.ts @@ -6,100 +6,91 @@ // Change the json schema instead import * as wasmlib from "wasmlib"; +import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; -export class ArrayOfImmutableBet { - objID: i32; - - constructor(objID: i32) { - this.objID = objID; - } +export class ArrayOfImmutableBet extends wasmtypes.ScProxy { length(): u32 { - return wasmlib.getLength(this.objID); + return this.proxy.length(); } getBet(index: u32): sc.ImmutableBet { - return new sc.ImmutableBet(this.objID, new wasmlib.Key32(index as i32)); + return new sc.ImmutableBet(this.proxy.index(index)); } } -export class ImmutableFairRouletteState extends wasmlib.ScMapID { +export class ImmutableFairRouletteState extends wasmtypes.ScProxy { bets(): sc.ArrayOfImmutableBet { - let arrID = wasmlib.getObjectID(this.mapID, wasmlib.Key32.fromString(sc.StateBets), wasmlib.TYPE_ARRAY|wasmlib.TYPE_BYTES); - return new sc.ArrayOfImmutableBet(arrID); + return new sc.ArrayOfImmutableBet(this.proxy.root(sc.StateBets)); } - lastWinningNumber(): wasmlib.ScImmutableUint16 { - return new wasmlib.ScImmutableUint16(this.mapID, wasmlib.Key32.fromString(sc.StateLastWinningNumber)); + lastWinningNumber(): wasmtypes.ScImmutableUint16 { + return new wasmtypes.ScImmutableUint16(this.proxy.root(sc.StateLastWinningNumber)); } - playPeriod(): wasmlib.ScImmutableUint32 { - return new wasmlib.ScImmutableUint32(this.mapID, wasmlib.Key32.fromString(sc.StatePlayPeriod)); + playPeriod(): wasmtypes.ScImmutableUint32 { + return new wasmtypes.ScImmutableUint32(this.proxy.root(sc.StatePlayPeriod)); } - roundNumber(): wasmlib.ScImmutableUint32 { - return new wasmlib.ScImmutableUint32(this.mapID, wasmlib.Key32.fromString(sc.StateRoundNumber)); + roundNumber(): wasmtypes.ScImmutableUint32 { + return new wasmtypes.ScImmutableUint32(this.proxy.root(sc.StateRoundNumber)); } - roundStartedAt(): wasmlib.ScImmutableUint32 { - return new wasmlib.ScImmutableUint32(this.mapID, wasmlib.Key32.fromString(sc.StateRoundStartedAt)); + roundStartedAt(): wasmtypes.ScImmutableUint32 { + return new wasmtypes.ScImmutableUint32(this.proxy.root(sc.StateRoundStartedAt)); } - roundStatus(): wasmlib.ScImmutableUint16 { - return new wasmlib.ScImmutableUint16(this.mapID, wasmlib.Key32.fromString(sc.StateRoundStatus)); + roundStatus(): wasmtypes.ScImmutableUint16 { + return new wasmtypes.ScImmutableUint16(this.proxy.root(sc.StateRoundStatus)); } } -export class ArrayOfMutableBet { - objID: i32; +export class ArrayOfMutableBet extends wasmtypes.ScProxy { - constructor(objID: i32) { - this.objID = objID; - } + appendBet(): sc.MutableBet { + return new sc.MutableBet(this.proxy.append()); + } clear(): void { - wasmlib.clear(this.objID); + this.proxy.clearArray(); } length(): u32 { - return wasmlib.getLength(this.objID); + return this.proxy.length(); } getBet(index: u32): sc.MutableBet { - return new sc.MutableBet(this.objID, new wasmlib.Key32(index as i32)); + return new sc.MutableBet(this.proxy.index(index)); } } -export class MutableFairRouletteState extends wasmlib.ScMapID { +export class MutableFairRouletteState extends wasmtypes.ScProxy { asImmutable(): sc.ImmutableFairRouletteState { - const imm = new sc.ImmutableFairRouletteState(); - imm.mapID = this.mapID; - return imm; + return new sc.ImmutableFairRouletteState(this.proxy); } bets(): sc.ArrayOfMutableBet { - let arrID = wasmlib.getObjectID(this.mapID, wasmlib.Key32.fromString(sc.StateBets), wasmlib.TYPE_ARRAY|wasmlib.TYPE_BYTES); - return new sc.ArrayOfMutableBet(arrID); + return new sc.ArrayOfMutableBet(this.proxy.root(sc.StateBets)); } - lastWinningNumber(): wasmlib.ScMutableUint16 { - return new wasmlib.ScMutableUint16(this.mapID, wasmlib.Key32.fromString(sc.StateLastWinningNumber)); + lastWinningNumber(): wasmtypes.ScMutableUint16 { + return new wasmtypes.ScMutableUint16(this.proxy.root(sc.StateLastWinningNumber)); } - playPeriod(): wasmlib.ScMutableUint32 { - return new wasmlib.ScMutableUint32(this.mapID, wasmlib.Key32.fromString(sc.StatePlayPeriod)); + playPeriod(): wasmtypes.ScMutableUint32 { + return new wasmtypes.ScMutableUint32(this.proxy.root(sc.StatePlayPeriod)); } - roundNumber(): wasmlib.ScMutableUint32 { - return new wasmlib.ScMutableUint32(this.mapID, wasmlib.Key32.fromString(sc.StateRoundNumber)); + roundNumber(): wasmtypes.ScMutableUint32 { + return new wasmtypes.ScMutableUint32(this.proxy.root(sc.StateRoundNumber)); } - roundStartedAt(): wasmlib.ScMutableUint32 { - return new wasmlib.ScMutableUint32(this.mapID, wasmlib.Key32.fromString(sc.StateRoundStartedAt)); + roundStartedAt(): wasmtypes.ScMutableUint32 { + return new wasmtypes.ScMutableUint32(this.proxy.root(sc.StateRoundStartedAt)); } - roundStatus(): wasmlib.ScMutableUint16 { - return new wasmlib.ScMutableUint16(this.mapID, wasmlib.Key32.fromString(sc.StateRoundStatus)); + roundStatus(): wasmtypes.ScMutableUint16 { + return new wasmtypes.ScMutableUint16(this.proxy.root(sc.StateRoundStatus)); } } diff --git a/contracts/wasm/fairroulette/ts/fairroulette/structs.ts b/contracts/wasm/fairroulette/ts/fairroulette/structs.ts index 1c4f21646b..0f8f9886eb 100644 --- a/contracts/wasm/fairroulette/ts/fairroulette/structs.ts +++ b/contracts/wasm/fairroulette/ts/fairroulette/structs.ts @@ -6,71 +6,58 @@ // Change the json schema instead import * as wasmlib from "wasmlib"; +import * as wasmtypes from "wasmlib/wasmtypes"; export class Bet { amount : u64 = 0; - better : wasmlib.ScAgentID = new wasmlib.ScAgentID(); + better : wasmtypes.ScAgentID = wasmtypes.agentIDFromBytes(null); number : u16 = 0; - static fromBytes(bytes: u8[]): Bet { - let decode = new wasmlib.BytesDecoder(bytes); - let data = new Bet(); - data.amount = decode.uint64(); - data.better = decode.agentID(); - data.number = decode.uint16(); - decode.close(); + static fromBytes(buf: u8[]|null): Bet { + const dec = new wasmtypes.WasmDecoder(buf); + const data = new Bet(); + data.amount = wasmtypes.uint64Decode(dec); + data.better = wasmtypes.agentIDDecode(dec); + data.number = wasmtypes.uint16Decode(dec); + dec.close(); return data; } bytes(): u8[] { - return new wasmlib.BytesEncoder(). - uint64(this.amount). - agentID(this.better). - uint16(this.number). - data(); + const enc = new wasmtypes.WasmEncoder(); + wasmtypes.uint64Encode(enc, this.amount); + wasmtypes.agentIDEncode(enc, this.better); + wasmtypes.uint16Encode(enc, this.number); + return enc.buf(); } } -export class ImmutableBet { - objID: i32; - keyID: wasmlib.Key32; - - constructor(objID: i32, keyID: wasmlib.Key32) { - this.objID = objID; - this.keyID = keyID; - } +export class ImmutableBet extends wasmtypes.ScProxy { exists(): boolean { - return wasmlib.exists(this.objID, this.keyID, wasmlib.TYPE_BYTES); + return this.proxy.exists(); } value(): Bet { - return Bet.fromBytes(wasmlib.getBytes(this.objID, this.keyID, wasmlib.TYPE_BYTES)); + return Bet.fromBytes(this.proxy.get()); } } -export class MutableBet { - objID: i32; - keyID: wasmlib.Key32; - - constructor(objID: i32, keyID: wasmlib.Key32) { - this.objID = objID; - this.keyID = keyID; - } +export class MutableBet extends wasmtypes.ScProxy { delete(): void { - wasmlib.delKey(this.objID, this.keyID, wasmlib.TYPE_BYTES); + this.proxy.delete(); } exists(): boolean { - return wasmlib.exists(this.objID, this.keyID, wasmlib.TYPE_BYTES); + return this.proxy.exists(); } setValue(value: Bet): void { - wasmlib.setBytes(this.objID, this.keyID, wasmlib.TYPE_BYTES, value.bytes()); + this.proxy.set(value.bytes()); } value(): Bet { - return Bet.fromBytes(wasmlib.getBytes(this.objID, this.keyID, wasmlib.TYPE_BYTES)); + return Bet.fromBytes(this.proxy.get()); } } diff --git a/contracts/wasm/helloworld/go/helloworld/lib.go b/contracts/wasm/helloworld/go/helloworld/lib.go index 0ee0ce2139..c7e912cd44 100644 --- a/contracts/wasm/helloworld/go/helloworld/lib.go +++ b/contracts/wasm/helloworld/go/helloworld/lib.go @@ -47,6 +47,6 @@ func viewGetHelloWorldThunk(ctx wasmlib.ScViewContext) { }, } viewGetHelloWorld(ctx, f) - ctx.Log("helloworld.viewGetHelloWorld ok") ctx.Results(results) + ctx.Log("helloworld.viewGetHelloWorld ok") } diff --git a/contracts/wasm/helloworld/ts/helloworld/consts.ts b/contracts/wasm/helloworld/ts/helloworld/consts.ts index d52c7a618a..802b2638fc 100644 --- a/contracts/wasm/helloworld/ts/helloworld/consts.ts +++ b/contracts/wasm/helloworld/ts/helloworld/consts.ts @@ -5,16 +5,16 @@ // >>>> DO NOT CHANGE THIS FILE! <<<< // Change the json schema instead -import * as wasmlib from "wasmlib"; +import * as wasmtypes from "wasmlib/wasmtypes"; export const ScName = "helloworld"; export const ScDescription = "The ubiquitous hello world demo"; -export const HScName = new wasmlib.ScHname(0x0683223c); +export const HScName = new wasmtypes.ScHname(0x0683223c); export const ResultHelloWorld = "helloWorld"; export const FuncHelloWorld = "helloWorld"; export const ViewGetHelloWorld = "getHelloWorld"; -export const HFuncHelloWorld = new wasmlib.ScHname(0x9d042e65); -export const HViewGetHelloWorld = new wasmlib.ScHname(0x210439ce); +export const HFuncHelloWorld = new wasmtypes.ScHname(0x9d042e65); +export const HViewGetHelloWorld = new wasmtypes.ScHname(0x210439ce); diff --git a/contracts/wasm/helloworld/ts/helloworld/contract.ts b/contracts/wasm/helloworld/ts/helloworld/contract.ts index 3740f30ca3..686743fdc8 100644 --- a/contracts/wasm/helloworld/ts/helloworld/contract.ts +++ b/contracts/wasm/helloworld/ts/helloworld/contract.ts @@ -6,6 +6,7 @@ // Change the json schema instead import * as wasmlib from "wasmlib"; +import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; export class HelloWorldCall { @@ -13,17 +14,17 @@ export class HelloWorldCall { } export class HelloWorldContext { - state: sc.MutableHelloWorldState = new sc.MutableHelloWorldState(); + state: sc.MutableHelloWorldState = new sc.MutableHelloWorldState(wasmlib.ScState.proxy()); } export class GetHelloWorldCall { func: wasmlib.ScView = new wasmlib.ScView(sc.HScName, sc.HViewGetHelloWorld); - results: sc.ImmutableGetHelloWorldResults = new sc.ImmutableGetHelloWorldResults(); + results: sc.ImmutableGetHelloWorldResults = new sc.ImmutableGetHelloWorldResults(wasmlib.ScView.nilProxy); } export class GetHelloWorldContext { - results: sc.MutableGetHelloWorldResults = new sc.MutableGetHelloWorldResults(); - state: sc.ImmutableHelloWorldState = new sc.ImmutableHelloWorldState(); + results: sc.MutableGetHelloWorldResults = new sc.MutableGetHelloWorldResults(wasmlib.ScView.nilProxy); + state: sc.ImmutableHelloWorldState = new sc.ImmutableHelloWorldState(wasmlib.ScState.proxy()); } export class ScFuncs { @@ -32,8 +33,8 @@ export class ScFuncs { } static getHelloWorld(ctx: wasmlib.ScViewCallContext): GetHelloWorldCall { - let f = new GetHelloWorldCall(); - f.func.setPtrs(null, f.results); + const f = new GetHelloWorldCall(); + f.results = new sc.ImmutableGetHelloWorldResults(wasmlib.newCallResultsProxy(f.func)); return f; } } diff --git a/contracts/wasm/helloworld/ts/helloworld/index.ts b/contracts/wasm/helloworld/ts/helloworld/index.ts index d88f5510f4..95162fe0c6 100644 --- a/contracts/wasm/helloworld/ts/helloworld/index.ts +++ b/contracts/wasm/helloworld/ts/helloworld/index.ts @@ -9,7 +9,6 @@ export * from "./helloworld"; export * from "./consts"; export * from "./contract"; -export * from "./keys"; export * from "./lib"; export * from "./results"; export * from "./state"; diff --git a/contracts/wasm/helloworld/ts/helloworld/keys.ts b/contracts/wasm/helloworld/ts/helloworld/keys.ts index 7fb73b33ec..c8806d28c4 100644 --- a/contracts/wasm/helloworld/ts/helloworld/keys.ts +++ b/contracts/wasm/helloworld/ts/helloworld/keys.ts @@ -5,15 +5,4 @@ // >>>> DO NOT CHANGE THIS FILE! <<<< // Change the json schema instead -import * as wasmlib from "wasmlib"; -import * as sc from "./index"; - -export const IdxResultHelloWorld = 0; - - -export let keyMap: string[] = [ - sc.ResultHelloWorld, -]; - -export let idxMap: wasmlib.Key32[] = new Array(keyMap.length); diff --git a/contracts/wasm/helloworld/ts/helloworld/lib.ts b/contracts/wasm/helloworld/ts/helloworld/lib.ts index c70f64e037..8233f26911 100644 --- a/contracts/wasm/helloworld/ts/helloworld/lib.ts +++ b/contracts/wasm/helloworld/ts/helloworld/lib.ts @@ -6,6 +6,7 @@ // Change the json schema instead import * as wasmlib from "wasmlib"; +import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; export function on_call(index: i32): void { @@ -16,16 +17,11 @@ export function on_load(): void { let exports = new wasmlib.ScExports(); exports.addFunc(sc.FuncHelloWorld, funcHelloWorldThunk); exports.addView(sc.ViewGetHelloWorld, viewGetHelloWorldThunk); - - for (let i = 0; i < sc.keyMap.length; i++) { - sc.idxMap[i] = wasmlib.Key32.fromString(sc.keyMap[i]); - } } function funcHelloWorldThunk(ctx: wasmlib.ScFuncContext): void { ctx.log("helloworld.funcHelloWorld"); let f = new sc.HelloWorldContext(); - f.state.mapID = wasmlib.OBJ_ID_STATE; sc.funcHelloWorld(ctx, f); ctx.log("helloworld.funcHelloWorld ok"); } @@ -33,8 +29,9 @@ function funcHelloWorldThunk(ctx: wasmlib.ScFuncContext): void { function viewGetHelloWorldThunk(ctx: wasmlib.ScViewContext): void { ctx.log("helloworld.viewGetHelloWorld"); let f = new sc.GetHelloWorldContext(); - f.results.mapID = wasmlib.OBJ_ID_RESULTS; - f.state.mapID = wasmlib.OBJ_ID_STATE; + const results = new wasmlib.ScDict([]); + f.results = new sc.MutableGetHelloWorldResults(results.asProxy()); sc.viewGetHelloWorld(ctx, f); + ctx.results(results); ctx.log("helloworld.viewGetHelloWorld ok"); } diff --git a/contracts/wasm/helloworld/ts/helloworld/results.ts b/contracts/wasm/helloworld/ts/helloworld/results.ts index b9337efedf..dd49d1b081 100644 --- a/contracts/wasm/helloworld/ts/helloworld/results.ts +++ b/contracts/wasm/helloworld/ts/helloworld/results.ts @@ -6,16 +6,17 @@ // Change the json schema instead import * as wasmlib from "wasmlib"; +import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; -export class ImmutableGetHelloWorldResults extends wasmlib.ScMapID { - helloWorld(): wasmlib.ScImmutableString { - return new wasmlib.ScImmutableString(this.mapID, wasmlib.Key32.fromString(sc.ResultHelloWorld)); +export class ImmutableGetHelloWorldResults extends wasmtypes.ScProxy { + helloWorld(): wasmtypes.ScImmutableString { + return new wasmtypes.ScImmutableString(this.proxy.root(sc.ResultHelloWorld)); } } -export class MutableGetHelloWorldResults extends wasmlib.ScMapID { - helloWorld(): wasmlib.ScMutableString { - return new wasmlib.ScMutableString(this.mapID, wasmlib.Key32.fromString(sc.ResultHelloWorld)); +export class MutableGetHelloWorldResults extends wasmtypes.ScProxy { + helloWorld(): wasmtypes.ScMutableString { + return new wasmtypes.ScMutableString(this.proxy.root(sc.ResultHelloWorld)); } } diff --git a/contracts/wasm/helloworld/ts/helloworld/state.ts b/contracts/wasm/helloworld/ts/helloworld/state.ts index b1476bca64..7f7c3807fe 100644 --- a/contracts/wasm/helloworld/ts/helloworld/state.ts +++ b/contracts/wasm/helloworld/ts/helloworld/state.ts @@ -6,15 +6,14 @@ // Change the json schema instead import * as wasmlib from "wasmlib"; +import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; -export class ImmutableHelloWorldState extends wasmlib.ScMapID { +export class ImmutableHelloWorldState extends wasmtypes.ScProxy { } -export class MutableHelloWorldState extends wasmlib.ScMapID { +export class MutableHelloWorldState extends wasmtypes.ScProxy { asImmutable(): sc.ImmutableHelloWorldState { - const imm = new sc.ImmutableHelloWorldState(); - imm.mapID = this.mapID; - return imm; + return new sc.ImmutableHelloWorldState(this.proxy); } } diff --git a/contracts/wasm/inccounter/go/inccounter/inccounter.go b/contracts/wasm/inccounter/go/inccounter/inccounter.go index f438068188..6af9bcde79 100644 --- a/contracts/wasm/inccounter/go/inccounter/inccounter.go +++ b/contracts/wasm/inccounter/go/inccounter/inccounter.go @@ -172,7 +172,7 @@ func viewGetVli(ctx wasmlib.ScViewContext, f *GetVliContext) { n := f.Params.Ni64().Value() buf := enc.VliEncode(n).Buf() dec := wasmtypes.NewWasmDecoder(buf) - x := wasmtypes.DecodeInt64(dec) + x := wasmtypes.Int64Decode(dec) str := strconv.FormatInt(n, 10) + " -" for j := 0; j < len(buf); j++ { @@ -193,7 +193,7 @@ func viewGetVlu(ctx wasmlib.ScViewContext, f *GetVluContext) { n := f.Params.Nu64().Value() buf := enc.VluEncode(n).Buf() dec := wasmtypes.NewWasmDecoder(buf) - x := wasmtypes.DecodeUint64(dec) + x := wasmtypes.Uint64Decode(dec) str := strconv.FormatUint(n, 10) + " -" for j := 0; j < len(buf); j++ { @@ -220,11 +220,10 @@ func localStatePost(ctx wasmlib.ScFuncContext, nr int64) { func vliSave(ctx wasmlib.ScFuncContext, name string, value int64) { enc := wasmtypes.NewWasmEncoder() state := wasmlib.ScState{} - state.Set([]byte(name), enc.VliEncode(value).Buf()) - - buf := state.Get([]byte(name)) - dec := wasmtypes.NewWasmDecoder(buf) - retrieved := wasmtypes.DecodeInt64(dec) + key := []byte(name) + state.Set(key, enc.VliEncode(value).Buf()) + dec := wasmtypes.NewWasmDecoder(state.Get(key)) + retrieved := wasmtypes.Int64Decode(dec) if retrieved != value { ctx.Log(name + " in : " + ctx.Utility().String(value)) ctx.Log(name + " out: " + ctx.Utility().String(retrieved)) @@ -234,11 +233,10 @@ func vliSave(ctx wasmlib.ScFuncContext, name string, value int64) { func vluSave(ctx wasmlib.ScFuncContext, name string, value uint64) { enc := wasmtypes.NewWasmEncoder() state := wasmlib.ScState{} - state.Set([]byte(name), enc.VluEncode(value).Buf()) - - buf := state.Get([]byte(name)) - dec := wasmtypes.NewWasmDecoder(buf) - retrieved := wasmtypes.DecodeUint64(dec) + key := []byte(name) + state.Set(key, enc.VluEncode(value).Buf()) + dec := wasmtypes.NewWasmDecoder(state.Get(key)) + retrieved := wasmtypes.Uint64Decode(dec) if retrieved != value { ctx.Log(name + " in : " + ctx.Utility().String(int64(value))) ctx.Log(name + " out: " + ctx.Utility().String(int64(retrieved))) diff --git a/contracts/wasm/inccounter/go/inccounter/lib.go b/contracts/wasm/inccounter/go/inccounter/lib.go index 7679907662..705d426d07 100644 --- a/contracts/wasm/inccounter/go/inccounter/lib.go +++ b/contracts/wasm/inccounter/go/inccounter/lib.go @@ -274,8 +274,8 @@ func viewGetCounterThunk(ctx wasmlib.ScViewContext) { }, } viewGetCounter(ctx, f) - ctx.Log("inccounter.viewGetCounter ok") ctx.Results(results) + ctx.Log("inccounter.viewGetCounter ok") } type GetVliContext struct { @@ -300,8 +300,8 @@ func viewGetVliThunk(ctx wasmlib.ScViewContext) { } ctx.Require(f.Params.Ni64().Exists(), "missing mandatory ni64") viewGetVli(ctx, f) - ctx.Log("inccounter.viewGetVli ok") ctx.Results(results) + ctx.Log("inccounter.viewGetVli ok") } type GetVluContext struct { @@ -326,6 +326,6 @@ func viewGetVluThunk(ctx wasmlib.ScViewContext) { } ctx.Require(f.Params.Nu64().Exists(), "missing mandatory nu64") viewGetVlu(ctx, f) - ctx.Log("inccounter.viewGetVlu ok") ctx.Results(results) + ctx.Log("inccounter.viewGetVlu ok") } diff --git a/contracts/wasm/inccounter/ts/inccounter/consts.ts b/contracts/wasm/inccounter/ts/inccounter/consts.ts index af35fdac0c..237257288f 100644 --- a/contracts/wasm/inccounter/ts/inccounter/consts.ts +++ b/contracts/wasm/inccounter/ts/inccounter/consts.ts @@ -5,11 +5,11 @@ // >>>> DO NOT CHANGE THIS FILE! <<<< // Change the json schema instead -import * as wasmlib from "wasmlib"; +import * as wasmtypes from "wasmlib/wasmtypes"; export const ScName = "inccounter"; export const ScDescription = ""; -export const HScName = new wasmlib.ScHname(0xaf2438e9); +export const HScName = new wasmtypes.ScHname(0xaf2438e9); export const ParamCounter = "counter"; export const ParamDelay = "delay"; @@ -47,20 +47,20 @@ export const ViewGetCounter = "getCounter"; export const ViewGetVli = "getVli"; export const ViewGetVlu = "getVlu"; -export const HFuncCallIncrement = new wasmlib.ScHname(0xeb5dcacd); -export const HFuncCallIncrementRecurse5x = new wasmlib.ScHname(0x8749fbff); -export const HFuncEndlessLoop = new wasmlib.ScHname(0x365f0929); -export const HFuncIncrement = new wasmlib.ScHname(0xd351bd12); -export const HFuncIncrementWithDelay = new wasmlib.ScHname(0xa235bba7); -export const HFuncInit = new wasmlib.ScHname(0x1f44d644); -export const HFuncLocalStateInternalCall = new wasmlib.ScHname(0xecfc5d33); -export const HFuncLocalStatePost = new wasmlib.ScHname(0x3fd54d13); -export const HFuncLocalStateSandboxCall = new wasmlib.ScHname(0x7bd22c53); -export const HFuncPostIncrement = new wasmlib.ScHname(0x81c772f5); -export const HFuncRepeatMany = new wasmlib.ScHname(0x4ff450d3); -export const HFuncTestVliCodec = new wasmlib.ScHname(0xd5356012); -export const HFuncTestVluCodec = new wasmlib.ScHname(0x9f7f63e6); -export const HFuncWhenMustIncrement = new wasmlib.ScHname(0xb4c3e7a6); -export const HViewGetCounter = new wasmlib.ScHname(0xb423e607); -export const HViewGetVli = new wasmlib.ScHname(0x0ee16f89); -export const HViewGetVlu = new wasmlib.ScHname(0x54d624e6); +export const HFuncCallIncrement = new wasmtypes.ScHname(0xeb5dcacd); +export const HFuncCallIncrementRecurse5x = new wasmtypes.ScHname(0x8749fbff); +export const HFuncEndlessLoop = new wasmtypes.ScHname(0x365f0929); +export const HFuncIncrement = new wasmtypes.ScHname(0xd351bd12); +export const HFuncIncrementWithDelay = new wasmtypes.ScHname(0xa235bba7); +export const HFuncInit = new wasmtypes.ScHname(0x1f44d644); +export const HFuncLocalStateInternalCall = new wasmtypes.ScHname(0xecfc5d33); +export const HFuncLocalStatePost = new wasmtypes.ScHname(0x3fd54d13); +export const HFuncLocalStateSandboxCall = new wasmtypes.ScHname(0x7bd22c53); +export const HFuncPostIncrement = new wasmtypes.ScHname(0x81c772f5); +export const HFuncRepeatMany = new wasmtypes.ScHname(0x4ff450d3); +export const HFuncTestVliCodec = new wasmtypes.ScHname(0xd5356012); +export const HFuncTestVluCodec = new wasmtypes.ScHname(0x9f7f63e6); +export const HFuncWhenMustIncrement = new wasmtypes.ScHname(0xb4c3e7a6); +export const HViewGetCounter = new wasmtypes.ScHname(0xb423e607); +export const HViewGetVli = new wasmtypes.ScHname(0x0ee16f89); +export const HViewGetVlu = new wasmtypes.ScHname(0x54d624e6); diff --git a/contracts/wasm/inccounter/ts/inccounter/contract.ts b/contracts/wasm/inccounter/ts/inccounter/contract.ts index 7a534c48cc..c780921434 100644 --- a/contracts/wasm/inccounter/ts/inccounter/contract.ts +++ b/contracts/wasm/inccounter/ts/inccounter/contract.ts @@ -6,6 +6,7 @@ // Change the json schema instead import * as wasmlib from "wasmlib"; +import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; export class CallIncrementCall { @@ -13,7 +14,7 @@ export class CallIncrementCall { } export class CallIncrementContext { - state: sc.MutableIncCounterState = new sc.MutableIncCounterState(); + state: sc.MutableIncCounterState = new sc.MutableIncCounterState(wasmlib.ScState.proxy()); } export class CallIncrementRecurse5xCall { @@ -21,7 +22,7 @@ export class CallIncrementRecurse5xCall { } export class CallIncrementRecurse5xContext { - state: sc.MutableIncCounterState = new sc.MutableIncCounterState(); + state: sc.MutableIncCounterState = new sc.MutableIncCounterState(wasmlib.ScState.proxy()); } export class EndlessLoopCall { @@ -29,7 +30,7 @@ export class EndlessLoopCall { } export class EndlessLoopContext { - state: sc.MutableIncCounterState = new sc.MutableIncCounterState(); + state: sc.MutableIncCounterState = new sc.MutableIncCounterState(wasmlib.ScState.proxy()); } export class IncrementCall { @@ -37,27 +38,27 @@ export class IncrementCall { } export class IncrementContext { - state: sc.MutableIncCounterState = new sc.MutableIncCounterState(); + state: sc.MutableIncCounterState = new sc.MutableIncCounterState(wasmlib.ScState.proxy()); } export class IncrementWithDelayCall { func: wasmlib.ScFunc = new wasmlib.ScFunc(sc.HScName, sc.HFuncIncrementWithDelay); - params: sc.MutableIncrementWithDelayParams = new sc.MutableIncrementWithDelayParams(); + params: sc.MutableIncrementWithDelayParams = new sc.MutableIncrementWithDelayParams(wasmlib.ScView.nilProxy); } export class IncrementWithDelayContext { - params: sc.ImmutableIncrementWithDelayParams = new sc.ImmutableIncrementWithDelayParams(); - state: sc.MutableIncCounterState = new sc.MutableIncCounterState(); + params: sc.ImmutableIncrementWithDelayParams = new sc.ImmutableIncrementWithDelayParams(wasmlib.paramsProxy()); + state: sc.MutableIncCounterState = new sc.MutableIncCounterState(wasmlib.ScState.proxy()); } export class InitCall { func: wasmlib.ScInitFunc = new wasmlib.ScInitFunc(sc.HScName, sc.HFuncInit); - params: sc.MutableInitParams = new sc.MutableInitParams(); + params: sc.MutableInitParams = new sc.MutableInitParams(wasmlib.ScView.nilProxy); } export class InitContext { - params: sc.ImmutableInitParams = new sc.ImmutableInitParams(); - state: sc.MutableIncCounterState = new sc.MutableIncCounterState(); + params: sc.ImmutableInitParams = new sc.ImmutableInitParams(wasmlib.paramsProxy()); + state: sc.MutableIncCounterState = new sc.MutableIncCounterState(wasmlib.ScState.proxy()); } export class LocalStateInternalCallCall { @@ -65,7 +66,7 @@ export class LocalStateInternalCallCall { } export class LocalStateInternalCallContext { - state: sc.MutableIncCounterState = new sc.MutableIncCounterState(); + state: sc.MutableIncCounterState = new sc.MutableIncCounterState(wasmlib.ScState.proxy()); } export class LocalStatePostCall { @@ -73,7 +74,7 @@ export class LocalStatePostCall { } export class LocalStatePostContext { - state: sc.MutableIncCounterState = new sc.MutableIncCounterState(); + state: sc.MutableIncCounterState = new sc.MutableIncCounterState(wasmlib.ScState.proxy()); } export class LocalStateSandboxCallCall { @@ -81,7 +82,7 @@ export class LocalStateSandboxCallCall { } export class LocalStateSandboxCallContext { - state: sc.MutableIncCounterState = new sc.MutableIncCounterState(); + state: sc.MutableIncCounterState = new sc.MutableIncCounterState(wasmlib.ScState.proxy()); } export class PostIncrementCall { @@ -89,17 +90,17 @@ export class PostIncrementCall { } export class PostIncrementContext { - state: sc.MutableIncCounterState = new sc.MutableIncCounterState(); + state: sc.MutableIncCounterState = new sc.MutableIncCounterState(wasmlib.ScState.proxy()); } export class RepeatManyCall { func: wasmlib.ScFunc = new wasmlib.ScFunc(sc.HScName, sc.HFuncRepeatMany); - params: sc.MutableRepeatManyParams = new sc.MutableRepeatManyParams(); + params: sc.MutableRepeatManyParams = new sc.MutableRepeatManyParams(wasmlib.ScView.nilProxy); } export class RepeatManyContext { - params: sc.ImmutableRepeatManyParams = new sc.ImmutableRepeatManyParams(); - state: sc.MutableIncCounterState = new sc.MutableIncCounterState(); + params: sc.ImmutableRepeatManyParams = new sc.ImmutableRepeatManyParams(wasmlib.paramsProxy()); + state: sc.MutableIncCounterState = new sc.MutableIncCounterState(wasmlib.ScState.proxy()); } export class TestVliCodecCall { @@ -107,7 +108,7 @@ export class TestVliCodecCall { } export class TestVliCodecContext { - state: sc.MutableIncCounterState = new sc.MutableIncCounterState(); + state: sc.MutableIncCounterState = new sc.MutableIncCounterState(wasmlib.ScState.proxy()); } export class TestVluCodecCall { @@ -115,51 +116,51 @@ export class TestVluCodecCall { } export class TestVluCodecContext { - state: sc.MutableIncCounterState = new sc.MutableIncCounterState(); + state: sc.MutableIncCounterState = new sc.MutableIncCounterState(wasmlib.ScState.proxy()); } export class WhenMustIncrementCall { func: wasmlib.ScFunc = new wasmlib.ScFunc(sc.HScName, sc.HFuncWhenMustIncrement); - params: sc.MutableWhenMustIncrementParams = new sc.MutableWhenMustIncrementParams(); + params: sc.MutableWhenMustIncrementParams = new sc.MutableWhenMustIncrementParams(wasmlib.ScView.nilProxy); } export class WhenMustIncrementContext { - params: sc.ImmutableWhenMustIncrementParams = new sc.ImmutableWhenMustIncrementParams(); - state: sc.MutableIncCounterState = new sc.MutableIncCounterState(); + params: sc.ImmutableWhenMustIncrementParams = new sc.ImmutableWhenMustIncrementParams(wasmlib.paramsProxy()); + state: sc.MutableIncCounterState = new sc.MutableIncCounterState(wasmlib.ScState.proxy()); } export class GetCounterCall { func: wasmlib.ScView = new wasmlib.ScView(sc.HScName, sc.HViewGetCounter); - results: sc.ImmutableGetCounterResults = new sc.ImmutableGetCounterResults(); + results: sc.ImmutableGetCounterResults = new sc.ImmutableGetCounterResults(wasmlib.ScView.nilProxy); } export class GetCounterContext { - results: sc.MutableGetCounterResults = new sc.MutableGetCounterResults(); - state: sc.ImmutableIncCounterState = new sc.ImmutableIncCounterState(); + results: sc.MutableGetCounterResults = new sc.MutableGetCounterResults(wasmlib.ScView.nilProxy); + state: sc.ImmutableIncCounterState = new sc.ImmutableIncCounterState(wasmlib.ScState.proxy()); } export class GetVliCall { func: wasmlib.ScView = new wasmlib.ScView(sc.HScName, sc.HViewGetVli); - params: sc.MutableGetVliParams = new sc.MutableGetVliParams(); - results: sc.ImmutableGetVliResults = new sc.ImmutableGetVliResults(); + params: sc.MutableGetVliParams = new sc.MutableGetVliParams(wasmlib.ScView.nilProxy); + results: sc.ImmutableGetVliResults = new sc.ImmutableGetVliResults(wasmlib.ScView.nilProxy); } export class GetVliContext { - params: sc.ImmutableGetVliParams = new sc.ImmutableGetVliParams(); - results: sc.MutableGetVliResults = new sc.MutableGetVliResults(); - state: sc.ImmutableIncCounterState = new sc.ImmutableIncCounterState(); + params: sc.ImmutableGetVliParams = new sc.ImmutableGetVliParams(wasmlib.paramsProxy()); + results: sc.MutableGetVliResults = new sc.MutableGetVliResults(wasmlib.ScView.nilProxy); + state: sc.ImmutableIncCounterState = new sc.ImmutableIncCounterState(wasmlib.ScState.proxy()); } export class GetVluCall { func: wasmlib.ScView = new wasmlib.ScView(sc.HScName, sc.HViewGetVlu); - params: sc.MutableGetVluParams = new sc.MutableGetVluParams(); - results: sc.ImmutableGetVluResults = new sc.ImmutableGetVluResults(); + params: sc.MutableGetVluParams = new sc.MutableGetVluParams(wasmlib.ScView.nilProxy); + results: sc.ImmutableGetVluResults = new sc.ImmutableGetVluResults(wasmlib.ScView.nilProxy); } export class GetVluContext { - params: sc.ImmutableGetVluParams = new sc.ImmutableGetVluParams(); - results: sc.MutableGetVluResults = new sc.MutableGetVluResults(); - state: sc.ImmutableIncCounterState = new sc.ImmutableIncCounterState(); + params: sc.ImmutableGetVluParams = new sc.ImmutableGetVluParams(wasmlib.paramsProxy()); + results: sc.MutableGetVluResults = new sc.MutableGetVluResults(wasmlib.ScView.nilProxy); + state: sc.ImmutableIncCounterState = new sc.ImmutableIncCounterState(wasmlib.ScState.proxy()); } export class ScFuncs { @@ -180,14 +181,14 @@ export class ScFuncs { } static incrementWithDelay(ctx: wasmlib.ScFuncCallContext): IncrementWithDelayCall { - let f = new IncrementWithDelayCall(); - f.func.setPtrs(f.params, null); + const f = new IncrementWithDelayCall(); + f.params = new sc.MutableIncrementWithDelayParams(wasmlib.newCallParamsProxy(f.func)); return f; } static init(ctx: wasmlib.ScFuncCallContext): InitCall { - let f = new InitCall(); - f.func.setPtrs(f.params, null); + const f = new InitCall(); + f.params = new sc.MutableInitParams(wasmlib.newCallParamsProxy(f.func)); return f; } @@ -208,8 +209,8 @@ export class ScFuncs { } static repeatMany(ctx: wasmlib.ScFuncCallContext): RepeatManyCall { - let f = new RepeatManyCall(); - f.func.setPtrs(f.params, null); + const f = new RepeatManyCall(); + f.params = new sc.MutableRepeatManyParams(wasmlib.newCallParamsProxy(f.func)); return f; } @@ -222,26 +223,28 @@ export class ScFuncs { } static whenMustIncrement(ctx: wasmlib.ScFuncCallContext): WhenMustIncrementCall { - let f = new WhenMustIncrementCall(); - f.func.setPtrs(f.params, null); + const f = new WhenMustIncrementCall(); + f.params = new sc.MutableWhenMustIncrementParams(wasmlib.newCallParamsProxy(f.func)); return f; } static getCounter(ctx: wasmlib.ScViewCallContext): GetCounterCall { - let f = new GetCounterCall(); - f.func.setPtrs(null, f.results); + const f = new GetCounterCall(); + f.results = new sc.ImmutableGetCounterResults(wasmlib.newCallResultsProxy(f.func)); return f; } static getVli(ctx: wasmlib.ScViewCallContext): GetVliCall { - let f = new GetVliCall(); - f.func.setPtrs(f.params, f.results); + const f = new GetVliCall(); + f.params = new sc.MutableGetVliParams(wasmlib.newCallParamsProxy(f.func)); + f.results = new sc.ImmutableGetVliResults(wasmlib.newCallResultsProxy(f.func)); return f; } static getVlu(ctx: wasmlib.ScViewCallContext): GetVluCall { - let f = new GetVluCall(); - f.func.setPtrs(f.params, f.results); + const f = new GetVluCall(); + f.params = new sc.MutableGetVluParams(wasmlib.newCallParamsProxy(f.func)); + f.results = new sc.ImmutableGetVluResults(wasmlib.newCallResultsProxy(f.func)); return f; } } diff --git a/contracts/wasm/inccounter/ts/inccounter/inccounter.ts b/contracts/wasm/inccounter/ts/inccounter/inccounter.ts index 8b940226ea..e47fece5b1 100644 --- a/contracts/wasm/inccounter/ts/inccounter/inccounter.ts +++ b/contracts/wasm/inccounter/ts/inccounter/inccounter.ts @@ -2,7 +2,9 @@ // SPDX-License-Identifier: Apache-2.0 import * as wasmlib from "wasmlib" +import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; +import {ScState} from "../../../../../packages/wasmvm/wasmlib/ts/wasmlib"; const hex = "0123456789abcdef"; @@ -104,16 +106,16 @@ export function funcRepeatMany(ctx: wasmlib.ScFuncContext, f: sc.RepeatManyConte export function funcTestVliCodec(ctx: wasmlib.ScFuncContext, f: sc.TestVliCodecContext): void { for (let i: i64 = -1000000; i < 1000000; i++) { - let enc = new wasmlib.BytesEncoder(); - enc.int64(i); - let buf = enc.data(); + let enc = new wasmtypes.WasmEncoder(); + wasmtypes.int64Encode(enc, i); + let buf = enc.buf(); // let txt = i.toString() + " -"; // for (let j = 0; j < buf.length; j++) { // let b = buf[j]; // txt += " " + hex.charAt((b >> 4) & 0x0f) + hex.charAt(b & 0x0f); // } - let dec = new wasmlib.BytesDecoder(buf); - let v = dec.int64(); + let dec = new wasmtypes.WasmDecoder(buf); + let v = wasmtypes.int64Decode(dec); // txt += " - " + v.toString(); // ctx.log(txt); ctx.require(i == v, "coder value mismatch") @@ -144,16 +146,16 @@ export function funcTestVliCodec(ctx: wasmlib.ScFuncContext, f: sc.TestVliCodecC export function funcTestVluCodec(ctx: wasmlib.ScFuncContext, f: sc.TestVluCodecContext): void { for (let i: u64 = 0; i < 2000000; i++) { - let enc = new wasmlib.BytesEncoder(); - enc.uint64(i); - let buf = enc.data(); + let enc = new wasmtypes.WasmEncoder(); + wasmtypes.uint64Encode(enc, i); + let buf = enc.buf(); // let txt = i.toString() + " -"; // for (let j = 0; j < buf.length; j++) { // let b = buf[j]; // txt += " " + hex.charAt((b >> 4) & 0x0f) + hex.charAt(b & 0x0f); // } - let dec = new wasmlib.BytesDecoder(buf); - let v = dec.uint64(); + let dec = new wasmtypes.WasmDecoder(buf); + let v = wasmtypes.uint64Decode(dec); // txt += " - " + v.toString(); // ctx.log(txt); ctx.require(i == v, "coder value mismatch") @@ -186,12 +188,12 @@ export function viewGetCounter(ctx: wasmlib.ScViewContext, f: sc.GetCounterConte } export function viewGetVli(ctx: wasmlib.ScViewContext, f: sc.GetVliContext): void { - let enc = new wasmlib.BytesEncoder(); + let enc = new wasmtypes.WasmEncoder(); let n = f.params.ni64().value(); - enc = enc.int64(n); - let buf = enc.data(); - let dec = new wasmlib.BytesDecoder(buf); - let x = dec.int64(); + wasmtypes.int64Encode(enc, n); + let buf = enc.buf(); + let dec = new wasmtypes.WasmDecoder(buf); + let x = wasmtypes.int64Decode(dec); let str = n.toString() + " -"; for (let j = 0; j < buf.length; j++) { @@ -207,12 +209,12 @@ export function viewGetVli(ctx: wasmlib.ScViewContext, f: sc.GetVliContext): voi } export function viewGetVlu(ctx: wasmlib.ScViewContext, f: sc.GetVluContext): void { - let enc = new wasmlib.BytesEncoder(); + let enc = new wasmtypes.WasmEncoder(); let n = f.params.nu64().value(); - enc = enc.uint64(n); - let buf = enc.data(); - let dec = new wasmlib.BytesDecoder(buf); - let x = dec.uint64(); + wasmtypes.uint64Encode(enc, n); + let buf = enc.buf(); + let dec = new wasmtypes.WasmDecoder(buf); + let x = wasmtypes.uint64Decode(dec); let str = n.toString() + " -"; for (let j = 0; j < buf.length; j++) { @@ -237,14 +239,12 @@ function localStatePost(ctx: wasmlib.ScFuncContext, nr: i64): void { } function vliSave(ctx: wasmlib.ScFuncContext, name: string, value: i64): void { - let encoder = new wasmlib.BytesEncoder(); - encoder.int64(value); - let spot = ctx.state().getBytes(wasmlib.Key32.fromString(name)); - spot.setValue(encoder.data()); - - let bytes = spot.value(); - let decoder = new wasmlib.BytesDecoder(bytes); - let retrieved = decoder.int64(); + let enc = new wasmtypes.WasmEncoder(); + const state = new ScState(); + let key = wasmtypes.stringToBytes(name); + state.set(key, enc.vliEncode(value).buf()); + let dec = new wasmtypes.WasmDecoder(state.get(key)); + let retrieved = wasmtypes.int64Decode(dec); if (retrieved != value) { ctx.log(name.toString() + " in : " + value.toString()); ctx.log(name.toString() + " out: " + retrieved.toString()); @@ -252,14 +252,12 @@ function vliSave(ctx: wasmlib.ScFuncContext, name: string, value: i64): void { } function vluSave(ctx: wasmlib.ScFuncContext, name: string, value: u64): void { - let encoder = new wasmlib.BytesEncoder(); - encoder.uint64(value); - let spot = ctx.state().getBytes(wasmlib.Key32.fromString(name)); - spot.setValue(encoder.data()); - - let bytes = spot.value(); - let decoder = new wasmlib.BytesDecoder(bytes); - let retrieved = decoder.uint64(); + let enc = new wasmtypes.WasmEncoder(); + const state = new ScState(); + let key = wasmtypes.stringToBytes(name); + state.set(key, enc.vluEncode(value).buf()); + let dec = new wasmtypes.WasmDecoder(state.get(key)); + let retrieved = wasmtypes.uint64Decode(dec); if (retrieved != value) { ctx.log(name.toString() + " in : " + value.toString()); ctx.log(name.toString() + " out: " + retrieved.toString()); diff --git a/contracts/wasm/inccounter/ts/inccounter/index.ts b/contracts/wasm/inccounter/ts/inccounter/index.ts index f944f6c574..96f957fe81 100644 --- a/contracts/wasm/inccounter/ts/inccounter/index.ts +++ b/contracts/wasm/inccounter/ts/inccounter/index.ts @@ -9,7 +9,6 @@ export * from "./inccounter"; export * from "./consts"; export * from "./contract"; -export * from "./keys"; export * from "./lib"; export * from "./params"; export * from "./results"; diff --git a/contracts/wasm/inccounter/ts/inccounter/keys.ts b/contracts/wasm/inccounter/ts/inccounter/keys.ts index 39f44e0192..2552fa53c5 100644 --- a/contracts/wasm/inccounter/ts/inccounter/keys.ts +++ b/contracts/wasm/inccounter/ts/inccounter/keys.ts @@ -5,8 +5,6 @@ // >>>> DO NOT CHANGE THIS FILE! <<<< // Change the json schema instead -import * as wasmlib from "wasmlib"; -import * as sc from "./index"; export const IdxParamCounter = 0; export const IdxParamDelay = 1; @@ -14,34 +12,3 @@ export const IdxParamDummy = 2; export const IdxParamNi64 = 3; export const IdxParamNu64 = 4; export const IdxParamNumRepeats = 5; - -export const IdxResultBuf = 6; -export const IdxResultCounter = 7; -export const IdxResultNi64 = 8; -export const IdxResultNu64 = 9; -export const IdxResultStr = 10; -export const IdxResultXi64 = 11; -export const IdxResultXu64 = 12; - -export const IdxStateCounter = 13; -export const IdxStateNumRepeats = 14; - -export let keyMap: string[] = [ - sc.ParamCounter, - sc.ParamDelay, - sc.ParamDummy, - sc.ParamNi64, - sc.ParamNu64, - sc.ParamNumRepeats, - sc.ResultBuf, - sc.ResultCounter, - sc.ResultNi64, - sc.ResultNu64, - sc.ResultStr, - sc.ResultXi64, - sc.ResultXu64, - sc.StateCounter, - sc.StateNumRepeats, -]; - -export let idxMap: wasmlib.Key32[] = new Array(keyMap.length); diff --git a/contracts/wasm/inccounter/ts/inccounter/lib.ts b/contracts/wasm/inccounter/ts/inccounter/lib.ts index 8c96a4479a..921b434d3f 100644 --- a/contracts/wasm/inccounter/ts/inccounter/lib.ts +++ b/contracts/wasm/inccounter/ts/inccounter/lib.ts @@ -6,6 +6,7 @@ // Change the json schema instead import * as wasmlib from "wasmlib"; +import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; export function on_call(index: i32): void { @@ -31,16 +32,11 @@ export function on_load(): void { exports.addView(sc.ViewGetCounter, viewGetCounterThunk); exports.addView(sc.ViewGetVli, viewGetVliThunk); exports.addView(sc.ViewGetVlu, viewGetVluThunk); - - for (let i = 0; i < sc.keyMap.length; i++) { - sc.idxMap[i] = wasmlib.Key32.fromString(sc.keyMap[i]); - } } function funcCallIncrementThunk(ctx: wasmlib.ScFuncContext): void { ctx.log("inccounter.funcCallIncrement"); let f = new sc.CallIncrementContext(); - f.state.mapID = wasmlib.OBJ_ID_STATE; sc.funcCallIncrement(ctx, f); ctx.log("inccounter.funcCallIncrement ok"); } @@ -48,7 +44,6 @@ function funcCallIncrementThunk(ctx: wasmlib.ScFuncContext): void { function funcCallIncrementRecurse5xThunk(ctx: wasmlib.ScFuncContext): void { ctx.log("inccounter.funcCallIncrementRecurse5x"); let f = new sc.CallIncrementRecurse5xContext(); - f.state.mapID = wasmlib.OBJ_ID_STATE; sc.funcCallIncrementRecurse5x(ctx, f); ctx.log("inccounter.funcCallIncrementRecurse5x ok"); } @@ -56,7 +51,6 @@ function funcCallIncrementRecurse5xThunk(ctx: wasmlib.ScFuncContext): void { function funcEndlessLoopThunk(ctx: wasmlib.ScFuncContext): void { ctx.log("inccounter.funcEndlessLoop"); let f = new sc.EndlessLoopContext(); - f.state.mapID = wasmlib.OBJ_ID_STATE; sc.funcEndlessLoop(ctx, f); ctx.log("inccounter.funcEndlessLoop ok"); } @@ -64,7 +58,6 @@ function funcEndlessLoopThunk(ctx: wasmlib.ScFuncContext): void { function funcIncrementThunk(ctx: wasmlib.ScFuncContext): void { ctx.log("inccounter.funcIncrement"); let f = new sc.IncrementContext(); - f.state.mapID = wasmlib.OBJ_ID_STATE; sc.funcIncrement(ctx, f); ctx.log("inccounter.funcIncrement ok"); } @@ -72,8 +65,6 @@ function funcIncrementThunk(ctx: wasmlib.ScFuncContext): void { function funcIncrementWithDelayThunk(ctx: wasmlib.ScFuncContext): void { ctx.log("inccounter.funcIncrementWithDelay"); let f = new sc.IncrementWithDelayContext(); - f.params.mapID = wasmlib.OBJ_ID_PARAMS; - f.state.mapID = wasmlib.OBJ_ID_STATE; ctx.require(f.params.delay().exists(), "missing mandatory delay"); sc.funcIncrementWithDelay(ctx, f); ctx.log("inccounter.funcIncrementWithDelay ok"); @@ -82,8 +73,6 @@ function funcIncrementWithDelayThunk(ctx: wasmlib.ScFuncContext): void { function funcInitThunk(ctx: wasmlib.ScFuncContext): void { ctx.log("inccounter.funcInit"); let f = new sc.InitContext(); - f.params.mapID = wasmlib.OBJ_ID_PARAMS; - f.state.mapID = wasmlib.OBJ_ID_STATE; sc.funcInit(ctx, f); ctx.log("inccounter.funcInit ok"); } @@ -91,7 +80,6 @@ function funcInitThunk(ctx: wasmlib.ScFuncContext): void { function funcLocalStateInternalCallThunk(ctx: wasmlib.ScFuncContext): void { ctx.log("inccounter.funcLocalStateInternalCall"); let f = new sc.LocalStateInternalCallContext(); - f.state.mapID = wasmlib.OBJ_ID_STATE; sc.funcLocalStateInternalCall(ctx, f); ctx.log("inccounter.funcLocalStateInternalCall ok"); } @@ -99,7 +87,6 @@ function funcLocalStateInternalCallThunk(ctx: wasmlib.ScFuncContext): void { function funcLocalStatePostThunk(ctx: wasmlib.ScFuncContext): void { ctx.log("inccounter.funcLocalStatePost"); let f = new sc.LocalStatePostContext(); - f.state.mapID = wasmlib.OBJ_ID_STATE; sc.funcLocalStatePost(ctx, f); ctx.log("inccounter.funcLocalStatePost ok"); } @@ -107,7 +94,6 @@ function funcLocalStatePostThunk(ctx: wasmlib.ScFuncContext): void { function funcLocalStateSandboxCallThunk(ctx: wasmlib.ScFuncContext): void { ctx.log("inccounter.funcLocalStateSandboxCall"); let f = new sc.LocalStateSandboxCallContext(); - f.state.mapID = wasmlib.OBJ_ID_STATE; sc.funcLocalStateSandboxCall(ctx, f); ctx.log("inccounter.funcLocalStateSandboxCall ok"); } @@ -115,7 +101,6 @@ function funcLocalStateSandboxCallThunk(ctx: wasmlib.ScFuncContext): void { function funcPostIncrementThunk(ctx: wasmlib.ScFuncContext): void { ctx.log("inccounter.funcPostIncrement"); let f = new sc.PostIncrementContext(); - f.state.mapID = wasmlib.OBJ_ID_STATE; sc.funcPostIncrement(ctx, f); ctx.log("inccounter.funcPostIncrement ok"); } @@ -123,8 +108,6 @@ function funcPostIncrementThunk(ctx: wasmlib.ScFuncContext): void { function funcRepeatManyThunk(ctx: wasmlib.ScFuncContext): void { ctx.log("inccounter.funcRepeatMany"); let f = new sc.RepeatManyContext(); - f.params.mapID = wasmlib.OBJ_ID_PARAMS; - f.state.mapID = wasmlib.OBJ_ID_STATE; sc.funcRepeatMany(ctx, f); ctx.log("inccounter.funcRepeatMany ok"); } @@ -132,7 +115,6 @@ function funcRepeatManyThunk(ctx: wasmlib.ScFuncContext): void { function funcTestVliCodecThunk(ctx: wasmlib.ScFuncContext): void { ctx.log("inccounter.funcTestVliCodec"); let f = new sc.TestVliCodecContext(); - f.state.mapID = wasmlib.OBJ_ID_STATE; sc.funcTestVliCodec(ctx, f); ctx.log("inccounter.funcTestVliCodec ok"); } @@ -140,7 +122,6 @@ function funcTestVliCodecThunk(ctx: wasmlib.ScFuncContext): void { function funcTestVluCodecThunk(ctx: wasmlib.ScFuncContext): void { ctx.log("inccounter.funcTestVluCodec"); let f = new sc.TestVluCodecContext(); - f.state.mapID = wasmlib.OBJ_ID_STATE; sc.funcTestVluCodec(ctx, f); ctx.log("inccounter.funcTestVluCodec ok"); } @@ -148,8 +129,6 @@ function funcTestVluCodecThunk(ctx: wasmlib.ScFuncContext): void { function funcWhenMustIncrementThunk(ctx: wasmlib.ScFuncContext): void { ctx.log("inccounter.funcWhenMustIncrement"); let f = new sc.WhenMustIncrementContext(); - f.params.mapID = wasmlib.OBJ_ID_PARAMS; - f.state.mapID = wasmlib.OBJ_ID_STATE; sc.funcWhenMustIncrement(ctx, f); ctx.log("inccounter.funcWhenMustIncrement ok"); } @@ -157,30 +136,31 @@ function funcWhenMustIncrementThunk(ctx: wasmlib.ScFuncContext): void { function viewGetCounterThunk(ctx: wasmlib.ScViewContext): void { ctx.log("inccounter.viewGetCounter"); let f = new sc.GetCounterContext(); - f.results.mapID = wasmlib.OBJ_ID_RESULTS; - f.state.mapID = wasmlib.OBJ_ID_STATE; + const results = new wasmlib.ScDict([]); + f.results = new sc.MutableGetCounterResults(results.asProxy()); sc.viewGetCounter(ctx, f); + ctx.results(results); ctx.log("inccounter.viewGetCounter ok"); } function viewGetVliThunk(ctx: wasmlib.ScViewContext): void { ctx.log("inccounter.viewGetVli"); let f = new sc.GetVliContext(); - f.params.mapID = wasmlib.OBJ_ID_PARAMS; - f.results.mapID = wasmlib.OBJ_ID_RESULTS; - f.state.mapID = wasmlib.OBJ_ID_STATE; + const results = new wasmlib.ScDict([]); + f.results = new sc.MutableGetVliResults(results.asProxy()); ctx.require(f.params.ni64().exists(), "missing mandatory ni64"); sc.viewGetVli(ctx, f); + ctx.results(results); ctx.log("inccounter.viewGetVli ok"); } function viewGetVluThunk(ctx: wasmlib.ScViewContext): void { ctx.log("inccounter.viewGetVlu"); let f = new sc.GetVluContext(); - f.params.mapID = wasmlib.OBJ_ID_PARAMS; - f.results.mapID = wasmlib.OBJ_ID_RESULTS; - f.state.mapID = wasmlib.OBJ_ID_STATE; + const results = new wasmlib.ScDict([]); + f.results = new sc.MutableGetVluResults(results.asProxy()); ctx.require(f.params.nu64().exists(), "missing mandatory nu64"); sc.viewGetVlu(ctx, f); + ctx.results(results); ctx.log("inccounter.viewGetVlu ok"); } diff --git a/contracts/wasm/inccounter/ts/inccounter/params.ts b/contracts/wasm/inccounter/ts/inccounter/params.ts index 6c2d8ed128..4848b39f5b 100644 --- a/contracts/wasm/inccounter/ts/inccounter/params.ts +++ b/contracts/wasm/inccounter/ts/inccounter/params.ts @@ -6,76 +6,77 @@ // Change the json schema instead import * as wasmlib from "wasmlib"; +import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; -export class ImmutableIncrementWithDelayParams extends wasmlib.ScMapID { - delay(): wasmlib.ScImmutableUint32 { - return new wasmlib.ScImmutableUint32(this.mapID, wasmlib.Key32.fromString(sc.ParamDelay)); +export class ImmutableIncrementWithDelayParams extends wasmtypes.ScProxy { + delay(): wasmtypes.ScImmutableUint32 { + return new wasmtypes.ScImmutableUint32(this.proxy.root(sc.ParamDelay)); } } -export class MutableIncrementWithDelayParams extends wasmlib.ScMapID { - delay(): wasmlib.ScMutableUint32 { - return new wasmlib.ScMutableUint32(this.mapID, wasmlib.Key32.fromString(sc.ParamDelay)); +export class MutableIncrementWithDelayParams extends wasmtypes.ScProxy { + delay(): wasmtypes.ScMutableUint32 { + return new wasmtypes.ScMutableUint32(this.proxy.root(sc.ParamDelay)); } } -export class ImmutableInitParams extends wasmlib.ScMapID { - counter(): wasmlib.ScImmutableInt64 { - return new wasmlib.ScImmutableInt64(this.mapID, sc.idxMap[sc.IdxParamCounter]); +export class ImmutableInitParams extends wasmtypes.ScProxy { + counter(): wasmtypes.ScImmutableInt64 { + return new wasmtypes.ScImmutableInt64(this.proxy.root(sc.ParamCounter)); } } -export class MutableInitParams extends wasmlib.ScMapID { - counter(): wasmlib.ScMutableInt64 { - return new wasmlib.ScMutableInt64(this.mapID, sc.idxMap[sc.IdxParamCounter]); +export class MutableInitParams extends wasmtypes.ScProxy { + counter(): wasmtypes.ScMutableInt64 { + return new wasmtypes.ScMutableInt64(this.proxy.root(sc.ParamCounter)); } } -export class ImmutableRepeatManyParams extends wasmlib.ScMapID { - numRepeats(): wasmlib.ScImmutableInt64 { - return new wasmlib.ScImmutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ParamNumRepeats)); +export class ImmutableRepeatManyParams extends wasmtypes.ScProxy { + numRepeats(): wasmtypes.ScImmutableInt64 { + return new wasmtypes.ScImmutableInt64(this.proxy.root(sc.ParamNumRepeats)); } } -export class MutableRepeatManyParams extends wasmlib.ScMapID { - numRepeats(): wasmlib.ScMutableInt64 { - return new wasmlib.ScMutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ParamNumRepeats)); +export class MutableRepeatManyParams extends wasmtypes.ScProxy { + numRepeats(): wasmtypes.ScMutableInt64 { + return new wasmtypes.ScMutableInt64(this.proxy.root(sc.ParamNumRepeats)); } } -export class ImmutableWhenMustIncrementParams extends wasmlib.ScMapID { - dummy(): wasmlib.ScImmutableInt64 { - return new wasmlib.ScImmutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ParamDummy)); +export class ImmutableWhenMustIncrementParams extends wasmtypes.ScProxy { + dummy(): wasmtypes.ScImmutableInt64 { + return new wasmtypes.ScImmutableInt64(this.proxy.root(sc.ParamDummy)); } } -export class MutableWhenMustIncrementParams extends wasmlib.ScMapID { - dummy(): wasmlib.ScMutableInt64 { - return new wasmlib.ScMutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ParamDummy)); +export class MutableWhenMustIncrementParams extends wasmtypes.ScProxy { + dummy(): wasmtypes.ScMutableInt64 { + return new wasmtypes.ScMutableInt64(this.proxy.root(sc.ParamDummy)); } } -export class ImmutableGetVliParams extends wasmlib.ScMapID { - ni64(): wasmlib.ScImmutableInt64 { - return new wasmlib.ScImmutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ParamNi64)); +export class ImmutableGetVliParams extends wasmtypes.ScProxy { + ni64(): wasmtypes.ScImmutableInt64 { + return new wasmtypes.ScImmutableInt64(this.proxy.root(sc.ParamNi64)); } } -export class MutableGetVliParams extends wasmlib.ScMapID { - ni64(): wasmlib.ScMutableInt64 { - return new wasmlib.ScMutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ParamNi64)); +export class MutableGetVliParams extends wasmtypes.ScProxy { + ni64(): wasmtypes.ScMutableInt64 { + return new wasmtypes.ScMutableInt64(this.proxy.root(sc.ParamNi64)); } } -export class ImmutableGetVluParams extends wasmlib.ScMapID { - nu64(): wasmlib.ScImmutableUint64 { - return new wasmlib.ScImmutableUint64(this.mapID, wasmlib.Key32.fromString(sc.ParamNu64)); +export class ImmutableGetVluParams extends wasmtypes.ScProxy { + nu64(): wasmtypes.ScImmutableUint64 { + return new wasmtypes.ScImmutableUint64(this.proxy.root(sc.ParamNu64)); } } -export class MutableGetVluParams extends wasmlib.ScMapID { - nu64(): wasmlib.ScMutableUint64 { - return new wasmlib.ScMutableUint64(this.mapID, wasmlib.Key32.fromString(sc.ParamNu64)); +export class MutableGetVluParams extends wasmtypes.ScProxy { + nu64(): wasmtypes.ScMutableUint64 { + return new wasmtypes.ScMutableUint64(this.proxy.root(sc.ParamNu64)); } } diff --git a/contracts/wasm/inccounter/ts/inccounter/results.ts b/contracts/wasm/inccounter/ts/inccounter/results.ts index 6b3cdfd082..4900372c82 100644 --- a/contracts/wasm/inccounter/ts/inccounter/results.ts +++ b/contracts/wasm/inccounter/ts/inccounter/results.ts @@ -6,88 +6,89 @@ // Change the json schema instead import * as wasmlib from "wasmlib"; +import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; -export class ImmutableGetCounterResults extends wasmlib.ScMapID { - counter(): wasmlib.ScImmutableInt64 { - return new wasmlib.ScImmutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ResultCounter)); +export class ImmutableGetCounterResults extends wasmtypes.ScProxy { + counter(): wasmtypes.ScImmutableInt64 { + return new wasmtypes.ScImmutableInt64(this.proxy.root(sc.ResultCounter)); } } -export class MutableGetCounterResults extends wasmlib.ScMapID { - counter(): wasmlib.ScMutableInt64 { - return new wasmlib.ScMutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ResultCounter)); +export class MutableGetCounterResults extends wasmtypes.ScProxy { + counter(): wasmtypes.ScMutableInt64 { + return new wasmtypes.ScMutableInt64(this.proxy.root(sc.ResultCounter)); } } -export class ImmutableGetVliResults extends wasmlib.ScMapID { - buf(): wasmlib.ScImmutableBytes { - return new wasmlib.ScImmutableBytes(this.mapID, wasmlib.Key32.fromString(sc.ResultBuf)); +export class ImmutableGetVliResults extends wasmtypes.ScProxy { + buf(): wasmtypes.ScImmutableBytes { + return new wasmtypes.ScImmutableBytes(this.proxy.root(sc.ResultBuf)); } - ni64(): wasmlib.ScImmutableInt64 { - return new wasmlib.ScImmutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ResultNi64)); + ni64(): wasmtypes.ScImmutableInt64 { + return new wasmtypes.ScImmutableInt64(this.proxy.root(sc.ResultNi64)); } - str(): wasmlib.ScImmutableString { - return new wasmlib.ScImmutableString(this.mapID, wasmlib.Key32.fromString(sc.ResultStr)); + str(): wasmtypes.ScImmutableString { + return new wasmtypes.ScImmutableString(this.proxy.root(sc.ResultStr)); } - xi64(): wasmlib.ScImmutableInt64 { - return new wasmlib.ScImmutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ResultXi64)); + xi64(): wasmtypes.ScImmutableInt64 { + return new wasmtypes.ScImmutableInt64(this.proxy.root(sc.ResultXi64)); } } -export class MutableGetVliResults extends wasmlib.ScMapID { - buf(): wasmlib.ScMutableBytes { - return new wasmlib.ScMutableBytes(this.mapID, wasmlib.Key32.fromString(sc.ResultBuf)); +export class MutableGetVliResults extends wasmtypes.ScProxy { + buf(): wasmtypes.ScMutableBytes { + return new wasmtypes.ScMutableBytes(this.proxy.root(sc.ResultBuf)); } - ni64(): wasmlib.ScMutableInt64 { - return new wasmlib.ScMutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ResultNi64)); + ni64(): wasmtypes.ScMutableInt64 { + return new wasmtypes.ScMutableInt64(this.proxy.root(sc.ResultNi64)); } - str(): wasmlib.ScMutableString { - return new wasmlib.ScMutableString(this.mapID, wasmlib.Key32.fromString(sc.ResultStr)); + str(): wasmtypes.ScMutableString { + return new wasmtypes.ScMutableString(this.proxy.root(sc.ResultStr)); } - xi64(): wasmlib.ScMutableInt64 { - return new wasmlib.ScMutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ResultXi64)); + xi64(): wasmtypes.ScMutableInt64 { + return new wasmtypes.ScMutableInt64(this.proxy.root(sc.ResultXi64)); } } -export class ImmutableGetVluResults extends wasmlib.ScMapID { - buf(): wasmlib.ScImmutableBytes { - return new wasmlib.ScImmutableBytes(this.mapID, wasmlib.Key32.fromString(sc.ResultBuf)); +export class ImmutableGetVluResults extends wasmtypes.ScProxy { + buf(): wasmtypes.ScImmutableBytes { + return new wasmtypes.ScImmutableBytes(this.proxy.root(sc.ResultBuf)); } - nu64(): wasmlib.ScImmutableUint64 { - return new wasmlib.ScImmutableUint64(this.mapID, wasmlib.Key32.fromString(sc.ResultNu64)); + nu64(): wasmtypes.ScImmutableUint64 { + return new wasmtypes.ScImmutableUint64(this.proxy.root(sc.ResultNu64)); } - str(): wasmlib.ScImmutableString { - return new wasmlib.ScImmutableString(this.mapID, wasmlib.Key32.fromString(sc.ResultStr)); + str(): wasmtypes.ScImmutableString { + return new wasmtypes.ScImmutableString(this.proxy.root(sc.ResultStr)); } - xu64(): wasmlib.ScImmutableUint64 { - return new wasmlib.ScImmutableUint64(this.mapID, wasmlib.Key32.fromString(sc.ResultXu64)); + xu64(): wasmtypes.ScImmutableUint64 { + return new wasmtypes.ScImmutableUint64(this.proxy.root(sc.ResultXu64)); } } -export class MutableGetVluResults extends wasmlib.ScMapID { - buf(): wasmlib.ScMutableBytes { - return new wasmlib.ScMutableBytes(this.mapID, wasmlib.Key32.fromString(sc.ResultBuf)); +export class MutableGetVluResults extends wasmtypes.ScProxy { + buf(): wasmtypes.ScMutableBytes { + return new wasmtypes.ScMutableBytes(this.proxy.root(sc.ResultBuf)); } - nu64(): wasmlib.ScMutableUint64 { - return new wasmlib.ScMutableUint64(this.mapID, wasmlib.Key32.fromString(sc.ResultNu64)); + nu64(): wasmtypes.ScMutableUint64 { + return new wasmtypes.ScMutableUint64(this.proxy.root(sc.ResultNu64)); } - str(): wasmlib.ScMutableString { - return new wasmlib.ScMutableString(this.mapID, wasmlib.Key32.fromString(sc.ResultStr)); + str(): wasmtypes.ScMutableString { + return new wasmtypes.ScMutableString(this.proxy.root(sc.ResultStr)); } - xu64(): wasmlib.ScMutableUint64 { - return new wasmlib.ScMutableUint64(this.mapID, wasmlib.Key32.fromString(sc.ResultXu64)); + xu64(): wasmtypes.ScMutableUint64 { + return new wasmtypes.ScMutableUint64(this.proxy.root(sc.ResultXu64)); } } diff --git a/contracts/wasm/inccounter/ts/inccounter/state.ts b/contracts/wasm/inccounter/ts/inccounter/state.ts index e121f2c893..4e824c41d8 100644 --- a/contracts/wasm/inccounter/ts/inccounter/state.ts +++ b/contracts/wasm/inccounter/ts/inccounter/state.ts @@ -6,30 +6,29 @@ // Change the json schema instead import * as wasmlib from "wasmlib"; +import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; -export class ImmutableIncCounterState extends wasmlib.ScMapID { - counter(): wasmlib.ScImmutableInt64 { - return new wasmlib.ScImmutableInt64(this.mapID, wasmlib.Key32.fromString(sc.StateCounter)); +export class ImmutableIncCounterState extends wasmtypes.ScProxy { + counter(): wasmtypes.ScImmutableInt64 { + return new wasmtypes.ScImmutableInt64(this.proxy.root(sc.StateCounter)); } - numRepeats(): wasmlib.ScImmutableInt64 { - return new wasmlib.ScImmutableInt64(this.mapID, wasmlib.Key32.fromString(sc.StateNumRepeats)); + numRepeats(): wasmtypes.ScImmutableInt64 { + return new wasmtypes.ScImmutableInt64(this.proxy.root(sc.StateNumRepeats)); } } -export class MutableIncCounterState extends wasmlib.ScMapID { +export class MutableIncCounterState extends wasmtypes.ScProxy { asImmutable(): sc.ImmutableIncCounterState { - const imm = new sc.ImmutableIncCounterState(); - imm.mapID = this.mapID; - return imm; + return new sc.ImmutableIncCounterState(this.proxy); } - counter(): wasmlib.ScMutableInt64 { - return new wasmlib.ScMutableInt64(this.mapID, wasmlib.Key32.fromString(sc.StateCounter)); + counter(): wasmtypes.ScMutableInt64 { + return new wasmtypes.ScMutableInt64(this.proxy.root(sc.StateCounter)); } - numRepeats(): wasmlib.ScMutableInt64 { - return new wasmlib.ScMutableInt64(this.mapID, wasmlib.Key32.fromString(sc.StateNumRepeats)); + numRepeats(): wasmtypes.ScMutableInt64 { + return new wasmtypes.ScMutableInt64(this.proxy.root(sc.StateNumRepeats)); } } diff --git a/contracts/wasm/testcore/go/testcore/lib.go b/contracts/wasm/testcore/go/testcore/lib.go index 9eb57c27f7..29235216eb 100644 --- a/contracts/wasm/testcore/go/testcore/lib.go +++ b/contracts/wasm/testcore/go/testcore/lib.go @@ -68,8 +68,8 @@ func funcCallOnChainThunk(ctx wasmlib.ScFuncContext) { } ctx.Require(f.Params.IntValue().Exists(), "missing mandatory intValue") funcCallOnChain(ctx, f) - ctx.Log("testcore.funcCallOnChain ok") ctx.Results(results) + ctx.Log("testcore.funcCallOnChain ok") } type CheckContextFromFullEPContext struct { @@ -128,8 +128,8 @@ func funcGetMintedSupplyThunk(ctx wasmlib.ScFuncContext) { }, } funcGetMintedSupply(ctx, f) - ctx.Log("testcore.funcGetMintedSupply ok") ctx.Results(results) + ctx.Log("testcore.funcGetMintedSupply ok") } type IncCounterContext struct { @@ -218,8 +218,8 @@ func funcRunRecursionThunk(ctx wasmlib.ScFuncContext) { } ctx.Require(f.Params.IntValue().Exists(), "missing mandatory intValue") funcRunRecursion(ctx, f) - ctx.Log("testcore.funcRunRecursion ok") ctx.Results(results) + ctx.Log("testcore.funcRunRecursion ok") } type SendToAddressContext struct { @@ -362,8 +362,8 @@ func funcTestChainOwnerIDFullThunk(ctx wasmlib.ScFuncContext) { }, } funcTestChainOwnerIDFull(ctx, f) - ctx.Log("testcore.funcTestChainOwnerIDFull ok") ctx.Results(results) + ctx.Log("testcore.funcTestChainOwnerIDFull ok") } type TestEventLogDeployContext struct { @@ -496,8 +496,8 @@ func viewFibonacciThunk(ctx wasmlib.ScViewContext) { } ctx.Require(f.Params.IntValue().Exists(), "missing mandatory intValue") viewFibonacci(ctx, f) - ctx.Log("testcore.viewFibonacci ok") ctx.Results(results) + ctx.Log("testcore.viewFibonacci ok") } type GetCounterContext struct { @@ -517,8 +517,8 @@ func viewGetCounterThunk(ctx wasmlib.ScViewContext) { }, } viewGetCounter(ctx, f) - ctx.Log("testcore.viewGetCounter ok") ctx.Results(results) + ctx.Log("testcore.viewGetCounter ok") } type GetIntContext struct { @@ -543,8 +543,8 @@ func viewGetIntThunk(ctx wasmlib.ScViewContext) { } ctx.Require(f.Params.Name().Exists(), "missing mandatory name") viewGetInt(ctx, f) - ctx.Log("testcore.viewGetInt ok") ctx.Results(results) + ctx.Log("testcore.viewGetInt ok") } type GetStringValueContext struct { @@ -569,8 +569,8 @@ func viewGetStringValueThunk(ctx wasmlib.ScViewContext) { } ctx.Require(f.Params.VarName().Exists(), "missing mandatory varName") viewGetStringValue(ctx, f) - ctx.Log("testcore.viewGetStringValue ok") ctx.Results(results) + ctx.Log("testcore.viewGetStringValue ok") } type JustViewContext struct { @@ -650,8 +650,8 @@ func viewTestChainOwnerIDViewThunk(ctx wasmlib.ScViewContext) { }, } viewTestChainOwnerIDView(ctx, f) - ctx.Log("testcore.viewTestChainOwnerIDView ok") ctx.Results(results) + ctx.Log("testcore.viewTestChainOwnerIDView ok") } type TestPanicViewEPContext struct { @@ -686,6 +686,6 @@ func viewTestSandboxCallThunk(ctx wasmlib.ScViewContext) { }, } viewTestSandboxCall(ctx, f) - ctx.Log("testcore.viewTestSandboxCall ok") ctx.Results(results) + ctx.Log("testcore.viewTestSandboxCall ok") } diff --git a/contracts/wasm/testcore/go/testcore/results.go b/contracts/wasm/testcore/go/testcore/results.go index cff391e8e7..0b01e33811 100644 --- a/contracts/wasm/testcore/go/testcore/results.go +++ b/contracts/wasm/testcore/go/testcore/results.go @@ -118,7 +118,7 @@ type MapStringToImmutableInt64 struct { } func (m MapStringToImmutableInt64) GetInt64(key string) wasmtypes.ScImmutableInt64 { - return wasmtypes.NewScImmutableInt64(m.proxy.Key(wasmtypes.BytesFromString(key))) + return wasmtypes.NewScImmutableInt64(m.proxy.Key(wasmtypes.StringToBytes(key))) } type ImmutableGetIntResults struct { @@ -139,7 +139,7 @@ func (m MapStringToMutableInt64) Clear() { } func (m MapStringToMutableInt64) GetInt64(key string) wasmtypes.ScMutableInt64 { - return wasmtypes.NewScMutableInt64(m.proxy.Key(wasmtypes.BytesFromString(key))) + return wasmtypes.NewScMutableInt64(m.proxy.Key(wasmtypes.StringToBytes(key))) } type MutableGetIntResults struct { @@ -156,7 +156,7 @@ type MapStringToImmutableString struct { } func (m MapStringToImmutableString) GetString(key string) wasmtypes.ScImmutableString { - return wasmtypes.NewScImmutableString(m.proxy.Key(wasmtypes.BytesFromString(key))) + return wasmtypes.NewScImmutableString(m.proxy.Key(wasmtypes.StringToBytes(key))) } type ImmutableGetStringValueResults struct { @@ -177,7 +177,7 @@ func (m MapStringToMutableString) Clear() { } func (m MapStringToMutableString) GetString(key string) wasmtypes.ScMutableString { - return wasmtypes.NewScMutableString(m.proxy.Key(wasmtypes.BytesFromString(key))) + return wasmtypes.NewScMutableString(m.proxy.Key(wasmtypes.StringToBytes(key))) } type MutableGetStringValueResults struct { diff --git a/contracts/wasm/testcore/go/testcore/testcore.go b/contracts/wasm/testcore/go/testcore/testcore.go index d38f648ca3..7a302e2b49 100644 --- a/contracts/wasm/testcore/go/testcore/testcore.go +++ b/contracts/wasm/testcore/go/testcore/testcore.go @@ -19,7 +19,7 @@ const ( ) func funcCallOnChain(ctx wasmlib.ScFuncContext, f *CallOnChainContext) { - paramIn := f.Params.IntValue().Value() + paramInt := f.Params.IntValue().Value() hnameContract := ctx.Contract() if f.Params.HnameContract().Exists() { @@ -41,9 +41,10 @@ func funcCallOnChain(ctx wasmlib.ScFuncContext, f *CallOnChainContext) { counter.SetValue(counter.Value() + 1) params := wasmlib.NewScDict() - params.Set([]byte(ParamIntValue), wasmtypes.BytesFromInt64(paramIn)) + key := []byte(ParamIntValue) + params.Set(key, wasmtypes.Int64ToBytes(paramInt)) ret := ctx.Call(hnameContract, hnameEP, params, nil) - retVal := wasmtypes.Int64FromBytes(ret.Get([]byte(ParamIntValue))) + retVal := wasmtypes.Int64FromBytes(ret.Get(key)) f.Results.IntValue().SetValue(retVal) } @@ -107,8 +108,8 @@ func funcRunRecursion(ctx wasmlib.ScFuncContext, f *RunRecursionContext) { } func funcSendToAddress(ctx wasmlib.ScFuncContext, f *SendToAddressContext) { - balances := wasmlib.NewScTransfersFromBalances(ctx.Balances()) - ctx.TransferToAddress(f.Params.Address().Value(), balances) + transfer := wasmlib.NewScTransfersFromBalances(ctx.Balances()) + ctx.TransferToAddress(f.Params.Address().Value(), transfer) } func funcSetInt(ctx wasmlib.ScFuncContext, f *SetIntContext) { diff --git a/contracts/wasm/testcore/test/testcore_test.go b/contracts/wasm/testcore/test/testcore_test.go index 745bdf0a43..0f08ceea20 100644 --- a/contracts/wasm/testcore/test/testcore_test.go +++ b/contracts/wasm/testcore/test/testcore_test.go @@ -73,15 +73,15 @@ func run2(t *testing.T, test func(*testing.T, bool), skipWasm ...bool) { *wasmsolo.GoWasm = false } - //exists, _ = util.ExistsFilePath("../ts/pkg/testcore_ts.wasm") - //if exists { - // *wasmsolo.TsWasm = true - // wasmlib.ConnectHost(nil) - // t.Run(fmt.Sprintf("run TS version of %s", t.Name()), func(t *testing.T) { - // test(t, true) - // }) - // *wasmsolo.TsWasm = false - //} + exists, _ = util.ExistsFilePath("../ts/pkg/testcore_ts.wasm") + if exists { + *wasmsolo.TsWasm = true + wasmlib.ConnectHost(nil) + t.Run(fmt.Sprintf("run TS version of %s", t.Name()), func(t *testing.T) { + test(t, true) + }) + *wasmsolo.TsWasm = false + } *wasmsolo.GoDebug = true wasmlib.ConnectHost(nil) diff --git a/contracts/wasm/testcore/ts/testcore/consts.ts b/contracts/wasm/testcore/ts/testcore/consts.ts index 9800e419f1..5604fa9874 100644 --- a/contracts/wasm/testcore/ts/testcore/consts.ts +++ b/contracts/wasm/testcore/ts/testcore/consts.ts @@ -5,11 +5,11 @@ // >>>> DO NOT CHANGE THIS FILE! <<<< // Change the json schema instead -import * as wasmlib from "wasmlib"; +import * as wasmtypes from "wasmlib/wasmtypes"; export const ScName = "testcore"; export const ScDescription = "Core test for ISCP wasmlib Rust/Wasm library"; -export const HScName = new wasmlib.ScHname(0x370d33ad); +export const HScName = new wasmtypes.ScHname(0x370d33ad); export const ParamAddress = "address"; export const ParamAgentID = "agentID"; @@ -82,35 +82,35 @@ export const ViewTestChainOwnerIDView = "testChainOwnerIDView"; export const ViewTestPanicViewEP = "testPanicViewEP"; export const ViewTestSandboxCall = "testSandboxCall"; -export const HFuncCallOnChain = new wasmlib.ScHname(0x95a3d123); -export const HFuncCheckContextFromFullEP = new wasmlib.ScHname(0xa56c24ba); -export const HFuncDoNothing = new wasmlib.ScHname(0xdda4a6de); -export const HFuncGetMintedSupply = new wasmlib.ScHname(0x0c2d113c); -export const HFuncIncCounter = new wasmlib.ScHname(0x7b287419); -export const HFuncInit = new wasmlib.ScHname(0x1f44d644); -export const HFuncPassTypesFull = new wasmlib.ScHname(0x733ea0ea); -export const HFuncRunRecursion = new wasmlib.ScHname(0x833425fd); -export const HFuncSendToAddress = new wasmlib.ScHname(0x63ce4634); -export const HFuncSetInt = new wasmlib.ScHname(0x62056f74); -export const HFuncSpawn = new wasmlib.ScHname(0xec929d12); -export const HFuncTestBlockContext1 = new wasmlib.ScHname(0x796d4136); -export const HFuncTestBlockContext2 = new wasmlib.ScHname(0x758b0452); -export const HFuncTestCallPanicFullEP = new wasmlib.ScHname(0x4c878834); -export const HFuncTestCallPanicViewEPFromFull = new wasmlib.ScHname(0xfd7e8c1d); -export const HFuncTestChainOwnerIDFull = new wasmlib.ScHname(0x2aff1167); -export const HFuncTestEventLogDeploy = new wasmlib.ScHname(0x96ff760a); -export const HFuncTestEventLogEventData = new wasmlib.ScHname(0x0efcf939); -export const HFuncTestEventLogGenericData = new wasmlib.ScHname(0x6a16629d); -export const HFuncTestPanicFullEP = new wasmlib.ScHname(0x24fdef07); -export const HFuncWithdrawToChain = new wasmlib.ScHname(0x437bc026); -export const HViewCheckContextFromViewEP = new wasmlib.ScHname(0x88ff0167); -export const HViewFibonacci = new wasmlib.ScHname(0x7940873c); -export const HViewGetCounter = new wasmlib.ScHname(0xb423e607); -export const HViewGetInt = new wasmlib.ScHname(0x1887e5ef); -export const HViewGetStringValue = new wasmlib.ScHname(0xcf0a4d32); -export const HViewJustView = new wasmlib.ScHname(0x33b8972e); -export const HViewPassTypesView = new wasmlib.ScHname(0x1a5b87ea); -export const HViewTestCallPanicViewEPFromView = new wasmlib.ScHname(0x91b10c99); -export const HViewTestChainOwnerIDView = new wasmlib.ScHname(0x26586c33); -export const HViewTestPanicViewEP = new wasmlib.ScHname(0x22bc4d72); -export const HViewTestSandboxCall = new wasmlib.ScHname(0x42d72b63); +export const HFuncCallOnChain = new wasmtypes.ScHname(0x95a3d123); +export const HFuncCheckContextFromFullEP = new wasmtypes.ScHname(0xa56c24ba); +export const HFuncDoNothing = new wasmtypes.ScHname(0xdda4a6de); +export const HFuncGetMintedSupply = new wasmtypes.ScHname(0x0c2d113c); +export const HFuncIncCounter = new wasmtypes.ScHname(0x7b287419); +export const HFuncInit = new wasmtypes.ScHname(0x1f44d644); +export const HFuncPassTypesFull = new wasmtypes.ScHname(0x733ea0ea); +export const HFuncRunRecursion = new wasmtypes.ScHname(0x833425fd); +export const HFuncSendToAddress = new wasmtypes.ScHname(0x63ce4634); +export const HFuncSetInt = new wasmtypes.ScHname(0x62056f74); +export const HFuncSpawn = new wasmtypes.ScHname(0xec929d12); +export const HFuncTestBlockContext1 = new wasmtypes.ScHname(0x796d4136); +export const HFuncTestBlockContext2 = new wasmtypes.ScHname(0x758b0452); +export const HFuncTestCallPanicFullEP = new wasmtypes.ScHname(0x4c878834); +export const HFuncTestCallPanicViewEPFromFull = new wasmtypes.ScHname(0xfd7e8c1d); +export const HFuncTestChainOwnerIDFull = new wasmtypes.ScHname(0x2aff1167); +export const HFuncTestEventLogDeploy = new wasmtypes.ScHname(0x96ff760a); +export const HFuncTestEventLogEventData = new wasmtypes.ScHname(0x0efcf939); +export const HFuncTestEventLogGenericData = new wasmtypes.ScHname(0x6a16629d); +export const HFuncTestPanicFullEP = new wasmtypes.ScHname(0x24fdef07); +export const HFuncWithdrawToChain = new wasmtypes.ScHname(0x437bc026); +export const HViewCheckContextFromViewEP = new wasmtypes.ScHname(0x88ff0167); +export const HViewFibonacci = new wasmtypes.ScHname(0x7940873c); +export const HViewGetCounter = new wasmtypes.ScHname(0xb423e607); +export const HViewGetInt = new wasmtypes.ScHname(0x1887e5ef); +export const HViewGetStringValue = new wasmtypes.ScHname(0xcf0a4d32); +export const HViewJustView = new wasmtypes.ScHname(0x33b8972e); +export const HViewPassTypesView = new wasmtypes.ScHname(0x1a5b87ea); +export const HViewTestCallPanicViewEPFromView = new wasmtypes.ScHname(0x91b10c99); +export const HViewTestChainOwnerIDView = new wasmtypes.ScHname(0x26586c33); +export const HViewTestPanicViewEP = new wasmtypes.ScHname(0x22bc4d72); +export const HViewTestSandboxCall = new wasmtypes.ScHname(0x42d72b63); diff --git a/contracts/wasm/testcore/ts/testcore/contract.ts b/contracts/wasm/testcore/ts/testcore/contract.ts index 8c45bf2c57..ef57c564f3 100644 --- a/contracts/wasm/testcore/ts/testcore/contract.ts +++ b/contracts/wasm/testcore/ts/testcore/contract.ts @@ -6,28 +6,29 @@ // Change the json schema instead import * as wasmlib from "wasmlib"; +import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; export class CallOnChainCall { func: wasmlib.ScFunc = new wasmlib.ScFunc(sc.HScName, sc.HFuncCallOnChain); - params: sc.MutableCallOnChainParams = new sc.MutableCallOnChainParams(); - results: sc.ImmutableCallOnChainResults = new sc.ImmutableCallOnChainResults(); + params: sc.MutableCallOnChainParams = new sc.MutableCallOnChainParams(wasmlib.ScView.nilProxy); + results: sc.ImmutableCallOnChainResults = new sc.ImmutableCallOnChainResults(wasmlib.ScView.nilProxy); } export class CallOnChainContext { - params: sc.ImmutableCallOnChainParams = new sc.ImmutableCallOnChainParams(); - results: sc.MutableCallOnChainResults = new sc.MutableCallOnChainResults(); - state: sc.MutableTestCoreState = new sc.MutableTestCoreState(); + params: sc.ImmutableCallOnChainParams = new sc.ImmutableCallOnChainParams(wasmlib.paramsProxy()); + results: sc.MutableCallOnChainResults = new sc.MutableCallOnChainResults(wasmlib.ScView.nilProxy); + state: sc.MutableTestCoreState = new sc.MutableTestCoreState(wasmlib.ScState.proxy()); } export class CheckContextFromFullEPCall { func: wasmlib.ScFunc = new wasmlib.ScFunc(sc.HScName, sc.HFuncCheckContextFromFullEP); - params: sc.MutableCheckContextFromFullEPParams = new sc.MutableCheckContextFromFullEPParams(); + params: sc.MutableCheckContextFromFullEPParams = new sc.MutableCheckContextFromFullEPParams(wasmlib.ScView.nilProxy); } export class CheckContextFromFullEPContext { - params: sc.ImmutableCheckContextFromFullEPParams = new sc.ImmutableCheckContextFromFullEPParams(); - state: sc.MutableTestCoreState = new sc.MutableTestCoreState(); + params: sc.ImmutableCheckContextFromFullEPParams = new sc.ImmutableCheckContextFromFullEPParams(wasmlib.paramsProxy()); + state: sc.MutableTestCoreState = new sc.MutableTestCoreState(wasmlib.ScState.proxy()); } export class DoNothingCall { @@ -35,17 +36,17 @@ export class DoNothingCall { } export class DoNothingContext { - state: sc.MutableTestCoreState = new sc.MutableTestCoreState(); + state: sc.MutableTestCoreState = new sc.MutableTestCoreState(wasmlib.ScState.proxy()); } export class GetMintedSupplyCall { func: wasmlib.ScFunc = new wasmlib.ScFunc(sc.HScName, sc.HFuncGetMintedSupply); - results: sc.ImmutableGetMintedSupplyResults = new sc.ImmutableGetMintedSupplyResults(); + results: sc.ImmutableGetMintedSupplyResults = new sc.ImmutableGetMintedSupplyResults(wasmlib.ScView.nilProxy); } export class GetMintedSupplyContext { - results: sc.MutableGetMintedSupplyResults = new sc.MutableGetMintedSupplyResults(); - state: sc.MutableTestCoreState = new sc.MutableTestCoreState(); + results: sc.MutableGetMintedSupplyResults = new sc.MutableGetMintedSupplyResults(wasmlib.ScView.nilProxy); + state: sc.MutableTestCoreState = new sc.MutableTestCoreState(wasmlib.ScState.proxy()); } export class IncCounterCall { @@ -53,69 +54,69 @@ export class IncCounterCall { } export class IncCounterContext { - state: sc.MutableTestCoreState = new sc.MutableTestCoreState(); + state: sc.MutableTestCoreState = new sc.MutableTestCoreState(wasmlib.ScState.proxy()); } export class InitCall { func: wasmlib.ScInitFunc = new wasmlib.ScInitFunc(sc.HScName, sc.HFuncInit); - params: sc.MutableInitParams = new sc.MutableInitParams(); + params: sc.MutableInitParams = new sc.MutableInitParams(wasmlib.ScView.nilProxy); } export class InitContext { - params: sc.ImmutableInitParams = new sc.ImmutableInitParams(); - state: sc.MutableTestCoreState = new sc.MutableTestCoreState(); + params: sc.ImmutableInitParams = new sc.ImmutableInitParams(wasmlib.paramsProxy()); + state: sc.MutableTestCoreState = new sc.MutableTestCoreState(wasmlib.ScState.proxy()); } export class PassTypesFullCall { func: wasmlib.ScFunc = new wasmlib.ScFunc(sc.HScName, sc.HFuncPassTypesFull); - params: sc.MutablePassTypesFullParams = new sc.MutablePassTypesFullParams(); + params: sc.MutablePassTypesFullParams = new sc.MutablePassTypesFullParams(wasmlib.ScView.nilProxy); } export class PassTypesFullContext { - params: sc.ImmutablePassTypesFullParams = new sc.ImmutablePassTypesFullParams(); - state: sc.MutableTestCoreState = new sc.MutableTestCoreState(); + params: sc.ImmutablePassTypesFullParams = new sc.ImmutablePassTypesFullParams(wasmlib.paramsProxy()); + state: sc.MutableTestCoreState = new sc.MutableTestCoreState(wasmlib.ScState.proxy()); } export class RunRecursionCall { func: wasmlib.ScFunc = new wasmlib.ScFunc(sc.HScName, sc.HFuncRunRecursion); - params: sc.MutableRunRecursionParams = new sc.MutableRunRecursionParams(); - results: sc.ImmutableRunRecursionResults = new sc.ImmutableRunRecursionResults(); + params: sc.MutableRunRecursionParams = new sc.MutableRunRecursionParams(wasmlib.ScView.nilProxy); + results: sc.ImmutableRunRecursionResults = new sc.ImmutableRunRecursionResults(wasmlib.ScView.nilProxy); } export class RunRecursionContext { - params: sc.ImmutableRunRecursionParams = new sc.ImmutableRunRecursionParams(); - results: sc.MutableRunRecursionResults = new sc.MutableRunRecursionResults(); - state: sc.MutableTestCoreState = new sc.MutableTestCoreState(); + params: sc.ImmutableRunRecursionParams = new sc.ImmutableRunRecursionParams(wasmlib.paramsProxy()); + results: sc.MutableRunRecursionResults = new sc.MutableRunRecursionResults(wasmlib.ScView.nilProxy); + state: sc.MutableTestCoreState = new sc.MutableTestCoreState(wasmlib.ScState.proxy()); } export class SendToAddressCall { func: wasmlib.ScFunc = new wasmlib.ScFunc(sc.HScName, sc.HFuncSendToAddress); - params: sc.MutableSendToAddressParams = new sc.MutableSendToAddressParams(); + params: sc.MutableSendToAddressParams = new sc.MutableSendToAddressParams(wasmlib.ScView.nilProxy); } export class SendToAddressContext { - params: sc.ImmutableSendToAddressParams = new sc.ImmutableSendToAddressParams(); - state: sc.MutableTestCoreState = new sc.MutableTestCoreState(); + params: sc.ImmutableSendToAddressParams = new sc.ImmutableSendToAddressParams(wasmlib.paramsProxy()); + state: sc.MutableTestCoreState = new sc.MutableTestCoreState(wasmlib.ScState.proxy()); } export class SetIntCall { func: wasmlib.ScFunc = new wasmlib.ScFunc(sc.HScName, sc.HFuncSetInt); - params: sc.MutableSetIntParams = new sc.MutableSetIntParams(); + params: sc.MutableSetIntParams = new sc.MutableSetIntParams(wasmlib.ScView.nilProxy); } export class SetIntContext { - params: sc.ImmutableSetIntParams = new sc.ImmutableSetIntParams(); - state: sc.MutableTestCoreState = new sc.MutableTestCoreState(); + params: sc.ImmutableSetIntParams = new sc.ImmutableSetIntParams(wasmlib.paramsProxy()); + state: sc.MutableTestCoreState = new sc.MutableTestCoreState(wasmlib.ScState.proxy()); } export class SpawnCall { func: wasmlib.ScFunc = new wasmlib.ScFunc(sc.HScName, sc.HFuncSpawn); - params: sc.MutableSpawnParams = new sc.MutableSpawnParams(); + params: sc.MutableSpawnParams = new sc.MutableSpawnParams(wasmlib.ScView.nilProxy); } export class SpawnContext { - params: sc.ImmutableSpawnParams = new sc.ImmutableSpawnParams(); - state: sc.MutableTestCoreState = new sc.MutableTestCoreState(); + params: sc.ImmutableSpawnParams = new sc.ImmutableSpawnParams(wasmlib.paramsProxy()); + state: sc.MutableTestCoreState = new sc.MutableTestCoreState(wasmlib.ScState.proxy()); } export class TestBlockContext1Call { @@ -123,7 +124,7 @@ export class TestBlockContext1Call { } export class TestBlockContext1Context { - state: sc.MutableTestCoreState = new sc.MutableTestCoreState(); + state: sc.MutableTestCoreState = new sc.MutableTestCoreState(wasmlib.ScState.proxy()); } export class TestBlockContext2Call { @@ -131,7 +132,7 @@ export class TestBlockContext2Call { } export class TestBlockContext2Context { - state: sc.MutableTestCoreState = new sc.MutableTestCoreState(); + state: sc.MutableTestCoreState = new sc.MutableTestCoreState(wasmlib.ScState.proxy()); } export class TestCallPanicFullEPCall { @@ -139,7 +140,7 @@ export class TestCallPanicFullEPCall { } export class TestCallPanicFullEPContext { - state: sc.MutableTestCoreState = new sc.MutableTestCoreState(); + state: sc.MutableTestCoreState = new sc.MutableTestCoreState(wasmlib.ScState.proxy()); } export class TestCallPanicViewEPFromFullCall { @@ -147,17 +148,17 @@ export class TestCallPanicViewEPFromFullCall { } export class TestCallPanicViewEPFromFullContext { - state: sc.MutableTestCoreState = new sc.MutableTestCoreState(); + state: sc.MutableTestCoreState = new sc.MutableTestCoreState(wasmlib.ScState.proxy()); } export class TestChainOwnerIDFullCall { func: wasmlib.ScFunc = new wasmlib.ScFunc(sc.HScName, sc.HFuncTestChainOwnerIDFull); - results: sc.ImmutableTestChainOwnerIDFullResults = new sc.ImmutableTestChainOwnerIDFullResults(); + results: sc.ImmutableTestChainOwnerIDFullResults = new sc.ImmutableTestChainOwnerIDFullResults(wasmlib.ScView.nilProxy); } export class TestChainOwnerIDFullContext { - results: sc.MutableTestChainOwnerIDFullResults = new sc.MutableTestChainOwnerIDFullResults(); - state: sc.MutableTestCoreState = new sc.MutableTestCoreState(); + results: sc.MutableTestChainOwnerIDFullResults = new sc.MutableTestChainOwnerIDFullResults(wasmlib.ScView.nilProxy); + state: sc.MutableTestCoreState = new sc.MutableTestCoreState(wasmlib.ScState.proxy()); } export class TestEventLogDeployCall { @@ -165,7 +166,7 @@ export class TestEventLogDeployCall { } export class TestEventLogDeployContext { - state: sc.MutableTestCoreState = new sc.MutableTestCoreState(); + state: sc.MutableTestCoreState = new sc.MutableTestCoreState(wasmlib.ScState.proxy()); } export class TestEventLogEventDataCall { @@ -173,17 +174,17 @@ export class TestEventLogEventDataCall { } export class TestEventLogEventDataContext { - state: sc.MutableTestCoreState = new sc.MutableTestCoreState(); + state: sc.MutableTestCoreState = new sc.MutableTestCoreState(wasmlib.ScState.proxy()); } export class TestEventLogGenericDataCall { func: wasmlib.ScFunc = new wasmlib.ScFunc(sc.HScName, sc.HFuncTestEventLogGenericData); - params: sc.MutableTestEventLogGenericDataParams = new sc.MutableTestEventLogGenericDataParams(); + params: sc.MutableTestEventLogGenericDataParams = new sc.MutableTestEventLogGenericDataParams(wasmlib.ScView.nilProxy); } export class TestEventLogGenericDataContext { - params: sc.ImmutableTestEventLogGenericDataParams = new sc.ImmutableTestEventLogGenericDataParams(); - state: sc.MutableTestCoreState = new sc.MutableTestCoreState(); + params: sc.ImmutableTestEventLogGenericDataParams = new sc.ImmutableTestEventLogGenericDataParams(wasmlib.paramsProxy()); + state: sc.MutableTestCoreState = new sc.MutableTestCoreState(wasmlib.ScState.proxy()); } export class TestPanicFullEPCall { @@ -191,73 +192,73 @@ export class TestPanicFullEPCall { } export class TestPanicFullEPContext { - state: sc.MutableTestCoreState = new sc.MutableTestCoreState(); + state: sc.MutableTestCoreState = new sc.MutableTestCoreState(wasmlib.ScState.proxy()); } export class WithdrawToChainCall { func: wasmlib.ScFunc = new wasmlib.ScFunc(sc.HScName, sc.HFuncWithdrawToChain); - params: sc.MutableWithdrawToChainParams = new sc.MutableWithdrawToChainParams(); + params: sc.MutableWithdrawToChainParams = new sc.MutableWithdrawToChainParams(wasmlib.ScView.nilProxy); } export class WithdrawToChainContext { - params: sc.ImmutableWithdrawToChainParams = new sc.ImmutableWithdrawToChainParams(); - state: sc.MutableTestCoreState = new sc.MutableTestCoreState(); + params: sc.ImmutableWithdrawToChainParams = new sc.ImmutableWithdrawToChainParams(wasmlib.paramsProxy()); + state: sc.MutableTestCoreState = new sc.MutableTestCoreState(wasmlib.ScState.proxy()); } export class CheckContextFromViewEPCall { func: wasmlib.ScView = new wasmlib.ScView(sc.HScName, sc.HViewCheckContextFromViewEP); - params: sc.MutableCheckContextFromViewEPParams = new sc.MutableCheckContextFromViewEPParams(); + params: sc.MutableCheckContextFromViewEPParams = new sc.MutableCheckContextFromViewEPParams(wasmlib.ScView.nilProxy); } export class CheckContextFromViewEPContext { - params: sc.ImmutableCheckContextFromViewEPParams = new sc.ImmutableCheckContextFromViewEPParams(); - state: sc.ImmutableTestCoreState = new sc.ImmutableTestCoreState(); + params: sc.ImmutableCheckContextFromViewEPParams = new sc.ImmutableCheckContextFromViewEPParams(wasmlib.paramsProxy()); + state: sc.ImmutableTestCoreState = new sc.ImmutableTestCoreState(wasmlib.ScState.proxy()); } export class FibonacciCall { func: wasmlib.ScView = new wasmlib.ScView(sc.HScName, sc.HViewFibonacci); - params: sc.MutableFibonacciParams = new sc.MutableFibonacciParams(); - results: sc.ImmutableFibonacciResults = new sc.ImmutableFibonacciResults(); + params: sc.MutableFibonacciParams = new sc.MutableFibonacciParams(wasmlib.ScView.nilProxy); + results: sc.ImmutableFibonacciResults = new sc.ImmutableFibonacciResults(wasmlib.ScView.nilProxy); } export class FibonacciContext { - params: sc.ImmutableFibonacciParams = new sc.ImmutableFibonacciParams(); - results: sc.MutableFibonacciResults = new sc.MutableFibonacciResults(); - state: sc.ImmutableTestCoreState = new sc.ImmutableTestCoreState(); + params: sc.ImmutableFibonacciParams = new sc.ImmutableFibonacciParams(wasmlib.paramsProxy()); + results: sc.MutableFibonacciResults = new sc.MutableFibonacciResults(wasmlib.ScView.nilProxy); + state: sc.ImmutableTestCoreState = new sc.ImmutableTestCoreState(wasmlib.ScState.proxy()); } export class GetCounterCall { func: wasmlib.ScView = new wasmlib.ScView(sc.HScName, sc.HViewGetCounter); - results: sc.ImmutableGetCounterResults = new sc.ImmutableGetCounterResults(); + results: sc.ImmutableGetCounterResults = new sc.ImmutableGetCounterResults(wasmlib.ScView.nilProxy); } export class GetCounterContext { - results: sc.MutableGetCounterResults = new sc.MutableGetCounterResults(); - state: sc.ImmutableTestCoreState = new sc.ImmutableTestCoreState(); + results: sc.MutableGetCounterResults = new sc.MutableGetCounterResults(wasmlib.ScView.nilProxy); + state: sc.ImmutableTestCoreState = new sc.ImmutableTestCoreState(wasmlib.ScState.proxy()); } export class GetIntCall { func: wasmlib.ScView = new wasmlib.ScView(sc.HScName, sc.HViewGetInt); - params: sc.MutableGetIntParams = new sc.MutableGetIntParams(); - results: sc.ImmutableGetIntResults = new sc.ImmutableGetIntResults(); + params: sc.MutableGetIntParams = new sc.MutableGetIntParams(wasmlib.ScView.nilProxy); + results: sc.ImmutableGetIntResults = new sc.ImmutableGetIntResults(wasmlib.ScView.nilProxy); } export class GetIntContext { - params: sc.ImmutableGetIntParams = new sc.ImmutableGetIntParams(); - results: sc.MutableGetIntResults = new sc.MutableGetIntResults(); - state: sc.ImmutableTestCoreState = new sc.ImmutableTestCoreState(); + params: sc.ImmutableGetIntParams = new sc.ImmutableGetIntParams(wasmlib.paramsProxy()); + results: sc.MutableGetIntResults = new sc.MutableGetIntResults(wasmlib.ScView.nilProxy); + state: sc.ImmutableTestCoreState = new sc.ImmutableTestCoreState(wasmlib.ScState.proxy()); } export class GetStringValueCall { func: wasmlib.ScView = new wasmlib.ScView(sc.HScName, sc.HViewGetStringValue); - params: sc.MutableGetStringValueParams = new sc.MutableGetStringValueParams(); - results: sc.ImmutableGetStringValueResults = new sc.ImmutableGetStringValueResults(); + params: sc.MutableGetStringValueParams = new sc.MutableGetStringValueParams(wasmlib.ScView.nilProxy); + results: sc.ImmutableGetStringValueResults = new sc.ImmutableGetStringValueResults(wasmlib.ScView.nilProxy); } export class GetStringValueContext { - params: sc.ImmutableGetStringValueParams = new sc.ImmutableGetStringValueParams(); - results: sc.MutableGetStringValueResults = new sc.MutableGetStringValueResults(); - state: sc.ImmutableTestCoreState = new sc.ImmutableTestCoreState(); + params: sc.ImmutableGetStringValueParams = new sc.ImmutableGetStringValueParams(wasmlib.paramsProxy()); + results: sc.MutableGetStringValueResults = new sc.MutableGetStringValueResults(wasmlib.ScView.nilProxy); + state: sc.ImmutableTestCoreState = new sc.ImmutableTestCoreState(wasmlib.ScState.proxy()); } export class JustViewCall { @@ -265,17 +266,17 @@ export class JustViewCall { } export class JustViewContext { - state: sc.ImmutableTestCoreState = new sc.ImmutableTestCoreState(); + state: sc.ImmutableTestCoreState = new sc.ImmutableTestCoreState(wasmlib.ScState.proxy()); } export class PassTypesViewCall { func: wasmlib.ScView = new wasmlib.ScView(sc.HScName, sc.HViewPassTypesView); - params: sc.MutablePassTypesViewParams = new sc.MutablePassTypesViewParams(); + params: sc.MutablePassTypesViewParams = new sc.MutablePassTypesViewParams(wasmlib.ScView.nilProxy); } export class PassTypesViewContext { - params: sc.ImmutablePassTypesViewParams = new sc.ImmutablePassTypesViewParams(); - state: sc.ImmutableTestCoreState = new sc.ImmutableTestCoreState(); + params: sc.ImmutablePassTypesViewParams = new sc.ImmutablePassTypesViewParams(wasmlib.paramsProxy()); + state: sc.ImmutableTestCoreState = new sc.ImmutableTestCoreState(wasmlib.ScState.proxy()); } export class TestCallPanicViewEPFromViewCall { @@ -283,17 +284,17 @@ export class TestCallPanicViewEPFromViewCall { } export class TestCallPanicViewEPFromViewContext { - state: sc.ImmutableTestCoreState = new sc.ImmutableTestCoreState(); + state: sc.ImmutableTestCoreState = new sc.ImmutableTestCoreState(wasmlib.ScState.proxy()); } export class TestChainOwnerIDViewCall { func: wasmlib.ScView = new wasmlib.ScView(sc.HScName, sc.HViewTestChainOwnerIDView); - results: sc.ImmutableTestChainOwnerIDViewResults = new sc.ImmutableTestChainOwnerIDViewResults(); + results: sc.ImmutableTestChainOwnerIDViewResults = new sc.ImmutableTestChainOwnerIDViewResults(wasmlib.ScView.nilProxy); } export class TestChainOwnerIDViewContext { - results: sc.MutableTestChainOwnerIDViewResults = new sc.MutableTestChainOwnerIDViewResults(); - state: sc.ImmutableTestCoreState = new sc.ImmutableTestCoreState(); + results: sc.MutableTestChainOwnerIDViewResults = new sc.MutableTestChainOwnerIDViewResults(wasmlib.ScView.nilProxy); + state: sc.ImmutableTestCoreState = new sc.ImmutableTestCoreState(wasmlib.ScState.proxy()); } export class TestPanicViewEPCall { @@ -301,29 +302,30 @@ export class TestPanicViewEPCall { } export class TestPanicViewEPContext { - state: sc.ImmutableTestCoreState = new sc.ImmutableTestCoreState(); + state: sc.ImmutableTestCoreState = new sc.ImmutableTestCoreState(wasmlib.ScState.proxy()); } export class TestSandboxCallCall { func: wasmlib.ScView = new wasmlib.ScView(sc.HScName, sc.HViewTestSandboxCall); - results: sc.ImmutableTestSandboxCallResults = new sc.ImmutableTestSandboxCallResults(); + results: sc.ImmutableTestSandboxCallResults = new sc.ImmutableTestSandboxCallResults(wasmlib.ScView.nilProxy); } export class TestSandboxCallContext { - results: sc.MutableTestSandboxCallResults = new sc.MutableTestSandboxCallResults(); - state: sc.ImmutableTestCoreState = new sc.ImmutableTestCoreState(); + results: sc.MutableTestSandboxCallResults = new sc.MutableTestSandboxCallResults(wasmlib.ScView.nilProxy); + state: sc.ImmutableTestCoreState = new sc.ImmutableTestCoreState(wasmlib.ScState.proxy()); } export class ScFuncs { static callOnChain(ctx: wasmlib.ScFuncCallContext): CallOnChainCall { - let f = new CallOnChainCall(); - f.func.setPtrs(f.params, f.results); + const f = new CallOnChainCall(); + f.params = new sc.MutableCallOnChainParams(wasmlib.newCallParamsProxy(f.func)); + f.results = new sc.ImmutableCallOnChainResults(wasmlib.newCallResultsProxy(f.func)); return f; } static checkContextFromFullEP(ctx: wasmlib.ScFuncCallContext): CheckContextFromFullEPCall { - let f = new CheckContextFromFullEPCall(); - f.func.setPtrs(f.params, null); + const f = new CheckContextFromFullEPCall(); + f.params = new sc.MutableCheckContextFromFullEPParams(wasmlib.newCallParamsProxy(f.func)); return f; } @@ -332,8 +334,8 @@ export class ScFuncs { } static getMintedSupply(ctx: wasmlib.ScFuncCallContext): GetMintedSupplyCall { - let f = new GetMintedSupplyCall(); - f.func.setPtrs(null, f.results); + const f = new GetMintedSupplyCall(); + f.results = new sc.ImmutableGetMintedSupplyResults(wasmlib.newCallResultsProxy(f.func)); return f; } @@ -342,38 +344,39 @@ export class ScFuncs { } static init(ctx: wasmlib.ScFuncCallContext): InitCall { - let f = new InitCall(); - f.func.setPtrs(f.params, null); + const f = new InitCall(); + f.params = new sc.MutableInitParams(wasmlib.newCallParamsProxy(f.func)); return f; } static passTypesFull(ctx: wasmlib.ScFuncCallContext): PassTypesFullCall { - let f = new PassTypesFullCall(); - f.func.setPtrs(f.params, null); + const f = new PassTypesFullCall(); + f.params = new sc.MutablePassTypesFullParams(wasmlib.newCallParamsProxy(f.func)); return f; } static runRecursion(ctx: wasmlib.ScFuncCallContext): RunRecursionCall { - let f = new RunRecursionCall(); - f.func.setPtrs(f.params, f.results); + const f = new RunRecursionCall(); + f.params = new sc.MutableRunRecursionParams(wasmlib.newCallParamsProxy(f.func)); + f.results = new sc.ImmutableRunRecursionResults(wasmlib.newCallResultsProxy(f.func)); return f; } static sendToAddress(ctx: wasmlib.ScFuncCallContext): SendToAddressCall { - let f = new SendToAddressCall(); - f.func.setPtrs(f.params, null); + const f = new SendToAddressCall(); + f.params = new sc.MutableSendToAddressParams(wasmlib.newCallParamsProxy(f.func)); return f; } static setInt(ctx: wasmlib.ScFuncCallContext): SetIntCall { - let f = new SetIntCall(); - f.func.setPtrs(f.params, null); + const f = new SetIntCall(); + f.params = new sc.MutableSetIntParams(wasmlib.newCallParamsProxy(f.func)); return f; } static spawn(ctx: wasmlib.ScFuncCallContext): SpawnCall { - let f = new SpawnCall(); - f.func.setPtrs(f.params, null); + const f = new SpawnCall(); + f.params = new sc.MutableSpawnParams(wasmlib.newCallParamsProxy(f.func)); return f; } @@ -394,8 +397,8 @@ export class ScFuncs { } static testChainOwnerIDFull(ctx: wasmlib.ScFuncCallContext): TestChainOwnerIDFullCall { - let f = new TestChainOwnerIDFullCall(); - f.func.setPtrs(null, f.results); + const f = new TestChainOwnerIDFullCall(); + f.results = new sc.ImmutableTestChainOwnerIDFullResults(wasmlib.newCallResultsProxy(f.func)); return f; } @@ -408,8 +411,8 @@ export class ScFuncs { } static testEventLogGenericData(ctx: wasmlib.ScFuncCallContext): TestEventLogGenericDataCall { - let f = new TestEventLogGenericDataCall(); - f.func.setPtrs(f.params, null); + const f = new TestEventLogGenericDataCall(); + f.params = new sc.MutableTestEventLogGenericDataParams(wasmlib.newCallParamsProxy(f.func)); return f; } @@ -418,38 +421,41 @@ export class ScFuncs { } static withdrawToChain(ctx: wasmlib.ScFuncCallContext): WithdrawToChainCall { - let f = new WithdrawToChainCall(); - f.func.setPtrs(f.params, null); + const f = new WithdrawToChainCall(); + f.params = new sc.MutableWithdrawToChainParams(wasmlib.newCallParamsProxy(f.func)); return f; } static checkContextFromViewEP(ctx: wasmlib.ScViewCallContext): CheckContextFromViewEPCall { - let f = new CheckContextFromViewEPCall(); - f.func.setPtrs(f.params, null); + const f = new CheckContextFromViewEPCall(); + f.params = new sc.MutableCheckContextFromViewEPParams(wasmlib.newCallParamsProxy(f.func)); return f; } static fibonacci(ctx: wasmlib.ScViewCallContext): FibonacciCall { - let f = new FibonacciCall(); - f.func.setPtrs(f.params, f.results); + const f = new FibonacciCall(); + f.params = new sc.MutableFibonacciParams(wasmlib.newCallParamsProxy(f.func)); + f.results = new sc.ImmutableFibonacciResults(wasmlib.newCallResultsProxy(f.func)); return f; } static getCounter(ctx: wasmlib.ScViewCallContext): GetCounterCall { - let f = new GetCounterCall(); - f.func.setPtrs(null, f.results); + const f = new GetCounterCall(); + f.results = new sc.ImmutableGetCounterResults(wasmlib.newCallResultsProxy(f.func)); return f; } static getInt(ctx: wasmlib.ScViewCallContext): GetIntCall { - let f = new GetIntCall(); - f.func.setPtrs(f.params, f.results); + const f = new GetIntCall(); + f.params = new sc.MutableGetIntParams(wasmlib.newCallParamsProxy(f.func)); + f.results = new sc.ImmutableGetIntResults(wasmlib.newCallResultsProxy(f.func)); return f; } static getStringValue(ctx: wasmlib.ScViewCallContext): GetStringValueCall { - let f = new GetStringValueCall(); - f.func.setPtrs(f.params, f.results); + const f = new GetStringValueCall(); + f.params = new sc.MutableGetStringValueParams(wasmlib.newCallParamsProxy(f.func)); + f.results = new sc.ImmutableGetStringValueResults(wasmlib.newCallResultsProxy(f.func)); return f; } @@ -458,8 +464,8 @@ export class ScFuncs { } static passTypesView(ctx: wasmlib.ScViewCallContext): PassTypesViewCall { - let f = new PassTypesViewCall(); - f.func.setPtrs(f.params, null); + const f = new PassTypesViewCall(); + f.params = new sc.MutablePassTypesViewParams(wasmlib.newCallParamsProxy(f.func)); return f; } @@ -468,8 +474,8 @@ export class ScFuncs { } static testChainOwnerIDView(ctx: wasmlib.ScViewCallContext): TestChainOwnerIDViewCall { - let f = new TestChainOwnerIDViewCall(); - f.func.setPtrs(null, f.results); + const f = new TestChainOwnerIDViewCall(); + f.results = new sc.ImmutableTestChainOwnerIDViewResults(wasmlib.newCallResultsProxy(f.func)); return f; } @@ -478,8 +484,8 @@ export class ScFuncs { } static testSandboxCall(ctx: wasmlib.ScViewCallContext): TestSandboxCallCall { - let f = new TestSandboxCallCall(); - f.func.setPtrs(null, f.results); + const f = new TestSandboxCallCall(); + f.results = new sc.ImmutableTestSandboxCallResults(wasmlib.newCallResultsProxy(f.func)); return f; } } diff --git a/contracts/wasm/testcore/ts/testcore/index.ts b/contracts/wasm/testcore/ts/testcore/index.ts index 02a05c8ac8..0fef884c82 100644 --- a/contracts/wasm/testcore/ts/testcore/index.ts +++ b/contracts/wasm/testcore/ts/testcore/index.ts @@ -9,7 +9,6 @@ export * from "./testcore"; export * from "./consts"; export * from "./contract"; -export * from "./keys"; export * from "./lib"; export * from "./params"; export * from "./results"; diff --git a/contracts/wasm/testcore/ts/testcore/keys.ts b/contracts/wasm/testcore/ts/testcore/keys.ts index f1fdbcb9fb..ea01558902 100644 --- a/contracts/wasm/testcore/ts/testcore/keys.ts +++ b/contracts/wasm/testcore/ts/testcore/keys.ts @@ -5,8 +5,6 @@ // >>>> DO NOT CHANGE THIS FILE! <<<< // Change the json schema instead -import * as wasmlib from "wasmlib"; -import * as sc from "./index"; export const IdxParamAddress = 0; export const IdxParamAgentID = 1; @@ -30,58 +28,3 @@ export const IdxParamProgHash = 18; export const IdxParamString = 19; export const IdxParamStringZero = 20; export const IdxParamVarName = 21; - -export const IdxResultChainOwnerID = 22; -export const IdxResultCounter = 23; -export const IdxResultIntValue = 24; -export const IdxResultMintedColor = 25; -export const IdxResultMintedSupply = 26; -export const IdxResultSandboxCall = 27; -export const IdxResultValues = 28; -export const IdxResultVars = 29; - -export const IdxStateCounter = 30; -export const IdxStateHnameEP = 31; -export const IdxStateInts = 32; -export const IdxStateMintedColor = 33; -export const IdxStateMintedSupply = 34; - -export let keyMap: string[] = [ - sc.ParamAddress, - sc.ParamAgentID, - sc.ParamCaller, - sc.ParamChainID, - sc.ParamChainOwnerID, - sc.ParamContractCreator, - sc.ParamContractID, - sc.ParamCounter, - sc.ParamFail, - sc.ParamHash, - sc.ParamHname, - sc.ParamHnameContract, - sc.ParamHnameEP, - sc.ParamHnameZero, - sc.ParamInt64, - sc.ParamInt64Zero, - sc.ParamIntValue, - sc.ParamName, - sc.ParamProgHash, - sc.ParamString, - sc.ParamStringZero, - sc.ParamVarName, - sc.ResultChainOwnerID, - sc.ResultCounter, - sc.ResultIntValue, - sc.ResultMintedColor, - sc.ResultMintedSupply, - sc.ResultSandboxCall, - sc.ResultValues, - sc.ResultVars, - sc.StateCounter, - sc.StateHnameEP, - sc.StateInts, - sc.StateMintedColor, - sc.StateMintedSupply, -]; - -export let idxMap: wasmlib.Key32[] = new Array(keyMap.length); diff --git a/contracts/wasm/testcore/ts/testcore/lib.ts b/contracts/wasm/testcore/ts/testcore/lib.ts index 2ff3e7d18e..b1fdf1995d 100644 --- a/contracts/wasm/testcore/ts/testcore/lib.ts +++ b/contracts/wasm/testcore/ts/testcore/lib.ts @@ -6,6 +6,7 @@ // Change the json schema instead import * as wasmlib from "wasmlib"; +import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; export function on_call(index: i32): void { @@ -46,28 +47,22 @@ export function on_load(): void { exports.addView(sc.ViewTestChainOwnerIDView, viewTestChainOwnerIDViewThunk); exports.addView(sc.ViewTestPanicViewEP, viewTestPanicViewEPThunk); exports.addView(sc.ViewTestSandboxCall, viewTestSandboxCallThunk); - - for (let i = 0; i < sc.keyMap.length; i++) { - sc.idxMap[i] = wasmlib.Key32.fromString(sc.keyMap[i]); - } } function funcCallOnChainThunk(ctx: wasmlib.ScFuncContext): void { ctx.log("testcore.funcCallOnChain"); let f = new sc.CallOnChainContext(); - f.params.mapID = wasmlib.OBJ_ID_PARAMS; - f.results.mapID = wasmlib.OBJ_ID_RESULTS; - f.state.mapID = wasmlib.OBJ_ID_STATE; + const results = new wasmlib.ScDict([]); + f.results = new sc.MutableCallOnChainResults(results.asProxy()); ctx.require(f.params.intValue().exists(), "missing mandatory intValue"); sc.funcCallOnChain(ctx, f); + ctx.results(results); ctx.log("testcore.funcCallOnChain ok"); } function funcCheckContextFromFullEPThunk(ctx: wasmlib.ScFuncContext): void { ctx.log("testcore.funcCheckContextFromFullEP"); let f = new sc.CheckContextFromFullEPContext(); - f.params.mapID = wasmlib.OBJ_ID_PARAMS; - f.state.mapID = wasmlib.OBJ_ID_STATE; ctx.require(f.params.agentID().exists(), "missing mandatory agentID"); ctx.require(f.params.caller().exists(), "missing mandatory caller"); ctx.require(f.params.chainID().exists(), "missing mandatory chainID"); @@ -80,7 +75,6 @@ function funcCheckContextFromFullEPThunk(ctx: wasmlib.ScFuncContext): void { function funcDoNothingThunk(ctx: wasmlib.ScFuncContext): void { ctx.log("testcore.funcDoNothing"); let f = new sc.DoNothingContext(); - f.state.mapID = wasmlib.OBJ_ID_STATE; sc.funcDoNothing(ctx, f); ctx.log("testcore.funcDoNothing ok"); } @@ -88,16 +82,16 @@ function funcDoNothingThunk(ctx: wasmlib.ScFuncContext): void { function funcGetMintedSupplyThunk(ctx: wasmlib.ScFuncContext): void { ctx.log("testcore.funcGetMintedSupply"); let f = new sc.GetMintedSupplyContext(); - f.results.mapID = wasmlib.OBJ_ID_RESULTS; - f.state.mapID = wasmlib.OBJ_ID_STATE; + const results = new wasmlib.ScDict([]); + f.results = new sc.MutableGetMintedSupplyResults(results.asProxy()); sc.funcGetMintedSupply(ctx, f); + ctx.results(results); ctx.log("testcore.funcGetMintedSupply ok"); } function funcIncCounterThunk(ctx: wasmlib.ScFuncContext): void { ctx.log("testcore.funcIncCounter"); let f = new sc.IncCounterContext(); - f.state.mapID = wasmlib.OBJ_ID_STATE; sc.funcIncCounter(ctx, f); ctx.log("testcore.funcIncCounter ok"); } @@ -105,8 +99,6 @@ function funcIncCounterThunk(ctx: wasmlib.ScFuncContext): void { function funcInitThunk(ctx: wasmlib.ScFuncContext): void { ctx.log("testcore.funcInit"); let f = new sc.InitContext(); - f.params.mapID = wasmlib.OBJ_ID_PARAMS; - f.state.mapID = wasmlib.OBJ_ID_STATE; sc.funcInit(ctx, f); ctx.log("testcore.funcInit ok"); } @@ -114,8 +106,6 @@ function funcInitThunk(ctx: wasmlib.ScFuncContext): void { function funcPassTypesFullThunk(ctx: wasmlib.ScFuncContext): void { ctx.log("testcore.funcPassTypesFull"); let f = new sc.PassTypesFullContext(); - f.params.mapID = wasmlib.OBJ_ID_PARAMS; - f.state.mapID = wasmlib.OBJ_ID_STATE; ctx.require(f.params.address().exists(), "missing mandatory address"); ctx.require(f.params.agentID().exists(), "missing mandatory agentID"); ctx.require(f.params.chainID().exists(), "missing mandatory chainID"); @@ -134,21 +124,19 @@ function funcPassTypesFullThunk(ctx: wasmlib.ScFuncContext): void { function funcRunRecursionThunk(ctx: wasmlib.ScFuncContext): void { ctx.log("testcore.funcRunRecursion"); let f = new sc.RunRecursionContext(); - f.params.mapID = wasmlib.OBJ_ID_PARAMS; - f.results.mapID = wasmlib.OBJ_ID_RESULTS; - f.state.mapID = wasmlib.OBJ_ID_STATE; + const results = new wasmlib.ScDict([]); + f.results = new sc.MutableRunRecursionResults(results.asProxy()); ctx.require(f.params.intValue().exists(), "missing mandatory intValue"); sc.funcRunRecursion(ctx, f); + ctx.results(results); ctx.log("testcore.funcRunRecursion ok"); } function funcSendToAddressThunk(ctx: wasmlib.ScFuncContext): void { ctx.log("testcore.funcSendToAddress"); + let f = new sc.SendToAddressContext(); ctx.require(ctx.caller().equals(ctx.contractCreator()), "no permission"); - let f = new sc.SendToAddressContext(); - f.params.mapID = wasmlib.OBJ_ID_PARAMS; - f.state.mapID = wasmlib.OBJ_ID_STATE; ctx.require(f.params.address().exists(), "missing mandatory address"); sc.funcSendToAddress(ctx, f); ctx.log("testcore.funcSendToAddress ok"); @@ -157,8 +145,6 @@ function funcSendToAddressThunk(ctx: wasmlib.ScFuncContext): void { function funcSetIntThunk(ctx: wasmlib.ScFuncContext): void { ctx.log("testcore.funcSetInt"); let f = new sc.SetIntContext(); - f.params.mapID = wasmlib.OBJ_ID_PARAMS; - f.state.mapID = wasmlib.OBJ_ID_STATE; ctx.require(f.params.intValue().exists(), "missing mandatory intValue"); ctx.require(f.params.name().exists(), "missing mandatory name"); sc.funcSetInt(ctx, f); @@ -168,8 +154,6 @@ function funcSetIntThunk(ctx: wasmlib.ScFuncContext): void { function funcSpawnThunk(ctx: wasmlib.ScFuncContext): void { ctx.log("testcore.funcSpawn"); let f = new sc.SpawnContext(); - f.params.mapID = wasmlib.OBJ_ID_PARAMS; - f.state.mapID = wasmlib.OBJ_ID_STATE; ctx.require(f.params.progHash().exists(), "missing mandatory progHash"); sc.funcSpawn(ctx, f); ctx.log("testcore.funcSpawn ok"); @@ -178,7 +162,6 @@ function funcSpawnThunk(ctx: wasmlib.ScFuncContext): void { function funcTestBlockContext1Thunk(ctx: wasmlib.ScFuncContext): void { ctx.log("testcore.funcTestBlockContext1"); let f = new sc.TestBlockContext1Context(); - f.state.mapID = wasmlib.OBJ_ID_STATE; sc.funcTestBlockContext1(ctx, f); ctx.log("testcore.funcTestBlockContext1 ok"); } @@ -186,7 +169,6 @@ function funcTestBlockContext1Thunk(ctx: wasmlib.ScFuncContext): void { function funcTestBlockContext2Thunk(ctx: wasmlib.ScFuncContext): void { ctx.log("testcore.funcTestBlockContext2"); let f = new sc.TestBlockContext2Context(); - f.state.mapID = wasmlib.OBJ_ID_STATE; sc.funcTestBlockContext2(ctx, f); ctx.log("testcore.funcTestBlockContext2 ok"); } @@ -194,7 +176,6 @@ function funcTestBlockContext2Thunk(ctx: wasmlib.ScFuncContext): void { function funcTestCallPanicFullEPThunk(ctx: wasmlib.ScFuncContext): void { ctx.log("testcore.funcTestCallPanicFullEP"); let f = new sc.TestCallPanicFullEPContext(); - f.state.mapID = wasmlib.OBJ_ID_STATE; sc.funcTestCallPanicFullEP(ctx, f); ctx.log("testcore.funcTestCallPanicFullEP ok"); } @@ -202,7 +183,6 @@ function funcTestCallPanicFullEPThunk(ctx: wasmlib.ScFuncContext): void { function funcTestCallPanicViewEPFromFullThunk(ctx: wasmlib.ScFuncContext): void { ctx.log("testcore.funcTestCallPanicViewEPFromFull"); let f = new sc.TestCallPanicViewEPFromFullContext(); - f.state.mapID = wasmlib.OBJ_ID_STATE; sc.funcTestCallPanicViewEPFromFull(ctx, f); ctx.log("testcore.funcTestCallPanicViewEPFromFull ok"); } @@ -210,16 +190,16 @@ function funcTestCallPanicViewEPFromFullThunk(ctx: wasmlib.ScFuncContext): void function funcTestChainOwnerIDFullThunk(ctx: wasmlib.ScFuncContext): void { ctx.log("testcore.funcTestChainOwnerIDFull"); let f = new sc.TestChainOwnerIDFullContext(); - f.results.mapID = wasmlib.OBJ_ID_RESULTS; - f.state.mapID = wasmlib.OBJ_ID_STATE; + const results = new wasmlib.ScDict([]); + f.results = new sc.MutableTestChainOwnerIDFullResults(results.asProxy()); sc.funcTestChainOwnerIDFull(ctx, f); + ctx.results(results); ctx.log("testcore.funcTestChainOwnerIDFull ok"); } function funcTestEventLogDeployThunk(ctx: wasmlib.ScFuncContext): void { ctx.log("testcore.funcTestEventLogDeploy"); let f = new sc.TestEventLogDeployContext(); - f.state.mapID = wasmlib.OBJ_ID_STATE; sc.funcTestEventLogDeploy(ctx, f); ctx.log("testcore.funcTestEventLogDeploy ok"); } @@ -227,7 +207,6 @@ function funcTestEventLogDeployThunk(ctx: wasmlib.ScFuncContext): void { function funcTestEventLogEventDataThunk(ctx: wasmlib.ScFuncContext): void { ctx.log("testcore.funcTestEventLogEventData"); let f = new sc.TestEventLogEventDataContext(); - f.state.mapID = wasmlib.OBJ_ID_STATE; sc.funcTestEventLogEventData(ctx, f); ctx.log("testcore.funcTestEventLogEventData ok"); } @@ -235,8 +214,6 @@ function funcTestEventLogEventDataThunk(ctx: wasmlib.ScFuncContext): void { function funcTestEventLogGenericDataThunk(ctx: wasmlib.ScFuncContext): void { ctx.log("testcore.funcTestEventLogGenericData"); let f = new sc.TestEventLogGenericDataContext(); - f.params.mapID = wasmlib.OBJ_ID_PARAMS; - f.state.mapID = wasmlib.OBJ_ID_STATE; ctx.require(f.params.counter().exists(), "missing mandatory counter"); sc.funcTestEventLogGenericData(ctx, f); ctx.log("testcore.funcTestEventLogGenericData ok"); @@ -245,7 +222,6 @@ function funcTestEventLogGenericDataThunk(ctx: wasmlib.ScFuncContext): void { function funcTestPanicFullEPThunk(ctx: wasmlib.ScFuncContext): void { ctx.log("testcore.funcTestPanicFullEP"); let f = new sc.TestPanicFullEPContext(); - f.state.mapID = wasmlib.OBJ_ID_STATE; sc.funcTestPanicFullEP(ctx, f); ctx.log("testcore.funcTestPanicFullEP ok"); } @@ -253,8 +229,6 @@ function funcTestPanicFullEPThunk(ctx: wasmlib.ScFuncContext): void { function funcWithdrawToChainThunk(ctx: wasmlib.ScFuncContext): void { ctx.log("testcore.funcWithdrawToChain"); let f = new sc.WithdrawToChainContext(); - f.params.mapID = wasmlib.OBJ_ID_PARAMS; - f.state.mapID = wasmlib.OBJ_ID_STATE; ctx.require(f.params.chainID().exists(), "missing mandatory chainID"); sc.funcWithdrawToChain(ctx, f); ctx.log("testcore.funcWithdrawToChain ok"); @@ -263,8 +237,6 @@ function funcWithdrawToChainThunk(ctx: wasmlib.ScFuncContext): void { function viewCheckContextFromViewEPThunk(ctx: wasmlib.ScViewContext): void { ctx.log("testcore.viewCheckContextFromViewEP"); let f = new sc.CheckContextFromViewEPContext(); - f.params.mapID = wasmlib.OBJ_ID_PARAMS; - f.state.mapID = wasmlib.OBJ_ID_STATE; ctx.require(f.params.agentID().exists(), "missing mandatory agentID"); ctx.require(f.params.chainID().exists(), "missing mandatory chainID"); ctx.require(f.params.chainOwnerID().exists(), "missing mandatory chainOwnerID"); @@ -276,49 +248,49 @@ function viewCheckContextFromViewEPThunk(ctx: wasmlib.ScViewContext): void { function viewFibonacciThunk(ctx: wasmlib.ScViewContext): void { ctx.log("testcore.viewFibonacci"); let f = new sc.FibonacciContext(); - f.params.mapID = wasmlib.OBJ_ID_PARAMS; - f.results.mapID = wasmlib.OBJ_ID_RESULTS; - f.state.mapID = wasmlib.OBJ_ID_STATE; + const results = new wasmlib.ScDict([]); + f.results = new sc.MutableFibonacciResults(results.asProxy()); ctx.require(f.params.intValue().exists(), "missing mandatory intValue"); sc.viewFibonacci(ctx, f); + ctx.results(results); ctx.log("testcore.viewFibonacci ok"); } function viewGetCounterThunk(ctx: wasmlib.ScViewContext): void { ctx.log("testcore.viewGetCounter"); let f = new sc.GetCounterContext(); - f.results.mapID = wasmlib.OBJ_ID_RESULTS; - f.state.mapID = wasmlib.OBJ_ID_STATE; + const results = new wasmlib.ScDict([]); + f.results = new sc.MutableGetCounterResults(results.asProxy()); sc.viewGetCounter(ctx, f); + ctx.results(results); ctx.log("testcore.viewGetCounter ok"); } function viewGetIntThunk(ctx: wasmlib.ScViewContext): void { ctx.log("testcore.viewGetInt"); let f = new sc.GetIntContext(); - f.params.mapID = wasmlib.OBJ_ID_PARAMS; - f.results.mapID = wasmlib.OBJ_ID_RESULTS; - f.state.mapID = wasmlib.OBJ_ID_STATE; + const results = new wasmlib.ScDict([]); + f.results = new sc.MutableGetIntResults(results.asProxy()); ctx.require(f.params.name().exists(), "missing mandatory name"); sc.viewGetInt(ctx, f); + ctx.results(results); ctx.log("testcore.viewGetInt ok"); } function viewGetStringValueThunk(ctx: wasmlib.ScViewContext): void { ctx.log("testcore.viewGetStringValue"); let f = new sc.GetStringValueContext(); - f.params.mapID = wasmlib.OBJ_ID_PARAMS; - f.results.mapID = wasmlib.OBJ_ID_RESULTS; - f.state.mapID = wasmlib.OBJ_ID_STATE; + const results = new wasmlib.ScDict([]); + f.results = new sc.MutableGetStringValueResults(results.asProxy()); ctx.require(f.params.varName().exists(), "missing mandatory varName"); sc.viewGetStringValue(ctx, f); + ctx.results(results); ctx.log("testcore.viewGetStringValue ok"); } function viewJustViewThunk(ctx: wasmlib.ScViewContext): void { ctx.log("testcore.viewJustView"); let f = new sc.JustViewContext(); - f.state.mapID = wasmlib.OBJ_ID_STATE; sc.viewJustView(ctx, f); ctx.log("testcore.viewJustView ok"); } @@ -326,8 +298,6 @@ function viewJustViewThunk(ctx: wasmlib.ScViewContext): void { function viewPassTypesViewThunk(ctx: wasmlib.ScViewContext): void { ctx.log("testcore.viewPassTypesView"); let f = new sc.PassTypesViewContext(); - f.params.mapID = wasmlib.OBJ_ID_PARAMS; - f.state.mapID = wasmlib.OBJ_ID_STATE; ctx.require(f.params.address().exists(), "missing mandatory address"); ctx.require(f.params.agentID().exists(), "missing mandatory agentID"); ctx.require(f.params.chainID().exists(), "missing mandatory chainID"); @@ -346,7 +316,6 @@ function viewPassTypesViewThunk(ctx: wasmlib.ScViewContext): void { function viewTestCallPanicViewEPFromViewThunk(ctx: wasmlib.ScViewContext): void { ctx.log("testcore.viewTestCallPanicViewEPFromView"); let f = new sc.TestCallPanicViewEPFromViewContext(); - f.state.mapID = wasmlib.OBJ_ID_STATE; sc.viewTestCallPanicViewEPFromView(ctx, f); ctx.log("testcore.viewTestCallPanicViewEPFromView ok"); } @@ -354,16 +323,16 @@ function viewTestCallPanicViewEPFromViewThunk(ctx: wasmlib.ScViewContext): void function viewTestChainOwnerIDViewThunk(ctx: wasmlib.ScViewContext): void { ctx.log("testcore.viewTestChainOwnerIDView"); let f = new sc.TestChainOwnerIDViewContext(); - f.results.mapID = wasmlib.OBJ_ID_RESULTS; - f.state.mapID = wasmlib.OBJ_ID_STATE; + const results = new wasmlib.ScDict([]); + f.results = new sc.MutableTestChainOwnerIDViewResults(results.asProxy()); sc.viewTestChainOwnerIDView(ctx, f); + ctx.results(results); ctx.log("testcore.viewTestChainOwnerIDView ok"); } function viewTestPanicViewEPThunk(ctx: wasmlib.ScViewContext): void { ctx.log("testcore.viewTestPanicViewEP"); let f = new sc.TestPanicViewEPContext(); - f.state.mapID = wasmlib.OBJ_ID_STATE; sc.viewTestPanicViewEP(ctx, f); ctx.log("testcore.viewTestPanicViewEP ok"); } @@ -371,8 +340,9 @@ function viewTestPanicViewEPThunk(ctx: wasmlib.ScViewContext): void { function viewTestSandboxCallThunk(ctx: wasmlib.ScViewContext): void { ctx.log("testcore.viewTestSandboxCall"); let f = new sc.TestSandboxCallContext(); - f.results.mapID = wasmlib.OBJ_ID_RESULTS; - f.state.mapID = wasmlib.OBJ_ID_STATE; + const results = new wasmlib.ScDict([]); + f.results = new sc.MutableTestSandboxCallResults(results.asProxy()); sc.viewTestSandboxCall(ctx, f); + ctx.results(results); ctx.log("testcore.viewTestSandboxCall ok"); } diff --git a/contracts/wasm/testcore/ts/testcore/params.ts b/contracts/wasm/testcore/ts/testcore/params.ts index 6736de4bd6..721ffa2bb8 100644 --- a/contracts/wasm/testcore/ts/testcore/params.ts +++ b/contracts/wasm/testcore/ts/testcore/params.ts @@ -6,424 +6,425 @@ // Change the json schema instead import * as wasmlib from "wasmlib"; +import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; -export class ImmutableCallOnChainParams extends wasmlib.ScMapID { - hnameContract(): wasmlib.ScImmutableHname { - return new wasmlib.ScImmutableHname(this.mapID, wasmlib.Key32.fromString(sc.ParamHnameContract)); +export class ImmutableCallOnChainParams extends wasmtypes.ScProxy { + hnameContract(): wasmtypes.ScImmutableHname { + return new wasmtypes.ScImmutableHname(this.proxy.root(sc.ParamHnameContract)); } - hnameEP(): wasmlib.ScImmutableHname { - return new wasmlib.ScImmutableHname(this.mapID, wasmlib.Key32.fromString(sc.ParamHnameEP)); + hnameEP(): wasmtypes.ScImmutableHname { + return new wasmtypes.ScImmutableHname(this.proxy.root(sc.ParamHnameEP)); } - intValue(): wasmlib.ScImmutableInt64 { - return new wasmlib.ScImmutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ParamIntValue)); + intValue(): wasmtypes.ScImmutableInt64 { + return new wasmtypes.ScImmutableInt64(this.proxy.root(sc.ParamIntValue)); } } -export class MutableCallOnChainParams extends wasmlib.ScMapID { - hnameContract(): wasmlib.ScMutableHname { - return new wasmlib.ScMutableHname(this.mapID, wasmlib.Key32.fromString(sc.ParamHnameContract)); +export class MutableCallOnChainParams extends wasmtypes.ScProxy { + hnameContract(): wasmtypes.ScMutableHname { + return new wasmtypes.ScMutableHname(this.proxy.root(sc.ParamHnameContract)); } - hnameEP(): wasmlib.ScMutableHname { - return new wasmlib.ScMutableHname(this.mapID, wasmlib.Key32.fromString(sc.ParamHnameEP)); + hnameEP(): wasmtypes.ScMutableHname { + return new wasmtypes.ScMutableHname(this.proxy.root(sc.ParamHnameEP)); } - intValue(): wasmlib.ScMutableInt64 { - return new wasmlib.ScMutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ParamIntValue)); + intValue(): wasmtypes.ScMutableInt64 { + return new wasmtypes.ScMutableInt64(this.proxy.root(sc.ParamIntValue)); } } -export class ImmutableCheckContextFromFullEPParams extends wasmlib.ScMapID { - agentID(): wasmlib.ScImmutableAgentID { - return new wasmlib.ScImmutableAgentID(this.mapID, wasmlib.Key32.fromString(sc.ParamAgentID)); +export class ImmutableCheckContextFromFullEPParams extends wasmtypes.ScProxy { + agentID(): wasmtypes.ScImmutableAgentID { + return new wasmtypes.ScImmutableAgentID(this.proxy.root(sc.ParamAgentID)); } - caller(): wasmlib.ScImmutableAgentID { - return new wasmlib.ScImmutableAgentID(this.mapID, wasmlib.Key32.fromString(sc.ParamCaller)); + caller(): wasmtypes.ScImmutableAgentID { + return new wasmtypes.ScImmutableAgentID(this.proxy.root(sc.ParamCaller)); } - chainID(): wasmlib.ScImmutableChainID { - return new wasmlib.ScImmutableChainID(this.mapID, wasmlib.Key32.fromString(sc.ParamChainID)); + chainID(): wasmtypes.ScImmutableChainID { + return new wasmtypes.ScImmutableChainID(this.proxy.root(sc.ParamChainID)); } - chainOwnerID(): wasmlib.ScImmutableAgentID { - return new wasmlib.ScImmutableAgentID(this.mapID, wasmlib.Key32.fromString(sc.ParamChainOwnerID)); + chainOwnerID(): wasmtypes.ScImmutableAgentID { + return new wasmtypes.ScImmutableAgentID(this.proxy.root(sc.ParamChainOwnerID)); } - contractCreator(): wasmlib.ScImmutableAgentID { - return new wasmlib.ScImmutableAgentID(this.mapID, wasmlib.Key32.fromString(sc.ParamContractCreator)); + contractCreator(): wasmtypes.ScImmutableAgentID { + return new wasmtypes.ScImmutableAgentID(this.proxy.root(sc.ParamContractCreator)); } } -export class MutableCheckContextFromFullEPParams extends wasmlib.ScMapID { - agentID(): wasmlib.ScMutableAgentID { - return new wasmlib.ScMutableAgentID(this.mapID, wasmlib.Key32.fromString(sc.ParamAgentID)); +export class MutableCheckContextFromFullEPParams extends wasmtypes.ScProxy { + agentID(): wasmtypes.ScMutableAgentID { + return new wasmtypes.ScMutableAgentID(this.proxy.root(sc.ParamAgentID)); } - caller(): wasmlib.ScMutableAgentID { - return new wasmlib.ScMutableAgentID(this.mapID, wasmlib.Key32.fromString(sc.ParamCaller)); + caller(): wasmtypes.ScMutableAgentID { + return new wasmtypes.ScMutableAgentID(this.proxy.root(sc.ParamCaller)); } - chainID(): wasmlib.ScMutableChainID { - return new wasmlib.ScMutableChainID(this.mapID, wasmlib.Key32.fromString(sc.ParamChainID)); + chainID(): wasmtypes.ScMutableChainID { + return new wasmtypes.ScMutableChainID(this.proxy.root(sc.ParamChainID)); } - chainOwnerID(): wasmlib.ScMutableAgentID { - return new wasmlib.ScMutableAgentID(this.mapID, wasmlib.Key32.fromString(sc.ParamChainOwnerID)); + chainOwnerID(): wasmtypes.ScMutableAgentID { + return new wasmtypes.ScMutableAgentID(this.proxy.root(sc.ParamChainOwnerID)); } - contractCreator(): wasmlib.ScMutableAgentID { - return new wasmlib.ScMutableAgentID(this.mapID, wasmlib.Key32.fromString(sc.ParamContractCreator)); + contractCreator(): wasmtypes.ScMutableAgentID { + return new wasmtypes.ScMutableAgentID(this.proxy.root(sc.ParamContractCreator)); } } -export class ImmutableInitParams extends wasmlib.ScMapID { - fail(): wasmlib.ScImmutableInt64 { - return new wasmlib.ScImmutableInt64(this.mapID, sc.idxMap[sc.IdxParamFail]); +export class ImmutableInitParams extends wasmtypes.ScProxy { + fail(): wasmtypes.ScImmutableInt64 { + return new wasmtypes.ScImmutableInt64(this.proxy.root(sc.ParamFail)); } } -export class MutableInitParams extends wasmlib.ScMapID { - fail(): wasmlib.ScMutableInt64 { - return new wasmlib.ScMutableInt64(this.mapID, sc.idxMap[sc.IdxParamFail]); +export class MutableInitParams extends wasmtypes.ScProxy { + fail(): wasmtypes.ScMutableInt64 { + return new wasmtypes.ScMutableInt64(this.proxy.root(sc.ParamFail)); } } -export class ImmutablePassTypesFullParams extends wasmlib.ScMapID { - address(): wasmlib.ScImmutableAddress { - return new wasmlib.ScImmutableAddress(this.mapID, wasmlib.Key32.fromString(sc.ParamAddress)); +export class ImmutablePassTypesFullParams extends wasmtypes.ScProxy { + address(): wasmtypes.ScImmutableAddress { + return new wasmtypes.ScImmutableAddress(this.proxy.root(sc.ParamAddress)); } - agentID(): wasmlib.ScImmutableAgentID { - return new wasmlib.ScImmutableAgentID(this.mapID, wasmlib.Key32.fromString(sc.ParamAgentID)); + agentID(): wasmtypes.ScImmutableAgentID { + return new wasmtypes.ScImmutableAgentID(this.proxy.root(sc.ParamAgentID)); } - chainID(): wasmlib.ScImmutableChainID { - return new wasmlib.ScImmutableChainID(this.mapID, wasmlib.Key32.fromString(sc.ParamChainID)); + chainID(): wasmtypes.ScImmutableChainID { + return new wasmtypes.ScImmutableChainID(this.proxy.root(sc.ParamChainID)); } - contractID(): wasmlib.ScImmutableAgentID { - return new wasmlib.ScImmutableAgentID(this.mapID, wasmlib.Key32.fromString(sc.ParamContractID)); + contractID(): wasmtypes.ScImmutableAgentID { + return new wasmtypes.ScImmutableAgentID(this.proxy.root(sc.ParamContractID)); } - hash(): wasmlib.ScImmutableHash { - return new wasmlib.ScImmutableHash(this.mapID, wasmlib.Key32.fromString(sc.ParamHash)); + hash(): wasmtypes.ScImmutableHash { + return new wasmtypes.ScImmutableHash(this.proxy.root(sc.ParamHash)); } - hname(): wasmlib.ScImmutableHname { - return new wasmlib.ScImmutableHname(this.mapID, wasmlib.Key32.fromString(sc.ParamHname)); + hname(): wasmtypes.ScImmutableHname { + return new wasmtypes.ScImmutableHname(this.proxy.root(sc.ParamHname)); } - hnameZero(): wasmlib.ScImmutableHname { - return new wasmlib.ScImmutableHname(this.mapID, wasmlib.Key32.fromString(sc.ParamHnameZero)); + hnameZero(): wasmtypes.ScImmutableHname { + return new wasmtypes.ScImmutableHname(this.proxy.root(sc.ParamHnameZero)); } - int64(): wasmlib.ScImmutableInt64 { - return new wasmlib.ScImmutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ParamInt64)); + int64(): wasmtypes.ScImmutableInt64 { + return new wasmtypes.ScImmutableInt64(this.proxy.root(sc.ParamInt64)); } - int64Zero(): wasmlib.ScImmutableInt64 { - return new wasmlib.ScImmutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ParamInt64Zero)); + int64Zero(): wasmtypes.ScImmutableInt64 { + return new wasmtypes.ScImmutableInt64(this.proxy.root(sc.ParamInt64Zero)); } - string(): wasmlib.ScImmutableString { - return new wasmlib.ScImmutableString(this.mapID, wasmlib.Key32.fromString(sc.ParamString)); + string(): wasmtypes.ScImmutableString { + return new wasmtypes.ScImmutableString(this.proxy.root(sc.ParamString)); } - stringZero(): wasmlib.ScImmutableString { - return new wasmlib.ScImmutableString(this.mapID, wasmlib.Key32.fromString(sc.ParamStringZero)); + stringZero(): wasmtypes.ScImmutableString { + return new wasmtypes.ScImmutableString(this.proxy.root(sc.ParamStringZero)); } } -export class MutablePassTypesFullParams extends wasmlib.ScMapID { - address(): wasmlib.ScMutableAddress { - return new wasmlib.ScMutableAddress(this.mapID, wasmlib.Key32.fromString(sc.ParamAddress)); +export class MutablePassTypesFullParams extends wasmtypes.ScProxy { + address(): wasmtypes.ScMutableAddress { + return new wasmtypes.ScMutableAddress(this.proxy.root(sc.ParamAddress)); } - agentID(): wasmlib.ScMutableAgentID { - return new wasmlib.ScMutableAgentID(this.mapID, wasmlib.Key32.fromString(sc.ParamAgentID)); + agentID(): wasmtypes.ScMutableAgentID { + return new wasmtypes.ScMutableAgentID(this.proxy.root(sc.ParamAgentID)); } - chainID(): wasmlib.ScMutableChainID { - return new wasmlib.ScMutableChainID(this.mapID, wasmlib.Key32.fromString(sc.ParamChainID)); + chainID(): wasmtypes.ScMutableChainID { + return new wasmtypes.ScMutableChainID(this.proxy.root(sc.ParamChainID)); } - contractID(): wasmlib.ScMutableAgentID { - return new wasmlib.ScMutableAgentID(this.mapID, wasmlib.Key32.fromString(sc.ParamContractID)); + contractID(): wasmtypes.ScMutableAgentID { + return new wasmtypes.ScMutableAgentID(this.proxy.root(sc.ParamContractID)); } - hash(): wasmlib.ScMutableHash { - return new wasmlib.ScMutableHash(this.mapID, wasmlib.Key32.fromString(sc.ParamHash)); + hash(): wasmtypes.ScMutableHash { + return new wasmtypes.ScMutableHash(this.proxy.root(sc.ParamHash)); } - hname(): wasmlib.ScMutableHname { - return new wasmlib.ScMutableHname(this.mapID, wasmlib.Key32.fromString(sc.ParamHname)); + hname(): wasmtypes.ScMutableHname { + return new wasmtypes.ScMutableHname(this.proxy.root(sc.ParamHname)); } - hnameZero(): wasmlib.ScMutableHname { - return new wasmlib.ScMutableHname(this.mapID, wasmlib.Key32.fromString(sc.ParamHnameZero)); + hnameZero(): wasmtypes.ScMutableHname { + return new wasmtypes.ScMutableHname(this.proxy.root(sc.ParamHnameZero)); } - int64(): wasmlib.ScMutableInt64 { - return new wasmlib.ScMutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ParamInt64)); + int64(): wasmtypes.ScMutableInt64 { + return new wasmtypes.ScMutableInt64(this.proxy.root(sc.ParamInt64)); } - int64Zero(): wasmlib.ScMutableInt64 { - return new wasmlib.ScMutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ParamInt64Zero)); + int64Zero(): wasmtypes.ScMutableInt64 { + return new wasmtypes.ScMutableInt64(this.proxy.root(sc.ParamInt64Zero)); } - string(): wasmlib.ScMutableString { - return new wasmlib.ScMutableString(this.mapID, wasmlib.Key32.fromString(sc.ParamString)); + string(): wasmtypes.ScMutableString { + return new wasmtypes.ScMutableString(this.proxy.root(sc.ParamString)); } - stringZero(): wasmlib.ScMutableString { - return new wasmlib.ScMutableString(this.mapID, wasmlib.Key32.fromString(sc.ParamStringZero)); + stringZero(): wasmtypes.ScMutableString { + return new wasmtypes.ScMutableString(this.proxy.root(sc.ParamStringZero)); } } -export class ImmutableRunRecursionParams extends wasmlib.ScMapID { - intValue(): wasmlib.ScImmutableInt64 { - return new wasmlib.ScImmutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ParamIntValue)); +export class ImmutableRunRecursionParams extends wasmtypes.ScProxy { + intValue(): wasmtypes.ScImmutableInt64 { + return new wasmtypes.ScImmutableInt64(this.proxy.root(sc.ParamIntValue)); } } -export class MutableRunRecursionParams extends wasmlib.ScMapID { - intValue(): wasmlib.ScMutableInt64 { - return new wasmlib.ScMutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ParamIntValue)); +export class MutableRunRecursionParams extends wasmtypes.ScProxy { + intValue(): wasmtypes.ScMutableInt64 { + return new wasmtypes.ScMutableInt64(this.proxy.root(sc.ParamIntValue)); } } -export class ImmutableSendToAddressParams extends wasmlib.ScMapID { - address(): wasmlib.ScImmutableAddress { - return new wasmlib.ScImmutableAddress(this.mapID, wasmlib.Key32.fromString(sc.ParamAddress)); +export class ImmutableSendToAddressParams extends wasmtypes.ScProxy { + address(): wasmtypes.ScImmutableAddress { + return new wasmtypes.ScImmutableAddress(this.proxy.root(sc.ParamAddress)); } } -export class MutableSendToAddressParams extends wasmlib.ScMapID { - address(): wasmlib.ScMutableAddress { - return new wasmlib.ScMutableAddress(this.mapID, wasmlib.Key32.fromString(sc.ParamAddress)); +export class MutableSendToAddressParams extends wasmtypes.ScProxy { + address(): wasmtypes.ScMutableAddress { + return new wasmtypes.ScMutableAddress(this.proxy.root(sc.ParamAddress)); } } -export class ImmutableSetIntParams extends wasmlib.ScMapID { - intValue(): wasmlib.ScImmutableInt64 { - return new wasmlib.ScImmutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ParamIntValue)); +export class ImmutableSetIntParams extends wasmtypes.ScProxy { + intValue(): wasmtypes.ScImmutableInt64 { + return new wasmtypes.ScImmutableInt64(this.proxy.root(sc.ParamIntValue)); } - name(): wasmlib.ScImmutableString { - return new wasmlib.ScImmutableString(this.mapID, wasmlib.Key32.fromString(sc.ParamName)); + name(): wasmtypes.ScImmutableString { + return new wasmtypes.ScImmutableString(this.proxy.root(sc.ParamName)); } } -export class MutableSetIntParams extends wasmlib.ScMapID { - intValue(): wasmlib.ScMutableInt64 { - return new wasmlib.ScMutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ParamIntValue)); +export class MutableSetIntParams extends wasmtypes.ScProxy { + intValue(): wasmtypes.ScMutableInt64 { + return new wasmtypes.ScMutableInt64(this.proxy.root(sc.ParamIntValue)); } - name(): wasmlib.ScMutableString { - return new wasmlib.ScMutableString(this.mapID, wasmlib.Key32.fromString(sc.ParamName)); + name(): wasmtypes.ScMutableString { + return new wasmtypes.ScMutableString(this.proxy.root(sc.ParamName)); } } -export class ImmutableSpawnParams extends wasmlib.ScMapID { - progHash(): wasmlib.ScImmutableHash { - return new wasmlib.ScImmutableHash(this.mapID, wasmlib.Key32.fromString(sc.ParamProgHash)); +export class ImmutableSpawnParams extends wasmtypes.ScProxy { + progHash(): wasmtypes.ScImmutableHash { + return new wasmtypes.ScImmutableHash(this.proxy.root(sc.ParamProgHash)); } } -export class MutableSpawnParams extends wasmlib.ScMapID { - progHash(): wasmlib.ScMutableHash { - return new wasmlib.ScMutableHash(this.mapID, wasmlib.Key32.fromString(sc.ParamProgHash)); +export class MutableSpawnParams extends wasmtypes.ScProxy { + progHash(): wasmtypes.ScMutableHash { + return new wasmtypes.ScMutableHash(this.proxy.root(sc.ParamProgHash)); } } -export class ImmutableTestEventLogGenericDataParams extends wasmlib.ScMapID { - counter(): wasmlib.ScImmutableInt64 { - return new wasmlib.ScImmutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ParamCounter)); +export class ImmutableTestEventLogGenericDataParams extends wasmtypes.ScProxy { + counter(): wasmtypes.ScImmutableInt64 { + return new wasmtypes.ScImmutableInt64(this.proxy.root(sc.ParamCounter)); } } -export class MutableTestEventLogGenericDataParams extends wasmlib.ScMapID { - counter(): wasmlib.ScMutableInt64 { - return new wasmlib.ScMutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ParamCounter)); +export class MutableTestEventLogGenericDataParams extends wasmtypes.ScProxy { + counter(): wasmtypes.ScMutableInt64 { + return new wasmtypes.ScMutableInt64(this.proxy.root(sc.ParamCounter)); } } -export class ImmutableWithdrawToChainParams extends wasmlib.ScMapID { - chainID(): wasmlib.ScImmutableChainID { - return new wasmlib.ScImmutableChainID(this.mapID, wasmlib.Key32.fromString(sc.ParamChainID)); +export class ImmutableWithdrawToChainParams extends wasmtypes.ScProxy { + chainID(): wasmtypes.ScImmutableChainID { + return new wasmtypes.ScImmutableChainID(this.proxy.root(sc.ParamChainID)); } } -export class MutableWithdrawToChainParams extends wasmlib.ScMapID { - chainID(): wasmlib.ScMutableChainID { - return new wasmlib.ScMutableChainID(this.mapID, wasmlib.Key32.fromString(sc.ParamChainID)); +export class MutableWithdrawToChainParams extends wasmtypes.ScProxy { + chainID(): wasmtypes.ScMutableChainID { + return new wasmtypes.ScMutableChainID(this.proxy.root(sc.ParamChainID)); } } -export class ImmutableCheckContextFromViewEPParams extends wasmlib.ScMapID { - agentID(): wasmlib.ScImmutableAgentID { - return new wasmlib.ScImmutableAgentID(this.mapID, wasmlib.Key32.fromString(sc.ParamAgentID)); +export class ImmutableCheckContextFromViewEPParams extends wasmtypes.ScProxy { + agentID(): wasmtypes.ScImmutableAgentID { + return new wasmtypes.ScImmutableAgentID(this.proxy.root(sc.ParamAgentID)); } - chainID(): wasmlib.ScImmutableChainID { - return new wasmlib.ScImmutableChainID(this.mapID, wasmlib.Key32.fromString(sc.ParamChainID)); + chainID(): wasmtypes.ScImmutableChainID { + return new wasmtypes.ScImmutableChainID(this.proxy.root(sc.ParamChainID)); } - chainOwnerID(): wasmlib.ScImmutableAgentID { - return new wasmlib.ScImmutableAgentID(this.mapID, wasmlib.Key32.fromString(sc.ParamChainOwnerID)); + chainOwnerID(): wasmtypes.ScImmutableAgentID { + return new wasmtypes.ScImmutableAgentID(this.proxy.root(sc.ParamChainOwnerID)); } - contractCreator(): wasmlib.ScImmutableAgentID { - return new wasmlib.ScImmutableAgentID(this.mapID, wasmlib.Key32.fromString(sc.ParamContractCreator)); + contractCreator(): wasmtypes.ScImmutableAgentID { + return new wasmtypes.ScImmutableAgentID(this.proxy.root(sc.ParamContractCreator)); } } -export class MutableCheckContextFromViewEPParams extends wasmlib.ScMapID { - agentID(): wasmlib.ScMutableAgentID { - return new wasmlib.ScMutableAgentID(this.mapID, wasmlib.Key32.fromString(sc.ParamAgentID)); +export class MutableCheckContextFromViewEPParams extends wasmtypes.ScProxy { + agentID(): wasmtypes.ScMutableAgentID { + return new wasmtypes.ScMutableAgentID(this.proxy.root(sc.ParamAgentID)); } - chainID(): wasmlib.ScMutableChainID { - return new wasmlib.ScMutableChainID(this.mapID, wasmlib.Key32.fromString(sc.ParamChainID)); + chainID(): wasmtypes.ScMutableChainID { + return new wasmtypes.ScMutableChainID(this.proxy.root(sc.ParamChainID)); } - chainOwnerID(): wasmlib.ScMutableAgentID { - return new wasmlib.ScMutableAgentID(this.mapID, wasmlib.Key32.fromString(sc.ParamChainOwnerID)); + chainOwnerID(): wasmtypes.ScMutableAgentID { + return new wasmtypes.ScMutableAgentID(this.proxy.root(sc.ParamChainOwnerID)); } - contractCreator(): wasmlib.ScMutableAgentID { - return new wasmlib.ScMutableAgentID(this.mapID, wasmlib.Key32.fromString(sc.ParamContractCreator)); + contractCreator(): wasmtypes.ScMutableAgentID { + return new wasmtypes.ScMutableAgentID(this.proxy.root(sc.ParamContractCreator)); } } -export class ImmutableFibonacciParams extends wasmlib.ScMapID { - intValue(): wasmlib.ScImmutableInt64 { - return new wasmlib.ScImmutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ParamIntValue)); +export class ImmutableFibonacciParams extends wasmtypes.ScProxy { + intValue(): wasmtypes.ScImmutableInt64 { + return new wasmtypes.ScImmutableInt64(this.proxy.root(sc.ParamIntValue)); } } -export class MutableFibonacciParams extends wasmlib.ScMapID { - intValue(): wasmlib.ScMutableInt64 { - return new wasmlib.ScMutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ParamIntValue)); +export class MutableFibonacciParams extends wasmtypes.ScProxy { + intValue(): wasmtypes.ScMutableInt64 { + return new wasmtypes.ScMutableInt64(this.proxy.root(sc.ParamIntValue)); } } -export class ImmutableGetIntParams extends wasmlib.ScMapID { - name(): wasmlib.ScImmutableString { - return new wasmlib.ScImmutableString(this.mapID, wasmlib.Key32.fromString(sc.ParamName)); +export class ImmutableGetIntParams extends wasmtypes.ScProxy { + name(): wasmtypes.ScImmutableString { + return new wasmtypes.ScImmutableString(this.proxy.root(sc.ParamName)); } } -export class MutableGetIntParams extends wasmlib.ScMapID { - name(): wasmlib.ScMutableString { - return new wasmlib.ScMutableString(this.mapID, wasmlib.Key32.fromString(sc.ParamName)); +export class MutableGetIntParams extends wasmtypes.ScProxy { + name(): wasmtypes.ScMutableString { + return new wasmtypes.ScMutableString(this.proxy.root(sc.ParamName)); } } -export class ImmutableGetStringValueParams extends wasmlib.ScMapID { - varName(): wasmlib.ScImmutableString { - return new wasmlib.ScImmutableString(this.mapID, wasmlib.Key32.fromString(sc.ParamVarName)); +export class ImmutableGetStringValueParams extends wasmtypes.ScProxy { + varName(): wasmtypes.ScImmutableString { + return new wasmtypes.ScImmutableString(this.proxy.root(sc.ParamVarName)); } } -export class MutableGetStringValueParams extends wasmlib.ScMapID { - varName(): wasmlib.ScMutableString { - return new wasmlib.ScMutableString(this.mapID, wasmlib.Key32.fromString(sc.ParamVarName)); +export class MutableGetStringValueParams extends wasmtypes.ScProxy { + varName(): wasmtypes.ScMutableString { + return new wasmtypes.ScMutableString(this.proxy.root(sc.ParamVarName)); } } -export class ImmutablePassTypesViewParams extends wasmlib.ScMapID { - address(): wasmlib.ScImmutableAddress { - return new wasmlib.ScImmutableAddress(this.mapID, wasmlib.Key32.fromString(sc.ParamAddress)); +export class ImmutablePassTypesViewParams extends wasmtypes.ScProxy { + address(): wasmtypes.ScImmutableAddress { + return new wasmtypes.ScImmutableAddress(this.proxy.root(sc.ParamAddress)); } - agentID(): wasmlib.ScImmutableAgentID { - return new wasmlib.ScImmutableAgentID(this.mapID, wasmlib.Key32.fromString(sc.ParamAgentID)); + agentID(): wasmtypes.ScImmutableAgentID { + return new wasmtypes.ScImmutableAgentID(this.proxy.root(sc.ParamAgentID)); } - chainID(): wasmlib.ScImmutableChainID { - return new wasmlib.ScImmutableChainID(this.mapID, wasmlib.Key32.fromString(sc.ParamChainID)); + chainID(): wasmtypes.ScImmutableChainID { + return new wasmtypes.ScImmutableChainID(this.proxy.root(sc.ParamChainID)); } - contractID(): wasmlib.ScImmutableAgentID { - return new wasmlib.ScImmutableAgentID(this.mapID, wasmlib.Key32.fromString(sc.ParamContractID)); + contractID(): wasmtypes.ScImmutableAgentID { + return new wasmtypes.ScImmutableAgentID(this.proxy.root(sc.ParamContractID)); } - hash(): wasmlib.ScImmutableHash { - return new wasmlib.ScImmutableHash(this.mapID, wasmlib.Key32.fromString(sc.ParamHash)); + hash(): wasmtypes.ScImmutableHash { + return new wasmtypes.ScImmutableHash(this.proxy.root(sc.ParamHash)); } - hname(): wasmlib.ScImmutableHname { - return new wasmlib.ScImmutableHname(this.mapID, wasmlib.Key32.fromString(sc.ParamHname)); + hname(): wasmtypes.ScImmutableHname { + return new wasmtypes.ScImmutableHname(this.proxy.root(sc.ParamHname)); } - hnameZero(): wasmlib.ScImmutableHname { - return new wasmlib.ScImmutableHname(this.mapID, wasmlib.Key32.fromString(sc.ParamHnameZero)); + hnameZero(): wasmtypes.ScImmutableHname { + return new wasmtypes.ScImmutableHname(this.proxy.root(sc.ParamHnameZero)); } - int64(): wasmlib.ScImmutableInt64 { - return new wasmlib.ScImmutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ParamInt64)); + int64(): wasmtypes.ScImmutableInt64 { + return new wasmtypes.ScImmutableInt64(this.proxy.root(sc.ParamInt64)); } - int64Zero(): wasmlib.ScImmutableInt64 { - return new wasmlib.ScImmutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ParamInt64Zero)); + int64Zero(): wasmtypes.ScImmutableInt64 { + return new wasmtypes.ScImmutableInt64(this.proxy.root(sc.ParamInt64Zero)); } - string(): wasmlib.ScImmutableString { - return new wasmlib.ScImmutableString(this.mapID, wasmlib.Key32.fromString(sc.ParamString)); + string(): wasmtypes.ScImmutableString { + return new wasmtypes.ScImmutableString(this.proxy.root(sc.ParamString)); } - stringZero(): wasmlib.ScImmutableString { - return new wasmlib.ScImmutableString(this.mapID, wasmlib.Key32.fromString(sc.ParamStringZero)); + stringZero(): wasmtypes.ScImmutableString { + return new wasmtypes.ScImmutableString(this.proxy.root(sc.ParamStringZero)); } } -export class MutablePassTypesViewParams extends wasmlib.ScMapID { - address(): wasmlib.ScMutableAddress { - return new wasmlib.ScMutableAddress(this.mapID, wasmlib.Key32.fromString(sc.ParamAddress)); +export class MutablePassTypesViewParams extends wasmtypes.ScProxy { + address(): wasmtypes.ScMutableAddress { + return new wasmtypes.ScMutableAddress(this.proxy.root(sc.ParamAddress)); } - agentID(): wasmlib.ScMutableAgentID { - return new wasmlib.ScMutableAgentID(this.mapID, wasmlib.Key32.fromString(sc.ParamAgentID)); + agentID(): wasmtypes.ScMutableAgentID { + return new wasmtypes.ScMutableAgentID(this.proxy.root(sc.ParamAgentID)); } - chainID(): wasmlib.ScMutableChainID { - return new wasmlib.ScMutableChainID(this.mapID, wasmlib.Key32.fromString(sc.ParamChainID)); + chainID(): wasmtypes.ScMutableChainID { + return new wasmtypes.ScMutableChainID(this.proxy.root(sc.ParamChainID)); } - contractID(): wasmlib.ScMutableAgentID { - return new wasmlib.ScMutableAgentID(this.mapID, wasmlib.Key32.fromString(sc.ParamContractID)); + contractID(): wasmtypes.ScMutableAgentID { + return new wasmtypes.ScMutableAgentID(this.proxy.root(sc.ParamContractID)); } - hash(): wasmlib.ScMutableHash { - return new wasmlib.ScMutableHash(this.mapID, wasmlib.Key32.fromString(sc.ParamHash)); + hash(): wasmtypes.ScMutableHash { + return new wasmtypes.ScMutableHash(this.proxy.root(sc.ParamHash)); } - hname(): wasmlib.ScMutableHname { - return new wasmlib.ScMutableHname(this.mapID, wasmlib.Key32.fromString(sc.ParamHname)); + hname(): wasmtypes.ScMutableHname { + return new wasmtypes.ScMutableHname(this.proxy.root(sc.ParamHname)); } - hnameZero(): wasmlib.ScMutableHname { - return new wasmlib.ScMutableHname(this.mapID, wasmlib.Key32.fromString(sc.ParamHnameZero)); + hnameZero(): wasmtypes.ScMutableHname { + return new wasmtypes.ScMutableHname(this.proxy.root(sc.ParamHnameZero)); } - int64(): wasmlib.ScMutableInt64 { - return new wasmlib.ScMutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ParamInt64)); + int64(): wasmtypes.ScMutableInt64 { + return new wasmtypes.ScMutableInt64(this.proxy.root(sc.ParamInt64)); } - int64Zero(): wasmlib.ScMutableInt64 { - return new wasmlib.ScMutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ParamInt64Zero)); + int64Zero(): wasmtypes.ScMutableInt64 { + return new wasmtypes.ScMutableInt64(this.proxy.root(sc.ParamInt64Zero)); } - string(): wasmlib.ScMutableString { - return new wasmlib.ScMutableString(this.mapID, wasmlib.Key32.fromString(sc.ParamString)); + string(): wasmtypes.ScMutableString { + return new wasmtypes.ScMutableString(this.proxy.root(sc.ParamString)); } - stringZero(): wasmlib.ScMutableString { - return new wasmlib.ScMutableString(this.mapID, wasmlib.Key32.fromString(sc.ParamStringZero)); + stringZero(): wasmtypes.ScMutableString { + return new wasmtypes.ScMutableString(this.proxy.root(sc.ParamStringZero)); } } diff --git a/contracts/wasm/testcore/ts/testcore/results.ts b/contracts/wasm/testcore/ts/testcore/results.ts index 15d59ab40c..c4ca687a3b 100644 --- a/contracts/wasm/testcore/ts/testcore/results.ts +++ b/contracts/wasm/testcore/ts/testcore/results.ts @@ -6,188 +6,169 @@ // Change the json schema instead import * as wasmlib from "wasmlib"; +import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; -export class ImmutableCallOnChainResults extends wasmlib.ScMapID { - intValue(): wasmlib.ScImmutableInt64 { - return new wasmlib.ScImmutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ResultIntValue)); +export class ImmutableCallOnChainResults extends wasmtypes.ScProxy { + intValue(): wasmtypes.ScImmutableInt64 { + return new wasmtypes.ScImmutableInt64(this.proxy.root(sc.ResultIntValue)); } } -export class MutableCallOnChainResults extends wasmlib.ScMapID { - intValue(): wasmlib.ScMutableInt64 { - return new wasmlib.ScMutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ResultIntValue)); +export class MutableCallOnChainResults extends wasmtypes.ScProxy { + intValue(): wasmtypes.ScMutableInt64 { + return new wasmtypes.ScMutableInt64(this.proxy.root(sc.ResultIntValue)); } } -export class ImmutableGetMintedSupplyResults extends wasmlib.ScMapID { - mintedColor(): wasmlib.ScImmutableColor { - return new wasmlib.ScImmutableColor(this.mapID, wasmlib.Key32.fromString(sc.ResultMintedColor)); +export class ImmutableGetMintedSupplyResults extends wasmtypes.ScProxy { + mintedColor(): wasmtypes.ScImmutableColor { + return new wasmtypes.ScImmutableColor(this.proxy.root(sc.ResultMintedColor)); } - mintedSupply(): wasmlib.ScImmutableUint64 { - return new wasmlib.ScImmutableUint64(this.mapID, wasmlib.Key32.fromString(sc.ResultMintedSupply)); + mintedSupply(): wasmtypes.ScImmutableUint64 { + return new wasmtypes.ScImmutableUint64(this.proxy.root(sc.ResultMintedSupply)); } } -export class MutableGetMintedSupplyResults extends wasmlib.ScMapID { - mintedColor(): wasmlib.ScMutableColor { - return new wasmlib.ScMutableColor(this.mapID, wasmlib.Key32.fromString(sc.ResultMintedColor)); +export class MutableGetMintedSupplyResults extends wasmtypes.ScProxy { + mintedColor(): wasmtypes.ScMutableColor { + return new wasmtypes.ScMutableColor(this.proxy.root(sc.ResultMintedColor)); } - mintedSupply(): wasmlib.ScMutableUint64 { - return new wasmlib.ScMutableUint64(this.mapID, wasmlib.Key32.fromString(sc.ResultMintedSupply)); + mintedSupply(): wasmtypes.ScMutableUint64 { + return new wasmtypes.ScMutableUint64(this.proxy.root(sc.ResultMintedSupply)); } } -export class ImmutableRunRecursionResults extends wasmlib.ScMapID { - intValue(): wasmlib.ScImmutableInt64 { - return new wasmlib.ScImmutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ResultIntValue)); +export class ImmutableRunRecursionResults extends wasmtypes.ScProxy { + intValue(): wasmtypes.ScImmutableInt64 { + return new wasmtypes.ScImmutableInt64(this.proxy.root(sc.ResultIntValue)); } } -export class MutableRunRecursionResults extends wasmlib.ScMapID { - intValue(): wasmlib.ScMutableInt64 { - return new wasmlib.ScMutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ResultIntValue)); +export class MutableRunRecursionResults extends wasmtypes.ScProxy { + intValue(): wasmtypes.ScMutableInt64 { + return new wasmtypes.ScMutableInt64(this.proxy.root(sc.ResultIntValue)); } } -export class ImmutableTestChainOwnerIDFullResults extends wasmlib.ScMapID { - chainOwnerID(): wasmlib.ScImmutableAgentID { - return new wasmlib.ScImmutableAgentID(this.mapID, wasmlib.Key32.fromString(sc.ResultChainOwnerID)); +export class ImmutableTestChainOwnerIDFullResults extends wasmtypes.ScProxy { + chainOwnerID(): wasmtypes.ScImmutableAgentID { + return new wasmtypes.ScImmutableAgentID(this.proxy.root(sc.ResultChainOwnerID)); } } -export class MutableTestChainOwnerIDFullResults extends wasmlib.ScMapID { - chainOwnerID(): wasmlib.ScMutableAgentID { - return new wasmlib.ScMutableAgentID(this.mapID, wasmlib.Key32.fromString(sc.ResultChainOwnerID)); +export class MutableTestChainOwnerIDFullResults extends wasmtypes.ScProxy { + chainOwnerID(): wasmtypes.ScMutableAgentID { + return new wasmtypes.ScMutableAgentID(this.proxy.root(sc.ResultChainOwnerID)); } } -export class ImmutableFibonacciResults extends wasmlib.ScMapID { - intValue(): wasmlib.ScImmutableInt64 { - return new wasmlib.ScImmutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ResultIntValue)); +export class ImmutableFibonacciResults extends wasmtypes.ScProxy { + intValue(): wasmtypes.ScImmutableInt64 { + return new wasmtypes.ScImmutableInt64(this.proxy.root(sc.ResultIntValue)); } } -export class MutableFibonacciResults extends wasmlib.ScMapID { - intValue(): wasmlib.ScMutableInt64 { - return new wasmlib.ScMutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ResultIntValue)); +export class MutableFibonacciResults extends wasmtypes.ScProxy { + intValue(): wasmtypes.ScMutableInt64 { + return new wasmtypes.ScMutableInt64(this.proxy.root(sc.ResultIntValue)); } } -export class ImmutableGetCounterResults extends wasmlib.ScMapID { - counter(): wasmlib.ScImmutableInt64 { - return new wasmlib.ScImmutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ResultCounter)); +export class ImmutableGetCounterResults extends wasmtypes.ScProxy { + counter(): wasmtypes.ScImmutableInt64 { + return new wasmtypes.ScImmutableInt64(this.proxy.root(sc.ResultCounter)); } } -export class MutableGetCounterResults extends wasmlib.ScMapID { - counter(): wasmlib.ScMutableInt64 { - return new wasmlib.ScMutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ResultCounter)); +export class MutableGetCounterResults extends wasmtypes.ScProxy { + counter(): wasmtypes.ScMutableInt64 { + return new wasmtypes.ScMutableInt64(this.proxy.root(sc.ResultCounter)); } } -export class MapStringToImmutableInt64 { - objID: i32; +export class MapStringToImmutableInt64 extends wasmtypes.ScProxy { - constructor(objID: i32) { - this.objID = objID; - } - - getInt64(key: string): wasmlib.ScImmutableInt64 { - return new wasmlib.ScImmutableInt64(this.objID, wasmlib.Key32.fromString(key)); + getInt64(key: string): wasmtypes.ScImmutableInt64 { + return new wasmtypes.ScImmutableInt64(this.proxy.key(wasmtypes.stringToBytes(key))); } } -export class ImmutableGetIntResults extends wasmlib.ScMapID { +export class ImmutableGetIntResults extends wasmtypes.ScProxy { values(): sc.MapStringToImmutableInt64 { - return new sc.MapStringToImmutableInt64(this.mapID); + return new sc.MapStringToImmutableInt64(this.proxy); } } -export class MapStringToMutableInt64 { - objID: i32; - - constructor(objID: i32) { - this.objID = objID; - } +export class MapStringToMutableInt64 extends wasmtypes.ScProxy { clear(): void { - wasmlib.clear(this.objID); + this.proxy.clearMap(); } - getInt64(key: string): wasmlib.ScMutableInt64 { - return new wasmlib.ScMutableInt64(this.objID, wasmlib.Key32.fromString(key)); + getInt64(key: string): wasmtypes.ScMutableInt64 { + return new wasmtypes.ScMutableInt64(this.proxy.key(wasmtypes.stringToBytes(key))); } } -export class MutableGetIntResults extends wasmlib.ScMapID { +export class MutableGetIntResults extends wasmtypes.ScProxy { values(): sc.MapStringToMutableInt64 { - return new sc.MapStringToMutableInt64(this.mapID); + return new sc.MapStringToMutableInt64(this.proxy); } } -export class MapStringToImmutableString { - objID: i32; +export class MapStringToImmutableString extends wasmtypes.ScProxy { - constructor(objID: i32) { - this.objID = objID; - } - - getString(key: string): wasmlib.ScImmutableString { - return new wasmlib.ScImmutableString(this.objID, wasmlib.Key32.fromString(key)); + getString(key: string): wasmtypes.ScImmutableString { + return new wasmtypes.ScImmutableString(this.proxy.key(wasmtypes.stringToBytes(key))); } } -export class ImmutableGetStringValueResults extends wasmlib.ScMapID { +export class ImmutableGetStringValueResults extends wasmtypes.ScProxy { vars(): sc.MapStringToImmutableString { - return new sc.MapStringToImmutableString(this.mapID); + return new sc.MapStringToImmutableString(this.proxy); } } -export class MapStringToMutableString { - objID: i32; - - constructor(objID: i32) { - this.objID = objID; - } +export class MapStringToMutableString extends wasmtypes.ScProxy { clear(): void { - wasmlib.clear(this.objID); + this.proxy.clearMap(); } - getString(key: string): wasmlib.ScMutableString { - return new wasmlib.ScMutableString(this.objID, wasmlib.Key32.fromString(key)); + getString(key: string): wasmtypes.ScMutableString { + return new wasmtypes.ScMutableString(this.proxy.key(wasmtypes.stringToBytes(key))); } } -export class MutableGetStringValueResults extends wasmlib.ScMapID { +export class MutableGetStringValueResults extends wasmtypes.ScProxy { vars(): sc.MapStringToMutableString { - return new sc.MapStringToMutableString(this.mapID); + return new sc.MapStringToMutableString(this.proxy); } } -export class ImmutableTestChainOwnerIDViewResults extends wasmlib.ScMapID { - chainOwnerID(): wasmlib.ScImmutableAgentID { - return new wasmlib.ScImmutableAgentID(this.mapID, wasmlib.Key32.fromString(sc.ResultChainOwnerID)); +export class ImmutableTestChainOwnerIDViewResults extends wasmtypes.ScProxy { + chainOwnerID(): wasmtypes.ScImmutableAgentID { + return new wasmtypes.ScImmutableAgentID(this.proxy.root(sc.ResultChainOwnerID)); } } -export class MutableTestChainOwnerIDViewResults extends wasmlib.ScMapID { - chainOwnerID(): wasmlib.ScMutableAgentID { - return new wasmlib.ScMutableAgentID(this.mapID, wasmlib.Key32.fromString(sc.ResultChainOwnerID)); +export class MutableTestChainOwnerIDViewResults extends wasmtypes.ScProxy { + chainOwnerID(): wasmtypes.ScMutableAgentID { + return new wasmtypes.ScMutableAgentID(this.proxy.root(sc.ResultChainOwnerID)); } } -export class ImmutableTestSandboxCallResults extends wasmlib.ScMapID { - sandboxCall(): wasmlib.ScImmutableString { - return new wasmlib.ScImmutableString(this.mapID, wasmlib.Key32.fromString(sc.ResultSandboxCall)); +export class ImmutableTestSandboxCallResults extends wasmtypes.ScProxy { + sandboxCall(): wasmtypes.ScImmutableString { + return new wasmtypes.ScImmutableString(this.proxy.root(sc.ResultSandboxCall)); } } -export class MutableTestSandboxCallResults extends wasmlib.ScMapID { - sandboxCall(): wasmlib.ScMutableString { - return new wasmlib.ScMutableString(this.mapID, wasmlib.Key32.fromString(sc.ResultSandboxCall)); +export class MutableTestSandboxCallResults extends wasmtypes.ScProxy { + sandboxCall(): wasmtypes.ScMutableString { + return new wasmtypes.ScMutableString(this.proxy.root(sc.ResultSandboxCall)); } } diff --git a/contracts/wasm/testcore/ts/testcore/state.ts b/contracts/wasm/testcore/ts/testcore/state.ts index 2b27ba7e40..8e60c99562 100644 --- a/contracts/wasm/testcore/ts/testcore/state.ts +++ b/contracts/wasm/testcore/ts/testcore/state.ts @@ -6,56 +6,53 @@ // Change the json schema instead import * as wasmlib from "wasmlib"; +import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; -export class ImmutableTestCoreState extends wasmlib.ScMapID { - counter(): wasmlib.ScImmutableInt64 { - return new wasmlib.ScImmutableInt64(this.mapID, wasmlib.Key32.fromString(sc.StateCounter)); +export class ImmutableTestCoreState extends wasmtypes.ScProxy { + counter(): wasmtypes.ScImmutableInt64 { + return new wasmtypes.ScImmutableInt64(this.proxy.root(sc.StateCounter)); } - hnameEP(): wasmlib.ScImmutableHname { - return new wasmlib.ScImmutableHname(this.mapID, wasmlib.Key32.fromString(sc.StateHnameEP)); + hnameEP(): wasmtypes.ScImmutableHname { + return new wasmtypes.ScImmutableHname(this.proxy.root(sc.StateHnameEP)); } ints(): sc.MapStringToImmutableInt64 { - let mapID = wasmlib.getObjectID(this.mapID, wasmlib.Key32.fromString(sc.StateInts), wasmlib.TYPE_MAP); - return new sc.MapStringToImmutableInt64(mapID); + return new sc.MapStringToImmutableInt64(this.proxy.root(sc.StateInts)); } - mintedColor(): wasmlib.ScImmutableColor { - return new wasmlib.ScImmutableColor(this.mapID, wasmlib.Key32.fromString(sc.StateMintedColor)); + mintedColor(): wasmtypes.ScImmutableColor { + return new wasmtypes.ScImmutableColor(this.proxy.root(sc.StateMintedColor)); } - mintedSupply(): wasmlib.ScImmutableUint64 { - return new wasmlib.ScImmutableUint64(this.mapID, wasmlib.Key32.fromString(sc.StateMintedSupply)); + mintedSupply(): wasmtypes.ScImmutableUint64 { + return new wasmtypes.ScImmutableUint64(this.proxy.root(sc.StateMintedSupply)); } } -export class MutableTestCoreState extends wasmlib.ScMapID { +export class MutableTestCoreState extends wasmtypes.ScProxy { asImmutable(): sc.ImmutableTestCoreState { - const imm = new sc.ImmutableTestCoreState(); - imm.mapID = this.mapID; - return imm; + return new sc.ImmutableTestCoreState(this.proxy); } - counter(): wasmlib.ScMutableInt64 { - return new wasmlib.ScMutableInt64(this.mapID, wasmlib.Key32.fromString(sc.StateCounter)); + counter(): wasmtypes.ScMutableInt64 { + return new wasmtypes.ScMutableInt64(this.proxy.root(sc.StateCounter)); } - hnameEP(): wasmlib.ScMutableHname { - return new wasmlib.ScMutableHname(this.mapID, wasmlib.Key32.fromString(sc.StateHnameEP)); + hnameEP(): wasmtypes.ScMutableHname { + return new wasmtypes.ScMutableHname(this.proxy.root(sc.StateHnameEP)); } ints(): sc.MapStringToMutableInt64 { - let mapID = wasmlib.getObjectID(this.mapID, wasmlib.Key32.fromString(sc.StateInts), wasmlib.TYPE_MAP); - return new sc.MapStringToMutableInt64(mapID); + return new sc.MapStringToMutableInt64(this.proxy.root(sc.StateInts)); } - mintedColor(): wasmlib.ScMutableColor { - return new wasmlib.ScMutableColor(this.mapID, wasmlib.Key32.fromString(sc.StateMintedColor)); + mintedColor(): wasmtypes.ScMutableColor { + return new wasmtypes.ScMutableColor(this.proxy.root(sc.StateMintedColor)); } - mintedSupply(): wasmlib.ScMutableUint64 { - return new wasmlib.ScMutableUint64(this.mapID, wasmlib.Key32.fromString(sc.StateMintedSupply)); + mintedSupply(): wasmtypes.ScMutableUint64 { + return new wasmtypes.ScMutableUint64(this.proxy.root(sc.StateMintedSupply)); } } diff --git a/contracts/wasm/testcore/ts/testcore/testcore.ts b/contracts/wasm/testcore/ts/testcore/testcore.ts index 58e7e960ed..ab91309231 100644 --- a/contracts/wasm/testcore/ts/testcore/testcore.ts +++ b/contracts/wasm/testcore/ts/testcore/testcore.ts @@ -2,6 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 import * as wasmlib from "wasmlib" +import * as wasmtypes from "wasmlib/wasmtypes"; import * as coreaccounts from "wasmlib/coreaccounts" import * as coregovernance from "wasmlib/coregovernance" import * as sc from "./index"; @@ -32,11 +33,12 @@ export function funcCallOnChain(ctx: wasmlib.ScFuncContext, f: sc.CallOnChainCon counter.setValue(counter.value() + 1); - let parms = wasmlib.ScMutableMap.create(); - parms.getInt64(wasmlib.Key32.fromString(sc.ParamIntValue)).setValue(paramInt); - let ret = ctx.call(hnameContract, hnameEP, parms, null); - let retVal = ret.getInt64(wasmlib.Key32.fromString(sc.ResultIntValue)); - f.results.intValue().setValue(retVal.value()); + let params = new wasmlib.ScDict([]); + const key = wasmtypes.stringToBytes(sc.ParamIntValue); + params.set(key, wasmtypes.int64ToBytes(paramInt)) + let ret = ctx.call(hnameContract, hnameEP, params, null); + let retVal = wasmtypes.int64FromBytes(ret.get(key)); + f.results.intValue().setValue(retVal); } export function funcCheckContextFromFullEP(ctx: wasmlib.ScFuncContext, f: sc.CheckContextFromFullEPContext): void { @@ -54,8 +56,8 @@ export function funcDoNothing(ctx: wasmlib.ScFuncContext, f: sc.DoNothingContext export function funcGetMintedSupply(ctx: wasmlib.ScFuncContext, f: sc.GetMintedSupplyContext): void { let minted = ctx.minted(); let mintedColors = minted.colors(); - ctx.require(mintedColors.length() == 1, "test only supports one minted color"); - let color = mintedColors.getColor(0).value(); + ctx.require(mintedColors.length == 1, "test only supports one minted color"); + let color = mintedColors[0]; let amount = minted.balance(color); f.results.mintedSupply().setValue(amount); f.results.mintedColor().setValue(color); @@ -73,14 +75,14 @@ export function funcInit(ctx: wasmlib.ScFuncContext, f: sc.InitContext): void { } export function funcPassTypesFull(ctx: wasmlib.ScFuncContext, f: sc.PassTypesFullContext): void { - let hash = ctx.utility().hashBlake2b(wasmlib.Convert.fromString(sc.ParamHash)); + let hash = ctx.utility().hashBlake2b(wasmtypes.stringToBytes(sc.ParamHash)); ctx.require(f.params.hash().value().equals(hash), "Hash wrong"); ctx.require(f.params.int64().value() == 42, "int64 wrong"); ctx.require(f.params.int64Zero().value() == 0, "int64-0 wrong"); ctx.require(f.params.string().value() == sc.ParamString, "string wrong"); ctx.require(f.params.stringZero().value() == "", "string-0 wrong"); - ctx.require(f.params.hname().value().equals(wasmlib.ScHname.fromName(sc.ParamHname)), "Hname wrong"); - ctx.require(f.params.hnameZero().value().equals(new wasmlib.ScHname(0)), "Hname-0 wrong"); + ctx.require(f.params.hname().value().equals(ctx.utility().hname(sc.ParamHname)), "Hname wrong"); + ctx.require(f.params.hnameZero().value().equals(new wasmtypes.ScHname(0)), "Hname-0 wrong"); } export function funcRunRecursion(ctx: wasmlib.ScFuncContext, f: sc.RunRecursionContext): void { @@ -98,8 +100,8 @@ export function funcRunRecursion(ctx: wasmlib.ScFuncContext, f: sc.RunRecursionC } export function funcSendToAddress(ctx: wasmlib.ScFuncContext, f: sc.SendToAddressContext): void { - let balances = wasmlib.ScTransfers.fromBalances(ctx.balances()); - ctx.transferToAddress(f.params.address().value(), balances); + let transfer = wasmlib.ScTransfers.fromBalances(ctx.balances()); + ctx.transferToAddress(f.params.address().value(), transfer); } export function funcSetInt(ctx: wasmlib.ScFuncContext, f: sc.SetIntContext): void { @@ -109,9 +111,9 @@ export function funcSetInt(ctx: wasmlib.ScFuncContext, f: sc.SetIntContext): voi export function funcSpawn(ctx: wasmlib.ScFuncContext, f: sc.SpawnContext): void { let spawnName = sc.ScName + "_spawned"; let spawnDescr = "spawned contract description"; - ctx.deploy(f.params.progHash().value(), spawnName, spawnDescr, null); + ctx.deployContract(f.params.progHash().value(), spawnName, spawnDescr, null); - let spawnHname = wasmlib.ScHname.fromName(spawnName); + let spawnHname = ctx.utility().hname(spawnName); for (let i = 0; i < 5; i++) { ctx.call(spawnHname, sc.HFuncIncCounter, null, null); } @@ -139,8 +141,8 @@ export function funcTestChainOwnerIDFull(ctx: wasmlib.ScFuncContext, f: sc.TestC export function funcTestEventLogDeploy(ctx: wasmlib.ScFuncContext, f: sc.TestEventLogDeployContext): void { // deploy the same contract with another name - let programHash = ctx.utility().hashBlake2b(wasmlib.Convert.fromString("testcore")); - ctx.deploy(programHash, CONTRACT_NAME_DEPLOYED, "test contract deploy log", null); + let programHash = ctx.utility().hashBlake2b(wasmtypes.stringToBytes("testcore")); + ctx.deployContract(programHash, CONTRACT_NAME_DEPLOYED, "test contract deploy log", null); } export function funcTestEventLogEventData(ctx: wasmlib.ScFuncContext, f: sc.TestEventLogEventDataContext): void { @@ -207,14 +209,14 @@ export function viewJustView(ctx: wasmlib.ScViewContext, f: sc.JustViewContext): } export function viewPassTypesView(ctx: wasmlib.ScViewContext, f: sc.PassTypesViewContext): void { - let hash = ctx.utility().hashBlake2b(wasmlib.Convert.fromString(sc.ParamHash)); + let hash = ctx.utility().hashBlake2b(wasmtypes.stringToBytes(sc.ParamHash)); ctx.require(f.params.hash().value().equals(hash), "Hash wrong"); ctx.require(f.params.int64().value() == 42, "int64 wrong"); ctx.require(f.params.int64Zero().value() == 0, "int64-0 wrong"); ctx.require(f.params.string().value() == sc.ParamString, "string wrong"); ctx.require(f.params.stringZero().value() == "", "string-0 wrong"); - ctx.require(f.params.hname().value().equals(wasmlib.ScHname.fromName(sc.ParamHname)), "Hname wrong"); - ctx.require(f.params.hnameZero().value().equals(new wasmlib.ScHname(0)), "Hname-0 wrong"); + ctx.require(f.params.hname().value().equals(ctx.utility().hname(sc.ParamHname)), "Hname wrong"); + ctx.require(f.params.hnameZero().value().equals(new wasmtypes.ScHname(0)), "Hname-0 wrong"); } export function viewTestCallPanicViewEPFromView(ctx: wasmlib.ScViewContext, f: sc.TestCallPanicViewEPFromViewContext): void { diff --git a/contracts/wasm/testwasmlib/go/testwasmlib/lib.go b/contracts/wasm/testwasmlib/go/testwasmlib/lib.go index 3590ed5a8e..e3417b7af1 100644 --- a/contracts/wasm/testwasmlib/go/testwasmlib/lib.go +++ b/contracts/wasm/testwasmlib/go/testwasmlib/lib.go @@ -218,8 +218,8 @@ func viewArrayLengthThunk(ctx wasmlib.ScViewContext) { } ctx.Require(f.Params.Name().Exists(), "missing mandatory name") viewArrayLength(ctx, f) - ctx.Log("testwasmlib.viewArrayLength ok") ctx.Results(results) + ctx.Log("testwasmlib.viewArrayLength ok") } type ArrayValueContext struct { @@ -245,8 +245,8 @@ func viewArrayValueThunk(ctx wasmlib.ScViewContext) { ctx.Require(f.Params.Index().Exists(), "missing mandatory index") ctx.Require(f.Params.Name().Exists(), "missing mandatory name") viewArrayValue(ctx, f) - ctx.Log("testwasmlib.viewArrayValue ok") ctx.Results(results) + ctx.Log("testwasmlib.viewArrayValue ok") } type BlockRecordContext struct { @@ -272,8 +272,8 @@ func viewBlockRecordThunk(ctx wasmlib.ScViewContext) { ctx.Require(f.Params.BlockIndex().Exists(), "missing mandatory blockIndex") ctx.Require(f.Params.RecordIndex().Exists(), "missing mandatory recordIndex") viewBlockRecord(ctx, f) - ctx.Log("testwasmlib.viewBlockRecord ok") ctx.Results(results) + ctx.Log("testwasmlib.viewBlockRecord ok") } type BlockRecordsContext struct { @@ -298,8 +298,8 @@ func viewBlockRecordsThunk(ctx wasmlib.ScViewContext) { } ctx.Require(f.Params.BlockIndex().Exists(), "missing mandatory blockIndex") viewBlockRecords(ctx, f) - ctx.Log("testwasmlib.viewBlockRecords ok") ctx.Results(results) + ctx.Log("testwasmlib.viewBlockRecords ok") } type GetRandomContext struct { @@ -319,8 +319,8 @@ func viewGetRandomThunk(ctx wasmlib.ScViewContext) { }, } viewGetRandom(ctx, f) - ctx.Log("testwasmlib.viewGetRandom ok") ctx.Results(results) + ctx.Log("testwasmlib.viewGetRandom ok") } type IotaBalanceContext struct { @@ -340,8 +340,8 @@ func viewIotaBalanceThunk(ctx wasmlib.ScViewContext) { }, } viewIotaBalance(ctx, f) - ctx.Log("testwasmlib.viewIotaBalance ok") ctx.Results(results) + ctx.Log("testwasmlib.viewIotaBalance ok") } type MapValueContext struct { @@ -367,6 +367,6 @@ func viewMapValueThunk(ctx wasmlib.ScViewContext) { ctx.Require(f.Params.Key().Exists(), "missing mandatory key") ctx.Require(f.Params.Name().Exists(), "missing mandatory name") viewMapValue(ctx, f) - ctx.Log("testwasmlib.viewMapValue ok") ctx.Results(results) + ctx.Log("testwasmlib.viewMapValue ok") } diff --git a/contracts/wasm/testwasmlib/go/testwasmlib/params.go b/contracts/wasm/testwasmlib/go/testwasmlib/params.go index 8e100e8b4f..46d7b5e5a7 100644 --- a/contracts/wasm/testwasmlib/go/testwasmlib/params.go +++ b/contracts/wasm/testwasmlib/go/testwasmlib/params.go @@ -134,7 +134,7 @@ type MapStringToImmutableBytes struct { } func (m MapStringToImmutableBytes) GetBytes(key string) wasmtypes.ScImmutableBytes { - return wasmtypes.NewScImmutableBytes(m.proxy.Key(wasmtypes.BytesFromString(key))) + return wasmtypes.NewScImmutableBytes(m.proxy.Key(wasmtypes.StringToBytes(key))) } type ImmutableParamTypesParams struct { @@ -227,7 +227,7 @@ func (m MapStringToMutableBytes) Clear() { } func (m MapStringToMutableBytes) GetBytes(key string) wasmtypes.ScMutableBytes { - return wasmtypes.NewScMutableBytes(m.proxy.Key(wasmtypes.BytesFromString(key))) + return wasmtypes.NewScMutableBytes(m.proxy.Key(wasmtypes.StringToBytes(key))) } type MutableParamTypesParams struct { diff --git a/contracts/wasm/testwasmlib/go/testwasmlib/state.go b/contracts/wasm/testwasmlib/go/testwasmlib/state.go index 2306c8428d..8b5a08bca6 100644 --- a/contracts/wasm/testwasmlib/go/testwasmlib/state.go +++ b/contracts/wasm/testwasmlib/go/testwasmlib/state.go @@ -14,7 +14,7 @@ type MapStringToImmutableStringArray struct { } func (m MapStringToImmutableStringArray) GetStringArray(key string) ImmutableStringArray { - return ImmutableStringArray{proxy: m.proxy.Key(wasmtypes.BytesFromString(key))} + return ImmutableStringArray{proxy: m.proxy.Key(wasmtypes.StringToBytes(key))} } type MapStringToImmutableStringMap struct { @@ -22,7 +22,7 @@ type MapStringToImmutableStringMap struct { } func (m MapStringToImmutableStringMap) GetStringMap(key string) ImmutableStringMap { - return ImmutableStringMap{proxy: m.proxy.Key(wasmtypes.BytesFromString(key))} + return ImmutableStringMap{proxy: m.proxy.Key(wasmtypes.StringToBytes(key))} } type ImmutableTestWasmLibState struct { @@ -50,7 +50,7 @@ func (m MapStringToMutableStringArray) Clear() { } func (m MapStringToMutableStringArray) GetStringArray(key string) MutableStringArray { - return MutableStringArray{proxy: m.proxy.Key(wasmtypes.BytesFromString(key))} + return MutableStringArray{proxy: m.proxy.Key(wasmtypes.StringToBytes(key))} } type MapStringToMutableStringMap struct { @@ -62,7 +62,7 @@ func (m MapStringToMutableStringMap) Clear() { } func (m MapStringToMutableStringMap) GetStringMap(key string) MutableStringMap { - return MutableStringMap{proxy: m.proxy.Key(wasmtypes.BytesFromString(key))} + return MutableStringMap{proxy: m.proxy.Key(wasmtypes.StringToBytes(key))} } type MutableTestWasmLibState struct { diff --git a/contracts/wasm/testwasmlib/go/testwasmlib/structs.go b/contracts/wasm/testwasmlib/go/testwasmlib/structs.go deleted file mode 100644 index 74e019cf78..0000000000 --- a/contracts/wasm/testwasmlib/go/testwasmlib/structs.go +++ /dev/null @@ -1,248 +0,0 @@ -// Copyright 2020 IOTA Stiftung -// SPDX-License-Identifier: Apache-2.0 - -// (Re-)generated by schema tool -// >>>> DO NOT CHANGE THIS FILE! <<<< -// Change the json schema instead - -package testwasmlib - -import ( - "github.com/iotaledger/wasp/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes" -) - -type CallRequest struct { - Contract wasmtypes.ScHname - Function wasmtypes.ScHname - Params []byte - Transfer []byte -} - -func NewCallRequestFromBytes(buf []byte) *CallRequest { - dec := wasmtypes.NewWasmDecoder(buf) - data := &CallRequest{} - data.Contract = wasmtypes.DecodeHname(dec) - data.Function = wasmtypes.DecodeHname(dec) - data.Params = wasmtypes.DecodeBytes(dec) - data.Transfer = wasmtypes.DecodeBytes(dec) - dec.Close() - return data -} - -func (o *CallRequest) Bytes() []byte { - enc := wasmtypes.NewWasmEncoder() - wasmtypes.EncodeHname(enc, o.Contract) - wasmtypes.EncodeHname(enc, o.Function) - wasmtypes.EncodeBytes(enc, o.Params) - wasmtypes.EncodeBytes(enc, o.Transfer) - return enc.Buf() -} - -type ImmutableCallRequest struct { - proxy wasmtypes.Proxy -} - -func (o ImmutableCallRequest) Exists() bool { - return o.proxy.Exists() -} - -func (o ImmutableCallRequest) Value() *CallRequest { - return NewCallRequestFromBytes(o.proxy.Get()) -} - -type MutableCallRequest struct { - proxy wasmtypes.Proxy -} - -func (o MutableCallRequest) Delete() { - o.proxy.Delete() -} - -func (o MutableCallRequest) Exists() bool { - return o.proxy.Exists() -} - -func (o MutableCallRequest) SetValue(value *CallRequest) { - o.proxy.Set(value.Bytes()) -} - -func (o MutableCallRequest) Value() *CallRequest { - return NewCallRequestFromBytes(o.proxy.Get()) -} - -type DeployRequest struct { - Description string - Name string - Params []byte - ProgHash wasmtypes.ScHash -} - -func NewDeployRequestFromBytes(buf []byte) *DeployRequest { - dec := wasmtypes.NewWasmDecoder(buf) - data := &DeployRequest{} - data.Description = wasmtypes.DecodeString(dec) - data.Name = wasmtypes.DecodeString(dec) - data.Params = wasmtypes.DecodeBytes(dec) - data.ProgHash = wasmtypes.DecodeHash(dec) - dec.Close() - return data -} - -func (o *DeployRequest) Bytes() []byte { - enc := wasmtypes.NewWasmEncoder() - wasmtypes.EncodeString(enc, o.Description) - wasmtypes.EncodeString(enc, o.Name) - wasmtypes.EncodeBytes(enc, o.Params) - wasmtypes.EncodeHash(enc, o.ProgHash) - return enc.Buf() -} - -type ImmutableDeployRequest struct { - proxy wasmtypes.Proxy -} - -func (o ImmutableDeployRequest) Exists() bool { - return o.proxy.Exists() -} - -func (o ImmutableDeployRequest) Value() *DeployRequest { - return NewDeployRequestFromBytes(o.proxy.Get()) -} - -type MutableDeployRequest struct { - proxy wasmtypes.Proxy -} - -func (o MutableDeployRequest) Delete() { - o.proxy.Delete() -} - -func (o MutableDeployRequest) Exists() bool { - return o.proxy.Exists() -} - -func (o MutableDeployRequest) SetValue(value *DeployRequest) { - o.proxy.Set(value.Bytes()) -} - -func (o MutableDeployRequest) Value() *DeployRequest { - return NewDeployRequestFromBytes(o.proxy.Get()) -} - -type PostRequest struct { - ChainID wasmtypes.ScChainID - Contract wasmtypes.ScHname - Delay uint32 - Function wasmtypes.ScHname - Params []byte - Transfer []byte -} - -func NewPostRequestFromBytes(buf []byte) *PostRequest { - dec := wasmtypes.NewWasmDecoder(buf) - data := &PostRequest{} - data.ChainID = wasmtypes.DecodeChainID(dec) - data.Contract = wasmtypes.DecodeHname(dec) - data.Delay = wasmtypes.DecodeUint32(dec) - data.Function = wasmtypes.DecodeHname(dec) - data.Params = wasmtypes.DecodeBytes(dec) - data.Transfer = wasmtypes.DecodeBytes(dec) - dec.Close() - return data -} - -func (o *PostRequest) Bytes() []byte { - enc := wasmtypes.NewWasmEncoder() - wasmtypes.EncodeChainID(enc, o.ChainID) - wasmtypes.EncodeHname(enc, o.Contract) - wasmtypes.EncodeUint32(enc, o.Delay) - wasmtypes.EncodeHname(enc, o.Function) - wasmtypes.EncodeBytes(enc, o.Params) - wasmtypes.EncodeBytes(enc, o.Transfer) - return enc.Buf() -} - -type ImmutablePostRequest struct { - proxy wasmtypes.Proxy -} - -func (o ImmutablePostRequest) Exists() bool { - return o.proxy.Exists() -} - -func (o ImmutablePostRequest) Value() *PostRequest { - return NewPostRequestFromBytes(o.proxy.Get()) -} - -type MutablePostRequest struct { - proxy wasmtypes.Proxy -} - -func (o MutablePostRequest) Delete() { - o.proxy.Delete() -} - -func (o MutablePostRequest) Exists() bool { - return o.proxy.Exists() -} - -func (o MutablePostRequest) SetValue(value *PostRequest) { - o.proxy.Set(value.Bytes()) -} - -func (o MutablePostRequest) Value() *PostRequest { - return NewPostRequestFromBytes(o.proxy.Get()) -} - -type SendRequest struct { - Address wasmtypes.ScAddress - Transfer []byte -} - -func NewSendRequestFromBytes(buf []byte) *SendRequest { - dec := wasmtypes.NewWasmDecoder(buf) - data := &SendRequest{} - data.Address = wasmtypes.DecodeAddress(dec) - data.Transfer = wasmtypes.DecodeBytes(dec) - dec.Close() - return data -} - -func (o *SendRequest) Bytes() []byte { - enc := wasmtypes.NewWasmEncoder() - wasmtypes.EncodeAddress(enc, o.Address) - wasmtypes.EncodeBytes(enc, o.Transfer) - return enc.Buf() -} - -type ImmutableSendRequest struct { - proxy wasmtypes.Proxy -} - -func (o ImmutableSendRequest) Exists() bool { - return o.proxy.Exists() -} - -func (o ImmutableSendRequest) Value() *SendRequest { - return NewSendRequestFromBytes(o.proxy.Get()) -} - -type MutableSendRequest struct { - proxy wasmtypes.Proxy -} - -func (o MutableSendRequest) Delete() { - o.proxy.Delete() -} - -func (o MutableSendRequest) Exists() bool { - return o.proxy.Exists() -} - -func (o MutableSendRequest) SetValue(value *SendRequest) { - o.proxy.Set(value.Bytes()) -} - -func (o MutableSendRequest) Value() *SendRequest { - return NewSendRequestFromBytes(o.proxy.Get()) -} diff --git a/contracts/wasm/testwasmlib/go/testwasmlib/typedefs.go b/contracts/wasm/testwasmlib/go/testwasmlib/typedefs.go index 633d0f8234..d6ac0e20ca 100644 --- a/contracts/wasm/testwasmlib/go/testwasmlib/typedefs.go +++ b/contracts/wasm/testwasmlib/go/testwasmlib/typedefs.go @@ -50,7 +50,7 @@ type MapStringToImmutableString struct { } func (m MapStringToImmutableString) GetString(key string) wasmtypes.ScImmutableString { - return wasmtypes.NewScImmutableString(m.proxy.Key(wasmtypes.BytesFromString(key))) + return wasmtypes.NewScImmutableString(m.proxy.Key(wasmtypes.StringToBytes(key))) } type ImmutableStringMap = MapStringToImmutableString @@ -64,7 +64,7 @@ func (m MapStringToMutableString) Clear() { } func (m MapStringToMutableString) GetString(key string) wasmtypes.ScMutableString { - return wasmtypes.NewScMutableString(m.proxy.Key(wasmtypes.BytesFromString(key))) + return wasmtypes.NewScMutableString(m.proxy.Key(wasmtypes.StringToBytes(key))) } type MutableStringMap = MapStringToMutableString diff --git a/contracts/wasm/testwasmlib/ts/testwasmlib/consts.ts b/contracts/wasm/testwasmlib/ts/testwasmlib/consts.ts index b39471a981..996d0e3dbf 100644 --- a/contracts/wasm/testwasmlib/ts/testwasmlib/consts.ts +++ b/contracts/wasm/testwasmlib/ts/testwasmlib/consts.ts @@ -5,11 +5,11 @@ // >>>> DO NOT CHANGE THIS FILE! <<<< // Change the json schema instead -import * as wasmlib from "wasmlib"; +import * as wasmtypes from "wasmlib/wasmtypes"; export const ScName = "testwasmlib"; export const ScDescription = "Exercise several aspects of WasmLib"; -export const HScName = new wasmlib.ScHname(0x89703a45); +export const HScName = new wasmtypes.ScHname(0x89703a45); export const ParamAddress = "address"; export const ParamAgentID = "agentID"; @@ -64,18 +64,18 @@ export const ViewGetRandom = "getRandom"; export const ViewIotaBalance = "iotaBalance"; export const ViewMapValue = "mapValue"; -export const HFuncArrayAppend = new wasmlib.ScHname(0x612f835f); -export const HFuncArrayClear = new wasmlib.ScHname(0x88021821); -export const HFuncArraySet = new wasmlib.ScHname(0x2c4150b3); -export const HFuncMapClear = new wasmlib.ScHname(0x027f215a); -export const HFuncMapSet = new wasmlib.ScHname(0xf2260404); -export const HFuncParamTypes = new wasmlib.ScHname(0x6921c4cd); -export const HFuncRandom = new wasmlib.ScHname(0xe86c97ca); -export const HFuncTriggerEvent = new wasmlib.ScHname(0xd5438ac6); -export const HViewArrayLength = new wasmlib.ScHname(0x3a831021); -export const HViewArrayValue = new wasmlib.ScHname(0x662dbd81); -export const HViewBlockRecord = new wasmlib.ScHname(0xad13b2f8); -export const HViewBlockRecords = new wasmlib.ScHname(0x16e249ea); -export const HViewGetRandom = new wasmlib.ScHname(0x46263045); -export const HViewIotaBalance = new wasmlib.ScHname(0x9d3920bd); -export const HViewMapValue = new wasmlib.ScHname(0x23149bef); +export const HFuncArrayAppend = new wasmtypes.ScHname(0x612f835f); +export const HFuncArrayClear = new wasmtypes.ScHname(0x88021821); +export const HFuncArraySet = new wasmtypes.ScHname(0x2c4150b3); +export const HFuncMapClear = new wasmtypes.ScHname(0x027f215a); +export const HFuncMapSet = new wasmtypes.ScHname(0xf2260404); +export const HFuncParamTypes = new wasmtypes.ScHname(0x6921c4cd); +export const HFuncRandom = new wasmtypes.ScHname(0xe86c97ca); +export const HFuncTriggerEvent = new wasmtypes.ScHname(0xd5438ac6); +export const HViewArrayLength = new wasmtypes.ScHname(0x3a831021); +export const HViewArrayValue = new wasmtypes.ScHname(0x662dbd81); +export const HViewBlockRecord = new wasmtypes.ScHname(0xad13b2f8); +export const HViewBlockRecords = new wasmtypes.ScHname(0x16e249ea); +export const HViewGetRandom = new wasmtypes.ScHname(0x46263045); +export const HViewIotaBalance = new wasmtypes.ScHname(0x9d3920bd); +export const HViewMapValue = new wasmtypes.ScHname(0x23149bef); diff --git a/contracts/wasm/testwasmlib/ts/testwasmlib/contract.ts b/contracts/wasm/testwasmlib/ts/testwasmlib/contract.ts index 091d1253b0..e8c5d3c508 100644 --- a/contracts/wasm/testwasmlib/ts/testwasmlib/contract.ts +++ b/contracts/wasm/testwasmlib/ts/testwasmlib/contract.ts @@ -6,72 +6,73 @@ // Change the json schema instead import * as wasmlib from "wasmlib"; +import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; export class ArrayAppendCall { func: wasmlib.ScFunc = new wasmlib.ScFunc(sc.HScName, sc.HFuncArrayAppend); - params: sc.MutableArrayAppendParams = new sc.MutableArrayAppendParams(); + params: sc.MutableArrayAppendParams = new sc.MutableArrayAppendParams(wasmlib.ScView.nilProxy); } export class ArrayAppendContext { events: sc.TestWasmLibEvents = new sc.TestWasmLibEvents(); - params: sc.ImmutableArrayAppendParams = new sc.ImmutableArrayAppendParams(); - state: sc.MutableTestWasmLibState = new sc.MutableTestWasmLibState(); + params: sc.ImmutableArrayAppendParams = new sc.ImmutableArrayAppendParams(wasmlib.paramsProxy()); + state: sc.MutableTestWasmLibState = new sc.MutableTestWasmLibState(wasmlib.ScState.proxy()); } export class ArrayClearCall { func: wasmlib.ScFunc = new wasmlib.ScFunc(sc.HScName, sc.HFuncArrayClear); - params: sc.MutableArrayClearParams = new sc.MutableArrayClearParams(); + params: sc.MutableArrayClearParams = new sc.MutableArrayClearParams(wasmlib.ScView.nilProxy); } export class ArrayClearContext { events: sc.TestWasmLibEvents = new sc.TestWasmLibEvents(); - params: sc.ImmutableArrayClearParams = new sc.ImmutableArrayClearParams(); - state: sc.MutableTestWasmLibState = new sc.MutableTestWasmLibState(); + params: sc.ImmutableArrayClearParams = new sc.ImmutableArrayClearParams(wasmlib.paramsProxy()); + state: sc.MutableTestWasmLibState = new sc.MutableTestWasmLibState(wasmlib.ScState.proxy()); } export class ArraySetCall { func: wasmlib.ScFunc = new wasmlib.ScFunc(sc.HScName, sc.HFuncArraySet); - params: sc.MutableArraySetParams = new sc.MutableArraySetParams(); + params: sc.MutableArraySetParams = new sc.MutableArraySetParams(wasmlib.ScView.nilProxy); } export class ArraySetContext { events: sc.TestWasmLibEvents = new sc.TestWasmLibEvents(); - params: sc.ImmutableArraySetParams = new sc.ImmutableArraySetParams(); - state: sc.MutableTestWasmLibState = new sc.MutableTestWasmLibState(); + params: sc.ImmutableArraySetParams = new sc.ImmutableArraySetParams(wasmlib.paramsProxy()); + state: sc.MutableTestWasmLibState = new sc.MutableTestWasmLibState(wasmlib.ScState.proxy()); } export class MapClearCall { func: wasmlib.ScFunc = new wasmlib.ScFunc(sc.HScName, sc.HFuncMapClear); - params: sc.MutableMapClearParams = new sc.MutableMapClearParams(); + params: sc.MutableMapClearParams = new sc.MutableMapClearParams(wasmlib.ScView.nilProxy); } export class MapClearContext { events: sc.TestWasmLibEvents = new sc.TestWasmLibEvents(); - params: sc.ImmutableMapClearParams = new sc.ImmutableMapClearParams(); - state: sc.MutableTestWasmLibState = new sc.MutableTestWasmLibState(); + params: sc.ImmutableMapClearParams = new sc.ImmutableMapClearParams(wasmlib.paramsProxy()); + state: sc.MutableTestWasmLibState = new sc.MutableTestWasmLibState(wasmlib.ScState.proxy()); } export class MapSetCall { func: wasmlib.ScFunc = new wasmlib.ScFunc(sc.HScName, sc.HFuncMapSet); - params: sc.MutableMapSetParams = new sc.MutableMapSetParams(); + params: sc.MutableMapSetParams = new sc.MutableMapSetParams(wasmlib.ScView.nilProxy); } export class MapSetContext { events: sc.TestWasmLibEvents = new sc.TestWasmLibEvents(); - params: sc.ImmutableMapSetParams = new sc.ImmutableMapSetParams(); - state: sc.MutableTestWasmLibState = new sc.MutableTestWasmLibState(); + params: sc.ImmutableMapSetParams = new sc.ImmutableMapSetParams(wasmlib.paramsProxy()); + state: sc.MutableTestWasmLibState = new sc.MutableTestWasmLibState(wasmlib.ScState.proxy()); } export class ParamTypesCall { func: wasmlib.ScFunc = new wasmlib.ScFunc(sc.HScName, sc.HFuncParamTypes); - params: sc.MutableParamTypesParams = new sc.MutableParamTypesParams(); + params: sc.MutableParamTypesParams = new sc.MutableParamTypesParams(wasmlib.ScView.nilProxy); } export class ParamTypesContext { events: sc.TestWasmLibEvents = new sc.TestWasmLibEvents(); - params: sc.ImmutableParamTypesParams = new sc.ImmutableParamTypesParams(); - state: sc.MutableTestWasmLibState = new sc.MutableTestWasmLibState(); + params: sc.ImmutableParamTypesParams = new sc.ImmutableParamTypesParams(wasmlib.paramsProxy()); + state: sc.MutableTestWasmLibState = new sc.MutableTestWasmLibState(wasmlib.ScState.proxy()); } export class RandomCall { @@ -80,134 +81,134 @@ export class RandomCall { export class RandomContext { events: sc.TestWasmLibEvents = new sc.TestWasmLibEvents(); - state: sc.MutableTestWasmLibState = new sc.MutableTestWasmLibState(); + state: sc.MutableTestWasmLibState = new sc.MutableTestWasmLibState(wasmlib.ScState.proxy()); } export class TriggerEventCall { func: wasmlib.ScFunc = new wasmlib.ScFunc(sc.HScName, sc.HFuncTriggerEvent); - params: sc.MutableTriggerEventParams = new sc.MutableTriggerEventParams(); + params: sc.MutableTriggerEventParams = new sc.MutableTriggerEventParams(wasmlib.ScView.nilProxy); } export class TriggerEventContext { events: sc.TestWasmLibEvents = new sc.TestWasmLibEvents(); - params: sc.ImmutableTriggerEventParams = new sc.ImmutableTriggerEventParams(); - state: sc.MutableTestWasmLibState = new sc.MutableTestWasmLibState(); + params: sc.ImmutableTriggerEventParams = new sc.ImmutableTriggerEventParams(wasmlib.paramsProxy()); + state: sc.MutableTestWasmLibState = new sc.MutableTestWasmLibState(wasmlib.ScState.proxy()); } export class ArrayLengthCall { func: wasmlib.ScView = new wasmlib.ScView(sc.HScName, sc.HViewArrayLength); - params: sc.MutableArrayLengthParams = new sc.MutableArrayLengthParams(); - results: sc.ImmutableArrayLengthResults = new sc.ImmutableArrayLengthResults(); + params: sc.MutableArrayLengthParams = new sc.MutableArrayLengthParams(wasmlib.ScView.nilProxy); + results: sc.ImmutableArrayLengthResults = new sc.ImmutableArrayLengthResults(wasmlib.ScView.nilProxy); } export class ArrayLengthContext { - params: sc.ImmutableArrayLengthParams = new sc.ImmutableArrayLengthParams(); - results: sc.MutableArrayLengthResults = new sc.MutableArrayLengthResults(); - state: sc.ImmutableTestWasmLibState = new sc.ImmutableTestWasmLibState(); + params: sc.ImmutableArrayLengthParams = new sc.ImmutableArrayLengthParams(wasmlib.paramsProxy()); + results: sc.MutableArrayLengthResults = new sc.MutableArrayLengthResults(wasmlib.ScView.nilProxy); + state: sc.ImmutableTestWasmLibState = new sc.ImmutableTestWasmLibState(wasmlib.ScState.proxy()); } export class ArrayValueCall { func: wasmlib.ScView = new wasmlib.ScView(sc.HScName, sc.HViewArrayValue); - params: sc.MutableArrayValueParams = new sc.MutableArrayValueParams(); - results: sc.ImmutableArrayValueResults = new sc.ImmutableArrayValueResults(); + params: sc.MutableArrayValueParams = new sc.MutableArrayValueParams(wasmlib.ScView.nilProxy); + results: sc.ImmutableArrayValueResults = new sc.ImmutableArrayValueResults(wasmlib.ScView.nilProxy); } export class ArrayValueContext { - params: sc.ImmutableArrayValueParams = new sc.ImmutableArrayValueParams(); - results: sc.MutableArrayValueResults = new sc.MutableArrayValueResults(); - state: sc.ImmutableTestWasmLibState = new sc.ImmutableTestWasmLibState(); + params: sc.ImmutableArrayValueParams = new sc.ImmutableArrayValueParams(wasmlib.paramsProxy()); + results: sc.MutableArrayValueResults = new sc.MutableArrayValueResults(wasmlib.ScView.nilProxy); + state: sc.ImmutableTestWasmLibState = new sc.ImmutableTestWasmLibState(wasmlib.ScState.proxy()); } export class BlockRecordCall { func: wasmlib.ScView = new wasmlib.ScView(sc.HScName, sc.HViewBlockRecord); - params: sc.MutableBlockRecordParams = new sc.MutableBlockRecordParams(); - results: sc.ImmutableBlockRecordResults = new sc.ImmutableBlockRecordResults(); + params: sc.MutableBlockRecordParams = new sc.MutableBlockRecordParams(wasmlib.ScView.nilProxy); + results: sc.ImmutableBlockRecordResults = new sc.ImmutableBlockRecordResults(wasmlib.ScView.nilProxy); } export class BlockRecordContext { - params: sc.ImmutableBlockRecordParams = new sc.ImmutableBlockRecordParams(); - results: sc.MutableBlockRecordResults = new sc.MutableBlockRecordResults(); - state: sc.ImmutableTestWasmLibState = new sc.ImmutableTestWasmLibState(); + params: sc.ImmutableBlockRecordParams = new sc.ImmutableBlockRecordParams(wasmlib.paramsProxy()); + results: sc.MutableBlockRecordResults = new sc.MutableBlockRecordResults(wasmlib.ScView.nilProxy); + state: sc.ImmutableTestWasmLibState = new sc.ImmutableTestWasmLibState(wasmlib.ScState.proxy()); } export class BlockRecordsCall { func: wasmlib.ScView = new wasmlib.ScView(sc.HScName, sc.HViewBlockRecords); - params: sc.MutableBlockRecordsParams = new sc.MutableBlockRecordsParams(); - results: sc.ImmutableBlockRecordsResults = new sc.ImmutableBlockRecordsResults(); + params: sc.MutableBlockRecordsParams = new sc.MutableBlockRecordsParams(wasmlib.ScView.nilProxy); + results: sc.ImmutableBlockRecordsResults = new sc.ImmutableBlockRecordsResults(wasmlib.ScView.nilProxy); } export class BlockRecordsContext { - params: sc.ImmutableBlockRecordsParams = new sc.ImmutableBlockRecordsParams(); - results: sc.MutableBlockRecordsResults = new sc.MutableBlockRecordsResults(); - state: sc.ImmutableTestWasmLibState = new sc.ImmutableTestWasmLibState(); + params: sc.ImmutableBlockRecordsParams = new sc.ImmutableBlockRecordsParams(wasmlib.paramsProxy()); + results: sc.MutableBlockRecordsResults = new sc.MutableBlockRecordsResults(wasmlib.ScView.nilProxy); + state: sc.ImmutableTestWasmLibState = new sc.ImmutableTestWasmLibState(wasmlib.ScState.proxy()); } export class GetRandomCall { func: wasmlib.ScView = new wasmlib.ScView(sc.HScName, sc.HViewGetRandom); - results: sc.ImmutableGetRandomResults = new sc.ImmutableGetRandomResults(); + results: sc.ImmutableGetRandomResults = new sc.ImmutableGetRandomResults(wasmlib.ScView.nilProxy); } export class GetRandomContext { - results: sc.MutableGetRandomResults = new sc.MutableGetRandomResults(); - state: sc.ImmutableTestWasmLibState = new sc.ImmutableTestWasmLibState(); + results: sc.MutableGetRandomResults = new sc.MutableGetRandomResults(wasmlib.ScView.nilProxy); + state: sc.ImmutableTestWasmLibState = new sc.ImmutableTestWasmLibState(wasmlib.ScState.proxy()); } export class IotaBalanceCall { func: wasmlib.ScView = new wasmlib.ScView(sc.HScName, sc.HViewIotaBalance); - results: sc.ImmutableIotaBalanceResults = new sc.ImmutableIotaBalanceResults(); + results: sc.ImmutableIotaBalanceResults = new sc.ImmutableIotaBalanceResults(wasmlib.ScView.nilProxy); } export class IotaBalanceContext { - results: sc.MutableIotaBalanceResults = new sc.MutableIotaBalanceResults(); - state: sc.ImmutableTestWasmLibState = new sc.ImmutableTestWasmLibState(); + results: sc.MutableIotaBalanceResults = new sc.MutableIotaBalanceResults(wasmlib.ScView.nilProxy); + state: sc.ImmutableTestWasmLibState = new sc.ImmutableTestWasmLibState(wasmlib.ScState.proxy()); } export class MapValueCall { func: wasmlib.ScView = new wasmlib.ScView(sc.HScName, sc.HViewMapValue); - params: sc.MutableMapValueParams = new sc.MutableMapValueParams(); - results: sc.ImmutableMapValueResults = new sc.ImmutableMapValueResults(); + params: sc.MutableMapValueParams = new sc.MutableMapValueParams(wasmlib.ScView.nilProxy); + results: sc.ImmutableMapValueResults = new sc.ImmutableMapValueResults(wasmlib.ScView.nilProxy); } export class MapValueContext { - params: sc.ImmutableMapValueParams = new sc.ImmutableMapValueParams(); - results: sc.MutableMapValueResults = new sc.MutableMapValueResults(); - state: sc.ImmutableTestWasmLibState = new sc.ImmutableTestWasmLibState(); + params: sc.ImmutableMapValueParams = new sc.ImmutableMapValueParams(wasmlib.paramsProxy()); + results: sc.MutableMapValueResults = new sc.MutableMapValueResults(wasmlib.ScView.nilProxy); + state: sc.ImmutableTestWasmLibState = new sc.ImmutableTestWasmLibState(wasmlib.ScState.proxy()); } export class ScFuncs { static arrayAppend(ctx: wasmlib.ScFuncCallContext): ArrayAppendCall { - let f = new ArrayAppendCall(); - f.func.setPtrs(f.params, null); + const f = new ArrayAppendCall(); + f.params = new sc.MutableArrayAppendParams(wasmlib.newCallParamsProxy(f.func)); return f; } static arrayClear(ctx: wasmlib.ScFuncCallContext): ArrayClearCall { - let f = new ArrayClearCall(); - f.func.setPtrs(f.params, null); + const f = new ArrayClearCall(); + f.params = new sc.MutableArrayClearParams(wasmlib.newCallParamsProxy(f.func)); return f; } static arraySet(ctx: wasmlib.ScFuncCallContext): ArraySetCall { - let f = new ArraySetCall(); - f.func.setPtrs(f.params, null); + const f = new ArraySetCall(); + f.params = new sc.MutableArraySetParams(wasmlib.newCallParamsProxy(f.func)); return f; } static mapClear(ctx: wasmlib.ScFuncCallContext): MapClearCall { - let f = new MapClearCall(); - f.func.setPtrs(f.params, null); + const f = new MapClearCall(); + f.params = new sc.MutableMapClearParams(wasmlib.newCallParamsProxy(f.func)); return f; } static mapSet(ctx: wasmlib.ScFuncCallContext): MapSetCall { - let f = new MapSetCall(); - f.func.setPtrs(f.params, null); + const f = new MapSetCall(); + f.params = new sc.MutableMapSetParams(wasmlib.newCallParamsProxy(f.func)); return f; } static paramTypes(ctx: wasmlib.ScFuncCallContext): ParamTypesCall { - let f = new ParamTypesCall(); - f.func.setPtrs(f.params, null); + const f = new ParamTypesCall(); + f.params = new sc.MutableParamTypesParams(wasmlib.newCallParamsProxy(f.func)); return f; } @@ -216,50 +217,55 @@ export class ScFuncs { } static triggerEvent(ctx: wasmlib.ScFuncCallContext): TriggerEventCall { - let f = new TriggerEventCall(); - f.func.setPtrs(f.params, null); + const f = new TriggerEventCall(); + f.params = new sc.MutableTriggerEventParams(wasmlib.newCallParamsProxy(f.func)); return f; } static arrayLength(ctx: wasmlib.ScViewCallContext): ArrayLengthCall { - let f = new ArrayLengthCall(); - f.func.setPtrs(f.params, f.results); + const f = new ArrayLengthCall(); + f.params = new sc.MutableArrayLengthParams(wasmlib.newCallParamsProxy(f.func)); + f.results = new sc.ImmutableArrayLengthResults(wasmlib.newCallResultsProxy(f.func)); return f; } static arrayValue(ctx: wasmlib.ScViewCallContext): ArrayValueCall { - let f = new ArrayValueCall(); - f.func.setPtrs(f.params, f.results); + const f = new ArrayValueCall(); + f.params = new sc.MutableArrayValueParams(wasmlib.newCallParamsProxy(f.func)); + f.results = new sc.ImmutableArrayValueResults(wasmlib.newCallResultsProxy(f.func)); return f; } static blockRecord(ctx: wasmlib.ScViewCallContext): BlockRecordCall { - let f = new BlockRecordCall(); - f.func.setPtrs(f.params, f.results); + const f = new BlockRecordCall(); + f.params = new sc.MutableBlockRecordParams(wasmlib.newCallParamsProxy(f.func)); + f.results = new sc.ImmutableBlockRecordResults(wasmlib.newCallResultsProxy(f.func)); return f; } static blockRecords(ctx: wasmlib.ScViewCallContext): BlockRecordsCall { - let f = new BlockRecordsCall(); - f.func.setPtrs(f.params, f.results); + const f = new BlockRecordsCall(); + f.params = new sc.MutableBlockRecordsParams(wasmlib.newCallParamsProxy(f.func)); + f.results = new sc.ImmutableBlockRecordsResults(wasmlib.newCallResultsProxy(f.func)); return f; } static getRandom(ctx: wasmlib.ScViewCallContext): GetRandomCall { - let f = new GetRandomCall(); - f.func.setPtrs(null, f.results); + const f = new GetRandomCall(); + f.results = new sc.ImmutableGetRandomResults(wasmlib.newCallResultsProxy(f.func)); return f; } static iotaBalance(ctx: wasmlib.ScViewCallContext): IotaBalanceCall { - let f = new IotaBalanceCall(); - f.func.setPtrs(null, f.results); + const f = new IotaBalanceCall(); + f.results = new sc.ImmutableIotaBalanceResults(wasmlib.newCallResultsProxy(f.func)); return f; } static mapValue(ctx: wasmlib.ScViewCallContext): MapValueCall { - let f = new MapValueCall(); - f.func.setPtrs(f.params, f.results); + const f = new MapValueCall(); + f.params = new sc.MutableMapValueParams(wasmlib.newCallParamsProxy(f.func)); + f.results = new sc.ImmutableMapValueResults(wasmlib.newCallResultsProxy(f.func)); return f; } } diff --git a/contracts/wasm/testwasmlib/ts/testwasmlib/events.ts b/contracts/wasm/testwasmlib/ts/testwasmlib/events.ts index 8fd0c6416b..9ee07eebf9 100644 --- a/contracts/wasm/testwasmlib/ts/testwasmlib/events.ts +++ b/contracts/wasm/testwasmlib/ts/testwasmlib/events.ts @@ -6,13 +6,14 @@ // Change the json schema instead import * as wasmlib from "wasmlib"; +import * as wasmtypes from "wasmlib/wasmtypes"; export class TestWasmLibEvents { - test(address: wasmlib.ScAddress, name: string): void { - new wasmlib.EventEncoder("testwasmlib.test"). - address(address). - string(name). - emit(); + test(address: wasmtypes.ScAddress, name: string): void { + const evt = new wasmlib.EventEncoder("testwasmlib.test"); + evt.encode(wasmtypes.addressToString(address)); + evt.encode(wasmtypes.stringToString(name)); + evt.emit(); } } diff --git a/contracts/wasm/testwasmlib/ts/testwasmlib/index.ts b/contracts/wasm/testwasmlib/ts/testwasmlib/index.ts index 502314c2d3..e647be41d3 100644 --- a/contracts/wasm/testwasmlib/ts/testwasmlib/index.ts +++ b/contracts/wasm/testwasmlib/ts/testwasmlib/index.ts @@ -10,7 +10,6 @@ export * from "./testwasmlib"; export * from "./consts"; export * from "./contract"; export * from "./events"; -export * from "./keys"; export * from "./lib"; export * from "./params"; export * from "./results"; diff --git a/contracts/wasm/testwasmlib/ts/testwasmlib/keys.ts b/contracts/wasm/testwasmlib/ts/testwasmlib/keys.ts index 92517c4880..0c38cb7e7d 100644 --- a/contracts/wasm/testwasmlib/ts/testwasmlib/keys.ts +++ b/contracts/wasm/testwasmlib/ts/testwasmlib/keys.ts @@ -5,8 +5,6 @@ // >>>> DO NOT CHANGE THIS FILE! <<<< // Change the json schema instead -import * as wasmlib from "wasmlib"; -import * as sc from "./index"; export const IdxParamAddress = 0; export const IdxParamAgentID = 1; @@ -33,53 +31,3 @@ export const IdxParamUint32 = 21; export const IdxParamUint64 = 22; export const IdxParamUint8 = 23; export const IdxParamValue = 24; - -export const IdxResultCount = 25; -export const IdxResultIotas = 26; -export const IdxResultLength = 27; -export const IdxResultRandom = 28; -export const IdxResultRecord = 29; -export const IdxResultValue = 30; - -export const IdxStateArrays = 31; -export const IdxStateMaps = 32; -export const IdxStateRandom = 33; - -export let keyMap: string[] = [ - sc.ParamAddress, - sc.ParamAgentID, - sc.ParamBlockIndex, - sc.ParamBool, - sc.ParamBytes, - sc.ParamChainID, - sc.ParamColor, - sc.ParamHash, - sc.ParamHname, - sc.ParamIndex, - sc.ParamInt16, - sc.ParamInt32, - sc.ParamInt64, - sc.ParamInt8, - sc.ParamKey, - sc.ParamName, - sc.ParamParam, - sc.ParamRecordIndex, - sc.ParamRequestID, - sc.ParamString, - sc.ParamUint16, - sc.ParamUint32, - sc.ParamUint64, - sc.ParamUint8, - sc.ParamValue, - sc.ResultCount, - sc.ResultIotas, - sc.ResultLength, - sc.ResultRandom, - sc.ResultRecord, - sc.ResultValue, - sc.StateArrays, - sc.StateMaps, - sc.StateRandom, -]; - -export let idxMap: wasmlib.Key32[] = new Array(keyMap.length); diff --git a/contracts/wasm/testwasmlib/ts/testwasmlib/lib.ts b/contracts/wasm/testwasmlib/ts/testwasmlib/lib.ts index dd8f65b877..1b63ed38bb 100644 --- a/contracts/wasm/testwasmlib/ts/testwasmlib/lib.ts +++ b/contracts/wasm/testwasmlib/ts/testwasmlib/lib.ts @@ -6,6 +6,7 @@ // Change the json schema instead import * as wasmlib from "wasmlib"; +import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; export function on_call(index: i32): void { @@ -29,17 +30,11 @@ export function on_load(): void { exports.addView(sc.ViewGetRandom, viewGetRandomThunk); exports.addView(sc.ViewIotaBalance, viewIotaBalanceThunk); exports.addView(sc.ViewMapValue, viewMapValueThunk); - - for (let i = 0; i < sc.keyMap.length; i++) { - sc.idxMap[i] = wasmlib.Key32.fromString(sc.keyMap[i]); - } } function funcArrayAppendThunk(ctx: wasmlib.ScFuncContext): void { ctx.log("testwasmlib.funcArrayAppend"); let f = new sc.ArrayAppendContext(); - f.params.mapID = wasmlib.OBJ_ID_PARAMS; - f.state.mapID = wasmlib.OBJ_ID_STATE; ctx.require(f.params.name().exists(), "missing mandatory name"); ctx.require(f.params.value().exists(), "missing mandatory value"); sc.funcArrayAppend(ctx, f); @@ -49,8 +44,6 @@ function funcArrayAppendThunk(ctx: wasmlib.ScFuncContext): void { function funcArrayClearThunk(ctx: wasmlib.ScFuncContext): void { ctx.log("testwasmlib.funcArrayClear"); let f = new sc.ArrayClearContext(); - f.params.mapID = wasmlib.OBJ_ID_PARAMS; - f.state.mapID = wasmlib.OBJ_ID_STATE; ctx.require(f.params.name().exists(), "missing mandatory name"); sc.funcArrayClear(ctx, f); ctx.log("testwasmlib.funcArrayClear ok"); @@ -59,8 +52,6 @@ function funcArrayClearThunk(ctx: wasmlib.ScFuncContext): void { function funcArraySetThunk(ctx: wasmlib.ScFuncContext): void { ctx.log("testwasmlib.funcArraySet"); let f = new sc.ArraySetContext(); - f.params.mapID = wasmlib.OBJ_ID_PARAMS; - f.state.mapID = wasmlib.OBJ_ID_STATE; ctx.require(f.params.index().exists(), "missing mandatory index"); ctx.require(f.params.name().exists(), "missing mandatory name"); ctx.require(f.params.value().exists(), "missing mandatory value"); @@ -71,8 +62,6 @@ function funcArraySetThunk(ctx: wasmlib.ScFuncContext): void { function funcMapClearThunk(ctx: wasmlib.ScFuncContext): void { ctx.log("testwasmlib.funcMapClear"); let f = new sc.MapClearContext(); - f.params.mapID = wasmlib.OBJ_ID_PARAMS; - f.state.mapID = wasmlib.OBJ_ID_STATE; ctx.require(f.params.name().exists(), "missing mandatory name"); sc.funcMapClear(ctx, f); ctx.log("testwasmlib.funcMapClear ok"); @@ -81,8 +70,6 @@ function funcMapClearThunk(ctx: wasmlib.ScFuncContext): void { function funcMapSetThunk(ctx: wasmlib.ScFuncContext): void { ctx.log("testwasmlib.funcMapSet"); let f = new sc.MapSetContext(); - f.params.mapID = wasmlib.OBJ_ID_PARAMS; - f.state.mapID = wasmlib.OBJ_ID_STATE; ctx.require(f.params.key().exists(), "missing mandatory key"); ctx.require(f.params.name().exists(), "missing mandatory name"); ctx.require(f.params.value().exists(), "missing mandatory value"); @@ -93,8 +80,6 @@ function funcMapSetThunk(ctx: wasmlib.ScFuncContext): void { function funcParamTypesThunk(ctx: wasmlib.ScFuncContext): void { ctx.log("testwasmlib.funcParamTypes"); let f = new sc.ParamTypesContext(); - f.params.mapID = wasmlib.OBJ_ID_PARAMS; - f.state.mapID = wasmlib.OBJ_ID_STATE; sc.funcParamTypes(ctx, f); ctx.log("testwasmlib.funcParamTypes ok"); } @@ -102,7 +87,6 @@ function funcParamTypesThunk(ctx: wasmlib.ScFuncContext): void { function funcRandomThunk(ctx: wasmlib.ScFuncContext): void { ctx.log("testwasmlib.funcRandom"); let f = new sc.RandomContext(); - f.state.mapID = wasmlib.OBJ_ID_STATE; sc.funcRandom(ctx, f); ctx.log("testwasmlib.funcRandom ok"); } @@ -110,8 +94,6 @@ function funcRandomThunk(ctx: wasmlib.ScFuncContext): void { function funcTriggerEventThunk(ctx: wasmlib.ScFuncContext): void { ctx.log("testwasmlib.funcTriggerEvent"); let f = new sc.TriggerEventContext(); - f.params.mapID = wasmlib.OBJ_ID_PARAMS; - f.state.mapID = wasmlib.OBJ_ID_STATE; ctx.require(f.params.address().exists(), "missing mandatory address"); ctx.require(f.params.name().exists(), "missing mandatory name"); sc.funcTriggerEvent(ctx, f); @@ -121,75 +103,77 @@ function funcTriggerEventThunk(ctx: wasmlib.ScFuncContext): void { function viewArrayLengthThunk(ctx: wasmlib.ScViewContext): void { ctx.log("testwasmlib.viewArrayLength"); let f = new sc.ArrayLengthContext(); - f.params.mapID = wasmlib.OBJ_ID_PARAMS; - f.results.mapID = wasmlib.OBJ_ID_RESULTS; - f.state.mapID = wasmlib.OBJ_ID_STATE; + const results = new wasmlib.ScDict([]); + f.results = new sc.MutableArrayLengthResults(results.asProxy()); ctx.require(f.params.name().exists(), "missing mandatory name"); sc.viewArrayLength(ctx, f); + ctx.results(results); ctx.log("testwasmlib.viewArrayLength ok"); } function viewArrayValueThunk(ctx: wasmlib.ScViewContext): void { ctx.log("testwasmlib.viewArrayValue"); let f = new sc.ArrayValueContext(); - f.params.mapID = wasmlib.OBJ_ID_PARAMS; - f.results.mapID = wasmlib.OBJ_ID_RESULTS; - f.state.mapID = wasmlib.OBJ_ID_STATE; + const results = new wasmlib.ScDict([]); + f.results = new sc.MutableArrayValueResults(results.asProxy()); ctx.require(f.params.index().exists(), "missing mandatory index"); ctx.require(f.params.name().exists(), "missing mandatory name"); sc.viewArrayValue(ctx, f); + ctx.results(results); ctx.log("testwasmlib.viewArrayValue ok"); } function viewBlockRecordThunk(ctx: wasmlib.ScViewContext): void { ctx.log("testwasmlib.viewBlockRecord"); let f = new sc.BlockRecordContext(); - f.params.mapID = wasmlib.OBJ_ID_PARAMS; - f.results.mapID = wasmlib.OBJ_ID_RESULTS; - f.state.mapID = wasmlib.OBJ_ID_STATE; + const results = new wasmlib.ScDict([]); + f.results = new sc.MutableBlockRecordResults(results.asProxy()); ctx.require(f.params.blockIndex().exists(), "missing mandatory blockIndex"); ctx.require(f.params.recordIndex().exists(), "missing mandatory recordIndex"); sc.viewBlockRecord(ctx, f); + ctx.results(results); ctx.log("testwasmlib.viewBlockRecord ok"); } function viewBlockRecordsThunk(ctx: wasmlib.ScViewContext): void { ctx.log("testwasmlib.viewBlockRecords"); let f = new sc.BlockRecordsContext(); - f.params.mapID = wasmlib.OBJ_ID_PARAMS; - f.results.mapID = wasmlib.OBJ_ID_RESULTS; - f.state.mapID = wasmlib.OBJ_ID_STATE; + const results = new wasmlib.ScDict([]); + f.results = new sc.MutableBlockRecordsResults(results.asProxy()); ctx.require(f.params.blockIndex().exists(), "missing mandatory blockIndex"); sc.viewBlockRecords(ctx, f); + ctx.results(results); ctx.log("testwasmlib.viewBlockRecords ok"); } function viewGetRandomThunk(ctx: wasmlib.ScViewContext): void { ctx.log("testwasmlib.viewGetRandom"); let f = new sc.GetRandomContext(); - f.results.mapID = wasmlib.OBJ_ID_RESULTS; - f.state.mapID = wasmlib.OBJ_ID_STATE; + const results = new wasmlib.ScDict([]); + f.results = new sc.MutableGetRandomResults(results.asProxy()); sc.viewGetRandom(ctx, f); + ctx.results(results); ctx.log("testwasmlib.viewGetRandom ok"); } function viewIotaBalanceThunk(ctx: wasmlib.ScViewContext): void { ctx.log("testwasmlib.viewIotaBalance"); let f = new sc.IotaBalanceContext(); - f.results.mapID = wasmlib.OBJ_ID_RESULTS; - f.state.mapID = wasmlib.OBJ_ID_STATE; + const results = new wasmlib.ScDict([]); + f.results = new sc.MutableIotaBalanceResults(results.asProxy()); sc.viewIotaBalance(ctx, f); + ctx.results(results); ctx.log("testwasmlib.viewIotaBalance ok"); } function viewMapValueThunk(ctx: wasmlib.ScViewContext): void { ctx.log("testwasmlib.viewMapValue"); let f = new sc.MapValueContext(); - f.params.mapID = wasmlib.OBJ_ID_PARAMS; - f.results.mapID = wasmlib.OBJ_ID_RESULTS; - f.state.mapID = wasmlib.OBJ_ID_STATE; + const results = new wasmlib.ScDict([]); + f.results = new sc.MutableMapValueResults(results.asProxy()); ctx.require(f.params.key().exists(), "missing mandatory key"); ctx.require(f.params.name().exists(), "missing mandatory name"); sc.viewMapValue(ctx, f); + ctx.results(results); ctx.log("testwasmlib.viewMapValue ok"); } diff --git a/contracts/wasm/testwasmlib/ts/testwasmlib/params.ts b/contracts/wasm/testwasmlib/ts/testwasmlib/params.ts index 7a86530e48..6f3ea91e16 100644 --- a/contracts/wasm/testwasmlib/ts/testwasmlib/params.ts +++ b/contracts/wasm/testwasmlib/ts/testwasmlib/params.ts @@ -6,392 +6,383 @@ // Change the json schema instead import * as wasmlib from "wasmlib"; +import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; -export class ImmutableArrayAppendParams extends wasmlib.ScMapID { - name(): wasmlib.ScImmutableString { - return new wasmlib.ScImmutableString(this.mapID, wasmlib.Key32.fromString(sc.ParamName)); +export class ImmutableArrayAppendParams extends wasmtypes.ScProxy { + name(): wasmtypes.ScImmutableString { + return new wasmtypes.ScImmutableString(this.proxy.root(sc.ParamName)); } - value(): wasmlib.ScImmutableString { - return new wasmlib.ScImmutableString(this.mapID, wasmlib.Key32.fromString(sc.ParamValue)); + value(): wasmtypes.ScImmutableString { + return new wasmtypes.ScImmutableString(this.proxy.root(sc.ParamValue)); } } -export class MutableArrayAppendParams extends wasmlib.ScMapID { - name(): wasmlib.ScMutableString { - return new wasmlib.ScMutableString(this.mapID, wasmlib.Key32.fromString(sc.ParamName)); +export class MutableArrayAppendParams extends wasmtypes.ScProxy { + name(): wasmtypes.ScMutableString { + return new wasmtypes.ScMutableString(this.proxy.root(sc.ParamName)); } - value(): wasmlib.ScMutableString { - return new wasmlib.ScMutableString(this.mapID, wasmlib.Key32.fromString(sc.ParamValue)); + value(): wasmtypes.ScMutableString { + return new wasmtypes.ScMutableString(this.proxy.root(sc.ParamValue)); } } -export class ImmutableArrayClearParams extends wasmlib.ScMapID { - name(): wasmlib.ScImmutableString { - return new wasmlib.ScImmutableString(this.mapID, wasmlib.Key32.fromString(sc.ParamName)); +export class ImmutableArrayClearParams extends wasmtypes.ScProxy { + name(): wasmtypes.ScImmutableString { + return new wasmtypes.ScImmutableString(this.proxy.root(sc.ParamName)); } } -export class MutableArrayClearParams extends wasmlib.ScMapID { - name(): wasmlib.ScMutableString { - return new wasmlib.ScMutableString(this.mapID, wasmlib.Key32.fromString(sc.ParamName)); +export class MutableArrayClearParams extends wasmtypes.ScProxy { + name(): wasmtypes.ScMutableString { + return new wasmtypes.ScMutableString(this.proxy.root(sc.ParamName)); } } -export class ImmutableArraySetParams extends wasmlib.ScMapID { - index(): wasmlib.ScImmutableUint32 { - return new wasmlib.ScImmutableUint32(this.mapID, wasmlib.Key32.fromString(sc.ParamIndex)); +export class ImmutableArraySetParams extends wasmtypes.ScProxy { + index(): wasmtypes.ScImmutableUint32 { + return new wasmtypes.ScImmutableUint32(this.proxy.root(sc.ParamIndex)); } - name(): wasmlib.ScImmutableString { - return new wasmlib.ScImmutableString(this.mapID, wasmlib.Key32.fromString(sc.ParamName)); + name(): wasmtypes.ScImmutableString { + return new wasmtypes.ScImmutableString(this.proxy.root(sc.ParamName)); } - value(): wasmlib.ScImmutableString { - return new wasmlib.ScImmutableString(this.mapID, wasmlib.Key32.fromString(sc.ParamValue)); + value(): wasmtypes.ScImmutableString { + return new wasmtypes.ScImmutableString(this.proxy.root(sc.ParamValue)); } } -export class MutableArraySetParams extends wasmlib.ScMapID { - index(): wasmlib.ScMutableUint32 { - return new wasmlib.ScMutableUint32(this.mapID, wasmlib.Key32.fromString(sc.ParamIndex)); +export class MutableArraySetParams extends wasmtypes.ScProxy { + index(): wasmtypes.ScMutableUint32 { + return new wasmtypes.ScMutableUint32(this.proxy.root(sc.ParamIndex)); } - name(): wasmlib.ScMutableString { - return new wasmlib.ScMutableString(this.mapID, wasmlib.Key32.fromString(sc.ParamName)); + name(): wasmtypes.ScMutableString { + return new wasmtypes.ScMutableString(this.proxy.root(sc.ParamName)); } - value(): wasmlib.ScMutableString { - return new wasmlib.ScMutableString(this.mapID, wasmlib.Key32.fromString(sc.ParamValue)); + value(): wasmtypes.ScMutableString { + return new wasmtypes.ScMutableString(this.proxy.root(sc.ParamValue)); } } -export class ImmutableMapClearParams extends wasmlib.ScMapID { - name(): wasmlib.ScImmutableString { - return new wasmlib.ScImmutableString(this.mapID, wasmlib.Key32.fromString(sc.ParamName)); +export class ImmutableMapClearParams extends wasmtypes.ScProxy { + name(): wasmtypes.ScImmutableString { + return new wasmtypes.ScImmutableString(this.proxy.root(sc.ParamName)); } } -export class MutableMapClearParams extends wasmlib.ScMapID { - name(): wasmlib.ScMutableString { - return new wasmlib.ScMutableString(this.mapID, wasmlib.Key32.fromString(sc.ParamName)); +export class MutableMapClearParams extends wasmtypes.ScProxy { + name(): wasmtypes.ScMutableString { + return new wasmtypes.ScMutableString(this.proxy.root(sc.ParamName)); } } -export class ImmutableMapSetParams extends wasmlib.ScMapID { - key(): wasmlib.ScImmutableString { - return new wasmlib.ScImmutableString(this.mapID, wasmlib.Key32.fromString(sc.ParamKey)); +export class ImmutableMapSetParams extends wasmtypes.ScProxy { + key(): wasmtypes.ScImmutableString { + return new wasmtypes.ScImmutableString(this.proxy.root(sc.ParamKey)); } - name(): wasmlib.ScImmutableString { - return new wasmlib.ScImmutableString(this.mapID, wasmlib.Key32.fromString(sc.ParamName)); + name(): wasmtypes.ScImmutableString { + return new wasmtypes.ScImmutableString(this.proxy.root(sc.ParamName)); } - value(): wasmlib.ScImmutableString { - return new wasmlib.ScImmutableString(this.mapID, wasmlib.Key32.fromString(sc.ParamValue)); + value(): wasmtypes.ScImmutableString { + return new wasmtypes.ScImmutableString(this.proxy.root(sc.ParamValue)); } } -export class MutableMapSetParams extends wasmlib.ScMapID { - key(): wasmlib.ScMutableString { - return new wasmlib.ScMutableString(this.mapID, wasmlib.Key32.fromString(sc.ParamKey)); +export class MutableMapSetParams extends wasmtypes.ScProxy { + key(): wasmtypes.ScMutableString { + return new wasmtypes.ScMutableString(this.proxy.root(sc.ParamKey)); } - name(): wasmlib.ScMutableString { - return new wasmlib.ScMutableString(this.mapID, wasmlib.Key32.fromString(sc.ParamName)); + name(): wasmtypes.ScMutableString { + return new wasmtypes.ScMutableString(this.proxy.root(sc.ParamName)); } - value(): wasmlib.ScMutableString { - return new wasmlib.ScMutableString(this.mapID, wasmlib.Key32.fromString(sc.ParamValue)); + value(): wasmtypes.ScMutableString { + return new wasmtypes.ScMutableString(this.proxy.root(sc.ParamValue)); } } -export class MapStringToImmutableBytes { - objID: i32; +export class MapStringToImmutableBytes extends wasmtypes.ScProxy { - constructor(objID: i32) { - this.objID = objID; - } - - getBytes(key: string): wasmlib.ScImmutableBytes { - return new wasmlib.ScImmutableBytes(this.objID, wasmlib.Key32.fromString(key)); + getBytes(key: string): wasmtypes.ScImmutableBytes { + return new wasmtypes.ScImmutableBytes(this.proxy.key(wasmtypes.stringToBytes(key))); } } -export class ImmutableParamTypesParams extends wasmlib.ScMapID { - address(): wasmlib.ScImmutableAddress { - return new wasmlib.ScImmutableAddress(this.mapID, wasmlib.Key32.fromString(sc.ParamAddress)); +export class ImmutableParamTypesParams extends wasmtypes.ScProxy { + address(): wasmtypes.ScImmutableAddress { + return new wasmtypes.ScImmutableAddress(this.proxy.root(sc.ParamAddress)); } - agentID(): wasmlib.ScImmutableAgentID { - return new wasmlib.ScImmutableAgentID(this.mapID, wasmlib.Key32.fromString(sc.ParamAgentID)); + agentID(): wasmtypes.ScImmutableAgentID { + return new wasmtypes.ScImmutableAgentID(this.proxy.root(sc.ParamAgentID)); } - bool(): wasmlib.ScImmutableBool { - return new wasmlib.ScImmutableBool(this.mapID, wasmlib.Key32.fromString(sc.ParamBool)); + bool(): wasmtypes.ScImmutableBool { + return new wasmtypes.ScImmutableBool(this.proxy.root(sc.ParamBool)); } - bytes(): wasmlib.ScImmutableBytes { - return new wasmlib.ScImmutableBytes(this.mapID, wasmlib.Key32.fromString(sc.ParamBytes)); + bytes(): wasmtypes.ScImmutableBytes { + return new wasmtypes.ScImmutableBytes(this.proxy.root(sc.ParamBytes)); } - chainID(): wasmlib.ScImmutableChainID { - return new wasmlib.ScImmutableChainID(this.mapID, wasmlib.Key32.fromString(sc.ParamChainID)); + chainID(): wasmtypes.ScImmutableChainID { + return new wasmtypes.ScImmutableChainID(this.proxy.root(sc.ParamChainID)); } - color(): wasmlib.ScImmutableColor { - return new wasmlib.ScImmutableColor(this.mapID, wasmlib.Key32.fromString(sc.ParamColor)); + color(): wasmtypes.ScImmutableColor { + return new wasmtypes.ScImmutableColor(this.proxy.root(sc.ParamColor)); } - hash(): wasmlib.ScImmutableHash { - return new wasmlib.ScImmutableHash(this.mapID, wasmlib.Key32.fromString(sc.ParamHash)); + hash(): wasmtypes.ScImmutableHash { + return new wasmtypes.ScImmutableHash(this.proxy.root(sc.ParamHash)); } - hname(): wasmlib.ScImmutableHname { - return new wasmlib.ScImmutableHname(this.mapID, wasmlib.Key32.fromString(sc.ParamHname)); + hname(): wasmtypes.ScImmutableHname { + return new wasmtypes.ScImmutableHname(this.proxy.root(sc.ParamHname)); } - int16(): wasmlib.ScImmutableInt16 { - return new wasmlib.ScImmutableInt16(this.mapID, wasmlib.Key32.fromString(sc.ParamInt16)); + int16(): wasmtypes.ScImmutableInt16 { + return new wasmtypes.ScImmutableInt16(this.proxy.root(sc.ParamInt16)); } - int32(): wasmlib.ScImmutableInt32 { - return new wasmlib.ScImmutableInt32(this.mapID, wasmlib.Key32.fromString(sc.ParamInt32)); + int32(): wasmtypes.ScImmutableInt32 { + return new wasmtypes.ScImmutableInt32(this.proxy.root(sc.ParamInt32)); } - int64(): wasmlib.ScImmutableInt64 { - return new wasmlib.ScImmutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ParamInt64)); + int64(): wasmtypes.ScImmutableInt64 { + return new wasmtypes.ScImmutableInt64(this.proxy.root(sc.ParamInt64)); } - int8(): wasmlib.ScImmutableInt8 { - return new wasmlib.ScImmutableInt8(this.mapID, wasmlib.Key32.fromString(sc.ParamInt8)); + int8(): wasmtypes.ScImmutableInt8 { + return new wasmtypes.ScImmutableInt8(this.proxy.root(sc.ParamInt8)); } param(): sc.MapStringToImmutableBytes { - return new sc.MapStringToImmutableBytes(this.mapID); + return new sc.MapStringToImmutableBytes(this.proxy); } - requestID(): wasmlib.ScImmutableRequestID { - return new wasmlib.ScImmutableRequestID(this.mapID, wasmlib.Key32.fromString(sc.ParamRequestID)); + requestID(): wasmtypes.ScImmutableRequestID { + return new wasmtypes.ScImmutableRequestID(this.proxy.root(sc.ParamRequestID)); } - string(): wasmlib.ScImmutableString { - return new wasmlib.ScImmutableString(this.mapID, wasmlib.Key32.fromString(sc.ParamString)); + string(): wasmtypes.ScImmutableString { + return new wasmtypes.ScImmutableString(this.proxy.root(sc.ParamString)); } - uint16(): wasmlib.ScImmutableUint16 { - return new wasmlib.ScImmutableUint16(this.mapID, wasmlib.Key32.fromString(sc.ParamUint16)); + uint16(): wasmtypes.ScImmutableUint16 { + return new wasmtypes.ScImmutableUint16(this.proxy.root(sc.ParamUint16)); } - uint32(): wasmlib.ScImmutableUint32 { - return new wasmlib.ScImmutableUint32(this.mapID, wasmlib.Key32.fromString(sc.ParamUint32)); + uint32(): wasmtypes.ScImmutableUint32 { + return new wasmtypes.ScImmutableUint32(this.proxy.root(sc.ParamUint32)); } - uint64(): wasmlib.ScImmutableUint64 { - return new wasmlib.ScImmutableUint64(this.mapID, wasmlib.Key32.fromString(sc.ParamUint64)); + uint64(): wasmtypes.ScImmutableUint64 { + return new wasmtypes.ScImmutableUint64(this.proxy.root(sc.ParamUint64)); } - uint8(): wasmlib.ScImmutableUint8 { - return new wasmlib.ScImmutableUint8(this.mapID, wasmlib.Key32.fromString(sc.ParamUint8)); + uint8(): wasmtypes.ScImmutableUint8 { + return new wasmtypes.ScImmutableUint8(this.proxy.root(sc.ParamUint8)); } } -export class MapStringToMutableBytes { - objID: i32; - - constructor(objID: i32) { - this.objID = objID; - } +export class MapStringToMutableBytes extends wasmtypes.ScProxy { clear(): void { - wasmlib.clear(this.objID); + this.proxy.clearMap(); } - getBytes(key: string): wasmlib.ScMutableBytes { - return new wasmlib.ScMutableBytes(this.objID, wasmlib.Key32.fromString(key)); + getBytes(key: string): wasmtypes.ScMutableBytes { + return new wasmtypes.ScMutableBytes(this.proxy.key(wasmtypes.stringToBytes(key))); } } -export class MutableParamTypesParams extends wasmlib.ScMapID { - address(): wasmlib.ScMutableAddress { - return new wasmlib.ScMutableAddress(this.mapID, wasmlib.Key32.fromString(sc.ParamAddress)); +export class MutableParamTypesParams extends wasmtypes.ScProxy { + address(): wasmtypes.ScMutableAddress { + return new wasmtypes.ScMutableAddress(this.proxy.root(sc.ParamAddress)); } - agentID(): wasmlib.ScMutableAgentID { - return new wasmlib.ScMutableAgentID(this.mapID, wasmlib.Key32.fromString(sc.ParamAgentID)); + agentID(): wasmtypes.ScMutableAgentID { + return new wasmtypes.ScMutableAgentID(this.proxy.root(sc.ParamAgentID)); } - bool(): wasmlib.ScMutableBool { - return new wasmlib.ScMutableBool(this.mapID, wasmlib.Key32.fromString(sc.ParamBool)); + bool(): wasmtypes.ScMutableBool { + return new wasmtypes.ScMutableBool(this.proxy.root(sc.ParamBool)); } - bytes(): wasmlib.ScMutableBytes { - return new wasmlib.ScMutableBytes(this.mapID, wasmlib.Key32.fromString(sc.ParamBytes)); + bytes(): wasmtypes.ScMutableBytes { + return new wasmtypes.ScMutableBytes(this.proxy.root(sc.ParamBytes)); } - chainID(): wasmlib.ScMutableChainID { - return new wasmlib.ScMutableChainID(this.mapID, wasmlib.Key32.fromString(sc.ParamChainID)); + chainID(): wasmtypes.ScMutableChainID { + return new wasmtypes.ScMutableChainID(this.proxy.root(sc.ParamChainID)); } - color(): wasmlib.ScMutableColor { - return new wasmlib.ScMutableColor(this.mapID, wasmlib.Key32.fromString(sc.ParamColor)); + color(): wasmtypes.ScMutableColor { + return new wasmtypes.ScMutableColor(this.proxy.root(sc.ParamColor)); } - hash(): wasmlib.ScMutableHash { - return new wasmlib.ScMutableHash(this.mapID, wasmlib.Key32.fromString(sc.ParamHash)); + hash(): wasmtypes.ScMutableHash { + return new wasmtypes.ScMutableHash(this.proxy.root(sc.ParamHash)); } - hname(): wasmlib.ScMutableHname { - return new wasmlib.ScMutableHname(this.mapID, wasmlib.Key32.fromString(sc.ParamHname)); + hname(): wasmtypes.ScMutableHname { + return new wasmtypes.ScMutableHname(this.proxy.root(sc.ParamHname)); } - int16(): wasmlib.ScMutableInt16 { - return new wasmlib.ScMutableInt16(this.mapID, wasmlib.Key32.fromString(sc.ParamInt16)); + int16(): wasmtypes.ScMutableInt16 { + return new wasmtypes.ScMutableInt16(this.proxy.root(sc.ParamInt16)); } - int32(): wasmlib.ScMutableInt32 { - return new wasmlib.ScMutableInt32(this.mapID, wasmlib.Key32.fromString(sc.ParamInt32)); + int32(): wasmtypes.ScMutableInt32 { + return new wasmtypes.ScMutableInt32(this.proxy.root(sc.ParamInt32)); } - int64(): wasmlib.ScMutableInt64 { - return new wasmlib.ScMutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ParamInt64)); + int64(): wasmtypes.ScMutableInt64 { + return new wasmtypes.ScMutableInt64(this.proxy.root(sc.ParamInt64)); } - int8(): wasmlib.ScMutableInt8 { - return new wasmlib.ScMutableInt8(this.mapID, wasmlib.Key32.fromString(sc.ParamInt8)); + int8(): wasmtypes.ScMutableInt8 { + return new wasmtypes.ScMutableInt8(this.proxy.root(sc.ParamInt8)); } param(): sc.MapStringToMutableBytes { - return new sc.MapStringToMutableBytes(this.mapID); + return new sc.MapStringToMutableBytes(this.proxy); } - requestID(): wasmlib.ScMutableRequestID { - return new wasmlib.ScMutableRequestID(this.mapID, wasmlib.Key32.fromString(sc.ParamRequestID)); + requestID(): wasmtypes.ScMutableRequestID { + return new wasmtypes.ScMutableRequestID(this.proxy.root(sc.ParamRequestID)); } - string(): wasmlib.ScMutableString { - return new wasmlib.ScMutableString(this.mapID, wasmlib.Key32.fromString(sc.ParamString)); + string(): wasmtypes.ScMutableString { + return new wasmtypes.ScMutableString(this.proxy.root(sc.ParamString)); } - uint16(): wasmlib.ScMutableUint16 { - return new wasmlib.ScMutableUint16(this.mapID, wasmlib.Key32.fromString(sc.ParamUint16)); + uint16(): wasmtypes.ScMutableUint16 { + return new wasmtypes.ScMutableUint16(this.proxy.root(sc.ParamUint16)); } - uint32(): wasmlib.ScMutableUint32 { - return new wasmlib.ScMutableUint32(this.mapID, wasmlib.Key32.fromString(sc.ParamUint32)); + uint32(): wasmtypes.ScMutableUint32 { + return new wasmtypes.ScMutableUint32(this.proxy.root(sc.ParamUint32)); } - uint64(): wasmlib.ScMutableUint64 { - return new wasmlib.ScMutableUint64(this.mapID, wasmlib.Key32.fromString(sc.ParamUint64)); + uint64(): wasmtypes.ScMutableUint64 { + return new wasmtypes.ScMutableUint64(this.proxy.root(sc.ParamUint64)); } - uint8(): wasmlib.ScMutableUint8 { - return new wasmlib.ScMutableUint8(this.mapID, wasmlib.Key32.fromString(sc.ParamUint8)); + uint8(): wasmtypes.ScMutableUint8 { + return new wasmtypes.ScMutableUint8(this.proxy.root(sc.ParamUint8)); } } -export class ImmutableTriggerEventParams extends wasmlib.ScMapID { - address(): wasmlib.ScImmutableAddress { - return new wasmlib.ScImmutableAddress(this.mapID, wasmlib.Key32.fromString(sc.ParamAddress)); +export class ImmutableTriggerEventParams extends wasmtypes.ScProxy { + address(): wasmtypes.ScImmutableAddress { + return new wasmtypes.ScImmutableAddress(this.proxy.root(sc.ParamAddress)); } - name(): wasmlib.ScImmutableString { - return new wasmlib.ScImmutableString(this.mapID, wasmlib.Key32.fromString(sc.ParamName)); + name(): wasmtypes.ScImmutableString { + return new wasmtypes.ScImmutableString(this.proxy.root(sc.ParamName)); } } -export class MutableTriggerEventParams extends wasmlib.ScMapID { - address(): wasmlib.ScMutableAddress { - return new wasmlib.ScMutableAddress(this.mapID, wasmlib.Key32.fromString(sc.ParamAddress)); +export class MutableTriggerEventParams extends wasmtypes.ScProxy { + address(): wasmtypes.ScMutableAddress { + return new wasmtypes.ScMutableAddress(this.proxy.root(sc.ParamAddress)); } - name(): wasmlib.ScMutableString { - return new wasmlib.ScMutableString(this.mapID, wasmlib.Key32.fromString(sc.ParamName)); + name(): wasmtypes.ScMutableString { + return new wasmtypes.ScMutableString(this.proxy.root(sc.ParamName)); } } -export class ImmutableArrayLengthParams extends wasmlib.ScMapID { - name(): wasmlib.ScImmutableString { - return new wasmlib.ScImmutableString(this.mapID, wasmlib.Key32.fromString(sc.ParamName)); +export class ImmutableArrayLengthParams extends wasmtypes.ScProxy { + name(): wasmtypes.ScImmutableString { + return new wasmtypes.ScImmutableString(this.proxy.root(sc.ParamName)); } } -export class MutableArrayLengthParams extends wasmlib.ScMapID { - name(): wasmlib.ScMutableString { - return new wasmlib.ScMutableString(this.mapID, wasmlib.Key32.fromString(sc.ParamName)); +export class MutableArrayLengthParams extends wasmtypes.ScProxy { + name(): wasmtypes.ScMutableString { + return new wasmtypes.ScMutableString(this.proxy.root(sc.ParamName)); } } -export class ImmutableArrayValueParams extends wasmlib.ScMapID { - index(): wasmlib.ScImmutableUint32 { - return new wasmlib.ScImmutableUint32(this.mapID, wasmlib.Key32.fromString(sc.ParamIndex)); +export class ImmutableArrayValueParams extends wasmtypes.ScProxy { + index(): wasmtypes.ScImmutableUint32 { + return new wasmtypes.ScImmutableUint32(this.proxy.root(sc.ParamIndex)); } - name(): wasmlib.ScImmutableString { - return new wasmlib.ScImmutableString(this.mapID, wasmlib.Key32.fromString(sc.ParamName)); + name(): wasmtypes.ScImmutableString { + return new wasmtypes.ScImmutableString(this.proxy.root(sc.ParamName)); } } -export class MutableArrayValueParams extends wasmlib.ScMapID { - index(): wasmlib.ScMutableUint32 { - return new wasmlib.ScMutableUint32(this.mapID, wasmlib.Key32.fromString(sc.ParamIndex)); +export class MutableArrayValueParams extends wasmtypes.ScProxy { + index(): wasmtypes.ScMutableUint32 { + return new wasmtypes.ScMutableUint32(this.proxy.root(sc.ParamIndex)); } - name(): wasmlib.ScMutableString { - return new wasmlib.ScMutableString(this.mapID, wasmlib.Key32.fromString(sc.ParamName)); + name(): wasmtypes.ScMutableString { + return new wasmtypes.ScMutableString(this.proxy.root(sc.ParamName)); } } -export class ImmutableBlockRecordParams extends wasmlib.ScMapID { - blockIndex(): wasmlib.ScImmutableUint32 { - return new wasmlib.ScImmutableUint32(this.mapID, wasmlib.Key32.fromString(sc.ParamBlockIndex)); +export class ImmutableBlockRecordParams extends wasmtypes.ScProxy { + blockIndex(): wasmtypes.ScImmutableUint32 { + return new wasmtypes.ScImmutableUint32(this.proxy.root(sc.ParamBlockIndex)); } - recordIndex(): wasmlib.ScImmutableUint32 { - return new wasmlib.ScImmutableUint32(this.mapID, wasmlib.Key32.fromString(sc.ParamRecordIndex)); + recordIndex(): wasmtypes.ScImmutableUint32 { + return new wasmtypes.ScImmutableUint32(this.proxy.root(sc.ParamRecordIndex)); } } -export class MutableBlockRecordParams extends wasmlib.ScMapID { - blockIndex(): wasmlib.ScMutableUint32 { - return new wasmlib.ScMutableUint32(this.mapID, wasmlib.Key32.fromString(sc.ParamBlockIndex)); +export class MutableBlockRecordParams extends wasmtypes.ScProxy { + blockIndex(): wasmtypes.ScMutableUint32 { + return new wasmtypes.ScMutableUint32(this.proxy.root(sc.ParamBlockIndex)); } - recordIndex(): wasmlib.ScMutableUint32 { - return new wasmlib.ScMutableUint32(this.mapID, wasmlib.Key32.fromString(sc.ParamRecordIndex)); + recordIndex(): wasmtypes.ScMutableUint32 { + return new wasmtypes.ScMutableUint32(this.proxy.root(sc.ParamRecordIndex)); } } -export class ImmutableBlockRecordsParams extends wasmlib.ScMapID { - blockIndex(): wasmlib.ScImmutableUint32 { - return new wasmlib.ScImmutableUint32(this.mapID, wasmlib.Key32.fromString(sc.ParamBlockIndex)); +export class ImmutableBlockRecordsParams extends wasmtypes.ScProxy { + blockIndex(): wasmtypes.ScImmutableUint32 { + return new wasmtypes.ScImmutableUint32(this.proxy.root(sc.ParamBlockIndex)); } } -export class MutableBlockRecordsParams extends wasmlib.ScMapID { - blockIndex(): wasmlib.ScMutableUint32 { - return new wasmlib.ScMutableUint32(this.mapID, wasmlib.Key32.fromString(sc.ParamBlockIndex)); +export class MutableBlockRecordsParams extends wasmtypes.ScProxy { + blockIndex(): wasmtypes.ScMutableUint32 { + return new wasmtypes.ScMutableUint32(this.proxy.root(sc.ParamBlockIndex)); } } -export class ImmutableMapValueParams extends wasmlib.ScMapID { - key(): wasmlib.ScImmutableString { - return new wasmlib.ScImmutableString(this.mapID, wasmlib.Key32.fromString(sc.ParamKey)); +export class ImmutableMapValueParams extends wasmtypes.ScProxy { + key(): wasmtypes.ScImmutableString { + return new wasmtypes.ScImmutableString(this.proxy.root(sc.ParamKey)); } - name(): wasmlib.ScImmutableString { - return new wasmlib.ScImmutableString(this.mapID, wasmlib.Key32.fromString(sc.ParamName)); + name(): wasmtypes.ScImmutableString { + return new wasmtypes.ScImmutableString(this.proxy.root(sc.ParamName)); } } -export class MutableMapValueParams extends wasmlib.ScMapID { - key(): wasmlib.ScMutableString { - return new wasmlib.ScMutableString(this.mapID, wasmlib.Key32.fromString(sc.ParamKey)); +export class MutableMapValueParams extends wasmtypes.ScProxy { + key(): wasmtypes.ScMutableString { + return new wasmtypes.ScMutableString(this.proxy.root(sc.ParamKey)); } - name(): wasmlib.ScMutableString { - return new wasmlib.ScMutableString(this.mapID, wasmlib.Key32.fromString(sc.ParamName)); + name(): wasmtypes.ScMutableString { + return new wasmtypes.ScMutableString(this.proxy.root(sc.ParamName)); } } diff --git a/contracts/wasm/testwasmlib/ts/testwasmlib/results.ts b/contracts/wasm/testwasmlib/ts/testwasmlib/results.ts index 05cd88628a..78d950db79 100644 --- a/contracts/wasm/testwasmlib/ts/testwasmlib/results.ts +++ b/contracts/wasm/testwasmlib/ts/testwasmlib/results.ts @@ -6,88 +6,89 @@ // Change the json schema instead import * as wasmlib from "wasmlib"; +import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; -export class ImmutableArrayLengthResults extends wasmlib.ScMapID { - length(): wasmlib.ScImmutableUint32 { - return new wasmlib.ScImmutableUint32(this.mapID, wasmlib.Key32.fromString(sc.ResultLength)); +export class ImmutableArrayLengthResults extends wasmtypes.ScProxy { + length(): wasmtypes.ScImmutableUint32 { + return new wasmtypes.ScImmutableUint32(this.proxy.root(sc.ResultLength)); } } -export class MutableArrayLengthResults extends wasmlib.ScMapID { - length(): wasmlib.ScMutableUint32 { - return new wasmlib.ScMutableUint32(this.mapID, wasmlib.Key32.fromString(sc.ResultLength)); +export class MutableArrayLengthResults extends wasmtypes.ScProxy { + length(): wasmtypes.ScMutableUint32 { + return new wasmtypes.ScMutableUint32(this.proxy.root(sc.ResultLength)); } } -export class ImmutableArrayValueResults extends wasmlib.ScMapID { - value(): wasmlib.ScImmutableString { - return new wasmlib.ScImmutableString(this.mapID, wasmlib.Key32.fromString(sc.ResultValue)); +export class ImmutableArrayValueResults extends wasmtypes.ScProxy { + value(): wasmtypes.ScImmutableString { + return new wasmtypes.ScImmutableString(this.proxy.root(sc.ResultValue)); } } -export class MutableArrayValueResults extends wasmlib.ScMapID { - value(): wasmlib.ScMutableString { - return new wasmlib.ScMutableString(this.mapID, wasmlib.Key32.fromString(sc.ResultValue)); +export class MutableArrayValueResults extends wasmtypes.ScProxy { + value(): wasmtypes.ScMutableString { + return new wasmtypes.ScMutableString(this.proxy.root(sc.ResultValue)); } } -export class ImmutableBlockRecordResults extends wasmlib.ScMapID { - record(): wasmlib.ScImmutableBytes { - return new wasmlib.ScImmutableBytes(this.mapID, wasmlib.Key32.fromString(sc.ResultRecord)); +export class ImmutableBlockRecordResults extends wasmtypes.ScProxy { + record(): wasmtypes.ScImmutableBytes { + return new wasmtypes.ScImmutableBytes(this.proxy.root(sc.ResultRecord)); } } -export class MutableBlockRecordResults extends wasmlib.ScMapID { - record(): wasmlib.ScMutableBytes { - return new wasmlib.ScMutableBytes(this.mapID, wasmlib.Key32.fromString(sc.ResultRecord)); +export class MutableBlockRecordResults extends wasmtypes.ScProxy { + record(): wasmtypes.ScMutableBytes { + return new wasmtypes.ScMutableBytes(this.proxy.root(sc.ResultRecord)); } } -export class ImmutableBlockRecordsResults extends wasmlib.ScMapID { - count(): wasmlib.ScImmutableUint32 { - return new wasmlib.ScImmutableUint32(this.mapID, wasmlib.Key32.fromString(sc.ResultCount)); +export class ImmutableBlockRecordsResults extends wasmtypes.ScProxy { + count(): wasmtypes.ScImmutableUint32 { + return new wasmtypes.ScImmutableUint32(this.proxy.root(sc.ResultCount)); } } -export class MutableBlockRecordsResults extends wasmlib.ScMapID { - count(): wasmlib.ScMutableUint32 { - return new wasmlib.ScMutableUint32(this.mapID, wasmlib.Key32.fromString(sc.ResultCount)); +export class MutableBlockRecordsResults extends wasmtypes.ScProxy { + count(): wasmtypes.ScMutableUint32 { + return new wasmtypes.ScMutableUint32(this.proxy.root(sc.ResultCount)); } } -export class ImmutableGetRandomResults extends wasmlib.ScMapID { - random(): wasmlib.ScImmutableUint64 { - return new wasmlib.ScImmutableUint64(this.mapID, wasmlib.Key32.fromString(sc.ResultRandom)); +export class ImmutableGetRandomResults extends wasmtypes.ScProxy { + random(): wasmtypes.ScImmutableUint64 { + return new wasmtypes.ScImmutableUint64(this.proxy.root(sc.ResultRandom)); } } -export class MutableGetRandomResults extends wasmlib.ScMapID { - random(): wasmlib.ScMutableUint64 { - return new wasmlib.ScMutableUint64(this.mapID, wasmlib.Key32.fromString(sc.ResultRandom)); +export class MutableGetRandomResults extends wasmtypes.ScProxy { + random(): wasmtypes.ScMutableUint64 { + return new wasmtypes.ScMutableUint64(this.proxy.root(sc.ResultRandom)); } } -export class ImmutableIotaBalanceResults extends wasmlib.ScMapID { - iotas(): wasmlib.ScImmutableUint64 { - return new wasmlib.ScImmutableUint64(this.mapID, wasmlib.Key32.fromString(sc.ResultIotas)); +export class ImmutableIotaBalanceResults extends wasmtypes.ScProxy { + iotas(): wasmtypes.ScImmutableUint64 { + return new wasmtypes.ScImmutableUint64(this.proxy.root(sc.ResultIotas)); } } -export class MutableIotaBalanceResults extends wasmlib.ScMapID { - iotas(): wasmlib.ScMutableUint64 { - return new wasmlib.ScMutableUint64(this.mapID, wasmlib.Key32.fromString(sc.ResultIotas)); +export class MutableIotaBalanceResults extends wasmtypes.ScProxy { + iotas(): wasmtypes.ScMutableUint64 { + return new wasmtypes.ScMutableUint64(this.proxy.root(sc.ResultIotas)); } } -export class ImmutableMapValueResults extends wasmlib.ScMapID { - value(): wasmlib.ScImmutableString { - return new wasmlib.ScImmutableString(this.mapID, wasmlib.Key32.fromString(sc.ResultValue)); +export class ImmutableMapValueResults extends wasmtypes.ScProxy { + value(): wasmtypes.ScImmutableString { + return new wasmtypes.ScImmutableString(this.proxy.root(sc.ResultValue)); } } -export class MutableMapValueResults extends wasmlib.ScMapID { - value(): wasmlib.ScMutableString { - return new wasmlib.ScMutableString(this.mapID, wasmlib.Key32.fromString(sc.ResultValue)); +export class MutableMapValueResults extends wasmtypes.ScProxy { + value(): wasmtypes.ScMutableString { + return new wasmtypes.ScMutableString(this.proxy.root(sc.ResultValue)); } } diff --git a/contracts/wasm/testwasmlib/ts/testwasmlib/state.ts b/contracts/wasm/testwasmlib/ts/testwasmlib/state.ts index 07351efdc4..9ff83d6549 100644 --- a/contracts/wasm/testwasmlib/ts/testwasmlib/state.ts +++ b/contracts/wasm/testwasmlib/ts/testwasmlib/state.ts @@ -6,102 +6,73 @@ // Change the json schema instead import * as wasmlib from "wasmlib"; +import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; -export class MapStringToImmutableStringArray { - objID: i32; - - constructor(objID: i32) { - this.objID = objID; - } +export class MapStringToImmutableStringArray extends wasmtypes.ScProxy { getStringArray(key: string): sc.ImmutableStringArray { - let subID = wasmlib.getObjectID(this.objID, wasmlib.Key32.fromString(key), wasmlib.TYPE_ARRAY|wasmlib.TYPE_STRING); - return new sc.ImmutableStringArray(subID); + return new sc.ImmutableStringArray(this.proxy.key(wasmtypes.stringToBytes(key))); } } -export class MapStringToImmutableStringMap { - objID: i32; - - constructor(objID: i32) { - this.objID = objID; - } +export class MapStringToImmutableStringMap extends wasmtypes.ScProxy { getStringMap(key: string): sc.ImmutableStringMap { - let subID = wasmlib.getObjectID(this.objID, wasmlib.Key32.fromString(key), wasmlib.TYPE_MAP); - return new sc.ImmutableStringMap(subID); + return new sc.ImmutableStringMap(this.proxy.key(wasmtypes.stringToBytes(key))); } } -export class ImmutableTestWasmLibState extends wasmlib.ScMapID { +export class ImmutableTestWasmLibState extends wasmtypes.ScProxy { arrays(): sc.MapStringToImmutableStringArray { - let mapID = wasmlib.getObjectID(this.mapID, wasmlib.Key32.fromString(sc.StateArrays), wasmlib.TYPE_MAP); - return new sc.MapStringToImmutableStringArray(mapID); + return new sc.MapStringToImmutableStringArray(this.proxy.root(sc.StateArrays)); } maps(): sc.MapStringToImmutableStringMap { - let mapID = wasmlib.getObjectID(this.mapID, wasmlib.Key32.fromString(sc.StateMaps), wasmlib.TYPE_MAP); - return new sc.MapStringToImmutableStringMap(mapID); + return new sc.MapStringToImmutableStringMap(this.proxy.root(sc.StateMaps)); } - random(): wasmlib.ScImmutableUint64 { - return new wasmlib.ScImmutableUint64(this.mapID, wasmlib.Key32.fromString(sc.StateRandom)); + random(): wasmtypes.ScImmutableUint64 { + return new wasmtypes.ScImmutableUint64(this.proxy.root(sc.StateRandom)); } } -export class MapStringToMutableStringArray { - objID: i32; - - constructor(objID: i32) { - this.objID = objID; - } +export class MapStringToMutableStringArray extends wasmtypes.ScProxy { clear(): void { - wasmlib.clear(this.objID); + this.proxy.clearMap(); } getStringArray(key: string): sc.MutableStringArray { - let subID = wasmlib.getObjectID(this.objID, wasmlib.Key32.fromString(key), wasmlib.TYPE_ARRAY|wasmlib.TYPE_STRING); - return new sc.MutableStringArray(subID); + return new sc.MutableStringArray(this.proxy.key(wasmtypes.stringToBytes(key))); } } -export class MapStringToMutableStringMap { - objID: i32; - - constructor(objID: i32) { - this.objID = objID; - } +export class MapStringToMutableStringMap extends wasmtypes.ScProxy { clear(): void { - wasmlib.clear(this.objID); + this.proxy.clearMap(); } getStringMap(key: string): sc.MutableStringMap { - let subID = wasmlib.getObjectID(this.objID, wasmlib.Key32.fromString(key), wasmlib.TYPE_MAP); - return new sc.MutableStringMap(subID); + return new sc.MutableStringMap(this.proxy.key(wasmtypes.stringToBytes(key))); } } -export class MutableTestWasmLibState extends wasmlib.ScMapID { +export class MutableTestWasmLibState extends wasmtypes.ScProxy { asImmutable(): sc.ImmutableTestWasmLibState { - const imm = new sc.ImmutableTestWasmLibState(); - imm.mapID = this.mapID; - return imm; + return new sc.ImmutableTestWasmLibState(this.proxy); } arrays(): sc.MapStringToMutableStringArray { - let mapID = wasmlib.getObjectID(this.mapID, wasmlib.Key32.fromString(sc.StateArrays), wasmlib.TYPE_MAP); - return new sc.MapStringToMutableStringArray(mapID); + return new sc.MapStringToMutableStringArray(this.proxy.root(sc.StateArrays)); } maps(): sc.MapStringToMutableStringMap { - let mapID = wasmlib.getObjectID(this.mapID, wasmlib.Key32.fromString(sc.StateMaps), wasmlib.TYPE_MAP); - return new sc.MapStringToMutableStringMap(mapID); + return new sc.MapStringToMutableStringMap(this.proxy.root(sc.StateMaps)); } - random(): wasmlib.ScMutableUint64 { - return new wasmlib.ScMutableUint64(this.mapID, wasmlib.Key32.fromString(sc.StateRandom)); + random(): wasmtypes.ScMutableUint64 { + return new wasmtypes.ScMutableUint64(this.proxy.root(sc.StateRandom)); } } diff --git a/contracts/wasm/testwasmlib/ts/testwasmlib/testwasmlib.ts b/contracts/wasm/testwasmlib/ts/testwasmlib/testwasmlib.ts index fd9aebacce..4808c8e61a 100644 --- a/contracts/wasm/testwasmlib/ts/testwasmlib/testwasmlib.ts +++ b/contracts/wasm/testwasmlib/ts/testwasmlib/testwasmlib.ts @@ -2,6 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 import * as wasmlib from "wasmlib" +import * as wasmtypes from "wasmlib/wasmtypes"; import * as coreblocklog from "wasmlib/coreblocklog" import * as sc from "./index"; @@ -39,18 +40,18 @@ export function funcParamTypes(ctx: wasmlib.ScFuncContext, f: sc.ParamTypesConte ctx.require(f.params.bool().value(), "mismatch: Bool"); } if (f.params.bytes().exists()) { - let byteData = wasmlib.Convert.fromString("these are bytes"); - ctx.require(wasmlib.Convert.equals(f.params.bytes().value(), byteData), "mismatch: Bytes"); + const byteData = wasmtypes.stringToBytes("these are bytes"); + ctx.require(wasmtypes.bytesCompare(f.params.bytes().value(), byteData) == 0, "mismatch: Bytes"); } if (f.params.chainID().exists()) { ctx.require(f.params.chainID().value().equals(ctx.chainID()), "mismatch: ChainID"); } if (f.params.color().exists()) { - let color = wasmlib.ScColor.fromBytes(wasmlib.Convert.fromString("RedGreenBlueYellowCyanBlackWhite")); + const color = wasmlib.colorFromBytes(wasmtypes.stringToBytes("RedGreenBlueYellowCyanBlackWhite")); ctx.require(f.params.color().value().equals(color), "mismatch: Color"); } if (f.params.hash().exists()) { - let hash = wasmlib.ScHash.fromBytes(wasmlib.Convert.fromString("0123456789abcdeffedcba9876543210")); + const hash = wasmtypes.hashFromBytes(wasmtypes.stringToBytes("0123456789abcdeffedcba9876543210")); ctx.require(f.params.hash().value().equals(hash), "mismatch: Hash"); } if (f.params.hname().exists()) { @@ -69,7 +70,7 @@ export function funcParamTypes(ctx: wasmlib.ScFuncContext, f: sc.ParamTypesConte ctx.require(f.params.int64().value() == -1234567890123456789, "mismatch: Int64"); } if (f.params.requestID().exists()) { - let requestId = wasmlib.ScRequestID.fromBytes(wasmlib.Convert.fromString("abcdefghijklmnopqrstuvwxyz123456\x00\x00")); + const requestId = wasmtypes.requestIDFromBytes(wasmtypes.stringToBytes("abcdefghijklmnopqrstuvwxyz123456\x00\x00")); ctx.require(f.params.requestID().value().equals(requestId), "mismatch: RequestID"); } if (f.params.string().exists()) { @@ -133,7 +134,7 @@ export function viewGetRandom(ctx: wasmlib.ScViewContext, f: sc.GetRandomContext } export function viewIotaBalance(ctx: wasmlib.ScViewContext, f: sc.IotaBalanceContext): void { - f.results.iotas().setValue(ctx.balances().balance(wasmlib.ScColor.IOTA)); + f.results.iotas().setValue(ctx.balances().balance(wasmtypes.IOTA)); } export function viewMapValue(ctx: wasmlib.ScViewContext, f: sc.MapValueContext): void { diff --git a/contracts/wasm/testwasmlib/ts/testwasmlib/typedefs.ts b/contracts/wasm/testwasmlib/ts/testwasmlib/typedefs.ts index 14c0baab9a..34f269a501 100644 --- a/contracts/wasm/testwasmlib/ts/testwasmlib/typedefs.ts +++ b/contracts/wasm/testwasmlib/ts/testwasmlib/typedefs.ts @@ -6,78 +6,63 @@ // Change the json schema instead import * as wasmlib from "wasmlib"; +import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; -export class ArrayOfImmutableString { - objID: i32; - - constructor(objID: i32) { - this.objID = objID; - } +export class ArrayOfImmutableString extends wasmtypes.ScProxy { length(): u32 { - return wasmlib.getLength(this.objID); + return this.proxy.length(); } - getString(index: u32): wasmlib.ScImmutableString { - return new wasmlib.ScImmutableString(this.objID, new wasmlib.Key32(index as i32)); + getString(index: u32): wasmtypes.ScImmutableString { + return new wasmtypes.ScImmutableString(this.proxy.index(index)); } } export class ImmutableStringArray extends ArrayOfImmutableString { }; -export class ArrayOfMutableString { - objID: i32; +export class ArrayOfMutableString extends wasmtypes.ScProxy { - constructor(objID: i32) { - this.objID = objID; - } + appendString(): wasmtypes.ScMutableString { + return new wasmtypes.ScMutableString(this.proxy.append()); + } clear(): void { - wasmlib.clear(this.objID); + this.proxy.clearArray(); } length(): u32 { - return wasmlib.getLength(this.objID); + return this.proxy.length(); } - getString(index: u32): wasmlib.ScMutableString { - return new wasmlib.ScMutableString(this.objID, new wasmlib.Key32(index as i32)); + getString(index: u32): wasmtypes.ScMutableString { + return new wasmtypes.ScMutableString(this.proxy.index(index)); } } export class MutableStringArray extends ArrayOfMutableString { }; -export class MapStringToImmutableString { - objID: i32; +export class MapStringToImmutableString extends wasmtypes.ScProxy { - constructor(objID: i32) { - this.objID = objID; - } - - getString(key: string): wasmlib.ScImmutableString { - return new wasmlib.ScImmutableString(this.objID, wasmlib.Key32.fromString(key)); + getString(key: string): wasmtypes.ScImmutableString { + return new wasmtypes.ScImmutableString(this.proxy.key(wasmtypes.stringToBytes(key))); } } export class ImmutableStringMap extends MapStringToImmutableString { }; -export class MapStringToMutableString { - objID: i32; - - constructor(objID: i32) { - this.objID = objID; - } +export class MapStringToMutableString extends wasmtypes.ScProxy { clear(): void { - wasmlib.clear(this.objID); + this.proxy.clearMap(); } - getString(key: string): wasmlib.ScMutableString { - return new wasmlib.ScMutableString(this.objID, wasmlib.Key32.fromString(key)); + getString(key: string): wasmtypes.ScMutableString { + return new wasmtypes.ScMutableString(this.proxy.key(wasmtypes.stringToBytes(key))); } } diff --git a/contracts/wasm/timestamp/go/timestamp/lib.go b/contracts/wasm/timestamp/go/timestamp/lib.go index e9f2f8ca4e..e6f34ed72b 100644 --- a/contracts/wasm/timestamp/go/timestamp/lib.go +++ b/contracts/wasm/timestamp/go/timestamp/lib.go @@ -47,6 +47,6 @@ func viewGetTimestampThunk(ctx wasmlib.ScViewContext) { }, } viewGetTimestamp(ctx, f) - ctx.Log("timestamp.viewGetTimestamp ok") ctx.Results(results) + ctx.Log("timestamp.viewGetTimestamp ok") } diff --git a/contracts/wasm/timestamp/ts/timestamp/consts.ts b/contracts/wasm/timestamp/ts/timestamp/consts.ts index 62157f5505..b3856cae71 100644 --- a/contracts/wasm/timestamp/ts/timestamp/consts.ts +++ b/contracts/wasm/timestamp/ts/timestamp/consts.ts @@ -5,11 +5,11 @@ // >>>> DO NOT CHANGE THIS FILE! <<<< // Change the json schema instead -import * as wasmlib from "wasmlib"; +import * as wasmtypes from "wasmlib/wasmtypes"; export const ScName = "timestamp"; export const ScDescription = "Extremely simple timestamp server"; -export const HScName = new wasmlib.ScHname(0x3988002e); +export const HScName = new wasmtypes.ScHname(0x3988002e); export const ResultTimestamp = "timestamp"; @@ -18,5 +18,5 @@ export const StateTimestamp = "timestamp"; export const FuncNow = "now"; export const ViewGetTimestamp = "getTimestamp"; -export const HFuncNow = new wasmlib.ScHname(0xd73b7fc9); -export const HViewGetTimestamp = new wasmlib.ScHname(0x40c6376a); +export const HFuncNow = new wasmtypes.ScHname(0xd73b7fc9); +export const HViewGetTimestamp = new wasmtypes.ScHname(0x40c6376a); diff --git a/contracts/wasm/timestamp/ts/timestamp/contract.ts b/contracts/wasm/timestamp/ts/timestamp/contract.ts index f95a487aa2..bdb16297af 100644 --- a/contracts/wasm/timestamp/ts/timestamp/contract.ts +++ b/contracts/wasm/timestamp/ts/timestamp/contract.ts @@ -6,6 +6,7 @@ // Change the json schema instead import * as wasmlib from "wasmlib"; +import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; export class NowCall { @@ -13,17 +14,17 @@ export class NowCall { } export class NowContext { - state: sc.MutabletimestampState = new sc.MutabletimestampState(); + state: sc.MutabletimestampState = new sc.MutabletimestampState(wasmlib.ScState.proxy()); } export class GetTimestampCall { func: wasmlib.ScView = new wasmlib.ScView(sc.HScName, sc.HViewGetTimestamp); - results: sc.ImmutableGetTimestampResults = new sc.ImmutableGetTimestampResults(); + results: sc.ImmutableGetTimestampResults = new sc.ImmutableGetTimestampResults(wasmlib.ScView.nilProxy); } export class GetTimestampContext { - results: sc.MutableGetTimestampResults = new sc.MutableGetTimestampResults(); - state: sc.ImmutabletimestampState = new sc.ImmutabletimestampState(); + results: sc.MutableGetTimestampResults = new sc.MutableGetTimestampResults(wasmlib.ScView.nilProxy); + state: sc.ImmutabletimestampState = new sc.ImmutabletimestampState(wasmlib.ScState.proxy()); } export class ScFuncs { @@ -32,8 +33,8 @@ export class ScFuncs { } static getTimestamp(ctx: wasmlib.ScViewCallContext): GetTimestampCall { - let f = new GetTimestampCall(); - f.func.setPtrs(null, f.results); + const f = new GetTimestampCall(); + f.results = new sc.ImmutableGetTimestampResults(wasmlib.newCallResultsProxy(f.func)); return f; } } diff --git a/contracts/wasm/timestamp/ts/timestamp/index.ts b/contracts/wasm/timestamp/ts/timestamp/index.ts index 0b905cf8fd..f356a4ef4f 100644 --- a/contracts/wasm/timestamp/ts/timestamp/index.ts +++ b/contracts/wasm/timestamp/ts/timestamp/index.ts @@ -9,7 +9,6 @@ export * from "./timestamp"; export * from "./consts"; export * from "./contract"; -export * from "./keys"; export * from "./lib"; export * from "./results"; export * from "./state"; diff --git a/contracts/wasm/timestamp/ts/timestamp/keys.ts b/contracts/wasm/timestamp/ts/timestamp/keys.ts index 3cfd4e84d0..c8806d28c4 100644 --- a/contracts/wasm/timestamp/ts/timestamp/keys.ts +++ b/contracts/wasm/timestamp/ts/timestamp/keys.ts @@ -5,17 +5,4 @@ // >>>> DO NOT CHANGE THIS FILE! <<<< // Change the json schema instead -import * as wasmlib from "wasmlib"; -import * as sc from "./index"; - -export const IdxResultTimestamp = 0; - -export const IdxStateTimestamp = 1; - -export let keyMap: string[] = [ - sc.ResultTimestamp, - sc.StateTimestamp, -]; - -export let idxMap: wasmlib.Key32[] = new Array(keyMap.length); diff --git a/contracts/wasm/timestamp/ts/timestamp/lib.ts b/contracts/wasm/timestamp/ts/timestamp/lib.ts index 80e29210f7..81c857cfd0 100644 --- a/contracts/wasm/timestamp/ts/timestamp/lib.ts +++ b/contracts/wasm/timestamp/ts/timestamp/lib.ts @@ -6,6 +6,7 @@ // Change the json schema instead import * as wasmlib from "wasmlib"; +import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; export function on_call(index: i32): void { @@ -16,16 +17,11 @@ export function on_load(): void { let exports = new wasmlib.ScExports(); exports.addFunc(sc.FuncNow, funcNowThunk); exports.addView(sc.ViewGetTimestamp, viewGetTimestampThunk); - - for (let i = 0; i < sc.keyMap.length; i++) { - sc.idxMap[i] = wasmlib.Key32.fromString(sc.keyMap[i]); - } } function funcNowThunk(ctx: wasmlib.ScFuncContext): void { ctx.log("timestamp.funcNow"); let f = new sc.NowContext(); - f.state.mapID = wasmlib.OBJ_ID_STATE; sc.funcNow(ctx, f); ctx.log("timestamp.funcNow ok"); } @@ -33,8 +29,9 @@ function funcNowThunk(ctx: wasmlib.ScFuncContext): void { function viewGetTimestampThunk(ctx: wasmlib.ScViewContext): void { ctx.log("timestamp.viewGetTimestamp"); let f = new sc.GetTimestampContext(); - f.results.mapID = wasmlib.OBJ_ID_RESULTS; - f.state.mapID = wasmlib.OBJ_ID_STATE; + const results = new wasmlib.ScDict([]); + f.results = new sc.MutableGetTimestampResults(results.asProxy()); sc.viewGetTimestamp(ctx, f); + ctx.results(results); ctx.log("timestamp.viewGetTimestamp ok"); } diff --git a/contracts/wasm/timestamp/ts/timestamp/results.ts b/contracts/wasm/timestamp/ts/timestamp/results.ts index bb6a357a74..3c8b1060d4 100644 --- a/contracts/wasm/timestamp/ts/timestamp/results.ts +++ b/contracts/wasm/timestamp/ts/timestamp/results.ts @@ -6,16 +6,17 @@ // Change the json schema instead import * as wasmlib from "wasmlib"; +import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; -export class ImmutableGetTimestampResults extends wasmlib.ScMapID { - timestamp(): wasmlib.ScImmutableUint64 { - return new wasmlib.ScImmutableUint64(this.mapID, wasmlib.Key32.fromString(sc.ResultTimestamp)); +export class ImmutableGetTimestampResults extends wasmtypes.ScProxy { + timestamp(): wasmtypes.ScImmutableUint64 { + return new wasmtypes.ScImmutableUint64(this.proxy.root(sc.ResultTimestamp)); } } -export class MutableGetTimestampResults extends wasmlib.ScMapID { - timestamp(): wasmlib.ScMutableUint64 { - return new wasmlib.ScMutableUint64(this.mapID, wasmlib.Key32.fromString(sc.ResultTimestamp)); +export class MutableGetTimestampResults extends wasmtypes.ScProxy { + timestamp(): wasmtypes.ScMutableUint64 { + return new wasmtypes.ScMutableUint64(this.proxy.root(sc.ResultTimestamp)); } } diff --git a/contracts/wasm/timestamp/ts/timestamp/state.ts b/contracts/wasm/timestamp/ts/timestamp/state.ts index 3e70cc6e39..0c9315e915 100644 --- a/contracts/wasm/timestamp/ts/timestamp/state.ts +++ b/contracts/wasm/timestamp/ts/timestamp/state.ts @@ -6,22 +6,21 @@ // Change the json schema instead import * as wasmlib from "wasmlib"; +import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; -export class ImmutabletimestampState extends wasmlib.ScMapID { - timestamp(): wasmlib.ScImmutableUint64 { - return new wasmlib.ScImmutableUint64(this.mapID, wasmlib.Key32.fromString(sc.StateTimestamp)); +export class ImmutabletimestampState extends wasmtypes.ScProxy { + timestamp(): wasmtypes.ScImmutableUint64 { + return new wasmtypes.ScImmutableUint64(this.proxy.root(sc.StateTimestamp)); } } -export class MutabletimestampState extends wasmlib.ScMapID { +export class MutabletimestampState extends wasmtypes.ScProxy { asImmutable(): sc.ImmutabletimestampState { - const imm = new sc.ImmutabletimestampState(); - imm.mapID = this.mapID; - return imm; + return new sc.ImmutabletimestampState(this.proxy); } - timestamp(): wasmlib.ScMutableUint64 { - return new wasmlib.ScMutableUint64(this.mapID, wasmlib.Key32.fromString(sc.StateTimestamp)); + timestamp(): wasmtypes.ScMutableUint64 { + return new wasmtypes.ScMutableUint64(this.proxy.root(sc.StateTimestamp)); } } diff --git a/contracts/wasm/tokenregistry/go/tokenregistry/state.go b/contracts/wasm/tokenregistry/go/tokenregistry/state.go index 46674f7be9..8e88404f71 100644 --- a/contracts/wasm/tokenregistry/go/tokenregistry/state.go +++ b/contracts/wasm/tokenregistry/go/tokenregistry/state.go @@ -26,7 +26,7 @@ type MapColorToImmutableToken struct { } func (m MapColorToImmutableToken) GetToken(key wasmtypes.ScColor) ImmutableToken { - return ImmutableToken{proxy: m.proxy.Key(wasmtypes.BytesFromColor(key))} + return ImmutableToken{proxy: m.proxy.Key(wasmtypes.ColorToBytes(key))} } type ImmutableTokenRegistryState struct { @@ -70,7 +70,7 @@ func (m MapColorToMutableToken) Clear() { } func (m MapColorToMutableToken) GetToken(key wasmtypes.ScColor) MutableToken { - return MutableToken{proxy: m.proxy.Key(wasmtypes.BytesFromColor(key))} + return MutableToken{proxy: m.proxy.Key(wasmtypes.ColorToBytes(key))} } type MutableTokenRegistryState struct { diff --git a/contracts/wasm/tokenregistry/go/tokenregistry/structs.go b/contracts/wasm/tokenregistry/go/tokenregistry/structs.go index 45d9e7ca71..85b36a2554 100644 --- a/contracts/wasm/tokenregistry/go/tokenregistry/structs.go +++ b/contracts/wasm/tokenregistry/go/tokenregistry/structs.go @@ -22,26 +22,26 @@ type Token struct { func NewTokenFromBytes(buf []byte) *Token { dec := wasmtypes.NewWasmDecoder(buf) data := &Token{} - data.Created = wasmtypes.DecodeUint64(dec) - data.Description = wasmtypes.DecodeString(dec) - data.MintedBy = wasmtypes.DecodeAgentID(dec) - data.Owner = wasmtypes.DecodeAgentID(dec) - data.Supply = wasmtypes.DecodeUint64(dec) - data.Updated = wasmtypes.DecodeUint64(dec) - data.UserDefined = wasmtypes.DecodeString(dec) + data.Created = wasmtypes.Uint64Decode(dec) + data.Description = wasmtypes.StringDecode(dec) + data.MintedBy = wasmtypes.AgentIDDecode(dec) + data.Owner = wasmtypes.AgentIDDecode(dec) + data.Supply = wasmtypes.Uint64Decode(dec) + data.Updated = wasmtypes.Uint64Decode(dec) + data.UserDefined = wasmtypes.StringDecode(dec) dec.Close() return data } func (o *Token) Bytes() []byte { enc := wasmtypes.NewWasmEncoder() - wasmtypes.EncodeUint64(enc, o.Created) - wasmtypes.EncodeString(enc, o.Description) - wasmtypes.EncodeAgentID(enc, o.MintedBy) - wasmtypes.EncodeAgentID(enc, o.Owner) - wasmtypes.EncodeUint64(enc, o.Supply) - wasmtypes.EncodeUint64(enc, o.Updated) - wasmtypes.EncodeString(enc, o.UserDefined) + wasmtypes.Uint64Encode(enc, o.Created) + wasmtypes.StringEncode(enc, o.Description) + wasmtypes.AgentIDEncode(enc, o.MintedBy) + wasmtypes.AgentIDEncode(enc, o.Owner) + wasmtypes.Uint64Encode(enc, o.Supply) + wasmtypes.Uint64Encode(enc, o.Updated) + wasmtypes.StringEncode(enc, o.UserDefined) return enc.Buf() } diff --git a/contracts/wasm/tokenregistry/ts/tokenregistry/consts.ts b/contracts/wasm/tokenregistry/ts/tokenregistry/consts.ts index fd519a0bf0..c1db612bdc 100644 --- a/contracts/wasm/tokenregistry/ts/tokenregistry/consts.ts +++ b/contracts/wasm/tokenregistry/ts/tokenregistry/consts.ts @@ -5,11 +5,11 @@ // >>>> DO NOT CHANGE THIS FILE! <<<< // Change the json schema instead -import * as wasmlib from "wasmlib"; +import * as wasmtypes from "wasmlib/wasmtypes"; export const ScName = "tokenregistry"; export const ScDescription = ""; -export const HScName = new wasmlib.ScHname(0xe1ba0c78); +export const HScName = new wasmtypes.ScHname(0xe1ba0c78); export const ParamColor = "color"; export const ParamDescription = "description"; @@ -23,7 +23,7 @@ export const FuncTransferOwnership = "transferOwnership"; export const FuncUpdateMetadata = "updateMetadata"; export const ViewGetInfo = "getInfo"; -export const HFuncMintSupply = new wasmlib.ScHname(0x564349a7); -export const HFuncTransferOwnership = new wasmlib.ScHname(0xbb9eb5af); -export const HFuncUpdateMetadata = new wasmlib.ScHname(0xa26b23b6); -export const HViewGetInfo = new wasmlib.ScHname(0xcfedba5f); +export const HFuncMintSupply = new wasmtypes.ScHname(0x564349a7); +export const HFuncTransferOwnership = new wasmtypes.ScHname(0xbb9eb5af); +export const HFuncUpdateMetadata = new wasmtypes.ScHname(0xa26b23b6); +export const HViewGetInfo = new wasmtypes.ScHname(0xcfedba5f); diff --git a/contracts/wasm/tokenregistry/ts/tokenregistry/contract.ts b/contracts/wasm/tokenregistry/ts/tokenregistry/contract.ts index c0b4241dbc..e3e9fa4965 100644 --- a/contracts/wasm/tokenregistry/ts/tokenregistry/contract.ts +++ b/contracts/wasm/tokenregistry/ts/tokenregistry/contract.ts @@ -6,70 +6,71 @@ // Change the json schema instead import * as wasmlib from "wasmlib"; +import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; export class MintSupplyCall { func: wasmlib.ScFunc = new wasmlib.ScFunc(sc.HScName, sc.HFuncMintSupply); - params: sc.MutableMintSupplyParams = new sc.MutableMintSupplyParams(); + params: sc.MutableMintSupplyParams = new sc.MutableMintSupplyParams(wasmlib.ScView.nilProxy); } export class MintSupplyContext { - params: sc.ImmutableMintSupplyParams = new sc.ImmutableMintSupplyParams(); - state: sc.MutableTokenRegistryState = new sc.MutableTokenRegistryState(); + params: sc.ImmutableMintSupplyParams = new sc.ImmutableMintSupplyParams(wasmlib.paramsProxy()); + state: sc.MutableTokenRegistryState = new sc.MutableTokenRegistryState(wasmlib.ScState.proxy()); } export class TransferOwnershipCall { func: wasmlib.ScFunc = new wasmlib.ScFunc(sc.HScName, sc.HFuncTransferOwnership); - params: sc.MutableTransferOwnershipParams = new sc.MutableTransferOwnershipParams(); + params: sc.MutableTransferOwnershipParams = new sc.MutableTransferOwnershipParams(wasmlib.ScView.nilProxy); } export class TransferOwnershipContext { - params: sc.ImmutableTransferOwnershipParams = new sc.ImmutableTransferOwnershipParams(); - state: sc.MutableTokenRegistryState = new sc.MutableTokenRegistryState(); + params: sc.ImmutableTransferOwnershipParams = new sc.ImmutableTransferOwnershipParams(wasmlib.paramsProxy()); + state: sc.MutableTokenRegistryState = new sc.MutableTokenRegistryState(wasmlib.ScState.proxy()); } export class UpdateMetadataCall { func: wasmlib.ScFunc = new wasmlib.ScFunc(sc.HScName, sc.HFuncUpdateMetadata); - params: sc.MutableUpdateMetadataParams = new sc.MutableUpdateMetadataParams(); + params: sc.MutableUpdateMetadataParams = new sc.MutableUpdateMetadataParams(wasmlib.ScView.nilProxy); } export class UpdateMetadataContext { - params: sc.ImmutableUpdateMetadataParams = new sc.ImmutableUpdateMetadataParams(); - state: sc.MutableTokenRegistryState = new sc.MutableTokenRegistryState(); + params: sc.ImmutableUpdateMetadataParams = new sc.ImmutableUpdateMetadataParams(wasmlib.paramsProxy()); + state: sc.MutableTokenRegistryState = new sc.MutableTokenRegistryState(wasmlib.ScState.proxy()); } export class GetInfoCall { func: wasmlib.ScView = new wasmlib.ScView(sc.HScName, sc.HViewGetInfo); - params: sc.MutableGetInfoParams = new sc.MutableGetInfoParams(); + params: sc.MutableGetInfoParams = new sc.MutableGetInfoParams(wasmlib.ScView.nilProxy); } export class GetInfoContext { - params: sc.ImmutableGetInfoParams = new sc.ImmutableGetInfoParams(); - state: sc.ImmutableTokenRegistryState = new sc.ImmutableTokenRegistryState(); + params: sc.ImmutableGetInfoParams = new sc.ImmutableGetInfoParams(wasmlib.paramsProxy()); + state: sc.ImmutableTokenRegistryState = new sc.ImmutableTokenRegistryState(wasmlib.ScState.proxy()); } export class ScFuncs { static mintSupply(ctx: wasmlib.ScFuncCallContext): MintSupplyCall { - let f = new MintSupplyCall(); - f.func.setPtrs(f.params, null); + const f = new MintSupplyCall(); + f.params = new sc.MutableMintSupplyParams(wasmlib.newCallParamsProxy(f.func)); return f; } static transferOwnership(ctx: wasmlib.ScFuncCallContext): TransferOwnershipCall { - let f = new TransferOwnershipCall(); - f.func.setPtrs(f.params, null); + const f = new TransferOwnershipCall(); + f.params = new sc.MutableTransferOwnershipParams(wasmlib.newCallParamsProxy(f.func)); return f; } static updateMetadata(ctx: wasmlib.ScFuncCallContext): UpdateMetadataCall { - let f = new UpdateMetadataCall(); - f.func.setPtrs(f.params, null); + const f = new UpdateMetadataCall(); + f.params = new sc.MutableUpdateMetadataParams(wasmlib.newCallParamsProxy(f.func)); return f; } static getInfo(ctx: wasmlib.ScViewCallContext): GetInfoCall { - let f = new GetInfoCall(); - f.func.setPtrs(f.params, null); + const f = new GetInfoCall(); + f.params = new sc.MutableGetInfoParams(wasmlib.newCallParamsProxy(f.func)); return f; } } diff --git a/contracts/wasm/tokenregistry/ts/tokenregistry/index.ts b/contracts/wasm/tokenregistry/ts/tokenregistry/index.ts index ff035c3e66..0a315da2f8 100644 --- a/contracts/wasm/tokenregistry/ts/tokenregistry/index.ts +++ b/contracts/wasm/tokenregistry/ts/tokenregistry/index.ts @@ -9,7 +9,6 @@ export * from "./tokenregistry"; export * from "./consts"; export * from "./contract"; -export * from "./keys"; export * from "./lib"; export * from "./params"; export * from "./state"; diff --git a/contracts/wasm/tokenregistry/ts/tokenregistry/keys.ts b/contracts/wasm/tokenregistry/ts/tokenregistry/keys.ts index 6e20801b3c..dc4dd7478c 100644 --- a/contracts/wasm/tokenregistry/ts/tokenregistry/keys.ts +++ b/contracts/wasm/tokenregistry/ts/tokenregistry/keys.ts @@ -5,23 +5,7 @@ // >>>> DO NOT CHANGE THIS FILE! <<<< // Change the json schema instead -import * as wasmlib from "wasmlib"; -import * as sc from "./index"; export const IdxParamColor = 0; export const IdxParamDescription = 1; export const IdxParamUserDefined = 2; - - -export const IdxStateColorList = 3; -export const IdxStateRegistry = 4; - -export let keyMap: string[] = [ - sc.ParamColor, - sc.ParamDescription, - sc.ParamUserDefined, - sc.StateColorList, - sc.StateRegistry, -]; - -export let idxMap: wasmlib.Key32[] = new Array(keyMap.length); diff --git a/contracts/wasm/tokenregistry/ts/tokenregistry/lib.ts b/contracts/wasm/tokenregistry/ts/tokenregistry/lib.ts index 48b2839424..a49d4de43e 100644 --- a/contracts/wasm/tokenregistry/ts/tokenregistry/lib.ts +++ b/contracts/wasm/tokenregistry/ts/tokenregistry/lib.ts @@ -6,6 +6,7 @@ // Change the json schema instead import * as wasmlib from "wasmlib"; +import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; export function on_call(index: i32): void { @@ -18,30 +19,22 @@ export function on_load(): void { exports.addFunc(sc.FuncTransferOwnership, funcTransferOwnershipThunk); exports.addFunc(sc.FuncUpdateMetadata, funcUpdateMetadataThunk); exports.addView(sc.ViewGetInfo, viewGetInfoThunk); - - for (let i = 0; i < sc.keyMap.length; i++) { - sc.idxMap[i] = wasmlib.Key32.fromString(sc.keyMap[i]); - } } function funcMintSupplyThunk(ctx: wasmlib.ScFuncContext): void { ctx.log("tokenregistry.funcMintSupply"); let f = new sc.MintSupplyContext(); - f.params.mapID = wasmlib.OBJ_ID_PARAMS; - f.state.mapID = wasmlib.OBJ_ID_STATE; sc.funcMintSupply(ctx, f); ctx.log("tokenregistry.funcMintSupply ok"); } function funcTransferOwnershipThunk(ctx: wasmlib.ScFuncContext): void { ctx.log("tokenregistry.funcTransferOwnership"); + let f = new sc.TransferOwnershipContext(); // TODO the one who can transfer token ownership ctx.require(ctx.caller().equals(ctx.contractCreator()), "no permission"); - let f = new sc.TransferOwnershipContext(); - f.params.mapID = wasmlib.OBJ_ID_PARAMS; - f.state.mapID = wasmlib.OBJ_ID_STATE; ctx.require(f.params.color().exists(), "missing mandatory color"); sc.funcTransferOwnership(ctx, f); ctx.log("tokenregistry.funcTransferOwnership ok"); @@ -49,13 +42,11 @@ function funcTransferOwnershipThunk(ctx: wasmlib.ScFuncContext): void { function funcUpdateMetadataThunk(ctx: wasmlib.ScFuncContext): void { ctx.log("tokenregistry.funcUpdateMetadata"); + let f = new sc.UpdateMetadataContext(); // TODO the one who can change the token info ctx.require(ctx.caller().equals(ctx.contractCreator()), "no permission"); - let f = new sc.UpdateMetadataContext(); - f.params.mapID = wasmlib.OBJ_ID_PARAMS; - f.state.mapID = wasmlib.OBJ_ID_STATE; ctx.require(f.params.color().exists(), "missing mandatory color"); sc.funcUpdateMetadata(ctx, f); ctx.log("tokenregistry.funcUpdateMetadata ok"); @@ -64,8 +55,6 @@ function funcUpdateMetadataThunk(ctx: wasmlib.ScFuncContext): void { function viewGetInfoThunk(ctx: wasmlib.ScViewContext): void { ctx.log("tokenregistry.viewGetInfo"); let f = new sc.GetInfoContext(); - f.params.mapID = wasmlib.OBJ_ID_PARAMS; - f.state.mapID = wasmlib.OBJ_ID_STATE; ctx.require(f.params.color().exists(), "missing mandatory color"); sc.viewGetInfo(ctx, f); ctx.log("tokenregistry.viewGetInfo ok"); diff --git a/contracts/wasm/tokenregistry/ts/tokenregistry/params.ts b/contracts/wasm/tokenregistry/ts/tokenregistry/params.ts index 7307270773..897598da51 100644 --- a/contracts/wasm/tokenregistry/ts/tokenregistry/params.ts +++ b/contracts/wasm/tokenregistry/ts/tokenregistry/params.ts @@ -6,60 +6,61 @@ // Change the json schema instead import * as wasmlib from "wasmlib"; +import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; -export class ImmutableMintSupplyParams extends wasmlib.ScMapID { - description(): wasmlib.ScImmutableString { - return new wasmlib.ScImmutableString(this.mapID, wasmlib.Key32.fromString(sc.ParamDescription)); +export class ImmutableMintSupplyParams extends wasmtypes.ScProxy { + description(): wasmtypes.ScImmutableString { + return new wasmtypes.ScImmutableString(this.proxy.root(sc.ParamDescription)); } - userDefined(): wasmlib.ScImmutableString { - return new wasmlib.ScImmutableString(this.mapID, wasmlib.Key32.fromString(sc.ParamUserDefined)); + userDefined(): wasmtypes.ScImmutableString { + return new wasmtypes.ScImmutableString(this.proxy.root(sc.ParamUserDefined)); } } -export class MutableMintSupplyParams extends wasmlib.ScMapID { - description(): wasmlib.ScMutableString { - return new wasmlib.ScMutableString(this.mapID, wasmlib.Key32.fromString(sc.ParamDescription)); +export class MutableMintSupplyParams extends wasmtypes.ScProxy { + description(): wasmtypes.ScMutableString { + return new wasmtypes.ScMutableString(this.proxy.root(sc.ParamDescription)); } - userDefined(): wasmlib.ScMutableString { - return new wasmlib.ScMutableString(this.mapID, wasmlib.Key32.fromString(sc.ParamUserDefined)); + userDefined(): wasmtypes.ScMutableString { + return new wasmtypes.ScMutableString(this.proxy.root(sc.ParamUserDefined)); } } -export class ImmutableTransferOwnershipParams extends wasmlib.ScMapID { - color(): wasmlib.ScImmutableColor { - return new wasmlib.ScImmutableColor(this.mapID, wasmlib.Key32.fromString(sc.ParamColor)); +export class ImmutableTransferOwnershipParams extends wasmtypes.ScProxy { + color(): wasmtypes.ScImmutableColor { + return new wasmtypes.ScImmutableColor(this.proxy.root(sc.ParamColor)); } } -export class MutableTransferOwnershipParams extends wasmlib.ScMapID { - color(): wasmlib.ScMutableColor { - return new wasmlib.ScMutableColor(this.mapID, wasmlib.Key32.fromString(sc.ParamColor)); +export class MutableTransferOwnershipParams extends wasmtypes.ScProxy { + color(): wasmtypes.ScMutableColor { + return new wasmtypes.ScMutableColor(this.proxy.root(sc.ParamColor)); } } -export class ImmutableUpdateMetadataParams extends wasmlib.ScMapID { - color(): wasmlib.ScImmutableColor { - return new wasmlib.ScImmutableColor(this.mapID, wasmlib.Key32.fromString(sc.ParamColor)); +export class ImmutableUpdateMetadataParams extends wasmtypes.ScProxy { + color(): wasmtypes.ScImmutableColor { + return new wasmtypes.ScImmutableColor(this.proxy.root(sc.ParamColor)); } } -export class MutableUpdateMetadataParams extends wasmlib.ScMapID { - color(): wasmlib.ScMutableColor { - return new wasmlib.ScMutableColor(this.mapID, wasmlib.Key32.fromString(sc.ParamColor)); +export class MutableUpdateMetadataParams extends wasmtypes.ScProxy { + color(): wasmtypes.ScMutableColor { + return new wasmtypes.ScMutableColor(this.proxy.root(sc.ParamColor)); } } -export class ImmutableGetInfoParams extends wasmlib.ScMapID { - color(): wasmlib.ScImmutableColor { - return new wasmlib.ScImmutableColor(this.mapID, wasmlib.Key32.fromString(sc.ParamColor)); +export class ImmutableGetInfoParams extends wasmtypes.ScProxy { + color(): wasmtypes.ScImmutableColor { + return new wasmtypes.ScImmutableColor(this.proxy.root(sc.ParamColor)); } } -export class MutableGetInfoParams extends wasmlib.ScMapID { - color(): wasmlib.ScMutableColor { - return new wasmlib.ScMutableColor(this.mapID, wasmlib.Key32.fromString(sc.ParamColor)); +export class MutableGetInfoParams extends wasmtypes.ScProxy { + color(): wasmtypes.ScMutableColor { + return new wasmtypes.ScMutableColor(this.proxy.root(sc.ParamColor)); } } diff --git a/contracts/wasm/tokenregistry/ts/tokenregistry/state.ts b/contracts/wasm/tokenregistry/ts/tokenregistry/state.ts index c9b96c3358..858d13588c 100644 --- a/contracts/wasm/tokenregistry/ts/tokenregistry/state.ts +++ b/contracts/wasm/tokenregistry/ts/tokenregistry/state.ts @@ -6,98 +6,77 @@ // Change the json schema instead import * as wasmlib from "wasmlib"; +import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; -export class ArrayOfImmutableColor { - objID: i32; - - constructor(objID: i32) { - this.objID = objID; - } +export class ArrayOfImmutableColor extends wasmtypes.ScProxy { length(): u32 { - return wasmlib.getLength(this.objID); + return this.proxy.length(); } - getColor(index: u32): wasmlib.ScImmutableColor { - return new wasmlib.ScImmutableColor(this.objID, new wasmlib.Key32(index as i32)); + getColor(index: u32): wasmtypes.ScImmutableColor { + return new wasmtypes.ScImmutableColor(this.proxy.index(index)); } } -export class MapColorToImmutableToken { - objID: i32; - - constructor(objID: i32) { - this.objID = objID; - } +export class MapColorToImmutableToken extends wasmtypes.ScProxy { - getToken(key: wasmlib.ScColor): sc.ImmutableToken { - return new sc.ImmutableToken(this.objID, key.getKeyID()); + getToken(key: wasmtypes.ScColor): sc.ImmutableToken { + return new sc.ImmutableToken(this.proxy.key(wasmtypes.colorToBytes(key))); } } -export class ImmutableTokenRegistryState extends wasmlib.ScMapID { +export class ImmutableTokenRegistryState extends wasmtypes.ScProxy { colorList(): sc.ArrayOfImmutableColor { - let arrID = wasmlib.getObjectID(this.mapID, wasmlib.Key32.fromString(sc.StateColorList), wasmlib.TYPE_ARRAY|wasmlib.TYPE_COLOR); - return new sc.ArrayOfImmutableColor(arrID); + return new sc.ArrayOfImmutableColor(this.proxy.root(sc.StateColorList)); } registry(): sc.MapColorToImmutableToken { - let mapID = wasmlib.getObjectID(this.mapID, wasmlib.Key32.fromString(sc.StateRegistry), wasmlib.TYPE_MAP); - return new sc.MapColorToImmutableToken(mapID); + return new sc.MapColorToImmutableToken(this.proxy.root(sc.StateRegistry)); } } -export class ArrayOfMutableColor { - objID: i32; +export class ArrayOfMutableColor extends wasmtypes.ScProxy { - constructor(objID: i32) { - this.objID = objID; - } + appendColor(): wasmtypes.ScMutableColor { + return new wasmtypes.ScMutableColor(this.proxy.append()); + } clear(): void { - wasmlib.clear(this.objID); + this.proxy.clearArray(); } length(): u32 { - return wasmlib.getLength(this.objID); + return this.proxy.length(); } - getColor(index: u32): wasmlib.ScMutableColor { - return new wasmlib.ScMutableColor(this.objID, new wasmlib.Key32(index as i32)); + getColor(index: u32): wasmtypes.ScMutableColor { + return new wasmtypes.ScMutableColor(this.proxy.index(index)); } } -export class MapColorToMutableToken { - objID: i32; - - constructor(objID: i32) { - this.objID = objID; - } +export class MapColorToMutableToken extends wasmtypes.ScProxy { clear(): void { - wasmlib.clear(this.objID); + this.proxy.clearMap(); } - getToken(key: wasmlib.ScColor): sc.MutableToken { - return new sc.MutableToken(this.objID, key.getKeyID()); + getToken(key: wasmtypes.ScColor): sc.MutableToken { + return new sc.MutableToken(this.proxy.key(wasmtypes.colorToBytes(key))); } } -export class MutableTokenRegistryState extends wasmlib.ScMapID { +export class MutableTokenRegistryState extends wasmtypes.ScProxy { asImmutable(): sc.ImmutableTokenRegistryState { - const imm = new sc.ImmutableTokenRegistryState(); - imm.mapID = this.mapID; - return imm; + return new sc.ImmutableTokenRegistryState(this.proxy); } colorList(): sc.ArrayOfMutableColor { - let arrID = wasmlib.getObjectID(this.mapID, wasmlib.Key32.fromString(sc.StateColorList), wasmlib.TYPE_ARRAY|wasmlib.TYPE_COLOR); - return new sc.ArrayOfMutableColor(arrID); + return new sc.ArrayOfMutableColor(this.proxy.root(sc.StateColorList)); } registry(): sc.MapColorToMutableToken { - let mapID = wasmlib.getObjectID(this.mapID, wasmlib.Key32.fromString(sc.StateRegistry), wasmlib.TYPE_MAP); - return new sc.MapColorToMutableToken(mapID); + return new sc.MapColorToMutableToken(this.proxy.root(sc.StateRegistry)); } } diff --git a/contracts/wasm/tokenregistry/ts/tokenregistry/structs.ts b/contracts/wasm/tokenregistry/ts/tokenregistry/structs.ts index ad32fbf939..2ed33dbcf4 100644 --- a/contracts/wasm/tokenregistry/ts/tokenregistry/structs.ts +++ b/contracts/wasm/tokenregistry/ts/tokenregistry/structs.ts @@ -6,83 +6,70 @@ // Change the json schema instead import * as wasmlib from "wasmlib"; +import * as wasmtypes from "wasmlib/wasmtypes"; export class Token { created : u64 = 0; // creation timestamp description : string = ""; // description what minted token represents - mintedBy : wasmlib.ScAgentID = new wasmlib.ScAgentID(); // original minter - owner : wasmlib.ScAgentID = new wasmlib.ScAgentID(); // current owner + mintedBy : wasmtypes.ScAgentID = wasmtypes.agentIDFromBytes(null); // original minter + owner : wasmtypes.ScAgentID = wasmtypes.agentIDFromBytes(null); // current owner supply : u64 = 0; // amount of tokens originally minted updated : u64 = 0; // last update timestamp userDefined : string = ""; // any user defined text - static fromBytes(bytes: u8[]): Token { - let decode = new wasmlib.BytesDecoder(bytes); - let data = new Token(); - data.created = decode.uint64(); - data.description = decode.string(); - data.mintedBy = decode.agentID(); - data.owner = decode.agentID(); - data.supply = decode.uint64(); - data.updated = decode.uint64(); - data.userDefined = decode.string(); - decode.close(); + static fromBytes(buf: u8[]|null): Token { + const dec = new wasmtypes.WasmDecoder(buf); + const data = new Token(); + data.created = wasmtypes.uint64Decode(dec); + data.description = wasmtypes.stringDecode(dec); + data.mintedBy = wasmtypes.agentIDDecode(dec); + data.owner = wasmtypes.agentIDDecode(dec); + data.supply = wasmtypes.uint64Decode(dec); + data.updated = wasmtypes.uint64Decode(dec); + data.userDefined = wasmtypes.stringDecode(dec); + dec.close(); return data; } bytes(): u8[] { - return new wasmlib.BytesEncoder(). - uint64(this.created). - string(this.description). - agentID(this.mintedBy). - agentID(this.owner). - uint64(this.supply). - uint64(this.updated). - string(this.userDefined). - data(); + const enc = new wasmtypes.WasmEncoder(); + wasmtypes.uint64Encode(enc, this.created); + wasmtypes.stringEncode(enc, this.description); + wasmtypes.agentIDEncode(enc, this.mintedBy); + wasmtypes.agentIDEncode(enc, this.owner); + wasmtypes.uint64Encode(enc, this.supply); + wasmtypes.uint64Encode(enc, this.updated); + wasmtypes.stringEncode(enc, this.userDefined); + return enc.buf(); } } -export class ImmutableToken { - objID: i32; - keyID: wasmlib.Key32; - - constructor(objID: i32, keyID: wasmlib.Key32) { - this.objID = objID; - this.keyID = keyID; - } +export class ImmutableToken extends wasmtypes.ScProxy { exists(): boolean { - return wasmlib.exists(this.objID, this.keyID, wasmlib.TYPE_BYTES); + return this.proxy.exists(); } value(): Token { - return Token.fromBytes(wasmlib.getBytes(this.objID, this.keyID, wasmlib.TYPE_BYTES)); + return Token.fromBytes(this.proxy.get()); } } -export class MutableToken { - objID: i32; - keyID: wasmlib.Key32; - - constructor(objID: i32, keyID: wasmlib.Key32) { - this.objID = objID; - this.keyID = keyID; - } +export class MutableToken extends wasmtypes.ScProxy { delete(): void { - wasmlib.delKey(this.objID, this.keyID, wasmlib.TYPE_BYTES); + this.proxy.delete(); } exists(): boolean { - return wasmlib.exists(this.objID, this.keyID, wasmlib.TYPE_BYTES); + return this.proxy.exists(); } setValue(value: Token): void { - wasmlib.setBytes(this.objID, this.keyID, wasmlib.TYPE_BYTES, value.bytes()); + this.proxy.set(value.bytes()); } value(): Token { - return Token.fromBytes(wasmlib.getBytes(this.objID, this.keyID, wasmlib.TYPE_BYTES)); + return Token.fromBytes(this.proxy.get()); } } diff --git a/contracts/wasm/tokenregistry/ts/tokenregistry/tokenregistry.ts b/contracts/wasm/tokenregistry/ts/tokenregistry/tokenregistry.ts index ab1cb2a2c2..d5cf15e697 100644 --- a/contracts/wasm/tokenregistry/ts/tokenregistry/tokenregistry.ts +++ b/contracts/wasm/tokenregistry/ts/tokenregistry/tokenregistry.ts @@ -7,8 +7,8 @@ import * as sc from "./index"; export function funcMintSupply(ctx: wasmlib.ScFuncContext, f: sc.MintSupplyContext): void { let minted = ctx.minted(); let mintedColors = minted.colors(); - ctx.require(mintedColors.length() == 1, "need single minted color"); - let mintedColor = mintedColors.getColor(0).value(); + ctx.require(mintedColors.length == 1, "need single minted color"); + let mintedColor = mintedColors[0]; let currentToken = f.state.registry().getToken(mintedColor); if (currentToken.exists()) { // should never happen, because transaction id is unique @@ -27,7 +27,7 @@ export function funcMintSupply(ctx: wasmlib.ScFuncContext, f: sc.MintSupplyConte } currentToken.setValue(token); let colorList = f.state.colorList(); - colorList.getColor(colorList.length()).setValue(mintedColor); + colorList.appendColor().setValue(mintedColor); } export function funcTransferOwnership(ctx: wasmlib.ScFuncContext, f: sc.TransferOwnershipContext): void { diff --git a/packages/wasmvm/wasmhost/wasmtosandboxtrace.go b/packages/wasmvm/wasmhost/wasmtosandboxtrace.go new file mode 100644 index 0000000000..fa52c0ccf1 --- /dev/null +++ b/packages/wasmvm/wasmhost/wasmtosandboxtrace.go @@ -0,0 +1,60 @@ +// Copyright 2020 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +package wasmhost + +import ( + "github.com/iotaledger/wasp/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes" +) + +// NOTE: These strings correspond to the Sandbox fnXxx constants in WasmLib +var sandboxFuncNames = []string{ + "nil", + "FnAccountID", + "#FnBalance", + "FnBalances", + "FnBlockContext", + "FnCall", + "FnCaller", + "FnChainID", + "FnChainOwnerID", + "FnContract", + "FnContractCreator", + "#FnDeployContract", + "FnEntropy", + "$FnEvent", + "FnIncomingTransfer", + "$FnLog", + "FnMinted", + "$FnPanic", + "FnParams", + "#FnPost", + "FnRequest", + "FnRequestID", + "#FnResults", + "#FnSend", + "#FnStateAnchor", + "FnTimestamp", + "$FnTrace", + "$FnUtilsBase58Decode", + "#FnUtilsBase58Encode", + "#FnUtilsBlsAddress", + "#FnUtilsBlsAggregate", + "#FnUtilsBlsValid", + "#FnUtilsEd25519Address", + "#FnUtilsEd25519Valid", + "#FnUtilsHashBlake2b", + "$FnUtilsHashName", + "#FnUtilsHashSha3", +} + +func traceSandbox(funcNr int32, params []byte) string { + name := sandboxFuncNames[-funcNr] + if name[0] == '$' { + return name[1:] + ", " + string(params) + } + if name[0] != '#' { + return name + } + return name[1:] + ", " + wasmtypes.Hex(params) +} diff --git a/packages/wasmvm/wasmhost/wasmtosandboxutils.go b/packages/wasmvm/wasmhost/wasmtosandboxutils.go index 98e6e1de49..c5dce35806 100644 --- a/packages/wasmvm/wasmhost/wasmtosandboxutils.go +++ b/packages/wasmvm/wasmhost/wasmtosandboxutils.go @@ -26,12 +26,12 @@ func (s WasmToSandbox) fnUtilsBlsAddress(args []byte) []byte { func (s WasmToSandbox) fnUtilsBlsAggregate(args []byte) []byte { dec := wasmtypes.NewWasmDecoder(args) - count := wasmtypes.DecodeUint32(dec) + count := wasmtypes.Uint32Decode(dec) pubKeysBin := make([][]byte, count) for i := uint32(0); i < count; i++ { pubKeysBin[i] = dec.Bytes() } - count = wasmtypes.DecodeUint32(dec) + count = wasmtypes.Uint32Decode(dec) sigsBin := make([][]byte, count) for i := uint32(0); i < count; i++ { sigsBin[i] = dec.Bytes() diff --git a/packages/wasmvm/wasmhost/wasmvm.go b/packages/wasmvm/wasmhost/wasmvm.go index 05b35a6499..06e39b2daf 100644 --- a/packages/wasmvm/wasmhost/wasmvm.go +++ b/packages/wasmvm/wasmhost/wasmvm.go @@ -10,6 +10,7 @@ import ( "time" "github.com/iotaledger/wasp/packages/wasmvm/wasmlib/go/wasmlib" + "github.com/iotaledger/wasp/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes" ) const ( @@ -35,9 +36,6 @@ var ( // HostTracing turns on debug tracing for ScHost calls HostTracing = false - // HostTracingAll turns on *all* debug tracing for ScHost calls - HostTracingAll = false - // WasmTimeout set this to non-zero for a one-time override of the defaultTimeout WasmTimeout = 0 * time.Second ) @@ -159,7 +157,9 @@ func (vm *WasmVMBase) HostStateGet(keyRef, keyLen, valRef, valLen int32) int32 { defer vm.catchPanicMessage() ctx := vm.getContext(0) - ctx.log().Debugf("HostStateGet(k(%d,%d),v(%d,s%d))", keyRef, keyLen, valRef, valLen) + if HostTracing { + vm.traceGet(ctx, keyRef, keyLen, valRef, valLen) + } // only check for existence ? if valLen < 0 { @@ -194,7 +194,9 @@ func (vm *WasmVMBase) HostStateSet(keyRef, keyLen, valRef, valLen int32) { defer vm.catchPanicMessage() ctx := vm.getContext(0) - ctx.log().Debugf("HostStateSet(k(%d,%d),v(%d,s%d))", keyRef, keyLen, valRef, valLen) + if HostTracing { + vm.traceSet(ctx, keyRef, keyLen, valRef, valLen) + } // export name? if keyRef == 0 { @@ -237,18 +239,18 @@ func (vm *WasmVMBase) LinkHost(impl WasmVM, host *WasmHost) error { } func (vm *WasmVMBase) Run(runner func() error) (err error) { - //defer func() { - // r := recover() - // if r == nil { - // return - // } - // // could be the wrong panic message due to a WasmTime bug, so we always - // // rethrow our intercepted first panic instead of WasmTime's last panic - // if vm.panicErr != nil { - // panic(vm.panicErr) - // } - // panic(r) - //}() + defer func() { + r := recover() + if r == nil { + return + } + // could be the wrong panic message due to a WasmTime bug, so we always + // rethrow our intercepted first panic instead of WasmTime's last panic + if vm.panicErr != nil { + panic(vm.panicErr) + } + panic(r) + }() if vm.timeoutStarted { // no need to wrap nested calls in timeout code @@ -310,3 +312,84 @@ func (vm *WasmVMBase) VMSetBytes(offset, size int32, bytes []byte) int32 { } return int32(len(bytes)) } + +func (vm *WasmVMBase) traceGet(ctx *WasmContext, keyRef, keyLen, valRef, valLen int32) { + // only check for existence ? + if valLen < 0 { + key := vm.impl.VMGetBytes(keyRef, keyLen) + ctx.log().Debugf("StateExists(%s) = %v", vm.traceKey(key), ctx.StateExists(key)) + return + } + + // get value for key request, or get cached result request (keyLen == 0) + if keyLen >= 0 { + if keyLen == 0 { + ctx.log().Debugf("=> %s", vm.traceVal(vm.result)) + return + } + // retrieve value associated with key + key := vm.impl.VMGetBytes(keyRef, keyLen) + ctx.log().Debugf("StateGet(%s)", vm.traceKey(key)) + return + } + + // sandbox func call request, keyLen is func nr + if keyLen == wasmlib.FnLog { + return + } + params := vm.impl.VMGetBytes(valRef, valLen) + ctx.log().Debugf("Sandbox(%s)", traceSandbox(keyLen, params)) +} + +func (vm *WasmVMBase) traceSet(ctx *WasmContext, keyRef, keyLen, valRef, valLen int32) { + // export name? + if keyRef == 0 { + name := string(vm.impl.VMGetBytes(valRef, valLen)) + ctx.log().Debugf("ExportName(%d, %s)", keyLen, name) + return + } + + key := vm.impl.VMGetBytes(keyRef, keyLen) + + // delete key ? + if valLen < 0 { + ctx.log().Debugf("StateDelete(%s)", vm.traceKey(key)) + return + } + + // set key + val := vm.impl.VMGetBytes(valRef, valLen) + ctx.log().Debugf("StateSet(%s, %s)", vm.traceKey(key), vm.traceVal(val)) +} + +func (vm *WasmVMBase) traceKey(key []byte) string { + name := "" + for i, b := range key { + if b == '.' { + return string(key[:i+1]) + wasmtypes.Hex(key[i+1:]) + } + if b == '#' { + name = string(key[:i+1]) + j := i + 1 + for ; (key[j] & 0x80) != 0; j++ { + } + dec := wasmtypes.NewWasmDecoder(key[i+1 : j+1]) + index := wasmtypes.Uint64Decode(dec) + name += wasmtypes.Uint64ToString(index) + if j+1 == len(key) { + return name + } + return name + "..." + wasmtypes.Hex(key[j+1:]) + } + } + return `"` + string(key) + `"` +} + +func (vm *WasmVMBase) traceVal(val []byte) string { + for _, b := range val { + if b < ' ' || b > '~' { + return wasmtypes.Hex(val) + } + } + return string(val) +} diff --git a/packages/wasmvm/wasmlib/go/wasmlib/assets.go b/packages/wasmvm/wasmlib/go/wasmlib/assets.go index 159c3af3c7..9084fbe9e9 100644 --- a/packages/wasmvm/wasmlib/go/wasmlib/assets.go +++ b/packages/wasmvm/wasmlib/go/wasmlib/assets.go @@ -19,7 +19,7 @@ func NewScAssetsFromBytes(buf []byte) ScAssets { size := wasmtypes.Uint32FromBytes(dec.FixedBytes(wasmtypes.ScUint32Length)) dict := make(ScAssets, size) for i := uint32(0); i < size; i++ { - color := wasmtypes.ColorFromBytes(dec.FixedBytes(wasmtypes.ScColorLength)) + color := wasmtypes.ColorDecode(dec) dict[color] = wasmtypes.Uint64FromBytes(dec.FixedBytes(wasmtypes.ScUint64Length)) } return dict @@ -34,10 +34,10 @@ func (a ScAssets) Bytes() []byte { return string(keys[i].Bytes()) < string(keys[j].Bytes()) }) enc := wasmtypes.NewWasmEncoder() - enc.FixedBytes(wasmtypes.BytesFromUint32(uint32(len(keys))), wasmtypes.ScUint32Length) + enc.FixedBytes(wasmtypes.Uint32ToBytes(uint32(len(keys))), wasmtypes.ScUint32Length) for _, color := range keys { - enc.FixedBytes(color.Bytes(), wasmtypes.ScColorLength) - enc.FixedBytes(wasmtypes.BytesFromUint64(a[color]), wasmtypes.ScUint64Length) + wasmtypes.ColorEncode(enc, color) + enc.FixedBytes(wasmtypes.Uint64ToBytes(a[color]), wasmtypes.ScUint64Length) } return enc.Buf() } @@ -73,7 +73,12 @@ func NewScTransfers() ScTransfers { // create a new transfers object from a balances object func NewScTransfersFromBalances(balances ScBalances) ScTransfers { - return ScTransfers(balances.assets) + transfer := NewScTransfers() + colors := balances.Colors() + for _, color := range colors { + transfer.Set(color, balances.Balance(color)) + } + return transfer } // create a new transfers object and initialize it with the specified amount of iotas @@ -83,8 +88,8 @@ func NewScTransferIotas(amount uint64) ScTransfers { // create a new transfers object and initialize it with the specified token transfer func NewScTransfer(color wasmtypes.ScColor, amount uint64) ScTransfers { - transfer := make(ScTransfers) - transfer[color] = amount + transfer := NewScTransfers() + transfer.Set(color, amount) return transfer } diff --git a/packages/wasmvm/wasmlib/go/wasmlib/context.go b/packages/wasmvm/wasmlib/go/wasmlib/context.go index 17c6c93c16..acb1297bf0 100644 --- a/packages/wasmvm/wasmlib/go/wasmlib/context.go +++ b/packages/wasmvm/wasmlib/go/wasmlib/context.go @@ -34,6 +34,7 @@ func (ctx ScFuncContext) Incoming() ScBalances { return ctx.IncomingTransfer() } +// TODO deprecated func (ctx ScFuncContext) TransferToAddress(address wasmtypes.ScAddress, transfer ScTransfers) { ctx.Send(address, transfer) } @@ -42,7 +43,7 @@ func (ctx ScFuncContext) TransferToAddress(address wasmtypes.ScAddress, transfer // smart contract view sandbox interface type ScViewContext struct { - ScSandbox + ScSandboxView } var _ ScViewCallContext = &ScViewContext{} diff --git a/packages/wasmvm/wasmlib/go/wasmlib/contract.go b/packages/wasmvm/wasmlib/go/wasmlib/contract.go index ee8273afed..22550eb2ac 100644 --- a/packages/wasmvm/wasmlib/go/wasmlib/contract.go +++ b/packages/wasmvm/wasmlib/go/wasmlib/contract.go @@ -22,7 +22,7 @@ type ScViewCallContext interface { type ScView struct { hContract wasmtypes.ScHname hFunction wasmtypes.ScHname - params ScDict + params *ScDict resultsProxy *wasmtypes.Proxy } @@ -36,7 +36,7 @@ func NewScView(ctx ScViewCallContext, hContract, hFunction wasmtypes.ScHname) *S func NewCallParamsProxy(v *ScView) wasmtypes.Proxy { v.params = NewScDict() - return wasmtypes.NewProxy(v.params) + return v.params.AsProxy() } func NewCallResultsProxy(v *ScView, resultsProxy *wasmtypes.Proxy) { @@ -110,7 +110,7 @@ func (f *ScInitFunc) OfContract(hContract wasmtypes.ScHname) *ScInitFunc { func (f *ScInitFunc) Params() []interface{} { var params []interface{} - for k, v := range f.params { + for k, v := range f.params.dict { params = append(params, k) params = append(params, v) } diff --git a/packages/wasmvm/wasmlib/go/wasmlib/coreaccounts/results.go b/packages/wasmvm/wasmlib/go/wasmlib/coreaccounts/results.go index 809f0a021f..4e147931f6 100644 --- a/packages/wasmvm/wasmlib/go/wasmlib/coreaccounts/results.go +++ b/packages/wasmvm/wasmlib/go/wasmlib/coreaccounts/results.go @@ -14,7 +14,7 @@ type MapAgentIDToImmutableBytes struct { } func (m MapAgentIDToImmutableBytes) GetBytes(key wasmtypes.ScAgentID) wasmtypes.ScImmutableBytes { - return wasmtypes.NewScImmutableBytes(m.proxy.Key(wasmtypes.BytesFromAgentID(key))) + return wasmtypes.NewScImmutableBytes(m.proxy.Key(wasmtypes.AgentIDToBytes(key))) } type ImmutableAccountsResults struct { @@ -35,7 +35,7 @@ func (m MapAgentIDToMutableBytes) Clear() { } func (m MapAgentIDToMutableBytes) GetBytes(key wasmtypes.ScAgentID) wasmtypes.ScMutableBytes { - return wasmtypes.NewScMutableBytes(m.proxy.Key(wasmtypes.BytesFromAgentID(key))) + return wasmtypes.NewScMutableBytes(m.proxy.Key(wasmtypes.AgentIDToBytes(key))) } type MutableAccountsResults struct { @@ -52,7 +52,7 @@ type MapColorToImmutableInt64 struct { } func (m MapColorToImmutableInt64) GetInt64(key wasmtypes.ScColor) wasmtypes.ScImmutableInt64 { - return wasmtypes.NewScImmutableInt64(m.proxy.Key(wasmtypes.BytesFromColor(key))) + return wasmtypes.NewScImmutableInt64(m.proxy.Key(wasmtypes.ColorToBytes(key))) } type ImmutableBalanceResults struct { @@ -73,7 +73,7 @@ func (m MapColorToMutableInt64) Clear() { } func (m MapColorToMutableInt64) GetInt64(key wasmtypes.ScColor) wasmtypes.ScMutableInt64 { - return wasmtypes.NewScMutableInt64(m.proxy.Key(wasmtypes.BytesFromColor(key))) + return wasmtypes.NewScMutableInt64(m.proxy.Key(wasmtypes.ColorToBytes(key))) } type MutableBalanceResults struct { diff --git a/packages/wasmvm/wasmlib/go/wasmlib/coreblob/params.go b/packages/wasmvm/wasmlib/go/wasmlib/coreblob/params.go index fa22049cbf..37414ca695 100644 --- a/packages/wasmvm/wasmlib/go/wasmlib/coreblob/params.go +++ b/packages/wasmvm/wasmlib/go/wasmlib/coreblob/params.go @@ -14,7 +14,7 @@ type MapStringToImmutableBytes struct { } func (m MapStringToImmutableBytes) GetBytes(key string) wasmtypes.ScImmutableBytes { - return wasmtypes.NewScImmutableBytes(m.proxy.Key(wasmtypes.BytesFromString(key))) + return wasmtypes.NewScImmutableBytes(m.proxy.Key(wasmtypes.StringToBytes(key))) } type ImmutableStoreBlobParams struct { @@ -35,7 +35,7 @@ func (m MapStringToMutableBytes) Clear() { } func (m MapStringToMutableBytes) GetBytes(key string) wasmtypes.ScMutableBytes { - return wasmtypes.NewScMutableBytes(m.proxy.Key(wasmtypes.BytesFromString(key))) + return wasmtypes.NewScMutableBytes(m.proxy.Key(wasmtypes.StringToBytes(key))) } type MutableStoreBlobParams struct { diff --git a/packages/wasmvm/wasmlib/go/wasmlib/coreblob/results.go b/packages/wasmvm/wasmlib/go/wasmlib/coreblob/results.go index e59c1a48b5..085521c318 100644 --- a/packages/wasmvm/wasmlib/go/wasmlib/coreblob/results.go +++ b/packages/wasmvm/wasmlib/go/wasmlib/coreblob/results.go @@ -46,7 +46,7 @@ type MapStringToImmutableInt32 struct { } func (m MapStringToImmutableInt32) GetInt32(key string) wasmtypes.ScImmutableInt32 { - return wasmtypes.NewScImmutableInt32(m.proxy.Key(wasmtypes.BytesFromString(key))) + return wasmtypes.NewScImmutableInt32(m.proxy.Key(wasmtypes.StringToBytes(key))) } type ImmutableGetBlobInfoResults struct { @@ -67,7 +67,7 @@ func (m MapStringToMutableInt32) Clear() { } func (m MapStringToMutableInt32) GetInt32(key string) wasmtypes.ScMutableInt32 { - return wasmtypes.NewScMutableInt32(m.proxy.Key(wasmtypes.BytesFromString(key))) + return wasmtypes.NewScMutableInt32(m.proxy.Key(wasmtypes.StringToBytes(key))) } type MutableGetBlobInfoResults struct { @@ -84,7 +84,7 @@ type MapHashToImmutableInt32 struct { } func (m MapHashToImmutableInt32) GetInt32(key wasmtypes.ScHash) wasmtypes.ScImmutableInt32 { - return wasmtypes.NewScImmutableInt32(m.proxy.Key(wasmtypes.BytesFromHash(key))) + return wasmtypes.NewScImmutableInt32(m.proxy.Key(wasmtypes.HashToBytes(key))) } type ImmutableListBlobsResults struct { @@ -105,7 +105,7 @@ func (m MapHashToMutableInt32) Clear() { } func (m MapHashToMutableInt32) GetInt32(key wasmtypes.ScHash) wasmtypes.ScMutableInt32 { - return wasmtypes.NewScMutableInt32(m.proxy.Key(wasmtypes.BytesFromHash(key))) + return wasmtypes.NewScMutableInt32(m.proxy.Key(wasmtypes.HashToBytes(key))) } type MutableListBlobsResults struct { diff --git a/packages/wasmvm/wasmlib/go/wasmlib/coreroot/results.go b/packages/wasmvm/wasmlib/go/wasmlib/coreroot/results.go index 7aeb190d2d..6b33a97de4 100644 --- a/packages/wasmvm/wasmlib/go/wasmlib/coreroot/results.go +++ b/packages/wasmvm/wasmlib/go/wasmlib/coreroot/results.go @@ -38,7 +38,7 @@ type MapHnameToImmutableBytes struct { } func (m MapHnameToImmutableBytes) GetBytes(key wasmtypes.ScHname) wasmtypes.ScImmutableBytes { - return wasmtypes.NewScImmutableBytes(m.proxy.Key(wasmtypes.BytesFromHname(key))) + return wasmtypes.NewScImmutableBytes(m.proxy.Key(wasmtypes.HnameToBytes(key))) } type ImmutableGetContractRecordsResults struct { @@ -58,7 +58,7 @@ func (m MapHnameToMutableBytes) Clear() { } func (m MapHnameToMutableBytes) GetBytes(key wasmtypes.ScHname) wasmtypes.ScMutableBytes { - return wasmtypes.NewScMutableBytes(m.proxy.Key(wasmtypes.BytesFromHname(key))) + return wasmtypes.NewScMutableBytes(m.proxy.Key(wasmtypes.HnameToBytes(key))) } type MutableGetContractRecordsResults struct { diff --git a/packages/wasmvm/wasmlib/go/wasmlib/dict.go b/packages/wasmvm/wasmlib/go/wasmlib/dict.go index 7507fe348e..4856b2eafe 100644 --- a/packages/wasmvm/wasmlib/go/wasmlib/dict.go +++ b/packages/wasmvm/wasmlib/go/wasmlib/dict.go @@ -9,21 +9,35 @@ import ( "github.com/iotaledger/wasp/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes" ) -type ScDict map[string][]byte +type ScImmutableDict struct { + dict map[string][]byte +} + +func (d *ScImmutableDict) Exists(key []byte) bool { + return d.dict[string(key)] != nil +} + +func (d *ScImmutableDict) Get(key []byte) []byte { + return d.dict[string(key)] +} + +type ScDict struct { + ScImmutableDict +} -var _ wasmtypes.IKvStore = ScDict{} +var _ wasmtypes.IKvStore = new(ScDict) -func NewScDict() ScDict { - return make(ScDict) +func NewScDict() *ScDict { + return &ScDict{ScImmutableDict{dict: make(map[string][]byte)}} } -func NewScDictFromBytes(buf []byte) ScDict { +func NewScDictFromBytes(buf []byte) *ScDict { if len(buf) == 0 { - return make(ScDict) + return NewScDict() } dec := wasmtypes.NewWasmDecoder(buf) size := wasmtypes.Uint32FromBytes(dec.FixedBytes(wasmtypes.ScUint32Length)) - dict := make(ScDict, size) + dict := NewScDict() for i := uint32(0); i < size; i++ { keyLen := wasmtypes.Uint16FromBytes(dec.FixedBytes(wasmtypes.ScUint16Length)) key := dec.FixedBytes(uint32(keyLen)) @@ -34,59 +48,42 @@ func NewScDictFromBytes(buf []byte) ScDict { return dict } -func (d ScDict) AsProxy() wasmtypes.Proxy { +func (d *ScDict) AsProxy() wasmtypes.Proxy { return wasmtypes.NewProxy(d) } -func (d ScDict) Bytes() []byte { - keys := make([]string, 0, len(d)) - for key := range d { +func (d *ScDict) Bytes() []byte { + if d == nil { + return []byte{0, 0, 0, 0} + } + keys := make([]string, 0, len(d.dict)) + for key := range d.dict { keys = append(keys, key) } sort.Slice(keys, func(i, j int) bool { return keys[i] < keys[j] }) enc := wasmtypes.NewWasmEncoder() - enc.FixedBytes(wasmtypes.BytesFromUint32(uint32(len(keys))), wasmtypes.ScUint32Length) + enc.FixedBytes(wasmtypes.Uint32ToBytes(uint32(len(keys))), wasmtypes.ScUint32Length) for _, k := range keys { key := []byte(k) - val := d[k] - enc.FixedBytes(wasmtypes.BytesFromUint16(uint16(len(key))), wasmtypes.ScUint16Length) + val := d.dict[k] + enc.FixedBytes(wasmtypes.Uint16ToBytes(uint16(len(key))), wasmtypes.ScUint16Length) enc.FixedBytes(key, uint32(len(key))) - enc.FixedBytes(wasmtypes.BytesFromUint32(uint32(len(val))), wasmtypes.ScUint32Length) + enc.FixedBytes(wasmtypes.Uint32ToBytes(uint32(len(val))), wasmtypes.ScUint32Length) enc.FixedBytes(val, uint32(len(val))) } return enc.Buf() } -func (d ScDict) Delete(key []byte) { - delete(d, string(key)) -} - -func (d ScDict) Exists(key []byte) bool { - return d[string(key)] != nil -} - -func (d ScDict) Get(key []byte) []byte { - return d[string(key)] -} - -func (d ScDict) Set(key, value []byte) { - d[string(key)] = value -} - -func (d ScDict) Immutable() ScImmutableDict { - return ScImmutableDict{d: d} -} - -type ScImmutableDict struct { - d ScDict +func (d *ScDict) Delete(key []byte) { + delete(d.dict, string(key)) } -func (d ScImmutableDict) Exists(key []byte) bool { - return d.d.Exists(key) +func (d *ScDict) Immutable() *ScImmutableDict { + return &d.ScImmutableDict } -func (d ScImmutableDict) Get(key []byte) []byte { - return d.d.Get(key) +func (d *ScDict) Set(key, value []byte) { + d.dict[string(key)] = value } diff --git a/packages/wasmvm/wasmlib/go/wasmlib/host.go b/packages/wasmvm/wasmlib/go/wasmlib/host.go index b28e972c8e..4bfdeaba12 100644 --- a/packages/wasmvm/wasmlib/go/wasmlib/host.go +++ b/packages/wasmvm/wasmlib/go/wasmlib/host.go @@ -37,14 +37,6 @@ func ConnectHost(h ScHost) ScHost { return oldHost } -func Log(text string) { - host.Sandbox(FnLog, []byte(text)) -} - -func Panic(text string) { - host.Sandbox(FnPanic, []byte(text)) -} - func ExportName(index int32, name string) { host.ExportName(index, name) } diff --git a/packages/wasmvm/wasmlib/go/wasmlib/sandbox.go b/packages/wasmvm/wasmlib/go/wasmlib/sandbox.go index 6140219e78..2670edee53 100644 --- a/packages/wasmvm/wasmlib/go/wasmlib/sandbox.go +++ b/packages/wasmvm/wasmlib/go/wasmlib/sandbox.go @@ -4,8 +4,6 @@ package wasmlib import ( - "encoding/binary" - "github.com/iotaledger/wasp/packages/wasmvm/wasmlib/go/wasmlib/wasmrequests" "github.com/iotaledger/wasp/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes" ) @@ -53,6 +51,14 @@ type ScSandbox struct{} // TODO go over core contract schemas to set correct unsigned types +func Log(text string) { + ScSandbox{}.Log(text) +} + +func Panic(text string) { + ScSandbox{}.Panic(text) +} + func NewParamsProxy() wasmtypes.Proxy { return wasmtypes.NewProxy(NewScDictFromBytes(Sandbox(FnParams, nil))) } @@ -71,13 +77,11 @@ func (s ScSandbox) Balances() ScBalances { return NewScAssetsFromBytes(Sandbox(FnBalances, nil)).Balances() } -// calls a smart contract view -func (s ScSandbox) Call(hContract, hFunction wasmtypes.ScHname, params ScDict) ScImmutableDict { - return s.call(hContract, hFunction, params, nil) -} - // calls a smart contract function -func (s ScSandbox) call(hContract, hFunction wasmtypes.ScHname, params ScDict, transfer ScTransfers) ScImmutableDict { +func (s ScSandbox) call(hContract, hFunction wasmtypes.ScHname, params *ScDict, transfer ScTransfers) *ScImmutableDict { + if params == nil { + params = NewScDict() + } req := &wasmrequests.CallRequest{ Contract: hContract, Function: hFunction, @@ -119,7 +123,7 @@ func (s ScSandbox) Panic(text string) { } // retrieve parameters passed to the smart contract function that was called -func (s ScSandbox) Params() ScImmutableDict { +func (s ScSandbox) Params() *ScImmutableDict { return NewScDictFromBytes(Sandbox(FnParams, nil)).Immutable() } @@ -134,7 +138,10 @@ func (s ScSandbox) Require(cond bool, msg string) { } } -func (s ScSandbox) Results(results ScDict) { +func (s ScSandbox) Results(results *ScDict) { + if results == nil { + results = NewScDict() + } Sandbox(FnResults, results.Bytes()) } @@ -153,6 +160,15 @@ func (s ScSandbox) Utility() ScSandboxUtils { return ScSandboxUtils{} } +type ScSandboxView struct { + ScSandbox +} + +// calls a smart contract view +func (s ScSandboxView) Call(hContract, hFunction wasmtypes.ScHname, params *ScDict) *ScImmutableDict { + return s.call(hContract, hFunction, params, nil) +} + type ScSandboxFunc struct { ScSandbox } @@ -162,7 +178,7 @@ type ScSandboxFunc struct { //} // calls a smart contract function -func (s ScSandboxFunc) Call(hContract, hFunction wasmtypes.ScHname, params ScDict, transfer ScTransfers) ScImmutableDict { +func (s ScSandboxFunc) Call(hContract, hFunction wasmtypes.ScHname, params *ScDict, transfer ScTransfers) *ScImmutableDict { return s.call(hContract, hFunction, params, transfer) } @@ -172,7 +188,10 @@ func (s ScSandboxFunc) Caller() wasmtypes.ScAgentID { } // deploys a smart contract -func (s ScSandboxFunc) DeployContract(programHash wasmtypes.ScHash, name, description string, initParams ScDict) { +func (s ScSandboxFunc) DeployContract(programHash wasmtypes.ScHash, name, description string, initParams *ScDict) { + if initParams == nil { + initParams = NewScDict() + } req := &wasmrequests.DeployRequest{ ProgHash: programHash, Name: name, @@ -204,7 +223,10 @@ func (s ScSandboxFunc) Minted() ScBalances { } // (delayed) posts a smart contract function request -func (s ScSandboxFunc) Post(chainID wasmtypes.ScChainID, hContract, hFunction wasmtypes.ScHname, params ScDict, transfer ScTransfers, delay uint32) { +func (s ScSandboxFunc) Post(chainID wasmtypes.ScChainID, hContract, hFunction wasmtypes.ScHname, params *ScDict, transfer ScTransfers, delay uint32) { + if params == nil { + params = NewScDict() + } if len(transfer) == 0 { s.Panic("missing transfer") } @@ -241,9 +263,9 @@ func (s ScSandboxFunc) Random(max uint64) (rnd uint64) { entropy = s.Utility().HashBlake2b(entropy).Bytes() offset = 0 } - rnd = binary.LittleEndian.Uint64(entropy[offset:offset+8]) % max + rnd = wasmtypes.Uint64FromBytes(entropy[offset:offset+8]) % max offset += 8 - return + return rnd } func (s ScSandboxFunc) RawState() ScState { diff --git a/packages/wasmvm/wasmlib/go/wasmlib/sandboxutils.go b/packages/wasmvm/wasmlib/go/wasmlib/sandboxutils.go index 2416a74e90..291acf9a1c 100644 --- a/packages/wasmvm/wasmlib/go/wasmlib/sandboxutils.go +++ b/packages/wasmvm/wasmlib/go/wasmlib/sandboxutils.go @@ -25,11 +25,11 @@ func (u ScSandboxUtils) BlsAddressFromPubKey(pubKey []byte) wasmtypes.ScAddress func (u ScSandboxUtils) BlsAggregateSignatures(pubKeys, sigs [][]byte) ([]byte, []byte) { enc := wasmtypes.NewWasmEncoder() - wasmtypes.EncodeUint32(enc, uint32(len(pubKeys))) + wasmtypes.Uint32Encode(enc, uint32(len(pubKeys))) for _, pubKey := range pubKeys { enc.Bytes(pubKey) } - wasmtypes.EncodeUint32(enc, uint32(len(sigs))) + wasmtypes.Uint32Encode(enc, uint32(len(sigs))) for _, sig := range sigs { enc.Bytes(sig) } diff --git a/packages/wasmvm/wasmlib/go/wasmlib/wasmrequests/structs.go b/packages/wasmvm/wasmlib/go/wasmlib/wasmrequests/structs.go index 7011c7d638..9ed3019507 100644 --- a/packages/wasmvm/wasmlib/go/wasmlib/wasmrequests/structs.go +++ b/packages/wasmvm/wasmlib/go/wasmlib/wasmrequests/structs.go @@ -19,20 +19,20 @@ type CallRequest struct { func NewCallRequestFromBytes(buf []byte) *CallRequest { dec := wasmtypes.NewWasmDecoder(buf) data := &CallRequest{} - data.Contract = wasmtypes.DecodeHname(dec) - data.Function = wasmtypes.DecodeHname(dec) - data.Params = wasmtypes.DecodeBytes(dec) - data.Transfer = wasmtypes.DecodeBytes(dec) + data.Contract = wasmtypes.HnameDecode(dec) + data.Function = wasmtypes.HnameDecode(dec) + data.Params = wasmtypes.BytesDecode(dec) + data.Transfer = wasmtypes.BytesDecode(dec) dec.Close() return data } func (o *CallRequest) Bytes() []byte { enc := wasmtypes.NewWasmEncoder() - wasmtypes.EncodeHname(enc, o.Contract) - wasmtypes.EncodeHname(enc, o.Function) - wasmtypes.EncodeBytes(enc, o.Params) - wasmtypes.EncodeBytes(enc, o.Transfer) + wasmtypes.HnameEncode(enc, o.Contract) + wasmtypes.HnameEncode(enc, o.Function) + wasmtypes.BytesEncode(enc, o.Params) + wasmtypes.BytesEncode(enc, o.Transfer) return enc.Buf() } @@ -78,20 +78,20 @@ type DeployRequest struct { func NewDeployRequestFromBytes(buf []byte) *DeployRequest { dec := wasmtypes.NewWasmDecoder(buf) data := &DeployRequest{} - data.Description = wasmtypes.DecodeString(dec) - data.Name = wasmtypes.DecodeString(dec) - data.Params = wasmtypes.DecodeBytes(dec) - data.ProgHash = wasmtypes.DecodeHash(dec) + data.Description = wasmtypes.StringDecode(dec) + data.Name = wasmtypes.StringDecode(dec) + data.Params = wasmtypes.BytesDecode(dec) + data.ProgHash = wasmtypes.HashDecode(dec) dec.Close() return data } func (o *DeployRequest) Bytes() []byte { enc := wasmtypes.NewWasmEncoder() - wasmtypes.EncodeString(enc, o.Description) - wasmtypes.EncodeString(enc, o.Name) - wasmtypes.EncodeBytes(enc, o.Params) - wasmtypes.EncodeHash(enc, o.ProgHash) + wasmtypes.StringEncode(enc, o.Description) + wasmtypes.StringEncode(enc, o.Name) + wasmtypes.BytesEncode(enc, o.Params) + wasmtypes.HashEncode(enc, o.ProgHash) return enc.Buf() } @@ -139,24 +139,24 @@ type PostRequest struct { func NewPostRequestFromBytes(buf []byte) *PostRequest { dec := wasmtypes.NewWasmDecoder(buf) data := &PostRequest{} - data.ChainID = wasmtypes.DecodeChainID(dec) - data.Contract = wasmtypes.DecodeHname(dec) - data.Delay = wasmtypes.DecodeUint32(dec) - data.Function = wasmtypes.DecodeHname(dec) - data.Params = wasmtypes.DecodeBytes(dec) - data.Transfer = wasmtypes.DecodeBytes(dec) + data.ChainID = wasmtypes.ChainIDDecode(dec) + data.Contract = wasmtypes.HnameDecode(dec) + data.Delay = wasmtypes.Uint32Decode(dec) + data.Function = wasmtypes.HnameDecode(dec) + data.Params = wasmtypes.BytesDecode(dec) + data.Transfer = wasmtypes.BytesDecode(dec) dec.Close() return data } func (o *PostRequest) Bytes() []byte { enc := wasmtypes.NewWasmEncoder() - wasmtypes.EncodeChainID(enc, o.ChainID) - wasmtypes.EncodeHname(enc, o.Contract) - wasmtypes.EncodeUint32(enc, o.Delay) - wasmtypes.EncodeHname(enc, o.Function) - wasmtypes.EncodeBytes(enc, o.Params) - wasmtypes.EncodeBytes(enc, o.Transfer) + wasmtypes.ChainIDEncode(enc, o.ChainID) + wasmtypes.HnameEncode(enc, o.Contract) + wasmtypes.Uint32Encode(enc, o.Delay) + wasmtypes.HnameEncode(enc, o.Function) + wasmtypes.BytesEncode(enc, o.Params) + wasmtypes.BytesEncode(enc, o.Transfer) return enc.Buf() } @@ -200,16 +200,16 @@ type SendRequest struct { func NewSendRequestFromBytes(buf []byte) *SendRequest { dec := wasmtypes.NewWasmDecoder(buf) data := &SendRequest{} - data.Address = wasmtypes.DecodeAddress(dec) - data.Transfer = wasmtypes.DecodeBytes(dec) + data.Address = wasmtypes.AddressDecode(dec) + data.Transfer = wasmtypes.BytesDecode(dec) dec.Close() return data } func (o *SendRequest) Bytes() []byte { enc := wasmtypes.NewWasmEncoder() - wasmtypes.EncodeAddress(enc, o.Address) - wasmtypes.EncodeBytes(enc, o.Transfer) + wasmtypes.AddressEncode(enc, o.Address) + wasmtypes.BytesEncode(enc, o.Transfer) return enc.Buf() } diff --git a/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/codec.go b/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/codec.go index d11a5efa47..c23daa9131 100644 --- a/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/codec.go +++ b/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/codec.go @@ -5,6 +5,7 @@ package wasmtypes // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ +// WasmDecoder decodes separate entities from a byte buffer type WasmDecoder struct { buf []byte } @@ -14,11 +15,12 @@ func NewWasmDecoder(buf []byte) *WasmDecoder { } func (d *WasmDecoder) abort(msg string) { - // make sure deferred Close() will not trigger another panic + // make sure a deferred Close() will not trigger another panic d.buf = nil panic(msg) } +// Byte decodes the next byte from the byte buffer func (d *WasmDecoder) Byte() byte { if len(d.buf) == 0 { d.abort("insufficient bytes") @@ -28,17 +30,20 @@ func (d *WasmDecoder) Byte() byte { return value } +// Bytes decodes the next variable sized slice of bytes from the byte buffer func (d *WasmDecoder) Bytes() []byte { length := uint32(d.VluDecode(32)) return d.FixedBytes(length) } +// Close finalizes decoding by panicking if any bytes remain in the byte buffer func (d *WasmDecoder) Close() { if len(d.buf) != 0 { d.abort("extra bytes") } } +// FixedBytes decodes the next fixed size slice of bytes from the byte buffer func (d *WasmDecoder) FixedBytes(size uint32) []byte { if uint32(len(d.buf)) < size { d.abort("insufficient bytes") @@ -48,13 +53,13 @@ func (d *WasmDecoder) FixedBytes(size uint32) []byte { return value } -// VliDecode: Variable Length Integer decoder -func (d *WasmDecoder) VliDecode(bits int) (value int64) { +// VliDecode: Variable Length Integer decoder, uses modified LEB128 +func (d *WasmDecoder) VliDecode(bits int) int64 { b := d.Byte() sign := b & 0x40 // first group of 6 bits - value = int64(b & 0x3f) + value := int64(b & 0x3f) s := 6 // while continuation bit is set @@ -77,7 +82,7 @@ func (d *WasmDecoder) VliDecode(bits int) (value int64) { return value | (int64(-1) << s) } -// VluDecode: Variable Length Unsigned decoder +// VluDecode: Variable Length Unsigned decoder, uses ULEB128 func (d *WasmDecoder) VluDecode(bits int) uint64 { // first group of 7 bits b := d.Byte() @@ -99,6 +104,7 @@ func (d *WasmDecoder) VluDecode(bits int) uint64 { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ +// WasmEncoder encodes separate entities into a byte buffer type WasmEncoder struct { buf []byte } @@ -107,15 +113,18 @@ func NewWasmEncoder() *WasmEncoder { return &WasmEncoder{buf: make([]byte, 0, 128)} } +// Buf retrieves the encoded byte buffer func (e *WasmEncoder) Buf() []byte { return e.buf } +// Byte encodes a single byte into the byte buffer func (e *WasmEncoder) Byte(value uint8) *WasmEncoder { e.buf = append(e.buf, value) return e } +// Bytes encodes a variable sized slice of bytes into the byte buffer func (e *WasmEncoder) Bytes(value []byte) *WasmEncoder { length := len(value) e.VluEncode(uint64(length)) @@ -123,26 +132,29 @@ func (e *WasmEncoder) Bytes(value []byte) *WasmEncoder { return e } +// FixedBytes encodes a fixed size slice of bytes into the byte buffer func (e *WasmEncoder) FixedBytes(value []byte, length uint32) *WasmEncoder { - if len(value) != int(length) { + if uint32(len(value)) != length { panic("invalid fixed bytes length") } e.buf = append(e.buf, value...) return e } -// vli (variable length integer) encoder +// VliEncode Variable Length Integer encoder, uses modified LEB128 func (e *WasmEncoder) VliEncode(value int64) *WasmEncoder { - // first group of 6 bits - // 1st byte encodes 0 as positive in bit 6 + // bit 7 is always continuation bit + + // first group: 6 bits of data plus sign bit + // bit 6 encodes 0 as positive and 1 as negative b := byte(value) & 0x3f value >>= 6 finalValue := int64(0) if value < 0 { - // encode negative value // 1st byte encodes 1 as negative in bit 6 b |= 0x40 + // negative value, start with all high bits set to 1 finalValue = -1 } @@ -151,19 +163,21 @@ func (e *WasmEncoder) VliEncode(value int64) *WasmEncoder { // emit with continuation bit e.buf = append(e.buf, b|0x80) - // next group of 7 bits + // next group of 7 data bits b = byte(value) & 0x7f value >>= 7 } - // emit without continuation bit + // emit without continuation bit to signal end e.buf = append(e.buf, b) return e } -// vlu (variable length unsigned) encoder +// VluEncode Variable Length Unsigned encoder, uses ULEB128 func (e *WasmEncoder) VluEncode(value uint64) *WasmEncoder { - // first group of 7 bits + // bit 7 is always continuation bit + + // first group of 7 data bits b := byte(value) value >>= 7 @@ -172,34 +186,32 @@ func (e *WasmEncoder) VluEncode(value uint64) *WasmEncoder { // emit with continuation bit e.buf = append(e.buf, b|0x80) - // next group of 7 bits + // next group of 7 data bits b = byte(value) value >>= 7 } - // emit without continuation bit + // emit without continuation bit to signal end e.buf = append(e.buf, b) return e } // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -// wrapper for simplified use by hashtypes +// base58Encode wrapper for simplified use by hashtypes func base58Encode(buf []byte) string { // TODO // return string(wasmlib.Sandbox(wasmstore.FnUtilsBase58Encode, buf)) - return hex(buf) + return Hex(buf) } -func hex(buf []byte) string { +// hex returns a hex string representing the byte buffer +func Hex(buf []byte) string { const hexa = "0123456789abcdef" - digits := len(buf) * 2 - res := make([]byte, digits) - for _, b := range buf { - digits-- - res[digits] = hexa[b&0x0f] - digits-- - res[digits] = hexa[b>>4] + res := make([]byte, len(buf)*2) + for i, b := range buf { + res[i*2] = hexa[b>>4] + res[i*2+1] = hexa[b&0x0f] } return string(res) } diff --git a/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/proxy.go b/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/proxy.go index 55bbac4317..156e4c2c3a 100644 --- a/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/proxy.go +++ b/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/proxy.go @@ -3,6 +3,8 @@ package wasmtypes +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + type IKvStore interface { Delete(key []byte) Exists(key []byte) bool @@ -61,7 +63,7 @@ func (p Proxy) Delete() { func (p Proxy) element(index uint32) Proxy { enc := p.Encoder() - EncodeUint32(enc, index) + Uint32Encode(enc, index) return p.sub('#', enc.Buf()) } @@ -76,7 +78,7 @@ func (p Proxy) Exists() bool { func (p Proxy) Expand(length uint32) { // update the length counter enc := p.Encoder() - EncodeUint32(enc, length) + Uint32Encode(enc, length) p.Set(enc.Buf()) } @@ -86,7 +88,11 @@ func (p Proxy) Get() []byte { // Index gets a Proxy for an element of an Array by its index func (p Proxy) Index(index uint32) Proxy { - if index >= p.Length() { + size := p.Length() + if index >= size { + if index == size { + panic("invalid index: use append") + } panic("invalid index") } return p.element(index) @@ -105,7 +111,7 @@ func (p Proxy) Length() uint32 { if buf == nil { return 0 } - return DecodeUint32(p.decoder(buf)) + return Uint32Decode(p.decoder(buf)) } // Root returns a Proxy for an element of a root container (Params/Results/State). diff --git a/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/address.go b/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/scaddress.go similarity index 75% rename from packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/address.go rename to packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/scaddress.go index c5a80e9fd0..e7a30b8bdc 100644 --- a/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/address.go +++ b/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/scaddress.go @@ -3,39 +3,34 @@ package wasmtypes +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + const ScAddressLength = 33 type ScAddress struct { id [ScAddressLength]byte } -func addressFromBytes(buf []byte) ScAddress { - o := ScAddress{} - copy(o.id[:], buf) - return o -} - func (o ScAddress) AsAgentID() ScAgentID { // agentID for address has Hname zero return NewScAgentID(o, 0) } func (o ScAddress) Bytes() []byte { - return o.id[:] + return AddressToBytes(o) } func (o ScAddress) String() string { - // TODO standardize human readable string - return base58Encode(o.id[:]) + return AddressToString(o) } // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -func DecodeAddress(dec *WasmDecoder) ScAddress { - return addressFromBytes(dec.FixedBytes(ScAddressLength)) +func AddressDecode(dec *WasmDecoder) ScAddress { + return addressFromBytesUnchecked(dec.FixedBytes(ScAddressLength)) } -func EncodeAddress(enc *WasmEncoder, value ScAddress) { +func AddressEncode(enc *WasmEncoder, value ScAddress) { enc.FixedBytes(value.Bytes(), ScAddressLength) } @@ -50,15 +45,22 @@ func AddressFromBytes(buf []byte) ScAddress { if buf[0] > 2 { panic("invalid Address: address type > 2") } - return addressFromBytes(buf) + return addressFromBytesUnchecked(buf) } -func BytesFromAddress(value ScAddress) []byte { - return value.Bytes() +func AddressToBytes(value ScAddress) []byte { + return value.id[:] } func AddressToString(value ScAddress) string { - return value.String() + // TODO standardize human readable string + return base58Encode(value.id[:]) +} + +func addressFromBytesUnchecked(buf []byte) ScAddress { + o := ScAddress{} + copy(o.id[:], buf) + return o } // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ @@ -76,7 +78,7 @@ func (o ScImmutableAddress) Exists() bool { } func (o ScImmutableAddress) String() string { - return o.Value().String() + return AddressToString(o.Value()) } func (o ScImmutableAddress) Value() ScAddress { @@ -98,5 +100,5 @@ func (o ScMutableAddress) Delete() { } func (o ScMutableAddress) SetValue(value ScAddress) { - o.proxy.Set(value.Bytes()) + o.proxy.Set(AddressToBytes(value)) } diff --git a/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/agentid.go b/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/scagentid.go similarity index 75% rename from packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/agentid.go rename to packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/scagentid.go index cf0eea2f65..f1b65c1c1a 100644 --- a/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/agentid.go +++ b/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/scagentid.go @@ -3,6 +3,8 @@ package wasmtypes +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + const ScAgentIDLength = ScAddressLength + ScHnameLength type ScAgentID struct { @@ -14,21 +16,12 @@ func NewScAgentID(address ScAddress, hname ScHname) ScAgentID { return ScAgentID{address: address, hname: hname} } -func agentIDFromBytes(buf []byte) ScAgentID { - return ScAgentID{ - address: AddressFromBytes(buf[:ScAddressLength]), - hname: HnameFromBytes(buf[ScAddressLength:]), - } -} - func (o ScAgentID) Address() ScAddress { return o.address } func (o ScAgentID) Bytes() []byte { - enc := NewWasmEncoder() - EncodeAgentID(enc, o) - return enc.Buf() + return AgentIDToBytes(o) } func (o ScAgentID) Hname() ScHname { @@ -40,19 +33,18 @@ func (o ScAgentID) IsAddress() bool { } func (o ScAgentID) String() string { - // TODO standardize human readable string - return o.address.String() + "::" + o.hname.String() + return AgentIDToString(o) } // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -func DecodeAgentID(dec *WasmDecoder) ScAgentID { - return agentIDFromBytes(dec.FixedBytes(ScAgentIDLength)) +func AgentIDDecode(dec *WasmDecoder) ScAgentID { + return agentIDFromBytesUnchecked(dec.FixedBytes(ScAgentIDLength)) } -func EncodeAgentID(enc *WasmEncoder, value ScAgentID) { - EncodeAddress(enc, value.address) - EncodeHname(enc, value.hname) +func AgentIDEncode(enc *WasmEncoder, value ScAgentID) { + AddressEncode(enc, value.address) + HnameEncode(enc, value.hname) } func AgentIDFromBytes(buf []byte) ScAgentID { @@ -66,15 +58,25 @@ func AgentIDFromBytes(buf []byte) ScAgentID { if buf[0] > 2 { panic("invalid AgentID: address type > 2") } - return agentIDFromBytes(buf) + return agentIDFromBytesUnchecked(buf) } -func BytesFromAgentID(value ScAgentID) []byte { - return value.Bytes() +func AgentIDToBytes(value ScAgentID) []byte { + enc := NewWasmEncoder() + AgentIDEncode(enc, value) + return enc.Buf() } func AgentIDToString(value ScAgentID) string { - return value.String() + // TODO standardize human readable string + return value.address.String() + "::" + value.hname.String() +} + +func agentIDFromBytesUnchecked(buf []byte) ScAgentID { + return ScAgentID{ + address: AddressFromBytes(buf[:ScAddressLength]), + hname: HnameFromBytes(buf[ScAddressLength:]), + } } // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ @@ -92,7 +94,7 @@ func (o ScImmutableAgentID) Exists() bool { } func (o ScImmutableAgentID) String() string { - return o.Value().String() + return AgentIDToString(o.Value()) } func (o ScImmutableAgentID) Value() ScAgentID { @@ -114,5 +116,5 @@ func (o ScMutableAgentID) Delete() { } func (o ScMutableAgentID) SetValue(value ScAgentID) { - o.proxy.Set(value.Bytes()) + o.proxy.Set(AgentIDToBytes(value)) } diff --git a/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/bool.go b/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/scbool.go similarity index 75% rename from packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/bool.go rename to packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/scbool.go index 401c196fab..8641a32d99 100644 --- a/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/bool.go +++ b/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/scbool.go @@ -3,41 +3,47 @@ package wasmtypes +const ( + ScBoolLength = 1 + ScBoolFalse = 0x00 + ScBoolTrue = 0xff +) + // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -func DecodeBool(dec *WasmDecoder) bool { +func BoolDecode(dec *WasmDecoder) bool { return dec.Byte() != 0 } -func EncodeBool(enc *WasmEncoder, value bool) { +func BoolEncode(enc *WasmEncoder, value bool) { if value { - enc.Byte(1) + enc.Byte(ScBoolTrue) return } - enc.Byte(0) + enc.Byte(ScBoolFalse) } func BoolFromBytes(buf []byte) bool { if buf == nil { return false } - if len(buf) != 1 { + if len(buf) != ScBoolLength { panic("invalid Bool length") } - if buf[0] == 0x00 { + if buf[0] == ScBoolFalse { return false } - if buf[0] != 0xff { + if buf[0] != ScBoolTrue { panic("invalid Bool value") } return true } -func BytesFromBool(value bool) []byte { +func BoolToBytes(value bool) []byte { if value { - return []byte{0xff} + return []byte{ScBoolTrue} } - return []byte{0x00} + return []byte{ScBoolFalse} } func BoolToString(value bool) string { @@ -84,5 +90,5 @@ func (o ScMutableBool) Delete() { } func (o ScMutableBool) SetValue(value bool) { - o.proxy.Set(BytesFromBool(value)) + o.proxy.Set(BoolToBytes(value)) } diff --git a/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/bytes.go b/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/scbytes.go similarity index 81% rename from packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/bytes.go rename to packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/scbytes.go index 002cf1834c..c9106bf0ee 100644 --- a/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/bytes.go +++ b/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/scbytes.go @@ -5,11 +5,11 @@ package wasmtypes // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -func DecodeBytes(dec *WasmDecoder) []byte { +func BytesDecode(dec *WasmDecoder) []byte { return dec.Bytes() } -func EncodeBytes(enc *WasmEncoder, value []byte) { +func BytesEncode(enc *WasmEncoder, value []byte) { enc.Bytes(value) } @@ -17,8 +17,12 @@ func BytesFromBytes(buf []byte) []byte { return buf } -func BytesToString(buf []byte) string { - return base58Encode(buf) +func BytesToBytes(buf []byte) []byte { + return buf +} + +func BytesToString(value []byte) string { + return base58Encode(value) } // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ @@ -58,5 +62,5 @@ func (o ScMutableBytes) Delete() { } func (o ScMutableBytes) SetValue(value []byte) { - o.proxy.Set(BytesFromBytes(value)) + o.proxy.Set(BytesToBytes(value)) } diff --git a/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/chainid.go b/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/scchainid.go similarity index 75% rename from packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/chainid.go rename to packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/scchainid.go index 2c5a18c0eb..6aee6c3e8a 100644 --- a/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/chainid.go +++ b/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/scchainid.go @@ -3,38 +3,33 @@ package wasmtypes +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + const ScChainIDLength = 33 type ScChainID struct { id [ScChainIDLength]byte } -func chainIDFromBytes(buf []byte) ScChainID { - o := ScChainID{} - copy(o.id[:], buf) - return o -} - func (o ScChainID) Address() ScAddress { return AddressFromBytes(o.id[:]) } func (o ScChainID) Bytes() []byte { - return o.id[:] + return ChainIDToBytes(o) } func (o ScChainID) String() string { - // TODO standardize human readable string - return base58Encode(o.id[:]) + return ChainIDToString(o) } // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -func DecodeChainID(dec *WasmDecoder) ScChainID { - return chainIDFromBytes(dec.FixedBytes(ScChainIDLength)) +func ChainIDDecode(dec *WasmDecoder) ScChainID { + return chainIDFromBytesUnchecked(dec.FixedBytes(ScChainIDLength)) } -func EncodeChainID(enc *WasmEncoder, value ScChainID) { +func ChainIDEncode(enc *WasmEncoder, value ScChainID) { enc.FixedBytes(value.Bytes(), ScChainIDLength) } @@ -49,15 +44,22 @@ func ChainIDFromBytes(buf []byte) ScChainID { if buf[0] != 2 { panic("invalid ChainID: not an alias address") } - return chainIDFromBytes(buf) + return chainIDFromBytesUnchecked(buf) } -func BytesFromChainID(value ScChainID) []byte { - return value.Bytes() +func ChainIDToBytes(value ScChainID) []byte { + return value.id[:] } func ChainIDToString(value ScChainID) string { - return value.String() + // TODO standardize human readable string + return base58Encode(value.id[:]) +} + +func chainIDFromBytesUnchecked(buf []byte) ScChainID { + o := ScChainID{} + copy(o.id[:], buf) + return o } // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ @@ -75,7 +77,7 @@ func (o ScImmutableChainID) Exists() bool { } func (o ScImmutableChainID) String() string { - return o.Value().String() + return ChainIDToString(o.Value()) } func (o ScImmutableChainID) Value() ScChainID { @@ -97,5 +99,5 @@ func (o ScMutableChainID) Delete() { } func (o ScMutableChainID) SetValue(value ScChainID) { - o.proxy.Set(value.Bytes()) + o.proxy.Set(ChainIDToBytes(value)) } diff --git a/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/color.go b/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/sccolor.go similarity index 74% rename from packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/color.go rename to packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/sccolor.go index 875d7a73bd..b750633e1b 100644 --- a/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/color.go +++ b/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/sccolor.go @@ -3,6 +3,8 @@ package wasmtypes +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + const ScColorLength = 32 type ScColor struct { @@ -20,28 +22,21 @@ func init() { } } -func newColorFromBytes(buf []byte) ScColor { - o := ScColor{} - copy(o.id[:], buf) - return o -} - func (o ScColor) Bytes() []byte { - return o.id[:] + return ColorToBytes(o) } func (o ScColor) String() string { - // TODO standardize human readable string - return base58Encode(o.id[:]) + return ColorToString(o) } // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -func DecodeColor(dec *WasmDecoder) ScColor { - return newColorFromBytes(dec.FixedBytes(ScColorLength)) +func ColorDecode(dec *WasmDecoder) ScColor { + return colorFromBytesUnchecked(dec.FixedBytes(ScColorLength)) } -func EncodeColor(enc *WasmEncoder, value ScColor) { +func ColorEncode(enc *WasmEncoder, value ScColor) { enc.FixedBytes(value.Bytes(), ScColorLength) } @@ -52,15 +47,22 @@ func ColorFromBytes(buf []byte) ScColor { if len(buf) != ScColorLength { panic("invalid Color length") } - return newColorFromBytes(buf) + return colorFromBytesUnchecked(buf) } -func BytesFromColor(value ScColor) []byte { - return value.Bytes() +func ColorToBytes(value ScColor) []byte { + return value.id[:] } func ColorToString(value ScColor) string { - return value.String() + // TODO standardize human readable string + return base58Encode(value.id[:]) +} + +func colorFromBytesUnchecked(buf []byte) ScColor { + o := ScColor{} + copy(o.id[:], buf) + return o } // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ @@ -78,7 +80,7 @@ func (o ScImmutableColor) Exists() bool { } func (o ScImmutableColor) String() string { - return o.Value().String() + return ColorToString(o.Value()) } func (o ScImmutableColor) Value() ScColor { @@ -100,5 +102,5 @@ func (o ScMutableColor) Delete() { } func (o ScMutableColor) SetValue(value ScColor) { - o.proxy.Set(value.Bytes()) + o.proxy.Set(ColorToBytes(value)) } diff --git a/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/hash.go b/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/schash.go similarity index 72% rename from packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/hash.go rename to packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/schash.go index e613b75bda..9ee920631c 100644 --- a/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/hash.go +++ b/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/schash.go @@ -3,34 +3,29 @@ package wasmtypes +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + const ScHashLength = 32 type ScHash struct { id [ScHashLength]byte } -func newHashFromBytes(buf []byte) ScHash { - o := ScHash{} - copy(o.id[:], buf) - return o -} - func (o ScHash) Bytes() []byte { - return o.id[:] + return HashToBytes(o) } func (o ScHash) String() string { - // TODO standardize human readable string - return base58Encode(o.id[:]) + return HashToString(o) } // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -func DecodeHash(dec *WasmDecoder) ScHash { - return newHashFromBytes(dec.FixedBytes(ScHashLength)) +func HashDecode(dec *WasmDecoder) ScHash { + return hashFromBytesUnchecked(dec.FixedBytes(ScHashLength)) } -func EncodeHash(enc *WasmEncoder, value ScHash) { +func HashEncode(enc *WasmEncoder, value ScHash) { enc.FixedBytes(value.Bytes(), ScHashLength) } @@ -41,15 +36,22 @@ func HashFromBytes(buf []byte) ScHash { if len(buf) != ScHashLength { panic("invalid Hash length") } - return newHashFromBytes(buf) + return hashFromBytesUnchecked(buf) } -func BytesFromHash(value ScHash) []byte { - return value.Bytes() +func HashToBytes(value ScHash) []byte { + return value.id[:] } func HashToString(value ScHash) string { - return value.String() + // TODO standardize human readable string + return base58Encode(value.id[:]) +} + +func hashFromBytesUnchecked(buf []byte) ScHash { + o := ScHash{} + copy(o.id[:], buf) + return o } // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ @@ -67,7 +69,7 @@ func (o ScImmutableHash) Exists() bool { } func (o ScImmutableHash) String() string { - return o.Value().String() + return HashToString(o.Value()) } func (o ScImmutableHash) Value() ScHash { @@ -89,5 +91,5 @@ func (o ScMutableHash) Delete() { } func (o ScMutableHash) SetValue(value ScHash) { - o.proxy.Set(value.Bytes()) + o.proxy.Set(HashToBytes(value)) } diff --git a/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/hname.go b/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/schname.go similarity index 69% rename from packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/hname.go rename to packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/schname.go index 3382278677..731d180552 100644 --- a/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/hname.go +++ b/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/schname.go @@ -4,39 +4,34 @@ package wasmtypes import ( - "encoding/binary" + "strconv" ) +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + const ScHnameLength = 4 type ScHname uint32 -func hnameFromBytes(buf []byte) ScHname { - return ScHname(binary.LittleEndian.Uint32(buf)) -} - //func HnameFromString(name string) ScHname { // return HnameFromBytes(wasmlib.Sandbox(wasmstore.FnUtilsHashName, []byte(name))) //} func (o ScHname) Bytes() []byte { - buf := make([]byte, 4) - binary.LittleEndian.PutUint32(buf, uint32(o)) - return buf + return HnameToBytes(o) } func (o ScHname) String() string { - // TODO standardize human readable string - return hex(o.Bytes()) + return HnameToString(o) } // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -func DecodeHname(dec *WasmDecoder) ScHname { - return hnameFromBytes(dec.FixedBytes(ScHnameLength)) +func HnameDecode(dec *WasmDecoder) ScHname { + return hnameFromBytesUnchecked(dec.FixedBytes(ScHnameLength)) } -func EncodeHname(enc *WasmEncoder, value ScHname) { +func HnameEncode(enc *WasmEncoder, value ScHname) { enc.FixedBytes(value.Bytes(), ScHnameLength) } @@ -47,15 +42,21 @@ func HnameFromBytes(buf []byte) ScHname { if len(buf) != ScHnameLength { panic("invalid Hname length") } - return hnameFromBytes(buf) + return hnameFromBytesUnchecked(buf) } -func BytesFromHname(value ScHname) []byte { - return value.Bytes() +func HnameToBytes(value ScHname) []byte { + return Uint32ToBytes(uint32(value)) } func HnameToString(value ScHname) string { - return value.String() + // TODO standardize human readable string + res := strconv.FormatUint(uint64(value), 16) + return "0000000"[:8-len(res)] + res +} + +func hnameFromBytesUnchecked(buf []byte) ScHname { + return ScHname(Uint32FromBytes(buf)) } // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ @@ -73,7 +74,7 @@ func (o ScImmutableHname) Exists() bool { } func (o ScImmutableHname) String() string { - return o.Value().String() + return HnameToString(o.Value()) } func (o ScImmutableHname) Value() ScHname { @@ -95,5 +96,5 @@ func (o ScMutableHname) Delete() { } func (o ScMutableHname) SetValue(value ScHname) { - o.proxy.Set(value.Bytes()) + o.proxy.Set(HnameToBytes(value)) } diff --git a/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/int16.go b/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/scint16.go similarity index 78% rename from packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/int16.go rename to packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/scint16.go index 467ab41f44..ba2538214b 100644 --- a/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/int16.go +++ b/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/scint16.go @@ -5,17 +5,18 @@ package wasmtypes import ( - "encoding/binary" "strconv" ) +const ScInt16Length = 2 + // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -func DecodeInt16(dec *WasmDecoder) int16 { +func Int16Decode(dec *WasmDecoder) int16 { return int16(dec.VliDecode(16)) } -func EncodeInt16(enc *WasmEncoder, value int16) { +func Int16Encode(enc *WasmEncoder, value int16) { enc.VliEncode(int64(value)) } @@ -23,16 +24,14 @@ func Int16FromBytes(buf []byte) int16 { if buf == nil { return 0 } - if len(buf) != 2 { + if len(buf) != ScInt16Length { panic("invalid Int16 length") } - return int16(binary.LittleEndian.Uint16(buf)) + return int16(buf[0]) | int16(buf[1])<<8 } -func BytesFromInt16(value int16) []byte { - tmp := make([]byte, 2) - binary.LittleEndian.PutUint16(tmp, uint16(value)) - return tmp +func Int16ToBytes(value int16) []byte { + return []byte{byte(value), byte(value >> 8)} } func Int16ToString(value int16) string { @@ -76,5 +75,5 @@ func (o ScMutableInt16) Delete() { } func (o ScMutableInt16) SetValue(value int16) { - o.proxy.Set(BytesFromInt16(value)) + o.proxy.Set(Int16ToBytes(value)) } diff --git a/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/int32.go b/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/scint32.go similarity index 84% rename from packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/int32.go rename to packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/scint32.go index afe677af4d..be7e997c72 100644 --- a/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/int32.go +++ b/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/scint32.go @@ -1,7 +1,6 @@ // Copyright 2020 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 -//nolint:dupl package wasmtypes import ( @@ -9,13 +8,15 @@ import ( "strconv" ) +const ScInt32Length = 4 + // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -func DecodeInt32(dec *WasmDecoder) int32 { +func Int32Decode(dec *WasmDecoder) int32 { return int32(dec.VliDecode(32)) } -func EncodeInt32(enc *WasmEncoder, value int32) { +func Int32Encode(enc *WasmEncoder, value int32) { enc.VliEncode(int64(value)) } @@ -23,14 +24,14 @@ func Int32FromBytes(buf []byte) int32 { if buf == nil { return 0 } - if len(buf) != 4 { + if len(buf) != ScInt32Length { panic("invalid Int32 length") } return int32(binary.LittleEndian.Uint32(buf)) } -func BytesFromInt32(value int32) []byte { - tmp := make([]byte, 4) +func Int32ToBytes(value int32) []byte { + tmp := make([]byte, ScInt32Length) binary.LittleEndian.PutUint32(tmp, uint32(value)) return tmp } @@ -76,5 +77,5 @@ func (o ScMutableInt32) Delete() { } func (o ScMutableInt32) SetValue(value int32) { - o.proxy.Set(BytesFromInt32(value)) + o.proxy.Set(Int32ToBytes(value)) } diff --git a/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/int64.go b/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/scint64.go similarity index 84% rename from packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/int64.go rename to packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/scint64.go index 98d17cd9b3..fcd6709f53 100644 --- a/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/int64.go +++ b/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/scint64.go @@ -8,13 +8,15 @@ import ( "strconv" ) +const ScInt64Length = 8 + // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -func DecodeInt64(dec *WasmDecoder) int64 { +func Int64Decode(dec *WasmDecoder) int64 { return dec.VliDecode(64) } -func EncodeInt64(enc *WasmEncoder, value int64) { +func Int64Encode(enc *WasmEncoder, value int64) { enc.VliEncode(value) } @@ -22,14 +24,14 @@ func Int64FromBytes(buf []byte) int64 { if buf == nil { return 0 } - if len(buf) != 8 { + if len(buf) != ScInt64Length { panic("invalid Int64 length") } return int64(binary.LittleEndian.Uint64(buf)) } -func BytesFromInt64(value int64) []byte { - tmp := make([]byte, 8) +func Int64ToBytes(value int64) []byte { + tmp := make([]byte, ScInt64Length) binary.LittleEndian.PutUint64(tmp, uint64(value)) return tmp } @@ -75,5 +77,5 @@ func (o ScMutableInt64) Delete() { } func (o ScMutableInt64) SetValue(value int64) { - o.proxy.Set(BytesFromInt64(value)) + o.proxy.Set(Int64ToBytes(value)) } diff --git a/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/int8.go b/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/scint8.go similarity index 85% rename from packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/int8.go rename to packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/scint8.go index 1f03df5a9b..5529e61216 100644 --- a/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/int8.go +++ b/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/scint8.go @@ -7,13 +7,15 @@ import ( "strconv" ) +const ScInt8Length = 1 + // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -func DecodeInt8(dec *WasmDecoder) int8 { +func Int8Decode(dec *WasmDecoder) int8 { return int8(dec.Byte()) } -func EncodeInt8(enc *WasmEncoder, value int8) { +func Int8Encode(enc *WasmEncoder, value int8) { enc.Byte(byte(value)) } @@ -21,13 +23,13 @@ func Int8FromBytes(buf []byte) int8 { if buf == nil { return 0 } - if len(buf) != 1 { + if len(buf) != ScInt8Length { panic("invalid Int8 length") } return int8(buf[0]) } -func BytesFromInt8(value int8) []byte { +func Int8ToBytes(value int8) []byte { return []byte{byte(value)} } @@ -72,5 +74,5 @@ func (o ScMutableInt8) Delete() { } func (o ScMutableInt8) SetValue(value int8) { - o.proxy.Set(BytesFromInt8(value)) + o.proxy.Set(Int8ToBytes(value)) } diff --git a/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/requestid.go b/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/screquestid.go similarity index 74% rename from packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/requestid.go rename to packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/screquestid.go index cdcdb3e2e5..deb9c12192 100644 --- a/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/requestid.go +++ b/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/screquestid.go @@ -3,34 +3,29 @@ package wasmtypes +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + const ScRequestIDLength = 34 type ScRequestID struct { id [ScRequestIDLength]byte } -func requestIDFromBytes(buf []byte) ScRequestID { - o := ScRequestID{} - copy(o.id[:], buf) - return o -} - func (o ScRequestID) Bytes() []byte { - return o.id[:] + return RequestIDToBytes(o) } func (o ScRequestID) String() string { - // TODO standardize human readable string - return base58Encode(o.id[:]) + return RequestIDToString(o) } // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -func DecodeRequestID(dec *WasmDecoder) ScRequestID { - return requestIDFromBytes(dec.FixedBytes(ScRequestIDLength)) +func RequestIDDecode(dec *WasmDecoder) ScRequestID { + return requestIDFromBytesUnchecked(dec.FixedBytes(ScRequestIDLength)) } -func EncodeRequestID(enc *WasmEncoder, value ScRequestID) { +func RequestIDEncode(enc *WasmEncoder, value ScRequestID) { enc.FixedBytes(value.Bytes(), ScRequestIDLength) } @@ -45,15 +40,22 @@ func RequestIDFromBytes(buf []byte) ScRequestID { if buf[ScHashLength] > 127 || buf[ScHashLength+1] != 0 { panic("invalid RequestID: output index > 127") } - return requestIDFromBytes(buf) + return requestIDFromBytesUnchecked(buf) } -func BytesFromRequestID(value ScRequestID) []byte { - return value.Bytes() +func RequestIDToBytes(value ScRequestID) []byte { + return value.id[:] } func RequestIDToString(value ScRequestID) string { - return value.String() + // TODO standardize human readable string + return base58Encode(value.id[:]) +} + +func requestIDFromBytesUnchecked(buf []byte) ScRequestID { + o := ScRequestID{} + copy(o.id[:], buf) + return o } // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ @@ -71,7 +73,7 @@ func (o ScImmutableRequestID) Exists() bool { } func (o ScImmutableRequestID) String() string { - return o.Value().String() + return RequestIDToString(o.Value()) } func (o ScImmutableRequestID) Value() ScRequestID { @@ -93,5 +95,5 @@ func (o ScMutableRequestID) Delete() { } func (o ScMutableRequestID) SetValue(value ScRequestID) { - o.proxy.Set(value.Bytes()) + o.proxy.Set(RequestIDToBytes(value)) } diff --git a/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/string.go b/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/scstring.go similarity index 87% rename from packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/string.go rename to packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/scstring.go index be17af5cd4..66bf3cdc70 100644 --- a/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/string.go +++ b/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/scstring.go @@ -5,11 +5,11 @@ package wasmtypes // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -func DecodeString(dec *WasmDecoder) string { +func StringDecode(dec *WasmDecoder) string { return string(dec.Bytes()) } -func EncodeString(enc *WasmEncoder, value string) { +func StringEncode(enc *WasmEncoder, value string) { enc.Bytes([]byte(value)) } @@ -17,7 +17,7 @@ func StringFromBytes(buf []byte) string { return string(buf) } -func BytesFromString(value string) []byte { +func StringToBytes(value string) []byte { return []byte(value) } @@ -62,5 +62,5 @@ func (o ScMutableString) Delete() { } func (o ScMutableString) SetValue(value string) { - o.proxy.Set(BytesFromString(value)) + o.proxy.Set(StringToBytes(value)) } diff --git a/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/uint16.go b/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/scuint16.go similarity index 88% rename from packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/uint16.go rename to packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/scuint16.go index 88c42b0e61..78513373d7 100644 --- a/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/uint16.go +++ b/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/scuint16.go @@ -1,21 +1,22 @@ // Copyright 2020 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 +//nolint:dupl package wasmtypes import ( "strconv" ) -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - const ScUint16Length = 2 -func DecodeUint16(dec *WasmDecoder) uint16 { +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +func Uint16Decode(dec *WasmDecoder) uint16 { return uint16(dec.VluDecode(16)) } -func EncodeUint16(enc *WasmEncoder, value uint16) { +func Uint16Encode(enc *WasmEncoder, value uint16) { enc.VluEncode(uint64(value)) } @@ -29,7 +30,7 @@ func Uint16FromBytes(buf []byte) uint16 { return uint16(buf[0]) | uint16(buf[1])<<8 } -func BytesFromUint16(value uint16) []byte { +func Uint16ToBytes(value uint16) []byte { return []byte{byte(value), byte(value >> 8)} } @@ -74,5 +75,5 @@ func (o ScMutableUint16) Delete() { } func (o ScMutableUint16) SetValue(value uint16) { - o.proxy.Set(BytesFromUint16(value)) + o.proxy.Set(Uint16ToBytes(value)) } diff --git a/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/uint32.go b/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/scuint32.go similarity index 89% rename from packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/uint32.go rename to packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/scuint32.go index d71d4c20a6..d022d0ba54 100644 --- a/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/uint32.go +++ b/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/scuint32.go @@ -8,15 +8,15 @@ import ( "strconv" ) -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - const ScUint32Length = 4 -func DecodeUint32(dec *WasmDecoder) uint32 { +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +func Uint32Decode(dec *WasmDecoder) uint32 { return uint32(dec.VluDecode(32)) } -func EncodeUint32(enc *WasmEncoder, value uint32) { +func Uint32Encode(enc *WasmEncoder, value uint32) { enc.VluEncode(uint64(value)) } @@ -30,7 +30,7 @@ func Uint32FromBytes(buf []byte) uint32 { return binary.LittleEndian.Uint32(buf) } -func BytesFromUint32(value uint32) []byte { +func Uint32ToBytes(value uint32) []byte { tmp := make([]byte, ScUint32Length) binary.LittleEndian.PutUint32(tmp, value) return tmp @@ -77,5 +77,5 @@ func (o ScMutableUint32) Delete() { } func (o ScMutableUint32) SetValue(value uint32) { - o.proxy.Set(BytesFromUint32(value)) + o.proxy.Set(Uint32ToBytes(value)) } diff --git a/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/uint64.go b/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/scuint64.go similarity index 89% rename from packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/uint64.go rename to packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/scuint64.go index 97956b491c..ef44a6197c 100644 --- a/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/uint64.go +++ b/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/scuint64.go @@ -8,15 +8,15 @@ import ( "strconv" ) -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - const ScUint64Length = 8 -func DecodeUint64(dec *WasmDecoder) uint64 { +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +func Uint64Decode(dec *WasmDecoder) uint64 { return dec.VluDecode(64) } -func EncodeUint64(enc *WasmEncoder, value uint64) { +func Uint64Encode(enc *WasmEncoder, value uint64) { enc.VluEncode(value) } @@ -30,7 +30,7 @@ func Uint64FromBytes(buf []byte) uint64 { return binary.LittleEndian.Uint64(buf) } -func BytesFromUint64(value uint64) []byte { +func Uint64ToBytes(value uint64) []byte { tmp := make([]byte, ScUint64Length) binary.LittleEndian.PutUint64(tmp, value) return tmp @@ -77,5 +77,5 @@ func (o ScMutableUint64) Delete() { } func (o ScMutableUint64) SetValue(value uint64) { - o.proxy.Set(BytesFromUint64(value)) + o.proxy.Set(Uint64ToBytes(value)) } diff --git a/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/uint8.go b/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/scuint8.go similarity index 88% rename from packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/uint8.go rename to packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/scuint8.go index 26ce34f394..2281e7cb38 100644 --- a/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/uint8.go +++ b/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/scuint8.go @@ -7,15 +7,15 @@ import ( "strconv" ) -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - const ScUint8Length = 1 -func DecodeUint8(dec *WasmDecoder) uint8 { +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +func Uint8Decode(dec *WasmDecoder) uint8 { return dec.Byte() } -func EncodeUint8(enc *WasmEncoder, value uint8) { +func Uint8Encode(enc *WasmEncoder, value uint8) { enc.Byte(value) } @@ -29,7 +29,7 @@ func Uint8FromBytes(buf []byte) uint8 { return buf[0] } -func BytesFromUint8(value uint8) []byte { +func Uint8ToBytes(value uint8) []byte { return []byte{value} } @@ -74,5 +74,5 @@ func (o ScMutableUint8) Delete() { } func (o ScMutableUint8) SetValue(value uint8) { - o.proxy.Set(BytesFromUint8(value)) + o.proxy.Set(Uint8ToBytes(value)) } diff --git a/packages/wasmvm/wasmlib/ts/wasmlib/assets.ts b/packages/wasmvm/wasmlib/ts/wasmlib/assets.ts new file mode 100644 index 0000000000..2ce732f192 --- /dev/null +++ b/packages/wasmvm/wasmlib/ts/wasmlib/assets.ts @@ -0,0 +1,94 @@ +// Copyright 2020 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +import * as wasmtypes from "./wasmtypes" +import {ScDict} from "./dict"; + +export class ScAssets { + assets: Map = new Map(); + + public constructor(buf: u8[]) { + if (buf.length != 0) { + const dec = new wasmtypes.WasmDecoder(buf); + const size = wasmtypes.uint32FromBytes(dec.fixedBytes(wasmtypes.ScUint32Length)); + for (let i: u32 = 0; i < size; i++) { + const color = wasmtypes.colorDecode(dec); + this.assets.set(ScDict.toKey(color.id), wasmtypes.uint64FromBytes(dec.fixedBytes(wasmtypes.ScUint64Length))); + } + } + } + + public balances(): ScBalances { + return new ScBalances(this); + } + + public toBytes(): u8[] { + const keys = this.assets.keys().sort(); + const enc = new wasmtypes.WasmEncoder(); + enc.fixedBytes(wasmtypes.uint32ToBytes(keys.length as u32), wasmtypes.ScUint32Length); + for (let i = 0; i < keys.length; i++) { + const mapKey = keys[i] + const colorId = ScDict.fromKey(mapKey); + enc.fixedBytes(colorId, wasmtypes.ScColorLength); + enc.fixedBytes(wasmtypes.uint64ToBytes(this.assets.get(mapKey)), wasmtypes.ScUint64Length); + } + return enc.buf() + } +} + +export class ScBalances { + assets: Map; + + constructor(assets: ScAssets) { + this.assets = assets.assets; + } + + public balance(color: wasmtypes.ScColor): u64 { + const mapKey = ScDict.toKey(color.id); + if (! this.assets.has(mapKey)) { + return 0; + } + return this.assets.get(mapKey); + } + + public colors(): wasmtypes.ScColor[] { + let colors: wasmtypes.ScColor[] = []; + const keys = this.assets.keys(); + for (let i = 0; i < keys.length; i++) { + const colorId = ScDict.fromKey(keys[i]); + colors.push(wasmtypes.colorFromBytes(colorId)); + } + return colors; + } +} + +export class ScTransfers extends ScAssets { + + public constructor() { + super([]); + } + + public static fromBalances(balances: ScBalances): ScTransfers { + const transfer = new ScTransfers(); + const colors = balances.colors(); + for (let i = 0; i < colors.length; i++) { + const color = colors[i]; + transfer.set(color, balances.balance(color)); + } + return transfer; + } + + public static iotas(amount: u64): ScTransfers { + return ScTransfers.transfer(wasmtypes.IOTA, amount); + } + + public static transfer(color: wasmtypes.ScColor, amount: u64): ScTransfers { + const transfer = new ScTransfers(); + transfer.set(color, amount); + return transfer; + } + + public set(color: wasmtypes.ScColor, amount: u64): void { + this.assets.set(ScDict.toKey(color.id), amount); + } +} diff --git a/packages/wasmvm/wasmlib/ts/wasmlib/bytes.ts b/packages/wasmvm/wasmlib/ts/wasmlib/bytes.ts deleted file mode 100644 index a2eeb684a0..0000000000 --- a/packages/wasmvm/wasmlib/ts/wasmlib/bytes.ts +++ /dev/null @@ -1,358 +0,0 @@ -// Copyright 2020 IOTA Stiftung -// SPDX-License-Identifier: Apache-2.0 - -import {Convert} from "./convert"; -import {ScAddress, ScAgentID, ScChainID, ScColor, ScHash, ScHname, ScRequestID} from "./hashtypes"; -import * as host from "./host"; -import {panic} from "./host"; - -// decodes separate entities from a byte buffer -export class BytesDecoder { - buf: u8[]; - - // constructs a decoder - constructor(data: u8[]) { - if (data.length == 0) { - panic("cannot decode empty byte array, use exist()"); - } - this.buf = data; - } - - // decodes an ScAddress from the byte buffer - address(): ScAddress { - return ScAddress.fromBytes(this.fixedBytes(host.TYPE_SIZES[host.TYPE_ADDRESS])); - } - - // decodes an ScAgentID from the byte buffer - agentID(): ScAgentID { - return ScAgentID.fromBytes(this.fixedBytes(host.TYPE_SIZES[host.TYPE_AGENT_ID])); - } - - // decodes a bool from the byte buffer - bool(): boolean { - return this.uint8() != 0; - } - - // decodes the next substring of bytes from the byte buffer - bytes(): u8[] { - const length = this.uint32(); - return this.fixedBytes(length); - } - - // decodes an ScChainID from the byte buffer - chainID(): ScChainID { - return ScChainID.fromBytes(this.fixedBytes(host.TYPE_SIZES[host.TYPE_CHAIN_ID])); - } - - close(): void { - if (this.buf.length != 0) { - panic("extra bytes"); - } - } - - // decodes an ScColor from the byte buffer - color(): ScColor { - return ScColor.fromBytes(this.fixedBytes(host.TYPE_SIZES[host.TYPE_COLOR])); - } - - // decodes the next substring of bytes from the byte buffer - fixedBytes(length: u32): u8[] { - if (u32(this.buf.length) < length) { - panic("insufficient bytes"); - } - let value = this.buf.slice(0, length); - this.buf = this.buf.slice(length); - return value; - } - - // decodes an ScHash from the byte buffer - hash(): ScHash { - return ScHash.fromBytes(this.fixedBytes(host.TYPE_SIZES[host.TYPE_HASH])); - } - - // decodes an ScHname from the byte buffer - hname(): ScHname { - return ScHname.fromBytes(this.fixedBytes(host.TYPE_SIZES[host.TYPE_HNAME])); - } - - // decodes an int8 from the byte buffer - int8(): i8 { - return this.uint8() as i8; - } - - // decodes an int16 from the byte buffer - // note that these are encoded using vli encoding to conserve space - int16(): i16 { - return this.vliDecode(16) as i16; - } - - // decodes an int32 from the byte buffer - // note that these are encoded using vli encoding to conserve space - int32(): i32 { - return this.vliDecode(32) as i32; - } - - // decodes an int64 from the byte buffer - // note that these are encoded using vli encoding to conserve space - int64(): i64 { - return this.vliDecode(64); - } - - // decodes an ScRequestID from the byte buffer - requestID(): ScRequestID { - return ScRequestID.fromBytes(this.fixedBytes(host.TYPE_SIZES[host.TYPE_REQUEST_ID])); - } - - // decodes an UTF-8 text string from the byte buffer - string(): string { - return Convert.toString(this.bytes()); - } - - // decodes an uint8 from the byte buffer - uint8(): u8 { - if (this.buf.length == 0) { - panic("insufficient bytes"); - } - return this.buf.shift(); - } - - // decodes an uint16 from the byte buffer - // note that these are encoded using vlu encoding to conserve space - uint16(): u16 { - return this.vluDecode(16) as u16; - } - - // decodes an uint32 from the byte buffer - // note that these are encoded using vlu encoding to conserve space - uint32(): u32 { - return this.vluDecode(32) as u32; - } - - // decodes an uint64 from the byte buffer - // note that these are encoded using vlu encoding to conserve space - uint64(): u64 { - return this.vluDecode(64); - } - - // vli (variable length integer) decoder - vliDecode(bits: i32): i64 { - let b = this.uint8(); - const sign = b & 0x40; - - // first group of 6 bits - let value = (b & 0x3f) as i64; - let s = 6; - - // while continuation bit is set - while ((b & 0x80) != 0) { - if (s >= bits) { - panic("integer representation too long"); - } - - // next group of 7 bits - b = this.uint8(); - value |= ((b & 0x7f) as i64) << s; - s += 7; - } - - if (sign == 0) { - // positive, sign bits are already zero - return value; - } - - // negative, extend sign bits - return value | ((-1 as i64) << s); - } - - // vlu decoder - vluDecode(bits: i32): u64 { - // first group of 7 bits - let b = this.uint8(); - let value = (b & 0x7f) as u64; - let s = 7; - - // while continuation bit is set - while ((b & 0x80) != 0) { - if (s >= bits) { - panic("integer representation too long"); - } - - // next group of 7 bits - b = this.uint8(); - value |= ((b & 0x7f) as u64) << s; - s += 7; - } - - return value; - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -// encodes separate entities into a byte buffer -export class BytesEncoder { - buf: u8[]; - - // constructs an encoder - constructor() { - this.buf = [] - } - - // encodes an ScAddress into the byte buffer - address(value: ScAddress): BytesEncoder { - return this.fixedBytes(value.toBytes(), host.TYPE_SIZES[host.TYPE_ADDRESS]); - } - - // encodes an ScAgentID into the byte buffer - agentID(value: ScAgentID): BytesEncoder { - return this.fixedBytes(value.toBytes(), host.TYPE_SIZES[host.TYPE_AGENT_ID]); - } - - // encodes a bool into the byte buffer - bool(value: boolean): BytesEncoder { - return this.uint8(value ? 1 : 0); - } - - // encodes a substring of bytes into the byte buffer - bytes(value: u8[]): BytesEncoder { - const length = value.length; - this.uint32(length); - return this.fixedBytes(value, length); - } - - // encodes an ScChainID into the byte buffer - chainID(value: ScChainID): BytesEncoder { - return this.fixedBytes(value.toBytes(), host.TYPE_SIZES[host.TYPE_CHAIN_ID]); - } - - // encodes an ScColor into the byte buffer - color(value: ScColor): BytesEncoder { - return this.fixedBytes(value.toBytes(), host.TYPE_SIZES[host.TYPE_COLOR]); - } - - // retrieve the encoded byte buffer - data(): u8[] { - return this.buf; - } - - // encodes a substring of bytes into the byte buffer - fixedBytes(value: u8[], length: u32): BytesEncoder { - if (value.length != length) { - panic("invalid fixed bytes length"); - } - for (let i: u32 = 0; i < length; i++) { - this.buf.push(value[i]); - } - return this; - } - - // encodes an ScHash into the byte buffer - hash(value: ScHash): BytesEncoder { - return this.fixedBytes(value.toBytes(), host.TYPE_SIZES[host.TYPE_HASH]); - } - - // encodes an ScHname into the byte buffer - hname(value: ScHname): BytesEncoder { - return this.fixedBytes(value.toBytes(), host.TYPE_SIZES[host.TYPE_HNAME]); - } - - // encodes an int8 into the byte buffer - int8(value: i8): BytesEncoder { - return this.uint8(value as u8); - } - - // encodes an int16 into the byte buffer - // note that these are encoded using vli encoding to conserve space - int16(value: i16): BytesEncoder { - return this.int64(value as i64); - } - - // encodes an int32 into the byte buffer - // note that these are encoded using vli encoding to conserve space - int32(value: i32): BytesEncoder { - return this.int64(value as i64); - } - - // encodes an int64 into the byte buffer - // note that these are encoded using vli encoding to conserve space - // vli (variable length integer) encoder - int64(value: i64): BytesEncoder { - // first group of 6 bits - // 1st byte encodes 0 as positive in bit 6 - let b = (value as u8) & 0x3f; - value >>= 6; - - let finalValue: i64 = 0; - if (value < 0) { - // encode negative value - // 1st byte encodes 1 as negative in bit 6 - b |= 0x40; - finalValue = -1; - } - - // keep shifting until all bits are done - while (value != finalValue) { - // emit with continuation bit - this.buf.push(b | 0x80); - - // next group of 7 bits - b = (value as u8) & 0x7f; - value >>= 7; - } - - // emit without continuation bit - this.buf.push(b); - return this; - } - - // encodes an ScRequestID into the byte buffer - requestID(value: ScRequestID): BytesEncoder { - return this.fixedBytes(value.toBytes(), host.TYPE_SIZES[host.TYPE_REQUEST_ID]); - } - - // encodes an UTF-8 text string into the byte buffer - string(value: string): BytesEncoder { - return this.bytes(Convert.fromString(value)); - } - - // encodes an uint8 into the byte buffer - uint8(value: u8): BytesEncoder { - this.buf.push(value); - return this; - } - - // encodes an uint16 into the byte buffer - // note that these are encoded using vlu encoding to conserve space - uint16(value: u16): BytesEncoder { - return this.uint64(value as u64); - } - - // encodes an uint32 into the byte buffer - // note that these are encoded using vlu encoding to conserve space - uint32(value: u32): BytesEncoder { - return this.uint64(value as u64); - } - - // encodes an uint64 into the byte buffer - // note that these are encoded using vlu encoding to conserve space - // vlu (variable length unsigned) encoder - uint64(value: u64): BytesEncoder { - // first group of 7 bits - let b = (value as u8) & 0x7f; - value >>= 7; - - // keep shifting until all bits are done - while (value != 0) { - // emit with continuation bit - this.buf.push(b | 0x80); - - // next group of 7 bits - b = (value as u8) & 0x7f; - value >>= 7; - } - - // emit without continuation bit - this.buf.push(b); - return this; - } -} diff --git a/packages/wasmvm/wasmlib/ts/wasmlib/context.ts b/packages/wasmvm/wasmlib/ts/wasmlib/context.ts index 20ba943aa9..2c5bcdeae7 100644 --- a/packages/wasmvm/wasmlib/ts/wasmlib/context.ts +++ b/packages/wasmvm/wasmlib/ts/wasmlib/context.ts @@ -3,376 +3,39 @@ // encapsulates standard host entities into a simple interface -import {BytesDecoder, BytesEncoder} from "./bytes"; -import {Convert} from "./convert"; +import * as wasmtypes from "./wasmtypes" +import {ScBalances, ScTransfers} from "./assets"; import {ScFuncCallContext, ScViewCallContext} from "./contract"; -import {ScAddress, ScAgentID, ScChainID, ScColor, ScHash, ScHname, ScRequestID} from "./hashtypes"; -import {log, OBJ_ID_ROOT, OBJ_ID_STATE, panic} from "./host"; -import {ScImmutableColorArray, ScImmutableMap} from "./immutable"; -import * as keys from "./keys"; -import {ScMutableMap} from "./mutable"; - -// all access to the objects in host's object tree starts here -export let ROOT = new ScMutableMap(OBJ_ID_ROOT); - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -// retrieves any information that is related to colored token balances -export class ScBalances { - balances: ScImmutableMap; - - constructor(id: keys.Key32) { - this.balances = ROOT.getMap(id).immutable() - } - - // retrieve the balance for the specified token color - balance(color: ScColor): u64 { - return this.balances.getUint64(color).value(); - } - - // retrieve an array of all token colors that have a non-zero balance - colors(): ScImmutableColorArray { - return this.balances.getColorArray(keys.KEY_COLOR); - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -// passes token transfer information to a function call -export class ScTransfers { - transfers: ScMutableMap; - - // create a new transfers object ready to add token transfers - constructor() { - this.transfers = ScMutableMap.create(); - } - - // create a new transfers object from a balances object - static fromBalances(balances: ScBalances): ScTransfers { - let transfers = new ScTransfers(); - let colors = balances.colors(); - for (let i:u32 = 0; i < colors.length(); i++) { - let color = colors.getColor(i).value(); - transfers.set(color, balances.balance(color)); - } - return transfers; - } - - // create a new transfers object and initialize it with the specified amount of iotas - static iotas(amount: u64): ScTransfers { - return ScTransfers.transfer(ScColor.IOTA, amount); - } - - // create a new transfers object and initialize it with the specified token transfer - static transfer(color: ScColor, amount: u64): ScTransfers { - let transfer = new ScTransfers(); - transfer.set(color, amount); - return transfer; - } - - // set the specified colored token transfer in the transfers object - // note that this will overwrite any previous amount for the specified color - set(color: ScColor, amount: u64): void { - this.transfers.getUint64(color).setValue(amount); - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -// provides access to utility functions that are handled by the host -export class ScUtility { - utility: ScMutableMap; - - constructor() { - this.utility = ROOT.getMap(keys.KEY_UTILITY) - } - - // decodes the specified base58-encoded string value to its original bytes - base58Decode(value: string): u8[] { - return this.utility.callFunc(keys.KEY_BASE58_DECODE, Convert.fromString(value)); - } - - // encodes the specified bytes to a base-58-encoded string - base58Encode(value: u8[]): string { - let result = this.utility.callFunc(keys.KEY_BASE58_ENCODE, value); - return Convert.toString(result); - } - - // retrieves the address for the specified BLS public key - blsAddressFromPubkey(pubKey: u8[]): ScAddress { - let result = this.utility.callFunc(keys.KEY_BLS_ADDRESS, pubKey); - return ScAddress.fromBytes(result); - } - - // aggregates the specified multiple BLS signatures and public keys into a single one - blsAggregateSignatures(pubKeysBin: u8[][], sigsBin: u8[][]): u8[][] { - let encode = new BytesEncoder(); - encode.int32(pubKeysBin.length); - for (let i = 0; i < pubKeysBin.length; i++) { - encode.bytes(pubKeysBin[i]); - } - encode.int32(sigsBin.length as i32); - for (let i = 0; i < sigsBin.length; i++) { - encode.bytes(sigsBin[i]); - } - let result = this.utility.callFunc(keys.KEY_BLS_AGGREGATE, encode.data()); - let decode = new BytesDecoder(result); - return [decode.bytes(), decode.bytes()]; - } - - // checks if the specified BLS signature is valid - blsValidSignature(data: u8[], pubKey: u8[], signature: u8[]): boolean { - let encode = new BytesEncoder(); - encode.bytes(data); - encode.bytes(pubKey); - encode.bytes(signature); - let result = this.utility.callFunc(keys.KEY_BLS_VALID, encode.data()); - return (result[0] & 0x01) != 0; - } - - // retrieves the address for the specified ED25519 public key - ed25519AddressFromPubkey(pubKey: u8[]): ScAddress { - let result = this.utility.callFunc(keys.KEY_ED25519_ADDRESS, pubKey); - return ScAddress.fromBytes(result); - } - - // checks if the specified ED25519 signature is valid - ed25519ValidSignature(data: u8[], pubKey: u8[], signature: u8[]): boolean { - let encode = new BytesEncoder(); - encode.bytes(data); - encode.bytes(pubKey); - encode.bytes(signature); - let result = this.utility.callFunc(keys.KEY_ED25519_VALID, encode.data()); - return (result[0] & 0x01) != 0; - } - - // hashes the specified value bytes using BLAKE2b hashing and returns the resulting 32-byte hash - hashBlake2b(value: u8[]): ScHash { - let hash = this.utility.callFunc(keys.KEY_HASH_BLAKE2B, value); - return ScHash.fromBytes(hash); - } - - // hashes the specified value bytes using SHA3 hashing and returns the resulting 32-byte hash - hashSha3(value: u8[]): ScHash { - let hash = this.utility.callFunc(keys.KEY_HASH_SHA3, value); - return ScHash.fromBytes(hash); - } - - // calculates 32-bit hash for the specified name string - hname(name: string): ScHname { - let result = this.utility.callFunc(keys.KEY_HNAME, Convert.fromString(name)); - return ScHname.fromBytes(result); - } -} - -// wrapper function for simplified internal access to base58 encoding -export function base58Encode(bytes: u8[]): string { - return new ScFuncContext().utility().base58Encode(bytes); -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -// shared interface part of ScFuncContext and ScViewContext -export class ScBaseContext { - // retrieve the agent id of this contract account - accountID(): ScAgentID { - return ROOT.getAgentID(keys.KEY_ACCOUNT_ID).value(); - } - - // access the current balances for all token colors - balances(): ScBalances { - return new ScBalances(keys.KEY_BALANCES); - } - - // retrieve the chain id of the chain this contract lives on - chainID(): ScChainID { - return ROOT.getChainID(keys.KEY_CHAIN_ID).value(); - } - - // retrieve the agent id of the owner of the chain this contract lives on - chainOwnerID(): ScAgentID { - return ROOT.getAgentID(keys.KEY_CHAIN_OWNER_ID).value(); - } - - // retrieve the hname of this contract - contract(): ScHname { - return ROOT.getHname(keys.KEY_CONTRACT).value(); - } - - // retrieve the agent id of the creator of this contract - contractCreator(): ScAgentID { - return ROOT.getAgentID(keys.KEY_CONTRACT_CREATOR).value(); - } - - // logs informational text message in the log on the host - log(text: string): void { - log(text); - } - - // logs error text message in the log on the host and then panics - panic(text: string): void { - panic(text); - } - - // retrieve parameters that were passed to the smart contract function - params(): ScImmutableMap { - return ROOT.getMap(keys.KEY_PARAMS).immutable(); - } - - // panics with specified message if specified condition is not satisfied - require(cond: boolean, msg: string): void { - if (!cond) { - panic(msg); - } - } - - // map that holds any results returned by the smart contract function - results(): ScMutableMap { - return ROOT.getMap(keys.KEY_RESULTS); - } - - // deterministic time stamp fixed at the moment of calling the smart contract - timestamp(): i64 { - return ROOT.getInt64(keys.KEY_TIMESTAMP).value(); - } - - // logs debugging trace text message in the log on the host - // similar to log() except this will only show in the log in a special debug mode - trace(text: string): void { - trace(text); - } - - // access diverse utility functions provided by the host - utility(): ScUtility { - return new ScUtility(); - } -} +import {panic, ScSandboxFunc, ScSandboxView} from "./sandbox"; // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // smart contract interface with mutable access to state -export class ScFuncContext extends ScBaseContext implements ScViewCallContext, ScFuncCallContext { +export class ScFuncContext extends ScSandboxFunc implements ScViewCallContext, ScFuncCallContext { canCallFunc(): void { - panic!("canCallFunc"); + panic("canCallFunc"); } canCallView(): void { - panic!("canCallView"); + panic("canCallView"); } - // synchronously calls the specified smart contract function, - // passing the provided parameters and token transfers to it - call(hcontract: ScHname, hfunction: ScHname, params: ScMutableMap | null, transfer: ScTransfers | null): ScImmutableMap { - let encode = new BytesEncoder(); - encode.hname(hcontract); - encode.hname(hfunction); - encode.int32((params === null) ? 0 : params.mapID()); - encode.int32((transfer === null) ? 0 : transfer.transfers.mapID()); - ROOT.getBytes(keys.KEY_CALL).setValue(encode.data()); - return ROOT.getMap(keys.KEY_RETURN).immutable(); - } - - // retrieve the agent id of the caller of the smart contract - caller(): ScAgentID { - return ROOT.getAgentID(keys.KEY_CALLER).value(); - } - - // deploys a new instance of the specified smart contract on the current chain - // the provided parameters are passed to the smart contract "init" function - deploy(programHash: ScHash, name: string, description: string, params: ScMutableMap | null): void { - let encode = new BytesEncoder(); - encode.hash(programHash); - encode.string(name); - encode.string(description); - encode.int32((params === null) ? 0 : params.mapID()); - ROOT.getBytes(keys.KEY_DEPLOY).setValue(encode.data()); - } - - // signals an event on the host that external entities can subscribe to - event(text: string): void { - ROOT.getString(keys.KEY_EVENT).setValue(text); - } - - // access the incoming balances for all token colors + // TODO deprecated incoming(): ScBalances { - return new ScBalances(keys.KEY_INCOMING); - } - - // retrieve the tokens that were minted in this transaction - minted(): ScBalances { - return new ScBalances(keys.KEY_MINTED); - } - - // asynchronously calls the specified smart contract function, - // passing the provided parameters and token transfers to it - // it is possible to schedule the call for a later execution by specifying a delay - post(chainID: ScChainID, hcontract: ScHname, hfunction: ScHname, params: ScMutableMap | null, transfer: ScTransfers, delay: u32): void { - let encode = new BytesEncoder(); - encode.chainID(chainID); - encode.hname(hcontract); - encode.hname(hfunction); - encode.int32((params === null) ? 0 : params.mapID()); - encode.int32(transfer.transfers.mapID()); - encode.uint32(delay); - ROOT.getBytes(keys.KEY_POST).setValue(encode.data()); - } - - // generates a random value from 0 to max (exclusive max) using a deterministic RNG - random(max: u64): u64 { - if (max == 0) { - this.panic("random: max parameter should be non-zero"); - } - let state = new ScMutableMap(OBJ_ID_STATE); - let rnd = state.getBytes(keys.KEY_RANDOM); - let seed = rnd.value(); - if (seed.length == 0) { - seed = ROOT.getBytes(keys.KEY_RANDOM).value(); - } - rnd.setValue(this.utility().hashSha3(seed).toBytes()); - return Convert.toI64(seed.slice(0, 8)) as u64 % max - } - - // retrieve the request id of this transaction - requestID(): ScRequestID { - return ROOT.getRequestID(keys.KEY_REQUEST_ID).value(); + return super.incomingTransfer(); } - // access mutable state storage on the host - state(): ScMutableMap { - return ROOT.getMap(keys.KEY_STATE); - } - - // transfers the specified tokens to the specified Tangle ledger address - transferToAddress(address: ScAddress, transfer: ScTransfers): void { - let transfers = ROOT.getMapArray(keys.KEY_TRANSFERS); - let tx = transfers.getMap(transfers.length()); - tx.getAddress(keys.KEY_ADDRESS).setValue(address); - tx.getInt32(keys.KEY_BALANCES).setValue(transfer.transfers.mapID()); + // TODO deprecated + transferToAddress(address: wasmtypes.ScAddress, transfer: ScTransfers): void { + super.send(address, transfer); } } // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // smart contract view interface which has only immutable access to state -export class ScViewContext extends ScBaseContext implements ScViewCallContext { +export class ScViewContext extends ScSandboxView implements ScViewCallContext { canCallView(): void { - panic!("canCallView"); - } - - // synchronously calls the specified smart contract view, - // passing the provided parameters to it - call(hcontract: ScHname, hfunction: ScHname, params: ScMutableMap | null): ScImmutableMap { - let encode = new BytesEncoder(); - encode.hname(hcontract); - encode.hname(hfunction); - encode.int32((params === null) ? 0 : params.mapID()); - encode.int32(0); - ROOT.getBytes(keys.KEY_CALL).setValue(encode.data()); - return ROOT.getMap(keys.KEY_RETURN).immutable(); - } - - // access immutable state storage on the host - state(): ScImmutableMap { - return ROOT.getMap(keys.KEY_STATE).immutable(); + panic("canCallView"); } } diff --git a/packages/wasmvm/wasmlib/ts/wasmlib/contract.ts b/packages/wasmvm/wasmlib/ts/wasmlib/contract.ts index 606b6c849d..7cc078223f 100644 --- a/packages/wasmvm/wasmlib/ts/wasmlib/contract.ts +++ b/packages/wasmvm/wasmlib/ts/wasmlib/contract.ts @@ -1,185 +1,131 @@ // Copyright 2020 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 -// base contract objects +import * as wasmrequests from "./wasmrequests" +import * as wasmtypes from "./wasmtypes" +import {ScAssets, ScTransfers} from "./assets"; +import {ScDict} from "./dict"; +import {sandbox} from "./host"; +import {FnCall, FnPost, panic, ScSandbox} from "./sandbox"; -import {BytesEncoder} from "./bytes"; -import {ROOT,ScTransfers} from "./context"; -import {ScChainID,ScHname} from "./hashtypes"; -import {getObjectID, panic, TYPE_MAP} from "./host"; -import * as keys from "./keys"; -import {ScMutableMap} from "./mutable"; +// base contract objects export interface ScFuncCallContext { - canCallFunc():void; + canCallFunc(): void; } export interface ScViewCallContext { - canCallView():void; + canCallView(): void; } -export class ScMapID { - mapID: i32 = 0; +export function newCallParamsProxy(v: ScView): wasmtypes.Proxy { + v.params = new ScDict([]); + return v.params.asProxy(); } -type NullableScMapID = ScMapID | null; +export function newCallResultsProxy(v: ScView): wasmtypes.Proxy { + const proxy = new ScDict([]).asProxy(); + v.resultsProxy = proxy; + return proxy +} // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ export class ScView { - hContract: ScHname; - hFunction: ScHname; - paramsID: NullableScMapID; - resultsID: NullableScMapID; + private static nilParams: ScDict = new ScDict([]); + public static nilProxy: wasmtypes.Proxy = new wasmtypes.Proxy(ScView.nilParams); - constructor(hContract: ScHname, hFunction: ScHname) { + hContract: wasmtypes.ScHname; + hFunction: wasmtypes.ScHname; + params: ScDict; + resultsProxy: wasmtypes.Proxy| null; + + constructor(hContract: wasmtypes.ScHname, hFunction: wasmtypes.ScHname) { this.hContract = hContract; this.hFunction = hFunction; - this.paramsID = null; - this.resultsID = null; - } - - setPtrs(paramsID: NullableScMapID, resultsID: NullableScMapID): void { - this.paramsID = paramsID; - this.resultsID = resultsID; - - if (paramsID === null) { - } else { - paramsID.mapID = ScMutableMap.create().mapID(); - } + this.params = ScView.nilParams; + this.resultsProxy = null; } call(): void { - this.callWithTransfer(0); + this.callWithTransfer(null); } - callWithTransfer(transferID: i32): void { - let encode = new BytesEncoder(); - encode.hname(this.hContract); - encode.hname(this.hFunction); - encode.int32(this.id(this.paramsID)); - encode.int32(transferID); - ROOT.getBytes(keys.KEY_CALL).setValue(encode.data()); - - let resultsID = this.resultsID; - if (resultsID === null) { - } else { - resultsID.mapID = getObjectID(1, keys.KEY_RETURN, TYPE_MAP); + protected callWithTransfer(transfer: ScAssets | null): void { + //TODO new ScSandboxFunc().call(...) + if (transfer === null) { + transfer = new ScAssets([]); + } + const req = new wasmrequests.CallRequest(); + req.contract = this.hContract; + req.function = this.hFunction; + req.params = this.params.toBytes(); + req.transfer = transfer.toBytes(); + const res = sandbox(FnCall, req.bytes()); + const proxy = this.resultsProxy; + if (proxy != null) { + proxy.kvStore = new ScDict(res); } } - clone(): ScView { - let o = new ScView(this.hContract, this.hFunction); - o.paramsID = this.paramsID; - o.resultsID = this.resultsID; - return o; - } - - ofContract(hContract: ScHname): ScView { - let ret = this.clone(); - ret.hContract = hContract; - return ret; - } - - id(paramsID: NullableScMapID): i32 { - if (paramsID === null) { - return 0; - } - return paramsID.mapID; + ofContract(hContract: wasmtypes.ScHname): ScView { + this.hContract = hContract; + return this; } } // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -export class ScInitFunc { - view: ScView; - - constructor(hContract: ScHname, hFunction: ScHname) { - this.view = new ScView(hContract, hFunction); - } - - setPtrs(paramsID: NullableScMapID, resultsID: NullableScMapID): void { - this.view.setPtrs(paramsID, resultsID); - } - +export class ScInitFunc extends ScView { call(): void { return panic("cannot call init"); } - - clone(): ScInitFunc { - let o = new ScInitFunc(this.view.hContract, this.view.hFunction); - o.view = this.view.clone(); - return o; - } - - ofContract(hContract: ScHname): ScInitFunc { - let ret = this.clone(); - ret.view.hContract = hContract; - return ret; - } } // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -export class ScFunc { - view: ScView; +export class ScFunc extends ScView { delaySeconds: u32 = 0; - transferID: i32 = 0; - - constructor(hContract: ScHname, hFunction: ScHname) { - this.view = new ScView(hContract, hFunction); - } - - setPtrs(paramsID: NullableScMapID, resultsID: NullableScMapID): void { - this.view.setPtrs(paramsID, resultsID); - } + transfers: ScAssets | null = null; call(): void { if (this.delaySeconds != 0) { return panic("cannot delay a call"); } - this.view.callWithTransfer(this.transferID); - } - - clone(): ScFunc { - let o = new ScFunc(this.view.hContract, this.view.hFunction); - o.view = this.view.clone(); - o.delaySeconds = this.delaySeconds; - o.transferID = this.transferID; - return o; + this.callWithTransfer(this.transfers); } delay(seconds: u32): ScFunc { - let ret = this.clone(); - ret.delaySeconds = seconds; - return ret; - } - - ofContract(hContract: ScHname): ScFunc { - let ret = this.clone(); - ret.view.hContract = hContract; - return ret; + this.delaySeconds = seconds; + return this; } post(): void { - return this.postToChain(ROOT.getChainID(keys.KEY_CHAIN_ID).value()); + return this.postToChain(new ScSandbox().chainID()); } - postToChain(chainID: ScChainID): void { - let encode = new BytesEncoder(); - encode.chainID(chainID); - encode.hname(this.view.hContract); - encode.hname(this.view.hFunction); - encode.int32(this.view.id(this.view.paramsID)); - encode.int32(this.transferID); - encode.uint32(this.delaySeconds); - ROOT.getBytes(keys.KEY_POST).setValue(encode.data()); + postToChain(chainID: wasmtypes.ScChainID): void { + let transfer = this.transfers; + if (transfer === null) { + transfer = new ScAssets([]); + } + const req = new wasmrequests.PostRequest(); + req.chainID = chainID; + req.contract = this.hContract; + req.function = this.hFunction; + req.params = this.params.toBytes(); + req.transfer = transfer.toBytes(); + req.delay = this.delaySeconds; + const res = sandbox(FnPost, req.bytes()); + if (this.resultsProxy) { + //TODO set kvStore directly? + this.resultsProxy = new wasmtypes.Proxy(new ScDict(res)); + } } - transfer(transfer: ScTransfers): ScFunc { - let ret = this.clone(); - ret.transferID = transfer.transfers.objID; - return ret; + transfer(transfers: ScTransfers): ScFunc { + this.transfers = transfers; + return this; } transferIotas(amount: i64): ScFunc { diff --git a/packages/wasmvm/wasmlib/ts/wasmlib/convert.ts b/packages/wasmvm/wasmlib/ts/wasmlib/convert.ts deleted file mode 100644 index 3e23835597..0000000000 --- a/packages/wasmvm/wasmlib/ts/wasmlib/convert.ts +++ /dev/null @@ -1,97 +0,0 @@ -// Copyright 2020 IOTA Stiftung -// SPDX-License-Identifier: Apache-2.0 - -// converts to and from little endian bytes -import {panic} from "./host"; - -export class Convert { - static equals(lhs: u8[], rhs: u8[]): boolean { - if (lhs.length != rhs.length) { - return false; - } - for (let i = lhs.length - 1; i >= 0; i--) { - if (lhs[i] != rhs[i]) { - return false; - } - } - return true; - } - - static fromI16(val: i16): u8[] { - return [ - val as u8, - (val >> 8) as u8, - ]; - } - - static fromI32(val: i32): u8[] { - return [ - val as u8, - (val >> 8) as u8, - (val >> 16) as u8, - (val >> 24) as u8, - ]; - } - - static fromI64(val: i64): u8[] { - return [ - val as u8, - (val >> 8) as u8, - (val >> 16) as u8, - (val >> 24) as u8, - (val >> 32) as u8, - (val >> 40) as u8, - (val >> 48) as u8, - (val >> 56) as u8, - ]; - } - - static fromString(val: string): u8[] { - let arrayBuffer = String.UTF8.encode(val); - let u8Array = Uint8Array.wrap(arrayBuffer) - let ret: u8[] = new Array(u8Array.length); - for (let i = 0; i < ret.length; i++) { - ret[i] = u8Array[i]; - } - return ret; - } - - static toI16(bytes: u8[]): i16 { - if (bytes.length != 2) { - panic("expected i16 (2 bytes)") - } - - let ret: i16 = bytes[1]; - return (ret << 8) | bytes[0]; - } - - static toI32(bytes: u8[]): i32 { - if (bytes.length != 4) { - panic("expected i32 (4 bytes)") - } - - let ret: i32 = bytes[3]; - ret = (ret << 8) | bytes[2]; - ret = (ret << 8) | bytes[1]; - return (ret << 8) | bytes[0]; - } - - static toI64(bytes: u8[]): i64 { - if (bytes.length != 8) { - panic("expected i64 (8 bytes)") - } - - let ret: i64 = bytes[7]; - ret = (ret << 8) | bytes[6]; - ret = (ret << 8) | bytes[5]; - ret = (ret << 8) | bytes[4]; - ret = (ret << 8) | bytes[3]; - ret = (ret << 8) | bytes[2]; - ret = (ret << 8) | bytes[1]; - return (ret << 8) | bytes[0]; - } - - static toString(bytes: u8[]): string { - return String.UTF8.decodeUnsafe(bytes.dataStart, bytes.length); - } -} \ No newline at end of file diff --git a/packages/wasmvm/wasmlib/ts/wasmlib/coreaccounts/consts.ts b/packages/wasmvm/wasmlib/ts/wasmlib/coreaccounts/consts.ts index 967aa43c5f..4b60887c1e 100644 --- a/packages/wasmvm/wasmlib/ts/wasmlib/coreaccounts/consts.ts +++ b/packages/wasmvm/wasmlib/ts/wasmlib/coreaccounts/consts.ts @@ -5,11 +5,11 @@ // >>>> DO NOT CHANGE THIS FILE! <<<< // Change the json schema instead -import * as wasmlib from "wasmlib"; +import * as wasmtypes from "wasmlib/wasmtypes"; export const ScName = "accounts"; export const ScDescription = "Core chain account ledger contract"; -export const HScName = new wasmlib.ScHname(0x3c4b5e02); +export const HScName = new wasmtypes.ScHname(0x3c4b5e02); export const ParamAgentID = "a"; export const ParamWithdrawAmount = "m"; @@ -27,10 +27,10 @@ export const ViewBalance = "balance"; export const ViewGetAccountNonce = "getAccountNonce"; export const ViewTotalAssets = "totalAssets"; -export const HFuncDeposit = new wasmlib.ScHname(0xbdc9102d); -export const HFuncHarvest = new wasmlib.ScHname(0x7b40efbd); -export const HFuncWithdraw = new wasmlib.ScHname(0x9dcc0f41); -export const HViewAccounts = new wasmlib.ScHname(0x3c4b5e02); -export const HViewBalance = new wasmlib.ScHname(0x84168cb4); -export const HViewGetAccountNonce = new wasmlib.ScHname(0x529d7df9); -export const HViewTotalAssets = new wasmlib.ScHname(0xfab0f8d2); +export const HFuncDeposit = new wasmtypes.ScHname(0xbdc9102d); +export const HFuncHarvest = new wasmtypes.ScHname(0x7b40efbd); +export const HFuncWithdraw = new wasmtypes.ScHname(0x9dcc0f41); +export const HViewAccounts = new wasmtypes.ScHname(0x3c4b5e02); +export const HViewBalance = new wasmtypes.ScHname(0x84168cb4); +export const HViewGetAccountNonce = new wasmtypes.ScHname(0x529d7df9); +export const HViewTotalAssets = new wasmtypes.ScHname(0xfab0f8d2); diff --git a/packages/wasmvm/wasmlib/ts/wasmlib/coreaccounts/contract.ts b/packages/wasmvm/wasmlib/ts/wasmlib/coreaccounts/contract.ts index a8fa2cb85b..15ec996c5f 100644 --- a/packages/wasmvm/wasmlib/ts/wasmlib/coreaccounts/contract.ts +++ b/packages/wasmvm/wasmlib/ts/wasmlib/coreaccounts/contract.ts @@ -6,16 +6,17 @@ // Change the json schema instead import * as wasmlib from "wasmlib"; +import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; export class DepositCall { func: wasmlib.ScFunc = new wasmlib.ScFunc(sc.HScName, sc.HFuncDeposit); - params: sc.MutableDepositParams = new sc.MutableDepositParams(); + params: sc.MutableDepositParams = new sc.MutableDepositParams(wasmlib.ScView.nilProxy); } export class HarvestCall { func: wasmlib.ScFunc = new wasmlib.ScFunc(sc.HScName, sc.HFuncHarvest); - params: sc.MutableHarvestParams = new sc.MutableHarvestParams(); + params: sc.MutableHarvestParams = new sc.MutableHarvestParams(wasmlib.ScView.nilProxy); } export class WithdrawCall { @@ -24,36 +25,36 @@ export class WithdrawCall { export class AccountsCall { func: wasmlib.ScView = new wasmlib.ScView(sc.HScName, sc.HViewAccounts); - results: sc.ImmutableAccountsResults = new sc.ImmutableAccountsResults(); + results: sc.ImmutableAccountsResults = new sc.ImmutableAccountsResults(wasmlib.ScView.nilProxy); } export class BalanceCall { func: wasmlib.ScView = new wasmlib.ScView(sc.HScName, sc.HViewBalance); - params: sc.MutableBalanceParams = new sc.MutableBalanceParams(); - results: sc.ImmutableBalanceResults = new sc.ImmutableBalanceResults(); + params: sc.MutableBalanceParams = new sc.MutableBalanceParams(wasmlib.ScView.nilProxy); + results: sc.ImmutableBalanceResults = new sc.ImmutableBalanceResults(wasmlib.ScView.nilProxy); } export class GetAccountNonceCall { func: wasmlib.ScView = new wasmlib.ScView(sc.HScName, sc.HViewGetAccountNonce); - params: sc.MutableGetAccountNonceParams = new sc.MutableGetAccountNonceParams(); - results: sc.ImmutableGetAccountNonceResults = new sc.ImmutableGetAccountNonceResults(); + params: sc.MutableGetAccountNonceParams = new sc.MutableGetAccountNonceParams(wasmlib.ScView.nilProxy); + results: sc.ImmutableGetAccountNonceResults = new sc.ImmutableGetAccountNonceResults(wasmlib.ScView.nilProxy); } export class TotalAssetsCall { func: wasmlib.ScView = new wasmlib.ScView(sc.HScName, sc.HViewTotalAssets); - results: sc.ImmutableTotalAssetsResults = new sc.ImmutableTotalAssetsResults(); + results: sc.ImmutableTotalAssetsResults = new sc.ImmutableTotalAssetsResults(wasmlib.ScView.nilProxy); } export class ScFuncs { static deposit(ctx: wasmlib.ScFuncCallContext): DepositCall { - let f = new DepositCall(); - f.func.setPtrs(f.params, null); + const f = new DepositCall(); + f.params = new sc.MutableDepositParams(wasmlib.newCallParamsProxy(f.func)); return f; } static harvest(ctx: wasmlib.ScFuncCallContext): HarvestCall { - let f = new HarvestCall(); - f.func.setPtrs(f.params, null); + const f = new HarvestCall(); + f.params = new sc.MutableHarvestParams(wasmlib.newCallParamsProxy(f.func)); return f; } @@ -62,26 +63,28 @@ export class ScFuncs { } static accounts(ctx: wasmlib.ScViewCallContext): AccountsCall { - let f = new AccountsCall(); - f.func.setPtrs(null, f.results); + const f = new AccountsCall(); + f.results = new sc.ImmutableAccountsResults(wasmlib.newCallResultsProxy(f.func)); return f; } static balance(ctx: wasmlib.ScViewCallContext): BalanceCall { - let f = new BalanceCall(); - f.func.setPtrs(f.params, f.results); + const f = new BalanceCall(); + f.params = new sc.MutableBalanceParams(wasmlib.newCallParamsProxy(f.func)); + f.results = new sc.ImmutableBalanceResults(wasmlib.newCallResultsProxy(f.func)); return f; } static getAccountNonce(ctx: wasmlib.ScViewCallContext): GetAccountNonceCall { - let f = new GetAccountNonceCall(); - f.func.setPtrs(f.params, f.results); + const f = new GetAccountNonceCall(); + f.params = new sc.MutableGetAccountNonceParams(wasmlib.newCallParamsProxy(f.func)); + f.results = new sc.ImmutableGetAccountNonceResults(wasmlib.newCallResultsProxy(f.func)); return f; } static totalAssets(ctx: wasmlib.ScViewCallContext): TotalAssetsCall { - let f = new TotalAssetsCall(); - f.func.setPtrs(null, f.results); + const f = new TotalAssetsCall(); + f.results = new sc.ImmutableTotalAssetsResults(wasmlib.newCallResultsProxy(f.func)); return f; } } diff --git a/packages/wasmvm/wasmlib/ts/wasmlib/coreaccounts/params.ts b/packages/wasmvm/wasmlib/ts/wasmlib/coreaccounts/params.ts index 973afb6f3e..e178f2268f 100644 --- a/packages/wasmvm/wasmlib/ts/wasmlib/coreaccounts/params.ts +++ b/packages/wasmvm/wasmlib/ts/wasmlib/coreaccounts/params.ts @@ -6,60 +6,61 @@ // Change the json schema instead import * as wasmlib from "wasmlib"; +import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; -export class ImmutableDepositParams extends wasmlib.ScMapID { - agentID(): wasmlib.ScImmutableAgentID { - return new wasmlib.ScImmutableAgentID(this.mapID, wasmlib.Key32.fromString(sc.ParamAgentID)); +export class ImmutableDepositParams extends wasmtypes.ScProxy { + agentID(): wasmtypes.ScImmutableAgentID { + return new wasmtypes.ScImmutableAgentID(this.proxy.root(sc.ParamAgentID)); } } -export class MutableDepositParams extends wasmlib.ScMapID { - agentID(): wasmlib.ScMutableAgentID { - return new wasmlib.ScMutableAgentID(this.mapID, wasmlib.Key32.fromString(sc.ParamAgentID)); +export class MutableDepositParams extends wasmtypes.ScProxy { + agentID(): wasmtypes.ScMutableAgentID { + return new wasmtypes.ScMutableAgentID(this.proxy.root(sc.ParamAgentID)); } } -export class ImmutableHarvestParams extends wasmlib.ScMapID { - withdrawAmount(): wasmlib.ScImmutableInt64 { - return new wasmlib.ScImmutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ParamWithdrawAmount)); +export class ImmutableHarvestParams extends wasmtypes.ScProxy { + withdrawAmount(): wasmtypes.ScImmutableInt64 { + return new wasmtypes.ScImmutableInt64(this.proxy.root(sc.ParamWithdrawAmount)); } - withdrawColor(): wasmlib.ScImmutableColor { - return new wasmlib.ScImmutableColor(this.mapID, wasmlib.Key32.fromString(sc.ParamWithdrawColor)); + withdrawColor(): wasmtypes.ScImmutableColor { + return new wasmtypes.ScImmutableColor(this.proxy.root(sc.ParamWithdrawColor)); } } -export class MutableHarvestParams extends wasmlib.ScMapID { - withdrawAmount(): wasmlib.ScMutableInt64 { - return new wasmlib.ScMutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ParamWithdrawAmount)); +export class MutableHarvestParams extends wasmtypes.ScProxy { + withdrawAmount(): wasmtypes.ScMutableInt64 { + return new wasmtypes.ScMutableInt64(this.proxy.root(sc.ParamWithdrawAmount)); } - withdrawColor(): wasmlib.ScMutableColor { - return new wasmlib.ScMutableColor(this.mapID, wasmlib.Key32.fromString(sc.ParamWithdrawColor)); + withdrawColor(): wasmtypes.ScMutableColor { + return new wasmtypes.ScMutableColor(this.proxy.root(sc.ParamWithdrawColor)); } } -export class ImmutableBalanceParams extends wasmlib.ScMapID { - agentID(): wasmlib.ScImmutableAgentID { - return new wasmlib.ScImmutableAgentID(this.mapID, wasmlib.Key32.fromString(sc.ParamAgentID)); +export class ImmutableBalanceParams extends wasmtypes.ScProxy { + agentID(): wasmtypes.ScImmutableAgentID { + return new wasmtypes.ScImmutableAgentID(this.proxy.root(sc.ParamAgentID)); } } -export class MutableBalanceParams extends wasmlib.ScMapID { - agentID(): wasmlib.ScMutableAgentID { - return new wasmlib.ScMutableAgentID(this.mapID, wasmlib.Key32.fromString(sc.ParamAgentID)); +export class MutableBalanceParams extends wasmtypes.ScProxy { + agentID(): wasmtypes.ScMutableAgentID { + return new wasmtypes.ScMutableAgentID(this.proxy.root(sc.ParamAgentID)); } } -export class ImmutableGetAccountNonceParams extends wasmlib.ScMapID { - agentID(): wasmlib.ScImmutableAgentID { - return new wasmlib.ScImmutableAgentID(this.mapID, wasmlib.Key32.fromString(sc.ParamAgentID)); +export class ImmutableGetAccountNonceParams extends wasmtypes.ScProxy { + agentID(): wasmtypes.ScImmutableAgentID { + return new wasmtypes.ScImmutableAgentID(this.proxy.root(sc.ParamAgentID)); } } -export class MutableGetAccountNonceParams extends wasmlib.ScMapID { - agentID(): wasmlib.ScMutableAgentID { - return new wasmlib.ScMutableAgentID(this.mapID, wasmlib.Key32.fromString(sc.ParamAgentID)); +export class MutableGetAccountNonceParams extends wasmtypes.ScProxy { + agentID(): wasmtypes.ScMutableAgentID { + return new wasmtypes.ScMutableAgentID(this.proxy.root(sc.ParamAgentID)); } } diff --git a/packages/wasmvm/wasmlib/ts/wasmlib/coreaccounts/results.ts b/packages/wasmvm/wasmlib/ts/wasmlib/coreaccounts/results.ts index a6c043e58f..4240c44101 100644 --- a/packages/wasmvm/wasmlib/ts/wasmlib/coreaccounts/results.ts +++ b/packages/wasmvm/wasmlib/ts/wasmlib/coreaccounts/results.ts @@ -6,108 +6,89 @@ // Change the json schema instead import * as wasmlib from "wasmlib"; +import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; -export class MapAgentIDToImmutableBytes { - objID: i32; +export class MapAgentIDToImmutableBytes extends wasmtypes.ScProxy { - constructor(objID: i32) { - this.objID = objID; - } - - getBytes(key: wasmlib.ScAgentID): wasmlib.ScImmutableBytes { - return new wasmlib.ScImmutableBytes(this.objID, key.getKeyID()); + getBytes(key: wasmtypes.ScAgentID): wasmtypes.ScImmutableBytes { + return new wasmtypes.ScImmutableBytes(this.proxy.key(wasmtypes.agentIDToBytes(key))); } } -export class ImmutableAccountsResults extends wasmlib.ScMapID { +export class ImmutableAccountsResults extends wasmtypes.ScProxy { agents(): sc.MapAgentIDToImmutableBytes { - return new sc.MapAgentIDToImmutableBytes(this.mapID); + return new sc.MapAgentIDToImmutableBytes(this.proxy); } } -export class MapAgentIDToMutableBytes { - objID: i32; - - constructor(objID: i32) { - this.objID = objID; - } +export class MapAgentIDToMutableBytes extends wasmtypes.ScProxy { clear(): void { - wasmlib.clear(this.objID); + this.proxy.clearMap(); } - getBytes(key: wasmlib.ScAgentID): wasmlib.ScMutableBytes { - return new wasmlib.ScMutableBytes(this.objID, key.getKeyID()); + getBytes(key: wasmtypes.ScAgentID): wasmtypes.ScMutableBytes { + return new wasmtypes.ScMutableBytes(this.proxy.key(wasmtypes.agentIDToBytes(key))); } } -export class MutableAccountsResults extends wasmlib.ScMapID { +export class MutableAccountsResults extends wasmtypes.ScProxy { agents(): sc.MapAgentIDToMutableBytes { - return new sc.MapAgentIDToMutableBytes(this.mapID); + return new sc.MapAgentIDToMutableBytes(this.proxy); } } -export class MapColorToImmutableInt64 { - objID: i32; +export class MapColorToImmutableInt64 extends wasmtypes.ScProxy { - constructor(objID: i32) { - this.objID = objID; - } - - getInt64(key: wasmlib.ScColor): wasmlib.ScImmutableInt64 { - return new wasmlib.ScImmutableInt64(this.objID, key.getKeyID()); + getInt64(key: wasmtypes.ScColor): wasmtypes.ScImmutableInt64 { + return new wasmtypes.ScImmutableInt64(this.proxy.key(wasmtypes.colorToBytes(key))); } } -export class ImmutableBalanceResults extends wasmlib.ScMapID { +export class ImmutableBalanceResults extends wasmtypes.ScProxy { balances(): sc.MapColorToImmutableInt64 { - return new sc.MapColorToImmutableInt64(this.mapID); + return new sc.MapColorToImmutableInt64(this.proxy); } } -export class MapColorToMutableInt64 { - objID: i32; - - constructor(objID: i32) { - this.objID = objID; - } +export class MapColorToMutableInt64 extends wasmtypes.ScProxy { clear(): void { - wasmlib.clear(this.objID); + this.proxy.clearMap(); } - getInt64(key: wasmlib.ScColor): wasmlib.ScMutableInt64 { - return new wasmlib.ScMutableInt64(this.objID, key.getKeyID()); + getInt64(key: wasmtypes.ScColor): wasmtypes.ScMutableInt64 { + return new wasmtypes.ScMutableInt64(this.proxy.key(wasmtypes.colorToBytes(key))); } } -export class MutableBalanceResults extends wasmlib.ScMapID { +export class MutableBalanceResults extends wasmtypes.ScProxy { balances(): sc.MapColorToMutableInt64 { - return new sc.MapColorToMutableInt64(this.mapID); + return new sc.MapColorToMutableInt64(this.proxy); } } -export class ImmutableGetAccountNonceResults extends wasmlib.ScMapID { - accountNonce(): wasmlib.ScImmutableInt64 { - return new wasmlib.ScImmutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ResultAccountNonce)); +export class ImmutableGetAccountNonceResults extends wasmtypes.ScProxy { + accountNonce(): wasmtypes.ScImmutableInt64 { + return new wasmtypes.ScImmutableInt64(this.proxy.root(sc.ResultAccountNonce)); } } -export class MutableGetAccountNonceResults extends wasmlib.ScMapID { - accountNonce(): wasmlib.ScMutableInt64 { - return new wasmlib.ScMutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ResultAccountNonce)); +export class MutableGetAccountNonceResults extends wasmtypes.ScProxy { + accountNonce(): wasmtypes.ScMutableInt64 { + return new wasmtypes.ScMutableInt64(this.proxy.root(sc.ResultAccountNonce)); } } -export class ImmutableTotalAssetsResults extends wasmlib.ScMapID { +export class ImmutableTotalAssetsResults extends wasmtypes.ScProxy { balances(): sc.MapColorToImmutableInt64 { - return new sc.MapColorToImmutableInt64(this.mapID); + return new sc.MapColorToImmutableInt64(this.proxy); } } -export class MutableTotalAssetsResults extends wasmlib.ScMapID { +export class MutableTotalAssetsResults extends wasmtypes.ScProxy { balances(): sc.MapColorToMutableInt64 { - return new sc.MapColorToMutableInt64(this.mapID); + return new sc.MapColorToMutableInt64(this.proxy); } } diff --git a/packages/wasmvm/wasmlib/ts/wasmlib/coreblob/consts.ts b/packages/wasmvm/wasmlib/ts/wasmlib/coreblob/consts.ts index 9293fa2b4f..d75a05d05d 100644 --- a/packages/wasmvm/wasmlib/ts/wasmlib/coreblob/consts.ts +++ b/packages/wasmvm/wasmlib/ts/wasmlib/coreblob/consts.ts @@ -5,11 +5,11 @@ // >>>> DO NOT CHANGE THIS FILE! <<<< // Change the json schema instead -import * as wasmlib from "wasmlib"; +import * as wasmtypes from "wasmlib/wasmtypes"; export const ScName = "blob"; export const ScDescription = "Core blob contract"; -export const HScName = new wasmlib.ScHname(0xfd91bc63); +export const HScName = new wasmtypes.ScHname(0xfd91bc63); export const ParamBlobs = "this"; export const ParamField = "field"; @@ -24,7 +24,7 @@ export const ViewGetBlobField = "getBlobField"; export const ViewGetBlobInfo = "getBlobInfo"; export const ViewListBlobs = "listBlobs"; -export const HFuncStoreBlob = new wasmlib.ScHname(0xddd4c281); -export const HViewGetBlobField = new wasmlib.ScHname(0x1f448130); -export const HViewGetBlobInfo = new wasmlib.ScHname(0xfde4ab46); -export const HViewListBlobs = new wasmlib.ScHname(0x62ca7990); +export const HFuncStoreBlob = new wasmtypes.ScHname(0xddd4c281); +export const HViewGetBlobField = new wasmtypes.ScHname(0x1f448130); +export const HViewGetBlobInfo = new wasmtypes.ScHname(0xfde4ab46); +export const HViewListBlobs = new wasmtypes.ScHname(0x62ca7990); diff --git a/packages/wasmvm/wasmlib/ts/wasmlib/coreblob/contract.ts b/packages/wasmvm/wasmlib/ts/wasmlib/coreblob/contract.ts index 61e3359ae3..8e3fe48cd7 100644 --- a/packages/wasmvm/wasmlib/ts/wasmlib/coreblob/contract.ts +++ b/packages/wasmvm/wasmlib/ts/wasmlib/coreblob/contract.ts @@ -6,53 +6,57 @@ // Change the json schema instead import * as wasmlib from "wasmlib"; +import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; export class StoreBlobCall { func: wasmlib.ScFunc = new wasmlib.ScFunc(sc.HScName, sc.HFuncStoreBlob); - params: sc.MutableStoreBlobParams = new sc.MutableStoreBlobParams(); - results: sc.ImmutableStoreBlobResults = new sc.ImmutableStoreBlobResults(); + params: sc.MutableStoreBlobParams = new sc.MutableStoreBlobParams(wasmlib.ScView.nilProxy); + results: sc.ImmutableStoreBlobResults = new sc.ImmutableStoreBlobResults(wasmlib.ScView.nilProxy); } export class GetBlobFieldCall { func: wasmlib.ScView = new wasmlib.ScView(sc.HScName, sc.HViewGetBlobField); - params: sc.MutableGetBlobFieldParams = new sc.MutableGetBlobFieldParams(); - results: sc.ImmutableGetBlobFieldResults = new sc.ImmutableGetBlobFieldResults(); + params: sc.MutableGetBlobFieldParams = new sc.MutableGetBlobFieldParams(wasmlib.ScView.nilProxy); + results: sc.ImmutableGetBlobFieldResults = new sc.ImmutableGetBlobFieldResults(wasmlib.ScView.nilProxy); } export class GetBlobInfoCall { func: wasmlib.ScView = new wasmlib.ScView(sc.HScName, sc.HViewGetBlobInfo); - params: sc.MutableGetBlobInfoParams = new sc.MutableGetBlobInfoParams(); - results: sc.ImmutableGetBlobInfoResults = new sc.ImmutableGetBlobInfoResults(); + params: sc.MutableGetBlobInfoParams = new sc.MutableGetBlobInfoParams(wasmlib.ScView.nilProxy); + results: sc.ImmutableGetBlobInfoResults = new sc.ImmutableGetBlobInfoResults(wasmlib.ScView.nilProxy); } export class ListBlobsCall { func: wasmlib.ScView = new wasmlib.ScView(sc.HScName, sc.HViewListBlobs); - results: sc.ImmutableListBlobsResults = new sc.ImmutableListBlobsResults(); + results: sc.ImmutableListBlobsResults = new sc.ImmutableListBlobsResults(wasmlib.ScView.nilProxy); } export class ScFuncs { static storeBlob(ctx: wasmlib.ScFuncCallContext): StoreBlobCall { - let f = new StoreBlobCall(); - f.func.setPtrs(f.params, f.results); + const f = new StoreBlobCall(); + f.params = new sc.MutableStoreBlobParams(wasmlib.newCallParamsProxy(f.func)); + f.results = new sc.ImmutableStoreBlobResults(wasmlib.newCallResultsProxy(f.func)); return f; } static getBlobField(ctx: wasmlib.ScViewCallContext): GetBlobFieldCall { - let f = new GetBlobFieldCall(); - f.func.setPtrs(f.params, f.results); + const f = new GetBlobFieldCall(); + f.params = new sc.MutableGetBlobFieldParams(wasmlib.newCallParamsProxy(f.func)); + f.results = new sc.ImmutableGetBlobFieldResults(wasmlib.newCallResultsProxy(f.func)); return f; } static getBlobInfo(ctx: wasmlib.ScViewCallContext): GetBlobInfoCall { - let f = new GetBlobInfoCall(); - f.func.setPtrs(f.params, f.results); + const f = new GetBlobInfoCall(); + f.params = new sc.MutableGetBlobInfoParams(wasmlib.newCallParamsProxy(f.func)); + f.results = new sc.ImmutableGetBlobInfoResults(wasmlib.newCallResultsProxy(f.func)); return f; } static listBlobs(ctx: wasmlib.ScViewCallContext): ListBlobsCall { - let f = new ListBlobsCall(); - f.func.setPtrs(null, f.results); + const f = new ListBlobsCall(); + f.results = new sc.ImmutableListBlobsResults(wasmlib.newCallResultsProxy(f.func)); return f; } } diff --git a/packages/wasmvm/wasmlib/ts/wasmlib/coreblob/params.ts b/packages/wasmvm/wasmlib/ts/wasmlib/coreblob/params.ts index b334596688..0319775753 100644 --- a/packages/wasmvm/wasmlib/ts/wasmlib/coreblob/params.ts +++ b/packages/wasmvm/wasmlib/ts/wasmlib/coreblob/params.ts @@ -6,76 +6,67 @@ // Change the json schema instead import * as wasmlib from "wasmlib"; +import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; -export class MapStringToImmutableBytes { - objID: i32; +export class MapStringToImmutableBytes extends wasmtypes.ScProxy { - constructor(objID: i32) { - this.objID = objID; - } - - getBytes(key: string): wasmlib.ScImmutableBytes { - return new wasmlib.ScImmutableBytes(this.objID, wasmlib.Key32.fromString(key)); + getBytes(key: string): wasmtypes.ScImmutableBytes { + return new wasmtypes.ScImmutableBytes(this.proxy.key(wasmtypes.stringToBytes(key))); } } -export class ImmutableStoreBlobParams extends wasmlib.ScMapID { +export class ImmutableStoreBlobParams extends wasmtypes.ScProxy { blobs(): sc.MapStringToImmutableBytes { - return new sc.MapStringToImmutableBytes(this.mapID); + return new sc.MapStringToImmutableBytes(this.proxy); } } -export class MapStringToMutableBytes { - objID: i32; - - constructor(objID: i32) { - this.objID = objID; - } +export class MapStringToMutableBytes extends wasmtypes.ScProxy { clear(): void { - wasmlib.clear(this.objID); + this.proxy.clearMap(); } - getBytes(key: string): wasmlib.ScMutableBytes { - return new wasmlib.ScMutableBytes(this.objID, wasmlib.Key32.fromString(key)); + getBytes(key: string): wasmtypes.ScMutableBytes { + return new wasmtypes.ScMutableBytes(this.proxy.key(wasmtypes.stringToBytes(key))); } } -export class MutableStoreBlobParams extends wasmlib.ScMapID { +export class MutableStoreBlobParams extends wasmtypes.ScProxy { blobs(): sc.MapStringToMutableBytes { - return new sc.MapStringToMutableBytes(this.mapID); + return new sc.MapStringToMutableBytes(this.proxy); } } -export class ImmutableGetBlobFieldParams extends wasmlib.ScMapID { - field(): wasmlib.ScImmutableString { - return new wasmlib.ScImmutableString(this.mapID, wasmlib.Key32.fromString(sc.ParamField)); +export class ImmutableGetBlobFieldParams extends wasmtypes.ScProxy { + field(): wasmtypes.ScImmutableString { + return new wasmtypes.ScImmutableString(this.proxy.root(sc.ParamField)); } - hash(): wasmlib.ScImmutableHash { - return new wasmlib.ScImmutableHash(this.mapID, wasmlib.Key32.fromString(sc.ParamHash)); + hash(): wasmtypes.ScImmutableHash { + return new wasmtypes.ScImmutableHash(this.proxy.root(sc.ParamHash)); } } -export class MutableGetBlobFieldParams extends wasmlib.ScMapID { - field(): wasmlib.ScMutableString { - return new wasmlib.ScMutableString(this.mapID, wasmlib.Key32.fromString(sc.ParamField)); +export class MutableGetBlobFieldParams extends wasmtypes.ScProxy { + field(): wasmtypes.ScMutableString { + return new wasmtypes.ScMutableString(this.proxy.root(sc.ParamField)); } - hash(): wasmlib.ScMutableHash { - return new wasmlib.ScMutableHash(this.mapID, wasmlib.Key32.fromString(sc.ParamHash)); + hash(): wasmtypes.ScMutableHash { + return new wasmtypes.ScMutableHash(this.proxy.root(sc.ParamHash)); } } -export class ImmutableGetBlobInfoParams extends wasmlib.ScMapID { - hash(): wasmlib.ScImmutableHash { - return new wasmlib.ScImmutableHash(this.mapID, wasmlib.Key32.fromString(sc.ParamHash)); +export class ImmutableGetBlobInfoParams extends wasmtypes.ScProxy { + hash(): wasmtypes.ScImmutableHash { + return new wasmtypes.ScImmutableHash(this.proxy.root(sc.ParamHash)); } } -export class MutableGetBlobInfoParams extends wasmlib.ScMapID { - hash(): wasmlib.ScMutableHash { - return new wasmlib.ScMutableHash(this.mapID, wasmlib.Key32.fromString(sc.ParamHash)); +export class MutableGetBlobInfoParams extends wasmtypes.ScProxy { + hash(): wasmtypes.ScMutableHash { + return new wasmtypes.ScMutableHash(this.proxy.root(sc.ParamHash)); } } diff --git a/packages/wasmvm/wasmlib/ts/wasmlib/coreblob/results.ts b/packages/wasmvm/wasmlib/ts/wasmlib/coreblob/results.ts index f10b4bf968..cf0d7fc40d 100644 --- a/packages/wasmvm/wasmlib/ts/wasmlib/coreblob/results.ts +++ b/packages/wasmvm/wasmlib/ts/wasmlib/coreblob/results.ts @@ -6,108 +6,89 @@ // Change the json schema instead import * as wasmlib from "wasmlib"; +import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; -export class ImmutableStoreBlobResults extends wasmlib.ScMapID { - hash(): wasmlib.ScImmutableHash { - return new wasmlib.ScImmutableHash(this.mapID, wasmlib.Key32.fromString(sc.ResultHash)); +export class ImmutableStoreBlobResults extends wasmtypes.ScProxy { + hash(): wasmtypes.ScImmutableHash { + return new wasmtypes.ScImmutableHash(this.proxy.root(sc.ResultHash)); } } -export class MutableStoreBlobResults extends wasmlib.ScMapID { - hash(): wasmlib.ScMutableHash { - return new wasmlib.ScMutableHash(this.mapID, wasmlib.Key32.fromString(sc.ResultHash)); +export class MutableStoreBlobResults extends wasmtypes.ScProxy { + hash(): wasmtypes.ScMutableHash { + return new wasmtypes.ScMutableHash(this.proxy.root(sc.ResultHash)); } } -export class ImmutableGetBlobFieldResults extends wasmlib.ScMapID { - bytes(): wasmlib.ScImmutableBytes { - return new wasmlib.ScImmutableBytes(this.mapID, wasmlib.Key32.fromString(sc.ResultBytes)); +export class ImmutableGetBlobFieldResults extends wasmtypes.ScProxy { + bytes(): wasmtypes.ScImmutableBytes { + return new wasmtypes.ScImmutableBytes(this.proxy.root(sc.ResultBytes)); } } -export class MutableGetBlobFieldResults extends wasmlib.ScMapID { - bytes(): wasmlib.ScMutableBytes { - return new wasmlib.ScMutableBytes(this.mapID, wasmlib.Key32.fromString(sc.ResultBytes)); +export class MutableGetBlobFieldResults extends wasmtypes.ScProxy { + bytes(): wasmtypes.ScMutableBytes { + return new wasmtypes.ScMutableBytes(this.proxy.root(sc.ResultBytes)); } } -export class MapStringToImmutableInt32 { - objID: i32; +export class MapStringToImmutableInt32 extends wasmtypes.ScProxy { - constructor(objID: i32) { - this.objID = objID; - } - - getInt32(key: string): wasmlib.ScImmutableInt32 { - return new wasmlib.ScImmutableInt32(this.objID, wasmlib.Key32.fromString(key)); + getInt32(key: string): wasmtypes.ScImmutableInt32 { + return new wasmtypes.ScImmutableInt32(this.proxy.key(wasmtypes.stringToBytes(key))); } } -export class ImmutableGetBlobInfoResults extends wasmlib.ScMapID { +export class ImmutableGetBlobInfoResults extends wasmtypes.ScProxy { blobSizes(): sc.MapStringToImmutableInt32 { - return new sc.MapStringToImmutableInt32(this.mapID); + return new sc.MapStringToImmutableInt32(this.proxy); } } -export class MapStringToMutableInt32 { - objID: i32; - - constructor(objID: i32) { - this.objID = objID; - } +export class MapStringToMutableInt32 extends wasmtypes.ScProxy { clear(): void { - wasmlib.clear(this.objID); + this.proxy.clearMap(); } - getInt32(key: string): wasmlib.ScMutableInt32 { - return new wasmlib.ScMutableInt32(this.objID, wasmlib.Key32.fromString(key)); + getInt32(key: string): wasmtypes.ScMutableInt32 { + return new wasmtypes.ScMutableInt32(this.proxy.key(wasmtypes.stringToBytes(key))); } } -export class MutableGetBlobInfoResults extends wasmlib.ScMapID { +export class MutableGetBlobInfoResults extends wasmtypes.ScProxy { blobSizes(): sc.MapStringToMutableInt32 { - return new sc.MapStringToMutableInt32(this.mapID); + return new sc.MapStringToMutableInt32(this.proxy); } } -export class MapHashToImmutableInt32 { - objID: i32; +export class MapHashToImmutableInt32 extends wasmtypes.ScProxy { - constructor(objID: i32) { - this.objID = objID; - } - - getInt32(key: wasmlib.ScHash): wasmlib.ScImmutableInt32 { - return new wasmlib.ScImmutableInt32(this.objID, key.getKeyID()); + getInt32(key: wasmtypes.ScHash): wasmtypes.ScImmutableInt32 { + return new wasmtypes.ScImmutableInt32(this.proxy.key(wasmtypes.hashToBytes(key))); } } -export class ImmutableListBlobsResults extends wasmlib.ScMapID { +export class ImmutableListBlobsResults extends wasmtypes.ScProxy { blobSizes(): sc.MapHashToImmutableInt32 { - return new sc.MapHashToImmutableInt32(this.mapID); + return new sc.MapHashToImmutableInt32(this.proxy); } } -export class MapHashToMutableInt32 { - objID: i32; - - constructor(objID: i32) { - this.objID = objID; - } +export class MapHashToMutableInt32 extends wasmtypes.ScProxy { clear(): void { - wasmlib.clear(this.objID); + this.proxy.clearMap(); } - getInt32(key: wasmlib.ScHash): wasmlib.ScMutableInt32 { - return new wasmlib.ScMutableInt32(this.objID, key.getKeyID()); + getInt32(key: wasmtypes.ScHash): wasmtypes.ScMutableInt32 { + return new wasmtypes.ScMutableInt32(this.proxy.key(wasmtypes.hashToBytes(key))); } } -export class MutableListBlobsResults extends wasmlib.ScMapID { +export class MutableListBlobsResults extends wasmtypes.ScProxy { blobSizes(): sc.MapHashToMutableInt32 { - return new sc.MapHashToMutableInt32(this.mapID); + return new sc.MapHashToMutableInt32(this.proxy); } } diff --git a/packages/wasmvm/wasmlib/ts/wasmlib/coreblocklog/consts.ts b/packages/wasmvm/wasmlib/ts/wasmlib/coreblocklog/consts.ts index 8525d71f43..11f90ad0e6 100644 --- a/packages/wasmvm/wasmlib/ts/wasmlib/coreblocklog/consts.ts +++ b/packages/wasmvm/wasmlib/ts/wasmlib/coreblocklog/consts.ts @@ -5,11 +5,11 @@ // >>>> DO NOT CHANGE THIS FILE! <<<< // Change the json schema instead -import * as wasmlib from "wasmlib"; +import * as wasmtypes from "wasmlib/wasmtypes"; export const ScName = "blocklog"; export const ScDescription = "Core block log contract"; -export const HScName = new wasmlib.ScHname(0xf538ef2b); +export const HScName = new wasmtypes.ScHname(0xf538ef2b); export const ParamBlockIndex = "n"; export const ParamContractHname = "h"; @@ -38,13 +38,13 @@ export const ViewGetRequestReceipt = "getRequestReceipt"; export const ViewGetRequestReceiptsForBlock = "getRequestReceiptsForBlock"; export const ViewIsRequestProcessed = "isRequestProcessed"; -export const HViewControlAddresses = new wasmlib.ScHname(0x796bd223); -export const HViewGetBlockInfo = new wasmlib.ScHname(0xbe89f9b3); -export const HViewGetEventsForBlock = new wasmlib.ScHname(0x36232798); -export const HViewGetEventsForContract = new wasmlib.ScHname(0x682a1922); -export const HViewGetEventsForRequest = new wasmlib.ScHname(0x4f8d68e4); -export const HViewGetLatestBlockInfo = new wasmlib.ScHname(0x084a1760); -export const HViewGetRequestIDsForBlock = new wasmlib.ScHname(0x5a20327a); -export const HViewGetRequestReceipt = new wasmlib.ScHname(0xb7f9534f); -export const HViewGetRequestReceiptsForBlock = new wasmlib.ScHname(0x77e3beef); -export const HViewIsRequestProcessed = new wasmlib.ScHname(0xd57d50a9); +export const HViewControlAddresses = new wasmtypes.ScHname(0x796bd223); +export const HViewGetBlockInfo = new wasmtypes.ScHname(0xbe89f9b3); +export const HViewGetEventsForBlock = new wasmtypes.ScHname(0x36232798); +export const HViewGetEventsForContract = new wasmtypes.ScHname(0x682a1922); +export const HViewGetEventsForRequest = new wasmtypes.ScHname(0x4f8d68e4); +export const HViewGetLatestBlockInfo = new wasmtypes.ScHname(0x084a1760); +export const HViewGetRequestIDsForBlock = new wasmtypes.ScHname(0x5a20327a); +export const HViewGetRequestReceipt = new wasmtypes.ScHname(0xb7f9534f); +export const HViewGetRequestReceiptsForBlock = new wasmtypes.ScHname(0x77e3beef); +export const HViewIsRequestProcessed = new wasmtypes.ScHname(0xd57d50a9); diff --git a/packages/wasmvm/wasmlib/ts/wasmlib/coreblocklog/contract.ts b/packages/wasmvm/wasmlib/ts/wasmlib/coreblocklog/contract.ts index 4c7fe2800f..1b399b29eb 100644 --- a/packages/wasmvm/wasmlib/ts/wasmlib/coreblocklog/contract.ts +++ b/packages/wasmvm/wasmlib/ts/wasmlib/coreblocklog/contract.ts @@ -6,124 +6,133 @@ // Change the json schema instead import * as wasmlib from "wasmlib"; +import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; export class ControlAddressesCall { func: wasmlib.ScView = new wasmlib.ScView(sc.HScName, sc.HViewControlAddresses); - results: sc.ImmutableControlAddressesResults = new sc.ImmutableControlAddressesResults(); + results: sc.ImmutableControlAddressesResults = new sc.ImmutableControlAddressesResults(wasmlib.ScView.nilProxy); } export class GetBlockInfoCall { func: wasmlib.ScView = new wasmlib.ScView(sc.HScName, sc.HViewGetBlockInfo); - params: sc.MutableGetBlockInfoParams = new sc.MutableGetBlockInfoParams(); - results: sc.ImmutableGetBlockInfoResults = new sc.ImmutableGetBlockInfoResults(); + params: sc.MutableGetBlockInfoParams = new sc.MutableGetBlockInfoParams(wasmlib.ScView.nilProxy); + results: sc.ImmutableGetBlockInfoResults = new sc.ImmutableGetBlockInfoResults(wasmlib.ScView.nilProxy); } export class GetEventsForBlockCall { func: wasmlib.ScView = new wasmlib.ScView(sc.HScName, sc.HViewGetEventsForBlock); - params: sc.MutableGetEventsForBlockParams = new sc.MutableGetEventsForBlockParams(); - results: sc.ImmutableGetEventsForBlockResults = new sc.ImmutableGetEventsForBlockResults(); + params: sc.MutableGetEventsForBlockParams = new sc.MutableGetEventsForBlockParams(wasmlib.ScView.nilProxy); + results: sc.ImmutableGetEventsForBlockResults = new sc.ImmutableGetEventsForBlockResults(wasmlib.ScView.nilProxy); } export class GetEventsForContractCall { func: wasmlib.ScView = new wasmlib.ScView(sc.HScName, sc.HViewGetEventsForContract); - params: sc.MutableGetEventsForContractParams = new sc.MutableGetEventsForContractParams(); - results: sc.ImmutableGetEventsForContractResults = new sc.ImmutableGetEventsForContractResults(); + params: sc.MutableGetEventsForContractParams = new sc.MutableGetEventsForContractParams(wasmlib.ScView.nilProxy); + results: sc.ImmutableGetEventsForContractResults = new sc.ImmutableGetEventsForContractResults(wasmlib.ScView.nilProxy); } export class GetEventsForRequestCall { func: wasmlib.ScView = new wasmlib.ScView(sc.HScName, sc.HViewGetEventsForRequest); - params: sc.MutableGetEventsForRequestParams = new sc.MutableGetEventsForRequestParams(); - results: sc.ImmutableGetEventsForRequestResults = new sc.ImmutableGetEventsForRequestResults(); + params: sc.MutableGetEventsForRequestParams = new sc.MutableGetEventsForRequestParams(wasmlib.ScView.nilProxy); + results: sc.ImmutableGetEventsForRequestResults = new sc.ImmutableGetEventsForRequestResults(wasmlib.ScView.nilProxy); } export class GetLatestBlockInfoCall { func: wasmlib.ScView = new wasmlib.ScView(sc.HScName, sc.HViewGetLatestBlockInfo); - results: sc.ImmutableGetLatestBlockInfoResults = new sc.ImmutableGetLatestBlockInfoResults(); + results: sc.ImmutableGetLatestBlockInfoResults = new sc.ImmutableGetLatestBlockInfoResults(wasmlib.ScView.nilProxy); } export class GetRequestIDsForBlockCall { func: wasmlib.ScView = new wasmlib.ScView(sc.HScName, sc.HViewGetRequestIDsForBlock); - params: sc.MutableGetRequestIDsForBlockParams = new sc.MutableGetRequestIDsForBlockParams(); - results: sc.ImmutableGetRequestIDsForBlockResults = new sc.ImmutableGetRequestIDsForBlockResults(); + params: sc.MutableGetRequestIDsForBlockParams = new sc.MutableGetRequestIDsForBlockParams(wasmlib.ScView.nilProxy); + results: sc.ImmutableGetRequestIDsForBlockResults = new sc.ImmutableGetRequestIDsForBlockResults(wasmlib.ScView.nilProxy); } export class GetRequestReceiptCall { func: wasmlib.ScView = new wasmlib.ScView(sc.HScName, sc.HViewGetRequestReceipt); - params: sc.MutableGetRequestReceiptParams = new sc.MutableGetRequestReceiptParams(); - results: sc.ImmutableGetRequestReceiptResults = new sc.ImmutableGetRequestReceiptResults(); + params: sc.MutableGetRequestReceiptParams = new sc.MutableGetRequestReceiptParams(wasmlib.ScView.nilProxy); + results: sc.ImmutableGetRequestReceiptResults = new sc.ImmutableGetRequestReceiptResults(wasmlib.ScView.nilProxy); } export class GetRequestReceiptsForBlockCall { func: wasmlib.ScView = new wasmlib.ScView(sc.HScName, sc.HViewGetRequestReceiptsForBlock); - params: sc.MutableGetRequestReceiptsForBlockParams = new sc.MutableGetRequestReceiptsForBlockParams(); - results: sc.ImmutableGetRequestReceiptsForBlockResults = new sc.ImmutableGetRequestReceiptsForBlockResults(); + params: sc.MutableGetRequestReceiptsForBlockParams = new sc.MutableGetRequestReceiptsForBlockParams(wasmlib.ScView.nilProxy); + results: sc.ImmutableGetRequestReceiptsForBlockResults = new sc.ImmutableGetRequestReceiptsForBlockResults(wasmlib.ScView.nilProxy); } export class IsRequestProcessedCall { func: wasmlib.ScView = new wasmlib.ScView(sc.HScName, sc.HViewIsRequestProcessed); - params: sc.MutableIsRequestProcessedParams = new sc.MutableIsRequestProcessedParams(); - results: sc.ImmutableIsRequestProcessedResults = new sc.ImmutableIsRequestProcessedResults(); + params: sc.MutableIsRequestProcessedParams = new sc.MutableIsRequestProcessedParams(wasmlib.ScView.nilProxy); + results: sc.ImmutableIsRequestProcessedResults = new sc.ImmutableIsRequestProcessedResults(wasmlib.ScView.nilProxy); } export class ScFuncs { static controlAddresses(ctx: wasmlib.ScViewCallContext): ControlAddressesCall { - let f = new ControlAddressesCall(); - f.func.setPtrs(null, f.results); + const f = new ControlAddressesCall(); + f.results = new sc.ImmutableControlAddressesResults(wasmlib.newCallResultsProxy(f.func)); return f; } static getBlockInfo(ctx: wasmlib.ScViewCallContext): GetBlockInfoCall { - let f = new GetBlockInfoCall(); - f.func.setPtrs(f.params, f.results); + const f = new GetBlockInfoCall(); + f.params = new sc.MutableGetBlockInfoParams(wasmlib.newCallParamsProxy(f.func)); + f.results = new sc.ImmutableGetBlockInfoResults(wasmlib.newCallResultsProxy(f.func)); return f; } static getEventsForBlock(ctx: wasmlib.ScViewCallContext): GetEventsForBlockCall { - let f = new GetEventsForBlockCall(); - f.func.setPtrs(f.params, f.results); + const f = new GetEventsForBlockCall(); + f.params = new sc.MutableGetEventsForBlockParams(wasmlib.newCallParamsProxy(f.func)); + f.results = new sc.ImmutableGetEventsForBlockResults(wasmlib.newCallResultsProxy(f.func)); return f; } static getEventsForContract(ctx: wasmlib.ScViewCallContext): GetEventsForContractCall { - let f = new GetEventsForContractCall(); - f.func.setPtrs(f.params, f.results); + const f = new GetEventsForContractCall(); + f.params = new sc.MutableGetEventsForContractParams(wasmlib.newCallParamsProxy(f.func)); + f.results = new sc.ImmutableGetEventsForContractResults(wasmlib.newCallResultsProxy(f.func)); return f; } static getEventsForRequest(ctx: wasmlib.ScViewCallContext): GetEventsForRequestCall { - let f = new GetEventsForRequestCall(); - f.func.setPtrs(f.params, f.results); + const f = new GetEventsForRequestCall(); + f.params = new sc.MutableGetEventsForRequestParams(wasmlib.newCallParamsProxy(f.func)); + f.results = new sc.ImmutableGetEventsForRequestResults(wasmlib.newCallResultsProxy(f.func)); return f; } static getLatestBlockInfo(ctx: wasmlib.ScViewCallContext): GetLatestBlockInfoCall { - let f = new GetLatestBlockInfoCall(); - f.func.setPtrs(null, f.results); + const f = new GetLatestBlockInfoCall(); + f.results = new sc.ImmutableGetLatestBlockInfoResults(wasmlib.newCallResultsProxy(f.func)); return f; } static getRequestIDsForBlock(ctx: wasmlib.ScViewCallContext): GetRequestIDsForBlockCall { - let f = new GetRequestIDsForBlockCall(); - f.func.setPtrs(f.params, f.results); + const f = new GetRequestIDsForBlockCall(); + f.params = new sc.MutableGetRequestIDsForBlockParams(wasmlib.newCallParamsProxy(f.func)); + f.results = new sc.ImmutableGetRequestIDsForBlockResults(wasmlib.newCallResultsProxy(f.func)); return f; } static getRequestReceipt(ctx: wasmlib.ScViewCallContext): GetRequestReceiptCall { - let f = new GetRequestReceiptCall(); - f.func.setPtrs(f.params, f.results); + const f = new GetRequestReceiptCall(); + f.params = new sc.MutableGetRequestReceiptParams(wasmlib.newCallParamsProxy(f.func)); + f.results = new sc.ImmutableGetRequestReceiptResults(wasmlib.newCallResultsProxy(f.func)); return f; } static getRequestReceiptsForBlock(ctx: wasmlib.ScViewCallContext): GetRequestReceiptsForBlockCall { - let f = new GetRequestReceiptsForBlockCall(); - f.func.setPtrs(f.params, f.results); + const f = new GetRequestReceiptsForBlockCall(); + f.params = new sc.MutableGetRequestReceiptsForBlockParams(wasmlib.newCallParamsProxy(f.func)); + f.results = new sc.ImmutableGetRequestReceiptsForBlockResults(wasmlib.newCallResultsProxy(f.func)); return f; } static isRequestProcessed(ctx: wasmlib.ScViewCallContext): IsRequestProcessedCall { - let f = new IsRequestProcessedCall(); - f.func.setPtrs(f.params, f.results); + const f = new IsRequestProcessedCall(); + f.params = new sc.MutableIsRequestProcessedParams(wasmlib.newCallParamsProxy(f.func)); + f.results = new sc.ImmutableIsRequestProcessedResults(wasmlib.newCallResultsProxy(f.func)); return f; } } diff --git a/packages/wasmvm/wasmlib/ts/wasmlib/coreblocklog/params.ts b/packages/wasmvm/wasmlib/ts/wasmlib/coreblocklog/params.ts index ef0d9d3587..217837ec0e 100644 --- a/packages/wasmvm/wasmlib/ts/wasmlib/coreblocklog/params.ts +++ b/packages/wasmvm/wasmlib/ts/wasmlib/coreblocklog/params.ts @@ -6,116 +6,117 @@ // Change the json schema instead import * as wasmlib from "wasmlib"; +import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; -export class ImmutableGetBlockInfoParams extends wasmlib.ScMapID { - blockIndex(): wasmlib.ScImmutableUint32 { - return new wasmlib.ScImmutableUint32(this.mapID, wasmlib.Key32.fromString(sc.ParamBlockIndex)); +export class ImmutableGetBlockInfoParams extends wasmtypes.ScProxy { + blockIndex(): wasmtypes.ScImmutableUint32 { + return new wasmtypes.ScImmutableUint32(this.proxy.root(sc.ParamBlockIndex)); } } -export class MutableGetBlockInfoParams extends wasmlib.ScMapID { - blockIndex(): wasmlib.ScMutableUint32 { - return new wasmlib.ScMutableUint32(this.mapID, wasmlib.Key32.fromString(sc.ParamBlockIndex)); +export class MutableGetBlockInfoParams extends wasmtypes.ScProxy { + blockIndex(): wasmtypes.ScMutableUint32 { + return new wasmtypes.ScMutableUint32(this.proxy.root(sc.ParamBlockIndex)); } } -export class ImmutableGetEventsForBlockParams extends wasmlib.ScMapID { - blockIndex(): wasmlib.ScImmutableUint32 { - return new wasmlib.ScImmutableUint32(this.mapID, wasmlib.Key32.fromString(sc.ParamBlockIndex)); +export class ImmutableGetEventsForBlockParams extends wasmtypes.ScProxy { + blockIndex(): wasmtypes.ScImmutableUint32 { + return new wasmtypes.ScImmutableUint32(this.proxy.root(sc.ParamBlockIndex)); } } -export class MutableGetEventsForBlockParams extends wasmlib.ScMapID { - blockIndex(): wasmlib.ScMutableUint32 { - return new wasmlib.ScMutableUint32(this.mapID, wasmlib.Key32.fromString(sc.ParamBlockIndex)); +export class MutableGetEventsForBlockParams extends wasmtypes.ScProxy { + blockIndex(): wasmtypes.ScMutableUint32 { + return new wasmtypes.ScMutableUint32(this.proxy.root(sc.ParamBlockIndex)); } } -export class ImmutableGetEventsForContractParams extends wasmlib.ScMapID { - contractHname(): wasmlib.ScImmutableHname { - return new wasmlib.ScImmutableHname(this.mapID, wasmlib.Key32.fromString(sc.ParamContractHname)); +export class ImmutableGetEventsForContractParams extends wasmtypes.ScProxy { + contractHname(): wasmtypes.ScImmutableHname { + return new wasmtypes.ScImmutableHname(this.proxy.root(sc.ParamContractHname)); } - fromBlock(): wasmlib.ScImmutableUint32 { - return new wasmlib.ScImmutableUint32(this.mapID, wasmlib.Key32.fromString(sc.ParamFromBlock)); + fromBlock(): wasmtypes.ScImmutableUint32 { + return new wasmtypes.ScImmutableUint32(this.proxy.root(sc.ParamFromBlock)); } - toBlock(): wasmlib.ScImmutableUint32 { - return new wasmlib.ScImmutableUint32(this.mapID, wasmlib.Key32.fromString(sc.ParamToBlock)); + toBlock(): wasmtypes.ScImmutableUint32 { + return new wasmtypes.ScImmutableUint32(this.proxy.root(sc.ParamToBlock)); } } -export class MutableGetEventsForContractParams extends wasmlib.ScMapID { - contractHname(): wasmlib.ScMutableHname { - return new wasmlib.ScMutableHname(this.mapID, wasmlib.Key32.fromString(sc.ParamContractHname)); +export class MutableGetEventsForContractParams extends wasmtypes.ScProxy { + contractHname(): wasmtypes.ScMutableHname { + return new wasmtypes.ScMutableHname(this.proxy.root(sc.ParamContractHname)); } - fromBlock(): wasmlib.ScMutableUint32 { - return new wasmlib.ScMutableUint32(this.mapID, wasmlib.Key32.fromString(sc.ParamFromBlock)); + fromBlock(): wasmtypes.ScMutableUint32 { + return new wasmtypes.ScMutableUint32(this.proxy.root(sc.ParamFromBlock)); } - toBlock(): wasmlib.ScMutableUint32 { - return new wasmlib.ScMutableUint32(this.mapID, wasmlib.Key32.fromString(sc.ParamToBlock)); + toBlock(): wasmtypes.ScMutableUint32 { + return new wasmtypes.ScMutableUint32(this.proxy.root(sc.ParamToBlock)); } } -export class ImmutableGetEventsForRequestParams extends wasmlib.ScMapID { - requestID(): wasmlib.ScImmutableRequestID { - return new wasmlib.ScImmutableRequestID(this.mapID, wasmlib.Key32.fromString(sc.ParamRequestID)); +export class ImmutableGetEventsForRequestParams extends wasmtypes.ScProxy { + requestID(): wasmtypes.ScImmutableRequestID { + return new wasmtypes.ScImmutableRequestID(this.proxy.root(sc.ParamRequestID)); } } -export class MutableGetEventsForRequestParams extends wasmlib.ScMapID { - requestID(): wasmlib.ScMutableRequestID { - return new wasmlib.ScMutableRequestID(this.mapID, wasmlib.Key32.fromString(sc.ParamRequestID)); +export class MutableGetEventsForRequestParams extends wasmtypes.ScProxy { + requestID(): wasmtypes.ScMutableRequestID { + return new wasmtypes.ScMutableRequestID(this.proxy.root(sc.ParamRequestID)); } } -export class ImmutableGetRequestIDsForBlockParams extends wasmlib.ScMapID { - blockIndex(): wasmlib.ScImmutableUint32 { - return new wasmlib.ScImmutableUint32(this.mapID, wasmlib.Key32.fromString(sc.ParamBlockIndex)); +export class ImmutableGetRequestIDsForBlockParams extends wasmtypes.ScProxy { + blockIndex(): wasmtypes.ScImmutableUint32 { + return new wasmtypes.ScImmutableUint32(this.proxy.root(sc.ParamBlockIndex)); } } -export class MutableGetRequestIDsForBlockParams extends wasmlib.ScMapID { - blockIndex(): wasmlib.ScMutableUint32 { - return new wasmlib.ScMutableUint32(this.mapID, wasmlib.Key32.fromString(sc.ParamBlockIndex)); +export class MutableGetRequestIDsForBlockParams extends wasmtypes.ScProxy { + blockIndex(): wasmtypes.ScMutableUint32 { + return new wasmtypes.ScMutableUint32(this.proxy.root(sc.ParamBlockIndex)); } } -export class ImmutableGetRequestReceiptParams extends wasmlib.ScMapID { - requestID(): wasmlib.ScImmutableRequestID { - return new wasmlib.ScImmutableRequestID(this.mapID, wasmlib.Key32.fromString(sc.ParamRequestID)); +export class ImmutableGetRequestReceiptParams extends wasmtypes.ScProxy { + requestID(): wasmtypes.ScImmutableRequestID { + return new wasmtypes.ScImmutableRequestID(this.proxy.root(sc.ParamRequestID)); } } -export class MutableGetRequestReceiptParams extends wasmlib.ScMapID { - requestID(): wasmlib.ScMutableRequestID { - return new wasmlib.ScMutableRequestID(this.mapID, wasmlib.Key32.fromString(sc.ParamRequestID)); +export class MutableGetRequestReceiptParams extends wasmtypes.ScProxy { + requestID(): wasmtypes.ScMutableRequestID { + return new wasmtypes.ScMutableRequestID(this.proxy.root(sc.ParamRequestID)); } } -export class ImmutableGetRequestReceiptsForBlockParams extends wasmlib.ScMapID { - blockIndex(): wasmlib.ScImmutableUint32 { - return new wasmlib.ScImmutableUint32(this.mapID, wasmlib.Key32.fromString(sc.ParamBlockIndex)); +export class ImmutableGetRequestReceiptsForBlockParams extends wasmtypes.ScProxy { + blockIndex(): wasmtypes.ScImmutableUint32 { + return new wasmtypes.ScImmutableUint32(this.proxy.root(sc.ParamBlockIndex)); } } -export class MutableGetRequestReceiptsForBlockParams extends wasmlib.ScMapID { - blockIndex(): wasmlib.ScMutableUint32 { - return new wasmlib.ScMutableUint32(this.mapID, wasmlib.Key32.fromString(sc.ParamBlockIndex)); +export class MutableGetRequestReceiptsForBlockParams extends wasmtypes.ScProxy { + blockIndex(): wasmtypes.ScMutableUint32 { + return new wasmtypes.ScMutableUint32(this.proxy.root(sc.ParamBlockIndex)); } } -export class ImmutableIsRequestProcessedParams extends wasmlib.ScMapID { - requestID(): wasmlib.ScImmutableRequestID { - return new wasmlib.ScImmutableRequestID(this.mapID, wasmlib.Key32.fromString(sc.ParamRequestID)); +export class ImmutableIsRequestProcessedParams extends wasmtypes.ScProxy { + requestID(): wasmtypes.ScImmutableRequestID { + return new wasmtypes.ScImmutableRequestID(this.proxy.root(sc.ParamRequestID)); } } -export class MutableIsRequestProcessedParams extends wasmlib.ScMapID { - requestID(): wasmlib.ScMutableRequestID { - return new wasmlib.ScMutableRequestID(this.mapID, wasmlib.Key32.fromString(sc.ParamRequestID)); +export class MutableIsRequestProcessedParams extends wasmtypes.ScProxy { + requestID(): wasmtypes.ScMutableRequestID { + return new wasmtypes.ScMutableRequestID(this.proxy.root(sc.ParamRequestID)); } } diff --git a/packages/wasmvm/wasmlib/ts/wasmlib/coreblocklog/results.ts b/packages/wasmvm/wasmlib/ts/wasmlib/coreblocklog/results.ts index 9330387092..ac4f341d57 100644 --- a/packages/wasmvm/wasmlib/ts/wasmlib/coreblocklog/results.ts +++ b/packages/wasmvm/wasmlib/ts/wasmlib/coreblocklog/results.ts @@ -6,246 +6,225 @@ // Change the json schema instead import * as wasmlib from "wasmlib"; +import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; -export class ImmutableControlAddressesResults extends wasmlib.ScMapID { - blockIndex(): wasmlib.ScImmutableUint32 { - return new wasmlib.ScImmutableUint32(this.mapID, wasmlib.Key32.fromString(sc.ResultBlockIndex)); +export class ImmutableControlAddressesResults extends wasmtypes.ScProxy { + blockIndex(): wasmtypes.ScImmutableUint32 { + return new wasmtypes.ScImmutableUint32(this.proxy.root(sc.ResultBlockIndex)); } - governingAddress(): wasmlib.ScImmutableAddress { - return new wasmlib.ScImmutableAddress(this.mapID, wasmlib.Key32.fromString(sc.ResultGoverningAddress)); + governingAddress(): wasmtypes.ScImmutableAddress { + return new wasmtypes.ScImmutableAddress(this.proxy.root(sc.ResultGoverningAddress)); } - stateControllerAddress(): wasmlib.ScImmutableAddress { - return new wasmlib.ScImmutableAddress(this.mapID, wasmlib.Key32.fromString(sc.ResultStateControllerAddress)); + stateControllerAddress(): wasmtypes.ScImmutableAddress { + return new wasmtypes.ScImmutableAddress(this.proxy.root(sc.ResultStateControllerAddress)); } } -export class MutableControlAddressesResults extends wasmlib.ScMapID { - blockIndex(): wasmlib.ScMutableUint32 { - return new wasmlib.ScMutableUint32(this.mapID, wasmlib.Key32.fromString(sc.ResultBlockIndex)); +export class MutableControlAddressesResults extends wasmtypes.ScProxy { + blockIndex(): wasmtypes.ScMutableUint32 { + return new wasmtypes.ScMutableUint32(this.proxy.root(sc.ResultBlockIndex)); } - governingAddress(): wasmlib.ScMutableAddress { - return new wasmlib.ScMutableAddress(this.mapID, wasmlib.Key32.fromString(sc.ResultGoverningAddress)); + governingAddress(): wasmtypes.ScMutableAddress { + return new wasmtypes.ScMutableAddress(this.proxy.root(sc.ResultGoverningAddress)); } - stateControllerAddress(): wasmlib.ScMutableAddress { - return new wasmlib.ScMutableAddress(this.mapID, wasmlib.Key32.fromString(sc.ResultStateControllerAddress)); + stateControllerAddress(): wasmtypes.ScMutableAddress { + return new wasmtypes.ScMutableAddress(this.proxy.root(sc.ResultStateControllerAddress)); } } -export class ImmutableGetBlockInfoResults extends wasmlib.ScMapID { - blockInfo(): wasmlib.ScImmutableBytes { - return new wasmlib.ScImmutableBytes(this.mapID, wasmlib.Key32.fromString(sc.ResultBlockInfo)); +export class ImmutableGetBlockInfoResults extends wasmtypes.ScProxy { + blockInfo(): wasmtypes.ScImmutableBytes { + return new wasmtypes.ScImmutableBytes(this.proxy.root(sc.ResultBlockInfo)); } } -export class MutableGetBlockInfoResults extends wasmlib.ScMapID { - blockInfo(): wasmlib.ScMutableBytes { - return new wasmlib.ScMutableBytes(this.mapID, wasmlib.Key32.fromString(sc.ResultBlockInfo)); +export class MutableGetBlockInfoResults extends wasmtypes.ScProxy { + blockInfo(): wasmtypes.ScMutableBytes { + return new wasmtypes.ScMutableBytes(this.proxy.root(sc.ResultBlockInfo)); } } -export class ArrayOfImmutableBytes { - objID: i32; - - constructor(objID: i32) { - this.objID = objID; - } +export class ArrayOfImmutableBytes extends wasmtypes.ScProxy { length(): u32 { - return wasmlib.getLength(this.objID); + return this.proxy.length(); } - getBytes(index: u32): wasmlib.ScImmutableBytes { - return new wasmlib.ScImmutableBytes(this.objID, new wasmlib.Key32(index as i32)); + getBytes(index: u32): wasmtypes.ScImmutableBytes { + return new wasmtypes.ScImmutableBytes(this.proxy.index(index)); } } -export class ImmutableGetEventsForBlockResults extends wasmlib.ScMapID { +export class ImmutableGetEventsForBlockResults extends wasmtypes.ScProxy { event(): sc.ArrayOfImmutableBytes { - let arrID = wasmlib.getObjectID(this.mapID, wasmlib.Key32.fromString(sc.ResultEvent), wasmlib.TYPE_ARRAY16|wasmlib.TYPE_BYTES); - return new sc.ArrayOfImmutableBytes(arrID); + return new sc.ArrayOfImmutableBytes(this.proxy.root(sc.ResultEvent)); } } -export class ArrayOfMutableBytes { - objID: i32; +export class ArrayOfMutableBytes extends wasmtypes.ScProxy { - constructor(objID: i32) { - this.objID = objID; - } + appendBytes(): wasmtypes.ScMutableBytes { + return new wasmtypes.ScMutableBytes(this.proxy.append()); + } clear(): void { - wasmlib.clear(this.objID); + this.proxy.clearArray(); } length(): u32 { - return wasmlib.getLength(this.objID); + return this.proxy.length(); } - getBytes(index: u32): wasmlib.ScMutableBytes { - return new wasmlib.ScMutableBytes(this.objID, new wasmlib.Key32(index as i32)); + getBytes(index: u32): wasmtypes.ScMutableBytes { + return new wasmtypes.ScMutableBytes(this.proxy.index(index)); } } -export class MutableGetEventsForBlockResults extends wasmlib.ScMapID { +export class MutableGetEventsForBlockResults extends wasmtypes.ScProxy { event(): sc.ArrayOfMutableBytes { - let arrID = wasmlib.getObjectID(this.mapID, wasmlib.Key32.fromString(sc.ResultEvent), wasmlib.TYPE_ARRAY16|wasmlib.TYPE_BYTES); - return new sc.ArrayOfMutableBytes(arrID); + return new sc.ArrayOfMutableBytes(this.proxy.root(sc.ResultEvent)); } } -export class ImmutableGetEventsForContractResults extends wasmlib.ScMapID { +export class ImmutableGetEventsForContractResults extends wasmtypes.ScProxy { event(): sc.ArrayOfImmutableBytes { - let arrID = wasmlib.getObjectID(this.mapID, wasmlib.Key32.fromString(sc.ResultEvent), wasmlib.TYPE_ARRAY16|wasmlib.TYPE_BYTES); - return new sc.ArrayOfImmutableBytes(arrID); + return new sc.ArrayOfImmutableBytes(this.proxy.root(sc.ResultEvent)); } } -export class MutableGetEventsForContractResults extends wasmlib.ScMapID { +export class MutableGetEventsForContractResults extends wasmtypes.ScProxy { event(): sc.ArrayOfMutableBytes { - let arrID = wasmlib.getObjectID(this.mapID, wasmlib.Key32.fromString(sc.ResultEvent), wasmlib.TYPE_ARRAY16|wasmlib.TYPE_BYTES); - return new sc.ArrayOfMutableBytes(arrID); + return new sc.ArrayOfMutableBytes(this.proxy.root(sc.ResultEvent)); } } -export class ImmutableGetEventsForRequestResults extends wasmlib.ScMapID { +export class ImmutableGetEventsForRequestResults extends wasmtypes.ScProxy { event(): sc.ArrayOfImmutableBytes { - let arrID = wasmlib.getObjectID(this.mapID, wasmlib.Key32.fromString(sc.ResultEvent), wasmlib.TYPE_ARRAY16|wasmlib.TYPE_BYTES); - return new sc.ArrayOfImmutableBytes(arrID); + return new sc.ArrayOfImmutableBytes(this.proxy.root(sc.ResultEvent)); } } -export class MutableGetEventsForRequestResults extends wasmlib.ScMapID { +export class MutableGetEventsForRequestResults extends wasmtypes.ScProxy { event(): sc.ArrayOfMutableBytes { - let arrID = wasmlib.getObjectID(this.mapID, wasmlib.Key32.fromString(sc.ResultEvent), wasmlib.TYPE_ARRAY16|wasmlib.TYPE_BYTES); - return new sc.ArrayOfMutableBytes(arrID); + return new sc.ArrayOfMutableBytes(this.proxy.root(sc.ResultEvent)); } } -export class ImmutableGetLatestBlockInfoResults extends wasmlib.ScMapID { - blockIndex(): wasmlib.ScImmutableUint32 { - return new wasmlib.ScImmutableUint32(this.mapID, wasmlib.Key32.fromString(sc.ResultBlockIndex)); +export class ImmutableGetLatestBlockInfoResults extends wasmtypes.ScProxy { + blockIndex(): wasmtypes.ScImmutableUint32 { + return new wasmtypes.ScImmutableUint32(this.proxy.root(sc.ResultBlockIndex)); } - blockInfo(): wasmlib.ScImmutableBytes { - return new wasmlib.ScImmutableBytes(this.mapID, wasmlib.Key32.fromString(sc.ResultBlockInfo)); + blockInfo(): wasmtypes.ScImmutableBytes { + return new wasmtypes.ScImmutableBytes(this.proxy.root(sc.ResultBlockInfo)); } } -export class MutableGetLatestBlockInfoResults extends wasmlib.ScMapID { - blockIndex(): wasmlib.ScMutableUint32 { - return new wasmlib.ScMutableUint32(this.mapID, wasmlib.Key32.fromString(sc.ResultBlockIndex)); +export class MutableGetLatestBlockInfoResults extends wasmtypes.ScProxy { + blockIndex(): wasmtypes.ScMutableUint32 { + return new wasmtypes.ScMutableUint32(this.proxy.root(sc.ResultBlockIndex)); } - blockInfo(): wasmlib.ScMutableBytes { - return new wasmlib.ScMutableBytes(this.mapID, wasmlib.Key32.fromString(sc.ResultBlockInfo)); + blockInfo(): wasmtypes.ScMutableBytes { + return new wasmtypes.ScMutableBytes(this.proxy.root(sc.ResultBlockInfo)); } } -export class ArrayOfImmutableRequestID { - objID: i32; - - constructor(objID: i32) { - this.objID = objID; - } +export class ArrayOfImmutableRequestID extends wasmtypes.ScProxy { length(): u32 { - return wasmlib.getLength(this.objID); + return this.proxy.length(); } - getRequestID(index: u32): wasmlib.ScImmutableRequestID { - return new wasmlib.ScImmutableRequestID(this.objID, new wasmlib.Key32(index as i32)); + getRequestID(index: u32): wasmtypes.ScImmutableRequestID { + return new wasmtypes.ScImmutableRequestID(this.proxy.index(index)); } } -export class ImmutableGetRequestIDsForBlockResults extends wasmlib.ScMapID { +export class ImmutableGetRequestIDsForBlockResults extends wasmtypes.ScProxy { requestID(): sc.ArrayOfImmutableRequestID { - let arrID = wasmlib.getObjectID(this.mapID, wasmlib.Key32.fromString(sc.ResultRequestID), wasmlib.TYPE_ARRAY16|wasmlib.TYPE_REQUEST_ID); - return new sc.ArrayOfImmutableRequestID(arrID); + return new sc.ArrayOfImmutableRequestID(this.proxy.root(sc.ResultRequestID)); } } -export class ArrayOfMutableRequestID { - objID: i32; +export class ArrayOfMutableRequestID extends wasmtypes.ScProxy { - constructor(objID: i32) { - this.objID = objID; - } + appendRequestID(): wasmtypes.ScMutableRequestID { + return new wasmtypes.ScMutableRequestID(this.proxy.append()); + } clear(): void { - wasmlib.clear(this.objID); + this.proxy.clearArray(); } length(): u32 { - return wasmlib.getLength(this.objID); + return this.proxy.length(); } - getRequestID(index: u32): wasmlib.ScMutableRequestID { - return new wasmlib.ScMutableRequestID(this.objID, new wasmlib.Key32(index as i32)); + getRequestID(index: u32): wasmtypes.ScMutableRequestID { + return new wasmtypes.ScMutableRequestID(this.proxy.index(index)); } } -export class MutableGetRequestIDsForBlockResults extends wasmlib.ScMapID { +export class MutableGetRequestIDsForBlockResults extends wasmtypes.ScProxy { requestID(): sc.ArrayOfMutableRequestID { - let arrID = wasmlib.getObjectID(this.mapID, wasmlib.Key32.fromString(sc.ResultRequestID), wasmlib.TYPE_ARRAY16|wasmlib.TYPE_REQUEST_ID); - return new sc.ArrayOfMutableRequestID(arrID); + return new sc.ArrayOfMutableRequestID(this.proxy.root(sc.ResultRequestID)); } } -export class ImmutableGetRequestReceiptResults extends wasmlib.ScMapID { - blockIndex(): wasmlib.ScImmutableUint32 { - return new wasmlib.ScImmutableUint32(this.mapID, wasmlib.Key32.fromString(sc.ResultBlockIndex)); +export class ImmutableGetRequestReceiptResults extends wasmtypes.ScProxy { + blockIndex(): wasmtypes.ScImmutableUint32 { + return new wasmtypes.ScImmutableUint32(this.proxy.root(sc.ResultBlockIndex)); } - requestIndex(): wasmlib.ScImmutableUint16 { - return new wasmlib.ScImmutableUint16(this.mapID, wasmlib.Key32.fromString(sc.ResultRequestIndex)); + requestIndex(): wasmtypes.ScImmutableUint16 { + return new wasmtypes.ScImmutableUint16(this.proxy.root(sc.ResultRequestIndex)); } - requestRecord(): wasmlib.ScImmutableBytes { - return new wasmlib.ScImmutableBytes(this.mapID, wasmlib.Key32.fromString(sc.ResultRequestRecord)); + requestRecord(): wasmtypes.ScImmutableBytes { + return new wasmtypes.ScImmutableBytes(this.proxy.root(sc.ResultRequestRecord)); } } -export class MutableGetRequestReceiptResults extends wasmlib.ScMapID { - blockIndex(): wasmlib.ScMutableUint32 { - return new wasmlib.ScMutableUint32(this.mapID, wasmlib.Key32.fromString(sc.ResultBlockIndex)); +export class MutableGetRequestReceiptResults extends wasmtypes.ScProxy { + blockIndex(): wasmtypes.ScMutableUint32 { + return new wasmtypes.ScMutableUint32(this.proxy.root(sc.ResultBlockIndex)); } - requestIndex(): wasmlib.ScMutableUint16 { - return new wasmlib.ScMutableUint16(this.mapID, wasmlib.Key32.fromString(sc.ResultRequestIndex)); + requestIndex(): wasmtypes.ScMutableUint16 { + return new wasmtypes.ScMutableUint16(this.proxy.root(sc.ResultRequestIndex)); } - requestRecord(): wasmlib.ScMutableBytes { - return new wasmlib.ScMutableBytes(this.mapID, wasmlib.Key32.fromString(sc.ResultRequestRecord)); + requestRecord(): wasmtypes.ScMutableBytes { + return new wasmtypes.ScMutableBytes(this.proxy.root(sc.ResultRequestRecord)); } } -export class ImmutableGetRequestReceiptsForBlockResults extends wasmlib.ScMapID { +export class ImmutableGetRequestReceiptsForBlockResults extends wasmtypes.ScProxy { requestRecord(): sc.ArrayOfImmutableBytes { - let arrID = wasmlib.getObjectID(this.mapID, wasmlib.Key32.fromString(sc.ResultRequestRecord), wasmlib.TYPE_ARRAY16|wasmlib.TYPE_BYTES); - return new sc.ArrayOfImmutableBytes(arrID); + return new sc.ArrayOfImmutableBytes(this.proxy.root(sc.ResultRequestRecord)); } } -export class MutableGetRequestReceiptsForBlockResults extends wasmlib.ScMapID { +export class MutableGetRequestReceiptsForBlockResults extends wasmtypes.ScProxy { requestRecord(): sc.ArrayOfMutableBytes { - let arrID = wasmlib.getObjectID(this.mapID, wasmlib.Key32.fromString(sc.ResultRequestRecord), wasmlib.TYPE_ARRAY16|wasmlib.TYPE_BYTES); - return new sc.ArrayOfMutableBytes(arrID); + return new sc.ArrayOfMutableBytes(this.proxy.root(sc.ResultRequestRecord)); } } -export class ImmutableIsRequestProcessedResults extends wasmlib.ScMapID { - requestProcessed(): wasmlib.ScImmutableString { - return new wasmlib.ScImmutableString(this.mapID, wasmlib.Key32.fromString(sc.ResultRequestProcessed)); +export class ImmutableIsRequestProcessedResults extends wasmtypes.ScProxy { + requestProcessed(): wasmtypes.ScImmutableString { + return new wasmtypes.ScImmutableString(this.proxy.root(sc.ResultRequestProcessed)); } } -export class MutableIsRequestProcessedResults extends wasmlib.ScMapID { - requestProcessed(): wasmlib.ScMutableString { - return new wasmlib.ScMutableString(this.mapID, wasmlib.Key32.fromString(sc.ResultRequestProcessed)); +export class MutableIsRequestProcessedResults extends wasmtypes.ScProxy { + requestProcessed(): wasmtypes.ScMutableString { + return new wasmtypes.ScMutableString(this.proxy.root(sc.ResultRequestProcessed)); } } diff --git a/packages/wasmvm/wasmlib/ts/wasmlib/coregovernance/consts.ts b/packages/wasmvm/wasmlib/ts/wasmlib/coregovernance/consts.ts index bc538fbb2b..56ca393177 100644 --- a/packages/wasmvm/wasmlib/ts/wasmlib/coregovernance/consts.ts +++ b/packages/wasmvm/wasmlib/ts/wasmlib/coregovernance/consts.ts @@ -5,11 +5,11 @@ // >>>> DO NOT CHANGE THIS FILE! <<<< // Change the json schema instead -import * as wasmlib from "wasmlib"; +import * as wasmtypes from "wasmlib/wasmtypes"; export const ScName = "governance"; export const ScDescription = "Core governance contract"; -export const HScName = new wasmlib.ScHname(0x17cf909f); +export const HScName = new wasmtypes.ScHname(0x17cf909f); export const ParamChainOwner = "oi"; export const ParamFeeColor = "fc"; @@ -47,15 +47,15 @@ export const ViewGetChainInfo = "getChainInfo"; export const ViewGetFeeInfo = "getFeeInfo"; export const ViewGetMaxBlobSize = "getMaxBlobSize"; -export const HFuncAddAllowedStateControllerAddress = new wasmlib.ScHname(0x9469d567); -export const HFuncClaimChainOwnership = new wasmlib.ScHname(0x03ff0fc0); -export const HFuncDelegateChainOwnership = new wasmlib.ScHname(0x93ecb6ad); -export const HFuncRemoveAllowedStateControllerAddress = new wasmlib.ScHname(0x31f69447); -export const HFuncRotateStateController = new wasmlib.ScHname(0x244d1038); -export const HFuncSetChainInfo = new wasmlib.ScHname(0x702f5d2b); -export const HFuncSetContractFee = new wasmlib.ScHname(0x8421a42b); -export const HFuncSetDefaultFee = new wasmlib.ScHname(0x3310ecd0); -export const HViewGetAllowedStateControllerAddresses = new wasmlib.ScHname(0xf3505183); -export const HViewGetChainInfo = new wasmlib.ScHname(0x434477e2); -export const HViewGetFeeInfo = new wasmlib.ScHname(0x9fe54b48); -export const HViewGetMaxBlobSize = new wasmlib.ScHname(0xe1db3d28); +export const HFuncAddAllowedStateControllerAddress = new wasmtypes.ScHname(0x9469d567); +export const HFuncClaimChainOwnership = new wasmtypes.ScHname(0x03ff0fc0); +export const HFuncDelegateChainOwnership = new wasmtypes.ScHname(0x93ecb6ad); +export const HFuncRemoveAllowedStateControllerAddress = new wasmtypes.ScHname(0x31f69447); +export const HFuncRotateStateController = new wasmtypes.ScHname(0x244d1038); +export const HFuncSetChainInfo = new wasmtypes.ScHname(0x702f5d2b); +export const HFuncSetContractFee = new wasmtypes.ScHname(0x8421a42b); +export const HFuncSetDefaultFee = new wasmtypes.ScHname(0x3310ecd0); +export const HViewGetAllowedStateControllerAddresses = new wasmtypes.ScHname(0xf3505183); +export const HViewGetChainInfo = new wasmtypes.ScHname(0x434477e2); +export const HViewGetFeeInfo = new wasmtypes.ScHname(0x9fe54b48); +export const HViewGetMaxBlobSize = new wasmtypes.ScHname(0xe1db3d28); diff --git a/packages/wasmvm/wasmlib/ts/wasmlib/coregovernance/contract.ts b/packages/wasmvm/wasmlib/ts/wasmlib/coregovernance/contract.ts index 045e454730..eb958607f4 100644 --- a/packages/wasmvm/wasmlib/ts/wasmlib/coregovernance/contract.ts +++ b/packages/wasmvm/wasmlib/ts/wasmlib/coregovernance/contract.ts @@ -6,11 +6,12 @@ // Change the json schema instead import * as wasmlib from "wasmlib"; +import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; export class AddAllowedStateControllerAddressCall { func: wasmlib.ScFunc = new wasmlib.ScFunc(sc.HScName, sc.HFuncAddAllowedStateControllerAddress); - params: sc.MutableAddAllowedStateControllerAddressParams = new sc.MutableAddAllowedStateControllerAddressParams(); + params: sc.MutableAddAllowedStateControllerAddressParams = new sc.MutableAddAllowedStateControllerAddressParams(wasmlib.ScView.nilProxy); } export class ClaimChainOwnershipCall { @@ -19,59 +20,59 @@ export class ClaimChainOwnershipCall { export class DelegateChainOwnershipCall { func: wasmlib.ScFunc = new wasmlib.ScFunc(sc.HScName, sc.HFuncDelegateChainOwnership); - params: sc.MutableDelegateChainOwnershipParams = new sc.MutableDelegateChainOwnershipParams(); + params: sc.MutableDelegateChainOwnershipParams = new sc.MutableDelegateChainOwnershipParams(wasmlib.ScView.nilProxy); } export class RemoveAllowedStateControllerAddressCall { func: wasmlib.ScFunc = new wasmlib.ScFunc(sc.HScName, sc.HFuncRemoveAllowedStateControllerAddress); - params: sc.MutableRemoveAllowedStateControllerAddressParams = new sc.MutableRemoveAllowedStateControllerAddressParams(); + params: sc.MutableRemoveAllowedStateControllerAddressParams = new sc.MutableRemoveAllowedStateControllerAddressParams(wasmlib.ScView.nilProxy); } export class RotateStateControllerCall { func: wasmlib.ScFunc = new wasmlib.ScFunc(sc.HScName, sc.HFuncRotateStateController); - params: sc.MutableRotateStateControllerParams = new sc.MutableRotateStateControllerParams(); + params: sc.MutableRotateStateControllerParams = new sc.MutableRotateStateControllerParams(wasmlib.ScView.nilProxy); } export class SetChainInfoCall { func: wasmlib.ScFunc = new wasmlib.ScFunc(sc.HScName, sc.HFuncSetChainInfo); - params: sc.MutableSetChainInfoParams = new sc.MutableSetChainInfoParams(); + params: sc.MutableSetChainInfoParams = new sc.MutableSetChainInfoParams(wasmlib.ScView.nilProxy); } export class SetContractFeeCall { func: wasmlib.ScFunc = new wasmlib.ScFunc(sc.HScName, sc.HFuncSetContractFee); - params: sc.MutableSetContractFeeParams = new sc.MutableSetContractFeeParams(); + params: sc.MutableSetContractFeeParams = new sc.MutableSetContractFeeParams(wasmlib.ScView.nilProxy); } export class SetDefaultFeeCall { func: wasmlib.ScFunc = new wasmlib.ScFunc(sc.HScName, sc.HFuncSetDefaultFee); - params: sc.MutableSetDefaultFeeParams = new sc.MutableSetDefaultFeeParams(); + params: sc.MutableSetDefaultFeeParams = new sc.MutableSetDefaultFeeParams(wasmlib.ScView.nilProxy); } export class GetAllowedStateControllerAddressesCall { func: wasmlib.ScView = new wasmlib.ScView(sc.HScName, sc.HViewGetAllowedStateControllerAddresses); - results: sc.ImmutableGetAllowedStateControllerAddressesResults = new sc.ImmutableGetAllowedStateControllerAddressesResults(); + results: sc.ImmutableGetAllowedStateControllerAddressesResults = new sc.ImmutableGetAllowedStateControllerAddressesResults(wasmlib.ScView.nilProxy); } export class GetChainInfoCall { func: wasmlib.ScView = new wasmlib.ScView(sc.HScName, sc.HViewGetChainInfo); - results: sc.ImmutableGetChainInfoResults = new sc.ImmutableGetChainInfoResults(); + results: sc.ImmutableGetChainInfoResults = new sc.ImmutableGetChainInfoResults(wasmlib.ScView.nilProxy); } export class GetFeeInfoCall { func: wasmlib.ScView = new wasmlib.ScView(sc.HScName, sc.HViewGetFeeInfo); - params: sc.MutableGetFeeInfoParams = new sc.MutableGetFeeInfoParams(); - results: sc.ImmutableGetFeeInfoResults = new sc.ImmutableGetFeeInfoResults(); + params: sc.MutableGetFeeInfoParams = new sc.MutableGetFeeInfoParams(wasmlib.ScView.nilProxy); + results: sc.ImmutableGetFeeInfoResults = new sc.ImmutableGetFeeInfoResults(wasmlib.ScView.nilProxy); } export class GetMaxBlobSizeCall { func: wasmlib.ScView = new wasmlib.ScView(sc.HScName, sc.HViewGetMaxBlobSize); - results: sc.ImmutableGetMaxBlobSizeResults = new sc.ImmutableGetMaxBlobSizeResults(); + results: sc.ImmutableGetMaxBlobSizeResults = new sc.ImmutableGetMaxBlobSizeResults(wasmlib.ScView.nilProxy); } export class ScFuncs { static addAllowedStateControllerAddress(ctx: wasmlib.ScFuncCallContext): AddAllowedStateControllerAddressCall { - let f = new AddAllowedStateControllerAddressCall(); - f.func.setPtrs(f.params, null); + const f = new AddAllowedStateControllerAddressCall(); + f.params = new sc.MutableAddAllowedStateControllerAddressParams(wasmlib.newCallParamsProxy(f.func)); return f; } @@ -80,62 +81,63 @@ export class ScFuncs { } static delegateChainOwnership(ctx: wasmlib.ScFuncCallContext): DelegateChainOwnershipCall { - let f = new DelegateChainOwnershipCall(); - f.func.setPtrs(f.params, null); + const f = new DelegateChainOwnershipCall(); + f.params = new sc.MutableDelegateChainOwnershipParams(wasmlib.newCallParamsProxy(f.func)); return f; } static removeAllowedStateControllerAddress(ctx: wasmlib.ScFuncCallContext): RemoveAllowedStateControllerAddressCall { - let f = new RemoveAllowedStateControllerAddressCall(); - f.func.setPtrs(f.params, null); + const f = new RemoveAllowedStateControllerAddressCall(); + f.params = new sc.MutableRemoveAllowedStateControllerAddressParams(wasmlib.newCallParamsProxy(f.func)); return f; } static rotateStateController(ctx: wasmlib.ScFuncCallContext): RotateStateControllerCall { - let f = new RotateStateControllerCall(); - f.func.setPtrs(f.params, null); + const f = new RotateStateControllerCall(); + f.params = new sc.MutableRotateStateControllerParams(wasmlib.newCallParamsProxy(f.func)); return f; } static setChainInfo(ctx: wasmlib.ScFuncCallContext): SetChainInfoCall { - let f = new SetChainInfoCall(); - f.func.setPtrs(f.params, null); + const f = new SetChainInfoCall(); + f.params = new sc.MutableSetChainInfoParams(wasmlib.newCallParamsProxy(f.func)); return f; } static setContractFee(ctx: wasmlib.ScFuncCallContext): SetContractFeeCall { - let f = new SetContractFeeCall(); - f.func.setPtrs(f.params, null); + const f = new SetContractFeeCall(); + f.params = new sc.MutableSetContractFeeParams(wasmlib.newCallParamsProxy(f.func)); return f; } static setDefaultFee(ctx: wasmlib.ScFuncCallContext): SetDefaultFeeCall { - let f = new SetDefaultFeeCall(); - f.func.setPtrs(f.params, null); + const f = new SetDefaultFeeCall(); + f.params = new sc.MutableSetDefaultFeeParams(wasmlib.newCallParamsProxy(f.func)); return f; } static getAllowedStateControllerAddresses(ctx: wasmlib.ScViewCallContext): GetAllowedStateControllerAddressesCall { - let f = new GetAllowedStateControllerAddressesCall(); - f.func.setPtrs(null, f.results); + const f = new GetAllowedStateControllerAddressesCall(); + f.results = new sc.ImmutableGetAllowedStateControllerAddressesResults(wasmlib.newCallResultsProxy(f.func)); return f; } static getChainInfo(ctx: wasmlib.ScViewCallContext): GetChainInfoCall { - let f = new GetChainInfoCall(); - f.func.setPtrs(null, f.results); + const f = new GetChainInfoCall(); + f.results = new sc.ImmutableGetChainInfoResults(wasmlib.newCallResultsProxy(f.func)); return f; } static getFeeInfo(ctx: wasmlib.ScViewCallContext): GetFeeInfoCall { - let f = new GetFeeInfoCall(); - f.func.setPtrs(f.params, f.results); + const f = new GetFeeInfoCall(); + f.params = new sc.MutableGetFeeInfoParams(wasmlib.newCallParamsProxy(f.func)); + f.results = new sc.ImmutableGetFeeInfoResults(wasmlib.newCallResultsProxy(f.func)); return f; } static getMaxBlobSize(ctx: wasmlib.ScViewCallContext): GetMaxBlobSizeCall { - let f = new GetMaxBlobSizeCall(); - f.func.setPtrs(null, f.results); + const f = new GetMaxBlobSizeCall(); + f.results = new sc.ImmutableGetMaxBlobSizeResults(wasmlib.newCallResultsProxy(f.func)); return f; } } diff --git a/packages/wasmvm/wasmlib/ts/wasmlib/coregovernance/params.ts b/packages/wasmvm/wasmlib/ts/wasmlib/coregovernance/params.ts index 8e0b37cb46..c504ac74f3 100644 --- a/packages/wasmvm/wasmlib/ts/wasmlib/coregovernance/params.ts +++ b/packages/wasmvm/wasmlib/ts/wasmlib/coregovernance/params.ts @@ -6,172 +6,173 @@ // Change the json schema instead import * as wasmlib from "wasmlib"; +import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; -export class ImmutableAddAllowedStateControllerAddressParams extends wasmlib.ScMapID { - chainOwner(): wasmlib.ScImmutableAgentID { - return new wasmlib.ScImmutableAgentID(this.mapID, wasmlib.Key32.fromString(sc.ParamChainOwner)); +export class ImmutableAddAllowedStateControllerAddressParams extends wasmtypes.ScProxy { + chainOwner(): wasmtypes.ScImmutableAgentID { + return new wasmtypes.ScImmutableAgentID(this.proxy.root(sc.ParamChainOwner)); } - feeColor(): wasmlib.ScImmutableColor { - return new wasmlib.ScImmutableColor(this.mapID, wasmlib.Key32.fromString(sc.ParamFeeColor)); + feeColor(): wasmtypes.ScImmutableColor { + return new wasmtypes.ScImmutableColor(this.proxy.root(sc.ParamFeeColor)); } - stateControllerAddress(): wasmlib.ScImmutableAddress { - return new wasmlib.ScImmutableAddress(this.mapID, wasmlib.Key32.fromString(sc.ParamStateControllerAddress)); + stateControllerAddress(): wasmtypes.ScImmutableAddress { + return new wasmtypes.ScImmutableAddress(this.proxy.root(sc.ParamStateControllerAddress)); } } -export class MutableAddAllowedStateControllerAddressParams extends wasmlib.ScMapID { - chainOwner(): wasmlib.ScMutableAgentID { - return new wasmlib.ScMutableAgentID(this.mapID, wasmlib.Key32.fromString(sc.ParamChainOwner)); +export class MutableAddAllowedStateControllerAddressParams extends wasmtypes.ScProxy { + chainOwner(): wasmtypes.ScMutableAgentID { + return new wasmtypes.ScMutableAgentID(this.proxy.root(sc.ParamChainOwner)); } - feeColor(): wasmlib.ScMutableColor { - return new wasmlib.ScMutableColor(this.mapID, wasmlib.Key32.fromString(sc.ParamFeeColor)); + feeColor(): wasmtypes.ScMutableColor { + return new wasmtypes.ScMutableColor(this.proxy.root(sc.ParamFeeColor)); } - stateControllerAddress(): wasmlib.ScMutableAddress { - return new wasmlib.ScMutableAddress(this.mapID, wasmlib.Key32.fromString(sc.ParamStateControllerAddress)); + stateControllerAddress(): wasmtypes.ScMutableAddress { + return new wasmtypes.ScMutableAddress(this.proxy.root(sc.ParamStateControllerAddress)); } } -export class ImmutableDelegateChainOwnershipParams extends wasmlib.ScMapID { - chainOwner(): wasmlib.ScImmutableAgentID { - return new wasmlib.ScImmutableAgentID(this.mapID, wasmlib.Key32.fromString(sc.ParamChainOwner)); +export class ImmutableDelegateChainOwnershipParams extends wasmtypes.ScProxy { + chainOwner(): wasmtypes.ScImmutableAgentID { + return new wasmtypes.ScImmutableAgentID(this.proxy.root(sc.ParamChainOwner)); } } -export class MutableDelegateChainOwnershipParams extends wasmlib.ScMapID { - chainOwner(): wasmlib.ScMutableAgentID { - return new wasmlib.ScMutableAgentID(this.mapID, wasmlib.Key32.fromString(sc.ParamChainOwner)); +export class MutableDelegateChainOwnershipParams extends wasmtypes.ScProxy { + chainOwner(): wasmtypes.ScMutableAgentID { + return new wasmtypes.ScMutableAgentID(this.proxy.root(sc.ParamChainOwner)); } } -export class ImmutableRemoveAllowedStateControllerAddressParams extends wasmlib.ScMapID { - stateControllerAddress(): wasmlib.ScImmutableAddress { - return new wasmlib.ScImmutableAddress(this.mapID, wasmlib.Key32.fromString(sc.ParamStateControllerAddress)); +export class ImmutableRemoveAllowedStateControllerAddressParams extends wasmtypes.ScProxy { + stateControllerAddress(): wasmtypes.ScImmutableAddress { + return new wasmtypes.ScImmutableAddress(this.proxy.root(sc.ParamStateControllerAddress)); } } -export class MutableRemoveAllowedStateControllerAddressParams extends wasmlib.ScMapID { - stateControllerAddress(): wasmlib.ScMutableAddress { - return new wasmlib.ScMutableAddress(this.mapID, wasmlib.Key32.fromString(sc.ParamStateControllerAddress)); +export class MutableRemoveAllowedStateControllerAddressParams extends wasmtypes.ScProxy { + stateControllerAddress(): wasmtypes.ScMutableAddress { + return new wasmtypes.ScMutableAddress(this.proxy.root(sc.ParamStateControllerAddress)); } } -export class ImmutableRotateStateControllerParams extends wasmlib.ScMapID { - stateControllerAddress(): wasmlib.ScImmutableAddress { - return new wasmlib.ScImmutableAddress(this.mapID, wasmlib.Key32.fromString(sc.ParamStateControllerAddress)); +export class ImmutableRotateStateControllerParams extends wasmtypes.ScProxy { + stateControllerAddress(): wasmtypes.ScImmutableAddress { + return new wasmtypes.ScImmutableAddress(this.proxy.root(sc.ParamStateControllerAddress)); } } -export class MutableRotateStateControllerParams extends wasmlib.ScMapID { - stateControllerAddress(): wasmlib.ScMutableAddress { - return new wasmlib.ScMutableAddress(this.mapID, wasmlib.Key32.fromString(sc.ParamStateControllerAddress)); +export class MutableRotateStateControllerParams extends wasmtypes.ScProxy { + stateControllerAddress(): wasmtypes.ScMutableAddress { + return new wasmtypes.ScMutableAddress(this.proxy.root(sc.ParamStateControllerAddress)); } } -export class ImmutableSetChainInfoParams extends wasmlib.ScMapID { - maxBlobSize(): wasmlib.ScImmutableInt32 { - return new wasmlib.ScImmutableInt32(this.mapID, wasmlib.Key32.fromString(sc.ParamMaxBlobSize)); +export class ImmutableSetChainInfoParams extends wasmtypes.ScProxy { + maxBlobSize(): wasmtypes.ScImmutableInt32 { + return new wasmtypes.ScImmutableInt32(this.proxy.root(sc.ParamMaxBlobSize)); } - maxEventSize(): wasmlib.ScImmutableInt16 { - return new wasmlib.ScImmutableInt16(this.mapID, wasmlib.Key32.fromString(sc.ParamMaxEventSize)); + maxEventSize(): wasmtypes.ScImmutableInt16 { + return new wasmtypes.ScImmutableInt16(this.proxy.root(sc.ParamMaxEventSize)); } - maxEventsPerReq(): wasmlib.ScImmutableInt16 { - return new wasmlib.ScImmutableInt16(this.mapID, wasmlib.Key32.fromString(sc.ParamMaxEventsPerReq)); + maxEventsPerReq(): wasmtypes.ScImmutableInt16 { + return new wasmtypes.ScImmutableInt16(this.proxy.root(sc.ParamMaxEventsPerReq)); } - ownerFee(): wasmlib.ScImmutableInt64 { - return new wasmlib.ScImmutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ParamOwnerFee)); + ownerFee(): wasmtypes.ScImmutableInt64 { + return new wasmtypes.ScImmutableInt64(this.proxy.root(sc.ParamOwnerFee)); } - validatorFee(): wasmlib.ScImmutableInt64 { - return new wasmlib.ScImmutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ParamValidatorFee)); + validatorFee(): wasmtypes.ScImmutableInt64 { + return new wasmtypes.ScImmutableInt64(this.proxy.root(sc.ParamValidatorFee)); } } -export class MutableSetChainInfoParams extends wasmlib.ScMapID { - maxBlobSize(): wasmlib.ScMutableInt32 { - return new wasmlib.ScMutableInt32(this.mapID, wasmlib.Key32.fromString(sc.ParamMaxBlobSize)); +export class MutableSetChainInfoParams extends wasmtypes.ScProxy { + maxBlobSize(): wasmtypes.ScMutableInt32 { + return new wasmtypes.ScMutableInt32(this.proxy.root(sc.ParamMaxBlobSize)); } - maxEventSize(): wasmlib.ScMutableInt16 { - return new wasmlib.ScMutableInt16(this.mapID, wasmlib.Key32.fromString(sc.ParamMaxEventSize)); + maxEventSize(): wasmtypes.ScMutableInt16 { + return new wasmtypes.ScMutableInt16(this.proxy.root(sc.ParamMaxEventSize)); } - maxEventsPerReq(): wasmlib.ScMutableInt16 { - return new wasmlib.ScMutableInt16(this.mapID, wasmlib.Key32.fromString(sc.ParamMaxEventsPerReq)); + maxEventsPerReq(): wasmtypes.ScMutableInt16 { + return new wasmtypes.ScMutableInt16(this.proxy.root(sc.ParamMaxEventsPerReq)); } - ownerFee(): wasmlib.ScMutableInt64 { - return new wasmlib.ScMutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ParamOwnerFee)); + ownerFee(): wasmtypes.ScMutableInt64 { + return new wasmtypes.ScMutableInt64(this.proxy.root(sc.ParamOwnerFee)); } - validatorFee(): wasmlib.ScMutableInt64 { - return new wasmlib.ScMutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ParamValidatorFee)); + validatorFee(): wasmtypes.ScMutableInt64 { + return new wasmtypes.ScMutableInt64(this.proxy.root(sc.ParamValidatorFee)); } } -export class ImmutableSetContractFeeParams extends wasmlib.ScMapID { - hname(): wasmlib.ScImmutableHname { - return new wasmlib.ScImmutableHname(this.mapID, wasmlib.Key32.fromString(sc.ParamHname)); +export class ImmutableSetContractFeeParams extends wasmtypes.ScProxy { + hname(): wasmtypes.ScImmutableHname { + return new wasmtypes.ScImmutableHname(this.proxy.root(sc.ParamHname)); } - ownerFee(): wasmlib.ScImmutableInt64 { - return new wasmlib.ScImmutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ParamOwnerFee)); + ownerFee(): wasmtypes.ScImmutableInt64 { + return new wasmtypes.ScImmutableInt64(this.proxy.root(sc.ParamOwnerFee)); } - validatorFee(): wasmlib.ScImmutableInt64 { - return new wasmlib.ScImmutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ParamValidatorFee)); + validatorFee(): wasmtypes.ScImmutableInt64 { + return new wasmtypes.ScImmutableInt64(this.proxy.root(sc.ParamValidatorFee)); } } -export class MutableSetContractFeeParams extends wasmlib.ScMapID { - hname(): wasmlib.ScMutableHname { - return new wasmlib.ScMutableHname(this.mapID, wasmlib.Key32.fromString(sc.ParamHname)); +export class MutableSetContractFeeParams extends wasmtypes.ScProxy { + hname(): wasmtypes.ScMutableHname { + return new wasmtypes.ScMutableHname(this.proxy.root(sc.ParamHname)); } - ownerFee(): wasmlib.ScMutableInt64 { - return new wasmlib.ScMutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ParamOwnerFee)); + ownerFee(): wasmtypes.ScMutableInt64 { + return new wasmtypes.ScMutableInt64(this.proxy.root(sc.ParamOwnerFee)); } - validatorFee(): wasmlib.ScMutableInt64 { - return new wasmlib.ScMutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ParamValidatorFee)); + validatorFee(): wasmtypes.ScMutableInt64 { + return new wasmtypes.ScMutableInt64(this.proxy.root(sc.ParamValidatorFee)); } } -export class ImmutableSetDefaultFeeParams extends wasmlib.ScMapID { - ownerFee(): wasmlib.ScImmutableInt64 { - return new wasmlib.ScImmutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ParamOwnerFee)); +export class ImmutableSetDefaultFeeParams extends wasmtypes.ScProxy { + ownerFee(): wasmtypes.ScImmutableInt64 { + return new wasmtypes.ScImmutableInt64(this.proxy.root(sc.ParamOwnerFee)); } - validatorFee(): wasmlib.ScImmutableInt64 { - return new wasmlib.ScImmutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ParamValidatorFee)); + validatorFee(): wasmtypes.ScImmutableInt64 { + return new wasmtypes.ScImmutableInt64(this.proxy.root(sc.ParamValidatorFee)); } } -export class MutableSetDefaultFeeParams extends wasmlib.ScMapID { - ownerFee(): wasmlib.ScMutableInt64 { - return new wasmlib.ScMutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ParamOwnerFee)); +export class MutableSetDefaultFeeParams extends wasmtypes.ScProxy { + ownerFee(): wasmtypes.ScMutableInt64 { + return new wasmtypes.ScMutableInt64(this.proxy.root(sc.ParamOwnerFee)); } - validatorFee(): wasmlib.ScMutableInt64 { - return new wasmlib.ScMutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ParamValidatorFee)); + validatorFee(): wasmtypes.ScMutableInt64 { + return new wasmtypes.ScMutableInt64(this.proxy.root(sc.ParamValidatorFee)); } } -export class ImmutableGetFeeInfoParams extends wasmlib.ScMapID { - hname(): wasmlib.ScImmutableHname { - return new wasmlib.ScImmutableHname(this.mapID, wasmlib.Key32.fromString(sc.ParamHname)); +export class ImmutableGetFeeInfoParams extends wasmtypes.ScProxy { + hname(): wasmtypes.ScImmutableHname { + return new wasmtypes.ScImmutableHname(this.proxy.root(sc.ParamHname)); } } -export class MutableGetFeeInfoParams extends wasmlib.ScMapID { - hname(): wasmlib.ScMutableHname { - return new wasmlib.ScMutableHname(this.mapID, wasmlib.Key32.fromString(sc.ParamHname)); +export class MutableGetFeeInfoParams extends wasmtypes.ScProxy { + hname(): wasmtypes.ScMutableHname { + return new wasmtypes.ScMutableHname(this.proxy.root(sc.ParamHname)); } } diff --git a/packages/wasmvm/wasmlib/ts/wasmlib/coregovernance/results.ts b/packages/wasmvm/wasmlib/ts/wasmlib/coregovernance/results.ts index ba0a89c508..00ff0db5d7 100644 --- a/packages/wasmvm/wasmlib/ts/wasmlib/coregovernance/results.ts +++ b/packages/wasmvm/wasmlib/ts/wasmlib/coregovernance/results.ts @@ -6,170 +6,163 @@ // Change the json schema instead import * as wasmlib from "wasmlib"; +import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; -export class ArrayOfImmutableBytes { - objID: i32; - - constructor(objID: i32) { - this.objID = objID; - } +export class ArrayOfImmutableBytes extends wasmtypes.ScProxy { length(): u32 { - return wasmlib.getLength(this.objID); + return this.proxy.length(); } - getBytes(index: u32): wasmlib.ScImmutableBytes { - return new wasmlib.ScImmutableBytes(this.objID, new wasmlib.Key32(index as i32)); + getBytes(index: u32): wasmtypes.ScImmutableBytes { + return new wasmtypes.ScImmutableBytes(this.proxy.index(index)); } } -export class ImmutableGetAllowedStateControllerAddressesResults extends wasmlib.ScMapID { +export class ImmutableGetAllowedStateControllerAddressesResults extends wasmtypes.ScProxy { allowedStateControllerAddresses(): sc.ArrayOfImmutableBytes { - let arrID = wasmlib.getObjectID(this.mapID, wasmlib.Key32.fromString(sc.ResultAllowedStateControllerAddresses), wasmlib.TYPE_ARRAY16|wasmlib.TYPE_BYTES); - return new sc.ArrayOfImmutableBytes(arrID); + return new sc.ArrayOfImmutableBytes(this.proxy.root(sc.ResultAllowedStateControllerAddresses)); } } -export class ArrayOfMutableBytes { - objID: i32; +export class ArrayOfMutableBytes extends wasmtypes.ScProxy { - constructor(objID: i32) { - this.objID = objID; - } + appendBytes(): wasmtypes.ScMutableBytes { + return new wasmtypes.ScMutableBytes(this.proxy.append()); + } clear(): void { - wasmlib.clear(this.objID); + this.proxy.clearArray(); } length(): u32 { - return wasmlib.getLength(this.objID); + return this.proxy.length(); } - getBytes(index: u32): wasmlib.ScMutableBytes { - return new wasmlib.ScMutableBytes(this.objID, new wasmlib.Key32(index as i32)); + getBytes(index: u32): wasmtypes.ScMutableBytes { + return new wasmtypes.ScMutableBytes(this.proxy.index(index)); } } -export class MutableGetAllowedStateControllerAddressesResults extends wasmlib.ScMapID { +export class MutableGetAllowedStateControllerAddressesResults extends wasmtypes.ScProxy { allowedStateControllerAddresses(): sc.ArrayOfMutableBytes { - let arrID = wasmlib.getObjectID(this.mapID, wasmlib.Key32.fromString(sc.ResultAllowedStateControllerAddresses), wasmlib.TYPE_ARRAY16|wasmlib.TYPE_BYTES); - return new sc.ArrayOfMutableBytes(arrID); + return new sc.ArrayOfMutableBytes(this.proxy.root(sc.ResultAllowedStateControllerAddresses)); } } -export class ImmutableGetChainInfoResults extends wasmlib.ScMapID { - chainID(): wasmlib.ScImmutableChainID { - return new wasmlib.ScImmutableChainID(this.mapID, wasmlib.Key32.fromString(sc.ResultChainID)); +export class ImmutableGetChainInfoResults extends wasmtypes.ScProxy { + chainID(): wasmtypes.ScImmutableChainID { + return new wasmtypes.ScImmutableChainID(this.proxy.root(sc.ResultChainID)); } - chainOwnerID(): wasmlib.ScImmutableAgentID { - return new wasmlib.ScImmutableAgentID(this.mapID, wasmlib.Key32.fromString(sc.ResultChainOwnerID)); + chainOwnerID(): wasmtypes.ScImmutableAgentID { + return new wasmtypes.ScImmutableAgentID(this.proxy.root(sc.ResultChainOwnerID)); } - defaultOwnerFee(): wasmlib.ScImmutableInt64 { - return new wasmlib.ScImmutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ResultDefaultOwnerFee)); + defaultOwnerFee(): wasmtypes.ScImmutableInt64 { + return new wasmtypes.ScImmutableInt64(this.proxy.root(sc.ResultDefaultOwnerFee)); } - defaultValidatorFee(): wasmlib.ScImmutableInt64 { - return new wasmlib.ScImmutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ResultDefaultValidatorFee)); + defaultValidatorFee(): wasmtypes.ScImmutableInt64 { + return new wasmtypes.ScImmutableInt64(this.proxy.root(sc.ResultDefaultValidatorFee)); } - description(): wasmlib.ScImmutableString { - return new wasmlib.ScImmutableString(this.mapID, wasmlib.Key32.fromString(sc.ResultDescription)); + description(): wasmtypes.ScImmutableString { + return new wasmtypes.ScImmutableString(this.proxy.root(sc.ResultDescription)); } - feeColor(): wasmlib.ScImmutableColor { - return new wasmlib.ScImmutableColor(this.mapID, wasmlib.Key32.fromString(sc.ResultFeeColor)); + feeColor(): wasmtypes.ScImmutableColor { + return new wasmtypes.ScImmutableColor(this.proxy.root(sc.ResultFeeColor)); } - maxBlobSize(): wasmlib.ScImmutableInt32 { - return new wasmlib.ScImmutableInt32(this.mapID, wasmlib.Key32.fromString(sc.ResultMaxBlobSize)); + maxBlobSize(): wasmtypes.ScImmutableInt32 { + return new wasmtypes.ScImmutableInt32(this.proxy.root(sc.ResultMaxBlobSize)); } - maxEventSize(): wasmlib.ScImmutableInt16 { - return new wasmlib.ScImmutableInt16(this.mapID, wasmlib.Key32.fromString(sc.ResultMaxEventSize)); + maxEventSize(): wasmtypes.ScImmutableInt16 { + return new wasmtypes.ScImmutableInt16(this.proxy.root(sc.ResultMaxEventSize)); } - maxEventsPerReq(): wasmlib.ScImmutableInt16 { - return new wasmlib.ScImmutableInt16(this.mapID, wasmlib.Key32.fromString(sc.ResultMaxEventsPerReq)); + maxEventsPerReq(): wasmtypes.ScImmutableInt16 { + return new wasmtypes.ScImmutableInt16(this.proxy.root(sc.ResultMaxEventsPerReq)); } } -export class MutableGetChainInfoResults extends wasmlib.ScMapID { - chainID(): wasmlib.ScMutableChainID { - return new wasmlib.ScMutableChainID(this.mapID, wasmlib.Key32.fromString(sc.ResultChainID)); +export class MutableGetChainInfoResults extends wasmtypes.ScProxy { + chainID(): wasmtypes.ScMutableChainID { + return new wasmtypes.ScMutableChainID(this.proxy.root(sc.ResultChainID)); } - chainOwnerID(): wasmlib.ScMutableAgentID { - return new wasmlib.ScMutableAgentID(this.mapID, wasmlib.Key32.fromString(sc.ResultChainOwnerID)); + chainOwnerID(): wasmtypes.ScMutableAgentID { + return new wasmtypes.ScMutableAgentID(this.proxy.root(sc.ResultChainOwnerID)); } - defaultOwnerFee(): wasmlib.ScMutableInt64 { - return new wasmlib.ScMutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ResultDefaultOwnerFee)); + defaultOwnerFee(): wasmtypes.ScMutableInt64 { + return new wasmtypes.ScMutableInt64(this.proxy.root(sc.ResultDefaultOwnerFee)); } - defaultValidatorFee(): wasmlib.ScMutableInt64 { - return new wasmlib.ScMutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ResultDefaultValidatorFee)); + defaultValidatorFee(): wasmtypes.ScMutableInt64 { + return new wasmtypes.ScMutableInt64(this.proxy.root(sc.ResultDefaultValidatorFee)); } - description(): wasmlib.ScMutableString { - return new wasmlib.ScMutableString(this.mapID, wasmlib.Key32.fromString(sc.ResultDescription)); + description(): wasmtypes.ScMutableString { + return new wasmtypes.ScMutableString(this.proxy.root(sc.ResultDescription)); } - feeColor(): wasmlib.ScMutableColor { - return new wasmlib.ScMutableColor(this.mapID, wasmlib.Key32.fromString(sc.ResultFeeColor)); + feeColor(): wasmtypes.ScMutableColor { + return new wasmtypes.ScMutableColor(this.proxy.root(sc.ResultFeeColor)); } - maxBlobSize(): wasmlib.ScMutableInt32 { - return new wasmlib.ScMutableInt32(this.mapID, wasmlib.Key32.fromString(sc.ResultMaxBlobSize)); + maxBlobSize(): wasmtypes.ScMutableInt32 { + return new wasmtypes.ScMutableInt32(this.proxy.root(sc.ResultMaxBlobSize)); } - maxEventSize(): wasmlib.ScMutableInt16 { - return new wasmlib.ScMutableInt16(this.mapID, wasmlib.Key32.fromString(sc.ResultMaxEventSize)); + maxEventSize(): wasmtypes.ScMutableInt16 { + return new wasmtypes.ScMutableInt16(this.proxy.root(sc.ResultMaxEventSize)); } - maxEventsPerReq(): wasmlib.ScMutableInt16 { - return new wasmlib.ScMutableInt16(this.mapID, wasmlib.Key32.fromString(sc.ResultMaxEventsPerReq)); + maxEventsPerReq(): wasmtypes.ScMutableInt16 { + return new wasmtypes.ScMutableInt16(this.proxy.root(sc.ResultMaxEventsPerReq)); } } -export class ImmutableGetFeeInfoResults extends wasmlib.ScMapID { - feeColor(): wasmlib.ScImmutableColor { - return new wasmlib.ScImmutableColor(this.mapID, wasmlib.Key32.fromString(sc.ResultFeeColor)); +export class ImmutableGetFeeInfoResults extends wasmtypes.ScProxy { + feeColor(): wasmtypes.ScImmutableColor { + return new wasmtypes.ScImmutableColor(this.proxy.root(sc.ResultFeeColor)); } - ownerFee(): wasmlib.ScImmutableInt64 { - return new wasmlib.ScImmutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ResultOwnerFee)); + ownerFee(): wasmtypes.ScImmutableInt64 { + return new wasmtypes.ScImmutableInt64(this.proxy.root(sc.ResultOwnerFee)); } - validatorFee(): wasmlib.ScImmutableInt64 { - return new wasmlib.ScImmutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ResultValidatorFee)); + validatorFee(): wasmtypes.ScImmutableInt64 { + return new wasmtypes.ScImmutableInt64(this.proxy.root(sc.ResultValidatorFee)); } } -export class MutableGetFeeInfoResults extends wasmlib.ScMapID { - feeColor(): wasmlib.ScMutableColor { - return new wasmlib.ScMutableColor(this.mapID, wasmlib.Key32.fromString(sc.ResultFeeColor)); +export class MutableGetFeeInfoResults extends wasmtypes.ScProxy { + feeColor(): wasmtypes.ScMutableColor { + return new wasmtypes.ScMutableColor(this.proxy.root(sc.ResultFeeColor)); } - ownerFee(): wasmlib.ScMutableInt64 { - return new wasmlib.ScMutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ResultOwnerFee)); + ownerFee(): wasmtypes.ScMutableInt64 { + return new wasmtypes.ScMutableInt64(this.proxy.root(sc.ResultOwnerFee)); } - validatorFee(): wasmlib.ScMutableInt64 { - return new wasmlib.ScMutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ResultValidatorFee)); + validatorFee(): wasmtypes.ScMutableInt64 { + return new wasmtypes.ScMutableInt64(this.proxy.root(sc.ResultValidatorFee)); } } -export class ImmutableGetMaxBlobSizeResults extends wasmlib.ScMapID { - maxBlobSize(): wasmlib.ScImmutableInt32 { - return new wasmlib.ScImmutableInt32(this.mapID, wasmlib.Key32.fromString(sc.ResultMaxBlobSize)); +export class ImmutableGetMaxBlobSizeResults extends wasmtypes.ScProxy { + maxBlobSize(): wasmtypes.ScImmutableInt32 { + return new wasmtypes.ScImmutableInt32(this.proxy.root(sc.ResultMaxBlobSize)); } } -export class MutableGetMaxBlobSizeResults extends wasmlib.ScMapID { - maxBlobSize(): wasmlib.ScMutableInt32 { - return new wasmlib.ScMutableInt32(this.mapID, wasmlib.Key32.fromString(sc.ResultMaxBlobSize)); +export class MutableGetMaxBlobSizeResults extends wasmtypes.ScProxy { + maxBlobSize(): wasmtypes.ScMutableInt32 { + return new wasmtypes.ScMutableInt32(this.proxy.root(sc.ResultMaxBlobSize)); } } diff --git a/packages/wasmvm/wasmlib/ts/wasmlib/coreroot/consts.ts b/packages/wasmvm/wasmlib/ts/wasmlib/coreroot/consts.ts index 8d5626b329..079f2dbd9d 100644 --- a/packages/wasmvm/wasmlib/ts/wasmlib/coreroot/consts.ts +++ b/packages/wasmvm/wasmlib/ts/wasmlib/coreroot/consts.ts @@ -5,11 +5,11 @@ // >>>> DO NOT CHANGE THIS FILE! <<<< // Change the json schema instead -import * as wasmlib from "wasmlib"; +import * as wasmtypes from "wasmlib/wasmtypes"; export const ScName = "root"; export const ScDescription = "Core root contract"; -export const HScName = new wasmlib.ScHname(0xcebf5908); +export const HScName = new wasmtypes.ScHname(0xcebf5908); export const ParamDeployer = "dp"; export const ParamDescription = "ds"; @@ -27,8 +27,8 @@ export const FuncRevokeDeployPermission = "revokeDeployPermission"; export const ViewFindContract = "findContract"; export const ViewGetContractRecords = "getContractRecords"; -export const HFuncDeployContract = new wasmlib.ScHname(0x28232c27); -export const HFuncGrantDeployPermission = new wasmlib.ScHname(0xf440263a); -export const HFuncRevokeDeployPermission = new wasmlib.ScHname(0x850744f1); -export const HViewFindContract = new wasmlib.ScHname(0xc145ca00); -export const HViewGetContractRecords = new wasmlib.ScHname(0x078b3ef3); +export const HFuncDeployContract = new wasmtypes.ScHname(0x28232c27); +export const HFuncGrantDeployPermission = new wasmtypes.ScHname(0xf440263a); +export const HFuncRevokeDeployPermission = new wasmtypes.ScHname(0x850744f1); +export const HViewFindContract = new wasmtypes.ScHname(0xc145ca00); +export const HViewGetContractRecords = new wasmtypes.ScHname(0x078b3ef3); diff --git a/packages/wasmvm/wasmlib/ts/wasmlib/coreroot/contract.ts b/packages/wasmvm/wasmlib/ts/wasmlib/coreroot/contract.ts index 7ab3399228..e092db33b9 100644 --- a/packages/wasmvm/wasmlib/ts/wasmlib/coreroot/contract.ts +++ b/packages/wasmvm/wasmlib/ts/wasmlib/coreroot/contract.ts @@ -6,62 +6,64 @@ // Change the json schema instead import * as wasmlib from "wasmlib"; +import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; export class DeployContractCall { func: wasmlib.ScFunc = new wasmlib.ScFunc(sc.HScName, sc.HFuncDeployContract); - params: sc.MutableDeployContractParams = new sc.MutableDeployContractParams(); + params: sc.MutableDeployContractParams = new sc.MutableDeployContractParams(wasmlib.ScView.nilProxy); } export class GrantDeployPermissionCall { func: wasmlib.ScFunc = new wasmlib.ScFunc(sc.HScName, sc.HFuncGrantDeployPermission); - params: sc.MutableGrantDeployPermissionParams = new sc.MutableGrantDeployPermissionParams(); + params: sc.MutableGrantDeployPermissionParams = new sc.MutableGrantDeployPermissionParams(wasmlib.ScView.nilProxy); } export class RevokeDeployPermissionCall { func: wasmlib.ScFunc = new wasmlib.ScFunc(sc.HScName, sc.HFuncRevokeDeployPermission); - params: sc.MutableRevokeDeployPermissionParams = new sc.MutableRevokeDeployPermissionParams(); + params: sc.MutableRevokeDeployPermissionParams = new sc.MutableRevokeDeployPermissionParams(wasmlib.ScView.nilProxy); } export class FindContractCall { func: wasmlib.ScView = new wasmlib.ScView(sc.HScName, sc.HViewFindContract); - params: sc.MutableFindContractParams = new sc.MutableFindContractParams(); - results: sc.ImmutableFindContractResults = new sc.ImmutableFindContractResults(); + params: sc.MutableFindContractParams = new sc.MutableFindContractParams(wasmlib.ScView.nilProxy); + results: sc.ImmutableFindContractResults = new sc.ImmutableFindContractResults(wasmlib.ScView.nilProxy); } export class GetContractRecordsCall { func: wasmlib.ScView = new wasmlib.ScView(sc.HScName, sc.HViewGetContractRecords); - results: sc.ImmutableGetContractRecordsResults = new sc.ImmutableGetContractRecordsResults(); + results: sc.ImmutableGetContractRecordsResults = new sc.ImmutableGetContractRecordsResults(wasmlib.ScView.nilProxy); } export class ScFuncs { static deployContract(ctx: wasmlib.ScFuncCallContext): DeployContractCall { - let f = new DeployContractCall(); - f.func.setPtrs(f.params, null); + const f = new DeployContractCall(); + f.params = new sc.MutableDeployContractParams(wasmlib.newCallParamsProxy(f.func)); return f; } static grantDeployPermission(ctx: wasmlib.ScFuncCallContext): GrantDeployPermissionCall { - let f = new GrantDeployPermissionCall(); - f.func.setPtrs(f.params, null); + const f = new GrantDeployPermissionCall(); + f.params = new sc.MutableGrantDeployPermissionParams(wasmlib.newCallParamsProxy(f.func)); return f; } static revokeDeployPermission(ctx: wasmlib.ScFuncCallContext): RevokeDeployPermissionCall { - let f = new RevokeDeployPermissionCall(); - f.func.setPtrs(f.params, null); + const f = new RevokeDeployPermissionCall(); + f.params = new sc.MutableRevokeDeployPermissionParams(wasmlib.newCallParamsProxy(f.func)); return f; } static findContract(ctx: wasmlib.ScViewCallContext): FindContractCall { - let f = new FindContractCall(); - f.func.setPtrs(f.params, f.results); + const f = new FindContractCall(); + f.params = new sc.MutableFindContractParams(wasmlib.newCallParamsProxy(f.func)); + f.results = new sc.ImmutableFindContractResults(wasmlib.newCallResultsProxy(f.func)); return f; } static getContractRecords(ctx: wasmlib.ScViewCallContext): GetContractRecordsCall { - let f = new GetContractRecordsCall(); - f.func.setPtrs(null, f.results); + const f = new GetContractRecordsCall(); + f.results = new sc.ImmutableGetContractRecordsResults(wasmlib.newCallResultsProxy(f.func)); return f; } } diff --git a/packages/wasmvm/wasmlib/ts/wasmlib/coreroot/params.ts b/packages/wasmvm/wasmlib/ts/wasmlib/coreroot/params.ts index 9129658507..a06c8a699f 100644 --- a/packages/wasmvm/wasmlib/ts/wasmlib/coreroot/params.ts +++ b/packages/wasmvm/wasmlib/ts/wasmlib/coreroot/params.ts @@ -6,68 +6,69 @@ // Change the json schema instead import * as wasmlib from "wasmlib"; +import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; -export class ImmutableDeployContractParams extends wasmlib.ScMapID { - description(): wasmlib.ScImmutableString { - return new wasmlib.ScImmutableString(this.mapID, wasmlib.Key32.fromString(sc.ParamDescription)); +export class ImmutableDeployContractParams extends wasmtypes.ScProxy { + description(): wasmtypes.ScImmutableString { + return new wasmtypes.ScImmutableString(this.proxy.root(sc.ParamDescription)); } - name(): wasmlib.ScImmutableString { - return new wasmlib.ScImmutableString(this.mapID, wasmlib.Key32.fromString(sc.ParamName)); + name(): wasmtypes.ScImmutableString { + return new wasmtypes.ScImmutableString(this.proxy.root(sc.ParamName)); } - programHash(): wasmlib.ScImmutableHash { - return new wasmlib.ScImmutableHash(this.mapID, wasmlib.Key32.fromString(sc.ParamProgramHash)); + programHash(): wasmtypes.ScImmutableHash { + return new wasmtypes.ScImmutableHash(this.proxy.root(sc.ParamProgramHash)); } } -export class MutableDeployContractParams extends wasmlib.ScMapID { - description(): wasmlib.ScMutableString { - return new wasmlib.ScMutableString(this.mapID, wasmlib.Key32.fromString(sc.ParamDescription)); +export class MutableDeployContractParams extends wasmtypes.ScProxy { + description(): wasmtypes.ScMutableString { + return new wasmtypes.ScMutableString(this.proxy.root(sc.ParamDescription)); } - name(): wasmlib.ScMutableString { - return new wasmlib.ScMutableString(this.mapID, wasmlib.Key32.fromString(sc.ParamName)); + name(): wasmtypes.ScMutableString { + return new wasmtypes.ScMutableString(this.proxy.root(sc.ParamName)); } - programHash(): wasmlib.ScMutableHash { - return new wasmlib.ScMutableHash(this.mapID, wasmlib.Key32.fromString(sc.ParamProgramHash)); + programHash(): wasmtypes.ScMutableHash { + return new wasmtypes.ScMutableHash(this.proxy.root(sc.ParamProgramHash)); } } -export class ImmutableGrantDeployPermissionParams extends wasmlib.ScMapID { - deployer(): wasmlib.ScImmutableAgentID { - return new wasmlib.ScImmutableAgentID(this.mapID, wasmlib.Key32.fromString(sc.ParamDeployer)); +export class ImmutableGrantDeployPermissionParams extends wasmtypes.ScProxy { + deployer(): wasmtypes.ScImmutableAgentID { + return new wasmtypes.ScImmutableAgentID(this.proxy.root(sc.ParamDeployer)); } } -export class MutableGrantDeployPermissionParams extends wasmlib.ScMapID { - deployer(): wasmlib.ScMutableAgentID { - return new wasmlib.ScMutableAgentID(this.mapID, wasmlib.Key32.fromString(sc.ParamDeployer)); +export class MutableGrantDeployPermissionParams extends wasmtypes.ScProxy { + deployer(): wasmtypes.ScMutableAgentID { + return new wasmtypes.ScMutableAgentID(this.proxy.root(sc.ParamDeployer)); } } -export class ImmutableRevokeDeployPermissionParams extends wasmlib.ScMapID { - deployer(): wasmlib.ScImmutableAgentID { - return new wasmlib.ScImmutableAgentID(this.mapID, wasmlib.Key32.fromString(sc.ParamDeployer)); +export class ImmutableRevokeDeployPermissionParams extends wasmtypes.ScProxy { + deployer(): wasmtypes.ScImmutableAgentID { + return new wasmtypes.ScImmutableAgentID(this.proxy.root(sc.ParamDeployer)); } } -export class MutableRevokeDeployPermissionParams extends wasmlib.ScMapID { - deployer(): wasmlib.ScMutableAgentID { - return new wasmlib.ScMutableAgentID(this.mapID, wasmlib.Key32.fromString(sc.ParamDeployer)); +export class MutableRevokeDeployPermissionParams extends wasmtypes.ScProxy { + deployer(): wasmtypes.ScMutableAgentID { + return new wasmtypes.ScMutableAgentID(this.proxy.root(sc.ParamDeployer)); } } -export class ImmutableFindContractParams extends wasmlib.ScMapID { - hname(): wasmlib.ScImmutableHname { - return new wasmlib.ScImmutableHname(this.mapID, wasmlib.Key32.fromString(sc.ParamHname)); +export class ImmutableFindContractParams extends wasmtypes.ScProxy { + hname(): wasmtypes.ScImmutableHname { + return new wasmtypes.ScImmutableHname(this.proxy.root(sc.ParamHname)); } } -export class MutableFindContractParams extends wasmlib.ScMapID { - hname(): wasmlib.ScMutableHname { - return new wasmlib.ScMutableHname(this.mapID, wasmlib.Key32.fromString(sc.ParamHname)); +export class MutableFindContractParams extends wasmtypes.ScProxy { + hname(): wasmtypes.ScMutableHname { + return new wasmtypes.ScMutableHname(this.proxy.root(sc.ParamHname)); } } diff --git a/packages/wasmvm/wasmlib/ts/wasmlib/coreroot/results.ts b/packages/wasmvm/wasmlib/ts/wasmlib/coreroot/results.ts index 7a7cf43c50..b35ef2e0b3 100644 --- a/packages/wasmvm/wasmlib/ts/wasmlib/coreroot/results.ts +++ b/packages/wasmvm/wasmlib/ts/wasmlib/coreroot/results.ts @@ -6,66 +6,55 @@ // Change the json schema instead import * as wasmlib from "wasmlib"; +import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; -export class ImmutableFindContractResults extends wasmlib.ScMapID { - contractFound(): wasmlib.ScImmutableBytes { - return new wasmlib.ScImmutableBytes(this.mapID, wasmlib.Key32.fromString(sc.ResultContractFound)); +export class ImmutableFindContractResults extends wasmtypes.ScProxy { + contractFound(): wasmtypes.ScImmutableBytes { + return new wasmtypes.ScImmutableBytes(this.proxy.root(sc.ResultContractFound)); } - contractRecData(): wasmlib.ScImmutableBytes { - return new wasmlib.ScImmutableBytes(this.mapID, wasmlib.Key32.fromString(sc.ResultContractRecData)); + contractRecData(): wasmtypes.ScImmutableBytes { + return new wasmtypes.ScImmutableBytes(this.proxy.root(sc.ResultContractRecData)); } } -export class MutableFindContractResults extends wasmlib.ScMapID { - contractFound(): wasmlib.ScMutableBytes { - return new wasmlib.ScMutableBytes(this.mapID, wasmlib.Key32.fromString(sc.ResultContractFound)); +export class MutableFindContractResults extends wasmtypes.ScProxy { + contractFound(): wasmtypes.ScMutableBytes { + return new wasmtypes.ScMutableBytes(this.proxy.root(sc.ResultContractFound)); } - contractRecData(): wasmlib.ScMutableBytes { - return new wasmlib.ScMutableBytes(this.mapID, wasmlib.Key32.fromString(sc.ResultContractRecData)); + contractRecData(): wasmtypes.ScMutableBytes { + return new wasmtypes.ScMutableBytes(this.proxy.root(sc.ResultContractRecData)); } } -export class MapHnameToImmutableBytes { - objID: i32; +export class MapHnameToImmutableBytes extends wasmtypes.ScProxy { - constructor(objID: i32) { - this.objID = objID; - } - - getBytes(key: wasmlib.ScHname): wasmlib.ScImmutableBytes { - return new wasmlib.ScImmutableBytes(this.objID, key.getKeyID()); + getBytes(key: wasmtypes.ScHname): wasmtypes.ScImmutableBytes { + return new wasmtypes.ScImmutableBytes(this.proxy.key(wasmtypes.hnameToBytes(key))); } } -export class ImmutableGetContractRecordsResults extends wasmlib.ScMapID { +export class ImmutableGetContractRecordsResults extends wasmtypes.ScProxy { contractRegistry(): sc.MapHnameToImmutableBytes { - let mapID = wasmlib.getObjectID(this.mapID, wasmlib.Key32.fromString(sc.ResultContractRegistry), wasmlib.TYPE_MAP); - return new sc.MapHnameToImmutableBytes(mapID); + return new sc.MapHnameToImmutableBytes(this.proxy.root(sc.ResultContractRegistry)); } } -export class MapHnameToMutableBytes { - objID: i32; - - constructor(objID: i32) { - this.objID = objID; - } +export class MapHnameToMutableBytes extends wasmtypes.ScProxy { clear(): void { - wasmlib.clear(this.objID); + this.proxy.clearMap(); } - getBytes(key: wasmlib.ScHname): wasmlib.ScMutableBytes { - return new wasmlib.ScMutableBytes(this.objID, key.getKeyID()); + getBytes(key: wasmtypes.ScHname): wasmtypes.ScMutableBytes { + return new wasmtypes.ScMutableBytes(this.proxy.key(wasmtypes.hnameToBytes(key))); } } -export class MutableGetContractRecordsResults extends wasmlib.ScMapID { +export class MutableGetContractRecordsResults extends wasmtypes.ScProxy { contractRegistry(): sc.MapHnameToMutableBytes { - let mapID = wasmlib.getObjectID(this.mapID, wasmlib.Key32.fromString(sc.ResultContractRegistry), wasmlib.TYPE_MAP); - return new sc.MapHnameToMutableBytes(mapID); + return new sc.MapHnameToMutableBytes(this.proxy.root(sc.ResultContractRegistry)); } } diff --git a/packages/wasmvm/wasmlib/ts/wasmlib/dict.ts b/packages/wasmvm/wasmlib/ts/wasmlib/dict.ts new file mode 100644 index 0000000000..686a349034 --- /dev/null +++ b/packages/wasmvm/wasmlib/ts/wasmlib/dict.ts @@ -0,0 +1,113 @@ +// Copyright 2020 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +import * as wasmtypes from "./wasmtypes" +import {log} from "./sandbox"; + +export class ScDict implements wasmtypes.IKvStore { + dict: Map = new Map(); + + static toKey(buf: u8[]): string { + let key = ""; + for (let i = 0; i < buf.length; i++) { + key += String.fromCharCode((buf[i] >> 4) + 0x40, (buf[i] & 0x0f) + 0x40); + } + //log("toKey(" + wasmtypes.hex(buf) + ")=" + key); + return key; + } + + static fromKey(key: string): u8[] { + let buf: u8[] = new Array(key.length / 2); + for (let i = 0; i < key.length; i += 2) { + const b1 = key.charCodeAt(i) as u8; + const b2 = key.charCodeAt(i + 1) as u8; + buf[i / 2] = (((b1 - 0x40) << 4) | (b2 - 0x40)); + } + //log("fromKey(" + key + ")=" + wasmtypes.hex(buf)); + return buf; + } + + public constructor(buf: u8[]) { + if (buf.length != 0) { + const dec = new wasmtypes.WasmDecoder(buf); + const size = wasmtypes.uint32FromBytes(dec.fixedBytes(wasmtypes.ScUint32Length)); + for (let i: u32 = 0; i < size; i++) { + const keyLen = wasmtypes.uint16FromBytes(dec.fixedBytes(wasmtypes.ScUint16Length)); + const key = dec.fixedBytes(keyLen as u32); + const valLen = wasmtypes.uint32FromBytes(dec.fixedBytes(wasmtypes.ScUint32Length)); + const val = dec.fixedBytes(valLen); + this.set(key, val); + } + } + } + + public asProxy(): wasmtypes.Proxy { + return new wasmtypes.Proxy(this); + } + + delete(key: u8[]): void { + this.dict.delete(ScDict.toKey(key)); + } + + exists(key: u8[]): bool { + return this.dict.has(ScDict.toKey(key)); + } + + get(key: u8[]): u8[] | null { + const mapKey = ScDict.toKey(key); + if (! this.dict.has(mapKey)) { + return null; + } + return this.dict.get(mapKey); + } + + public immutable(): ScImmutableDict { + return new ScImmutableDict(this); + } + + set(key: u8[], value: u8[]): void { + this.dict.set(ScDict.toKey(key), value); + } + + public toBytes(): u8[] { + if (this.dict.size == 0) { + return [0, 0, 0, 0]; + } + const keys = this.dict.keys().sort(); + const enc = new wasmtypes.WasmEncoder(); + enc.fixedBytes(wasmtypes.uint32ToBytes(keys.length as u32), wasmtypes.ScUint32Length); + for (let i = 0; i < keys.length; i++) { + const k = keys[i]; + const key = ScDict.fromKey(k); + let val = this.dict.get(k); + if (val === null) { + val = []; + } + enc.fixedBytes(wasmtypes.uint16ToBytes(key.length as u16), wasmtypes.ScUint16Length); + enc.fixedBytes(key, key.length as u32); + enc.fixedBytes(wasmtypes.uint32ToBytes(val.length as u32), wasmtypes.ScUint32Length); + enc.fixedBytes(val, val.length as u32); + } + return enc.buf(); + } +} + +export class ScImmutableDict { + dict: Map; + + public constructor(dict: ScDict) { + this.dict = dict.dict; + } + + exists(key: u8[]): bool { + return this.dict.has(ScDict.toKey(key)); + } + + get(key: u8[]): u8[] | null { + const mapKey = ScDict.toKey(key); + if (! this.dict.has(mapKey)) { + return null; + } + return this.dict.get(mapKey); + } +} diff --git a/packages/wasmvm/wasmlib/ts/wasmlib/events.ts b/packages/wasmvm/wasmlib/ts/wasmlib/events.ts index 0779992c77..30db9907e6 100644 --- a/packages/wasmvm/wasmlib/ts/wasmlib/events.ts +++ b/packages/wasmvm/wasmlib/ts/wasmlib/events.ts @@ -1,115 +1,26 @@ // Copyright 2020 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 -import {ScAddress, ScAgentID, ScChainID, ScColor, ScHash, ScHname, ScRequestID} from "./hashtypes"; -import * as keys from "./keys"; -import {base58Encode, ROOT} from "./context"; +import * as wasmtypes from "./wasmtypes" +import {ScSandboxFunc} from "./sandbox"; -// encodes separate entities into a byte buffer export class EventEncoder { event: string; // constructs an encoder constructor(eventName: string) { this.event = eventName; - let timestamp = ROOT.getInt64(keys.KEY_TIMESTAMP).value(); - this.int64(timestamp / 1_000_000_000); + let timestamp = new ScSandboxFunc().timestamp(); + // convert nanoseconds to seconds + this.encode(wasmtypes.uint64ToString(timestamp / 1_000_000_000)); } - // encodes an ScAddress into the byte buffer - address(value: ScAddress): EventEncoder { - return this.string(value.toString()); - } - - // encodes an ScAgentID into the byte buffer - agentID(value: ScAgentID): EventEncoder { - return this.string(value.toString()); - } - - // encodes a Bool into the byte buffer - bool(value: bool): EventEncoder { - return this.uint8(value ? 1 : 0); - } - - // encodes a substring of bytes into the byte buffer - bytes(value: u8[]): EventEncoder { - return this.string(base58Encode(value)); - } - - // encodes an ScChainID into the byte buffer - chainID(value: ScChainID): EventEncoder { - return this.string(value.toString()); - } - - // encodes an ScColor into the byte buffer - color(value: ScColor): EventEncoder { - return this.string(value.toString()); - } - - // retrieve the encoded byte buffer emit(): void { - ROOT.getString(keys.KEY_EVENT).setValue(this.event); - } - - // encodes an ScHash into the byte buffer - hash(value: ScHash): EventEncoder { - return this.string(value.toString()); - } - - // encodes an ScHname into the byte buffer - hname(value: ScHname): EventEncoder { - return this.string(value.toString()); - } - - // encodes an Int8 into the byte buffer - int8(value: i8): EventEncoder { - return this.string(value.toString()); - } - - // encodes an Int16 into the byte buffer - int16(value: i16): EventEncoder { - return this.string(value.toString()); - } - - // encodes an Int32 into the byte buffer - int32(value: i32): EventEncoder { - return this.string(value.toString()); - } - - // encodes an Int64 into the byte buffer - int64(value: i64): EventEncoder { - return this.string(value.toString()); - } - - // encodes an ScRequestID into the byte buffer - requestID(value: ScRequestID): EventEncoder { - return this.string(value.toString()); + new ScSandboxFunc().event(this.event); } - // encodes an UTF-8 text string into the byte buffer - string(value: string): EventEncoder { + encode(value: string): void { //TODO encode potential vertical bars that are present in the value string this.event += "|" + value; - return this; - } - - // encodes an Uint8 into the byte buffer - uint8(value: u8): EventEncoder { - return this.string(value.toString()); - } - - // encodes an Uint16 into the byte buffer - uint16(value: u16): EventEncoder { - return this.string(value.toString()); - } - - // encodes an Uint32 into the byte buffer - uint32(value: u32): EventEncoder { - return this.string(value.toString()); - } - - // encodes an Uint64 into the byte buffer - uint64(value: u64): EventEncoder { - return this.string(value.toString()); } } diff --git a/packages/wasmvm/wasmlib/ts/wasmlib/exports.ts b/packages/wasmvm/wasmlib/ts/wasmlib/exports.ts index 19a08439fc..9f81d44b9a 100644 --- a/packages/wasmvm/wasmlib/ts/wasmlib/exports.ts +++ b/packages/wasmvm/wasmlib/ts/wasmlib/exports.ts @@ -3,10 +3,8 @@ // Provide host with details about funcs and views in this smart contract -import {ROOT, ScFuncContext, ScViewContext} from "./context"; -import {KEY_EXPORTS, KEY_PARAMS, KEY_RESULTS, KEY_STATE, KEY_ZZZZZZZ} from "./keys"; -import {ScMutableStringArray} from "./mutable"; -import {getObjectID, OBJ_ID_PARAMS, OBJ_ID_RESULTS, OBJ_ID_ROOT, OBJ_ID_STATE, TYPE_MAP} from "./host"; +import {ScFuncContext, ScViewContext} from "./context"; +import {exportName, exportWasmTag} from "./host"; // Note that we do not use the Wasm export symbol table on purpose // because Wasm does not allow us to determine whether the symbols @@ -27,11 +25,6 @@ let views: Array = []; // the host will pass the index of one of the entry points // that was provided by onLoad during SC initialization export function onCall(index: i32): void { - let ctx = new ScFuncContext(); - ctx.require(getObjectID(OBJ_ID_ROOT, KEY_STATE, TYPE_MAP) == OBJ_ID_STATE, "object id mismatch"); - ctx.require(getObjectID(OBJ_ID_ROOT, KEY_PARAMS, TYPE_MAP) == OBJ_ID_PARAMS, "object id mismatch"); - ctx.require(getObjectID(OBJ_ID_ROOT, KEY_RESULTS, TYPE_MAP) == OBJ_ID_RESULTS, "object id mismatch"); - if ((index & 0x8000) != 0) { // immutable view function, invoke with a view context let view = views[index & 0x7fff]; @@ -41,7 +34,7 @@ export function onCall(index: i32): void { // mutable full function, invoke with a func context let func = funcs[index]; - func(ctx); + func(new ScFuncContext()); } // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ @@ -49,15 +42,9 @@ export function onCall(index: i32): void { // context for onLoad function to be able to tell host which // funcs and views are available as entry points to the SC export class ScExports { - exports: ScMutableStringArray; - // constructs the symbol export context for the onLoad function constructor() { - this.exports = ROOT.getStringArray(KEY_EXPORTS); - // tell host what value our special predefined key is - // this helps detect versioning problems between host - // and client versions of WasmLib - this.exports.getString(KEY_ZZZZZZZ.keyID).setValue("TypeScript:KEY_ZZZZZZZ"); + exportWasmTag() } // defines the external name of a smart contract func @@ -65,7 +52,7 @@ export class ScExports { addFunc(name: string, f: ScFuncContextFunc): void { let index = funcs.length; funcs.push(f); - this.exports.getString(index).setValue(name); + exportName(index, name); } // defines the external name of a smart contract view @@ -73,7 +60,7 @@ export class ScExports { addView(name: string, v: ScViewContextFunc): void { let index = views.length as i32; views.push(v); - this.exports.getString(index | 0x8000).setValue(name); + exportName(index | 0x8000, name); } } diff --git a/packages/wasmvm/wasmlib/ts/wasmlib/hashtypes.ts b/packages/wasmvm/wasmlib/ts/wasmlib/hashtypes.ts deleted file mode 100644 index 72e35f1ac5..0000000000 --- a/packages/wasmvm/wasmlib/ts/wasmlib/hashtypes.ts +++ /dev/null @@ -1,337 +0,0 @@ -// Copyright 2020 IOTA Stiftung -// SPDX-License-Identifier: Apache-2.0 - -// standard value types used by the ISCP - -import {base58Encode, ScFuncContext} from "./context"; -import {Convert} from "./convert"; -import {getKeyIDFromBytes, panic} from "./host"; -import {Key32, MapKey} from "./keys"; - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -function zeroes(count: i32): u8[] { - let buf : u8[] = new Array(count); - buf.fill(0); - return buf; -} - -// value object for 33-byte Tangle address ids -export class ScAddress implements MapKey { - id: u8[] = zeroes(33); - - // construct from byte array - static fromBytes(bytes: u8[]): ScAddress { - let o = new ScAddress(); - if (bytes.length != o.id.length) { - panic("invalid address id length"); - } - o.id = bytes.slice(0); - return o; - } - - // returns agent id representation of this Tangle address - asAgentID(): ScAgentID { - return ScAgentID.fromParts(this, ScHname.zero); - } - - equals(other: ScAddress): boolean { - return Convert.equals(this.id, other.id); - } - - // can be used as key in maps - getKeyID(): Key32 { - return getKeyIDFromBytes(this.id); - } - - // convert to byte array representation - toBytes(): u8[] { - return this.id; - } - - // human-readable string representation - toString(): string { - return base58Encode(this.id); - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -// value object for 37-byte agent ids -export class ScAgentID implements MapKey { - id: u8[] = zeroes(37); - - // construct from byte array - static fromBytes(bytes: u8[]): ScAgentID { - let o = new ScAgentID(); - if (bytes.length != o.id.length) { - panic("invalid agent id length"); - } - o.id = bytes.slice(0); - return o; - } - - // construct from address and contract name hash - static fromParts(address: ScAddress, hname: ScHname): ScAgentID { - let agentID = new ScAgentID(); - agentID.id = address.id.concat(hname.id); - return agentID; - } - - // gets Tangle address from agent id - address(): ScAddress { - let address = new ScAddress(); - address.id = this.id.slice(0, address.id.length); - return address; - } - - equals(other: ScAgentID): boolean { - return Convert.equals(this.id, other.id); - } - - // can be used as key in maps - getKeyID(): Key32 { - return getKeyIDFromBytes(this.id); - } - - // get contract name hash for this agent - hname(): ScHname { - let hname = new ScHname(0); - hname.id = this.id.slice(this.id.length - hname.id.length); - return hname; - } - - // checks to see if agent id represents a Tangle address - isAddress(): boolean { - return this.hname().equals(ScHname.zero); - } - - // convert to byte array representation - toBytes(): u8[] { - return this.id; - } - - // human-readable string representation - toString(): string { - return base58Encode(this.id); - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -// value object for 33-byte chain ids -export class ScChainID implements MapKey { - id: u8[] = zeroes(33); - - // construct from byte array - static fromBytes(bytes: u8[]): ScChainID { - let o = new ScChainID(); - if (bytes.length != o.id.length) { - panic("invalid chain id length"); - } - o.id = bytes.slice(0); - return o; - } - - // gets Tangle address from chain id - address(): ScAddress { - let address = new ScAddress(); - address.id = this.id.slice(0, address.id.length); - return address; - } - - equals(other: ScChainID): boolean { - return Convert.equals(this.id, other.id); - } - - // can be used as key in maps - getKeyID(): Key32 { - return getKeyIDFromBytes(this.id); - } - - // convert to byte array representation - toBytes(): u8[] { - return this.id; - } - - // human-readable string representation - toString(): string { - return base58Encode(this.id); - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -// value object for 32-byte token color -export class ScColor implements MapKey { - id: u8[] = new Array(32); - - // predefined colors - static IOTA: ScColor = new ScColor(0x00); - static MINT: ScColor = new ScColor(0xff); - - constructor(fill: u8) { - this.id.fill(fill) - } - - // construct from byte array - static fromBytes(bytes: u8[]): ScColor { - let o = new ScColor(0); - if (bytes.length != o.id.length) { - panic("invalid color id length"); - } - o.id = bytes.slice(0); - return o; - } - - // construct from request id, this will return newly minted color - static fromRequestID(requestID: ScRequestID): ScColor { - let color = new ScColor(0); - color.id = requestID.id.slice(0, color.id.length) - return color; - } - - equals(other: ScColor): boolean { - return Convert.equals(this.id, other.id); - } - - // can be used as key in maps - getKeyID(): Key32 { - return getKeyIDFromBytes(this.id); - } - - // convert to byte array representation - toBytes(): u8[] { - return this.id; - } - - // human-readable string representation - toString(): string { - return base58Encode(this.id); - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -// value object for 32-byte hash value -export class ScHash implements MapKey { - id: u8[] = zeroes(32); - - // construct from byte array - static fromBytes(bytes: u8[]): ScHash { - let o = new ScHash(); - if (bytes.length != o.id.length) { - panic("invalid hash id length"); - } - o.id = bytes.slice(0); - return o; - } - - equals(other: ScHash): boolean { - return Convert.equals(this.id, other.id); - } - - // can be used as key in maps - getKeyID(): Key32 { - return getKeyIDFromBytes(this.id); - } - - // convert to byte array representation - toBytes(): u8[] { - return this.id; - } - - // human-readable string representation - toString(): string { - return base58Encode(this.id); - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -// value object for 4-byte name hash -export class ScHname implements MapKey { - id: u8[] = zeroes(4) - - static zero: ScHname = new ScHname(0); - - // construct from name string - constructor(id: u32) { - this.id = Convert.fromI32(id); - } - - static fromName(name: string): ScHname { - return new ScFuncContext().utility().hname(name); - } - - // construct from byte array - static fromBytes(bytes: u8[]): ScHname { - let o = new ScHname(0); - if (bytes.length != o.id.length) { - panic("invalid hname length"); - } - o.id = bytes.slice(0); - return o; - } - - equals(other: ScHname): boolean { - return Convert.equals(this.id, other.id); - } - - // can be used as key in maps - getKeyID(): Key32 { - return getKeyIDFromBytes(this.id); - } - - // convert to byte array representation - toBytes(): u8[] { - return this.id; - } - - // human-readable string representation: 8 hex digits - toString(): string { - const hex = "0123456789abcdef"; - let res = "" - for (let i = 3; i >= 0; i--) { - let b = this.id[i]; - res += hex.charAt((b >> 4) & 0x0f) + hex.charAt(b & 0x0f); - } - return res; - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -// value object for 34-byte transaction request ids -export class ScRequestID implements MapKey { - id: u8[] = zeroes(34); - - // construct from byte array - static fromBytes(bytes: u8[]): ScRequestID { - let o = new ScRequestID(); - if (bytes.length != o.id.length) { - panic("invalid request id length"); - } - o.id = bytes.slice(0); - return o; - } - - equals(other: ScRequestID): boolean { - return Convert.equals(this.id, other.id); - } - - // can be used as key in maps - getKeyID(): Key32 { - return getKeyIDFromBytes(this.id); - } - - // convert to byte array representation - toBytes(): u8[] { - return this.id; - } - - // human-readable string representation - toString(): string { - return base58Encode(this.id); - } -} diff --git a/packages/wasmvm/wasmlib/ts/wasmlib/host.ts b/packages/wasmvm/wasmlib/ts/wasmlib/host.ts index b5588d3475..c7ce125126 100644 --- a/packages/wasmvm/wasmlib/ts/wasmlib/host.ts +++ b/packages/wasmvm/wasmlib/ts/wasmlib/host.ts @@ -1,200 +1,32 @@ // Copyright 2020 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 +import * as wasmtypes from "./wasmtypes" + // interface WasmLib to the VM host -// all type id values should exactly match their counterpart values on the host! - -import * as keys from "./keys"; -import {Key32} from "./keys"; -import {Convert} from "./convert"; - -export const TYPE_ARRAY: i32 = 0x20; -export const TYPE_ARRAY16: i32 = 0x60; -export const TYPE_CALL: i32 = 0x80; -export const TYPE_MASK: i32 = 0x1f; - -export const TYPE_ADDRESS: i32 = 1; -export const TYPE_AGENT_ID: i32 = 2; -export const TYPE_BOOL: i32 = 3; -export const TYPE_BYTES: i32 = 4; -export const TYPE_CHAIN_ID: i32 = 5; -export const TYPE_COLOR: i32 = 6; -export const TYPE_HASH: i32 = 7; -export const TYPE_HNAME: i32 = 8; -export const TYPE_INT8: i32 = 9; -export const TYPE_INT16: i32 = 10; -export const TYPE_INT32: i32 = 11; -export const TYPE_INT64: i32 = 12; -export const TYPE_MAP: i32 = 13; -export const TYPE_REQUEST_ID: i32 = 14; -export const TYPE_STRING: i32 = 15; - -export const OBJ_ID_NULL: i32 = 0; -export const OBJ_ID_ROOT: i32 = 1; -export const OBJ_ID_STATE: i32 = 2; -export const OBJ_ID_PARAMS: i32 = 3; -export const OBJ_ID_RESULTS: i32 = 4; - -// size in bytes of predefined types, indexed by the TYPE_* consts -export const TYPE_SIZES: u8[] = [0, 33, 37, 1, 0, 33, 32, 32, 4, 1, 2, 4, 8, 0, 34, 0]; - - -// These 4 external functions are funneling the entire WasmLib functionality +// These 2 external functions are funneling the entire WasmLib functionality // to their counterparts on the host. -// Copy the value data bytes of type stored in the host container object , -// under key , into the pre-allocated which can hold len bytes. -// Returns the actual length of the value data bytes on the host. -@external("WasmLib", "hostGetBytes") -export declare function hostGetBytes(objID: i32, keyID: i32, typeID: i32, buffer: usize, size: i32): i32; - -// Retrieve the key id associated with the data bytes of length . -// A negative length indicates a bytes key, positive indicates a string key -// We discern between the two for better readable logging purposes -@external("WasmLib", "hostGetKeyID") -export declare function hostGetKeyID(key: usize, size: i32): i32; - -// Retrieve the id of the container sub-object of type stored in -// the host container object , under key . -@external("WasmLib", "hostGetObjectID") -export declare function hostGetObjectID(objID: i32, keyID: i32, typeID: i32): i32; - -// copy the value data bytes of type from the -// into the host container object , under key . -@external("WasmLib", "hostSetBytes") -export declare function hostSetBytes(objID: i32, keyID: i32, typeID: i32, buffer: usize, size: i32): void; - @external("WasmLib", "hostStateGet") export declare function hostStateGet(keyRef: usize, keyLen: i32, valRef: usize, valLen: i32): i32; @external("WasmLib", "hostStateSet") export declare function hostStateSet(keyRef: usize, keyLen: i32, valRef: usize, valLen: i32): void; - -export function callFunc(objID: i32, keyID: Key32, params: u8[]): u8[] { - // variable-sized type, first query expected length of bytes array - // (pass zero-length buffer) - let size = hostGetBytes(objID, keyID.keyID, TYPE_CALL, params.dataStart, params.length); - - // -1 means non-existent, so return default value for type - if (size <= 0) { - return []; - } - - // allocate a sufficient length byte array in Wasm memory - // and let the host copy the actual data bytes into this Wasm byte array - let result: u8[] = new Array(size); - hostGetBytes(objID, keyID.keyID, TYPE_CALL + 1, result.dataStart, size); - return result; -} - -// Clear the entire contents of the specified container object. -// Removes all its sub-objects as well. -export function clear(objID: i32): void { - // special key "length" is used with integer value zero - setBytes(objID, keys.KEY_LENGTH, TYPE_INT32, Convert.fromI32(0)); +export function exportName(index: i32, name: string): void { + const buf = wasmtypes.stringToBytes(name); + hostStateSet(0, index, buf.dataStart, buf.length as i32); } -// Delete the value with the specified key and type from the specified container object. -export function delKey(objID: i32, keyID: Key32, typeID: i32): void { - // size -1 means delete - // this removes the need for a separate hostDelete function - hostSetBytes(objID, keyID.keyID, typeID, 0, -1); +export function exportWasmTag(): void { + exportName(-1, "WASM::TYPESCRIPT"); } -// Check if the specified container object contains a value with the specified key and type. -export function exists(objID: i32, keyID: Key32, typeID: i32): boolean { - // negative length (-1) means only test for existence - // returned size -1 indicates keyID not found (or error) - // this removes the need for a separate hostExists function - return hostGetBytes(objID, keyID.keyID, typeID, 0, -1) >= 0; -} - -// Retrieve the bytes stored in the specified container object under the specified key -// and with specified type. Note that if the key does not exist this function will -// return the default value for the specified type. -export function getBytes(objID: i32, keyID: Key32, typeID: i32): u8[] { - let size = TYPE_SIZES[typeID] as i32; - if (size == 0) { - // variable-sized type, first query expected length of bytes array - // (pass zero-length buffer) - size = hostGetBytes(objID, keyID.keyID, typeID, 0, 0); - - // -1 means non-existent, so return default value for type - if (size < 0) { - return []; - } +export function sandbox(funcNr: i32, params: u8[] | null): u8[] { + if (params === null) { + params = []; } - - // allocate a sufficient length byte array in Wasm memory - // and let the host copy the actual data bytes into this Wasm byte array - let result: u8[] = new Array(size); - hostGetBytes(objID, keyID.keyID, typeID, result.dataStart, size); - return result; -} - -// Retrieve the key id that the host has associated with the specified bytes key -export function getKeyID(bytes: u8[], size: i32): Key32 { - // negative size indicates this is a bytes key - return new Key32(hostGetKeyID(bytes.dataStart, size)); -} - -// Retrieve the key id that the host has associated with the specified bytes key -export function getKeyIDFromBytes(bytes: u8[]): Key32 { - // negative size indicates this is a bytes key - return getKeyID(bytes, -bytes.length - 1); -} - -// Retrieve the key id that the host has associated with the specified string key -export function getKeyIDFromString(key: string): Key32 { - let bytes = Convert.fromString(key); - - // non-negative size indicates this is a string key - return getKeyID(bytes, bytes.length); -} - -// Retrieve the key id that the host has associated with the specified integer key -export function getKeyIDFromUint64(key: u64, nrOfBytes: usize): Key32 { - // negative size indicates this is a bytes key - return getKeyID(Convert.fromI64(key as i64), -nrOfBytes - 1); -} - -// Retrieve the length of an array container object on the host -export function getLength(objID: i32): u32 { - // special integer key "length" is used - let bytes = getBytes(objID, keys.KEY_LENGTH, TYPE_INT32); - return Convert.toI32(bytes) as u32; -} - -// Retrieve the id of the specified container sub-object -export function getObjectID(objID: i32, keyID: Key32, typeID: i32): i32 { - return hostGetObjectID(objID, keyID.keyID, typeID); -} - -// Direct logging of informational text to host log -export function log(text: string): void { - setBytes(1, keys.KEY_LOG, TYPE_STRING, Convert.fromString(text)); -} - -// Direct logging of error to host log, followed by panicking out of the Wasm code -export function panic(text: string): void { - setBytes(1, keys.KEY_PANIC, TYPE_STRING, Convert.fromString(text)); -} - -// Store the provided value bytes of specified type in the specified container object -// under the specified key. Note that if the key does not exist this function will -// create it first. -export function setBytes(objID: i32, keyID: Key32, typeID: i32, value: u8[]): void { - return hostSetBytes(objID, keyID.keyID, typeID, value.dataStart, value.length); -} - -// Direct logging of debug trace text to host log -export function trace(text: string): void { - setBytes(1, keys.KEY_TRACE, TYPE_STRING, Convert.fromString(text)); -} - -export function sandbox(funcNr: i32, params: u8[]): u8[] { // call sandbox function, result value will be cached by host // always negative funcNr as keyLen indicates sandbox call // this removes the need for a separate hostSandbox function @@ -215,7 +47,7 @@ export function stateDelete(key: u8[]): void { hostStateSet(key.dataStart, key.length as i32, 0, -1); } -export function stateExistst(key: u8[]): bool { +export function stateExists(key: u8[]): bool { return hostStateGet(key.dataStart, key.length as i32, 0, -1) >= 0; } diff --git a/packages/wasmvm/wasmlib/ts/wasmlib/immutable.ts b/packages/wasmvm/wasmlib/ts/wasmlib/immutable.ts deleted file mode 100644 index abcb56e410..0000000000 --- a/packages/wasmvm/wasmlib/ts/wasmlib/immutable.ts +++ /dev/null @@ -1,717 +0,0 @@ -// Copyright 2020 IOTA Stiftung -// SPDX-License-Identifier: Apache-2.0 - -// immutable proxies to host objects - -import { base58Encode } from "./context"; -import {Convert} from "./convert"; -import {ScAddress,ScAgentID,ScChainID,ScColor,ScHash,ScHname,ScRequestID} from "./hashtypes"; -import * as host from "./host"; -import {Key32,MapKey} from "./keys"; - -// value proxy for immutable ScAddress in host container -export class ScImmutableAddress { - objID: i32; - keyID: Key32; - - constructor(objID: i32, keyID: Key32) { - this.objID = objID; - this.keyID = keyID; - } - - // check if value exists in host container - exists(): boolean { - return host.exists(this.objID, this.keyID, host.TYPE_ADDRESS); - } - - // human-readable string representation - toString(): string { - return this.value().toString(); - } - - // get value from host container - value(): ScAddress { - return ScAddress.fromBytes(host.getBytes(this.objID, this.keyID, host.TYPE_ADDRESS)); - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -// value proxy for immutable ScAgentID in host container -export class ScImmutableAgentID { - objID: i32; - keyID: Key32; - - constructor(objID: i32, keyID: Key32) { - this.objID = objID; - this.keyID = keyID; - } - - // check if value exists in host container - exists(): boolean { - return host.exists(this.objID, this.keyID, host.TYPE_AGENT_ID); - } - - // human-readable string representation - toString(): string { - return this.value().toString(); - } - - // get value from host container - value(): ScAgentID { - return ScAgentID.fromBytes(host.getBytes(this.objID, this.keyID, host.TYPE_AGENT_ID)); - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -// value proxy for immutable Bool in host container -export class ScImmutableBool { - objID: i32; - keyID: Key32; - - constructor(objID: i32, keyID: Key32) { - this.objID = objID; - this.keyID = keyID; - } - - // check if value exists in host container - exists(): boolean { - return host.exists(this.objID, this.keyID, host.TYPE_BOOL); - } - - // human-readable string representation - toString(): string { - return this.value().toString(); - } - - // get value from host container - value(): boolean { - let bytes = host.getBytes(this.objID, this.keyID, host.TYPE_BOOL); - return bytes[0] != 0; - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -// value proxy for immutable bytes array in host container -export class ScImmutableBytes { - objID: i32; - keyID: Key32; - - constructor(objID: i32, keyID: Key32) { - this.objID = objID; - this.keyID = keyID; - } - - // check if value exists in host container - exists(): boolean { - return host.exists(this.objID, this.keyID, host.TYPE_BYTES); - } - - // human-readable string representation - toString(): string { - return base58Encode(this.value()); - } - - // get value from host container - value(): u8[] { - return host.getBytes(this.objID, this.keyID, host.TYPE_BYTES); - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -// value proxy for immutable ScChainID in host container -export class ScImmutableChainID { - objID: i32; - keyID: Key32; - - constructor(objID: i32, keyID: Key32) { - this.objID = objID; - this.keyID = keyID; - } - - // check if value exists in host container - exists(): boolean { - return host.exists(this.objID, this.keyID, host.TYPE_CHAIN_ID); - } - - // human-readable string representation - toString(): string { - return this.value().toString(); - } - - // get value from host container - value(): ScChainID { - return ScChainID.fromBytes(host.getBytes(this.objID, this.keyID, host.TYPE_CHAIN_ID)); - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -// value proxy for immutable ScColor in host container -export class ScImmutableColor { - objID: i32; - keyID: Key32; - - constructor(objID: i32, keyID: Key32) { - this.objID = objID; - this.keyID = keyID; - } - - // check if value exists in host container - exists(): boolean { - return host.exists(this.objID, this.keyID, host.TYPE_COLOR); - } - - // human-readable string representation - toString(): string { - return this.value().toString(); - } - - // get value from host container - value(): ScColor { - return ScColor.fromBytes(host.getBytes(this.objID, this.keyID, host.TYPE_COLOR)); - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -// array proxy for immutable array of ScColor -export class ScImmutableColorArray { - objID: i32; - - constructor(id: i32) { - this.objID = id; - } - - // get value proxy for item at index, index can be 0..length()-1 - getColor(index: u32): ScImmutableColor { - return new ScImmutableColor(this.objID, new Key32(index as i32)); - } - - // number of items in array - length(): u32 { - return host.getLength(this.objID); - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -// value proxy for immutable ScHash in host container -export class ScImmutableHash { - objID: i32; - keyID: Key32; - - constructor(objID: i32, keyID: Key32) { - this.objID = objID; - this.keyID = keyID; - } - - // check if value exists in host container - exists(): boolean { - return host.exists(this.objID, this.keyID, host.TYPE_HASH); - } - - // human-readable string representation - toString(): string { - return this.value().toString(); - } - - // get value from host container - value(): ScHash { - return ScHash.fromBytes(host.getBytes(this.objID, this.keyID, host.TYPE_HASH)); - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -// value proxy for immutable ScHname in host container -export class ScImmutableHname { - objID: i32; - keyID: Key32; - - constructor(objID: i32, keyID: Key32) { - this.objID = objID; - this.keyID = keyID; - } - - // check if value exists in host container - exists(): boolean { - return host.exists(this.objID, this.keyID, host.TYPE_HNAME); - } - - // human-readable string representation - toString(): string { - return this.value().toString(); - } - - // get value from host container - value(): ScHname { - return ScHname.fromBytes(host.getBytes(this.objID, this.keyID, host.TYPE_HNAME)); - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -// value proxy for immutable Int8 in host container -export class ScImmutableInt8 { - objID: i32; - keyID: Key32; - - constructor(objID: i32, keyID: Key32) { - this.objID = objID; - this.keyID = keyID; - } - - // check if value exists in host container - exists(): boolean { - return host.exists(this.objID, this.keyID, host.TYPE_INT8); - } - - // human-readable string representation - toString(): string { - return this.value().toString(); - } - - // get value from host container - value(): i8 { - let bytes = host.getBytes(this.objID, this.keyID, host.TYPE_INT8); - return bytes[0] as i8; - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -// value proxy for immutable Int16 in host container -export class ScImmutableInt16 { - objID: i32; - keyID: Key32; - - constructor(objID: i32, keyID: Key32) { - this.objID = objID; - this.keyID = keyID; - } - - // check if value exists in host container - exists(): boolean { - return host.exists(this.objID, this.keyID, host.TYPE_INT16); - } - - // human-readable string representation - toString(): string { - return this.value().toString(); - } - - // get value from host container - value(): i16 { - let bytes = host.getBytes(this.objID, this.keyID, host.TYPE_INT16); - return Convert.toI16(bytes); - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -// value proxy for immutable Int32 in host container -export class ScImmutableInt32 { - objID: i32; - keyID: Key32; - - constructor(objID: i32, keyID: Key32) { - this.objID = objID; - this.keyID = keyID; - } - - // check if value exists in host container - exists(): boolean { - return host.exists(this.objID, this.keyID, host.TYPE_INT32); - } - - // human-readable string representation - toString(): string { - return this.value().toString(); - } - - // get value from host container - value(): i32 { - let bytes = host.getBytes(this.objID, this.keyID, host.TYPE_INT32); - return Convert.toI32(bytes); - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -// value proxy for immutable Int64 in host container -export class ScImmutableInt64 { - objID: i32; - keyID: Key32; - - constructor(objID: i32, keyID: Key32) { - this.objID = objID; - this.keyID = keyID; - } - - // check if value exists in host container - exists(): boolean { - return host.exists(this.objID, this.keyID, host.TYPE_INT64); - } - - // human-readable string representation - toString(): string { - return this.value().toString(); - } - - // get value from host container - value(): i64 { - let bytes = host.getBytes(this.objID, this.keyID, host.TYPE_INT64); - return Convert.toI64(bytes); - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -// map proxy for immutable map -export class ScImmutableMap { - objID: i32; - - constructor(id: i32) { - this.objID = id; - } - - callFunc(keyID: Key32, params: u8[]): u8[] { - return host.callFunc(this.objID, keyID, params); - } - - // get value proxy for immutable ScAddress field specified by key - getAddress(key: MapKey): ScImmutableAddress { - return new ScImmutableAddress(this.objID, key.getKeyID()); - } - - // get value proxy for immutable ScAgentID field specified by key - getAgentID(key: MapKey): ScImmutableAgentID { - return new ScImmutableAgentID(this.objID, key.getKeyID()); - } - - // get value proxy for immutable Bool field specified by key - getBool(key: MapKey): ScImmutableBool { - return new ScImmutableBool(this.objID, key.getKeyID()); - } - - // get value proxy for immutable bytes array field specified by key - getBytes(key: MapKey): ScImmutableBytes { - return new ScImmutableBytes(this.objID, key.getKeyID()); - } - - // get value proxy for immutable ScChainID field specified by key - getChainID(key: MapKey): ScImmutableChainID { - return new ScImmutableChainID(this.objID, key.getKeyID()); - } - - // get value proxy for immutable ScColor field specified by key - getColor(key: MapKey): ScImmutableColor { - return new ScImmutableColor(this.objID, key.getKeyID()); - } - - // get array proxy for ScImmutableColorArray specified by key - getColorArray(key: MapKey): ScImmutableColorArray { - let arrID = host.getObjectID(this.objID, key.getKeyID(), host.TYPE_COLOR | host.TYPE_ARRAY); - return new ScImmutableColorArray(arrID); - } - - // get value proxy for immutable ScHash field specified by key - getHash(key: MapKey): ScImmutableHash { - return new ScImmutableHash(this.objID, key.getKeyID()); - } - - // get value proxy for immutable ScHname field specified by key - getHname(key: MapKey): ScImmutableHname { - return new ScImmutableHname(this.objID, key.getKeyID()); - } - - // get value proxy for immutable Int8 field specified by key - getInt8(key: MapKey): ScImmutableInt8 { - return new ScImmutableInt8(this.objID, key.getKeyID()); - } - - // get value proxy for immutable Int16 field specified by key - getInt16(key: MapKey): ScImmutableInt16 { - return new ScImmutableInt16(this.objID, key.getKeyID()); - } - - // get value proxy for immutable Int32 field specified by key - getInt32(key: MapKey): ScImmutableInt32 { - return new ScImmutableInt32(this.objID, key.getKeyID()); - } - - // get value proxy for immutable Int64 field specified by key - getInt64(key: MapKey): ScImmutableInt64 { - return new ScImmutableInt64(this.objID, key.getKeyID()); - } - - // get map proxy for ScImmutableMap specified by key - getMap(key: MapKey): ScImmutableMap { - let mapID = host.getObjectID(this.objID, key.getKeyID(), host.TYPE_MAP); - return new ScImmutableMap(mapID); - } - - // get array proxy for ScImmutableMapArray specified by key - getMapArray(key: MapKey): ScImmutableMapArray { - let arrID = host.getObjectID(this.objID, key.getKeyID(), host.TYPE_MAP | host.TYPE_ARRAY); - return new ScImmutableMapArray(arrID); - } - - // get value proxy for immutable ScRequestID field specified by key - getRequestID(key: MapKey): ScImmutableRequestID { - return new ScImmutableRequestID(this.objID, key.getKeyID()); - } - - // get value proxy for immutable UTF-8 text string field specified by key - getString(key: MapKey): ScImmutableString { - return new ScImmutableString(this.objID, key.getKeyID()); - } - - // get array proxy for ScImmutableStringArray specified by key - getStringArray(key: MapKey): ScImmutableStringArray { - let arrID = host.getObjectID(this.objID, key.getKeyID(), host.TYPE_STRING | host.TYPE_ARRAY); - return new ScImmutableStringArray(arrID); - } - - // get value proxy for immutable Uint8 field specified by key - getUint8(key: MapKey): ScImmutableUint8 { - return new ScImmutableUint8(this.objID, key.getKeyID()); - } - - // get value proxy for immutable Uint16 field specified by key - getUint16(key: MapKey): ScImmutableUint16 { - return new ScImmutableUint16(this.objID, key.getKeyID()); - } - - // get value proxy for immutable Uint32 field specified by key - getUint32(key: MapKey): ScImmutableUint32 { - return new ScImmutableUint32(this.objID, key.getKeyID()); - } - - // get value proxy for immutable Uint64 field specified by key - getUint64(key: MapKey): ScImmutableUint64 { - return new ScImmutableUint64(this.objID, key.getKeyID()); - } - - mapID(): i32 { - return this.objID; - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -// array proxy for immutable array of maps -export class ScImmutableMapArray { - objID: i32; - - constructor(id: i32) { - this.objID = id; - } - - // get value proxy for item at index, index can be 0..length()-1 - getMap(index: u32): ScImmutableMap { - let mapID = host.getObjectID(this.objID, new Key32(index as i32), host.TYPE_MAP); - return new ScImmutableMap(mapID); - } - - // number of items in array - length(): u32 { - return host.getLength(this.objID); - } -} - -// value proxy for immutable ScRequestID in host container -export class ScImmutableRequestID { - objID: i32; - keyID: Key32; - - constructor(objID: i32, keyID: Key32) { - this.objID = objID; - this.keyID = keyID; - } - - // check if value exists in host container - exists(): boolean { - return host.exists(this.objID, this.keyID, host.TYPE_REQUEST_ID); - } - - // human-readable string representation - toString(): string { - return this.value().toString(); - } - - // get value from host container - value(): ScRequestID { - return ScRequestID.fromBytes(host.getBytes(this.objID, this.keyID, host.TYPE_REQUEST_ID)); - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -// value proxy for immutable UTF-8 text string in host container -export class ScImmutableString { - objID: i32; - keyID: Key32; - - constructor(objID: i32, keyID: Key32) { - this.objID = objID; - this.keyID = keyID; - } - - // check if value exists in host container - exists(): boolean { - return host.exists(this.objID, this.keyID, host.TYPE_STRING); - } - - // human-readable string representation - toString(): string { - return this.value(); - } - - // get value from host container - value(): string { - let bytes = host.getBytes(this.objID, this.keyID, host.TYPE_STRING); - return Convert.toString(bytes); - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -// array proxy for immutable array of UTF-8 text string -export class ScImmutableStringArray { - objID: i32; - - constructor(id: i32) { - this.objID = id; - } - - // get value proxy for item at index, index can be 0..length()-1 - getString(index: u32): ScImmutableString { - return new ScImmutableString(this.objID, new Key32(index as i32)); - } - - // number of items in array - length(): u2 { - return host.getLength(this.objID); - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -// value proxy for immutable Uint8 in host container -export class ScImmutableUint8 { - objID: i32; - keyID: Key32; - - constructor(objID: i32, keyID: Key32) { - this.objID = objID; - this.keyID = keyID; - } - - // check if value exists in host container - exists(): boolean { - return host.exists(this.objID, this.keyID, host.TYPE_INT8); - } - - // human-readable string representation - toString(): string { - return this.value().toString(); - } - - // get value from host container - value(): u8 { - let bytes = host.getBytes(this.objID, this.keyID, host.TYPE_INT8); - return bytes[0] as u8; - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -// value proxy for immutable Uint16 in host container -export class ScImmutableUint16 { - objID: i32; - keyID: Key32; - - constructor(objID: i32, keyID: Key32) { - this.objID = objID; - this.keyID = keyID; - } - - // check if value exists in host container - exists(): boolean { - return host.exists(this.objID, this.keyID, host.TYPE_INT16); - } - - // human-readable string representation - toString(): string { - return this.value().toString(); - } - - // get value from host container - value(): u16 { - let bytes = host.getBytes(this.objID, this.keyID, host.TYPE_INT16); - return Convert.toI16(bytes) as u16; - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -// value proxy for immutable Uint32 in host container -export class ScImmutableUint32 { - objID: i32; - keyID: Key32; - - constructor(objID: i32, keyID: Key32) { - this.objID = objID; - this.keyID = keyID; - } - - // check if value exists in host container - exists(): boolean { - return host.exists(this.objID, this.keyID, host.TYPE_INT32); - } - - // human-readable string representation - toString(): string { - return this.value().toString(); - } - - // get value from host container - value(): u32 { - let bytes = host.getBytes(this.objID, this.keyID, host.TYPE_INT32); - return Convert.toI32(bytes) as u32; - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -// value proxy for immutable Uint64 in host container -export class ScImmutableUint64 { - objID: i32; - keyID: Key32; - - constructor(objID: i32, keyID: Key32) { - this.objID = objID; - this.keyID = keyID; - } - - // check if value exists in host container - exists(): boolean { - return host.exists(this.objID, this.keyID, host.TYPE_INT64); - } - - // human-readable string representation - toString(): string { - return this.value().toString(); - } - - // get value from host container - value(): u64 { - let bytes = host.getBytes(this.objID, this.keyID, host.TYPE_INT64); - return Convert.toI64(bytes) as u64; - } -} diff --git a/packages/wasmvm/wasmlib/ts/wasmlib/index.ts b/packages/wasmvm/wasmlib/ts/wasmlib/index.ts index bb10d93cda..d93844e1c6 100644 --- a/packages/wasmvm/wasmlib/ts/wasmlib/index.ts +++ b/packages/wasmvm/wasmlib/ts/wasmlib/index.ts @@ -1,11 +1,13 @@ -export * from "./bytes" +export * from "./assets" export * from "./context" export * from "./contract" -export * from "./convert" +export * from "./dict" export * from "./events" export * from "./exports" -export * from "./hashtypes" export * from "./host" -export * from "./immutable" -export * from "./keys" -export * from "./mutable" +export * from "./sandbox" +export * from "./sandboxutils" +export * from "./state" + +export * from "./wasmrequests" +export * from "./wasmtypes" diff --git a/packages/wasmvm/wasmlib/ts/wasmlib/keys.ts b/packages/wasmvm/wasmlib/ts/wasmlib/keys.ts deleted file mode 100644 index 7e1b25601c..0000000000 --- a/packages/wasmvm/wasmlib/ts/wasmlib/keys.ts +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright 2020 IOTA Stiftung -// SPDX-License-Identifier: Apache-2.0 - -// conversion of data bytes to key id - -import {getKeyIDFromString} from "./host"; - -export interface MapKey { - getKeyID(): Key32; -} - -export class Key32 implements MapKey { - keyID: i32; - - constructor(keyID: i32) { - this.keyID = keyID; - } - - static fromString(key: string): Key32 { - return getKeyIDFromString(key); - } - - getKeyID(): Key32 { - return this; - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -// all predefined key id values should exactly match their counterpart values on the host! -// note that predefined key ids are negative values to distinguish them from indexes - -// @formatter:off -export const KEY_ACCOUNT_ID = new Key32(-1); -export const KEY_ADDRESS = new Key32(-2); -export const KEY_BALANCES = new Key32(-3); -export const KEY_BASE58_DECODE = new Key32(-4); -export const KEY_BASE58_ENCODE = new Key32(-5); -export const KEY_BLS_ADDRESS = new Key32(-6); -export const KEY_BLS_AGGREGATE = new Key32(-7); -export const KEY_BLS_VALID = new Key32(-8); -export const KEY_CALL = new Key32(-9); -export const KEY_CALLER = new Key32(-10); -export const KEY_CHAIN_ID = new Key32(-11); -export const KEY_CHAIN_OWNER_ID = new Key32(-12); -export const KEY_COLOR = new Key32(-13); -export const KEY_CONTRACT = new Key32(-14); -export const KEY_CONTRACT_CREATOR = new Key32(-15); -export const KEY_DEPLOY = new Key32(-16); -export const KEY_ED25519_ADDRESS = new Key32(-17); -export const KEY_ED25519_VALID = new Key32(-18); -export const KEY_EVENT = new Key32(-19); -export const KEY_EXPORTS = new Key32(-20); -export const KEY_HASH_BLAKE2B = new Key32(-21); -export const KEY_HASH_SHA3 = new Key32(-22); -export const KEY_HNAME = new Key32(-23); -export const KEY_INCOMING = new Key32(-24); -export const KEY_LENGTH = new Key32(-25); -export const KEY_LOG = new Key32(-26); -export const KEY_MAPS = new Key32(-27); -export const KEY_MINTED = new Key32(-28); -export const KEY_PANIC = new Key32(-29); -export const KEY_PARAMS = new Key32(-30); -export const KEY_POST = new Key32(-31); -export const KEY_RANDOM = new Key32(-32); -export const KEY_REQUEST_ID = new Key32(-33); -export const KEY_RESULTS = new Key32(-34); -export const KEY_RETURN = new Key32(-35); -export const KEY_STATE = new Key32(-36); -export const KEY_TIMESTAMP = new Key32(-37); -export const KEY_TRACE = new Key32(-38); -export const KEY_TRANSFERS = new Key32(-39); -export const KEY_UTILITY = new Key32(-40); -export const KEY_ZZZZZZZ = new Key32(-41); -// @formatter:on diff --git a/packages/wasmvm/wasmlib/ts/wasmlib/mutable.ts b/packages/wasmvm/wasmlib/ts/wasmlib/mutable.ts deleted file mode 100644 index 2d91d17fb3..0000000000 --- a/packages/wasmvm/wasmlib/ts/wasmlib/mutable.ts +++ /dev/null @@ -1,917 +0,0 @@ -// Copyright 2020 IOTA Stiftung -// SPDX-License-Identifier: Apache-2.0 - -// mutable proxies to host objects - -import {base58Encode, ROOT} from "./context"; -import {Convert} from "./convert"; -import {ScAddress, ScAgentID, ScChainID, ScColor, ScHash, ScHname, ScRequestID} from "./hashtypes"; -import * as host from "./host"; -import { - ScImmutableMap, - ScImmutableMapArray, - ScImmutableStringArray, -} from "./immutable"; -import {Key32, KEY_MAPS, MapKey} from "./keys"; - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -// value proxy for mutable ScAddress in host container -export class ScMutableAddress { - objID: i32; - keyID: Key32; - - constructor(objID: i32, keyID: Key32) { - this.objID = objID; - this.keyID = keyID; - } - - // delete value from host container - delete(): void { - host.delKey(this.objID, this.keyID, host.TYPE_ADDRESS); - } - - // check if value exists in host container - exists(): boolean { - return host.exists(this.objID, this.keyID, host.TYPE_ADDRESS); - } - - // set value in host container - setValue(val: ScAddress): void { - host.setBytes(this.objID, this.keyID, host.TYPE_ADDRESS, val.toBytes()); - } - - // human-readable string representation - toString(): string { - return this.value().toString(); - } - - // retrieve value from host container - value(): ScAddress { - return ScAddress.fromBytes(host.getBytes(this.objID, this.keyID, host.TYPE_ADDRESS)); - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -// value proxy for mutable ScAgentID in host container -export class ScMutableAgentID { - objID: i32; - keyID: Key32; - - constructor(objID: i32, keyID: Key32) { - this.objID = objID; - this.keyID = keyID; - } - - // delete value from host container - delete(): void { - host.delKey(this.objID, this.keyID, host.TYPE_AGENT_ID); - } - - // check if value exists in host container - exists(): boolean { - return host.exists(this.objID, this.keyID, host.TYPE_AGENT_ID); - } - - // set value in host container - setValue(val: ScAgentID): void { - host.setBytes(this.objID, this.keyID, host.TYPE_AGENT_ID, val.toBytes()); - } - - // human-readable string representation - toString(): string { - return this.value().toString(); - } - - // retrieve value from host container - value(): ScAgentID { - return ScAgentID.fromBytes(host.getBytes(this.objID, this.keyID, host.TYPE_AGENT_ID)); - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -// value proxy for mutable Bool in host container -export class ScMutableBool { - objID: i32; - keyID: Key32; - - constructor(objID: i32, keyID: Key32) { - this.objID = objID; - this.keyID = keyID; - } - - // delete value from host container - delete(): void { - host.delKey(this.objID, this.keyID, host.TYPE_BOOL); - } - - // check if value exists in host container - exists(): boolean { - return host.exists(this.objID, this.keyID, host.TYPE_BOOL); - } - - // set value in host container - setValue(val: boolean): void { - let bytes: u8[] = [(val ? 1 : 0) as u8] - host.setBytes(this.objID, this.keyID, host.TYPE_BOOL, bytes); - } - - // human-readable string representation - toString(): string { - return this.value().toString(); - } - - // retrieve value from host container - value(): boolean { - let bytes = host.getBytes(this.objID, this.keyID, host.TYPE_BOOL); - return bytes[0] != 0; - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -// value proxy for mutable bytes array in host container -export class ScMutableBytes { - objID: i32; - keyID: Key32; - - constructor(objID: i32, keyID: Key32) { - this.objID = objID; - this.keyID = keyID; - } - - // delete value from host container - delete(): void { - host.delKey(this.objID, this.keyID, host.TYPE_BYTES); - } - - // check if value exists in host container - exists(): boolean { - return host.exists(this.objID, this.keyID, host.TYPE_BYTES); - } - - // set value in host container - setValue(val: u8[]): void { - host.setBytes(this.objID, this.keyID, host.TYPE_BYTES, val); - } - - // human-readable string representation - toString(): string { - return base58Encode(this.value()); - } - - // retrieve value from host container - value(): u8[] { - return host.getBytes(this.objID, this.keyID, host.TYPE_BYTES); - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -// value proxy for mutable ScChainID in host container -export class ScMutableChainID { - objID: i32; - keyID: Key32; - - constructor(objID: i32, keyID: Key32) { - this.objID = objID; - this.keyID = keyID; - } - - // delete value from host container - delete(): void { - host.delKey(this.objID, this.keyID, host.TYPE_CHAIN_ID); - } - - // check if value exists in host container - exists(): boolean { - return host.exists(this.objID, this.keyID, host.TYPE_CHAIN_ID); - } - - // set value in host container - setValue(val: ScChainID): void { - host.setBytes(this.objID, this.keyID, host.TYPE_CHAIN_ID, val.toBytes()); - } - - // human-readable string representation - toString(): string { - return this.value().toString(); - } - - // retrieve value from host container - value(): ScChainID { - return ScChainID.fromBytes(host.getBytes(this.objID, this.keyID, host.TYPE_CHAIN_ID)); - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -// value proxy for mutable ScColor in host container -export class ScMutableColor { - objID: i32; - keyID: Key32; - - constructor(objID: i32, keyID: Key32) { - this.objID = objID; - this.keyID = keyID; - } - - // delete value from host container - delete(): void { - host.delKey(this.objID, this.keyID, host.TYPE_COLOR); - } - - // check if value exists in host container - exists(): boolean { - return host.exists(this.objID, this.keyID, host.TYPE_COLOR); - } - - // set value in host container - setValue(val: ScColor): void { - host.setBytes(this.objID, this.keyID, host.TYPE_COLOR, val.toBytes()); - } - - // human-readable string representation - toString(): string { - return this.value().toString(); - } - - // retrieve value from host container - value(): ScColor { - return ScColor.fromBytes(host.getBytes(this.objID, this.keyID, host.TYPE_COLOR)); - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -// value proxy for mutable ScHash in host container -export class ScMutableHash { - objID: i32; - keyID: Key32; - - constructor(objID: i32, keyID: Key32) { - this.objID = objID; - this.keyID = keyID; - } - - // delete value from host container - delete(): void { - host.delKey(this.objID, this.keyID, host.TYPE_HASH); - } - - // check if value exists in host container - exists(): boolean { - return host.exists(this.objID, this.keyID, host.TYPE_HASH); - } - - // set value in host container - setValue(val: ScHash): void { - host.setBytes(this.objID, this.keyID, host.TYPE_HASH, val.toBytes()); - } - - // human-readable string representation - toString(): string { - return this.value().toString(); - } - - // retrieve value from host container - value(): ScHash { - return ScHash.fromBytes(host.getBytes(this.objID, this.keyID, host.TYPE_HASH)); - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -// value proxy for mutable ScHname in host container -export class ScMutableHname { - objID: i32; - keyID: Key32; - - constructor(objID: i32, keyID: Key32) { - this.objID = objID; - this.keyID = keyID; - } - - // delete value from host container - delete(): void { - host.delKey(this.objID, this.keyID, host.TYPE_HNAME); - } - - // check if value exists in host container - exists(): boolean { - return host.exists(this.objID, this.keyID, host.TYPE_HNAME); - } - - // set value in host container - setValue(val: ScHname): void { - host.setBytes(this.objID, this.keyID, host.TYPE_HNAME, val.toBytes()); - } - - // human-readable string representation - toString(): string { - return this.value().toString(); - } - - // retrieve value from host container - value(): ScHname { - return ScHname.fromBytes(host.getBytes(this.objID, this.keyID, host.TYPE_HNAME)); - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -// value proxy for mutable Int8 in host container -export class ScMutableInt8 { - objID: i32; - keyID: Key32; - - constructor(objID: i32, keyID: Key32) { - this.objID = objID; - this.keyID = keyID; - } - - // delete value from host container - delete(): void { - host.delKey(this.objID, this.keyID, host.TYPE_INT8); - } - - // check if value exists in host container - exists(): boolean { - return host.exists(this.objID, this.keyID, host.TYPE_INT8); - } - - // set value in host container - setValue(val: i8): void { - let bytes: u8[] = [val as u8]; - host.setBytes(this.objID, this.keyID, host.TYPE_INT8, bytes); - } - - // human-readable string representation - toString(): string { - return this.value().toString(); - } - - // retrieve value from host container - value(): i8 { - let bytes = host.getBytes(this.objID, this.keyID, host.TYPE_INT8); - return bytes[0] as i8; - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -// value proxy for mutable Int16 in host container -export class ScMutableInt16 { - objID: i32; - keyID: Key32; - - constructor(objID: i32, keyID: Key32) { - this.objID = objID; - this.keyID = keyID; - } - - // delete value from host container - delete(): void { - host.delKey(this.objID, this.keyID, host.TYPE_INT16); - } - - // check if value exists in host container - exists(): boolean { - return host.exists(this.objID, this.keyID, host.TYPE_INT16); - } - - // set value in host container - setValue(val: i16): void { - host.setBytes(this.objID, this.keyID, host.TYPE_INT16, Convert.fromI16(val)); - } - - // human-readable string representation - toString(): string { - return this.value().toString(); - } - - // retrieve value from host container - value(): i16 { - return Convert.toI16(host.getBytes(this.objID, this.keyID, host.TYPE_INT16)); - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -// value proxy for mutable Int32 in host container -export class ScMutableInt32 { - objID: i32; - keyID: Key32; - - constructor(objID: i32, keyID: Key32) { - this.objID = objID; - this.keyID = keyID; - } - - // delete value from host container - delete(): void { - host.delKey(this.objID, this.keyID, host.TYPE_INT32); - } - - // check if value exists in host container - exists(): boolean { - return host.exists(this.objID, this.keyID, host.TYPE_INT32); - } - - // set value in host container - setValue(val: i32): void { - host.setBytes(this.objID, this.keyID, host.TYPE_INT32, Convert.fromI32(val)); - } - - // human-readable string representation - toString(): string { - return this.value().toString(); - } - - // retrieve value from host container - value(): i32 { - return Convert.toI32(host.getBytes(this.objID, this.keyID, host.TYPE_INT32)); - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -// value proxy for mutable Int64 in host container -export class ScMutableInt64 { - objID: i32; - keyID: Key32; - - constructor(objID: i32, keyID: Key32) { - this.objID = objID; - this.keyID = keyID; - } - - // delete value from host container - delete(): void { - host.delKey(this.objID, this.keyID, host.TYPE_INT64); - } - - // check if value exists in host container - exists(): boolean { - return host.exists(this.objID, this.keyID, host.TYPE_INT64); - } - - // set value in host container - setValue(val: i64): void { - host.setBytes(this.objID, this.keyID, host.TYPE_INT64, Convert.fromI64(val)); - } - - // human-readable string representation - toString(): string { - return this.value().toString(); - } - - // retrieve value from host container - value(): i64 { - return Convert.toI64(host.getBytes(this.objID, this.keyID, host.TYPE_INT64)); - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -// map proxy for mutable map -export class ScMutableMap { - objID: i32; - - constructor(id: i32) { - this.objID = id; - } - - // construct a new map on the host and return a map proxy for it - static create(): ScMutableMap { - let maps = ROOT.getMapArray(KEY_MAPS); - return maps.getMap(maps.length()); - } - - callFunc(keyID: Key32, params: u8[]): u8[] { - return host.callFunc(this.objID, keyID, params); - } - - // empty the map - clear(): void { - host.clear(this.objID); - } - - // get value proxy for mutable ScAddress field specified by key - getAddress(key: MapKey): ScMutableAddress { - return new ScMutableAddress(this.objID, key.getKeyID()); - } - - // get value proxy for mutable ScAgentID field specified by key - getAgentID(key: MapKey): ScMutableAgentID { - return new ScMutableAgentID(this.objID, key.getKeyID()); - } - - // get value proxy for mutable Bool field specified by key - getBool(key: MapKey): ScMutableBool { - return new ScMutableBool(this.objID, key.getKeyID()); - } - - // get value proxy for mutable Bytes array field specified by key - getBytes(key: MapKey): ScMutableBytes { - return new ScMutableBytes(this.objID, key.getKeyID()); - } - - // get value proxy for mutable ScChainID field specified by key - getChainID(key: MapKey): ScMutableChainID { - return new ScMutableChainID(this.objID, key.getKeyID()); - } - - // get value proxy for mutable ScColor field specified by key - getColor(key: MapKey): ScMutableColor { - return new ScMutableColor(this.objID, key.getKeyID()); - } - - // get value proxy for mutable ScHash field specified by key - getHash(key: MapKey): ScMutableHash { - return new ScMutableHash(this.objID, key.getKeyID()); - } - - // get value proxy for mutable ScHname field specified by key - getHname(key: MapKey): ScMutableHname { - return new ScMutableHname(this.objID, key.getKeyID()); - } - - // get value proxy for mutable Int8 field specified by key - getInt8(key: MapKey): ScMutableInt8 { - return new ScMutableInt8(this.objID, key.getKeyID()); - } - - // get value proxy for mutable Int16 field specified by key - getInt16(key: MapKey): ScMutableInt16 { - return new ScMutableInt16(this.objID, key.getKeyID()); - } - - // get value proxy for mutable Int32 field specified by key - getInt32(key: MapKey): ScMutableInt32 { - return new ScMutableInt32(this.objID, key.getKeyID()); - } - - // get value proxy for mutable Int64 field specified by key - getInt64(key: MapKey): ScMutableInt64 { - return new ScMutableInt64(this.objID, key.getKeyID()); - } - - // get map proxy for ScMutableMap specified by key - getMap(key: MapKey): ScMutableMap { - let mapID = host.getObjectID(this.objID, key.getKeyID(), host.TYPE_MAP); - return new ScMutableMap(mapID); - } - - // get array proxy for ScMutableMapArray specified by key - getMapArray(key: MapKey): ScMutableMapArray { - let arrID = host.getObjectID(this.objID, key.getKeyID(), host.TYPE_MAP | host.TYPE_ARRAY); - return new ScMutableMapArray(arrID); - } - - // get value proxy for mutable ScRequestID field specified by key - getRequestID(key: MapKey): ScMutableRequestID { - return new ScMutableRequestID(this.objID, key.getKeyID()); - } - - // get value proxy for mutable UTF-8 text string field specified by key - getString(key: MapKey): ScMutableString { - return new ScMutableString(this.objID, key.getKeyID()); - } - - // get array proxy for ScMutableStringArray specified by key - getStringArray(key: MapKey): ScMutableStringArray { - let arrID = host.getObjectID(this.objID, key.getKeyID(), host.TYPE_STRING | host.TYPE_ARRAY); - return new ScMutableStringArray(arrID); - } - - // get value proxy for mutable Uint8 field specified by key - getUint8(key: MapKey): ScMutableUint8 { - return new ScMutableUint8(this.objID, key.getKeyID()); - } - - // get value proxy for mutable Uint16 field specified by key - getUint16(key: MapKey): ScMutableUint16 { - return new ScMutableUint16(this.objID, key.getKeyID()); - } - - // get value proxy for mutable Uint32 field specified by key - getUint32(key: MapKey): ScMutableUint32 { - return new ScMutableUint32(this.objID, key.getKeyID()); - } - - // get value proxy for mutable Uint64 field specified by key - getUint64(key: MapKey): ScMutableUint64 { - return new ScMutableUint64(this.objID, key.getKeyID()); - } - - // get immutable version of map proxy - immutable(): ScImmutableMap { - return new ScImmutableMap(this.objID); - } - - mapID(): i32 { - return this.objID; - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -// array proxy for mutable array of maps -export class ScMutableMapArray { - objID: i32; - - constructor(id: i32) { - this.objID = id; - } - - // empty the array - clear(): void { - host.clear(this.objID); - } - - // get value proxy for item at index, index can be 0..length() - // when index equals length() a new item is appended - getMap(index: u32): ScMutableMap { - let mapID = host.getObjectID(this.objID, new Key32(index as i32), host.TYPE_MAP); - return new ScMutableMap(mapID); - } - - // get immutable version of array proxy - immutable(): ScImmutableMapArray { - return new ScImmutableMapArray(this.objID); - } - - // number of items in array - length(): u32 { - return host.getLength(this.objID); - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -// value proxy for mutable ScRequestID in host container -export class ScMutableRequestID { - objID: i32; - keyID: Key32; - - constructor(objID: i32, keyID: Key32) { - this.objID = objID; - this.keyID = keyID; - } - - // delete value from host container - delete(): void { - host.delKey(this.objID, this.keyID, host.TYPE_REQUEST_ID); - } - - // check if value exists in host container - exists(): boolean { - return host.exists(this.objID, this.keyID, host.TYPE_REQUEST_ID); - } - - // set value in host container - setValue(val: ScRequestID): void { - host.setBytes(this.objID, this.keyID, host.TYPE_REQUEST_ID, val.toBytes()); - } - - // human-readable string representation - toString(): string { - return this.value().toString(); - } - - // retrieve value from host container - value(): ScRequestID { - return ScRequestID.fromBytes(host.getBytes(this.objID, this.keyID, host.TYPE_REQUEST_ID)); - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -// value proxy for mutable UTF-8 text string in host container -export class ScMutableString { - objID: i32; - keyID: Key32; - - constructor(objID: i32, keyID: Key32) { - this.objID = objID; - this.keyID = keyID; - } - - // delete value from host container - delete(): void { - host.delKey(this.objID, this.keyID, host.TYPE_STRING); - } - - // check if value exists in host container - exists(): boolean { - return host.exists(this.objID, this.keyID, host.TYPE_STRING); - } - - // set value in host container - setValue(val: string): void { - host.setBytes(this.objID, this.keyID, host.TYPE_STRING, Convert.fromString(val)); - } - - // human-readable string representation - toString(): string { - return this.value(); - } - - // retrieve value from host container - value(): string { - let bytes = host.getBytes(this.objID, this.keyID, host.TYPE_STRING); - return Convert.toString(bytes); - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -// array proxy for mutable array of UTF-8 text string -export class ScMutableStringArray { - objID: i32; - - constructor(id: i32) { - this.objID = id; - } - - // empty the array - clear(): void { - host.clear(this.objID); - } - - // get value proxy for item at index, index can be 0..length() - // when index equals length() a new item is appended - getString(index: u32): ScMutableString { - return new ScMutableString(this.objID, new Key32(index as i32)); - } - - // get immutable version of array proxy - immutable(): ScImmutableStringArray { - return new ScImmutableStringArray(this.objID); - } - - // number of items in array - length(): u32 { - return host.getLength(this.objID); - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -// value proxy for mutable Uint8 in host container -export class ScMutableUint8 { - objID: i32; - keyID: Key32; - - constructor(objID: i32, keyID: Key32) { - this.objID = objID; - this.keyID = keyID; - } - - // delete value from host container - delete(): void { - host.delKey(this.objID, this.keyID, host.TYPE_INT8); - } - - // check if value exists in host container - exists(): boolean { - return host.exists(this.objID, this.keyID, host.TYPE_INT8); - } - - // set value in host container - setValue(val: u8): void { - let bytes: u8[] = [val as u8]; - host.setBytes(this.objID, this.keyID, host.TYPE_INT8, bytes); - } - - // human-readable string representation - toString(): string { - return this.value().toString(); - } - - // retrieve value from host container - value(): u8 { - let bytes = host.getBytes(this.objID, this.keyID, host.TYPE_INT8); - return bytes[0] as u8; - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -// value proxy for mutable Uint16 in host container -export class ScMutableUint16 { - objID: i32; - keyID: Key32; - - constructor(objID: i32, keyID: Key32) { - this.objID = objID; - this.keyID = keyID; - } - - // delete value from host container - delete(): void { - host.delKey(this.objID, this.keyID, host.TYPE_INT16); - } - - // check if value exists in host container - exists(): boolean { - return host.exists(this.objID, this.keyID, host.TYPE_INT16); - } - - // set value in host container - setValue(val: u16): void { - host.setBytes(this.objID, this.keyID, host.TYPE_INT16, Convert.fromI16(val)); - } - - // human-readable string representation - toString(): string { - return this.value().toString(); - } - - // retrieve value from host container - value(): u16 { - let bytes = host.getBytes(this.objID, this.keyID, host.TYPE_INT16); - return Convert.toI16(bytes) as u16; - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -// value proxy for mutable Uint32 in host container -export class ScMutableUint32 { - objID: i32; - keyID: Key32; - - constructor(objID: i32, keyID: Key32) { - this.objID = objID; - this.keyID = keyID; - } - - // delete value from host container - delete(): void { - host.delKey(this.objID, this.keyID, host.TYPE_INT32); - } - - // check if value exists in host container - exists(): boolean { - return host.exists(this.objID, this.keyID, host.TYPE_INT32); - } - - // set value in host container - setValue(val: u32): void { - host.setBytes(this.objID, this.keyID, host.TYPE_INT32, Convert.fromI32(val)); - } - - // human-readable string representation - toString(): string { - return this.value().toString(); - } - - // retrieve value from host container - value(): u32 { - let bytes = host.getBytes(this.objID, this.keyID, host.TYPE_INT32); - return Convert.toI32(bytes) as u32; - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -// value proxy for mutable Uint64 in host container -export class ScMutableUint64 { - objID: i32; - keyID: Key32; - - constructor(objID: i32, keyID: Key32) { - this.objID = objID; - this.keyID = keyID; - } - - // delete value from host container - delete(): void { - host.delKey(this.objID, this.keyID, host.TYPE_INT64); - } - - // check if value exists in host container - exists(): boolean { - return host.exists(this.objID, this.keyID, host.TYPE_INT64); - } - - // set value in host container - setValue(val: u64): void { - host.setBytes(this.objID, this.keyID, host.TYPE_INT64, Convert.fromI64(val)); - } - - // human-readable string representation - toString(): string { - return this.value().toString(); - } - - // retrieve value from host container - value(): u64 { - let bytes = host.getBytes(this.objID, this.keyID, host.TYPE_INT64); - return Convert.toI64(bytes) as u64; - } -} diff --git a/packages/wasmvm/wasmlib/ts/wasmlib/sandbox.ts b/packages/wasmvm/wasmlib/ts/wasmlib/sandbox.ts new file mode 100644 index 0000000000..0a976dfa0e --- /dev/null +++ b/packages/wasmvm/wasmlib/ts/wasmlib/sandbox.ts @@ -0,0 +1,299 @@ +// Copyright 2020 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +import * as wasmrequests from "./wasmrequests" +import * as wasmtypes from "./wasmtypes" +import {ScAssets, ScBalances, ScTransfers} from "./assets"; +import {ScDict, ScImmutableDict} from "./dict"; +import {sandbox} from "./host"; +import {ScSandboxUtils} from "./sandboxutils"; +import {ScImmutableState, ScState} from "./state"; + +// @formatter:off +export const FnAccountID : i32 = -1; +export const FnBalance : i32 = -2; +export const FnBalances : i32 = -3; +export const FnBlockContext : i32 = -4; +export const FnCall : i32 = -5; +export const FnCaller : i32 = -6; +export const FnChainID : i32 = -7; +export const FnChainOwnerID : i32 = -8; +export const FnContract : i32 = -9; +export const FnContractCreator : i32 = -10; +export const FnDeployContract : i32 = -11; +export const FnEntropy : i32 = -12; +export const FnEvent : i32 = -13; +export const FnIncomingTransfer : i32 = -14; +export const FnLog : i32 = -15; +export const FnMinted : i32 = -16; +export const FnPanic : i32 = -17; +export const FnParams : i32 = -18; +export const FnPost : i32 = -19; +export const FnRequest : i32 = -20; +export const FnRequestID : i32 = -21; +export const FnResults : i32 = -22; +export const FnSend : i32 = -23; +export const FnStateAnchor : i32 = -24; +export const FnTimestamp : i32 = -25; +export const FnTrace : i32 = -26; +export const FnUtilsBase58Decode : i32 = -27; +export const FnUtilsBase58Encode : i32 = -28; +export const FnUtilsBlsAddress : i32 = -29; +export const FnUtilsBlsAggregate : i32 = -30; +export const FnUtilsBlsValid : i32 = -31; +export const FnUtilsEd25519Address : i32 = -32; +export const FnUtilsEd25519Valid : i32 = -33; +export const FnUtilsHashBlake2b : i32 = -34; +export const FnUtilsHashName : i32 = -35; +export const FnUtilsHashSha3 : i32 = -36; +// @formatter:on + +// Direct logging of informational text to host log +export function log(text: string): void { + new ScSandbox().log(text); +} + +// Direct logging of error to host log, followed by panicking out of the Wasm code +export function panic(text: string): void { + new ScSandbox().panic(text); +} + +export function paramsProxy(): wasmtypes.Proxy { + return new ScDict(sandbox(FnParams, null)).asProxy(); +} + +export function resultsProxy(): wasmtypes.Proxy { + return new ScDict([]).asProxy(); +} + +export class ScSandbox { + // retrieve the agent id of this contract account + public accountID(): wasmtypes.ScAgentID { + return wasmtypes.agentIDFromBytes(sandbox(FnAccountID, null)) + } + + public balance(color: wasmtypes.ScColor): u64 { + return wasmtypes.uint64FromBytes(sandbox(FnBalance, color.toBytes())) + } + + // access the current balances for all assets + public balances(): ScBalances { + return new ScAssets(sandbox(FnBalances, null)).balances() + } + + // calls a smart contract function + protected callWithTransfer(hContract: wasmtypes.ScHname, hFunction: wasmtypes.ScHname, params: ScDict | null, transfer: ScTransfers | null): ScImmutableDict { + if (params === null) { + params = new ScDict([]); + } + if (transfer === null) { + transfer = new ScTransfers(); + } + const req = new wasmrequests.CallRequest(); + req.contract = hContract; + req.function = hFunction; + req.params = params.toBytes(); + req.transfer = transfer.toBytes(); + const res = sandbox(FnCall, req.bytes()); + return new ScDict(res).immutable() + } + + // retrieve the chain id of the chain this contract lives on + public chainID(): wasmtypes.ScChainID { + return wasmtypes.chainIDFromBytes(sandbox(FnChainID, null)) + } + + // retrieve the agent id of the owner of the chain this contract lives on + public chainOwnerID(): wasmtypes.ScAgentID { + return wasmtypes.agentIDFromBytes(sandbox(FnChainOwnerID, null)) + } + + // retrieve the hname of this contract + public contract(): wasmtypes.ScHname { + return wasmtypes.hnameFromBytes(sandbox(FnContract, null)) + } + + // retrieve the agent id of the creator of this contract + public contractCreator(): wasmtypes.ScAgentID { + return wasmtypes.agentIDFromBytes(sandbox(FnContractCreator, null)) + } + + // logs informational text message + public log(text: string): void { + sandbox(FnLog, wasmtypes.stringToBytes(text)) + } + + // logs error text message and then panics + public panic(text: string): void { + sandbox(FnPanic, wasmtypes.stringToBytes(text)) + } + + // retrieve parameters passed to the smart contract function that was called + public params(): ScImmutableDict { + return new ScDict(sandbox(FnParams, null)).immutable() + } + + public rawState(): ScImmutableState { + return new ScImmutableState(); + } + + // panics if condition is not satisfied + public require(cond: bool, msg: string): void { + if (!cond) { + this.panic(msg) + } + } + + public results(results: ScDict): void { + sandbox(FnResults, results.toBytes()) + } + + // deterministic time stamp fixed at the moment of calling the smart contract + public timestamp(): u64 { + return wasmtypes.uint64FromBytes(sandbox(FnTimestamp, null)) + } + + // logs debugging trace text message + public trace(text: string): void { + sandbox(FnTrace, wasmtypes.stringToBytes(text)); + } + + // access diverse utility functions + public utility(): ScSandboxUtils { + return new ScSandboxUtils(); + } +} + +export class ScSandboxView extends ScSandbox { + // calls a smart contract view + public call(hContract: wasmtypes.ScHname, hFunction: wasmtypes.ScHname, params: ScDict | null): ScImmutableDict { + return this.callWithTransfer(hContract, hFunction, params, null) + } +} + +export class ScSandboxFunc extends ScSandbox { + private static entropy: u8[] = []; + private static offset: u32 = 0; + + //public blockContext(construct func(sandbox: ScSandbox) interface{}, onClose func(interface{})): interface{} { + // panic("implement me") + //} + + // calls a smart contract function + public call(hContract: wasmtypes.ScHname, hFunction: wasmtypes.ScHname, params: ScDict | null, transfer: ScTransfers | null): ScImmutableDict { + return this.callWithTransfer(hContract, hFunction, params, transfer) + } + + // retrieve the agent id of the caller of the smart contract + public caller(): wasmtypes.ScAgentID { + return wasmtypes.agentIDFromBytes(sandbox(FnCaller, null)) + } + + // deploys a smart contract + public deployContract(programHash: wasmtypes.ScHash, name: string, description: string, initParams: ScDict | null): void { + if (initParams === null) { + initParams = new ScDict([]); + } + const req = new wasmrequests.DeployRequest(); + req.progHash = programHash; + req.name = name; + req.description = description; + req.params = initParams.toBytes(); + sandbox(FnDeployContract, req.bytes()) + } + + // returns random entropy data for current request. + public entropy(): wasmtypes.ScHash { + return wasmtypes.hashFromBytes(sandbox(FnEntropy, null)) + } + + // signals an event on the node that external entities can subscribe to + public event(msg: string): void { + sandbox(FnEvent, wasmtypes.stringToBytes(msg)) + } + + // access the incoming balances for all assets + public incomingTransfer(): ScBalances { + const buf = sandbox(FnIncomingTransfer, null); + return new ScAssets(buf).balances(); + } + + // retrieve the assets that were minted in this transaction + public minted(): ScBalances { + return new ScAssets(sandbox(FnMinted, null)).balances() + } + + // (delayed) posts a smart contract function request + public post(chainID: wasmtypes.ScChainID, hContract: wasmtypes.ScHname, hFunction: wasmtypes.ScHname, params: ScDict, transfer: ScTransfers, delay: u32): void { + if (transfer.balances().colors().length == 0) { + this.panic("missing transfer"); + } + const req = new wasmrequests.PostRequest(); + req.chainID = chainID; + req.contract = hContract; + req.function = hFunction; + req.params = params.toBytes(); + req.transfer = transfer.toBytes(); + req.delay = delay; + sandbox(FnPost, req.bytes()) + } + + // generates a random value from 0 to max (exclusive: max) using a deterministic RNG + public random(max: u64): u64 { + if (max == 0) { + this.panic("random: max parameter should be non-zero"); + } + + // note that entropy gets reset for every request + if (ScSandboxFunc.entropy.length == 0) { + // first time in this: request, initialize with current request entropy + ScSandboxFunc.entropy = this.entropy().toBytes(); + ScSandboxFunc.offset = 0; + } + if (ScSandboxFunc.offset == 32) { + // ran out of entropy: data, hash entropy for next pseudo-random entropy + ScSandboxFunc.entropy = this.utility().hashBlake2b(ScSandboxFunc.entropy).toBytes(); + ScSandboxFunc.offset = 0; + } + let rnd = wasmtypes.uint64FromBytes(ScSandboxFunc.entropy.slice(ScSandboxFunc.offset, ScSandboxFunc.offset + 8)) % max; + ScSandboxFunc.offset += 8; + return rnd; + } + + public rawState(): ScState { + return new ScState(); + } + + //public request(): ScRequest { + // panic("implement me") + //} + + // retrieve the request id of this transaction + public requestID(): wasmtypes.ScRequestID { + return wasmtypes.requestIDFromBytes(sandbox(FnRequestID, null)) + } + + // transfer assetss to the specified Tangle ledger address + public send(address: wasmtypes.ScAddress, transfer: ScTransfers): void { + // we need some assets to send + let assets: u64 = 0; + const balances = transfer.balances(); + const colors = balances.colors(); + for (let i = 0; i < colors.length; i++) { + assets += balances.balance(colors[i]); + } + if (assets == 0) { + // only try to send when non-zero assets + return + } + + const req = new wasmrequests.SendRequest(); + req.address = address; + req.transfer = transfer.toBytes(); + sandbox(FnSend, req.bytes()) + } + + //public stateAnchor(): interface{} { + // panic("implement me") + //} +} \ No newline at end of file diff --git a/packages/wasmvm/wasmlib/ts/wasmlib/sandboxutils.ts b/packages/wasmvm/wasmlib/ts/wasmlib/sandboxutils.ts new file mode 100644 index 0000000000..038f7ae009 --- /dev/null +++ b/packages/wasmvm/wasmlib/ts/wasmlib/sandboxutils.ts @@ -0,0 +1,66 @@ +// Copyright 2020 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +import * as util from "./sandbox"; +import * as wasmtypes from "./wasmtypes" +import {sandbox} from "./host"; + +export class ScSandboxUtils { + // decodes the specified base58-encoded string value to its original bytes + public base58Decode(value: string): u8[] { + return sandbox(util.FnUtilsBase58Decode, wasmtypes.stringToBytes(value)); + } + + // encodes the specified bytes to a base-58-encoded string + public base58Encode(bytes: u8[]): string { + return wasmtypes.bytesToString(sandbox(util.FnUtilsBase58Encode, bytes)); + } + + public blsAddressFromPubKey(pubKey: u8[]): wasmtypes.ScAddress { + return wasmtypes.addressFromBytes(sandbox(util.FnUtilsBlsAddress, pubKey)); + } + + public blsAggregateSignatures(pubKeys: u8[][], sigs: u8[][]): u8[][] { + const enc = new wasmtypes.WasmEncoder(); + wasmtypes.uint32Encode(enc, pubKeys.length as u32); + for (let i = 0; i < pubKeys.length; i++) { + enc.bytes(pubKeys[i]); + } + wasmtypes.uint32Encode(enc, sigs.length as u32); + for (let i = 0; i < sigs.length; i++) { + enc.bytes(sigs[i]); + } + const result = sandbox(util.FnUtilsBlsAggregate, enc.buf()); + const decode = new wasmtypes.WasmDecoder(result); + return [decode.bytes(), decode.bytes()]; + } + + public blsValidSignature(data: u8[], pubKey: u8[], signature: u8[]): bool { + const enc = new wasmtypes.WasmEncoder().bytes(data).bytes(pubKey).bytes(signature); + return wasmtypes.boolFromBytes(sandbox(util.FnUtilsBlsValid, enc.buf())); + } + + public ed25519AddressFromPubKey(pubKey: u8[]): wasmtypes.ScAddress { + return wasmtypes.addressFromBytes(sandbox(util.FnUtilsEd25519Address, pubKey)); + } + + public ed25519ValidSignature(data: u8[], pubKey: u8[], signature: u8[]): bool { + const enc = new wasmtypes.WasmEncoder().bytes(data).bytes(pubKey).bytes(signature); + return wasmtypes.boolFromBytes(sandbox(util.FnUtilsEd25519Valid, enc.buf())); + } + + // hashes the specified value bytes using blake2b hashing and returns the resulting 32-byte hash + public hashBlake2b(value: u8[]): wasmtypes.ScHash { + return wasmtypes.hashFromBytes(sandbox(util.FnUtilsHashBlake2b, value)); + } + + // hashes the specified value bytes using sha3 hashing and returns the resulting 32-byte hash + public hashSha3(value: u8[]): wasmtypes.ScHash { + return wasmtypes.hashFromBytes(sandbox(util.FnUtilsHashSha3, value)); + } + + // hashes the specified value bytes using blake2b hashing and returns the resulting 32-byte hash + public hname(value: string): wasmtypes.ScHname { + return wasmtypes.hnameFromBytes(sandbox(util.FnUtilsHashName, wasmtypes.stringToBytes(value))); + } +} diff --git a/packages/wasmvm/wasmlib/ts/wasmlib/state.ts b/packages/wasmvm/wasmlib/ts/wasmlib/state.ts new file mode 100644 index 0000000000..35b21f2255 --- /dev/null +++ b/packages/wasmvm/wasmlib/ts/wasmlib/state.ts @@ -0,0 +1,42 @@ +// Copyright 2020 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +import * as wasmtypes from "./wasmtypes" +import {IKvStore} from "./wasmtypes" +import {stateDelete, stateExists, stateGet, stateSet} from "./host"; + +export class ScImmutableState { + exists(key: u8[]): bool { + return stateExists(key); + } + + get(key: u8[]): u8[] | null { + return stateGet(key); + } +} + +export class ScState implements IKvStore { + public static proxy(): wasmtypes.Proxy { + return new wasmtypes.Proxy(new ScState()); + } + + delete(key: u8[]): void { + stateDelete(key); + } + + exists(key: u8[]): bool { + return stateExists(key); + } + + get(key: u8[]): u8[] | null { + return stateGet(key); + } + + public immutable(): ScImmutableState { + return this; + } + + set(key: u8[], value: u8[]): void { + stateSet(key, value); + } +} diff --git a/packages/wasmvm/wasmlib/ts/wasmlib/wasmrequests/consts.ts b/packages/wasmvm/wasmlib/ts/wasmlib/wasmrequests/consts.ts index cb0890609e..b5f82978f6 100644 --- a/packages/wasmvm/wasmlib/ts/wasmlib/wasmrequests/consts.ts +++ b/packages/wasmvm/wasmlib/ts/wasmlib/wasmrequests/consts.ts @@ -5,10 +5,10 @@ // >>>> DO NOT CHANGE THIS FILE! <<<< // Change the json schema instead -import * as wasmlib from "wasmlib"; +import * as wasmtypes from "wasmlib/wasmtypes"; export const ScName = "requests"; export const ScDescription = "WasmLib request structures"; -export const HScName = new wasmlib.ScHname(0x98e19453); +export const HScName = new wasmtypes.ScHname(0x98e19453); diff --git a/packages/wasmvm/wasmlib/ts/wasmlib/wasmrequests/contract.ts b/packages/wasmvm/wasmlib/ts/wasmlib/wasmrequests/contract.ts index 227f20d89d..2ca7e6369c 100644 --- a/packages/wasmvm/wasmlib/ts/wasmlib/wasmrequests/contract.ts +++ b/packages/wasmvm/wasmlib/ts/wasmlib/wasmrequests/contract.ts @@ -6,6 +6,7 @@ // Change the json schema instead import * as wasmlib from "wasmlib"; +import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; export class ScFuncs { diff --git a/packages/wasmvm/wasmlib/ts/wasmlib/wasmrequests/index.ts b/packages/wasmvm/wasmlib/ts/wasmlib/wasmrequests/index.ts index 34b1120be4..d057bb4090 100644 --- a/packages/wasmvm/wasmlib/ts/wasmlib/wasmrequests/index.ts +++ b/packages/wasmvm/wasmlib/ts/wasmlib/wasmrequests/index.ts @@ -7,3 +7,4 @@ export * from "./consts"; export * from "./contract"; +export * from "./structs"; diff --git a/packages/wasmvm/wasmlib/ts/wasmlib/wasmrequests/structs.ts b/packages/wasmvm/wasmlib/ts/wasmlib/wasmrequests/structs.ts index cea6528926..93253500ca 100644 --- a/packages/wasmvm/wasmlib/ts/wasmlib/wasmrequests/structs.ts +++ b/packages/wasmvm/wasmlib/ts/wasmlib/wasmrequests/structs.ts @@ -6,75 +6,62 @@ // Change the json schema instead import * as wasmlib from "wasmlib"; +import * as wasmtypes from "wasmlib/wasmtypes"; export class CallRequest { - contract : wasmlib.ScHname = new wasmlib.ScHname(0); - function : wasmlib.ScHname = new wasmlib.ScHname(0); + contract : wasmtypes.ScHname = new wasmtypes.ScHname(0); + function : wasmtypes.ScHname = new wasmtypes.ScHname(0); params : u8[] = []; transfer : u8[] = []; - static fromBytes(bytes: u8[]): CallRequest { - let decode = new wasmlib.BytesDecoder(bytes); - let data = new CallRequest(); - data.contract = decode.hname(); - data.function = decode.hname(); - data.params = decode.bytes(); - data.transfer = decode.bytes(); - decode.close(); + static fromBytes(buf: u8[]|null): CallRequest { + const dec = new wasmtypes.WasmDecoder(buf); + const data = new CallRequest(); + data.contract = wasmtypes.hnameDecode(dec); + data.function = wasmtypes.hnameDecode(dec); + data.params = wasmtypes.bytesDecode(dec); + data.transfer = wasmtypes.bytesDecode(dec); + dec.close(); return data; } bytes(): u8[] { - return new wasmlib.BytesEncoder(). - hname(this.contract). - hname(this.function). - bytes(this.params). - bytes(this.transfer). - data(); + const enc = new wasmtypes.WasmEncoder(); + wasmtypes.hnameEncode(enc, this.contract); + wasmtypes.hnameEncode(enc, this.function); + wasmtypes.bytesEncode(enc, this.params); + wasmtypes.bytesEncode(enc, this.transfer); + return enc.buf(); } } -export class ImmutableCallRequest { - objID: i32; - keyID: wasmlib.Key32; - - constructor(objID: i32, keyID: wasmlib.Key32) { - this.objID = objID; - this.keyID = keyID; - } +export class ImmutableCallRequest extends wasmtypes.ScProxy { exists(): boolean { - return wasmlib.exists(this.objID, this.keyID, wasmlib.TYPE_BYTES); + return this.proxy.exists(); } value(): CallRequest { - return CallRequest.fromBytes(wasmlib.getBytes(this.objID, this.keyID, wasmlib.TYPE_BYTES)); + return CallRequest.fromBytes(this.proxy.get()); } } -export class MutableCallRequest { - objID: i32; - keyID: wasmlib.Key32; - - constructor(objID: i32, keyID: wasmlib.Key32) { - this.objID = objID; - this.keyID = keyID; - } +export class MutableCallRequest extends wasmtypes.ScProxy { delete(): void { - wasmlib.delKey(this.objID, this.keyID, wasmlib.TYPE_BYTES); + this.proxy.delete(); } exists(): boolean { - return wasmlib.exists(this.objID, this.keyID, wasmlib.TYPE_BYTES); + return this.proxy.exists(); } setValue(value: CallRequest): void { - wasmlib.setBytes(this.objID, this.keyID, wasmlib.TYPE_BYTES, value.bytes()); + this.proxy.set(value.bytes()); } value(): CallRequest { - return CallRequest.fromBytes(wasmlib.getBytes(this.objID, this.keyID, wasmlib.TYPE_BYTES)); + return CallRequest.fromBytes(this.proxy.get()); } } @@ -82,211 +69,169 @@ export class DeployRequest { description : string = ""; name : string = ""; params : u8[] = []; - progHash : wasmlib.ScHash = new wasmlib.ScHash(); - - static fromBytes(bytes: u8[]): DeployRequest { - let decode = new wasmlib.BytesDecoder(bytes); - let data = new DeployRequest(); - data.description = decode.string(); - data.name = decode.string(); - data.params = decode.bytes(); - data.progHash = decode.hash(); - decode.close(); + progHash : wasmtypes.ScHash = new wasmtypes.ScHash(); + + static fromBytes(buf: u8[]|null): DeployRequest { + const dec = new wasmtypes.WasmDecoder(buf); + const data = new DeployRequest(); + data.description = wasmtypes.stringDecode(dec); + data.name = wasmtypes.stringDecode(dec); + data.params = wasmtypes.bytesDecode(dec); + data.progHash = wasmtypes.hashDecode(dec); + dec.close(); return data; } bytes(): u8[] { - return new wasmlib.BytesEncoder(). - string(this.description). - string(this.name). - bytes(this.params). - hash(this.progHash). - data(); + const enc = new wasmtypes.WasmEncoder(); + wasmtypes.stringEncode(enc, this.description); + wasmtypes.stringEncode(enc, this.name); + wasmtypes.bytesEncode(enc, this.params); + wasmtypes.hashEncode(enc, this.progHash); + return enc.buf(); } } -export class ImmutableDeployRequest { - objID: i32; - keyID: wasmlib.Key32; - - constructor(objID: i32, keyID: wasmlib.Key32) { - this.objID = objID; - this.keyID = keyID; - } +export class ImmutableDeployRequest extends wasmtypes.ScProxy { exists(): boolean { - return wasmlib.exists(this.objID, this.keyID, wasmlib.TYPE_BYTES); + return this.proxy.exists(); } value(): DeployRequest { - return DeployRequest.fromBytes(wasmlib.getBytes(this.objID, this.keyID, wasmlib.TYPE_BYTES)); + return DeployRequest.fromBytes(this.proxy.get()); } } -export class MutableDeployRequest { - objID: i32; - keyID: wasmlib.Key32; - - constructor(objID: i32, keyID: wasmlib.Key32) { - this.objID = objID; - this.keyID = keyID; - } +export class MutableDeployRequest extends wasmtypes.ScProxy { delete(): void { - wasmlib.delKey(this.objID, this.keyID, wasmlib.TYPE_BYTES); + this.proxy.delete(); } exists(): boolean { - return wasmlib.exists(this.objID, this.keyID, wasmlib.TYPE_BYTES); + return this.proxy.exists(); } setValue(value: DeployRequest): void { - wasmlib.setBytes(this.objID, this.keyID, wasmlib.TYPE_BYTES, value.bytes()); + this.proxy.set(value.bytes()); } value(): DeployRequest { - return DeployRequest.fromBytes(wasmlib.getBytes(this.objID, this.keyID, wasmlib.TYPE_BYTES)); + return DeployRequest.fromBytes(this.proxy.get()); } } export class PostRequest { - chainID : wasmlib.ScChainID = new wasmlib.ScChainID(); - contract : wasmlib.ScHname = new wasmlib.ScHname(0); + chainID : wasmtypes.ScChainID = new wasmtypes.ScChainID(); + contract : wasmtypes.ScHname = new wasmtypes.ScHname(0); delay : u32 = 0; - function : wasmlib.ScHname = new wasmlib.ScHname(0); + function : wasmtypes.ScHname = new wasmtypes.ScHname(0); params : u8[] = []; transfer : u8[] = []; - static fromBytes(bytes: u8[]): PostRequest { - let decode = new wasmlib.BytesDecoder(bytes); - let data = new PostRequest(); - data.chainID = decode.chainID(); - data.contract = decode.hname(); - data.delay = decode.uint32(); - data.function = decode.hname(); - data.params = decode.bytes(); - data.transfer = decode.bytes(); - decode.close(); + static fromBytes(buf: u8[]|null): PostRequest { + const dec = new wasmtypes.WasmDecoder(buf); + const data = new PostRequest(); + data.chainID = wasmtypes.chainIDDecode(dec); + data.contract = wasmtypes.hnameDecode(dec); + data.delay = wasmtypes.uint32Decode(dec); + data.function = wasmtypes.hnameDecode(dec); + data.params = wasmtypes.bytesDecode(dec); + data.transfer = wasmtypes.bytesDecode(dec); + dec.close(); return data; } bytes(): u8[] { - return new wasmlib.BytesEncoder(). - chainID(this.chainID). - hname(this.contract). - uint32(this.delay). - hname(this.function). - bytes(this.params). - bytes(this.transfer). - data(); + const enc = new wasmtypes.WasmEncoder(); + wasmtypes.chainIDEncode(enc, this.chainID); + wasmtypes.hnameEncode(enc, this.contract); + wasmtypes.uint32Encode(enc, this.delay); + wasmtypes.hnameEncode(enc, this.function); + wasmtypes.bytesEncode(enc, this.params); + wasmtypes.bytesEncode(enc, this.transfer); + return enc.buf(); } } -export class ImmutablePostRequest { - objID: i32; - keyID: wasmlib.Key32; - - constructor(objID: i32, keyID: wasmlib.Key32) { - this.objID = objID; - this.keyID = keyID; - } +export class ImmutablePostRequest extends wasmtypes.ScProxy { exists(): boolean { - return wasmlib.exists(this.objID, this.keyID, wasmlib.TYPE_BYTES); + return this.proxy.exists(); } value(): PostRequest { - return PostRequest.fromBytes(wasmlib.getBytes(this.objID, this.keyID, wasmlib.TYPE_BYTES)); + return PostRequest.fromBytes(this.proxy.get()); } } -export class MutablePostRequest { - objID: i32; - keyID: wasmlib.Key32; - - constructor(objID: i32, keyID: wasmlib.Key32) { - this.objID = objID; - this.keyID = keyID; - } +export class MutablePostRequest extends wasmtypes.ScProxy { delete(): void { - wasmlib.delKey(this.objID, this.keyID, wasmlib.TYPE_BYTES); + this.proxy.delete(); } exists(): boolean { - return wasmlib.exists(this.objID, this.keyID, wasmlib.TYPE_BYTES); + return this.proxy.exists(); } setValue(value: PostRequest): void { - wasmlib.setBytes(this.objID, this.keyID, wasmlib.TYPE_BYTES, value.bytes()); + this.proxy.set(value.bytes()); } value(): PostRequest { - return PostRequest.fromBytes(wasmlib.getBytes(this.objID, this.keyID, wasmlib.TYPE_BYTES)); + return PostRequest.fromBytes(this.proxy.get()); } } export class SendRequest { - address : wasmlib.ScAddress = new wasmlib.ScAddress(); + address : wasmtypes.ScAddress = new wasmtypes.ScAddress(); transfer : u8[] = []; - static fromBytes(bytes: u8[]): SendRequest { - let decode = new wasmlib.BytesDecoder(bytes); - let data = new SendRequest(); - data.address = decode.address(); - data.transfer = decode.bytes(); - decode.close(); + static fromBytes(buf: u8[]|null): SendRequest { + const dec = new wasmtypes.WasmDecoder(buf); + const data = new SendRequest(); + data.address = wasmtypes.addressDecode(dec); + data.transfer = wasmtypes.bytesDecode(dec); + dec.close(); return data; } bytes(): u8[] { - return new wasmlib.BytesEncoder(). - address(this.address). - bytes(this.transfer). - data(); + const enc = new wasmtypes.WasmEncoder(); + wasmtypes.addressEncode(enc, this.address); + wasmtypes.bytesEncode(enc, this.transfer); + return enc.buf(); } } -export class ImmutableSendRequest { - objID: i32; - keyID: wasmlib.Key32; - - constructor(objID: i32, keyID: wasmlib.Key32) { - this.objID = objID; - this.keyID = keyID; - } +export class ImmutableSendRequest extends wasmtypes.ScProxy { exists(): boolean { - return wasmlib.exists(this.objID, this.keyID, wasmlib.TYPE_BYTES); + return this.proxy.exists(); } value(): SendRequest { - return SendRequest.fromBytes(wasmlib.getBytes(this.objID, this.keyID, wasmlib.TYPE_BYTES)); + return SendRequest.fromBytes(this.proxy.get()); } } -export class MutableSendRequest { - objID: i32; - keyID: wasmlib.Key32; - - constructor(objID: i32, keyID: wasmlib.Key32) { - this.objID = objID; - this.keyID = keyID; - } +export class MutableSendRequest extends wasmtypes.ScProxy { delete(): void { - wasmlib.delKey(this.objID, this.keyID, wasmlib.TYPE_BYTES); + this.proxy.delete(); } exists(): boolean { - return wasmlib.exists(this.objID, this.keyID, wasmlib.TYPE_BYTES); + return this.proxy.exists(); } setValue(value: SendRequest): void { - wasmlib.setBytes(this.objID, this.keyID, wasmlib.TYPE_BYTES, value.bytes()); + this.proxy.set(value.bytes()); } value(): SendRequest { - return SendRequest.fromBytes(wasmlib.getBytes(this.objID, this.keyID, wasmlib.TYPE_BYTES)); + return SendRequest.fromBytes(this.proxy.get()); } } diff --git a/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/codec.ts b/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/codec.ts new file mode 100644 index 0000000000..4f69fe9e6e --- /dev/null +++ b/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/codec.ts @@ -0,0 +1,216 @@ +// Copyright 2020 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +import {panic} from "../sandbox"; + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +// WasmDecoder decodes separate entities from a byte buffer +export class WasmDecoder { + buf: u8[]; + + constructor(buf: u8[] | null) { + this.buf = buf == null ? [] : buf; + } + + // decodes the next byte from the byte buffer + byte(): u8 { + if (this.buf.length == 0) { + panic("insufficient bytes"); + } + return this.buf.shift(); + } + + // decodes the next variable sized slice of bytes from the byte buffer + bytes(): u8[] { + const length = this.vluDecode(32) as u32; + return this.fixedBytes(length); + } + + // finalizes decoding by panicking if any bytes remain in the byte buffer + close(): void { + if (this.buf.length != 0) { + panic("extra bytes"); + } + } + + // decodes the next fixed size slice of bytes from the byte buffer + fixedBytes(size: u32): u8[] { + if ((this.buf.length as u32) < size) { + panic("insufficient bytes"); + } + let value = this.buf.slice(0, size); + this.buf = this.buf.slice(size); + return value; + } + + // Variable Length Integer decoder, uses modified LEB128 + vliDecode(bits: i32): i64 { + let b = this.byte(); + const sign = b & 0x40; + + // first group of 6 bits + let value = (b & 0x3f) as i64; + let s = 6; + + // while continuation bit is set + for (; (b & 0x80) != 0; s += 7) { + if (s >= bits) { + panic("integer representation too long"); + } + + // next group of 7 bits + b = this.byte(); + value |= ((b & 0x7f) as i64) << s; + } + + if (sign == 0) { + // positive, sign bits are already zero + return value; + } + + // negative, extend sign bits + return value | ((-1 as i64) << s); + } + + // Variable Length Unsigned decoder, uses ULEB128 + vluDecode(bits: i32): u64 { + // first group of 7 bits + let b = this.byte(); + let value = (b & 0x7f) as u64; + let s = 7; + + // while continuation bit is set + for (; (b & 0x80) != 0; s += 7) { + if (s >= bits) { + panic("integer representation too long"); + } + + // next group of 7 bits + b = this.byte(); + value |= ((b & 0x7f) as u64) << s; + } + + return value; + } +} + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +// WasmEncoder encodes separate entities into a byte buffer +export class WasmEncoder { + data: u8[]; + + // constructs an encoder + constructor() { + this.data = []; + } + + // retrieves the encoded byte buffer + buf(): u8[] { + return this.data; + } + + // encodes a single byte into the byte buffer + byte(value: u8): WasmEncoder { + this.data.push(value); + return this; + } + + // encodes a variable sized slice of bytes into the byte buffer + bytes(value: u8[]): WasmEncoder { + const length = value.length; + this.vluEncode(length as u64); + return this.fixedBytes(value, length as u32); + } + + // encodes a fixed size slice of bytes into the byte buffer + fixedBytes(value: u8[], length: u32): WasmEncoder { + if ((value.length as u32) != length) { + panic("invalid fixed bytes length"); + } + this.data = this.data.concat(value); + return this; + } + + // Variable Length Integer encoder, uses modified LEB128 + vliEncode(value: i64): WasmEncoder { + // bit 7 is always continuation bit + + // first group: 6 bits of data plus sign bit + // bit 6 encodes 0 as positive and 1 as negative + let b = (value as u8) & 0x3f; + value >>= 6; + + let finalValue: i64 = 0; + if (value < 0) { + // 1st byte encodes 1 as negative in bit 6 + b |= 0x40; + // negative value, start with all high bits set to 1 + finalValue = -1; + } + + // keep shifting until all bits are done + while (value != finalValue) { + // emit with continuation bit + this.data.push(b | 0x80); + + // next group of 7 data bits + b = (value as u8) & 0x7f; + value >>= 7; + } + + // emit without continuation bit to signal end + this.data.push(b); + return this; + } + + // Variable Length Unsigned encoder, uses ULEB128 + vluEncode(value: u64): WasmEncoder { + // bit 7 is always continuation bit + + // first group of 7 data bits + let b = (value as u8) & 0x7f; + value >>= 7; + + // keep shifting until all bits are done + while (value != 0) { + // emit with continuation bit + this.data.push(b | 0x80); + + // next group of 7 data bits + b = (value as u8) & 0x7f; + value >>= 7; + } + + // emit without continuation bit to signal end + this.data.push(b); + return this; + } +} + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +// wrapper for simplified use by hashtypes +export function base58Encode(buf: u8[]): string { + // TODO + // return string(wasmlib.Sandbox(wasmstore.FnUtilsBase58Encode, buf)) + return hex(buf); +} + +// returns a hex string representing the byte buffer +export function hex(buf: u8[]): string { + const hexa = "0123456789abcdef"; + let res = ""; + for (let i = 0; i < buf.length; i++) { + const b = buf[i]; + res += hexa.charAt(b >> 4) + hexa.charAt(b & 0x0f); + } + return res +} + +export function zeroes(count: u32): u8[] { + let buf: u8[] = new Array(count); + buf.fill(0); + return buf; +} diff --git a/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/index.ts b/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/index.ts new file mode 100644 index 0000000000..0efea2b74e --- /dev/null +++ b/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/index.ts @@ -0,0 +1,24 @@ +// Copyright 2020 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +export * from "./codec" +export * from "./proxy" + +export * from "./scaddress" +export * from "./scagentid" +export * from "./scbool" +export * from "./scbytes" +export * from "./scchainid" +export * from "./sccolor" +export * from "./schash" +export * from "./schname" +export * from "./scint8" +export * from "./scint16" +export * from "./scint32" +export * from "./scint64" +export * from "./screquestid" +export * from "./scstring" +export * from "./scuint8" +export * from "./scuint16" +export * from "./scuint32" +export * from "./scuint64" diff --git a/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/package.json b/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/package.json new file mode 100644 index 0000000000..b7e5668731 --- /dev/null +++ b/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/package.json @@ -0,0 +1,12 @@ +{ + "name": "wasmtypes", + "description": "WasmTypes, interface library for ISCP Wasm VM", + "version": "1.0.0", + "author": "Eric Hop", + "dependencies": { + "@assemblyscript/loader": "^0.19.18" + }, + "devDependencies": { + "assemblyscript": "^0.19.18" + } +} diff --git a/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/proxy.ts b/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/proxy.ts new file mode 100644 index 0000000000..3cc5f3a8f6 --- /dev/null +++ b/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/proxy.ts @@ -0,0 +1,154 @@ +// Copyright 2020 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +import {panic} from "../sandbox"; +import {WasmDecoder, WasmEncoder} from "./codec"; +import {uint32Decode, uint32Encode} from "./scuint32"; +import {stringToBytes} from "./scstring"; + +export interface IKvStore { + delete(key: u8[]): void; + + exists(key: u8[]): bool; + + get(key: u8[]): u8[] | null; + + set(key: u8[], value: u8[]): void; +} + +export class ScProxy { + protected proxy: Proxy; + + public constructor(proxy: Proxy) { + this.proxy = proxy; + } +} + +export class Proxy { + _key: u8[] = []; + kvStore: IKvStore; + + constructor(kvStore: IKvStore) { + this.kvStore = kvStore; + } + + // Append returns a Proxy for a newly appended null element + // Note that this will essentially return the element at Length() + public append(): Proxy { + const length = this.length(); + this.expand(length + 1); + return this.element(length); + } + + // ClearArray clears an array by deleting all elements + // TODO Note that this does not delete recursive container elements + public clearArray(): void { + for (let length = this.length(); length != 0; length--) { + this.element(length - 1).delete(); + } + + // clear the length counter + this.delete(); + } + + // ClearMap clears a map by deleting all elements + // TODO Note that this does not delete recursive container elements + public clearMap(): void { + // TODO clearPrefix + + // clear the length counter + this.delete(); + } + + public decoder(): WasmDecoder { + return this._decoder(this.get()); + } + + protected _decoder(buf: u8[] | null): WasmDecoder { + return new WasmDecoder(buf); + } + + delete(): void { + this.kvStore.delete(this._key); + } + + protected element(index: u32): Proxy { + let enc = this.encoder(); + uint32Encode(enc, index); + return this.sub('#'.charCodeAt(0) as u8, enc.buf()); + } + + public encoder(): WasmEncoder { + return new WasmEncoder(); + } + + exists(): bool { + return this.kvStore.exists(this._key); + } + + public expand(length: u32): void { + // update the length counter + let enc = this.encoder(); + uint32Encode(enc, length); + this.set(enc.buf()); + } + + get(): u8[] | null { + return this.kvStore.get(this._key); + } + + // Index gets a Proxy for an element of an Array by its index + public index(index: u32): Proxy { + const size = this.length(); + if (index >= size) { + if (index == size) { + panic("invalid index: use append"); + } + panic("invalid index"); + } + return this.element(index); + } + + // Key gets a Proxy for an element of a Map by its key + public key(key: u8[]): Proxy { + return this.sub('.'.charCodeAt(0) as u8, key); + } + + // Length returns the number of elements in an Array + // Never try to access an index >= Length() + public length(): u32 { + // get the length counter + let buf = this.get(); + if (buf == null) { + return 0; + } + return uint32Decode(this._decoder(buf)); + } + + protected proxy(kvStore: IKvStore, key: u8[]): Proxy { + const res = new Proxy(kvStore); + res._key = key; + return res; + } + + // Root returns a Proxy for an element of a root container (Params/Results/State). + // The key is always a string. + public root(key: string): Proxy { + return this.proxy(this.kvStore, stringToBytes(key)); + } + + set(value: u8[]): void { + this.kvStore.set(this._key, value); + } + + // sub returns a proxy for an element of a container. + // The separator is significant, it prevents potential clashes with other elements. + // Different separators can be used to indicate different sub-containers + protected sub(sep: u8, key: u8[]): Proxy { + if (this._key.length == 0) { + // this must be a root proxy + return this.proxy(this.kvStore, key.slice(0)); + } + return this.proxy(this.kvStore, this._key.concat([sep]).concat(key)); + } +} \ No newline at end of file diff --git a/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/scaddress.ts b/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/scaddress.ts new file mode 100644 index 0000000000..2e19d3f3da --- /dev/null +++ b/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/scaddress.ts @@ -0,0 +1,109 @@ +// Copyright 2020 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +import {panic} from "../sandbox"; +import {base58Encode, WasmDecoder, WasmEncoder, zeroes} from "./codec"; +import {Proxy} from "./proxy"; +import {ScAgentID} from "./scagentid"; +import {bytesCompare} from "./scbytes"; +import {ScHname} from "./schname"; + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +export const ScAddressLength = 33; + +export class ScAddress { + id: u8[] = zeroes(ScAddressLength); + + asAgentID(): ScAgentID { + // agentID for address has Hname zero + return new ScAgentID(this, new ScHname(0)); + } + + public equals(other: ScAddress): bool { + return bytesCompare(this.id, other.id) == 0; + } + + // convert to byte array representation + public toBytes(): u8[] { + return addressToBytes(this); + } + + // human-readable string representation + public toString(): string { + return addressToString(this); + } +} + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +export function addressDecode(dec: WasmDecoder): ScAddress { + return addressFromBytesUnchecked(dec.fixedBytes(ScAddressLength)) +} + +export function addressEncode(enc: WasmEncoder, value: ScAddress): void { + enc.fixedBytes(value.toBytes(), ScAddressLength) +} + +export function addressFromBytes(buf: u8[] | null): ScAddress { + if (buf == null) { + return new ScAddress(); + } + if (buf.length != ScAddressLength) { + panic("invalid Address length"); + } + // max ledgerstate.AliasAddressType + if (buf[0] > 2) { + panic("invalid Address: address type > 2"); + } + return addressFromBytesUnchecked(buf); +} + +export function addressToBytes(value: ScAddress): u8[] { + return value.id; +} + +export function addressToString(value: ScAddress): string { + // TODO standardize human readable string + return base58Encode(value.id); +} + +function addressFromBytesUnchecked(buf: u8[]): ScAddress { + let o = new ScAddress(); + o.id = buf.slice(0); + return o; +} + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +export class ScImmutableAddress { + proxy: Proxy; + + constructor(proxy: Proxy) { + this.proxy = proxy; + } + + exists(): bool { + return this.proxy.exists(); + } + + toString(): string { + return addressToString(this.value()); + } + + value(): ScAddress { + return addressFromBytes(this.proxy.get()); + } +} + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +export class ScMutableAddress extends ScImmutableAddress { + delete(): void { + this.proxy.delete(); + } + + setValue(value: ScAddress): void { + this.proxy.set(addressToBytes(value)); + } +} diff --git a/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/scagentid.ts b/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/scagentid.ts new file mode 100644 index 0000000000..bc66ca69f9 --- /dev/null +++ b/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/scagentid.ts @@ -0,0 +1,125 @@ +// Copyright 2020 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +import {panic} from "../sandbox"; +import {WasmDecoder, WasmEncoder, zeroes} from "./codec"; +import {Proxy} from "./proxy"; +import {addressEncode, addressFromBytes, ScAddress, ScAddressLength} from "./scaddress"; +import {hnameEncode, hnameFromBytes, ScHname} from "./schname"; + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +export const ScAgentIDLength = 37; + +export class ScAgentID { + _address: ScAddress; + _hname: ScHname; + + constructor(address: ScAddress, hname: ScHname) { + this._address = address; + this._hname = hname; + } + + public equals(other: ScAgentID): bool { + return this._address.equals(other._address) && + this._hname.equals(other._hname); + } + + public address(): ScAddress { + return this._address; + } + + public hname(): ScHname { + return this._hname; + } + + public isAddress(): bool { + return this._hname.equals(new ScHname(0)); + } + + // convert to byte array representation + public toBytes(): u8[] { + return agentIDToBytes(this) + } + + // human-readable string representation + public toString(): string { + return agentIDToString(this) + } +} + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +export function agentIDDecode(dec: WasmDecoder): ScAgentID { + return agentIDFromBytesUnchecked(dec.fixedBytes(ScAgentIDLength)); +} + +export function agentIDEncode(enc: WasmEncoder, value: ScAgentID): void { + addressEncode(enc, value._address); + hnameEncode(enc, value._hname); +} + +export function agentIDFromBytes(buf: u8[] | null): ScAgentID { + if (buf == null) { + return agentIDFromBytesUnchecked(zeroes(ScAgentIDLength)); + } + if (buf.length != ScAgentIDLength) { + panic("invalid AgentID length"); + } + // max ledgerstate.AliasAddressType + if (buf[0] > 2) { + panic("invalid AgentID: address type > 2"); + } + return agentIDFromBytesUnchecked(buf); +} + +export function agentIDToBytes(value: ScAgentID): u8[] { + const enc = new WasmEncoder(); + agentIDEncode(enc, value); + return enc.buf(); +} + +export function agentIDToString(value: ScAgentID): string { + // TODO standardize human readable string + return value._address.toString() + "::" + value._hname.toString(); +} + +function agentIDFromBytesUnchecked(buf: u8[]): ScAgentID { + return new ScAgentID( + addressFromBytes(buf.slice(0, ScAddressLength)), + hnameFromBytes(buf.slice(ScAddressLength))); +} + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +export class ScImmutableAgentID { + proxy: Proxy; + + constructor(proxy: Proxy) { + this.proxy = proxy; + } + + exists(): bool { + return this.proxy.exists(); + } + + toString(): string { + return agentIDToString(this.value()); + } + + value(): ScAgentID { + return agentIDFromBytes(this.proxy.get()); + } +} + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +export class ScMutableAgentID extends ScImmutableAgentID { + delete(): void { + this.proxy.delete(); + } + + setValue(value: ScAgentID): void { + this.proxy.set(agentIDToBytes(value)); + } +} diff --git a/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/scbool.ts b/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/scbool.ts new file mode 100644 index 0000000000..6879080608 --- /dev/null +++ b/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/scbool.ts @@ -0,0 +1,78 @@ +// Copyright 2020 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +import {panic} from "../sandbox"; +import {WasmDecoder, WasmEncoder} from "./codec"; +import {Proxy} from "./proxy"; + +export const ScBoolLength = 1; +export const ScBoolFalse = 0x00 +export const ScBoolTrue = 0xff + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +export function boolDecode(dec: WasmDecoder): bool { + return dec.byte() != 0; +} + +export function boolEncode(enc: WasmEncoder, value: bool): void { + enc.byte((value ? ScBoolTrue : ScBoolFalse) as u8); +} + +export function boolFromBytes(buf: u8[] | null): bool { + if (buf == null) { + return false; + } + if (buf.length != ScBoolLength) { + panic("invalid Bool length"); + } + if (buf[0] == ScBoolFalse) { + return false; + } + if (buf[0] != ScBoolTrue) { + panic("invalid Bool value"); + } + return true; +} + +export function boolToBytes(value: bool): u8[] { + return [(value ? ScBoolTrue : ScBoolFalse) as u8]; +} + +export function boolToString(value: bool): string { + return value ? "1" : "0"; +} + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +export class ScImmutableBool { + proxy: Proxy; + + constructor(proxy: Proxy) { + this.proxy = proxy; + } + + exists(): bool { + return this.proxy.exists(); + } + + toString(): string { + return boolToString(this.value()); + } + + value(): bool { + return boolFromBytes(this.proxy.get()); + } +} + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +export class ScMutableBool extends ScImmutableBool { + delete(): void { + this.proxy.delete(); + } + + setValue(value: bool): void { + this.proxy.set(boolToBytes(value)); + } +} diff --git a/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/scbytes.ts b/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/scbytes.ts new file mode 100644 index 0000000000..4aa95a210f --- /dev/null +++ b/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/scbytes.ts @@ -0,0 +1,71 @@ +// Copyright 2020 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +import {base58Encode, WasmDecoder, WasmEncoder} from "./codec"; +import {Proxy} from "./proxy"; + +export function bytesCompare(lhs: u8[], rhs: u8[]): i32 { + const size = (lhs.length < rhs.length) ? lhs.length : rhs.length; + for (let i = 0; i < size; i++) { + if (lhs[i] != rhs[i]) { + return (lhs[i] > rhs[i]) ? 1 : -1 + } + } + return (lhs.length > size) ? 1 : (rhs.length > size) ? -1 : 0; +} + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +export function bytesDecode(dec: WasmDecoder): u8[] { + return dec.bytes(); +} + +export function bytesEncode(enc: WasmEncoder, value: u8[]): void { + enc.bytes(value); +} + +export function bytesFromBytes(buf: u8[] | null): u8[] { + return buf == null ? [] : buf; +} + +export function bytesToBytes(buf: u8[]): u8[] { + return buf; +} + +export function bytesToString(value: u8[]): string { + return base58Encode(value); +} + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +export class ScImmutableBytes { + proxy: Proxy; + + constructor(proxy: Proxy) { + this.proxy = proxy; + } + + exists(): bool { + return this.proxy.exists(); + } + + toString(): string { + return bytesToString(this.value()); + } + + value(): u8[] { + return bytesFromBytes(this.proxy.get()); + } +} + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +export class ScMutableBytes extends ScImmutableBytes { + delete(): void { + this.proxy.delete(); + } + + setValue(value: u8[]): void { + this.proxy.set(bytesToBytes(value)); + } +} diff --git a/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/scchainid.ts b/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/scchainid.ts new file mode 100644 index 0000000000..b3403ce774 --- /dev/null +++ b/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/scchainid.ts @@ -0,0 +1,107 @@ +// Copyright 2020 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +import {panic} from "../sandbox"; +import {base58Encode, WasmDecoder, WasmEncoder, zeroes} from "./codec"; +import {Proxy} from "./proxy"; +import {addressFromBytes, ScAddress} from "./scaddress"; +import {bytesCompare} from "./scbytes"; + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +export const ScChainIDLength = 33; + +export class ScChainID { + id: u8[] = zeroes(ScChainIDLength); + + public address(): ScAddress { + return addressFromBytes(this.id); + } + + public equals(other: ScChainID): bool { + return bytesCompare(this.id, other.id) == 0; + } + + // convert to byte array representation + public toBytes(): u8[] { + return chainIDToBytes(this); + } + + // human-readable string representation + public toString(): string { + return chainIDToString(this) + } +} + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +export function chainIDDecode(dec: WasmDecoder): ScChainID { + return chainIDFromBytesUnchecked(dec.fixedBytes(ScChainIDLength)); +} + +export function chainIDEncode(enc: WasmEncoder, value: ScChainID): void { + enc.fixedBytes(value.toBytes(), ScChainIDLength); +} + +export function chainIDFromBytes(buf: u8[] | null): ScChainID { + if (buf == null) { + return new ScChainID(); + } + if (buf.length != ScChainIDLength) { + panic("invalid ChainID length"); + } + // must be ledgerstate.AliasAddressType + if (buf[0] != 2) { + panic("invalid ChainID: not an alias address"); + } + return chainIDFromBytesUnchecked(buf); +} + +export function chainIDToBytes(value: ScChainID): u8[] { + return value.id; +} + +export function chainIDToString(value: ScChainID): string { + // TODO standardize human readable string + return base58Encode(value.id); +} + +function chainIDFromBytesUnchecked(buf: u8[]): ScChainID { + let o = new ScChainID(); + o.id = buf.slice(0); + return o; +} + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +export class ScImmutableChainID { + proxy: Proxy; + + constructor(proxy: Proxy) { + this.proxy = proxy; + } + + exists(): bool { + return this.proxy.exists(); + } + + toString(): string { + return chainIDToString(this.value()); + } + + value(): ScChainID { + return chainIDFromBytes(this.proxy.get()); + } +} + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +export class ScMutableChainID extends ScImmutableChainID { + delete(): void { + this.proxy.delete(); + } + + setValue(value: ScChainID): void { + this.proxy.set(chainIDToBytes(value)); + } +} diff --git a/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/sccolor.ts b/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/sccolor.ts new file mode 100644 index 0000000000..ce48018d6c --- /dev/null +++ b/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/sccolor.ts @@ -0,0 +1,107 @@ +// Copyright 2020 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +import {panic} from "../sandbox"; +import {base58Encode, WasmDecoder, WasmEncoder, zeroes} from "./codec"; +import {Proxy} from "./proxy"; +import {bytesCompare} from "./scbytes"; + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +export const ScColorLength = 32; + +export class ScColor { + id: u8[] = zeroes(ScColorLength); + + constructor(fill: u8) { + this.id.fill(fill); + } + + public equals(other: ScColor): bool { + return bytesCompare(this.id, other.id) == 0; + } + + // convert to byte array representation + public toBytes(): u8[] { + return colorToBytes(this); + } + + // human-readable string representation + public toString(): string { + // TODO standardize human readable string + return colorToString(this); + } +} + +// predefined colors +export const IOTA: ScColor = new ScColor(0x00); +export const MINT: ScColor = new ScColor(0xff); + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +export function colorDecode(dec: WasmDecoder): ScColor { + return colorFromBytesUnchecked(dec.fixedBytes(ScColorLength)); +} + +export function colorEncode(enc: WasmEncoder, value: ScColor): void { + enc.fixedBytes(value.toBytes(), ScColorLength); +} + +export function colorFromBytes(buf: u8[] | null): ScColor { + if (buf == null) { + return new ScColor(0); + } + if (buf.length != ScColorLength) { + panic("invalid Color length"); + } + return colorFromBytesUnchecked(buf); +} + +export function colorToBytes(value: ScColor): u8[] { + return value.id; +} + +export function colorToString(value: ScColor): string { + // TODO standardize human readable string + return base58Encode(value.id); +} + +function colorFromBytesUnchecked(buf: u8[]): ScColor { + let o = new ScColor(0); + o.id = buf.slice(0); + return o; +} + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +export class ScImmutableColor { + proxy: Proxy; + + constructor(proxy: Proxy) { + this.proxy = proxy; + } + + exists(): bool { + return this.proxy.exists(); + } + + toString(): string { + return colorToString(this.value()); + } + + value(): ScColor { + return colorFromBytes(this.proxy.get()); + } +} + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +export class ScMutableColor extends ScImmutableColor { + delete(): void { + this.proxy.delete(); + } + + setValue(value: ScColor): void { + this.proxy.set(colorToBytes(value)); + } +} diff --git a/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/schash.ts b/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/schash.ts new file mode 100644 index 0000000000..bcea2ea230 --- /dev/null +++ b/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/schash.ts @@ -0,0 +1,98 @@ +// Copyright 2020 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +import {panic} from "../sandbox"; +import {base58Encode, WasmDecoder, WasmEncoder, zeroes} from "./codec"; +import {Proxy} from "./proxy"; +import {bytesCompare} from "./scbytes"; + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +export const ScHashLength = 32; + +export class ScHash { + id: u8[] = zeroes(ScHashLength); + + public equals(other: ScHash): bool { + return bytesCompare(this.id, other.id) == 0; + } + + // convert to byte array representation + public toBytes(): u8[] { + return hashToBytes(this); + } + + // human-readable string representation + public toString(): string { + return hashToString(this); + } +} + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +export function hashDecode(dec: WasmDecoder): ScHash { + return hashFromBytesUnchecked(dec.fixedBytes(ScHashLength)); +} + +export function hashEncode(enc: WasmEncoder, value: ScHash): void { + enc.fixedBytes(value.toBytes(), ScHashLength); +} + +export function hashFromBytes(buf: u8[] | null): ScHash { + if (buf == null) { + return new ScHash(); + } + if (buf.length != ScHashLength) { + panic("invalid Hash length"); + } + return hashFromBytesUnchecked(buf); +} + +export function hashToBytes(value: ScHash): u8[] { + return value.id; +} + +export function hashToString(value: ScHash): string { + // TODO standardize human readable string + return base58Encode(value.id); +} + +function hashFromBytesUnchecked(buf: u8[]): ScHash { + let o = new ScHash(); + o.id = buf.slice(0); + return o; +} + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +export class ScImmutableHash { + proxy: Proxy; + + constructor(proxy: Proxy) { + this.proxy = proxy; + } + + exists(): bool { + return this.proxy.exists(); + } + + toString(): string { + return hashToString(this.value()); + } + + value(): ScHash { + return hashFromBytes(this.proxy.get()); + } +} + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +export class ScMutableHash extends ScImmutableHash { + delete(): void { + this.proxy.delete(); + } + + setValue(value: ScHash): void { + this.proxy.set(hashToBytes(value)); + } +} diff --git a/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/schname.ts b/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/schname.ts new file mode 100644 index 0000000000..08180bf4ef --- /dev/null +++ b/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/schname.ts @@ -0,0 +1,104 @@ +// Copyright 2020 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +import {panic} from "../sandbox"; +import {WasmDecoder, WasmEncoder} from "./codec"; +import {Proxy} from "./proxy"; +import {bytesCompare} from "./scbytes"; +import {uint32FromBytes, uint32ToBytes} from "./scuint32"; + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +export const ScHnameLength = 4; + +export class ScHname { + id: u8[]; + + constructor(id: u32) { + this.id = uint32ToBytes(id); + } + + public equals(other: ScHname): bool { + return bytesCompare(this.id, other.id) == 0; + } + + // convert to byte array representation + public toBytes(): u8[] { + return hnameToBytes(this); + } + + // human-readable string representation + public toString(): string { + return hnameToString(this) + } +} + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +export function hnameDecode(dec: WasmDecoder): ScHname { + return hnameFromBytesUnchecked(dec.fixedBytes(ScHnameLength)); +} + +export function hnameEncode(enc: WasmEncoder, value: ScHname): void { + enc.fixedBytes(value.toBytes(), ScHnameLength); +} + +export function hnameFromBytes(buf: u8[] | null): ScHname { + if (buf == null) { + return new ScHname(0); + } + if (buf.length != ScHnameLength) { + panic("invalid Hname length"); + } + return hnameFromBytesUnchecked(buf); +} + +export function hnameToBytes(value: ScHname): u8[] { + return value.id; +} + +export function hnameToString(value: ScHname): string { + // TODO standardize human readable string + const res = uint32FromBytes(value.id).toString(16); + return "0000000".slice(0, 8 - res.length) + res; +} + +function hnameFromBytesUnchecked(buf: u8[]): ScHname { + let o = new ScHname(0); + o.id = buf.slice(0); + return o; +} + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +export class ScImmutableHname { + proxy: Proxy; + + constructor(proxy: Proxy) { + this.proxy = proxy; + } + + exists(): bool { + return this.proxy.exists(); + } + + toString(): string { + return hnameToString(this.value()); + } + + value(): ScHname { + return hnameFromBytes(this.proxy.get()); + } +} + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +export class ScMutableHname extends ScImmutableHname { + delete(): void { + this.proxy.delete(); + } + + setValue(value: ScHname): void { + this.proxy.set(hnameToBytes(value)); + } +} diff --git a/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/scint16.ts b/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/scint16.ts new file mode 100644 index 0000000000..c8b2ac60b6 --- /dev/null +++ b/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/scint16.ts @@ -0,0 +1,74 @@ +// Copyright 2020 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +import {panic} from "../sandbox"; +import {WasmDecoder, WasmEncoder} from "./codec"; +import {Proxy} from "./proxy"; + +export const ScInt16Length = 2; + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +export function int16Decode(dec: WasmDecoder): i16 { + return dec.vliDecode(16) as i16; +} + +export function int16Encode(enc: WasmEncoder, value: i16): void { + enc.vliEncode(value as i64); +} + +export function int16FromBytes(buf: u8[] | null): i16 { + if (buf == null) { + return 0; + } + if (buf.length != ScInt16Length) { + panic("invalid Int16 length"); + } + let ret: i16 = buf[1]; + return (ret << 8) | buf[0]; +} + +export function int16ToBytes(value: i16): u8[] { + return [ + value as u8, + (value >> 8) as u8, + ]; +} + +export function int16ToString(value: i16): string { + return value.toString(); +} + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +export class ScImmutableInt16 { + proxy: Proxy; + + constructor(proxy: Proxy) { + this.proxy = proxy; + } + + exists(): bool { + return this.proxy.exists(); + } + + toString(): string { + return int16ToString(this.value()); + } + + value(): i16 { + return int16FromBytes(this.proxy.get()); + } +} + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +export class ScMutableInt16 extends ScImmutableInt16 { + delete(): void { + this.proxy.delete(); + } + + setValue(value: i16): void { + this.proxy.set(int16ToBytes(value)); + } +} diff --git a/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/scint32.ts b/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/scint32.ts new file mode 100644 index 0000000000..4c53f41d99 --- /dev/null +++ b/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/scint32.ts @@ -0,0 +1,78 @@ +// Copyright 2020 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +import {panic} from "../sandbox"; +import {WasmDecoder, WasmEncoder} from "./codec"; +import {Proxy} from "./proxy"; + +export const ScInt32Length = 4; + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +export function int32Decode(dec: WasmDecoder): i32 { + return dec.vliDecode(32) as i32; +} + +export function int32Encode(enc: WasmEncoder, value: i32): void { + enc.vliEncode(value as i64); +} + +export function int32FromBytes(buf: u8[] | null): i32 { + if (buf == null) { + return 0; + } + if (buf.length != ScInt32Length) { + panic("invalid Int32 length"); + } + let ret: i32 = buf[3]; + ret = (ret << 8) | buf[2]; + ret = (ret << 8) | buf[1]; + return (ret << 8) | buf[0]; +} + +export function int32ToBytes(value: i32): u8[] { + return [ + value as u8, + (value >> 8) as u8, + (value >> 16) as u8, + (value >> 24) as u8, + ]; +} + +export function int32ToString(value: i32): string { + return value.toString(); +} + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +export class ScImmutableInt32 { + proxy: Proxy; + + constructor(proxy: Proxy) { + this.proxy = proxy; + } + + exists(): bool { + return this.proxy.exists(); + } + + toString(): string { + return int32ToString(this.value()); + } + + value(): i32 { + return int32FromBytes(this.proxy.get()); + } +} + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +export class ScMutableInt32 extends ScImmutableInt32 { + delete(): void { + this.proxy.delete(); + } + + setValue(value: i32): void { + this.proxy.set(int32ToBytes(value)); + } +} diff --git a/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/scint64.ts b/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/scint64.ts new file mode 100644 index 0000000000..9bf5c50820 --- /dev/null +++ b/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/scint64.ts @@ -0,0 +1,86 @@ +// Copyright 2020 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +import {panic} from "../sandbox"; +import {WasmDecoder, WasmEncoder} from "./codec"; +import {Proxy} from "./proxy"; + +export const ScInt64Length = 8; + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +export function int64Decode(dec: WasmDecoder): i64 { + return dec.vliDecode(64); +} + +export function int64Encode(enc: WasmEncoder, value: i64): void { + enc.vliEncode(value); +} + +export function int64FromBytes(buf: u8[] | null): i64 { + if (buf == null) { + return 0; + } + if (buf.length != ScInt64Length) { + panic("invalid Int64 length"); + } + let ret: i64 = buf[7]; + ret = (ret << 8) | buf[6]; + ret = (ret << 8) | buf[5]; + ret = (ret << 8) | buf[4]; + ret = (ret << 8) | buf[3]; + ret = (ret << 8) | buf[2]; + ret = (ret << 8) | buf[1]; + return (ret << 8) | buf[0]; +} + +export function int64ToBytes(value: i64): u8[] { + return [ + value as u8, + (value >> 8) as u8, + (value >> 16) as u8, + (value >> 24) as u8, + (value >> 32) as u8, + (value >> 40) as u8, + (value >> 48) as u8, + (value >> 56) as u8, + ]; +} + +export function int64ToString(value: i64): string { + return value.toString(); +} + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +export class ScImmutableInt64 { + proxy: Proxy; + + constructor(proxy: Proxy) { + this.proxy = proxy; + } + + exists(): bool { + return this.proxy.exists(); + } + + toString(): string { + return int64ToString(this.value()); + } + + value(): i64 { + return int64FromBytes(this.proxy.get()); + } +} + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +export class ScMutableInt64 extends ScImmutableInt64 { + delete(): void { + this.proxy.delete(); + } + + setValue(value: i64): void { + this.proxy.set(int64ToBytes(value)); + } +} diff --git a/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/scint8.ts b/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/scint8.ts new file mode 100644 index 0000000000..e8ac27729f --- /dev/null +++ b/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/scint8.ts @@ -0,0 +1,70 @@ +// Copyright 2020 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +import {panic} from "../sandbox"; +import {WasmDecoder, WasmEncoder} from "./codec"; +import {Proxy} from "./proxy"; + +export const ScInt8Length = 1; + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +export function int8Decode(dec: WasmDecoder): i8 { + return dec.byte() as i8; +} + +export function int8Encode(enc: WasmEncoder, value: i8): void { + enc.byte(value as u8); +} + +export function int8FromBytes(buf: u8[] | null): i8 { + if (buf == null) { + return 0; + } + if (buf.length != ScInt8Length) { + panic("invalid Int8 length"); + } + return buf[0] as i8; +} + +export function int8ToBytes(value: i8): u8[] { + return [value as u8]; +} + +export function int8ToString(value: i8): string { + return value.toString(); +} + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +export class ScImmutableInt8 { + proxy: Proxy; + + constructor(proxy: Proxy) { + this.proxy = proxy; + } + + exists(): bool { + return this.proxy.exists(); + } + + toString(): string { + return int8ToString(this.value()); + } + + value(): i8 { + return int8FromBytes(this.proxy.get()); + } +} + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +export class ScMutableInt8 extends ScImmutableInt8 { + delete(): void { + this.proxy.delete(); + } + + setValue(value: i8): void { + this.proxy.set(int8ToBytes(value)); + } +} diff --git a/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/screquestid.ts b/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/screquestid.ts new file mode 100644 index 0000000000..b59465f6eb --- /dev/null +++ b/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/screquestid.ts @@ -0,0 +1,103 @@ +// Copyright 2020 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +import {panic} from "../sandbox"; +import {base58Encode, WasmDecoder, WasmEncoder, zeroes} from "./codec"; +import {Proxy} from "./proxy"; +import {bytesCompare} from "./scbytes"; +import {ScHashLength} from "./schash"; + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +export const ScRequestIDLength = 34; + +export class ScRequestID { + id: u8[] = zeroes(ScRequestIDLength); + + public equals(other: ScRequestID): bool { + return bytesCompare(this.id, other.id) == 0; + } + + // convert to byte array representation + public toBytes(): u8[] { + return requestIDToBytes(this); + } + + // human-readable string representation + public toString(): string { + return requestIDToString(this); + } +} + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +export function requestIDDecode(dec: WasmDecoder): ScRequestID { + return requestIDFromBytesUnchecked(dec.fixedBytes(ScRequestIDLength)); +} + +export function requestIDEncode(enc: WasmEncoder, value: ScRequestID): void { + enc.fixedBytes(value.toBytes(), ScRequestIDLength); +} + +export function requestIDFromBytes(buf: u8[] | null): ScRequestID { + if (buf == null) { + return new ScRequestID(); + } + if (buf.length != ScRequestIDLength) { + panic("invalid RequestID length"); + } + // final uint16 output index must be > ledgerstate.MaxOutputCount + if (buf[ScHashLength] > 127 || buf[ScHashLength + 1] != 0) { + panic("invalid RequestID: output index > 127"); + } + return requestIDFromBytesUnchecked(buf); +} + +export function requestIDToBytes(value: ScRequestID): u8[] { + return value.id; +} + +export function requestIDToString(value: ScRequestID): string { + // TODO standardize human readable string + return base58Encode(value.id); +} + +function requestIDFromBytesUnchecked(buf: u8[]): ScRequestID { + let o = new ScRequestID(); + o.id = buf.slice(0); + return o; +} + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +export class ScImmutableRequestID { + proxy: Proxy; + + constructor(proxy: Proxy) { + this.proxy = proxy; + } + + exists(): bool { + return this.proxy.exists(); + } + + toString(): string { + return requestIDToString(this.value()); + } + + value(): ScRequestID { + return requestIDFromBytes(this.proxy.get()); + } +} + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +export class ScMutableRequestID extends ScImmutableRequestID { + delete(): void { + this.proxy.delete(); + } + + setValue(value: ScRequestID): void { + this.proxy.set(requestIDToBytes(value)); + } +} diff --git a/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/scstring.ts b/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/scstring.ts new file mode 100644 index 0000000000..830dd3751d --- /dev/null +++ b/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/scstring.ts @@ -0,0 +1,67 @@ +// Copyright 2020 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +import {WasmDecoder, WasmEncoder} from "./codec"; +import {Proxy} from "./proxy"; + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +export function stringDecode(dec: WasmDecoder): string { + return stringFromBytes(dec.bytes()); +} + +export function stringEncode(enc: WasmEncoder, value: string): void { + enc.bytes(stringToBytes(value)); +} + +export function stringFromBytes(buf: u8[] | null): string { + return buf == null ? "" : String.UTF8.decodeUnsafe(buf.dataStart, buf.length); +} + +export function stringToBytes(value: string): u8[] { + let arrayBuffer = String.UTF8.encode(value); + let u8Array = Uint8Array.wrap(arrayBuffer) + let ret: u8[] = new Array(u8Array.length); + for (let i = 0; i < ret.length; i++) { + ret[i] = u8Array[i]; + } + return ret; +} + +export function stringToString(value: string): string { + return value; +} + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +export class ScImmutableString { + proxy: Proxy; + + constructor(proxy: Proxy) { + this.proxy = proxy; + } + + exists(): bool { + return this.proxy.exists(); + } + + toString(): string { + return this.value().toString(); + } + + value(): string { + return stringFromBytes(this.proxy.get()); + } +} + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +export class ScMutableString extends ScImmutableString { + delete(): void { + this.proxy.delete(); + } + + setValue(value: string): void { + this.proxy.set(stringToBytes(value)); + } +} diff --git a/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/scuint16.ts b/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/scuint16.ts new file mode 100644 index 0000000000..18fee10a33 --- /dev/null +++ b/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/scuint16.ts @@ -0,0 +1,74 @@ +// Copyright 2020 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +import {panic} from "../sandbox"; +import {WasmDecoder, WasmEncoder} from "./codec"; +import {Proxy} from "./proxy"; + +export const ScUint16Length = 2; + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +export function uint16Decode(dec: WasmDecoder): u16 { + return dec.vluDecode(16) as u16; +} + +export function uint16Encode(enc: WasmEncoder, value: u16): void { + enc.vluEncode(value as u64); +} + +export function uint16FromBytes(buf: u8[] | null): u16 { + if (buf == null) { + return 0; + } + if (buf.length != ScUint16Length) { + panic("invalid Uint16 length"); + } + let ret: u16 = buf[1]; + return (ret << 8) | buf[0]; +} + +export function uint16ToBytes(value: u16): u8[] { + return [ + value as u8, + (value >> 8) as u8, + ]; +} + +export function uint16ToString(value: u16): string { + return value.toString(); +} + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +export class ScImmutableUint16 { + proxy: Proxy; + + constructor(proxy: Proxy) { + this.proxy = proxy; + } + + exists(): bool { + return this.proxy.exists(); + } + + toString(): string { + return uint16ToString(this.value()); + } + + value(): u16 { + return uint16FromBytes(this.proxy.get()); + } +} + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +export class ScMutableUint16 extends ScImmutableUint16 { + delete(): void { + this.proxy.delete(); + } + + setValue(value: u16): void { + this.proxy.set(uint16ToBytes(value)); + } +} diff --git a/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/scuint32.ts b/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/scuint32.ts new file mode 100644 index 0000000000..4c38d333bb --- /dev/null +++ b/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/scuint32.ts @@ -0,0 +1,78 @@ +// Copyright 2020 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +import {panic} from "../sandbox"; +import {WasmDecoder, WasmEncoder} from "./codec"; +import {Proxy} from "./proxy"; + +export const ScUint32Length = 4; + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +export function uint32Decode(dec: WasmDecoder): u32 { + return dec.vluDecode(32) as u32; +} + +export function uint32Encode(enc: WasmEncoder, value: u32): void { + enc.vluEncode(value as u64); +} + +export function uint32FromBytes(buf: u8[] | null): u32 { + if (buf == null) { + return 0; + } + if (buf.length != ScUint32Length) { + panic("invalid Uint32 length"); + } + let ret: u32 = buf[3]; + ret = (ret << 8) | buf[2]; + ret = (ret << 8) | buf[1]; + return (ret << 8) | buf[0]; +} + +export function uint32ToBytes(value: u32): u8[] { + return [ + value as u8, + (value >> 8) as u8, + (value >> 16) as u8, + (value >> 24) as u8, + ]; +} + +export function uint32ToString(value: u32): string { + return value.toString(); +} + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +export class ScImmutableUint32 { + proxy: Proxy; + + constructor(proxy: Proxy) { + this.proxy = proxy; + } + + exists(): bool { + return this.proxy.exists(); + } + + toString(): string { + return uint32ToString(this.value()); + } + + value(): u32 { + return uint32FromBytes(this.proxy.get()); + } +} + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +export class ScMutableUint32 extends ScImmutableUint32 { + delete(): void { + this.proxy.delete(); + } + + setValue(value: u32): void { + this.proxy.set(uint32ToBytes(value)); + } +} diff --git a/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/scuint64.ts b/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/scuint64.ts new file mode 100644 index 0000000000..a0e9fb14dc --- /dev/null +++ b/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/scuint64.ts @@ -0,0 +1,86 @@ +// Copyright 2020 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +import {panic} from "../sandbox"; +import {WasmDecoder, WasmEncoder} from "./codec"; +import {Proxy} from "./proxy"; + +export const ScUint64Length = 8; + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +export function uint64Decode(dec: WasmDecoder): u64 { + return dec.vluDecode(64); +} + +export function uint64Encode(enc: WasmEncoder, value: u64): void { + enc.vluEncode(value); +} + +export function uint64FromBytes(buf: u8[] | null): u64 { + if (buf == null) { + return 0; + } + if (buf.length != ScUint64Length) { + panic("invalid Uint64 length"); + } + let ret: u64 = buf[7]; + ret = (ret << 8) | buf[6]; + ret = (ret << 8) | buf[5]; + ret = (ret << 8) | buf[4]; + ret = (ret << 8) | buf[3]; + ret = (ret << 8) | buf[2]; + ret = (ret << 8) | buf[1]; + return (ret << 8) | buf[0]; +} + +export function uint64ToBytes(value: u64): u8[] { + return [ + value as u8, + (value >> 8) as u8, + (value >> 16) as u8, + (value >> 24) as u8, + (value >> 32) as u8, + (value >> 40) as u8, + (value >> 48) as u8, + (value >> 56) as u8, + ]; +} + +export function uint64ToString(value: u64): string { + return value.toString(); +} + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +export class ScImmutableUint64 { + proxy: Proxy; + + constructor(proxy: Proxy) { + this.proxy = proxy; + } + + exists(): bool { + return this.proxy.exists(); + } + + toString(): string { + return uint64ToString(this.value()); + } + + value(): u64 { + return uint64FromBytes(this.proxy.get()); + } +} + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +export class ScMutableUint64 extends ScImmutableUint64 { + delete(): void { + this.proxy.delete(); + } + + setValue(value: u64): void { + this.proxy.set(uint64ToBytes(value)); + } +} diff --git a/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/scuint8.ts b/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/scuint8.ts new file mode 100644 index 0000000000..8df25ffc39 --- /dev/null +++ b/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/scuint8.ts @@ -0,0 +1,70 @@ +// Copyright 2020 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +import {panic} from "../sandbox"; +import {WasmDecoder, WasmEncoder} from "./codec"; +import {Proxy} from "./proxy"; + +export const ScUint8Length = 1; + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +export function uint8Decode(dec: WasmDecoder): u8 { + return dec.byte(); +} + +export function uint8Encode(enc: WasmEncoder, value: u8): void { + enc.byte(value); +} + +export function uint8FromBytes(buf: u8[] | null): u8 { + if (buf == null) { + return 0; + } + if (buf.length != ScUint8Length) { + panic("invalid Uint8 length"); + } + return buf[0]; +} + +export function uint8ToBytes(value: u8): u8[] { + return [value]; +} + +export function uint8ToString(value: u8): string { + return value.toString(); +} + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +export class ScImmutableUint8 { + proxy: Proxy; + + constructor(proxy: Proxy) { + this.proxy = proxy; + } + + exists(): bool { + return this.proxy.exists(); + } + + toString(): string { + return uint8ToString(this.value()); + } + + value(): u8 { + return uint8FromBytes(this.proxy.get()); + } +} + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +export class ScMutableUint8 extends ScImmutableUint8 { + delete(): void { + this.proxy.delete(); + } + + setValue(value: u8): void { + this.proxy.set(uint8ToBytes(value)); + } +} diff --git a/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/tsconfig.json b/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/tsconfig.json new file mode 100644 index 0000000000..b51e156a90 --- /dev/null +++ b/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/tsconfig.json @@ -0,0 +1,6 @@ +{ + "extends": "assemblyscript/std/assembly.json", + "include": [ + "./*.ts" + ] +} \ No newline at end of file diff --git a/packages/wasmvm/wasmsolo/solocontext.go b/packages/wasmvm/wasmsolo/solocontext.go index 9c1480d906..a1386dcc1e 100644 --- a/packages/wasmvm/wasmsolo/solocontext.go +++ b/packages/wasmvm/wasmsolo/solocontext.go @@ -30,10 +30,10 @@ const ( ) var ( // TODO set back to false - GoDebug = flag.Bool("godebug", true, "debug go smart contract code") + GoDebug = flag.Bool("godebug", false, "debug go smart contract code") GoWasm = flag.Bool("gowasm", false, "prefer go wasm smart contract code") GoWasmEdge = flag.Bool("gowasmedge", false, "use WasmEdge instead of WasmTime") - TsWasm = flag.Bool("tswasm", false, "prefer typescript wasm smart contract code") + TsWasm = flag.Bool("tswasm", true, "prefer typescript wasm smart contract code") ) type SoloContext struct { @@ -175,7 +175,6 @@ func StartChain(t *testing.T, chainName string, env ...*solo.Solo) *solo.Chain { wasmhost.DisableWasmTimeout = true } wasmhost.HostTracing = SoloHostTracing - // wasmhost.HostTracingAll = SoloHostTracing var soloEnv *solo.Solo if len(env) != 0 { diff --git a/packages/wasmvm/wasmsolo/solosandboxutils.go b/packages/wasmvm/wasmsolo/solosandboxutils.go index 95855487d3..0360d20e3f 100644 --- a/packages/wasmvm/wasmsolo/solosandboxutils.go +++ b/packages/wasmvm/wasmsolo/solosandboxutils.go @@ -26,12 +26,12 @@ func (s *SoloSandbox) fnUtilsBlsAddress(args []byte) []byte { func (s *SoloSandbox) fnUtilsBlsAggregate(args []byte) []byte { dec := wasmtypes.NewWasmDecoder(args) - count := int(wasmtypes.DecodeUint32(dec)) + count := int(wasmtypes.Uint32Decode(dec)) pubKeysBin := make([][]byte, count) for i := 0; i < count; i++ { pubKeysBin[i] = dec.Bytes() } - count = int(wasmtypes.DecodeUint32(dec)) + count = int(wasmtypes.Uint32Decode(dec)) sigsBin := make([][]byte, count) for i := 0; i < count; i++ { sigsBin[i] = dec.Bytes() diff --git a/packages/wasmvm/wasmvmhost/host.go b/packages/wasmvm/wasmvmhost/host.go index 908afe9b4b..40735424bb 100644 --- a/packages/wasmvm/wasmvmhost/host.go +++ b/packages/wasmvm/wasmvmhost/host.go @@ -8,7 +8,10 @@ package wasmvmhost import "github.com/iotaledger/wasp/packages/wasmvm/wasmlib/go/wasmlib" -// new Wasm VM +// interface WasmLib to the VM host + +// These 2 external functions are funneling the entire WasmLib functionality +// to their counterparts on the host. //go:wasm-module WasmLib //export hostStateGet @@ -60,8 +63,8 @@ func (w *WasmVMHost) ConnectWasmHost() { func (w *WasmVMHost) ExportName(index int32, name string) { // nil key indicates export name, with keyLen indicating index // this removes the need for a separate hostExportName function - value := []byte(name) - hostStateSet(nil, index, ptr(value), int32(len(value))) + buf := []byte(name) + hostStateSet(nil, index, ptr(buf), int32(len(buf))) } func (w *WasmVMHost) ExportWasmTag() { diff --git a/tools/schema/generator/emitter.go b/tools/schema/generator/emitter.go index c0a98ae562..47f3e4c0cd 100644 --- a/tools/schema/generator/emitter.go +++ b/tools/schema/generator/emitter.go @@ -405,6 +405,7 @@ func (g *GenBase) setFieldKeys(pad bool, maxCamelLength, maxSnakeLength int) { } g.setMultiKeyValues("fldName", g.currentField.Name) g.setMultiKeyValues("fldType", g.currentField.Type) + g.setMultiKeyValues("fldMapKey", g.currentField.MapKey) isArray := "" if g.currentField.Array { @@ -415,7 +416,6 @@ func (g *GenBase) setFieldKeys(pad bool, maxCamelLength, maxSnakeLength int) { g.keys["fldAlias"] = g.currentField.Alias g.keys["fldComment"] = g.currentField.Comment - g.keys["fldMapKey"] = g.currentField.MapKey g.keys["fldIndex"] = strconv.Itoa(g.currentField.KeyID) if pad { diff --git a/tools/schema/generator/goclienttemplates/service.go b/tools/schema/generator/goclienttemplates/service.go index 694c2df338..d75e3cb63d 100644 --- a/tools/schema/generator/goclienttemplates/service.go +++ b/tools/schema/generator/goclienttemplates/service.go @@ -138,7 +138,7 @@ $#if basetype callResultGetterBasic callResultGetterStruct func (r *$FuncName$+Results) $FldName() map[$fldKeyLangType]$fldLangType { res := make(map[$fldKeyLangType]$fldLangType) r.res.ForEach(func(key []byte, val []byte) { - res[r.res.To$fldMapKey(key)] = r.res.To$FldType(val) + res[r.res.To$FldMapKey(key)] = r.res.To$FldType(val) }) return res } diff --git a/tools/schema/generator/gotemplates/alltemplates.go b/tools/schema/generator/gotemplates/alltemplates.go index 3d7cf7b52d..7460299451 100644 --- a/tools/schema/generator/gotemplates/alltemplates.go +++ b/tools/schema/generator/gotemplates/alltemplates.go @@ -51,10 +51,6 @@ var TypeDependent = model.StringMapMap{ } var common = map[string]string{ - // ******************************* - "goPackage": ` -package $package -`, // ******************************* "importWasmLib": ` import "github.com/iotaledger/wasp/packages/wasmvm/wasmlib/go/wasmlib" @@ -62,6 +58,10 @@ import "github.com/iotaledger/wasp/packages/wasmvm/wasmlib/go/wasmlib" // ******************************* "importWasmTypes": ` import "github.com/iotaledger/wasp/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes" +`, + // ******************************* + "goPackage": ` +package $package `, // ******************************* "goHeader": ` diff --git a/tools/schema/generator/gotemplates/lib.go b/tools/schema/generator/gotemplates/lib.go index 6203505b5e..f05bd55688 100644 --- a/tools/schema/generator/gotemplates/lib.go +++ b/tools/schema/generator/gotemplates/lib.go @@ -39,8 +39,8 @@ $#if view ImmutablePackageStateInit $#emit accessCheck $#each mandatory requireMandatory $kind$FuncName(ctx, f) - ctx.Log("$package.$kind$FuncName ok") $#if result returnResultDict + ctx.Log("$package.$kind$FuncName ok") } `, // ******************************* diff --git a/tools/schema/generator/gotemplates/proxy.go b/tools/schema/generator/gotemplates/proxy.go index 6ac0c7d4a2..6a3f235a9f 100644 --- a/tools/schema/generator/gotemplates/proxy.go +++ b/tools/schema/generator/gotemplates/proxy.go @@ -37,16 +37,16 @@ $#if this proxyMapThis proxyMapOther // ******************************* "proxyMapThis": ` -func (s $TypeName) $FldName() Map$fldMapKey$+To$mut$FldType { +func (s $TypeName) $FldName() Map$FldMapKey$+To$mut$FldType { //nolint:gosimple - return Map$fldMapKey$+To$mut$FldType{proxy: s.proxy} + return Map$FldMapKey$+To$mut$FldType{proxy: s.proxy} } `, // ******************************* "proxyMapOther": ` -func (s $TypeName) $FldName() Map$fldMapKey$+To$mut$FldType { - return Map$fldMapKey$+To$mut$FldType{proxy: s.proxy.Root($Kind$FldName)} +func (s $TypeName) $FldName() Map$FldMapKey$+To$mut$FldType { + return Map$FldMapKey$+To$mut$FldType{proxy: s.proxy.Root($Kind$FldName)} } `, // ******************************* diff --git a/tools/schema/generator/gotemplates/structs.go b/tools/schema/generator/gotemplates/structs.go index 6718afa4d6..cda808607b 100644 --- a/tools/schema/generator/gotemplates/structs.go +++ b/tools/schema/generator/gotemplates/structs.go @@ -39,11 +39,11 @@ $#emit structMethods `, // ******************************* "structDecode": ` - data.$FldName$fldPad = wasmtypes.Decode$FldType(dec) + data.$FldName$fldPad = wasmtypes.$FldType$+Decode(dec) `, // ******************************* "structEncode": ` - wasmtypes.Encode$FldType(enc, o.$FldName) + wasmtypes.$FldType$+Encode(enc, o.$FldName) `, // ******************************* "structMethods": ` diff --git a/tools/schema/generator/gotemplates/typedefs.go b/tools/schema/generator/gotemplates/typedefs.go index ad0f48f043..59a3a57c7a 100644 --- a/tools/schema/generator/gotemplates/typedefs.go +++ b/tools/schema/generator/gotemplates/typedefs.go @@ -83,7 +83,7 @@ func (a $proxy) Get$FldType(index uint32) $mut$FldType { `, // ******************************* "typedefProxyMap": ` -$#set proxy Map$fldMapKey$+To$mut$FldType +$#set proxy Map$FldMapKey$+To$mut$FldType $#if exist else typedefProxyMapNew `, // ******************************* @@ -107,14 +107,14 @@ func (m $proxy) Clear() { "typedefProxyMapNewBaseType": ` func (m $proxy) Get$FldType(key $fldKeyLangType) wasmtypes.Sc$mut$FldType { - return wasmtypes.NewSc$mut$FldType(m.proxy.Key(wasmtypes.BytesFrom$fldMapKey(key))) + return wasmtypes.NewSc$mut$FldType(m.proxy.Key(wasmtypes.$FldMapKey$+ToBytes(key))) } `, // ******************************* "typedefProxyMapNewOtherType": ` func (m $proxy) Get$FldType(key $fldKeyLangType) $mut$FldType { - return $mut$FldType{proxy: m.proxy.Key(wasmtypes.BytesFrom$fldMapKey(key))} + return $mut$FldType{proxy: m.proxy.Key(wasmtypes.$FldMapKey$+ToBytes(key))} } `, } diff --git a/tools/schema/generator/rstemplates/proxy.go b/tools/schema/generator/rstemplates/proxy.go index b391095c33..11073ee7cc 100644 --- a/tools/schema/generator/rstemplates/proxy.go +++ b/tools/schema/generator/rstemplates/proxy.go @@ -48,15 +48,15 @@ $#if this proxyMapThis proxyMapOther `, // ******************************* "proxyMapThis": ` - pub fn $fld_name(&self) -> Map$fldMapKey$+To$mut$FldType { - Map$fldMapKey$+To$mut$FldType { obj_id: self.id } + pub fn $fld_name(&self) -> Map$FldMapKey$+To$mut$FldType { + Map$FldMapKey$+To$mut$FldType { obj_id: self.id } } `, // ******************************* "proxyMapOther": ` - pub fn $fld_name(&self) -> Map$fldMapKey$+To$mut$FldType { + pub fn $fld_name(&self) -> Map$FldMapKey$+To$mut$FldType { let map_id = get_object_id(self.id, $varID, TYPE_MAP); - Map$fldMapKey$+To$mut$FldType { obj_id: map_id } + Map$FldMapKey$+To$mut$FldType { obj_id: map_id } } `, // ******************************* diff --git a/tools/schema/generator/rstemplates/typedefs.go b/tools/schema/generator/rstemplates/typedefs.go index c47174c021..d5e2677c24 100644 --- a/tools/schema/generator/rstemplates/typedefs.go +++ b/tools/schema/generator/rstemplates/typedefs.go @@ -84,7 +84,7 @@ $#emit setVarType `, // ******************************* "typedefProxyMap": ` -$#set proxy Map$fldMapKey$+To$mut$FldType +$#set proxy Map$FldMapKey$+To$mut$FldType $#if exist else typedefProxyMapNew `, // ******************************* diff --git a/tools/schema/generator/tsclienttemplates/service.go b/tools/schema/generator/tsclienttemplates/service.go index 719bce8953..842cae48b9 100644 --- a/tools/schema/generator/tsclienttemplates/service.go +++ b/tools/schema/generator/tsclienttemplates/service.go @@ -127,7 +127,7 @@ $#if basetype callResultGetterBasic callResultGetterStruct $fldName(): Map<$fldKeyLangType, $fldLangType> { const res = new Map<$fldKeyLangType, $fldLangType>(); this.forEach((key, val) => { - res.set(this.to$fldMapKey(key), this.to$FldType(val)); + res.set(this.to$FldMapKey(key), this.to$FldType(val)); }); return res; } diff --git a/tools/schema/generator/tstemplates/alltemplates.go b/tools/schema/generator/tstemplates/alltemplates.go index f30640fe55..958deb9128 100644 --- a/tools/schema/generator/tstemplates/alltemplates.go +++ b/tools/schema/generator/tstemplates/alltemplates.go @@ -29,78 +29,39 @@ var Templates = []map[string]string{ var TypeDependent = model.StringMapMap{ "fldLangType": { - "Address": "wasmlib.ScAddress", - "AgentID": "wasmlib.ScAgentID", + "Address": "wasmtypes.ScAddress", + "AgentID": "wasmtypes.ScAgentID", "Bool": "bool", "Bytes": "u8[]", - "ChainID": "wasmlib.ScChainID", - "Color": "wasmlib.ScColor", - "Hash": "wasmlib.ScHash", - "Hname": "wasmlib.ScHname", + "ChainID": "wasmtypes.ScChainID", + "Color": "wasmtypes.ScColor", + "Hash": "wasmtypes.ScHash", + "Hname": "wasmtypes.ScHname", "Int8": "i8", "Int16": "i16", "Int32": "i32", "Int64": "i64", - "RequestID": "wasmlib.ScRequestID", + "RequestID": "wasmtypes.ScRequestID", "String": "string", "Uint8": "u8", "Uint16": "u16", "Uint32": "u32", "Uint64": "u64", }, - "fldTypeID": { - "Address": "wasmlib.TYPE_ADDRESS", - "AgentID": "wasmlib.TYPE_AGENT_ID", - "Bool": "wasmlib.TYPE_BOOL", - "ChainID": "wasmlib.TYPE_CHAIN_ID", - "Color": "wasmlib.TYPE_COLOR", - "Hash": "wasmlib.TYPE_HASH", - "Hname": "wasmlib.TYPE_HNAME", - "Int8": "wasmlib.TYPE_INT8", - "Int16": "wasmlib.TYPE_INT16", - "Int32": "wasmlib.TYPE_INT32", - "Int64": "wasmlib.TYPE_INT64", - "RequestID": "wasmlib.TYPE_REQUEST_ID", - "String": "wasmlib.TYPE_STRING", - "Uint8": "wasmlib.TYPE_INT8", - "Uint16": "wasmlib.TYPE_INT16", - "Uint32": "wasmlib.TYPE_INT32", - "Uint64": "wasmlib.TYPE_INT64", - "": "wasmlib.TYPE_BYTES", - }, - "fldToKey32": { - "Address": "key.getKeyID()", - "AgentID": "key.getKeyID()", - "Bool": "???cannot use Bool as map key", - "ChainID": "key.getKeyID()", - "Color": "key.getKeyID()", - "Hash": "key.getKeyID()", - "Hname": "key.getKeyID()", - "Int8": "wasmlib.getKeyIDFromUint64(key as u64, 1)", - "Int16": "wasmlib.getKeyIDFromUint64(key as u64, 2)", - "Int32": "wasmlib.getKeyIDFromUint64(key as u64, 4)", - "Int64": "wasmlib.getKeyIDFromUint64(key as u64, 8)", - "RequestID": "key.getKeyID()", - "String": "wasmlib.Key32.fromString(key)", - "Uint8": "wasmlib.getKeyIDFromUint64(key as u64, 1)", - "Uint16": "wasmlib.getKeyIDFromUint64(key as u64, 2)", - "Uint32": "wasmlib.getKeyIDFromUint64(key as u64, 4)", - "Uint64": "wasmlib.getKeyIDFromUint64(key, 8)", - }, "fldTypeInit": { - "Address": "new wasmlib.ScAddress()", - "AgentID": "new wasmlib.ScAgentID()", + "Address": "new wasmtypes.ScAddress()", + "AgentID": "wasmtypes.agentIDFromBytes(null)", "Bool": "false", "Bytes": "[]", - "ChainID": "new wasmlib.ScChainID()", - "Color": "new wasmlib.ScColor(0)", - "Hash": "new wasmlib.ScHash()", - "Hname": "new wasmlib.ScHname(0)", + "ChainID": "new wasmtypes.ScChainID()", + "Color": "new wasmtypes.ScColor(0)", + "Hash": "new wasmtypes.ScHash()", + "Hname": "new wasmtypes.ScHname(0)", "Int8": "0", "Int16": "0", "Int32": "0", "Int64": "0", - "RequestID": "new wasmlib.ScRequestID()", + "RequestID": "new wasmtypes.ScRequestID()", "String": "\"\"", "Uint8": "0", "Uint16": "0", @@ -110,18 +71,13 @@ var TypeDependent = model.StringMapMap{ } var common = map[string]string{ - // ******************************* - "initGlobals": ` -$#set arrayTypeID wasmlib.TYPE_ARRAY -$#if core setArrayTypeID -`, - // ******************************* - "setArrayTypeID": ` -$#set arrayTypeID wasmlib.TYPE_ARRAY16 -`, // ******************************* "importWasmLib": ` import * as wasmlib from "wasmlib"; +`, + // ******************************* + "importWasmTypes": ` +import * as wasmtypes from "wasmlib/wasmtypes"; `, // ******************************* "importSc": ` @@ -130,6 +86,7 @@ import * as sc from "./index"; // ******************************* "tsImports": ` $#emit importWasmLib +$#emit importWasmTypes $#emit importSc `, // ******************************* @@ -138,14 +95,5 @@ $#emit importSc "extends": "assemblyscript/std/assembly.json", "include": ["./*.ts"] } -`, - // ******************************* - "setVarType": ` -$#set varType wasmlib.TYPE_MAP -$#if array setVarTypeArray -`, - // ******************************* - "setVarTypeArray": ` -$#set varType $arrayTypeID|$fldTypeID `, } diff --git a/tools/schema/generator/tstemplates/consts.go b/tools/schema/generator/tstemplates/consts.go index 5f56e70bf0..62c2f4ef0f 100644 --- a/tools/schema/generator/tstemplates/consts.go +++ b/tools/schema/generator/tstemplates/consts.go @@ -3,11 +3,11 @@ package tstemplates var constsTs = map[string]string{ // ******************************* "consts.ts": ` -$#emit importWasmLib +$#emit importWasmTypes export const ScName = "$scName"; export const ScDescription = "$scDesc"; -export const HScName = new wasmlib.ScHname(0x$hscName); +export const HScName = new wasmtypes.ScHname(0x$hscName); $#if params constParams $#if results constResults $#if state constState @@ -44,6 +44,6 @@ export const $Kind$FuncName$funcPad = "$funcName"; `, // ******************************* "constHFunc": ` -export const H$Kind$FuncName$funcPad = new wasmlib.ScHname(0x$hFuncName); +export const H$Kind$FuncName$funcPad = new wasmtypes.ScHname(0x$hFuncName); `, } diff --git a/tools/schema/generator/tstemplates/contract.go b/tools/schema/generator/tstemplates/contract.go index 51788b0edb..7bd087692d 100644 --- a/tools/schema/generator/tstemplates/contract.go +++ b/tools/schema/generator/tstemplates/contract.go @@ -43,27 +43,27 @@ $#if events PackageEventsExist `, // ******************************* "ImmutableFuncNameParams": ` - params: sc.Immutable$FuncName$+Params = new sc.Immutable$FuncName$+Params(); + params: sc.Immutable$FuncName$+Params = new sc.Immutable$FuncName$+Params(wasmlib.paramsProxy()); `, // ******************************* "MutableFuncNameParams": ` - params: sc.Mutable$FuncName$+Params = new sc.Mutable$FuncName$+Params(); + params: sc.Mutable$FuncName$+Params = new sc.Mutable$FuncName$+Params(wasmlib.ScView.nilProxy); `, // ******************************* "ImmutableFuncNameResults": ` - results: sc.Immutable$FuncName$+Results = new sc.Immutable$FuncName$+Results(); + results: sc.Immutable$FuncName$+Results = new sc.Immutable$FuncName$+Results(wasmlib.ScView.nilProxy); `, // ******************************* "MutableFuncNameResults": ` - results: sc.Mutable$FuncName$+Results = new sc.Mutable$FuncName$+Results(); + results: sc.Mutable$FuncName$+Results = new sc.Mutable$FuncName$+Results(wasmlib.ScView.nilProxy); `, // ******************************* "ImmutablePackageState": ` - state: sc.Immutable$Package$+State = new sc.Immutable$Package$+State(); + state: sc.Immutable$Package$+State = new sc.Immutable$Package$+State(wasmlib.ScState.proxy()); `, // ******************************* "MutablePackageState": ` - state: sc.Mutable$Package$+State = new sc.Mutable$Package$+State(); + state: sc.Mutable$Package$+State = new sc.Mutable$Package$+State(wasmlib.ScState.proxy()); `, // ******************************* "FuncNameForCall": ` @@ -71,26 +71,23 @@ $#emit setupInitFunc $#if separator newline $#set separator $true static $funcName(ctx: wasmlib.Sc$Kind$+CallContext): $FuncName$+Call { -$#set paramsID null -$#set resultsID null -$#if param setParamsID -$#if result setResultsID $#if ptrs setPtrs noPtrs } `, // ******************************* "setPtrs": ` - let f = new $FuncName$+Call(); - f.func.setPtrs($paramsID, $resultsID); + const f = new $FuncName$+Call(); +$#if param initParams +$#if result initResults return f; `, // ******************************* - "setParamsID": ` -$#set paramsID f.params + "initParams": ` + f.params = new sc.Mutable$FuncName$+Params(wasmlib.newCallParamsProxy(f.func)); `, // ******************************* - "setResultsID": ` -$#set resultsID f.results + "initResults": ` + f.results = new sc.Immutable$FuncName$+Results(wasmlib.newCallResultsProxy(f.func)); `, // ******************************* "noPtrs": ` diff --git a/tools/schema/generator/tstemplates/events.go b/tools/schema/generator/tstemplates/events.go index 1712275c9e..b89140e08b 100644 --- a/tools/schema/generator/tstemplates/events.go +++ b/tools/schema/generator/tstemplates/events.go @@ -4,6 +4,7 @@ var eventsTs = map[string]string{ // ******************************* "events.ts": ` $#emit importWasmLib +$#emit importWasmTypes $#set TypeName $Package$+Events export class $TypeName { @@ -17,9 +18,9 @@ $#set separator $#each event eventParam $evtName($params): void { - new wasmlib.EventEncoder("$package.$evtName"). + const evt = new wasmlib.EventEncoder("$package.$evtName"); $#each event eventEmit - emit(); + evt.emit(); } `, // ******************************* @@ -29,6 +30,6 @@ $#set separator , `, // ******************************* "eventEmit": ` - $fldType($fldName). + evt.encode(wasmtypes.$fldType$+ToString($fldName)); `, } diff --git a/tools/schema/generator/tstemplates/index.go b/tools/schema/generator/tstemplates/index.go index 4bb4725cad..0b29c496c2 100644 --- a/tools/schema/generator/tstemplates/index.go +++ b/tools/schema/generator/tstemplates/index.go @@ -7,11 +7,12 @@ $#if core else exportName export * from "./consts"; export * from "./contract"; $#if events exportEvents -$#if core else exportKeys $#if core else exportLib $#if params exportParams $#if results exportResults -$#if core else exportRest +$#if core else exportState +$#if structs exportStructs +$#if typedefs exportTypedefs `, // ******************************* "exportName": ` @@ -21,10 +22,6 @@ export * from "./$package"; // ******************************* "exportEvents": ` export * from "./events"; -`, - // ******************************* - "exportKeys": ` -export * from "./keys"; `, // ******************************* "exportLib": ` @@ -39,10 +36,8 @@ export * from "./params"; export * from "./results"; `, // ******************************* - "exportRest": ` + "exportState": ` export * from "./state"; -$#if structs exportStructs -$#if typedefs exportTypedefs `, // ******************************* "exportStructs": ` diff --git a/tools/schema/generator/tstemplates/keys.go b/tools/schema/generator/tstemplates/keys.go index 6aaa919ad5..18c57b1788 100644 --- a/tools/schema/generator/tstemplates/keys.go +++ b/tools/schema/generator/tstemplates/keys.go @@ -3,34 +3,11 @@ package tstemplates var keysTs = map[string]string{ // ******************************* "keys.ts": ` -$#emit tsImports -$#set constPrefix Param $#each params constFieldIdx - -$#set constPrefix Result -$#each results constFieldIdx - -$#set constPrefix State -$#each state constFieldIdx - -export let keyMap: string[] = [ -$#set constPrefix Param -$#each params constFieldKey -$#set constPrefix Result -$#each results constFieldKey -$#set constPrefix State -$#each state constFieldKey -]; - -export let idxMap: wasmlib.Key32[] = new Array(keyMap.length); `, // ******************************* "constFieldIdx": ` -export const Idx$constPrefix$FldName$fldPad = $fldIndex; -`, - // ******************************* - "constFieldKey": ` - sc.$constPrefix$FldName, +export const IdxParam$FldName$fldPad = $fldIndex; `, } diff --git a/tools/schema/generator/tstemplates/lib.go b/tools/schema/generator/tstemplates/lib.go index fa20ef1595..4a13c90a59 100644 --- a/tools/schema/generator/tstemplates/lib.go +++ b/tools/schema/generator/tstemplates/lib.go @@ -12,10 +12,6 @@ export function on_call(index: i32): void { export function on_load(): void { let exports = new wasmlib.ScExports(); $#each func libExportFunc - - for (let i = 0; i < sc.keyMap.length; i++) { - sc.idxMap[i] = wasmlib.Key32.fromString(sc.keyMap[i]); - } } $#each func libThunk `, @@ -28,29 +24,28 @@ $#each func libThunk function $kind$FuncName$+Thunk(ctx: wasmlib.Sc$Kind$+Context): void { ctx.log("$package.$kind$FuncName"); -$#emit accessCheck let f = new sc.$FuncName$+Context(); -$#if param ImmutableFuncNameParamsInit -$#if result MutableFuncNameResultsInit - f.state.mapID = wasmlib.OBJ_ID_STATE; +$#if result initResultsDict +$#emit accessCheck $#each mandatory requireMandatory sc.$kind$FuncName(ctx, f); +$#if result returnResultDict ctx.log("$package.$kind$FuncName ok"); } `, // ******************************* - "ImmutableFuncNameParamsInit": ` - f.params.mapID = wasmlib.OBJ_ID_PARAMS; + "initResultsDict": ` + const results = new wasmlib.ScDict([]); + f.results = new sc.Mutable$FuncName$+Results(results.asProxy()); `, // ******************************* - "MutableFuncNameResultsInit": ` - f.results.mapID = wasmlib.OBJ_ID_RESULTS; + "returnResultDict": ` + ctx.results(results); `, // ******************************* "requireMandatory": ` ctx.require(f.params.$fldName().exists(), "missing mandatory $fldName"); `, - // ******************************* "accessCheck": ` $#set accessFinalize accessOther @@ -85,7 +80,7 @@ $#set accessFinalize accessDone // ******************************* "accessOther": ` $#if funcAccessComment accessComment - let access = ctx.state().getAgentID(wasmlib.Key32.fromString("$funcAccess")); + const access = f.state.$funcAccess(); ctx.require(access.exists(), "access not set: $funcAccess"); ctx.require(ctx.caller().equals(access.value()), "no permission"); diff --git a/tools/schema/generator/tstemplates/params.go b/tools/schema/generator/tstemplates/params.go index 8216ac2135..1ed8053884 100644 --- a/tools/schema/generator/tstemplates/params.go +++ b/tools/schema/generator/tstemplates/params.go @@ -23,7 +23,7 @@ $#if param paramsProxyStruct $#set TypeName $mut$FuncName$+Params $#each param proxyContainers -export class $TypeName extends wasmlib.ScMapID { +export class $TypeName extends wasmtypes.ScProxy { $#set separator $false $#each param proxyMethods } diff --git a/tools/schema/generator/tstemplates/proxy.go b/tools/schema/generator/tstemplates/proxy.go index 2e2f1ddaac..9174310b06 100644 --- a/tools/schema/generator/tstemplates/proxy.go +++ b/tools/schema/generator/tstemplates/proxy.go @@ -10,14 +10,7 @@ $#if map typedefProxyMap "proxyMethods": ` $#if separator newline $#set separator $true -$#set varID wasmlib.Key32.fromString(sc.$Kind$FldName) -$#if init setInitVarID -$#if core setCoreVarID $#if array proxyArray proxyMethods2 -`, - // ******************************* - "setInitVarID": ` -$#set varID sc.idxMap[sc.Idx$Kind$FldName] `, // ******************************* "proxyMethods2": ` @@ -25,21 +18,17 @@ $#if map proxyMap proxyMethods3 `, // ******************************* "proxyMethods3": ` -$#if basetype proxyBaseType proxyMethods4 +$#if basetype proxyBaseType proxyOtherType `, // ******************************* - "proxyMethods4": ` + // TODO when will this be called, and if so, fix it + "proxyOtherType": ` $#if typedef proxyTypeDef proxyStruct -`, - // ******************************* - "setCoreVarID": ` -$#set varID wasmlib.Key32.fromString(sc.$Kind$FldName) `, // ******************************* "proxyArray": ` $fldName(): sc.ArrayOf$mut$FldType { - let arrID = wasmlib.getObjectID(this.mapID, $varID, $arrayTypeID|$fldTypeID); - return new sc.ArrayOf$mut$FldType(arrID); + return new sc.ArrayOf$mut$FldType(this.proxy.root(sc.$Kind$FldName)); } `, // ******************************* @@ -48,32 +37,32 @@ $#if this proxyMapThis proxyMapOther `, // ******************************* "proxyMapThis": ` - $fldName(): sc.Map$fldMapKey$+To$mut$FldType { - return new sc.Map$fldMapKey$+To$mut$FldType(this.mapID); + $fldName(): sc.Map$FldMapKey$+To$mut$FldType { + return new sc.Map$FldMapKey$+To$mut$FldType(this.proxy); } `, // ******************************* "proxyMapOther": ` - $fldName(): sc.Map$fldMapKey$+To$mut$FldType { - let mapID = wasmlib.getObjectID(this.mapID, $varID, wasmlib.TYPE_MAP); - return new sc.Map$fldMapKey$+To$mut$FldType(mapID); + $fldName(): sc.Map$FldMapKey$+To$mut$FldType { + return new sc.Map$FldMapKey$+To$mut$FldType(this.proxy.root(sc.$Kind$FldName)); } `, // ******************************* "proxyBaseType": ` - $fldName(): wasmlib.Sc$mut$FldType { - return new wasmlib.Sc$mut$FldType(this.mapID, $varID); + $fldName(): wasmtypes.Sc$mut$FldType { + return new wasmtypes.Sc$mut$FldType(this.proxy.root(sc.$Kind$FldName)); } `, // ******************************* + // TODO when will this be called, and if so, fix it "proxyTypeDef": ` -$#emit setVarType $oldName(): sc.$mut$OldType { let subID = wasmlib.getObjectID(this.mapID, $varID, $varType); return new sc.$mut$OldType(subID); } `, // ******************************* + // TODO when will this be called, and if so, fix it "proxyStruct": ` $fldName(): sc.$mut$FldType { return new sc.$mut$FldType(this.mapID, $varID); diff --git a/tools/schema/generator/tstemplates/results.go b/tools/schema/generator/tstemplates/results.go index 61dabe5049..f0594f6c56 100644 --- a/tools/schema/generator/tstemplates/results.go +++ b/tools/schema/generator/tstemplates/results.go @@ -23,7 +23,7 @@ $#if result resultsProxyStruct $#set TypeName $mut$FuncName$+Results $#each result proxyContainers -export class $TypeName extends wasmlib.ScMapID { +export class $TypeName extends wasmtypes.ScProxy { $#set separator $false $#each result proxyMethods } diff --git a/tools/schema/generator/tstemplates/state.go b/tools/schema/generator/tstemplates/state.go index 979756a368..b44d6e5908 100644 --- a/tools/schema/generator/tstemplates/state.go +++ b/tools/schema/generator/tstemplates/state.go @@ -15,7 +15,7 @@ $#emit stateProxyStruct $#set TypeName $mut$Package$+State $#each state proxyContainers -export class $TypeName extends wasmlib.ScMapID { +export class $TypeName extends wasmtypes.ScProxy { $#set separator $false $#if mut stateProxyImmutableFunc $#each state proxyMethods @@ -25,9 +25,7 @@ $#each state proxyMethods "stateProxyImmutableFunc": ` $#set separator $true asImmutable(): sc.Immutable$Package$+State { - const imm = new sc.Immutable$Package$+State(); - imm.mapID = this.mapID; - return imm; + return new sc.Immutable$Package$+State(this.proxy); } `, } diff --git a/tools/schema/generator/tstemplates/structs.go b/tools/schema/generator/tstemplates/structs.go index 254d8b329d..6be85664ce 100644 --- a/tools/schema/generator/tstemplates/structs.go +++ b/tools/schema/generator/tstemplates/structs.go @@ -4,6 +4,7 @@ var structsTs = map[string]string{ // ******************************* "structs.ts": ` $#emit importWasmLib +$#emit importWasmTypes $#each structs structType `, // ******************************* @@ -12,18 +13,18 @@ $#each structs structType export class $StrName { $#each struct structField - static fromBytes(bytes: u8[]): $StrName { - let decode = new wasmlib.BytesDecoder(bytes); - let data = new $StrName(); + static fromBytes(buf: u8[]|null): $StrName { + const dec = new wasmtypes.WasmDecoder(buf); + const data = new $StrName(); $#each struct structDecode - decode.close(); + dec.close(); return data; } bytes(): u8[] { - return new wasmlib.BytesEncoder(). + const enc = new wasmtypes.WasmEncoder(); $#each struct structEncode - data(); + return enc.buf(); } } $#set mut Immutable @@ -37,32 +38,25 @@ $#emit structMethods `, // ******************************* "structDecode": ` - data.$fldName$fldPad = decode.$fldType(); + data.$fldName$fldPad = wasmtypes.$fldType$+Decode(dec); `, // ******************************* "structEncode": ` - $fldType(this.$fldName). + wasmtypes.$fldType$+Encode(enc, this.$fldName); `, // ******************************* "structMethods": ` -export class $mut$StrName { - objID: i32; - keyID: wasmlib.Key32; - - constructor(objID: i32, keyID: wasmlib.Key32) { - this.objID = objID; - this.keyID = keyID; - } +export class $mut$StrName extends wasmtypes.ScProxy { $#if mut structMethodDelete exists(): boolean { - return wasmlib.exists(this.objID, this.keyID, wasmlib.TYPE_BYTES); + return this.proxy.exists(); } $#if mut structMethodSetValue value(): $StrName { - return $StrName.fromBytes(wasmlib.getBytes(this.objID, this.keyID, wasmlib.TYPE_BYTES)); + return $StrName.fromBytes(this.proxy.get()); } } `, @@ -70,14 +64,14 @@ $#if mut structMethodSetValue "structMethodDelete": ` delete(): void { - wasmlib.delKey(this.objID, this.keyID, wasmlib.TYPE_BYTES); + this.proxy.delete(); } `, // ******************************* "structMethodSetValue": ` setValue(value: $StrName): void { - wasmlib.setBytes(this.objID, this.keyID, wasmlib.TYPE_BYTES, value.bytes()); + this.proxy.set(value.bytes()); } `, } diff --git a/tools/schema/generator/tstemplates/typedefs.go b/tools/schema/generator/tstemplates/typedefs.go index 5ca4fc2303..2d7f8a74cc 100644 --- a/tools/schema/generator/tstemplates/typedefs.go +++ b/tools/schema/generator/tstemplates/typedefs.go @@ -33,106 +33,85 @@ $#if exist else typedefProxyArrayNew // ******************************* "typedefProxyArrayNew": ` -export class $proxy { - objID: i32; - - constructor(objID: i32) { - this.objID = objID; - } -$#if mut typedefProxyArrayClear +export class $proxy extends wasmtypes.ScProxy { +$#if mut typedefProxyArrayMut length(): u32 { - return wasmlib.getLength(this.objID); + return this.proxy.length(); } $#if basetype typedefProxyArrayNewBaseType typedefProxyArrayNewOtherType } $#set exist $proxy `, // ******************************* - "typedefProxyArrayClear": ` + "typedefProxyArrayMut": ` +$#if basetype typedefProxyArrayAppendBaseType typedefProxyArrayAppendOtherType clear(): void { - wasmlib.clear(this.objID); + this.proxy.clearArray(); } `, // ******************************* - "typedefProxyArrayNewBaseType": ` + "typedefProxyArrayAppendBaseType": ` - get$FldType(index: u32): wasmlib.Sc$mut$FldType { - return new wasmlib.Sc$mut$FldType(this.objID, new wasmlib.Key32(index as i32)); - } + append$FldType(): wasmtypes.Sc$mut$FldType { + return new wasmtypes.Sc$mut$FldType(this.proxy.append()); + } `, // ******************************* - "typedefProxyArrayNewOtherType": ` -$#if typedef typedefProxyArrayNewOtherTypeTypeDef typedefProxyArrayNewOtherTypeStruct + "typedefProxyArrayAppendOtherType": ` + + append$FldType(): sc.$mut$FldType { + return new sc.$mut$FldType(this.proxy.append()); + } `, // ******************************* - "typedefProxyArrayNewOtherTypeTypeDef": ` -$#emit setVarType + "typedefProxyArrayNewBaseType": ` - get$OldType(index: u32): sc.$mut$OldType { - let subID = wasmlib.getObjectID(this.objID, new wasmlib.Key32(index as i32), $varType); - return new sc.$mut$OldType(subID); - } + get$FldType(index: u32): wasmtypes.Sc$mut$FldType { + return new wasmtypes.Sc$mut$FldType(this.proxy.index(index)); + } `, // ******************************* - "typedefProxyArrayNewOtherTypeStruct": ` + "typedefProxyArrayNewOtherType": ` get$FldType(index: u32): sc.$mut$FldType { - return new sc.$mut$FldType(this.objID, new wasmlib.Key32(index as i32)); + return new sc.$mut$FldType(this.proxy.index(index)); } `, // ******************************* "typedefProxyMap": ` -$#set proxy Map$fldMapKey$+To$mut$FldType +$#set proxy Map$FldMapKey$+To$mut$FldType $#if exist else typedefProxyMapNew `, // ******************************* "typedefProxyMapNew": ` -export class $proxy { - objID: i32; - - constructor(objID: i32) { - this.objID = objID; - } -$#if mut typedefProxyMapClear +export class $proxy extends wasmtypes.ScProxy { +$#if mut typedefProxyMapMut $#if basetype typedefProxyMapNewBaseType typedefProxyMapNewOtherType } $#set exist $proxy `, // ******************************* - "typedefProxyMapClear": ` + "typedefProxyMapMut": ` clear(): void { - wasmlib.clear(this.objID); + this.proxy.clearMap(); } `, // ******************************* "typedefProxyMapNewBaseType": ` - get$FldType(key: $fldKeyLangType): wasmlib.Sc$mut$FldType { - return new wasmlib.Sc$mut$FldType(this.objID, $fldKeyToKey32); + get$FldType(key: $fldKeyLangType): wasmtypes.Sc$mut$FldType { + return new wasmtypes.Sc$mut$FldType(this.proxy.key(wasmtypes.$fldMapKey$+ToBytes(key))); } `, // ******************************* "typedefProxyMapNewOtherType": ` -$#if typedef typedefProxyMapNewOtherTypeTypeDef typedefProxyMapNewOtherTypeStruct -`, - // ******************************* - "typedefProxyMapNewOtherTypeTypeDef": ` -$#emit setVarType - - get$OldType(key: $oldKeyLangType): sc.$mut$OldType { - let subID = wasmlib.getObjectID(this.objID, $oldKeyToKey32, $varType); - return new sc.$mut$OldType(subID); - } -`, - // ******************************* - "typedefProxyMapNewOtherTypeStruct": ` get$FldType(key: $fldKeyLangType): sc.$mut$FldType { - return new sc.$mut$FldType(this.objID, $fldKeyToKey32); + return new sc.$mut$FldType(this.proxy.key(wasmtypes.$fldMapKey$+ToBytes(key))); } `, } From 49374da8c1bb10700a196e8f22eaa2affd1f0f8b Mon Sep 17 00:00:00 2001 From: "Bruno A. dos Santos" Date: Sun, 30 Jan 2022 22:56:31 +0100 Subject: [PATCH 052/111] Added logic to load wasm SC from current path --- packages/vm/wasmsolo/solocontext.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/packages/vm/wasmsolo/solocontext.go b/packages/vm/wasmsolo/solocontext.go index 479ce39b22..3b59aefd59 100644 --- a/packages/vm/wasmsolo/solocontext.go +++ b/packages/vm/wasmsolo/solocontext.go @@ -352,6 +352,10 @@ func (ctx *SoloContext) upload(keyPair *ed25519.KeyPair) { exists, _ := util.ExistsFilePath(rsFile) if exists { wasmFile = rsFile + } else { + rsFile := wasmFile + exists, _ = util.ExistsFilePath(rsFile) + wasmFile = rsFile } // try Go Wasm file? @@ -360,6 +364,12 @@ func (ctx *SoloContext) upload(keyPair *ed25519.KeyPair) { exists, _ = util.ExistsFilePath(goFile) if exists { wasmFile = goFile + } else { + goFile = ctx.scName + "_go.wasm" + exists, _ = util.ExistsFilePath(goFile) + if exists { + wasmFile = goFile + } } } @@ -369,6 +379,12 @@ func (ctx *SoloContext) upload(keyPair *ed25519.KeyPair) { exists, _ = util.ExistsFilePath(tsFile) if exists { wasmFile = tsFile + } else { + tsFile = ctx.scName + "_ts.wasm" + exists, _ = util.ExistsFilePath(tsFile) + if exists { + wasmFile = tsFile + } } } From f2b059d9c222e6b041a35f9ca5c1a51f8d6849df Mon Sep 17 00:00:00 2001 From: Eric Hop Date: Sun, 30 Jan 2022 18:13:13 -0800 Subject: [PATCH 053/111] Typescript refactoring complete --- .../ts/donatewithfeedback/structs.ts | 6 +- .../fairauction/ts/fairauction/structs.ts | 12 +-- .../fairroulette/ts/fairroulette/structs.ts | 6 +- .../inccounter/go/inccounter/inccounter.go | 22 +++--- .../inccounter/ts/inccounter/inccounter.ts | 23 +++--- .../testwasmlib/ts/testwasmlib/testwasmlib.ts | 30 ++++++- .../tokenregistry/ts/tokenregistry/structs.ts | 6 +- packages/wasmvm/wasmhost/wasmtosandbox.go | 2 +- packages/wasmvm/wasmlib/go/wasmlib/dict.go | 6 +- .../wasmlib/go/wasmlib/wasmtypes/codec.go | 5 +- .../wasmlib/go/wasmlib/wasmtypes/proxy.go | 24 ++---- packages/wasmvm/wasmlib/ts/wasmlib/assets.ts | 2 +- .../wasmvm/wasmlib/ts/wasmlib/contract.ts | 2 +- packages/wasmvm/wasmlib/ts/wasmlib/dict.ts | 54 +++++++++++-- .../wasmlib/ts/wasmlib/package-lock.json | 78 ++++++++++++++++++- .../wasmvm/wasmlib/ts/wasmlib/package.json | 4 +- .../ts/wasmlib/wasmrequests/structs.ts | 24 +++--- .../wasmlib/ts/wasmlib/wasmtypes/codec.ts | 15 ++-- .../wasmlib/ts/wasmlib/wasmtypes/package.json | 4 +- .../wasmlib/ts/wasmlib/wasmtypes/proxy.ts | 34 ++++---- packages/wasmvm/wasmsolo/solosandbox.go | 4 +- tools/schema/generator/tstemplates/structs.go | 4 +- 22 files changed, 255 insertions(+), 112 deletions(-) diff --git a/contracts/wasm/donatewithfeedback/ts/donatewithfeedback/structs.ts b/contracts/wasm/donatewithfeedback/ts/donatewithfeedback/structs.ts index 2e569735c4..42232806a7 100644 --- a/contracts/wasm/donatewithfeedback/ts/donatewithfeedback/structs.ts +++ b/contracts/wasm/donatewithfeedback/ts/donatewithfeedback/structs.ts @@ -16,7 +16,7 @@ export class Donation { timestamp : u64 = 0; // when the donation took place static fromBytes(buf: u8[]|null): Donation { - const dec = new wasmtypes.WasmDecoder(buf); + const dec = new wasmtypes.WasmDecoder(buf==null ? [] : buf); const data = new Donation(); data.amount = wasmtypes.uint64Decode(dec); data.donator = wasmtypes.agentIDDecode(dec); @@ -40,7 +40,7 @@ export class Donation { export class ImmutableDonation extends wasmtypes.ScProxy { - exists(): boolean { + exists(): bool { return this.proxy.exists(); } @@ -55,7 +55,7 @@ export class MutableDonation extends wasmtypes.ScProxy { this.proxy.delete(); } - exists(): boolean { + exists(): bool { return this.proxy.exists(); } diff --git a/contracts/wasm/fairauction/ts/fairauction/structs.ts b/contracts/wasm/fairauction/ts/fairauction/structs.ts index 6b3321c4ed..59e0d2a741 100644 --- a/contracts/wasm/fairauction/ts/fairauction/structs.ts +++ b/contracts/wasm/fairauction/ts/fairauction/structs.ts @@ -22,7 +22,7 @@ export class Auction { whenStarted : u64 = 0; // timestamp when auction started static fromBytes(buf: u8[]|null): Auction { - const dec = new wasmtypes.WasmDecoder(buf); + const dec = new wasmtypes.WasmDecoder(buf==null ? [] : buf); const data = new Auction(); data.color = wasmtypes.colorDecode(dec); data.creator = wasmtypes.agentIDDecode(dec); @@ -58,7 +58,7 @@ export class Auction { export class ImmutableAuction extends wasmtypes.ScProxy { - exists(): boolean { + exists(): bool { return this.proxy.exists(); } @@ -73,7 +73,7 @@ export class MutableAuction extends wasmtypes.ScProxy { this.proxy.delete(); } - exists(): boolean { + exists(): bool { return this.proxy.exists(); } @@ -92,7 +92,7 @@ export class Bid { timestamp : u64 = 0; // timestamp of most recent bid static fromBytes(buf: u8[]|null): Bid { - const dec = new wasmtypes.WasmDecoder(buf); + const dec = new wasmtypes.WasmDecoder(buf==null ? [] : buf); const data = new Bid(); data.amount = wasmtypes.uint64Decode(dec); data.index = wasmtypes.uint32Decode(dec); @@ -112,7 +112,7 @@ export class Bid { export class ImmutableBid extends wasmtypes.ScProxy { - exists(): boolean { + exists(): bool { return this.proxy.exists(); } @@ -127,7 +127,7 @@ export class MutableBid extends wasmtypes.ScProxy { this.proxy.delete(); } - exists(): boolean { + exists(): bool { return this.proxy.exists(); } diff --git a/contracts/wasm/fairroulette/ts/fairroulette/structs.ts b/contracts/wasm/fairroulette/ts/fairroulette/structs.ts index 0f8f9886eb..3c1840b7fa 100644 --- a/contracts/wasm/fairroulette/ts/fairroulette/structs.ts +++ b/contracts/wasm/fairroulette/ts/fairroulette/structs.ts @@ -14,7 +14,7 @@ export class Bet { number : u16 = 0; static fromBytes(buf: u8[]|null): Bet { - const dec = new wasmtypes.WasmDecoder(buf); + const dec = new wasmtypes.WasmDecoder(buf==null ? [] : buf); const data = new Bet(); data.amount = wasmtypes.uint64Decode(dec); data.better = wasmtypes.agentIDDecode(dec); @@ -34,7 +34,7 @@ export class Bet { export class ImmutableBet extends wasmtypes.ScProxy { - exists(): boolean { + exists(): bool { return this.proxy.exists(); } @@ -49,7 +49,7 @@ export class MutableBet extends wasmtypes.ScProxy { this.proxy.delete(); } - exists(): boolean { + exists(): bool { return this.proxy.exists(); } diff --git a/contracts/wasm/inccounter/go/inccounter/inccounter.go b/contracts/wasm/inccounter/go/inccounter/inccounter.go index 6af9bcde79..f259354fbc 100644 --- a/contracts/wasm/inccounter/go/inccounter/inccounter.go +++ b/contracts/wasm/inccounter/go/inccounter/inccounter.go @@ -219,27 +219,29 @@ func localStatePost(ctx wasmlib.ScFuncContext, nr int64) { func vliSave(ctx wasmlib.ScFuncContext, name string, value int64) { enc := wasmtypes.NewWasmEncoder() - state := wasmlib.ScState{} + state := ctx.RawState() key := []byte(name) state.Set(key, enc.VliEncode(value).Buf()) - dec := wasmtypes.NewWasmDecoder(state.Get(key)) - retrieved := wasmtypes.Int64Decode(dec) - if retrieved != value { + buf := state.Get(key) + dec := wasmtypes.NewWasmDecoder(buf) + val := wasmtypes.Int64Decode(dec) + if val != value { ctx.Log(name + " in : " + ctx.Utility().String(value)) - ctx.Log(name + " out: " + ctx.Utility().String(retrieved)) + ctx.Log(name + " out: " + ctx.Utility().String(val)) } } func vluSave(ctx wasmlib.ScFuncContext, name string, value uint64) { enc := wasmtypes.NewWasmEncoder() - state := wasmlib.ScState{} + state := ctx.RawState() key := []byte(name) state.Set(key, enc.VluEncode(value).Buf()) - dec := wasmtypes.NewWasmDecoder(state.Get(key)) - retrieved := wasmtypes.Uint64Decode(dec) - if retrieved != value { + buf := state.Get(key) + dec := wasmtypes.NewWasmDecoder(buf) + val := wasmtypes.Uint64Decode(dec) + if val != value { ctx.Log(name + " in : " + ctx.Utility().String(int64(value))) - ctx.Log(name + " out: " + ctx.Utility().String(int64(retrieved))) + ctx.Log(name + " out: " + ctx.Utility().String(int64(val))) } } diff --git a/contracts/wasm/inccounter/ts/inccounter/inccounter.ts b/contracts/wasm/inccounter/ts/inccounter/inccounter.ts index e47fece5b1..8916e2b127 100644 --- a/contracts/wasm/inccounter/ts/inccounter/inccounter.ts +++ b/contracts/wasm/inccounter/ts/inccounter/inccounter.ts @@ -4,7 +4,6 @@ import * as wasmlib from "wasmlib" import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; -import {ScState} from "../../../../../packages/wasmvm/wasmlib/ts/wasmlib"; const hex = "0123456789abcdef"; @@ -240,27 +239,29 @@ function localStatePost(ctx: wasmlib.ScFuncContext, nr: i64): void { function vliSave(ctx: wasmlib.ScFuncContext, name: string, value: i64): void { let enc = new wasmtypes.WasmEncoder(); - const state = new ScState(); + const state = ctx.rawState(); let key = wasmtypes.stringToBytes(name); state.set(key, enc.vliEncode(value).buf()); - let dec = new wasmtypes.WasmDecoder(state.get(key)); - let retrieved = wasmtypes.int64Decode(dec); - if (retrieved != value) { + const buf = state.get(key); + let dec = new wasmtypes.WasmDecoder(buf == null ? [] : buf); + let val = wasmtypes.int64Decode(dec); + if (val != value) { ctx.log(name.toString() + " in : " + value.toString()); - ctx.log(name.toString() + " out: " + retrieved.toString()); + ctx.log(name.toString() + " out: " + val.toString()); } } function vluSave(ctx: wasmlib.ScFuncContext, name: string, value: u64): void { let enc = new wasmtypes.WasmEncoder(); - const state = new ScState(); + const state = ctx.rawState(); let key = wasmtypes.stringToBytes(name); state.set(key, enc.vluEncode(value).buf()); - let dec = new wasmtypes.WasmDecoder(state.get(key)); - let retrieved = wasmtypes.uint64Decode(dec); - if (retrieved != value) { + const buf = state.get(key); + let dec = new wasmtypes.WasmDecoder(buf == null ? [] : buf); + let val = wasmtypes.uint64Decode(dec); + if (val != value) { ctx.log(name.toString() + " in : " + value.toString()); - ctx.log(name.toString() + " out: " + retrieved.toString()); + ctx.log(name.toString() + " out: " + val.toString()); } } diff --git a/contracts/wasm/testwasmlib/ts/testwasmlib/testwasmlib.ts b/contracts/wasm/testwasmlib/ts/testwasmlib/testwasmlib.ts index 4808c8e61a..41eb29297a 100644 --- a/contracts/wasm/testwasmlib/ts/testwasmlib/testwasmlib.ts +++ b/contracts/wasm/testwasmlib/ts/testwasmlib/testwasmlib.ts @@ -7,6 +7,10 @@ import * as coreblocklog from "wasmlib/coreblocklog" import * as sc from "./index"; export function funcArrayAppend(ctx: wasmlib.ScFuncContext, f: sc.ArrayAppendContext): void { + let name = f.params.name().value(); + let array = f.state.arrays().getStringArray(name); + let value = f.params.value().value(); + array.appendString().setValue(value); } export function funcArrayClear(ctx: wasmlib.ScFuncContext, f: sc.ArrayClearContext): void { @@ -24,9 +28,17 @@ export function funcArraySet(ctx: wasmlib.ScFuncContext, f: sc.ArraySetContext): } export function funcMapClear(ctx: wasmlib.ScFuncContext, f: sc.MapClearContext): void { + let name = f.params.name().value(); + let myMap = f.state.maps().getStringMap(name); + myMap.clear(); } export function funcMapSet(ctx: wasmlib.ScFuncContext, f: sc.MapSetContext): void { + let name = f.params.name().value(); + let myMap = f.state.maps().getStringMap(name); + let key = f.params.key().value(); + let value = f.params.value().value(); + myMap.getString(key).setValue(value); } export function funcParamTypes(ctx: wasmlib.ScFuncContext, f: sc.ParamTypesContext): void { @@ -118,8 +130,17 @@ export function viewBlockRecord(ctx: wasmlib.ScViewContext, f: sc.BlockRecordCon records.params.blockIndex().setValue(f.params.blockIndex().value()); records.func.call(); let recordIndex = f.params.recordIndex().value(); - ctx.require(recordIndex < records.results.requestRecord().length(), "invalid recordIndex"); - f.results.record().setValue(records.results.requestRecord().getBytes(recordIndex).value()); + ctx.log("index: " + recordIndex.toString()); + recordIndex = f.params.recordIndex().value(); + ctx.log("index: " + recordIndex.toString()); + const requestRecord = records.results.requestRecord(); + const length = requestRecord.length(); + ctx.log("length: " + length.toString()); + const length2 = requestRecord.length(); + ctx.log("length2: " + length2.toString()); + ctx.require(recordIndex < length, "invalid recordIndex"); + const buf = requestRecord.getBytes(recordIndex).value(); + f.results.record().setValue(buf); } export function viewBlockRecords(ctx: wasmlib.ScViewContext, f: sc.BlockRecordsContext): void { @@ -138,4 +159,9 @@ export function viewIotaBalance(ctx: wasmlib.ScViewContext, f: sc.IotaBalanceCon } export function viewMapValue(ctx: wasmlib.ScViewContext, f: sc.MapValueContext): void { + let name = f.params.name().value(); + let myMap = f.state.maps().getStringMap(name); + let key = f.params.key().value(); + let value = myMap.getString(key).value(); + f.results.value().setValue(value); } diff --git a/contracts/wasm/tokenregistry/ts/tokenregistry/structs.ts b/contracts/wasm/tokenregistry/ts/tokenregistry/structs.ts index 2ed33dbcf4..05a4de83b4 100644 --- a/contracts/wasm/tokenregistry/ts/tokenregistry/structs.ts +++ b/contracts/wasm/tokenregistry/ts/tokenregistry/structs.ts @@ -18,7 +18,7 @@ export class Token { userDefined : string = ""; // any user defined text static fromBytes(buf: u8[]|null): Token { - const dec = new wasmtypes.WasmDecoder(buf); + const dec = new wasmtypes.WasmDecoder(buf==null ? [] : buf); const data = new Token(); data.created = wasmtypes.uint64Decode(dec); data.description = wasmtypes.stringDecode(dec); @@ -46,7 +46,7 @@ export class Token { export class ImmutableToken extends wasmtypes.ScProxy { - exists(): boolean { + exists(): bool { return this.proxy.exists(); } @@ -61,7 +61,7 @@ export class MutableToken extends wasmtypes.ScProxy { this.proxy.delete(); } - exists(): boolean { + exists(): bool { return this.proxy.exists(); } diff --git a/packages/wasmvm/wasmhost/wasmtosandbox.go b/packages/wasmvm/wasmhost/wasmtosandbox.go index dd28ed0ac3..23cf2cf70a 100644 --- a/packages/wasmvm/wasmhost/wasmtosandbox.go +++ b/packages/wasmvm/wasmhost/wasmtosandbox.go @@ -207,7 +207,7 @@ func (s *WasmToSandbox) fnMinted(args []byte) []byte { } func (s *WasmToSandbox) fnPanic(args []byte) []byte { - s.common.Log().Panicf(string(args)) + s.common.Log().Panicf("WASM panic: %s", string(args)) return nil } diff --git a/packages/wasmvm/wasmlib/go/wasmlib/dict.go b/packages/wasmvm/wasmlib/go/wasmlib/dict.go index 4856b2eafe..818c5134f0 100644 --- a/packages/wasmvm/wasmlib/go/wasmlib/dict.go +++ b/packages/wasmvm/wasmlib/go/wasmlib/dict.go @@ -39,9 +39,11 @@ func NewScDictFromBytes(buf []byte) *ScDict { size := wasmtypes.Uint32FromBytes(dec.FixedBytes(wasmtypes.ScUint32Length)) dict := NewScDict() for i := uint32(0); i < size; i++ { - keyLen := wasmtypes.Uint16FromBytes(dec.FixedBytes(wasmtypes.ScUint16Length)) + keyBuf := dec.FixedBytes(wasmtypes.ScUint16Length) + keyLen := wasmtypes.Uint16FromBytes(keyBuf) key := dec.FixedBytes(uint32(keyLen)) - valLen := wasmtypes.Uint32FromBytes(dec.FixedBytes(wasmtypes.ScUint32Length)) + valBuf := dec.FixedBytes(wasmtypes.ScUint32Length) + valLen := wasmtypes.Uint32FromBytes(valBuf) val := dec.FixedBytes(valLen) dict.Set(key, val) } diff --git a/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/codec.go b/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/codec.go index c23daa9131..a3856badd1 100644 --- a/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/codec.go +++ b/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/codec.go @@ -11,6 +11,9 @@ type WasmDecoder struct { } func NewWasmDecoder(buf []byte) *WasmDecoder { + if len(buf) == 0 { + panic("empty decode buffer") + } return &WasmDecoder{buf: buf} } @@ -46,7 +49,7 @@ func (d *WasmDecoder) Close() { // FixedBytes decodes the next fixed size slice of bytes from the byte buffer func (d *WasmDecoder) FixedBytes(size uint32) []byte { if uint32(len(d.buf)) < size { - d.abort("insufficient bytes") + d.abort("insufficient fixed bytes") } value := d.buf[:size] d.buf = d.buf[size:] diff --git a/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/proxy.go b/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/proxy.go index 156e4c2c3a..c018277fcf 100644 --- a/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/proxy.go +++ b/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/proxy.go @@ -25,7 +25,7 @@ func NewProxy(kvStore IKvStore) Proxy { // Note that this will essentially return the element at Length() func (p Proxy) Append() Proxy { length := p.Length() - p.Expand(length + 1) + p.expand(length + 1) return p.element(length) } @@ -49,35 +49,24 @@ func (p Proxy) ClearMap() { p.Delete() } -func (p Proxy) Decoder() *WasmDecoder { - return p.decoder(p.Get()) -} - -func (p Proxy) decoder(buf []byte) *WasmDecoder { - return NewWasmDecoder(buf) -} - func (p Proxy) Delete() { p.kvStore.Delete(p.key) } func (p Proxy) element(index uint32) Proxy { - enc := p.Encoder() + enc := NewWasmEncoder() Uint32Encode(enc, index) return p.sub('#', enc.Buf()) } -func (p Proxy) Encoder() *WasmEncoder { - return NewWasmEncoder() -} - func (p Proxy) Exists() bool { return p.kvStore.Exists(p.key) } -func (p Proxy) Expand(length uint32) { +// TODO have a Grow function that grows an array? +func (p Proxy) expand(length uint32) { // update the length counter - enc := p.Encoder() + enc := NewWasmEncoder() Uint32Encode(enc, length) p.Set(enc.Buf()) } @@ -111,7 +100,8 @@ func (p Proxy) Length() uint32 { if buf == nil { return 0 } - return Uint32Decode(p.decoder(buf)) + dec := NewWasmDecoder(buf) + return Uint32Decode(dec) } // Root returns a Proxy for an element of a root container (Params/Results/State). diff --git a/packages/wasmvm/wasmlib/ts/wasmlib/assets.ts b/packages/wasmvm/wasmlib/ts/wasmlib/assets.ts index 2ce732f192..812ab1bddb 100644 --- a/packages/wasmvm/wasmlib/ts/wasmlib/assets.ts +++ b/packages/wasmvm/wasmlib/ts/wasmlib/assets.ts @@ -45,7 +45,7 @@ export class ScBalances { public balance(color: wasmtypes.ScColor): u64 { const mapKey = ScDict.toKey(color.id); - if (! this.assets.has(mapKey)) { + if (!this.assets.has(mapKey)) { return 0; } return this.assets.get(mapKey); diff --git a/packages/wasmvm/wasmlib/ts/wasmlib/contract.ts b/packages/wasmvm/wasmlib/ts/wasmlib/contract.ts index 7cc078223f..d32213079a 100644 --- a/packages/wasmvm/wasmlib/ts/wasmlib/contract.ts +++ b/packages/wasmvm/wasmlib/ts/wasmlib/contract.ts @@ -38,7 +38,7 @@ export class ScView { hContract: wasmtypes.ScHname; hFunction: wasmtypes.ScHname; params: ScDict; - resultsProxy: wasmtypes.Proxy| null; + resultsProxy: wasmtypes.Proxy | null; constructor(hContract: wasmtypes.ScHname, hFunction: wasmtypes.ScHname) { this.hContract = hContract; diff --git a/packages/wasmvm/wasmlib/ts/wasmlib/dict.ts b/packages/wasmvm/wasmlib/ts/wasmlib/dict.ts index 686a349034..6759ce3e1b 100644 --- a/packages/wasmvm/wasmlib/ts/wasmlib/dict.ts +++ b/packages/wasmvm/wasmlib/ts/wasmlib/dict.ts @@ -2,8 +2,25 @@ // SPDX-License-Identifier: Apache-2.0 import * as wasmtypes from "./wasmtypes" +import {hex, stringFromBytes} from "./wasmtypes" import {log} from "./sandbox"; +export function keya(key: u8[]): string { + for (let i = 0; i < key.length; i++) { + if (key[i] == 0x23) { + return stringFromBytes(key.slice(0, i + 1)) + hex(key.slice(i + 1)); + } + if (key[i] < 0x20 || key[i] > 0x7e) { + return hex(key); + } + } + return stringFromBytes(key); +} + +export function vala(val: u8[] | null): string { + return val != null ? "[" + hex(val) + "]" : "null"; +} + export class ScDict implements wasmtypes.IKvStore { dict: Map = new Map(); @@ -12,7 +29,6 @@ export class ScDict implements wasmtypes.IKvStore { for (let i = 0; i < buf.length; i++) { key += String.fromCharCode((buf[i] >> 4) + 0x40, (buf[i] & 0x0f) + 0x40); } - //log("toKey(" + wasmtypes.hex(buf) + ")=" + key); return key; } @@ -23,7 +39,6 @@ export class ScDict implements wasmtypes.IKvStore { const b2 = key.charCodeAt(i + 1) as u8; buf[i / 2] = (((b1 - 0x40) << 4) | (b2 - 0x40)); } - //log("fromKey(" + key + ")=" + wasmtypes.hex(buf)); return buf; } @@ -32,9 +47,11 @@ export class ScDict implements wasmtypes.IKvStore { const dec = new wasmtypes.WasmDecoder(buf); const size = wasmtypes.uint32FromBytes(dec.fixedBytes(wasmtypes.ScUint32Length)); for (let i: u32 = 0; i < size; i++) { - const keyLen = wasmtypes.uint16FromBytes(dec.fixedBytes(wasmtypes.ScUint16Length)); + const keyBuf = dec.fixedBytes(wasmtypes.ScUint16Length); + const keyLen = wasmtypes.uint16FromBytes(keyBuf); const key = dec.fixedBytes(keyLen as u32); - const valLen = wasmtypes.uint32FromBytes(dec.fixedBytes(wasmtypes.ScUint32Length)); + const valBuf = dec.fixedBytes(wasmtypes.ScUint32Length); + const valLen = wasmtypes.uint32FromBytes(valBuf); const val = dec.fixedBytes(valLen); this.set(key, val); } @@ -46,19 +63,37 @@ export class ScDict implements wasmtypes.IKvStore { } delete(key: u8[]): void { + // this.dump("delete"); + // log("dict.delete(" + keya(key) + ")"); this.dict.delete(ScDict.toKey(key)); + // this.dump("Delete") + } + + protected dump(which: string): void { + const keys = this.dict.keys() + for (let i = 0; i < keys.length; i++) { + log("dict." + which + "." + i.toString() + "." + keya(ScDict.fromKey(keys[i])) + " = " + vala(this.dict.get(keys[i]))); + } } exists(key: u8[]): bool { - return this.dict.has(ScDict.toKey(key)); + const mapKey = ScDict.toKey(key); + const ret = this.dict.has(mapKey); + // this.dump("exists"); + // log("dict.exists(" + keya(key) + ") = " + ret.toString()); + return ret; } get(key: u8[]): u8[] | null { + // this.dump("get") const mapKey = ScDict.toKey(key); - if (! this.dict.has(mapKey)) { + if (!this.dict.has(mapKey)) { + // log("dict.get(" + keya(key) + ") = null"); return null; } - return this.dict.get(mapKey); + const value = this.dict.get(mapKey); + // log("dict.get(" + keya(key) + ") = " + vala(value)); + return value; } public immutable(): ScImmutableDict { @@ -66,7 +101,10 @@ export class ScDict implements wasmtypes.IKvStore { } set(key: u8[], value: u8[]): void { + // this.dump("set") + // log("dict.set(" + keya(key) + ", " + vala(value) + ")"); this.dict.set(ScDict.toKey(key), value); + // this.dump("Set") } public toBytes(): u8[] { @@ -105,7 +143,7 @@ export class ScImmutableDict { get(key: u8[]): u8[] | null { const mapKey = ScDict.toKey(key); - if (! this.dict.has(mapKey)) { + if (!this.dict.has(mapKey)) { return null; } return this.dict.get(mapKey); diff --git a/packages/wasmvm/wasmlib/ts/wasmlib/package-lock.json b/packages/wasmvm/wasmlib/ts/wasmlib/package-lock.json index b0e4152706..b50dee9169 100644 --- a/packages/wasmvm/wasmlib/ts/wasmlib/package-lock.json +++ b/packages/wasmvm/wasmlib/ts/wasmlib/package-lock.json @@ -1,8 +1,84 @@ { "name": "wasmlib", "version": "1.0.0", - "lockfileVersion": 1, + "lockfileVersion": 2, "requires": true, + "packages": { + "": { + "name": "wasmlib", + "version": "1.0.0", + "dependencies": { + "@assemblyscript/loader": "^0.19.22" + }, + "devDependencies": { + "assemblyscript": "^0.19.22" + } + }, + "node_modules/@assemblyscript/loader": { + "version": "0.19.22", + "resolved": "https://registry.npmjs.org/@assemblyscript/loader/-/loader-0.19.22.tgz", + "integrity": "sha512-ksrMVpPOatD7ZzXCw+c/g3zId5rm8MMnQe7P32dH/qtDrgT9SbQjJYEngRP0YhRF0qrBCga2PtpID7arqphGyg==" + }, + "node_modules/assemblyscript": { + "version": "0.19.22", + "resolved": "https://registry.npmjs.org/assemblyscript/-/assemblyscript-0.19.22.tgz", + "integrity": "sha512-+Rclbx0+BI3qAe9fjc8XGbSUDaayTtjINnD19I4MmfpT2R43c9YTQERP36676shkPxb1fisDFZeSTL65Da8Q2g==", + "dev": true, + "dependencies": { + "binaryen": "102.0.0-nightly.20211028", + "long": "^5.2.0", + "source-map-support": "^0.5.20" + }, + "bin": { + "asc": "bin/asc", + "asinit": "bin/asinit" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/assemblyscript" + } + }, + "node_modules/binaryen": { + "version": "102.0.0-nightly.20211028", + "resolved": "https://registry.npmjs.org/binaryen/-/binaryen-102.0.0-nightly.20211028.tgz", + "integrity": "sha512-GCJBVB5exbxzzvyt8MGDv/MeUjs6gkXDvf4xOIItRBptYl0Tz5sm1o/uG95YK0L0VeG5ajDu3hRtkBP2kzqC5w==", + "dev": true, + "bin": { + "wasm-opt": "bin/wasm-opt" + } + }, + "node_modules/buffer-from": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz", + "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==", + "dev": true + }, + "node_modules/long": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/long/-/long-5.2.0.tgz", + "integrity": "sha512-9RTUNjK60eJbx3uz+TEGF7fUr29ZDxR5QzXcyDpeSfeH28S9ycINflOgOlppit5U+4kNTe83KQnMEerw7GmE8w==", + "dev": true + }, + "node_modules/source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/source-map-support": { + "version": "0.5.21", + "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.21.tgz", + "integrity": "sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==", + "dev": true, + "dependencies": { + "buffer-from": "^1.0.0", + "source-map": "^0.6.0" + } + } + }, "dependencies": { "@assemblyscript/loader": { "version": "0.19.22", diff --git a/packages/wasmvm/wasmlib/ts/wasmlib/package.json b/packages/wasmvm/wasmlib/ts/wasmlib/package.json index b3d0b9c01d..aee97e6323 100644 --- a/packages/wasmvm/wasmlib/ts/wasmlib/package.json +++ b/packages/wasmvm/wasmlib/ts/wasmlib/package.json @@ -4,9 +4,9 @@ "version": "1.0.0", "author": "Eric Hop", "dependencies": { - "@assemblyscript/loader": "^0.19.18" + "@assemblyscript/loader": "^0.19.22" }, "devDependencies": { - "assemblyscript": "^0.19.18" + "assemblyscript": "^0.19.22" } } diff --git a/packages/wasmvm/wasmlib/ts/wasmlib/wasmrequests/structs.ts b/packages/wasmvm/wasmlib/ts/wasmlib/wasmrequests/structs.ts index 93253500ca..9af2c268cd 100644 --- a/packages/wasmvm/wasmlib/ts/wasmlib/wasmrequests/structs.ts +++ b/packages/wasmvm/wasmlib/ts/wasmlib/wasmrequests/structs.ts @@ -15,7 +15,7 @@ export class CallRequest { transfer : u8[] = []; static fromBytes(buf: u8[]|null): CallRequest { - const dec = new wasmtypes.WasmDecoder(buf); + const dec = new wasmtypes.WasmDecoder(buf==null ? [] : buf); const data = new CallRequest(); data.contract = wasmtypes.hnameDecode(dec); data.function = wasmtypes.hnameDecode(dec); @@ -37,7 +37,7 @@ export class CallRequest { export class ImmutableCallRequest extends wasmtypes.ScProxy { - exists(): boolean { + exists(): bool { return this.proxy.exists(); } @@ -52,7 +52,7 @@ export class MutableCallRequest extends wasmtypes.ScProxy { this.proxy.delete(); } - exists(): boolean { + exists(): bool { return this.proxy.exists(); } @@ -72,7 +72,7 @@ export class DeployRequest { progHash : wasmtypes.ScHash = new wasmtypes.ScHash(); static fromBytes(buf: u8[]|null): DeployRequest { - const dec = new wasmtypes.WasmDecoder(buf); + const dec = new wasmtypes.WasmDecoder(buf==null ? [] : buf); const data = new DeployRequest(); data.description = wasmtypes.stringDecode(dec); data.name = wasmtypes.stringDecode(dec); @@ -94,7 +94,7 @@ export class DeployRequest { export class ImmutableDeployRequest extends wasmtypes.ScProxy { - exists(): boolean { + exists(): bool { return this.proxy.exists(); } @@ -109,7 +109,7 @@ export class MutableDeployRequest extends wasmtypes.ScProxy { this.proxy.delete(); } - exists(): boolean { + exists(): bool { return this.proxy.exists(); } @@ -131,7 +131,7 @@ export class PostRequest { transfer : u8[] = []; static fromBytes(buf: u8[]|null): PostRequest { - const dec = new wasmtypes.WasmDecoder(buf); + const dec = new wasmtypes.WasmDecoder(buf==null ? [] : buf); const data = new PostRequest(); data.chainID = wasmtypes.chainIDDecode(dec); data.contract = wasmtypes.hnameDecode(dec); @@ -157,7 +157,7 @@ export class PostRequest { export class ImmutablePostRequest extends wasmtypes.ScProxy { - exists(): boolean { + exists(): bool { return this.proxy.exists(); } @@ -172,7 +172,7 @@ export class MutablePostRequest extends wasmtypes.ScProxy { this.proxy.delete(); } - exists(): boolean { + exists(): bool { return this.proxy.exists(); } @@ -190,7 +190,7 @@ export class SendRequest { transfer : u8[] = []; static fromBytes(buf: u8[]|null): SendRequest { - const dec = new wasmtypes.WasmDecoder(buf); + const dec = new wasmtypes.WasmDecoder(buf==null ? [] : buf); const data = new SendRequest(); data.address = wasmtypes.addressDecode(dec); data.transfer = wasmtypes.bytesDecode(dec); @@ -208,7 +208,7 @@ export class SendRequest { export class ImmutableSendRequest extends wasmtypes.ScProxy { - exists(): boolean { + exists(): bool { return this.proxy.exists(); } @@ -223,7 +223,7 @@ export class MutableSendRequest extends wasmtypes.ScProxy { this.proxy.delete(); } - exists(): boolean { + exists(): bool { return this.proxy.exists(); } diff --git a/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/codec.ts b/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/codec.ts index 4f69fe9e6e..22b5ad19b7 100644 --- a/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/codec.ts +++ b/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/codec.ts @@ -9,8 +9,11 @@ import {panic} from "../sandbox"; export class WasmDecoder { buf: u8[]; - constructor(buf: u8[] | null) { - this.buf = buf == null ? [] : buf; + constructor(buf: u8[]) { + if (buf.length == 0) { + panic("empty decode buffer"); + } + this.buf = buf; } // decodes the next byte from the byte buffer @@ -18,7 +21,9 @@ export class WasmDecoder { if (this.buf.length == 0) { panic("insufficient bytes"); } - return this.buf.shift(); + const value = this.buf[0]; + this.buf = this.buf.slice(1); + return value; } // decodes the next variable sized slice of bytes from the byte buffer @@ -37,7 +42,7 @@ export class WasmDecoder { // decodes the next fixed size slice of bytes from the byte buffer fixedBytes(size: u32): u8[] { if ((this.buf.length as u32) < size) { - panic("insufficient bytes"); + panic("insufficient fixed bytes"); } let value = this.buf.slice(0, size); this.buf = this.buf.slice(size); @@ -206,7 +211,7 @@ export function hex(buf: u8[]): string { const b = buf[i]; res += hexa.charAt(b >> 4) + hexa.charAt(b & 0x0f); } - return res + return res; } export function zeroes(count: u32): u8[] { diff --git a/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/package.json b/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/package.json index b7e5668731..6261945296 100644 --- a/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/package.json +++ b/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/package.json @@ -4,9 +4,9 @@ "version": "1.0.0", "author": "Eric Hop", "dependencies": { - "@assemblyscript/loader": "^0.19.18" + "@assemblyscript/loader": "^0.19.22" }, "devDependencies": { - "assemblyscript": "^0.19.18" + "assemblyscript": "^0.19.22" } } diff --git a/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/proxy.ts b/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/proxy.ts index 3cc5f3a8f6..8adb483b73 100644 --- a/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/proxy.ts +++ b/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/proxy.ts @@ -1,10 +1,10 @@ // Copyright 2020 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 -import {panic} from "../sandbox"; import {WasmDecoder, WasmEncoder} from "./codec"; import {uint32Decode, uint32Encode} from "./scuint32"; import {stringToBytes} from "./scstring"; +import {panic} from "../sandbox"; export interface IKvStore { delete(key: u8[]): void; @@ -25,10 +25,13 @@ export class ScProxy { } export class Proxy { + static proxies: u32 = 0; + id: u32; _key: u8[] = []; kvStore: IKvStore; constructor(kvStore: IKvStore) { + this.id = Proxy.proxies++; this.kvStore = kvStore; } @@ -60,41 +63,34 @@ export class Proxy { this.delete(); } - public decoder(): WasmDecoder { - return this._decoder(this.get()); - } - - protected _decoder(buf: u8[] | null): WasmDecoder { - return new WasmDecoder(buf); - } - delete(): void { + //log(this.id.toString() + ".delete(" + keya(this._key) + ")"); this.kvStore.delete(this._key); } protected element(index: u32): Proxy { - let enc = this.encoder(); + let enc = new WasmEncoder(); uint32Encode(enc, index); return this.sub('#'.charCodeAt(0) as u8, enc.buf()); } - public encoder(): WasmEncoder { - return new WasmEncoder(); - } - exists(): bool { + //log(this.id.toString() + ".exists(" + keya(this._key) + ")"); return this.kvStore.exists(this._key); } - public expand(length: u32): void { + //TODO have a Grow function that grows an array? + protected expand(length: u32): void { // update the length counter - let enc = this.encoder(); + let enc = new WasmEncoder(); uint32Encode(enc, length); this.set(enc.buf()); } get(): u8[] | null { - return this.kvStore.get(this._key); + const buf = this.kvStore.get(this._key); + //log(this.id.toString() + ".get(" + keya(this._key) + ") = " + vala(buf)); + return buf; } // Index gets a Proxy for an element of an Array by its index @@ -122,7 +118,8 @@ export class Proxy { if (buf == null) { return 0; } - return uint32Decode(this._decoder(buf)); + const dec = new WasmDecoder(buf) + return uint32Decode(dec); } protected proxy(kvStore: IKvStore, key: u8[]): Proxy { @@ -138,6 +135,7 @@ export class Proxy { } set(value: u8[]): void { + //log(this.id.toString() + ".set(" + keya(this._key) + ") = " + vala(value)); this.kvStore.set(this._key, value); } diff --git a/packages/wasmvm/wasmsolo/solosandbox.go b/packages/wasmvm/wasmsolo/solosandbox.go index b493ed2bc9..4ff07f22a5 100644 --- a/packages/wasmvm/wasmsolo/solosandbox.go +++ b/packages/wasmvm/wasmsolo/solosandbox.go @@ -181,7 +181,9 @@ func (s *SoloSandbox) fnCall(args []byte) []byte { return s.postSync(s.ctx.scName, funcName, params, transfer) } + _ = wasmhost.Connect(s.ctx.wasmHostOld) res, err := s.ctx.Chain.CallView(s.ctx.scName, funcName, params) + _ = wasmhost.Connect(s.ctx.wc) s.ctx.Err = err if err != nil { return nil @@ -237,7 +239,7 @@ func (s *SoloSandbox) fnMinted(args []byte) []byte { } func (s *SoloSandbox) fnPanic(args []byte) []byte { - s.ctx.Chain.Log.Panicf(string(args)) + s.ctx.Chain.Log.Panicf("SOLO panic: %s", string(args)) return nil } diff --git a/tools/schema/generator/tstemplates/structs.go b/tools/schema/generator/tstemplates/structs.go index 6be85664ce..caea7991b2 100644 --- a/tools/schema/generator/tstemplates/structs.go +++ b/tools/schema/generator/tstemplates/structs.go @@ -14,7 +14,7 @@ export class $StrName { $#each struct structField static fromBytes(buf: u8[]|null): $StrName { - const dec = new wasmtypes.WasmDecoder(buf); + const dec = new wasmtypes.WasmDecoder(buf==null ? [] : buf); const data = new $StrName(); $#each struct structDecode dec.close(); @@ -50,7 +50,7 @@ $#emit structMethods export class $mut$StrName extends wasmtypes.ScProxy { $#if mut structMethodDelete - exists(): boolean { + exists(): bool { return this.proxy.exists(); } $#if mut structMethodSetValue From 96fb2213d9951c209d7b66f61f95f07b08103fa5 Mon Sep 17 00:00:00 2001 From: Eric Hop Date: Mon, 31 Jan 2022 10:42:21 -0800 Subject: [PATCH 054/111] Initial Rust wasmtypes --- .../wasmlib/go/wasmlib/wasmtypes/codec.go | 3 +- packages/wasmvm/wasmlib/src/lib.rs | 2 + .../wasmvm/wasmlib/src/wasmrequests/mod.rs | 6 +- .../wasmlib/src/wasmrequests/structs.rs | 12 +- .../wasmvm/wasmlib/src/wasmtypes/codec.rs | 211 ++++++++++++++++++ packages/wasmvm/wasmlib/src/wasmtypes/mod.rs | 46 ++++ .../wasmvm/wasmlib/src/wasmtypes/proxy.rs | 42 ++++ .../wasmvm/wasmlib/src/wasmtypes/scaddress.rs | 113 ++++++++++ .../wasmvm/wasmlib/src/wasmtypes/scagentid.rs | 113 ++++++++++ .../wasmvm/wasmlib/src/wasmtypes/scchainid.rs | 113 ++++++++++ .../wasmvm/wasmlib/src/wasmtypes/sccolor.rs | 116 ++++++++++ .../wasmvm/wasmlib/src/wasmtypes/schash.rs | 113 ++++++++++ .../wasmvm/wasmlib/src/wasmtypes/schname.rs | 113 ++++++++++ .../wasmlib/src/wasmtypes/screquestid.rs | 113 ++++++++++ .../wasmvm/wasmlib/src/wasmtypes/scuint16.rs | 92 ++++++++ .../wasmvm/wasmlib/src/wasmtypes/scuint32.rs | 92 ++++++++ .../wasmvm/wasmlib/src/wasmtypes/scuint64.rs | 92 ++++++++ .../wasmvm/wasmlib/src/wasmtypes/scuint8.rs | 96 ++++++++ packages/wasmvm/wasmsolo/solocontext.go | 4 +- .../generator/rstemplates/alltemplates.go | 1 + tools/schema/generator/rstemplates/mod.go | 24 +- tools/schema/generator/rstemplates/structs.go | 2 +- 22 files changed, 1500 insertions(+), 19 deletions(-) create mode 100644 packages/wasmvm/wasmlib/src/wasmtypes/codec.rs create mode 100644 packages/wasmvm/wasmlib/src/wasmtypes/mod.rs create mode 100644 packages/wasmvm/wasmlib/src/wasmtypes/proxy.rs create mode 100644 packages/wasmvm/wasmlib/src/wasmtypes/scaddress.rs create mode 100644 packages/wasmvm/wasmlib/src/wasmtypes/scagentid.rs create mode 100644 packages/wasmvm/wasmlib/src/wasmtypes/scchainid.rs create mode 100644 packages/wasmvm/wasmlib/src/wasmtypes/sccolor.rs create mode 100644 packages/wasmvm/wasmlib/src/wasmtypes/schash.rs create mode 100644 packages/wasmvm/wasmlib/src/wasmtypes/schname.rs create mode 100644 packages/wasmvm/wasmlib/src/wasmtypes/screquestid.rs create mode 100644 packages/wasmvm/wasmlib/src/wasmtypes/scuint16.rs create mode 100644 packages/wasmvm/wasmlib/src/wasmtypes/scuint32.rs create mode 100644 packages/wasmvm/wasmlib/src/wasmtypes/scuint64.rs create mode 100644 packages/wasmvm/wasmlib/src/wasmtypes/scuint8.rs diff --git a/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/codec.go b/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/codec.go index a3856badd1..14e70b50d2 100644 --- a/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/codec.go +++ b/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/codec.go @@ -131,8 +131,7 @@ func (e *WasmEncoder) Byte(value uint8) *WasmEncoder { func (e *WasmEncoder) Bytes(value []byte) *WasmEncoder { length := len(value) e.VluEncode(uint64(length)) - e.FixedBytes(value, uint32(length)) - return e + return e.FixedBytes(value, uint32(length)) } // FixedBytes encodes a fixed size slice of bytes into the byte buffer diff --git a/packages/wasmvm/wasmlib/src/lib.rs b/packages/wasmvm/wasmlib/src/lib.rs index 6b28fa2f1b..3d52f99131 100644 --- a/packages/wasmvm/wasmlib/src/lib.rs +++ b/packages/wasmvm/wasmlib/src/lib.rs @@ -28,6 +28,8 @@ pub mod host; mod immutable; pub mod keys; mod mutable; +//pub mod wasmrequests; +pub mod wasmtypes; // When the `wee_alloc` feature is enabled, // use `wee_alloc` as the global allocator. diff --git a/packages/wasmvm/wasmlib/src/wasmrequests/mod.rs b/packages/wasmvm/wasmlib/src/wasmrequests/mod.rs index 8218c37b11..25c034042a 100644 --- a/packages/wasmvm/wasmlib/src/wasmrequests/mod.rs +++ b/packages/wasmvm/wasmlib/src/wasmrequests/mod.rs @@ -9,10 +9,8 @@ pub use consts::*; pub use contract::*; -pub use params::*; -pub use results::*; +pub use structs::*; pub mod consts; pub mod contract; -pub mod params; -pub mod results; +pub mod structs; diff --git a/packages/wasmvm/wasmlib/src/wasmrequests/structs.rs b/packages/wasmvm/wasmlib/src/wasmrequests/structs.rs index d46ee5f8dc..d1eb3e91db 100644 --- a/packages/wasmvm/wasmlib/src/wasmrequests/structs.rs +++ b/packages/wasmvm/wasmlib/src/wasmrequests/structs.rs @@ -15,8 +15,8 @@ use wasmlib::host::*; pub struct CallRequest { pub contract : ScHname, pub function : ScHname, - pub params : , - pub transfer : , + pub params : Vec, + pub transfer : Vec, } impl CallRequest { @@ -84,7 +84,7 @@ impl MutableCallRequest { pub struct DeployRequest { pub description : String, pub name : String, - pub params : , + pub params : Vec, pub prog_hash : ScHash, } @@ -155,8 +155,8 @@ pub struct PostRequest { pub contract : ScHname, pub delay : u32, pub function : ScHname, - pub params : , - pub transfer : , + pub params : Vec, + pub transfer : Vec, } impl PostRequest { @@ -227,7 +227,7 @@ impl MutablePostRequest { #[derive(Clone)] pub struct SendRequest { pub address : ScAddress, - pub transfer : , + pub transfer : Vec, } impl SendRequest { diff --git a/packages/wasmvm/wasmlib/src/wasmtypes/codec.rs b/packages/wasmvm/wasmlib/src/wasmtypes/codec.rs new file mode 100644 index 0000000000..06f505205a --- /dev/null +++ b/packages/wasmvm/wasmlib/src/wasmtypes/codec.rs @@ -0,0 +1,211 @@ +// Copyright 2020 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +use crate::hashtypes::*; +use crate::host::*; + +pub struct WasmDecoder<'a> { + buf: &'a [u8], +} + +impl WasmDecoder<'_> { + // constructs a decoder + pub fn new(buf: &[u8]) -> WasmDecoder { + if buf.len() == 0 { + panic("empty decode buffer"); + } + WasmDecoder { buf } + } + + // decodes the next variable length substring of bytes from the byte buffer + pub fn bytes(&mut self) -> &[u8] { + let length = self.vlu_decode(32); + self.fixed_bytes(length as usize) + } + + // decodes an uint8 from the byte buffer + pub fn byte(&mut self) -> u8 { + if self.buf.len() == 0 { + panic("insufficient bytes"); + } + let value = self.buf[0]; + self.buf = &self.buf[1..]; + value + } + + // decodes the next fixed length substring of bytes from the byte buffer + pub fn fixed_bytes(&mut self, size: usize) -> &[u8] { + if self.buf.len() < size { + panic("insufficient fixed bytes"); + } + let value = &self.buf[..size]; + self.buf = &self.buf[size..]; + value + } + + // vli (variable length integer) decoder + pub fn vli_decode(&mut self, bits: i32) -> i64 { + let mut b = self.byte(); + let sign = b & 0x40; + + // first group of 6 bits + let mut value = (b & 0x3f) as i64; + let mut s = 6; + + // while continuation bit is set + while (b & 0x80) != 0 { + if s >= bits { + panic("integer representation too long"); + } + + // next group of 7 bits + b = self.byte(); + value |= ((b & 0x7f) as i64) << s; + s += 7; + } + + if sign == 0 { + // positive, sign bits are already zero + return value; + } + + // negative, extend sign bits + value | (-1_i64 << s) + } + + // vlu (variable length unsigned) decoder + pub fn vlu_decode(&mut self, bits: i32) -> u64 { + // first group of 6 bits + let mut b = self.byte(); + let mut value = (b & 0x7f) as u64; + let mut s = 7; + + // while continuation bit is set + while (b & 0x80) != 0 { + if s >= bits { + panic("integer representation too long"); + } + + // next group of 7 bits + b = self.byte(); + value |= ((b & 0x7f) as u64) << s; + s += 7; + } + + value + } +} + +impl Drop for WasmDecoder<'_> { + fn drop(&mut self) { + if self.buf.len() != 0 { + panic("extra bytes"); + } + } +} + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +// encodes separate entities into a byte buffer +pub struct WasmEncoder { + buf: Vec, +} + +impl WasmEncoder { + // constructs an encoder + pub fn new() -> WasmEncoder { + WasmEncoder { buf: Vec::new() } + } + + // encodes an uint8 into the byte buffer + pub fn byte(&mut self, value: u8) -> &WasmEncoder { + self.buf.push(value); + self + } + + // encodes a variable sized substring of bytes into the byte buffer + pub fn bytes(&mut self, value: &[u8]) -> &WasmEncoder { + let length = value.len(); + self.vlu_encode(length as u64); + self.fixed_bytes(value, length) + } + + // retrieve the encoded byte buffer + pub fn buf(&self) -> Vec { + self.buf.clone() + } + + // encodes a fixed sized substring of bytes into the byte buffer + pub fn fixed_bytes(&mut self, value: &[u8], length: usize) -> &WasmEncoder { + if value.len() != length as usize { + panic("invalid fixed bytes length"); + } + self.buf.extend_from_slice(value); + self + } + + // encodes an int64 into the byte buffer + // note that these are encoded using vli encoding to conserve space + // vli (variable length integer) encoder + pub fn vli_encode(&mut self, mut value: i64) -> &WasmEncoder { + // first group of 6 bits + // 1st byte encodes 0 as positive in bit 6 + let mut b = value as u8 & 0x3f; + value >>= 6; + + let mut final_value = 0_i64; + if value < 0 { + // encode negative value + // 1st byte encodes 1 as negative in bit 6 + b |= 0x40; + final_value = -1_i64; + } + + // keep shifting until all bits are done + while value != final_value { + // emit with continuation bit + self.buf.push(b|0x80); + + // next group of 7 bits + b = value as u8 & 0x7f; + value >>= 7; + } + + // emit without continuation bit + self.buf.push(b); + self + } + + // encodes an uint64 into the byte buffer + // note that these are encoded using vlu encoding to conserve space + // vlu (variable length unsigned) encoder + pub fn vlu_encode(&mut self, mut value: u64) -> &WasmEncoder { + // first group of 7 bits + // 1st byte encodes 0 as positive in bit 6 + let mut b = value as u8; + value >>= 7; + + // keep shifting until all bits are done + while value != 0 { + // emit with continuation bit + self.buf.push(b|0x80); + + // next group of 7 bits + b = value as u8; + value >>= 7; + } + + // emit without continuation bit + self.buf.push(b); + self + } +} + +pub fn base58_encode(buf: &[u8]) -> String { + hex(buf) +} + +pub fn hex(buf: &[u8]) -> String { + //TODO + "".to_string() +} diff --git a/packages/wasmvm/wasmlib/src/wasmtypes/mod.rs b/packages/wasmvm/wasmlib/src/wasmtypes/mod.rs new file mode 100644 index 0000000000..c4b1d3aa8a --- /dev/null +++ b/packages/wasmvm/wasmlib/src/wasmtypes/mod.rs @@ -0,0 +1,46 @@ +// Copyright 2020 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +#![allow(unused_imports)] + +pub use codec::*; +pub use proxy::*; +pub use scaddress::*; +pub use scagentid::*; +// pub use scbool::*; +//pub use scbytes::*; +pub use scchainid::*; +pub use sccolor::*; +pub use schash::*; +pub use schname::*; +// pub use scint8::*; +// pub use scint16::*; +// pub use scint32::*; +// pub use scint64::*; +pub use screquestid::*; +// pub use scstring::*; +pub use scuint8::*; +pub use scuint16::*; +pub use scuint32::*; +pub use scuint64::*; + +pub mod codec; +pub mod proxy; +pub mod scaddress; +pub mod scagentid; +// pub mod scbool; +// pub mod scbytes; +pub mod scchainid; +pub mod sccolor; +pub mod schash; +pub mod schname; +// pub mod scint8; +// pub mod scint16; +// pub mod scint32; +// pub mod scint64; +pub mod screquestid; +// pub mod scstring; +pub mod scuint8; +pub mod scuint16; +pub mod scuint32; +pub mod scuint64; diff --git a/packages/wasmvm/wasmlib/src/wasmtypes/proxy.rs b/packages/wasmvm/wasmlib/src/wasmtypes/proxy.rs new file mode 100644 index 0000000000..e0c445d003 --- /dev/null +++ b/packages/wasmvm/wasmlib/src/wasmtypes/proxy.rs @@ -0,0 +1,42 @@ +// Copyright 2020 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +use crate::wasmtypes::*; + +pub trait IKvStore { + fn delete(&self, key: &[u8]); + fn exists(&self, key: &[u8]) -> bool; + fn get(&self, key: &[u8]) -> &[u8]; + fn set(&self, key: &[u8], value: &[u8]); +} + +pub struct Proxy<'a> { + key: Vec, + kv_store: &'a dyn IKvStore, +} + +impl Proxy<'_> { + pub fn new(kv_store: &dyn IKvStore) -> Proxy { + Proxy { key:Vec::new(), kv_store } + } + + pub fn delete(&self) { + self.kv_store.delete(&self.key); + } + + pub fn exists(&self) -> bool { + self.kv_store.exists(&self.key) + } + + pub fn get(&self) -> &[u8] { + self.kv_store.get(&self.key) + } + + pub fn root(&self, key:&str) -> Proxy { + Proxy { key: key.as_bytes().to_vec(), kv_store: self.kv_store } + } + + pub fn set(&self, value: &[u8]) { + self.kv_store.set(&self.key, value); + } +} diff --git a/packages/wasmvm/wasmlib/src/wasmtypes/scaddress.rs b/packages/wasmvm/wasmlib/src/wasmtypes/scaddress.rs new file mode 100644 index 0000000000..af311cf0da --- /dev/null +++ b/packages/wasmvm/wasmlib/src/wasmtypes/scaddress.rs @@ -0,0 +1,113 @@ +// Copyright 2020 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +use std::convert::TryInto; + +use crate::wasmtypes::*; + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +pub const SC_ADDRESS_LENGTH: usize = 33; + +#[derive(PartialEq, Clone)] +pub struct ScAddress { + id: [u8; SC_ADDRESS_LENGTH], +} + +impl ScAddress { + pub fn from_bytes(buf: &[u8]) -> ScAddress { + address_from_bytes(buf) + } + + pub fn to_bytes(&self) -> &[u8] { + address_to_bytes(self) + } + + pub fn to_string(&self) -> String { + address_to_string(self) + } +} + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +pub fn address_decode(dec: &mut WasmDecoder) -> ScAddress { + address_from_bytes_unchecked(dec.fixed_bytes(SC_ADDRESS_LENGTH)) +} + +pub fn address_encode(enc: &mut WasmEncoder, value: &ScAddress) { + enc.fixed_bytes(&value.to_bytes(), SC_ADDRESS_LENGTH); +} + +pub fn address_from_bytes(buf: &[u8]) -> ScAddress { + ScAddress { id: buf.try_into().expect("invalid Address length") } +} + +pub fn address_to_bytes(value: &ScAddress) -> &[u8] { + &value.id +} + +pub fn address_to_string(value: &ScAddress) -> String { + // TODO standardize human readable string + base58_encode(&value.id) +} + +fn address_from_bytes_unchecked(buf: &[u8]) -> ScAddress { + ScAddress { id: buf.try_into().expect("invalid Address length") } +} + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +pub struct ScImmutableAddress<'a> { + proxy: Proxy<'a>, +} + +impl ScImmutableAddress<'_> { + pub fn new(proxy: Proxy) -> ScImmutableAddress { + ScImmutableAddress { proxy } + } + + pub fn exists(&self) -> bool { + self.proxy.exists() + } + + pub fn to_string(&self) -> String { + address_to_string(&self.value()) + } + + pub fn value(&self) -> ScAddress { + address_from_bytes(self.proxy.get()) + } +} + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +// value proxy for mutable ScAddress in host container +pub struct ScMutableAddress<'a> { + proxy: Proxy<'a>, +} + +impl ScMutableAddress<'_> { + pub fn new(proxy: Proxy) -> ScMutableAddress { + ScMutableAddress { proxy } + } + + pub fn delete(&self) { + self.proxy.delete(); + } + + pub fn exists(&self) -> bool { + self.proxy.exists() + } + + pub fn set_value(&self, val: &ScAddress) { + self.proxy.set(address_to_bytes(&val)); + } + + pub fn to_string(&self) -> String { + address_to_string(&self.value()) + } + + pub fn value(&self) -> ScAddress { + address_from_bytes(self.proxy.get()) + } +} diff --git a/packages/wasmvm/wasmlib/src/wasmtypes/scagentid.rs b/packages/wasmvm/wasmlib/src/wasmtypes/scagentid.rs new file mode 100644 index 0000000000..0850ce5de4 --- /dev/null +++ b/packages/wasmvm/wasmlib/src/wasmtypes/scagentid.rs @@ -0,0 +1,113 @@ +// Copyright 2020 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +use std::convert::TryInto; + +use crate::wasmtypes::*; + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +pub const SC_AGENT_ID_LENGTH: usize = 37; + +#[derive(PartialEq, Clone)] +pub struct ScAgentId { + id: [u8; SC_AGENT_ID_LENGTH], +} + +impl ScAgentId { + pub fn from_bytes(buf: &[u8]) -> ScAgentId { + agent_id_from_bytes(buf) + } + + pub fn to_bytes(&self) -> &[u8] { + agent_id_to_bytes(self) + } + + pub fn to_string(&self) -> String { + agent_id_to_string(self) + } +} + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +pub fn agent_id_decode(dec: &mut WasmDecoder) -> ScAgentId { + agent_id_from_bytes_unchecked(dec.fixed_bytes(SC_AGENT_ID_LENGTH)) +} + +pub fn agent_id_encode(enc: &mut WasmEncoder, value: &ScAgentId) { + enc.fixed_bytes(&value.to_bytes(), SC_AGENT_ID_LENGTH); +} + +pub fn agent_id_from_bytes(buf: &[u8]) -> ScAgentId { + ScAgentId { id: buf.try_into().expect("invalid AgentId length") } +} + +pub fn agent_id_to_bytes(value: &ScAgentId) -> &[u8] { + &value.id +} + +pub fn agent_id_to_string(value: &ScAgentId) -> String { + // TODO standardize human readable string + base58_encode(&value.id) +} + +fn agent_id_from_bytes_unchecked(buf: &[u8]) -> ScAgentId { + ScAgentId { id: buf.try_into().expect("invalid AgentId length") } +} + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +pub struct ScImmutableAgentId<'a> { + proxy: Proxy<'a>, +} + +impl ScImmutableAgentId<'_> { + pub fn new(proxy: Proxy) -> ScImmutableAgentId { + ScImmutableAgentId { proxy } + } + + pub fn exists(&self) -> bool { + self.proxy.exists() + } + + pub fn to_string(&self) -> String { + agent_id_to_string(&self.value()) + } + + pub fn value(&self) -> ScAgentId { + agent_id_from_bytes(self.proxy.get()) + } +} + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +// value proxy for mutable ScAgentId in host container +pub struct ScMutableAgentId<'a> { + proxy: Proxy<'a>, +} + +impl ScMutableAgentId<'_> { + pub fn new(proxy: Proxy) -> ScMutableAgentId { + ScMutableAgentId { proxy } + } + + pub fn delete(&self) { + self.proxy.delete(); + } + + pub fn exists(&self) -> bool { + self.proxy.exists() + } + + pub fn set_value(&self, val: &ScAgentId) { + self.proxy.set(agent_id_to_bytes(&val)); + } + + pub fn to_string(&self) -> String { + agent_id_to_string(&self.value()) + } + + pub fn value(&self) -> ScAgentId { + agent_id_from_bytes(self.proxy.get()) + } +} diff --git a/packages/wasmvm/wasmlib/src/wasmtypes/scchainid.rs b/packages/wasmvm/wasmlib/src/wasmtypes/scchainid.rs new file mode 100644 index 0000000000..387a454c6d --- /dev/null +++ b/packages/wasmvm/wasmlib/src/wasmtypes/scchainid.rs @@ -0,0 +1,113 @@ +// Copyright 2020 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +use std::convert::TryInto; + +use crate::wasmtypes::*; + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +pub const SC_CHAIN_ID_LENGTH: usize = 33; + +#[derive(PartialEq, Clone)] +pub struct ScChainId { + id: [u8; SC_CHAIN_ID_LENGTH], +} + +impl ScChainId { + pub fn from_bytes(buf: &[u8]) -> ScChainId { + chain_id_from_bytes(buf) + } + + pub fn to_bytes(&self) -> &[u8] { + chain_id_to_bytes(self) + } + + pub fn to_string(&self) -> String { + chain_id_to_string(self) + } +} + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +pub fn chain_id_decode(dec: &mut WasmDecoder) -> ScChainId { + chain_id_from_bytes_unchecked(dec.fixed_bytes(SC_CHAIN_ID_LENGTH)) +} + +pub fn chain_id_encode(enc: &mut WasmEncoder, value: &ScChainId) { + enc.fixed_bytes(&value.to_bytes(), SC_CHAIN_ID_LENGTH); +} + +pub fn chain_id_from_bytes(buf: &[u8]) -> ScChainId { + ScChainId { id: buf.try_into().expect("invalid ChainId length") } +} + +pub fn chain_id_to_bytes(value: &ScChainId) -> &[u8] { + &value.id +} + +pub fn chain_id_to_string(value: &ScChainId) -> String { + // TODO standardize human readable string + base58_encode(&value.id) +} + +fn chain_id_from_bytes_unchecked(buf: &[u8]) -> ScChainId { + ScChainId { id: buf.try_into().expect("invalid ChainId length") } +} + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +pub struct ScImmutableChainId<'a> { + proxy: Proxy<'a>, +} + +impl ScImmutableChainId<'_> { + pub fn new(proxy: Proxy) -> ScImmutableChainId { + ScImmutableChainId { proxy } + } + + pub fn exists(&self) -> bool { + self.proxy.exists() + } + + pub fn to_string(&self) -> String { + chain_id_to_string(&self.value()) + } + + pub fn value(&self) -> ScChainId { + chain_id_from_bytes(self.proxy.get()) + } +} + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +// value proxy for mutable ScChainId in host container +pub struct ScMutableChainId<'a> { + proxy: Proxy<'a>, +} + +impl ScMutableChainId<'_> { + pub fn new(proxy: Proxy) -> ScMutableChainId { + ScMutableChainId { proxy } + } + + pub fn delete(&self) { + self.proxy.delete(); + } + + pub fn exists(&self) -> bool { + self.proxy.exists() + } + + pub fn set_value(&self, val: &ScChainId) { + self.proxy.set(chain_id_to_bytes(&val)); + } + + pub fn to_string(&self) -> String { + chain_id_to_string(&self.value()) + } + + pub fn value(&self) -> ScChainId { + chain_id_from_bytes(self.proxy.get()) + } +} diff --git a/packages/wasmvm/wasmlib/src/wasmtypes/sccolor.rs b/packages/wasmvm/wasmlib/src/wasmtypes/sccolor.rs new file mode 100644 index 0000000000..58cb50050d --- /dev/null +++ b/packages/wasmvm/wasmlib/src/wasmtypes/sccolor.rs @@ -0,0 +1,116 @@ +// Copyright 2020 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +use std::convert::TryInto; + +use crate::wasmtypes::*; + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +pub const SC_COLOR_LENGTH: usize = 32; + +#[derive(PartialEq, Clone)] +pub struct ScColor { + id: [u8; SC_COLOR_LENGTH], +} + +impl ScColor { + pub const IOTA: ScColor = ScColor { id: [0x00; SC_COLOR_LENGTH] }; + pub const MINT: ScColor = ScColor { id: [0xff; SC_COLOR_LENGTH] }; + + pub fn from_bytes(buf: &[u8]) -> ScColor { + color_from_bytes(buf) + } + + pub fn to_bytes(&self) -> &[u8] { + color_to_bytes(self) + } + + pub fn to_string(&self) -> String { + color_to_string(self) + } +} + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +pub fn color_decode(dec: &mut WasmDecoder) -> ScColor { + color_from_bytes_unchecked(dec.fixed_bytes(SC_COLOR_LENGTH)) +} + +pub fn color_encode(enc: &mut WasmEncoder, value: &ScColor) { + enc.fixed_bytes(&value.to_bytes(), SC_COLOR_LENGTH); +} + +pub fn color_from_bytes(buf: &[u8]) -> ScColor { + ScColor { id: buf.try_into().expect("invalid Color length") } +} + +pub fn color_to_bytes(value: &ScColor) -> &[u8] { + &value.id +} + +pub fn color_to_string(value: &ScColor) -> String { + // TODO standardize human readable string + base58_encode(&value.id) +} + +fn color_from_bytes_unchecked(buf: &[u8]) -> ScColor { + ScColor { id: buf.try_into().expect("invalid Color length") } +} + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +pub struct ScImmutableColor<'a> { + proxy: Proxy<'a>, +} + +impl ScImmutableColor<'_> { + pub fn new(proxy: Proxy) -> ScImmutableColor { + ScImmutableColor { proxy } + } + + pub fn exists(&self) -> bool { + self.proxy.exists() + } + + pub fn to_string(&self) -> String { + color_to_string(&self.value()) + } + + pub fn value(&self) -> ScColor { + color_from_bytes(self.proxy.get()) + } +} + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +// value proxy for mutable ScColor in host container +pub struct ScMutableColor<'a> { + proxy: Proxy<'a>, +} + +impl ScMutableColor<'_> { + pub fn new(proxy: Proxy) -> ScMutableColor { + ScMutableColor { proxy } + } + + pub fn delete(&self) { + self.proxy.delete(); + } + + pub fn exists(&self) -> bool { + self.proxy.exists() + } + + pub fn set_value(&self, val: &ScColor) { + self.proxy.set(color_to_bytes(&val)); + } + + pub fn to_string(&self) -> String { + color_to_string(&self.value()) + } + + pub fn value(&self) -> ScColor { + color_from_bytes(self.proxy.get()) + } +} diff --git a/packages/wasmvm/wasmlib/src/wasmtypes/schash.rs b/packages/wasmvm/wasmlib/src/wasmtypes/schash.rs new file mode 100644 index 0000000000..1ca8bd6b0b --- /dev/null +++ b/packages/wasmvm/wasmlib/src/wasmtypes/schash.rs @@ -0,0 +1,113 @@ +// Copyright 2020 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +use std::convert::TryInto; + +use crate::wasmtypes::*; + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +pub const SC_HASH_LENGTH: usize = 32; + +#[derive(PartialEq, Clone)] +pub struct ScHash { + id: [u8; SC_HASH_LENGTH], +} + +impl ScHash { + pub fn from_bytes(buf: &[u8]) -> ScHash { + hash_from_bytes(buf) + } + + pub fn to_bytes(&self) -> &[u8] { + hash_to_bytes(self) + } + + pub fn to_string(&self) -> String { + hash_to_string(self) + } +} + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +pub fn hash_decode(dec: &mut WasmDecoder) -> ScHash { + hash_from_bytes_unchecked(dec.fixed_bytes(SC_HASH_LENGTH)) +} + +pub fn hash_encode(enc: &mut WasmEncoder, value: &ScHash) { + enc.fixed_bytes(&value.to_bytes(), SC_HASH_LENGTH); +} + +pub fn hash_from_bytes(buf: &[u8]) -> ScHash { + ScHash { id: buf.try_into().expect("invalid Hash length") } +} + +pub fn hash_to_bytes(value: &ScHash) -> &[u8] { + &value.id +} + +pub fn hash_to_string(value: &ScHash) -> String { + // TODO standardize human readable string + base58_encode(&value.id) +} + +fn hash_from_bytes_unchecked(buf: &[u8]) -> ScHash { + ScHash { id: buf.try_into().expect("invalid Hash length") } +} + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +pub struct ScImmutableHash<'a> { + proxy: Proxy<'a>, +} + +impl ScImmutableHash<'_> { + pub fn new(proxy: Proxy) -> ScImmutableHash { + ScImmutableHash { proxy } + } + + pub fn exists(&self) -> bool { + self.proxy.exists() + } + + pub fn to_string(&self) -> String { + hash_to_string(&self.value()) + } + + pub fn value(&self) -> ScHash { + hash_from_bytes(self.proxy.get()) + } +} + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +// value proxy for mutable ScHash in host container +pub struct ScMutableHash<'a> { + proxy: Proxy<'a>, +} + +impl ScMutableHash<'_> { + pub fn new(proxy: Proxy) -> ScMutableHash { + ScMutableHash { proxy } + } + + pub fn delete(&self) { + self.proxy.delete(); + } + + pub fn exists(&self) -> bool { + self.proxy.exists() + } + + pub fn set_value(&self, val: &ScHash) { + self.proxy.set(hash_to_bytes(&val)); + } + + pub fn to_string(&self) -> String { + hash_to_string(&self.value()) + } + + pub fn value(&self) -> ScHash { + hash_from_bytes(self.proxy.get()) + } +} diff --git a/packages/wasmvm/wasmlib/src/wasmtypes/schname.rs b/packages/wasmvm/wasmlib/src/wasmtypes/schname.rs new file mode 100644 index 0000000000..cf2ac414c7 --- /dev/null +++ b/packages/wasmvm/wasmlib/src/wasmtypes/schname.rs @@ -0,0 +1,113 @@ +// Copyright 2020 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +use std::convert::TryInto; + +use crate::wasmtypes::*; + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +pub const SC_HNAME_LENGTH: usize = 4; + +#[derive(PartialEq, Clone)] +pub struct ScHname { + id: [u8; SC_HNAME_LENGTH], +} + +impl ScHname { + pub fn from_bytes(buf: &[u8]) -> ScHname { + hname_from_bytes(buf) + } + + pub fn to_bytes(&self) -> &[u8] { + hname_to_bytes(self) + } + + pub fn to_string(&self) -> String { + hname_to_string(self) + } +} + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +pub fn hname_decode(dec: &mut WasmDecoder) -> ScHname { + hname_from_bytes_unchecked(dec.fixed_bytes(SC_HNAME_LENGTH)) +} + +pub fn hname_encode(enc: &mut WasmEncoder, value: &ScHname) { + enc.fixed_bytes(&value.to_bytes(), SC_HNAME_LENGTH); +} + +pub fn hname_from_bytes(buf: &[u8]) -> ScHname { + ScHname { id: buf.try_into().expect("invalid Hname length") } +} + +pub fn hname_to_bytes(value: &ScHname) -> &[u8] { + &value.id +} + +pub fn hname_to_string(value: &ScHname) -> String { + // TODO standardize human readable string + base58_encode(&value.id) +} + +fn hname_from_bytes_unchecked(buf: &[u8]) -> ScHname { + ScHname { id: buf.try_into().expect("invalid Hname length") } +} + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +pub struct ScImmutableHname<'a> { + proxy: Proxy<'a>, +} + +impl ScImmutableHname<'_> { + pub fn new(proxy: Proxy) -> ScImmutableHname { + ScImmutableHname { proxy } + } + + pub fn exists(&self) -> bool { + self.proxy.exists() + } + + pub fn to_string(&self) -> String { + hname_to_string(&self.value()) + } + + pub fn value(&self) -> ScHname { + hname_from_bytes(self.proxy.get()) + } +} + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +// value proxy for mutable ScHname in host container +pub struct ScMutableHname<'a> { + proxy: Proxy<'a>, +} + +impl ScMutableHname<'_> { + pub fn new(proxy: Proxy) -> ScMutableHname { + ScMutableHname { proxy } + } + + pub fn delete(&self) { + self.proxy.delete(); + } + + pub fn exists(&self) -> bool { + self.proxy.exists() + } + + pub fn set_value(&self, val: &ScHname) { + self.proxy.set(hname_to_bytes(&val)); + } + + pub fn to_string(&self) -> String { + hname_to_string(&self.value()) + } + + pub fn value(&self) -> ScHname { + hname_from_bytes(self.proxy.get()) + } +} diff --git a/packages/wasmvm/wasmlib/src/wasmtypes/screquestid.rs b/packages/wasmvm/wasmlib/src/wasmtypes/screquestid.rs new file mode 100644 index 0000000000..4e782fe0a5 --- /dev/null +++ b/packages/wasmvm/wasmlib/src/wasmtypes/screquestid.rs @@ -0,0 +1,113 @@ +// Copyright 2020 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +use std::convert::TryInto; + +use crate::wasmtypes::*; + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +pub const SC_REQUEST_ID_LENGTH: usize = 34; + +#[derive(PartialEq, Clone)] +pub struct ScRequestId { + id: [u8; SC_REQUEST_ID_LENGTH], +} + +impl ScRequestId { + pub fn from_bytes(buf: &[u8]) -> ScRequestId { + request_id_from_bytes(buf) + } + + pub fn to_bytes(&self) -> &[u8] { + request_id_to_bytes(self) + } + + pub fn to_string(&self) -> String { + request_id_to_string(self) + } +} + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +pub fn request_id_decode(dec: &mut WasmDecoder) -> ScRequestId { + request_id_from_bytes_unchecked(dec.fixed_bytes(SC_REQUEST_ID_LENGTH)) +} + +pub fn request_id_encode(enc: &mut WasmEncoder, value: &ScRequestId) { + enc.fixed_bytes(&value.to_bytes(), SC_REQUEST_ID_LENGTH); +} + +pub fn request_id_from_bytes(buf: &[u8]) -> ScRequestId { + ScRequestId { id: buf.try_into().expect("invalid RequestId length") } +} + +pub fn request_id_to_bytes(value: &ScRequestId) -> &[u8] { + &value.id +} + +pub fn request_id_to_string(value: &ScRequestId) -> String { + // TODO standardize human readable string + base58_encode(&value.id) +} + +fn request_id_from_bytes_unchecked(buf: &[u8]) -> ScRequestId { + ScRequestId { id: buf.try_into().expect("invalid RequestId length") } +} + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +pub struct ScImmutableRequestId<'a> { + proxy: Proxy<'a>, +} + +impl ScImmutableRequestId<'_> { + pub fn new(proxy: Proxy) -> ScImmutableRequestId { + ScImmutableRequestId { proxy } + } + + pub fn exists(&self) -> bool { + self.proxy.exists() + } + + pub fn to_string(&self) -> String { + request_id_to_string(&self.value()) + } + + pub fn value(&self) -> ScRequestId { + request_id_from_bytes(self.proxy.get()) + } +} + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +// value proxy for mutable ScRequestId in host container +pub struct ScMutableRequestId<'a> { + proxy: Proxy<'a>, +} + +impl ScMutableRequestId<'_> { + pub fn new(proxy: Proxy) -> ScMutableRequestId { + ScMutableRequestId { proxy } + } + + pub fn delete(&self) { + self.proxy.delete(); + } + + pub fn exists(&self) -> bool { + self.proxy.exists() + } + + pub fn set_value(&self, val: &ScRequestId) { + self.proxy.set(request_id_to_bytes(&val)); + } + + pub fn to_string(&self) -> String { + request_id_to_string(&self.value()) + } + + pub fn value(&self) -> ScRequestId { + request_id_from_bytes(self.proxy.get()) + } +} diff --git a/packages/wasmvm/wasmlib/src/wasmtypes/scuint16.rs b/packages/wasmvm/wasmlib/src/wasmtypes/scuint16.rs new file mode 100644 index 0000000000..76bcdad875 --- /dev/null +++ b/packages/wasmvm/wasmlib/src/wasmtypes/scuint16.rs @@ -0,0 +1,92 @@ +// Copyright 2020 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +use std::convert::TryInto; + +use crate::wasmtypes::*; + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +pub const SC_UINT16_LENGTH: usize = 2; + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +pub fn uint16_decode(dec: &mut WasmDecoder) -> u16 { + dec.vlu_decode(16) as u16 +} + +pub fn uint16_encode(enc: &mut WasmEncoder, value: u16) { + enc.vlu_encode(value as u64); +} + +pub fn uint16_from_bytes(buf: &[u8]) -> u16 { + if buf.len() == 0 { + return 0; + } + u16::from_le_bytes(buf.try_into().expect("invalid Uint16 length")) +} + +pub fn uint16_to_bytes(value: u16) -> Vec { + value.to_le_bytes().to_vec() +} + +pub fn uint16_to_string(value: u16) -> String { + value.to_string() +} + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +pub struct ScImmutableUint16<'a> { + proxy: Proxy<'a>, +} + +impl ScImmutableUint16<'_> { + pub fn new(proxy: Proxy) -> ScImmutableUint16 { + ScImmutableUint16 { proxy } + } + + pub fn exists(&self) -> bool { + self.proxy.exists() + } + + pub fn to_string(&self) -> String { + uint16_to_string(self.value()) + } + + pub fn value(&self) -> u16 { + uint16_from_bytes(self.proxy.get()) + } +} + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +// value proxy for mutable u16 in host container +pub struct ScMutableUint16<'a> { + proxy: Proxy<'a>, +} + +impl ScMutableUint16<'_> { + pub fn new(proxy: Proxy) -> ScMutableUint16 { + ScMutableUint16 { proxy } + } + + pub fn delete(&self) { + self.proxy.delete(); + } + + pub fn exists(&self) -> bool { + self.proxy.exists() + } + + pub fn set_value(&self, val: u16) { + self.proxy.set(&uint16_to_bytes(val)); + } + + pub fn to_string(&self) -> String { + uint16_to_string(self.value()) + } + + pub fn value(&self) -> u16 { + uint16_from_bytes(self.proxy.get()) + } +} diff --git a/packages/wasmvm/wasmlib/src/wasmtypes/scuint32.rs b/packages/wasmvm/wasmlib/src/wasmtypes/scuint32.rs new file mode 100644 index 0000000000..9560725c19 --- /dev/null +++ b/packages/wasmvm/wasmlib/src/wasmtypes/scuint32.rs @@ -0,0 +1,92 @@ +// Copyright 2020 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +use std::convert::TryInto; + +use crate::wasmtypes::*; + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +pub const SC_UINT32_LENGTH: usize = 4; + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +pub fn uint32_decode(dec: &mut WasmDecoder) -> u32 { + dec.vlu_decode(32) as u32 +} + +pub fn uint32_encode(enc: &mut WasmEncoder, value: u32) { + enc.vlu_encode(value as u64); +} + +pub fn uint32_from_bytes(buf: &[u8]) -> u32 { + if buf.len() == 0 { + return 0; + } + u32::from_le_bytes(buf.try_into().expect("invalid u32 length")) +} + +pub fn uint32_to_bytes(value: u32) -> Vec { + value.to_le_bytes().to_vec() +} + +pub fn uint32_to_string(value: u32) -> String { + value.to_string() +} + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +pub struct ScImmutableUint32<'a> { + proxy: Proxy<'a>, +} + +impl ScImmutableUint32<'_> { + pub fn new(proxy: Proxy) -> ScImmutableUint32 { + ScImmutableUint32 { proxy } + } + + pub fn exists(&self) -> bool { + self.proxy.exists() + } + + pub fn to_string(&self) -> String { + uint32_to_string(self.value()) + } + + pub fn value(&self) -> u32 { + uint32_from_bytes(self.proxy.get()) + } +} + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +// value proxy for mutable u32 in host container +pub struct ScMutableUint32<'a> { + proxy: Proxy<'a>, +} + +impl ScMutableUint32<'_> { + pub fn new(proxy: Proxy) -> ScMutableUint32 { + ScMutableUint32 { proxy } + } + + pub fn delete(&self) { + self.proxy.delete(); + } + + pub fn exists(&self) -> bool { + self.proxy.exists() + } + + pub fn set_value(&self, val: u32) { + self.proxy.set(&uint32_to_bytes(val)); + } + + pub fn to_string(&self) -> String { + uint32_to_string(self.value()) + } + + pub fn value(&self) -> u32 { + uint32_from_bytes(self.proxy.get()) + } +} diff --git a/packages/wasmvm/wasmlib/src/wasmtypes/scuint64.rs b/packages/wasmvm/wasmlib/src/wasmtypes/scuint64.rs new file mode 100644 index 0000000000..44ad029b4f --- /dev/null +++ b/packages/wasmvm/wasmlib/src/wasmtypes/scuint64.rs @@ -0,0 +1,92 @@ +// Copyright 2020 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +use std::convert::TryInto; + +use crate::wasmtypes::*; + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +pub const SC_UINT64_LENGTH: usize = 8; + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +pub fn uint64_decode(dec: &mut WasmDecoder) -> u64 { + dec.vlu_decode(64) +} + +pub fn uint64_encode(enc: &mut WasmEncoder, value: u64) { + enc.vlu_encode(value); +} + +pub fn uint64_from_bytes(buf: &[u8]) -> u64 { + if buf.len() == 0 { + return 0; + } + u64::from_le_bytes(buf.try_into().expect("invalid Uint64 length")) +} + +pub fn uint64_to_bytes(value: u64) -> Vec { + value.to_le_bytes().to_vec() +} + +pub fn uint64_to_string(value: u64) -> String { + value.to_string() +} + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +pub struct ScImmutableUint64<'a> { + proxy: Proxy<'a>, +} + +impl ScImmutableUint64<'_> { + pub fn new(proxy: Proxy) -> ScImmutableUint64 { + ScImmutableUint64 { proxy } + } + + pub fn exists(&self) -> bool { + self.proxy.exists() + } + + pub fn to_string(&self) -> String { + uint64_to_string(self.value()) + } + + pub fn value(&self) -> u64 { + uint64_from_bytes(self.proxy.get()) + } +} + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +// value proxy for mutable u64 in host container +pub struct ScMutableUint64<'a> { + proxy: Proxy<'a>, +} + +impl ScMutableUint64<'_> { + pub fn new(proxy: Proxy) -> ScMutableUint64 { + ScMutableUint64 { proxy } + } + + pub fn delete(&self) { + self.proxy.delete(); + } + + pub fn exists(&self) -> bool { + self.proxy.exists() + } + + pub fn set_value(&self, val: u64) { + self.proxy.set(&uint64_to_bytes(val)); + } + + pub fn to_string(&self) -> String { + uint64_to_string(self.value()) + } + + pub fn value(&self) -> u64 { + uint64_from_bytes(self.proxy.get()) + } +} diff --git a/packages/wasmvm/wasmlib/src/wasmtypes/scuint8.rs b/packages/wasmvm/wasmlib/src/wasmtypes/scuint8.rs new file mode 100644 index 0000000000..1a4d26a897 --- /dev/null +++ b/packages/wasmvm/wasmlib/src/wasmtypes/scuint8.rs @@ -0,0 +1,96 @@ +// Copyright 2020 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +use std::convert::TryInto; + +use crate::host::*; +use crate::wasmtypes::*; + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +pub const SC_UINT8_LENGTH: usize = 1; + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +pub fn uint8_decode(dec: &mut WasmDecoder) -> u8 { + dec.vlu_decode(8) as u8 +} + +pub fn uint8_encode(enc: &mut WasmEncoder, value: u8) { + enc.vlu_encode(value as u64); +} + +pub fn uint8_from_bytes(buf: &[u8]) -> u8 { + if buf.len() == 0 { + return 0; + } + if buf.len() != SC_UINT8_LENGTH { + panic("invalid Uint8 length"); + } + buf[0] +} + +pub fn uint8_to_bytes(value: u8) -> Vec { + [value].to_vec() +} + +pub fn uint8_to_string(value: u8) -> String { + value.to_string() +} + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +pub struct ScImmutableUint8<'a> { + proxy: Proxy<'a>, +} + +impl ScImmutableUint8<'_> { + pub fn new(proxy: Proxy) -> ScImmutableUint8 { + ScImmutableUint8 { proxy } + } + + pub fn exists(&self) -> bool { + self.proxy.exists() + } + + pub fn to_string(&self) -> String { + uint8_to_string(self.value()) + } + + pub fn value(&self) -> u8 { + uint8_from_bytes(self.proxy.get()) + } +} + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +// value proxy for mutable u8 in host container +pub struct ScMutableUint8<'a> { + proxy: Proxy<'a>, +} + +impl ScMutableUint8<'_> { + pub fn new(proxy: Proxy) -> ScMutableUint8 { + ScMutableUint8 { proxy } + } + + pub fn delete(&self) { + self.proxy.delete(); + } + + pub fn exists(&self) -> bool { + self.proxy.exists() + } + + pub fn set_value(&self, val: u8) { + self.proxy.set(&uint8_to_bytes(val)); + } + + pub fn to_string(&self) -> String { + uint8_to_string(self.value()) + } + + pub fn value(&self) -> u8 { + uint8_from_bytes(self.proxy.get()) + } +} diff --git a/packages/wasmvm/wasmsolo/solocontext.go b/packages/wasmvm/wasmsolo/solocontext.go index 61facfcbaf..728cc9c108 100644 --- a/packages/wasmvm/wasmsolo/solocontext.go +++ b/packages/wasmvm/wasmsolo/solocontext.go @@ -30,10 +30,10 @@ const ( ) var ( // TODO set back to false - GoDebug = flag.Bool("godebug", false, "debug go smart contract code") + GoDebug = flag.Bool("godebug", true, "debug go smart contract code") GoWasm = flag.Bool("gowasm", false, "prefer go wasm smart contract code") GoWasmEdge = flag.Bool("gowasmedge", false, "use WasmEdge instead of WasmTime") - TsWasm = flag.Bool("tswasm", true, "prefer typescript wasm smart contract code") + TsWasm = flag.Bool("tswasm", false, "prefer typescript wasm smart contract code") ) type SoloContext struct { diff --git a/tools/schema/generator/rstemplates/alltemplates.go b/tools/schema/generator/rstemplates/alltemplates.go index 0764cd0b16..02f1fb4a6c 100644 --- a/tools/schema/generator/rstemplates/alltemplates.go +++ b/tools/schema/generator/rstemplates/alltemplates.go @@ -33,6 +33,7 @@ var TypeDependent = model.StringMapMap{ "Address": "ScAddress", "AgentID": "ScAgentID", "Bool": "bool", + "Bytes": "Vec", "ChainID": "ScChainID", "Color": "ScColor", "Hash": "ScHash", diff --git a/tools/schema/generator/rstemplates/mod.go b/tools/schema/generator/rstemplates/mod.go index bfa74afb9f..37dace60da 100644 --- a/tools/schema/generator/rstemplates/mod.go +++ b/tools/schema/generator/rstemplates/mod.go @@ -7,12 +7,28 @@ var modRs = map[string]string{ pub use consts::*; pub use contract::*; -pub use params::*; -pub use results::*; +$#set moduleName params +$#if params pubUseModule +$#set moduleName results +$#if results pubUseModule +$#set moduleName structs +$#if structs pubUseModule pub mod consts; pub mod contract; -pub mod params; -pub mod results; +$#set moduleName params +$#if params pubModModule +$#set moduleName results +$#if results pubModModule +$#set moduleName structs +$#if structs pubModModule +`, + // ******************************* + "pubUseModule": ` +pub use $moduleName::*; +`, + // ******************************* + "pubModModule": ` +pub mod $moduleName; `, } diff --git a/tools/schema/generator/rstemplates/structs.go b/tools/schema/generator/rstemplates/structs.go index 6d0e1fc499..7c76433933 100644 --- a/tools/schema/generator/rstemplates/structs.go +++ b/tools/schema/generator/rstemplates/structs.go @@ -6,7 +6,7 @@ var structsRs = map[string]string{ #![allow(dead_code)] #![allow(unused_imports)] -use wasmlib::*; +$#if core useCrate useWasmLib use wasmlib::host::*; $#if typedefs useTypeDefs $#each structs structType From 3c987e6fd5d0bdf3374609e1e5932cb5b4af0166 Mon Sep 17 00:00:00 2001 From: Eric Hop Date: Mon, 31 Jan 2022 21:30:58 -0800 Subject: [PATCH 055/111] Rust wasmtypes complete --- .../wasm/testwasmlib/test/testwasmlib_test.go | 10 +- .../wasmlib/go/wasmlib/wasmtypes/scbool.go | 2 +- .../wasmlib/src/wasmrequests/structs.rs | 2 +- .../wasmvm/wasmlib/src/wasmtypes/codec.rs | 9 +- packages/wasmvm/wasmlib/src/wasmtypes/mod.rs | 28 ++--- .../wasmvm/wasmlib/src/wasmtypes/proxy.rs | 82 ++++++++++++- .../wasmvm/wasmlib/src/wasmtypes/scaddress.rs | 4 +- .../wasmvm/wasmlib/src/wasmtypes/scagentid.rs | 4 +- .../wasmvm/wasmlib/src/wasmtypes/scbool.rs | 114 ++++++++++++++++++ .../wasmvm/wasmlib/src/wasmtypes/scbytes.rs | 86 +++++++++++++ .../wasmvm/wasmlib/src/wasmtypes/scchainid.rs | 4 +- .../wasmvm/wasmlib/src/wasmtypes/sccolor.rs | 4 +- .../wasmvm/wasmlib/src/wasmtypes/schash.rs | 4 +- .../wasmvm/wasmlib/src/wasmtypes/schname.rs | 4 +- .../wasmvm/wasmlib/src/wasmtypes/scint16.rs | 92 ++++++++++++++ .../wasmvm/wasmlib/src/wasmtypes/scint32.rs | 92 ++++++++++++++ .../wasmvm/wasmlib/src/wasmtypes/scint64.rs | 92 ++++++++++++++ .../wasmvm/wasmlib/src/wasmtypes/scint8.rs | 96 +++++++++++++++ .../wasmlib/src/wasmtypes/screquestid.rs | 4 +- .../wasmvm/wasmlib/src/wasmtypes/scstring.rs | 85 +++++++++++++ .../wasmvm/wasmlib/src/wasmtypes/scuint16.rs | 4 +- .../wasmvm/wasmlib/src/wasmtypes/scuint32.rs | 4 +- .../wasmvm/wasmlib/src/wasmtypes/scuint64.rs | 4 +- .../wasmvm/wasmlib/src/wasmtypes/scuint8.rs | 8 +- .../wasmlib/ts/wasmlib/wasmtypes/proxy.ts | 24 ++-- .../wasmlib/ts/wasmlib/wasmtypes/scbool.ts | 2 +- .../wasmlib/ts/wasmlib/wasmtypes/scstring.ts | 2 +- 27 files changed, 801 insertions(+), 65 deletions(-) create mode 100644 packages/wasmvm/wasmlib/src/wasmtypes/scbool.rs create mode 100644 packages/wasmvm/wasmlib/src/wasmtypes/scbytes.rs create mode 100644 packages/wasmvm/wasmlib/src/wasmtypes/scint16.rs create mode 100644 packages/wasmvm/wasmlib/src/wasmtypes/scint32.rs create mode 100644 packages/wasmvm/wasmlib/src/wasmtypes/scint64.rs create mode 100644 packages/wasmvm/wasmlib/src/wasmtypes/scint8.rs create mode 100644 packages/wasmvm/wasmlib/src/wasmtypes/scstring.rs diff --git a/contracts/wasm/testwasmlib/test/testwasmlib_test.go b/contracts/wasm/testwasmlib/test/testwasmlib_test.go index a3c102d407..1f7d4a7cb1 100644 --- a/contracts/wasm/testwasmlib/test/testwasmlib_test.go +++ b/contracts/wasm/testwasmlib/test/testwasmlib_test.go @@ -260,21 +260,21 @@ func TestClearMap(t *testing.T) { require.NoError(t, ctx.Err) as = testwasmlib.ScFuncs.MapSet(ctx) - as.Params.Name().SetValue("bands") + as.Params.Name().SetValue("albums") as.Params.Key().SetValue("Dire Straits") as.Params.Value().SetValue("Calling Elvis") as.Func.TransferIotas(1).Post() require.NoError(t, ctx.Err) as = testwasmlib.ScFuncs.MapSet(ctx) - as.Params.Name().SetValue("bands") + as.Params.Name().SetValue("albums") as.Params.Key().SetValue("ELO") as.Params.Value().SetValue("Mr. Blue Sky") as.Func.TransferIotas(1).Post() require.NoError(t, ctx.Err) av := testwasmlib.ScFuncs.MapValue(ctx) - av.Params.Name().SetValue("bands") + av.Params.Name().SetValue("albums") av.Params.Key().SetValue("Dire Straits") av.Func.Call() require.NoError(t, ctx.Err) @@ -283,12 +283,12 @@ func TestClearMap(t *testing.T) { require.EqualValues(t, "Calling Elvis", value.Value()) ac := testwasmlib.ScFuncs.MapClear(ctx) - ac.Params.Name().SetValue("bands") + ac.Params.Name().SetValue("albums") ac.Func.TransferIotas(1).Post() require.NoError(t, ctx.Err) av = testwasmlib.ScFuncs.MapValue(ctx) - av.Params.Name().SetValue("bands") + av.Params.Name().SetValue("albums") av.Params.Key().SetValue("Dire Straits") av.Func.Call() require.NoError(t, ctx.Err) diff --git a/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/scbool.go b/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/scbool.go index 8641a32d99..20dfea296f 100644 --- a/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/scbool.go +++ b/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/scbool.go @@ -12,7 +12,7 @@ const ( // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ func BoolDecode(dec *WasmDecoder) bool { - return dec.Byte() != 0 + return dec.Byte() != ScBoolFalse } func BoolEncode(enc *WasmEncoder, value bool) { diff --git a/packages/wasmvm/wasmlib/src/wasmrequests/structs.rs b/packages/wasmvm/wasmlib/src/wasmrequests/structs.rs index d1eb3e91db..71d09fc67d 100644 --- a/packages/wasmvm/wasmlib/src/wasmrequests/structs.rs +++ b/packages/wasmvm/wasmlib/src/wasmrequests/structs.rs @@ -8,7 +8,7 @@ #![allow(dead_code)] #![allow(unused_imports)] -use wasmlib::*; +use crate::*; use wasmlib::host::*; #[derive(Clone)] diff --git a/packages/wasmvm/wasmlib/src/wasmtypes/codec.rs b/packages/wasmvm/wasmlib/src/wasmtypes/codec.rs index 06f505205a..37864540f1 100644 --- a/packages/wasmvm/wasmlib/src/wasmtypes/codec.rs +++ b/packages/wasmvm/wasmlib/src/wasmtypes/codec.rs @@ -206,6 +206,11 @@ pub fn base58_encode(buf: &[u8]) -> String { } pub fn hex(buf: &[u8]) -> String { - //TODO - "".to_string() + let hexa = "0123456789abcdef".as_bytes(); + let mut res: Vec = Vec::new(); + for b in buf { + res.push(hexa[*b as usize >> 4]); + res.push(hexa[*b as usize & 0x0f]); + } + String::from_utf8(res).expect("WTF? invalid?") } diff --git a/packages/wasmvm/wasmlib/src/wasmtypes/mod.rs b/packages/wasmvm/wasmlib/src/wasmtypes/mod.rs index c4b1d3aa8a..c6375cbd0a 100644 --- a/packages/wasmvm/wasmlib/src/wasmtypes/mod.rs +++ b/packages/wasmvm/wasmlib/src/wasmtypes/mod.rs @@ -7,18 +7,18 @@ pub use codec::*; pub use proxy::*; pub use scaddress::*; pub use scagentid::*; -// pub use scbool::*; -//pub use scbytes::*; +pub use scbool::*; +pub use scbytes::*; pub use scchainid::*; pub use sccolor::*; pub use schash::*; pub use schname::*; -// pub use scint8::*; -// pub use scint16::*; -// pub use scint32::*; -// pub use scint64::*; +pub use scint8::*; +pub use scint16::*; +pub use scint32::*; +pub use scint64::*; pub use screquestid::*; -// pub use scstring::*; +pub use scstring::*; pub use scuint8::*; pub use scuint16::*; pub use scuint32::*; @@ -28,18 +28,18 @@ pub mod codec; pub mod proxy; pub mod scaddress; pub mod scagentid; -// pub mod scbool; -// pub mod scbytes; +pub mod scbool; +pub mod scbytes; pub mod scchainid; pub mod sccolor; pub mod schash; pub mod schname; -// pub mod scint8; -// pub mod scint16; -// pub mod scint32; -// pub mod scint64; +pub mod scint8; +pub mod scint16; +pub mod scint32; +pub mod scint64; pub mod screquestid; -// pub mod scstring; +pub mod scstring; pub mod scuint8; pub mod scuint16; pub mod scuint32; diff --git a/packages/wasmvm/wasmlib/src/wasmtypes/proxy.rs b/packages/wasmvm/wasmlib/src/wasmtypes/proxy.rs index e0c445d003..33cc54cf7f 100644 --- a/packages/wasmvm/wasmlib/src/wasmtypes/proxy.rs +++ b/packages/wasmvm/wasmlib/src/wasmtypes/proxy.rs @@ -1,6 +1,7 @@ // Copyright 2020 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 +use crate::host::*; use crate::wasmtypes::*; pub trait IKvStore { @@ -10,33 +11,106 @@ pub trait IKvStore { fn set(&self, key: &[u8], value: &[u8]); } -pub struct Proxy<'a> { +pub struct Proxy<'a> { key: Vec, kv_store: &'a dyn IKvStore, } impl Proxy<'_> { pub fn new(kv_store: &dyn IKvStore) -> Proxy { - Proxy { key:Vec::new(), kv_store } + Proxy { kv_store, key: Vec::new() } + } + + pub fn append(&self) -> Proxy { + let length = self.length(); + self.expand(length + 1); + self.element(length) + } + + pub fn clear_array(&self) { + let mut length = self.length(); + while length != 0 { + length -= 1; + self.element(length).delete(); + } + + // clear the length counter + self.delete(); + } + + pub fn clear_map(&self) { + // TODO clear prefix + + // clear the length counter + self.delete(); } pub fn delete(&self) { self.kv_store.delete(&self.key); } + fn element(&self, index: u32) -> Proxy { + let mut enc = WasmEncoder::new(); + uint32_encode(&mut enc, index); + // 0x23 is '#' + self.sub(0x23, &enc.buf()) + } + pub fn exists(&self) -> bool { self.kv_store.exists(&self.key) } + pub fn expand(&self, length: u32) { + // update the length counter + let mut enc = WasmEncoder::new(); + uint32_encode(&mut enc, length); + self.set(&enc.buf()); + } + pub fn get(&self) -> &[u8] { self.kv_store.get(&self.key) } - pub fn root(&self, key:&str) -> Proxy { - Proxy { key: key.as_bytes().to_vec(), kv_store: self.kv_store } + pub fn index(&self, index: u32) -> Proxy { + let size = self.length(); + if index >= size { + if index == size { + panic("invalid index: use append"); + } + panic("invalid index"); + } + self.element(index) + } + + pub fn key(&self, key: &[u8]) -> Proxy { + // 0x2e is '.' + self.sub(0x2e, key) + } + + pub fn length(&self) -> u32 { + let buf = self.get(); + if buf.len() == 0 { + return 0; + } + let mut dec = WasmDecoder::new(buf); + uint32_decode(&mut dec) + } + + pub fn root(&self, key: &str) -> Proxy { + Proxy { kv_store: self.kv_store, key: string_to_bytes(key).to_vec() } } pub fn set(&self, value: &[u8]) { self.kv_store.set(&self.key, value); } + + fn sub(&self, sep: u8, key: &[u8]) -> Proxy { + if self.key.len() == 0 { + return Proxy { kv_store: self.kv_store, key: key.to_vec() }; + } + let mut buf: Vec = self.key.clone(); + buf.push(sep); + buf.extend_from_slice(key); + Proxy { kv_store: self.kv_store, key: buf } + } } diff --git a/packages/wasmvm/wasmlib/src/wasmtypes/scaddress.rs b/packages/wasmvm/wasmlib/src/wasmtypes/scaddress.rs index af311cf0da..773b8b37ca 100644 --- a/packages/wasmvm/wasmlib/src/wasmtypes/scaddress.rs +++ b/packages/wasmvm/wasmlib/src/wasmtypes/scaddress.rs @@ -99,8 +99,8 @@ impl ScMutableAddress<'_> { self.proxy.exists() } - pub fn set_value(&self, val: &ScAddress) { - self.proxy.set(address_to_bytes(&val)); + pub fn set_value(&self, value: &ScAddress) { + self.proxy.set(address_to_bytes(&value)); } pub fn to_string(&self) -> String { diff --git a/packages/wasmvm/wasmlib/src/wasmtypes/scagentid.rs b/packages/wasmvm/wasmlib/src/wasmtypes/scagentid.rs index 0850ce5de4..b603252fde 100644 --- a/packages/wasmvm/wasmlib/src/wasmtypes/scagentid.rs +++ b/packages/wasmvm/wasmlib/src/wasmtypes/scagentid.rs @@ -99,8 +99,8 @@ impl ScMutableAgentId<'_> { self.proxy.exists() } - pub fn set_value(&self, val: &ScAgentId) { - self.proxy.set(agent_id_to_bytes(&val)); + pub fn set_value(&self, value: &ScAgentId) { + self.proxy.set(agent_id_to_bytes(&value)); } pub fn to_string(&self) -> String { diff --git a/packages/wasmvm/wasmlib/src/wasmtypes/scbool.rs b/packages/wasmvm/wasmlib/src/wasmtypes/scbool.rs new file mode 100644 index 0000000000..3d85b5cac2 --- /dev/null +++ b/packages/wasmvm/wasmlib/src/wasmtypes/scbool.rs @@ -0,0 +1,114 @@ +// Copyright 2020 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +use std::convert::TryInto; + +use crate::host::*; +use crate::wasmtypes::*; + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +pub const SC_BOOL_LENGTH: usize = 1; +pub const SC_BOOL_FALSE: u8 = 0x00; +pub const SC_BOOL_TRUE: u8 = 0xff; + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +pub fn bool_decode(dec: &mut WasmDecoder) -> bool { + dec.byte() != SC_BOOL_FALSE +} + +pub fn bool_encode(enc: &mut WasmEncoder, value: bool) { + if value { + enc.byte(SC_BOOL_TRUE); + return; + } + enc.byte(SC_BOOL_FALSE); +} + +pub fn bool_from_bytes(buf: &[u8]) -> bool { + if buf.len() == 0 { + return false; + } + if buf.len() != SC_BOOL_LENGTH { + panic("invalid Bool length"); + } + if buf[0] == SC_BOOL_FALSE { + return false; + } + if buf[0] != SC_BOOL_FALSE { + panic("invalid Bool value"); + } + return true; +} + +pub fn bool_to_bytes(value: bool) -> Vec { + if value { + return [SC_BOOL_TRUE].to_vec(); + } + [SC_BOOL_FALSE].to_vec() +} + +pub fn bool_to_string(value: bool) -> String { + if value { + return "1".to_string(); + } + "0".to_string() +} + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +pub struct ScImmutableBool<'a> { + proxy: Proxy<'a>, +} + +impl ScImmutableBool<'_> { + pub fn new(proxy: Proxy) -> ScImmutableBool { + ScImmutableBool { proxy } + } + + pub fn exists(&self) -> bool { + self.proxy.exists() + } + + pub fn to_string(&self) -> String { + bool_to_string(self.value()) + } + + pub fn value(&self) -> bool { + bool_from_bytes(self.proxy.get()) + } +} + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +// value proxy for mutable bool in host container +pub struct ScMutableBool<'a> { + proxy: Proxy<'a>, +} + +impl ScMutableBool<'_> { + pub fn new(proxy: Proxy) -> ScMutableBool { + ScMutableBool { proxy } + } + + pub fn delete(&self) { + self.proxy.delete(); + } + + pub fn exists(&self) -> bool { + self.proxy.exists() + } + + pub fn set_value(&self, value: bool) { + self.proxy.set(&bool_to_bytes(value)); + } + + pub fn to_string(&self) -> String { + bool_to_string(self.value()) + } + + pub fn value(&self) -> bool { + bool_from_bytes(self.proxy.get()) + } +} diff --git a/packages/wasmvm/wasmlib/src/wasmtypes/scbytes.rs b/packages/wasmvm/wasmlib/src/wasmtypes/scbytes.rs new file mode 100644 index 0000000000..d6e591a8a9 --- /dev/null +++ b/packages/wasmvm/wasmlib/src/wasmtypes/scbytes.rs @@ -0,0 +1,86 @@ +// Copyright 2020 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +use std::convert::TryInto; + +use crate::wasmtypes::*; + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +pub fn bytes_decode(dec: &mut WasmDecoder) -> Vec { + dec.bytes().to_vec() +} + +pub fn bytes_encode(enc: &mut WasmEncoder, value: &[u8]) { + enc.bytes(value); +} + +pub fn bytes_from_bytes(buf: &[u8]) -> Vec { + buf.to_vec() +} + +pub fn bytes_to_bytes(value: &[u8]) -> &[u8] { + value +} + +pub fn bytes_to_string(value: &[u8]) -> String { + // TODO standardize human readable string + base58_encode(value) +} + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +pub struct ScImmutableBytes<'a> { + proxy: Proxy<'a>, +} + +impl ScImmutableBytes<'_> { + pub fn new(proxy: Proxy) -> ScImmutableBytes { + ScImmutableBytes { proxy } + } + + pub fn exists(&self) -> bool { + self.proxy.exists() + } + + pub fn to_string(&self) -> String { + bytes_to_string(&self.value()) + } + + pub fn value(&self) -> Vec { + bytes_from_bytes(self.proxy.get()) + } +} + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +// value proxy for mutable ScBytes in host container +pub struct ScMutableBytes<'a> { + proxy: Proxy<'a>, +} + +impl ScMutableBytes<'_> { + pub fn new(proxy: Proxy) -> ScMutableBytes { + ScMutableBytes { proxy } + } + + pub fn delete(&self) { + self.proxy.delete(); + } + + pub fn exists(&self) -> bool { + self.proxy.exists() + } + + pub fn set_value(&self, value: &[u8]) { + self.proxy.set(bytes_to_bytes(value)); + } + + pub fn to_string(&self) -> String { + bytes_to_string(&self.value()) + } + + pub fn value(&self) -> Vec { + bytes_from_bytes(self.proxy.get()) + } +} diff --git a/packages/wasmvm/wasmlib/src/wasmtypes/scchainid.rs b/packages/wasmvm/wasmlib/src/wasmtypes/scchainid.rs index 387a454c6d..4f27bc1c99 100644 --- a/packages/wasmvm/wasmlib/src/wasmtypes/scchainid.rs +++ b/packages/wasmvm/wasmlib/src/wasmtypes/scchainid.rs @@ -99,8 +99,8 @@ impl ScMutableChainId<'_> { self.proxy.exists() } - pub fn set_value(&self, val: &ScChainId) { - self.proxy.set(chain_id_to_bytes(&val)); + pub fn set_value(&self, value: &ScChainId) { + self.proxy.set(chain_id_to_bytes(&value)); } pub fn to_string(&self) -> String { diff --git a/packages/wasmvm/wasmlib/src/wasmtypes/sccolor.rs b/packages/wasmvm/wasmlib/src/wasmtypes/sccolor.rs index 58cb50050d..fc43365f63 100644 --- a/packages/wasmvm/wasmlib/src/wasmtypes/sccolor.rs +++ b/packages/wasmvm/wasmlib/src/wasmtypes/sccolor.rs @@ -102,8 +102,8 @@ impl ScMutableColor<'_> { self.proxy.exists() } - pub fn set_value(&self, val: &ScColor) { - self.proxy.set(color_to_bytes(&val)); + pub fn set_value(&self, value: &ScColor) { + self.proxy.set(color_to_bytes(&value)); } pub fn to_string(&self) -> String { diff --git a/packages/wasmvm/wasmlib/src/wasmtypes/schash.rs b/packages/wasmvm/wasmlib/src/wasmtypes/schash.rs index 1ca8bd6b0b..8654aebab4 100644 --- a/packages/wasmvm/wasmlib/src/wasmtypes/schash.rs +++ b/packages/wasmvm/wasmlib/src/wasmtypes/schash.rs @@ -99,8 +99,8 @@ impl ScMutableHash<'_> { self.proxy.exists() } - pub fn set_value(&self, val: &ScHash) { - self.proxy.set(hash_to_bytes(&val)); + pub fn set_value(&self, value: &ScHash) { + self.proxy.set(hash_to_bytes(&value)); } pub fn to_string(&self) -> String { diff --git a/packages/wasmvm/wasmlib/src/wasmtypes/schname.rs b/packages/wasmvm/wasmlib/src/wasmtypes/schname.rs index cf2ac414c7..501b9bd084 100644 --- a/packages/wasmvm/wasmlib/src/wasmtypes/schname.rs +++ b/packages/wasmvm/wasmlib/src/wasmtypes/schname.rs @@ -99,8 +99,8 @@ impl ScMutableHname<'_> { self.proxy.exists() } - pub fn set_value(&self, val: &ScHname) { - self.proxy.set(hname_to_bytes(&val)); + pub fn set_value(&self, value: &ScHname) { + self.proxy.set(hname_to_bytes(&value)); } pub fn to_string(&self) -> String { diff --git a/packages/wasmvm/wasmlib/src/wasmtypes/scint16.rs b/packages/wasmvm/wasmlib/src/wasmtypes/scint16.rs new file mode 100644 index 0000000000..cd1500bc2b --- /dev/null +++ b/packages/wasmvm/wasmlib/src/wasmtypes/scint16.rs @@ -0,0 +1,92 @@ +// Copyright 2020 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +use std::convert::TryInto; + +use crate::wasmtypes::*; + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +pub const SC_INT16_LENGTH: usize = 2; + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +pub fn int16_decode(dec: &mut WasmDecoder) -> i16 { + dec.vli_decode(16) as i16 +} + +pub fn int16_encode(enc: &mut WasmEncoder, value: i16) { + enc.vli_encode(value as i64); +} + +pub fn int16_from_bytes(buf: &[u8]) -> i16 { + if buf.len() == 0 { + return 0; + } + i16::from_le_bytes(buf.try_into().expect("invalid Int16 length")) +} + +pub fn int16_to_bytes(value: i16) -> Vec { + value.to_le_bytes().to_vec() +} + +pub fn int16_to_string(value: i16) -> String { + value.to_string() +} + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +pub struct ScImmutableInt16<'a> { + proxy: Proxy<'a>, +} + +impl ScImmutableInt16<'_> { + pub fn new(proxy: Proxy) -> ScImmutableInt16 { + ScImmutableInt16 { proxy } + } + + pub fn exists(&self) -> bool { + self.proxy.exists() + } + + pub fn to_string(&self) -> String { + int16_to_string(self.value()) + } + + pub fn value(&self) -> i16 { + int16_from_bytes(self.proxy.get()) + } +} + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +// value proxy for mutable i16 in host container +pub struct ScMutableInt16<'a> { + proxy: Proxy<'a>, +} + +impl ScMutableInt16<'_> { + pub fn new(proxy: Proxy) -> ScMutableInt16 { + ScMutableInt16 { proxy } + } + + pub fn delete(&self) { + self.proxy.delete(); + } + + pub fn exists(&self) -> bool { + self.proxy.exists() + } + + pub fn set_value(&self, value: i16) { + self.proxy.set(&int16_to_bytes(value)); + } + + pub fn to_string(&self) -> String { + int16_to_string(self.value()) + } + + pub fn value(&self) -> i16 { + int16_from_bytes(self.proxy.get()) + } +} diff --git a/packages/wasmvm/wasmlib/src/wasmtypes/scint32.rs b/packages/wasmvm/wasmlib/src/wasmtypes/scint32.rs new file mode 100644 index 0000000000..8b8d587628 --- /dev/null +++ b/packages/wasmvm/wasmlib/src/wasmtypes/scint32.rs @@ -0,0 +1,92 @@ +// Copyright 2020 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +use std::convert::TryInto; + +use crate::wasmtypes::*; + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +pub const SC_INT32_LENGTH: usize = 4; + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +pub fn int32_decode(dec: &mut WasmDecoder) -> i32 { + dec.vli_decode(32) as i32 +} + +pub fn int32_encode(enc: &mut WasmEncoder, value: i32) { + enc.vli_encode(value as i64); +} + +pub fn int32_from_bytes(buf: &[u8]) -> i32 { + if buf.len() == 0 { + return 0; + } + i32::from_le_bytes(buf.try_into().expect("invalid i32 length")) +} + +pub fn int32_to_bytes(value: i32) -> Vec { + value.to_le_bytes().to_vec() +} + +pub fn int32_to_string(value: i32) -> String { + value.to_string() +} + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +pub struct ScImmutableInt32<'a> { + proxy: Proxy<'a>, +} + +impl ScImmutableInt32<'_> { + pub fn new(proxy: Proxy) -> ScImmutableInt32 { + ScImmutableInt32 { proxy } + } + + pub fn exists(&self) -> bool { + self.proxy.exists() + } + + pub fn to_string(&self) -> String { + int32_to_string(self.value()) + } + + pub fn value(&self) -> i32 { + int32_from_bytes(self.proxy.get()) + } +} + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +// value proxy for mutable i32 in host container +pub struct ScMutableInt32<'a> { + proxy: Proxy<'a>, +} + +impl ScMutableInt32<'_> { + pub fn new(proxy: Proxy) -> ScMutableInt32 { + ScMutableInt32 { proxy } + } + + pub fn delete(&self) { + self.proxy.delete(); + } + + pub fn exists(&self) -> bool { + self.proxy.exists() + } + + pub fn set_value(&self, value: i32) { + self.proxy.set(&int32_to_bytes(value)); + } + + pub fn to_string(&self) -> String { + int32_to_string(self.value()) + } + + pub fn value(&self) -> i32 { + int32_from_bytes(self.proxy.get()) + } +} diff --git a/packages/wasmvm/wasmlib/src/wasmtypes/scint64.rs b/packages/wasmvm/wasmlib/src/wasmtypes/scint64.rs new file mode 100644 index 0000000000..188a03b493 --- /dev/null +++ b/packages/wasmvm/wasmlib/src/wasmtypes/scint64.rs @@ -0,0 +1,92 @@ +// Copyright 2020 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +use std::convert::TryInto; + +use crate::wasmtypes::*; + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +pub const SC_INT64_LENGTH: usize = 8; + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +pub fn int64_decode(dec: &mut WasmDecoder) -> i64 { + dec.vli_decode(64) +} + +pub fn int64_encode(enc: &mut WasmEncoder, value: i64) { + enc.vli_encode(value); +} + +pub fn int64_from_bytes(buf: &[u8]) -> i64 { + if buf.len() == 0 { + return 0; + } + i64::from_le_bytes(buf.try_into().expect("invalid Int64 length")) +} + +pub fn int64_to_bytes(value: i64) -> Vec { + value.to_le_bytes().to_vec() +} + +pub fn int64_to_string(value: i64) -> String { + value.to_string() +} + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +pub struct ScImmutableInt64<'a> { + proxy: Proxy<'a>, +} + +impl ScImmutableInt64<'_> { + pub fn new(proxy: Proxy) -> ScImmutableInt64 { + ScImmutableInt64 { proxy } + } + + pub fn exists(&self) -> bool { + self.proxy.exists() + } + + pub fn to_string(&self) -> String { + int64_to_string(self.value()) + } + + pub fn value(&self) -> i64 { + int64_from_bytes(self.proxy.get()) + } +} + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +// value proxy for mutable i64 in host container +pub struct ScMutableInt64<'a> { + proxy: Proxy<'a>, +} + +impl ScMutableInt64<'_> { + pub fn new(proxy: Proxy) -> ScMutableInt64 { + ScMutableInt64 { proxy } + } + + pub fn delete(&self) { + self.proxy.delete(); + } + + pub fn exists(&self) -> bool { + self.proxy.exists() + } + + pub fn set_value(&self, value: i64) { + self.proxy.set(&int64_to_bytes(value)); + } + + pub fn to_string(&self) -> String { + int64_to_string(self.value()) + } + + pub fn value(&self) -> i64 { + int64_from_bytes(self.proxy.get()) + } +} diff --git a/packages/wasmvm/wasmlib/src/wasmtypes/scint8.rs b/packages/wasmvm/wasmlib/src/wasmtypes/scint8.rs new file mode 100644 index 0000000000..3c483c3d38 --- /dev/null +++ b/packages/wasmvm/wasmlib/src/wasmtypes/scint8.rs @@ -0,0 +1,96 @@ +// Copyright 2020 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +use std::convert::TryInto; + +use crate::host::*; +use crate::wasmtypes::*; + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +pub const SC_INT8_LENGTH: usize = 1; + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +pub fn int8_decode(dec: &mut WasmDecoder) -> i8 { + dec.byte() as i8 +} + +pub fn int8_encode(enc: &mut WasmEncoder, value: i8) { + enc.byte(value as u8); +} + +pub fn int8_from_bytes(buf: &[u8]) -> i8 { + if buf.len() == 0 { + return 0; + } + if buf.len() != SC_INT8_LENGTH { + panic("invalid Int8 length"); + } + buf[0] as i8 +} + +pub fn int8_to_bytes(value: i8) -> Vec { + [value as u8].to_vec() +} + +pub fn int8_to_string(value: i8) -> String { + value.to_string() +} + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +pub struct ScImmutableInt8<'a> { + proxy: Proxy<'a>, +} + +impl ScImmutableInt8<'_> { + pub fn new(proxy: Proxy) -> ScImmutableInt8 { + ScImmutableInt8 { proxy } + } + + pub fn exists(&self) -> bool { + self.proxy.exists() + } + + pub fn to_string(&self) -> String { + int8_to_string(self.value()) + } + + pub fn value(&self) -> i8 { + int8_from_bytes(self.proxy.get()) + } +} + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +// value proxy for mutable i8 in host container +pub struct ScMutableInt8<'a> { + proxy: Proxy<'a>, +} + +impl ScMutableInt8<'_> { + pub fn new(proxy: Proxy) -> ScMutableInt8 { + ScMutableInt8 { proxy } + } + + pub fn delete(&self) { + self.proxy.delete(); + } + + pub fn exists(&self) -> bool { + self.proxy.exists() + } + + pub fn set_value(&self, value: i8) { + self.proxy.set(&int8_to_bytes(value)); + } + + pub fn to_string(&self) -> String { + int8_to_string(self.value()) + } + + pub fn value(&self) -> i8 { + int8_from_bytes(self.proxy.get()) + } +} diff --git a/packages/wasmvm/wasmlib/src/wasmtypes/screquestid.rs b/packages/wasmvm/wasmlib/src/wasmtypes/screquestid.rs index 4e782fe0a5..2c16dbe9f2 100644 --- a/packages/wasmvm/wasmlib/src/wasmtypes/screquestid.rs +++ b/packages/wasmvm/wasmlib/src/wasmtypes/screquestid.rs @@ -99,8 +99,8 @@ impl ScMutableRequestId<'_> { self.proxy.exists() } - pub fn set_value(&self, val: &ScRequestId) { - self.proxy.set(request_id_to_bytes(&val)); + pub fn set_value(&self, value: &ScRequestId) { + self.proxy.set(request_id_to_bytes(&value)); } pub fn to_string(&self) -> String { diff --git a/packages/wasmvm/wasmlib/src/wasmtypes/scstring.rs b/packages/wasmvm/wasmlib/src/wasmtypes/scstring.rs new file mode 100644 index 0000000000..7f4fb65fcb --- /dev/null +++ b/packages/wasmvm/wasmlib/src/wasmtypes/scstring.rs @@ -0,0 +1,85 @@ +// Copyright 2020 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +use std::convert::TryInto; + +use crate::wasmtypes::*; + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +pub fn string_decode(dec: &mut WasmDecoder) -> String { + string_from_bytes(dec.bytes()) +} + +pub fn string_encode(enc: &mut WasmEncoder, value: &str) { + enc.bytes(string_to_bytes(value)); +} + +pub fn string_from_bytes(buf: &[u8]) -> String { + String::from_utf8_lossy(buf).to_string() +} + +pub fn string_to_bytes(value: &str) -> &[u8] { + value.as_bytes() +} + +pub fn string_to_string(value: &str) -> String { + value.to_string() +} + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +pub struct ScImmutableString<'a> { + proxy: Proxy<'a>, +} + +impl ScImmutableString<'_> { + pub fn new(proxy: Proxy) -> ScImmutableString { + ScImmutableString { proxy } + } + + pub fn exists(&self) -> bool { + self.proxy.exists() + } + + pub fn to_string(&self) -> String { + self.value() + } + + pub fn value(&self) -> String { + string_from_bytes(self.proxy.get()) + } +} + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +// value proxy for mutable ScString in host container +pub struct ScMutableString<'a> { + proxy: Proxy<'a>, +} + +impl ScMutableString<'_> { + pub fn new(proxy: Proxy) -> ScMutableString { + ScMutableString { proxy } + } + + pub fn delete(&self) { + self.proxy.delete(); + } + + pub fn exists(&self) -> bool { + self.proxy.exists() + } + + pub fn set_value(&self, value: &str) { + self.proxy.set(string_to_bytes(value)); + } + + pub fn to_string(&self) -> String { + self.value() + } + + pub fn value(&self) -> String { + string_from_bytes(self.proxy.get()) + } +} diff --git a/packages/wasmvm/wasmlib/src/wasmtypes/scuint16.rs b/packages/wasmvm/wasmlib/src/wasmtypes/scuint16.rs index 76bcdad875..f1598524d1 100644 --- a/packages/wasmvm/wasmlib/src/wasmtypes/scuint16.rs +++ b/packages/wasmvm/wasmlib/src/wasmtypes/scuint16.rs @@ -78,8 +78,8 @@ impl ScMutableUint16<'_> { self.proxy.exists() } - pub fn set_value(&self, val: u16) { - self.proxy.set(&uint16_to_bytes(val)); + pub fn set_value(&self, value: u16) { + self.proxy.set(&uint16_to_bytes(value)); } pub fn to_string(&self) -> String { diff --git a/packages/wasmvm/wasmlib/src/wasmtypes/scuint32.rs b/packages/wasmvm/wasmlib/src/wasmtypes/scuint32.rs index 9560725c19..f5d7e09cfa 100644 --- a/packages/wasmvm/wasmlib/src/wasmtypes/scuint32.rs +++ b/packages/wasmvm/wasmlib/src/wasmtypes/scuint32.rs @@ -78,8 +78,8 @@ impl ScMutableUint32<'_> { self.proxy.exists() } - pub fn set_value(&self, val: u32) { - self.proxy.set(&uint32_to_bytes(val)); + pub fn set_value(&self, value: u32) { + self.proxy.set(&uint32_to_bytes(value)); } pub fn to_string(&self) -> String { diff --git a/packages/wasmvm/wasmlib/src/wasmtypes/scuint64.rs b/packages/wasmvm/wasmlib/src/wasmtypes/scuint64.rs index 44ad029b4f..54560a045b 100644 --- a/packages/wasmvm/wasmlib/src/wasmtypes/scuint64.rs +++ b/packages/wasmvm/wasmlib/src/wasmtypes/scuint64.rs @@ -78,8 +78,8 @@ impl ScMutableUint64<'_> { self.proxy.exists() } - pub fn set_value(&self, val: u64) { - self.proxy.set(&uint64_to_bytes(val)); + pub fn set_value(&self, value: u64) { + self.proxy.set(&uint64_to_bytes(value)); } pub fn to_string(&self) -> String { diff --git a/packages/wasmvm/wasmlib/src/wasmtypes/scuint8.rs b/packages/wasmvm/wasmlib/src/wasmtypes/scuint8.rs index 1a4d26a897..2ce97663ef 100644 --- a/packages/wasmvm/wasmlib/src/wasmtypes/scuint8.rs +++ b/packages/wasmvm/wasmlib/src/wasmtypes/scuint8.rs @@ -13,11 +13,11 @@ pub const SC_UINT8_LENGTH: usize = 1; // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ pub fn uint8_decode(dec: &mut WasmDecoder) -> u8 { - dec.vlu_decode(8) as u8 + dec.byte() } pub fn uint8_encode(enc: &mut WasmEncoder, value: u8) { - enc.vlu_encode(value as u64); + enc.byte(value); } pub fn uint8_from_bytes(buf: &[u8]) -> u8 { @@ -82,8 +82,8 @@ impl ScMutableUint8<'_> { self.proxy.exists() } - pub fn set_value(&self, val: u8) { - self.proxy.set(&uint8_to_bytes(val)); + pub fn set_value(&self, value: u8) { + self.proxy.set(&uint8_to_bytes(value)); } pub fn to_string(&self) -> String { diff --git a/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/proxy.ts b/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/proxy.ts index 8adb483b73..0413034cec 100644 --- a/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/proxy.ts +++ b/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/proxy.ts @@ -25,16 +25,20 @@ export class ScProxy { } export class Proxy { - static proxies: u32 = 0; - id: u32; _key: u8[] = []; kvStore: IKvStore; constructor(kvStore: IKvStore) { - this.id = Proxy.proxies++; this.kvStore = kvStore; } + // alternative constructor + protected proxy(kvStore: IKvStore, key: u8[]): Proxy { + const res = new Proxy(kvStore); + res._key = key; + return res; + } + // Append returns a Proxy for a newly appended null element // Note that this will essentially return the element at Length() public append(): Proxy { @@ -57,7 +61,7 @@ export class Proxy { // ClearMap clears a map by deleting all elements // TODO Note that this does not delete recursive container elements public clearMap(): void { - // TODO clearPrefix + // TODO clear prefix // clear the length counter this.delete(); @@ -71,7 +75,8 @@ export class Proxy { protected element(index: u32): Proxy { let enc = new WasmEncoder(); uint32Encode(enc, index); - return this.sub('#'.charCodeAt(0) as u8, enc.buf()); + // 0x23 is '#' + return this.sub(0x23, enc.buf()); } exists(): bool { @@ -107,7 +112,8 @@ export class Proxy { // Key gets a Proxy for an element of a Map by its key public key(key: u8[]): Proxy { - return this.sub('.'.charCodeAt(0) as u8, key); + // 0x2e is '.' + return this.sub(0x2e, key); } // Length returns the number of elements in an Array @@ -122,12 +128,6 @@ export class Proxy { return uint32Decode(dec); } - protected proxy(kvStore: IKvStore, key: u8[]): Proxy { - const res = new Proxy(kvStore); - res._key = key; - return res; - } - // Root returns a Proxy for an element of a root container (Params/Results/State). // The key is always a string. public root(key: string): Proxy { diff --git a/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/scbool.ts b/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/scbool.ts index 6879080608..c26377cc77 100644 --- a/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/scbool.ts +++ b/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/scbool.ts @@ -12,7 +12,7 @@ export const ScBoolTrue = 0xff // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ export function boolDecode(dec: WasmDecoder): bool { - return dec.byte() != 0; + return dec.byte() != ScBoolFalse; } export function boolEncode(enc: WasmEncoder, value: bool): void { diff --git a/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/scstring.ts b/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/scstring.ts index 830dd3751d..8d66756758 100644 --- a/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/scstring.ts +++ b/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/scstring.ts @@ -46,7 +46,7 @@ export class ScImmutableString { } toString(): string { - return this.value().toString(); + return this.value(); } value(): string { From 4f60d04ce27bc14a8344d0518628aac4d8ba15b5 Mon Sep 17 00:00:00 2001 From: Eric Hop Date: Tue, 1 Feb 2022 18:06:22 -0800 Subject: [PATCH 056/111] Implemented large parts of Rust WasmLib --- .../ts/donatewithfeedback/structs.ts | 6 +- contracts/wasm/erc721/ts/erc721/erc721.ts | 2 +- .../fairauction/ts/fairauction/fairauction.ts | 2 +- .../fairauction/ts/fairauction/structs.ts | 12 +- .../fairroulette/ts/fairroulette/structs.ts | 6 +- .../wasm/testwasmlib/test/testwasmlib_test.go | 28 +- .../tokenregistry/ts/tokenregistry/structs.ts | 8 +- packages/wasmvm/wasmlib/Cargo.lock | 250 +++++ packages/wasmvm/wasmlib/go/wasmlib/sandbox.go | 8 +- .../wasmlib/go/wasmlib/wasmtypes/proxy.go | 4 +- .../wasmlib/go/wasmlib/wasmtypes/scaddress.go | 2 +- .../wasmlib/go/wasmlib/wasmtypes/scagentid.go | 19 +- .../wasmlib/go/wasmlib/wasmtypes/scbool.go | 2 +- .../wasmlib/go/wasmlib/wasmtypes/scchainid.go | 2 +- .../wasmlib/go/wasmlib/wasmtypes/sccolor.go | 2 +- .../wasmlib/go/wasmlib/wasmtypes/schash.go | 2 +- .../wasmlib/go/wasmlib/wasmtypes/schname.go | 2 +- .../wasmlib/go/wasmlib/wasmtypes/scint16.go | 2 +- .../wasmlib/go/wasmlib/wasmtypes/scint32.go | 2 +- .../wasmlib/go/wasmlib/wasmtypes/scint64.go | 2 +- .../wasmlib/go/wasmlib/wasmtypes/scint8.go | 2 +- .../go/wasmlib/wasmtypes/screquestid.go | 2 +- .../wasmlib/go/wasmlib/wasmtypes/scuint16.go | 2 +- .../wasmlib/go/wasmlib/wasmtypes/scuint32.go | 2 +- .../wasmlib/go/wasmlib/wasmtypes/scuint64.go | 2 +- .../wasmlib/go/wasmlib/wasmtypes/scuint8.go | 2 +- packages/wasmvm/wasmlib/src/bytes.rs | 363 ------- packages/wasmvm/wasmlib/src/dict.rs | 56 ++ packages/wasmvm/wasmlib/src/exports.rs | 24 +- packages/wasmvm/wasmlib/src/hashtypes.rs | 301 ------ packages/wasmvm/wasmlib/src/host.rs | 212 +--- packages/wasmvm/wasmlib/src/immutable.rs | 728 -------------- packages/wasmvm/wasmlib/src/keys.rs | 82 -- packages/wasmvm/wasmlib/src/lib.rs | 35 +- packages/wasmvm/wasmlib/src/mutable.rs | 930 ------------------ packages/wasmvm/wasmlib/src/sandbox.rs | 172 ++++ packages/wasmvm/wasmlib/src/sandboxutils.rs | 67 ++ packages/wasmvm/wasmlib/src/state.rs | 37 + .../wasmvm/wasmlib/src/wasmtypes/codec.rs | 9 +- packages/wasmvm/wasmlib/src/wasmtypes/mod.rs | 40 +- .../wasmvm/wasmlib/src/wasmtypes/proxy.rs | 24 +- .../wasmvm/wasmlib/src/wasmtypes/scaddress.rs | 25 +- .../wasmvm/wasmlib/src/wasmtypes/scagentid.rs | 83 +- .../wasmvm/wasmlib/src/wasmtypes/scbool.rs | 10 +- .../wasmvm/wasmlib/src/wasmtypes/scbytes.rs | 14 +- .../wasmvm/wasmlib/src/wasmtypes/scchainid.rs | 47 +- .../wasmvm/wasmlib/src/wasmtypes/sccolor.rs | 20 +- .../wasmvm/wasmlib/src/wasmtypes/schash.rs | 20 +- .../wasmvm/wasmlib/src/wasmtypes/schname.rs | 47 +- .../wasmvm/wasmlib/src/wasmtypes/scint16.rs | 8 +- .../wasmvm/wasmlib/src/wasmtypes/scint32.rs | 10 +- .../wasmvm/wasmlib/src/wasmtypes/scint64.rs | 8 +- .../wasmvm/wasmlib/src/wasmtypes/scint8.rs | 10 +- .../wasmlib/src/wasmtypes/screquestid.rs | 42 +- .../wasmvm/wasmlib/src/wasmtypes/scstring.rs | 18 +- .../wasmvm/wasmlib/src/wasmtypes/scuint16.rs | 8 +- .../wasmvm/wasmlib/src/wasmtypes/scuint32.rs | 10 +- .../wasmvm/wasmlib/src/wasmtypes/scuint64.rs | 8 +- .../wasmvm/wasmlib/src/wasmtypes/scuint8.rs | 10 +- packages/wasmvm/wasmlib/ts/wasmlib/dict.ts | 15 +- packages/wasmvm/wasmlib/ts/wasmlib/exports.ts | 4 +- packages/wasmvm/wasmlib/ts/wasmlib/host.ts | 4 - packages/wasmvm/wasmlib/ts/wasmlib/sandbox.ts | 73 +- packages/wasmvm/wasmlib/ts/wasmlib/state.ts | 10 +- .../ts/wasmlib/wasmrequests/structs.ts | 16 +- .../wasmlib/ts/wasmlib/wasmtypes/proxy.ts | 6 +- .../wasmlib/ts/wasmlib/wasmtypes/scaddress.ts | 4 +- .../wasmlib/ts/wasmlib/wasmtypes/scagentid.ts | 24 +- .../wasmlib/ts/wasmlib/wasmtypes/scbool.ts | 4 +- .../wasmlib/ts/wasmlib/wasmtypes/scbytes.ts | 4 +- .../wasmlib/ts/wasmlib/wasmtypes/scchainid.ts | 4 +- .../wasmlib/ts/wasmlib/wasmtypes/sccolor.ts | 4 +- .../wasmlib/ts/wasmlib/wasmtypes/schash.ts | 4 +- .../wasmlib/ts/wasmlib/wasmtypes/schname.ts | 4 +- .../wasmlib/ts/wasmlib/wasmtypes/scint16.ts | 4 +- .../wasmlib/ts/wasmlib/wasmtypes/scint32.ts | 4 +- .../wasmlib/ts/wasmlib/wasmtypes/scint64.ts | 4 +- .../wasmlib/ts/wasmlib/wasmtypes/scint8.ts | 4 +- .../ts/wasmlib/wasmtypes/screquestid.ts | 4 +- .../wasmlib/ts/wasmlib/wasmtypes/scstring.ts | 4 +- .../wasmlib/ts/wasmlib/wasmtypes/scuint16.ts | 4 +- .../wasmlib/ts/wasmlib/wasmtypes/scuint32.ts | 4 +- .../wasmlib/ts/wasmlib/wasmtypes/scuint64.ts | 4 +- .../wasmlib/ts/wasmlib/wasmtypes/scuint8.ts | 4 +- packages/wasmvm/wasmsolo/solocontext.go | 2 +- .../generator/tstemplates/alltemplates.go | 2 +- tools/schema/generator/tstemplates/structs.go | 4 +- 87 files changed, 1050 insertions(+), 3031 deletions(-) create mode 100644 packages/wasmvm/wasmlib/Cargo.lock delete mode 100644 packages/wasmvm/wasmlib/src/bytes.rs create mode 100644 packages/wasmvm/wasmlib/src/dict.rs delete mode 100644 packages/wasmvm/wasmlib/src/hashtypes.rs delete mode 100644 packages/wasmvm/wasmlib/src/immutable.rs delete mode 100644 packages/wasmvm/wasmlib/src/keys.rs delete mode 100644 packages/wasmvm/wasmlib/src/mutable.rs create mode 100644 packages/wasmvm/wasmlib/src/sandbox.rs create mode 100644 packages/wasmvm/wasmlib/src/sandboxutils.rs create mode 100644 packages/wasmvm/wasmlib/src/state.rs diff --git a/contracts/wasm/donatewithfeedback/ts/donatewithfeedback/structs.ts b/contracts/wasm/donatewithfeedback/ts/donatewithfeedback/structs.ts index 42232806a7..12b01ac1c4 100644 --- a/contracts/wasm/donatewithfeedback/ts/donatewithfeedback/structs.ts +++ b/contracts/wasm/donatewithfeedback/ts/donatewithfeedback/structs.ts @@ -10,13 +10,13 @@ import * as wasmtypes from "wasmlib/wasmtypes"; export class Donation { amount : u64 = 0; // amount donated - donator : wasmtypes.ScAgentID = wasmtypes.agentIDFromBytes(null); // who donated + donator : wasmtypes.ScAgentID = wasmtypes.agentIDFromBytes([]); // who donated error : string = ""; // error to be reported to donator if anything goes wrong feedback : string = ""; // the feedback for the person donated to timestamp : u64 = 0; // when the donation took place - static fromBytes(buf: u8[]|null): Donation { - const dec = new wasmtypes.WasmDecoder(buf==null ? [] : buf); + static fromBytes(buf: u8[]): Donation { + const dec = new wasmtypes.WasmDecoder(buf); const data = new Donation(); data.amount = wasmtypes.uint64Decode(dec); data.donator = wasmtypes.agentIDDecode(dec); diff --git a/contracts/wasm/erc721/ts/erc721/erc721.ts b/contracts/wasm/erc721/ts/erc721/erc721.ts index 23576dc46c..de8b9052f7 100644 --- a/contracts/wasm/erc721/ts/erc721/erc721.ts +++ b/contracts/wasm/erc721/ts/erc721/erc721.ts @@ -17,7 +17,7 @@ import * as sc from "./index"; // set the required base URI, to which the base58 encoded token ID will be concatenated const BASE_URI = "my/special/base/uri/"; -const ZERO = wasmtypes.agentIDFromBytes(null); +const ZERO = wasmtypes.agentIDFromBytes([]); /////////////////////////// HELPER FUNCTIONS //////////////////////////// diff --git a/contracts/wasm/fairauction/ts/fairauction/fairauction.ts b/contracts/wasm/fairauction/ts/fairauction/fairauction.ts index 96a3914c70..1b34e2e1ff 100644 --- a/contracts/wasm/fairauction/ts/fairauction/fairauction.ts +++ b/contracts/wasm/fairauction/ts/fairauction/fairauction.ts @@ -163,7 +163,7 @@ export function funcStartAuction(ctx: wasmlib.ScFuncContext, f: sc.StartAuctionC auction.description = description; auction.duration = duration; auction.highestBid = 0; - auction.highestBidder = wasmtypes.agentIDFromBytes(null); + auction.highestBidder = wasmtypes.agentIDFromBytes([]); auction.minimumBid = minimumBid; auction.numTokens = numTokens; auction.ownerMargin = ownerMargin; diff --git a/contracts/wasm/fairauction/ts/fairauction/structs.ts b/contracts/wasm/fairauction/ts/fairauction/structs.ts index 59e0d2a741..484db9e693 100644 --- a/contracts/wasm/fairauction/ts/fairauction/structs.ts +++ b/contracts/wasm/fairauction/ts/fairauction/structs.ts @@ -10,19 +10,19 @@ import * as wasmtypes from "wasmlib/wasmtypes"; export class Auction { color : wasmtypes.ScColor = new wasmtypes.ScColor(0); // color of tokens for sale - creator : wasmtypes.ScAgentID = wasmtypes.agentIDFromBytes(null); // issuer of start_auction transaction + creator : wasmtypes.ScAgentID = wasmtypes.agentIDFromBytes([]); // issuer of start_auction transaction deposit : u64 = 0; // deposit by auction owner to cover the SC fees description : string = ""; // auction description duration : u32 = 0; // auction duration in minutes highestBid : u64 = 0; // the current highest bid amount - highestBidder : wasmtypes.ScAgentID = wasmtypes.agentIDFromBytes(null); // the current highest bidder + highestBidder : wasmtypes.ScAgentID = wasmtypes.agentIDFromBytes([]); // the current highest bidder minimumBid : u64 = 0; // minimum bid amount numTokens : u64 = 0; // number of tokens for sale ownerMargin : u64 = 0; // auction owner's margin in promilles whenStarted : u64 = 0; // timestamp when auction started - static fromBytes(buf: u8[]|null): Auction { - const dec = new wasmtypes.WasmDecoder(buf==null ? [] : buf); + static fromBytes(buf: u8[]): Auction { + const dec = new wasmtypes.WasmDecoder(buf); const data = new Auction(); data.color = wasmtypes.colorDecode(dec); data.creator = wasmtypes.agentIDDecode(dec); @@ -91,8 +91,8 @@ export class Bid { index : u32 = 0; // index of bidder in bidder list timestamp : u64 = 0; // timestamp of most recent bid - static fromBytes(buf: u8[]|null): Bid { - const dec = new wasmtypes.WasmDecoder(buf==null ? [] : buf); + static fromBytes(buf: u8[]): Bid { + const dec = new wasmtypes.WasmDecoder(buf); const data = new Bid(); data.amount = wasmtypes.uint64Decode(dec); data.index = wasmtypes.uint32Decode(dec); diff --git a/contracts/wasm/fairroulette/ts/fairroulette/structs.ts b/contracts/wasm/fairroulette/ts/fairroulette/structs.ts index 3c1840b7fa..c58ebb04a9 100644 --- a/contracts/wasm/fairroulette/ts/fairroulette/structs.ts +++ b/contracts/wasm/fairroulette/ts/fairroulette/structs.ts @@ -10,11 +10,11 @@ import * as wasmtypes from "wasmlib/wasmtypes"; export class Bet { amount : u64 = 0; - better : wasmtypes.ScAgentID = wasmtypes.agentIDFromBytes(null); + better : wasmtypes.ScAgentID = wasmtypes.agentIDFromBytes([]); number : u16 = 0; - static fromBytes(buf: u8[]|null): Bet { - const dec = new wasmtypes.WasmDecoder(buf==null ? [] : buf); + static fromBytes(buf: u8[]): Bet { + const dec = new wasmtypes.WasmDecoder(buf); const data = new Bet(); data.amount = wasmtypes.uint64Decode(dec); data.better = wasmtypes.agentIDDecode(dec); diff --git a/contracts/wasm/testwasmlib/test/testwasmlib_test.go b/contracts/wasm/testwasmlib/test/testwasmlib_test.go index 1f7d4a7cb1..836a17971c 100644 --- a/contracts/wasm/testwasmlib/test/testwasmlib_test.go +++ b/contracts/wasm/testwasmlib/test/testwasmlib_test.go @@ -129,19 +129,25 @@ func TestInvalidSizeParams(t *testing.T) { for index, param := range allParams { t.Run("InvalidSize "+param, func(t *testing.T) { invalidLength := fmt.Sprintf("invalid %s%s length", strings.ToUpper(param[:1]), param[1:]) - pt := testwasmlib.ScFuncs.ParamTypes(ctx) - pt.Params.Param().GetBytes(param).SetValue(make([]byte, 0)) - pt.Func.TransferIotas(1).Post() - require.Error(t, ctx.Err) - require.Contains(t, ctx.Err.Error(), invalidLength) - pt = testwasmlib.ScFuncs.ParamTypes(ctx) - pt.Params.Param().GetBytes(param).SetValue(make([]byte, allLengths[index]-1)) - pt.Func.TransferIotas(1).Post() - require.Error(t, ctx.Err) - require.Contains(t, ctx.Err.Error(), invalidLength) + // note that zero lengths are valid and will return a default value + + // no need to check bool/int8/uint8 + if allLengths[index] != 1 { + pt := testwasmlib.ScFuncs.ParamTypes(ctx) + pt.Params.Param().GetBytes(param).SetValue(make([]byte, 1)) + pt.Func.TransferIotas(1).Post() + require.Error(t, ctx.Err) + require.Contains(t, ctx.Err.Error(), invalidLength) + + pt = testwasmlib.ScFuncs.ParamTypes(ctx) + pt.Params.Param().GetBytes(param).SetValue(make([]byte, allLengths[index]-1)) + pt.Func.TransferIotas(1).Post() + require.Error(t, ctx.Err) + require.Contains(t, ctx.Err.Error(), invalidLength) + } - pt = testwasmlib.ScFuncs.ParamTypes(ctx) + pt := testwasmlib.ScFuncs.ParamTypes(ctx) pt.Params.Param().GetBytes(param).SetValue(make([]byte, allLengths[index]+1)) pt.Func.TransferIotas(1).Post() require.Error(t, ctx.Err) diff --git a/contracts/wasm/tokenregistry/ts/tokenregistry/structs.ts b/contracts/wasm/tokenregistry/ts/tokenregistry/structs.ts index 05a4de83b4..ed98aeddb6 100644 --- a/contracts/wasm/tokenregistry/ts/tokenregistry/structs.ts +++ b/contracts/wasm/tokenregistry/ts/tokenregistry/structs.ts @@ -11,14 +11,14 @@ import * as wasmtypes from "wasmlib/wasmtypes"; export class Token { created : u64 = 0; // creation timestamp description : string = ""; // description what minted token represents - mintedBy : wasmtypes.ScAgentID = wasmtypes.agentIDFromBytes(null); // original minter - owner : wasmtypes.ScAgentID = wasmtypes.agentIDFromBytes(null); // current owner + mintedBy : wasmtypes.ScAgentID = wasmtypes.agentIDFromBytes([]); // original minter + owner : wasmtypes.ScAgentID = wasmtypes.agentIDFromBytes([]); // current owner supply : u64 = 0; // amount of tokens originally minted updated : u64 = 0; // last update timestamp userDefined : string = ""; // any user defined text - static fromBytes(buf: u8[]|null): Token { - const dec = new wasmtypes.WasmDecoder(buf==null ? [] : buf); + static fromBytes(buf: u8[]): Token { + const dec = new wasmtypes.WasmDecoder(buf); const data = new Token(); data.created = wasmtypes.uint64Decode(dec); data.description = wasmtypes.stringDecode(dec); diff --git a/packages/wasmvm/wasmlib/Cargo.lock b/packages/wasmvm/wasmlib/Cargo.lock new file mode 100644 index 0000000000..fbada2ac38 --- /dev/null +++ b/packages/wasmvm/wasmlib/Cargo.lock @@ -0,0 +1,250 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +[[package]] +name = "bumpalo" +version = "3.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4a45a46ab1f2412e53d3a0ade76ffad2025804294569aae387231a0cd6e0899" + +[[package]] +name = "cfg-if" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "console_error_panic_hook" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a06aeb73f470f66dcdbf7223caeebb85984942f22f1adb2a088cf9668146bbbc" +dependencies = [ + "cfg-if 1.0.0", + "wasm-bindgen", +] + +[[package]] +name = "js-sys" +version = "0.3.56" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a38fc24e30fd564ce974c02bf1d337caddff65be6cc4735a1f7eab22a7440f04" +dependencies = [ + "wasm-bindgen", +] + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" + +[[package]] +name = "libc" +version = "0.2.116" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "565dbd88872dbe4cc8a46e527f26483c1d1f7afa6b884a3bd6cd893d4f98da74" + +[[package]] +name = "log" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710" +dependencies = [ + "cfg-if 1.0.0", +] + +[[package]] +name = "memory_units" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8452105ba047068f40ff7093dd1d9da90898e63dd61736462e9cdda6a90ad3c3" + +[[package]] +name = "proc-macro2" +version = "1.0.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7342d5883fbccae1cc37a2353b09c87c9b0f3afd73f5fb9bba687a1f733b029" +dependencies = [ + "unicode-xid", +] + +[[package]] +name = "quote" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "864d3e96a899863136fc6e99f3d7cae289dafe43bf2c5ac19b70df7210c0a145" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "scoped-tls" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea6a9290e3c9cf0f18145ef7ffa62d68ee0bf5fcd651017e586dc7fd5da448c2" + +[[package]] +name = "syn" +version = "1.0.86" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a65b3f4ffa0092e9887669db0eae07941f023991ab58ea44da8fe8e2d511c6b" +dependencies = [ + "proc-macro2", + "quote", + "unicode-xid", +] + +[[package]] +name = "unicode-xid" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" + +[[package]] +name = "wasm-bindgen" +version = "0.2.79" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25f1af7423d8588a3d840681122e72e6a24ddbcb3f0ec385cac0d12d24256c06" +dependencies = [ + "cfg-if 1.0.0", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.79" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b21c0df030f5a177f3cba22e9bc4322695ec43e7257d865302900290bcdedca" +dependencies = [ + "bumpalo", + "lazy_static", + "log", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-futures" +version = "0.4.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2eb6ec270a31b1d3c7e266b999739109abce8b6c87e4b31fcfcd788b65267395" +dependencies = [ + "cfg-if 1.0.0", + "js-sys", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.79" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f4203d69e40a52ee523b2529a773d5ffc1dc0071801c87b3d270b471b80ed01" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.79" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa8a30d46208db204854cadbb5d4baf5fcf8071ba5bf48190c3e59937962ebc" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.79" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d958d035c4438e28c70e4321a2911302f10135ce78a9c7834c0cab4123d06a2" + +[[package]] +name = "wasm-bindgen-test" +version = "0.3.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "45c8d417d87eefa0087e62e3c75ad086be39433449e2961add9a5d9ce5acc2f1" +dependencies = [ + "console_error_panic_hook", + "js-sys", + "scoped-tls", + "wasm-bindgen", + "wasm-bindgen-futures", + "wasm-bindgen-test-macro", +] + +[[package]] +name = "wasm-bindgen-test-macro" +version = "0.3.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0e560d44db5e73b69a9757a15512fe7e1ef93ed2061c928871a4025798293dd" +dependencies = [ + "proc-macro2", + "quote", +] + +[[package]] +name = "wasmlib" +version = "0.1.0" +dependencies = [ + "console_error_panic_hook", + "wasm-bindgen", + "wasm-bindgen-test", + "wee_alloc", +] + +[[package]] +name = "web-sys" +version = "0.3.56" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c060b319f29dd25724f09a2ba1418f142f539b2be99fbf4d2d5a8f7330afb8eb" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "wee_alloc" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dbb3b5a6b2bb17cb6ad44a2e68a43e8d2722c997da10e928665c72ec6c0a0b8e" +dependencies = [ + "cfg-if 0.1.10", + "libc", + "memory_units", + "winapi", +] + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" diff --git a/packages/wasmvm/wasmlib/go/wasmlib/sandbox.go b/packages/wasmvm/wasmlib/go/wasmlib/sandbox.go index 2670edee53..c4c2c1a7bc 100644 --- a/packages/wasmvm/wasmlib/go/wasmlib/sandbox.go +++ b/packages/wasmvm/wasmlib/go/wasmlib/sandbox.go @@ -52,11 +52,15 @@ type ScSandbox struct{} // TODO go over core contract schemas to set correct unsigned types func Log(text string) { - ScSandbox{}.Log(text) + Sandbox(FnLog, []byte(text)) } func Panic(text string) { - ScSandbox{}.Panic(text) + Sandbox(FnPanic, []byte(text)) +} + +func Trace(text string) { + Sandbox(FnTrace, []byte(text)) } func NewParamsProxy() wasmtypes.Proxy { diff --git a/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/proxy.go b/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/proxy.go index c018277fcf..cbf71d2ee3 100644 --- a/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/proxy.go +++ b/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/proxy.go @@ -97,7 +97,7 @@ func (p Proxy) Key(key []byte) Proxy { func (p Proxy) Length() uint32 { // get the length counter buf := p.Get() - if buf == nil { + if len(buf) == 0 { return 0 } dec := NewWasmDecoder(buf) @@ -118,7 +118,7 @@ func (p Proxy) Set(value []byte) { // The separator is significant, it prevents potential clashes with other elements. // Different separators can be used to indicate different sub-containers func (p Proxy) sub(sep byte, key []byte) Proxy { - if p.key == nil { + if len(p.key) == 0 { // this must be a root proxy return Proxy{kvStore: p.kvStore, key: key} } diff --git a/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/scaddress.go b/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/scaddress.go index e7a30b8bdc..00c4821cd4 100644 --- a/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/scaddress.go +++ b/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/scaddress.go @@ -35,7 +35,7 @@ func AddressEncode(enc *WasmEncoder, value ScAddress) { } func AddressFromBytes(buf []byte) ScAddress { - if buf == nil { + if len(buf) == 0 { return ScAddress{} } if len(buf) != ScAddressLength { diff --git a/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/scagentid.go b/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/scagentid.go index f1b65c1c1a..82945484ba 100644 --- a/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/scagentid.go +++ b/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/scagentid.go @@ -39,7 +39,10 @@ func (o ScAgentID) String() string { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ func AgentIDDecode(dec *WasmDecoder) ScAgentID { - return agentIDFromBytesUnchecked(dec.FixedBytes(ScAgentIDLength)) + return ScAgentID{ + address: AddressDecode(dec), + hname: HnameDecode(dec), + } } func AgentIDEncode(enc *WasmEncoder, value ScAgentID) { @@ -48,7 +51,7 @@ func AgentIDEncode(enc *WasmEncoder, value ScAgentID) { } func AgentIDFromBytes(buf []byte) ScAgentID { - if buf == nil { + if len(buf) == 0 { return ScAgentID{} } if len(buf) != ScAgentIDLength { @@ -58,7 +61,10 @@ func AgentIDFromBytes(buf []byte) ScAgentID { if buf[0] > 2 { panic("invalid AgentID: address type > 2") } - return agentIDFromBytesUnchecked(buf) + return ScAgentID{ + address: AddressFromBytes(buf[:ScAddressLength]), + hname: HnameFromBytes(buf[ScAddressLength:]), + } } func AgentIDToBytes(value ScAgentID) []byte { @@ -72,13 +78,6 @@ func AgentIDToString(value ScAgentID) string { return value.address.String() + "::" + value.hname.String() } -func agentIDFromBytesUnchecked(buf []byte) ScAgentID { - return ScAgentID{ - address: AddressFromBytes(buf[:ScAddressLength]), - hname: HnameFromBytes(buf[ScAddressLength:]), - } -} - // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ type ScImmutableAgentID struct { diff --git a/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/scbool.go b/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/scbool.go index 20dfea296f..fbdd393fa3 100644 --- a/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/scbool.go +++ b/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/scbool.go @@ -24,7 +24,7 @@ func BoolEncode(enc *WasmEncoder, value bool) { } func BoolFromBytes(buf []byte) bool { - if buf == nil { + if len(buf) == 0 { return false } if len(buf) != ScBoolLength { diff --git a/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/scchainid.go b/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/scchainid.go index 6aee6c3e8a..32865c7091 100644 --- a/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/scchainid.go +++ b/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/scchainid.go @@ -34,7 +34,7 @@ func ChainIDEncode(enc *WasmEncoder, value ScChainID) { } func ChainIDFromBytes(buf []byte) ScChainID { - if buf == nil { + if len(buf) == 0 { return ScChainID{id: [ScChainIDLength]byte{2}} } if len(buf) != ScChainIDLength { diff --git a/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/sccolor.go b/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/sccolor.go index b750633e1b..7134d15e42 100644 --- a/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/sccolor.go +++ b/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/sccolor.go @@ -41,7 +41,7 @@ func ColorEncode(enc *WasmEncoder, value ScColor) { } func ColorFromBytes(buf []byte) ScColor { - if buf == nil { + if len(buf) == 0 { return ScColor{} } if len(buf) != ScColorLength { diff --git a/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/schash.go b/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/schash.go index 9ee920631c..cce62c926b 100644 --- a/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/schash.go +++ b/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/schash.go @@ -30,7 +30,7 @@ func HashEncode(enc *WasmEncoder, value ScHash) { } func HashFromBytes(buf []byte) ScHash { - if buf == nil { + if len(buf) == 0 { return ScHash{} } if len(buf) != ScHashLength { diff --git a/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/schname.go b/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/schname.go index 731d180552..b91d0080b7 100644 --- a/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/schname.go +++ b/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/schname.go @@ -36,7 +36,7 @@ func HnameEncode(enc *WasmEncoder, value ScHname) { } func HnameFromBytes(buf []byte) ScHname { - if buf == nil { + if len(buf) == 0 { return 0 } if len(buf) != ScHnameLength { diff --git a/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/scint16.go b/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/scint16.go index ba2538214b..7cd4eb6931 100644 --- a/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/scint16.go +++ b/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/scint16.go @@ -21,7 +21,7 @@ func Int16Encode(enc *WasmEncoder, value int16) { } func Int16FromBytes(buf []byte) int16 { - if buf == nil { + if len(buf) == 0 { return 0 } if len(buf) != ScInt16Length { diff --git a/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/scint32.go b/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/scint32.go index be7e997c72..09a7a69756 100644 --- a/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/scint32.go +++ b/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/scint32.go @@ -21,7 +21,7 @@ func Int32Encode(enc *WasmEncoder, value int32) { } func Int32FromBytes(buf []byte) int32 { - if buf == nil { + if len(buf) == 0 { return 0 } if len(buf) != ScInt32Length { diff --git a/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/scint64.go b/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/scint64.go index fcd6709f53..9bad0aca25 100644 --- a/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/scint64.go +++ b/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/scint64.go @@ -21,7 +21,7 @@ func Int64Encode(enc *WasmEncoder, value int64) { } func Int64FromBytes(buf []byte) int64 { - if buf == nil { + if len(buf) == 0 { return 0 } if len(buf) != ScInt64Length { diff --git a/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/scint8.go b/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/scint8.go index 5529e61216..e82e8f2c18 100644 --- a/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/scint8.go +++ b/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/scint8.go @@ -20,7 +20,7 @@ func Int8Encode(enc *WasmEncoder, value int8) { } func Int8FromBytes(buf []byte) int8 { - if buf == nil { + if len(buf) == 0 { return 0 } if len(buf) != ScInt8Length { diff --git a/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/screquestid.go b/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/screquestid.go index deb9c12192..4538fa86c5 100644 --- a/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/screquestid.go +++ b/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/screquestid.go @@ -30,7 +30,7 @@ func RequestIDEncode(enc *WasmEncoder, value ScRequestID) { } func RequestIDFromBytes(buf []byte) ScRequestID { - if buf == nil { + if len(buf) == 0 { return ScRequestID{} } if len(buf) != ScRequestIDLength { diff --git a/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/scuint16.go b/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/scuint16.go index 78513373d7..40dacc0d72 100644 --- a/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/scuint16.go +++ b/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/scuint16.go @@ -21,7 +21,7 @@ func Uint16Encode(enc *WasmEncoder, value uint16) { } func Uint16FromBytes(buf []byte) uint16 { - if buf == nil { + if len(buf) == 0 { return 0 } if len(buf) != ScUint16Length { diff --git a/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/scuint32.go b/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/scuint32.go index d022d0ba54..02947d1c3f 100644 --- a/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/scuint32.go +++ b/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/scuint32.go @@ -21,7 +21,7 @@ func Uint32Encode(enc *WasmEncoder, value uint32) { } func Uint32FromBytes(buf []byte) uint32 { - if buf == nil { + if len(buf) == 0 { return 0 } if len(buf) != ScUint32Length { diff --git a/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/scuint64.go b/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/scuint64.go index ef44a6197c..6f2d91b638 100644 --- a/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/scuint64.go +++ b/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/scuint64.go @@ -21,7 +21,7 @@ func Uint64Encode(enc *WasmEncoder, value uint64) { } func Uint64FromBytes(buf []byte) uint64 { - if buf == nil { + if len(buf) == 0 { return 0 } if len(buf) != ScUint64Length { diff --git a/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/scuint8.go b/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/scuint8.go index 2281e7cb38..0cbc0ce574 100644 --- a/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/scuint8.go +++ b/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/scuint8.go @@ -20,7 +20,7 @@ func Uint8Encode(enc *WasmEncoder, value uint8) { } func Uint8FromBytes(buf []byte) uint8 { - if buf == nil { + if len(buf) == 0 { return 0 } if len(buf) != ScUint8Length { diff --git a/packages/wasmvm/wasmlib/src/bytes.rs b/packages/wasmvm/wasmlib/src/bytes.rs deleted file mode 100644 index 591a5c45ab..0000000000 --- a/packages/wasmvm/wasmlib/src/bytes.rs +++ /dev/null @@ -1,363 +0,0 @@ -// Copyright 2020 IOTA Stiftung -// SPDX-License-Identifier: Apache-2.0 - -use crate::hashtypes::*; -use crate::host::*; - -// decodes separate entities from a byte buffer -pub struct BytesDecoder<'a> { - buf: &'a [u8], -} - -impl BytesDecoder<'_> { - // constructs a decoder - pub fn new(data: &[u8]) -> BytesDecoder { - if data.len() == 0 { - panic("cannot decode empty byte array, use exist()"); - } - BytesDecoder { buf: data } - } - - // decodes an ScAddress from the byte buffer - pub fn address(&mut self) -> ScAddress { - ScAddress::from_bytes(self.fixed_bytes(TYPE_SIZES[TYPE_ADDRESS as usize] as usize)) - } - - // decodes an ScAgentID from the byte buffer - pub fn agent_id(&mut self) -> ScAgentID { - ScAgentID::from_bytes(self.fixed_bytes(TYPE_SIZES[TYPE_AGENT_ID as usize] as usize)) - } - - // decodes a bool from the byte buffer - pub fn bool(&mut self) -> bool { - self.uint8() != 0 - } - - // decodes the next variable length substring of bytes from the byte buffer - pub fn bytes(&mut self) -> &[u8] { - let length = self.uint32(); - self.fixed_bytes(length as usize) - } - - // decodes an ScChainID from the byte buffer - pub fn chain_id(&mut self) -> ScChainID { - ScChainID::from_bytes(self.fixed_bytes(TYPE_SIZES[TYPE_CHAIN_ID as usize] as usize)) - } - - // decodes an ScColor from the byte buffer - pub fn color(&mut self) -> ScColor { - ScColor::from_bytes(self.fixed_bytes(TYPE_SIZES[TYPE_COLOR as usize] as usize)) - } - - // decodes the next fixed length substring of bytes from the byte buffer - pub fn fixed_bytes(&mut self, size: usize) -> &[u8] { - if self.buf.len() < size { - panic("insufficient bytes"); - } - let value = &self.buf[..size]; - self.buf = &self.buf[size..]; - value - } - - // decodes an ScHash from the byte buffer - pub fn hash(&mut self) -> ScHash { - ScHash::from_bytes(self.fixed_bytes(TYPE_SIZES[TYPE_HASH as usize] as usize)) - } - - // decodes an ScHname from the byte buffer - pub fn hname(&mut self) -> ScHname { - ScHname::from_bytes(self.fixed_bytes(TYPE_SIZES[TYPE_HNAME as usize] as usize)) - } - - // decodes an int8 from the byte buffer - pub fn int8(&mut self) -> i8 { - self.uint8() as i8 - } - - // decodes an int16 from the byte buffer - // note that these are encoded using vli encoding to conserve space - pub fn int16(&mut self) -> i16 { - self.vli_decode(16) as i16 - } - - // decodes an int32 from the byte buffer - // note that these are encoded using vli encoding to conserve space - pub fn int32(&mut self) -> i32 { - self.vli_decode(32) as i32 - } - - // decodes an int64 from the byte buffer - // note that these are encoded using vli encoding to conserve space - pub fn int64(&mut self) -> i64 { - self.vli_decode(64) - } - - // decodes an ScRequestID from the byte buffer - pub fn request_id(&mut self) -> ScRequestID { - ScRequestID::from_bytes(self.fixed_bytes(TYPE_SIZES[TYPE_REQUEST_ID as usize] as usize)) - } - - // decodes an UTF-8 text string from the byte buffer - pub fn string(&mut self) -> String { - String::from_utf8_lossy(self.bytes()).to_string() - } - - // decodes an uint8 from the byte buffer - pub fn uint8(&mut self) -> u8 { - if self.buf.len() == 0 { - panic("insufficient bytes"); - } - let value = self.buf[0]; - self.buf = &self.buf[1..]; - value - } - - // decodes an uint16 from the byte buffer - // note that these are encoded using vli encoding to conserve space - pub fn uint16(&mut self) -> u16 { - self.vlu_decode(16) as u16 - } - - // decodes an uint32 from the byte buffer - // note that these are encoded using vli encoding to conserve space - pub fn uint32(&mut self) -> u32 { - self.vlu_decode(32) as u32 - } - - // decodes an uint64 from the byte buffer - // note that these are encoded using vli encoding to conserve space - pub fn uint64(&mut self) -> u64 { - self.vlu_decode(64) - } - - // vli (variable length integer) decoder - fn vli_decode(&mut self, bits: i32) -> i64 { - let mut b = self.uint8(); - let sign = b & 0x40; - - // first group of 6 bits - let mut value = (b & 0x3f) as i64; - let mut s = 6; - - // while continuation bit is set - while (b & 0x80) != 0 { - if s >= bits { - panic("integer representation too long"); - } - - // next group of 7 bits - b = self.uint8(); - value |= ((b & 0x7f) as i64) << s; - s += 7; - } - - if sign == 0 { - // positive, sign bits are already zero - return value; - } - - // negative, extend sign bits - value | (-1_i64 << s) - } - - // vlu (variable length unsigned) decoder - fn vlu_decode(&mut self, bits: i32) -> u64 { - // first group of 6 bits - let mut b = self.uint8(); - let mut value = (b & 0x7f) as u64; - let mut s = 7; - - // while continuation bit is set - while (b & 0x80) != 0 { - if s >= bits { - panic("integer representation too long"); - } - - // next group of 7 bits - b = self.uint8(); - value |= ((b & 0x7f) as u64) << s; - s += 7; - } - - value - } -} - -impl Drop for BytesDecoder<'_> { - fn drop(&mut self) { - if self.buf.len() != 0 { - panic("extra bytes"); - } - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -// encodes separate entities into a byte buffer -pub struct BytesEncoder { - buf: Vec, -} - -impl BytesEncoder { - // constructs an encoder - pub fn new() -> BytesEncoder { - BytesEncoder { buf: Vec::new() } - } - - // encodes an ScAddress into the byte buffer - pub fn address(&mut self, value: &ScAddress) -> &BytesEncoder { - self.fixed_bytes(value.to_bytes(), TYPE_SIZES[TYPE_ADDRESS as usize] as usize) - } - - // encodes an ScAgentID into the byte buffer - pub fn agent_id(&mut self, value: &ScAgentID) -> &BytesEncoder { - self.fixed_bytes(value.to_bytes(), TYPE_SIZES[TYPE_AGENT_ID as usize] as usize) - } - - // encodes a bool into the byte buffer - pub fn bool(&mut self, value: bool) -> &BytesEncoder { - self.uint8(value as u8) - } - - // encodes a variable sized substring of bytes into the byte buffer - pub fn bytes(&mut self, value: &[u8]) -> &BytesEncoder { - let length = value.len(); - self.uint32(length as u32); - self.fixed_bytes(value, length) - } - - // encodes an ScChainID into the byte buffer - pub fn chain_id(&mut self, value: &ScChainID) -> &BytesEncoder { - self.fixed_bytes(value.to_bytes(), TYPE_SIZES[TYPE_CHAIN_ID as usize] as usize) - } - - // encodes an ScColor into the byte buffer - pub fn color(&mut self, value: &ScColor) -> &BytesEncoder { - self.fixed_bytes(value.to_bytes(), TYPE_SIZES[TYPE_COLOR as usize] as usize) - } - - // retrieve the encoded byte buffer - pub fn data(&self) -> Vec { - self.buf.clone() - } - - // encodes a fixed sized substring of bytes into the byte buffer - pub fn fixed_bytes(&mut self, value: &[u8], length: usize) -> &BytesEncoder { - if value.len() != length as usize { - panic("invalid fixed bytes length"); - } - self.buf.extend_from_slice(value); - self - } - - // encodes an ScHash into the byte buffer - pub fn hash(&mut self, value: &ScHash) -> &BytesEncoder { - self.fixed_bytes(value.to_bytes(), TYPE_SIZES[TYPE_HASH as usize] as usize) - } - - // encodes an ScHname into the byte buffer - pub fn hname(&mut self, value: ScHname) -> &BytesEncoder { - self.fixed_bytes(&value.to_bytes(), TYPE_SIZES[TYPE_HNAME as usize] as usize) - } - - // encodes an int8 into the byte buffer - pub fn int8(&mut self, value: i8) -> &BytesEncoder { - self.uint8(value as u8) - } - - // encodes an int16 into the byte buffer - // note that these are encoded using vli encoding to conserve space - pub fn int16(&mut self, value: i16) -> &BytesEncoder { - self.int64(value as i64) - } - - // encodes an int32 into the byte buffer - // note that these are encoded using vli encoding to conserve space - pub fn int32(&mut self, value: i32) -> &BytesEncoder { - self.int64(value as i64) - } - - // encodes an int64 into the byte buffer - // note that these are encoded using vli encoding to conserve space - // vli (variable length integer) encoder - pub fn int64(&mut self, mut value: i64) -> &BytesEncoder { - // first group of 6 bits - // 1st byte encodes 0 as positive in bit 6 - let mut b = value as u8 & 0x3f; - value >>= 6; - - let mut final_value = 0_i64; - if value < 0 { - // encode negative value - // 1st byte encodes 1 as negative in bit 6 - b |= 0x40; - final_value = -1_i64; - } - - // keep shifting until all bits are done - while value != final_value { - // emit with continuation bit - self.buf.push(b|0x80); - - // next group of 7 bits - b = value as u8 & 0x7f; - value >>= 7; - } - - // emit without continuation bit - self.buf.push(b); - self - } - - // encodes an ScRequestID into the byte buffer - pub fn request_id(&mut self, value: &ScRequestID) -> &BytesEncoder { - self.fixed_bytes(value.to_bytes(), TYPE_SIZES[TYPE_REQUEST_ID as usize] as usize) - } - - // encodes an UTF-8 text string into the byte buffer - pub fn string(&mut self, value: &str) -> &BytesEncoder { - self.bytes(value.as_bytes()) - } - - // encodes an uint8 into the byte buffer - pub fn uint8(&mut self, value: u8) -> &BytesEncoder { - self.buf.push(value); - self - } - - // encodes an uint16 into the byte buffer - // note that these are encoded using vlu encoding to conserve space - pub fn uint16(&mut self, value: u16) -> &BytesEncoder { - self.uint64(value as u64) - } - - // encodes an uint32 into the byte buffer - // note that these are encoded using vlu encoding to conserve space - pub fn uint32(&mut self, value: u32) -> &BytesEncoder { - self.uint64(value as u64) - } - - // encodes an uint64 into the byte buffer - // note that these are encoded using vlu encoding to conserve space - // vlu (variable length unsigned) encoder - pub fn uint64(&mut self, mut value: u64) -> &BytesEncoder { - // first group of 7 bits - // 1st byte encodes 0 as positive in bit 6 - let mut b = value as u8; - value >>= 7; - - // keep shifting until all bits are done - while value != 0 { - // emit with continuation bit - self.buf.push(b|0x80); - - // next group of 7 bits - b = value as u8; - value >>= 7; - } - - // emit without continuation bit - self.buf.push(b); - self - } -} diff --git a/packages/wasmvm/wasmlib/src/dict.rs b/packages/wasmvm/wasmlib/src/dict.rs new file mode 100644 index 0000000000..8cb29fd831 --- /dev/null +++ b/packages/wasmvm/wasmlib/src/dict.rs @@ -0,0 +1,56 @@ +// Copyright 2020 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +use std::collections::HashMap; + +use crate::host::*; +use crate::wasmtypes::IKvStore; + +pub struct ScImmutableDict<'a> { + dict: &'a HashMap,Vec>, +} + +impl ScImmutableDict<'_> { + pub fn from_dict(dict: &ScDict)-> ScImmutableDict { + ScImmutableDict{ dict: &dict.dict } + } + + pub fn exists(&self, key: &[u8]) -> bool { + self.dict.contains_key(key) + } + + pub fn get(&self, key: &[u8]) -> Option<&Vec> { + self.dict.get(key) + } +} + +pub struct ScDict { + dict: HashMap,Vec>, +} + +impl ScDict { + pub fn new(buf: &[u8]) -> ScDict { + ScDict { dict: HashMap::new(), } + } +} + +impl IKvStore for ScDict { + fn delete(& mut self, key: &[u8]) { + self.dict.remove(key); + } + + fn exists(&self, key: &[u8]) -> bool { + self.dict.contains_key(key) + } + + fn get(&self, key: &[u8]) -> Vec { + if !self.dict.contains_key(key) { + return Vec::new(); + } + self.dict.get(key).unwrap().to_vec() + } + + fn set(& mut self, key: &[u8], value: &[u8]) { + self.dict.insert(key.to_vec(), value.to_vec()); + } +} diff --git a/packages/wasmvm/wasmlib/src/exports.rs b/packages/wasmvm/wasmlib/src/exports.rs index ee57906745..cc6fa22540 100644 --- a/packages/wasmvm/wasmlib/src/exports.rs +++ b/packages/wasmvm/wasmlib/src/exports.rs @@ -5,8 +5,6 @@ use crate::context::*; use crate::host::*; -use crate::keys::*; -use crate::mutable::*; // Note that we do not use the Wasm export symbol table on purpose // because Wasm does not allow us to determine whether the symbols @@ -25,11 +23,6 @@ static mut VIEWS: Vec = vec![]; // the host will pass the index of one of the entry points // that was provided by on_load during SC initialization fn on_call(index: i32) { - let ctx = ScFuncContext {}; - ctx.require(get_object_id(OBJ_ID_ROOT, KEY_STATE, TYPE_MAP) == OBJ_ID_STATE, "object id mismatch"); - ctx.require(get_object_id(OBJ_ID_ROOT, KEY_PARAMS, TYPE_MAP) == OBJ_ID_PARAMS, "object id mismatch"); - ctx.require(get_object_id(OBJ_ID_ROOT, KEY_RESULTS, TYPE_MAP) == OBJ_ID_RESULTS, "object id mismatch"); - unsafe { if (index & 0x8000) != 0 { // immutable view function, invoke with a view context @@ -47,27 +40,22 @@ fn on_call(index: i32) { // context for on_load function to be able to tell host which // funcs and views are available as entry points to the SC pub struct ScExports { - exports: ScMutableStringArray, } impl ScExports { // constructs the symbol export context for the on_load function pub fn new() -> ScExports { - let exports = ROOT.get_string_array(&KEY_EXPORTS); - // tell host what value our special predefined key is - // this helps detect versioning problems between host - // and client versions of WasmLib - exports.get_string(KEY_ZZZZZZZ.0 as u32).set_value("Rust:KEY_ZZZZZZZ"); - ScExports { exports: exports } + export_name(-1, "WASM::RUST"); + ScExports { } } // defines the external name of a smart contract func // and the entry point function associated with it pub fn add_func(&self, name: &str, f: fn(&ScFuncContext)) { unsafe { - let index = FUNCS.len() as u32; + let index = FUNCS.len() as i32; FUNCS.push(f); - self.exports.get_string(index).set_value(name); + export_name(index, name); } } @@ -75,9 +63,9 @@ impl ScExports { // and the entry point function associated with it pub fn add_view(&self, name: &str, v: fn(&ScViewContext)) { unsafe { - let index = VIEWS.len() as u32; + let index = VIEWS.len() as i32; VIEWS.push(v); - self.exports.get_string(index | 0x8000).set_value(name); + export_name(index | 0x8000, name); } } } diff --git a/packages/wasmvm/wasmlib/src/hashtypes.rs b/packages/wasmvm/wasmlib/src/hashtypes.rs deleted file mode 100644 index 56fdb4ce2c..0000000000 --- a/packages/wasmvm/wasmlib/src/hashtypes.rs +++ /dev/null @@ -1,301 +0,0 @@ -// Copyright 2020 IOTA Stiftung -// SPDX-License-Identifier: Apache-2.0 - -// standard value types used by the ISCP - -use std::convert::TryInto; - -use crate::context::*; -use crate::host::*; -use crate::keys::*; - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -// value object for 33-byte Tangle address ids -#[derive(PartialEq, Clone)] -pub struct ScAddress { - id: [u8; 33], -} - -impl ScAddress { - pub const ZERO: ScAddress = ScAddress { id: [0; 33] }; - - // construct from byte array - pub fn from_bytes(bytes: &[u8]) -> ScAddress { - ScAddress { id: bytes.try_into().expect("invalid address id length") } - } - - // returns agent id representation of this Tangle address - pub fn as_agent_id(&self) -> ScAgentID { - let mut agent_id = ScAgentID { id: [0; 37] }; - agent_id.id[..33].copy_from_slice(&self.id[..33]); - agent_id - } - - // convert to byte array representation - pub fn to_bytes(&self) -> &[u8] { - &self.id - } - - // human-readable string representation - pub fn to_string(&self) -> String { - base58_encode(&self.id) - } -} - -// can be used as key in maps -impl MapKey for ScAddress { - fn get_key_id(&self) -> Key32 { - get_key_id_from_bytes(&self.id) - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -// value object for 37-byte agent ids -#[derive(PartialEq, Clone)] -pub struct ScAgentID { - id: [u8; 37], -} - -impl ScAgentID { - pub const ZERO: ScAgentID = ScAgentID { id: [0; 37] }; - - // construct from address and contract name hash - pub fn new(address: &ScAddress, hname: ScHname) -> ScAgentID { - let mut agent_id = ScAgentID { id: [0; 37] }; - agent_id.id[..33].copy_from_slice(&address.to_bytes()); - agent_id.id[33..].copy_from_slice(&hname.to_bytes()); - agent_id - } - - // construct from byte array - pub fn from_bytes(bytes: &[u8]) -> ScAgentID { - ScAgentID { id: bytes.try_into().expect("invalid agent id length") } - } - - // gets Tangle address from agent id - pub fn address(&self) -> ScAddress { - let mut address = ScAddress { id: [0; 33] }; - address.id[..33].copy_from_slice(&self.id[..33]); - address - } - - // get contract name hash for this agent - pub fn hname(&self) -> ScHname { - ScHname::from_bytes(&self.id[33..]) - } - - // checks to see if agent id represents a Tangle address - pub fn is_address(&self) -> bool { - self.hname() == ScHname(0) - } - - // convert to byte array representation - pub fn to_bytes(&self) -> &[u8] { - &self.id - } - - // human-readable string representation - pub fn to_string(&self) -> String { - base58_encode(&self.id) - } -} - -// can be used as key in maps -impl MapKey for ScAgentID { - fn get_key_id(&self) -> Key32 { - get_key_id_from_bytes(&self.id) - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -// value object for 33-byte chain ids -#[derive(PartialEq, Clone)] -pub struct ScChainID { - id: [u8; 33], -} - -impl ScChainID { - // construct from byte array - pub fn from_bytes(bytes: &[u8]) -> ScChainID { - ScChainID { id: bytes.try_into().expect("invalid chain id length") } - } - - // gets Tangle address from chain id - pub fn address(&self) -> ScAddress { - let mut address = ScAddress { id: [0; 33] }; - address.id[..33].copy_from_slice(&self.id[..33]); - address - } - - // convert to byte array representation - pub fn to_bytes(&self) -> &[u8] { - &self.id - } - - // human-readable string representation - pub fn to_string(&self) -> String { - base58_encode(&self.id) - } -} - -// can be used as key in maps -impl MapKey for ScChainID { - fn get_key_id(&self) -> Key32 { - get_key_id_from_bytes(&self.id) - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -// value object for 32-byte token color -#[derive(PartialEq, Clone)] -pub struct ScColor { - id: [u8; 32], -} - -impl ScColor { - // predefined colors - pub const IOTA: ScColor = ScColor { id: [0x00; 32] }; - pub const MINT: ScColor = ScColor { id: [0xff; 32] }; - - // construct from byte array - pub fn from_bytes(bytes: &[u8]) -> ScColor { - ScColor { id: bytes.try_into().expect("invalid color id length") } - } - - // construct from request id, this will return newly minted color - pub fn from_request_id(request_id: &ScRequestID) -> ScColor { - let mut color = ScColor { id: [0x00; 32] }; - color.id[..].copy_from_slice(&request_id.id[..]); - color - } - - // convert to byte array representation - pub fn to_bytes(&self) -> &[u8] { - &self.id - } - - // human-readable string representation - pub fn to_string(&self) -> String { - base58_encode(&self.id) - } -} - -// can be used as key in maps -impl MapKey for ScColor { - fn get_key_id(&self) -> Key32 { - get_key_id_from_bytes(&self.id) - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -// value object for 32-byte hash value -#[derive(PartialEq, Clone)] -pub struct ScHash { - id: [u8; 32], -} - -impl ScHash { - pub const ZERO: ScHash = ScHash { id: [0; 32] }; - - // construct from byte array - pub fn from_bytes(bytes: &[u8]) -> ScHash { - ScHash { id: bytes.try_into().expect("invalid hash id length") } - } - - // convert to byte array representation - pub fn to_bytes(&self) -> &[u8] { - &self.id - } - - // human-readable string representation - pub fn to_string(&self) -> String { - base58_encode(&self.id) - } -} - -// can be used as key in maps -impl MapKey for ScHash { - fn get_key_id(&self) -> Key32 { - get_key_id_from_bytes(&self.id) - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -// value object for 4-byte name hash -#[derive(PartialEq, Clone, Copy)] -pub struct ScHname(pub u32); - -impl ScHname { - // construct from name string - pub fn new(name: &str) -> ScHname { - ScFuncContext {}.utility().hname(name) - } - - // construct from byte array - pub fn from_bytes(bytes: &[u8]) -> ScHname { - let val = u32::from_le_bytes(bytes.try_into().expect("invalid hname length")); - ScHname(val) - } - - // convert to byte array representation - pub fn to_bytes(&self) -> Vec { - self.0.to_le_bytes().to_vec() - } - - // human-readable string representation: 8 hex digits - pub fn to_string(&self) -> String { - let hex = "0123456789abcdef".as_bytes(); - let mut res = [0u8; 8]; - let mut val = self.0; - for n in 0..8 { - res[7 - n] = hex[val as usize & 0x0f]; - val >>= 4; - } - String::from_utf8(res.to_vec()).expect("WTF? invalid?") - } -} - -// can be used as key in maps -impl MapKey for ScHname { - fn get_key_id(&self) -> Key32 { - get_key_id_from_bytes(&self.0.to_le_bytes()) - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -// value object for 34-byte transaction request ids -#[derive(PartialEq, Clone)] -pub struct ScRequestID { - id: [u8; 34], -} - -impl ScRequestID { - // construct from byte array - pub fn from_bytes(bytes: &[u8]) -> ScRequestID { - ScRequestID { id: bytes.try_into().expect("invalid request id length") } - } - - // convert to byte array representation - pub fn to_bytes(&self) -> &[u8] { - &self.id - } - - // human-readable string representation - pub fn to_string(&self) -> String { - base58_encode(&self.id) - } -} - -// can be used as key in maps -impl MapKey for ScRequestID { - fn get_key_id(&self) -> Key32 { - get_key_id_from_bytes(&self.id) - } -} diff --git a/packages/wasmvm/wasmlib/src/host.rs b/packages/wasmvm/wasmlib/src/host.rs index 29c320fb2c..0852dad1bb 100644 --- a/packages/wasmvm/wasmlib/src/host.rs +++ b/packages/wasmvm/wasmlib/src/host.rs @@ -3,204 +3,24 @@ // interface WasmLib to the VM host -use std::convert::TryInto; - -use crate::keys::*; - -// all type id values should exactly match their counterpart values on the host! -pub const TYPE_ARRAY: i32 = 0x20; -pub const TYPE_ARRAY16: i32 = 0x60; -pub const TYPE_CALL: i32 = 0x80; -pub const TYPE_MASK: i32 = 0x1f; - -pub const TYPE_ADDRESS: i32 = 1; -pub const TYPE_AGENT_ID: i32 = 2; -pub const TYPE_BOOL: i32 = 3; -pub const TYPE_BYTES: i32 = 4; -pub const TYPE_CHAIN_ID: i32 = 5; -pub const TYPE_COLOR: i32 = 6; -pub const TYPE_HASH: i32 = 7; -pub const TYPE_HNAME: i32 = 8; -pub const TYPE_INT8: i32 = 9; -pub const TYPE_INT16: i32 = 10; -pub const TYPE_INT32: i32 = 11; -pub const TYPE_INT64: i32 = 12; -pub const TYPE_MAP: i32 = 13; -pub const TYPE_REQUEST_ID: i32 = 14; -pub const TYPE_STRING: i32 = 15; - -pub const OBJ_ID_NULL: i32 = 0; -pub const OBJ_ID_ROOT: i32 = 1; -pub const OBJ_ID_STATE: i32 = 2; -pub const OBJ_ID_PARAMS: i32 = 3; -pub const OBJ_ID_RESULTS: i32 = 4; - -// size in bytes of predefined types, indexed by the TYPE_* consts -pub const TYPE_SIZES: &[u8] = &[0, 33, 37, 1, 0, 33, 32, 32, 4, 1, 2, 4, 8, 0, 34, 0]; - -// These 4 external functions are funneling the entire WasmLib functionality -// to their counterparts on the host. +// These 2 external functions are funneling the entire +// WasmLib functionality to their counterparts on the host. #[link(wasm_import_module = "WasmLib")] extern { - // Copy the value data bytes of type stored in the host container object , - // under key , into the pre-allocated which can hold len bytes. - // Returns the actual length of the value data bytes on the host. - pub fn hostGetBytes(obj_id: i32, key_id: i32, type_id: i32, buffer: *const u8, size: i32) -> i32; - - // Retrieve the key id associated with the data bytes of length . - // A negative length indicates a bytes key, positive indicates a string key - // We discern between the two for better readable logging purposes - pub fn hostGetKeyID(key: *const u8, size: i32) -> i32; - - // Retrieve the id of the container sub-object of type stored in - // the host container object , under key . - pub fn hostGetObjectID(obj_id: i32, key_id: i32, type_id: i32) -> i32; - - // copy the value data bytes of type from the - // into the host container object , under key . - pub fn hostSetBytes(obj_id: i32, key_id: i32, type_id: i32, buffer: *const u8, size: i32); - pub fn hostStateGet(key_ref: *const u8, key_len: i32, val_ref: *const u8, val_len: i32) -> i32; pub fn hostStateSet(key_ref: *const u8, key_len: i32, val_ref: *const u8, val_len: i32); } -pub fn call_func(obj_id: i32, key_id: Key32, params: &[u8]) -> Vec { - unsafe { - let mut args = std::ptr::null(); - let mut size = params.len() as i32; - if size != 0 { - args = params.as_ptr(); - } - - // variable-sized type, first query expected length of bytes array - // (pass zero-length buffer) - size = hostGetBytes(obj_id, key_id.0, TYPE_CALL, args, size); - - // -1 means non-existent, so return default value for type - if size <= 0 { - return vec![0_u8; 0]; - } - - // allocate a sufficient length byte array in Wasm memory - // and let the host copy the actual data bytes into this Wasm byte array - let mut result = vec![0_u8; size as usize]; - hostGetBytes(obj_id, key_id.0, TYPE_CALL + 1, result.as_mut_ptr(), size); - result - } -} - -// Clear the entire contents of the specified container object. -// Removes all its sub-objects as well. -pub fn clear(obj_id: i32) { - // special key "length" is used with integer value zero - set_bytes(obj_id, KEY_LENGTH, TYPE_INT32, &0_i32.to_le_bytes()); -} - -// Delete the value with the specified key and type from the specified container object. -pub fn del_key(obj_id: i32, key_id: Key32, type_id: i32) { - unsafe { - // size -1 means delete - // this removes the need for a separate hostDelete function - hostSetBytes(obj_id, key_id.0, type_id, std::ptr::null(), -1); - } -} - -// Check if the specified container object contains a value with the specified key and type. -pub fn exists(obj_id: i32, key_id: Key32, type_id: i32) -> bool { - unsafe { - // size -1 means only test for existence - // returned size -1 indicates keyID not found (or error) - // this removes the need for a separate hostExists function - hostGetBytes(obj_id, key_id.0, type_id, std::ptr::null(), -1) >= 0 - } -} - -// Retrieve the bytes stored in the specified container object under the specified key -// and with specified type. Note that if the key does not exist this function will -// return the default value for the specified type. -pub fn get_bytes(obj_id: i32, key_id: Key32, type_id: i32) -> Vec { - unsafe { - let mut size = TYPE_SIZES[type_id as usize] as i32; - if size == 0 { - // variable-sized type, first query expected length of bytes array - // (pass zero-length buffer) - size = hostGetBytes(obj_id, key_id.0, type_id, std::ptr::null(), 0); - - // -1 means non-existent, so return default value for type - if size < 0 { - return vec![0_u8; 0]; - } - } - - // allocate a sufficiently sized byte array in Wasm memory - // and let the host copy the actual data bytes into this Wasm byte array - let mut result = vec![0_u8; size as usize]; - hostGetBytes(obj_id, key_id.0, type_id, result.as_mut_ptr(), size); - result - } -} - -// Retrieve the key id that the host has associated with the specified bytes key -pub fn get_key_id_from_bytes(bytes: &[u8]) -> Key32 { - unsafe { - let size = bytes.len() as i32; - // negative size indicates this is a bytes key - Key32(hostGetKeyID(bytes.as_ptr(), -size - 1)) - } -} - -// Retrieve the key id that the host has associated with the specified string key -pub fn get_key_id_from_string(key: &str) -> Key32 { - let bytes = key.as_bytes(); - unsafe { - // non-negative size indicates this is a string key - Key32(hostGetKeyID(bytes.as_ptr(), bytes.len() as i32)) - } -} - -// Retrieve the key id that the host has associated with the specified integer key -pub fn get_key_id_from_uint64(key: u64, nr_of_bytes: usize) -> Key32 { - let bytes = key.to_le_bytes(); - get_key_id_from_bytes(&bytes[..nr_of_bytes]) -} - -// Retrieve the length of an array container object on the host -pub fn get_length(obj_id: i32) -> u32 { - // special integer key "length" is used - let bytes = get_bytes(obj_id, KEY_LENGTH, TYPE_INT32); - u32::from_le_bytes(bytes.try_into().unwrap()) -} - -// Retrieve the id of the specified container sub-object -pub fn get_object_id(obj_id: i32, key_id: Key32, type_id: i32) -> i32 { +pub fn export_name(index: i32, name: &str) { unsafe { - hostGetObjectID(obj_id, key_id.0, type_id) + let buf = name.as_bytes(); + hostStateSet(std::ptr::null(), index, buf.as_ptr(), buf.len() as i32); } } -// Direct logging of informational text to host log -pub fn log(text: &str) { - set_bytes(1, KEY_LOG, TYPE_STRING, text.as_bytes()); -} - -// Direct logging of error to host log, followed by panicking out of the Wasm code -pub fn panic(text: &str) { - set_bytes(1, KEY_PANIC, TYPE_STRING, text.as_bytes()); -} - -// Store the provided value bytes of specified type in the specified container object -// under the specified key. Note that if the key does not exist this function will -// create it first. -pub fn set_bytes(obj_id: i32, key_id: Key32, type_id: i32, value: &[u8]) { - unsafe { - hostSetBytes(obj_id, key_id.0, type_id, value.as_ptr(), value.len() as i32); - } -} - -// Direct logging of debug trace text to host log -pub fn trace(text: &str) { - set_bytes(1, KEY_TRACE, TYPE_STRING, text.as_bytes()) +pub fn export_wasm_tag() { + export_name(-1, "WASM::RUST"); } pub fn sandbox(func_nr: i32, params: &[u8]) -> Vec { @@ -212,7 +32,7 @@ pub fn sandbox(func_nr: i32, params: &[u8]) -> Vec { // zero length, no need to retrieve cached value if size == 0 { - return vec![0_u8; 0]; + return Vec::new(); } // retrieve cached value from host @@ -234,27 +54,23 @@ pub fn state_exists(key: &[u8]) -> bool { } } -pub fn state_get(key: &[u8]) -> Option> { +pub fn state_get(key: &[u8]) -> Vec { unsafe { // variable sized result expected, // query size first by passing zero length buffer // value will be cached by host let size = hostStateGet(key.as_ptr(), key.len() as i32, std::ptr::null(), 0); - // -1 means non-existent - if size < 0 { - return None; - } - - // zero length, no need to retrieve cached value - if size == 0 { - return Some(vec![0_u8; 0]); + // -1 means non-existent, return default empty buffer + // zero length, no need to retrieve cached value, return empty buffer + if size <= 0 { + return Vec::new(); } // retrieve cached value from host let mut result = vec![0_u8; size as usize]; hostStateGet(std::ptr::null(), 0, result.as_mut_ptr(), size); - Some(result) + result } } diff --git a/packages/wasmvm/wasmlib/src/immutable.rs b/packages/wasmvm/wasmlib/src/immutable.rs deleted file mode 100644 index 643df4e34c..0000000000 --- a/packages/wasmvm/wasmlib/src/immutable.rs +++ /dev/null @@ -1,728 +0,0 @@ -// Copyright 2020 IOTA Stiftung -// SPDX-License-Identifier: Apache-2.0 - -// immutable proxies to host objects - -use std::convert::TryInto; - -use crate::context::*; -use crate::hashtypes::*; -use crate::host::*; -use crate::keys::*; - -// value proxy for immutable ScAddress in host container -pub struct ScImmutableAddress { - obj_id: i32, - key_id: Key32, -} - -impl ScImmutableAddress { - pub fn new(obj_id: i32, key_id: Key32) -> ScImmutableAddress { - ScImmutableAddress { obj_id, key_id } - } - - // check if value exists in host container - pub fn exists(&self) -> bool { - exists(self.obj_id, self.key_id, TYPE_ADDRESS) - } - - // human-readable string representation - pub fn to_string(&self) -> String { - self.value().to_string() - } - - // get value from host container - pub fn value(&self) -> ScAddress { - ScAddress::from_bytes(&get_bytes(self.obj_id, self.key_id, TYPE_ADDRESS)) - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -// value proxy for immutable ScAgentID in host container -pub struct ScImmutableAgentID { - obj_id: i32, - key_id: Key32, -} - -impl ScImmutableAgentID { - pub fn new(obj_id: i32, key_id: Key32) -> ScImmutableAgentID { - ScImmutableAgentID { obj_id, key_id } - } - - // check if value exists in host container - pub fn exists(&self) -> bool { - exists(self.obj_id, self.key_id, TYPE_AGENT_ID) - } - - // human-readable string representation - pub fn to_string(&self) -> String { - self.value().to_string() - } - - // get value from host container - pub fn value(&self) -> ScAgentID { - ScAgentID::from_bytes(&get_bytes(self.obj_id, self.key_id, TYPE_AGENT_ID)) - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -// value proxy for immutable Bool in host container -pub struct ScImmutableBool { - obj_id: i32, - key_id: Key32, -} - -impl ScImmutableBool { - pub fn new(obj_id: i32, key_id: Key32) -> ScImmutableBool { - ScImmutableBool { obj_id, key_id } - } - - // check if value exists in host container - pub fn exists(&self) -> bool { - exists(self.obj_id, self.key_id, TYPE_BOOL) - } - - // human-readable string representation - pub fn to_string(&self) -> String { - self.value().to_string() - } - - // get value from host container - pub fn value(&self) -> bool { - let bytes = get_bytes(self.obj_id, self.key_id, TYPE_BOOL); - bytes[0] != 0 - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -// value proxy for immutable bytes array in host container -pub struct ScImmutableBytes { - obj_id: i32, - key_id: Key32, -} - -impl ScImmutableBytes { - pub fn new(obj_id: i32, key_id: Key32) -> ScImmutableBytes { - ScImmutableBytes { obj_id, key_id } - } - - // check if value exists in host container - pub fn exists(&self) -> bool { - exists(self.obj_id, self.key_id, TYPE_BYTES) - } - - // human-readable string representation - pub fn to_string(&self) -> String { - base58_encode(&self.value()) - } - - // get value from host container - pub fn value(&self) -> Vec { - get_bytes(self.obj_id, self.key_id, TYPE_BYTES) - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -// value proxy for immutable ScChainID in host container -pub struct ScImmutableChainID { - obj_id: i32, - key_id: Key32, -} - -impl ScImmutableChainID { - pub fn new(obj_id: i32, key_id: Key32) -> ScImmutableChainID { - ScImmutableChainID { obj_id, key_id } - } - - // check if value exists in host container - pub fn exists(&self) -> bool { - exists(self.obj_id, self.key_id, TYPE_CHAIN_ID) - } - - // human-readable string representation - pub fn to_string(&self) -> String { - self.value().to_string() - } - - // get value from host container - pub fn value(&self) -> ScChainID { - ScChainID::from_bytes(&get_bytes(self.obj_id, self.key_id, TYPE_CHAIN_ID)) - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -// value proxy for immutable ScColor in host container -pub struct ScImmutableColor { - obj_id: i32, - key_id: Key32, -} - -impl ScImmutableColor { - pub fn new(obj_id: i32, key_id: Key32) -> ScImmutableColor { - ScImmutableColor { obj_id, key_id } - } - - // check if value exists in host container - pub fn exists(&self) -> bool { - exists(self.obj_id, self.key_id, TYPE_COLOR) - } - - // human-readable string representation - pub fn to_string(&self) -> String { - self.value().to_string() - } - - // get value from host container - pub fn value(&self) -> ScColor { - ScColor::from_bytes(&get_bytes(self.obj_id, self.key_id, TYPE_COLOR)) - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -// array proxy for immutable array of ScColor -pub struct ScImmutableColorArray { - pub(crate) obj_id: i32, -} - -impl ScImmutableColorArray { - // get value proxy for item at index, index can be 0..length()-1 - pub fn get_color(&self, index: u32) -> ScImmutableColor { - ScImmutableColor { obj_id: self.obj_id, key_id: Key32(index as i32) } - } - - // number of items in array - pub fn length(&self) -> u32 { - get_length(self.obj_id) - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -// value proxy for immutable ScHash in host container -pub struct ScImmutableHash { - obj_id: i32, - key_id: Key32, -} - -impl ScImmutableHash { - pub fn new(obj_id: i32, key_id: Key32) -> ScImmutableHash { - ScImmutableHash { obj_id, key_id } - } - - // check if value exists in host container - pub fn exists(&self) -> bool { - exists(self.obj_id, self.key_id, TYPE_HASH) - } - - // human-readable string representation - pub fn to_string(&self) -> String { - self.value().to_string() - } - - // get value from host container - pub fn value(&self) -> ScHash { - ScHash::from_bytes(&get_bytes(self.obj_id, self.key_id, TYPE_HASH)) - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -// value proxy for immutable ScHname in host container -pub struct ScImmutableHname { - obj_id: i32, - key_id: Key32, -} - -impl ScImmutableHname { - pub fn new(obj_id: i32, key_id: Key32) -> ScImmutableHname { - ScImmutableHname { obj_id, key_id } - } - - // check if value exists in host container - pub fn exists(&self) -> bool { - exists(self.obj_id, self.key_id, TYPE_HNAME) - } - - // human-readable string representation - pub fn to_string(&self) -> String { - self.value().to_string() - } - - // get value from host container - pub fn value(&self) -> ScHname { - ScHname::from_bytes(&get_bytes(self.obj_id, self.key_id, TYPE_HNAME)) - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -// value proxy for immutable Int8 in host container -pub struct ScImmutableInt8 { - obj_id: i32, - key_id: Key32, -} - -impl ScImmutableInt8 { - pub fn new(obj_id: i32, key_id: Key32) -> ScImmutableInt8 { - ScImmutableInt8 { obj_id, key_id } - } - - // check if value exists in host container - pub fn exists(&self) -> bool { - exists(self.obj_id, self.key_id, TYPE_INT8) - } - - // human-readable string representation - pub fn to_string(&self) -> String { - self.value().to_string() - } - - // get value from host container - pub fn value(&self) -> i8 { - let bytes = get_bytes(self.obj_id, self.key_id, TYPE_INT8); - bytes[0] as i8 - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -// value proxy for immutable Int16 in host container -pub struct ScImmutableInt16 { - obj_id: i32, - key_id: Key32, -} - -impl ScImmutableInt16 { - pub fn new(obj_id: i32, key_id: Key32) -> ScImmutableInt16 { - ScImmutableInt16 { obj_id, key_id } - } - - // check if value exists in host container - pub fn exists(&self) -> bool { - exists(self.obj_id, self.key_id, TYPE_INT16) - } - - // human-readable string representation - pub fn to_string(&self) -> String { - self.value().to_string() - } - - // get value from host container - pub fn value(&self) -> i16 { - let bytes = get_bytes(self.obj_id, self.key_id, TYPE_INT16); - i16::from_le_bytes(bytes.try_into().expect("invalid i16 length")) - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -// value proxy for immutable Int32 in host container -pub struct ScImmutableInt32 { - obj_id: i32, - key_id: Key32, -} - -impl ScImmutableInt32 { - pub fn new(obj_id: i32, key_id: Key32) -> ScImmutableInt32 { - ScImmutableInt32 { obj_id, key_id } - } - - // check if value exists in host container - pub fn exists(&self) -> bool { - exists(self.obj_id, self.key_id, TYPE_INT32) - } - - // human-readable string representation - pub fn to_string(&self) -> String { - self.value().to_string() - } - - // get value from host container - pub fn value(&self) -> i32 { - let bytes = get_bytes(self.obj_id, self.key_id, TYPE_INT32); - i32::from_le_bytes(bytes.try_into().expect("invalid i32 length")) - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -// value proxy for immutable Int64 in host container -pub struct ScImmutableInt64 { - obj_id: i32, - key_id: Key32, -} - -impl ScImmutableInt64 { - pub fn new(obj_id: i32, key_id: Key32) -> ScImmutableInt64 { - ScImmutableInt64 { obj_id, key_id } - } - - // check if value exists in host container - pub fn exists(&self) -> bool { - exists(self.obj_id, self.key_id, TYPE_INT64) - } - - // human-readable string representation - pub fn to_string(&self) -> String { - self.value().to_string() - } - - // get value from host container - pub fn value(&self) -> i64 { - let bytes = get_bytes(self.obj_id, self.key_id, TYPE_INT64); - i64::from_le_bytes(bytes.try_into().expect("invalid i64 length")) - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -// map proxy for immutable map -pub struct ScImmutableMap { - pub(crate) obj_id: i32, -} - -impl ScImmutableMap { - pub fn call_func(&self, key_id: Key32, params: &[u8]) -> Vec { - call_func(self.obj_id, key_id, params) - } - - // get value proxy for immutable ScAddress field specified by key - pub fn get_address(&self, key: &T) -> ScImmutableAddress { - ScImmutableAddress { obj_id: self.obj_id, key_id: key.get_key_id() } - } - - // get value proxy for immutable ScAgentID field specified by key - pub fn get_agent_id(&self, key: &T) -> ScImmutableAgentID { - ScImmutableAgentID { obj_id: self.obj_id, key_id: key.get_key_id() } - } - - // get value proxy for immutable Bool field specified by key - pub fn get_bool(&self, key: &T) -> ScImmutableBool { - ScImmutableBool { obj_id: self.obj_id, key_id: key.get_key_id() } - } - - // get value proxy for immutable bytes array field specified by key - pub fn get_bytes(&self, key: &T) -> ScImmutableBytes { - ScImmutableBytes { obj_id: self.obj_id, key_id: key.get_key_id() } - } - - // get value proxy for immutable ScChainID field specified by key - pub fn get_chain_id(&self, key: &T) -> ScImmutableChainID { - ScImmutableChainID { obj_id: self.obj_id, key_id: key.get_key_id() } - } - - // get value proxy for immutable ScColor field specified by key - pub fn get_color(&self, key: &T) -> ScImmutableColor { - ScImmutableColor { obj_id: self.obj_id, key_id: key.get_key_id() } - } - - // get array proxy for ScImmutableColorArray specified by key - pub fn get_color_array(&self, key: &T) -> ScImmutableColorArray { - let arr_id = get_object_id(self.obj_id, key.get_key_id(), TYPE_COLOR | TYPE_ARRAY); - ScImmutableColorArray { obj_id: arr_id } - } - - // get value proxy for immutable ScHash field specified by key - pub fn get_hash(&self, key: &T) -> ScImmutableHash { - ScImmutableHash { obj_id: self.obj_id, key_id: key.get_key_id() } - } - - // get value proxy for immutable ScHname field specified by key - pub fn get_hname(&self, key: &T) -> ScImmutableHname { - ScImmutableHname { obj_id: self.obj_id, key_id: key.get_key_id() } - } - - // get value proxy for immutable Int8 field specified by key - pub fn get_int8(&self, key: &T) -> ScImmutableInt8 { - ScImmutableInt8 { obj_id: self.obj_id, key_id: key.get_key_id() } - } - - // get value proxy for immutable Int16 field specified by key - pub fn get_int16(&self, key: &T) -> ScImmutableInt16 { - ScImmutableInt16 { obj_id: self.obj_id, key_id: key.get_key_id() } - } - - // get value proxy for immutable Int32 field specified by key - pub fn get_int32(&self, key: &T) -> ScImmutableInt32 { - ScImmutableInt32 { obj_id: self.obj_id, key_id: key.get_key_id() } - } - - // get value proxy for immutable Int64 field specified by key - pub fn get_int64(&self, key: &T) -> ScImmutableInt64 { - ScImmutableInt64 { obj_id: self.obj_id, key_id: key.get_key_id() } - } - - // get map proxy for ScImmutableMap specified by key - pub fn get_map(&self, key: &T) -> ScImmutableMap { - let map_id = get_object_id(self.obj_id, key.get_key_id(), TYPE_MAP); - ScImmutableMap { obj_id: map_id } - } - - // get array proxy for ScImmutableMapArray specified by key - pub fn get_map_array(&self, key: &T) -> ScImmutableMapArray { - let arr_id = get_object_id(self.obj_id, key.get_key_id(), TYPE_MAP | TYPE_ARRAY); - ScImmutableMapArray { obj_id: arr_id } - } - - // get value proxy for immutable ScRequestID field specified by key - pub fn get_request_id(&self, key: &T) -> ScImmutableRequestID { - ScImmutableRequestID { obj_id: self.obj_id, key_id: key.get_key_id() } - } - - // get value proxy for immutable UTF-8 text string field specified by key - pub fn get_string(&self, key: &T) -> ScImmutableString { - ScImmutableString { obj_id: self.obj_id, key_id: key.get_key_id() } - } - - // get array proxy for ScImmutableStringArray specified by key - pub fn get_string_array(&self, key: &T) -> ScImmutableStringArray { - let arr_id = get_object_id(self.obj_id, key.get_key_id(), TYPE_STRING | TYPE_ARRAY); - ScImmutableStringArray { obj_id: arr_id } - } - - // get value proxy for immutable Uint8 field specified by key - pub fn get_uint8(&self, key: &T) -> ScImmutableUint8 { - ScImmutableUint8 { obj_id: self.obj_id, key_id: key.get_key_id() } - } - - // get value proxy for immutable Uint16 field specified by key - pub fn get_uint16(&self, key: &T) -> ScImmutableUint16 { - ScImmutableUint16 { obj_id: self.obj_id, key_id: key.get_key_id() } - } - - // get value proxy for immutable Uint32 field specified by key - pub fn get_uint32(&self, key: &T) -> ScImmutableUint32 { - ScImmutableUint32 { obj_id: self.obj_id, key_id: key.get_key_id() } - } - - // get value proxy for immutable Uint64 field specified by key - pub fn get_uint64(&self, key: &T) -> ScImmutableUint64 { - ScImmutableUint64 { obj_id: self.obj_id, key_id: key.get_key_id() } - } - - pub fn map_id(&self) -> i32 { - self.obj_id - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -// array proxy for immutable array of maps -pub struct ScImmutableMapArray { - pub(crate) obj_id: i32, -} - -impl ScImmutableMapArray { - // get value proxy for item at index, index can be 0..length()-1 - pub fn get_map(&self, index: u32) -> ScImmutableMap { - let map_id = get_object_id(self.obj_id, Key32(index as i32), TYPE_MAP); - ScImmutableMap { obj_id: map_id } - } - - // number of items in array - pub fn length(&self) -> u32 { - get_length(self.obj_id) - } -} - -// value proxy for immutable ScRequestID in host container -pub struct ScImmutableRequestID { - obj_id: i32, - key_id: Key32, -} - -impl ScImmutableRequestID { - pub fn new(obj_id: i32, key_id: Key32) -> ScImmutableRequestID { - ScImmutableRequestID { obj_id, key_id } - } - - // check if value exists in host container - pub fn exists(&self) -> bool { - exists(self.obj_id, self.key_id, TYPE_REQUEST_ID) - } - - // human-readable string representation - pub fn to_string(&self) -> String { - self.value().to_string() - } - - // get value from host container - pub fn value(&self) -> ScRequestID { - ScRequestID::from_bytes(&get_bytes(self.obj_id, self.key_id, TYPE_REQUEST_ID)) - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -// value proxy for immutable UTF-8 text string in host container -pub struct ScImmutableString { - obj_id: i32, - key_id: Key32, -} - -impl ScImmutableString { - pub fn new(obj_id: i32, key_id: Key32) -> ScImmutableString { - ScImmutableString { obj_id, key_id } - } - - // check if value exists in host container - pub fn exists(&self) -> bool { - exists(self.obj_id, self.key_id, TYPE_STRING) - } - - // human-readable string representation - pub fn to_string(&self) -> String { - self.value() - } - - // get value from host container - pub fn value(&self) -> String { - let bytes = get_bytes(self.obj_id, self.key_id, TYPE_STRING); - unsafe { String::from_utf8_unchecked(bytes) } - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -// array proxy for immutable array of UTF-8 text string -pub struct ScImmutableStringArray { - pub(crate) obj_id: i32, -} - -impl ScImmutableStringArray { - // get value proxy for item at index, index can be 0..length()-1 - pub fn get_string(&self, index: u32) -> ScImmutableString { - ScImmutableString { obj_id: self.obj_id, key_id: Key32(index as i32) } - } - - // number of items in array - pub fn length(&self) -> u32 { - get_length(self.obj_id) - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -// value proxy for immutable Uint8 in host container -pub struct ScImmutableUint8 { - obj_id: i32, - key_id: Key32, -} - -impl ScImmutableUint8 { - pub fn new(obj_id: i32, key_id: Key32) -> ScImmutableUint8 { - ScImmutableUint8 { obj_id, key_id } - } - - // check if value exists in host container - pub fn exists(&self) -> bool { - exists(self.obj_id, self.key_id, TYPE_INT8) - } - - // human-readable string representation - pub fn to_string(&self) -> String { - self.value().to_string() - } - - // get value from host container - pub fn value(&self) -> u8 { - let bytes = get_bytes(self.obj_id, self.key_id, TYPE_INT8); - bytes[0] - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -// value proxy for immutable Uint16 in host container -pub struct ScImmutableUint16 { - obj_id: i32, - key_id: Key32, -} - -impl ScImmutableUint16 { - pub fn new(obj_id: i32, key_id: Key32) -> ScImmutableUint16 { - ScImmutableUint16 { obj_id, key_id } - } - - // check if value exists in host container - pub fn exists(&self) -> bool { - exists(self.obj_id, self.key_id, TYPE_INT16) - } - - // human-readable string representation - pub fn to_string(&self) -> String { - self.value().to_string() - } - - // get value from host container - pub fn value(&self) -> u16 { - let bytes = get_bytes(self.obj_id, self.key_id, TYPE_INT16); - u16::from_le_bytes(bytes.try_into().expect("invalid u16 length")) - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -// value proxy for immutable Uint32 in host container -pub struct ScImmutableUint32 { - obj_id: i32, - key_id: Key32, -} - -impl ScImmutableUint32 { - pub fn new(obj_id: i32, key_id: Key32) -> ScImmutableUint32 { - ScImmutableUint32 { obj_id, key_id } - } - - // check if value exists in host container - pub fn exists(&self) -> bool { - exists(self.obj_id, self.key_id, TYPE_INT32) - } - - // human-readable string representation - pub fn to_string(&self) -> String { - self.value().to_string() - } - - // get value from host container - pub fn value(&self) -> u32 { - let bytes = get_bytes(self.obj_id, self.key_id, TYPE_INT32); - u32::from_le_bytes(bytes.try_into().expect("invalid u32 length")) - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -// value proxy for immutable Uint64 in host container -pub struct ScImmutableUint64 { - obj_id: i32, - key_id: Key32, -} - -impl ScImmutableUint64 { - pub fn new(obj_id: i32, key_id: Key32) -> ScImmutableUint64 { - ScImmutableUint64 { obj_id, key_id } - } - - // check if value exists in host container - pub fn exists(&self) -> bool { - exists(self.obj_id, self.key_id, TYPE_INT64) - } - - // human-readable string representation - pub fn to_string(&self) -> String { - self.value().to_string() - } - - // get value from host container - pub fn value(&self) -> u64 { - let bytes = get_bytes(self.obj_id, self.key_id, TYPE_INT64); - u64::from_le_bytes(bytes.try_into().expect("invalid u64 length")) - } -} diff --git a/packages/wasmvm/wasmlib/src/keys.rs b/packages/wasmvm/wasmlib/src/keys.rs deleted file mode 100644 index 6e1d9b2acb..0000000000 --- a/packages/wasmvm/wasmlib/src/keys.rs +++ /dev/null @@ -1,82 +0,0 @@ -// Copyright 2020 IOTA Stiftung -// SPDX-License-Identifier: Apache-2.0 - -use crate::host::*; - -// conversion of data bytes to key id -pub trait MapKey { - fn get_key_id(&self) -> Key32; -} - -// implementations for both flavors of Rust string -impl MapKey for str { - fn get_key_id(&self) -> Key32 { - get_key_id_from_string(self) - } -} - -impl MapKey for String { - fn get_key_id(&self) -> Key32 { - get_key_id_from_string(self) - } -} - -// special type for predefined key ids -#[derive(Clone, Copy)] -pub struct Key32(pub i32); - -// implementation for predefined key ids -impl MapKey for Key32 { - fn get_key_id(&self) -> Key32 { - *self - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -// all predefined key id values should exactly match their counterpart values on the host! -// note that predefined key ids are negative values to distinguish them from indexes - -// @formatter:off -pub const KEY_ACCOUNT_ID : Key32 = Key32(-1); -pub const KEY_ADDRESS : Key32 = Key32(-2); -pub const KEY_BALANCES : Key32 = Key32(-3); -pub const KEY_BASE58_DECODE : Key32 = Key32(-4); -pub const KEY_BASE58_ENCODE : Key32 = Key32(-5); -pub const KEY_BLS_ADDRESS : Key32 = Key32(-6); -pub const KEY_BLS_AGGREGATE : Key32 = Key32(-7); -pub const KEY_BLS_VALID : Key32 = Key32(-8); -pub const KEY_CALL : Key32 = Key32(-9); -pub const KEY_CALLER : Key32 = Key32(-10); -pub const KEY_CHAIN_ID : Key32 = Key32(-11); -pub const KEY_CHAIN_OWNER_ID : Key32 = Key32(-12); -pub const KEY_COLOR : Key32 = Key32(-13); -pub const KEY_CONTRACT : Key32 = Key32(-14); -pub const KEY_CONTRACT_CREATOR : Key32 = Key32(-15); -pub const KEY_DEPLOY : Key32 = Key32(-16); -pub const KEY_ED25519_ADDRESS : Key32 = Key32(-17); -pub const KEY_ED25519_VALID : Key32 = Key32(-18); -pub const KEY_EVENT : Key32 = Key32(-19); -pub const KEY_EXPORTS : Key32 = Key32(-20); -pub const KEY_HASH_BLAKE2B : Key32 = Key32(-21); -pub const KEY_HASH_SHA3 : Key32 = Key32(-22); -pub const KEY_HNAME : Key32 = Key32(-23); -pub const KEY_INCOMING : Key32 = Key32(-24); -pub const KEY_LENGTH : Key32 = Key32(-25); -pub const KEY_LOG : Key32 = Key32(-26); -pub const KEY_MAPS : Key32 = Key32(-27); -pub const KEY_MINTED : Key32 = Key32(-28); -pub const KEY_PANIC : Key32 = Key32(-29); -pub const KEY_PARAMS : Key32 = Key32(-30); -pub const KEY_POST : Key32 = Key32(-31); -pub const KEY_RANDOM : Key32 = Key32(-32); -pub const KEY_REQUEST_ID : Key32 = Key32(-33); -pub const KEY_RESULTS : Key32 = Key32(-34); -pub const KEY_RETURN : Key32 = Key32(-35); -pub const KEY_STATE : Key32 = Key32(-36); -pub const KEY_TIMESTAMP : Key32 = Key32(-37); -pub const KEY_TRACE : Key32 = Key32(-38); -pub const KEY_TRANSFERS : Key32 = Key32(-39); -pub const KEY_UTILITY : Key32 = Key32(-40); -pub const KEY_ZZZZZZZ : Key32 = Key32(-41); -// @formatter:on diff --git a/packages/wasmvm/wasmlib/src/lib.rs b/packages/wasmvm/wasmlib/src/lib.rs index 3d52f99131..5950dd5916 100644 --- a/packages/wasmvm/wasmlib/src/lib.rs +++ b/packages/wasmvm/wasmlib/src/lib.rs @@ -3,31 +3,24 @@ #![allow(dead_code)] -pub use bytes::*; -pub use context::*; -pub use contract::*; -pub use events::*; +// pub use context::*; +// pub use contract::*; +// pub use events::*; pub use exports::ScExports; -pub use hashtypes::*; -pub use immutable::*; -pub use keys::*; -pub use mutable::*; -mod bytes; -mod context; -mod contract; -pub mod coreaccounts; -pub mod coreblob; -pub mod coreblocklog; -pub mod coregovernance; -pub mod coreroot; -mod events; +// mod context; +// mod contract; +// pub mod coreaccounts; +// pub mod coreblob; +// pub mod coreblocklog; +// pub mod coregovernance; +// pub mod coreroot; +pub mod dict; +// mod events; mod exports; -mod hashtypes; pub mod host; -mod immutable; -pub mod keys; -mod mutable; +pub mod sandbox; +pub mod state; //pub mod wasmrequests; pub mod wasmtypes; diff --git a/packages/wasmvm/wasmlib/src/mutable.rs b/packages/wasmvm/wasmlib/src/mutable.rs deleted file mode 100644 index 8e78cf6719..0000000000 --- a/packages/wasmvm/wasmlib/src/mutable.rs +++ /dev/null @@ -1,930 +0,0 @@ -// Copyright 2020 IOTA Stiftung -// SPDX-License-Identifier: Apache-2.0 - -// mutable proxies to host objects - -use std::convert::TryInto; - -use crate::context::*; -use crate::hashtypes::*; -use crate::host::*; -use crate::immutable::*; -use crate::keys::*; - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -// value proxy for mutable ScAddress in host container -pub struct ScMutableAddress { - obj_id: i32, - key_id: Key32, -} - -impl ScMutableAddress { - pub fn new(obj_id: i32, key_id: Key32) -> ScMutableAddress { - ScMutableAddress { obj_id, key_id } - } - - // delete value from host container - pub fn delete(&self) { - del_key(self.obj_id, self.key_id, TYPE_ADDRESS); - } - - // check if value exists in host container - pub fn exists(&self) -> bool { - exists(self.obj_id, self.key_id, TYPE_ADDRESS) - } - - // set value in host container - pub fn set_value(&self, val: &ScAddress) { - set_bytes(self.obj_id, self.key_id, TYPE_ADDRESS, val.to_bytes()); - } - - // human-readable string representation - pub fn to_string(&self) -> String { - self.value().to_string() - } - - // retrieve value from host container - pub fn value(&self) -> ScAddress { - ScAddress::from_bytes(&get_bytes(self.obj_id, self.key_id, TYPE_ADDRESS)) - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -// value proxy for mutable ScAgentID in host container -pub struct ScMutableAgentID { - obj_id: i32, - key_id: Key32, -} - -impl ScMutableAgentID { - pub fn new(obj_id: i32, key_id: Key32) -> ScMutableAgentID { - ScMutableAgentID { obj_id, key_id } - } - - // delete value from host container - pub fn delete(&self) { - del_key(self.obj_id, self.key_id, TYPE_AGENT_ID) - } - - // check if value exists in host container - pub fn exists(&self) -> bool { - exists(self.obj_id, self.key_id, TYPE_AGENT_ID) - } - - // set value in host container - pub fn set_value(&self, val: &ScAgentID) { - set_bytes(self.obj_id, self.key_id, TYPE_AGENT_ID, val.to_bytes()); - } - - // human-readable string representation - pub fn to_string(&self) -> String { - self.value().to_string() - } - - // retrieve value from host container - pub fn value(&self) -> ScAgentID { - ScAgentID::from_bytes(&get_bytes(self.obj_id, self.key_id, TYPE_AGENT_ID)) - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -// value proxy for mutable Bool in host container -pub struct ScMutableBool { - obj_id: i32, - key_id: Key32, -} - -impl ScMutableBool { - pub fn new(obj_id: i32, key_id: Key32) -> ScMutableBool { - ScMutableBool { obj_id, key_id } - } - - // delete value from host container - pub fn delete(&self) { - del_key(self.obj_id, self.key_id, TYPE_BOOL) - } - - // check if value exists in host container - pub fn exists(&self) -> bool { - exists(self.obj_id, self.key_id, TYPE_BOOL) - } - - // set value in host container - pub fn set_value(&self, val: bool) { - let bytes = [val as u8]; - set_bytes(self.obj_id, self.key_id, TYPE_BOOL, &bytes); - } - - // human-readable string representation - pub fn to_string(&self) -> String { - self.value().to_string() - } - - // retrieve value from host container - pub fn value(&self) -> bool { - let bytes = get_bytes(self.obj_id, self.key_id, TYPE_BOOL); - bytes[0] != 0 - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -// value proxy for mutable bytes array in host container -pub struct ScMutableBytes { - obj_id: i32, - key_id: Key32, -} - -impl ScMutableBytes { - pub fn new(obj_id: i32, key_id: Key32) -> ScMutableBytes { - ScMutableBytes { obj_id, key_id } - } - - // delete value from host container - pub fn delete(&self) { - del_key(self.obj_id, self.key_id, TYPE_BYTES) - } - - // check if value exists in host container - pub fn exists(&self) -> bool { - exists(self.obj_id, self.key_id, TYPE_BYTES) - } - - // set value in host container - pub fn set_value(&self, val: &[u8]) { - set_bytes(self.obj_id, self.key_id, TYPE_BYTES, val); - } - - // human-readable string representation - pub fn to_string(&self) -> String { - base58_encode(&self.value()) - } - - // retrieve value from host container - pub fn value(&self) -> Vec { - get_bytes(self.obj_id, self.key_id, TYPE_BYTES) - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -// value proxy for mutable ScChainID in host container -pub struct ScMutableChainID { - obj_id: i32, - key_id: Key32, -} - -impl ScMutableChainID { - pub fn new(obj_id: i32, key_id: Key32) -> ScMutableChainID { - ScMutableChainID { obj_id, key_id } - } - - // delete value from host container - pub fn delete(&self) { - del_key(self.obj_id, self.key_id, TYPE_CHAIN_ID) - } - - // check if value exists in host container - pub fn exists(&self) -> bool { - exists(self.obj_id, self.key_id, TYPE_CHAIN_ID) - } - - // set value in host container - pub fn set_value(&self, val: &ScChainID) { - set_bytes(self.obj_id, self.key_id, TYPE_CHAIN_ID, val.to_bytes()); - } - - // human-readable string representation - pub fn to_string(&self) -> String { - self.value().to_string() - } - - // retrieve value from host container - pub fn value(&self) -> ScChainID { - ScChainID::from_bytes(&get_bytes(self.obj_id, self.key_id, TYPE_CHAIN_ID)) - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -// value proxy for mutable ScColor in host container -pub struct ScMutableColor { - obj_id: i32, - key_id: Key32, -} - -impl ScMutableColor { - pub fn new(obj_id: i32, key_id: Key32) -> ScMutableColor { - ScMutableColor { obj_id, key_id } - } - - // delete value from host container - pub fn delete(&self) { - del_key(self.obj_id, self.key_id, TYPE_COLOR) - } - - // check if value exists in host container - pub fn exists(&self) -> bool { - exists(self.obj_id, self.key_id, TYPE_COLOR) - } - - // set value in host container - pub fn set_value(&self, val: &ScColor) { - set_bytes(self.obj_id, self.key_id, TYPE_COLOR, val.to_bytes()); - } - - // human-readable string representation - pub fn to_string(&self) -> String { - self.value().to_string() - } - - // retrieve value from host container - pub fn value(&self) -> ScColor { - ScColor::from_bytes(&get_bytes(self.obj_id, self.key_id, TYPE_COLOR)) - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -// value proxy for mutable ScHash in host container -pub struct ScMutableHash { - obj_id: i32, - key_id: Key32, -} - -impl ScMutableHash { - pub fn new(obj_id: i32, key_id: Key32) -> ScMutableHash { - ScMutableHash { obj_id, key_id } - } - - // delete value from host container - pub fn delete(&self) { - del_key(self.obj_id, self.key_id, TYPE_HASH) - } - - // check if value exists in host container - pub fn exists(&self) -> bool { - exists(self.obj_id, self.key_id, TYPE_HASH) - } - - // set value in host container - pub fn set_value(&self, val: &ScHash) { - set_bytes(self.obj_id, self.key_id, TYPE_HASH, val.to_bytes()); - } - - // human-readable string representation - pub fn to_string(&self) -> String { - self.value().to_string() - } - - // retrieve value from host container - pub fn value(&self) -> ScHash { - ScHash::from_bytes(&get_bytes(self.obj_id, self.key_id, TYPE_HASH)) - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -// value proxy for mutable ScHname in host container -pub struct ScMutableHname { - obj_id: i32, - key_id: Key32, -} - -impl ScMutableHname { - pub fn new(obj_id: i32, key_id: Key32) -> ScMutableHname { - ScMutableHname { obj_id, key_id } - } - - // delete value from host container - pub fn delete(&self) { - del_key(self.obj_id, self.key_id, TYPE_HNAME) - } - - // check if value exists in host container - pub fn exists(&self) -> bool { - exists(self.obj_id, self.key_id, TYPE_HNAME) - } - - // set value in host container - pub fn set_value(&self, val: ScHname) { - set_bytes(self.obj_id, self.key_id, TYPE_HNAME, &val.to_bytes()); - } - - // human-readable string representation - pub fn to_string(&self) -> String { - self.value().to_string() - } - - // retrieve value from host container - pub fn value(&self) -> ScHname { - ScHname::from_bytes(&get_bytes(self.obj_id, self.key_id, TYPE_HNAME)) - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -// value proxy for mutable Int8 in host container -pub struct ScMutableInt8 { - obj_id: i32, - key_id: Key32, -} - -impl ScMutableInt8 { - pub fn new(obj_id: i32, key_id: Key32) -> ScMutableInt8 { - ScMutableInt8 { obj_id, key_id } - } - - // delete value from host container - pub fn delete(&self) { - del_key(self.obj_id, self.key_id, TYPE_INT8) - } - - // check if value exists in host container - pub fn exists(&self) -> bool { - exists(self.obj_id, self.key_id, TYPE_INT8) - } - - // set value in host container - pub fn set_value(&self, val: i8) { - let bytes = [val as u8]; - set_bytes(self.obj_id, self.key_id, TYPE_INT8, &bytes); - } - - // human-readable string representation - pub fn to_string(&self) -> String { - self.value().to_string() - } - - // retrieve value from host container - pub fn value(&self) -> i8 { - let bytes = get_bytes(self.obj_id, self.key_id, TYPE_INT8); - bytes[0] as i8 - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -// value proxy for mutable Int16 in host container -pub struct ScMutableInt16 { - obj_id: i32, - key_id: Key32, -} - -impl ScMutableInt16 { - pub fn new(obj_id: i32, key_id: Key32) -> ScMutableInt16 { - ScMutableInt16 { obj_id, key_id } - } - - // delete value from host container - pub fn delete(&self) { - del_key(self.obj_id, self.key_id, TYPE_INT16) - } - - // check if value exists in host container - pub fn exists(&self) -> bool { - exists(self.obj_id, self.key_id, TYPE_INT16) - } - - // set value in host container - pub fn set_value(&self, val: i16) { - set_bytes(self.obj_id, self.key_id, TYPE_INT16, &val.to_le_bytes()); - } - - // human-readable string representation - pub fn to_string(&self) -> String { - self.value().to_string() - } - - // retrieve value from host container - pub fn value(&self) -> i16 { - let bytes = get_bytes(self.obj_id, self.key_id, TYPE_INT16); - i16::from_le_bytes(bytes.try_into().expect("invalid i16 length")) - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -// value proxy for mutable Int32 in host container -pub struct ScMutableInt32 { - obj_id: i32, - key_id: Key32, -} - -impl ScMutableInt32 { - pub fn new(obj_id: i32, key_id: Key32) -> ScMutableInt32 { - ScMutableInt32 { obj_id, key_id } - } - - // delete value from host container - pub fn delete(&self) { - del_key(self.obj_id, self.key_id, TYPE_INT32) - } - - // check if value exists in host container - pub fn exists(&self) -> bool { - exists(self.obj_id, self.key_id, TYPE_INT32) - } - - // set value in host container - pub fn set_value(&self, val: i32) { - set_bytes(self.obj_id, self.key_id, TYPE_INT32, &val.to_le_bytes()); - } - - // human-readable string representation - pub fn to_string(&self) -> String { - self.value().to_string() - } - - // retrieve value from host container - pub fn value(&self) -> i32 { - let bytes = get_bytes(self.obj_id, self.key_id, TYPE_INT32); - i32::from_le_bytes(bytes.try_into().expect("invalid i32 length")) - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -// value proxy for mutable Int64 in host container -pub struct ScMutableInt64 { - obj_id: i32, - key_id: Key32, -} - -impl ScMutableInt64 { - pub fn new(obj_id: i32, key_id: Key32) -> ScMutableInt64 { - ScMutableInt64 { obj_id, key_id } - } - - // delete value from host container - pub fn delete(&self) { - del_key(self.obj_id, self.key_id, TYPE_INT64) - } - - // check if value exists in host container - pub fn exists(&self) -> bool { - exists(self.obj_id, self.key_id, TYPE_INT64) - } - - // set value in host container - pub fn set_value(&self, val: i64) { - set_bytes(self.obj_id, self.key_id, TYPE_INT64, &val.to_le_bytes()); - } - - // human-readable string representation - pub fn to_string(&self) -> String { - self.value().to_string() - } - - // retrieve value from host container - pub fn value(&self) -> i64 { - let bytes = get_bytes(self.obj_id, self.key_id, TYPE_INT64); - i64::from_le_bytes(bytes.try_into().expect("invalid i64 length")) - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -// map proxy for mutable map -#[derive(Clone, Copy)] -pub struct ScMutableMap { - pub(crate) obj_id: i32, -} - -impl ScMutableMap { - pub fn call_func(&self, key_id: Key32, params: &[u8]) -> Vec { - call_func(self.obj_id, key_id, params) - } - - // construct a new map on the host and return a map proxy for it - pub fn new() -> ScMutableMap { - let maps = ROOT.get_map_array(&KEY_MAPS); - maps.get_map(maps.length()) - } - - // empty the map - pub fn clear(&self) { - clear(self.obj_id); - } - - // get value proxy for mutable ScAddress field specified by key - pub fn get_address(&self, key: &T) -> ScMutableAddress { - ScMutableAddress { obj_id: self.obj_id, key_id: key.get_key_id() } - } - - // get value proxy for mutable ScAgentID field specified by key - pub fn get_agent_id(&self, key: &T) -> ScMutableAgentID { - ScMutableAgentID { obj_id: self.obj_id, key_id: key.get_key_id() } - } - - // get value proxy for mutable Bool field specified by key - pub fn get_bool(&self, key: &T) -> ScMutableBool { - ScMutableBool { obj_id: self.obj_id, key_id: key.get_key_id() } - } - - // get value proxy for mutable bytes array field specified by key - pub fn get_bytes(&self, key: &T) -> ScMutableBytes { - ScMutableBytes { obj_id: self.obj_id, key_id: key.get_key_id() } - } - - // get value proxy for mutable ScChainID field specified by key - pub fn get_chain_id(&self, key: &T) -> ScMutableChainID { - ScMutableChainID { obj_id: self.obj_id, key_id: key.get_key_id() } - } - - // get value proxy for mutable ScColor field specified by key - pub fn get_color(&self, key: &T) -> ScMutableColor { - ScMutableColor { obj_id: self.obj_id, key_id: key.get_key_id() } - } - - // get value proxy for mutable ScHash field specified by key - pub fn get_hash(&self, key: &T) -> ScMutableHash { - ScMutableHash { obj_id: self.obj_id, key_id: key.get_key_id() } - } - - // get value proxy for mutable ScHname field specified by key - pub fn get_hname(&self, key: &T) -> ScMutableHname { - ScMutableHname { obj_id: self.obj_id, key_id: key.get_key_id() } - } - - // get value proxy for mutable Int8 field specified by key - pub fn get_int8(&self, key: &T) -> ScMutableInt8 { - ScMutableInt8 { obj_id: self.obj_id, key_id: key.get_key_id() } - } - - // get value proxy for mutable Int16 field specified by key - pub fn get_int16(&self, key: &T) -> ScMutableInt16 { - ScMutableInt16 { obj_id: self.obj_id, key_id: key.get_key_id() } - } - - // get value proxy for mutable Int32 field specified by key - pub fn get_int32(&self, key: &T) -> ScMutableInt32 { - ScMutableInt32 { obj_id: self.obj_id, key_id: key.get_key_id() } - } - - // get value proxy for mutable Int64 field specified by key - pub fn get_int64(&self, key: &T) -> ScMutableInt64 { - ScMutableInt64 { obj_id: self.obj_id, key_id: key.get_key_id() } - } - - // get map proxy for ScMutableMap specified by key - pub fn get_map(&self, key: &T) -> ScMutableMap { - let map_id = get_object_id(self.obj_id, key.get_key_id(), TYPE_MAP); - ScMutableMap { obj_id: map_id } - } - - // get array proxy for ScMutableMapArray specified by key - pub fn get_map_array(&self, key: &T) -> ScMutableMapArray { - let arr_id = get_object_id(self.obj_id, key.get_key_id(), TYPE_MAP | TYPE_ARRAY); - ScMutableMapArray { obj_id: arr_id } - } - - // get value proxy for mutable ScRequestID field specified by key - pub fn get_request_id(&self, key: &T) -> ScMutableRequestID { - ScMutableRequestID { obj_id: self.obj_id, key_id: key.get_key_id() } - } - - // get value proxy for mutable UTF-8 text string field specified by key - pub fn get_string(&self, key: &T) -> ScMutableString { - ScMutableString { obj_id: self.obj_id, key_id: key.get_key_id() } - } - - // get array proxy for ScMutableStringArray specified by key - pub fn get_string_array(&self, key: &T) -> ScMutableStringArray { - let arr_id = get_object_id(self.obj_id, key.get_key_id(), TYPE_STRING | TYPE_ARRAY); - ScMutableStringArray { obj_id: arr_id } - } - - // get value proxy for mutable Uint8 field specified by key - pub fn get_uint8(&self, key: &T) -> ScMutableUint8 { - ScMutableUint8 { obj_id: self.obj_id, key_id: key.get_key_id() } - } - - // get value proxy for mutable Uint16 field specified by key - pub fn get_uint16(&self, key: &T) -> ScMutableUint16 { - ScMutableUint16 { obj_id: self.obj_id, key_id: key.get_key_id() } - } - - // get value proxy for mutable Uint32 field specified by key - pub fn get_uint32(&self, key: &T) -> ScMutableUint32 { - ScMutableUint32 { obj_id: self.obj_id, key_id: key.get_key_id() } - } - - // get value proxy for mutable Uint64 field specified by key - pub fn get_uint64(&self, key: &T) -> ScMutableUint64 { - ScMutableUint64 { obj_id: self.obj_id, key_id: key.get_key_id() } - } - - // get immutable version of map proxy - pub fn immutable(&self) -> ScImmutableMap { - ScImmutableMap { obj_id: self.obj_id } - } - - pub fn map_id(&self) -> i32 { - self.obj_id - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -// array proxy for mutable array of maps -pub struct ScMutableMapArray { - pub(crate) obj_id: i32, -} - -impl ScMutableMapArray { - // empty the array - pub fn clear(&self) { - clear(self.obj_id); - } - - // get value proxy for item at index, index can be 0..length() - // when index equals length() a new item is appended - pub fn get_map(&self, index: u32) -> ScMutableMap { - let map_id = get_object_id(self.obj_id, Key32(index as i32), TYPE_MAP); - ScMutableMap { obj_id: map_id } - } - - // get immutable version of array proxy - pub fn immutable(&self) -> ScImmutableMapArray { - ScImmutableMapArray { obj_id: self.obj_id } - } - - // number of items in array - pub fn length(&self) -> u32 { - get_length(self.obj_id) - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -// value proxy for mutable ScRequestID in host container -pub struct ScMutableRequestID { - obj_id: i32, - key_id: Key32, -} - -impl ScMutableRequestID { - pub fn new(obj_id: i32, key_id: Key32) -> ScMutableRequestID { - ScMutableRequestID { obj_id, key_id } - } - - // delete value from host container - pub fn delete(&self) { - del_key(self.obj_id, self.key_id, TYPE_REQUEST_ID) - } - - // check if value exists in host container - pub fn exists(&self) -> bool { - exists(self.obj_id, self.key_id, TYPE_REQUEST_ID) - } - - // set value in host container - pub fn set_value(&self, val: &ScRequestID) { - set_bytes(self.obj_id, self.key_id, TYPE_REQUEST_ID, val.to_bytes()); - } - - // human-readable string representation - pub fn to_string(&self) -> String { - self.value().to_string() - } - - // retrieve value from host container - pub fn value(&self) -> ScRequestID { - ScRequestID::from_bytes(&get_bytes(self.obj_id, self.key_id, TYPE_REQUEST_ID)) - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -// value proxy for mutable UTF-8 text string in host container -pub struct ScMutableString { - obj_id: i32, - key_id: Key32, -} - -impl ScMutableString { - pub fn new(obj_id: i32, key_id: Key32) -> ScMutableString { - ScMutableString { obj_id, key_id } - } - - // delete value from host container - pub fn delete(&self) { - del_key(self.obj_id, self.key_id, TYPE_STRING) - } - - // check if value exists in host container - pub fn exists(&self) -> bool { - exists(self.obj_id, self.key_id, TYPE_STRING) - } - - // set value in host container - pub fn set_value(&self, val: &str) { - set_bytes(self.obj_id, self.key_id, TYPE_STRING, val.as_bytes()); - } - - // human-readable string representation - pub fn to_string(&self) -> String { - self.value() - } - - // retrieve value from host container - pub fn value(&self) -> String { - let bytes = get_bytes(self.obj_id, self.key_id, TYPE_STRING); - unsafe { String::from_utf8_unchecked(bytes) } - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -// array proxy for mutable array of UTF-8 text string -pub struct ScMutableStringArray { - pub(crate) obj_id: i32, -} - -impl ScMutableStringArray { - // empty the array - pub fn clear(&self) { - clear(self.obj_id); - } - - // get value proxy for item at index, index can be 0..length() - // when index equals length() a new item is appended - pub fn get_string(&self, index: u32) -> ScMutableString { - ScMutableString { obj_id: self.obj_id, key_id: Key32(index as i32) } - } - - // get immutable version of array proxy - pub fn immutable(&self) -> ScImmutableStringArray { - ScImmutableStringArray { obj_id: self.obj_id } - } - - // number of items in array - pub fn length(&self) -> u32 { - get_length(self.obj_id) - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -// value proxy for mutable Uint8 in host container -pub struct ScMutableUint8 { - obj_id: i32, - key_id: Key32, -} - -impl ScMutableUint8 { - pub fn new(obj_id: i32, key_id: Key32) -> ScMutableUint8 { - ScMutableUint8 { obj_id, key_id } - } - - // delete value from host container - pub fn delete(&self) { - del_key(self.obj_id, self.key_id, TYPE_INT8) - } - - // check if value exists in host container - pub fn exists(&self) -> bool { - exists(self.obj_id, self.key_id, TYPE_INT8) - } - - // set value in host container - pub fn set_value(&self, val: u8) { - let bytes = [val]; - set_bytes(self.obj_id, self.key_id, TYPE_INT8, &bytes); - } - - // human-readable string representation - pub fn to_string(&self) -> String { - self.value().to_string() - } - - // retrieve value from host container - pub fn value(&self) -> u8 { - let bytes = get_bytes(self.obj_id, self.key_id, TYPE_INT8); - bytes[0] - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -// value proxy for mutable Uint16 in host container -pub struct ScMutableUint16 { - obj_id: i32, - key_id: Key32, -} - -impl ScMutableUint16 { - pub fn new(obj_id: i32, key_id: Key32) -> ScMutableUint16 { - ScMutableUint16 { obj_id, key_id } - } - - // delete value from host container - pub fn delete(&self) { - del_key(self.obj_id, self.key_id, TYPE_INT16) - } - - // check if value exists in host container - pub fn exists(&self) -> bool { - exists(self.obj_id, self.key_id, TYPE_INT16) - } - - // set value in host container - pub fn set_value(&self, val: u16) { - set_bytes(self.obj_id, self.key_id, TYPE_INT16, &val.to_le_bytes()); - } - - // human-readable string representation - pub fn to_string(&self) -> String { - self.value().to_string() - } - - // retrieve value from host container - pub fn value(&self) -> u16 { - let bytes = get_bytes(self.obj_id, self.key_id, TYPE_INT16); - u16::from_le_bytes(bytes.try_into().expect("invalid u16 length")) - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -// value proxy for mutable Uint32 in host container -pub struct ScMutableUint32 { - obj_id: i32, - key_id: Key32, -} - -impl ScMutableUint32 { - pub fn new(obj_id: i32, key_id: Key32) -> ScMutableUint32 { - ScMutableUint32 { obj_id, key_id } - } - - // delete value from host container - pub fn delete(&self) { - del_key(self.obj_id, self.key_id, TYPE_INT32) - } - - // check if value exists in host container - pub fn exists(&self) -> bool { - exists(self.obj_id, self.key_id, TYPE_INT32) - } - - // set value in host container - pub fn set_value(&self, val: u32) { - set_bytes(self.obj_id, self.key_id, TYPE_INT32, &val.to_le_bytes()); - } - - // human-readable string representation - pub fn to_string(&self) -> String { - self.value().to_string() - } - - // retrieve value from host container - pub fn value(&self) -> u32 { - let bytes = get_bytes(self.obj_id, self.key_id, TYPE_INT32); - u32::from_le_bytes(bytes.try_into().expect("invalid u32 length")) - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -// value proxy for mutable Uint64 in host container -pub struct ScMutableUint64 { - obj_id: i32, - key_id: Key32, -} - -impl ScMutableUint64 { - pub fn new(obj_id: i32, key_id: Key32) -> ScMutableUint64 { - ScMutableUint64 { obj_id, key_id } - } - - // delete value from host container - pub fn delete(&self) { - del_key(self.obj_id, self.key_id, TYPE_INT64) - } - - // check if value exists in host container - pub fn exists(&self) -> bool { - exists(self.obj_id, self.key_id, TYPE_INT64) - } - - // set value in host container - pub fn set_value(&self, val: u64) { - set_bytes(self.obj_id, self.key_id, TYPE_INT64, &val.to_le_bytes()); - } - - // human-readable string representation - pub fn to_string(&self) -> String { - self.value().to_string() - } - - // retrieve value from host container - pub fn value(&self) -> u64 { - let bytes = get_bytes(self.obj_id, self.key_id, TYPE_INT64); - u64::from_le_bytes(bytes.try_into().expect("invalid ui64 length")) - } -} diff --git a/packages/wasmvm/wasmlib/src/sandbox.rs b/packages/wasmvm/wasmlib/src/sandbox.rs new file mode 100644 index 0000000000..15d48a5373 --- /dev/null +++ b/packages/wasmvm/wasmlib/src/sandbox.rs @@ -0,0 +1,172 @@ +// Copyright 2020 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +use crate::host::*; +use crate::wasmtypes; + +// @formatter:off +pub const FN_ACCOUNT_ID : i32 = -1; +pub const FN_BALANCE : i32 = -2; +pub const FN_BALANCES : i32 = -3; +pub const FN_BLOCK_CONTEXT : i32 = -4; +pub const FN_CALL : i32 = -5; +pub const FN_CALLER : i32 = -6; +pub const FN_CHAIN_ID : i32 = -7; +pub const FN_CHAIN_OWNER_ID : i32 = -8; +pub const FN_CONTRACT : i32 = -9; +pub const FN_CONTRACT_CREATOR : i32 = -10; +pub const FN_DEPLOY_CONTRACT : i32 = -11; +pub const FN_ENTROPY : i32 = -12; +pub const FN_EVENT : i32 = -13; +pub const FN_INCOMING_TRANSFER : i32 = -14; +pub const FN_LOG : i32 = -15; +pub const FN_MINTED : i32 = -16; +pub const FN_PANIC : i32 = -17; +pub const FN_PARAMS : i32 = -18; +pub const FN_POST : i32 = -19; +pub const FN_REQUEST : i32 = -20; +pub const FN_REQUEST_ID : i32 = -21; +pub const FN_RESULTS : i32 = -22; +pub const FN_SEND : i32 = -23; +pub const FN_STATE_ANCHOR : i32 = -24; +pub const FN_TIMESTAMP : i32 = -25; +pub const FN_TRACE : i32 = -26; +pub const FN_UTILS_BASE58_DECODE : i32 = -27; +pub const FN_UTILS_BASE58_ENCODE : i32 = -28; +pub const FN_UTILS_BLS_ADDRESS : i32 = -29; +pub const FN_UTILS_BLS_AGGREGATE : i32 = -30; +pub const FN_UTILS_BLS_VALID : i32 = -31; +pub const FN_UTILS_ED25519_ADDRESS : i32 = -32; +pub const FN_UTILS_ED25519_VALID : i32 = -33; +pub const FN_UTILS_HASH_BLAKE2B : i32 = -34; +pub const FN_UTILS_HASH_NAME : i32 = -35; +pub const FN_UTILS_HASH_SHA3 : i32 = -36; +// @formatter:on + +// Direct logging of informational text to host log +pub fn log(text: &str) { + sandbox(FN_LOG, text.as_bytes()); +} + +// Direct logging of error to host log, followed by panicking out of the Wasm code +pub fn panic(text: &str) { + sandbox(FN_PANIC, text.as_bytes()); +} + +// Direct logging of debug trace text to host log +pub fn trace(text: &str) { + sandbox(FN_TRACE, text.as_bytes()); +} + +pub struct ScSandbox {} + +impl ScSandbox { + // retrieve the agent id of this contract account + pub fn accountID() -> wasmtypes::ScAgentID { + wasmtypes::agent_id_from_bytes(sandbox(FN_ACCOUNT_ID, null)) + } + + pub fn balance(color: wasmtypes::ScColor) -> u64 { + wasmtypes::uint64_from_bytes(sandbox(FN_BALANCE, &color.toBytes())) + } + + // access the current balances for all assets + pub fn balances() -> ScBalances { + return ScAssets::new(sandbox(FN_BALANCES, null)).balances() + } + + // calls a smart contract function + fn callWithTransfer(hContract: wasmtypes::ScHname, hFunction: wasmtypes::ScHname, params: Option, transfer: Option) -> ScImmutableDict { + if (params == None) { + params = new ScDict([]); + } + if (transfer == None) { + transfer = new ScTransfers(); + } + const req = new wasmrequests.CallRequest(); + req.contract = hContract; + req.function = hFunction; + req.params = params.toBytes(); + req.transfer = transfer.toBytes(); + const res = sandbox(FN_CALL, req.bytes()); + return new ScDict(res).immutable() + } + + // retrieve the chain id of the chain this contract lives on + pub fn chainID() -> wasmtypes::ScChainID { + return wasmtypes::chainIDFromBytes(sandbox(FN_CHAIN_ID, null)) + } + + // retrieve the agent id of the owner of the chain this contract lives on + pub fn chainOwnerID() -> wasmtypes::ScAgentID { + return wasmtypes::agentIDFromBytes(sandbox(FN_CHAIN_OWNER_ID, null)) + } + + // retrieve the hname of this contract + pub fn contract() -> wasmtypes::ScHname { + return wasmtypes::hnameFromBytes(sandbox(FN_CONTRACT, null)) + } + + // retrieve the agent id of the creator of this contract + pub fn contractCreator() -> wasmtypes::ScAgentID { + return wasmtypes::agentIDFromBytes(sandbox(FN_CONTRACT_CREATOR, null)) + } + + // logs informational text message + pub fn log(text: string) -> void { + sandbox(FN_LOG, wasmtypes::stringToBytes(text)) + } + + // logs error text message and then panics + pub fn panic(text: string) -> void { + sandbox(FN_PANIC, wasmtypes::stringToBytes(text)) + } + + // retrieve parameters passed to the smart contract function that was called + pub fn params() -> ScImmutableDict { + return new + ScDict(sandbox(FN_PARAMS, null)).immutable() + } + + // panics if condition is not satisfied + pub fn require(cond: bool, msg: string) -> void { + if (!cond) { + this.panic(msg) + } + } + + pub fn results(results: ScDict) -> void { + sandbox(FN_RESULTS, results.toBytes()) + } + + // deterministic time stamp fixed at the moment of calling the smart contract + pub fn timestamp() -> u64 { + return wasmtypes::uint64FromBytes(sandbox(FN_TIMESTAMP, null)) + } + + // logs debugging trace text message + pub fn trace(text: string) -> void { + sandbox(FN_TRACE, wasmtypes::stringToBytes(text)); + } + + // access diverse utility functions + pub fn utility() -> ScSandboxUtils { + return ScSandboxUtils {}; + } +} + +pub struct ScSandboxView {} + +impl ScSandboxView { + pub fn rawState() -> ScImmutableState { + return ScImmutableState {}; + } +} + +pub struct ScSandboxFunc {} + +impl ScSandboxFunc { + pub fn rawState() -> ScState { + return ScState {}; + } +} diff --git a/packages/wasmvm/wasmlib/src/sandboxutils.rs b/packages/wasmvm/wasmlib/src/sandboxutils.rs new file mode 100644 index 0000000000..526dad8eb7 --- /dev/null +++ b/packages/wasmvm/wasmlib/src/sandboxutils.rs @@ -0,0 +1,67 @@ +// Copyright 2020 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +use crate::host::*; +use crate::wasmtypes; + +pub struct ScSandboxUtils {} + +impl ScSandboxUtils { + // decodes the specified base58-encoded string value to its original bytes + pub fn base58Decode(value: string) -> &[u8] { + return sandbox(util.FnUtilsBase58Decode, wasmtypes.stringToBytes(value)); + } + + // encodes the specified bytes to a base-58-encoded string + pub fn base58Encode(bytes: &[u8]) -> string { + return wasmtypes.bytesToString(sandbox(util.FnUtilsBase58Encode, bytes)); + } + + pub fn blsAddressFromPubKey(pubKey: &[u8]) -> wasmtypes.ScAddress { + return wasmtypes.addressFromBytes(sandbox(util.FnUtilsBlsAddress, pubKey)); + } + + pub fn blsAggregateSignatures(pubKeys: &[u8][], sigs: &[u8][]) -> &[u8][] { + const enc = new wasmtypes.WasmEncoder(); + wasmtypes.uint32Encode(enc, pubKeys.length as u32); + for (let i = 0; i < pubKeys.length; i++) { + enc.bytes(pubKeys[i]); + } + wasmtypes.uint32Encode(enc, sigs.length as u32); + for (let i = 0; i < sigs.length; i++) { + enc.bytes(sigs[i]); + } + const result = sandbox(util.FnUtilsBlsAggregate, enc.buf()); + const decode = new wasmtypes.WasmDecoder(result); + return [decode.bytes(), decode.bytes()]; + } + + pub fn blsValidSignature(data: &[u8], pubKey: &[u8], signature: &[u8]) -> bool { + const enc = new wasmtypes.WasmEncoder().bytes(data).bytes(pubKey).bytes(signature); + return wasmtypes.boolFromBytes(sandbox(util.FnUtilsBlsValid, enc.buf())); +} + +pub fn ed25519AddressFromPubKey(pubKey: &[u8]) -> wasmtypes.ScAddress { +return wasmtypes.addressFromBytes(sandbox(util.FnUtilsEd25519Address, pubKey)); +} + +pub fn ed25519ValidSignature(data: &[u8], pubKey: &[u8], signature: &[u8]) -> bool { +const enc = new wasmtypes.WasmEncoder().bytes(data).bytes(pubKey).bytes(signature); +return wasmtypes.boolFromBytes(sandbox(util.FnUtilsEd25519Valid, enc.buf())); +} + +// hashes the specified value bytes using blake2b hashing and returns the resulting 32-byte hash +pub fn hashBlake2b(value: &[u8]) -> wasmtypes.ScHash { +return wasmtypes.hashFromBytes(sandbox(util.FnUtilsHashBlake2b, value)); +} + +// hashes the specified value bytes using sha3 hashing and returns the resulting 32-byte hash +pub fn hashSha3(value: &[u8]) -> wasmtypes.ScHash { +return wasmtypes.hashFromBytes(sandbox(util.FnUtilsHashSha3, value)); +} + +// hashes the specified value bytes using blake2b hashing and returns the resulting 32-byte hash +pub fn hname(value: string) -> wasmtypes.ScHname { +return wasmtypes.hnameFromBytes(sandbox(util.FnUtilsHashName, wasmtypes.stringToBytes(value))); +} +} \ No newline at end of file diff --git a/packages/wasmvm/wasmlib/src/state.rs b/packages/wasmvm/wasmlib/src/state.rs new file mode 100644 index 0000000000..9d4dd44367 --- /dev/null +++ b/packages/wasmvm/wasmlib/src/state.rs @@ -0,0 +1,37 @@ +// Copyright 2020 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +use crate::host::*; +use crate::wasmtypes::IKvStore; + +pub struct ScImmutableState {} + +impl ScImmutableState { + pub fn exists(&self, key: &[u8]) -> bool { + state_exists(key) + } + + pub fn get(&self, key: &[u8]) -> Vec { + state_get(key) + } +} + +pub struct ScState {} + +impl IKvStore for ScState { + fn delete(&mut self, key: &[u8]) { + state_delete(key); + } + + fn exists(&self, key: &[u8]) -> bool { + state_exists(key) + } + + fn get(&self, key: &[u8]) -> Vec { + state_get(key) + } + + fn set(&mut self, key: &[u8], value: &[u8]) { + state_set(key, value); + } +} diff --git a/packages/wasmvm/wasmlib/src/wasmtypes/codec.rs b/packages/wasmvm/wasmlib/src/wasmtypes/codec.rs index 37864540f1..caa83bf8ce 100644 --- a/packages/wasmvm/wasmlib/src/wasmtypes/codec.rs +++ b/packages/wasmvm/wasmlib/src/wasmtypes/codec.rs @@ -1,8 +1,7 @@ // Copyright 2020 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 -use crate::hashtypes::*; -use crate::host::*; +use crate::sandbox::*; pub struct WasmDecoder<'a> { buf: &'a [u8], @@ -18,7 +17,7 @@ impl WasmDecoder<'_> { } // decodes the next variable length substring of bytes from the byte buffer - pub fn bytes(&mut self) -> &[u8] { + pub fn bytes(&mut self) -> Vec { let length = self.vlu_decode(32); self.fixed_bytes(length as usize) } @@ -34,13 +33,13 @@ impl WasmDecoder<'_> { } // decodes the next fixed length substring of bytes from the byte buffer - pub fn fixed_bytes(&mut self, size: usize) -> &[u8] { + pub fn fixed_bytes(&mut self, size: usize) -> Vec { if self.buf.len() < size { panic("insufficient fixed bytes"); } let value = &self.buf[..size]; self.buf = &self.buf[size..]; - value + value.to_vec() } // vli (variable length integer) decoder diff --git a/packages/wasmvm/wasmlib/src/wasmtypes/mod.rs b/packages/wasmvm/wasmlib/src/wasmtypes/mod.rs index c6375cbd0a..4ecdb90728 100644 --- a/packages/wasmvm/wasmlib/src/wasmtypes/mod.rs +++ b/packages/wasmvm/wasmlib/src/wasmtypes/mod.rs @@ -24,23 +24,23 @@ pub use scuint16::*; pub use scuint32::*; pub use scuint64::*; -pub mod codec; -pub mod proxy; -pub mod scaddress; -pub mod scagentid; -pub mod scbool; -pub mod scbytes; -pub mod scchainid; -pub mod sccolor; -pub mod schash; -pub mod schname; -pub mod scint8; -pub mod scint16; -pub mod scint32; -pub mod scint64; -pub mod screquestid; -pub mod scstring; -pub mod scuint8; -pub mod scuint16; -pub mod scuint32; -pub mod scuint64; +mod codec; +mod proxy; +mod scaddress; +mod scagentid; +mod scbool; +mod scbytes; +mod scchainid; +mod sccolor; +mod schash; +mod schname; +mod scint8; +mod scint16; +mod scint32; +mod scint64; +mod screquestid; +mod scstring; +mod scuint8; +mod scuint16; +mod scuint32; +mod scuint64; diff --git a/packages/wasmvm/wasmlib/src/wasmtypes/proxy.rs b/packages/wasmvm/wasmlib/src/wasmtypes/proxy.rs index 33cc54cf7f..9e836c8461 100644 --- a/packages/wasmvm/wasmlib/src/wasmtypes/proxy.rs +++ b/packages/wasmvm/wasmlib/src/wasmtypes/proxy.rs @@ -1,14 +1,14 @@ // Copyright 2020 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 -use crate::host::*; +use crate::sandbox::*; use crate::wasmtypes::*; pub trait IKvStore { - fn delete(&self, key: &[u8]); + fn delete(&mut self, key: &[u8]); fn exists(&self, key: &[u8]) -> bool; - fn get(&self, key: &[u8]) -> &[u8]; - fn set(&self, key: &[u8], value: &[u8]); + fn get(&self, key: &[u8]) -> Vec; + fn set(&mut self, key: &[u8], value: &[u8]); } pub struct Proxy<'a> { @@ -21,13 +21,13 @@ impl Proxy<'_> { Proxy { kv_store, key: Vec::new() } } - pub fn append(&self) -> Proxy { + pub fn append(&mut self) -> Proxy { let length = self.length(); self.expand(length + 1); self.element(length) } - pub fn clear_array(&self) { + pub fn clear_array(&mut self) { let mut length = self.length(); while length != 0 { length -= 1; @@ -38,14 +38,14 @@ impl Proxy<'_> { self.delete(); } - pub fn clear_map(&self) { + pub fn clear_map(&mut self) { // TODO clear prefix // clear the length counter self.delete(); } - pub fn delete(&self) { + pub fn delete(&mut self) { self.kv_store.delete(&self.key); } @@ -60,14 +60,14 @@ impl Proxy<'_> { self.kv_store.exists(&self.key) } - pub fn expand(&self, length: u32) { + pub fn expand(&mut self, length: u32) { // update the length counter let mut enc = WasmEncoder::new(); uint32_encode(&mut enc, length); self.set(&enc.buf()); } - pub fn get(&self) -> &[u8] { + pub fn get(&self) -> Vec { self.kv_store.get(&self.key) } @@ -92,7 +92,7 @@ impl Proxy<'_> { if buf.len() == 0 { return 0; } - let mut dec = WasmDecoder::new(buf); + let mut dec = WasmDecoder::new(&buf); uint32_decode(&mut dec) } @@ -100,7 +100,7 @@ impl Proxy<'_> { Proxy { kv_store: self.kv_store, key: string_to_bytes(key).to_vec() } } - pub fn set(&self, value: &[u8]) { + pub fn set(&mut self, value: &[u8]) { self.kv_store.set(&self.key, value); } diff --git a/packages/wasmvm/wasmlib/src/wasmtypes/scaddress.rs b/packages/wasmvm/wasmlib/src/wasmtypes/scaddress.rs index 773b8b37ca..f3380f4e5a 100644 --- a/packages/wasmvm/wasmlib/src/wasmtypes/scaddress.rs +++ b/packages/wasmvm/wasmlib/src/wasmtypes/scaddress.rs @@ -3,6 +3,7 @@ use std::convert::TryInto; +use crate::*; use crate::wasmtypes::*; // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ @@ -15,11 +16,15 @@ pub struct ScAddress { } impl ScAddress { - pub fn from_bytes(buf: &[u8]) -> ScAddress { + pub fn new(buf: &[u8]) -> ScAddress { address_from_bytes(buf) } - pub fn to_bytes(&self) -> &[u8] { + pub fn as_agent_id(&self) -> ScAgentID { + ScAgentID::new(self, &ScHname(0)) + } + + pub fn to_bytes(&self) -> Vec { address_to_bytes(self) } @@ -31,7 +36,7 @@ impl ScAddress { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ pub fn address_decode(dec: &mut WasmDecoder) -> ScAddress { - address_from_bytes_unchecked(dec.fixed_bytes(SC_ADDRESS_LENGTH)) + address_from_bytes_unchecked(&dec.fixed_bytes(SC_ADDRESS_LENGTH)) } pub fn address_encode(enc: &mut WasmEncoder, value: &ScAddress) { @@ -42,8 +47,8 @@ pub fn address_from_bytes(buf: &[u8]) -> ScAddress { ScAddress { id: buf.try_into().expect("invalid Address length") } } -pub fn address_to_bytes(value: &ScAddress) -> &[u8] { - &value.id +pub fn address_to_bytes(value: &ScAddress) -> Vec { + value.id.to_vec() } pub fn address_to_string(value: &ScAddress) -> String { @@ -75,7 +80,7 @@ impl ScImmutableAddress<'_> { } pub fn value(&self) -> ScAddress { - address_from_bytes(self.proxy.get()) + address_from_bytes(&self.proxy.get()) } } @@ -91,7 +96,7 @@ impl ScMutableAddress<'_> { ScMutableAddress { proxy } } - pub fn delete(&self) { + pub fn delete(&mut self) { self.proxy.delete(); } @@ -99,8 +104,8 @@ impl ScMutableAddress<'_> { self.proxy.exists() } - pub fn set_value(&self, value: &ScAddress) { - self.proxy.set(address_to_bytes(&value)); + pub fn set_value(&mut self, value: &ScAddress) { + self.proxy.set(&address_to_bytes(&value)); } pub fn to_string(&self) -> String { @@ -108,6 +113,6 @@ impl ScMutableAddress<'_> { } pub fn value(&self) -> ScAddress { - address_from_bytes(self.proxy.get()) + address_from_bytes(&self.proxy.get()) } } diff --git a/packages/wasmvm/wasmlib/src/wasmtypes/scagentid.rs b/packages/wasmvm/wasmlib/src/wasmtypes/scagentid.rs index b603252fde..3ca028f751 100644 --- a/packages/wasmvm/wasmlib/src/wasmtypes/scagentid.rs +++ b/packages/wasmvm/wasmlib/src/wasmtypes/scagentid.rs @@ -3,6 +3,8 @@ use std::convert::TryInto; +use crate::*; +use crate::sandbox::*; use crate::wasmtypes::*; // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ @@ -10,16 +12,33 @@ use crate::wasmtypes::*; pub const SC_AGENT_ID_LENGTH: usize = 37; #[derive(PartialEq, Clone)] -pub struct ScAgentId { - id: [u8; SC_AGENT_ID_LENGTH], +pub struct ScAgentID { + address: ScAddress, + hname: ScHname, } -impl ScAgentId { - pub fn from_bytes(buf: &[u8]) -> ScAgentId { +impl ScAgentID { + pub fn new(address: &ScAddress, hname: &ScHname) -> ScAgentID { + ScAgentID { address: address_from_bytes(&address.to_bytes()), hname: hname_from_bytes(&hname.to_bytes()) } + } + + pub fn from_bytes(buf: &[u8]) -> ScAgentID { agent_id_from_bytes(buf) } - pub fn to_bytes(&self) -> &[u8] { + pub fn address(&self) -> &ScAddress { + &self.address + } + + pub fn hname(&self) -> &ScHname { + &self.hname + } + + pub fn is_address(&self) -> bool { + self.hname == ScHname(0) + } + + pub fn to_bytes(&self) -> Vec { agent_id_to_bytes(self) } @@ -30,29 +49,41 @@ impl ScAgentId { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -pub fn agent_id_decode(dec: &mut WasmDecoder) -> ScAgentId { - agent_id_from_bytes_unchecked(dec.fixed_bytes(SC_AGENT_ID_LENGTH)) +pub fn agent_id_decode(dec: &mut WasmDecoder) -> ScAgentID { + ScAgentID { address: address_decode(dec), hname: hname_decode(dec) } } -pub fn agent_id_encode(enc: &mut WasmEncoder, value: &ScAgentId) { - enc.fixed_bytes(&value.to_bytes(), SC_AGENT_ID_LENGTH); +pub fn agent_id_encode(enc: &mut WasmEncoder, value: &ScAgentID) { + address_encode(enc, value.address()); + hname_encode(enc, value.hname()); } -pub fn agent_id_from_bytes(buf: &[u8]) -> ScAgentId { - ScAgentId { id: buf.try_into().expect("invalid AgentId length") } +pub fn agent_id_from_bytes(buf: &[u8]) -> ScAgentID { + if buf.len() == 0 { + return ScAgentID { address: address_from_bytes(buf), hname: hname_from_bytes(buf) }; + } + if buf.len() != SC_AGENT_ID_LENGTH { + panic("invalid AgentId length"); + } + // max ledgerstate.AliasAddressType + if buf[0] > 2 { + panic("invalid AgentID: address type > 2"); + } + ScAgentID { + address: address_from_bytes(&buf[..SC_ADDRESS_LENGTH]), + hname: hname_from_bytes(&buf[SC_ADDRESS_LENGTH..]), + } } -pub fn agent_id_to_bytes(value: &ScAgentId) -> &[u8] { - &value.id +pub fn agent_id_to_bytes(value: &ScAgentID) -> Vec { + let mut enc = WasmEncoder::new(); + agent_id_encode(&mut enc, value); + enc.buf() } -pub fn agent_id_to_string(value: &ScAgentId) -> String { +pub fn agent_id_to_string(value: &ScAgentID) -> String { // TODO standardize human readable string - base58_encode(&value.id) -} - -fn agent_id_from_bytes_unchecked(buf: &[u8]) -> ScAgentId { - ScAgentId { id: buf.try_into().expect("invalid AgentId length") } + value.address.to_string() + "::" + &value.hname.to_string() } // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ @@ -74,8 +105,8 @@ impl ScImmutableAgentId<'_> { agent_id_to_string(&self.value()) } - pub fn value(&self) -> ScAgentId { - agent_id_from_bytes(self.proxy.get()) + pub fn value(&self) -> ScAgentID { + agent_id_from_bytes(&self.proxy.get()) } } @@ -91,7 +122,7 @@ impl ScMutableAgentId<'_> { ScMutableAgentId { proxy } } - pub fn delete(&self) { + pub fn delete(&mut self) { self.proxy.delete(); } @@ -99,15 +130,15 @@ impl ScMutableAgentId<'_> { self.proxy.exists() } - pub fn set_value(&self, value: &ScAgentId) { - self.proxy.set(agent_id_to_bytes(&value)); + pub fn set_value(&mut self, value: &ScAgentID) { + self.proxy.set(&agent_id_to_bytes(&value)); } pub fn to_string(&self) -> String { agent_id_to_string(&self.value()) } - pub fn value(&self) -> ScAgentId { - agent_id_from_bytes(self.proxy.get()) + pub fn value(&self) -> ScAgentID { + agent_id_from_bytes(&self.proxy.get()) } } diff --git a/packages/wasmvm/wasmlib/src/wasmtypes/scbool.rs b/packages/wasmvm/wasmlib/src/wasmtypes/scbool.rs index 3d85b5cac2..f21632f3c8 100644 --- a/packages/wasmvm/wasmlib/src/wasmtypes/scbool.rs +++ b/packages/wasmvm/wasmlib/src/wasmtypes/scbool.rs @@ -3,7 +3,7 @@ use std::convert::TryInto; -use crate::host::*; +use crate::sandbox::*; use crate::wasmtypes::*; // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ @@ -76,7 +76,7 @@ impl ScImmutableBool<'_> { } pub fn value(&self) -> bool { - bool_from_bytes(self.proxy.get()) + bool_from_bytes(&self.proxy.get()) } } @@ -92,7 +92,7 @@ impl ScMutableBool<'_> { ScMutableBool { proxy } } - pub fn delete(&self) { + pub fn delete(&mut self) { self.proxy.delete(); } @@ -100,7 +100,7 @@ impl ScMutableBool<'_> { self.proxy.exists() } - pub fn set_value(&self, value: bool) { + pub fn set_value(&mut self, value: bool) { self.proxy.set(&bool_to_bytes(value)); } @@ -109,6 +109,6 @@ impl ScMutableBool<'_> { } pub fn value(&self) -> bool { - bool_from_bytes(self.proxy.get()) + bool_from_bytes(&self.proxy.get()) } } diff --git a/packages/wasmvm/wasmlib/src/wasmtypes/scbytes.rs b/packages/wasmvm/wasmlib/src/wasmtypes/scbytes.rs index d6e591a8a9..159670863d 100644 --- a/packages/wasmvm/wasmlib/src/wasmtypes/scbytes.rs +++ b/packages/wasmvm/wasmlib/src/wasmtypes/scbytes.rs @@ -19,8 +19,8 @@ pub fn bytes_from_bytes(buf: &[u8]) -> Vec { buf.to_vec() } -pub fn bytes_to_bytes(value: &[u8]) -> &[u8] { - value +pub fn bytes_to_bytes(value: &[u8]) -> Vec { + value.to_vec() } pub fn bytes_to_string(value: &[u8]) -> String { @@ -48,7 +48,7 @@ impl ScImmutableBytes<'_> { } pub fn value(&self) -> Vec { - bytes_from_bytes(self.proxy.get()) + bytes_from_bytes(&self.proxy.get()) } } @@ -64,7 +64,7 @@ impl ScMutableBytes<'_> { ScMutableBytes { proxy } } - pub fn delete(&self) { + pub fn delete(&mut self) { self.proxy.delete(); } @@ -72,8 +72,8 @@ impl ScMutableBytes<'_> { self.proxy.exists() } - pub fn set_value(&self, value: &[u8]) { - self.proxy.set(bytes_to_bytes(value)); + pub fn set_value(&mut self, value: &[u8]) { + self.proxy.set(&bytes_to_bytes(value)); } pub fn to_string(&self) -> String { @@ -81,6 +81,6 @@ impl ScMutableBytes<'_> { } pub fn value(&self) -> Vec { - bytes_from_bytes(self.proxy.get()) + bytes_from_bytes(&self.proxy.get()) } } diff --git a/packages/wasmvm/wasmlib/src/wasmtypes/scchainid.rs b/packages/wasmvm/wasmlib/src/wasmtypes/scchainid.rs index 4f27bc1c99..d063c7036f 100644 --- a/packages/wasmvm/wasmlib/src/wasmtypes/scchainid.rs +++ b/packages/wasmvm/wasmlib/src/wasmtypes/scchainid.rs @@ -3,6 +3,7 @@ use std::convert::TryInto; +use crate::*; use crate::wasmtypes::*; // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ @@ -10,16 +11,20 @@ use crate::wasmtypes::*; pub const SC_CHAIN_ID_LENGTH: usize = 33; #[derive(PartialEq, Clone)] -pub struct ScChainId { +pub struct ScChainID { id: [u8; SC_CHAIN_ID_LENGTH], } -impl ScChainId { - pub fn from_bytes(buf: &[u8]) -> ScChainId { +impl ScChainID { + pub fn new(buf: &[u8]) -> ScChainID { chain_id_from_bytes(buf) } - pub fn to_bytes(&self) -> &[u8] { + pub fn address(&self) -> ScAddress { + address_from_bytes(&self.id) + } + + pub fn to_bytes(&self) -> Vec { chain_id_to_bytes(self) } @@ -30,29 +35,29 @@ impl ScChainId { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -pub fn chain_id_decode(dec: &mut WasmDecoder) -> ScChainId { - chain_id_from_bytes_unchecked(dec.fixed_bytes(SC_CHAIN_ID_LENGTH)) +pub fn chain_id_decode(dec: &mut WasmDecoder) -> ScChainID { + chain_id_from_bytes_unchecked(&dec.fixed_bytes(SC_CHAIN_ID_LENGTH)) } -pub fn chain_id_encode(enc: &mut WasmEncoder, value: &ScChainId) { +pub fn chain_id_encode(enc: &mut WasmEncoder, value: &ScChainID) { enc.fixed_bytes(&value.to_bytes(), SC_CHAIN_ID_LENGTH); } -pub fn chain_id_from_bytes(buf: &[u8]) -> ScChainId { - ScChainId { id: buf.try_into().expect("invalid ChainId length") } +pub fn chain_id_from_bytes(buf: &[u8]) -> ScChainID { + ScChainID { id: buf.try_into().expect("invalid ChainId length") } } -pub fn chain_id_to_bytes(value: &ScChainId) -> &[u8] { - &value.id +pub fn chain_id_to_bytes(value: &ScChainID) -> Vec { + value.id.to_vec() } -pub fn chain_id_to_string(value: &ScChainId) -> String { +pub fn chain_id_to_string(value: &ScChainID) -> String { // TODO standardize human readable string base58_encode(&value.id) } -fn chain_id_from_bytes_unchecked(buf: &[u8]) -> ScChainId { - ScChainId { id: buf.try_into().expect("invalid ChainId length") } +fn chain_id_from_bytes_unchecked(buf: &[u8]) -> ScChainID { + ScChainID { id: buf.try_into().expect("invalid ChainId length") } } // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ @@ -74,8 +79,8 @@ impl ScImmutableChainId<'_> { chain_id_to_string(&self.value()) } - pub fn value(&self) -> ScChainId { - chain_id_from_bytes(self.proxy.get()) + pub fn value(&self) -> ScChainID { + chain_id_from_bytes(&self.proxy.get()) } } @@ -91,7 +96,7 @@ impl ScMutableChainId<'_> { ScMutableChainId { proxy } } - pub fn delete(&self) { + pub fn delete(&mut self) { self.proxy.delete(); } @@ -99,15 +104,15 @@ impl ScMutableChainId<'_> { self.proxy.exists() } - pub fn set_value(&self, value: &ScChainId) { - self.proxy.set(chain_id_to_bytes(&value)); + pub fn set_value(&mut self, value: &ScChainID) { + self.proxy.set(&chain_id_to_bytes(&value)); } pub fn to_string(&self) -> String { chain_id_to_string(&self.value()) } - pub fn value(&self) -> ScChainId { - chain_id_from_bytes(self.proxy.get()) + pub fn value(&self) -> ScChainID { + chain_id_from_bytes(&self.proxy.get()) } } diff --git a/packages/wasmvm/wasmlib/src/wasmtypes/sccolor.rs b/packages/wasmvm/wasmlib/src/wasmtypes/sccolor.rs index fc43365f63..f427fd9980 100644 --- a/packages/wasmvm/wasmlib/src/wasmtypes/sccolor.rs +++ b/packages/wasmvm/wasmlib/src/wasmtypes/sccolor.rs @@ -18,11 +18,11 @@ impl ScColor { pub const IOTA: ScColor = ScColor { id: [0x00; SC_COLOR_LENGTH] }; pub const MINT: ScColor = ScColor { id: [0xff; SC_COLOR_LENGTH] }; - pub fn from_bytes(buf: &[u8]) -> ScColor { + pub fn new(buf: &[u8]) -> ScColor { color_from_bytes(buf) } - pub fn to_bytes(&self) -> &[u8] { + pub fn to_bytes(&self) -> Vec { color_to_bytes(self) } @@ -34,7 +34,7 @@ impl ScColor { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ pub fn color_decode(dec: &mut WasmDecoder) -> ScColor { - color_from_bytes_unchecked(dec.fixed_bytes(SC_COLOR_LENGTH)) + color_from_bytes_unchecked(&dec.fixed_bytes(SC_COLOR_LENGTH)) } pub fn color_encode(enc: &mut WasmEncoder, value: &ScColor) { @@ -45,8 +45,8 @@ pub fn color_from_bytes(buf: &[u8]) -> ScColor { ScColor { id: buf.try_into().expect("invalid Color length") } } -pub fn color_to_bytes(value: &ScColor) -> &[u8] { - &value.id +pub fn color_to_bytes(value: &ScColor) -> Vec { + value.id.to_vec() } pub fn color_to_string(value: &ScColor) -> String { @@ -78,7 +78,7 @@ impl ScImmutableColor<'_> { } pub fn value(&self) -> ScColor { - color_from_bytes(self.proxy.get()) + color_from_bytes(&self.proxy.get()) } } @@ -94,7 +94,7 @@ impl ScMutableColor<'_> { ScMutableColor { proxy } } - pub fn delete(&self) { + pub fn delete(&mut self) { self.proxy.delete(); } @@ -102,8 +102,8 @@ impl ScMutableColor<'_> { self.proxy.exists() } - pub fn set_value(&self, value: &ScColor) { - self.proxy.set(color_to_bytes(&value)); + pub fn set_value(&mut self, value: &ScColor) { + self.proxy.set(&color_to_bytes(&value)); } pub fn to_string(&self) -> String { @@ -111,6 +111,6 @@ impl ScMutableColor<'_> { } pub fn value(&self) -> ScColor { - color_from_bytes(self.proxy.get()) + color_from_bytes(&self.proxy.get()) } } diff --git a/packages/wasmvm/wasmlib/src/wasmtypes/schash.rs b/packages/wasmvm/wasmlib/src/wasmtypes/schash.rs index 8654aebab4..aba1837beb 100644 --- a/packages/wasmvm/wasmlib/src/wasmtypes/schash.rs +++ b/packages/wasmvm/wasmlib/src/wasmtypes/schash.rs @@ -15,11 +15,11 @@ pub struct ScHash { } impl ScHash { - pub fn from_bytes(buf: &[u8]) -> ScHash { + pub fn new(buf: &[u8]) -> ScHash { hash_from_bytes(buf) } - pub fn to_bytes(&self) -> &[u8] { + pub fn to_bytes(&self) -> Vec { hash_to_bytes(self) } @@ -31,7 +31,7 @@ impl ScHash { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ pub fn hash_decode(dec: &mut WasmDecoder) -> ScHash { - hash_from_bytes_unchecked(dec.fixed_bytes(SC_HASH_LENGTH)) + hash_from_bytes_unchecked(&dec.fixed_bytes(SC_HASH_LENGTH)) } pub fn hash_encode(enc: &mut WasmEncoder, value: &ScHash) { @@ -42,8 +42,8 @@ pub fn hash_from_bytes(buf: &[u8]) -> ScHash { ScHash { id: buf.try_into().expect("invalid Hash length") } } -pub fn hash_to_bytes(value: &ScHash) -> &[u8] { - &value.id +pub fn hash_to_bytes(value: &ScHash) -> Vec { + value.id.to_vec() } pub fn hash_to_string(value: &ScHash) -> String { @@ -75,7 +75,7 @@ impl ScImmutableHash<'_> { } pub fn value(&self) -> ScHash { - hash_from_bytes(self.proxy.get()) + hash_from_bytes(&self.proxy.get()) } } @@ -91,7 +91,7 @@ impl ScMutableHash<'_> { ScMutableHash { proxy } } - pub fn delete(&self) { + pub fn delete(&mut self) { self.proxy.delete(); } @@ -99,8 +99,8 @@ impl ScMutableHash<'_> { self.proxy.exists() } - pub fn set_value(&self, value: &ScHash) { - self.proxy.set(hash_to_bytes(&value)); + pub fn set_value(&mut self, value: &ScHash) { + self.proxy.set(&hash_to_bytes(&value)); } pub fn to_string(&self) -> String { @@ -108,6 +108,6 @@ impl ScMutableHash<'_> { } pub fn value(&self) -> ScHash { - hash_from_bytes(self.proxy.get()) + hash_from_bytes(&self.proxy.get()) } } diff --git a/packages/wasmvm/wasmlib/src/wasmtypes/schname.rs b/packages/wasmvm/wasmlib/src/wasmtypes/schname.rs index 501b9bd084..465624836b 100644 --- a/packages/wasmvm/wasmlib/src/wasmtypes/schname.rs +++ b/packages/wasmvm/wasmlib/src/wasmtypes/schname.rs @@ -10,16 +10,14 @@ use crate::wasmtypes::*; pub const SC_HNAME_LENGTH: usize = 4; #[derive(PartialEq, Clone)] -pub struct ScHname { - id: [u8; SC_HNAME_LENGTH], -} +pub struct ScHname(pub u32); impl ScHname { - pub fn from_bytes(buf: &[u8]) -> ScHname { - hname_from_bytes(buf) + pub fn new(buf: &[u8]) -> ScHname { + ScHname(uint32_from_bytes(buf)) } - pub fn to_bytes(&self) -> &[u8] { + pub fn to_bytes(&self) -> Vec { hname_to_bytes(self) } @@ -31,28 +29,33 @@ impl ScHname { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ pub fn hname_decode(dec: &mut WasmDecoder) -> ScHname { - hname_from_bytes_unchecked(dec.fixed_bytes(SC_HNAME_LENGTH)) + hname_from_bytes(&dec.fixed_bytes(SC_HNAME_LENGTH)) } pub fn hname_encode(enc: &mut WasmEncoder, value: &ScHname) { - enc.fixed_bytes(&value.to_bytes(), SC_HNAME_LENGTH); + enc.fixed_bytes(&hname_to_bytes(value), SC_HNAME_LENGTH); } pub fn hname_from_bytes(buf: &[u8]) -> ScHname { - ScHname { id: buf.try_into().expect("invalid Hname length") } + if buf.len() == 0 { + return ScHname(0); + } + ScHname(u32::from_le_bytes(buf.try_into().expect("invalid Hname length"))) } -pub fn hname_to_bytes(value: &ScHname) -> &[u8] { - &value.id +pub fn hname_to_bytes(value: &ScHname) -> Vec { + value.0.to_le_bytes().to_vec() } pub fn hname_to_string(value: &ScHname) -> String { - // TODO standardize human readable string - base58_encode(&value.id) -} - -fn hname_from_bytes_unchecked(buf: &[u8]) -> ScHname { - ScHname { id: buf.try_into().expect("invalid Hname length") } + let hexa = "0123456789abcdef".as_bytes(); + let mut res = [0u8; 8]; + let mut val = value.0; + for n in 0..8 { + res[7 - n] = hexa[val as usize & 0x0f]; + val >>= 4; + } + String::from_utf8(res.to_vec()).expect("WTF? invalid?") } // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ @@ -75,7 +78,7 @@ impl ScImmutableHname<'_> { } pub fn value(&self) -> ScHname { - hname_from_bytes(self.proxy.get()) + hname_from_bytes(&self.proxy.get()) } } @@ -91,7 +94,7 @@ impl ScMutableHname<'_> { ScMutableHname { proxy } } - pub fn delete(&self) { + pub fn delete(&mut self) { self.proxy.delete(); } @@ -99,8 +102,8 @@ impl ScMutableHname<'_> { self.proxy.exists() } - pub fn set_value(&self, value: &ScHname) { - self.proxy.set(hname_to_bytes(&value)); + pub fn set_value(&mut self, value: &ScHname) { + self.proxy.set(&hname_to_bytes(&value)); } pub fn to_string(&self) -> String { @@ -108,6 +111,6 @@ impl ScMutableHname<'_> { } pub fn value(&self) -> ScHname { - hname_from_bytes(self.proxy.get()) + hname_from_bytes(&self.proxy.get()) } } diff --git a/packages/wasmvm/wasmlib/src/wasmtypes/scint16.rs b/packages/wasmvm/wasmlib/src/wasmtypes/scint16.rs index cd1500bc2b..f54c07555b 100644 --- a/packages/wasmvm/wasmlib/src/wasmtypes/scint16.rs +++ b/packages/wasmvm/wasmlib/src/wasmtypes/scint16.rs @@ -54,7 +54,7 @@ impl ScImmutableInt16<'_> { } pub fn value(&self) -> i16 { - int16_from_bytes(self.proxy.get()) + int16_from_bytes(&self.proxy.get()) } } @@ -70,7 +70,7 @@ impl ScMutableInt16<'_> { ScMutableInt16 { proxy } } - pub fn delete(&self) { + pub fn delete(&mut self) { self.proxy.delete(); } @@ -78,7 +78,7 @@ impl ScMutableInt16<'_> { self.proxy.exists() } - pub fn set_value(&self, value: i16) { + pub fn set_value(&mut self, value: i16) { self.proxy.set(&int16_to_bytes(value)); } @@ -87,6 +87,6 @@ impl ScMutableInt16<'_> { } pub fn value(&self) -> i16 { - int16_from_bytes(self.proxy.get()) + int16_from_bytes(&self.proxy.get()) } } diff --git a/packages/wasmvm/wasmlib/src/wasmtypes/scint32.rs b/packages/wasmvm/wasmlib/src/wasmtypes/scint32.rs index 8b8d587628..17652d3122 100644 --- a/packages/wasmvm/wasmlib/src/wasmtypes/scint32.rs +++ b/packages/wasmvm/wasmlib/src/wasmtypes/scint32.rs @@ -23,7 +23,7 @@ pub fn int32_from_bytes(buf: &[u8]) -> i32 { if buf.len() == 0 { return 0; } - i32::from_le_bytes(buf.try_into().expect("invalid i32 length")) + i32::from_le_bytes(buf.try_into().expect("invalid Int32 length")) } pub fn int32_to_bytes(value: i32) -> Vec { @@ -54,7 +54,7 @@ impl ScImmutableInt32<'_> { } pub fn value(&self) -> i32 { - int32_from_bytes(self.proxy.get()) + int32_from_bytes(&self.proxy.get()) } } @@ -70,7 +70,7 @@ impl ScMutableInt32<'_> { ScMutableInt32 { proxy } } - pub fn delete(&self) { + pub fn delete(&mut self) { self.proxy.delete(); } @@ -78,7 +78,7 @@ impl ScMutableInt32<'_> { self.proxy.exists() } - pub fn set_value(&self, value: i32) { + pub fn set_value(&mut self, value: i32) { self.proxy.set(&int32_to_bytes(value)); } @@ -87,6 +87,6 @@ impl ScMutableInt32<'_> { } pub fn value(&self) -> i32 { - int32_from_bytes(self.proxy.get()) + int32_from_bytes(&self.proxy.get()) } } diff --git a/packages/wasmvm/wasmlib/src/wasmtypes/scint64.rs b/packages/wasmvm/wasmlib/src/wasmtypes/scint64.rs index 188a03b493..a31b694bc4 100644 --- a/packages/wasmvm/wasmlib/src/wasmtypes/scint64.rs +++ b/packages/wasmvm/wasmlib/src/wasmtypes/scint64.rs @@ -54,7 +54,7 @@ impl ScImmutableInt64<'_> { } pub fn value(&self) -> i64 { - int64_from_bytes(self.proxy.get()) + int64_from_bytes(&self.proxy.get()) } } @@ -70,7 +70,7 @@ impl ScMutableInt64<'_> { ScMutableInt64 { proxy } } - pub fn delete(&self) { + pub fn delete(&mut self) { self.proxy.delete(); } @@ -78,7 +78,7 @@ impl ScMutableInt64<'_> { self.proxy.exists() } - pub fn set_value(&self, value: i64) { + pub fn set_value(&mut self, value: i64) { self.proxy.set(&int64_to_bytes(value)); } @@ -87,6 +87,6 @@ impl ScMutableInt64<'_> { } pub fn value(&self) -> i64 { - int64_from_bytes(self.proxy.get()) + int64_from_bytes(&self.proxy.get()) } } diff --git a/packages/wasmvm/wasmlib/src/wasmtypes/scint8.rs b/packages/wasmvm/wasmlib/src/wasmtypes/scint8.rs index 3c483c3d38..cd2b14291c 100644 --- a/packages/wasmvm/wasmlib/src/wasmtypes/scint8.rs +++ b/packages/wasmvm/wasmlib/src/wasmtypes/scint8.rs @@ -3,7 +3,7 @@ use std::convert::TryInto; -use crate::host::*; +use crate::sandbox::*; use crate::wasmtypes::*; // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ @@ -58,7 +58,7 @@ impl ScImmutableInt8<'_> { } pub fn value(&self) -> i8 { - int8_from_bytes(self.proxy.get()) + int8_from_bytes(&self.proxy.get()) } } @@ -74,7 +74,7 @@ impl ScMutableInt8<'_> { ScMutableInt8 { proxy } } - pub fn delete(&self) { + pub fn delete(&mut self) { self.proxy.delete(); } @@ -82,7 +82,7 @@ impl ScMutableInt8<'_> { self.proxy.exists() } - pub fn set_value(&self, value: i8) { + pub fn set_value(&mut self, value: i8) { self.proxy.set(&int8_to_bytes(value)); } @@ -91,6 +91,6 @@ impl ScMutableInt8<'_> { } pub fn value(&self) -> i8 { - int8_from_bytes(self.proxy.get()) + int8_from_bytes(&self.proxy.get()) } } diff --git a/packages/wasmvm/wasmlib/src/wasmtypes/screquestid.rs b/packages/wasmvm/wasmlib/src/wasmtypes/screquestid.rs index 2c16dbe9f2..726c47eb42 100644 --- a/packages/wasmvm/wasmlib/src/wasmtypes/screquestid.rs +++ b/packages/wasmvm/wasmlib/src/wasmtypes/screquestid.rs @@ -10,16 +10,16 @@ use crate::wasmtypes::*; pub const SC_REQUEST_ID_LENGTH: usize = 34; #[derive(PartialEq, Clone)] -pub struct ScRequestId { +pub struct ScRequestID { id: [u8; SC_REQUEST_ID_LENGTH], } -impl ScRequestId { - pub fn from_bytes(buf: &[u8]) -> ScRequestId { +impl ScRequestID { + pub fn new(buf: &[u8]) -> ScRequestID { request_id_from_bytes(buf) } - pub fn to_bytes(&self) -> &[u8] { + pub fn to_bytes(&self) -> Vec { request_id_to_bytes(self) } @@ -30,29 +30,29 @@ impl ScRequestId { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -pub fn request_id_decode(dec: &mut WasmDecoder) -> ScRequestId { - request_id_from_bytes_unchecked(dec.fixed_bytes(SC_REQUEST_ID_LENGTH)) +pub fn request_id_decode(dec: &mut WasmDecoder) -> ScRequestID { + request_id_from_bytes_unchecked(&dec.fixed_bytes(SC_REQUEST_ID_LENGTH)) } -pub fn request_id_encode(enc: &mut WasmEncoder, value: &ScRequestId) { +pub fn request_id_encode(enc: &mut WasmEncoder, value: &ScRequestID) { enc.fixed_bytes(&value.to_bytes(), SC_REQUEST_ID_LENGTH); } -pub fn request_id_from_bytes(buf: &[u8]) -> ScRequestId { - ScRequestId { id: buf.try_into().expect("invalid RequestId length") } +pub fn request_id_from_bytes(buf: &[u8]) -> ScRequestID { + ScRequestID { id: buf.try_into().expect("invalid RequestId length") } } -pub fn request_id_to_bytes(value: &ScRequestId) -> &[u8] { - &value.id +pub fn request_id_to_bytes(value: &ScRequestID) -> Vec { + value.id.to_vec() } -pub fn request_id_to_string(value: &ScRequestId) -> String { +pub fn request_id_to_string(value: &ScRequestID) -> String { // TODO standardize human readable string base58_encode(&value.id) } -fn request_id_from_bytes_unchecked(buf: &[u8]) -> ScRequestId { - ScRequestId { id: buf.try_into().expect("invalid RequestId length") } +fn request_id_from_bytes_unchecked(buf: &[u8]) -> ScRequestID { + ScRequestID { id: buf.try_into().expect("invalid RequestId length") } } // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ @@ -74,8 +74,8 @@ impl ScImmutableRequestId<'_> { request_id_to_string(&self.value()) } - pub fn value(&self) -> ScRequestId { - request_id_from_bytes(self.proxy.get()) + pub fn value(&self) -> ScRequestID { + request_id_from_bytes(&self.proxy.get()) } } @@ -91,7 +91,7 @@ impl ScMutableRequestId<'_> { ScMutableRequestId { proxy } } - pub fn delete(&self) { + pub fn delete(&mut self) { self.proxy.delete(); } @@ -99,15 +99,15 @@ impl ScMutableRequestId<'_> { self.proxy.exists() } - pub fn set_value(&self, value: &ScRequestId) { - self.proxy.set(request_id_to_bytes(&value)); + pub fn set_value(&mut self, value: &ScRequestID) { + self.proxy.set(&request_id_to_bytes(&value)); } pub fn to_string(&self) -> String { request_id_to_string(&self.value()) } - pub fn value(&self) -> ScRequestId { - request_id_from_bytes(self.proxy.get()) + pub fn value(&self) -> ScRequestID { + request_id_from_bytes(&self.proxy.get()) } } diff --git a/packages/wasmvm/wasmlib/src/wasmtypes/scstring.rs b/packages/wasmvm/wasmlib/src/wasmtypes/scstring.rs index 7f4fb65fcb..9b9ca735ba 100644 --- a/packages/wasmvm/wasmlib/src/wasmtypes/scstring.rs +++ b/packages/wasmvm/wasmlib/src/wasmtypes/scstring.rs @@ -8,19 +8,19 @@ use crate::wasmtypes::*; // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ pub fn string_decode(dec: &mut WasmDecoder) -> String { - string_from_bytes(dec.bytes()) + string_from_bytes(&dec.bytes()) } pub fn string_encode(enc: &mut WasmEncoder, value: &str) { - enc.bytes(string_to_bytes(value)); + enc.bytes(&string_to_bytes(value)); } pub fn string_from_bytes(buf: &[u8]) -> String { String::from_utf8_lossy(buf).to_string() } -pub fn string_to_bytes(value: &str) -> &[u8] { - value.as_bytes() +pub fn string_to_bytes(value: &str) -> Vec { + value.to_vec() } pub fn string_to_string(value: &str) -> String { @@ -47,7 +47,7 @@ impl ScImmutableString<'_> { } pub fn value(&self) -> String { - string_from_bytes(self.proxy.get()) + string_from_bytes(&self.proxy.get()) } } @@ -63,7 +63,7 @@ impl ScMutableString<'_> { ScMutableString { proxy } } - pub fn delete(&self) { + pub fn delete(&mut self) { self.proxy.delete(); } @@ -71,8 +71,8 @@ impl ScMutableString<'_> { self.proxy.exists() } - pub fn set_value(&self, value: &str) { - self.proxy.set(string_to_bytes(value)); + pub fn set_value(&mut self, value: &str) { + self.proxy.set(&string_to_bytes(value)); } pub fn to_string(&self) -> String { @@ -80,6 +80,6 @@ impl ScMutableString<'_> { } pub fn value(&self) -> String { - string_from_bytes(self.proxy.get()) + string_from_bytes(&self.proxy.get()) } } diff --git a/packages/wasmvm/wasmlib/src/wasmtypes/scuint16.rs b/packages/wasmvm/wasmlib/src/wasmtypes/scuint16.rs index f1598524d1..1bc523210c 100644 --- a/packages/wasmvm/wasmlib/src/wasmtypes/scuint16.rs +++ b/packages/wasmvm/wasmlib/src/wasmtypes/scuint16.rs @@ -54,7 +54,7 @@ impl ScImmutableUint16<'_> { } pub fn value(&self) -> u16 { - uint16_from_bytes(self.proxy.get()) + uint16_from_bytes(&self.proxy.get()) } } @@ -70,7 +70,7 @@ impl ScMutableUint16<'_> { ScMutableUint16 { proxy } } - pub fn delete(&self) { + pub fn delete(&mut self) { self.proxy.delete(); } @@ -78,7 +78,7 @@ impl ScMutableUint16<'_> { self.proxy.exists() } - pub fn set_value(&self, value: u16) { + pub fn set_value(&mut self, value: u16) { self.proxy.set(&uint16_to_bytes(value)); } @@ -87,6 +87,6 @@ impl ScMutableUint16<'_> { } pub fn value(&self) -> u16 { - uint16_from_bytes(self.proxy.get()) + uint16_from_bytes(&self.proxy.get()) } } diff --git a/packages/wasmvm/wasmlib/src/wasmtypes/scuint32.rs b/packages/wasmvm/wasmlib/src/wasmtypes/scuint32.rs index f5d7e09cfa..90666b1815 100644 --- a/packages/wasmvm/wasmlib/src/wasmtypes/scuint32.rs +++ b/packages/wasmvm/wasmlib/src/wasmtypes/scuint32.rs @@ -23,7 +23,7 @@ pub fn uint32_from_bytes(buf: &[u8]) -> u32 { if buf.len() == 0 { return 0; } - u32::from_le_bytes(buf.try_into().expect("invalid u32 length")) + u32::from_le_bytes(buf.try_into().expect("invalid Uint32 length")) } pub fn uint32_to_bytes(value: u32) -> Vec { @@ -54,7 +54,7 @@ impl ScImmutableUint32<'_> { } pub fn value(&self) -> u32 { - uint32_from_bytes(self.proxy.get()) + uint32_from_bytes(&self.proxy.get()) } } @@ -70,7 +70,7 @@ impl ScMutableUint32<'_> { ScMutableUint32 { proxy } } - pub fn delete(&self) { + pub fn delete(&mut self) { self.proxy.delete(); } @@ -78,7 +78,7 @@ impl ScMutableUint32<'_> { self.proxy.exists() } - pub fn set_value(&self, value: u32) { + pub fn set_value(&mut self, value: u32) { self.proxy.set(&uint32_to_bytes(value)); } @@ -87,6 +87,6 @@ impl ScMutableUint32<'_> { } pub fn value(&self) -> u32 { - uint32_from_bytes(self.proxy.get()) + uint32_from_bytes(&self.proxy.get()) } } diff --git a/packages/wasmvm/wasmlib/src/wasmtypes/scuint64.rs b/packages/wasmvm/wasmlib/src/wasmtypes/scuint64.rs index 54560a045b..1bd90a134c 100644 --- a/packages/wasmvm/wasmlib/src/wasmtypes/scuint64.rs +++ b/packages/wasmvm/wasmlib/src/wasmtypes/scuint64.rs @@ -54,7 +54,7 @@ impl ScImmutableUint64<'_> { } pub fn value(&self) -> u64 { - uint64_from_bytes(self.proxy.get()) + uint64_from_bytes(&self.proxy.get()) } } @@ -70,7 +70,7 @@ impl ScMutableUint64<'_> { ScMutableUint64 { proxy } } - pub fn delete(&self) { + pub fn delete(&mut self) { self.proxy.delete(); } @@ -78,7 +78,7 @@ impl ScMutableUint64<'_> { self.proxy.exists() } - pub fn set_value(&self, value: u64) { + pub fn set_value(&mut self, value: u64) { self.proxy.set(&uint64_to_bytes(value)); } @@ -87,6 +87,6 @@ impl ScMutableUint64<'_> { } pub fn value(&self) -> u64 { - uint64_from_bytes(self.proxy.get()) + uint64_from_bytes(&self.proxy.get()) } } diff --git a/packages/wasmvm/wasmlib/src/wasmtypes/scuint8.rs b/packages/wasmvm/wasmlib/src/wasmtypes/scuint8.rs index 2ce97663ef..c2e55407e8 100644 --- a/packages/wasmvm/wasmlib/src/wasmtypes/scuint8.rs +++ b/packages/wasmvm/wasmlib/src/wasmtypes/scuint8.rs @@ -3,7 +3,7 @@ use std::convert::TryInto; -use crate::host::*; +use crate::sandbox::*; use crate::wasmtypes::*; // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ @@ -58,7 +58,7 @@ impl ScImmutableUint8<'_> { } pub fn value(&self) -> u8 { - uint8_from_bytes(self.proxy.get()) + uint8_from_bytes(&self.proxy.get()) } } @@ -74,7 +74,7 @@ impl ScMutableUint8<'_> { ScMutableUint8 { proxy } } - pub fn delete(&self) { + pub fn delete(&mut self) { self.proxy.delete(); } @@ -82,7 +82,7 @@ impl ScMutableUint8<'_> { self.proxy.exists() } - pub fn set_value(&self, value: u8) { + pub fn set_value(&mut self, value: u8) { self.proxy.set(&uint8_to_bytes(value)); } @@ -91,6 +91,6 @@ impl ScMutableUint8<'_> { } pub fn value(&self) -> u8 { - uint8_from_bytes(self.proxy.get()) + uint8_from_bytes(&self.proxy.get()) } } diff --git a/packages/wasmvm/wasmlib/ts/wasmlib/dict.ts b/packages/wasmvm/wasmlib/ts/wasmlib/dict.ts index 6759ce3e1b..c77a9dda6e 100644 --- a/packages/wasmvm/wasmlib/ts/wasmlib/dict.ts +++ b/packages/wasmvm/wasmlib/ts/wasmlib/dict.ts @@ -17,8 +17,8 @@ export function keya(key: u8[]): string { return stringFromBytes(key); } -export function vala(val: u8[] | null): string { - return val != null ? "[" + hex(val) + "]" : "null"; +export function vala(val: u8[]): string { + return hex(val); } export class ScDict implements wasmtypes.IKvStore { @@ -84,12 +84,12 @@ export class ScDict implements wasmtypes.IKvStore { return ret; } - get(key: u8[]): u8[] | null { + get(key: u8[]): u8[] { // this.dump("get") const mapKey = ScDict.toKey(key); if (!this.dict.has(mapKey)) { // log("dict.get(" + keya(key) + ") = null"); - return null; + return []; } const value = this.dict.get(mapKey); // log("dict.get(" + keya(key) + ") = " + vala(value)); @@ -118,9 +118,6 @@ export class ScDict implements wasmtypes.IKvStore { const k = keys[i]; const key = ScDict.fromKey(k); let val = this.dict.get(k); - if (val === null) { - val = []; - } enc.fixedBytes(wasmtypes.uint16ToBytes(key.length as u16), wasmtypes.ScUint16Length); enc.fixedBytes(key, key.length as u32); enc.fixedBytes(wasmtypes.uint32ToBytes(val.length as u32), wasmtypes.ScUint32Length); @@ -141,10 +138,10 @@ export class ScImmutableDict { return this.dict.has(ScDict.toKey(key)); } - get(key: u8[]): u8[] | null { + get(key: u8[]): u8[] { const mapKey = ScDict.toKey(key); if (!this.dict.has(mapKey)) { - return null; + return []; } return this.dict.get(mapKey); } diff --git a/packages/wasmvm/wasmlib/ts/wasmlib/exports.ts b/packages/wasmvm/wasmlib/ts/wasmlib/exports.ts index 9f81d44b9a..193ca47384 100644 --- a/packages/wasmvm/wasmlib/ts/wasmlib/exports.ts +++ b/packages/wasmvm/wasmlib/ts/wasmlib/exports.ts @@ -4,7 +4,7 @@ // Provide host with details about funcs and views in this smart contract import {ScFuncContext, ScViewContext} from "./context"; -import {exportName, exportWasmTag} from "./host"; +import {exportName} from "./host"; // Note that we do not use the Wasm export symbol table on purpose // because Wasm does not allow us to determine whether the symbols @@ -44,7 +44,7 @@ export function onCall(index: i32): void { export class ScExports { // constructs the symbol export context for the onLoad function constructor() { - exportWasmTag() + exportName(-1, "WASM::TYPESCRIPT"); } // defines the external name of a smart contract func diff --git a/packages/wasmvm/wasmlib/ts/wasmlib/host.ts b/packages/wasmvm/wasmlib/ts/wasmlib/host.ts index c7ce125126..c201d39d74 100644 --- a/packages/wasmvm/wasmlib/ts/wasmlib/host.ts +++ b/packages/wasmvm/wasmlib/ts/wasmlib/host.ts @@ -19,10 +19,6 @@ export function exportName(index: i32, name: string): void { hostStateSet(0, index, buf.dataStart, buf.length as i32); } -export function exportWasmTag(): void { - exportName(-1, "WASM::TYPESCRIPT"); -} - export function sandbox(funcNr: i32, params: u8[] | null): u8[] { if (params === null) { params = []; diff --git a/packages/wasmvm/wasmlib/ts/wasmlib/sandbox.ts b/packages/wasmvm/wasmlib/ts/wasmlib/sandbox.ts index 0a976dfa0e..b2e60699b9 100644 --- a/packages/wasmvm/wasmlib/ts/wasmlib/sandbox.ts +++ b/packages/wasmvm/wasmlib/ts/wasmlib/sandbox.ts @@ -48,37 +48,38 @@ export const FnUtilsHashName : i32 = -35; export const FnUtilsHashSha3 : i32 = -36; // @formatter:on -// Direct logging of informational text to host log +// Direct logging of text to host log export function log(text: string): void { - new ScSandbox().log(text); + sandbox(FnLog, wasmtypes.stringToBytes(text)); } // Direct logging of error to host log, followed by panicking out of the Wasm code export function panic(text: string): void { - new ScSandbox().panic(text); + sandbox(FnPanic, wasmtypes.stringToBytes(text)); } -export function paramsProxy(): wasmtypes.Proxy { - return new ScDict(sandbox(FnParams, null)).asProxy(); +// Direct conditional logging of debug-level informational text to host log +export function trace(text: string): void { + sandbox(FnTrace, wasmtypes.stringToBytes(text)); } -export function resultsProxy(): wasmtypes.Proxy { - return new ScDict([]).asProxy(); +export function paramsProxy(): wasmtypes.Proxy { + return new ScDict(sandbox(FnParams, null)).asProxy(); } export class ScSandbox { // retrieve the agent id of this contract account public accountID(): wasmtypes.ScAgentID { - return wasmtypes.agentIDFromBytes(sandbox(FnAccountID, null)) + return wasmtypes.agentIDFromBytes(sandbox(FnAccountID, null)); } public balance(color: wasmtypes.ScColor): u64 { - return wasmtypes.uint64FromBytes(sandbox(FnBalance, color.toBytes())) + return wasmtypes.uint64FromBytes(sandbox(FnBalance, color.toBytes())); } // access the current balances for all assets public balances(): ScBalances { - return new ScAssets(sandbox(FnBalances, null)).balances() + return new ScAssets(sandbox(FnBalances, null)).balances(); } // calls a smart contract function @@ -95,62 +96,58 @@ export class ScSandbox { req.params = params.toBytes(); req.transfer = transfer.toBytes(); const res = sandbox(FnCall, req.bytes()); - return new ScDict(res).immutable() + return new ScDict(res).immutable(); } // retrieve the chain id of the chain this contract lives on public chainID(): wasmtypes.ScChainID { - return wasmtypes.chainIDFromBytes(sandbox(FnChainID, null)) + return wasmtypes.chainIDFromBytes(sandbox(FnChainID, null)); } // retrieve the agent id of the owner of the chain this contract lives on public chainOwnerID(): wasmtypes.ScAgentID { - return wasmtypes.agentIDFromBytes(sandbox(FnChainOwnerID, null)) + return wasmtypes.agentIDFromBytes(sandbox(FnChainOwnerID, null)); } // retrieve the hname of this contract public contract(): wasmtypes.ScHname { - return wasmtypes.hnameFromBytes(sandbox(FnContract, null)) + return wasmtypes.hnameFromBytes(sandbox(FnContract, null)); } // retrieve the agent id of the creator of this contract public contractCreator(): wasmtypes.ScAgentID { - return wasmtypes.agentIDFromBytes(sandbox(FnContractCreator, null)) + return wasmtypes.agentIDFromBytes(sandbox(FnContractCreator, null)); } // logs informational text message public log(text: string): void { - sandbox(FnLog, wasmtypes.stringToBytes(text)) + sandbox(FnLog, wasmtypes.stringToBytes(text)); } // logs error text message and then panics public panic(text: string): void { - sandbox(FnPanic, wasmtypes.stringToBytes(text)) + sandbox(FnPanic, wasmtypes.stringToBytes(text)); } // retrieve parameters passed to the smart contract function that was called public params(): ScImmutableDict { - return new ScDict(sandbox(FnParams, null)).immutable() - } - - public rawState(): ScImmutableState { - return new ScImmutableState(); + return new ScDict(sandbox(FnParams, null)).immutable(); } // panics if condition is not satisfied public require(cond: bool, msg: string): void { if (!cond) { - this.panic(msg) + this.panic(msg); } } public results(results: ScDict): void { - sandbox(FnResults, results.toBytes()) + sandbox(FnResults, results.toBytes()); } // deterministic time stamp fixed at the moment of calling the smart contract public timestamp(): u64 { - return wasmtypes.uint64FromBytes(sandbox(FnTimestamp, null)) + return wasmtypes.uint64FromBytes(sandbox(FnTimestamp, null)); } // logs debugging trace text message @@ -167,7 +164,11 @@ export class ScSandbox { export class ScSandboxView extends ScSandbox { // calls a smart contract view public call(hContract: wasmtypes.ScHname, hFunction: wasmtypes.ScHname, params: ScDict | null): ScImmutableDict { - return this.callWithTransfer(hContract, hFunction, params, null) + return this.callWithTransfer(hContract, hFunction, params, null); + } + + public rawState(): ScImmutableState { + return new ScImmutableState(); } } @@ -181,12 +182,12 @@ export class ScSandboxFunc extends ScSandbox { // calls a smart contract function public call(hContract: wasmtypes.ScHname, hFunction: wasmtypes.ScHname, params: ScDict | null, transfer: ScTransfers | null): ScImmutableDict { - return this.callWithTransfer(hContract, hFunction, params, transfer) + return this.callWithTransfer(hContract, hFunction, params, transfer); } // retrieve the agent id of the caller of the smart contract public caller(): wasmtypes.ScAgentID { - return wasmtypes.agentIDFromBytes(sandbox(FnCaller, null)) + return wasmtypes.agentIDFromBytes(sandbox(FnCaller, null)); } // deploys a smart contract @@ -199,17 +200,17 @@ export class ScSandboxFunc extends ScSandbox { req.name = name; req.description = description; req.params = initParams.toBytes(); - sandbox(FnDeployContract, req.bytes()) + sandbox(FnDeployContract, req.bytes()); } // returns random entropy data for current request. public entropy(): wasmtypes.ScHash { - return wasmtypes.hashFromBytes(sandbox(FnEntropy, null)) + return wasmtypes.hashFromBytes(sandbox(FnEntropy, null)); } // signals an event on the node that external entities can subscribe to public event(msg: string): void { - sandbox(FnEvent, wasmtypes.stringToBytes(msg)) + sandbox(FnEvent, wasmtypes.stringToBytes(msg)); } // access the incoming balances for all assets @@ -220,7 +221,7 @@ export class ScSandboxFunc extends ScSandbox { // retrieve the assets that were minted in this transaction public minted(): ScBalances { - return new ScAssets(sandbox(FnMinted, null)).balances() + return new ScAssets(sandbox(FnMinted, null)).balances(); } // (delayed) posts a smart contract function request @@ -235,7 +236,7 @@ export class ScSandboxFunc extends ScSandbox { req.params = params.toBytes(); req.transfer = transfer.toBytes(); req.delay = delay; - sandbox(FnPost, req.bytes()) + sandbox(FnPost, req.bytes()); } // generates a random value from 0 to max (exclusive: max) using a deterministic RNG @@ -270,7 +271,7 @@ export class ScSandboxFunc extends ScSandbox { // retrieve the request id of this transaction public requestID(): wasmtypes.ScRequestID { - return wasmtypes.requestIDFromBytes(sandbox(FnRequestID, null)) + return wasmtypes.requestIDFromBytes(sandbox(FnRequestID, null)); } // transfer assetss to the specified Tangle ledger address @@ -284,13 +285,13 @@ export class ScSandboxFunc extends ScSandbox { } if (assets == 0) { // only try to send when non-zero assets - return + return; } const req = new wasmrequests.SendRequest(); req.address = address; req.transfer = transfer.toBytes(); - sandbox(FnSend, req.bytes()) + sandbox(FnSend, req.bytes()); } //public stateAnchor(): interface{} { diff --git a/packages/wasmvm/wasmlib/ts/wasmlib/state.ts b/packages/wasmvm/wasmlib/ts/wasmlib/state.ts index 35b21f2255..121619fa3b 100644 --- a/packages/wasmvm/wasmlib/ts/wasmlib/state.ts +++ b/packages/wasmvm/wasmlib/ts/wasmlib/state.ts @@ -10,8 +10,9 @@ export class ScImmutableState { return stateExists(key); } - get(key: u8[]): u8[] | null { - return stateGet(key); + get(key: u8[]): u8[] { + const val = stateGet(key); + return val === null ? [] : val; } } @@ -28,8 +29,9 @@ export class ScState implements IKvStore { return stateExists(key); } - get(key: u8[]): u8[] | null { - return stateGet(key); + get(key: u8[]): u8[] { + const val = stateGet(key); + return val === null ? [] : val; } public immutable(): ScImmutableState { diff --git a/packages/wasmvm/wasmlib/ts/wasmlib/wasmrequests/structs.ts b/packages/wasmvm/wasmlib/ts/wasmlib/wasmrequests/structs.ts index 9af2c268cd..f54abe9321 100644 --- a/packages/wasmvm/wasmlib/ts/wasmlib/wasmrequests/structs.ts +++ b/packages/wasmvm/wasmlib/ts/wasmlib/wasmrequests/structs.ts @@ -14,8 +14,8 @@ export class CallRequest { params : u8[] = []; transfer : u8[] = []; - static fromBytes(buf: u8[]|null): CallRequest { - const dec = new wasmtypes.WasmDecoder(buf==null ? [] : buf); + static fromBytes(buf: u8[]): CallRequest { + const dec = new wasmtypes.WasmDecoder(buf); const data = new CallRequest(); data.contract = wasmtypes.hnameDecode(dec); data.function = wasmtypes.hnameDecode(dec); @@ -71,8 +71,8 @@ export class DeployRequest { params : u8[] = []; progHash : wasmtypes.ScHash = new wasmtypes.ScHash(); - static fromBytes(buf: u8[]|null): DeployRequest { - const dec = new wasmtypes.WasmDecoder(buf==null ? [] : buf); + static fromBytes(buf: u8[]): DeployRequest { + const dec = new wasmtypes.WasmDecoder(buf); const data = new DeployRequest(); data.description = wasmtypes.stringDecode(dec); data.name = wasmtypes.stringDecode(dec); @@ -130,8 +130,8 @@ export class PostRequest { params : u8[] = []; transfer : u8[] = []; - static fromBytes(buf: u8[]|null): PostRequest { - const dec = new wasmtypes.WasmDecoder(buf==null ? [] : buf); + static fromBytes(buf: u8[]): PostRequest { + const dec = new wasmtypes.WasmDecoder(buf); const data = new PostRequest(); data.chainID = wasmtypes.chainIDDecode(dec); data.contract = wasmtypes.hnameDecode(dec); @@ -189,8 +189,8 @@ export class SendRequest { address : wasmtypes.ScAddress = new wasmtypes.ScAddress(); transfer : u8[] = []; - static fromBytes(buf: u8[]|null): SendRequest { - const dec = new wasmtypes.WasmDecoder(buf==null ? [] : buf); + static fromBytes(buf: u8[]): SendRequest { + const dec = new wasmtypes.WasmDecoder(buf); const data = new SendRequest(); data.address = wasmtypes.addressDecode(dec); data.transfer = wasmtypes.bytesDecode(dec); diff --git a/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/proxy.ts b/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/proxy.ts index 0413034cec..a74b9433b7 100644 --- a/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/proxy.ts +++ b/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/proxy.ts @@ -11,7 +11,7 @@ export interface IKvStore { exists(key: u8[]): bool; - get(key: u8[]): u8[] | null; + get(key: u8[]): u8[]; set(key: u8[], value: u8[]): void; } @@ -92,7 +92,7 @@ export class Proxy { this.set(enc.buf()); } - get(): u8[] | null { + get(): u8[] { const buf = this.kvStore.get(this._key); //log(this.id.toString() + ".get(" + keya(this._key) + ") = " + vala(buf)); return buf; @@ -121,7 +121,7 @@ export class Proxy { public length(): u32 { // get the length counter let buf = this.get(); - if (buf == null) { + if (buf.length == 0) { return 0; } const dec = new WasmDecoder(buf) diff --git a/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/scaddress.ts b/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/scaddress.ts index 2e19d3f3da..c17bc3e5c0 100644 --- a/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/scaddress.ts +++ b/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/scaddress.ts @@ -45,8 +45,8 @@ export function addressEncode(enc: WasmEncoder, value: ScAddress): void { enc.fixedBytes(value.toBytes(), ScAddressLength) } -export function addressFromBytes(buf: u8[] | null): ScAddress { - if (buf == null) { +export function addressFromBytes(buf: u8[]): ScAddress { + if (buf.length == 0) { return new ScAddress(); } if (buf.length != ScAddressLength) { diff --git a/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/scagentid.ts b/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/scagentid.ts index bc66ca69f9..7c0c9ff378 100644 --- a/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/scagentid.ts +++ b/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/scagentid.ts @@ -2,10 +2,10 @@ // SPDX-License-Identifier: Apache-2.0 import {panic} from "../sandbox"; -import {WasmDecoder, WasmEncoder, zeroes} from "./codec"; +import {WasmDecoder, WasmEncoder} from "./codec"; import {Proxy} from "./proxy"; -import {addressEncode, addressFromBytes, ScAddress, ScAddressLength} from "./scaddress"; -import {hnameEncode, hnameFromBytes, ScHname} from "./schname"; +import {addressDecode, addressEncode, addressFromBytes, ScAddress, ScAddressLength} from "./scaddress"; +import {hnameDecode, hnameEncode, hnameFromBytes, ScHname} from "./schname"; // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ @@ -51,7 +51,7 @@ export class ScAgentID { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ export function agentIDDecode(dec: WasmDecoder): ScAgentID { - return agentIDFromBytesUnchecked(dec.fixedBytes(ScAgentIDLength)); + return new ScAgentID(addressDecode(dec), hnameDecode(dec)) } export function agentIDEncode(enc: WasmEncoder, value: ScAgentID): void { @@ -59,9 +59,9 @@ export function agentIDEncode(enc: WasmEncoder, value: ScAgentID): void { hnameEncode(enc, value._hname); } -export function agentIDFromBytes(buf: u8[] | null): ScAgentID { - if (buf == null) { - return agentIDFromBytesUnchecked(zeroes(ScAgentIDLength)); +export function agentIDFromBytes(buf: u8[]): ScAgentID { + if (buf.length == 0) { + return new ScAgentID(addressFromBytes(buf), hnameFromBytes(buf)); } if (buf.length != ScAgentIDLength) { panic("invalid AgentID length"); @@ -70,7 +70,9 @@ export function agentIDFromBytes(buf: u8[] | null): ScAgentID { if (buf[0] > 2) { panic("invalid AgentID: address type > 2"); } - return agentIDFromBytesUnchecked(buf); + return new ScAgentID( + addressFromBytes(buf.slice(0, ScAddressLength)), + hnameFromBytes(buf.slice(ScAddressLength))); } export function agentIDToBytes(value: ScAgentID): u8[] { @@ -84,12 +86,6 @@ export function agentIDToString(value: ScAgentID): string { return value._address.toString() + "::" + value._hname.toString(); } -function agentIDFromBytesUnchecked(buf: u8[]): ScAgentID { - return new ScAgentID( - addressFromBytes(buf.slice(0, ScAddressLength)), - hnameFromBytes(buf.slice(ScAddressLength))); -} - // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ export class ScImmutableAgentID { diff --git a/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/scbool.ts b/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/scbool.ts index c26377cc77..bf0fd997a3 100644 --- a/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/scbool.ts +++ b/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/scbool.ts @@ -19,8 +19,8 @@ export function boolEncode(enc: WasmEncoder, value: bool): void { enc.byte((value ? ScBoolTrue : ScBoolFalse) as u8); } -export function boolFromBytes(buf: u8[] | null): bool { - if (buf == null) { +export function boolFromBytes(buf: u8[]): bool { + if (buf.length == 0) { return false; } if (buf.length != ScBoolLength) { diff --git a/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/scbytes.ts b/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/scbytes.ts index 4aa95a210f..0e22898dbb 100644 --- a/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/scbytes.ts +++ b/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/scbytes.ts @@ -24,8 +24,8 @@ export function bytesEncode(enc: WasmEncoder, value: u8[]): void { enc.bytes(value); } -export function bytesFromBytes(buf: u8[] | null): u8[] { - return buf == null ? [] : buf; +export function bytesFromBytes(buf: u8[]): u8[] { + return buf; } export function bytesToBytes(buf: u8[]): u8[] { diff --git a/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/scchainid.ts b/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/scchainid.ts index b3403ce774..683108d374 100644 --- a/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/scchainid.ts +++ b/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/scchainid.ts @@ -43,8 +43,8 @@ export function chainIDEncode(enc: WasmEncoder, value: ScChainID): void { enc.fixedBytes(value.toBytes(), ScChainIDLength); } -export function chainIDFromBytes(buf: u8[] | null): ScChainID { - if (buf == null) { +export function chainIDFromBytes(buf: u8[]): ScChainID { + if (buf.length == 0) { return new ScChainID(); } if (buf.length != ScChainIDLength) { diff --git a/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/sccolor.ts b/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/sccolor.ts index ce48018d6c..5cff8f301f 100644 --- a/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/sccolor.ts +++ b/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/sccolor.ts @@ -47,8 +47,8 @@ export function colorEncode(enc: WasmEncoder, value: ScColor): void { enc.fixedBytes(value.toBytes(), ScColorLength); } -export function colorFromBytes(buf: u8[] | null): ScColor { - if (buf == null) { +export function colorFromBytes(buf: u8[]): ScColor { + if (buf.length == 0) { return new ScColor(0); } if (buf.length != ScColorLength) { diff --git a/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/schash.ts b/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/schash.ts index bcea2ea230..baebece7f0 100644 --- a/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/schash.ts +++ b/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/schash.ts @@ -38,8 +38,8 @@ export function hashEncode(enc: WasmEncoder, value: ScHash): void { enc.fixedBytes(value.toBytes(), ScHashLength); } -export function hashFromBytes(buf: u8[] | null): ScHash { - if (buf == null) { +export function hashFromBytes(buf: u8[]): ScHash { + if (buf.length == 0) { return new ScHash(); } if (buf.length != ScHashLength) { diff --git a/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/schname.ts b/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/schname.ts index 08180bf4ef..4a570fff0a 100644 --- a/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/schname.ts +++ b/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/schname.ts @@ -43,8 +43,8 @@ export function hnameEncode(enc: WasmEncoder, value: ScHname): void { enc.fixedBytes(value.toBytes(), ScHnameLength); } -export function hnameFromBytes(buf: u8[] | null): ScHname { - if (buf == null) { +export function hnameFromBytes(buf: u8[]): ScHname { + if (buf.length == 0) { return new ScHname(0); } if (buf.length != ScHnameLength) { diff --git a/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/scint16.ts b/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/scint16.ts index c8b2ac60b6..3cd6044c2a 100644 --- a/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/scint16.ts +++ b/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/scint16.ts @@ -17,8 +17,8 @@ export function int16Encode(enc: WasmEncoder, value: i16): void { enc.vliEncode(value as i64); } -export function int16FromBytes(buf: u8[] | null): i16 { - if (buf == null) { +export function int16FromBytes(buf: u8[]): i16 { + if (buf.length == 0) { return 0; } if (buf.length != ScInt16Length) { diff --git a/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/scint32.ts b/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/scint32.ts index 4c53f41d99..b4b68c466a 100644 --- a/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/scint32.ts +++ b/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/scint32.ts @@ -17,8 +17,8 @@ export function int32Encode(enc: WasmEncoder, value: i32): void { enc.vliEncode(value as i64); } -export function int32FromBytes(buf: u8[] | null): i32 { - if (buf == null) { +export function int32FromBytes(buf: u8[]): i32 { + if (buf.length == 0) { return 0; } if (buf.length != ScInt32Length) { diff --git a/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/scint64.ts b/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/scint64.ts index 9bf5c50820..2d042af751 100644 --- a/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/scint64.ts +++ b/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/scint64.ts @@ -17,8 +17,8 @@ export function int64Encode(enc: WasmEncoder, value: i64): void { enc.vliEncode(value); } -export function int64FromBytes(buf: u8[] | null): i64 { - if (buf == null) { +export function int64FromBytes(buf: u8[]): i64 { + if (buf.length == 0) { return 0; } if (buf.length != ScInt64Length) { diff --git a/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/scint8.ts b/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/scint8.ts index e8ac27729f..46702803fe 100644 --- a/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/scint8.ts +++ b/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/scint8.ts @@ -17,8 +17,8 @@ export function int8Encode(enc: WasmEncoder, value: i8): void { enc.byte(value as u8); } -export function int8FromBytes(buf: u8[] | null): i8 { - if (buf == null) { +export function int8FromBytes(buf: u8[]): i8 { + if (buf.length == 0) { return 0; } if (buf.length != ScInt8Length) { diff --git a/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/screquestid.ts b/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/screquestid.ts index b59465f6eb..07c6b897a8 100644 --- a/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/screquestid.ts +++ b/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/screquestid.ts @@ -39,8 +39,8 @@ export function requestIDEncode(enc: WasmEncoder, value: ScRequestID): void { enc.fixedBytes(value.toBytes(), ScRequestIDLength); } -export function requestIDFromBytes(buf: u8[] | null): ScRequestID { - if (buf == null) { +export function requestIDFromBytes(buf: u8[]): ScRequestID { + if (buf.length == 0) { return new ScRequestID(); } if (buf.length != ScRequestIDLength) { diff --git a/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/scstring.ts b/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/scstring.ts index 8d66756758..f46e2eb8c7 100644 --- a/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/scstring.ts +++ b/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/scstring.ts @@ -14,8 +14,8 @@ export function stringEncode(enc: WasmEncoder, value: string): void { enc.bytes(stringToBytes(value)); } -export function stringFromBytes(buf: u8[] | null): string { - return buf == null ? "" : String.UTF8.decodeUnsafe(buf.dataStart, buf.length); +export function stringFromBytes(buf: u8[]): string { + return String.UTF8.decodeUnsafe(buf.dataStart, buf.length); } export function stringToBytes(value: string): u8[] { diff --git a/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/scuint16.ts b/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/scuint16.ts index 18fee10a33..79ea80bcd7 100644 --- a/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/scuint16.ts +++ b/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/scuint16.ts @@ -17,8 +17,8 @@ export function uint16Encode(enc: WasmEncoder, value: u16): void { enc.vluEncode(value as u64); } -export function uint16FromBytes(buf: u8[] | null): u16 { - if (buf == null) { +export function uint16FromBytes(buf: u8[]): u16 { + if (buf.length == 0) { return 0; } if (buf.length != ScUint16Length) { diff --git a/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/scuint32.ts b/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/scuint32.ts index 4c38d333bb..da0997d638 100644 --- a/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/scuint32.ts +++ b/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/scuint32.ts @@ -17,8 +17,8 @@ export function uint32Encode(enc: WasmEncoder, value: u32): void { enc.vluEncode(value as u64); } -export function uint32FromBytes(buf: u8[] | null): u32 { - if (buf == null) { +export function uint32FromBytes(buf: u8[]): u32 { + if (buf.length == 0) { return 0; } if (buf.length != ScUint32Length) { diff --git a/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/scuint64.ts b/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/scuint64.ts index a0e9fb14dc..95e0e6a483 100644 --- a/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/scuint64.ts +++ b/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/scuint64.ts @@ -17,8 +17,8 @@ export function uint64Encode(enc: WasmEncoder, value: u64): void { enc.vluEncode(value); } -export function uint64FromBytes(buf: u8[] | null): u64 { - if (buf == null) { +export function uint64FromBytes(buf: u8[]): u64 { + if (buf.length == 0) { return 0; } if (buf.length != ScUint64Length) { diff --git a/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/scuint8.ts b/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/scuint8.ts index 8df25ffc39..96ec663e77 100644 --- a/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/scuint8.ts +++ b/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/scuint8.ts @@ -17,8 +17,8 @@ export function uint8Encode(enc: WasmEncoder, value: u8): void { enc.byte(value); } -export function uint8FromBytes(buf: u8[] | null): u8 { - if (buf == null) { +export function uint8FromBytes(buf: u8[]): u8 { + if (buf.length == 0) { return 0; } if (buf.length != ScUint8Length) { diff --git a/packages/wasmvm/wasmsolo/solocontext.go b/packages/wasmvm/wasmsolo/solocontext.go index 728cc9c108..4fdcbd881e 100644 --- a/packages/wasmvm/wasmsolo/solocontext.go +++ b/packages/wasmvm/wasmsolo/solocontext.go @@ -30,7 +30,7 @@ const ( ) var ( // TODO set back to false - GoDebug = flag.Bool("godebug", true, "debug go smart contract code") + GoDebug = flag.Bool("godebug", false, "debug go smart contract code") GoWasm = flag.Bool("gowasm", false, "prefer go wasm smart contract code") GoWasmEdge = flag.Bool("gowasmedge", false, "use WasmEdge instead of WasmTime") TsWasm = flag.Bool("tswasm", false, "prefer typescript wasm smart contract code") diff --git a/tools/schema/generator/tstemplates/alltemplates.go b/tools/schema/generator/tstemplates/alltemplates.go index 958deb9128..d4826bf462 100644 --- a/tools/schema/generator/tstemplates/alltemplates.go +++ b/tools/schema/generator/tstemplates/alltemplates.go @@ -50,7 +50,7 @@ var TypeDependent = model.StringMapMap{ }, "fldTypeInit": { "Address": "new wasmtypes.ScAddress()", - "AgentID": "wasmtypes.agentIDFromBytes(null)", + "AgentID": "wasmtypes.agentIDFromBytes([])", "Bool": "false", "Bytes": "[]", "ChainID": "new wasmtypes.ScChainID()", diff --git a/tools/schema/generator/tstemplates/structs.go b/tools/schema/generator/tstemplates/structs.go index caea7991b2..3ff7cb126f 100644 --- a/tools/schema/generator/tstemplates/structs.go +++ b/tools/schema/generator/tstemplates/structs.go @@ -13,8 +13,8 @@ $#each structs structType export class $StrName { $#each struct structField - static fromBytes(buf: u8[]|null): $StrName { - const dec = new wasmtypes.WasmDecoder(buf==null ? [] : buf); + static fromBytes(buf: u8[]): $StrName { + const dec = new wasmtypes.WasmDecoder(buf); const data = new $StrName(); $#each struct structDecode dec.close(); From 0887e3b2251f53228c04ce65457266160c02474c Mon Sep 17 00:00:00 2001 From: Luke Thorne Date: Wed, 2 Feb 2022 15:06:22 -0500 Subject: [PATCH 057/111] changes required for the deployment --- .../wasm/fairroulette/frontend/Dockerfile | 2 +- .../fairroulette/frontend/package-lock.json | 6058 ++++++++++++++++- .../wasm/fairroulette/frontend/package.json | 3 +- .../wasm/fairroulette/frontend/waypoint.hcl | 3 +- go.mod | 2 +- go.sum | 10 - packages/wasp/constants.go | 2 +- tools/evm-server/wasp-evm.nomad.tpl | 3 +- tools/evm-server/waypoint.hcl | 1 - wasp.nomad.tpl | 9 +- waypoint.hcl | 3 +- 11 files changed, 5877 insertions(+), 219 deletions(-) diff --git a/contracts/wasm/fairroulette/frontend/Dockerfile b/contracts/wasm/fairroulette/frontend/Dockerfile index 5c6979f31f..d19e58571b 100644 --- a/contracts/wasm/fairroulette/frontend/Dockerfile +++ b/contracts/wasm/fairroulette/frontend/Dockerfile @@ -1,4 +1,4 @@ -FROM node:current-alpine as build +FROM node:lts-buster as build COPY package.json . COPY package-lock.json . diff --git a/contracts/wasm/fairroulette/frontend/package-lock.json b/contracts/wasm/fairroulette/frontend/package-lock.json index cccc8d9e98..b82daf39e7 100644 --- a/contracts/wasm/fairroulette/frontend/package-lock.json +++ b/contracts/wasm/fairroulette/frontend/package-lock.json @@ -1,14 +1,5783 @@ { "name": "svelte-app", "version": "1.0.0", - "lockfileVersion": 1, + "lockfileVersion": 2, "requires": true, + "packages": { + "": { + "name": "svelte-app", + "version": "1.0.0", + "dependencies": { + "@babel/eslint-parser": "^7.15.8", + "lottie-web": "^5.7.13", + "svelte-router-spa": "^6.0.2", + "tslib": "^2.3.1" + }, + "devDependencies": { + "@rollup/plugin-commonjs": "^17.0.0", + "@rollup/plugin-node-resolve": "^11.0.0", + "@rollup/plugin-replace": "^3.0.0", + "@rollup/plugin-typescript": "^8.2.5", + "@tsconfig/svelte": "^2.0.0", + "@types/gtag.js": "^0.0.7", + "@typescript-eslint/eslint-plugin": "^4.29.2", + "@typescript-eslint/parser": "^4.29.2", + "base64-js": "^1.5.1", + "blakejs": "^1.1.1", + "eslint": "^7.32.0", + "eslint-plugin-security": "^1.4.0", + "eslint-plugin-svelte3": "^3.2.0", + "ieee754": "^1.2.1", + "nanoevents": "^6.0.0", + "node-sass": "^6.0.1", + "prettier": "^2.3.2", + "random-number-csprng": "^1.0.2", + "rollup": "^2.3.4", + "rollup-plugin-css-only": "^3.1.0", + "rollup-plugin-livereload": "^2.0.0", + "rollup-plugin-node-builtins": "^2.1.2", + "rollup-plugin-node-globals": "^1.4.0", + "rollup-plugin-svelte": "^7.0.0", + "rollup-plugin-terser": "^7.0.0", + "rollup-plugin-typescript2": "^0.30.0", + "rollup-plugin-web-worker-loader": "^1.6.1", + "sirv-cli": "^1.0.0", + "svelte": "^3.0.0", + "svelte-check": "^2.0.0", + "svelte-preprocess": "^4.0.0", + "threads": "^1.6.5", + "tweetnacl": "^1.0.3", + "typescript": "^4.0.0", + "uuid": "^8.3.2" + } + }, + "node_modules/@babel/code-frame": { + "version": "7.12.11", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.12.11.tgz", + "integrity": "sha512-Zt1yodBx1UcyiePMSkWnU4hPqhwq7hGi2nFL1LeA3EUl+q2LQx16MISgJ0+z7dnmgvP9QtIleuETGOiOH1RcIw==", + "dependencies": { + "@babel/highlight": "^7.10.4" + } + }, + "node_modules/@babel/eslint-parser": { + "version": "7.15.8", + "resolved": "https://registry.npmjs.org/@babel/eslint-parser/-/eslint-parser-7.15.8.tgz", + "integrity": "sha512-fYP7QFngCvgxjUuw8O057SVH5jCXsbFFOoE77CFDcvzwBVgTOkMD/L4mIC5Ud1xf8chK/no2fRbSSn1wvNmKuQ==", + "dependencies": { + "eslint-scope": "^5.1.1", + "eslint-visitor-keys": "^2.1.0", + "semver": "^6.3.0" + }, + "engines": { + "node": "^10.13.0 || ^12.13.0 || >=14.0.0" + }, + "peerDependencies": { + "@babel/core": ">=7.11.0", + "eslint": ">=7.5.0" + } + }, + "node_modules/@babel/eslint-parser/node_modules/semver": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", + "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "bin": { + "semver": "bin/semver.js" + } + }, + "node_modules/@babel/helper-validator-identifier": { + "version": "7.15.7", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.15.7.tgz", + "integrity": "sha512-K4JvCtQqad9OY2+yTU8w+E82ywk/fe+ELNlt1G8z3bVGlZfn/hOcQQsUhGhW/N+tb3fxK800wLtKOE/aM0m72w==", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/highlight": { + "version": "7.14.5", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.14.5.tgz", + "integrity": "sha512-qf9u2WFWVV0MppaL877j2dBtQIDgmidgjGk5VIMw3OadXvYaXn66U1BFlH2t4+t3i+8PhedppRv+i40ABzd+gg==", + "dependencies": { + "@babel/helper-validator-identifier": "^7.14.5", + "chalk": "^2.0.0", + "js-tokens": "^4.0.0" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/highlight/node_modules/ansi-styles": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "dependencies": { + "color-convert": "^1.9.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/@babel/highlight/node_modules/chalk": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "dependencies": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/@babel/highlight/node_modules/color-convert": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", + "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", + "dependencies": { + "color-name": "1.1.3" + } + }, + "node_modules/@babel/highlight/node_modules/color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=" + }, + "node_modules/@babel/highlight/node_modules/escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", + "engines": { + "node": ">=0.8.0" + } + }, + "node_modules/@babel/highlight/node_modules/has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", + "engines": { + "node": ">=4" + } + }, + "node_modules/@babel/highlight/node_modules/supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "dependencies": { + "has-flag": "^3.0.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/@eslint/eslintrc": { + "version": "0.4.3", + "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-0.4.3.tgz", + "integrity": "sha512-J6KFFz5QCYUJq3pf0mjEcCJVERbzv71PUIDczuh9JkwGEzced6CO5ADLHB1rbf/+oPBtoPfMYNOpGDzCANlbXw==", + "dependencies": { + "ajv": "^6.12.4", + "debug": "^4.1.1", + "espree": "^7.3.0", + "globals": "^13.9.0", + "ignore": "^4.0.6", + "import-fresh": "^3.2.1", + "js-yaml": "^3.13.1", + "minimatch": "^3.0.4", + "strip-json-comments": "^3.1.1" + }, + "engines": { + "node": "^10.12.0 || >=12.0.0" + } + }, + "node_modules/@eslint/eslintrc/node_modules/ignore": { + "version": "4.0.6", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-4.0.6.tgz", + "integrity": "sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg==", + "engines": { + "node": ">= 4" + } + }, + "node_modules/@humanwhocodes/config-array": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.5.0.tgz", + "integrity": "sha512-FagtKFz74XrTl7y6HCzQpwDfXP0yhxe9lHLD1UZxjvZIcbyRz8zTFF/yYNfSfzU414eDwZ1SrO0Qvtyf+wFMQg==", + "dependencies": { + "@humanwhocodes/object-schema": "^1.2.0", + "debug": "^4.1.1", + "minimatch": "^3.0.4" + }, + "engines": { + "node": ">=10.10.0" + } + }, + "node_modules/@humanwhocodes/object-schema": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-1.2.0.tgz", + "integrity": "sha512-wdppn25U8z/2yiaT6YGquE6X8sSv7hNMWSXYSSU1jGv/yd6XqjXgTDJ8KP4NgjTXfJ3GbRjeeb8RTV7a/VpM+w==" + }, + "node_modules/@nodelib/fs.scandir": { + "version": "2.1.5", + "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", + "integrity": "sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==", + "dev": true, + "dependencies": { + "@nodelib/fs.stat": "2.0.5", + "run-parallel": "^1.1.9" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/@nodelib/fs.stat": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/@nodelib/fs.stat/-/fs.stat-2.0.5.tgz", + "integrity": "sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A==", + "dev": true, + "engines": { + "node": ">= 8" + } + }, + "node_modules/@nodelib/fs.walk": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/@nodelib/fs.walk/-/fs.walk-1.2.8.tgz", + "integrity": "sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==", + "dev": true, + "dependencies": { + "@nodelib/fs.scandir": "2.1.5", + "fastq": "^1.6.0" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/@polka/url": { + "version": "1.0.0-next.21", + "resolved": "https://registry.npmjs.org/@polka/url/-/url-1.0.0-next.21.tgz", + "integrity": "sha512-a5Sab1C4/icpTZVzZc5Ghpz88yQtGOyNqYXcZgOssB2uuAr+wF/MvN6bgtW32q7HHrvBki+BsZ0OuNv6EV3K9g==", + "dev": true + }, + "node_modules/@rollup/plugin-commonjs": { + "version": "17.1.0", + "resolved": "https://registry.npmjs.org/@rollup/plugin-commonjs/-/plugin-commonjs-17.1.0.tgz", + "integrity": "sha512-PoMdXCw0ZyvjpCMT5aV4nkL0QywxP29sODQsSGeDpr/oI49Qq9tRtAsb/LbYbDzFlOydVEqHmmZWFtXJEAX9ew==", + "dev": true, + "dependencies": { + "@rollup/pluginutils": "^3.1.0", + "commondir": "^1.0.1", + "estree-walker": "^2.0.1", + "glob": "^7.1.6", + "is-reference": "^1.2.1", + "magic-string": "^0.25.7", + "resolve": "^1.17.0" + }, + "engines": { + "node": ">= 8.0.0" + }, + "peerDependencies": { + "rollup": "^2.30.0" + } + }, + "node_modules/@rollup/plugin-node-resolve": { + "version": "11.2.1", + "resolved": "https://registry.npmjs.org/@rollup/plugin-node-resolve/-/plugin-node-resolve-11.2.1.tgz", + "integrity": "sha512-yc2n43jcqVyGE2sqV5/YCmocy9ArjVAP/BeXyTtADTBBX6V0e5UMqwO8CdQ0kzjb6zu5P1qMzsScCMRvE9OlVg==", + "dev": true, + "dependencies": { + "@rollup/pluginutils": "^3.1.0", + "@types/resolve": "1.17.1", + "builtin-modules": "^3.1.0", + "deepmerge": "^4.2.2", + "is-module": "^1.0.0", + "resolve": "^1.19.0" + }, + "engines": { + "node": ">= 10.0.0" + }, + "peerDependencies": { + "rollup": "^1.20.0||^2.0.0" + } + }, + "node_modules/@rollup/plugin-replace": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/@rollup/plugin-replace/-/plugin-replace-3.0.0.tgz", + "integrity": "sha512-3c7JCbMuYXM4PbPWT4+m/4Y6U60SgsnDT/cCyAyUKwFHg7pTSfsSQzIpETha3a3ig6OdOKzZz87D9ZXIK3qsDg==", + "dev": true, + "dependencies": { + "@rollup/pluginutils": "^3.1.0", + "magic-string": "^0.25.7" + }, + "peerDependencies": { + "rollup": "^1.20.0 || ^2.0.0" + } + }, + "node_modules/@rollup/plugin-typescript": { + "version": "8.3.0", + "resolved": "https://registry.npmjs.org/@rollup/plugin-typescript/-/plugin-typescript-8.3.0.tgz", + "integrity": "sha512-I5FpSvLbtAdwJ+naznv+B4sjXZUcIvLLceYpITAn7wAP8W0wqc5noLdGIp9HGVntNhRWXctwPYrSSFQxtl0FPA==", + "dev": true, + "dependencies": { + "@rollup/pluginutils": "^3.1.0", + "resolve": "^1.17.0" + }, + "engines": { + "node": ">=8.0.0" + }, + "peerDependencies": { + "rollup": "^2.14.0", + "tslib": "*", + "typescript": ">=3.7.0" + } + }, + "node_modules/@rollup/pluginutils": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-3.1.0.tgz", + "integrity": "sha512-GksZ6pr6TpIjHm8h9lSQ8pi8BE9VeubNT0OMJ3B5uZJ8pz73NPiqOtCog/x2/QzM1ENChPKxMDhiQuRHsqc+lg==", + "dev": true, + "dependencies": { + "@types/estree": "0.0.39", + "estree-walker": "^1.0.1", + "picomatch": "^2.2.2" + }, + "engines": { + "node": ">= 8.0.0" + }, + "peerDependencies": { + "rollup": "^1.20.0||^2.0.0" + } + }, + "node_modules/@rollup/pluginutils/node_modules/estree-walker": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-1.0.1.tgz", + "integrity": "sha512-1fMXF3YP4pZZVozF8j/ZLfvnR8NSIljt56UhbZ5PeeDmmGHpgpdwQt7ITlGvYaQukCvuBRMLEiKiYC+oeIg4cg==", + "dev": true + }, + "node_modules/@tsconfig/svelte": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/@tsconfig/svelte/-/svelte-2.0.1.tgz", + "integrity": "sha512-aqkICXbM1oX5FfgZd2qSSAGdyo/NRxjWCamxoyi3T8iVQnzGge19HhDYzZ6NrVOW7bhcWNSq9XexWFtMzbB24A==", + "dev": true + }, + "node_modules/@types/estree": { + "version": "0.0.39", + "resolved": "https://registry.npmjs.org/@types/estree/-/estree-0.0.39.tgz", + "integrity": "sha512-EYNwp3bU+98cpU4lAWYYL7Zz+2gryWH1qbdDTidVd6hkiR6weksdbMadyXKXNPEkQFhXM+hVO9ZygomHXp+AIw==", + "dev": true + }, + "node_modules/@types/gtag.js": { + "version": "0.0.7", + "resolved": "https://registry.npmjs.org/@types/gtag.js/-/gtag.js-0.0.7.tgz", + "integrity": "sha512-Kl5beBoB0OXw7WeFgHHpLEchvC7HyIu3v1AksNNTemAF6jmEmQGqhZQSHcG6BOU/Lq0xsByQNqLzicLPjVkxYQ==", + "dev": true + }, + "node_modules/@types/json-schema": { + "version": "7.0.9", + "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.9.tgz", + "integrity": "sha512-qcUXuemtEu+E5wZSJHNxUXeCZhAfXKQ41D+duX+VYPde7xyEVZci+/oXKJL13tnRs9lR2pr4fod59GT6/X1/yQ==", + "dev": true + }, + "node_modules/@types/minimist": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/@types/minimist/-/minimist-1.2.2.tgz", + "integrity": "sha512-jhuKLIRrhvCPLqwPcx6INqmKeiA5EWrsCOPhrlFSrbrmU4ZMPjj5Ul/oLCMDO98XRUIwVm78xICz4EPCektzeQ==", + "dev": true + }, + "node_modules/@types/node": { + "version": "16.11.6", + "resolved": "https://registry.npmjs.org/@types/node/-/node-16.11.6.tgz", + "integrity": "sha512-ua7PgUoeQFjmWPcoo9khiPum3Pd60k4/2ZGXt18sm2Slk0W0xZTqt5Y0Ny1NyBiN1EVQ/+FaF9NcY4Qe6rwk5w==", + "dev": true + }, + "node_modules/@types/normalize-package-data": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/@types/normalize-package-data/-/normalize-package-data-2.4.1.tgz", + "integrity": "sha512-Gj7cI7z+98M282Tqmp2K5EIsoouUEzbBJhQQzDE3jSIRk6r9gsz0oUokqIUR4u1R3dMHo0pDHM7sNOHyhulypw==", + "dev": true + }, + "node_modules/@types/pug": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/@types/pug/-/pug-2.0.5.tgz", + "integrity": "sha512-LOnASQoeNZMkzexRuyqcBBDZ6rS+rQxUMkmj5A0PkhhiSZivLIuz6Hxyr1mkGoEZEkk66faROmpMi4fFkrKsBA==", + "dev": true + }, + "node_modules/@types/resolve": { + "version": "1.17.1", + "resolved": "https://registry.npmjs.org/@types/resolve/-/resolve-1.17.1.tgz", + "integrity": "sha512-yy7HuzQhj0dhGpD8RLXSZWEkLsV9ibvxvi6EiJ3bkqLAO1RGo0WbkWQiwpRlSFymTJRz0d3k5LM3kkx8ArDbLw==", + "dev": true, + "dependencies": { + "@types/node": "*" + } + }, + "node_modules/@types/sass": { + "version": "1.16.1", + "resolved": "https://registry.npmjs.org/@types/sass/-/sass-1.16.1.tgz", + "integrity": "sha512-iZUcRrGuz/Tbg3loODpW7vrQJkUtpY2fFSf4ELqqkApcS2TkZ1msk7ie8iZPB86lDOP8QOTTmuvWjc5S0R9OjQ==", + "dev": true, + "dependencies": { + "@types/node": "*" + } + }, + "node_modules/@typescript-eslint/eslint-plugin": { + "version": "4.33.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-4.33.0.tgz", + "integrity": "sha512-aINiAxGVdOl1eJyVjaWn/YcVAq4Gi/Yo35qHGCnqbWVz61g39D0h23veY/MA0rFFGfxK7TySg2uwDeNv+JgVpg==", + "dev": true, + "dependencies": { + "@typescript-eslint/experimental-utils": "4.33.0", + "@typescript-eslint/scope-manager": "4.33.0", + "debug": "^4.3.1", + "functional-red-black-tree": "^1.0.1", + "ignore": "^5.1.8", + "regexpp": "^3.1.0", + "semver": "^7.3.5", + "tsutils": "^3.21.0" + }, + "engines": { + "node": "^10.12.0 || >=12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "@typescript-eslint/parser": "^4.0.0", + "eslint": "^5.0.0 || ^6.0.0 || ^7.0.0" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/@typescript-eslint/experimental-utils": { + "version": "4.33.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-4.33.0.tgz", + "integrity": "sha512-zeQjOoES5JFjTnAhI5QY7ZviczMzDptls15GFsI6jyUOq0kOf9+WonkhtlIhh0RgHRnqj5gdNxW5j1EvAyYg6Q==", + "dev": true, + "dependencies": { + "@types/json-schema": "^7.0.7", + "@typescript-eslint/scope-manager": "4.33.0", + "@typescript-eslint/types": "4.33.0", + "@typescript-eslint/typescript-estree": "4.33.0", + "eslint-scope": "^5.1.1", + "eslint-utils": "^3.0.0" + }, + "engines": { + "node": "^10.12.0 || >=12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "*" + } + }, + "node_modules/@typescript-eslint/parser": { + "version": "4.33.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-4.33.0.tgz", + "integrity": "sha512-ZohdsbXadjGBSK0/r+d87X0SBmKzOq4/S5nzK6SBgJspFo9/CUDJ7hjayuze+JK7CZQLDMroqytp7pOcFKTxZA==", + "dev": true, + "dependencies": { + "@typescript-eslint/scope-manager": "4.33.0", + "@typescript-eslint/types": "4.33.0", + "@typescript-eslint/typescript-estree": "4.33.0", + "debug": "^4.3.1" + }, + "engines": { + "node": "^10.12.0 || >=12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^5.0.0 || ^6.0.0 || ^7.0.0" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/@typescript-eslint/scope-manager": { + "version": "4.33.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-4.33.0.tgz", + "integrity": "sha512-5IfJHpgTsTZuONKbODctL4kKuQje/bzBRkwHE8UOZ4f89Zeddg+EGZs8PD8NcN4LdM3ygHWYB3ukPAYjvl/qbQ==", + "dev": true, + "dependencies": { + "@typescript-eslint/types": "4.33.0", + "@typescript-eslint/visitor-keys": "4.33.0" + }, + "engines": { + "node": "^8.10.0 || ^10.13.0 || >=11.10.1" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@typescript-eslint/types": { + "version": "4.33.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-4.33.0.tgz", + "integrity": "sha512-zKp7CjQzLQImXEpLt2BUw1tvOMPfNoTAfb8l51evhYbOEEzdWyQNmHWWGPR6hwKJDAi+1VXSBmnhL9kyVTTOuQ==", + "dev": true, + "engines": { + "node": "^8.10.0 || ^10.13.0 || >=11.10.1" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@typescript-eslint/typescript-estree": { + "version": "4.33.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-4.33.0.tgz", + "integrity": "sha512-rkWRY1MPFzjwnEVHsxGemDzqqddw2QbTJlICPD9p9I9LfsO8fdmfQPOX3uKfUaGRDFJbfrtm/sXhVXN4E+bzCA==", + "dev": true, + "dependencies": { + "@typescript-eslint/types": "4.33.0", + "@typescript-eslint/visitor-keys": "4.33.0", + "debug": "^4.3.1", + "globby": "^11.0.3", + "is-glob": "^4.0.1", + "semver": "^7.3.5", + "tsutils": "^3.21.0" + }, + "engines": { + "node": "^10.12.0 || >=12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/@typescript-eslint/visitor-keys": { + "version": "4.33.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-4.33.0.tgz", + "integrity": "sha512-uqi/2aSz9g2ftcHWf8uLPJA70rUv6yuMW5Bohw+bwcuzaxQIHaKFZCKGoGXIrc9vkTJ3+0txM73K0Hq3d5wgIg==", + "dev": true, + "dependencies": { + "@typescript-eslint/types": "4.33.0", + "eslint-visitor-keys": "^2.0.0" + }, + "engines": { + "node": "^8.10.0 || ^10.13.0 || >=11.10.1" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/abbrev": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz", + "integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==", + "dev": true + }, + "node_modules/abstract-leveldown": { + "version": "0.12.4", + "resolved": "https://registry.npmjs.org/abstract-leveldown/-/abstract-leveldown-0.12.4.tgz", + "integrity": "sha1-KeGOYy5g5OIh1YECR4UqY9ey5BA=", + "dev": true, + "dependencies": { + "xtend": "~3.0.0" + } + }, + "node_modules/abstract-leveldown/node_modules/xtend": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/xtend/-/xtend-3.0.0.tgz", + "integrity": "sha1-XM50B7r2Qsunvs2laBEcST9ZZlo=", + "dev": true, + "engines": { + "node": ">=0.4" + } + }, + "node_modules/acorn": { + "version": "7.4.1", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.4.1.tgz", + "integrity": "sha512-nQyp0o1/mNdbTO1PO6kHkwSrmgZ0MT/jCCpNiwbUjGoRN4dlBhqJtoQuCnEOKzgTVwg0ZWiCoQy6SxMebQVh8A==", + "bin": { + "acorn": "bin/acorn" + }, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/acorn-jsx": { + "version": "5.3.2", + "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.2.tgz", + "integrity": "sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==", + "peerDependencies": { + "acorn": "^6.0.0 || ^7.0.0 || ^8.0.0" + } + }, + "node_modules/ajv": { + "version": "6.12.6", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", + "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", + "dependencies": { + "fast-deep-equal": "^3.1.1", + "fast-json-stable-stringify": "^2.0.0", + "json-schema-traverse": "^0.4.1", + "uri-js": "^4.2.2" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/epoberezkin" + } + }, + "node_modules/amdefine": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/amdefine/-/amdefine-1.0.1.tgz", + "integrity": "sha1-SlKCrBZHKek2Gbz9OtFR+BfOkfU=", + "dev": true, + "engines": { + "node": ">=0.4.2" + } + }, + "node_modules/ansi-colors": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.1.tgz", + "integrity": "sha512-JoX0apGbHaUJBNl6yF+p6JAFYZ666/hhCGKN5t9QFjbJQKUU/g8MNbFDbvfrgKXvI1QpZplPOnwIo99lX/AAmA==", + "engines": { + "node": ">=6" + } + }, + "node_modules/ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "engines": { + "node": ">=8" + } + }, + "node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/anymatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.2.tgz", + "integrity": "sha512-P43ePfOAIupkguHUycrc4qJ9kz8ZiuOUijaETwX7THt0Y/GNK7v0aa8rY816xWjZ7rJdA5XdMcpVFTKMq+RvWg==", + "dev": true, + "dependencies": { + "normalize-path": "^3.0.0", + "picomatch": "^2.0.4" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/aproba": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/aproba/-/aproba-1.2.0.tgz", + "integrity": "sha512-Y9J6ZjXtoYh8RnXVCMOU/ttDmk1aBjunq9vO0ta5x85WDQiQfUF9sIPBITdbiiIVcBo03Hi3jMxigBtsddlXRw==", + "dev": true + }, + "node_modules/are-we-there-yet": { + "version": "1.1.7", + "resolved": "https://registry.npmjs.org/are-we-there-yet/-/are-we-there-yet-1.1.7.tgz", + "integrity": "sha512-nxwy40TuMiUGqMyRHgCSWZ9FM4VAoRP4xUYSTv5ImRog+h9yISPbVH7H8fASCIzYn9wlEv4zvFL7uKDMCFQm3g==", + "dev": true, + "dependencies": { + "delegates": "^1.0.0", + "readable-stream": "^2.0.6" + } + }, + "node_modules/argparse": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", + "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", + "dependencies": { + "sprintf-js": "~1.0.2" + } + }, + "node_modules/array-union": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/array-union/-/array-union-2.1.0.tgz", + "integrity": "sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/arrify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/arrify/-/arrify-1.0.1.tgz", + "integrity": "sha1-iYUI2iIm84DfkEcoRWhJwVAaSw0=", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/asn1": { + "version": "0.2.4", + "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.4.tgz", + "integrity": "sha512-jxwzQpLQjSmWXgwaCZE9Nz+glAG01yF1QnWgbhGwHI5A6FRIEY6IVqtHhIepHqI7/kyEyQEagBC5mBEFlIYvdg==", + "dev": true, + "dependencies": { + "safer-buffer": "~2.1.0" + } + }, + "node_modules/asn1.js": { + "version": "5.4.1", + "resolved": "https://registry.npmjs.org/asn1.js/-/asn1.js-5.4.1.tgz", + "integrity": "sha512-+I//4cYPccV8LdmBLiX8CYvf9Sp3vQsrqu2QNXRcrbiWvcx/UdlFiqUJJzxRQxgsZmvhXhn4cSKeSmoFjVdupA==", + "dev": true, + "dependencies": { + "bn.js": "^4.0.0", + "inherits": "^2.0.1", + "minimalistic-assert": "^1.0.0", + "safer-buffer": "^2.1.0" + } + }, + "node_modules/asn1.js/node_modules/bn.js": { + "version": "4.12.0", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.12.0.tgz", + "integrity": "sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA==", + "dev": true + }, + "node_modules/assert-plus": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", + "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=", + "dev": true, + "engines": { + "node": ">=0.8" + } + }, + "node_modules/astral-regex": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/astral-regex/-/astral-regex-2.0.0.tgz", + "integrity": "sha512-Z7tMw1ytTXt5jqMcOP+OQteU1VuNK9Y02uuJtKQ1Sv69jXQKKg5cibLwGJow8yzZP+eAc18EmLGPal0bp36rvQ==", + "engines": { + "node": ">=8" + } + }, + "node_modules/async-foreach": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/async-foreach/-/async-foreach-0.1.3.tgz", + "integrity": "sha1-NhIfhFwFeBct5Bmpfb6x0W7DRUI=", + "dev": true, + "engines": { + "node": "*" + } + }, + "node_modules/asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=", + "dev": true + }, + "node_modules/aws-sign2": { + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.7.0.tgz", + "integrity": "sha1-tG6JCTSpWR8tL2+G1+ap8bP+dqg=", + "dev": true, + "engines": { + "node": "*" + } + }, + "node_modules/aws4": { + "version": "1.11.0", + "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.11.0.tgz", + "integrity": "sha512-xh1Rl34h6Fi1DC2WWKfxUTVqRsNnr6LsKz2+hfwDxQJWmrx8+c7ylaqBMcHfl1U1r2dsifOvKX3LQuLNZ+XSvA==", + "dev": true + }, + "node_modules/balanced-match": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==" + }, + "node_modules/base64-js": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", + "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, + "node_modules/bcrypt-pbkdf": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz", + "integrity": "sha1-pDAdOJtqQ/m2f/PKEaP2Y342Dp4=", + "dev": true, + "dependencies": { + "tweetnacl": "^0.14.3" + } + }, + "node_modules/bcrypt-pbkdf/node_modules/tweetnacl": { + "version": "0.14.5", + "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz", + "integrity": "sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q=", + "dev": true + }, + "node_modules/binary-extensions": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz", + "integrity": "sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/bl": { + "version": "0.8.2", + "resolved": "https://registry.npmjs.org/bl/-/bl-0.8.2.tgz", + "integrity": "sha1-yba8oI0bwuoA/Ir7Txpf0eHGbk4=", + "dev": true, + "dependencies": { + "readable-stream": "~1.0.26" + } + }, + "node_modules/bl/node_modules/isarray": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", + "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", + "dev": true + }, + "node_modules/bl/node_modules/readable-stream": { + "version": "1.0.34", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz", + "integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=", + "dev": true, + "dependencies": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.1", + "isarray": "0.0.1", + "string_decoder": "~0.10.x" + } + }, + "node_modules/bl/node_modules/string_decoder": { + "version": "0.10.31", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", + "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=", + "dev": true + }, + "node_modules/blakejs": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/blakejs/-/blakejs-1.1.1.tgz", + "integrity": "sha512-bLG6PHOCZJKNshTjGRBvET0vTciwQE6zFKOKKXPDJfwFBd4Ac0yBfPZqcGvGJap50l7ktvlpFqc2jGVaUgbJgg==", + "dev": true + }, + "node_modules/bluebird": { + "version": "3.7.2", + "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.7.2.tgz", + "integrity": "sha512-XpNj6GDQzdfW+r2Wnn7xiSAd7TM3jzkxGXBGTtWKuSXv1xUV+azxAm8jdWZN06QTQk+2N2XB9jRDkvbmQmcRtg==", + "dev": true + }, + "node_modules/bn.js": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-5.2.0.tgz", + "integrity": "sha512-D7iWRBvnZE8ecXiLj/9wbxH7Tk79fAh8IHaTNq1RWRixsS02W+5qS+iE9yq6RYl0asXx5tw0bLhmT5pIfbSquw==", + "dev": true + }, + "node_modules/brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "node_modules/braces": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", + "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", + "dev": true, + "dependencies": { + "fill-range": "^7.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/brorand": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/brorand/-/brorand-1.1.0.tgz", + "integrity": "sha1-EsJe/kCkXjwyPrhnWgoM5XsiNx8=", + "dev": true + }, + "node_modules/browserify-aes": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/browserify-aes/-/browserify-aes-1.2.0.tgz", + "integrity": "sha512-+7CHXqGuspUn/Sl5aO7Ea0xWGAtETPXNSAjHo48JfLdPWcMng33Xe4znFvQweqc/uzk5zSOI3H52CYnjCfb5hA==", + "dev": true, + "dependencies": { + "buffer-xor": "^1.0.3", + "cipher-base": "^1.0.0", + "create-hash": "^1.1.0", + "evp_bytestokey": "^1.0.3", + "inherits": "^2.0.1", + "safe-buffer": "^5.0.1" + } + }, + "node_modules/browserify-cipher": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/browserify-cipher/-/browserify-cipher-1.0.1.tgz", + "integrity": "sha512-sPhkz0ARKbf4rRQt2hTpAHqn47X3llLkUGn+xEJzLjwY8LRs2p0v7ljvI5EyoRO/mexrNunNECisZs+gw2zz1w==", + "dev": true, + "dependencies": { + "browserify-aes": "^1.0.4", + "browserify-des": "^1.0.0", + "evp_bytestokey": "^1.0.0" + } + }, + "node_modules/browserify-des": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/browserify-des/-/browserify-des-1.0.2.tgz", + "integrity": "sha512-BioO1xf3hFwz4kc6iBhI3ieDFompMhrMlnDFC4/0/vd5MokpuAc3R+LYbwTA9A5Yc9pq9UYPqffKpW2ObuwX5A==", + "dev": true, + "dependencies": { + "cipher-base": "^1.0.1", + "des.js": "^1.0.0", + "inherits": "^2.0.1", + "safe-buffer": "^5.1.2" + } + }, + "node_modules/browserify-fs": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/browserify-fs/-/browserify-fs-1.0.0.tgz", + "integrity": "sha1-8HWqinKdTRcW0GZiDjhvzBMRqW8=", + "dev": true, + "dependencies": { + "level-filesystem": "^1.0.1", + "level-js": "^2.1.3", + "levelup": "^0.18.2" + } + }, + "node_modules/browserify-rsa": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/browserify-rsa/-/browserify-rsa-4.1.0.tgz", + "integrity": "sha512-AdEER0Hkspgno2aR97SAf6vi0y0k8NuOpGnVH3O99rcA5Q6sh8QxcngtHuJ6uXwnfAXNM4Gn1Gb7/MV1+Ymbog==", + "dev": true, + "dependencies": { + "bn.js": "^5.0.0", + "randombytes": "^2.0.1" + } + }, + "node_modules/browserify-sign": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/browserify-sign/-/browserify-sign-4.2.1.tgz", + "integrity": "sha512-/vrA5fguVAKKAVTNJjgSm1tRQDHUU6DbwO9IROu/0WAzC8PKhucDSh18J0RMvVeHAn5puMd+QHC2erPRNf8lmg==", + "dev": true, + "dependencies": { + "bn.js": "^5.1.1", + "browserify-rsa": "^4.0.1", + "create-hash": "^1.2.0", + "create-hmac": "^1.1.7", + "elliptic": "^6.5.3", + "inherits": "^2.0.4", + "parse-asn1": "^5.1.5", + "readable-stream": "^3.6.0", + "safe-buffer": "^5.2.0" + } + }, + "node_modules/browserify-sign/node_modules/readable-stream": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", + "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", + "dev": true, + "dependencies": { + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/browserify-sign/node_modules/safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, + "node_modules/buffer-crc32": { + "version": "0.2.13", + "resolved": "https://registry.npmjs.org/buffer-crc32/-/buffer-crc32-0.2.13.tgz", + "integrity": "sha1-DTM+PwDqxQqhRUq9MO+MKl2ackI=", + "dev": true, + "engines": { + "node": "*" + } + }, + "node_modules/buffer-es6": { + "version": "4.9.3", + "resolved": "https://registry.npmjs.org/buffer-es6/-/buffer-es6-4.9.3.tgz", + "integrity": "sha1-8mNHuC33b9N+GLy1KIxJcM/VxAQ=", + "dev": true + }, + "node_modules/buffer-from": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz", + "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==", + "dev": true + }, + "node_modules/buffer-xor": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/buffer-xor/-/buffer-xor-1.0.3.tgz", + "integrity": "sha1-JuYe0UIvtw3ULm42cp7VHYVf6Nk=", + "dev": true + }, + "node_modules/builtin-modules": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-3.2.0.tgz", + "integrity": "sha512-lGzLKcioL90C7wMczpkY0n/oART3MbBa8R9OFGE1rJxoVI86u4WAGfEk8Wjv10eKSyTHVGkSo3bvBylCEtk7LA==", + "dev": true, + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/callsites": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz", + "integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==", + "engines": { + "node": ">=6" + } + }, + "node_modules/camelcase": { + "version": "5.3.1", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz", + "integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/camelcase-keys": { + "version": "6.2.2", + "resolved": "https://registry.npmjs.org/camelcase-keys/-/camelcase-keys-6.2.2.tgz", + "integrity": "sha512-YrwaA0vEKazPBkn0ipTiMpSajYDSe+KjQfrjhcBMxJt/znbvlHd8Pw/Vamaz5EB4Wfhs3SUR3Z9mwRu/P3s3Yg==", + "dev": true, + "dependencies": { + "camelcase": "^5.3.1", + "map-obj": "^4.0.0", + "quick-lru": "^4.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/caseless": { + "version": "0.12.0", + "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz", + "integrity": "sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw=", + "dev": true + }, + "node_modules/chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "dependencies": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" + } + }, + "node_modules/chokidar": { + "version": "3.5.2", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.2.tgz", + "integrity": "sha512-ekGhOnNVPgT77r4K/U3GDhu+FQ2S8TnK/s2KbIGXi0SZWuwkZ2QNyfWdZW+TVfn84DpEP7rLeCt2UI6bJ8GwbQ==", + "dev": true, + "dependencies": { + "anymatch": "~3.1.2", + "braces": "~3.0.2", + "glob-parent": "~5.1.2", + "is-binary-path": "~2.1.0", + "is-glob": "~4.0.1", + "normalize-path": "~3.0.0", + "readdirp": "~3.6.0" + }, + "engines": { + "node": ">= 8.10.0" + }, + "optionalDependencies": { + "fsevents": "~2.3.2" + } + }, + "node_modules/chownr": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/chownr/-/chownr-2.0.0.tgz", + "integrity": "sha512-bIomtDF5KGpdogkLd9VspvFzk9KfpyyGlS8YFVZl7TGPBHL5snIOnxeshwVgPteQ9b4Eydl+pVbIyE1DcvCWgQ==", + "dev": true, + "engines": { + "node": ">=10" + } + }, + "node_modules/cipher-base": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/cipher-base/-/cipher-base-1.0.4.tgz", + "integrity": "sha512-Kkht5ye6ZGmwv40uUDZztayT2ThLQGfnj/T71N/XzeZeo3nf8foyW7zGTsPYkEya3m5f3cAypH+qe7YOrM1U2Q==", + "dev": true, + "dependencies": { + "inherits": "^2.0.1", + "safe-buffer": "^5.0.1" + } + }, + "node_modules/cliui": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-5.0.0.tgz", + "integrity": "sha512-PYeGSEmmHM6zvoef2w8TPzlrnNpXIjTipYK780YswmIP9vjxmd6Y2a3CB2Ks6/AU8NHjZugXvo8w3oWM2qnwXA==", + "dev": true, + "dependencies": { + "string-width": "^3.1.0", + "strip-ansi": "^5.2.0", + "wrap-ansi": "^5.1.0" + } + }, + "node_modules/cliui/node_modules/ansi-regex": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", + "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/cliui/node_modules/is-fullwidth-code-point": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", + "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", + "dev": true, + "engines": { + "node": ">=4" + } + }, + "node_modules/cliui/node_modules/string-width": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-3.1.0.tgz", + "integrity": "sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w==", + "dev": true, + "dependencies": { + "emoji-regex": "^7.0.1", + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^5.1.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/cliui/node_modules/strip-ansi": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", + "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", + "dev": true, + "dependencies": { + "ansi-regex": "^4.1.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/clone": { + "version": "0.1.19", + "resolved": "https://registry.npmjs.org/clone/-/clone-0.1.19.tgz", + "integrity": "sha1-YT+2hjmyaklKxTJT4Vsaa9iK2oU=", + "dev": true, + "engines": { + "node": "*" + } + }, + "node_modules/code-point-at": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz", + "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" + }, + "node_modules/combined-stream": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", + "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", + "dev": true, + "dependencies": { + "delayed-stream": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/commander": { + "version": "2.20.3", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", + "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", + "dev": true + }, + "node_modules/commondir": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/commondir/-/commondir-1.0.1.tgz", + "integrity": "sha1-3dgA2gxmEnOTzKWVDqloo6rxJTs=", + "dev": true + }, + "node_modules/concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" + }, + "node_modules/concat-stream": { + "version": "1.6.2", + "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.2.tgz", + "integrity": "sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==", + "dev": true, + "engines": [ + "node >= 0.8" + ], + "dependencies": { + "buffer-from": "^1.0.0", + "inherits": "^2.0.3", + "readable-stream": "^2.2.2", + "typedarray": "^0.0.6" + } + }, + "node_modules/console-clear": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/console-clear/-/console-clear-1.1.1.tgz", + "integrity": "sha512-pMD+MVR538ipqkG5JXeOEbKWS5um1H4LUUccUQG68qpeqBYbzYy79Gh55jkd2TtPdRfUaLWdv6LPP//5Zt0aPQ==", + "dev": true, + "engines": { + "node": ">=4" + } + }, + "node_modules/console-control-strings": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz", + "integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4=", + "dev": true + }, + "node_modules/core-util-is": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz", + "integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==", + "dev": true + }, + "node_modules/create-ecdh": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/create-ecdh/-/create-ecdh-4.0.4.tgz", + "integrity": "sha512-mf+TCx8wWc9VpuxfP2ht0iSISLZnt0JgWlrOKZiNqyUZWnjIaCIVNQArMHnCZKfEYRg6IM7A+NeJoN8gf/Ws0A==", + "dev": true, + "dependencies": { + "bn.js": "^4.1.0", + "elliptic": "^6.5.3" + } + }, + "node_modules/create-ecdh/node_modules/bn.js": { + "version": "4.12.0", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.12.0.tgz", + "integrity": "sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA==", + "dev": true + }, + "node_modules/create-error": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/create-error/-/create-error-0.3.1.tgz", + "integrity": "sha1-aYECRaYp5lRDK/BDdzYAA6U1GiM=", + "dev": true + }, + "node_modules/create-hash": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/create-hash/-/create-hash-1.2.0.tgz", + "integrity": "sha512-z00bCGNHDG8mHAkP7CtT1qVu+bFQUPjYq/4Iv3C3kWjTFV10zIjfSoeqXo9Asws8gwSHDGj/hl2u4OGIjapeCg==", + "dev": true, + "dependencies": { + "cipher-base": "^1.0.1", + "inherits": "^2.0.1", + "md5.js": "^1.3.4", + "ripemd160": "^2.0.1", + "sha.js": "^2.4.0" + } + }, + "node_modules/create-hmac": { + "version": "1.1.7", + "resolved": "https://registry.npmjs.org/create-hmac/-/create-hmac-1.1.7.tgz", + "integrity": "sha512-MJG9liiZ+ogc4TzUwuvbER1JRdgvUFSB5+VR/g5h82fGaIRWMWddtKBHi7/sVhfjQZ6SehlyhvQYrcYkaUIpLg==", + "dev": true, + "dependencies": { + "cipher-base": "^1.0.3", + "create-hash": "^1.1.0", + "inherits": "^2.0.1", + "ripemd160": "^2.0.0", + "safe-buffer": "^5.0.1", + "sha.js": "^2.4.8" + } + }, + "node_modules/cross-spawn": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", + "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", + "dependencies": { + "path-key": "^3.1.0", + "shebang-command": "^2.0.0", + "which": "^2.0.1" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/crypto-browserify": { + "version": "3.12.0", + "resolved": "https://registry.npmjs.org/crypto-browserify/-/crypto-browserify-3.12.0.tgz", + "integrity": "sha512-fz4spIh+znjO2VjL+IdhEpRJ3YN6sMzITSBijk6FK2UvTqruSQW+/cCZTSNsMiZNvUeq0CqurF+dAbyiGOY6Wg==", + "dev": true, + "dependencies": { + "browserify-cipher": "^1.0.0", + "browserify-sign": "^4.0.0", + "create-ecdh": "^4.0.0", + "create-hash": "^1.1.0", + "create-hmac": "^1.1.0", + "diffie-hellman": "^5.0.0", + "inherits": "^2.0.1", + "pbkdf2": "^3.0.3", + "public-encrypt": "^4.0.0", + "randombytes": "^2.0.0", + "randomfill": "^1.0.3" + }, + "engines": { + "node": "*" + } + }, + "node_modules/dashdash": { + "version": "1.14.1", + "resolved": "https://registry.npmjs.org/dashdash/-/dashdash-1.14.1.tgz", + "integrity": "sha1-hTz6D3y+L+1d4gMmuN1YEDX24vA=", + "dev": true, + "dependencies": { + "assert-plus": "^1.0.0" + }, + "engines": { + "node": ">=0.10" + } + }, + "node_modules/debug": { + "version": "4.3.2", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.2.tgz", + "integrity": "sha512-mOp8wKcvj7XxC78zLgw/ZA+6TSgkoE2C/ienthhRD298T7UNwAg9diBpLRxC0mOezLl4B0xV7M0cCO6P/O0Xhw==", + "dependencies": { + "ms": "2.1.2" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/decamelize": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz", + "integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/decamelize-keys": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/decamelize-keys/-/decamelize-keys-1.1.0.tgz", + "integrity": "sha1-0XGoeTMlKAfrPLYdwcFEXQeN8tk=", + "dev": true, + "dependencies": { + "decamelize": "^1.1.0", + "map-obj": "^1.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/decamelize-keys/node_modules/map-obj": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/map-obj/-/map-obj-1.0.1.tgz", + "integrity": "sha1-2TPOuSBdgr3PSIb2dCvcK03qFG0=", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/deep-is": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.4.tgz", + "integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==" + }, + "node_modules/deepmerge": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-4.2.2.tgz", + "integrity": "sha512-FJ3UgI4gIl+PHZm53knsuSFpE+nESMr7M4v9QcgB7S63Kj/6WqMiFQJpBBYz1Pt+66bZpP3Q7Lye0Oo9MPKEdg==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/deferred-leveldown": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/deferred-leveldown/-/deferred-leveldown-0.2.0.tgz", + "integrity": "sha1-LO8fER4cV4cNi7uK8mUOWHzS9bQ=", + "dev": true, + "dependencies": { + "abstract-leveldown": "~0.12.1" + } + }, + "node_modules/delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=", + "dev": true, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/delegates": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delegates/-/delegates-1.0.0.tgz", + "integrity": "sha1-hMbhWbgZBP3KWaDvRM2HDTElD5o=", + "dev": true + }, + "node_modules/des.js": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/des.js/-/des.js-1.0.1.tgz", + "integrity": "sha512-Q0I4pfFrv2VPd34/vfLrFOoRmlYj3OV50i7fskps1jZWK1kApMWWT9G6RRUeYedLcBDIhnSDaUvJMb3AhUlaEA==", + "dev": true, + "dependencies": { + "inherits": "^2.0.1", + "minimalistic-assert": "^1.0.0" + } + }, + "node_modules/detect-indent": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/detect-indent/-/detect-indent-6.1.0.tgz", + "integrity": "sha512-reYkTUJAZb9gUuZ2RvVCNhVHdg62RHnJ7WJl8ftMi4diZ6NWlciOzQN88pUhSELEwflJht4oQDv0F0BMlwaYtA==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/diffie-hellman": { + "version": "5.0.3", + "resolved": "https://registry.npmjs.org/diffie-hellman/-/diffie-hellman-5.0.3.tgz", + "integrity": "sha512-kqag/Nl+f3GwyK25fhUMYj81BUOrZ9IuJsjIcDE5icNM9FJHAVm3VcUDxdLPoQtTuUylWm6ZIknYJwwaPxsUzg==", + "dev": true, + "dependencies": { + "bn.js": "^4.1.0", + "miller-rabin": "^4.0.0", + "randombytes": "^2.0.0" + } + }, + "node_modules/diffie-hellman/node_modules/bn.js": { + "version": "4.12.0", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.12.0.tgz", + "integrity": "sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA==", + "dev": true + }, + "node_modules/dir-glob": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/dir-glob/-/dir-glob-3.0.1.tgz", + "integrity": "sha512-WkrWp9GR4KXfKGYzOLmTuGVi1UWFfws377n9cc55/tb6DuqyF6pcQ5AbiHEshaDpY9v6oaSr2XCDidGmMwdzIA==", + "dev": true, + "dependencies": { + "path-type": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/doctrine": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-3.0.0.tgz", + "integrity": "sha512-yS+Q5i3hBf7GBkd4KG8a7eBNNWNGLTaEwwYWUijIYM7zrlYDM0BFXHjjPWlWZ1Rg7UaddZeIDmi9jF3HmqiQ2w==", + "dependencies": { + "esutils": "^2.0.2" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/ecc-jsbn": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz", + "integrity": "sha1-OoOpBOVDUyh4dMVkt1SThoSamMk=", + "dev": true, + "dependencies": { + "jsbn": "~0.1.0", + "safer-buffer": "^2.1.0" + } + }, + "node_modules/elliptic": { + "version": "6.5.4", + "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.5.4.tgz", + "integrity": "sha512-iLhC6ULemrljPZb+QutR5TQGB+pdW6KGD5RSegS+8sorOZT+rdQFbsQFJgvN3eRqNALqJer4oQ16YvJHlU8hzQ==", + "dev": true, + "dependencies": { + "bn.js": "^4.11.9", + "brorand": "^1.1.0", + "hash.js": "^1.0.0", + "hmac-drbg": "^1.0.1", + "inherits": "^2.0.4", + "minimalistic-assert": "^1.0.1", + "minimalistic-crypto-utils": "^1.0.1" + } + }, + "node_modules/elliptic/node_modules/bn.js": { + "version": "4.12.0", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.12.0.tgz", + "integrity": "sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA==", + "dev": true + }, + "node_modules/emoji-regex": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-7.0.3.tgz", + "integrity": "sha512-CwBLREIQ7LvYFB0WyRvwhq5N5qPhc6PMjD6bYggFlI5YyDgl+0vxq5VHbMOFqLg7hfWzmu8T5Z1QofhmTIhItA==", + "dev": true + }, + "node_modules/enquirer": { + "version": "2.3.6", + "resolved": "https://registry.npmjs.org/enquirer/-/enquirer-2.3.6.tgz", + "integrity": "sha512-yjNnPr315/FjS4zIsUxYguYUPP2e1NK4d7E7ZOLiyYCcbFBiTMyID+2wvm2w6+pZ/odMA7cRkjhsPbltwBOrLg==", + "dependencies": { + "ansi-colors": "^4.1.1" + }, + "engines": { + "node": ">=8.6" + } + }, + "node_modules/env-paths": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/env-paths/-/env-paths-2.2.1.tgz", + "integrity": "sha512-+h1lkLKhZMTYjog1VEpJNG7NZJWcuc2DDk/qsqSTRRCOXiLjeQ1d1/udrUGhqMxUgAlwKNZ0cf2uqan5GLuS2A==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/errno": { + "version": "0.1.8", + "resolved": "https://registry.npmjs.org/errno/-/errno-0.1.8.tgz", + "integrity": "sha512-dJ6oBr5SQ1VSd9qkk7ByRgb/1SH4JZjCHSW/mr63/QcXO9zLVxvJ6Oy13nio03rxpSnVDDjFor75SjVeZWPW/A==", + "dev": true, + "dependencies": { + "prr": "~1.0.1" + }, + "bin": { + "errno": "cli.js" + } + }, + "node_modules/error-ex": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.2.tgz", + "integrity": "sha512-7dFHNmqeFSEt2ZBsCriorKnn3Z2pj+fd9kmI6QoWw4//DL+icEBfc0U7qJCisqrTsKTjw4fNFy2pW9OqStD84g==", + "dev": true, + "dependencies": { + "is-arrayish": "^0.2.1" + } + }, + "node_modules/es6-promise": { + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-3.3.1.tgz", + "integrity": "sha1-oIzd6EzNvzTQJ6FFG8kdS80ophM=", + "dev": true + }, + "node_modules/escape-string-regexp": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", + "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/eslint": { + "version": "7.32.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-7.32.0.tgz", + "integrity": "sha512-VHZ8gX+EDfz+97jGcgyGCyRia/dPOd6Xh9yPv8Bl1+SoaIwD+a/vlrOmGRUyOYu7MwUhc7CxqeaDZU13S4+EpA==", + "dependencies": { + "@babel/code-frame": "7.12.11", + "@eslint/eslintrc": "^0.4.3", + "@humanwhocodes/config-array": "^0.5.0", + "ajv": "^6.10.0", + "chalk": "^4.0.0", + "cross-spawn": "^7.0.2", + "debug": "^4.0.1", + "doctrine": "^3.0.0", + "enquirer": "^2.3.5", + "escape-string-regexp": "^4.0.0", + "eslint-scope": "^5.1.1", + "eslint-utils": "^2.1.0", + "eslint-visitor-keys": "^2.0.0", + "espree": "^7.3.1", + "esquery": "^1.4.0", + "esutils": "^2.0.2", + "fast-deep-equal": "^3.1.3", + "file-entry-cache": "^6.0.1", + "functional-red-black-tree": "^1.0.1", + "glob-parent": "^5.1.2", + "globals": "^13.6.0", + "ignore": "^4.0.6", + "import-fresh": "^3.0.0", + "imurmurhash": "^0.1.4", + "is-glob": "^4.0.0", + "js-yaml": "^3.13.1", + "json-stable-stringify-without-jsonify": "^1.0.1", + "levn": "^0.4.1", + "lodash.merge": "^4.6.2", + "minimatch": "^3.0.4", + "natural-compare": "^1.4.0", + "optionator": "^0.9.1", + "progress": "^2.0.0", + "regexpp": "^3.1.0", + "semver": "^7.2.1", + "strip-ansi": "^6.0.0", + "strip-json-comments": "^3.1.0", + "table": "^6.0.9", + "text-table": "^0.2.0", + "v8-compile-cache": "^2.0.3" + }, + "bin": { + "eslint": "bin/eslint.js" + }, + "engines": { + "node": "^10.12.0 || >=12.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/eslint-plugin-security": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-security/-/eslint-plugin-security-1.4.0.tgz", + "integrity": "sha512-xlS7P2PLMXeqfhyf3NpqbvbnW04kN8M9NtmhpR3XGyOvt/vNKS7XPXT5EDbwKW9vCjWH4PpfQvgD/+JgN0VJKA==", + "dev": true, + "dependencies": { + "safe-regex": "^1.1.0" + } + }, + "node_modules/eslint-plugin-svelte3": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/eslint-plugin-svelte3/-/eslint-plugin-svelte3-3.2.1.tgz", + "integrity": "sha512-YoBR9mLoKCjGghJ/gvpnFZKaMEu/VRcuxpSRS8KuozuEo7CdBH7bmBHa6FmMm0i4kJnOyx+PVsaptz96K6H/4Q==", + "dev": true, + "engines": { + "node": ">=10" + }, + "peerDependencies": { + "eslint": ">=6.0.0", + "svelte": "^3.2.0" + } + }, + "node_modules/eslint-scope": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.1.1.tgz", + "integrity": "sha512-2NxwbF/hZ0KpepYN0cNbo+FN6XoK7GaHlQhgx/hIZl6Va0bF45RQOOwhLIy8lQDbuCiadSLCBnH2CFYquit5bw==", + "dependencies": { + "esrecurse": "^4.3.0", + "estraverse": "^4.1.1" + }, + "engines": { + "node": ">=8.0.0" + } + }, + "node_modules/eslint-utils": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-3.0.0.tgz", + "integrity": "sha512-uuQC43IGctw68pJA1RgbQS8/NP7rch6Cwd4j3ZBtgo4/8Flj4eGE7ZYSZRN3iq5pVUv6GPdW5Z1RFleo84uLDA==", + "dev": true, + "dependencies": { + "eslint-visitor-keys": "^2.0.0" + }, + "engines": { + "node": "^10.0.0 || ^12.0.0 || >= 14.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/mysticatea" + }, + "peerDependencies": { + "eslint": ">=5" + } + }, + "node_modules/eslint-visitor-keys": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-2.1.0.tgz", + "integrity": "sha512-0rSmRBzXgDzIsD6mGdJgevzgezI534Cer5L/vyMX0kHzT/jiB43jRhd9YUlMGYLQy2zprNmoT8qasCGtY+QaKw==", + "engines": { + "node": ">=10" + } + }, + "node_modules/eslint/node_modules/eslint-utils": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-2.1.0.tgz", + "integrity": "sha512-w94dQYoauyvlDc43XnGB8lU3Zt713vNChgt4EWwhXAP2XkBvndfxF0AgIqKOOasjPIPzj9JqgwkwbCYD0/V3Zg==", + "dependencies": { + "eslint-visitor-keys": "^1.1.0" + }, + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/mysticatea" + } + }, + "node_modules/eslint/node_modules/eslint-utils/node_modules/eslint-visitor-keys": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-1.3.0.tgz", + "integrity": "sha512-6J72N8UNa462wa/KFODt/PJ3IU60SDpC3QXC1Hjc1BXXpfL2C9R5+AU7jhe0F6GREqVMh4Juu+NY7xn+6dipUQ==", + "engines": { + "node": ">=4" + } + }, + "node_modules/eslint/node_modules/ignore": { + "version": "4.0.6", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-4.0.6.tgz", + "integrity": "sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg==", + "engines": { + "node": ">= 4" + } + }, + "node_modules/esm": { + "version": "3.2.25", + "resolved": "https://registry.npmjs.org/esm/-/esm-3.2.25.tgz", + "integrity": "sha512-U1suiZ2oDVWv4zPO56S0NcR5QriEahGtdN2OR6FiOG4WJvcjBVFB0qI4+eKoWFH483PKGuLuu6V8Z4T5g63UVA==", + "dev": true, + "optional": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/espree": { + "version": "7.3.1", + "resolved": "https://registry.npmjs.org/espree/-/espree-7.3.1.tgz", + "integrity": "sha512-v3JCNCE64umkFpmkFGqzVKsOT0tN1Zr+ueqLZfpV1Ob8e+CEgPWa+OxCoGH3tnhimMKIaBm4m/vaRpJ/krRz2g==", + "dependencies": { + "acorn": "^7.4.0", + "acorn-jsx": "^5.3.1", + "eslint-visitor-keys": "^1.3.0" + }, + "engines": { + "node": "^10.12.0 || >=12.0.0" + } + }, + "node_modules/espree/node_modules/eslint-visitor-keys": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-1.3.0.tgz", + "integrity": "sha512-6J72N8UNa462wa/KFODt/PJ3IU60SDpC3QXC1Hjc1BXXpfL2C9R5+AU7jhe0F6GREqVMh4Juu+NY7xn+6dipUQ==", + "engines": { + "node": ">=4" + } + }, + "node_modules/esprima": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", + "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", + "bin": { + "esparse": "bin/esparse.js", + "esvalidate": "bin/esvalidate.js" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/esquery": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.4.0.tgz", + "integrity": "sha512-cCDispWt5vHHtwMY2YrAQ4ibFkAL8RbH5YGBnZBc90MolvvfkkQcJro/aZiAQUlQ3qgrYS6D6v8Gc5G5CQsc9w==", + "dependencies": { + "estraverse": "^5.1.0" + }, + "engines": { + "node": ">=0.10" + } + }, + "node_modules/esquery/node_modules/estraverse": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz", + "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==", + "engines": { + "node": ">=4.0" + } + }, + "node_modules/esrecurse": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.3.0.tgz", + "integrity": "sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag==", + "dependencies": { + "estraverse": "^5.2.0" + }, + "engines": { + "node": ">=4.0" + } + }, + "node_modules/esrecurse/node_modules/estraverse": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz", + "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==", + "engines": { + "node": ">=4.0" + } + }, + "node_modules/estraverse": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.3.0.tgz", + "integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==", + "engines": { + "node": ">=4.0" + } + }, + "node_modules/estree-walker": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-2.0.2.tgz", + "integrity": "sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==", + "dev": true + }, + "node_modules/esutils": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", + "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/evp_bytestokey": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/evp_bytestokey/-/evp_bytestokey-1.0.3.tgz", + "integrity": "sha512-/f2Go4TognH/KvCISP7OUsHn85hT9nUkxxA9BEWxFn+Oj9o8ZNLm/40hdlgSLyuOimsrTKLUMEorQexp/aPQeA==", + "dev": true, + "dependencies": { + "md5.js": "^1.3.4", + "safe-buffer": "^5.1.1" + } + }, + "node_modules/extend": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz", + "integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==", + "dev": true + }, + "node_modules/extsprintf": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/extsprintf/-/extsprintf-1.3.0.tgz", + "integrity": "sha1-lpGEQOMEGnpBT4xS48V06zw+HgU=", + "dev": true, + "engines": [ + "node >=0.6.0" + ] + }, + "node_modules/fast-deep-equal": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", + "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==" + }, + "node_modules/fast-glob": { + "version": "3.2.7", + "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.2.7.tgz", + "integrity": "sha512-rYGMRwip6lUMvYD3BTScMwT1HtAs2d71SMv66Vrxs0IekGZEjhM0pcMfjQPnknBt2zeCwQMEupiN02ZP4DiT1Q==", + "dev": true, + "dependencies": { + "@nodelib/fs.stat": "^2.0.2", + "@nodelib/fs.walk": "^1.2.3", + "glob-parent": "^5.1.2", + "merge2": "^1.3.0", + "micromatch": "^4.0.4" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/fast-json-stable-stringify": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", + "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==" + }, + "node_modules/fast-levenshtein": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", + "integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=" + }, + "node_modules/fastq": { + "version": "1.13.0", + "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.13.0.tgz", + "integrity": "sha512-YpkpUnK8od0o1hmeSc7UUs/eB/vIPWJYjKck2QKIzAf71Vm1AAQ3EbuZB3g2JIy+pg+ERD0vqI79KyZiB2e2Nw==", + "dev": true, + "dependencies": { + "reusify": "^1.0.4" + } + }, + "node_modules/file-entry-cache": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-6.0.1.tgz", + "integrity": "sha512-7Gps/XWymbLk2QLYK4NzpMOrYjMhdIxXuIvy2QBsLE6ljuodKvdkWs/cpyJJ3CVIVpH0Oi1Hvg1ovbMzLdFBBg==", + "dependencies": { + "flat-cache": "^3.0.4" + }, + "engines": { + "node": "^10.12.0 || >=12.0.0" + } + }, + "node_modules/fill-range": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", + "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", + "dev": true, + "dependencies": { + "to-regex-range": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/find-cache-dir": { + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/find-cache-dir/-/find-cache-dir-3.3.2.tgz", + "integrity": "sha512-wXZV5emFEjrridIgED11OoUKLxiYjAcqot/NJdAkOhlJ+vGzwhOAfcG5OX1jP+S0PcjEn8bdMJv+g2jwQ3Onig==", + "dev": true, + "dependencies": { + "commondir": "^1.0.1", + "make-dir": "^3.0.2", + "pkg-dir": "^4.1.0" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/avajs/find-cache-dir?sponsor=1" + } + }, + "node_modules/find-up": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz", + "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==", + "dev": true, + "dependencies": { + "locate-path": "^5.0.0", + "path-exists": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/flat-cache": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-3.0.4.tgz", + "integrity": "sha512-dm9s5Pw7Jc0GvMYbshN6zchCA9RgQlzzEZX3vylR9IqFfS8XciblUXOKfW6SiuJ0e13eDYZoZV5wdrev7P3Nwg==", + "dependencies": { + "flatted": "^3.1.0", + "rimraf": "^3.0.2" + }, + "engines": { + "node": "^10.12.0 || >=12.0.0" + } + }, + "node_modules/flatted": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/flatted/-/flatted-3.2.2.tgz", + "integrity": "sha512-JaTY/wtrcSyvXJl4IMFHPKyFur1sE9AUqc0QnhOaJ0CxHtAoIV8pYDzeEfAaNEtGkOfq4gr3LBFmdXW5mOQFnA==" + }, + "node_modules/foreach": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/foreach/-/foreach-2.0.5.tgz", + "integrity": "sha1-C+4AUBiusmDQo6865ljdATbsG5k=", + "dev": true + }, + "node_modules/forever-agent": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz", + "integrity": "sha1-+8cfDEGt6zf5bFd60e1C2P2sypE=", + "dev": true, + "engines": { + "node": "*" + } + }, + "node_modules/form-data": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.3.tgz", + "integrity": "sha512-1lLKB2Mu3aGP1Q/2eCOx0fNbRMe7XdwktwOruhfqqd0rIJWwN4Dh+E3hrPSlDCXnSR7UtZ1N38rVXm+6+MEhJQ==", + "dev": true, + "dependencies": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.6", + "mime-types": "^2.1.12" + }, + "engines": { + "node": ">= 0.12" + } + }, + "node_modules/fs-extra": { + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-8.1.0.tgz", + "integrity": "sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g==", + "dev": true, + "dependencies": { + "graceful-fs": "^4.2.0", + "jsonfile": "^4.0.0", + "universalify": "^0.1.0" + }, + "engines": { + "node": ">=6 <7 || >=8" + } + }, + "node_modules/fs-minipass": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/fs-minipass/-/fs-minipass-2.1.0.tgz", + "integrity": "sha512-V/JgOLFCS+R6Vcq0slCuaeWEdNC3ouDlJMNIsacH2VtALiu9mV4LPrHc5cDl8k5aw6J8jwgWWpiTo5RYhmIzvg==", + "dev": true, + "dependencies": { + "minipass": "^3.0.0" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" + }, + "node_modules/fsevents": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", + "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", + "dev": true, + "hasInstallScript": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, + "node_modules/function-bind": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", + "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==", + "dev": true + }, + "node_modules/functional-red-black-tree": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz", + "integrity": "sha1-GwqzvVU7Kg1jmdKcDj6gslIHgyc=" + }, + "node_modules/fwd-stream": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/fwd-stream/-/fwd-stream-1.0.4.tgz", + "integrity": "sha1-7Sgcq+1G/uz5Ie4y3ExQs3KsfPo=", + "dev": true, + "dependencies": { + "readable-stream": "~1.0.26-4" + } + }, + "node_modules/fwd-stream/node_modules/isarray": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", + "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", + "dev": true + }, + "node_modules/fwd-stream/node_modules/readable-stream": { + "version": "1.0.34", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz", + "integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=", + "dev": true, + "dependencies": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.1", + "isarray": "0.0.1", + "string_decoder": "~0.10.x" + } + }, + "node_modules/fwd-stream/node_modules/string_decoder": { + "version": "0.10.31", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", + "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=", + "dev": true + }, + "node_modules/gauge": { + "version": "2.7.4", + "resolved": "https://registry.npmjs.org/gauge/-/gauge-2.7.4.tgz", + "integrity": "sha1-LANAXHU4w51+s3sxcCLjJfsBi/c=", + "dev": true, + "dependencies": { + "aproba": "^1.0.3", + "console-control-strings": "^1.0.0", + "has-unicode": "^2.0.0", + "object-assign": "^4.1.0", + "signal-exit": "^3.0.0", + "string-width": "^1.0.1", + "strip-ansi": "^3.0.1", + "wide-align": "^1.1.0" + } + }, + "node_modules/gauge/node_modules/ansi-regex": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", + "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/gauge/node_modules/strip-ansi": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", + "dev": true, + "dependencies": { + "ansi-regex": "^2.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/gaze": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/gaze/-/gaze-1.1.3.tgz", + "integrity": "sha512-BRdNm8hbWzFzWHERTrejLqwHDfS4GibPoq5wjTPIoJHoBtKGPg3xAFfxmM+9ztbXelxcf2hwQcaz1PtmFeue8g==", + "dev": true, + "dependencies": { + "globule": "^1.0.0" + }, + "engines": { + "node": ">= 4.0.0" + } + }, + "node_modules/get-caller-file": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", + "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", + "dev": true, + "engines": { + "node": "6.* || 8.* || >= 10.*" + } + }, + "node_modules/get-port": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/get-port/-/get-port-3.2.0.tgz", + "integrity": "sha1-3Xzn3hh8Bsi/NTeWrHHgmfCYDrw=", + "dev": true, + "engines": { + "node": ">=4" + } + }, + "node_modules/get-stdin": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/get-stdin/-/get-stdin-4.0.1.tgz", + "integrity": "sha1-uWjGsKBDhDJJAui/Gl3zJXmkUP4=", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/getpass": { + "version": "0.1.7", + "resolved": "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz", + "integrity": "sha1-Xv+OPmhNVprkyysSgmBOi6YhSfo=", + "dev": true, + "dependencies": { + "assert-plus": "^1.0.0" + } + }, + "node_modules/glob": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.0.tgz", + "integrity": "sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q==", + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/glob-parent": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", + "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", + "dependencies": { + "is-glob": "^4.0.1" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/globals": { + "version": "13.12.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-13.12.0.tgz", + "integrity": "sha512-uS8X6lSKN2JumVoXrbUz+uG4BYG+eiawqm3qFcT7ammfbUHeCBoJMlHcec/S3krSk73/AE/f0szYFmgAA3kYZg==", + "dependencies": { + "type-fest": "^0.20.2" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/globby": { + "version": "11.0.4", + "resolved": "https://registry.npmjs.org/globby/-/globby-11.0.4.tgz", + "integrity": "sha512-9O4MVG9ioZJ08ffbcyVYyLOJLk5JQ688pJ4eMGLpdWLHq/Wr1D9BlriLQyL0E+jbkuePVZXYFj47QM/v093wHg==", + "dev": true, + "dependencies": { + "array-union": "^2.1.0", + "dir-glob": "^3.0.1", + "fast-glob": "^3.1.1", + "ignore": "^5.1.4", + "merge2": "^1.3.0", + "slash": "^3.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/globule": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/globule/-/globule-1.3.3.tgz", + "integrity": "sha512-mb1aYtDbIjTu4ShMB85m3UzjX9BVKe9WCzsnfMSZk+K5GpIbBOexgg4PPCt5eHDEG5/ZQAUX2Kct02zfiPLsKg==", + "dev": true, + "dependencies": { + "glob": "~7.1.1", + "lodash": "~4.17.10", + "minimatch": "~3.0.2" + }, + "engines": { + "node": ">= 0.10" + } + }, + "node_modules/globule/node_modules/glob": { + "version": "7.1.7", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.7.tgz", + "integrity": "sha512-OvD9ENzPLbegENnYP5UUfJIirTg4+XwMWGaQfQTY0JenxNvvIKP3U3/tAQSPIu/lHxXYSZmpXlUHeqAIdKzBLQ==", + "dev": true, + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/graceful-fs": { + "version": "4.2.8", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.8.tgz", + "integrity": "sha512-qkIilPUYcNhJpd33n0GBXTB1MMPp14TxEsEs0pTrsSVucApsYzW5V+Q8Qxhik6KU3evy+qkAAowTByymK0avdg==", + "dev": true + }, + "node_modules/har-schema": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/har-schema/-/har-schema-2.0.0.tgz", + "integrity": "sha1-qUwiJOvKwEeCoNkDVSHyRzW37JI=", + "dev": true, + "engines": { + "node": ">=4" + } + }, + "node_modules/har-validator": { + "version": "5.1.5", + "resolved": "https://registry.npmjs.org/har-validator/-/har-validator-5.1.5.tgz", + "integrity": "sha512-nmT2T0lljbxdQZfspsno9hgrG3Uir6Ks5afism62poxqBM6sDnMEuPmzTq8XN0OEwqKLLdh1jQI3qyE66Nzb3w==", + "deprecated": "this library is no longer supported", + "dev": true, + "dependencies": { + "ajv": "^6.12.3", + "har-schema": "^2.0.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/hard-rejection": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/hard-rejection/-/hard-rejection-2.1.0.tgz", + "integrity": "sha512-VIZB+ibDhx7ObhAe7OVtoEbuP4h/MuOTHJ+J8h/eBXotJYl0fBgR72xDFCKgIh22OJZIOVNxBMWuhAr10r8HdA==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/has": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", + "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==", + "dev": true, + "dependencies": { + "function-bind": "^1.1.1" + }, + "engines": { + "node": ">= 0.4.0" + } + }, + "node_modules/has-ansi": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz", + "integrity": "sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE=", + "dev": true, + "dependencies": { + "ansi-regex": "^2.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/has-ansi/node_modules/ansi-regex": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", + "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "engines": { + "node": ">=8" + } + }, + "node_modules/has-unicode": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/has-unicode/-/has-unicode-2.0.1.tgz", + "integrity": "sha1-4Ob+aijPUROIVeCG0Wkedx3iqLk=", + "dev": true + }, + "node_modules/hash-base": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/hash-base/-/hash-base-3.1.0.tgz", + "integrity": "sha512-1nmYp/rhMDiE7AYkDw+lLwlAzz0AntGIe51F3RfFfEqyQ3feY2eI/NcwC6umIQVOASPMsWJLJScWKSSvzL9IVA==", + "dev": true, + "dependencies": { + "inherits": "^2.0.4", + "readable-stream": "^3.6.0", + "safe-buffer": "^5.2.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/hash-base/node_modules/readable-stream": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", + "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", + "dev": true, + "dependencies": { + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/hash-base/node_modules/safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, + "node_modules/hash.js": { + "version": "1.1.7", + "resolved": "https://registry.npmjs.org/hash.js/-/hash.js-1.1.7.tgz", + "integrity": "sha512-taOaskGt4z4SOANNseOviYDvjEJinIkRgmp7LbKP2YTTmVxWBl87s/uzK9r+44BclBSp2X7K1hqeNfz9JbBeXA==", + "dev": true, + "dependencies": { + "inherits": "^2.0.3", + "minimalistic-assert": "^1.0.1" + } + }, + "node_modules/hmac-drbg": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/hmac-drbg/-/hmac-drbg-1.0.1.tgz", + "integrity": "sha1-0nRXAQJabHdabFRXk+1QL8DGSaE=", + "dev": true, + "dependencies": { + "hash.js": "^1.0.3", + "minimalistic-assert": "^1.0.0", + "minimalistic-crypto-utils": "^1.0.1" + } + }, + "node_modules/hosted-git-info": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-4.0.2.tgz", + "integrity": "sha512-c9OGXbZ3guC/xOlCg1Ci/VgWlwsqDv1yMQL1CWqXDL0hDjXuNcq0zuR4xqPSuasI3kqFDhqSyTjREz5gzq0fXg==", + "dev": true, + "dependencies": { + "lru-cache": "^6.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/http-signature": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.2.0.tgz", + "integrity": "sha1-muzZJRFHcvPZW2WmCruPfBj7rOE=", + "dev": true, + "dependencies": { + "assert-plus": "^1.0.0", + "jsprim": "^1.2.2", + "sshpk": "^1.7.0" + }, + "engines": { + "node": ">=0.8", + "npm": ">=1.3.7" + } + }, + "node_modules/idb-wrapper": { + "version": "1.7.2", + "resolved": "https://registry.npmjs.org/idb-wrapper/-/idb-wrapper-1.7.2.tgz", + "integrity": "sha512-zfNREywMuf0NzDo9mVsL0yegjsirJxHpKHvWcyRozIqQy89g0a3U+oBPOCN4cc0oCiOuYgZHimzaW/R46G1Mpg==", + "dev": true + }, + "node_modules/ieee754": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz", + "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, + "node_modules/ignore": { + "version": "5.1.8", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.1.8.tgz", + "integrity": "sha512-BMpfD7PpiETpBl/A6S498BaIJ6Y/ABT93ETbby2fP00v4EbvPBXWEoaR1UBPKs3iR53pJY7EtZk5KACI57i1Uw==", + "dev": true, + "engines": { + "node": ">= 4" + } + }, + "node_modules/import-fresh": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.0.tgz", + "integrity": "sha512-veYYhQa+D1QBKznvhUHxb8faxlrwUnxseDAbAp457E0wLNio2bOSKnjYDhMj+YiAq61xrMGhQk9iXVk5FzgQMw==", + "dependencies": { + "parent-module": "^1.0.0", + "resolve-from": "^4.0.0" + }, + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/imurmurhash": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", + "integrity": "sha1-khi5srkoojixPcT7a21XbyMUU+o=", + "engines": { + "node": ">=0.8.19" + } + }, + "node_modules/indent-string": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/indent-string/-/indent-string-4.0.0.tgz", + "integrity": "sha512-EdDDZu4A2OyIK7Lr/2zG+w5jmbuk1DVBnEwREQvBzspBJkCEbRa8GxU1lghYcaGJCnRWibjDXlq779X1/y5xwg==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/indexof": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/indexof/-/indexof-0.0.1.tgz", + "integrity": "sha1-gtwzbSMrkGIXnQWrMpOmYFn9Q10=", + "dev": true + }, + "node_modules/inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "dependencies": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "node_modules/inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" + }, + "node_modules/is": { + "version": "0.2.7", + "resolved": "https://registry.npmjs.org/is/-/is-0.2.7.tgz", + "integrity": "sha1-OzSixI81mXLzUEKEkZOucmS2NWI=", + "dev": true, + "engines": { + "node": "*" + } + }, + "node_modules/is-arrayish": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz", + "integrity": "sha1-d8mYQFJ6qOyxqLppe4BkWnqSap0=", + "dev": true + }, + "node_modules/is-binary-path": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", + "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", + "dev": true, + "dependencies": { + "binary-extensions": "^2.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/is-core-module": { + "version": "2.8.0", + "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.8.0.tgz", + "integrity": "sha512-vd15qHsaqrRL7dtH6QNuy0ndJmRDrS9HAM1CAiSifNUFv4x1a0CCVsj18hJ1mShxIG6T2i1sO78MkP56r0nYRw==", + "dev": true, + "dependencies": { + "has": "^1.0.3" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-extglob": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-fullwidth-code-point": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", + "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", + "dev": true, + "dependencies": { + "number-is-nan": "^1.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-glob": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", + "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", + "dependencies": { + "is-extglob": "^2.1.1" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-module": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-module/-/is-module-1.0.0.tgz", + "integrity": "sha1-Mlj7afeMFNW4FdZkM2tM/7ZEFZE=", + "dev": true + }, + "node_modules/is-number": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", + "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", + "dev": true, + "engines": { + "node": ">=0.12.0" + } + }, + "node_modules/is-object": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/is-object/-/is-object-0.1.2.tgz", + "integrity": "sha1-AO+8CIFsM8/ErIJR0TLhDcZQmNc=", + "dev": true + }, + "node_modules/is-observable": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-observable/-/is-observable-2.1.0.tgz", + "integrity": "sha512-DailKdLb0WU+xX8K5w7VsJhapwHLZ9jjmazqCJq4X12CTgqq73TKnbRcnSLuXYPOoLQgV5IrD7ePiX/h1vnkBw==", + "dev": true, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/is-plain-obj": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-1.1.0.tgz", + "integrity": "sha1-caUMhCnfync8kqOQpKA7OfzVHT4=", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-reference": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/is-reference/-/is-reference-1.2.1.tgz", + "integrity": "sha512-U82MsXXiFIrjCK4otLT+o2NA2Cd2g5MLoOVXUZjIOhLurrRxpEXzI8O0KZHr3IjLvlAH1kTPYSuqer5T9ZVBKQ==", + "dev": true, + "dependencies": { + "@types/estree": "*" + } + }, + "node_modules/is-typedarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", + "integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=", + "dev": true + }, + "node_modules/isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", + "dev": true + }, + "node_modules/isbuffer": { + "version": "0.0.0", + "resolved": "https://registry.npmjs.org/isbuffer/-/isbuffer-0.0.0.tgz", + "integrity": "sha1-OMFG2d9Si4v5sHAcPUPPEt8/w5s=", + "dev": true + }, + "node_modules/isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=" + }, + "node_modules/isstream": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz", + "integrity": "sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo=", + "dev": true + }, + "node_modules/jest-worker": { + "version": "26.6.2", + "resolved": "https://registry.npmjs.org/jest-worker/-/jest-worker-26.6.2.tgz", + "integrity": "sha512-KWYVV1c4i+jbMpaBC+U++4Va0cp8OisU185o73T1vo99hqi7w8tSJfUXYswwqqrjzwxa6KpRK54WhPvwf5w6PQ==", + "dev": true, + "dependencies": { + "@types/node": "*", + "merge-stream": "^2.0.0", + "supports-color": "^7.0.0" + }, + "engines": { + "node": ">= 10.13.0" + } + }, + "node_modules/js-base64": { + "version": "2.6.4", + "resolved": "https://registry.npmjs.org/js-base64/-/js-base64-2.6.4.tgz", + "integrity": "sha512-pZe//GGmwJndub7ZghVHz7vjb2LgC1m8B07Au3eYqeqv9emhESByMXxaEgkUkEqJe87oBbSniGYoQNIBklc7IQ==", + "dev": true + }, + "node_modules/js-tokens": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", + "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==" + }, + "node_modules/js-yaml": { + "version": "3.14.1", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz", + "integrity": "sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==", + "dependencies": { + "argparse": "^1.0.7", + "esprima": "^4.0.0" + }, + "bin": { + "js-yaml": "bin/js-yaml.js" + } + }, + "node_modules/jsbn": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz", + "integrity": "sha1-peZUwuWi3rXyAdls77yoDA7y9RM=", + "dev": true + }, + "node_modules/json-parse-even-better-errors": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/json-parse-even-better-errors/-/json-parse-even-better-errors-2.3.1.tgz", + "integrity": "sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w==", + "dev": true + }, + "node_modules/json-schema": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.4.0.tgz", + "integrity": "sha512-es94M3nTIfsEPisRafak+HDLfHXnKBhV3vU5eqPcS3flIWqcxJWgXHXiey3YrpaNsanY5ei1VoYEbOzijuq9BA==", + "dev": true + }, + "node_modules/json-schema-traverse": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", + "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==" + }, + "node_modules/json-stable-stringify-without-jsonify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz", + "integrity": "sha1-nbe1lJatPzz+8wp1FC0tkwrXJlE=" + }, + "node_modules/json-stringify-safe": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", + "integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=", + "dev": true + }, + "node_modules/jsonfile": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", + "integrity": "sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=", + "dev": true, + "optionalDependencies": { + "graceful-fs": "^4.1.6" + } + }, + "node_modules/jsprim": { + "version": "1.4.2", + "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.2.tgz", + "integrity": "sha512-P2bSOMAc/ciLz6DzgjVlGJP9+BrJWu5UDGK70C2iweC5QBIeFf0ZXRvGjEj2uYgrY2MkAAhsSWHDWlFtEroZWw==", + "dev": true, + "dependencies": { + "assert-plus": "1.0.0", + "extsprintf": "1.3.0", + "json-schema": "0.4.0", + "verror": "1.10.0" + }, + "engines": { + "node": ">=0.6.0" + } + }, + "node_modules/kind-of": { + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.3.tgz", + "integrity": "sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/kleur": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/kleur/-/kleur-3.0.3.tgz", + "integrity": "sha512-eTIzlVOSUR+JxdDFepEYcBMtZ9Qqdef+rnzWdRZuMbOywu5tO2w2N7rqjoANZ5k9vywhL6Br1VRjUIgTQx4E8w==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/level-blobs": { + "version": "0.1.7", + "resolved": "https://registry.npmjs.org/level-blobs/-/level-blobs-0.1.7.tgz", + "integrity": "sha1-mrm5e7mfHtv594o0M+Ie1WOGva8=", + "dev": true, + "dependencies": { + "level-peek": "1.0.6", + "once": "^1.3.0", + "readable-stream": "^1.0.26-4" + } + }, + "node_modules/level-blobs/node_modules/isarray": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", + "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", + "dev": true + }, + "node_modules/level-blobs/node_modules/readable-stream": { + "version": "1.1.14", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", + "integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=", + "dev": true, + "dependencies": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.1", + "isarray": "0.0.1", + "string_decoder": "~0.10.x" + } + }, + "node_modules/level-blobs/node_modules/string_decoder": { + "version": "0.10.31", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", + "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=", + "dev": true + }, + "node_modules/level-filesystem": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/level-filesystem/-/level-filesystem-1.2.0.tgz", + "integrity": "sha1-oArKmRnEpN+v3KaoEI0iWq3/Y7M=", + "dev": true, + "dependencies": { + "concat-stream": "^1.4.4", + "errno": "^0.1.1", + "fwd-stream": "^1.0.4", + "level-blobs": "^0.1.7", + "level-peek": "^1.0.6", + "level-sublevel": "^5.2.0", + "octal": "^1.0.0", + "once": "^1.3.0", + "xtend": "^2.2.0" + } + }, + "node_modules/level-fix-range": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/level-fix-range/-/level-fix-range-1.0.2.tgz", + "integrity": "sha1-vxW5Fa422EcMgh6IPd95zRZCCCg=", + "dev": true + }, + "node_modules/level-hooks": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/level-hooks/-/level-hooks-4.5.0.tgz", + "integrity": "sha1-G5rmGSKTDzMF0aYfxNg8gQLA3ZM=", + "dev": true, + "dependencies": { + "string-range": "~1.2" + } + }, + "node_modules/level-js": { + "version": "2.2.4", + "resolved": "https://registry.npmjs.org/level-js/-/level-js-2.2.4.tgz", + "integrity": "sha1-vAVfQYBjXUSJtWHJSG+jcOjBFpc=", + "dev": true, + "dependencies": { + "abstract-leveldown": "~0.12.0", + "idb-wrapper": "^1.5.0", + "isbuffer": "~0.0.0", + "ltgt": "^2.1.2", + "typedarray-to-buffer": "~1.0.0", + "xtend": "~2.1.2" + } + }, + "node_modules/level-js/node_modules/xtend": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/xtend/-/xtend-2.1.2.tgz", + "integrity": "sha1-bv7MKk2tjmlixJAbM3znuoe10os=", + "dev": true, + "dependencies": { + "object-keys": "~0.4.0" + }, + "engines": { + "node": ">=0.4" + } + }, + "node_modules/level-peek": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/level-peek/-/level-peek-1.0.6.tgz", + "integrity": "sha1-vsUccqgu5GTTNkNMfIdsP8vM538=", + "dev": true, + "dependencies": { + "level-fix-range": "~1.0.2" + } + }, + "node_modules/level-sublevel": { + "version": "5.2.3", + "resolved": "https://registry.npmjs.org/level-sublevel/-/level-sublevel-5.2.3.tgz", + "integrity": "sha1-dEwSxy0ucr543eO5tc2E1iGRQTo=", + "dev": true, + "dependencies": { + "level-fix-range": "2.0", + "level-hooks": ">=4.4.0 <5", + "string-range": "~1.2.1", + "xtend": "~2.0.4" + } + }, + "node_modules/level-sublevel/node_modules/level-fix-range": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/level-fix-range/-/level-fix-range-2.0.0.tgz", + "integrity": "sha1-xBfWIVlEIVGhnZojZ4aPFyTC1Ug=", + "dev": true, + "dependencies": { + "clone": "~0.1.9" + } + }, + "node_modules/level-sublevel/node_modules/object-keys": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-0.2.0.tgz", + "integrity": "sha1-zd7AKZiwkb5CvxA1rjLknxy26mc=", + "deprecated": "Please update to the latest object-keys", + "dev": true, + "dependencies": { + "foreach": "~2.0.1", + "indexof": "~0.0.1", + "is": "~0.2.6" + } + }, + "node_modules/level-sublevel/node_modules/xtend": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/xtend/-/xtend-2.0.6.tgz", + "integrity": "sha1-XqZXptukRwacLlnFihE4ywxebO4=", + "dev": true, + "dependencies": { + "is-object": "~0.1.2", + "object-keys": "~0.2.0" + }, + "engines": { + "node": ">=0.4" + } + }, + "node_modules/levelup": { + "version": "0.18.6", + "resolved": "https://registry.npmjs.org/levelup/-/levelup-0.18.6.tgz", + "integrity": "sha1-5qAcsIlhbI7MApHCqb0/DETj5es=", + "dev": true, + "dependencies": { + "bl": "~0.8.1", + "deferred-leveldown": "~0.2.0", + "errno": "~0.1.1", + "prr": "~0.0.0", + "readable-stream": "~1.0.26", + "semver": "~2.3.1", + "xtend": "~3.0.0" + } + }, + "node_modules/levelup/node_modules/isarray": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", + "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", + "dev": true + }, + "node_modules/levelup/node_modules/prr": { + "version": "0.0.0", + "resolved": "https://registry.npmjs.org/prr/-/prr-0.0.0.tgz", + "integrity": "sha1-GoS4WQgyVQFBGFPQCB7j+obikmo=", + "dev": true + }, + "node_modules/levelup/node_modules/readable-stream": { + "version": "1.0.34", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz", + "integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=", + "dev": true, + "dependencies": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.1", + "isarray": "0.0.1", + "string_decoder": "~0.10.x" + } + }, + "node_modules/levelup/node_modules/semver": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/semver/-/semver-2.3.2.tgz", + "integrity": "sha1-uYSPJdbPNjMwc+ye+IVtQvEjPlI=", + "dev": true, + "bin": { + "semver": "bin/semver" + } + }, + "node_modules/levelup/node_modules/string_decoder": { + "version": "0.10.31", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", + "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=", + "dev": true + }, + "node_modules/levelup/node_modules/xtend": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/xtend/-/xtend-3.0.0.tgz", + "integrity": "sha1-XM50B7r2Qsunvs2laBEcST9ZZlo=", + "dev": true, + "engines": { + "node": ">=0.4" + } + }, + "node_modules/levn": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/levn/-/levn-0.4.1.tgz", + "integrity": "sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==", + "dependencies": { + "prelude-ls": "^1.2.1", + "type-check": "~0.4.0" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/lines-and-columns": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/lines-and-columns/-/lines-and-columns-1.1.6.tgz", + "integrity": "sha1-HADHQ7QzzQpOgHWPe2SldEDZ/wA=", + "dev": true + }, + "node_modules/livereload": { + "version": "0.9.3", + "resolved": "https://registry.npmjs.org/livereload/-/livereload-0.9.3.tgz", + "integrity": "sha512-q7Z71n3i4X0R9xthAryBdNGVGAO2R5X+/xXpmKeuPMrteg+W2U8VusTKV3YiJbXZwKsOlFlHe+go6uSNjfxrZw==", + "dev": true, + "dependencies": { + "chokidar": "^3.5.0", + "livereload-js": "^3.3.1", + "opts": ">= 1.2.0", + "ws": "^7.4.3" + }, + "bin": { + "livereload": "bin/livereload.js" + }, + "engines": { + "node": ">=8.0.0" + } + }, + "node_modules/livereload-js": { + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/livereload-js/-/livereload-js-3.3.2.tgz", + "integrity": "sha512-w677WnINxFkuixAoUEXOStewzLYGI76XVag+0JWMMEyjJQKs0ibWZMxkTlB96Lm3EjZ7IeOxVziBEbtxVQqQZA==", + "dev": true + }, + "node_modules/local-access": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/local-access/-/local-access-1.1.0.tgz", + "integrity": "sha512-XfegD5pyTAfb+GY6chk283Ox5z8WexG56OvM06RWLpAc/UHozO8X6xAxEkIitZOtsSMM1Yr3DkHgW5W+onLhCw==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/locate-path": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", + "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==", + "dev": true, + "dependencies": { + "p-locate": "^4.1.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/lodash": { + "version": "4.17.21", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", + "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", + "dev": true + }, + "node_modules/lodash.clonedeep": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz", + "integrity": "sha1-4j8/nE+Pvd6HJSnBBxhXoIblzO8=" + }, + "node_modules/lodash.merge": { + "version": "4.6.2", + "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz", + "integrity": "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==" + }, + "node_modules/lodash.truncate": { + "version": "4.4.2", + "resolved": "https://registry.npmjs.org/lodash.truncate/-/lodash.truncate-4.4.2.tgz", + "integrity": "sha1-WjUNoLERO4N+z//VgSy+WNbq4ZM=" + }, + "node_modules/lottie-web": { + "version": "5.7.14", + "resolved": "https://registry.npmjs.org/lottie-web/-/lottie-web-5.7.14.tgz", + "integrity": "sha512-J+QEPse7Rws0XvTqRJNtcE8cszb5FWYFHubEK6bgDJtw64/AQJ40aazbWXsWGBM4sm/PgLBLgmmhDU4QpLiieg==" + }, + "node_modules/lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/ltgt": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/ltgt/-/ltgt-2.2.1.tgz", + "integrity": "sha1-81ypHEk/e3PaDgdJUwTxezH4fuU=", + "dev": true + }, + "node_modules/magic-string": { + "version": "0.25.7", + "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.25.7.tgz", + "integrity": "sha512-4CrMT5DOHTDk4HYDlzmwu4FVCcIYI8gauveasrdCu2IKIFOJ3f0v/8MDGJCDL9oD2ppz/Av1b0Nj345H9M+XIA==", + "dev": true, + "dependencies": { + "sourcemap-codec": "^1.4.4" + } + }, + "node_modules/make-dir": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-3.1.0.tgz", + "integrity": "sha512-g3FeP20LNwhALb/6Cz6Dd4F2ngze0jz7tbzrD2wAV+o9FeNHe4rL+yK2md0J/fiSf1sa1ADhXqi5+oVwOM/eGw==", + "dev": true, + "dependencies": { + "semver": "^6.0.0" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/make-dir/node_modules/semver": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", + "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "dev": true, + "bin": { + "semver": "bin/semver.js" + } + }, + "node_modules/map-obj": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/map-obj/-/map-obj-4.3.0.tgz", + "integrity": "sha512-hdN1wVrZbb29eBGiGjJbeP8JbKjq1urkHJ/LIP/NY48MZ1QVXUsQBV1G1zvYFHn1XE06cwjBsOI2K3Ulnj1YXQ==", + "dev": true, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/md5.js": { + "version": "1.3.5", + "resolved": "https://registry.npmjs.org/md5.js/-/md5.js-1.3.5.tgz", + "integrity": "sha512-xitP+WxNPcTTOgnTJcrhM0xvdPepipPSf3I8EIpGKeFLjt3PlJLIDG3u8EX53ZIubkb+5U2+3rELYpEhHhzdkg==", + "dev": true, + "dependencies": { + "hash-base": "^3.0.0", + "inherits": "^2.0.1", + "safe-buffer": "^5.1.2" + } + }, + "node_modules/meow": { + "version": "9.0.0", + "resolved": "https://registry.npmjs.org/meow/-/meow-9.0.0.tgz", + "integrity": "sha512-+obSblOQmRhcyBt62furQqRAQpNyWXo8BuQ5bN7dG8wmwQ+vwHKp/rCFD4CrTP8CsDQD1sjoZ94K417XEUk8IQ==", + "dev": true, + "dependencies": { + "@types/minimist": "^1.2.0", + "camelcase-keys": "^6.2.2", + "decamelize": "^1.2.0", + "decamelize-keys": "^1.1.0", + "hard-rejection": "^2.1.0", + "minimist-options": "4.1.0", + "normalize-package-data": "^3.0.0", + "read-pkg-up": "^7.0.1", + "redent": "^3.0.0", + "trim-newlines": "^3.0.0", + "type-fest": "^0.18.0", + "yargs-parser": "^20.2.3" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/meow/node_modules/type-fest": { + "version": "0.18.1", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.18.1.tgz", + "integrity": "sha512-OIAYXk8+ISY+qTOwkHtKqzAuxchoMiD9Udx+FSGQDuiRR+PJKJHc2NJAXlbhkGwTt/4/nKZxELY1w3ReWOL8mw==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/merge-stream": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz", + "integrity": "sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==", + "dev": true + }, + "node_modules/merge2": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz", + "integrity": "sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==", + "dev": true, + "engines": { + "node": ">= 8" + } + }, + "node_modules/micromatch": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.4.tgz", + "integrity": "sha512-pRmzw/XUcwXGpD9aI9q/0XOwLNygjETJ8y0ao0wdqprrzDa4YnxLcz7fQRZr8voh8V10kGhABbNcHVk5wHgWwg==", + "dev": true, + "dependencies": { + "braces": "^3.0.1", + "picomatch": "^2.2.3" + }, + "engines": { + "node": ">=8.6" + } + }, + "node_modules/miller-rabin": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/miller-rabin/-/miller-rabin-4.0.1.tgz", + "integrity": "sha512-115fLhvZVqWwHPbClyntxEVfVDfl9DLLTuJvq3g2O/Oxi8AiNouAHvDSzHS0viUJc+V5vm3eq91Xwqn9dp4jRA==", + "dev": true, + "dependencies": { + "bn.js": "^4.0.0", + "brorand": "^1.0.1" + }, + "bin": { + "miller-rabin": "bin/miller-rabin" + } + }, + "node_modules/miller-rabin/node_modules/bn.js": { + "version": "4.12.0", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.12.0.tgz", + "integrity": "sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA==", + "dev": true + }, + "node_modules/mime": { + "version": "2.5.2", + "resolved": "https://registry.npmjs.org/mime/-/mime-2.5.2.tgz", + "integrity": "sha512-tqkh47FzKeCPD2PUiPB6pkbMzsCasjxAfC62/Wap5qrUWcb+sFasXUC5I3gYM5iBM8v/Qpn4UK0x+j0iHyFPDg==", + "dev": true, + "bin": { + "mime": "cli.js" + }, + "engines": { + "node": ">=4.0.0" + } + }, + "node_modules/mime-db": { + "version": "1.50.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.50.0.tgz", + "integrity": "sha512-9tMZCDlYHqeERXEHO9f/hKfNXhre5dK2eE/krIvUjZbS2KPcqGDfNShIWS1uW9XOTKQKqK6qbeOci18rbfW77A==", + "dev": true, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime-types": { + "version": "2.1.33", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.33.tgz", + "integrity": "sha512-plLElXp7pRDd0bNZHw+nMd52vRYjLwQjygaNg7ddJ2uJtTlmnTCjWuPKxVu6//AdaRuME84SvLW91sIkBqGT0g==", + "dev": true, + "dependencies": { + "mime-db": "1.50.0" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/min-indent": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/min-indent/-/min-indent-1.0.1.tgz", + "integrity": "sha512-I9jwMn07Sy/IwOj3zVkVik2JTvgpaykDZEigL6Rx6N9LbMywwUSMtxET+7lVoDLLd3O3IXwJwvuuns8UB/HeAg==", + "dev": true, + "engines": { + "node": ">=4" + } + }, + "node_modules/minimalistic-assert": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz", + "integrity": "sha512-UtJcAD4yEaGtjPezWuO9wC4nwUnVH/8/Im3yEHQP4b67cXlD/Qr9hdITCU1xDbSEXg2XKNaP8jsReV7vQd00/A==", + "dev": true + }, + "node_modules/minimalistic-crypto-utils": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/minimalistic-crypto-utils/-/minimalistic-crypto-utils-1.0.1.tgz", + "integrity": "sha1-9sAMHAsIIkblxNmd+4x8CDsrWCo=", + "dev": true + }, + "node_modules/minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, + "node_modules/minimist": { + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", + "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==", + "dev": true + }, + "node_modules/minimist-options": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/minimist-options/-/minimist-options-4.1.0.tgz", + "integrity": "sha512-Q4r8ghd80yhO/0j1O3B2BjweX3fiHg9cdOwjJd2J76Q135c+NDxGCqdYKQ1SKBuFfgWbAUzBfvYjPUEeNgqN1A==", + "dev": true, + "dependencies": { + "arrify": "^1.0.1", + "is-plain-obj": "^1.1.0", + "kind-of": "^6.0.3" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/minipass": { + "version": "3.1.5", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-3.1.5.tgz", + "integrity": "sha512-+8NzxD82XQoNKNrl1d/FSi+X8wAEWR+sbYAfIvub4Nz0d22plFG72CEVVaufV8PNf4qSslFTD8VMOxNVhHCjTw==", + "dev": true, + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/minizlib": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/minizlib/-/minizlib-2.1.2.tgz", + "integrity": "sha512-bAxsR8BVfj60DWXHE3u30oHzfl4G7khkSuPW+qvpd7jFRHm7dLxOjUk1EHACJ/hxLY8phGJ0YhYHZo7jil7Qdg==", + "dev": true, + "dependencies": { + "minipass": "^3.0.0", + "yallist": "^4.0.0" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/mkdirp": { + "version": "0.5.5", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz", + "integrity": "sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==", + "dev": true, + "dependencies": { + "minimist": "^1.2.5" + }, + "bin": { + "mkdirp": "bin/cmd.js" + } + }, + "node_modules/mri": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/mri/-/mri-1.2.0.tgz", + "integrity": "sha512-tzzskb3bG8LvYGFF/mDTpq3jpI6Q9wc3LEmBaghu+DdCssd1FakN7Bc0hVNmEyGq1bq3RgfkCb3cmQLpNPOroA==", + "dev": true, + "engines": { + "node": ">=4" + } + }, + "node_modules/ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" + }, + "node_modules/nan": { + "version": "2.15.0", + "resolved": "https://registry.npmjs.org/nan/-/nan-2.15.0.tgz", + "integrity": "sha512-8ZtvEnA2c5aYCZYd1cvgdnU6cqwixRoYg70xPLWUws5ORTa/lnw+u4amixRS/Ac5U5mQVgp9pnlSUnbNWFaWZQ==", + "dev": true + }, + "node_modules/nanoevents": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/nanoevents/-/nanoevents-6.0.2.tgz", + "integrity": "sha512-FRS2otuFcPPYDPYViNWQ42+1iZqbXydinkRHTHFxrF4a1CpBfmydR9zkI44WSXAXCyPrkcGtPk5CnpW6Y3lFKQ==", + "dev": true, + "engines": { + "node": "^12.0.0 || ^14.0.0 || >=16.0.0" + } + }, + "node_modules/natural-compare": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", + "integrity": "sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=" + }, + "node_modules/node-gyp": { + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/node-gyp/-/node-gyp-7.1.2.tgz", + "integrity": "sha512-CbpcIo7C3eMu3dL1c3d0xw449fHIGALIJsRP4DDPHpyiW8vcriNY7ubh9TE4zEKfSxscY7PjeFnshE7h75ynjQ==", + "dev": true, + "dependencies": { + "env-paths": "^2.2.0", + "glob": "^7.1.4", + "graceful-fs": "^4.2.3", + "nopt": "^5.0.0", + "npmlog": "^4.1.2", + "request": "^2.88.2", + "rimraf": "^3.0.2", + "semver": "^7.3.2", + "tar": "^6.0.2", + "which": "^2.0.2" + }, + "bin": { + "node-gyp": "bin/node-gyp.js" + }, + "engines": { + "node": ">= 10.12.0" + } + }, + "node_modules/node-sass": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/node-sass/-/node-sass-6.0.1.tgz", + "integrity": "sha512-f+Rbqt92Ful9gX0cGtdYwjTrWAaGURgaK5rZCWOgCNyGWusFYHhbqCCBoFBeat+HKETOU02AyTxNhJV0YZf2jQ==", + "dev": true, + "hasInstallScript": true, + "dependencies": { + "async-foreach": "^0.1.3", + "chalk": "^1.1.1", + "cross-spawn": "^7.0.3", + "gaze": "^1.0.0", + "get-stdin": "^4.0.1", + "glob": "^7.0.3", + "lodash": "^4.17.15", + "meow": "^9.0.0", + "nan": "^2.13.2", + "node-gyp": "^7.1.0", + "npmlog": "^4.0.0", + "request": "^2.88.0", + "sass-graph": "2.2.5", + "stdout-stream": "^1.4.0", + "true-case-path": "^1.0.2" + }, + "bin": { + "node-sass": "bin/node-sass" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/node-sass/node_modules/ansi-regex": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", + "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/node-sass/node_modules/ansi-styles": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", + "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/node-sass/node_modules/chalk": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", + "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", + "dev": true, + "dependencies": { + "ansi-styles": "^2.2.1", + "escape-string-regexp": "^1.0.2", + "has-ansi": "^2.0.0", + "strip-ansi": "^3.0.0", + "supports-color": "^2.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/node-sass/node_modules/escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", + "dev": true, + "engines": { + "node": ">=0.8.0" + } + }, + "node_modules/node-sass/node_modules/strip-ansi": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", + "dev": true, + "dependencies": { + "ansi-regex": "^2.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/node-sass/node_modules/supports-color": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", + "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=", + "dev": true, + "engines": { + "node": ">=0.8.0" + } + }, + "node_modules/nopt": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/nopt/-/nopt-5.0.0.tgz", + "integrity": "sha512-Tbj67rffqceeLpcRXrT7vKAN8CwfPeIBgM7E6iBkmKLV7bEMwpGgYLGv0jACUsECaa/vuxP0IjEont6umdMgtQ==", + "dev": true, + "dependencies": { + "abbrev": "1" + }, + "bin": { + "nopt": "bin/nopt.js" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/normalize-package-data": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-3.0.3.tgz", + "integrity": "sha512-p2W1sgqij3zMMyRC067Dg16bfzVH+w7hyegmpIvZ4JNjqtGOVAIvLmjBx3yP7YTe9vKJgkoNOPjwQGogDoMXFA==", + "dev": true, + "dependencies": { + "hosted-git-info": "^4.0.1", + "is-core-module": "^2.5.0", + "semver": "^7.3.4", + "validate-npm-package-license": "^3.0.1" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/normalize-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", + "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/npmlog": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/npmlog/-/npmlog-4.1.2.tgz", + "integrity": "sha512-2uUqazuKlTaSI/dC8AzicUck7+IrEaOnN/e0jd3Xtt1KcGpwx30v50mL7oPyr/h9bL3E4aZccVwpwP+5W9Vjkg==", + "dev": true, + "dependencies": { + "are-we-there-yet": "~1.1.2", + "console-control-strings": "~1.1.0", + "gauge": "~2.7.3", + "set-blocking": "~2.0.0" + } + }, + "node_modules/number-is-nan": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz", + "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/oauth-sign": { + "version": "0.9.0", + "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.9.0.tgz", + "integrity": "sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ==", + "dev": true, + "engines": { + "node": "*" + } + }, + "node_modules/object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/object-keys": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-0.4.0.tgz", + "integrity": "sha1-KKaq50KN0sOpLz2V8hM13SBOAzY=", + "dev": true + }, + "node_modules/observable-fns": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/observable-fns/-/observable-fns-0.6.1.tgz", + "integrity": "sha512-9gRK4+sRWzeN6AOewNBTLXir7Zl/i3GB6Yl26gK4flxz8BXVpD3kt8amREmWNb0mxYOGDotvE5a4N+PtGGKdkg==", + "dev": true + }, + "node_modules/octal": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/octal/-/octal-1.0.0.tgz", + "integrity": "sha1-Y+cWKmjvvrniE1iNWOmJ0eXEUws=", + "dev": true + }, + "node_modules/once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "dependencies": { + "wrappy": "1" + } + }, + "node_modules/optionator": { + "version": "0.9.1", + "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.1.tgz", + "integrity": "sha512-74RlY5FCnhq4jRxVUPKDaRwrVNXMqsGsiW6AJw4XK8hmtm10wC0ypZBLw5IIp85NZMr91+qd1RvvENwg7jjRFw==", + "dependencies": { + "deep-is": "^0.1.3", + "fast-levenshtein": "^2.0.6", + "levn": "^0.4.1", + "prelude-ls": "^1.2.1", + "type-check": "^0.4.0", + "word-wrap": "^1.2.3" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/opts": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/opts/-/opts-2.0.2.tgz", + "integrity": "sha512-k41FwbcLnlgnFh69f4qdUfvDQ+5vaSDnVPFI/y5XuhKRq97EnVVneO9F1ESVCdiVu4fCS2L8usX3mU331hB7pg==", + "dev": true + }, + "node_modules/p-limit": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", + "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==", + "dev": true, + "dependencies": { + "p-try": "^2.0.0" + }, + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/p-locate": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz", + "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==", + "dev": true, + "dependencies": { + "p-limit": "^2.2.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/p-try": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", + "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/parent-module": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", + "integrity": "sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==", + "dependencies": { + "callsites": "^3.0.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/parse-asn1": { + "version": "5.1.6", + "resolved": "https://registry.npmjs.org/parse-asn1/-/parse-asn1-5.1.6.tgz", + "integrity": "sha512-RnZRo1EPU6JBnra2vGHj0yhp6ebyjBZpmUCLHWiFhxlzvBCCpAuZ7elsBp1PVAbQN0/04VD/19rfzlBSwLstMw==", + "dev": true, + "dependencies": { + "asn1.js": "^5.2.0", + "browserify-aes": "^1.0.0", + "evp_bytestokey": "^1.0.0", + "pbkdf2": "^3.0.3", + "safe-buffer": "^5.1.1" + } + }, + "node_modules/parse-json": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-5.2.0.tgz", + "integrity": "sha512-ayCKvm/phCGxOkYRSCM82iDwct8/EonSEgCSxWxD7ve6jHggsFl4fZVQBPRNgQoKiuV/odhFrGzQXZwbifC8Rg==", + "dev": true, + "dependencies": { + "@babel/code-frame": "^7.0.0", + "error-ex": "^1.3.1", + "json-parse-even-better-errors": "^2.3.0", + "lines-and-columns": "^1.1.6" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/path-exists": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", + "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/path-key": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", + "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", + "engines": { + "node": ">=8" + } + }, + "node_modules/path-parse": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", + "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==", + "dev": true + }, + "node_modules/path-type": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-type/-/path-type-4.0.0.tgz", + "integrity": "sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/pbkdf2": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/pbkdf2/-/pbkdf2-3.1.2.tgz", + "integrity": "sha512-iuh7L6jA7JEGu2WxDwtQP1ddOpaJNC4KlDEFfdQajSGgGPNi4OyDc2R7QnbY2bR9QjBVGwgvTdNJZoE7RaxUMA==", + "dev": true, + "dependencies": { + "create-hash": "^1.1.2", + "create-hmac": "^1.1.4", + "ripemd160": "^2.0.1", + "safe-buffer": "^5.0.1", + "sha.js": "^2.4.8" + }, + "engines": { + "node": ">=0.12" + } + }, + "node_modules/performance-now": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz", + "integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns=", + "dev": true + }, + "node_modules/picomatch": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.0.tgz", + "integrity": "sha512-lY1Q/PiJGC2zOv/z391WOTD+Z02bCgsFfvxoXXf6h7kv9o+WmsmzYqrAwY63sNgOxE4xEdq0WyUnXfKeBrSvYw==", + "dev": true, + "engines": { + "node": ">=8.6" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/pkg-dir": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-4.2.0.tgz", + "integrity": "sha512-HRDzbaKjC+AOWVXxAU/x54COGeIv9eb+6CkDSQoNTt4XyWoIJvuPsXizxu/Fr23EiekbtZwmh1IcIG/l/a10GQ==", + "dev": true, + "dependencies": { + "find-up": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/prelude-ls": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz", + "integrity": "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==", + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/prettier": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.4.1.tgz", + "integrity": "sha512-9fbDAXSBcc6Bs1mZrDYb3XKzDLm4EXXL9sC1LqKP5rZkT6KRr/rf9amVUcODVXgguK/isJz0d0hP72WeaKWsvA==", + "dev": true, + "bin": { + "prettier": "bin-prettier.js" + }, + "engines": { + "node": ">=10.13.0" + } + }, + "node_modules/process-es6": { + "version": "0.11.6", + "resolved": "https://registry.npmjs.org/process-es6/-/process-es6-0.11.6.tgz", + "integrity": "sha1-xrs4n5qVH4K9TrFpYAEFvS/5x3g=", + "dev": true + }, + "node_modules/process-nextick-args": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", + "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==", + "dev": true + }, + "node_modules/progress": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/progress/-/progress-2.0.3.tgz", + "integrity": "sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA==", + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/prr": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/prr/-/prr-1.0.1.tgz", + "integrity": "sha1-0/wRS6BplaRexok/SEzrHXj19HY=", + "dev": true + }, + "node_modules/psl": { + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/psl/-/psl-1.8.0.tgz", + "integrity": "sha512-RIdOzyoavK+hA18OGGWDqUTsCLhtA7IcZ/6NCs4fFJaHBDab+pDDmDIByWFRQJq2Cd7r1OoQxBGKOaztq+hjIQ==", + "dev": true + }, + "node_modules/public-encrypt": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/public-encrypt/-/public-encrypt-4.0.3.tgz", + "integrity": "sha512-zVpa8oKZSz5bTMTFClc1fQOnyyEzpl5ozpi1B5YcvBrdohMjH2rfsBtyXcuNuwjsDIXmBYlF2N5FlJYhR29t8Q==", + "dev": true, + "dependencies": { + "bn.js": "^4.1.0", + "browserify-rsa": "^4.0.0", + "create-hash": "^1.1.0", + "parse-asn1": "^5.0.0", + "randombytes": "^2.0.1", + "safe-buffer": "^5.1.2" + } + }, + "node_modules/public-encrypt/node_modules/bn.js": { + "version": "4.12.0", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.12.0.tgz", + "integrity": "sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA==", + "dev": true + }, + "node_modules/punycode": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz", + "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==", + "engines": { + "node": ">=6" + } + }, + "node_modules/qs": { + "version": "6.5.2", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.2.tgz", + "integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA==", + "dev": true, + "engines": { + "node": ">=0.6" + } + }, + "node_modules/queue-microtask": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz", + "integrity": "sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, + "node_modules/quick-lru": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/quick-lru/-/quick-lru-4.0.1.tgz", + "integrity": "sha512-ARhCpm70fzdcvNQfPoy49IaanKkTlRWF2JMzqhcJbhSFRZv7nPTvZJdcY7301IPmvW+/p0RgIWnQDLJxifsQ7g==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/random-number-csprng": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/random-number-csprng/-/random-number-csprng-1.0.2.tgz", + "integrity": "sha1-/NEg5i3/wsB2dMfD/gHhayX3OiY=", + "dev": true, + "dependencies": { + "bluebird": "^3.3.3", + "create-error": "^0.3.1" + } + }, + "node_modules/randombytes": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz", + "integrity": "sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ==", + "dev": true, + "dependencies": { + "safe-buffer": "^5.1.0" + } + }, + "node_modules/randomfill": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/randomfill/-/randomfill-1.0.4.tgz", + "integrity": "sha512-87lcbR8+MhcWcUiQ+9e+Rwx8MyR2P7qnt15ynUlbm3TU/fjbgz4GsvfSUDTemtCCtVCqb4ZcEFlyPNTh9bBTLw==", + "dev": true, + "dependencies": { + "randombytes": "^2.0.5", + "safe-buffer": "^5.1.0" + } + }, + "node_modules/read-pkg": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-5.2.0.tgz", + "integrity": "sha512-Ug69mNOpfvKDAc2Q8DRpMjjzdtrnv9HcSMX+4VsZxD1aZ6ZzrIE7rlzXBtWTyhULSMKg076AW6WR5iZpD0JiOg==", + "dev": true, + "dependencies": { + "@types/normalize-package-data": "^2.4.0", + "normalize-package-data": "^2.5.0", + "parse-json": "^5.0.0", + "type-fest": "^0.6.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/read-pkg-up": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/read-pkg-up/-/read-pkg-up-7.0.1.tgz", + "integrity": "sha512-zK0TB7Xd6JpCLmlLmufqykGE+/TlOePD6qKClNW7hHDKFh/J7/7gCWGR7joEQEW1bKq3a3yUZSObOoWLFQ4ohg==", + "dev": true, + "dependencies": { + "find-up": "^4.1.0", + "read-pkg": "^5.2.0", + "type-fest": "^0.8.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/read-pkg-up/node_modules/type-fest": { + "version": "0.8.1", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.8.1.tgz", + "integrity": "sha512-4dbzIzqvjtgiM5rw1k5rEHtBANKmdudhGyBEajN01fEyhaAIhsoKNy6y7+IN93IfpFtwY9iqi7kD+xwKhQsNJA==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/read-pkg/node_modules/hosted-git-info": { + "version": "2.8.9", + "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.9.tgz", + "integrity": "sha512-mxIDAb9Lsm6DoOJ7xH+5+X4y1LU/4Hi50L9C5sIswK3JzULS4bwk1FvjdBgvYR4bzT4tuUQiC15FE2f5HbLvYw==", + "dev": true + }, + "node_modules/read-pkg/node_modules/normalize-package-data": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.5.0.tgz", + "integrity": "sha512-/5CMN3T0R4XTj4DcGaexo+roZSdSFW/0AOOTROrjxzCG1wrWXEsGbRKevjlIL+ZDE4sZlJr5ED4YW0yqmkK+eA==", + "dev": true, + "dependencies": { + "hosted-git-info": "^2.1.4", + "resolve": "^1.10.0", + "semver": "2 || 3 || 4 || 5", + "validate-npm-package-license": "^3.0.1" + } + }, + "node_modules/read-pkg/node_modules/semver": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", + "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", + "dev": true, + "bin": { + "semver": "bin/semver" + } + }, + "node_modules/read-pkg/node_modules/type-fest": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.6.0.tgz", + "integrity": "sha512-q+MB8nYR1KDLrgr4G5yemftpMC7/QLqVndBmEEdqzmNj5dcFOO4Oo8qlwZE3ULT3+Zim1F8Kq4cBnikNhlCMlg==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/readable-stream": { + "version": "2.3.7", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", + "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==", + "dev": true, + "dependencies": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + }, + "node_modules/readdirp": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", + "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", + "dev": true, + "dependencies": { + "picomatch": "^2.2.1" + }, + "engines": { + "node": ">=8.10.0" + } + }, + "node_modules/redent": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/redent/-/redent-3.0.0.tgz", + "integrity": "sha512-6tDA8g98We0zd0GvVeMT9arEOnTw9qM03L9cJXaCjrip1OO764RDBLBfrB4cwzNGDj5OA5ioymC9GkizgWJDUg==", + "dev": true, + "dependencies": { + "indent-string": "^4.0.0", + "strip-indent": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/regexpp": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/regexpp/-/regexpp-3.2.0.tgz", + "integrity": "sha512-pq2bWo9mVD43nbts2wGv17XLiNLya+GklZ8kaDLV2Z08gDCsGpnKn9BFMepvWuHCbyVvY7J5o5+BVvoQbmlJLg==", + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/mysticatea" + } + }, + "node_modules/request": { + "version": "2.88.2", + "resolved": "https://registry.npmjs.org/request/-/request-2.88.2.tgz", + "integrity": "sha512-MsvtOrfG9ZcrOwAW+Qi+F6HbD0CWXEh9ou77uOb7FM2WPhwT7smM833PzanhJLsgXjN89Ir6V2PczXNnMpwKhw==", + "deprecated": "request has been deprecated, see https://github.com/request/request/issues/3142", + "dev": true, + "dependencies": { + "aws-sign2": "~0.7.0", + "aws4": "^1.8.0", + "caseless": "~0.12.0", + "combined-stream": "~1.0.6", + "extend": "~3.0.2", + "forever-agent": "~0.6.1", + "form-data": "~2.3.2", + "har-validator": "~5.1.3", + "http-signature": "~1.2.0", + "is-typedarray": "~1.0.0", + "isstream": "~0.1.2", + "json-stringify-safe": "~5.0.1", + "mime-types": "~2.1.19", + "oauth-sign": "~0.9.0", + "performance-now": "^2.1.0", + "qs": "~6.5.2", + "safe-buffer": "^5.1.2", + "tough-cookie": "~2.5.0", + "tunnel-agent": "^0.6.0", + "uuid": "^3.3.2" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/request/node_modules/uuid": { + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz", + "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==", + "deprecated": "Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.", + "dev": true, + "bin": { + "uuid": "bin/uuid" + } + }, + "node_modules/require-directory": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", + "integrity": "sha1-jGStX9MNqxyXbiNE/+f3kqam30I=", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/require-from-string": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/require-from-string/-/require-from-string-2.0.2.tgz", + "integrity": "sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/require-main-filename": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-2.0.0.tgz", + "integrity": "sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg==", + "dev": true + }, + "node_modules/require-relative": { + "version": "0.8.7", + "resolved": "https://registry.npmjs.org/require-relative/-/require-relative-0.8.7.tgz", + "integrity": "sha1-eZlTn8ngR6N5KPoZb44VY9q9Nt4=", + "dev": true + }, + "node_modules/resolve": { + "version": "1.20.0", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.20.0.tgz", + "integrity": "sha512-wENBPt4ySzg4ybFQW2TT1zMQucPK95HSh/nq2CFTZVOGut2+pQvSsgtda4d26YrYcr067wjbmzOG8byDPBX63A==", + "dev": true, + "dependencies": { + "is-core-module": "^2.2.0", + "path-parse": "^1.0.6" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/resolve-from": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz", + "integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==", + "engines": { + "node": ">=4" + } + }, + "node_modules/ret": { + "version": "0.1.15", + "resolved": "https://registry.npmjs.org/ret/-/ret-0.1.15.tgz", + "integrity": "sha512-TTlYpa+OL+vMMNG24xSlQGEJ3B/RzEfUlLct7b5G/ytav+wPrplCpVMFuwzXbkecJrb6IYo1iFb0S9v37754mg==", + "dev": true, + "engines": { + "node": ">=0.12" + } + }, + "node_modules/reusify": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/reusify/-/reusify-1.0.4.tgz", + "integrity": "sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==", + "dev": true, + "engines": { + "iojs": ">=1.0.0", + "node": ">=0.10.0" + } + }, + "node_modules/rimraf": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", + "integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==", + "dependencies": { + "glob": "^7.1.3" + }, + "bin": { + "rimraf": "bin.js" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/ripemd160": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/ripemd160/-/ripemd160-2.0.2.tgz", + "integrity": "sha512-ii4iagi25WusVoiC4B4lq7pbXfAp3D9v5CwfkY33vffw2+pkDjY1D8GaN7spsxvCSx8dkPqOZCEZyfxcmJG2IA==", + "dev": true, + "dependencies": { + "hash-base": "^3.0.0", + "inherits": "^2.0.1" + } + }, + "node_modules/rollup": { + "version": "2.58.3", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-2.58.3.tgz", + "integrity": "sha512-ei27MSw1KhRur4p87Q0/Va2NAYqMXOX++FNEumMBcdreIRLURKy+cE2wcDJKBn0nfmhP2ZGrJkP1XPO+G8FJQw==", + "dev": true, + "bin": { + "rollup": "dist/bin/rollup" + }, + "engines": { + "node": ">=10.0.0" + }, + "optionalDependencies": { + "fsevents": "~2.3.2" + } + }, + "node_modules/rollup-plugin-css-only": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/rollup-plugin-css-only/-/rollup-plugin-css-only-3.1.0.tgz", + "integrity": "sha512-TYMOE5uoD76vpj+RTkQLzC9cQtbnJNktHPB507FzRWBVaofg7KhIqq1kGbcVOadARSozWF883Ho9KpSPKH8gqA==", + "dev": true, + "dependencies": { + "@rollup/pluginutils": "4" + }, + "engines": { + "node": ">=10.12.0" + }, + "peerDependencies": { + "rollup": "1 || 2" + } + }, + "node_modules/rollup-plugin-css-only/node_modules/@rollup/pluginutils": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-4.1.1.tgz", + "integrity": "sha512-clDjivHqWGXi7u+0d2r2sBi4Ie6VLEAzWMIkvJLnDmxoOhBYOTfzGbOQBA32THHm11/LiJbd01tJUpJsbshSWQ==", + "dev": true, + "dependencies": { + "estree-walker": "^2.0.1", + "picomatch": "^2.2.2" + }, + "engines": { + "node": ">= 8.0.0" + } + }, + "node_modules/rollup-plugin-livereload": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/rollup-plugin-livereload/-/rollup-plugin-livereload-2.0.5.tgz", + "integrity": "sha512-vqQZ/UQowTW7VoiKEM5ouNW90wE5/GZLfdWuR0ELxyKOJUIaj+uismPZZaICU4DnWPVjnpCDDxEqwU7pcKY/PA==", + "dev": true, + "dependencies": { + "livereload": "^0.9.1" + }, + "engines": { + "node": ">=8.3" + } + }, + "node_modules/rollup-plugin-node-builtins": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/rollup-plugin-node-builtins/-/rollup-plugin-node-builtins-2.1.2.tgz", + "integrity": "sha1-JKH+1KQyV7a2Q3HYq8bOGrFFl+k=", + "dev": true, + "dependencies": { + "browserify-fs": "^1.0.0", + "buffer-es6": "^4.9.2", + "crypto-browserify": "^3.11.0", + "process-es6": "^0.11.2" + } + }, + "node_modules/rollup-plugin-node-globals": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/rollup-plugin-node-globals/-/rollup-plugin-node-globals-1.4.0.tgz", + "integrity": "sha512-xRkB+W/m1KLIzPUmG0ofvR+CPNcvuCuNdjVBVS7ALKSxr3EDhnzNceGkGi1m8MToSli13AzKFYH4ie9w3I5L3g==", + "dev": true, + "dependencies": { + "acorn": "^5.7.3", + "buffer-es6": "^4.9.3", + "estree-walker": "^0.5.2", + "magic-string": "^0.22.5", + "process-es6": "^0.11.6", + "rollup-pluginutils": "^2.3.1" + } + }, + "node_modules/rollup-plugin-node-globals/node_modules/acorn": { + "version": "5.7.4", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-5.7.4.tgz", + "integrity": "sha512-1D++VG7BhrtvQpNbBzovKNc1FLGGEE/oGe7b9xJm/RFHMBeUaUGpluV9RLjZa47YFdPcDAenEYuq9pQPcMdLJg==", + "dev": true, + "bin": { + "acorn": "bin/acorn" + }, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/rollup-plugin-node-globals/node_modules/estree-walker": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-0.5.2.tgz", + "integrity": "sha512-XpCnW/AE10ws/kDAs37cngSkvgIR8aN3G0MS85m7dUpuK2EREo9VJ00uvw6Dg/hXEpfsE1I1TvJOJr+Z+TL+ig==", + "dev": true + }, + "node_modules/rollup-plugin-node-globals/node_modules/magic-string": { + "version": "0.22.5", + "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.22.5.tgz", + "integrity": "sha512-oreip9rJZkzvA8Qzk9HFs8fZGF/u7H/gtrE8EN6RjKJ9kh2HlC+yQ2QezifqTZfGyiuAV0dRv5a+y/8gBb1m9w==", + "dev": true, + "dependencies": { + "vlq": "^0.2.2" + } + }, + "node_modules/rollup-plugin-svelte": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/rollup-plugin-svelte/-/rollup-plugin-svelte-7.1.0.tgz", + "integrity": "sha512-vopCUq3G+25sKjwF5VilIbiY6KCuMNHP1PFvx2Vr3REBNMDllKHFZN2B9jwwC+MqNc3UPKkjXnceLPEjTjXGXg==", + "dev": true, + "dependencies": { + "require-relative": "^0.8.7", + "rollup-pluginutils": "^2.8.2" + }, + "engines": { + "node": ">=10" + }, + "peerDependencies": { + "rollup": ">=2.0.0", + "svelte": ">=3.5.0" + } + }, + "node_modules/rollup-plugin-terser": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/rollup-plugin-terser/-/rollup-plugin-terser-7.0.2.tgz", + "integrity": "sha512-w3iIaU4OxcF52UUXiZNsNeuXIMDvFrr+ZXK6bFZ0Q60qyVfq4uLptoS4bbq3paG3x216eQllFZX7zt6TIImguQ==", + "dev": true, + "dependencies": { + "@babel/code-frame": "^7.10.4", + "jest-worker": "^26.2.1", + "serialize-javascript": "^4.0.0", + "terser": "^5.0.0" + }, + "peerDependencies": { + "rollup": "^2.0.0" + } + }, + "node_modules/rollup-plugin-typescript2": { + "version": "0.30.0", + "resolved": "https://registry.npmjs.org/rollup-plugin-typescript2/-/rollup-plugin-typescript2-0.30.0.tgz", + "integrity": "sha512-NUFszIQyhgDdhRS9ya/VEmsnpTe+GERDMmFo0Y+kf8ds51Xy57nPNGglJY+W6x1vcouA7Au7nsTgsLFj2I0PxQ==", + "dev": true, + "dependencies": { + "@rollup/pluginutils": "^4.1.0", + "find-cache-dir": "^3.3.1", + "fs-extra": "8.1.0", + "resolve": "1.20.0", + "tslib": "2.1.0" + }, + "peerDependencies": { + "rollup": ">=1.26.3", + "typescript": ">=2.4.0" + } + }, + "node_modules/rollup-plugin-typescript2/node_modules/@rollup/pluginutils": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-4.1.1.tgz", + "integrity": "sha512-clDjivHqWGXi7u+0d2r2sBi4Ie6VLEAzWMIkvJLnDmxoOhBYOTfzGbOQBA32THHm11/LiJbd01tJUpJsbshSWQ==", + "dev": true, + "dependencies": { + "estree-walker": "^2.0.1", + "picomatch": "^2.2.2" + }, + "engines": { + "node": ">= 8.0.0" + } + }, + "node_modules/rollup-plugin-typescript2/node_modules/tslib": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.1.0.tgz", + "integrity": "sha512-hcVC3wYEziELGGmEEXue7D75zbwIIVUMWAVbHItGPx0ziyXxrOMQx4rQEVEV45Ut/1IotuEvwqPopzIOkDMf0A==", + "dev": true + }, + "node_modules/rollup-plugin-web-worker-loader": { + "version": "1.6.1", + "resolved": "https://registry.npmjs.org/rollup-plugin-web-worker-loader/-/rollup-plugin-web-worker-loader-1.6.1.tgz", + "integrity": "sha512-4QywQSz1NXFHKdyiou16mH3ijpcfLtLGOrAqvAqu1Gx+P8+zj+3gwC2BSL/VW1d+LW4nIHC8F7d7OXhs9UdR2A==", + "dev": true, + "peerDependencies": { + "rollup": "^1.9.2 || ^2.0.0" + } + }, + "node_modules/rollup-pluginutils": { + "version": "2.8.2", + "resolved": "https://registry.npmjs.org/rollup-pluginutils/-/rollup-pluginutils-2.8.2.tgz", + "integrity": "sha512-EEp9NhnUkwY8aif6bxgovPHMoMoNr2FulJziTndpt5H9RdwC47GSGuII9XxpSdzVGM0GWrNPHV6ie1LTNJPaLQ==", + "dev": true, + "dependencies": { + "estree-walker": "^0.6.1" + } + }, + "node_modules/rollup-pluginutils/node_modules/estree-walker": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-0.6.1.tgz", + "integrity": "sha512-SqmZANLWS0mnatqbSfRP5g8OXZC12Fgg1IwNtLsyHDzJizORW4khDfjPqJZsemPWBB2uqykUah5YpQ6epsqC/w==", + "dev": true + }, + "node_modules/run-parallel": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz", + "integrity": "sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "dependencies": { + "queue-microtask": "^1.2.2" + } + }, + "node_modules/sade": { + "version": "1.7.4", + "resolved": "https://registry.npmjs.org/sade/-/sade-1.7.4.tgz", + "integrity": "sha512-y5yauMD93rX840MwUJr7C1ysLFBgMspsdTo4UVrDg3fXDvtwOyIqykhVAAm6fk/3au77773itJStObgK+LKaiA==", + "dev": true, + "dependencies": { + "mri": "^1.1.0" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", + "dev": true + }, + "node_modules/safe-regex": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/safe-regex/-/safe-regex-1.1.0.tgz", + "integrity": "sha1-QKNmnzsHfR6UPURinhV91IAjvy4=", + "dev": true, + "dependencies": { + "ret": "~0.1.10" + } + }, + "node_modules/safer-buffer": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", + "dev": true + }, + "node_modules/sander": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/sander/-/sander-0.5.1.tgz", + "integrity": "sha1-dB4kXiMfB8r7b98PEzrfohalAq0=", + "dev": true, + "dependencies": { + "es6-promise": "^3.1.2", + "graceful-fs": "^4.1.3", + "mkdirp": "^0.5.1", + "rimraf": "^2.5.2" + } + }, + "node_modules/sander/node_modules/rimraf": { + "version": "2.7.1", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.7.1.tgz", + "integrity": "sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w==", + "dev": true, + "dependencies": { + "glob": "^7.1.3" + }, + "bin": { + "rimraf": "bin.js" + } + }, + "node_modules/sass-graph": { + "version": "2.2.5", + "resolved": "https://registry.npmjs.org/sass-graph/-/sass-graph-2.2.5.tgz", + "integrity": "sha512-VFWDAHOe6mRuT4mZRd4eKE+d8Uedrk6Xnh7Sh9b4NGufQLQjOrvf/MQoOdx+0s92L89FeyUUNfU597j/3uNpag==", + "dev": true, + "dependencies": { + "glob": "^7.0.0", + "lodash": "^4.0.0", + "scss-tokenizer": "^0.2.3", + "yargs": "^13.3.2" + }, + "bin": { + "sassgraph": "bin/sassgraph" + } + }, + "node_modules/scss-tokenizer": { + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/scss-tokenizer/-/scss-tokenizer-0.2.3.tgz", + "integrity": "sha1-jrBtualyMzOCTT9VMGQRSYR85dE=", + "dev": true, + "dependencies": { + "js-base64": "^2.1.8", + "source-map": "^0.4.2" + } + }, + "node_modules/semiver": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/semiver/-/semiver-1.1.0.tgz", + "integrity": "sha512-QNI2ChmuioGC1/xjyYwyZYADILWyW6AmS1UH6gDj/SFUUUS4MBAWs/7mxnkRPc/F4iHezDP+O8t0dO8WHiEOdg==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/semver": { + "version": "7.3.5", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.5.tgz", + "integrity": "sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ==", + "dependencies": { + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/serialize-javascript": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-4.0.0.tgz", + "integrity": "sha512-GaNA54380uFefWghODBWEGisLZFj00nS5ACs6yHa9nLqlLpVLO8ChDGeKRjZnV4Nh4n0Qi7nhYZD/9fCPzEqkw==", + "dev": true, + "dependencies": { + "randombytes": "^2.1.0" + } + }, + "node_modules/set-blocking": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", + "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=", + "dev": true + }, + "node_modules/sha.js": { + "version": "2.4.11", + "resolved": "https://registry.npmjs.org/sha.js/-/sha.js-2.4.11.tgz", + "integrity": "sha512-QMEp5B7cftE7APOjk5Y6xgrbWu+WkLVQwk8JNjZ8nKRciZaByEW6MubieAiToS7+dwvrjGhH8jRXz3MVd0AYqQ==", + "dev": true, + "dependencies": { + "inherits": "^2.0.1", + "safe-buffer": "^5.0.1" + }, + "bin": { + "sha.js": "bin.js" + } + }, + "node_modules/shebang-command": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", + "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", + "dependencies": { + "shebang-regex": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/shebang-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", + "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", + "engines": { + "node": ">=8" + } + }, + "node_modules/signal-exit": { + "version": "3.0.5", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.5.tgz", + "integrity": "sha512-KWcOiKeQj6ZyXx7zq4YxSMgHRlod4czeBQZrPb8OKcohcqAXShm7E20kEMle9WBt26hFcAf0qLOcp5zmY7kOqQ==", + "dev": true + }, + "node_modules/sirv": { + "version": "1.0.18", + "resolved": "https://registry.npmjs.org/sirv/-/sirv-1.0.18.tgz", + "integrity": "sha512-f2AOPogZmXgJ9Ma2M22ZEhc1dNtRIzcEkiflMFeVTRq+OViOZMvH1IPMVOwrKaxpSaHioBJiDR0SluRqGa7atA==", + "dev": true, + "dependencies": { + "@polka/url": "^1.0.0-next.20", + "mime": "^2.3.1", + "totalist": "^1.0.0" + }, + "engines": { + "node": ">= 10" + } + }, + "node_modules/sirv-cli": { + "version": "1.0.14", + "resolved": "https://registry.npmjs.org/sirv-cli/-/sirv-cli-1.0.14.tgz", + "integrity": "sha512-yyUTNr984ANKDloqepkYbBSqvx3buwYg2sQKPWjSU+IBia5loaoka2If8N9CMwt8AfP179cdEl7kYJ//iWJHjQ==", + "dev": true, + "dependencies": { + "console-clear": "^1.1.0", + "get-port": "^3.2.0", + "kleur": "^3.0.0", + "local-access": "^1.0.1", + "sade": "^1.6.0", + "semiver": "^1.0.0", + "sirv": "^1.0.13", + "tinydate": "^1.0.0" + }, + "bin": { + "sirv": "bin.js" + }, + "engines": { + "node": ">= 10" + } + }, + "node_modules/slash": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz", + "integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/slice-ansi": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-4.0.0.tgz", + "integrity": "sha512-qMCMfhY040cVHT43K9BFygqYbUPFZKHOg7K73mtTWJRb8pyP3fzf4Ixd5SzdEJQ6MRUg/WBnOLxghZtKKurENQ==", + "dependencies": { + "ansi-styles": "^4.0.0", + "astral-regex": "^2.0.0", + "is-fullwidth-code-point": "^3.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/slice-ansi?sponsor=1" + } + }, + "node_modules/slice-ansi/node_modules/is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "engines": { + "node": ">=8" + } + }, + "node_modules/sorcery": { + "version": "0.10.0", + "resolved": "https://registry.npmjs.org/sorcery/-/sorcery-0.10.0.tgz", + "integrity": "sha1-iukK19fLBfxZ8asMY3hF1cFaUrc=", + "dev": true, + "dependencies": { + "buffer-crc32": "^0.2.5", + "minimist": "^1.2.0", + "sander": "^0.5.0", + "sourcemap-codec": "^1.3.0" + }, + "bin": { + "sorcery": "bin/index.js" + } + }, + "node_modules/source-map": { + "version": "0.4.4", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.4.4.tgz", + "integrity": "sha1-66T12pwNyZneaAMti092FzZSA2s=", + "dev": true, + "dependencies": { + "amdefine": ">=0.0.4" + }, + "engines": { + "node": ">=0.8.0" + } + }, + "node_modules/source-map-support": { + "version": "0.5.20", + "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.20.tgz", + "integrity": "sha512-n1lZZ8Ve4ksRqizaBQgxXDgKwttHDhyfQjA6YZZn8+AroHbsIz+JjwxQDxbp+7y5OYCI8t1Yk7etjD9CRd2hIw==", + "dev": true, + "dependencies": { + "buffer-from": "^1.0.0", + "source-map": "^0.6.0" + } + }, + "node_modules/source-map-support/node_modules/source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/sourcemap-codec": { + "version": "1.4.8", + "resolved": "https://registry.npmjs.org/sourcemap-codec/-/sourcemap-codec-1.4.8.tgz", + "integrity": "sha512-9NykojV5Uih4lgo5So5dtw+f0JgJX30KCNI8gwhz2J9A15wD0Ml6tjHKwf6fTSa6fAdVBdZeNOs9eJ71qCk8vA==", + "dev": true + }, + "node_modules/spdx-correct": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-3.1.1.tgz", + "integrity": "sha512-cOYcUWwhCuHCXi49RhFRCyJEK3iPj1Ziz9DpViV3tbZOwXD49QzIN3MpOLJNxh2qwq2lJJZaKMVw9qNi4jTC0w==", + "dev": true, + "dependencies": { + "spdx-expression-parse": "^3.0.0", + "spdx-license-ids": "^3.0.0" + } + }, + "node_modules/spdx-exceptions": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/spdx-exceptions/-/spdx-exceptions-2.3.0.tgz", + "integrity": "sha512-/tTrYOC7PPI1nUAgx34hUpqXuyJG+DTHJTnIULG4rDygi4xu/tfgmq1e1cIRwRzwZgo4NLySi+ricLkZkw4i5A==", + "dev": true + }, + "node_modules/spdx-expression-parse": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/spdx-expression-parse/-/spdx-expression-parse-3.0.1.tgz", + "integrity": "sha512-cbqHunsQWnJNE6KhVSMsMeH5H/L9EpymbzqTQ3uLwNCLZ1Q481oWaofqH7nO6V07xlXwY6PhQdQ2IedWx/ZK4Q==", + "dev": true, + "dependencies": { + "spdx-exceptions": "^2.1.0", + "spdx-license-ids": "^3.0.0" + } + }, + "node_modules/spdx-license-ids": { + "version": "3.0.10", + "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.10.tgz", + "integrity": "sha512-oie3/+gKf7QtpitB0LYLETe+k8SifzsX4KixvpOsbI6S0kRiRQ5MKOio8eMSAKQ17N06+wdEOXRiId+zOxo0hA==", + "dev": true + }, + "node_modules/sprintf-js": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", + "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=" + }, + "node_modules/sshpk": { + "version": "1.16.1", + "resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.16.1.tgz", + "integrity": "sha512-HXXqVUq7+pcKeLqqZj6mHFUMvXtOJt1uoUx09pFW6011inTMxqI8BA8PM95myrIyyKwdnzjdFjLiE6KBPVtJIg==", + "dev": true, + "dependencies": { + "asn1": "~0.2.3", + "assert-plus": "^1.0.0", + "bcrypt-pbkdf": "^1.0.0", + "dashdash": "^1.12.0", + "ecc-jsbn": "~0.1.1", + "getpass": "^0.1.1", + "jsbn": "~0.1.0", + "safer-buffer": "^2.0.2", + "tweetnacl": "~0.14.0" + }, + "bin": { + "sshpk-conv": "bin/sshpk-conv", + "sshpk-sign": "bin/sshpk-sign", + "sshpk-verify": "bin/sshpk-verify" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/sshpk/node_modules/tweetnacl": { + "version": "0.14.5", + "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz", + "integrity": "sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q=", + "dev": true + }, + "node_modules/stdout-stream": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/stdout-stream/-/stdout-stream-1.4.1.tgz", + "integrity": "sha512-j4emi03KXqJWcIeF8eIXkjMFN1Cmb8gUlDYGeBALLPo5qdyTfA9bOtl8m33lRoC+vFMkP3gl0WsDr6+gzxbbTA==", + "dev": true, + "dependencies": { + "readable-stream": "^2.0.1" + } + }, + "node_modules/string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "dev": true, + "dependencies": { + "safe-buffer": "~5.1.0" + } + }, + "node_modules/string-range": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/string-range/-/string-range-1.2.2.tgz", + "integrity": "sha1-qJPtNH5yKZvIO++78qaSqNI51d0=", + "dev": true + }, + "node_modules/string-width": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", + "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", + "dev": true, + "dependencies": { + "code-point-at": "^1.0.0", + "is-fullwidth-code-point": "^1.0.0", + "strip-ansi": "^3.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/string-width/node_modules/ansi-regex": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", + "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/string-width/node_modules/strip-ansi": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", + "dev": true, + "dependencies": { + "ansi-regex": "^2.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dependencies": { + "ansi-regex": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/strip-indent": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/strip-indent/-/strip-indent-3.0.0.tgz", + "integrity": "sha512-laJTa3Jb+VQpaC6DseHhF7dXVqHTfJPCRDaEbid/drOhgitgYku/letMUqOXFoWV0zIIUbjpdH2t+tYj4bQMRQ==", + "dev": true, + "dependencies": { + "min-indent": "^1.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/strip-json-comments": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", + "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==", + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/svelte": { + "version": "3.44.0", + "resolved": "https://registry.npmjs.org/svelte/-/svelte-3.44.0.tgz", + "integrity": "sha512-zWACSJBSncGiDvFfYOMFGNV5zDLOlyhftmO5yOZ0lEtQMptpElaRtl39MWz1+lYCpwUq4F3Q2lTzI9TrTL+eMA==", + "engines": { + "node": ">= 8" + } + }, + "node_modules/svelte-check": { + "version": "2.2.7", + "resolved": "https://registry.npmjs.org/svelte-check/-/svelte-check-2.2.7.tgz", + "integrity": "sha512-lH8ArmwVC+D314cToZkXBBfj7NlpvgQGP7nXCAMnNHo6hTEcbKcf/cAZgzbnAOTftjIJrmLHp+EDW887VJFSOQ==", + "dev": true, + "dependencies": { + "chalk": "^4.0.0", + "chokidar": "^3.4.1", + "fast-glob": "^3.2.7", + "import-fresh": "^3.2.1", + "minimist": "^1.2.5", + "sade": "^1.7.4", + "source-map": "^0.7.3", + "svelte-preprocess": "^4.0.0", + "typescript": "*" + }, + "bin": { + "svelte-check": "bin/svelte-check" + }, + "peerDependencies": { + "svelte": "^3.24.0" + } + }, + "node_modules/svelte-check/node_modules/source-map": { + "version": "0.7.3", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.7.3.tgz", + "integrity": "sha512-CkCj6giN3S+n9qrYiBTX5gystlENnRW5jZeNLHpe6aue+SrHcG5VYwujhW9s4dY31mEGsxBDrHR6oI69fTXsaQ==", + "dev": true, + "engines": { + "node": ">= 8" + } + }, + "node_modules/svelte-preprocess": { + "version": "4.9.8", + "resolved": "https://registry.npmjs.org/svelte-preprocess/-/svelte-preprocess-4.9.8.tgz", + "integrity": "sha512-EQS/oRZzMtYdAprppZxY3HcysKh11w54MgA63ybtL+TAZ4hVqYOnhw41JVJjWN9dhPnNjjLzvbZ2tMhTsla1Og==", + "dev": true, + "hasInstallScript": true, + "dependencies": { + "@types/pug": "^2.0.4", + "@types/sass": "^1.16.0", + "detect-indent": "^6.0.0", + "magic-string": "^0.25.7", + "sorcery": "^0.10.0", + "strip-indent": "^3.0.0" + }, + "engines": { + "node": ">= 9.11.2" + }, + "peerDependencies": { + "@babel/core": "^7.10.2", + "coffeescript": "^2.5.1", + "less": "^3.11.3", + "postcss": "^7 || ^8", + "postcss-load-config": "^2.1.0 || ^3.0.0", + "pug": "^3.0.0", + "sass": "^1.26.8", + "stylus": "^0.54.7", + "sugarss": "^2.0.0", + "svelte": "^3.23.0", + "typescript": "^3.9.5 || ^4.0.0" + }, + "peerDependenciesMeta": { + "@babel/core": { + "optional": true + }, + "coffeescript": { + "optional": true + }, + "less": { + "optional": true + }, + "node-sass": { + "optional": true + }, + "postcss": { + "optional": true + }, + "postcss-load-config": { + "optional": true + }, + "pug": { + "optional": true + }, + "sass": { + "optional": true + }, + "stylus": { + "optional": true + }, + "sugarss": { + "optional": true + }, + "typescript": { + "optional": true + } + } + }, + "node_modules/svelte-router-spa": { + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/svelte-router-spa/-/svelte-router-spa-6.0.3.tgz", + "integrity": "sha512-aHgyUVVI/WjipQNmKcXpX0hFZtkW5Y6hwH5aXLr2P/aRQ/qlX8ZbKQJUwKjOD59p7tt/c+wqokiIt68N7aNuKQ==", + "dependencies": { + "url-params-parser": "^1.0.3" + }, + "peerDependencies": { + "svelte": "^3.36.0" + } + }, + "node_modules/table": { + "version": "6.7.2", + "resolved": "https://registry.npmjs.org/table/-/table-6.7.2.tgz", + "integrity": "sha512-UFZK67uvyNivLeQbVtkiUs8Uuuxv24aSL4/Vil2PJVtMgU8Lx0CYkP12uCGa3kjyQzOSgV1+z9Wkb82fCGsO0g==", + "dependencies": { + "ajv": "^8.0.1", + "lodash.clonedeep": "^4.5.0", + "lodash.truncate": "^4.4.2", + "slice-ansi": "^4.0.0", + "string-width": "^4.2.3", + "strip-ansi": "^6.0.1" + }, + "engines": { + "node": ">=10.0.0" + } + }, + "node_modules/table/node_modules/ajv": { + "version": "8.6.3", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.6.3.tgz", + "integrity": "sha512-SMJOdDP6LqTkD0Uq8qLi+gMwSt0imXLSV080qFVwJCpH9U6Mb+SUGHAXM0KNbcBPguytWyvFxcHgMLe2D2XSpw==", + "dependencies": { + "fast-deep-equal": "^3.1.1", + "json-schema-traverse": "^1.0.0", + "require-from-string": "^2.0.2", + "uri-js": "^4.2.2" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/epoberezkin" + } + }, + "node_modules/table/node_modules/emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==" + }, + "node_modules/table/node_modules/is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "engines": { + "node": ">=8" + } + }, + "node_modules/table/node_modules/json-schema-traverse": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz", + "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==" + }, + "node_modules/table/node_modules/string-width": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/tar": { + "version": "6.1.11", + "resolved": "https://registry.npmjs.org/tar/-/tar-6.1.11.tgz", + "integrity": "sha512-an/KZQzQUkZCkuoAA64hM92X0Urb6VpRhAFllDzz44U2mcD5scmT3zBc4VgVpkugF580+DQn8eAFSyoQt0tznA==", + "dev": true, + "dependencies": { + "chownr": "^2.0.0", + "fs-minipass": "^2.0.0", + "minipass": "^3.0.0", + "minizlib": "^2.1.1", + "mkdirp": "^1.0.3", + "yallist": "^4.0.0" + }, + "engines": { + "node": ">= 10" + } + }, + "node_modules/tar/node_modules/mkdirp": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz", + "integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==", + "dev": true, + "bin": { + "mkdirp": "bin/cmd.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/terser": { + "version": "5.9.0", + "resolved": "https://registry.npmjs.org/terser/-/terser-5.9.0.tgz", + "integrity": "sha512-h5hxa23sCdpzcye/7b8YqbE5OwKca/ni0RQz1uRX3tGh8haaGHqcuSqbGRybuAKNdntZ0mDgFNXPJ48xQ2RXKQ==", + "dev": true, + "dependencies": { + "commander": "^2.20.0", + "source-map": "~0.7.2", + "source-map-support": "~0.5.20" + }, + "bin": { + "terser": "bin/terser" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/terser/node_modules/source-map": { + "version": "0.7.3", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.7.3.tgz", + "integrity": "sha512-CkCj6giN3S+n9qrYiBTX5gystlENnRW5jZeNLHpe6aue+SrHcG5VYwujhW9s4dY31mEGsxBDrHR6oI69fTXsaQ==", + "dev": true, + "engines": { + "node": ">= 8" + } + }, + "node_modules/text-table": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", + "integrity": "sha1-f17oI66AUgfACvLfSoTsP8+lcLQ=" + }, + "node_modules/threads": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/threads/-/threads-1.7.0.tgz", + "integrity": "sha512-Mx5NBSHX3sQYR6iI9VYbgHKBLisyB+xROCBGjjWm1O9wb9vfLxdaGtmT/KCjUqMsSNW6nERzCW3T6H43LqjDZQ==", + "dev": true, + "dependencies": { + "callsites": "^3.1.0", + "debug": "^4.2.0", + "is-observable": "^2.1.0", + "observable-fns": "^0.6.1" + }, + "funding": { + "url": "https://github.com/andywer/threads.js?sponsor=1" + }, + "optionalDependencies": { + "tiny-worker": ">= 2" + } + }, + "node_modules/tiny-worker": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/tiny-worker/-/tiny-worker-2.3.0.tgz", + "integrity": "sha512-pJ70wq5EAqTAEl9IkGzA+fN0836rycEuz2Cn6yeZ6FRzlVS5IDOkFHpIoEsksPRQV34GDqXm65+OlnZqUSyK2g==", + "dev": true, + "optional": true, + "dependencies": { + "esm": "^3.2.25" + } + }, + "node_modules/tinydate": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/tinydate/-/tinydate-1.3.0.tgz", + "integrity": "sha512-7cR8rLy2QhYHpsBDBVYnnWXm8uRTr38RoZakFSW7Bs7PzfMPNZthuMLkwqZv7MTu8lhQ91cOFYS5a7iFj2oR3w==", + "dev": true, + "engines": { + "node": ">=4" + } + }, + "node_modules/to-regex-range": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", + "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", + "dev": true, + "dependencies": { + "is-number": "^7.0.0" + }, + "engines": { + "node": ">=8.0" + } + }, + "node_modules/totalist": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/totalist/-/totalist-1.1.0.tgz", + "integrity": "sha512-gduQwd1rOdDMGxFG1gEvhV88Oirdo2p+KjoYFU7k2g+i7n6AFFbDQ5kMPUsW0pNbfQsB/cwXvT1i4Bue0s9g5g==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/tough-cookie": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.5.0.tgz", + "integrity": "sha512-nlLsUzgm1kfLXSXfRZMc1KLAugd4hqJHDTvc2hDIwS3mZAfMEuMbc03SujMF+GEcpaX/qboeycw6iO8JwVv2+g==", + "dev": true, + "dependencies": { + "psl": "^1.1.28", + "punycode": "^2.1.1" + }, + "engines": { + "node": ">=0.8" + } + }, + "node_modules/trim-newlines": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/trim-newlines/-/trim-newlines-3.0.1.tgz", + "integrity": "sha512-c1PTsA3tYrIsLGkJkzHF+w9F2EyxfXGo4UyJc4pFL++FMjnq0HJS69T3M7d//gKrFKwy429bouPescbjecU+Zw==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/true-case-path": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/true-case-path/-/true-case-path-1.0.3.tgz", + "integrity": "sha512-m6s2OdQe5wgpFMC+pAJ+q9djG82O2jcHPOI6RNg1yy9rCYR+WD6Nbpl32fDpfC56nirdRy+opFa/Vk7HYhqaew==", + "dev": true, + "dependencies": { + "glob": "^7.1.2" + } + }, + "node_modules/tslib": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.3.1.tgz", + "integrity": "sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw==" + }, + "node_modules/tsutils": { + "version": "3.21.0", + "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-3.21.0.tgz", + "integrity": "sha512-mHKK3iUXL+3UF6xL5k0PEhKRUBKPBCv/+RkEOpjRWxxx27KKRBmmA60A9pgOUvMi8GKhRMPEmjBRPzs2W7O1OA==", + "dev": true, + "dependencies": { + "tslib": "^1.8.1" + }, + "engines": { + "node": ">= 6" + }, + "peerDependencies": { + "typescript": ">=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta" + } + }, + "node_modules/tsutils/node_modules/tslib": { + "version": "1.14.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", + "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==", + "dev": true + }, + "node_modules/tunnel-agent": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", + "integrity": "sha1-J6XeoGs2sEoKmWZ3SykIaPD8QP0=", + "dev": true, + "dependencies": { + "safe-buffer": "^5.0.1" + }, + "engines": { + "node": "*" + } + }, + "node_modules/tweetnacl": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-1.0.3.tgz", + "integrity": "sha512-6rt+RN7aOi1nGMyC4Xa5DdYiukl2UWCbcJft7YhxReBGQD7OAM8Pbxw6YMo4r2diNEA8FEmu32YOn9rhaiE5yw==", + "dev": true + }, + "node_modules/type-check": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz", + "integrity": "sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==", + "dependencies": { + "prelude-ls": "^1.2.1" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/type-fest": { + "version": "0.20.2", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.20.2.tgz", + "integrity": "sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/typedarray": { + "version": "0.0.6", + "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", + "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=", + "dev": true + }, + "node_modules/typedarray-to-buffer": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/typedarray-to-buffer/-/typedarray-to-buffer-1.0.4.tgz", + "integrity": "sha1-m7i6DoQfs/TPH+fCRenz+opf6Zw=", + "dev": true + }, + "node_modules/typescript": { + "version": "4.4.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.4.4.tgz", + "integrity": "sha512-DqGhF5IKoBl8WNf8C1gu8q0xZSInh9j1kJJMqT3a94w1JzVaBU4EXOSMrz9yDqMT0xt3selp83fuFMQ0uzv6qA==", + "dev": true, + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=4.2.0" + } + }, + "node_modules/universalify": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz", + "integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==", + "dev": true, + "engines": { + "node": ">= 4.0.0" + } + }, + "node_modules/uri-js": { + "version": "4.4.1", + "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", + "integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==", + "dependencies": { + "punycode": "^2.1.0" + } + }, + "node_modules/url-params-parser": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/url-params-parser/-/url-params-parser-1.0.4.tgz", + "integrity": "sha512-0m6BqGpY2OetTZ3UPTLKkbTfUHigsX2YhrzORT9iYiyUJ/SP2WJ3cggg2YWtvMs36GPwK9Q44ffddyarniu2Tg==" + }, + "node_modules/util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", + "dev": true + }, + "node_modules/uuid": { + "version": "8.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", + "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", + "dev": true, + "bin": { + "uuid": "dist/bin/uuid" + } + }, + "node_modules/v8-compile-cache": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.3.0.tgz", + "integrity": "sha512-l8lCEmLcLYZh4nbunNZvQCJc5pv7+RCwa8q/LdUx8u7lsWvPDKmpodJAJNwkAhJC//dFY48KuIEmjtd4RViDrA==" + }, + "node_modules/validate-npm-package-license": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz", + "integrity": "sha512-DpKm2Ui/xN7/HQKCtpZxoRWBhZ9Z0kqtygG8XCgNQ8ZlDnxuQmWhj566j8fN4Cu3/JmbhsDo7fcAJq4s9h27Ew==", + "dev": true, + "dependencies": { + "spdx-correct": "^3.0.0", + "spdx-expression-parse": "^3.0.0" + } + }, + "node_modules/verror": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/verror/-/verror-1.10.0.tgz", + "integrity": "sha1-OhBcoXBTr1XW4nDB+CiGguGNpAA=", + "dev": true, + "engines": [ + "node >=0.6.0" + ], + "dependencies": { + "assert-plus": "^1.0.0", + "core-util-is": "1.0.2", + "extsprintf": "^1.2.0" + } + }, + "node_modules/verror/node_modules/core-util-is": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", + "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", + "dev": true + }, + "node_modules/vlq": { + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/vlq/-/vlq-0.2.3.tgz", + "integrity": "sha512-DRibZL6DsNhIgYQ+wNdWDL2SL3bKPlVrRiBqV5yuMm++op8W4kGFtaQfCs4KEJn0wBZcHVHJ3eoywX8983k1ow==", + "dev": true + }, + "node_modules/which": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "dependencies": { + "isexe": "^2.0.0" + }, + "bin": { + "node-which": "bin/node-which" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/which-module": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/which-module/-/which-module-2.0.0.tgz", + "integrity": "sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho=", + "dev": true + }, + "node_modules/wide-align": { + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/wide-align/-/wide-align-1.1.5.tgz", + "integrity": "sha512-eDMORYaPNZ4sQIuuYPDHdQvf4gyCF9rEEV/yPxGfwPkRodwEgiMUUXTx/dex+Me0wxx53S+NgUHaP7y3MGlDmg==", + "dev": true, + "dependencies": { + "string-width": "^1.0.2 || 2 || 3 || 4" + } + }, + "node_modules/word-wrap": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.3.tgz", + "integrity": "sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ==", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/wrap-ansi": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-5.1.0.tgz", + "integrity": "sha512-QC1/iN/2/RPVJ5jYK8BGttj5z83LmSKmvbvrXPNCLZSEb32KKVDJDl/MOt2N01qU2H/FkzEa9PKto1BqDjtd7Q==", + "dev": true, + "dependencies": { + "ansi-styles": "^3.2.0", + "string-width": "^3.0.0", + "strip-ansi": "^5.0.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/wrap-ansi/node_modules/ansi-regex": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", + "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/wrap-ansi/node_modules/ansi-styles": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "dev": true, + "dependencies": { + "color-convert": "^1.9.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/wrap-ansi/node_modules/color-convert": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", + "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", + "dev": true, + "dependencies": { + "color-name": "1.1.3" + } + }, + "node_modules/wrap-ansi/node_modules/color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=", + "dev": true + }, + "node_modules/wrap-ansi/node_modules/is-fullwidth-code-point": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", + "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", + "dev": true, + "engines": { + "node": ">=4" + } + }, + "node_modules/wrap-ansi/node_modules/string-width": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-3.1.0.tgz", + "integrity": "sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w==", + "dev": true, + "dependencies": { + "emoji-regex": "^7.0.1", + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^5.1.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/wrap-ansi/node_modules/strip-ansi": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", + "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", + "dev": true, + "dependencies": { + "ansi-regex": "^4.1.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" + }, + "node_modules/ws": { + "version": "7.5.5", + "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.5.tgz", + "integrity": "sha512-BAkMFcAzl8as1G/hArkxOxq3G7pjUqQ3gzYbLL0/5zNkph70e+lCoxBGnm6AW1+/aiNeV4fnKqZ8m4GZewmH2w==", + "dev": true, + "engines": { + "node": ">=8.3.0" + }, + "peerDependencies": { + "bufferutil": "^4.0.1", + "utf-8-validate": "^5.0.2" + }, + "peerDependenciesMeta": { + "bufferutil": { + "optional": true + }, + "utf-8-validate": { + "optional": true + } + } + }, + "node_modules/xtend": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/xtend/-/xtend-2.2.0.tgz", + "integrity": "sha1-7vax8ZjByN6vrYsXZaBNrUoBxak=", + "dev": true, + "engines": { + "node": ">=0.4" + } + }, + "node_modules/y18n": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.3.tgz", + "integrity": "sha512-JKhqTOwSrqNA1NY5lSztJ1GrBiUodLMmIZuLiDaMRJ+itFd+ABVE8XBjOvIWL+rSqNDC74LCSFmlb/U4UZ4hJQ==", + "dev": true + }, + "node_modules/yallist": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" + }, + "node_modules/yargs": { + "version": "13.3.2", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-13.3.2.tgz", + "integrity": "sha512-AX3Zw5iPruN5ie6xGRIDgqkT+ZhnRlZMLMHAs8tg7nRruy2Nb+i5o9bwghAogtM08q1dpr2LVoS8KSTMYpWXUw==", + "dev": true, + "dependencies": { + "cliui": "^5.0.0", + "find-up": "^3.0.0", + "get-caller-file": "^2.0.1", + "require-directory": "^2.1.1", + "require-main-filename": "^2.0.0", + "set-blocking": "^2.0.0", + "string-width": "^3.0.0", + "which-module": "^2.0.0", + "y18n": "^4.0.0", + "yargs-parser": "^13.1.2" + } + }, + "node_modules/yargs-parser": { + "version": "20.2.9", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-20.2.9.tgz", + "integrity": "sha512-y11nGElTIV+CT3Zv9t7VKl+Q3hTQoT9a1Qzezhhl6Rp21gJ/IVTW7Z3y9EWXhuUBC2Shnf+DX0antecpAwSP8w==", + "dev": true, + "engines": { + "node": ">=10" + } + }, + "node_modules/yargs/node_modules/ansi-regex": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", + "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/yargs/node_modules/find-up": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-3.0.0.tgz", + "integrity": "sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg==", + "dev": true, + "dependencies": { + "locate-path": "^3.0.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/yargs/node_modules/is-fullwidth-code-point": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", + "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", + "dev": true, + "engines": { + "node": ">=4" + } + }, + "node_modules/yargs/node_modules/locate-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-3.0.0.tgz", + "integrity": "sha512-7AO748wWnIhNqAuaty2ZWHkQHRSNfPVIsPIfwEOWO22AmaoVrWavlOcMR5nzTLNYvp36X220/maaRsrec1G65A==", + "dev": true, + "dependencies": { + "p-locate": "^3.0.0", + "path-exists": "^3.0.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/yargs/node_modules/p-locate": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-3.0.0.tgz", + "integrity": "sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ==", + "dev": true, + "dependencies": { + "p-limit": "^2.0.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/yargs/node_modules/path-exists": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz", + "integrity": "sha1-zg6+ql94yxiSXqfYENe1mwEP1RU=", + "dev": true, + "engines": { + "node": ">=4" + } + }, + "node_modules/yargs/node_modules/string-width": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-3.1.0.tgz", + "integrity": "sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w==", + "dev": true, + "dependencies": { + "emoji-regex": "^7.0.1", + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^5.1.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/yargs/node_modules/strip-ansi": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", + "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", + "dev": true, + "dependencies": { + "ansi-regex": "^4.1.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/yargs/node_modules/yargs-parser": { + "version": "13.1.2", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-13.1.2.tgz", + "integrity": "sha512-3lbsNRf/j+A4QuSZfDRA7HRSfWrzO0YjqTJd5kjAq37Zep1CEgaYmrH9Q3GwPiB9cHyd1Y1UwggGhJGoxipbzg==", + "dev": true, + "dependencies": { + "camelcase": "^5.0.0", + "decamelize": "^1.2.0" + } + } + }, "dependencies": { "@babel/code-frame": { "version": "7.12.11", "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.12.11.tgz", "integrity": "sha512-Zt1yodBx1UcyiePMSkWnU4hPqhwq7hGi2nFL1LeA3EUl+q2LQx16MISgJ0+z7dnmgvP9QtIleuETGOiOH1RcIw==", - "dev": true, "requires": { "@babel/highlight": "^7.10.4" } @@ -33,14 +5802,12 @@ "@babel/helper-validator-identifier": { "version": "7.15.7", "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.15.7.tgz", - "integrity": "sha512-K4JvCtQqad9OY2+yTU8w+E82ywk/fe+ELNlt1G8z3bVGlZfn/hOcQQsUhGhW/N+tb3fxK800wLtKOE/aM0m72w==", - "dev": true + "integrity": "sha512-K4JvCtQqad9OY2+yTU8w+E82ywk/fe+ELNlt1G8z3bVGlZfn/hOcQQsUhGhW/N+tb3fxK800wLtKOE/aM0m72w==" }, "@babel/highlight": { "version": "7.14.5", "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.14.5.tgz", "integrity": "sha512-qf9u2WFWVV0MppaL877j2dBtQIDgmidgjGk5VIMw3OadXvYaXn66U1BFlH2t4+t3i+8PhedppRv+i40ABzd+gg==", - "dev": true, "requires": { "@babel/helper-validator-identifier": "^7.14.5", "chalk": "^2.0.0", @@ -51,7 +5818,6 @@ "version": "3.2.1", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", - "dev": true, "requires": { "color-convert": "^1.9.0" } @@ -60,7 +5826,6 @@ "version": "2.4.2", "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", - "dev": true, "requires": { "ansi-styles": "^3.2.1", "escape-string-regexp": "^1.0.5", @@ -71,7 +5836,6 @@ "version": "1.9.3", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", - "dev": true, "requires": { "color-name": "1.1.3" } @@ -79,26 +5843,22 @@ "color-name": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", - "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=", - "dev": true + "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=" }, "escape-string-regexp": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", - "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", - "dev": true + "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=" }, "has-flag": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", - "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", - "dev": true + "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=" }, "supports-color": { "version": "5.5.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", - "dev": true, "requires": { "has-flag": "^3.0.0" } @@ -109,7 +5869,6 @@ "version": "0.4.3", "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-0.4.3.tgz", "integrity": "sha512-J6KFFz5QCYUJq3pf0mjEcCJVERbzv71PUIDczuh9JkwGEzced6CO5ADLHB1rbf/+oPBtoPfMYNOpGDzCANlbXw==", - "dev": true, "requires": { "ajv": "^6.12.4", "debug": "^4.1.1", @@ -125,8 +5884,7 @@ "ignore": { "version": "4.0.6", "resolved": "https://registry.npmjs.org/ignore/-/ignore-4.0.6.tgz", - "integrity": "sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg==", - "dev": true + "integrity": "sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg==" } } }, @@ -134,7 +5892,6 @@ "version": "0.5.0", "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.5.0.tgz", "integrity": "sha512-FagtKFz74XrTl7y6HCzQpwDfXP0yhxe9lHLD1UZxjvZIcbyRz8zTFF/yYNfSfzU414eDwZ1SrO0Qvtyf+wFMQg==", - "dev": true, "requires": { "@humanwhocodes/object-schema": "^1.2.0", "debug": "^4.1.1", @@ -144,8 +5901,7 @@ "@humanwhocodes/object-schema": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-1.2.0.tgz", - "integrity": "sha512-wdppn25U8z/2yiaT6YGquE6X8sSv7hNMWSXYSSU1jGv/yd6XqjXgTDJ8KP4NgjTXfJ3GbRjeeb8RTV7a/VpM+w==", - "dev": true + "integrity": "sha512-wdppn25U8z/2yiaT6YGquE6X8sSv7hNMWSXYSSU1jGv/yd6XqjXgTDJ8KP4NgjTXfJ3GbRjeeb8RTV7a/VpM+w==" }, "@nodelib/fs.scandir": { "version": "2.1.5", @@ -422,20 +6178,18 @@ "acorn": { "version": "7.4.1", "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.4.1.tgz", - "integrity": "sha512-nQyp0o1/mNdbTO1PO6kHkwSrmgZ0MT/jCCpNiwbUjGoRN4dlBhqJtoQuCnEOKzgTVwg0ZWiCoQy6SxMebQVh8A==", - "dev": true + "integrity": "sha512-nQyp0o1/mNdbTO1PO6kHkwSrmgZ0MT/jCCpNiwbUjGoRN4dlBhqJtoQuCnEOKzgTVwg0ZWiCoQy6SxMebQVh8A==" }, "acorn-jsx": { "version": "5.3.2", "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.2.tgz", "integrity": "sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==", - "dev": true + "requires": {} }, "ajv": { "version": "6.12.6", "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", - "dev": true, "requires": { "fast-deep-equal": "^3.1.1", "fast-json-stable-stringify": "^2.0.0", @@ -452,20 +6206,17 @@ "ansi-colors": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.1.tgz", - "integrity": "sha512-JoX0apGbHaUJBNl6yF+p6JAFYZ666/hhCGKN5t9QFjbJQKUU/g8MNbFDbvfrgKXvI1QpZplPOnwIo99lX/AAmA==", - "dev": true + "integrity": "sha512-JoX0apGbHaUJBNl6yF+p6JAFYZ666/hhCGKN5t9QFjbJQKUU/g8MNbFDbvfrgKXvI1QpZplPOnwIo99lX/AAmA==" }, "ansi-regex": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", - "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", - "dev": true + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==" }, "ansi-styles": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dev": true, "requires": { "color-convert": "^2.0.1" } @@ -500,7 +6251,6 @@ "version": "1.0.10", "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", - "dev": true, "requires": { "sprintf-js": "~1.0.2" } @@ -555,8 +6305,7 @@ "astral-regex": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/astral-regex/-/astral-regex-2.0.0.tgz", - "integrity": "sha512-Z7tMw1ytTXt5jqMcOP+OQteU1VuNK9Y02uuJtKQ1Sv69jXQKKg5cibLwGJow8yzZP+eAc18EmLGPal0bp36rvQ==", - "dev": true + "integrity": "sha512-Z7tMw1ytTXt5jqMcOP+OQteU1VuNK9Y02uuJtKQ1Sv69jXQKKg5cibLwGJow8yzZP+eAc18EmLGPal0bp36rvQ==" }, "async-foreach": { "version": "0.1.3", @@ -585,8 +6334,7 @@ "balanced-match": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", - "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", - "dev": true + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==" }, "base64-js": { "version": "1.5.1", @@ -674,7 +6422,6 @@ "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", - "dev": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -822,8 +6569,7 @@ "callsites": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz", - "integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==", - "dev": true + "integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==" }, "camelcase": { "version": "5.3.1", @@ -852,7 +6598,6 @@ "version": "4.1.2", "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", - "dev": true, "requires": { "ansi-styles": "^4.1.0", "supports-color": "^7.1.0" @@ -951,7 +6696,6 @@ "version": "2.0.1", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dev": true, "requires": { "color-name": "~1.1.4" } @@ -959,8 +6703,7 @@ "color-name": { "version": "1.1.4", "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" }, "combined-stream": { "version": "1.0.8", @@ -986,8 +6729,7 @@ "concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", - "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", - "dev": true + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" }, "concat-stream": { "version": "1.6.2", @@ -1074,7 +6816,6 @@ "version": "7.0.3", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", - "dev": true, "requires": { "path-key": "^3.1.0", "shebang-command": "^2.0.0", @@ -1113,7 +6854,6 @@ "version": "4.3.2", "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.2.tgz", "integrity": "sha512-mOp8wKcvj7XxC78zLgw/ZA+6TSgkoE2C/ienthhRD298T7UNwAg9diBpLRxC0mOezLl4B0xV7M0cCO6P/O0Xhw==", - "dev": true, "requires": { "ms": "2.1.2" } @@ -1145,8 +6885,7 @@ "deep-is": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.4.tgz", - "integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==", - "dev": true + "integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==" }, "deepmerge": { "version": "4.2.2", @@ -1223,7 +6962,6 @@ "version": "3.0.0", "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-3.0.0.tgz", "integrity": "sha512-yS+Q5i3hBf7GBkd4KG8a7eBNNWNGLTaEwwYWUijIYM7zrlYDM0BFXHjjPWlWZ1Rg7UaddZeIDmi9jF3HmqiQ2w==", - "dev": true, "requires": { "esutils": "^2.0.2" } @@ -1271,7 +7009,6 @@ "version": "2.3.6", "resolved": "https://registry.npmjs.org/enquirer/-/enquirer-2.3.6.tgz", "integrity": "sha512-yjNnPr315/FjS4zIsUxYguYUPP2e1NK4d7E7ZOLiyYCcbFBiTMyID+2wvm2w6+pZ/odMA7cRkjhsPbltwBOrLg==", - "dev": true, "requires": { "ansi-colors": "^4.1.1" } @@ -1309,14 +7046,12 @@ "escape-string-regexp": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", - "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", - "dev": true + "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==" }, "eslint": { "version": "7.32.0", "resolved": "https://registry.npmjs.org/eslint/-/eslint-7.32.0.tgz", "integrity": "sha512-VHZ8gX+EDfz+97jGcgyGCyRia/dPOd6Xh9yPv8Bl1+SoaIwD+a/vlrOmGRUyOYu7MwUhc7CxqeaDZU13S4+EpA==", - "dev": true, "requires": { "@babel/code-frame": "7.12.11", "@eslint/eslintrc": "^0.4.3", @@ -1364,7 +7099,6 @@ "version": "2.1.0", "resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-2.1.0.tgz", "integrity": "sha512-w94dQYoauyvlDc43XnGB8lU3Zt713vNChgt4EWwhXAP2XkBvndfxF0AgIqKOOasjPIPzj9JqgwkwbCYD0/V3Zg==", - "dev": true, "requires": { "eslint-visitor-keys": "^1.1.0" }, @@ -1372,16 +7106,14 @@ "eslint-visitor-keys": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-1.3.0.tgz", - "integrity": "sha512-6J72N8UNa462wa/KFODt/PJ3IU60SDpC3QXC1Hjc1BXXpfL2C9R5+AU7jhe0F6GREqVMh4Juu+NY7xn+6dipUQ==", - "dev": true + "integrity": "sha512-6J72N8UNa462wa/KFODt/PJ3IU60SDpC3QXC1Hjc1BXXpfL2C9R5+AU7jhe0F6GREqVMh4Juu+NY7xn+6dipUQ==" } } }, "ignore": { "version": "4.0.6", "resolved": "https://registry.npmjs.org/ignore/-/ignore-4.0.6.tgz", - "integrity": "sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg==", - "dev": true + "integrity": "sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg==" } } }, @@ -1398,7 +7130,8 @@ "version": "3.2.1", "resolved": "https://registry.npmjs.org/eslint-plugin-svelte3/-/eslint-plugin-svelte3-3.2.1.tgz", "integrity": "sha512-YoBR9mLoKCjGghJ/gvpnFZKaMEu/VRcuxpSRS8KuozuEo7CdBH7bmBHa6FmMm0i4kJnOyx+PVsaptz96K6H/4Q==", - "dev": true + "dev": true, + "requires": {} }, "eslint-scope": { "version": "5.1.1", @@ -1434,7 +7167,6 @@ "version": "7.3.1", "resolved": "https://registry.npmjs.org/espree/-/espree-7.3.1.tgz", "integrity": "sha512-v3JCNCE64umkFpmkFGqzVKsOT0tN1Zr+ueqLZfpV1Ob8e+CEgPWa+OxCoGH3tnhimMKIaBm4m/vaRpJ/krRz2g==", - "dev": true, "requires": { "acorn": "^7.4.0", "acorn-jsx": "^5.3.1", @@ -1444,22 +7176,19 @@ "eslint-visitor-keys": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-1.3.0.tgz", - "integrity": "sha512-6J72N8UNa462wa/KFODt/PJ3IU60SDpC3QXC1Hjc1BXXpfL2C9R5+AU7jhe0F6GREqVMh4Juu+NY7xn+6dipUQ==", - "dev": true + "integrity": "sha512-6J72N8UNa462wa/KFODt/PJ3IU60SDpC3QXC1Hjc1BXXpfL2C9R5+AU7jhe0F6GREqVMh4Juu+NY7xn+6dipUQ==" } } }, "esprima": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", - "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", - "dev": true + "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==" }, "esquery": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.4.0.tgz", "integrity": "sha512-cCDispWt5vHHtwMY2YrAQ4ibFkAL8RbH5YGBnZBc90MolvvfkkQcJro/aZiAQUlQ3qgrYS6D6v8Gc5G5CQsc9w==", - "dev": true, "requires": { "estraverse": "^5.1.0" }, @@ -1467,8 +7196,7 @@ "estraverse": { "version": "5.3.0", "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz", - "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==", - "dev": true + "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==" } } }, @@ -1501,8 +7229,7 @@ "esutils": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", - "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==", - "dev": true + "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==" }, "evp_bytestokey": { "version": "1.0.3", @@ -1529,8 +7256,7 @@ "fast-deep-equal": { "version": "3.1.3", "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", - "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", - "dev": true + "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==" }, "fast-glob": { "version": "3.2.7", @@ -1548,14 +7274,12 @@ "fast-json-stable-stringify": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", - "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==", - "dev": true + "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==" }, "fast-levenshtein": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", - "integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=", - "dev": true + "integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=" }, "fastq": { "version": "1.13.0", @@ -1570,7 +7294,6 @@ "version": "6.0.1", "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-6.0.1.tgz", "integrity": "sha512-7Gps/XWymbLk2QLYK4NzpMOrYjMhdIxXuIvy2QBsLE6ljuodKvdkWs/cpyJJ3CVIVpH0Oi1Hvg1ovbMzLdFBBg==", - "dev": true, "requires": { "flat-cache": "^3.0.4" } @@ -1609,7 +7332,6 @@ "version": "3.0.4", "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-3.0.4.tgz", "integrity": "sha512-dm9s5Pw7Jc0GvMYbshN6zchCA9RgQlzzEZX3vylR9IqFfS8XciblUXOKfW6SiuJ0e13eDYZoZV5wdrev7P3Nwg==", - "dev": true, "requires": { "flatted": "^3.1.0", "rimraf": "^3.0.2" @@ -1618,8 +7340,7 @@ "flatted": { "version": "3.2.2", "resolved": "https://registry.npmjs.org/flatted/-/flatted-3.2.2.tgz", - "integrity": "sha512-JaTY/wtrcSyvXJl4IMFHPKyFur1sE9AUqc0QnhOaJ0CxHtAoIV8pYDzeEfAaNEtGkOfq4gr3LBFmdXW5mOQFnA==", - "dev": true + "integrity": "sha512-JaTY/wtrcSyvXJl4IMFHPKyFur1sE9AUqc0QnhOaJ0CxHtAoIV8pYDzeEfAaNEtGkOfq4gr3LBFmdXW5mOQFnA==" }, "foreach": { "version": "2.0.5", @@ -1667,8 +7388,7 @@ "fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", - "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", - "dev": true + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" }, "fsevents": { "version": "2.3.2", @@ -1686,8 +7406,7 @@ "functional-red-black-tree": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz", - "integrity": "sha1-GwqzvVU7Kg1jmdKcDj6gslIHgyc=", - "dev": true + "integrity": "sha1-GwqzvVU7Kg1jmdKcDj6gslIHgyc=" }, "fwd-stream": { "version": "1.0.4", @@ -1797,7 +7516,6 @@ "version": "7.2.0", "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.0.tgz", "integrity": "sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q==", - "dev": true, "requires": { "fs.realpath": "^1.0.0", "inflight": "^1.0.4", @@ -1811,7 +7529,6 @@ "version": "5.1.2", "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", - "dev": true, "requires": { "is-glob": "^4.0.1" } @@ -1820,7 +7537,6 @@ "version": "13.12.0", "resolved": "https://registry.npmjs.org/globals/-/globals-13.12.0.tgz", "integrity": "sha512-uS8X6lSKN2JumVoXrbUz+uG4BYG+eiawqm3qFcT7ammfbUHeCBoJMlHcec/S3krSk73/AE/f0szYFmgAA3kYZg==", - "dev": true, "requires": { "type-fest": "^0.20.2" } @@ -1923,8 +7639,7 @@ "has-flag": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "dev": true + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==" }, "has-unicode": { "version": "2.0.1", @@ -2025,7 +7740,6 @@ "version": "3.3.0", "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.0.tgz", "integrity": "sha512-veYYhQa+D1QBKznvhUHxb8faxlrwUnxseDAbAp457E0wLNio2bOSKnjYDhMj+YiAq61xrMGhQk9iXVk5FzgQMw==", - "dev": true, "requires": { "parent-module": "^1.0.0", "resolve-from": "^4.0.0" @@ -2034,8 +7748,7 @@ "imurmurhash": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", - "integrity": "sha1-khi5srkoojixPcT7a21XbyMUU+o=", - "dev": true + "integrity": "sha1-khi5srkoojixPcT7a21XbyMUU+o=" }, "indent-string": { "version": "4.0.0", @@ -2053,7 +7766,6 @@ "version": "1.0.6", "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", - "dev": true, "requires": { "once": "^1.3.0", "wrappy": "1" @@ -2062,8 +7774,7 @@ "inherits": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", - "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", - "dev": true + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" }, "is": { "version": "0.2.7", @@ -2098,8 +7809,7 @@ "is-extglob": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", - "integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=", - "dev": true + "integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=" }, "is-fullwidth-code-point": { "version": "1.0.0", @@ -2114,7 +7824,6 @@ "version": "4.0.3", "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", - "dev": true, "requires": { "is-extglob": "^2.1.1" } @@ -2179,8 +7888,7 @@ "isexe": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", - "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=", - "dev": true + "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=" }, "isstream": { "version": "0.1.2", @@ -2208,14 +7916,12 @@ "js-tokens": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", - "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", - "dev": true + "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==" }, "js-yaml": { "version": "3.14.1", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz", "integrity": "sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==", - "dev": true, "requires": { "argparse": "^1.0.7", "esprima": "^4.0.0" @@ -2234,22 +7940,20 @@ "dev": true }, "json-schema": { - "version": "0.2.3", - "resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.2.3.tgz", - "integrity": "sha1-tIDIkuWaLwWVTOcnvT8qTogvnhM=", + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.4.0.tgz", + "integrity": "sha512-es94M3nTIfsEPisRafak+HDLfHXnKBhV3vU5eqPcS3flIWqcxJWgXHXiey3YrpaNsanY5ei1VoYEbOzijuq9BA==", "dev": true }, "json-schema-traverse": { "version": "0.4.1", "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", - "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", - "dev": true + "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==" }, "json-stable-stringify-without-jsonify": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz", - "integrity": "sha1-nbe1lJatPzz+8wp1FC0tkwrXJlE=", - "dev": true + "integrity": "sha1-nbe1lJatPzz+8wp1FC0tkwrXJlE=" }, "json-stringify-safe": { "version": "5.0.1", @@ -2267,14 +7971,14 @@ } }, "jsprim": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.1.tgz", - "integrity": "sha1-MT5mvB5cwG5Di8G3SZwuXFastqI=", + "version": "1.4.2", + "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.2.tgz", + "integrity": "sha512-P2bSOMAc/ciLz6DzgjVlGJP9+BrJWu5UDGK70C2iweC5QBIeFf0ZXRvGjEj2uYgrY2MkAAhsSWHDWlFtEroZWw==", "dev": true, "requires": { "assert-plus": "1.0.0", "extsprintf": "1.3.0", - "json-schema": "0.2.3", + "json-schema": "0.4.0", "verror": "1.10.0" } }, @@ -2500,7 +8204,6 @@ "version": "0.4.1", "resolved": "https://registry.npmjs.org/levn/-/levn-0.4.1.tgz", "integrity": "sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==", - "dev": true, "requires": { "prelude-ls": "^1.2.1", "type-check": "~0.4.0" @@ -2554,20 +8257,17 @@ "lodash.clonedeep": { "version": "4.5.0", "resolved": "https://registry.npmjs.org/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz", - "integrity": "sha1-4j8/nE+Pvd6HJSnBBxhXoIblzO8=", - "dev": true + "integrity": "sha1-4j8/nE+Pvd6HJSnBBxhXoIblzO8=" }, "lodash.merge": { "version": "4.6.2", "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz", - "integrity": "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==", - "dev": true + "integrity": "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==" }, "lodash.truncate": { "version": "4.4.2", "resolved": "https://registry.npmjs.org/lodash.truncate/-/lodash.truncate-4.4.2.tgz", - "integrity": "sha1-WjUNoLERO4N+z//VgSy+WNbq4ZM=", - "dev": true + "integrity": "sha1-WjUNoLERO4N+z//VgSy+WNbq4ZM=" }, "lottie-web": { "version": "5.7.14", @@ -2578,7 +8278,6 @@ "version": "6.0.0", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", - "dev": true, "requires": { "yallist": "^4.0.0" } @@ -2743,7 +8442,6 @@ "version": "3.0.4", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", - "dev": true, "requires": { "brace-expansion": "^1.1.7" } @@ -2802,8 +8500,7 @@ "ms": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", - "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", - "dev": true + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" }, "nan": { "version": "2.15.0", @@ -2820,8 +8517,7 @@ "natural-compare": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", - "integrity": "sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=", - "dev": true + "integrity": "sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=" }, "node-gyp": { "version": "7.1.2", @@ -2991,7 +8687,6 @@ "version": "1.4.0", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", - "dev": true, "requires": { "wrappy": "1" } @@ -3000,7 +8695,6 @@ "version": "0.9.1", "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.1.tgz", "integrity": "sha512-74RlY5FCnhq4jRxVUPKDaRwrVNXMqsGsiW6AJw4XK8hmtm10wC0ypZBLw5IIp85NZMr91+qd1RvvENwg7jjRFw==", - "dev": true, "requires": { "deep-is": "^0.1.3", "fast-levenshtein": "^2.0.6", @@ -3044,7 +8738,6 @@ "version": "1.0.1", "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", "integrity": "sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==", - "dev": true, "requires": { "callsites": "^3.0.0" } @@ -3083,14 +8776,12 @@ "path-is-absolute": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", - "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", - "dev": true + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=" }, "path-key": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", - "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", - "dev": true + "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==" }, "path-parse": { "version": "1.0.7", @@ -3141,8 +8832,7 @@ "prelude-ls": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz", - "integrity": "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==", - "dev": true + "integrity": "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==" }, "prettier": { "version": "2.4.1", @@ -3165,8 +8855,7 @@ "progress": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/progress/-/progress-2.0.3.tgz", - "integrity": "sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA==", - "dev": true + "integrity": "sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA==" }, "prr": { "version": "1.0.1", @@ -3205,8 +8894,7 @@ "punycode": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz", - "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==", - "dev": true + "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==" }, "qs": { "version": "6.5.2", @@ -3355,8 +9043,7 @@ "regexpp": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/regexpp/-/regexpp-3.2.0.tgz", - "integrity": "sha512-pq2bWo9mVD43nbts2wGv17XLiNLya+GklZ8kaDLV2Z08gDCsGpnKn9BFMepvWuHCbyVvY7J5o5+BVvoQbmlJLg==", - "dev": true + "integrity": "sha512-pq2bWo9mVD43nbts2wGv17XLiNLya+GklZ8kaDLV2Z08gDCsGpnKn9BFMepvWuHCbyVvY7J5o5+BVvoQbmlJLg==" }, "request": { "version": "2.88.2", @@ -3403,8 +9090,7 @@ "require-from-string": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/require-from-string/-/require-from-string-2.0.2.tgz", - "integrity": "sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==", - "dev": true + "integrity": "sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==" }, "require-main-filename": { "version": "2.0.0", @@ -3431,8 +9117,7 @@ "resolve-from": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz", - "integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==", - "dev": true + "integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==" }, "ret": { "version": "0.1.15", @@ -3450,7 +9135,6 @@ "version": "3.0.2", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", "integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==", - "dev": true, "requires": { "glob": "^7.1.3" } @@ -3610,7 +9294,8 @@ "version": "1.6.1", "resolved": "https://registry.npmjs.org/rollup-plugin-web-worker-loader/-/rollup-plugin-web-worker-loader-1.6.1.tgz", "integrity": "sha512-4QywQSz1NXFHKdyiou16mH3ijpcfLtLGOrAqvAqu1Gx+P8+zj+3gwC2BSL/VW1d+LW4nIHC8F7d7OXhs9UdR2A==", - "dev": true + "dev": true, + "requires": {} }, "rollup-pluginutils": { "version": "2.8.2", @@ -3723,7 +9408,6 @@ "version": "7.3.5", "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.5.tgz", "integrity": "sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ==", - "dev": true, "requires": { "lru-cache": "^6.0.0" } @@ -3757,7 +9441,6 @@ "version": "2.0.0", "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", - "dev": true, "requires": { "shebang-regex": "^3.0.0" } @@ -3765,8 +9448,7 @@ "shebang-regex": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", - "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", - "dev": true + "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==" }, "signal-exit": { "version": "3.0.5", @@ -3811,7 +9493,6 @@ "version": "4.0.0", "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-4.0.0.tgz", "integrity": "sha512-qMCMfhY040cVHT43K9BFygqYbUPFZKHOg7K73mtTWJRb8pyP3fzf4Ixd5SzdEJQ6MRUg/WBnOLxghZtKKurENQ==", - "dev": true, "requires": { "ansi-styles": "^4.0.0", "astral-regex": "^2.0.0", @@ -3821,8 +9502,7 @@ "is-fullwidth-code-point": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", - "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", - "dev": true + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==" } } }, @@ -3906,8 +9586,7 @@ "sprintf-js": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", - "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", - "dev": true + "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=" }, "sshpk": { "version": "1.16.1", @@ -3943,6 +9622,15 @@ "readable-stream": "^2.0.1" } }, + "string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "dev": true, + "requires": { + "safe-buffer": "~5.1.0" + } + }, "string-range": { "version": "1.2.2", "resolved": "https://registry.npmjs.org/string-range/-/string-range-1.2.2.tgz", @@ -3977,20 +9665,10 @@ } } }, - "string_decoder": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", - "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", - "dev": true, - "requires": { - "safe-buffer": "~5.1.0" - } - }, "strip-ansi": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", - "dev": true, "requires": { "ansi-regex": "^5.0.1" } @@ -4007,14 +9685,12 @@ "strip-json-comments": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", - "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==", - "dev": true + "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==" }, "supports-color": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "dev": true, "requires": { "has-flag": "^4.0.0" } @@ -4022,8 +9698,7 @@ "svelte": { "version": "3.44.0", "resolved": "https://registry.npmjs.org/svelte/-/svelte-3.44.0.tgz", - "integrity": "sha512-zWACSJBSncGiDvFfYOMFGNV5zDLOlyhftmO5yOZ0lEtQMptpElaRtl39MWz1+lYCpwUq4F3Q2lTzI9TrTL+eMA==", - "dev": true + "integrity": "sha512-zWACSJBSncGiDvFfYOMFGNV5zDLOlyhftmO5yOZ0lEtQMptpElaRtl39MWz1+lYCpwUq4F3Q2lTzI9TrTL+eMA==" }, "svelte-check": { "version": "2.2.7", @@ -4076,7 +9751,6 @@ "version": "6.7.2", "resolved": "https://registry.npmjs.org/table/-/table-6.7.2.tgz", "integrity": "sha512-UFZK67uvyNivLeQbVtkiUs8Uuuxv24aSL4/Vil2PJVtMgU8Lx0CYkP12uCGa3kjyQzOSgV1+z9Wkb82fCGsO0g==", - "dev": true, "requires": { "ajv": "^8.0.1", "lodash.clonedeep": "^4.5.0", @@ -4090,7 +9764,6 @@ "version": "8.6.3", "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.6.3.tgz", "integrity": "sha512-SMJOdDP6LqTkD0Uq8qLi+gMwSt0imXLSV080qFVwJCpH9U6Mb+SUGHAXM0KNbcBPguytWyvFxcHgMLe2D2XSpw==", - "dev": true, "requires": { "fast-deep-equal": "^3.1.1", "json-schema-traverse": "^1.0.0", @@ -4101,26 +9774,22 @@ "emoji-regex": { "version": "8.0.0", "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", - "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", - "dev": true + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==" }, "is-fullwidth-code-point": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", - "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", - "dev": true + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==" }, "json-schema-traverse": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz", - "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==", - "dev": true + "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==" }, "string-width": { "version": "4.2.3", "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", - "dev": true, "requires": { "emoji-regex": "^8.0.0", "is-fullwidth-code-point": "^3.0.0", @@ -4173,8 +9842,7 @@ "text-table": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", - "integrity": "sha1-f17oI66AUgfACvLfSoTsP8+lcLQ=", - "dev": true + "integrity": "sha1-f17oI66AUgfACvLfSoTsP8+lcLQ=" }, "threads": { "version": "1.7.0", @@ -4245,6 +9913,11 @@ "glob": "^7.1.2" } }, + "tslib": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.3.1.tgz", + "integrity": "sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw==" + }, "tsutils": { "version": "3.21.0", "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-3.21.0.tgz", @@ -4281,7 +9954,6 @@ "version": "0.4.0", "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz", "integrity": "sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==", - "dev": true, "requires": { "prelude-ls": "^1.2.1" } @@ -4289,8 +9961,7 @@ "type-fest": { "version": "0.20.2", "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.20.2.tgz", - "integrity": "sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==", - "dev": true + "integrity": "sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==" }, "typedarray": { "version": "0.0.6", @@ -4320,7 +9991,6 @@ "version": "4.4.1", "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", "integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==", - "dev": true, "requires": { "punycode": "^2.1.0" } @@ -4345,8 +10015,7 @@ "v8-compile-cache": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.3.0.tgz", - "integrity": "sha512-l8lCEmLcLYZh4nbunNZvQCJc5pv7+RCwa8q/LdUx8u7lsWvPDKmpodJAJNwkAhJC//dFY48KuIEmjtd4RViDrA==", - "dev": true + "integrity": "sha512-l8lCEmLcLYZh4nbunNZvQCJc5pv7+RCwa8q/LdUx8u7lsWvPDKmpodJAJNwkAhJC//dFY48KuIEmjtd4RViDrA==" }, "validate-npm-package-license": { "version": "3.0.4", @@ -4387,7 +10056,6 @@ "version": "2.0.2", "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", - "dev": true, "requires": { "isexe": "^2.0.0" } @@ -4410,8 +10078,7 @@ "word-wrap": { "version": "1.2.3", "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.3.tgz", - "integrity": "sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ==", - "dev": true + "integrity": "sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ==" }, "wrap-ansi": { "version": "5.1.0", @@ -4485,14 +10152,14 @@ "wrappy": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", - "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", - "dev": true + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" }, "ws": { "version": "7.5.5", "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.5.tgz", "integrity": "sha512-BAkMFcAzl8as1G/hArkxOxq3G7pjUqQ3gzYbLL0/5zNkph70e+lCoxBGnm6AW1+/aiNeV4fnKqZ8m4GZewmH2w==", - "dev": true + "dev": true, + "requires": {} }, "xtend": { "version": "2.2.0", @@ -4509,8 +10176,7 @@ "yallist": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", - "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", - "dev": true + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" }, "yargs": { "version": "13.3.2", diff --git a/contracts/wasm/fairroulette/frontend/package.json b/contracts/wasm/fairroulette/frontend/package.json index 3ea890b88c..60f9d89948 100644 --- a/contracts/wasm/fairroulette/frontend/package.json +++ b/contracts/wasm/fairroulette/frontend/package.json @@ -49,6 +49,7 @@ "dependencies": { "@babel/eslint-parser": "^7.15.8", "lottie-web": "^5.7.13", - "svelte-router-spa": "^6.0.2" + "svelte-router-spa": "^6.0.2", + "tslib": "^2.3.1" } } diff --git a/contracts/wasm/fairroulette/frontend/waypoint.hcl b/contracts/wasm/fairroulette/frontend/waypoint.hcl index 5a8b4635f0..3aebf200dd 100644 --- a/contracts/wasm/fairroulette/frontend/waypoint.hcl +++ b/contracts/wasm/fairroulette/frontend/waypoint.hcl @@ -18,7 +18,6 @@ variable "goshimmer_url" { variable "chainid" { type = string - default = "mjNp2do4hTL5pnW5Fo8z6ncoSCB3543MEwTgGuVy9tsS" } variable "adminWhitelist" { @@ -36,7 +35,7 @@ variable "ghcr" { # An application to deploy. app "fairroulette" { # Build specifies how an application should be deployed. In this case, - # we'll build using a Dockerfile and keeping it in a local registry. + # we'll build using a Dockerfile and keeping it in a github registry. build { use "docker" { disable_entrypoint = true diff --git a/go.mod b/go.mod index b34c5c63e6..1eab4fdde9 100644 --- a/go.mod +++ b/go.mod @@ -24,7 +24,7 @@ require ( github.com/pangpanglabs/echoswagger/v2 v2.1.0 github.com/pkg/errors v0.9.1 github.com/prometheus/client_golang v1.10.0 - github.com/second-state/WasmEdge-go v0.9.0 // indirect + github.com/second-state/WasmEdge-go v0.9.0 github.com/spf13/cobra v1.1.3 github.com/spf13/pflag v1.0.5 github.com/spf13/viper v1.7.0 diff --git a/go.sum b/go.sum index bccf796c22..2b7ccbbff9 100644 --- a/go.sum +++ b/go.sum @@ -151,10 +151,6 @@ github.com/btcsuite/winsvc v1.0.0/go.mod h1:jsenWakMcC0zFBFurPLEAyrnc/teJEM1O46f github.com/buger/jsonparser v0.0.0-20181115193947-bf1c66bbce23/go.mod h1:bbYlZJ7hK1yFx9hf58LP0zeX7UjIGs20ufpu3evjr+s= github.com/bygui86/multi-profile/v2 v2.1.0 h1:x/jPqeL/6hJqLXoDI/H5zLPsSFbDR6IEbrBbFpkWQdw= github.com/bygui86/multi-profile/v2 v2.1.0/go.mod h1:f4qCZiQo1nnJdwbPoADUtdDXg3hhnpfgZ9iq3/kW4BA= -github.com/bytecodealliance/wasmtime-go v0.21.0 h1:8C6fNmpfzF6QQ9h0PCvGaYORhtgMvANCumafDPDmBSU= -github.com/bytecodealliance/wasmtime-go v0.21.0/go.mod h1:q320gUxqyI8yB+ZqRuaJOEnGkAnHh6WtJjMaT2CW4wI= -github.com/bytecodealliance/wasmtime-go v0.31.0 h1:AbMdV1pwjw/0Ito5yARcGzY366cq5NIiDk5vpy1c2Lw= -github.com/bytecodealliance/wasmtime-go v0.31.0/go.mod h1:q320gUxqyI8yB+ZqRuaJOEnGkAnHh6WtJjMaT2CW4wI= github.com/bytecodealliance/wasmtime-go v0.32.0 h1:/GsrnJz2bfULAIZygN4vUElLYliQrx/o/1opP9X7Gck= github.com/bytecodealliance/wasmtime-go v0.32.0/go.mod h1:q320gUxqyI8yB+ZqRuaJOEnGkAnHh6WtJjMaT2CW4wI= github.com/c-bata/go-prompt v0.2.2/go.mod h1:VzqtzE2ksDBcdln8G7mk2RX9QyGjH+OVqOCSiVIqS34= @@ -578,8 +574,6 @@ github.com/influxdata/promql/v2 v2.12.0/go.mod h1:fxOPu+DY0bqCTCECchSRtWfc+0X19y github.com/influxdata/roaring v0.4.13-0.20180809181101-fc520f41fab6/go.mod h1:bSgUQ7q5ZLSO+bKBGqJiCBGAl+9DxyW63zLTujjUlOE= github.com/influxdata/tdigest v0.0.0-20181121200506-bf2b5ad3c0a9/go.mod h1:Js0mqiSBE6Ffsg94weZZ2c+v/ciT8QRHFOap7EKDrR0= github.com/influxdata/usage-client v0.0.0-20160829180054-6d3895376368/go.mod h1:Wbbw6tYNvwa5dlB6304Sd+82Z3f7PmVZHVKU637d4po= -github.com/iotaledger/goshimmer v0.7.5-0.20210811162925-25c827e8326a h1:JKIoZ7yxR8b0cLJY/vyKRj2lnEHlYCRkTvMz5V8OZfc= -github.com/iotaledger/goshimmer v0.7.5-0.20210811162925-25c827e8326a/go.mod h1:L4a9tQOOlD37go7UztwlCFMrNlmgwKK9ixaPf45A/8U= github.com/iotaledger/hive.go v0.0.0-20210625103722-68b2cf52ef4e h1:jUHV5HGa/1o9qoPPr8ms3dMueSVUb1ZB2Z1XyJ79qfU= github.com/iotaledger/hive.go v0.0.0-20210625103722-68b2cf52ef4e/go.mod h1:NyBg/Ny7FFAdDs59zdwTVoysU2ZbJVQnRwyLIDFKJYA= github.com/ipfs/go-cid v0.0.1/go.mod h1:GHWU/WuQdMPmIosc4Yn1bcCT7dSeX4lBafM7iqUPQvM= @@ -1294,10 +1288,6 @@ github.com/sasha-s/go-deadlock v0.2.0 h1:lMqc+fUb7RrFS3gQLtoQsJ7/6TV/pAIFvBsqX73 github.com/sasha-s/go-deadlock v0.2.0/go.mod h1:StQn567HiB1fF2yJ44N9au7wOhrPS3iZqiDbRupzT10= github.com/sclevine/agouti v3.0.0+incompatible/go.mod h1:b4WX9W9L1sfQKXeJf1mUTLZKJ48R1S7H23Ji7oFO5Bw= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= -github.com/second-state/WasmEdge-go v0.8.2 h1:dD5+ZKY9Vr+Ye5F9VZGP/WP2MnXfORQocUxXQvXUVE0= -github.com/second-state/WasmEdge-go v0.8.2/go.mod h1:Q3h79fwQs7GUSOm3ZzHXK+j4cKmCFP3SKpGfFNDtqD8= -github.com/second-state/WasmEdge-go v0.9.0-rc3 h1:Ol6KaPguuqyd42vb9W7VCRR4V92yZdVpqUh0MWD07Y4= -github.com/second-state/WasmEdge-go v0.9.0-rc3/go.mod h1:Q3h79fwQs7GUSOm3ZzHXK+j4cKmCFP3SKpGfFNDtqD8= github.com/second-state/WasmEdge-go v0.9.0 h1:CapdsNNP5HG8nIeX8qmRteie8SZC/+BkmNXq+IoQlKE= github.com/second-state/WasmEdge-go v0.9.0/go.mod h1:Q3h79fwQs7GUSOm3ZzHXK+j4cKmCFP3SKpGfFNDtqD8= github.com/segmentio/kafka-go v0.1.0/go.mod h1:X6itGqS9L4jDletMsxZ7Dz+JFWxM6JHfPOCvTvk+EJo= diff --git a/packages/wasp/constants.go b/packages/wasp/constants.go index 265409ec52..78fd382de9 100644 --- a/packages/wasp/constants.go +++ b/packages/wasp/constants.go @@ -4,7 +4,7 @@ var VersionHash string const ( // Version version number - Version = "0.2.3" + Version = "0.2.4" // Name app code name Name = "Wasp" diff --git a/tools/evm-server/wasp-evm.nomad.tpl b/tools/evm-server/wasp-evm.nomad.tpl index f1cd533e3f..eee1ecd7bb 100644 --- a/tools/evm-server/wasp-evm.nomad.tpl +++ b/tools/evm-server/wasp-evm.nomad.tpl @@ -68,7 +68,8 @@ job "iscp-evm-server" { "evm", "jsonrpc", "-d", - "--chainid=1074", + "--chainid", + "1074", "-l=0.0.0.0:$${NOMAD_PORT_evm}", ] ports = [ diff --git a/tools/evm-server/waypoint.hcl b/tools/evm-server/waypoint.hcl index 581a9c3700..92f46fc9e8 100644 --- a/tools/evm-server/waypoint.hcl +++ b/tools/evm-server/waypoint.hcl @@ -8,7 +8,6 @@ labels = { "team" = "iscp" } variable "chainid" { type = string - default = "oBrnaPHdo2J6bV4oebfbExCoLtbSrU6fRwaHLtAo4akh" } variable "wallet_seed" { diff --git a/wasp.nomad.tpl b/wasp.nomad.tpl index e2f91e3f4e..ce5e714312 100644 --- a/wasp.nomad.tpl +++ b/wasp.nomad.tpl @@ -43,8 +43,11 @@ variable "wasp_config" { "port": {{ env "NOMAD_PORT_peering" }}, "netid": "{{ env "NOMAD_ADDR_peering" }}" }, + "profiling":{ + "enabled": true + }, "nodeconn": { - "address": "{{ range service "goshimmer-leader-node" }}{{ if in .Tags "txstream" }}{{ .Address }}:{{ .Port }}{{end}}{{end}}" + "address": "goshimmer.sc.iota.org:5000" }, "nanomsg":{ "port": {{ env "NOMAD_PORT_nanomsg" }} @@ -74,7 +77,7 @@ job "iscp-evm" { sticky = true } - count = 5 + count = 0 network { mode = "host" @@ -179,7 +182,7 @@ job "iscp-evm" { sticky = true } - count = 3 + count = 1 network { mode = "host" diff --git a/waypoint.hcl b/waypoint.hcl index 058fa712e9..0872ebfb6f 100644 --- a/waypoint.hcl +++ b/waypoint.hcl @@ -28,7 +28,6 @@ app "wasp-evm" { buildkit = true dockerfile = "./Dockerfile" build_args = { - GOLANG_IMAGE_TAG = "1.17-buster" BUILD_TAGS = "rocksdb,builtin_static" BUILD_LD_FLAGS = "-X github.com/iotaledger/wasp/packages/wasp.VersionHash=${gitrefhash()}" } @@ -37,7 +36,7 @@ app "wasp-evm" { registry { use "docker" { image = "ghcr.io/luke-thorne/wasp" - tag = gitrefpretty() + tag = gitrefhash() encoded_auth = base64encode(jsonencode(var.ghcr)) } } From 20f19438b90098f8705a4fee8d522e47ea30dfbd Mon Sep 17 00:00:00 2001 From: HowJMay Date: Wed, 2 Feb 2022 18:14:23 +0800 Subject: [PATCH 058/111] chore: Support Apple M1 On M1 Apple Silicon, replacing wasmtime-go with a local libray help us support the macOS arm64 machines. --- .../docs/guide/chains_and_nodes/running-a-node.md | 10 ++++++++++ documentation/temp/misc/runwasp.md | 12 ++++++++++++ 2 files changed, 22 insertions(+) diff --git a/documentation/docs/guide/chains_and_nodes/running-a-node.md b/documentation/docs/guide/chains_and_nodes/running-a-node.md index 71f89d6936..5765ff3024 100644 --- a/documentation/docs/guide/chains_and_nodes/running-a-node.md +++ b/documentation/docs/guide/chains_and_nodes/running-a-node.md @@ -64,6 +64,16 @@ You can build and install both `wasp` and `wasp-cli` by running: make install ``` +### macOS arm64 (M1 Apple Silicon) + +[`wasmtime-go`](https://github.com/bytecodealliance/wasmtime-go) hasn't supported macOS on arm64 yet, so you should build your own wasmtime library. You can follow the README in `wasmtime-go` to build the library. +Once a wasmtime library is built, then you can run the following commands. + +```bash +go mod edit -replace=github.com/bytecodealliance/wasmtime-go= +make install +``` + ### Microsoft Windows ```bash diff --git a/documentation/temp/misc/runwasp.md b/documentation/temp/misc/runwasp.md index 7f2aa995ce..d96282cce2 100644 --- a/documentation/temp/misc/runwasp.md +++ b/documentation/temp/misc/runwasp.md @@ -15,6 +15,18 @@ $ cd wasp $ make install ``` +### macOS arm64 (M1 Apple Silicon) + +[`wasmtime-go`](https://github.com/bytecodealliance/wasmtime-go) hasn't supported macOS on arm64 yet, so you should build your own wasmtime library. You can follow the README in `wasmtime-go` to build the library. +Once a wasmtime library is built, then you can run the following commands. + +```bash +$ git clone https://github.com/iotaledger/wasp.git +$ cd wasp +$ go mod edit -replace=github.com/bytecodealliance/wasmtime-go= +$ make install +``` + ## Step 2: Run Goshimmer ### Option 1: follow the official docs From c8c9f0748e69e79fcacdf52b802a4b68a9c52ea2 Mon Sep 17 00:00:00 2001 From: Eric Hop Date: Thu, 3 Feb 2022 16:53:36 -0800 Subject: [PATCH 059/111] Rust refactor complete, passes all tests --- contracts/wasm/dividend/go/dividend/keys.go | 8 - contracts/wasm/dividend/src/contract.rs | 37 +- contracts/wasm/dividend/src/dividend.rs | 9 +- contracts/wasm/dividend/src/keys.rs | 46 --- contracts/wasm/dividend/src/lib.rs | 71 +--- contracts/wasm/dividend/src/params.rs | 55 ++- contracts/wasm/dividend/src/results.rs | 27 +- contracts/wasm/dividend/src/state.rs | 70 ++-- contracts/wasm/dividend/test/dividend_bg.wasm | Bin 32319 -> 55972 bytes contracts/wasm/dividend/ts/dividend/keys.ts | 11 - .../go/donatewithfeedback/keys.go | 8 - .../wasm/donatewithfeedback/src/contract.rs | 29 +- .../src/donatewithfeedback.rs | 2 +- contracts/wasm/donatewithfeedback/src/keys.rs | 56 --- contracts/wasm/donatewithfeedback/src/lib.rs | 52 +-- .../wasm/donatewithfeedback/src/params.rs | 40 +- .../wasm/donatewithfeedback/src/results.rs | 52 ++- .../wasm/donatewithfeedback/src/state.rs | 53 +-- .../wasm/donatewithfeedback/src/structs.rs | 49 ++- .../test/donatewithfeedback_bg.wasm | Bin 36830 -> 59227 bytes .../ts/donatewithfeedback/keys.ts | 11 - contracts/wasm/erc20/go/erc20/keys.go | 8 - contracts/wasm/erc20/src/contract.rs | 50 +-- contracts/wasm/erc20/src/events.rs | 21 +- contracts/wasm/erc20/src/keys.rs | 50 --- contracts/wasm/erc20/src/lib.rs | 77 +--- contracts/wasm/erc20/src/params.rs | 100 +++-- contracts/wasm/erc20/src/results.rs | 40 +- contracts/wasm/erc20/src/state.rs | 45 +-- contracts/wasm/erc20/src/typedefs.rs | 15 +- contracts/wasm/erc20/test/erc20_bg.wasm | Bin 35709 -> 52476 bytes contracts/wasm/erc20/ts/erc20/keys.ts | 14 - contracts/wasm/erc721/go/erc721/keys.go | 8 - contracts/wasm/erc721/src/contract.rs | 101 ++--- contracts/wasm/erc721/src/erc721.rs | 28 +- contracts/wasm/erc721/src/events.rs | 49 +-- contracts/wasm/erc721/src/keys.rs | 78 ---- contracts/wasm/erc721/src/lib.rs | 149 ++----- contracts/wasm/erc721/src/params.rs | 188 +++++---- contracts/wasm/erc721/src/results.rs | 88 ++-- contracts/wasm/erc721/src/state.rs | 109 +++-- contracts/wasm/erc721/src/typedefs.rs | 15 +- contracts/wasm/erc721/test/erc721_bg.wasm | Bin 40124 -> 68915 bytes contracts/wasm/erc721/ts/erc721/keys.ts | 19 - .../wasm/fairauction/go/fairauction/keys.go | 8 - contracts/wasm/fairauction/src/contract.rs | 35 +- contracts/wasm/fairauction/src/fairauction.rs | 2 +- contracts/wasm/fairauction/src/keys.rs | 70 ---- contracts/wasm/fairauction/src/lib.rs | 64 +-- contracts/wasm/fairauction/src/params.rs | 77 ++-- contracts/wasm/fairauction/src/results.rs | 61 ++- contracts/wasm/fairauction/src/state.rs | 82 ++-- contracts/wasm/fairauction/src/structs.rs | 113 +++--- contracts/wasm/fairauction/src/typedefs.rs | 39 +- .../wasm/fairauction/test/fairauction_bg.wasm | Bin 43101 -> 71620 bytes .../wasm/fairauction/ts/fairauction/keys.ts | 13 - .../wasm/fairroulette/go/fairroulette/keys.go | 8 - contracts/wasm/fairroulette/src/contract.rs | 44 +- contracts/wasm/fairroulette/src/events.rs | 37 +- .../wasm/fairroulette/src/fairroulette.rs | 14 +- contracts/wasm/fairroulette/src/keys.rs | 52 --- contracts/wasm/fairroulette/src/lib.rs | 98 ++--- contracts/wasm/fairroulette/src/params.rs | 28 +- contracts/wasm/fairroulette/src/results.rs | 52 ++- contracts/wasm/fairroulette/src/state.rs | 65 +-- contracts/wasm/fairroulette/src/structs.rs | 41 +- .../fairroulette/test/fairroulette_bg.wasm | Bin 41128 -> 75201 bytes .../ts/fairroulette/fairroulette.ts | 13 +- .../wasm/fairroulette/ts/fairroulette/keys.ts | 10 - .../wasm/helloworld/go/helloworld/keys.go | 8 - contracts/wasm/helloworld/src/contract.rs | 10 +- contracts/wasm/helloworld/src/keys.rs | 30 -- contracts/wasm/helloworld/src/lib.rs | 22 +- contracts/wasm/helloworld/src/results.rs | 15 +- contracts/wasm/helloworld/src/state.rs | 10 +- .../wasm/helloworld/test/helloworld_bg.wasm | Bin 15385 -> 37435 bytes .../wasm/helloworld/ts/helloworld/keys.ts | 8 - .../inccounter/go/inccounter/inccounter.go | 14 +- .../wasm/inccounter/go/inccounter/keys.go | 8 - contracts/wasm/inccounter/src/contract.rs | 70 ++-- contracts/wasm/inccounter/src/inccounter.rs | 60 +-- contracts/wasm/inccounter/src/keys.rs | 58 --- contracts/wasm/inccounter/src/lib.rs | 116 ++---- contracts/wasm/inccounter/src/params.rs | 75 ++-- contracts/wasm/inccounter/src/results.rs | 63 ++- contracts/wasm/inccounter/src/state.rs | 20 +- .../wasm/inccounter/test/inccounter_bg.wasm | Bin 42161 -> 62649 bytes .../inccounter/ts/inccounter/inccounter.ts | 18 +- .../wasm/inccounter/ts/inccounter/keys.ts | 14 - contracts/wasm/testcore/go/testcore/keys.go | 8 - contracts/wasm/testcore/src/contract.rs | 161 ++++---- contracts/wasm/testcore/src/keys.rs | 98 ----- contracts/wasm/testcore/src/lib.rs | 251 ++++-------- contracts/wasm/testcore/src/params.rs | 303 +++++++------- contracts/wasm/testcore/src/results.rs | 155 ++++--- contracts/wasm/testcore/src/state.rs | 34 +- contracts/wasm/testcore/src/testcore.rs | 23 +- contracts/wasm/testcore/test/testcore_bg.wasm | Bin 53986 -> 84539 bytes contracts/wasm/testcore/test/testcore_test.go | 18 +- contracts/wasm/testcore/ts/testcore/keys.ts | 30 -- .../wasm/testwasmlib/go/testwasmlib/keys.go | 8 - contracts/wasm/testwasmlib/src/contract.rs | 103 ++--- contracts/wasm/testwasmlib/src/events.rs | 9 +- contracts/wasm/testwasmlib/src/keys.rs | 96 ----- contracts/wasm/testwasmlib/src/lib.rs | 153 ++----- contracts/wasm/testwasmlib/src/params.rs | 270 ++++++------- contracts/wasm/testwasmlib/src/results.rs | 88 ++-- contracts/wasm/testwasmlib/src/state.rs | 61 ++- contracts/wasm/testwasmlib/src/testwasmlib.rs | 24 +- contracts/wasm/testwasmlib/src/typedefs.rs | 39 +- .../wasm/testwasmlib/test/testwasmlib_bg.wasm | Bin 44657 -> 83586 bytes .../wasm/testwasmlib/ts/testwasmlib/keys.ts | 33 -- contracts/wasm/timestamp/go/timestamp/keys.go | 8 - contracts/wasm/timestamp/src/contract.rs | 10 +- contracts/wasm/timestamp/src/keys.rs | 32 -- contracts/wasm/timestamp/src/lib.rs | 22 +- contracts/wasm/timestamp/src/results.rs | 15 +- contracts/wasm/timestamp/src/state.rs | 16 +- .../wasm/timestamp/test/timestamp_bg.wasm | Bin 28202 -> 38927 bytes contracts/wasm/timestamp/ts/timestamp/keys.ts | 8 - .../tokenregistry/go/tokenregistry/keys.go | 8 - contracts/wasm/tokenregistry/src/contract.rs | 26 +- contracts/wasm/tokenregistry/src/keys.rs | 38 -- contracts/wasm/tokenregistry/src/lib.rs | 50 +-- contracts/wasm/tokenregistry/src/params.rs | 56 ++- contracts/wasm/tokenregistry/src/state.rs | 63 ++- contracts/wasm/tokenregistry/src/structs.rs | 57 ++- .../wasm/tokenregistry/src/tokenregistry.rs | 6 +- .../tokenregistry/test/tokenregistry_bg.wasm | Bin 32055 -> 54414 bytes .../tokenregistry/ts/tokenregistry/keys.ts | 11 - documentation/tutorial-examples/src/lib.rs | 26 +- .../test/example_tutorial_bg.wasm | Bin 16813 -> 51609 bytes .../sbtests/sbtestsc/testcore_bg.wasm | Bin 53986 -> 84539 bytes packages/wasmvm/wasmlib/go/wasmlib/events.go | 4 +- .../wasmlib/go/wasmlib/wasmtypes/scchainid.go | 4 +- .../go/wasmlib/wasmtypes/screquestid.go | 2 +- packages/wasmvm/wasmlib/src/assets.rs | 123 ++++++ packages/wasmvm/wasmlib/src/context.rs | 379 +----------------- packages/wasmvm/wasmlib/src/contract.rs | 119 +++--- .../wasmlib/src/coreaccounts/contract.rs | 46 +-- .../wasmvm/wasmlib/src/coreaccounts/params.rs | 55 ++- .../wasmlib/src/coreaccounts/results.rs | 79 ++-- .../wasmvm/wasmlib/src/coreblob/contract.rs | 35 +- .../wasmvm/wasmlib/src/coreblob/params.rs | 57 ++- .../wasmvm/wasmlib/src/coreblob/results.rs | 79 ++-- .../wasmlib/src/coreblocklog/contract.rs | 86 ++-- .../wasmvm/wasmlib/src/coreblocklog/params.rs | 107 +++-- .../wasmlib/src/coreblocklog/results.rs | 201 +++++----- .../wasmlib/src/coregovernance/contract.rs | 73 ++-- .../wasmlib/src/coregovernance/params.rs | 135 ++++--- .../wasmlib/src/coregovernance/results.rs | 117 +++--- .../wasmvm/wasmlib/src/coreroot/contract.rs | 35 +- .../wasmvm/wasmlib/src/coreroot/params.rs | 59 ++- .../wasmvm/wasmlib/src/coreroot/results.rs | 47 +-- packages/wasmvm/wasmlib/src/dict.rs | 104 ++++- packages/wasmvm/wasmlib/src/events.rs | 104 +---- packages/wasmvm/wasmlib/src/exports.rs | 2 +- packages/wasmvm/wasmlib/src/lib.rs | 34 +- packages/wasmvm/wasmlib/src/sandbox.rs | 263 +++++++++--- packages/wasmvm/wasmlib/src/sandboxutils.rs | 92 +++-- packages/wasmvm/wasmlib/src/state.rs | 37 -- .../wasmlib/src/wasmrequests/contract.rs | 2 - .../wasmlib/src/wasmrequests/structs.rs | 177 ++++---- .../wasmvm/wasmlib/src/wasmtypes/proxy.rs | 50 +-- .../wasmvm/wasmlib/src/wasmtypes/scaddress.rs | 31 +- .../wasmvm/wasmlib/src/wasmtypes/scagentid.rs | 42 +- .../wasmvm/wasmlib/src/wasmtypes/scbool.rs | 21 +- .../wasmvm/wasmlib/src/wasmtypes/scbytes.rs | 18 +- .../wasmvm/wasmlib/src/wasmtypes/scchainid.rs | 43 +- .../wasmvm/wasmlib/src/wasmtypes/sccolor.rs | 28 +- .../wasmvm/wasmlib/src/wasmtypes/schash.rs | 26 +- .../wasmvm/wasmlib/src/wasmtypes/schname.rs | 41 +- .../wasmvm/wasmlib/src/wasmtypes/scint16.rs | 23 +- .../wasmvm/wasmlib/src/wasmtypes/scint32.rs | 23 +- .../wasmvm/wasmlib/src/wasmtypes/scint64.rs | 23 +- .../wasmvm/wasmlib/src/wasmtypes/scint8.rs | 19 +- .../wasmlib/src/wasmtypes/screquestid.rs | 42 +- .../wasmvm/wasmlib/src/wasmtypes/scstring.rs | 20 +- .../wasmvm/wasmlib/src/wasmtypes/scuint16.rs | 23 +- .../wasmvm/wasmlib/src/wasmtypes/scuint32.rs | 23 +- .../wasmvm/wasmlib/src/wasmtypes/scuint64.rs | 23 +- .../wasmvm/wasmlib/src/wasmtypes/scuint8.rs | 19 +- packages/wasmvm/wasmlib/ts/wasmlib/assets.ts | 1 - packages/wasmvm/wasmlib/ts/wasmlib/events.ts | 7 +- packages/wasmvm/wasmlib/ts/wasmlib/sandbox.ts | 6 +- .../wasmlib/ts/wasmlib/wasmtypes/scchainid.ts | 4 +- .../ts/wasmlib/wasmtypes/screquestid.ts | 2 +- tools/cluster/tests/wasm/inccounter_bg.wasm | Bin 42161 -> 62649 bytes tools/schema/generator/generator.go | 4 - .../generator/gotemplates/alltemplates.go | 1 - tools/schema/generator/gotemplates/events.go | 2 +- tools/schema/generator/gotemplates/keys.go | 8 - .../generator/rstemplates/alltemplates.go | 67 +--- .../schema/generator/rstemplates/contract.go | 23 +- tools/schema/generator/rstemplates/events.go | 17 +- tools/schema/generator/rstemplates/funcs.go | 2 +- tools/schema/generator/rstemplates/keys.go | 48 --- tools/schema/generator/rstemplates/lib.go | 37 +- tools/schema/generator/rstemplates/params.go | 18 +- tools/schema/generator/rstemplates/proxy.go | 24 +- tools/schema/generator/rstemplates/results.go | 18 +- tools/schema/generator/rstemplates/state.go | 10 +- tools/schema/generator/rstemplates/structs.go | 26 +- .../schema/generator/rstemplates/typedefs.go | 73 ++-- .../generator/tstemplates/alltemplates.go | 1 - tools/schema/generator/tstemplates/events.go | 2 +- tools/schema/generator/tstemplates/keys.go | 13 - 207 files changed, 3842 insertions(+), 5767 deletions(-) delete mode 100644 contracts/wasm/dividend/go/dividend/keys.go delete mode 100644 contracts/wasm/dividend/src/keys.rs delete mode 100644 contracts/wasm/dividend/ts/dividend/keys.ts delete mode 100644 contracts/wasm/donatewithfeedback/go/donatewithfeedback/keys.go delete mode 100644 contracts/wasm/donatewithfeedback/src/keys.rs delete mode 100644 contracts/wasm/donatewithfeedback/ts/donatewithfeedback/keys.ts delete mode 100644 contracts/wasm/erc20/go/erc20/keys.go delete mode 100644 contracts/wasm/erc20/src/keys.rs delete mode 100644 contracts/wasm/erc20/ts/erc20/keys.ts delete mode 100644 contracts/wasm/erc721/go/erc721/keys.go delete mode 100644 contracts/wasm/erc721/src/keys.rs delete mode 100644 contracts/wasm/erc721/ts/erc721/keys.ts delete mode 100644 contracts/wasm/fairauction/go/fairauction/keys.go delete mode 100644 contracts/wasm/fairauction/src/keys.rs delete mode 100644 contracts/wasm/fairauction/ts/fairauction/keys.ts delete mode 100644 contracts/wasm/fairroulette/go/fairroulette/keys.go delete mode 100644 contracts/wasm/fairroulette/src/keys.rs delete mode 100644 contracts/wasm/fairroulette/ts/fairroulette/keys.ts delete mode 100644 contracts/wasm/helloworld/go/helloworld/keys.go delete mode 100644 contracts/wasm/helloworld/src/keys.rs delete mode 100644 contracts/wasm/helloworld/ts/helloworld/keys.ts delete mode 100644 contracts/wasm/inccounter/go/inccounter/keys.go delete mode 100644 contracts/wasm/inccounter/src/keys.rs delete mode 100644 contracts/wasm/inccounter/ts/inccounter/keys.ts delete mode 100644 contracts/wasm/testcore/go/testcore/keys.go delete mode 100644 contracts/wasm/testcore/src/keys.rs delete mode 100644 contracts/wasm/testcore/ts/testcore/keys.ts delete mode 100644 contracts/wasm/testwasmlib/go/testwasmlib/keys.go delete mode 100644 contracts/wasm/testwasmlib/src/keys.rs delete mode 100644 contracts/wasm/testwasmlib/ts/testwasmlib/keys.ts delete mode 100644 contracts/wasm/timestamp/go/timestamp/keys.go delete mode 100644 contracts/wasm/timestamp/src/keys.rs delete mode 100644 contracts/wasm/timestamp/ts/timestamp/keys.ts delete mode 100644 contracts/wasm/tokenregistry/go/tokenregistry/keys.go delete mode 100644 contracts/wasm/tokenregistry/src/keys.rs delete mode 100644 contracts/wasm/tokenregistry/ts/tokenregistry/keys.ts create mode 100644 packages/wasmvm/wasmlib/src/assets.rs delete mode 100644 packages/wasmvm/wasmlib/src/state.rs delete mode 100644 tools/schema/generator/gotemplates/keys.go delete mode 100644 tools/schema/generator/rstemplates/keys.go delete mode 100644 tools/schema/generator/tstemplates/keys.go diff --git a/contracts/wasm/dividend/go/dividend/keys.go b/contracts/wasm/dividend/go/dividend/keys.go deleted file mode 100644 index 708a8a2be6..0000000000 --- a/contracts/wasm/dividend/go/dividend/keys.go +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright 2020 IOTA Stiftung -// SPDX-License-Identifier: Apache-2.0 - -// (Re-)generated by schema tool -// >>>> DO NOT CHANGE THIS FILE! <<<< -// Change the json schema instead - -package dividend diff --git a/contracts/wasm/dividend/src/contract.rs b/contracts/wasm/dividend/src/contract.rs index 794ea5c465..6ff7e103c7 100644 --- a/contracts/wasm/dividend/src/contract.rs +++ b/contracts/wasm/dividend/src/contract.rs @@ -7,8 +7,6 @@ #![allow(dead_code)] -use std::ptr; - use wasmlib::*; use crate::consts::*; @@ -49,55 +47,56 @@ pub struct ScFuncs { } impl ScFuncs { - pub fn divide(_ctx: & dyn ScFuncCallContext) -> DivideCall { + pub fn divide(_ctx: &dyn ScFuncCallContext) -> DivideCall { DivideCall { func: ScFunc::new(HSC_NAME, HFUNC_DIVIDE), } } - pub fn init(_ctx: & dyn ScFuncCallContext) -> InitCall { + pub fn init(_ctx: &dyn ScFuncCallContext) -> InitCall { let mut f = InitCall { func: ScInitFunc::new(HSC_NAME, HFUNC_INIT), - params: MutableInitParams { id: 0 }, + params: MutableInitParams { proxy: Proxy::nil() }, }; - f.func.set_ptrs(&mut f.params.id, ptr::null_mut()); + ScInitFunc::link_params(&mut f.params.proxy, &f.func); f } - pub fn member(_ctx: & dyn ScFuncCallContext) -> MemberCall { + pub fn member(_ctx: &dyn ScFuncCallContext) -> MemberCall { let mut f = MemberCall { func: ScFunc::new(HSC_NAME, HFUNC_MEMBER), - params: MutableMemberParams { id: 0 }, + params: MutableMemberParams { proxy: Proxy::nil() }, }; - f.func.set_ptrs(&mut f.params.id, ptr::null_mut()); + ScFunc::link_params(&mut f.params.proxy, &f.func); f } - pub fn set_owner(_ctx: & dyn ScFuncCallContext) -> SetOwnerCall { + pub fn set_owner(_ctx: &dyn ScFuncCallContext) -> SetOwnerCall { let mut f = SetOwnerCall { func: ScFunc::new(HSC_NAME, HFUNC_SET_OWNER), - params: MutableSetOwnerParams { id: 0 }, + params: MutableSetOwnerParams { proxy: Proxy::nil() }, }; - f.func.set_ptrs(&mut f.params.id, ptr::null_mut()); + ScFunc::link_params(&mut f.params.proxy, &f.func); f } - pub fn get_factor(_ctx: & dyn ScViewCallContext) -> GetFactorCall { + pub fn get_factor(_ctx: &dyn ScViewCallContext) -> GetFactorCall { let mut f = GetFactorCall { func: ScView::new(HSC_NAME, HVIEW_GET_FACTOR), - params: MutableGetFactorParams { id: 0 }, - results: ImmutableGetFactorResults { id: 0 }, + params: MutableGetFactorParams { proxy: Proxy::nil() }, + results: ImmutableGetFactorResults { proxy: Proxy::nil() }, }; - f.func.set_ptrs(&mut f.params.id, &mut f.results.id); + ScView::link_params(&mut f.params.proxy, &f.func); + ScView::link_results(&mut f.results.proxy, &f.func); f } - pub fn get_owner(_ctx: & dyn ScViewCallContext) -> GetOwnerCall { + pub fn get_owner(_ctx: &dyn ScViewCallContext) -> GetOwnerCall { let mut f = GetOwnerCall { func: ScView::new(HSC_NAME, HVIEW_GET_OWNER), - results: ImmutableGetOwnerResults { id: 0 }, + results: ImmutableGetOwnerResults { proxy: Proxy::nil() }, }; - f.func.set_ptrs(ptr::null_mut(), &mut f.results.id); + ScView::link_results(&mut f.results.proxy, &f.func); f } } diff --git a/contracts/wasm/dividend/src/dividend.rs b/contracts/wasm/dividend/src/dividend.rs index 8154f0334c..595609d1f5 100644 --- a/contracts/wasm/dividend/src/dividend.rs +++ b/contracts/wasm/dividend/src/dividend.rs @@ -90,12 +90,9 @@ pub fn func_member(_ctx: &ScFuncContext, f: &MemberContext) { let member_list: ArrayOfMutableAddress = f.state.member_list(); // Now we will append the new address to the memberList array. - // First we determine the current length of the array. - let length: u32 = member_list.length(); - - // Next we create an ScMutableAddress proxy to the address value that lives - // at that index in the memberList array (no value, since we're appending). - let new_address: ScMutableAddress = member_list.get_address(length); + // We create an ScMutableAddress proxy to an address value that lives + // at the end of the memberList array (no value yet, since we're appending). + let new_address: ScMutableAddress = member_list.append_address(); // And finally we append the new address to the array by telling the proxy // to update the value it refers to with the 'address' parameter. diff --git a/contracts/wasm/dividend/src/keys.rs b/contracts/wasm/dividend/src/keys.rs deleted file mode 100644 index f15d21bcd6..0000000000 --- a/contracts/wasm/dividend/src/keys.rs +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright 2020 IOTA Stiftung -// SPDX-License-Identifier: Apache-2.0 - -// (Re-)generated by schema tool -// >>>> DO NOT CHANGE THIS FILE! <<<< -// Change the json schema instead - -#![allow(dead_code)] - -use wasmlib::*; - -use crate::*; - -pub(crate) const IDX_PARAM_ADDRESS : usize = 0; -pub(crate) const IDX_PARAM_FACTOR : usize = 1; -pub(crate) const IDX_PARAM_OWNER : usize = 2; - -pub(crate) const IDX_RESULT_FACTOR : usize = 3; -pub(crate) const IDX_RESULT_OWNER : usize = 4; - -pub(crate) const IDX_STATE_MEMBER_LIST : usize = 5; -pub(crate) const IDX_STATE_MEMBERS : usize = 6; -pub(crate) const IDX_STATE_OWNER : usize = 7; -pub(crate) const IDX_STATE_TOTAL_FACTOR : usize = 8; - -pub const KEY_MAP_LEN: usize = 9; - -pub const KEY_MAP: [&str; KEY_MAP_LEN] = [ - PARAM_ADDRESS, - PARAM_FACTOR, - PARAM_OWNER, - RESULT_FACTOR, - RESULT_OWNER, - STATE_MEMBER_LIST, - STATE_MEMBERS, - STATE_OWNER, - STATE_TOTAL_FACTOR, -]; - -pub static mut IDX_MAP: [Key32; KEY_MAP_LEN] = [Key32(0); KEY_MAP_LEN]; - -pub fn idx_map(idx: usize) -> Key32 { - unsafe { - IDX_MAP[idx] - } -} diff --git a/contracts/wasm/dividend/src/lib.rs b/contracts/wasm/dividend/src/lib.rs index 58f053d384..c31c49e88c 100644 --- a/contracts/wasm/dividend/src/lib.rs +++ b/contracts/wasm/dividend/src/lib.rs @@ -10,17 +10,14 @@ use dividend::*; use wasmlib::*; -use wasmlib::host::*; use crate::consts::*; -use crate::keys::*; use crate::params::*; use crate::results::*; use crate::state::*; mod consts; mod contract; -mod keys; mod params; mod results; mod state; @@ -35,12 +32,6 @@ fn on_load() { exports.add_func(FUNC_SET_OWNER, func_set_owner_thunk); exports.add_view(VIEW_GET_FACTOR, view_get_factor_thunk); exports.add_view(VIEW_GET_OWNER, view_get_owner_thunk); - - unsafe { - for i in 0..KEY_MAP_LEN { - IDX_MAP[i] = get_key_id_from_string(KEY_MAP[i]); - } - } } pub struct DivideContext { @@ -50,9 +41,7 @@ pub struct DivideContext { fn func_divide_thunk(ctx: &ScFuncContext) { ctx.log("dividend.funcDivide"); let f = DivideContext { - state: MutableDividendState { - id: OBJ_ID_STATE, - }, + state: MutableDividendState { proxy: state_proxy() }, }; func_divide(ctx, &f); ctx.log("dividend.funcDivide ok"); @@ -66,12 +55,8 @@ pub struct InitContext { fn func_init_thunk(ctx: &ScFuncContext) { ctx.log("dividend.funcInit"); let f = InitContext { - params: ImmutableInitParams { - id: OBJ_ID_PARAMS, - }, - state: MutableDividendState { - id: OBJ_ID_STATE, - }, + params: ImmutableInitParams { proxy: params_proxy() }, + state: MutableDividendState { proxy: state_proxy() }, }; func_init(ctx, &f); ctx.log("dividend.funcInit ok"); @@ -84,20 +69,16 @@ pub struct MemberContext { fn func_member_thunk(ctx: &ScFuncContext) { ctx.log("dividend.funcMember"); + let f = MemberContext { + params: ImmutableMemberParams { proxy: params_proxy() }, + state: MutableDividendState { proxy: state_proxy() }, + }; // only defined owner of contract can add members - let access = ctx.state().get_agent_id("owner"); + let access = f.state.owner(); ctx.require(access.exists(), "access not set: owner"); ctx.require(ctx.caller() == access.value(), "no permission"); - let f = MemberContext { - params: ImmutableMemberParams { - id: OBJ_ID_PARAMS, - }, - state: MutableDividendState { - id: OBJ_ID_STATE, - }, - }; ctx.require(f.params.address().exists(), "missing mandatory address"); ctx.require(f.params.factor().exists(), "missing mandatory factor"); func_member(ctx, &f); @@ -111,20 +92,16 @@ pub struct SetOwnerContext { fn func_set_owner_thunk(ctx: &ScFuncContext) { ctx.log("dividend.funcSetOwner"); + let f = SetOwnerContext { + params: ImmutableSetOwnerParams { proxy: params_proxy() }, + state: MutableDividendState { proxy: state_proxy() }, + }; // only defined owner of contract can change owner - let access = ctx.state().get_agent_id("owner"); + let access = f.state.owner(); ctx.require(access.exists(), "access not set: owner"); ctx.require(ctx.caller() == access.value(), "no permission"); - let f = SetOwnerContext { - params: ImmutableSetOwnerParams { - id: OBJ_ID_PARAMS, - }, - state: MutableDividendState { - id: OBJ_ID_STATE, - }, - }; ctx.require(f.params.owner().exists(), "missing mandatory owner"); func_set_owner(ctx, &f); ctx.log("dividend.funcSetOwner ok"); @@ -139,18 +116,13 @@ pub struct GetFactorContext { fn view_get_factor_thunk(ctx: &ScViewContext) { ctx.log("dividend.viewGetFactor"); let f = GetFactorContext { - params: ImmutableGetFactorParams { - id: OBJ_ID_PARAMS, - }, - results: MutableGetFactorResults { - id: OBJ_ID_RESULTS, - }, - state: ImmutableDividendState { - id: OBJ_ID_STATE, - }, + params: ImmutableGetFactorParams { proxy: params_proxy() }, + results: MutableGetFactorResults { proxy: results_proxy() }, + state: ImmutableDividendState { proxy: state_proxy() }, }; ctx.require(f.params.address().exists(), "missing mandatory address"); view_get_factor(ctx, &f); + ctx.results(&f.results.proxy.kv_store); ctx.log("dividend.viewGetFactor ok"); } @@ -162,13 +134,10 @@ pub struct GetOwnerContext { fn view_get_owner_thunk(ctx: &ScViewContext) { ctx.log("dividend.viewGetOwner"); let f = GetOwnerContext { - results: MutableGetOwnerResults { - id: OBJ_ID_RESULTS, - }, - state: ImmutableDividendState { - id: OBJ_ID_STATE, - }, + results: MutableGetOwnerResults { proxy: results_proxy() }, + state: ImmutableDividendState { proxy: state_proxy() }, }; view_get_owner(ctx, &f); + ctx.results(&f.results.proxy.kv_store); ctx.log("dividend.viewGetOwner ok"); } diff --git a/contracts/wasm/dividend/src/params.rs b/contracts/wasm/dividend/src/params.rs index 513767bdbc..616425efe4 100644 --- a/contracts/wasm/dividend/src/params.rs +++ b/contracts/wasm/dividend/src/params.rs @@ -9,103 +9,100 @@ #![allow(unused_imports)] use wasmlib::*; -use wasmlib::host::*; - use crate::*; -use crate::keys::*; -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableInitParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableInitParams { pub fn owner(&self) -> ScImmutableAgentID { - ScImmutableAgentID::new(self.id, idx_map(IDX_PARAM_OWNER)) + ScImmutableAgentID::new(self.proxy.root(PARAM_OWNER)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableInitParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableInitParams { pub fn owner(&self) -> ScMutableAgentID { - ScMutableAgentID::new(self.id, idx_map(IDX_PARAM_OWNER)) + ScMutableAgentID::new(self.proxy.root(PARAM_OWNER)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableMemberParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableMemberParams { pub fn address(&self) -> ScImmutableAddress { - ScImmutableAddress::new(self.id, PARAM_ADDRESS.get_key_id()) + ScImmutableAddress::new(self.proxy.root(PARAM_ADDRESS)) } pub fn factor(&self) -> ScImmutableUint64 { - ScImmutableUint64::new(self.id, PARAM_FACTOR.get_key_id()) + ScImmutableUint64::new(self.proxy.root(PARAM_FACTOR)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableMemberParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableMemberParams { pub fn address(&self) -> ScMutableAddress { - ScMutableAddress::new(self.id, PARAM_ADDRESS.get_key_id()) + ScMutableAddress::new(self.proxy.root(PARAM_ADDRESS)) } pub fn factor(&self) -> ScMutableUint64 { - ScMutableUint64::new(self.id, PARAM_FACTOR.get_key_id()) + ScMutableUint64::new(self.proxy.root(PARAM_FACTOR)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableSetOwnerParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableSetOwnerParams { pub fn owner(&self) -> ScImmutableAgentID { - ScImmutableAgentID::new(self.id, PARAM_OWNER.get_key_id()) + ScImmutableAgentID::new(self.proxy.root(PARAM_OWNER)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableSetOwnerParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableSetOwnerParams { pub fn owner(&self) -> ScMutableAgentID { - ScMutableAgentID::new(self.id, PARAM_OWNER.get_key_id()) + ScMutableAgentID::new(self.proxy.root(PARAM_OWNER)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableGetFactorParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableGetFactorParams { pub fn address(&self) -> ScImmutableAddress { - ScImmutableAddress::new(self.id, PARAM_ADDRESS.get_key_id()) + ScImmutableAddress::new(self.proxy.root(PARAM_ADDRESS)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableGetFactorParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableGetFactorParams { pub fn address(&self) -> ScMutableAddress { - ScMutableAddress::new(self.id, PARAM_ADDRESS.get_key_id()) + ScMutableAddress::new(self.proxy.root(PARAM_ADDRESS)) } } diff --git a/contracts/wasm/dividend/src/results.rs b/contracts/wasm/dividend/src/results.rs index 433d9451a3..c380d19b56 100644 --- a/contracts/wasm/dividend/src/results.rs +++ b/contracts/wasm/dividend/src/results.rs @@ -9,51 +9,48 @@ #![allow(unused_imports)] use wasmlib::*; -use wasmlib::host::*; - use crate::*; -use crate::keys::*; -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableGetFactorResults { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableGetFactorResults { pub fn factor(&self) -> ScImmutableUint64 { - ScImmutableUint64::new(self.id, RESULT_FACTOR.get_key_id()) + ScImmutableUint64::new(self.proxy.root(RESULT_FACTOR)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableGetFactorResults { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableGetFactorResults { pub fn factor(&self) -> ScMutableUint64 { - ScMutableUint64::new(self.id, RESULT_FACTOR.get_key_id()) + ScMutableUint64::new(self.proxy.root(RESULT_FACTOR)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableGetOwnerResults { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableGetOwnerResults { pub fn owner(&self) -> ScImmutableAgentID { - ScImmutableAgentID::new(self.id, RESULT_OWNER.get_key_id()) + ScImmutableAgentID::new(self.proxy.root(RESULT_OWNER)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableGetOwnerResults { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableGetOwnerResults { pub fn owner(&self) -> ScMutableAgentID { - ScMutableAgentID::new(self.id, RESULT_OWNER.get_key_id()) + ScMutableAgentID::new(self.proxy.root(RESULT_OWNER)) } } diff --git a/contracts/wasm/dividend/src/state.rs b/contracts/wasm/dividend/src/state.rs index edc7818dbc..0618671e5b 100644 --- a/contracts/wasm/dividend/src/state.rs +++ b/contracts/wasm/dividend/src/state.rs @@ -9,121 +9,119 @@ #![allow(unused_imports)] use wasmlib::*; -use wasmlib::host::*; use crate::*; -use crate::keys::*; -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ArrayOfImmutableAddress { - pub(crate) obj_id: i32, + pub(crate) proxy: Proxy, } impl ArrayOfImmutableAddress { pub fn length(&self) -> u32 { - get_length(self.obj_id) + self.proxy.length() } pub fn get_address(&self, index: u32) -> ScImmutableAddress { - ScImmutableAddress::new(self.obj_id, Key32(index as i32)) + ScImmutableAddress::new(self.proxy.index(index)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MapAddressToImmutableUint64 { - pub(crate) obj_id: i32, + pub(crate) proxy: Proxy, } impl MapAddressToImmutableUint64 { pub fn get_uint64(&self, key: &ScAddress) -> ScImmutableUint64 { - ScImmutableUint64::new(self.obj_id, key.get_key_id()) + ScImmutableUint64::new(self.proxy.key(&address_to_bytes(key))) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableDividendState { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableDividendState { pub fn member_list(&self) -> ArrayOfImmutableAddress { - let arr_id = get_object_id(self.id, STATE_MEMBER_LIST.get_key_id(), TYPE_ARRAY | TYPE_ADDRESS); - ArrayOfImmutableAddress { obj_id: arr_id } + ArrayOfImmutableAddress { proxy: self.proxy.root(STATE_MEMBER_LIST) } } pub fn members(&self) -> MapAddressToImmutableUint64 { - let map_id = get_object_id(self.id, STATE_MEMBERS.get_key_id(), TYPE_MAP); - MapAddressToImmutableUint64 { obj_id: map_id } + MapAddressToImmutableUint64 { proxy: self.proxy.root(STATE_MEMBERS) } } pub fn owner(&self) -> ScImmutableAgentID { - ScImmutableAgentID::new(self.id, STATE_OWNER.get_key_id()) + ScImmutableAgentID::new(self.proxy.root(STATE_OWNER)) } pub fn total_factor(&self) -> ScImmutableUint64 { - ScImmutableUint64::new(self.id, STATE_TOTAL_FACTOR.get_key_id()) + ScImmutableUint64::new(self.proxy.root(STATE_TOTAL_FACTOR)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ArrayOfMutableAddress { - pub(crate) obj_id: i32, + pub(crate) proxy: Proxy, } impl ArrayOfMutableAddress { - pub fn clear(&self) { - clear(self.obj_id); + pub fn append_address(&self) -> ScMutableAddress { + ScMutableAddress::new(self.proxy.append()) + } + + pub fn clear(&self) { + self.proxy.clear_array(); } pub fn length(&self) -> u32 { - get_length(self.obj_id) + self.proxy.length() } pub fn get_address(&self, index: u32) -> ScMutableAddress { - ScMutableAddress::new(self.obj_id, Key32(index as i32)) + ScMutableAddress::new(self.proxy.index(index)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MapAddressToMutableUint64 { - pub(crate) obj_id: i32, + pub(crate) proxy: Proxy, } impl MapAddressToMutableUint64 { pub fn clear(&self) { - clear(self.obj_id); + self.proxy.clear_map(); } pub fn get_uint64(&self, key: &ScAddress) -> ScMutableUint64 { - ScMutableUint64::new(self.obj_id, key.get_key_id()) + ScMutableUint64::new(self.proxy.key(&address_to_bytes(key))) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableDividendState { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableDividendState { pub fn as_immutable(&self) -> ImmutableDividendState { - ImmutableDividendState { id: self.id } + ImmutableDividendState { proxy: self.proxy.root("") } } pub fn member_list(&self) -> ArrayOfMutableAddress { - let arr_id = get_object_id(self.id, STATE_MEMBER_LIST.get_key_id(), TYPE_ARRAY | TYPE_ADDRESS); - ArrayOfMutableAddress { obj_id: arr_id } + ArrayOfMutableAddress { proxy: self.proxy.root(STATE_MEMBER_LIST) } } pub fn members(&self) -> MapAddressToMutableUint64 { - let map_id = get_object_id(self.id, STATE_MEMBERS.get_key_id(), TYPE_MAP); - MapAddressToMutableUint64 { obj_id: map_id } + MapAddressToMutableUint64 { proxy: self.proxy.root(STATE_MEMBERS) } } pub fn owner(&self) -> ScMutableAgentID { - ScMutableAgentID::new(self.id, STATE_OWNER.get_key_id()) + ScMutableAgentID::new(self.proxy.root(STATE_OWNER)) } pub fn total_factor(&self) -> ScMutableUint64 { - ScMutableUint64::new(self.id, STATE_TOTAL_FACTOR.get_key_id()) + ScMutableUint64::new(self.proxy.root(STATE_TOTAL_FACTOR)) } } diff --git a/contracts/wasm/dividend/test/dividend_bg.wasm b/contracts/wasm/dividend/test/dividend_bg.wasm index c97fe7d5c4c428160a6ee9720ef911116bcd2592..a44980873047fd201ba8f9474a55a8acd807c586 100644 GIT binary patch literal 55972 zcmdqK3!Gk6dGEh(?`7tlNp>JWNCNElHA*50nOtWQP-aI7L=aF=u%cv02FOgvWikm+ zl}sQiDk551siFo&K?TJYD^}F;6fIV2@f=&xT8-4UoF0#*r`pRop$YwaEj>nyquPal zc=o1CyRO)}WAyydfziS92SX z5``i_C7>0)2-P_M0Wqydl}ZqXVMh>GxbV7CQBkEU4C4y_>1Cx-uh(g`5^f8ZEUCm{ zFr(T5x$?2G@t{%5;_8)yS8g4-CJJg>w_LJ$>%hifZ>ZZ11DiJoZwxyw41+vu^xPW` z9d-PofuDwJe+mxuzeo7{27kZx)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Z;eKgw z;^@b3bjpdlkshUgAPXZnAg*wf*bN1!2Kga;YR%3!N0#G(OtSRN$^SL~&UN?qwBOgc z669;wZ))#cyCS@QZR@nKbLINgJ!`}{Ot28N`#r(5TS$oT2`qYebSY24vNS^M@>D@=-@1Rs$ZBSj_*eW~zgnpt7C z{PnEG{CiM)4q{m{5c5IxFg`qxxPAoBl)?~vVrlZ6hv73kYDWRN3sGf8{mn%4(GN%E z8&ZLw`u+mV4JhOKIn?V>AAwJR4`<|R+!|LPqin0irw$*^Vdac+6h6f?oCnI+-QNA+ zB>aWvhUJr>U6Z=oA6UA{JpFD>&4GxA8pxe$zHH(|@pH5(a+#eGqUj8({8xt%090a( zt+~yNHCMgYRyLEt0a}-pm^JT>ok)V1pR4fPgb$??;@{SYbPDPje72UD$CW6^vFB@f^`D2Wdsd+Wr+A*WF#*R&y?$LaJ@|K#Sx4I2grcK-{|Mmfaw n+wn{$;`*(4z7e0|owpo)^Cx$BX-1>?6JPvT_K?Z`^wIwhY*8i~ diff --git a/contracts/wasm/dividend/ts/dividend/keys.ts b/contracts/wasm/dividend/ts/dividend/keys.ts deleted file mode 100644 index 7a229a25ef..0000000000 --- a/contracts/wasm/dividend/ts/dividend/keys.ts +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2020 IOTA Stiftung -// SPDX-License-Identifier: Apache-2.0 - -// (Re-)generated by schema tool -// >>>> DO NOT CHANGE THIS FILE! <<<< -// Change the json schema instead - - -export const IdxParamAddress = 0; -export const IdxParamFactor = 1; -export const IdxParamOwner = 2; diff --git a/contracts/wasm/donatewithfeedback/go/donatewithfeedback/keys.go b/contracts/wasm/donatewithfeedback/go/donatewithfeedback/keys.go deleted file mode 100644 index 94694d46f8..0000000000 --- a/contracts/wasm/donatewithfeedback/go/donatewithfeedback/keys.go +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright 2020 IOTA Stiftung -// SPDX-License-Identifier: Apache-2.0 - -// (Re-)generated by schema tool -// >>>> DO NOT CHANGE THIS FILE! <<<< -// Change the json schema instead - -package donatewithfeedback diff --git a/contracts/wasm/donatewithfeedback/src/contract.rs b/contracts/wasm/donatewithfeedback/src/contract.rs index d726d153ca..02b5198919 100644 --- a/contracts/wasm/donatewithfeedback/src/contract.rs +++ b/contracts/wasm/donatewithfeedback/src/contract.rs @@ -7,8 +7,6 @@ #![allow(dead_code)] -use std::ptr; - use wasmlib::*; use crate::consts::*; @@ -40,40 +38,41 @@ pub struct ScFuncs { } impl ScFuncs { - pub fn donate(_ctx: & dyn ScFuncCallContext) -> DonateCall { + pub fn donate(_ctx: &dyn ScFuncCallContext) -> DonateCall { let mut f = DonateCall { func: ScFunc::new(HSC_NAME, HFUNC_DONATE), - params: MutableDonateParams { id: 0 }, + params: MutableDonateParams { proxy: Proxy::nil() }, }; - f.func.set_ptrs(&mut f.params.id, ptr::null_mut()); + ScFunc::link_params(&mut f.params.proxy, &f.func); f } - pub fn withdraw(_ctx: & dyn ScFuncCallContext) -> WithdrawCall { + pub fn withdraw(_ctx: &dyn ScFuncCallContext) -> WithdrawCall { let mut f = WithdrawCall { func: ScFunc::new(HSC_NAME, HFUNC_WITHDRAW), - params: MutableWithdrawParams { id: 0 }, + params: MutableWithdrawParams { proxy: Proxy::nil() }, }; - f.func.set_ptrs(&mut f.params.id, ptr::null_mut()); + ScFunc::link_params(&mut f.params.proxy, &f.func); f } - pub fn donation(_ctx: & dyn ScViewCallContext) -> DonationCall { + pub fn donation(_ctx: &dyn ScViewCallContext) -> DonationCall { let mut f = DonationCall { func: ScView::new(HSC_NAME, HVIEW_DONATION), - params: MutableDonationParams { id: 0 }, - results: ImmutableDonationResults { id: 0 }, + params: MutableDonationParams { proxy: Proxy::nil() }, + results: ImmutableDonationResults { proxy: Proxy::nil() }, }; - f.func.set_ptrs(&mut f.params.id, &mut f.results.id); + ScView::link_params(&mut f.params.proxy, &f.func); + ScView::link_results(&mut f.results.proxy, &f.func); f } - pub fn donation_info(_ctx: & dyn ScViewCallContext) -> DonationInfoCall { + pub fn donation_info(_ctx: &dyn ScViewCallContext) -> DonationInfoCall { let mut f = DonationInfoCall { func: ScView::new(HSC_NAME, HVIEW_DONATION_INFO), - results: ImmutableDonationInfoResults { id: 0 }, + results: ImmutableDonationInfoResults { proxy: Proxy::nil() }, }; - f.func.set_ptrs(ptr::null_mut(), &mut f.results.id); + ScView::link_results(&mut f.results.proxy, &f.func); f } } diff --git a/contracts/wasm/donatewithfeedback/src/donatewithfeedback.rs b/contracts/wasm/donatewithfeedback/src/donatewithfeedback.rs index ca49e35551..a814c6636d 100644 --- a/contracts/wasm/donatewithfeedback/src/donatewithfeedback.rs +++ b/contracts/wasm/donatewithfeedback/src/donatewithfeedback.rs @@ -22,7 +22,7 @@ pub fn func_donate(ctx: &ScFuncContext, f: &DonateContext) { } } let log = f.state.log(); - log.get_donation(log.length()).set_value(&donation); + log.append_donation().set_value(&donation); let largest_donation = f.state.max_donation(); let total_donated = f.state.total_donation(); diff --git a/contracts/wasm/donatewithfeedback/src/keys.rs b/contracts/wasm/donatewithfeedback/src/keys.rs deleted file mode 100644 index 15946701bc..0000000000 --- a/contracts/wasm/donatewithfeedback/src/keys.rs +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright 2020 IOTA Stiftung -// SPDX-License-Identifier: Apache-2.0 - -// (Re-)generated by schema tool -// >>>> DO NOT CHANGE THIS FILE! <<<< -// Change the json schema instead - -#![allow(dead_code)] - -use wasmlib::*; - -use crate::*; - -pub(crate) const IDX_PARAM_AMOUNT : usize = 0; -pub(crate) const IDX_PARAM_FEEDBACK : usize = 1; -pub(crate) const IDX_PARAM_NR : usize = 2; - -pub(crate) const IDX_RESULT_AMOUNT : usize = 3; -pub(crate) const IDX_RESULT_COUNT : usize = 4; -pub(crate) const IDX_RESULT_DONATOR : usize = 5; -pub(crate) const IDX_RESULT_ERROR : usize = 6; -pub(crate) const IDX_RESULT_FEEDBACK : usize = 7; -pub(crate) const IDX_RESULT_MAX_DONATION : usize = 8; -pub(crate) const IDX_RESULT_TIMESTAMP : usize = 9; -pub(crate) const IDX_RESULT_TOTAL_DONATION : usize = 10; - -pub(crate) const IDX_STATE_LOG : usize = 11; -pub(crate) const IDX_STATE_MAX_DONATION : usize = 12; -pub(crate) const IDX_STATE_TOTAL_DONATION : usize = 13; - -pub const KEY_MAP_LEN: usize = 14; - -pub const KEY_MAP: [&str; KEY_MAP_LEN] = [ - PARAM_AMOUNT, - PARAM_FEEDBACK, - PARAM_NR, - RESULT_AMOUNT, - RESULT_COUNT, - RESULT_DONATOR, - RESULT_ERROR, - RESULT_FEEDBACK, - RESULT_MAX_DONATION, - RESULT_TIMESTAMP, - RESULT_TOTAL_DONATION, - STATE_LOG, - STATE_MAX_DONATION, - STATE_TOTAL_DONATION, -]; - -pub static mut IDX_MAP: [Key32; KEY_MAP_LEN] = [Key32(0); KEY_MAP_LEN]; - -pub fn idx_map(idx: usize) -> Key32 { - unsafe { - IDX_MAP[idx] - } -} diff --git a/contracts/wasm/donatewithfeedback/src/lib.rs b/contracts/wasm/donatewithfeedback/src/lib.rs index feb50f1542..694df46136 100644 --- a/contracts/wasm/donatewithfeedback/src/lib.rs +++ b/contracts/wasm/donatewithfeedback/src/lib.rs @@ -10,17 +10,15 @@ use donatewithfeedback::*; use wasmlib::*; -use wasmlib::host::*; use crate::consts::*; -use crate::keys::*; use crate::params::*; use crate::results::*; use crate::state::*; +use crate::structs::*; mod consts; mod contract; -mod keys; mod params; mod results; mod state; @@ -34,12 +32,6 @@ fn on_load() { exports.add_func(FUNC_WITHDRAW, func_withdraw_thunk); exports.add_view(VIEW_DONATION, view_donation_thunk); exports.add_view(VIEW_DONATION_INFO, view_donation_info_thunk); - - unsafe { - for i in 0..KEY_MAP_LEN { - IDX_MAP[i] = get_key_id_from_string(KEY_MAP[i]); - } - } } pub struct DonateContext { @@ -50,12 +42,8 @@ pub struct DonateContext { fn func_donate_thunk(ctx: &ScFuncContext) { ctx.log("donatewithfeedback.funcDonate"); let f = DonateContext { - params: ImmutableDonateParams { - id: OBJ_ID_PARAMS, - }, - state: MutableDonateWithFeedbackState { - id: OBJ_ID_STATE, - }, + params: ImmutableDonateParams { proxy: params_proxy() }, + state: MutableDonateWithFeedbackState { proxy: state_proxy() }, }; func_donate(ctx, &f); ctx.log("donatewithfeedback.funcDonate ok"); @@ -68,18 +56,14 @@ pub struct WithdrawContext { fn func_withdraw_thunk(ctx: &ScFuncContext) { ctx.log("donatewithfeedback.funcWithdraw"); + let f = WithdrawContext { + params: ImmutableWithdrawParams { proxy: params_proxy() }, + state: MutableDonateWithFeedbackState { proxy: state_proxy() }, + }; // only SC creator can withdraw donated funds ctx.require(ctx.caller() == ctx.contract_creator(), "no permission"); - let f = WithdrawContext { - params: ImmutableWithdrawParams { - id: OBJ_ID_PARAMS, - }, - state: MutableDonateWithFeedbackState { - id: OBJ_ID_STATE, - }, - }; func_withdraw(ctx, &f); ctx.log("donatewithfeedback.funcWithdraw ok"); } @@ -93,18 +77,13 @@ pub struct DonationContext { fn view_donation_thunk(ctx: &ScViewContext) { ctx.log("donatewithfeedback.viewDonation"); let f = DonationContext { - params: ImmutableDonationParams { - id: OBJ_ID_PARAMS, - }, - results: MutableDonationResults { - id: OBJ_ID_RESULTS, - }, - state: ImmutableDonateWithFeedbackState { - id: OBJ_ID_STATE, - }, + params: ImmutableDonationParams { proxy: params_proxy() }, + results: MutableDonationResults { proxy: results_proxy() }, + state: ImmutableDonateWithFeedbackState { proxy: state_proxy() }, }; ctx.require(f.params.nr().exists(), "missing mandatory nr"); view_donation(ctx, &f); + ctx.results(&f.results.proxy.kv_store); ctx.log("donatewithfeedback.viewDonation ok"); } @@ -116,13 +95,10 @@ pub struct DonationInfoContext { fn view_donation_info_thunk(ctx: &ScViewContext) { ctx.log("donatewithfeedback.viewDonationInfo"); let f = DonationInfoContext { - results: MutableDonationInfoResults { - id: OBJ_ID_RESULTS, - }, - state: ImmutableDonateWithFeedbackState { - id: OBJ_ID_STATE, - }, + results: MutableDonationInfoResults { proxy: results_proxy() }, + state: ImmutableDonateWithFeedbackState { proxy: state_proxy() }, }; view_donation_info(ctx, &f); + ctx.results(&f.results.proxy.kv_store); ctx.log("donatewithfeedback.viewDonationInfo ok"); } diff --git a/contracts/wasm/donatewithfeedback/src/params.rs b/contracts/wasm/donatewithfeedback/src/params.rs index 83c963d1e7..0021442994 100644 --- a/contracts/wasm/donatewithfeedback/src/params.rs +++ b/contracts/wasm/donatewithfeedback/src/params.rs @@ -9,74 +9,70 @@ #![allow(unused_imports)] use wasmlib::*; -use wasmlib::host::*; - use crate::*; -use crate::keys::*; -use crate::structs::*; -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableDonateParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableDonateParams { pub fn feedback(&self) -> ScImmutableString { - ScImmutableString::new(self.id, PARAM_FEEDBACK.get_key_id()) + ScImmutableString::new(self.proxy.root(PARAM_FEEDBACK)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableDonateParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableDonateParams { pub fn feedback(&self) -> ScMutableString { - ScMutableString::new(self.id, PARAM_FEEDBACK.get_key_id()) + ScMutableString::new(self.proxy.root(PARAM_FEEDBACK)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableWithdrawParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableWithdrawParams { pub fn amount(&self) -> ScImmutableUint64 { - ScImmutableUint64::new(self.id, PARAM_AMOUNT.get_key_id()) + ScImmutableUint64::new(self.proxy.root(PARAM_AMOUNT)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableWithdrawParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableWithdrawParams { pub fn amount(&self) -> ScMutableUint64 { - ScMutableUint64::new(self.id, PARAM_AMOUNT.get_key_id()) + ScMutableUint64::new(self.proxy.root(PARAM_AMOUNT)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableDonationParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableDonationParams { pub fn nr(&self) -> ScImmutableUint32 { - ScImmutableUint32::new(self.id, PARAM_NR.get_key_id()) + ScImmutableUint32::new(self.proxy.root(PARAM_NR)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableDonationParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableDonationParams { pub fn nr(&self) -> ScMutableUint32 { - ScMutableUint32::new(self.id, PARAM_NR.get_key_id()) + ScMutableUint32::new(self.proxy.root(PARAM_NR)) } } diff --git a/contracts/wasm/donatewithfeedback/src/results.rs b/contracts/wasm/donatewithfeedback/src/results.rs index 26e61646b0..6ca1b5fedd 100644 --- a/contracts/wasm/donatewithfeedback/src/results.rs +++ b/contracts/wasm/donatewithfeedback/src/results.rs @@ -9,100 +9,96 @@ #![allow(unused_imports)] use wasmlib::*; -use wasmlib::host::*; - use crate::*; -use crate::keys::*; -use crate::structs::*; -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableDonationResults { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableDonationResults { pub fn amount(&self) -> ScImmutableUint64 { - ScImmutableUint64::new(self.id, RESULT_AMOUNT.get_key_id()) + ScImmutableUint64::new(self.proxy.root(RESULT_AMOUNT)) } pub fn donator(&self) -> ScImmutableAgentID { - ScImmutableAgentID::new(self.id, RESULT_DONATOR.get_key_id()) + ScImmutableAgentID::new(self.proxy.root(RESULT_DONATOR)) } pub fn error(&self) -> ScImmutableString { - ScImmutableString::new(self.id, RESULT_ERROR.get_key_id()) + ScImmutableString::new(self.proxy.root(RESULT_ERROR)) } pub fn feedback(&self) -> ScImmutableString { - ScImmutableString::new(self.id, RESULT_FEEDBACK.get_key_id()) + ScImmutableString::new(self.proxy.root(RESULT_FEEDBACK)) } pub fn timestamp(&self) -> ScImmutableUint64 { - ScImmutableUint64::new(self.id, RESULT_TIMESTAMP.get_key_id()) + ScImmutableUint64::new(self.proxy.root(RESULT_TIMESTAMP)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableDonationResults { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableDonationResults { pub fn amount(&self) -> ScMutableUint64 { - ScMutableUint64::new(self.id, RESULT_AMOUNT.get_key_id()) + ScMutableUint64::new(self.proxy.root(RESULT_AMOUNT)) } pub fn donator(&self) -> ScMutableAgentID { - ScMutableAgentID::new(self.id, RESULT_DONATOR.get_key_id()) + ScMutableAgentID::new(self.proxy.root(RESULT_DONATOR)) } pub fn error(&self) -> ScMutableString { - ScMutableString::new(self.id, RESULT_ERROR.get_key_id()) + ScMutableString::new(self.proxy.root(RESULT_ERROR)) } pub fn feedback(&self) -> ScMutableString { - ScMutableString::new(self.id, RESULT_FEEDBACK.get_key_id()) + ScMutableString::new(self.proxy.root(RESULT_FEEDBACK)) } pub fn timestamp(&self) -> ScMutableUint64 { - ScMutableUint64::new(self.id, RESULT_TIMESTAMP.get_key_id()) + ScMutableUint64::new(self.proxy.root(RESULT_TIMESTAMP)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableDonationInfoResults { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableDonationInfoResults { pub fn count(&self) -> ScImmutableUint32 { - ScImmutableUint32::new(self.id, RESULT_COUNT.get_key_id()) + ScImmutableUint32::new(self.proxy.root(RESULT_COUNT)) } pub fn max_donation(&self) -> ScImmutableUint64 { - ScImmutableUint64::new(self.id, RESULT_MAX_DONATION.get_key_id()) + ScImmutableUint64::new(self.proxy.root(RESULT_MAX_DONATION)) } pub fn total_donation(&self) -> ScImmutableUint64 { - ScImmutableUint64::new(self.id, RESULT_TOTAL_DONATION.get_key_id()) + ScImmutableUint64::new(self.proxy.root(RESULT_TOTAL_DONATION)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableDonationInfoResults { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableDonationInfoResults { pub fn count(&self) -> ScMutableUint32 { - ScMutableUint32::new(self.id, RESULT_COUNT.get_key_id()) + ScMutableUint32::new(self.proxy.root(RESULT_COUNT)) } pub fn max_donation(&self) -> ScMutableUint64 { - ScMutableUint64::new(self.id, RESULT_MAX_DONATION.get_key_id()) + ScMutableUint64::new(self.proxy.root(RESULT_MAX_DONATION)) } pub fn total_donation(&self) -> ScMutableUint64 { - ScMutableUint64::new(self.id, RESULT_TOTAL_DONATION.get_key_id()) + ScMutableUint64::new(self.proxy.root(RESULT_TOTAL_DONATION)) } } diff --git a/contracts/wasm/donatewithfeedback/src/state.rs b/contracts/wasm/donatewithfeedback/src/state.rs index bb871adbae..f6f0348306 100644 --- a/contracts/wasm/donatewithfeedback/src/state.rs +++ b/contracts/wasm/donatewithfeedback/src/state.rs @@ -9,86 +9,87 @@ #![allow(unused_imports)] use wasmlib::*; -use wasmlib::host::*; use crate::*; -use crate::keys::*; -use crate::structs::*; -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ArrayOfImmutableDonation { - pub(crate) obj_id: i32, + pub(crate) proxy: Proxy, } impl ArrayOfImmutableDonation { pub fn length(&self) -> u32 { - get_length(self.obj_id) + self.proxy.length() } + pub fn get_donation(&self, index: u32) -> ImmutableDonation { - ImmutableDonation { obj_id: self.obj_id, key_id: Key32(index as i32) } + ImmutableDonation { proxy: self.proxy.index(index) } } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableDonateWithFeedbackState { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableDonateWithFeedbackState { pub fn log(&self) -> ArrayOfImmutableDonation { - let arr_id = get_object_id(self.id, STATE_LOG.get_key_id(), TYPE_ARRAY | TYPE_BYTES); - ArrayOfImmutableDonation { obj_id: arr_id } + ArrayOfImmutableDonation { proxy: self.proxy.root(STATE_LOG) } } pub fn max_donation(&self) -> ScImmutableUint64 { - ScImmutableUint64::new(self.id, STATE_MAX_DONATION.get_key_id()) + ScImmutableUint64::new(self.proxy.root(STATE_MAX_DONATION)) } pub fn total_donation(&self) -> ScImmutableUint64 { - ScImmutableUint64::new(self.id, STATE_TOTAL_DONATION.get_key_id()) + ScImmutableUint64::new(self.proxy.root(STATE_TOTAL_DONATION)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ArrayOfMutableDonation { - pub(crate) obj_id: i32, + pub(crate) proxy: Proxy, } impl ArrayOfMutableDonation { - pub fn clear(&self) { - clear(self.obj_id); + + pub fn append_donation(&self) -> MutableDonation { + MutableDonation { proxy: self.proxy.append() } + } + pub fn clear(&self) { + self.proxy.clear_array(); } pub fn length(&self) -> u32 { - get_length(self.obj_id) + self.proxy.length() } + pub fn get_donation(&self, index: u32) -> MutableDonation { - MutableDonation { obj_id: self.obj_id, key_id: Key32(index as i32) } + MutableDonation { proxy: self.proxy.index(index) } } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableDonateWithFeedbackState { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableDonateWithFeedbackState { pub fn as_immutable(&self) -> ImmutableDonateWithFeedbackState { - ImmutableDonateWithFeedbackState { id: self.id } + ImmutableDonateWithFeedbackState { proxy: self.proxy.root("") } } pub fn log(&self) -> ArrayOfMutableDonation { - let arr_id = get_object_id(self.id, STATE_LOG.get_key_id(), TYPE_ARRAY | TYPE_BYTES); - ArrayOfMutableDonation { obj_id: arr_id } + ArrayOfMutableDonation { proxy: self.proxy.root(STATE_LOG) } } pub fn max_donation(&self) -> ScMutableUint64 { - ScMutableUint64::new(self.id, STATE_MAX_DONATION.get_key_id()) + ScMutableUint64::new(self.proxy.root(STATE_MAX_DONATION)) } pub fn total_donation(&self) -> ScMutableUint64 { - ScMutableUint64::new(self.id, STATE_TOTAL_DONATION.get_key_id()) + ScMutableUint64::new(self.proxy.root(STATE_TOTAL_DONATION)) } } diff --git a/contracts/wasm/donatewithfeedback/src/structs.rs b/contracts/wasm/donatewithfeedback/src/structs.rs index 873f41a6ef..0e71a055a0 100644 --- a/contracts/wasm/donatewithfeedback/src/structs.rs +++ b/contracts/wasm/donatewithfeedback/src/structs.rs @@ -9,7 +9,6 @@ #![allow(unused_imports)] use wasmlib::*; -use wasmlib::host::*; #[derive(Clone)] pub struct Donation { @@ -22,63 +21,61 @@ pub struct Donation { impl Donation { pub fn from_bytes(bytes: &[u8]) -> Donation { - let mut decode = BytesDecoder::new(bytes); + let mut dec = WasmDecoder::new(bytes); Donation { - amount : decode.uint64(), - donator : decode.agent_id(), - error : decode.string(), - feedback : decode.string(), - timestamp : decode.uint64(), + amount : uint64_decode(&mut dec), + donator : agent_id_decode(&mut dec), + error : string_decode(&mut dec), + feedback : string_decode(&mut dec), + timestamp : uint64_decode(&mut dec), } } pub fn to_bytes(&self) -> Vec { - let mut encode = BytesEncoder::new(); - encode.uint64(self.amount); - encode.agent_id(&self.donator); - encode.string(&self.error); - encode.string(&self.feedback); - encode.uint64(self.timestamp); - return encode.data(); + let mut enc = WasmEncoder::new(); + uint64_encode(&mut enc, self.amount); + agent_id_encode(&mut enc, &self.donator); + string_encode(&mut enc, &self.error); + string_encode(&mut enc, &self.feedback); + uint64_encode(&mut enc, self.timestamp); + enc.buf() } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableDonation { - pub(crate) obj_id: i32, - pub(crate) key_id: Key32, + pub(crate) proxy: Proxy, } impl ImmutableDonation { pub fn exists(&self) -> bool { - exists(self.obj_id, self.key_id, TYPE_BYTES) + self.proxy.exists() } pub fn value(&self) -> Donation { - Donation::from_bytes(&get_bytes(self.obj_id, self.key_id, TYPE_BYTES)) + Donation::from_bytes(&self.proxy.get()) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableDonation { - pub(crate) obj_id: i32, - pub(crate) key_id: Key32, + pub(crate) proxy: Proxy, } impl MutableDonation { pub fn delete(&self) { - del_key(self.obj_id, self.key_id, TYPE_BYTES); + self.proxy.delete(); } pub fn exists(&self) -> bool { - exists(self.obj_id, self.key_id, TYPE_BYTES) + self.proxy.exists() } pub fn set_value(&self, value: &Donation) { - set_bytes(self.obj_id, self.key_id, TYPE_BYTES, &value.to_bytes()); + self.proxy.set(&value.to_bytes()); } pub fn value(&self) -> Donation { - Donation::from_bytes(&get_bytes(self.obj_id, self.key_id, TYPE_BYTES)) + Donation::from_bytes(&self.proxy.get()) } } diff --git a/contracts/wasm/donatewithfeedback/test/donatewithfeedback_bg.wasm b/contracts/wasm/donatewithfeedback/test/donatewithfeedback_bg.wasm index 49f8eb30aa3582efdb347be57d914b9c3000ef2c..924c7b295d7d69996acbef36c8067f1adbae4956 100644 GIT binary patch literal 59227 zcmdSC3xHi!dH20<=Q49bf=KKAhwe~(|CX)c7 zU*8YS?AzLFJ?ptY&wBPc!G_VTVGso2P2rsN(Vjhl{)Bth$9u{{us-B=sJjVwIj`to zO|P^ESGotj0r%9$mFt6GebrjhR3}&J9lE&EbzzqQFS+jApjUE;_SoMmHDVB687+xw z=K|)Ln=kCSWc%pYtH(Bs4ZeDCET|rO`!sHM$8U?Si7G)YiQ?``@T@3Gs*N~Eg0LE< zl^J1B4dQAen3)_C9~DGF7}S#_h+~it2i4hOHI8W#CrPcwv!GV(32H%7<-Z`V#c`t& zR+CwAoE)9-LN!U^B<96>5Z8kwVwAW_SG6z>dU(V&t@tmgba58MVVFcAH$y$?J(gj5 zDsd&MB;9eyL$wLw3V#4T4niQ)e@Q}rK~kv%VHkD?Opc}@4JsAgtn`LqRIgX~F9^HB zuu|#j>SF9lxFcM$q{4h=Rl6WyK0ZDXG-_E~-8#5+`^e={P}{!kf-T!OYzjUR>U86V zEn9-$2)kYz26@;xam(5hH(e8*b`9v%|GpPq6a6Ls&c7ylINZyPzYdT7?eOa8zOe7q zKMwys{B}4VT^0Rn_;7etc*-&G!})A~O#Si42j4Q3U%E5DVyG46bYQph zXl$5wqAXlDFAL7hqM#zHRppjJ>x7rMPqDB_>Mhy*{hgn5Hqz{J0jCX2oaTcWi6kakJ zY;HGVaGr%c1=27}&gL9At698mXNv(t#*HHU0u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^wtZS;B5v*!#S<${y zRJ*=d2+&SY1nn0R@AdEN5}D4v+!GP;$L*{!|A9b&^{boKu5M^wrk^={~+dmvTo6xXnbuXk&pB7QN63+b!EZdJWAfbiL zbnivPF#kJ(S=P|fvZg&)-neYd^2VSMhrA(JivKksXlQF|*f23zw-%%8o7T3Et7&S{ z?;gHt3}@Gp-RC8IaTy+S9)5$^M*SAt57f8(Y?5B|_D%ZvcZND|C-jfrnWew}PfMq- zY*@RpeZwsVLrh=8ipG|9axG#wSe>*xA^P$9&^yzI6|+KQM@x|n0#7<#TI9?bF5>^; zV1;0L$`|vo@J{@O;1~Dz;GW#}@rzFlmO=ExuYWX-2ImW-u8+MvSug(i@Ng7-{xFPu zh~bfF7kFI0yd^!bWzX;quH{7Iu zc4T0>W!-9U`;R61=3l%wka%K_QuWB?@%oDQ#yaI0ecOAp$JfK^lFe74&7o~;XjuWd zYFQpMwJdL3A8f`rX}>C?|Mk7`{`2UPmv5k@uITL1JN1;Ko+s23kLzcTp648STpv3+ z+Bs6H-D8u(G>QRK`%UejBjz0Gm&*#sYZ#--M`e^=!$&)AFWVFPP zulF7s+V5!=Brv}lEoncQ)<=(xuRMZoIl8|@OBVebTJ99nBj2Bui&qUR_YL=Fqoq__ zhL+|DV0XMfx!-zpc|d*eqp++m-}krgZ%lkCh5VHaUw|LmxPJ}qNkrVg3ilV{SA0+t Y_TBog*SZ-dAsGqI9)4N>;+LELKZN$sBLDyZ diff --git a/contracts/wasm/donatewithfeedback/ts/donatewithfeedback/keys.ts b/contracts/wasm/donatewithfeedback/ts/donatewithfeedback/keys.ts deleted file mode 100644 index f7b1b1466c..0000000000 --- a/contracts/wasm/donatewithfeedback/ts/donatewithfeedback/keys.ts +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2020 IOTA Stiftung -// SPDX-License-Identifier: Apache-2.0 - -// (Re-)generated by schema tool -// >>>> DO NOT CHANGE THIS FILE! <<<< -// Change the json schema instead - - -export const IdxParamAmount = 0; -export const IdxParamFeedback = 1; -export const IdxParamNr = 2; diff --git a/contracts/wasm/erc20/go/erc20/keys.go b/contracts/wasm/erc20/go/erc20/keys.go deleted file mode 100644 index cd095ce0e0..0000000000 --- a/contracts/wasm/erc20/go/erc20/keys.go +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright 2020 IOTA Stiftung -// SPDX-License-Identifier: Apache-2.0 - -// (Re-)generated by schema tool -// >>>> DO NOT CHANGE THIS FILE! <<<< -// Change the json schema instead - -package erc20 diff --git a/contracts/wasm/erc20/src/contract.rs b/contracts/wasm/erc20/src/contract.rs index cc412c413d..0b46fdb182 100644 --- a/contracts/wasm/erc20/src/contract.rs +++ b/contracts/wasm/erc20/src/contract.rs @@ -7,8 +7,6 @@ #![allow(dead_code)] -use std::ptr; - use wasmlib::*; use crate::consts::*; @@ -56,68 +54,70 @@ pub struct ScFuncs { } impl ScFuncs { - pub fn approve(_ctx: & dyn ScFuncCallContext) -> ApproveCall { + pub fn approve(_ctx: &dyn ScFuncCallContext) -> ApproveCall { let mut f = ApproveCall { func: ScFunc::new(HSC_NAME, HFUNC_APPROVE), - params: MutableApproveParams { id: 0 }, + params: MutableApproveParams { proxy: Proxy::nil() }, }; - f.func.set_ptrs(&mut f.params.id, ptr::null_mut()); + ScFunc::link_params(&mut f.params.proxy, &f.func); f } - pub fn init(_ctx: & dyn ScFuncCallContext) -> InitCall { + pub fn init(_ctx: &dyn ScFuncCallContext) -> InitCall { let mut f = InitCall { func: ScInitFunc::new(HSC_NAME, HFUNC_INIT), - params: MutableInitParams { id: 0 }, + params: MutableInitParams { proxy: Proxy::nil() }, }; - f.func.set_ptrs(&mut f.params.id, ptr::null_mut()); + ScInitFunc::link_params(&mut f.params.proxy, &f.func); f } - pub fn transfer(_ctx: & dyn ScFuncCallContext) -> TransferCall { + pub fn transfer(_ctx: &dyn ScFuncCallContext) -> TransferCall { let mut f = TransferCall { func: ScFunc::new(HSC_NAME, HFUNC_TRANSFER), - params: MutableTransferParams { id: 0 }, + params: MutableTransferParams { proxy: Proxy::nil() }, }; - f.func.set_ptrs(&mut f.params.id, ptr::null_mut()); + ScFunc::link_params(&mut f.params.proxy, &f.func); f } - pub fn transfer_from(_ctx: & dyn ScFuncCallContext) -> TransferFromCall { + pub fn transfer_from(_ctx: &dyn ScFuncCallContext) -> TransferFromCall { let mut f = TransferFromCall { func: ScFunc::new(HSC_NAME, HFUNC_TRANSFER_FROM), - params: MutableTransferFromParams { id: 0 }, + params: MutableTransferFromParams { proxy: Proxy::nil() }, }; - f.func.set_ptrs(&mut f.params.id, ptr::null_mut()); + ScFunc::link_params(&mut f.params.proxy, &f.func); f } - pub fn allowance(_ctx: & dyn ScViewCallContext) -> AllowanceCall { + pub fn allowance(_ctx: &dyn ScViewCallContext) -> AllowanceCall { let mut f = AllowanceCall { func: ScView::new(HSC_NAME, HVIEW_ALLOWANCE), - params: MutableAllowanceParams { id: 0 }, - results: ImmutableAllowanceResults { id: 0 }, + params: MutableAllowanceParams { proxy: Proxy::nil() }, + results: ImmutableAllowanceResults { proxy: Proxy::nil() }, }; - f.func.set_ptrs(&mut f.params.id, &mut f.results.id); + ScView::link_params(&mut f.params.proxy, &f.func); + ScView::link_results(&mut f.results.proxy, &f.func); f } - pub fn balance_of(_ctx: & dyn ScViewCallContext) -> BalanceOfCall { + pub fn balance_of(_ctx: &dyn ScViewCallContext) -> BalanceOfCall { let mut f = BalanceOfCall { func: ScView::new(HSC_NAME, HVIEW_BALANCE_OF), - params: MutableBalanceOfParams { id: 0 }, - results: ImmutableBalanceOfResults { id: 0 }, + params: MutableBalanceOfParams { proxy: Proxy::nil() }, + results: ImmutableBalanceOfResults { proxy: Proxy::nil() }, }; - f.func.set_ptrs(&mut f.params.id, &mut f.results.id); + ScView::link_params(&mut f.params.proxy, &f.func); + ScView::link_results(&mut f.results.proxy, &f.func); f } - pub fn total_supply(_ctx: & dyn ScViewCallContext) -> TotalSupplyCall { + pub fn total_supply(_ctx: &dyn ScViewCallContext) -> TotalSupplyCall { let mut f = TotalSupplyCall { func: ScView::new(HSC_NAME, HVIEW_TOTAL_SUPPLY), - results: ImmutableTotalSupplyResults { id: 0 }, + results: ImmutableTotalSupplyResults { proxy: Proxy::nil() }, }; - f.func.set_ptrs(ptr::null_mut(), &mut f.results.id); + ScView::link_results(&mut f.results.proxy, &f.func); f } } diff --git a/contracts/wasm/erc20/src/events.rs b/contracts/wasm/erc20/src/events.rs index 125ae3544a..5958f115b4 100644 --- a/contracts/wasm/erc20/src/events.rs +++ b/contracts/wasm/erc20/src/events.rs @@ -6,6 +6,7 @@ // Change the json schema instead #![allow(dead_code)] +#![allow(unused_mut)] use wasmlib::*; @@ -15,18 +16,18 @@ pub struct Erc20Events { impl Erc20Events { pub fn approval(&self, amount: u64, owner: &ScAgentID, spender: &ScAgentID) { - let mut encoder = EventEncoder::new("erc20.approval"); - encoder.uint64(amount); - encoder.agent_id(&owner); - encoder.agent_id(&spender); - encoder.emit(); + let mut evt = EventEncoder::new("erc20.approval"); + evt.encode(&uint64_to_string(amount)); + evt.encode(&agent_id_to_string(&owner)); + evt.encode(&agent_id_to_string(&spender)); + evt.emit(); } pub fn transfer(&self, amount: u64, from: &ScAgentID, to: &ScAgentID) { - let mut encoder = EventEncoder::new("erc20.transfer"); - encoder.uint64(amount); - encoder.agent_id(&from); - encoder.agent_id(&to); - encoder.emit(); + let mut evt = EventEncoder::new("erc20.transfer"); + evt.encode(&uint64_to_string(amount)); + evt.encode(&agent_id_to_string(&from)); + evt.encode(&agent_id_to_string(&to)); + evt.emit(); } } diff --git a/contracts/wasm/erc20/src/keys.rs b/contracts/wasm/erc20/src/keys.rs deleted file mode 100644 index 44095bd456..0000000000 --- a/contracts/wasm/erc20/src/keys.rs +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright 2020 IOTA Stiftung -// SPDX-License-Identifier: Apache-2.0 - -// (Re-)generated by schema tool -// >>>> DO NOT CHANGE THIS FILE! <<<< -// Change the json schema instead - -#![allow(dead_code)] - -use wasmlib::*; - -use crate::*; - -pub(crate) const IDX_PARAM_ACCOUNT : usize = 0; -pub(crate) const IDX_PARAM_AMOUNT : usize = 1; -pub(crate) const IDX_PARAM_CREATOR : usize = 2; -pub(crate) const IDX_PARAM_DELEGATION : usize = 3; -pub(crate) const IDX_PARAM_RECIPIENT : usize = 4; -pub(crate) const IDX_PARAM_SUPPLY : usize = 5; - -pub(crate) const IDX_RESULT_AMOUNT : usize = 6; -pub(crate) const IDX_RESULT_SUPPLY : usize = 7; - -pub(crate) const IDX_STATE_ALL_ALLOWANCES : usize = 8; -pub(crate) const IDX_STATE_BALANCES : usize = 9; -pub(crate) const IDX_STATE_SUPPLY : usize = 10; - -pub const KEY_MAP_LEN: usize = 11; - -pub const KEY_MAP: [&str; KEY_MAP_LEN] = [ - PARAM_ACCOUNT, - PARAM_AMOUNT, - PARAM_CREATOR, - PARAM_DELEGATION, - PARAM_RECIPIENT, - PARAM_SUPPLY, - RESULT_AMOUNT, - RESULT_SUPPLY, - STATE_ALL_ALLOWANCES, - STATE_BALANCES, - STATE_SUPPLY, -]; - -pub static mut IDX_MAP: [Key32; KEY_MAP_LEN] = [Key32(0); KEY_MAP_LEN]; - -pub fn idx_map(idx: usize) -> Key32 { - unsafe { - IDX_MAP[idx] - } -} diff --git a/contracts/wasm/erc20/src/lib.rs b/contracts/wasm/erc20/src/lib.rs index e3bc083c0b..ee59283ca1 100644 --- a/contracts/wasm/erc20/src/lib.rs +++ b/contracts/wasm/erc20/src/lib.rs @@ -10,19 +10,17 @@ use erc20::*; use wasmlib::*; -use wasmlib::host::*; use crate::consts::*; use crate::events::*; -use crate::keys::*; use crate::params::*; use crate::results::*; use crate::state::*; +use crate::typedefs::*; mod consts; mod contract; mod events; -mod keys; mod params; mod results; mod state; @@ -39,12 +37,6 @@ fn on_load() { exports.add_view(VIEW_ALLOWANCE, view_allowance_thunk); exports.add_view(VIEW_BALANCE_OF, view_balance_of_thunk); exports.add_view(VIEW_TOTAL_SUPPLY, view_total_supply_thunk); - - unsafe { - for i in 0..KEY_MAP_LEN { - IDX_MAP[i] = get_key_id_from_string(KEY_MAP[i]); - } - } } pub struct ApproveContext { @@ -57,12 +49,8 @@ fn func_approve_thunk(ctx: &ScFuncContext) { ctx.log("erc20.funcApprove"); let f = ApproveContext { events: Erc20Events {}, - params: ImmutableApproveParams { - id: OBJ_ID_PARAMS, - }, - state: MutableErc20State { - id: OBJ_ID_STATE, - }, + params: ImmutableApproveParams { proxy: params_proxy() }, + state: MutableErc20State { proxy: state_proxy() }, }; ctx.require(f.params.amount().exists(), "missing mandatory amount"); ctx.require(f.params.delegation().exists(), "missing mandatory delegation"); @@ -80,12 +68,8 @@ fn func_init_thunk(ctx: &ScFuncContext) { ctx.log("erc20.funcInit"); let f = InitContext { events: Erc20Events {}, - params: ImmutableInitParams { - id: OBJ_ID_PARAMS, - }, - state: MutableErc20State { - id: OBJ_ID_STATE, - }, + params: ImmutableInitParams { proxy: params_proxy() }, + state: MutableErc20State { proxy: state_proxy() }, }; ctx.require(f.params.creator().exists(), "missing mandatory creator"); ctx.require(f.params.supply().exists(), "missing mandatory supply"); @@ -103,12 +87,8 @@ fn func_transfer_thunk(ctx: &ScFuncContext) { ctx.log("erc20.funcTransfer"); let f = TransferContext { events: Erc20Events {}, - params: ImmutableTransferParams { - id: OBJ_ID_PARAMS, - }, - state: MutableErc20State { - id: OBJ_ID_STATE, - }, + params: ImmutableTransferParams { proxy: params_proxy() }, + state: MutableErc20State { proxy: state_proxy() }, }; ctx.require(f.params.account().exists(), "missing mandatory account"); ctx.require(f.params.amount().exists(), "missing mandatory amount"); @@ -126,12 +106,8 @@ fn func_transfer_from_thunk(ctx: &ScFuncContext) { ctx.log("erc20.funcTransferFrom"); let f = TransferFromContext { events: Erc20Events {}, - params: ImmutableTransferFromParams { - id: OBJ_ID_PARAMS, - }, - state: MutableErc20State { - id: OBJ_ID_STATE, - }, + params: ImmutableTransferFromParams { proxy: params_proxy() }, + state: MutableErc20State { proxy: state_proxy() }, }; ctx.require(f.params.account().exists(), "missing mandatory account"); ctx.require(f.params.amount().exists(), "missing mandatory amount"); @@ -149,19 +125,14 @@ pub struct AllowanceContext { fn view_allowance_thunk(ctx: &ScViewContext) { ctx.log("erc20.viewAllowance"); let f = AllowanceContext { - params: ImmutableAllowanceParams { - id: OBJ_ID_PARAMS, - }, - results: MutableAllowanceResults { - id: OBJ_ID_RESULTS, - }, - state: ImmutableErc20State { - id: OBJ_ID_STATE, - }, + params: ImmutableAllowanceParams { proxy: params_proxy() }, + results: MutableAllowanceResults { proxy: results_proxy() }, + state: ImmutableErc20State { proxy: state_proxy() }, }; ctx.require(f.params.account().exists(), "missing mandatory account"); ctx.require(f.params.delegation().exists(), "missing mandatory delegation"); view_allowance(ctx, &f); + ctx.results(&f.results.proxy.kv_store); ctx.log("erc20.viewAllowance ok"); } @@ -174,18 +145,13 @@ pub struct BalanceOfContext { fn view_balance_of_thunk(ctx: &ScViewContext) { ctx.log("erc20.viewBalanceOf"); let f = BalanceOfContext { - params: ImmutableBalanceOfParams { - id: OBJ_ID_PARAMS, - }, - results: MutableBalanceOfResults { - id: OBJ_ID_RESULTS, - }, - state: ImmutableErc20State { - id: OBJ_ID_STATE, - }, + params: ImmutableBalanceOfParams { proxy: params_proxy() }, + results: MutableBalanceOfResults { proxy: results_proxy() }, + state: ImmutableErc20State { proxy: state_proxy() }, }; ctx.require(f.params.account().exists(), "missing mandatory account"); view_balance_of(ctx, &f); + ctx.results(&f.results.proxy.kv_store); ctx.log("erc20.viewBalanceOf ok"); } @@ -197,13 +163,10 @@ pub struct TotalSupplyContext { fn view_total_supply_thunk(ctx: &ScViewContext) { ctx.log("erc20.viewTotalSupply"); let f = TotalSupplyContext { - results: MutableTotalSupplyResults { - id: OBJ_ID_RESULTS, - }, - state: ImmutableErc20State { - id: OBJ_ID_STATE, - }, + results: MutableTotalSupplyResults { proxy: results_proxy() }, + state: ImmutableErc20State { proxy: state_proxy() }, }; view_total_supply(ctx, &f); + ctx.results(&f.results.proxy.kv_store); ctx.log("erc20.viewTotalSupply ok"); } diff --git a/contracts/wasm/erc20/src/params.rs b/contracts/wasm/erc20/src/params.rs index 2af088ec14..8c6e884652 100644 --- a/contracts/wasm/erc20/src/params.rs +++ b/contracts/wasm/erc20/src/params.rs @@ -9,188 +9,184 @@ #![allow(unused_imports)] use wasmlib::*; -use wasmlib::host::*; - use crate::*; -use crate::keys::*; -use crate::typedefs::*; -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableApproveParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableApproveParams { pub fn amount(&self) -> ScImmutableUint64 { - ScImmutableUint64::new(self.id, PARAM_AMOUNT.get_key_id()) + ScImmutableUint64::new(self.proxy.root(PARAM_AMOUNT)) } pub fn delegation(&self) -> ScImmutableAgentID { - ScImmutableAgentID::new(self.id, PARAM_DELEGATION.get_key_id()) + ScImmutableAgentID::new(self.proxy.root(PARAM_DELEGATION)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableApproveParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableApproveParams { pub fn amount(&self) -> ScMutableUint64 { - ScMutableUint64::new(self.id, PARAM_AMOUNT.get_key_id()) + ScMutableUint64::new(self.proxy.root(PARAM_AMOUNT)) } pub fn delegation(&self) -> ScMutableAgentID { - ScMutableAgentID::new(self.id, PARAM_DELEGATION.get_key_id()) + ScMutableAgentID::new(self.proxy.root(PARAM_DELEGATION)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableInitParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableInitParams { pub fn creator(&self) -> ScImmutableAgentID { - ScImmutableAgentID::new(self.id, idx_map(IDX_PARAM_CREATOR)) + ScImmutableAgentID::new(self.proxy.root(PARAM_CREATOR)) } pub fn supply(&self) -> ScImmutableUint64 { - ScImmutableUint64::new(self.id, idx_map(IDX_PARAM_SUPPLY)) + ScImmutableUint64::new(self.proxy.root(PARAM_SUPPLY)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableInitParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableInitParams { pub fn creator(&self) -> ScMutableAgentID { - ScMutableAgentID::new(self.id, idx_map(IDX_PARAM_CREATOR)) + ScMutableAgentID::new(self.proxy.root(PARAM_CREATOR)) } pub fn supply(&self) -> ScMutableUint64 { - ScMutableUint64::new(self.id, idx_map(IDX_PARAM_SUPPLY)) + ScMutableUint64::new(self.proxy.root(PARAM_SUPPLY)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableTransferParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableTransferParams { pub fn account(&self) -> ScImmutableAgentID { - ScImmutableAgentID::new(self.id, PARAM_ACCOUNT.get_key_id()) + ScImmutableAgentID::new(self.proxy.root(PARAM_ACCOUNT)) } pub fn amount(&self) -> ScImmutableUint64 { - ScImmutableUint64::new(self.id, PARAM_AMOUNT.get_key_id()) + ScImmutableUint64::new(self.proxy.root(PARAM_AMOUNT)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableTransferParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableTransferParams { pub fn account(&self) -> ScMutableAgentID { - ScMutableAgentID::new(self.id, PARAM_ACCOUNT.get_key_id()) + ScMutableAgentID::new(self.proxy.root(PARAM_ACCOUNT)) } pub fn amount(&self) -> ScMutableUint64 { - ScMutableUint64::new(self.id, PARAM_AMOUNT.get_key_id()) + ScMutableUint64::new(self.proxy.root(PARAM_AMOUNT)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableTransferFromParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableTransferFromParams { pub fn account(&self) -> ScImmutableAgentID { - ScImmutableAgentID::new(self.id, PARAM_ACCOUNT.get_key_id()) + ScImmutableAgentID::new(self.proxy.root(PARAM_ACCOUNT)) } pub fn amount(&self) -> ScImmutableUint64 { - ScImmutableUint64::new(self.id, PARAM_AMOUNT.get_key_id()) + ScImmutableUint64::new(self.proxy.root(PARAM_AMOUNT)) } pub fn recipient(&self) -> ScImmutableAgentID { - ScImmutableAgentID::new(self.id, PARAM_RECIPIENT.get_key_id()) + ScImmutableAgentID::new(self.proxy.root(PARAM_RECIPIENT)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableTransferFromParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableTransferFromParams { pub fn account(&self) -> ScMutableAgentID { - ScMutableAgentID::new(self.id, PARAM_ACCOUNT.get_key_id()) + ScMutableAgentID::new(self.proxy.root(PARAM_ACCOUNT)) } pub fn amount(&self) -> ScMutableUint64 { - ScMutableUint64::new(self.id, PARAM_AMOUNT.get_key_id()) + ScMutableUint64::new(self.proxy.root(PARAM_AMOUNT)) } pub fn recipient(&self) -> ScMutableAgentID { - ScMutableAgentID::new(self.id, PARAM_RECIPIENT.get_key_id()) + ScMutableAgentID::new(self.proxy.root(PARAM_RECIPIENT)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableAllowanceParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableAllowanceParams { pub fn account(&self) -> ScImmutableAgentID { - ScImmutableAgentID::new(self.id, PARAM_ACCOUNT.get_key_id()) + ScImmutableAgentID::new(self.proxy.root(PARAM_ACCOUNT)) } pub fn delegation(&self) -> ScImmutableAgentID { - ScImmutableAgentID::new(self.id, PARAM_DELEGATION.get_key_id()) + ScImmutableAgentID::new(self.proxy.root(PARAM_DELEGATION)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableAllowanceParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableAllowanceParams { pub fn account(&self) -> ScMutableAgentID { - ScMutableAgentID::new(self.id, PARAM_ACCOUNT.get_key_id()) + ScMutableAgentID::new(self.proxy.root(PARAM_ACCOUNT)) } pub fn delegation(&self) -> ScMutableAgentID { - ScMutableAgentID::new(self.id, PARAM_DELEGATION.get_key_id()) + ScMutableAgentID::new(self.proxy.root(PARAM_DELEGATION)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableBalanceOfParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableBalanceOfParams { pub fn account(&self) -> ScImmutableAgentID { - ScImmutableAgentID::new(self.id, PARAM_ACCOUNT.get_key_id()) + ScImmutableAgentID::new(self.proxy.root(PARAM_ACCOUNT)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableBalanceOfParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableBalanceOfParams { pub fn account(&self) -> ScMutableAgentID { - ScMutableAgentID::new(self.id, PARAM_ACCOUNT.get_key_id()) + ScMutableAgentID::new(self.proxy.root(PARAM_ACCOUNT)) } } diff --git a/contracts/wasm/erc20/src/results.rs b/contracts/wasm/erc20/src/results.rs index e3a962fa2e..1e8db6a2be 100644 --- a/contracts/wasm/erc20/src/results.rs +++ b/contracts/wasm/erc20/src/results.rs @@ -9,74 +9,70 @@ #![allow(unused_imports)] use wasmlib::*; -use wasmlib::host::*; - use crate::*; -use crate::keys::*; -use crate::typedefs::*; -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableAllowanceResults { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableAllowanceResults { pub fn amount(&self) -> ScImmutableUint64 { - ScImmutableUint64::new(self.id, RESULT_AMOUNT.get_key_id()) + ScImmutableUint64::new(self.proxy.root(RESULT_AMOUNT)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableAllowanceResults { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableAllowanceResults { pub fn amount(&self) -> ScMutableUint64 { - ScMutableUint64::new(self.id, RESULT_AMOUNT.get_key_id()) + ScMutableUint64::new(self.proxy.root(RESULT_AMOUNT)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableBalanceOfResults { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableBalanceOfResults { pub fn amount(&self) -> ScImmutableUint64 { - ScImmutableUint64::new(self.id, RESULT_AMOUNT.get_key_id()) + ScImmutableUint64::new(self.proxy.root(RESULT_AMOUNT)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableBalanceOfResults { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableBalanceOfResults { pub fn amount(&self) -> ScMutableUint64 { - ScMutableUint64::new(self.id, RESULT_AMOUNT.get_key_id()) + ScMutableUint64::new(self.proxy.root(RESULT_AMOUNT)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableTotalSupplyResults { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableTotalSupplyResults { pub fn supply(&self) -> ScImmutableUint64 { - ScImmutableUint64::new(self.id, RESULT_SUPPLY.get_key_id()) + ScImmutableUint64::new(self.proxy.root(RESULT_SUPPLY)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableTotalSupplyResults { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableTotalSupplyResults { pub fn supply(&self) -> ScMutableUint64 { - ScMutableUint64::new(self.id, RESULT_SUPPLY.get_key_id()) + ScMutableUint64::new(self.proxy.root(RESULT_SUPPLY)) } } diff --git a/contracts/wasm/erc20/src/state.rs b/contracts/wasm/erc20/src/state.rs index d9e39d1dc2..a027e12ef2 100644 --- a/contracts/wasm/erc20/src/state.rs +++ b/contracts/wasm/erc20/src/state.rs @@ -9,82 +9,73 @@ #![allow(unused_imports)] use wasmlib::*; -use wasmlib::host::*; use crate::*; -use crate::keys::*; -use crate::typedefs::*; -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MapAgentIDToImmutableAllowancesForAgent { - pub(crate) obj_id: i32, + pub(crate) proxy: Proxy, } impl MapAgentIDToImmutableAllowancesForAgent { pub fn get_allowances_for_agent(&self, key: &ScAgentID) -> ImmutableAllowancesForAgent { - let sub_id = get_object_id(self.obj_id, key.get_key_id(), TYPE_MAP); - ImmutableAllowancesForAgent { obj_id: sub_id } + ImmutableAllowancesForAgent { proxy: self.proxy.key(&agent_id_to_bytes(key)) } } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableErc20State { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableErc20State { pub fn all_allowances(&self) -> MapAgentIDToImmutableAllowancesForAgent { - let map_id = get_object_id(self.id, STATE_ALL_ALLOWANCES.get_key_id(), TYPE_MAP); - MapAgentIDToImmutableAllowancesForAgent { obj_id: map_id } + MapAgentIDToImmutableAllowancesForAgent { proxy: self.proxy.root(STATE_ALL_ALLOWANCES) } } pub fn balances(&self) -> MapAgentIDToImmutableUint64 { - let map_id = get_object_id(self.id, STATE_BALANCES.get_key_id(), TYPE_MAP); - MapAgentIDToImmutableUint64 { obj_id: map_id } + MapAgentIDToImmutableUint64 { proxy: self.proxy.root(STATE_BALANCES) } } pub fn supply(&self) -> ScImmutableUint64 { - ScImmutableUint64::new(self.id, STATE_SUPPLY.get_key_id()) + ScImmutableUint64::new(self.proxy.root(STATE_SUPPLY)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MapAgentIDToMutableAllowancesForAgent { - pub(crate) obj_id: i32, + pub(crate) proxy: Proxy, } impl MapAgentIDToMutableAllowancesForAgent { pub fn clear(&self) { - clear(self.obj_id); + self.proxy.clear_map(); } pub fn get_allowances_for_agent(&self, key: &ScAgentID) -> MutableAllowancesForAgent { - let sub_id = get_object_id(self.obj_id, key.get_key_id(), TYPE_MAP); - MutableAllowancesForAgent { obj_id: sub_id } + MutableAllowancesForAgent { proxy: self.proxy.key(&agent_id_to_bytes(key)) } } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableErc20State { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableErc20State { pub fn as_immutable(&self) -> ImmutableErc20State { - ImmutableErc20State { id: self.id } + ImmutableErc20State { proxy: self.proxy.root("") } } pub fn all_allowances(&self) -> MapAgentIDToMutableAllowancesForAgent { - let map_id = get_object_id(self.id, STATE_ALL_ALLOWANCES.get_key_id(), TYPE_MAP); - MapAgentIDToMutableAllowancesForAgent { obj_id: map_id } + MapAgentIDToMutableAllowancesForAgent { proxy: self.proxy.root(STATE_ALL_ALLOWANCES) } } pub fn balances(&self) -> MapAgentIDToMutableUint64 { - let map_id = get_object_id(self.id, STATE_BALANCES.get_key_id(), TYPE_MAP); - MapAgentIDToMutableUint64 { obj_id: map_id } + MapAgentIDToMutableUint64 { proxy: self.proxy.root(STATE_BALANCES) } } pub fn supply(&self) -> ScMutableUint64 { - ScMutableUint64::new(self.id, STATE_SUPPLY.get_key_id()) + ScMutableUint64::new(self.proxy.root(STATE_SUPPLY)) } } diff --git a/contracts/wasm/erc20/src/typedefs.rs b/contracts/wasm/erc20/src/typedefs.rs index e0af7ebc3f..28aa811c16 100644 --- a/contracts/wasm/erc20/src/typedefs.rs +++ b/contracts/wasm/erc20/src/typedefs.rs @@ -8,33 +8,32 @@ #![allow(dead_code)] use wasmlib::*; -use wasmlib::host::*; -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MapAgentIDToImmutableUint64 { - pub(crate) obj_id: i32, + pub(crate) proxy: Proxy, } impl MapAgentIDToImmutableUint64 { pub fn get_uint64(&self, key: &ScAgentID) -> ScImmutableUint64 { - ScImmutableUint64::new(self.obj_id, key.get_key_id()) + ScImmutableUint64::new(self.proxy.key(&agent_id_to_bytes(key))) } } pub type ImmutableAllowancesForAgent = MapAgentIDToImmutableUint64; -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MapAgentIDToMutableUint64 { - pub(crate) obj_id: i32, + pub(crate) proxy: Proxy, } impl MapAgentIDToMutableUint64 { pub fn clear(&self) { - clear(self.obj_id); + self.proxy.clear_map(); } pub fn get_uint64(&self, key: &ScAgentID) -> ScMutableUint64 { - ScMutableUint64::new(self.obj_id, key.get_key_id()) + ScMutableUint64::new(self.proxy.key(&agent_id_to_bytes(key))) } }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qmy{n1ijofpk7xbjOlJzvqru5njJB4E)Sa#8stqo#8wyJ@AU z@aJVs;S^Dl)ln-K{yq2>>> DO NOT CHANGE THIS FILE! <<<< -// Change the json schema instead - - -export const IdxParamAccount = 0; -export const IdxParamAmount = 1; -export const IdxParamCreator = 2; -export const IdxParamDelegation = 3; -export const IdxParamRecipient = 4; -export const IdxParamSupply = 5; diff --git a/contracts/wasm/erc721/go/erc721/keys.go b/contracts/wasm/erc721/go/erc721/keys.go deleted file mode 100644 index 3fdcc944a6..0000000000 --- a/contracts/wasm/erc721/go/erc721/keys.go +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright 2020 IOTA Stiftung -// SPDX-License-Identifier: Apache-2.0 - -// (Re-)generated by schema tool -// >>>> DO NOT CHANGE THIS FILE! <<<< -// Change the json schema instead - -package erc721 diff --git a/contracts/wasm/erc721/src/contract.rs b/contracts/wasm/erc721/src/contract.rs index 4f23b4c652..c57cef147a 100644 --- a/contracts/wasm/erc721/src/contract.rs +++ b/contracts/wasm/erc721/src/contract.rs @@ -7,8 +7,6 @@ #![allow(dead_code)] -use std::ptr; - use wasmlib::*; use crate::consts::*; @@ -94,134 +92,139 @@ pub struct ScFuncs { } impl ScFuncs { - pub fn approve(_ctx: & dyn ScFuncCallContext) -> ApproveCall { + pub fn approve(_ctx: &dyn ScFuncCallContext) -> ApproveCall { let mut f = ApproveCall { func: ScFunc::new(HSC_NAME, HFUNC_APPROVE), - params: MutableApproveParams { id: 0 }, + params: MutableApproveParams { proxy: Proxy::nil() }, }; - f.func.set_ptrs(&mut f.params.id, ptr::null_mut()); + ScFunc::link_params(&mut f.params.proxy, &f.func); f } - pub fn burn(_ctx: & dyn ScFuncCallContext) -> BurnCall { + pub fn burn(_ctx: &dyn ScFuncCallContext) -> BurnCall { let mut f = BurnCall { func: ScFunc::new(HSC_NAME, HFUNC_BURN), - params: MutableBurnParams { id: 0 }, + params: MutableBurnParams { proxy: Proxy::nil() }, }; - f.func.set_ptrs(&mut f.params.id, ptr::null_mut()); + ScFunc::link_params(&mut f.params.proxy, &f.func); f } - pub fn init(_ctx: & dyn ScFuncCallContext) -> InitCall { + pub fn init(_ctx: &dyn ScFuncCallContext) -> InitCall { let mut f = InitCall { func: ScInitFunc::new(HSC_NAME, HFUNC_INIT), - params: MutableInitParams { id: 0 }, + params: MutableInitParams { proxy: Proxy::nil() }, }; - f.func.set_ptrs(&mut f.params.id, ptr::null_mut()); + ScInitFunc::link_params(&mut f.params.proxy, &f.func); f } - pub fn mint(_ctx: & dyn ScFuncCallContext) -> MintCall { + pub fn mint(_ctx: &dyn ScFuncCallContext) -> MintCall { let mut f = MintCall { func: ScFunc::new(HSC_NAME, HFUNC_MINT), - params: MutableMintParams { id: 0 }, + params: MutableMintParams { proxy: Proxy::nil() }, }; - f.func.set_ptrs(&mut f.params.id, ptr::null_mut()); + ScFunc::link_params(&mut f.params.proxy, &f.func); f } - pub fn safe_transfer_from(_ctx: & dyn ScFuncCallContext) -> SafeTransferFromCall { + pub fn safe_transfer_from(_ctx: &dyn ScFuncCallContext) -> SafeTransferFromCall { let mut f = SafeTransferFromCall { func: ScFunc::new(HSC_NAME, HFUNC_SAFE_TRANSFER_FROM), - params: MutableSafeTransferFromParams { id: 0 }, + params: MutableSafeTransferFromParams { proxy: Proxy::nil() }, }; - f.func.set_ptrs(&mut f.params.id, ptr::null_mut()); + ScFunc::link_params(&mut f.params.proxy, &f.func); f } - pub fn set_approval_for_all(_ctx: & dyn ScFuncCallContext) -> SetApprovalForAllCall { + pub fn set_approval_for_all(_ctx: &dyn ScFuncCallContext) -> SetApprovalForAllCall { let mut f = SetApprovalForAllCall { func: ScFunc::new(HSC_NAME, HFUNC_SET_APPROVAL_FOR_ALL), - params: MutableSetApprovalForAllParams { id: 0 }, + params: MutableSetApprovalForAllParams { proxy: Proxy::nil() }, }; - f.func.set_ptrs(&mut f.params.id, ptr::null_mut()); + ScFunc::link_params(&mut f.params.proxy, &f.func); f } - pub fn transfer_from(_ctx: & dyn ScFuncCallContext) -> TransferFromCall { + pub fn transfer_from(_ctx: &dyn ScFuncCallContext) -> TransferFromCall { let mut f = TransferFromCall { func: ScFunc::new(HSC_NAME, HFUNC_TRANSFER_FROM), - params: MutableTransferFromParams { id: 0 }, + params: MutableTransferFromParams { proxy: Proxy::nil() }, }; - f.func.set_ptrs(&mut f.params.id, ptr::null_mut()); + ScFunc::link_params(&mut f.params.proxy, &f.func); f } - pub fn balance_of(_ctx: & dyn ScViewCallContext) -> BalanceOfCall { + pub fn balance_of(_ctx: &dyn ScViewCallContext) -> BalanceOfCall { let mut f = BalanceOfCall { func: ScView::new(HSC_NAME, HVIEW_BALANCE_OF), - params: MutableBalanceOfParams { id: 0 }, - results: ImmutableBalanceOfResults { id: 0 }, + params: MutableBalanceOfParams { proxy: Proxy::nil() }, + results: ImmutableBalanceOfResults { proxy: Proxy::nil() }, }; - f.func.set_ptrs(&mut f.params.id, &mut f.results.id); + ScView::link_params(&mut f.params.proxy, &f.func); + ScView::link_results(&mut f.results.proxy, &f.func); f } - pub fn get_approved(_ctx: & dyn ScViewCallContext) -> GetApprovedCall { + pub fn get_approved(_ctx: &dyn ScViewCallContext) -> GetApprovedCall { let mut f = GetApprovedCall { func: ScView::new(HSC_NAME, HVIEW_GET_APPROVED), - params: MutableGetApprovedParams { id: 0 }, - results: ImmutableGetApprovedResults { id: 0 }, + params: MutableGetApprovedParams { proxy: Proxy::nil() }, + results: ImmutableGetApprovedResults { proxy: Proxy::nil() }, }; - f.func.set_ptrs(&mut f.params.id, &mut f.results.id); + ScView::link_params(&mut f.params.proxy, &f.func); + ScView::link_results(&mut f.results.proxy, &f.func); f } - pub fn is_approved_for_all(_ctx: & dyn ScViewCallContext) -> IsApprovedForAllCall { + pub fn is_approved_for_all(_ctx: &dyn ScViewCallContext) -> IsApprovedForAllCall { let mut f = IsApprovedForAllCall { func: ScView::new(HSC_NAME, HVIEW_IS_APPROVED_FOR_ALL), - params: MutableIsApprovedForAllParams { id: 0 }, - results: ImmutableIsApprovedForAllResults { id: 0 }, + params: MutableIsApprovedForAllParams { proxy: Proxy::nil() }, + results: ImmutableIsApprovedForAllResults { proxy: Proxy::nil() }, }; - f.func.set_ptrs(&mut f.params.id, &mut f.results.id); + ScView::link_params(&mut f.params.proxy, &f.func); + ScView::link_results(&mut f.results.proxy, &f.func); f } - pub fn name(_ctx: & dyn ScViewCallContext) -> NameCall { + pub fn name(_ctx: &dyn ScViewCallContext) -> NameCall { let mut f = NameCall { func: ScView::new(HSC_NAME, HVIEW_NAME), - results: ImmutableNameResults { id: 0 }, + results: ImmutableNameResults { proxy: Proxy::nil() }, }; - f.func.set_ptrs(ptr::null_mut(), &mut f.results.id); + ScView::link_results(&mut f.results.proxy, &f.func); f } - pub fn owner_of(_ctx: & dyn ScViewCallContext) -> OwnerOfCall { + pub fn owner_of(_ctx: &dyn ScViewCallContext) -> OwnerOfCall { let mut f = OwnerOfCall { func: ScView::new(HSC_NAME, HVIEW_OWNER_OF), - params: MutableOwnerOfParams { id: 0 }, - results: ImmutableOwnerOfResults { id: 0 }, + params: MutableOwnerOfParams { proxy: Proxy::nil() }, + results: ImmutableOwnerOfResults { proxy: Proxy::nil() }, }; - f.func.set_ptrs(&mut f.params.id, &mut f.results.id); + ScView::link_params(&mut f.params.proxy, &f.func); + ScView::link_results(&mut f.results.proxy, &f.func); f } - pub fn symbol(_ctx: & dyn ScViewCallContext) -> SymbolCall { + pub fn symbol(_ctx: &dyn ScViewCallContext) -> SymbolCall { let mut f = SymbolCall { func: ScView::new(HSC_NAME, HVIEW_SYMBOL), - results: ImmutableSymbolResults { id: 0 }, + results: ImmutableSymbolResults { proxy: Proxy::nil() }, }; - f.func.set_ptrs(ptr::null_mut(), &mut f.results.id); + ScView::link_results(&mut f.results.proxy, &f.func); f } - pub fn token_uri(_ctx: & dyn ScViewCallContext) -> TokenURICall { + pub fn token_uri(_ctx: &dyn ScViewCallContext) -> TokenURICall { let mut f = TokenURICall { func: ScView::new(HSC_NAME, HVIEW_TOKEN_URI), - params: MutableTokenURIParams { id: 0 }, - results: ImmutableTokenURIResults { id: 0 }, + params: MutableTokenURIParams { proxy: Proxy::nil() }, + results: ImmutableTokenURIResults { proxy: Proxy::nil() }, }; - f.func.set_ptrs(&mut f.params.id, &mut f.results.id); + ScView::link_params(&mut f.params.proxy, &f.func); + ScView::link_results(&mut f.results.proxy, &f.func); f } } diff --git a/contracts/wasm/erc721/src/erc721.rs b/contracts/wasm/erc721/src/erc721.rs index 26b0263492..503bc78f26 100644 --- a/contracts/wasm/erc721/src/erc721.rs +++ b/contracts/wasm/erc721/src/erc721.rs @@ -22,7 +22,7 @@ const BASE_URI: &str = "my/special/base/uri/"; /////////////////////////// HELPER FUNCTIONS //////////////////////////// // checks if caller is owner, or one of its delegated operators -fn can_operate(state: MutableErc721State, caller: &ScAgentID, owner: &ScAgentID) -> bool { +fn can_operate(state: &MutableErc721State, caller: &ScAgentID, owner: &ScAgentID) -> bool { if *caller == *owner { return true; } @@ -32,7 +32,7 @@ fn can_operate(state: MutableErc721State, caller: &ScAgentID, owner: &ScAgentID) } // checks if caller is owner, or one of its delegated operators, or approved account for tokenID -fn can_transfer(state: MutableErc721State, caller: &ScAgentID, owner: &ScAgentID, token_id: &ScHash) -> bool { +fn can_transfer(state: &MutableErc721State, caller: &ScAgentID, owner: &ScAgentID, token_id: &ScHash) -> bool { if can_operate(state, caller, owner) { return true; } @@ -42,7 +42,7 @@ fn can_transfer(state: MutableErc721State, caller: &ScAgentID, owner: &ScAgentID } // common code for safeTransferFrom and transferFrom -fn transfer(ctx: &ScFuncContext, state: MutableErc721State, from: &ScAgentID, to: &ScAgentID, token_id: &ScHash) { +fn transfer(ctx: &ScFuncContext, state: &MutableErc721State, from: &ScAgentID, to: &ScAgentID, token_id: &ScHash) { let token_owner = state.owners().get_agent_id(token_id); ctx.require(token_owner.exists(), "tokenID does not exist"); @@ -66,12 +66,16 @@ fn transfer(ctx: &ScFuncContext, state: MutableErc721State, from: &ScAgentID, to let current_approved = state.approved_accounts().get_agent_id(&token_id); if current_approved.exists() { current_approved.delete(); - events.approval(&ScAgentID::ZERO, &owner, &token_id); + events.approval(&zero(), &owner, &token_id); } events.transfer(from, to, token_id); } +fn zero() -> ScAgentID { + ScAgentID::from_bytes(&[]) +} + /////////////////////////// SC FUNCS //////////////////////////// // Gives permission to to to transfer tokenID token to another account. @@ -82,7 +86,7 @@ pub fn func_approve(ctx: &ScFuncContext, f: &ApproveContext) { let token_owner = f.state.owners().get_agent_id(&token_id); ctx.require(token_owner.exists(), "tokenID does not exist"); let owner = token_owner.value(); - ctx.require(can_operate(f.state, &ctx.caller(), &owner), "not owner or operator"); + ctx.require(can_operate(&f.state, &ctx.caller(), &owner), "not owner or operator"); let approved = f.params.approved(); if !approved.exists() { @@ -90,7 +94,7 @@ pub fn func_approve(ctx: &ScFuncContext, f: &ApproveContext) { let current_approved = f.state.approved_accounts().get_agent_id(&token_id); if current_approved.exists() { current_approved.delete(); - f.events.approval(&ScAgentID::ZERO, &owner, &token_id); + f.events.approval(&zero(), &owner, &token_id); } return; } @@ -106,21 +110,21 @@ pub fn func_approve(ctx: &ScFuncContext, f: &ApproveContext) { pub fn func_burn(ctx: &ScFuncContext, f: &BurnContext) { let token_id = f.params.token_id().value(); let owner = f.state.owners().get_agent_id(&token_id).value(); - ctx.require(owner != ScAgentID::ZERO, "tokenID does not exist"); + ctx.require(owner != zero(), "tokenID does not exist"); ctx.require(ctx.caller() == owner, "caller is not owner"); // remove approval if it exists let current_approved = f.state.approved_accounts().get_agent_id(&token_id); if current_approved.exists() { current_approved.delete(); - f.events.approval(&ScAgentID::ZERO, &owner, &token_id); + f.events.approval(&zero(), &owner, &token_id); } let balance = f.state.balances().get_uint64(&owner); balance.set_value(balance.value() - 1); f.state.owners().get_agent_id(&token_id).delete(); - f.events.transfer(&owner, &ScAgentID::ZERO, &token_id); + f.events.transfer(&owner, &zero(), &token_id); } // Initializes the contract by setting a name and a symbol to the token collection. @@ -151,7 +155,7 @@ pub fn func_mint(ctx: &ScFuncContext, f: &MintContext) { let balance = f.state.balances().get_uint64(&owner); balance.set_value(balance.value() + 1); - f.events.transfer(&ScAgentID::ZERO, &owner, &token_id); + f.events.transfer(&zero(), &owner, &token_id); // if !owner.is_address() { // //TODO interpret to as SC address and call its onERC721Received() function // } @@ -163,7 +167,7 @@ pub fn func_safe_transfer_from(ctx: &ScFuncContext, f: &SafeTransferFromContext) let from = f.params.from().value(); let to = f.params.to().value(); let token_id = f.params.token_id().value(); - transfer(&ctx, f.state, &from, &to, &token_id); + transfer(&ctx, &f.state, &from, &to, &token_id); // if !to.is_address() { // //TODO interpret to as SC address and call its onERC721Received() function // } @@ -187,7 +191,7 @@ pub fn func_transfer_from(ctx: &ScFuncContext, f: &TransferFromContext) { let from = f.params.from().value(); let to = f.params.to().value(); let token_id = f.params.token_id().value(); - transfer(ctx, f.state, &from, &to, &token_id); + transfer(ctx, &f.state, &from, &to, &token_id); } /////////////////////////// SC VIEWS //////////////////////////// diff --git a/contracts/wasm/erc721/src/events.rs b/contracts/wasm/erc721/src/events.rs index 5d13ded8be..f4f652f53e 100644 --- a/contracts/wasm/erc721/src/events.rs +++ b/contracts/wasm/erc721/src/events.rs @@ -6,6 +6,7 @@ // Change the json schema instead #![allow(dead_code)] +#![allow(unused_mut)] use wasmlib::*; @@ -15,41 +16,41 @@ pub struct Erc721Events { impl Erc721Events { pub fn approval(&self, approved: &ScAgentID, owner: &ScAgentID, token_id: &ScHash) { - let mut encoder = EventEncoder::new("erc721.approval"); - encoder.agent_id(&approved); - encoder.agent_id(&owner); - encoder.hash(&token_id); - encoder.emit(); + let mut evt = EventEncoder::new("erc721.approval"); + evt.encode(&agent_id_to_string(&approved)); + evt.encode(&agent_id_to_string(&owner)); + evt.encode(&hash_to_string(&token_id)); + evt.emit(); } pub fn approval_for_all(&self, approval: bool, operator: &ScAgentID, owner: &ScAgentID) { - let mut encoder = EventEncoder::new("erc721.approvalForAll"); - encoder.bool(approval); - encoder.agent_id(&operator); - encoder.agent_id(&owner); - encoder.emit(); + let mut evt = EventEncoder::new("erc721.approvalForAll"); + evt.encode(&bool_to_string(approval)); + evt.encode(&agent_id_to_string(&operator)); + evt.encode(&agent_id_to_string(&owner)); + evt.emit(); } pub fn init(&self, name: &str, symbol: &str) { - let mut encoder = EventEncoder::new("erc721.init"); - encoder.string(&name); - encoder.string(&symbol); - encoder.emit(); + let mut evt = EventEncoder::new("erc721.init"); + evt.encode(&string_to_string(&name)); + evt.encode(&string_to_string(&symbol)); + evt.emit(); } pub fn mint(&self, balance: u64, owner: &ScAgentID, token_id: &ScHash) { - let mut encoder = EventEncoder::new("erc721.mint"); - encoder.uint64(balance); - encoder.agent_id(&owner); - encoder.hash(&token_id); - encoder.emit(); + let mut evt = EventEncoder::new("erc721.mint"); + evt.encode(&uint64_to_string(balance)); + evt.encode(&agent_id_to_string(&owner)); + evt.encode(&hash_to_string(&token_id)); + evt.emit(); } pub fn transfer(&self, from: &ScAgentID, to: &ScAgentID, token_id: &ScHash) { - let mut encoder = EventEncoder::new("erc721.transfer"); - encoder.agent_id(&from); - encoder.agent_id(&to); - encoder.hash(&token_id); - encoder.emit(); + let mut evt = EventEncoder::new("erc721.transfer"); + evt.encode(&agent_id_to_string(&from)); + evt.encode(&agent_id_to_string(&to)); + evt.encode(&hash_to_string(&token_id)); + evt.emit(); } } diff --git a/contracts/wasm/erc721/src/keys.rs b/contracts/wasm/erc721/src/keys.rs deleted file mode 100644 index dacf7d5ea9..0000000000 --- a/contracts/wasm/erc721/src/keys.rs +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright 2020 IOTA Stiftung -// SPDX-License-Identifier: Apache-2.0 - -// (Re-)generated by schema tool -// >>>> DO NOT CHANGE THIS FILE! <<<< -// Change the json schema instead - -#![allow(dead_code)] - -use wasmlib::*; - -use crate::*; - -pub(crate) const IDX_PARAM_APPROVAL : usize = 0; -pub(crate) const IDX_PARAM_APPROVED : usize = 1; -pub(crate) const IDX_PARAM_DATA : usize = 2; -pub(crate) const IDX_PARAM_FROM : usize = 3; -pub(crate) const IDX_PARAM_NAME : usize = 4; -pub(crate) const IDX_PARAM_OPERATOR : usize = 5; -pub(crate) const IDX_PARAM_OWNER : usize = 6; -pub(crate) const IDX_PARAM_SYMBOL : usize = 7; -pub(crate) const IDX_PARAM_TO : usize = 8; -pub(crate) const IDX_PARAM_TOKEN_ID : usize = 9; -pub(crate) const IDX_PARAM_TOKEN_URI : usize = 10; - -pub(crate) const IDX_RESULT_AMOUNT : usize = 11; -pub(crate) const IDX_RESULT_APPROVAL : usize = 12; -pub(crate) const IDX_RESULT_APPROVED : usize = 13; -pub(crate) const IDX_RESULT_NAME : usize = 14; -pub(crate) const IDX_RESULT_OWNER : usize = 15; -pub(crate) const IDX_RESULT_SYMBOL : usize = 16; -pub(crate) const IDX_RESULT_TOKEN_URI : usize = 17; - -pub(crate) const IDX_STATE_APPROVED_ACCOUNTS : usize = 18; -pub(crate) const IDX_STATE_APPROVED_OPERATORS : usize = 19; -pub(crate) const IDX_STATE_BALANCES : usize = 20; -pub(crate) const IDX_STATE_NAME : usize = 21; -pub(crate) const IDX_STATE_OWNERS : usize = 22; -pub(crate) const IDX_STATE_SYMBOL : usize = 23; -pub(crate) const IDX_STATE_TOKEN_UR_IS : usize = 24; - -pub const KEY_MAP_LEN: usize = 25; - -pub const KEY_MAP: [&str; KEY_MAP_LEN] = [ - PARAM_APPROVAL, - PARAM_APPROVED, - PARAM_DATA, - PARAM_FROM, - PARAM_NAME, - PARAM_OPERATOR, - PARAM_OWNER, - PARAM_SYMBOL, - PARAM_TO, - PARAM_TOKEN_ID, - PARAM_TOKEN_URI, - RESULT_AMOUNT, - RESULT_APPROVAL, - RESULT_APPROVED, - RESULT_NAME, - RESULT_OWNER, - RESULT_SYMBOL, - RESULT_TOKEN_URI, - STATE_APPROVED_ACCOUNTS, - STATE_APPROVED_OPERATORS, - STATE_BALANCES, - STATE_NAME, - STATE_OWNERS, - STATE_SYMBOL, - STATE_TOKEN_UR_IS, -]; - -pub static mut IDX_MAP: [Key32; KEY_MAP_LEN] = [Key32(0); KEY_MAP_LEN]; - -pub fn idx_map(idx: usize) -> Key32 { - unsafe { - IDX_MAP[idx] - } -} diff --git a/contracts/wasm/erc721/src/lib.rs b/contracts/wasm/erc721/src/lib.rs index c1ab699f72..6318a9e84e 100644 --- a/contracts/wasm/erc721/src/lib.rs +++ b/contracts/wasm/erc721/src/lib.rs @@ -10,19 +10,17 @@ use erc721::*; use wasmlib::*; -use wasmlib::host::*; use crate::consts::*; use crate::events::*; -use crate::keys::*; use crate::params::*; use crate::results::*; use crate::state::*; +use crate::typedefs::*; mod consts; mod contract; mod events; -mod keys; mod params; mod results; mod state; @@ -46,12 +44,6 @@ fn on_load() { exports.add_view(VIEW_OWNER_OF, view_owner_of_thunk); exports.add_view(VIEW_SYMBOL, view_symbol_thunk); exports.add_view(VIEW_TOKEN_URI, view_token_uri_thunk); - - unsafe { - for i in 0..KEY_MAP_LEN { - IDX_MAP[i] = get_key_id_from_string(KEY_MAP[i]); - } - } } pub struct ApproveContext { @@ -64,12 +56,8 @@ fn func_approve_thunk(ctx: &ScFuncContext) { ctx.log("erc721.funcApprove"); let f = ApproveContext { events: Erc721Events {}, - params: ImmutableApproveParams { - id: OBJ_ID_PARAMS, - }, - state: MutableErc721State { - id: OBJ_ID_STATE, - }, + params: ImmutableApproveParams { proxy: params_proxy() }, + state: MutableErc721State { proxy: state_proxy() }, }; ctx.require(f.params.token_id().exists(), "missing mandatory tokenID"); func_approve(ctx, &f); @@ -86,12 +74,8 @@ fn func_burn_thunk(ctx: &ScFuncContext) { ctx.log("erc721.funcBurn"); let f = BurnContext { events: Erc721Events {}, - params: ImmutableBurnParams { - id: OBJ_ID_PARAMS, - }, - state: MutableErc721State { - id: OBJ_ID_STATE, - }, + params: ImmutableBurnParams { proxy: params_proxy() }, + state: MutableErc721State { proxy: state_proxy() }, }; ctx.require(f.params.token_id().exists(), "missing mandatory tokenID"); func_burn(ctx, &f); @@ -108,12 +92,8 @@ fn func_init_thunk(ctx: &ScFuncContext) { ctx.log("erc721.funcInit"); let f = InitContext { events: Erc721Events {}, - params: ImmutableInitParams { - id: OBJ_ID_PARAMS, - }, - state: MutableErc721State { - id: OBJ_ID_STATE, - }, + params: ImmutableInitParams { proxy: params_proxy() }, + state: MutableErc721State { proxy: state_proxy() }, }; ctx.require(f.params.name().exists(), "missing mandatory name"); ctx.require(f.params.symbol().exists(), "missing mandatory symbol"); @@ -131,12 +111,8 @@ fn func_mint_thunk(ctx: &ScFuncContext) { ctx.log("erc721.funcMint"); let f = MintContext { events: Erc721Events {}, - params: ImmutableMintParams { - id: OBJ_ID_PARAMS, - }, - state: MutableErc721State { - id: OBJ_ID_STATE, - }, + params: ImmutableMintParams { proxy: params_proxy() }, + state: MutableErc721State { proxy: state_proxy() }, }; ctx.require(f.params.token_id().exists(), "missing mandatory tokenID"); func_mint(ctx, &f); @@ -153,12 +129,8 @@ fn func_safe_transfer_from_thunk(ctx: &ScFuncContext) { ctx.log("erc721.funcSafeTransferFrom"); let f = SafeTransferFromContext { events: Erc721Events {}, - params: ImmutableSafeTransferFromParams { - id: OBJ_ID_PARAMS, - }, - state: MutableErc721State { - id: OBJ_ID_STATE, - }, + params: ImmutableSafeTransferFromParams { proxy: params_proxy() }, + state: MutableErc721State { proxy: state_proxy() }, }; ctx.require(f.params.from().exists(), "missing mandatory from"); ctx.require(f.params.to().exists(), "missing mandatory to"); @@ -177,12 +149,8 @@ fn func_set_approval_for_all_thunk(ctx: &ScFuncContext) { ctx.log("erc721.funcSetApprovalForAll"); let f = SetApprovalForAllContext { events: Erc721Events {}, - params: ImmutableSetApprovalForAllParams { - id: OBJ_ID_PARAMS, - }, - state: MutableErc721State { - id: OBJ_ID_STATE, - }, + params: ImmutableSetApprovalForAllParams { proxy: params_proxy() }, + state: MutableErc721State { proxy: state_proxy() }, }; ctx.require(f.params.approval().exists(), "missing mandatory approval"); ctx.require(f.params.operator().exists(), "missing mandatory operator"); @@ -200,12 +168,8 @@ fn func_transfer_from_thunk(ctx: &ScFuncContext) { ctx.log("erc721.funcTransferFrom"); let f = TransferFromContext { events: Erc721Events {}, - params: ImmutableTransferFromParams { - id: OBJ_ID_PARAMS, - }, - state: MutableErc721State { - id: OBJ_ID_STATE, - }, + params: ImmutableTransferFromParams { proxy: params_proxy() }, + state: MutableErc721State { proxy: state_proxy() }, }; ctx.require(f.params.from().exists(), "missing mandatory from"); ctx.require(f.params.to().exists(), "missing mandatory to"); @@ -223,18 +187,13 @@ pub struct BalanceOfContext { fn view_balance_of_thunk(ctx: &ScViewContext) { ctx.log("erc721.viewBalanceOf"); let f = BalanceOfContext { - params: ImmutableBalanceOfParams { - id: OBJ_ID_PARAMS, - }, - results: MutableBalanceOfResults { - id: OBJ_ID_RESULTS, - }, - state: ImmutableErc721State { - id: OBJ_ID_STATE, - }, + params: ImmutableBalanceOfParams { proxy: params_proxy() }, + results: MutableBalanceOfResults { proxy: results_proxy() }, + state: ImmutableErc721State { proxy: state_proxy() }, }; ctx.require(f.params.owner().exists(), "missing mandatory owner"); view_balance_of(ctx, &f); + ctx.results(&f.results.proxy.kv_store); ctx.log("erc721.viewBalanceOf ok"); } @@ -247,18 +206,13 @@ pub struct GetApprovedContext { fn view_get_approved_thunk(ctx: &ScViewContext) { ctx.log("erc721.viewGetApproved"); let f = GetApprovedContext { - params: ImmutableGetApprovedParams { - id: OBJ_ID_PARAMS, - }, - results: MutableGetApprovedResults { - id: OBJ_ID_RESULTS, - }, - state: ImmutableErc721State { - id: OBJ_ID_STATE, - }, + params: ImmutableGetApprovedParams { proxy: params_proxy() }, + results: MutableGetApprovedResults { proxy: results_proxy() }, + state: ImmutableErc721State { proxy: state_proxy() }, }; ctx.require(f.params.token_id().exists(), "missing mandatory tokenID"); view_get_approved(ctx, &f); + ctx.results(&f.results.proxy.kv_store); ctx.log("erc721.viewGetApproved ok"); } @@ -271,19 +225,14 @@ pub struct IsApprovedForAllContext { fn view_is_approved_for_all_thunk(ctx: &ScViewContext) { ctx.log("erc721.viewIsApprovedForAll"); let f = IsApprovedForAllContext { - params: ImmutableIsApprovedForAllParams { - id: OBJ_ID_PARAMS, - }, - results: MutableIsApprovedForAllResults { - id: OBJ_ID_RESULTS, - }, - state: ImmutableErc721State { - id: OBJ_ID_STATE, - }, + params: ImmutableIsApprovedForAllParams { proxy: params_proxy() }, + results: MutableIsApprovedForAllResults { proxy: results_proxy() }, + state: ImmutableErc721State { proxy: state_proxy() }, }; ctx.require(f.params.operator().exists(), "missing mandatory operator"); ctx.require(f.params.owner().exists(), "missing mandatory owner"); view_is_approved_for_all(ctx, &f); + ctx.results(&f.results.proxy.kv_store); ctx.log("erc721.viewIsApprovedForAll ok"); } @@ -295,14 +244,11 @@ pub struct NameContext { fn view_name_thunk(ctx: &ScViewContext) { ctx.log("erc721.viewName"); let f = NameContext { - results: MutableNameResults { - id: OBJ_ID_RESULTS, - }, - state: ImmutableErc721State { - id: OBJ_ID_STATE, - }, + results: MutableNameResults { proxy: results_proxy() }, + state: ImmutableErc721State { proxy: state_proxy() }, }; view_name(ctx, &f); + ctx.results(&f.results.proxy.kv_store); ctx.log("erc721.viewName ok"); } @@ -315,18 +261,13 @@ pub struct OwnerOfContext { fn view_owner_of_thunk(ctx: &ScViewContext) { ctx.log("erc721.viewOwnerOf"); let f = OwnerOfContext { - params: ImmutableOwnerOfParams { - id: OBJ_ID_PARAMS, - }, - results: MutableOwnerOfResults { - id: OBJ_ID_RESULTS, - }, - state: ImmutableErc721State { - id: OBJ_ID_STATE, - }, + params: ImmutableOwnerOfParams { proxy: params_proxy() }, + results: MutableOwnerOfResults { proxy: results_proxy() }, + state: ImmutableErc721State { proxy: state_proxy() }, }; ctx.require(f.params.token_id().exists(), "missing mandatory tokenID"); view_owner_of(ctx, &f); + ctx.results(&f.results.proxy.kv_store); ctx.log("erc721.viewOwnerOf ok"); } @@ -338,14 +279,11 @@ pub struct SymbolContext { fn view_symbol_thunk(ctx: &ScViewContext) { ctx.log("erc721.viewSymbol"); let f = SymbolContext { - results: MutableSymbolResults { - id: OBJ_ID_RESULTS, - }, - state: ImmutableErc721State { - id: OBJ_ID_STATE, - }, + results: MutableSymbolResults { proxy: results_proxy() }, + state: ImmutableErc721State { proxy: state_proxy() }, }; view_symbol(ctx, &f); + ctx.results(&f.results.proxy.kv_store); ctx.log("erc721.viewSymbol ok"); } @@ -358,17 +296,12 @@ pub struct TokenURIContext { fn view_token_uri_thunk(ctx: &ScViewContext) { ctx.log("erc721.viewTokenURI"); let f = TokenURIContext { - params: ImmutableTokenURIParams { - id: OBJ_ID_PARAMS, - }, - results: MutableTokenURIResults { - id: OBJ_ID_RESULTS, - }, - state: ImmutableErc721State { - id: OBJ_ID_STATE, - }, + params: ImmutableTokenURIParams { proxy: params_proxy() }, + results: MutableTokenURIResults { proxy: results_proxy() }, + state: ImmutableErc721State { proxy: state_proxy() }, }; ctx.require(f.params.token_id().exists(), "missing mandatory tokenID"); view_token_uri(ctx, &f); + ctx.results(&f.results.proxy.kv_store); ctx.log("erc721.viewTokenURI ok"); } diff --git a/contracts/wasm/erc721/src/params.rs b/contracts/wasm/erc721/src/params.rs index 14db52728e..b4dd0d00e6 100644 --- a/contracts/wasm/erc721/src/params.rs +++ b/contracts/wasm/erc721/src/params.rs @@ -9,352 +9,348 @@ #![allow(unused_imports)] use wasmlib::*; -use wasmlib::host::*; - use crate::*; -use crate::keys::*; -use crate::typedefs::*; -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableApproveParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableApproveParams { pub fn approved(&self) -> ScImmutableAgentID { - ScImmutableAgentID::new(self.id, PARAM_APPROVED.get_key_id()) + ScImmutableAgentID::new(self.proxy.root(PARAM_APPROVED)) } pub fn token_id(&self) -> ScImmutableHash { - ScImmutableHash::new(self.id, PARAM_TOKEN_ID.get_key_id()) + ScImmutableHash::new(self.proxy.root(PARAM_TOKEN_ID)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableApproveParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableApproveParams { pub fn approved(&self) -> ScMutableAgentID { - ScMutableAgentID::new(self.id, PARAM_APPROVED.get_key_id()) + ScMutableAgentID::new(self.proxy.root(PARAM_APPROVED)) } pub fn token_id(&self) -> ScMutableHash { - ScMutableHash::new(self.id, PARAM_TOKEN_ID.get_key_id()) + ScMutableHash::new(self.proxy.root(PARAM_TOKEN_ID)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableBurnParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableBurnParams { pub fn token_id(&self) -> ScImmutableHash { - ScImmutableHash::new(self.id, PARAM_TOKEN_ID.get_key_id()) + ScImmutableHash::new(self.proxy.root(PARAM_TOKEN_ID)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableBurnParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableBurnParams { pub fn token_id(&self) -> ScMutableHash { - ScMutableHash::new(self.id, PARAM_TOKEN_ID.get_key_id()) + ScMutableHash::new(self.proxy.root(PARAM_TOKEN_ID)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableInitParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableInitParams { pub fn name(&self) -> ScImmutableString { - ScImmutableString::new(self.id, idx_map(IDX_PARAM_NAME)) + ScImmutableString::new(self.proxy.root(PARAM_NAME)) } pub fn symbol(&self) -> ScImmutableString { - ScImmutableString::new(self.id, idx_map(IDX_PARAM_SYMBOL)) + ScImmutableString::new(self.proxy.root(PARAM_SYMBOL)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableInitParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableInitParams { pub fn name(&self) -> ScMutableString { - ScMutableString::new(self.id, idx_map(IDX_PARAM_NAME)) + ScMutableString::new(self.proxy.root(PARAM_NAME)) } pub fn symbol(&self) -> ScMutableString { - ScMutableString::new(self.id, idx_map(IDX_PARAM_SYMBOL)) + ScMutableString::new(self.proxy.root(PARAM_SYMBOL)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableMintParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableMintParams { pub fn token_id(&self) -> ScImmutableHash { - ScImmutableHash::new(self.id, PARAM_TOKEN_ID.get_key_id()) + ScImmutableHash::new(self.proxy.root(PARAM_TOKEN_ID)) } pub fn token_uri(&self) -> ScImmutableString { - ScImmutableString::new(self.id, PARAM_TOKEN_URI.get_key_id()) + ScImmutableString::new(self.proxy.root(PARAM_TOKEN_URI)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableMintParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableMintParams { pub fn token_id(&self) -> ScMutableHash { - ScMutableHash::new(self.id, PARAM_TOKEN_ID.get_key_id()) + ScMutableHash::new(self.proxy.root(PARAM_TOKEN_ID)) } pub fn token_uri(&self) -> ScMutableString { - ScMutableString::new(self.id, PARAM_TOKEN_URI.get_key_id()) + ScMutableString::new(self.proxy.root(PARAM_TOKEN_URI)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableSafeTransferFromParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableSafeTransferFromParams { pub fn data(&self) -> ScImmutableBytes { - ScImmutableBytes::new(self.id, PARAM_DATA.get_key_id()) + ScImmutableBytes::new(self.proxy.root(PARAM_DATA)) } pub fn from(&self) -> ScImmutableAgentID { - ScImmutableAgentID::new(self.id, PARAM_FROM.get_key_id()) + ScImmutableAgentID::new(self.proxy.root(PARAM_FROM)) } pub fn to(&self) -> ScImmutableAgentID { - ScImmutableAgentID::new(self.id, PARAM_TO.get_key_id()) + ScImmutableAgentID::new(self.proxy.root(PARAM_TO)) } pub fn token_id(&self) -> ScImmutableHash { - ScImmutableHash::new(self.id, PARAM_TOKEN_ID.get_key_id()) + ScImmutableHash::new(self.proxy.root(PARAM_TOKEN_ID)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableSafeTransferFromParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableSafeTransferFromParams { pub fn data(&self) -> ScMutableBytes { - ScMutableBytes::new(self.id, PARAM_DATA.get_key_id()) + ScMutableBytes::new(self.proxy.root(PARAM_DATA)) } pub fn from(&self) -> ScMutableAgentID { - ScMutableAgentID::new(self.id, PARAM_FROM.get_key_id()) + ScMutableAgentID::new(self.proxy.root(PARAM_FROM)) } pub fn to(&self) -> ScMutableAgentID { - ScMutableAgentID::new(self.id, PARAM_TO.get_key_id()) + ScMutableAgentID::new(self.proxy.root(PARAM_TO)) } pub fn token_id(&self) -> ScMutableHash { - ScMutableHash::new(self.id, PARAM_TOKEN_ID.get_key_id()) + ScMutableHash::new(self.proxy.root(PARAM_TOKEN_ID)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableSetApprovalForAllParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableSetApprovalForAllParams { pub fn approval(&self) -> ScImmutableBool { - ScImmutableBool::new(self.id, PARAM_APPROVAL.get_key_id()) + ScImmutableBool::new(self.proxy.root(PARAM_APPROVAL)) } pub fn operator(&self) -> ScImmutableAgentID { - ScImmutableAgentID::new(self.id, PARAM_OPERATOR.get_key_id()) + ScImmutableAgentID::new(self.proxy.root(PARAM_OPERATOR)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableSetApprovalForAllParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableSetApprovalForAllParams { pub fn approval(&self) -> ScMutableBool { - ScMutableBool::new(self.id, PARAM_APPROVAL.get_key_id()) + ScMutableBool::new(self.proxy.root(PARAM_APPROVAL)) } pub fn operator(&self) -> ScMutableAgentID { - ScMutableAgentID::new(self.id, PARAM_OPERATOR.get_key_id()) + ScMutableAgentID::new(self.proxy.root(PARAM_OPERATOR)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableTransferFromParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableTransferFromParams { pub fn from(&self) -> ScImmutableAgentID { - ScImmutableAgentID::new(self.id, PARAM_FROM.get_key_id()) + ScImmutableAgentID::new(self.proxy.root(PARAM_FROM)) } pub fn to(&self) -> ScImmutableAgentID { - ScImmutableAgentID::new(self.id, PARAM_TO.get_key_id()) + ScImmutableAgentID::new(self.proxy.root(PARAM_TO)) } pub fn token_id(&self) -> ScImmutableHash { - ScImmutableHash::new(self.id, PARAM_TOKEN_ID.get_key_id()) + ScImmutableHash::new(self.proxy.root(PARAM_TOKEN_ID)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableTransferFromParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableTransferFromParams { pub fn from(&self) -> ScMutableAgentID { - ScMutableAgentID::new(self.id, PARAM_FROM.get_key_id()) + ScMutableAgentID::new(self.proxy.root(PARAM_FROM)) } pub fn to(&self) -> ScMutableAgentID { - ScMutableAgentID::new(self.id, PARAM_TO.get_key_id()) + ScMutableAgentID::new(self.proxy.root(PARAM_TO)) } pub fn token_id(&self) -> ScMutableHash { - ScMutableHash::new(self.id, PARAM_TOKEN_ID.get_key_id()) + ScMutableHash::new(self.proxy.root(PARAM_TOKEN_ID)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableBalanceOfParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableBalanceOfParams { pub fn owner(&self) -> ScImmutableAgentID { - ScImmutableAgentID::new(self.id, PARAM_OWNER.get_key_id()) + ScImmutableAgentID::new(self.proxy.root(PARAM_OWNER)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableBalanceOfParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableBalanceOfParams { pub fn owner(&self) -> ScMutableAgentID { - ScMutableAgentID::new(self.id, PARAM_OWNER.get_key_id()) + ScMutableAgentID::new(self.proxy.root(PARAM_OWNER)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableGetApprovedParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableGetApprovedParams { pub fn token_id(&self) -> ScImmutableHash { - ScImmutableHash::new(self.id, PARAM_TOKEN_ID.get_key_id()) + ScImmutableHash::new(self.proxy.root(PARAM_TOKEN_ID)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableGetApprovedParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableGetApprovedParams { pub fn token_id(&self) -> ScMutableHash { - ScMutableHash::new(self.id, PARAM_TOKEN_ID.get_key_id()) + ScMutableHash::new(self.proxy.root(PARAM_TOKEN_ID)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableIsApprovedForAllParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableIsApprovedForAllParams { pub fn operator(&self) -> ScImmutableAgentID { - ScImmutableAgentID::new(self.id, PARAM_OPERATOR.get_key_id()) + ScImmutableAgentID::new(self.proxy.root(PARAM_OPERATOR)) } pub fn owner(&self) -> ScImmutableAgentID { - ScImmutableAgentID::new(self.id, PARAM_OWNER.get_key_id()) + ScImmutableAgentID::new(self.proxy.root(PARAM_OWNER)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableIsApprovedForAllParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableIsApprovedForAllParams { pub fn operator(&self) -> ScMutableAgentID { - ScMutableAgentID::new(self.id, PARAM_OPERATOR.get_key_id()) + ScMutableAgentID::new(self.proxy.root(PARAM_OPERATOR)) } pub fn owner(&self) -> ScMutableAgentID { - ScMutableAgentID::new(self.id, PARAM_OWNER.get_key_id()) + ScMutableAgentID::new(self.proxy.root(PARAM_OWNER)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableOwnerOfParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableOwnerOfParams { pub fn token_id(&self) -> ScImmutableHash { - ScImmutableHash::new(self.id, PARAM_TOKEN_ID.get_key_id()) + ScImmutableHash::new(self.proxy.root(PARAM_TOKEN_ID)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableOwnerOfParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableOwnerOfParams { pub fn token_id(&self) -> ScMutableHash { - ScMutableHash::new(self.id, PARAM_TOKEN_ID.get_key_id()) + ScMutableHash::new(self.proxy.root(PARAM_TOKEN_ID)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableTokenURIParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableTokenURIParams { pub fn token_id(&self) -> ScImmutableHash { - ScImmutableHash::new(self.id, PARAM_TOKEN_ID.get_key_id()) + ScImmutableHash::new(self.proxy.root(PARAM_TOKEN_ID)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableTokenURIParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableTokenURIParams { pub fn token_id(&self) -> ScMutableHash { - ScMutableHash::new(self.id, PARAM_TOKEN_ID.get_key_id()) + ScMutableHash::new(self.proxy.root(PARAM_TOKEN_ID)) } } diff --git a/contracts/wasm/erc721/src/results.rs b/contracts/wasm/erc721/src/results.rs index 12dc895e67..b1fcde1170 100644 --- a/contracts/wasm/erc721/src/results.rs +++ b/contracts/wasm/erc721/src/results.rs @@ -9,162 +9,158 @@ #![allow(unused_imports)] use wasmlib::*; -use wasmlib::host::*; - use crate::*; -use crate::keys::*; -use crate::typedefs::*; -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableBalanceOfResults { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableBalanceOfResults { pub fn amount(&self) -> ScImmutableUint64 { - ScImmutableUint64::new(self.id, RESULT_AMOUNT.get_key_id()) + ScImmutableUint64::new(self.proxy.root(RESULT_AMOUNT)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableBalanceOfResults { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableBalanceOfResults { pub fn amount(&self) -> ScMutableUint64 { - ScMutableUint64::new(self.id, RESULT_AMOUNT.get_key_id()) + ScMutableUint64::new(self.proxy.root(RESULT_AMOUNT)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableGetApprovedResults { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableGetApprovedResults { pub fn approved(&self) -> ScImmutableAgentID { - ScImmutableAgentID::new(self.id, RESULT_APPROVED.get_key_id()) + ScImmutableAgentID::new(self.proxy.root(RESULT_APPROVED)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableGetApprovedResults { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableGetApprovedResults { pub fn approved(&self) -> ScMutableAgentID { - ScMutableAgentID::new(self.id, RESULT_APPROVED.get_key_id()) + ScMutableAgentID::new(self.proxy.root(RESULT_APPROVED)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableIsApprovedForAllResults { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableIsApprovedForAllResults { pub fn approval(&self) -> ScImmutableBool { - ScImmutableBool::new(self.id, RESULT_APPROVAL.get_key_id()) + ScImmutableBool::new(self.proxy.root(RESULT_APPROVAL)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableIsApprovedForAllResults { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableIsApprovedForAllResults { pub fn approval(&self) -> ScMutableBool { - ScMutableBool::new(self.id, RESULT_APPROVAL.get_key_id()) + ScMutableBool::new(self.proxy.root(RESULT_APPROVAL)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableNameResults { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableNameResults { pub fn name(&self) -> ScImmutableString { - ScImmutableString::new(self.id, RESULT_NAME.get_key_id()) + ScImmutableString::new(self.proxy.root(RESULT_NAME)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableNameResults { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableNameResults { pub fn name(&self) -> ScMutableString { - ScMutableString::new(self.id, RESULT_NAME.get_key_id()) + ScMutableString::new(self.proxy.root(RESULT_NAME)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableOwnerOfResults { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableOwnerOfResults { pub fn owner(&self) -> ScImmutableAgentID { - ScImmutableAgentID::new(self.id, RESULT_OWNER.get_key_id()) + ScImmutableAgentID::new(self.proxy.root(RESULT_OWNER)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableOwnerOfResults { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableOwnerOfResults { pub fn owner(&self) -> ScMutableAgentID { - ScMutableAgentID::new(self.id, RESULT_OWNER.get_key_id()) + ScMutableAgentID::new(self.proxy.root(RESULT_OWNER)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableSymbolResults { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableSymbolResults { pub fn symbol(&self) -> ScImmutableString { - ScImmutableString::new(self.id, RESULT_SYMBOL.get_key_id()) + ScImmutableString::new(self.proxy.root(RESULT_SYMBOL)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableSymbolResults { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableSymbolResults { pub fn symbol(&self) -> ScMutableString { - ScMutableString::new(self.id, RESULT_SYMBOL.get_key_id()) + ScMutableString::new(self.proxy.root(RESULT_SYMBOL)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableTokenURIResults { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableTokenURIResults { pub fn token_uri(&self) -> ScImmutableString { - ScImmutableString::new(self.id, RESULT_TOKEN_URI.get_key_id()) + ScImmutableString::new(self.proxy.root(RESULT_TOKEN_URI)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableTokenURIResults { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableTokenURIResults { pub fn token_uri(&self) -> ScMutableString { - ScMutableString::new(self.id, RESULT_TOKEN_URI.get_key_id()) + ScMutableString::new(self.proxy.root(RESULT_TOKEN_URI)) } } diff --git a/contracts/wasm/erc721/src/state.rs b/contracts/wasm/erc721/src/state.rs index 48a77bd618..e99e1ca9f5 100644 --- a/contracts/wasm/erc721/src/state.rs +++ b/contracts/wasm/erc721/src/state.rs @@ -9,198 +9,183 @@ #![allow(unused_imports)] use wasmlib::*; -use wasmlib::host::*; use crate::*; -use crate::keys::*; -use crate::typedefs::*; -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MapHashToImmutableAgentID { - pub(crate) obj_id: i32, + pub(crate) proxy: Proxy, } impl MapHashToImmutableAgentID { pub fn get_agent_id(&self, key: &ScHash) -> ScImmutableAgentID { - ScImmutableAgentID::new(self.obj_id, key.get_key_id()) + ScImmutableAgentID::new(self.proxy.key(&hash_to_bytes(key))) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MapAgentIDToImmutableOperators { - pub(crate) obj_id: i32, + pub(crate) proxy: Proxy, } impl MapAgentIDToImmutableOperators { pub fn get_operators(&self, key: &ScAgentID) -> ImmutableOperators { - let sub_id = get_object_id(self.obj_id, key.get_key_id(), TYPE_MAP); - ImmutableOperators { obj_id: sub_id } + ImmutableOperators { proxy: self.proxy.key(&agent_id_to_bytes(key)) } } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MapAgentIDToImmutableUint64 { - pub(crate) obj_id: i32, + pub(crate) proxy: Proxy, } impl MapAgentIDToImmutableUint64 { pub fn get_uint64(&self, key: &ScAgentID) -> ScImmutableUint64 { - ScImmutableUint64::new(self.obj_id, key.get_key_id()) + ScImmutableUint64::new(self.proxy.key(&agent_id_to_bytes(key))) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MapHashToImmutableString { - pub(crate) obj_id: i32, + pub(crate) proxy: Proxy, } impl MapHashToImmutableString { pub fn get_string(&self, key: &ScHash) -> ScImmutableString { - ScImmutableString::new(self.obj_id, key.get_key_id()) + ScImmutableString::new(self.proxy.key(&hash_to_bytes(key))) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableErc721State { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableErc721State { pub fn approved_accounts(&self) -> MapHashToImmutableAgentID { - let map_id = get_object_id(self.id, STATE_APPROVED_ACCOUNTS.get_key_id(), TYPE_MAP); - MapHashToImmutableAgentID { obj_id: map_id } + MapHashToImmutableAgentID { proxy: self.proxy.root(STATE_APPROVED_ACCOUNTS) } } pub fn approved_operators(&self) -> MapAgentIDToImmutableOperators { - let map_id = get_object_id(self.id, STATE_APPROVED_OPERATORS.get_key_id(), TYPE_MAP); - MapAgentIDToImmutableOperators { obj_id: map_id } + MapAgentIDToImmutableOperators { proxy: self.proxy.root(STATE_APPROVED_OPERATORS) } } pub fn balances(&self) -> MapAgentIDToImmutableUint64 { - let map_id = get_object_id(self.id, STATE_BALANCES.get_key_id(), TYPE_MAP); - MapAgentIDToImmutableUint64 { obj_id: map_id } + MapAgentIDToImmutableUint64 { proxy: self.proxy.root(STATE_BALANCES) } } pub fn name(&self) -> ScImmutableString { - ScImmutableString::new(self.id, STATE_NAME.get_key_id()) + ScImmutableString::new(self.proxy.root(STATE_NAME)) } pub fn owners(&self) -> MapHashToImmutableAgentID { - let map_id = get_object_id(self.id, STATE_OWNERS.get_key_id(), TYPE_MAP); - MapHashToImmutableAgentID { obj_id: map_id } + MapHashToImmutableAgentID { proxy: self.proxy.root(STATE_OWNERS) } } pub fn symbol(&self) -> ScImmutableString { - ScImmutableString::new(self.id, STATE_SYMBOL.get_key_id()) + ScImmutableString::new(self.proxy.root(STATE_SYMBOL)) } pub fn token_ur_is(&self) -> MapHashToImmutableString { - let map_id = get_object_id(self.id, STATE_TOKEN_UR_IS.get_key_id(), TYPE_MAP); - MapHashToImmutableString { obj_id: map_id } + MapHashToImmutableString { proxy: self.proxy.root(STATE_TOKEN_UR_IS) } } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MapHashToMutableAgentID { - pub(crate) obj_id: i32, + pub(crate) proxy: Proxy, } impl MapHashToMutableAgentID { pub fn clear(&self) { - clear(self.obj_id); + self.proxy.clear_map(); } pub fn get_agent_id(&self, key: &ScHash) -> ScMutableAgentID { - ScMutableAgentID::new(self.obj_id, key.get_key_id()) + ScMutableAgentID::new(self.proxy.key(&hash_to_bytes(key))) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MapAgentIDToMutableOperators { - pub(crate) obj_id: i32, + pub(crate) proxy: Proxy, } impl MapAgentIDToMutableOperators { pub fn clear(&self) { - clear(self.obj_id); + self.proxy.clear_map(); } pub fn get_operators(&self, key: &ScAgentID) -> MutableOperators { - let sub_id = get_object_id(self.obj_id, key.get_key_id(), TYPE_MAP); - MutableOperators { obj_id: sub_id } + MutableOperators { proxy: self.proxy.key(&agent_id_to_bytes(key)) } } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MapAgentIDToMutableUint64 { - pub(crate) obj_id: i32, + pub(crate) proxy: Proxy, } impl MapAgentIDToMutableUint64 { pub fn clear(&self) { - clear(self.obj_id); + self.proxy.clear_map(); } pub fn get_uint64(&self, key: &ScAgentID) -> ScMutableUint64 { - ScMutableUint64::new(self.obj_id, key.get_key_id()) + ScMutableUint64::new(self.proxy.key(&agent_id_to_bytes(key))) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MapHashToMutableString { - pub(crate) obj_id: i32, + pub(crate) proxy: Proxy, } impl MapHashToMutableString { pub fn clear(&self) { - clear(self.obj_id); + self.proxy.clear_map(); } pub fn get_string(&self, key: &ScHash) -> ScMutableString { - ScMutableString::new(self.obj_id, key.get_key_id()) + ScMutableString::new(self.proxy.key(&hash_to_bytes(key))) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableErc721State { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableErc721State { pub fn as_immutable(&self) -> ImmutableErc721State { - ImmutableErc721State { id: self.id } + ImmutableErc721State { proxy: self.proxy.root("") } } pub fn approved_accounts(&self) -> MapHashToMutableAgentID { - let map_id = get_object_id(self.id, STATE_APPROVED_ACCOUNTS.get_key_id(), TYPE_MAP); - MapHashToMutableAgentID { obj_id: map_id } + MapHashToMutableAgentID { proxy: self.proxy.root(STATE_APPROVED_ACCOUNTS) } } pub fn approved_operators(&self) -> MapAgentIDToMutableOperators { - let map_id = get_object_id(self.id, STATE_APPROVED_OPERATORS.get_key_id(), TYPE_MAP); - MapAgentIDToMutableOperators { obj_id: map_id } + MapAgentIDToMutableOperators { proxy: self.proxy.root(STATE_APPROVED_OPERATORS) } } pub fn balances(&self) -> MapAgentIDToMutableUint64 { - let map_id = get_object_id(self.id, STATE_BALANCES.get_key_id(), TYPE_MAP); - MapAgentIDToMutableUint64 { obj_id: map_id } + MapAgentIDToMutableUint64 { proxy: self.proxy.root(STATE_BALANCES) } } pub fn name(&self) -> ScMutableString { - ScMutableString::new(self.id, STATE_NAME.get_key_id()) + ScMutableString::new(self.proxy.root(STATE_NAME)) } pub fn owners(&self) -> MapHashToMutableAgentID { - let map_id = get_object_id(self.id, STATE_OWNERS.get_key_id(), TYPE_MAP); - MapHashToMutableAgentID { obj_id: map_id } + MapHashToMutableAgentID { proxy: self.proxy.root(STATE_OWNERS) } } pub fn symbol(&self) -> ScMutableString { - ScMutableString::new(self.id, STATE_SYMBOL.get_key_id()) + ScMutableString::new(self.proxy.root(STATE_SYMBOL)) } pub fn token_ur_is(&self) -> MapHashToMutableString { - let map_id = get_object_id(self.id, STATE_TOKEN_UR_IS.get_key_id(), TYPE_MAP); - MapHashToMutableString { obj_id: map_id } + MapHashToMutableString { proxy: self.proxy.root(STATE_TOKEN_UR_IS) } } } diff --git a/contracts/wasm/erc721/src/typedefs.rs b/contracts/wasm/erc721/src/typedefs.rs index 63cd1a30d9..792f1c820f 100644 --- a/contracts/wasm/erc721/src/typedefs.rs +++ b/contracts/wasm/erc721/src/typedefs.rs @@ -8,33 +8,32 @@ #![allow(dead_code)] use wasmlib::*; -use wasmlib::host::*; -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MapAgentIDToImmutableBool { - pub(crate) obj_id: i32, + pub(crate) proxy: Proxy, } impl MapAgentIDToImmutableBool { pub fn get_bool(&self, key: &ScAgentID) -> ScImmutableBool { - ScImmutableBool::new(self.obj_id, key.get_key_id()) + ScImmutableBool::new(self.proxy.key(&agent_id_to_bytes(key))) } } pub type ImmutableOperators = MapAgentIDToImmutableBool; -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MapAgentIDToMutableBool { - pub(crate) obj_id: i32, + pub(crate) proxy: Proxy, } impl MapAgentIDToMutableBool { pub fn clear(&self) { - clear(self.obj_id); + self.proxy.clear_map(); } pub fn get_bool(&self, key: &ScAgentID) -> ScMutableBool { - ScMutableBool::new(self.obj_id, key.get_key_id()) + ScMutableBool::new(self.proxy.key(&agent_id_to_bytes(key))) } } diff --git a/contracts/wasm/erc721/test/erc721_bg.wasm b/contracts/wasm/erc721/test/erc721_bg.wasm index ba5fba1619971af2ffef1b730de321b511722acc..f05a78ffbdf9d8f0633f33bb88201fbc91bee559 100644 GIT binary patch literal 68915 zcmeFa4VZA_|334xa!JoasPg8ry)VsB9=C-xi)24K_MT~PMlM^DwDrR;&#v%iyh{>lUXh&Nv6s9}c<3e7=oPA;P+px}k)4tay_lZQ-tn@ri}&oG zd%@hcxv3XS%_W`XkGJr6B!6dieb!Eg@~qVwX|>a1I-Q*BtkcR{X)EdENxLqFOThvFfn0%ej(`&osf5SP3_tqSiaI z)#u!n{=jRpvu{a%A$v=*kQBd| z_0uv9!^M$wCajLXMf`p6p_fmGOZSCWPWQ7w1NJy%b2HS*%5>}6GI{QJMr*BUd(~@& zYwlb~CbHz&<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1Gz+&ub; zw^q-nG#6WsTwZGKIys6*$4=dJLCaZ9&8yFtbyoR;W0&tKt!_RxJabKVIHlZNq}86T z8KYnF+ZMN8^Px+2Rz@Fv*CTru-u&aM&%Em|u3la`F$&hdym@tVN8!k;A9{1&Innac z)Ro%m_di?S`_mJf?*6wu$1Mt{M&&&>ULOqg{`G|qknmP^WNfN#c?K0xpPiSvVYD$ot&I>V&|PF z4Sr(%$-#a5PoDF;{qw!&?_74r!TrmA@Ar23&3ARpZSC#;^ps!rES%oHymNN%>i;?C zuCovH_nx3nzt_xA{po&7(4+ zr__vI;e1>E1r3^mnSKx~htVT`xGMDL1R?MHkuT7|pB5aA7@##Hm;F-M9L(`gp>GR4 zI~aU*kXQcHP*A2d~pX9u$w&G);f z_{>+R_;Z{5OCrArNWqLC;!hRxLp4FsZ}Y)-cx-rVFeg|U_@%NRRGR$x;pIWq-^E|T zY4VHV->`fjEor=N!G9H45BLe7 zvcJ&hra{Qh|FZ5AgR=h{AYHlws5NkM^gO!os)8TEa2HB)g+le(;aLQ{*`- zxUj4euDe-nAAhoel{NXnzp~fRfWMEqB0p*FDBA86gKz;z_W0ZCzW>^zgOW!3FGVH* z&rp}9@_`@K}VmyO3RTCl8hL1)sjaYOgA-c8FkZAj!g%>>> DO NOT CHANGE THIS FILE! <<<< -// Change the json schema instead - - -export const IdxParamApproval = 0; -export const IdxParamApproved = 1; -export const IdxParamData = 2; -export const IdxParamFrom = 3; -export const IdxParamName = 4; -export const IdxParamOperator = 5; -export const IdxParamOwner = 6; -export const IdxParamSymbol = 7; -export const IdxParamTo = 8; -export const IdxParamTokenID = 9; -export const IdxParamTokenURI = 10; diff --git a/contracts/wasm/fairauction/go/fairauction/keys.go b/contracts/wasm/fairauction/go/fairauction/keys.go deleted file mode 100644 index c0165dc247..0000000000 --- a/contracts/wasm/fairauction/go/fairauction/keys.go +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright 2020 IOTA Stiftung -// SPDX-License-Identifier: Apache-2.0 - -// (Re-)generated by schema tool -// >>>> DO NOT CHANGE THIS FILE! <<<< -// Change the json schema instead - -package fairauction diff --git a/contracts/wasm/fairauction/src/contract.rs b/contracts/wasm/fairauction/src/contract.rs index 78cd2681ae..6cd44328a3 100644 --- a/contracts/wasm/fairauction/src/contract.rs +++ b/contracts/wasm/fairauction/src/contract.rs @@ -7,8 +7,6 @@ #![allow(dead_code)] -use std::ptr; - use wasmlib::*; use crate::consts::*; @@ -45,49 +43,50 @@ pub struct ScFuncs { } impl ScFuncs { - pub fn finalize_auction(_ctx: & dyn ScFuncCallContext) -> FinalizeAuctionCall { + pub fn finalize_auction(_ctx: &dyn ScFuncCallContext) -> FinalizeAuctionCall { let mut f = FinalizeAuctionCall { func: ScFunc::new(HSC_NAME, HFUNC_FINALIZE_AUCTION), - params: MutableFinalizeAuctionParams { id: 0 }, + params: MutableFinalizeAuctionParams { proxy: Proxy::nil() }, }; - f.func.set_ptrs(&mut f.params.id, ptr::null_mut()); + ScFunc::link_params(&mut f.params.proxy, &f.func); f } - pub fn place_bid(_ctx: & dyn ScFuncCallContext) -> PlaceBidCall { + pub fn place_bid(_ctx: &dyn ScFuncCallContext) -> PlaceBidCall { let mut f = PlaceBidCall { func: ScFunc::new(HSC_NAME, HFUNC_PLACE_BID), - params: MutablePlaceBidParams { id: 0 }, + params: MutablePlaceBidParams { proxy: Proxy::nil() }, }; - f.func.set_ptrs(&mut f.params.id, ptr::null_mut()); + ScFunc::link_params(&mut f.params.proxy, &f.func); f } - pub fn set_owner_margin(_ctx: & dyn ScFuncCallContext) -> SetOwnerMarginCall { + pub fn set_owner_margin(_ctx: &dyn ScFuncCallContext) -> SetOwnerMarginCall { let mut f = SetOwnerMarginCall { func: ScFunc::new(HSC_NAME, HFUNC_SET_OWNER_MARGIN), - params: MutableSetOwnerMarginParams { id: 0 }, + params: MutableSetOwnerMarginParams { proxy: Proxy::nil() }, }; - f.func.set_ptrs(&mut f.params.id, ptr::null_mut()); + ScFunc::link_params(&mut f.params.proxy, &f.func); f } - pub fn start_auction(_ctx: & dyn ScFuncCallContext) -> StartAuctionCall { + pub fn start_auction(_ctx: &dyn ScFuncCallContext) -> StartAuctionCall { let mut f = StartAuctionCall { func: ScFunc::new(HSC_NAME, HFUNC_START_AUCTION), - params: MutableStartAuctionParams { id: 0 }, + params: MutableStartAuctionParams { proxy: Proxy::nil() }, }; - f.func.set_ptrs(&mut f.params.id, ptr::null_mut()); + ScFunc::link_params(&mut f.params.proxy, &f.func); f } - pub fn get_info(_ctx: & dyn ScViewCallContext) -> GetInfoCall { + pub fn get_info(_ctx: &dyn ScViewCallContext) -> GetInfoCall { let mut f = GetInfoCall { func: ScView::new(HSC_NAME, HVIEW_GET_INFO), - params: MutableGetInfoParams { id: 0 }, - results: ImmutableGetInfoResults { id: 0 }, + params: MutableGetInfoParams { proxy: Proxy::nil() }, + results: ImmutableGetInfoResults { proxy: Proxy::nil() }, }; - f.func.set_ptrs(&mut f.params.id, &mut f.results.id); + ScView::link_params(&mut f.params.proxy, &f.func); + ScView::link_results(&mut f.results.proxy, &f.func); f } } diff --git a/contracts/wasm/fairauction/src/fairauction.rs b/contracts/wasm/fairauction/src/fairauction.rs index 8c951d38bc..6f3b4c1644 100644 --- a/contracts/wasm/fairauction/src/fairauction.rs +++ b/contracts/wasm/fairauction/src/fairauction.rs @@ -80,7 +80,7 @@ pub fn func_place_bid(ctx: &ScFuncContext, f: &PlaceBidContext) { ctx.require(bid_amount >= auction.minimum_bid, "Insufficient bid amount"); ctx.log(&("New bid from: ".to_string() + &caller.to_string())); let index = bidder_list.length(); - bidder_list.get_agent_id(index).set_value(&caller); + bidder_list.append_agent_id().set_value(&caller); let bid = Bid { index: index, amount: bid_amount, diff --git a/contracts/wasm/fairauction/src/keys.rs b/contracts/wasm/fairauction/src/keys.rs deleted file mode 100644 index 843e56e642..0000000000 --- a/contracts/wasm/fairauction/src/keys.rs +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright 2020 IOTA Stiftung -// SPDX-License-Identifier: Apache-2.0 - -// (Re-)generated by schema tool -// >>>> DO NOT CHANGE THIS FILE! <<<< -// Change the json schema instead - -#![allow(dead_code)] - -use wasmlib::*; - -use crate::*; - -pub(crate) const IDX_PARAM_COLOR : usize = 0; -pub(crate) const IDX_PARAM_DESCRIPTION : usize = 1; -pub(crate) const IDX_PARAM_DURATION : usize = 2; -pub(crate) const IDX_PARAM_MINIMUM_BID : usize = 3; -pub(crate) const IDX_PARAM_OWNER_MARGIN : usize = 4; - -pub(crate) const IDX_RESULT_BIDDERS : usize = 5; -pub(crate) const IDX_RESULT_COLOR : usize = 6; -pub(crate) const IDX_RESULT_CREATOR : usize = 7; -pub(crate) const IDX_RESULT_DEPOSIT : usize = 8; -pub(crate) const IDX_RESULT_DESCRIPTION : usize = 9; -pub(crate) const IDX_RESULT_DURATION : usize = 10; -pub(crate) const IDX_RESULT_HIGHEST_BID : usize = 11; -pub(crate) const IDX_RESULT_HIGHEST_BIDDER : usize = 12; -pub(crate) const IDX_RESULT_MINIMUM_BID : usize = 13; -pub(crate) const IDX_RESULT_NUM_TOKENS : usize = 14; -pub(crate) const IDX_RESULT_OWNER_MARGIN : usize = 15; -pub(crate) const IDX_RESULT_WHEN_STARTED : usize = 16; - -pub(crate) const IDX_STATE_AUCTIONS : usize = 17; -pub(crate) const IDX_STATE_BIDDER_LIST : usize = 18; -pub(crate) const IDX_STATE_BIDS : usize = 19; -pub(crate) const IDX_STATE_OWNER_MARGIN : usize = 20; - -pub const KEY_MAP_LEN: usize = 21; - -pub const KEY_MAP: [&str; KEY_MAP_LEN] = [ - PARAM_COLOR, - PARAM_DESCRIPTION, - PARAM_DURATION, - PARAM_MINIMUM_BID, - PARAM_OWNER_MARGIN, - RESULT_BIDDERS, - RESULT_COLOR, - RESULT_CREATOR, - RESULT_DEPOSIT, - RESULT_DESCRIPTION, - RESULT_DURATION, - RESULT_HIGHEST_BID, - RESULT_HIGHEST_BIDDER, - RESULT_MINIMUM_BID, - RESULT_NUM_TOKENS, - RESULT_OWNER_MARGIN, - RESULT_WHEN_STARTED, - STATE_AUCTIONS, - STATE_BIDDER_LIST, - STATE_BIDS, - STATE_OWNER_MARGIN, -]; - -pub static mut IDX_MAP: [Key32; KEY_MAP_LEN] = [Key32(0); KEY_MAP_LEN]; - -pub fn idx_map(idx: usize) -> Key32 { - unsafe { - IDX_MAP[idx] - } -} diff --git a/contracts/wasm/fairauction/src/lib.rs b/contracts/wasm/fairauction/src/lib.rs index 97dec4b38d..fb3ac5a603 100644 --- a/contracts/wasm/fairauction/src/lib.rs +++ b/contracts/wasm/fairauction/src/lib.rs @@ -10,17 +10,16 @@ use fairauction::*; use wasmlib::*; -use wasmlib::host::*; use crate::consts::*; -use crate::keys::*; use crate::params::*; use crate::results::*; use crate::state::*; +use crate::structs::*; +use crate::typedefs::*; mod consts; mod contract; -mod keys; mod params; mod results; mod state; @@ -36,12 +35,6 @@ fn on_load() { exports.add_func(FUNC_SET_OWNER_MARGIN, func_set_owner_margin_thunk); exports.add_func(FUNC_START_AUCTION, func_start_auction_thunk); exports.add_view(VIEW_GET_INFO, view_get_info_thunk); - - unsafe { - for i in 0..KEY_MAP_LEN { - IDX_MAP[i] = get_key_id_from_string(KEY_MAP[i]); - } - } } pub struct FinalizeAuctionContext { @@ -51,18 +44,14 @@ pub struct FinalizeAuctionContext { fn func_finalize_auction_thunk(ctx: &ScFuncContext) { ctx.log("fairauction.funcFinalizeAuction"); + let f = FinalizeAuctionContext { + params: ImmutableFinalizeAuctionParams { proxy: params_proxy() }, + state: MutableFairAuctionState { proxy: state_proxy() }, + }; // only SC itself can invoke this function ctx.require(ctx.caller() == ctx.account_id(), "no permission"); - let f = FinalizeAuctionContext { - params: ImmutableFinalizeAuctionParams { - id: OBJ_ID_PARAMS, - }, - state: MutableFairAuctionState { - id: OBJ_ID_STATE, - }, - }; ctx.require(f.params.color().exists(), "missing mandatory color"); func_finalize_auction(ctx, &f); ctx.log("fairauction.funcFinalizeAuction ok"); @@ -76,12 +65,8 @@ pub struct PlaceBidContext { fn func_place_bid_thunk(ctx: &ScFuncContext) { ctx.log("fairauction.funcPlaceBid"); let f = PlaceBidContext { - params: ImmutablePlaceBidParams { - id: OBJ_ID_PARAMS, - }, - state: MutableFairAuctionState { - id: OBJ_ID_STATE, - }, + params: ImmutablePlaceBidParams { proxy: params_proxy() }, + state: MutableFairAuctionState { proxy: state_proxy() }, }; ctx.require(f.params.color().exists(), "missing mandatory color"); func_place_bid(ctx, &f); @@ -95,18 +80,14 @@ pub struct SetOwnerMarginContext { fn func_set_owner_margin_thunk(ctx: &ScFuncContext) { ctx.log("fairauction.funcSetOwnerMargin"); + let f = SetOwnerMarginContext { + params: ImmutableSetOwnerMarginParams { proxy: params_proxy() }, + state: MutableFairAuctionState { proxy: state_proxy() }, + }; // only SC creator can set owner margin ctx.require(ctx.caller() == ctx.contract_creator(), "no permission"); - let f = SetOwnerMarginContext { - params: ImmutableSetOwnerMarginParams { - id: OBJ_ID_PARAMS, - }, - state: MutableFairAuctionState { - id: OBJ_ID_STATE, - }, - }; ctx.require(f.params.owner_margin().exists(), "missing mandatory ownerMargin"); func_set_owner_margin(ctx, &f); ctx.log("fairauction.funcSetOwnerMargin ok"); @@ -120,12 +101,8 @@ pub struct StartAuctionContext { fn func_start_auction_thunk(ctx: &ScFuncContext) { ctx.log("fairauction.funcStartAuction"); let f = StartAuctionContext { - params: ImmutableStartAuctionParams { - id: OBJ_ID_PARAMS, - }, - state: MutableFairAuctionState { - id: OBJ_ID_STATE, - }, + params: ImmutableStartAuctionParams { proxy: params_proxy() }, + state: MutableFairAuctionState { proxy: state_proxy() }, }; ctx.require(f.params.color().exists(), "missing mandatory color"); ctx.require(f.params.minimum_bid().exists(), "missing mandatory minimumBid"); @@ -142,17 +119,12 @@ pub struct GetInfoContext { fn view_get_info_thunk(ctx: &ScViewContext) { ctx.log("fairauction.viewGetInfo"); let f = GetInfoContext { - params: ImmutableGetInfoParams { - id: OBJ_ID_PARAMS, - }, - results: MutableGetInfoResults { - id: OBJ_ID_RESULTS, - }, - state: ImmutableFairAuctionState { - id: OBJ_ID_STATE, - }, + params: ImmutableGetInfoParams { proxy: params_proxy() }, + results: MutableGetInfoResults { proxy: results_proxy() }, + state: ImmutableFairAuctionState { proxy: state_proxy() }, }; ctx.require(f.params.color().exists(), "missing mandatory color"); view_get_info(ctx, &f); + ctx.results(&f.results.proxy.kv_store); ctx.log("fairauction.viewGetInfo ok"); } diff --git a/contracts/wasm/fairauction/src/params.rs b/contracts/wasm/fairauction/src/params.rs index 9a8424ee55..06a6b55eb2 100644 --- a/contracts/wasm/fairauction/src/params.rs +++ b/contracts/wasm/fairauction/src/params.rs @@ -9,143 +9,138 @@ #![allow(unused_imports)] use wasmlib::*; -use wasmlib::host::*; - use crate::*; -use crate::keys::*; -use crate::structs::*; -use crate::typedefs::*; -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableFinalizeAuctionParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableFinalizeAuctionParams { pub fn color(&self) -> ScImmutableColor { - ScImmutableColor::new(self.id, PARAM_COLOR.get_key_id()) + ScImmutableColor::new(self.proxy.root(PARAM_COLOR)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableFinalizeAuctionParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableFinalizeAuctionParams { pub fn color(&self) -> ScMutableColor { - ScMutableColor::new(self.id, PARAM_COLOR.get_key_id()) + ScMutableColor::new(self.proxy.root(PARAM_COLOR)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutablePlaceBidParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutablePlaceBidParams { pub fn color(&self) -> ScImmutableColor { - ScImmutableColor::new(self.id, PARAM_COLOR.get_key_id()) + ScImmutableColor::new(self.proxy.root(PARAM_COLOR)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutablePlaceBidParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutablePlaceBidParams { pub fn color(&self) -> ScMutableColor { - ScMutableColor::new(self.id, PARAM_COLOR.get_key_id()) + ScMutableColor::new(self.proxy.root(PARAM_COLOR)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableSetOwnerMarginParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableSetOwnerMarginParams { pub fn owner_margin(&self) -> ScImmutableUint64 { - ScImmutableUint64::new(self.id, PARAM_OWNER_MARGIN.get_key_id()) + ScImmutableUint64::new(self.proxy.root(PARAM_OWNER_MARGIN)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableSetOwnerMarginParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableSetOwnerMarginParams { pub fn owner_margin(&self) -> ScMutableUint64 { - ScMutableUint64::new(self.id, PARAM_OWNER_MARGIN.get_key_id()) + ScMutableUint64::new(self.proxy.root(PARAM_OWNER_MARGIN)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableStartAuctionParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableStartAuctionParams { pub fn color(&self) -> ScImmutableColor { - ScImmutableColor::new(self.id, PARAM_COLOR.get_key_id()) + ScImmutableColor::new(self.proxy.root(PARAM_COLOR)) } pub fn description(&self) -> ScImmutableString { - ScImmutableString::new(self.id, PARAM_DESCRIPTION.get_key_id()) + ScImmutableString::new(self.proxy.root(PARAM_DESCRIPTION)) } pub fn duration(&self) -> ScImmutableUint32 { - ScImmutableUint32::new(self.id, PARAM_DURATION.get_key_id()) + ScImmutableUint32::new(self.proxy.root(PARAM_DURATION)) } pub fn minimum_bid(&self) -> ScImmutableUint64 { - ScImmutableUint64::new(self.id, PARAM_MINIMUM_BID.get_key_id()) + ScImmutableUint64::new(self.proxy.root(PARAM_MINIMUM_BID)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableStartAuctionParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableStartAuctionParams { pub fn color(&self) -> ScMutableColor { - ScMutableColor::new(self.id, PARAM_COLOR.get_key_id()) + ScMutableColor::new(self.proxy.root(PARAM_COLOR)) } pub fn description(&self) -> ScMutableString { - ScMutableString::new(self.id, PARAM_DESCRIPTION.get_key_id()) + ScMutableString::new(self.proxy.root(PARAM_DESCRIPTION)) } pub fn duration(&self) -> ScMutableUint32 { - ScMutableUint32::new(self.id, PARAM_DURATION.get_key_id()) + ScMutableUint32::new(self.proxy.root(PARAM_DURATION)) } pub fn minimum_bid(&self) -> ScMutableUint64 { - ScMutableUint64::new(self.id, PARAM_MINIMUM_BID.get_key_id()) + ScMutableUint64::new(self.proxy.root(PARAM_MINIMUM_BID)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableGetInfoParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableGetInfoParams { pub fn color(&self) -> ScImmutableColor { - ScImmutableColor::new(self.id, PARAM_COLOR.get_key_id()) + ScImmutableColor::new(self.proxy.root(PARAM_COLOR)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableGetInfoParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableGetInfoParams { pub fn color(&self) -> ScMutableColor { - ScMutableColor::new(self.id, PARAM_COLOR.get_key_id()) + ScMutableColor::new(self.proxy.root(PARAM_COLOR)) } } diff --git a/contracts/wasm/fairauction/src/results.rs b/contracts/wasm/fairauction/src/results.rs index b9635d084b..e0769eb70d 100644 --- a/contracts/wasm/fairauction/src/results.rs +++ b/contracts/wasm/fairauction/src/results.rs @@ -9,119 +9,114 @@ #![allow(unused_imports)] use wasmlib::*; -use wasmlib::host::*; - use crate::*; -use crate::keys::*; -use crate::structs::*; -use crate::typedefs::*; -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableGetInfoResults { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableGetInfoResults { pub fn bidders(&self) -> ScImmutableUint32 { - ScImmutableUint32::new(self.id, RESULT_BIDDERS.get_key_id()) + ScImmutableUint32::new(self.proxy.root(RESULT_BIDDERS)) } pub fn color(&self) -> ScImmutableColor { - ScImmutableColor::new(self.id, RESULT_COLOR.get_key_id()) + ScImmutableColor::new(self.proxy.root(RESULT_COLOR)) } pub fn creator(&self) -> ScImmutableAgentID { - ScImmutableAgentID::new(self.id, RESULT_CREATOR.get_key_id()) + ScImmutableAgentID::new(self.proxy.root(RESULT_CREATOR)) } pub fn deposit(&self) -> ScImmutableUint64 { - ScImmutableUint64::new(self.id, RESULT_DEPOSIT.get_key_id()) + ScImmutableUint64::new(self.proxy.root(RESULT_DEPOSIT)) } pub fn description(&self) -> ScImmutableString { - ScImmutableString::new(self.id, RESULT_DESCRIPTION.get_key_id()) + ScImmutableString::new(self.proxy.root(RESULT_DESCRIPTION)) } pub fn duration(&self) -> ScImmutableUint32 { - ScImmutableUint32::new(self.id, RESULT_DURATION.get_key_id()) + ScImmutableUint32::new(self.proxy.root(RESULT_DURATION)) } pub fn highest_bid(&self) -> ScImmutableUint64 { - ScImmutableUint64::new(self.id, RESULT_HIGHEST_BID.get_key_id()) + ScImmutableUint64::new(self.proxy.root(RESULT_HIGHEST_BID)) } pub fn highest_bidder(&self) -> ScImmutableAgentID { - ScImmutableAgentID::new(self.id, RESULT_HIGHEST_BIDDER.get_key_id()) + ScImmutableAgentID::new(self.proxy.root(RESULT_HIGHEST_BIDDER)) } pub fn minimum_bid(&self) -> ScImmutableUint64 { - ScImmutableUint64::new(self.id, RESULT_MINIMUM_BID.get_key_id()) + ScImmutableUint64::new(self.proxy.root(RESULT_MINIMUM_BID)) } pub fn num_tokens(&self) -> ScImmutableUint64 { - ScImmutableUint64::new(self.id, RESULT_NUM_TOKENS.get_key_id()) + ScImmutableUint64::new(self.proxy.root(RESULT_NUM_TOKENS)) } pub fn owner_margin(&self) -> ScImmutableUint64 { - ScImmutableUint64::new(self.id, RESULT_OWNER_MARGIN.get_key_id()) + ScImmutableUint64::new(self.proxy.root(RESULT_OWNER_MARGIN)) } pub fn when_started(&self) -> ScImmutableUint64 { - ScImmutableUint64::new(self.id, RESULT_WHEN_STARTED.get_key_id()) + ScImmutableUint64::new(self.proxy.root(RESULT_WHEN_STARTED)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableGetInfoResults { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableGetInfoResults { pub fn bidders(&self) -> ScMutableUint32 { - ScMutableUint32::new(self.id, RESULT_BIDDERS.get_key_id()) + ScMutableUint32::new(self.proxy.root(RESULT_BIDDERS)) } pub fn color(&self) -> ScMutableColor { - ScMutableColor::new(self.id, RESULT_COLOR.get_key_id()) + ScMutableColor::new(self.proxy.root(RESULT_COLOR)) } pub fn creator(&self) -> ScMutableAgentID { - ScMutableAgentID::new(self.id, RESULT_CREATOR.get_key_id()) + ScMutableAgentID::new(self.proxy.root(RESULT_CREATOR)) } pub fn deposit(&self) -> ScMutableUint64 { - ScMutableUint64::new(self.id, RESULT_DEPOSIT.get_key_id()) + ScMutableUint64::new(self.proxy.root(RESULT_DEPOSIT)) } pub fn description(&self) -> ScMutableString { - ScMutableString::new(self.id, RESULT_DESCRIPTION.get_key_id()) + ScMutableString::new(self.proxy.root(RESULT_DESCRIPTION)) } pub fn duration(&self) -> ScMutableUint32 { - ScMutableUint32::new(self.id, RESULT_DURATION.get_key_id()) + ScMutableUint32::new(self.proxy.root(RESULT_DURATION)) } pub fn highest_bid(&self) -> ScMutableUint64 { - ScMutableUint64::new(self.id, RESULT_HIGHEST_BID.get_key_id()) + ScMutableUint64::new(self.proxy.root(RESULT_HIGHEST_BID)) } pub fn highest_bidder(&self) -> ScMutableAgentID { - ScMutableAgentID::new(self.id, RESULT_HIGHEST_BIDDER.get_key_id()) + ScMutableAgentID::new(self.proxy.root(RESULT_HIGHEST_BIDDER)) } pub fn minimum_bid(&self) -> ScMutableUint64 { - ScMutableUint64::new(self.id, RESULT_MINIMUM_BID.get_key_id()) + ScMutableUint64::new(self.proxy.root(RESULT_MINIMUM_BID)) } pub fn num_tokens(&self) -> ScMutableUint64 { - ScMutableUint64::new(self.id, RESULT_NUM_TOKENS.get_key_id()) + ScMutableUint64::new(self.proxy.root(RESULT_NUM_TOKENS)) } pub fn owner_margin(&self) -> ScMutableUint64 { - ScMutableUint64::new(self.id, RESULT_OWNER_MARGIN.get_key_id()) + ScMutableUint64::new(self.proxy.root(RESULT_OWNER_MARGIN)) } pub fn when_started(&self) -> ScMutableUint64 { - ScMutableUint64::new(self.id, RESULT_WHEN_STARTED.get_key_id()) + ScMutableUint64::new(self.proxy.root(RESULT_WHEN_STARTED)) } } diff --git a/contracts/wasm/fairauction/src/state.rs b/contracts/wasm/fairauction/src/state.rs index e78565a455..82cc101b0c 100644 --- a/contracts/wasm/fairauction/src/state.rs +++ b/contracts/wasm/fairauction/src/state.rs @@ -9,147 +9,133 @@ #![allow(unused_imports)] use wasmlib::*; -use wasmlib::host::*; use crate::*; -use crate::keys::*; -use crate::structs::*; -use crate::typedefs::*; -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MapColorToImmutableAuction { - pub(crate) obj_id: i32, + pub(crate) proxy: Proxy, } impl MapColorToImmutableAuction { pub fn get_auction(&self, key: &ScColor) -> ImmutableAuction { - ImmutableAuction { obj_id: self.obj_id, key_id: key.get_key_id() } + ImmutableAuction { proxy: self.proxy.key(&color_to_bytes(key)) } } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MapColorToImmutableBidderList { - pub(crate) obj_id: i32, + pub(crate) proxy: Proxy, } impl MapColorToImmutableBidderList { pub fn get_bidder_list(&self, key: &ScColor) -> ImmutableBidderList { - let sub_id = get_object_id(self.obj_id, key.get_key_id(), TYPE_ARRAY | TYPE_AGENT_ID); - ImmutableBidderList { obj_id: sub_id } + ImmutableBidderList { proxy: self.proxy.key(&color_to_bytes(key)) } } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MapColorToImmutableBids { - pub(crate) obj_id: i32, + pub(crate) proxy: Proxy, } impl MapColorToImmutableBids { pub fn get_bids(&self, key: &ScColor) -> ImmutableBids { - let sub_id = get_object_id(self.obj_id, key.get_key_id(), TYPE_MAP); - ImmutableBids { obj_id: sub_id } + ImmutableBids { proxy: self.proxy.key(&color_to_bytes(key)) } } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableFairAuctionState { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableFairAuctionState { pub fn auctions(&self) -> MapColorToImmutableAuction { - let map_id = get_object_id(self.id, STATE_AUCTIONS.get_key_id(), TYPE_MAP); - MapColorToImmutableAuction { obj_id: map_id } + MapColorToImmutableAuction { proxy: self.proxy.root(STATE_AUCTIONS) } } pub fn bidder_list(&self) -> MapColorToImmutableBidderList { - let map_id = get_object_id(self.id, STATE_BIDDER_LIST.get_key_id(), TYPE_MAP); - MapColorToImmutableBidderList { obj_id: map_id } + MapColorToImmutableBidderList { proxy: self.proxy.root(STATE_BIDDER_LIST) } } pub fn bids(&self) -> MapColorToImmutableBids { - let map_id = get_object_id(self.id, STATE_BIDS.get_key_id(), TYPE_MAP); - MapColorToImmutableBids { obj_id: map_id } + MapColorToImmutableBids { proxy: self.proxy.root(STATE_BIDS) } } pub fn owner_margin(&self) -> ScImmutableUint64 { - ScImmutableUint64::new(self.id, STATE_OWNER_MARGIN.get_key_id()) + ScImmutableUint64::new(self.proxy.root(STATE_OWNER_MARGIN)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MapColorToMutableAuction { - pub(crate) obj_id: i32, + pub(crate) proxy: Proxy, } impl MapColorToMutableAuction { pub fn clear(&self) { - clear(self.obj_id); + self.proxy.clear_map(); } pub fn get_auction(&self, key: &ScColor) -> MutableAuction { - MutableAuction { obj_id: self.obj_id, key_id: key.get_key_id() } + MutableAuction { proxy: self.proxy.key(&color_to_bytes(key)) } } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MapColorToMutableBidderList { - pub(crate) obj_id: i32, + pub(crate) proxy: Proxy, } impl MapColorToMutableBidderList { pub fn clear(&self) { - clear(self.obj_id); + self.proxy.clear_map(); } pub fn get_bidder_list(&self, key: &ScColor) -> MutableBidderList { - let sub_id = get_object_id(self.obj_id, key.get_key_id(), TYPE_ARRAY | TYPE_AGENT_ID); - MutableBidderList { obj_id: sub_id } + MutableBidderList { proxy: self.proxy.key(&color_to_bytes(key)) } } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MapColorToMutableBids { - pub(crate) obj_id: i32, + pub(crate) proxy: Proxy, } impl MapColorToMutableBids { pub fn clear(&self) { - clear(self.obj_id); + self.proxy.clear_map(); } pub fn get_bids(&self, key: &ScColor) -> MutableBids { - let sub_id = get_object_id(self.obj_id, key.get_key_id(), TYPE_MAP); - MutableBids { obj_id: sub_id } + MutableBids { proxy: self.proxy.key(&color_to_bytes(key)) } } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableFairAuctionState { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableFairAuctionState { pub fn as_immutable(&self) -> ImmutableFairAuctionState { - ImmutableFairAuctionState { id: self.id } + ImmutableFairAuctionState { proxy: self.proxy.root("") } } pub fn auctions(&self) -> MapColorToMutableAuction { - let map_id = get_object_id(self.id, STATE_AUCTIONS.get_key_id(), TYPE_MAP); - MapColorToMutableAuction { obj_id: map_id } + MapColorToMutableAuction { proxy: self.proxy.root(STATE_AUCTIONS) } } pub fn bidder_list(&self) -> MapColorToMutableBidderList { - let map_id = get_object_id(self.id, STATE_BIDDER_LIST.get_key_id(), TYPE_MAP); - MapColorToMutableBidderList { obj_id: map_id } + MapColorToMutableBidderList { proxy: self.proxy.root(STATE_BIDDER_LIST) } } pub fn bids(&self) -> MapColorToMutableBids { - let map_id = get_object_id(self.id, STATE_BIDS.get_key_id(), TYPE_MAP); - MapColorToMutableBids { obj_id: map_id } + MapColorToMutableBids { proxy: self.proxy.root(STATE_BIDS) } } pub fn owner_margin(&self) -> ScMutableUint64 { - ScMutableUint64::new(self.id, STATE_OWNER_MARGIN.get_key_id()) + ScMutableUint64::new(self.proxy.root(STATE_OWNER_MARGIN)) } } diff --git a/contracts/wasm/fairauction/src/structs.rs b/contracts/wasm/fairauction/src/structs.rs index 18935b7857..27ee703b4f 100644 --- a/contracts/wasm/fairauction/src/structs.rs +++ b/contracts/wasm/fairauction/src/structs.rs @@ -9,7 +9,6 @@ #![allow(unused_imports)] use wasmlib::*; -use wasmlib::host::*; use crate::typedefs::*; #[derive(Clone)] @@ -29,76 +28,74 @@ pub struct Auction { impl Auction { pub fn from_bytes(bytes: &[u8]) -> Auction { - let mut decode = BytesDecoder::new(bytes); + let mut dec = WasmDecoder::new(bytes); Auction { - color : decode.color(), - creator : decode.agent_id(), - deposit : decode.uint64(), - description : decode.string(), - duration : decode.uint32(), - highest_bid : decode.uint64(), - highest_bidder : decode.agent_id(), - minimum_bid : decode.uint64(), - num_tokens : decode.uint64(), - owner_margin : decode.uint64(), - when_started : decode.uint64(), + color : color_decode(&mut dec), + creator : agent_id_decode(&mut dec), + deposit : uint64_decode(&mut dec), + description : string_decode(&mut dec), + duration : uint32_decode(&mut dec), + highest_bid : uint64_decode(&mut dec), + highest_bidder : agent_id_decode(&mut dec), + minimum_bid : uint64_decode(&mut dec), + num_tokens : uint64_decode(&mut dec), + owner_margin : uint64_decode(&mut dec), + when_started : uint64_decode(&mut dec), } } pub fn to_bytes(&self) -> Vec { - let mut encode = BytesEncoder::new(); - encode.color(&self.color); - encode.agent_id(&self.creator); - encode.uint64(self.deposit); - encode.string(&self.description); - encode.uint32(self.duration); - encode.uint64(self.highest_bid); - encode.agent_id(&self.highest_bidder); - encode.uint64(self.minimum_bid); - encode.uint64(self.num_tokens); - encode.uint64(self.owner_margin); - encode.uint64(self.when_started); - return encode.data(); + let mut enc = WasmEncoder::new(); + color_encode(&mut enc, &self.color); + agent_id_encode(&mut enc, &self.creator); + uint64_encode(&mut enc, self.deposit); + string_encode(&mut enc, &self.description); + uint32_encode(&mut enc, self.duration); + uint64_encode(&mut enc, self.highest_bid); + agent_id_encode(&mut enc, &self.highest_bidder); + uint64_encode(&mut enc, self.minimum_bid); + uint64_encode(&mut enc, self.num_tokens); + uint64_encode(&mut enc, self.owner_margin); + uint64_encode(&mut enc, self.when_started); + enc.buf() } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableAuction { - pub(crate) obj_id: i32, - pub(crate) key_id: Key32, + pub(crate) proxy: Proxy, } impl ImmutableAuction { pub fn exists(&self) -> bool { - exists(self.obj_id, self.key_id, TYPE_BYTES) + self.proxy.exists() } pub fn value(&self) -> Auction { - Auction::from_bytes(&get_bytes(self.obj_id, self.key_id, TYPE_BYTES)) + Auction::from_bytes(&self.proxy.get()) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableAuction { - pub(crate) obj_id: i32, - pub(crate) key_id: Key32, + pub(crate) proxy: Proxy, } impl MutableAuction { pub fn delete(&self) { - del_key(self.obj_id, self.key_id, TYPE_BYTES); + self.proxy.delete(); } pub fn exists(&self) -> bool { - exists(self.obj_id, self.key_id, TYPE_BYTES) + self.proxy.exists() } pub fn set_value(&self, value: &Auction) { - set_bytes(self.obj_id, self.key_id, TYPE_BYTES, &value.to_bytes()); + self.proxy.set(&value.to_bytes()); } pub fn value(&self) -> Auction { - Auction::from_bytes(&get_bytes(self.obj_id, self.key_id, TYPE_BYTES)) + Auction::from_bytes(&self.proxy.get()) } } @@ -111,59 +108,57 @@ pub struct Bid { impl Bid { pub fn from_bytes(bytes: &[u8]) -> Bid { - let mut decode = BytesDecoder::new(bytes); + let mut dec = WasmDecoder::new(bytes); Bid { - amount : decode.uint64(), - index : decode.uint32(), - timestamp : decode.uint64(), + amount : uint64_decode(&mut dec), + index : uint32_decode(&mut dec), + timestamp : uint64_decode(&mut dec), } } pub fn to_bytes(&self) -> Vec { - let mut encode = BytesEncoder::new(); - encode.uint64(self.amount); - encode.uint32(self.index); - encode.uint64(self.timestamp); - return encode.data(); + let mut enc = WasmEncoder::new(); + uint64_encode(&mut enc, self.amount); + uint32_encode(&mut enc, self.index); + uint64_encode(&mut enc, self.timestamp); + enc.buf() } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableBid { - pub(crate) obj_id: i32, - pub(crate) key_id: Key32, + pub(crate) proxy: Proxy, } impl ImmutableBid { pub fn exists(&self) -> bool { - exists(self.obj_id, self.key_id, TYPE_BYTES) + self.proxy.exists() } pub fn value(&self) -> Bid { - Bid::from_bytes(&get_bytes(self.obj_id, self.key_id, TYPE_BYTES)) + Bid::from_bytes(&self.proxy.get()) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableBid { - pub(crate) obj_id: i32, - pub(crate) key_id: Key32, + pub(crate) proxy: Proxy, } impl MutableBid { pub fn delete(&self) { - del_key(self.obj_id, self.key_id, TYPE_BYTES); + self.proxy.delete(); } pub fn exists(&self) -> bool { - exists(self.obj_id, self.key_id, TYPE_BYTES) + self.proxy.exists() } pub fn set_value(&self, value: &Bid) { - set_bytes(self.obj_id, self.key_id, TYPE_BYTES, &value.to_bytes()); + self.proxy.set(&value.to_bytes()); } pub fn value(&self) -> Bid { - Bid::from_bytes(&get_bytes(self.obj_id, self.key_id, TYPE_BYTES)) + Bid::from_bytes(&self.proxy.get()) } } diff --git a/contracts/wasm/fairauction/src/typedefs.rs b/contracts/wasm/fairauction/src/typedefs.rs index 123f38eec8..3d72f5d290 100644 --- a/contracts/wasm/fairauction/src/typedefs.rs +++ b/contracts/wasm/fairauction/src/typedefs.rs @@ -8,72 +8,75 @@ #![allow(dead_code)] use wasmlib::*; -use wasmlib::host::*; use crate::structs::*; -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ArrayOfImmutableAgentID { - pub(crate) obj_id: i32, + pub(crate) proxy: Proxy, } impl ArrayOfImmutableAgentID { pub fn length(&self) -> u32 { - get_length(self.obj_id) + self.proxy.length() } pub fn get_agent_id(&self, index: u32) -> ScImmutableAgentID { - ScImmutableAgentID::new(self.obj_id, Key32(index as i32)) + ScImmutableAgentID::new(self.proxy.index(index)) } } pub type ImmutableBidderList = ArrayOfImmutableAgentID; -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ArrayOfMutableAgentID { - pub(crate) obj_id: i32, + pub(crate) proxy: Proxy, } impl ArrayOfMutableAgentID { - pub fn clear(&self) { - clear(self.obj_id); + pub fn append_agent_id(&self) -> ScMutableAgentID { + ScMutableAgentID::new(self.proxy.append()) + } + + pub fn clear(&self) { + self.proxy.clear_array(); } pub fn length(&self) -> u32 { - get_length(self.obj_id) + self.proxy.length() } pub fn get_agent_id(&self, index: u32) -> ScMutableAgentID { - ScMutableAgentID::new(self.obj_id, Key32(index as i32)) + ScMutableAgentID::new(self.proxy.index(index)) } } pub type MutableBidderList = ArrayOfMutableAgentID; -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MapAgentIDToImmutableBid { - pub(crate) obj_id: i32, + pub(crate) proxy: Proxy, } impl MapAgentIDToImmutableBid { pub fn get_bid(&self, key: &ScAgentID) -> ImmutableBid { - ImmutableBid { obj_id: self.obj_id, key_id: key.get_key_id() } + ImmutableBid { proxy: self.proxy.key(&agent_id_to_bytes(key)) } } } pub type ImmutableBids = MapAgentIDToImmutableBid; -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MapAgentIDToMutableBid { - pub(crate) obj_id: i32, + pub(crate) proxy: Proxy, } impl MapAgentIDToMutableBid { pub fn clear(&self) { - clear(self.obj_id); + self.proxy.clear_map(); } pub fn get_bid(&self, key: &ScAgentID) -> MutableBid { - MutableBid { obj_id: self.obj_id, key_id: key.get_key_id() } + MutableBid { proxy: self.proxy.key(&agent_id_to_bytes(key)) } } } diff --git a/contracts/wasm/fairauction/test/fairauction_bg.wasm b/contracts/wasm/fairauction/test/fairauction_bg.wasm index 6a1f50c25afe193e8611c26e19ed55dfd92e1489..8ffaeb218d2f5b07f3cd312e8b10ea8547aca081 100644 GIT binary patch literal 71620 zcmdqK54@&jUFUz_*Zn-t`SY9uH#+LbOmRO?`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{x@o#%R)+!=EkAiRMIY<)syW`0jn3O(!*%hwobvZZ0>q zpH!%ZGYfv#@@QRQVbok|Ds?4iL@iAn;mX2{Qq)qqcx~sB)+MC{<>q~_dGkeWia&XA z>&+j%YIkM$iT6FWf8kw!bI{=rQvN@qsF#@95jX>Kc=aMPi;_pFOnl%{lPt3UL7 zdH;9MZ2I`W?>lW#I3+6YyW_T~uh1GcmEzypIQ+kx2g^H7UNiiWX)TvGoihC1edmVn zSvC2@_gs9|@L$glXGFoiohu9ed%WTA&AlLMj)I$~yzzq94gbk&i+=Q$!pxR$7&vmZSFXm9sL z>-!(P=wpvn*Z2I@57&F&uU_mO`Qe+|f7pG=kAL*wrH7yU;iZYU;4Me}$KT@ZB=9pI zgD2phe_o~i#MtjC1;rrnqu=mn&wP7jWmA(soj(i$_ZH3yubu2Cq@De!jMynPqf=I@ zb5y25b1;KcGeaIXZUXb>j9tdDEkY2jst{z zWs-HD8I=8>2x&fsO^i9fC_nOlyWoYaGHMGW|5J?b1s~=;vyREj!$pj>I-FDR%dh7E z&eA40#=kNY0*n3uKP;bU*!2CA{7I#-@TX-h;bdWw-BBw)_$S~ga-A8xrK~5M)3e$h zKBmjcn*8A3*lTFOzni%tKWT0&+V1ejdKZ9Xk3XaB`)@ueC~36cEHVLjhPpJB5B#Vd z&p#)6lkQn(R4A8&((LG7UaN@~m;FipNdjl)O13oIC8tb?hv zr+cV}JlL18d3}su9VFAuyP9?m^l#a{8Q(7`Z^O;lO%%kB6x8!tsM_2!IM}mg{-*20 zf`UMsPhGTNS^I+aq;2!2&Sl+OmTlRT$Q7I4zIgtk_PNDtiSq6qEVeILw0uE(i=v+M dH({0%See?sVDW-ZI&SJ%vTWJr#hvYQ{|}7j=Mw+` diff --git a/contracts/wasm/fairauction/ts/fairauction/keys.ts b/contracts/wasm/fairauction/ts/fairauction/keys.ts deleted file mode 100644 index d582c31633..0000000000 --- a/contracts/wasm/fairauction/ts/fairauction/keys.ts +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2020 IOTA Stiftung -// SPDX-License-Identifier: Apache-2.0 - -// (Re-)generated by schema tool -// >>>> DO NOT CHANGE THIS FILE! <<<< -// Change the json schema instead - - -export const IdxParamColor = 0; -export const IdxParamDescription = 1; -export const IdxParamDuration = 2; -export const IdxParamMinimumBid = 3; -export const IdxParamOwnerMargin = 4; diff --git a/contracts/wasm/fairroulette/go/fairroulette/keys.go b/contracts/wasm/fairroulette/go/fairroulette/keys.go deleted file mode 100644 index 2882306527..0000000000 --- a/contracts/wasm/fairroulette/go/fairroulette/keys.go +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright 2020 IOTA Stiftung -// SPDX-License-Identifier: Apache-2.0 - -// (Re-)generated by schema tool -// >>>> DO NOT CHANGE THIS FILE! <<<< -// Change the json schema instead - -package fairroulette diff --git a/contracts/wasm/fairroulette/src/contract.rs b/contracts/wasm/fairroulette/src/contract.rs index cfdd6239e9..93e41a2410 100644 --- a/contracts/wasm/fairroulette/src/contract.rs +++ b/contracts/wasm/fairroulette/src/contract.rs @@ -7,8 +7,6 @@ #![allow(dead_code)] -use std::ptr; - use wasmlib::*; use crate::consts::*; @@ -61,75 +59,75 @@ pub struct ScFuncs { } impl ScFuncs { - pub fn force_payout(_ctx: & dyn ScFuncCallContext) -> ForcePayoutCall { + pub fn force_payout(_ctx: &dyn ScFuncCallContext) -> ForcePayoutCall { ForcePayoutCall { func: ScFunc::new(HSC_NAME, HFUNC_FORCE_PAYOUT), } } - pub fn force_reset(_ctx: & dyn ScFuncCallContext) -> ForceResetCall { + pub fn force_reset(_ctx: &dyn ScFuncCallContext) -> ForceResetCall { ForceResetCall { func: ScFunc::new(HSC_NAME, HFUNC_FORCE_RESET), } } - pub fn pay_winners(_ctx: & dyn ScFuncCallContext) -> PayWinnersCall { + pub fn pay_winners(_ctx: &dyn ScFuncCallContext) -> PayWinnersCall { PayWinnersCall { func: ScFunc::new(HSC_NAME, HFUNC_PAY_WINNERS), } } - pub fn place_bet(_ctx: & dyn ScFuncCallContext) -> PlaceBetCall { + pub fn place_bet(_ctx: &dyn ScFuncCallContext) -> PlaceBetCall { let mut f = PlaceBetCall { func: ScFunc::new(HSC_NAME, HFUNC_PLACE_BET), - params: MutablePlaceBetParams { id: 0 }, + params: MutablePlaceBetParams { proxy: Proxy::nil() }, }; - f.func.set_ptrs(&mut f.params.id, ptr::null_mut()); + ScFunc::link_params(&mut f.params.proxy, &f.func); f } - pub fn play_period(_ctx: & dyn ScFuncCallContext) -> PlayPeriodCall { + pub fn play_period(_ctx: &dyn ScFuncCallContext) -> PlayPeriodCall { let mut f = PlayPeriodCall { func: ScFunc::new(HSC_NAME, HFUNC_PLAY_PERIOD), - params: MutablePlayPeriodParams { id: 0 }, + params: MutablePlayPeriodParams { proxy: Proxy::nil() }, }; - f.func.set_ptrs(&mut f.params.id, ptr::null_mut()); + ScFunc::link_params(&mut f.params.proxy, &f.func); f } - pub fn last_winning_number(_ctx: & dyn ScViewCallContext) -> LastWinningNumberCall { + pub fn last_winning_number(_ctx: &dyn ScViewCallContext) -> LastWinningNumberCall { let mut f = LastWinningNumberCall { func: ScView::new(HSC_NAME, HVIEW_LAST_WINNING_NUMBER), - results: ImmutableLastWinningNumberResults { id: 0 }, + results: ImmutableLastWinningNumberResults { proxy: Proxy::nil() }, }; - f.func.set_ptrs(ptr::null_mut(), &mut f.results.id); + ScView::link_results(&mut f.results.proxy, &f.func); f } - pub fn round_number(_ctx: & dyn ScViewCallContext) -> RoundNumberCall { + pub fn round_number(_ctx: &dyn ScViewCallContext) -> RoundNumberCall { let mut f = RoundNumberCall { func: ScView::new(HSC_NAME, HVIEW_ROUND_NUMBER), - results: ImmutableRoundNumberResults { id: 0 }, + results: ImmutableRoundNumberResults { proxy: Proxy::nil() }, }; - f.func.set_ptrs(ptr::null_mut(), &mut f.results.id); + ScView::link_results(&mut f.results.proxy, &f.func); f } - pub fn round_started_at(_ctx: & dyn ScViewCallContext) -> RoundStartedAtCall { + pub fn round_started_at(_ctx: &dyn ScViewCallContext) -> RoundStartedAtCall { let mut f = RoundStartedAtCall { func: ScView::new(HSC_NAME, HVIEW_ROUND_STARTED_AT), - results: ImmutableRoundStartedAtResults { id: 0 }, + results: ImmutableRoundStartedAtResults { proxy: Proxy::nil() }, }; - f.func.set_ptrs(ptr::null_mut(), &mut f.results.id); + ScView::link_results(&mut f.results.proxy, &f.func); f } - pub fn round_status(_ctx: & dyn ScViewCallContext) -> RoundStatusCall { + pub fn round_status(_ctx: &dyn ScViewCallContext) -> RoundStatusCall { let mut f = RoundStatusCall { func: ScView::new(HSC_NAME, HVIEW_ROUND_STATUS), - results: ImmutableRoundStatusResults { id: 0 }, + results: ImmutableRoundStatusResults { proxy: Proxy::nil() }, }; - f.func.set_ptrs(ptr::null_mut(), &mut f.results.id); + ScView::link_results(&mut f.results.proxy, &f.func); f } } diff --git a/contracts/wasm/fairroulette/src/events.rs b/contracts/wasm/fairroulette/src/events.rs index 838e1e032d..5c27ee9975 100644 --- a/contracts/wasm/fairroulette/src/events.rs +++ b/contracts/wasm/fairroulette/src/events.rs @@ -6,6 +6,7 @@ // Change the json schema instead #![allow(dead_code)] +#![allow(unused_mut)] use wasmlib::*; @@ -15,37 +16,39 @@ pub struct FairRouletteEvents { impl FairRouletteEvents { pub fn bet(&self, address: &ScAddress, amount: u64, number: u16) { - let mut encoder = EventEncoder::new("fairroulette.bet"); - encoder.address(&address); - encoder.uint64(amount); - encoder.uint16(number); - encoder.emit(); + let mut evt = EventEncoder::new("fairroulette.bet"); + evt.encode(&address_to_string(&address)); + evt.encode(&uint64_to_string(amount)); + evt.encode(&uint16_to_string(number)); + evt.emit(); } pub fn payout(&self, address: &ScAddress, amount: u64) { - let mut encoder = EventEncoder::new("fairroulette.payout"); - encoder.address(&address); - encoder.uint64(amount); - encoder.emit(); + let mut evt = EventEncoder::new("fairroulette.payout"); + evt.encode(&address_to_string(&address)); + evt.encode(&uint64_to_string(amount)); + evt.emit(); } pub fn round(&self, number: u32) { - let mut encoder = EventEncoder::new("fairroulette.round"); - encoder.uint32(number); - encoder.emit(); + let mut evt = EventEncoder::new("fairroulette.round"); + evt.encode(&uint32_to_string(number)); + evt.emit(); } pub fn start(&self) { - EventEncoder::new("fairroulette.start").emit(); + let mut evt = EventEncoder::new("fairroulette.start"); + evt.emit(); } pub fn stop(&self) { - EventEncoder::new("fairroulette.stop").emit(); + let mut evt = EventEncoder::new("fairroulette.stop"); + evt.emit(); } pub fn winner(&self, number: u16) { - let mut encoder = EventEncoder::new("fairroulette.winner"); - encoder.uint16(number); - encoder.emit(); + let mut evt = EventEncoder::new("fairroulette.winner"); + evt.encode(&uint16_to_string(number)); + evt.emit(); } } diff --git a/contracts/wasm/fairroulette/src/fairroulette.rs b/contracts/wasm/fairroulette/src/fairroulette.rs index 1ba07ef5bd..9b897835e2 100644 --- a/contracts/wasm/fairroulette/src/fairroulette.rs +++ b/contracts/wasm/fairroulette/src/fairroulette.rs @@ -39,7 +39,8 @@ pub fn func_place_bet(ctx: &ScFuncContext, f: &PlaceBetContext) { // Get the array of current bets from state storage. let bets: ArrayOfMutableBet = f.state.bets(); - for i in 0..bets.length() { + let nr_of_bets = bets.length(); + for i in 0..nr_of_bets { let bet: Bet = bets.get_bet(i).value(); if bet.better.address() == ctx.caller().address() { @@ -74,17 +75,14 @@ pub fn func_place_bet(ctx: &ScFuncContext, f: &PlaceBetContext) { number: number, }; - // Determine what the next bet number is by retrieving the length of the bets array. - let bet_nr: u32 = bets.length(); - // Append the bet data to the bets array. The bet array will automatically take care // of serializing the bet struct into a bytes representation. - bets.get_bet(bet_nr).set_value(&bet); + bets.append_bet().set_value(&bet); f.events.bet(&bet.better.address(), bet.amount, bet.number); // Was this the first bet of this round? - if bet_nr == 0 { + if nr_of_bets == 0 { // Yes it was, query the state for the length of the playing period in seconds by // retrieving the playPeriod value from state storage let mut play_period: u32 = f.state.play_period().value(); @@ -154,10 +152,10 @@ pub fn func_pay_winners(ctx: &ScFuncContext, f: &PayWinnersContext) { let bets: ArrayOfMutableBet = f.state.bets(); // Determine the amount of bets in the 'bets' array. - let nr_bets: u32 = bets.length(); + let nr_of_bets: u32 = bets.length(); // Loop through all indexes of the 'bets' array. - for i in 0..nr_bets { + for i in 0..nr_of_bets { // Retrieve the bet stored at the next index let bet: Bet = bets.get_bet(i).value(); diff --git a/contracts/wasm/fairroulette/src/keys.rs b/contracts/wasm/fairroulette/src/keys.rs deleted file mode 100644 index e487249b10..0000000000 --- a/contracts/wasm/fairroulette/src/keys.rs +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright 2020 IOTA Stiftung -// SPDX-License-Identifier: Apache-2.0 - -// (Re-)generated by schema tool -// >>>> DO NOT CHANGE THIS FILE! <<<< -// Change the json schema instead - -#![allow(dead_code)] - -use wasmlib::*; - -use crate::*; - -pub(crate) const IDX_PARAM_NUMBER : usize = 0; -pub(crate) const IDX_PARAM_PLAY_PERIOD : usize = 1; - -pub(crate) const IDX_RESULT_LAST_WINNING_NUMBER : usize = 2; -pub(crate) const IDX_RESULT_ROUND_NUMBER : usize = 3; -pub(crate) const IDX_RESULT_ROUND_STARTED_AT : usize = 4; -pub(crate) const IDX_RESULT_ROUND_STATUS : usize = 5; - -pub(crate) const IDX_STATE_BETS : usize = 6; -pub(crate) const IDX_STATE_LAST_WINNING_NUMBER : usize = 7; -pub(crate) const IDX_STATE_PLAY_PERIOD : usize = 8; -pub(crate) const IDX_STATE_ROUND_NUMBER : usize = 9; -pub(crate) const IDX_STATE_ROUND_STARTED_AT : usize = 10; -pub(crate) const IDX_STATE_ROUND_STATUS : usize = 11; - -pub const KEY_MAP_LEN: usize = 12; - -pub const KEY_MAP: [&str; KEY_MAP_LEN] = [ - PARAM_NUMBER, - PARAM_PLAY_PERIOD, - RESULT_LAST_WINNING_NUMBER, - RESULT_ROUND_NUMBER, - RESULT_ROUND_STARTED_AT, - RESULT_ROUND_STATUS, - STATE_BETS, - STATE_LAST_WINNING_NUMBER, - STATE_PLAY_PERIOD, - STATE_ROUND_NUMBER, - STATE_ROUND_STARTED_AT, - STATE_ROUND_STATUS, -]; - -pub static mut IDX_MAP: [Key32; KEY_MAP_LEN] = [Key32(0); KEY_MAP_LEN]; - -pub fn idx_map(idx: usize) -> Key32 { - unsafe { - IDX_MAP[idx] - } -} diff --git a/contracts/wasm/fairroulette/src/lib.rs b/contracts/wasm/fairroulette/src/lib.rs index 753003c506..a68f8e7911 100644 --- a/contracts/wasm/fairroulette/src/lib.rs +++ b/contracts/wasm/fairroulette/src/lib.rs @@ -10,19 +10,17 @@ use fairroulette::*; use wasmlib::*; -use wasmlib::host::*; use crate::consts::*; use crate::events::*; -use crate::keys::*; use crate::params::*; use crate::results::*; use crate::state::*; +use crate::structs::*; mod consts; mod contract; mod events; -mod keys; mod params; mod results; mod state; @@ -41,12 +39,6 @@ fn on_load() { exports.add_view(VIEW_ROUND_NUMBER, view_round_number_thunk); exports.add_view(VIEW_ROUND_STARTED_AT, view_round_started_at_thunk); exports.add_view(VIEW_ROUND_STATUS, view_round_status_thunk); - - unsafe { - for i in 0..KEY_MAP_LEN { - IDX_MAP[i] = get_key_id_from_string(KEY_MAP[i]); - } - } } pub struct ForcePayoutContext { @@ -56,16 +48,14 @@ pub struct ForcePayoutContext { fn func_force_payout_thunk(ctx: &ScFuncContext) { ctx.log("fairroulette.funcForcePayout"); + let f = ForcePayoutContext { + events: FairRouletteEvents {}, + state: MutableFairRouletteState { proxy: state_proxy() }, + }; // only SC creator can restart the round forcefully ctx.require(ctx.caller() == ctx.contract_creator(), "no permission"); - let f = ForcePayoutContext { - events: FairRouletteEvents {}, - state: MutableFairRouletteState { - id: OBJ_ID_STATE, - }, - }; func_force_payout(ctx, &f); ctx.log("fairroulette.funcForcePayout ok"); } @@ -77,16 +67,14 @@ pub struct ForceResetContext { fn func_force_reset_thunk(ctx: &ScFuncContext) { ctx.log("fairroulette.funcForceReset"); + let f = ForceResetContext { + events: FairRouletteEvents {}, + state: MutableFairRouletteState { proxy: state_proxy() }, + }; // only SC creator can restart the round forcefully ctx.require(ctx.caller() == ctx.contract_creator(), "no permission"); - let f = ForceResetContext { - events: FairRouletteEvents {}, - state: MutableFairRouletteState { - id: OBJ_ID_STATE, - }, - }; func_force_reset(ctx, &f); ctx.log("fairroulette.funcForceReset ok"); } @@ -98,16 +86,14 @@ pub struct PayWinnersContext { fn func_pay_winners_thunk(ctx: &ScFuncContext) { ctx.log("fairroulette.funcPayWinners"); + let f = PayWinnersContext { + events: FairRouletteEvents {}, + state: MutableFairRouletteState { proxy: state_proxy() }, + }; // only SC itself can invoke this function ctx.require(ctx.caller() == ctx.account_id(), "no permission"); - let f = PayWinnersContext { - events: FairRouletteEvents {}, - state: MutableFairRouletteState { - id: OBJ_ID_STATE, - }, - }; func_pay_winners(ctx, &f); ctx.log("fairroulette.funcPayWinners ok"); } @@ -122,12 +108,8 @@ fn func_place_bet_thunk(ctx: &ScFuncContext) { ctx.log("fairroulette.funcPlaceBet"); let f = PlaceBetContext { events: FairRouletteEvents {}, - params: ImmutablePlaceBetParams { - id: OBJ_ID_PARAMS, - }, - state: MutableFairRouletteState { - id: OBJ_ID_STATE, - }, + params: ImmutablePlaceBetParams { proxy: params_proxy() }, + state: MutableFairRouletteState { proxy: state_proxy() }, }; ctx.require(f.params.number().exists(), "missing mandatory number"); func_place_bet(ctx, &f); @@ -142,19 +124,15 @@ pub struct PlayPeriodContext { fn func_play_period_thunk(ctx: &ScFuncContext) { ctx.log("fairroulette.funcPlayPeriod"); + let f = PlayPeriodContext { + events: FairRouletteEvents {}, + params: ImmutablePlayPeriodParams { proxy: params_proxy() }, + state: MutableFairRouletteState { proxy: state_proxy() }, + }; // only SC creator can update the play period ctx.require(ctx.caller() == ctx.contract_creator(), "no permission"); - let f = PlayPeriodContext { - events: FairRouletteEvents {}, - params: ImmutablePlayPeriodParams { - id: OBJ_ID_PARAMS, - }, - state: MutableFairRouletteState { - id: OBJ_ID_STATE, - }, - }; ctx.require(f.params.play_period().exists(), "missing mandatory playPeriod"); func_play_period(ctx, &f); ctx.log("fairroulette.funcPlayPeriod ok"); @@ -168,14 +146,11 @@ pub struct LastWinningNumberContext { fn view_last_winning_number_thunk(ctx: &ScViewContext) { ctx.log("fairroulette.viewLastWinningNumber"); let f = LastWinningNumberContext { - results: MutableLastWinningNumberResults { - id: OBJ_ID_RESULTS, - }, - state: ImmutableFairRouletteState { - id: OBJ_ID_STATE, - }, + results: MutableLastWinningNumberResults { proxy: results_proxy() }, + state: ImmutableFairRouletteState { proxy: state_proxy() }, }; view_last_winning_number(ctx, &f); + ctx.results(&f.results.proxy.kv_store); ctx.log("fairroulette.viewLastWinningNumber ok"); } @@ -187,14 +162,11 @@ pub struct RoundNumberContext { fn view_round_number_thunk(ctx: &ScViewContext) { ctx.log("fairroulette.viewRoundNumber"); let f = RoundNumberContext { - results: MutableRoundNumberResults { - id: OBJ_ID_RESULTS, - }, - state: ImmutableFairRouletteState { - id: OBJ_ID_STATE, - }, + results: MutableRoundNumberResults { proxy: results_proxy() }, + state: ImmutableFairRouletteState { proxy: state_proxy() }, }; view_round_number(ctx, &f); + ctx.results(&f.results.proxy.kv_store); ctx.log("fairroulette.viewRoundNumber ok"); } @@ -206,14 +178,11 @@ pub struct RoundStartedAtContext { fn view_round_started_at_thunk(ctx: &ScViewContext) { ctx.log("fairroulette.viewRoundStartedAt"); let f = RoundStartedAtContext { - results: MutableRoundStartedAtResults { - id: OBJ_ID_RESULTS, - }, - state: ImmutableFairRouletteState { - id: OBJ_ID_STATE, - }, + results: MutableRoundStartedAtResults { proxy: results_proxy() }, + state: ImmutableFairRouletteState { proxy: state_proxy() }, }; view_round_started_at(ctx, &f); + ctx.results(&f.results.proxy.kv_store); ctx.log("fairroulette.viewRoundStartedAt ok"); } @@ -225,13 +194,10 @@ pub struct RoundStatusContext { fn view_round_status_thunk(ctx: &ScViewContext) { ctx.log("fairroulette.viewRoundStatus"); let f = RoundStatusContext { - results: MutableRoundStatusResults { - id: OBJ_ID_RESULTS, - }, - state: ImmutableFairRouletteState { - id: OBJ_ID_STATE, - }, + results: MutableRoundStatusResults { proxy: results_proxy() }, + state: ImmutableFairRouletteState { proxy: state_proxy() }, }; view_round_status(ctx, &f); + ctx.results(&f.results.proxy.kv_store); ctx.log("fairroulette.viewRoundStatus ok"); } diff --git a/contracts/wasm/fairroulette/src/params.rs b/contracts/wasm/fairroulette/src/params.rs index 0df4fb72e3..2bbddfd291 100644 --- a/contracts/wasm/fairroulette/src/params.rs +++ b/contracts/wasm/fairroulette/src/params.rs @@ -9,52 +9,48 @@ #![allow(unused_imports)] use wasmlib::*; -use wasmlib::host::*; - use crate::*; -use crate::keys::*; -use crate::structs::*; -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutablePlaceBetParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutablePlaceBetParams { pub fn number(&self) -> ScImmutableUint16 { - ScImmutableUint16::new(self.id, PARAM_NUMBER.get_key_id()) + ScImmutableUint16::new(self.proxy.root(PARAM_NUMBER)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutablePlaceBetParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutablePlaceBetParams { pub fn number(&self) -> ScMutableUint16 { - ScMutableUint16::new(self.id, PARAM_NUMBER.get_key_id()) + ScMutableUint16::new(self.proxy.root(PARAM_NUMBER)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutablePlayPeriodParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutablePlayPeriodParams { pub fn play_period(&self) -> ScImmutableUint32 { - ScImmutableUint32::new(self.id, PARAM_PLAY_PERIOD.get_key_id()) + ScImmutableUint32::new(self.proxy.root(PARAM_PLAY_PERIOD)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutablePlayPeriodParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutablePlayPeriodParams { pub fn play_period(&self) -> ScMutableUint32 { - ScMutableUint32::new(self.id, PARAM_PLAY_PERIOD.get_key_id()) + ScMutableUint32::new(self.proxy.root(PARAM_PLAY_PERIOD)) } } diff --git a/contracts/wasm/fairroulette/src/results.rs b/contracts/wasm/fairroulette/src/results.rs index 8c0a904962..116797efb3 100644 --- a/contracts/wasm/fairroulette/src/results.rs +++ b/contracts/wasm/fairroulette/src/results.rs @@ -9,96 +9,92 @@ #![allow(unused_imports)] use wasmlib::*; -use wasmlib::host::*; - use crate::*; -use crate::keys::*; -use crate::structs::*; -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableLastWinningNumberResults { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableLastWinningNumberResults { pub fn last_winning_number(&self) -> ScImmutableUint16 { - ScImmutableUint16::new(self.id, RESULT_LAST_WINNING_NUMBER.get_key_id()) + ScImmutableUint16::new(self.proxy.root(RESULT_LAST_WINNING_NUMBER)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableLastWinningNumberResults { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableLastWinningNumberResults { pub fn last_winning_number(&self) -> ScMutableUint16 { - ScMutableUint16::new(self.id, RESULT_LAST_WINNING_NUMBER.get_key_id()) + ScMutableUint16::new(self.proxy.root(RESULT_LAST_WINNING_NUMBER)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableRoundNumberResults { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableRoundNumberResults { pub fn round_number(&self) -> ScImmutableUint32 { - ScImmutableUint32::new(self.id, RESULT_ROUND_NUMBER.get_key_id()) + ScImmutableUint32::new(self.proxy.root(RESULT_ROUND_NUMBER)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableRoundNumberResults { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableRoundNumberResults { pub fn round_number(&self) -> ScMutableUint32 { - ScMutableUint32::new(self.id, RESULT_ROUND_NUMBER.get_key_id()) + ScMutableUint32::new(self.proxy.root(RESULT_ROUND_NUMBER)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableRoundStartedAtResults { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableRoundStartedAtResults { pub fn round_started_at(&self) -> ScImmutableUint32 { - ScImmutableUint32::new(self.id, RESULT_ROUND_STARTED_AT.get_key_id()) + ScImmutableUint32::new(self.proxy.root(RESULT_ROUND_STARTED_AT)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableRoundStartedAtResults { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableRoundStartedAtResults { pub fn round_started_at(&self) -> ScMutableUint32 { - ScMutableUint32::new(self.id, RESULT_ROUND_STARTED_AT.get_key_id()) + ScMutableUint32::new(self.proxy.root(RESULT_ROUND_STARTED_AT)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableRoundStatusResults { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableRoundStatusResults { pub fn round_status(&self) -> ScImmutableUint16 { - ScImmutableUint16::new(self.id, RESULT_ROUND_STATUS.get_key_id()) + ScImmutableUint16::new(self.proxy.root(RESULT_ROUND_STATUS)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableRoundStatusResults { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableRoundStatusResults { pub fn round_status(&self) -> ScMutableUint16 { - ScMutableUint16::new(self.id, RESULT_ROUND_STATUS.get_key_id()) + ScMutableUint16::new(self.proxy.root(RESULT_ROUND_STATUS)) } } diff --git a/contracts/wasm/fairroulette/src/state.rs b/contracts/wasm/fairroulette/src/state.rs index 20f12b0ef7..011c023ab1 100644 --- a/contracts/wasm/fairroulette/src/state.rs +++ b/contracts/wasm/fairroulette/src/state.rs @@ -9,110 +9,111 @@ #![allow(unused_imports)] use wasmlib::*; -use wasmlib::host::*; use crate::*; -use crate::keys::*; -use crate::structs::*; -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ArrayOfImmutableBet { - pub(crate) obj_id: i32, + pub(crate) proxy: Proxy, } impl ArrayOfImmutableBet { pub fn length(&self) -> u32 { - get_length(self.obj_id) + self.proxy.length() } + pub fn get_bet(&self, index: u32) -> ImmutableBet { - ImmutableBet { obj_id: self.obj_id, key_id: Key32(index as i32) } + ImmutableBet { proxy: self.proxy.index(index) } } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableFairRouletteState { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableFairRouletteState { pub fn bets(&self) -> ArrayOfImmutableBet { - let arr_id = get_object_id(self.id, STATE_BETS.get_key_id(), TYPE_ARRAY | TYPE_BYTES); - ArrayOfImmutableBet { obj_id: arr_id } + ArrayOfImmutableBet { proxy: self.proxy.root(STATE_BETS) } } pub fn last_winning_number(&self) -> ScImmutableUint16 { - ScImmutableUint16::new(self.id, STATE_LAST_WINNING_NUMBER.get_key_id()) + ScImmutableUint16::new(self.proxy.root(STATE_LAST_WINNING_NUMBER)) } pub fn play_period(&self) -> ScImmutableUint32 { - ScImmutableUint32::new(self.id, STATE_PLAY_PERIOD.get_key_id()) + ScImmutableUint32::new(self.proxy.root(STATE_PLAY_PERIOD)) } pub fn round_number(&self) -> ScImmutableUint32 { - ScImmutableUint32::new(self.id, STATE_ROUND_NUMBER.get_key_id()) + ScImmutableUint32::new(self.proxy.root(STATE_ROUND_NUMBER)) } pub fn round_started_at(&self) -> ScImmutableUint32 { - ScImmutableUint32::new(self.id, STATE_ROUND_STARTED_AT.get_key_id()) + ScImmutableUint32::new(self.proxy.root(STATE_ROUND_STARTED_AT)) } pub fn round_status(&self) -> ScImmutableUint16 { - ScImmutableUint16::new(self.id, STATE_ROUND_STATUS.get_key_id()) + ScImmutableUint16::new(self.proxy.root(STATE_ROUND_STATUS)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ArrayOfMutableBet { - pub(crate) obj_id: i32, + pub(crate) proxy: Proxy, } impl ArrayOfMutableBet { - pub fn clear(&self) { - clear(self.obj_id); + + pub fn append_bet(&self) -> MutableBet { + MutableBet { proxy: self.proxy.append() } + } + pub fn clear(&self) { + self.proxy.clear_array(); } pub fn length(&self) -> u32 { - get_length(self.obj_id) + self.proxy.length() } + pub fn get_bet(&self, index: u32) -> MutableBet { - MutableBet { obj_id: self.obj_id, key_id: Key32(index as i32) } + MutableBet { proxy: self.proxy.index(index) } } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableFairRouletteState { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableFairRouletteState { pub fn as_immutable(&self) -> ImmutableFairRouletteState { - ImmutableFairRouletteState { id: self.id } + ImmutableFairRouletteState { proxy: self.proxy.root("") } } pub fn bets(&self) -> ArrayOfMutableBet { - let arr_id = get_object_id(self.id, STATE_BETS.get_key_id(), TYPE_ARRAY | TYPE_BYTES); - ArrayOfMutableBet { obj_id: arr_id } + ArrayOfMutableBet { proxy: self.proxy.root(STATE_BETS) } } pub fn last_winning_number(&self) -> ScMutableUint16 { - ScMutableUint16::new(self.id, STATE_LAST_WINNING_NUMBER.get_key_id()) + ScMutableUint16::new(self.proxy.root(STATE_LAST_WINNING_NUMBER)) } pub fn play_period(&self) -> ScMutableUint32 { - ScMutableUint32::new(self.id, STATE_PLAY_PERIOD.get_key_id()) + ScMutableUint32::new(self.proxy.root(STATE_PLAY_PERIOD)) } pub fn round_number(&self) -> ScMutableUint32 { - ScMutableUint32::new(self.id, STATE_ROUND_NUMBER.get_key_id()) + ScMutableUint32::new(self.proxy.root(STATE_ROUND_NUMBER)) } pub fn round_started_at(&self) -> ScMutableUint32 { - ScMutableUint32::new(self.id, STATE_ROUND_STARTED_AT.get_key_id()) + ScMutableUint32::new(self.proxy.root(STATE_ROUND_STARTED_AT)) } pub fn round_status(&self) -> ScMutableUint16 { - ScMutableUint16::new(self.id, STATE_ROUND_STATUS.get_key_id()) + ScMutableUint16::new(self.proxy.root(STATE_ROUND_STATUS)) } } diff --git a/contracts/wasm/fairroulette/src/structs.rs b/contracts/wasm/fairroulette/src/structs.rs index 1e4ba4c7ff..1d6aa76ba5 100644 --- a/contracts/wasm/fairroulette/src/structs.rs +++ b/contracts/wasm/fairroulette/src/structs.rs @@ -9,7 +9,6 @@ #![allow(unused_imports)] use wasmlib::*; -use wasmlib::host::*; #[derive(Clone)] pub struct Bet { @@ -20,59 +19,57 @@ pub struct Bet { impl Bet { pub fn from_bytes(bytes: &[u8]) -> Bet { - let mut decode = BytesDecoder::new(bytes); + let mut dec = WasmDecoder::new(bytes); Bet { - amount : decode.uint64(), - better : decode.agent_id(), - number : decode.uint16(), + amount : uint64_decode(&mut dec), + better : agent_id_decode(&mut dec), + number : uint16_decode(&mut dec), } } pub fn to_bytes(&self) -> Vec { - let mut encode = BytesEncoder::new(); - encode.uint64(self.amount); - encode.agent_id(&self.better); - encode.uint16(self.number); - return encode.data(); + let mut enc = WasmEncoder::new(); + uint64_encode(&mut enc, self.amount); + agent_id_encode(&mut enc, &self.better); + uint16_encode(&mut enc, self.number); + enc.buf() } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableBet { - pub(crate) obj_id: i32, - pub(crate) key_id: Key32, + pub(crate) proxy: Proxy, } impl ImmutableBet { pub fn exists(&self) -> bool { - exists(self.obj_id, self.key_id, TYPE_BYTES) + self.proxy.exists() } pub fn value(&self) -> Bet { - Bet::from_bytes(&get_bytes(self.obj_id, self.key_id, TYPE_BYTES)) + Bet::from_bytes(&self.proxy.get()) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableBet { - pub(crate) obj_id: i32, - pub(crate) key_id: Key32, + pub(crate) proxy: Proxy, } impl MutableBet { pub fn delete(&self) { - del_key(self.obj_id, self.key_id, TYPE_BYTES); + self.proxy.delete(); } pub fn exists(&self) -> bool { - exists(self.obj_id, self.key_id, TYPE_BYTES) + self.proxy.exists() } pub fn set_value(&self, value: &Bet) { - set_bytes(self.obj_id, self.key_id, TYPE_BYTES, &value.to_bytes()); + self.proxy.set(&value.to_bytes()); } pub fn value(&self) -> Bet { - Bet::from_bytes(&get_bytes(self.obj_id, self.key_id, TYPE_BYTES)) + Bet::from_bytes(&self.proxy.get()) } } diff --git a/contracts/wasm/fairroulette/test/fairroulette_bg.wasm b/contracts/wasm/fairroulette/test/fairroulette_bg.wasm index 8a487046e577c630120c4f266620f0d80ef06705..ad3fda95ecbe0cd445816a4f8f04e977f6456d43 100644 GIT binary patch literal 75201 zcmdqK51eIHb?1A|KKI_bRkx}+t*y3nPdxXgofHE+I}<|ppfjo6qd*4@OyXonX2xLt zJhcjy#uha}x{%hOqBao|G>9z{K?4E*6GLLDXfPp2jE*GXnGPWdnUG8;F&QQ?GT+}? z`<#1jb#>E7=S|+DKh!;c_TRPF|F!l$*$ZFs(mczu{M!7f=Y>6cGX2T-oR@P|?6FJz zWIW($hfA)z`r$WI=}YY0CH^jz;hCDbF{%c$!Ob3vb% z@I&kRdkKAqXN0N$#9*KMk{_LY@ylPa`v-QvaQ9FAz)$SXdWSwfgU5s7tKlo5I~79F z34=~Ids46H6ur)Dr;}x!yqB-o1N(8(#OvRU4H za^CAu=ZT%r2~$&94#cQA$Dh#a^*X)IRHrlB&3jLvbZ5E~o)Y+vMtYqPtiL{WXp5Iw z*3(N~XLL5Lj(S}77^wcE*Q`57H$feD_^;dT^PcNG4+a0LM3!e1SVt*Und^4CMVCqH zr4}>mXG}QDm^zK*DwK7zeqVi3G4IUGXolS`FY`{w2SrxsS{-KHu3mKec}{P6$fmpe z$1DEpc4ua07+5#IAV2fWZjoo}d($9BTwY$u22)khd+ATS^yL@6CS+4Df7y?m|MD09 zc=o1Tmp}Hx^Uu$IC7*sBeZ+il#=G*L&#%e9|5-ozQy0JXE8*O)gca86dj9`V_)PdT zzxwyt@Za*UgzLC^AOF8xk3JCo-Cg;A?@ptE64nG^7`JW!nKN{Wpc3X^C5fATpqKkvotK!U)ZCY*uQARi|qLLG;SVw_5MS!bc@RNZoapycl1RLq8X zVY4YeA4Z|-?3~LOR%eOp;%u&YUxiUImr=5qEe5o_!CDGckAhh>75~LWv9oJ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>iRT{sm?DR(VevT{*ZhvK^n dH(~-495|wD(b7ddG~C#|Y{iOAOMAK&{68vx=12el diff --git a/contracts/wasm/fairroulette/ts/fairroulette/fairroulette.ts b/contracts/wasm/fairroulette/ts/fairroulette/fairroulette.ts index 653fbae2f0..f5ebb791b3 100644 --- a/contracts/wasm/fairroulette/ts/fairroulette/fairroulette.ts +++ b/contracts/wasm/fairroulette/ts/fairroulette/fairroulette.ts @@ -37,8 +37,8 @@ export function funcPlaceBet(ctx: wasmlib.ScFuncContext, f: sc.PlaceBetContext): // Get the array of current bets from state storage. let bets: sc.ArrayOfMutableBet = f.state.bets(); - const nrBets = bets.length(); - for (let i: u32 = 0; i < nrBets; i++) { + const nrOfBets = bets.length(); + for (let i: u32 = 0; i < nrOfBets; i++) { let bet: sc.Bet = bets.getBet(i).value(); if (bet.better.address() == ctx.caller().address()) { @@ -72,9 +72,6 @@ export function funcPlaceBet(ctx: wasmlib.ScFuncContext, f: sc.PlaceBetContext): bet.amount = amount; bet.number = number; - // Determine what the next bet number is by retrieving the length of the bets array. - let betNr: u32 = bets.length(); - // Append the bet data to the bets array. The bet array will automatically take care // of serializing the bet struct into a bytes representation. bets.appendBet().setValue(bet); @@ -82,7 +79,7 @@ export function funcPlaceBet(ctx: wasmlib.ScFuncContext, f: sc.PlaceBetContext): f.events.bet(bet.better.address(), bet.amount, bet.number); // Was this the first bet of this round? - if (betNr == 0) { + if (nrOfBets == 0) { // Yes it was, query the state for the length of the playing period in seconds by // retrieving the playPeriod value from state storage let playPeriod: u32 = f.state.playPeriod().value(); @@ -152,10 +149,10 @@ export function funcPayWinners(ctx: wasmlib.ScFuncContext, f: sc.PayWinnersConte let bets: sc.ArrayOfMutableBet = f.state.bets(); // Determine the amount of bets in the 'bets' array. - let nrBets: u32 = bets.length(); + let nrOfBets: u32 = bets.length(); // Loop through all indexes of the 'bets' array. - for (let i: u32 = 0; i < nrBets; i++) { + for (let i: u32 = 0; i < nrOfBets; i++) { // Retrieve the bet stored at the next index let bet: sc.Bet = bets.getBet(i).value(); diff --git a/contracts/wasm/fairroulette/ts/fairroulette/keys.ts b/contracts/wasm/fairroulette/ts/fairroulette/keys.ts deleted file mode 100644 index 300e156672..0000000000 --- a/contracts/wasm/fairroulette/ts/fairroulette/keys.ts +++ /dev/null @@ -1,10 +0,0 @@ -// Copyright 2020 IOTA Stiftung -// SPDX-License-Identifier: Apache-2.0 - -// (Re-)generated by schema tool -// >>>> DO NOT CHANGE THIS FILE! <<<< -// Change the json schema instead - - -export const IdxParamNumber = 0; -export const IdxParamPlayPeriod = 1; diff --git a/contracts/wasm/helloworld/go/helloworld/keys.go b/contracts/wasm/helloworld/go/helloworld/keys.go deleted file mode 100644 index 9346abb4e0..0000000000 --- a/contracts/wasm/helloworld/go/helloworld/keys.go +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright 2020 IOTA Stiftung -// SPDX-License-Identifier: Apache-2.0 - -// (Re-)generated by schema tool -// >>>> DO NOT CHANGE THIS FILE! <<<< -// Change the json schema instead - -package helloworld diff --git a/contracts/wasm/helloworld/src/contract.rs b/contracts/wasm/helloworld/src/contract.rs index ca5b365fd9..27ed5ecc8d 100644 --- a/contracts/wasm/helloworld/src/contract.rs +++ b/contracts/wasm/helloworld/src/contract.rs @@ -7,8 +7,6 @@ #![allow(dead_code)] -use std::ptr; - use wasmlib::*; use crate::consts::*; @@ -27,18 +25,18 @@ pub struct ScFuncs { } impl ScFuncs { - pub fn hello_world(_ctx: & dyn ScFuncCallContext) -> HelloWorldCall { + pub fn hello_world(_ctx: &dyn ScFuncCallContext) -> HelloWorldCall { HelloWorldCall { func: ScFunc::new(HSC_NAME, HFUNC_HELLO_WORLD), } } - pub fn get_hello_world(_ctx: & dyn ScViewCallContext) -> GetHelloWorldCall { + pub fn get_hello_world(_ctx: &dyn ScViewCallContext) -> GetHelloWorldCall { let mut f = GetHelloWorldCall { func: ScView::new(HSC_NAME, HVIEW_GET_HELLO_WORLD), - results: ImmutableGetHelloWorldResults { id: 0 }, + results: ImmutableGetHelloWorldResults { proxy: Proxy::nil() }, }; - f.func.set_ptrs(ptr::null_mut(), &mut f.results.id); + ScView::link_results(&mut f.results.proxy, &f.func); f } } diff --git a/contracts/wasm/helloworld/src/keys.rs b/contracts/wasm/helloworld/src/keys.rs deleted file mode 100644 index 468a469a19..0000000000 --- a/contracts/wasm/helloworld/src/keys.rs +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright 2020 IOTA Stiftung -// SPDX-License-Identifier: Apache-2.0 - -// (Re-)generated by schema tool -// >>>> DO NOT CHANGE THIS FILE! <<<< -// Change the json schema instead - -#![allow(dead_code)] - -use wasmlib::*; - -use crate::*; - - -pub(crate) const IDX_RESULT_HELLO_WORLD : usize = 0; - - -pub const KEY_MAP_LEN: usize = 1; - -pub const KEY_MAP: [&str; KEY_MAP_LEN] = [ - RESULT_HELLO_WORLD, -]; - -pub static mut IDX_MAP: [Key32; KEY_MAP_LEN] = [Key32(0); KEY_MAP_LEN]; - -pub fn idx_map(idx: usize) -> Key32 { - unsafe { - IDX_MAP[idx] - } -} diff --git a/contracts/wasm/helloworld/src/lib.rs b/contracts/wasm/helloworld/src/lib.rs index 80bb927a85..2633ab21f2 100644 --- a/contracts/wasm/helloworld/src/lib.rs +++ b/contracts/wasm/helloworld/src/lib.rs @@ -10,16 +10,13 @@ use helloworld::*; use wasmlib::*; -use wasmlib::host::*; use crate::consts::*; -use crate::keys::*; use crate::results::*; use crate::state::*; mod consts; mod contract; -mod keys; mod results; mod state; mod helloworld; @@ -29,12 +26,6 @@ fn on_load() { let exports = ScExports::new(); exports.add_func(FUNC_HELLO_WORLD, func_hello_world_thunk); exports.add_view(VIEW_GET_HELLO_WORLD, view_get_hello_world_thunk); - - unsafe { - for i in 0..KEY_MAP_LEN { - IDX_MAP[i] = get_key_id_from_string(KEY_MAP[i]); - } - } } pub struct HelloWorldContext { @@ -44,9 +35,7 @@ pub struct HelloWorldContext { fn func_hello_world_thunk(ctx: &ScFuncContext) { ctx.log("helloworld.funcHelloWorld"); let f = HelloWorldContext { - state: MutableHelloWorldState { - id: OBJ_ID_STATE, - }, + state: MutableHelloWorldState { proxy: state_proxy() }, }; func_hello_world(ctx, &f); ctx.log("helloworld.funcHelloWorld ok"); @@ -60,13 +49,10 @@ pub struct GetHelloWorldContext { fn view_get_hello_world_thunk(ctx: &ScViewContext) { ctx.log("helloworld.viewGetHelloWorld"); let f = GetHelloWorldContext { - results: MutableGetHelloWorldResults { - id: OBJ_ID_RESULTS, - }, - state: ImmutableHelloWorldState { - id: OBJ_ID_STATE, - }, + results: MutableGetHelloWorldResults { proxy: results_proxy() }, + state: ImmutableHelloWorldState { proxy: state_proxy() }, }; view_get_hello_world(ctx, &f); + ctx.results(&f.results.proxy.kv_store); ctx.log("helloworld.viewGetHelloWorld ok"); } diff --git a/contracts/wasm/helloworld/src/results.rs b/contracts/wasm/helloworld/src/results.rs index 49fc1b6000..798cb05acd 100644 --- a/contracts/wasm/helloworld/src/results.rs +++ b/contracts/wasm/helloworld/src/results.rs @@ -9,29 +9,26 @@ #![allow(unused_imports)] use wasmlib::*; -use wasmlib::host::*; - use crate::*; -use crate::keys::*; -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableGetHelloWorldResults { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableGetHelloWorldResults { pub fn hello_world(&self) -> ScImmutableString { - ScImmutableString::new(self.id, RESULT_HELLO_WORLD.get_key_id()) + ScImmutableString::new(self.proxy.root(RESULT_HELLO_WORLD)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableGetHelloWorldResults { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableGetHelloWorldResults { pub fn hello_world(&self) -> ScMutableString { - ScMutableString::new(self.id, RESULT_HELLO_WORLD.get_key_id()) + ScMutableString::new(self.proxy.root(RESULT_HELLO_WORLD)) } } diff --git a/contracts/wasm/helloworld/src/state.rs b/contracts/wasm/helloworld/src/state.rs index 435ad75b1c..bbde370a5e 100644 --- a/contracts/wasm/helloworld/src/state.rs +++ b/contracts/wasm/helloworld/src/state.rs @@ -9,17 +9,15 @@ #![allow(unused_imports)] use wasmlib::*; -use wasmlib::host::*; use crate::*; -use crate::keys::*; -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableHelloWorldState { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableHelloWorldState { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } diff --git a/contracts/wasm/helloworld/test/helloworld_bg.wasm b/contracts/wasm/helloworld/test/helloworld_bg.wasm index 2841ff6b87cd7faff56b55614a27503a675f95cd..87a4824bc2db7ccd3795f02ef39ffc5ff8e8691c 100644 GIT binary patch literal 37435 zcmc(|3!Gk6eeb>3-ut=CJTu7-1jvoBpT{T@$YpYynFN&CQ34^{6cCjtnIr>bCdni- zlLV@g2}CP`7!;K%QnXa?3Lf>;({gltk6LUwil5h3w6sQFdJgA3yq2D0TUxDozrX+5 z`eWDv@1*f==FxC@Sh|D7VS5z)X zj{i~FRVYMp?7Ie0;Ha-w!&1~1#SzcDD6GaBOSe%FyQowWHriZR;=+?9{<%^$2tvD~ zvQ%nsZ)f(B+vCnUs}#9lR=JJ!XA={XL9MbdD(@QHH8Ofr7*s}fU%PW;V0&<#?zRo= z+!rVu2Ax4IEi-Mo9(07Y z6z-~N+RUXT0g>EXtaqFg=Dc0c!tVp zMTm}SAt=udj+q1uHK5Ws%YR%X67!d{YR*3Q{475GMK=PRdO#FBgNkVz4Hc=YwhG`CyEj4;FDJ))!BC)(<`FJFs2+Z*mIq zxe>kl#FTJv>WrkM(i$9YLK6(LVl?WI*T<+RU#bpaI^yJal5J^CY*9VGv#h&ny(4={ z%i=z6wA(%HLk++UvZJ)vFH@r_*i7A~`D%I6!ytA2G`IC2f+)#5U0U5Bb;iJ^jyht$ zWS*}}bE3VR2T2PNi)T$_sE~=&ghxsL_b!~RLqqXH86;z{ccefVqS3xyuxw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zHA=;8ZiJzw<@NRD^GD7-l{D7qTYAs<(dq8dZgFVo-0bw?`RViL3f=lhcjCx+_i*$2 r;w7dvyGO_8j&?`H^GD8s*bB>7?&}_%I6BM1b2F3E(@PVx-NXM6neS;) diff --git a/contracts/wasm/helloworld/ts/helloworld/keys.ts b/contracts/wasm/helloworld/ts/helloworld/keys.ts deleted file mode 100644 index c8806d28c4..0000000000 --- a/contracts/wasm/helloworld/ts/helloworld/keys.ts +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright 2020 IOTA Stiftung -// SPDX-License-Identifier: Apache-2.0 - -// (Re-)generated by schema tool -// >>>> DO NOT CHANGE THIS FILE! <<<< -// Change the json schema instead - - diff --git a/contracts/wasm/inccounter/go/inccounter/inccounter.go b/contracts/wasm/inccounter/go/inccounter/inccounter.go index f259354fbc..7df1839aee 100644 --- a/contracts/wasm/inccounter/go/inccounter/inccounter.go +++ b/contracts/wasm/inccounter/go/inccounter/inccounter.go @@ -222,12 +222,13 @@ func vliSave(ctx wasmlib.ScFuncContext, name string, value int64) { state := ctx.RawState() key := []byte(name) state.Set(key, enc.VliEncode(value).Buf()) + buf := state.Get(key) dec := wasmtypes.NewWasmDecoder(buf) - val := wasmtypes.Int64Decode(dec) + val := dec.VliDecode(64) if val != value { - ctx.Log(name + " in : " + ctx.Utility().String(value)) - ctx.Log(name + " out: " + ctx.Utility().String(val)) + ctx.Log(name + " in : " + wasmtypes.Int64ToString(value)) + ctx.Log(name + " out: " + wasmtypes.Int64ToString(val)) } } @@ -236,12 +237,13 @@ func vluSave(ctx wasmlib.ScFuncContext, name string, value uint64) { state := ctx.RawState() key := []byte(name) state.Set(key, enc.VluEncode(value).Buf()) + buf := state.Get(key) dec := wasmtypes.NewWasmDecoder(buf) - val := wasmtypes.Uint64Decode(dec) + val := dec.VluDecode(64) if val != value { - ctx.Log(name + " in : " + ctx.Utility().String(int64(value))) - ctx.Log(name + " out: " + ctx.Utility().String(int64(val))) + ctx.Log(name + " in : " + wasmtypes.Uint64ToString(value)) + ctx.Log(name + " out: " + wasmtypes.Uint64ToString(val)) } } diff --git a/contracts/wasm/inccounter/go/inccounter/keys.go b/contracts/wasm/inccounter/go/inccounter/keys.go deleted file mode 100644 index 7d83ea0649..0000000000 --- a/contracts/wasm/inccounter/go/inccounter/keys.go +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright 2020 IOTA Stiftung -// SPDX-License-Identifier: Apache-2.0 - -// (Re-)generated by schema tool -// >>>> DO NOT CHANGE THIS FILE! <<<< -// Change the json schema instead - -package inccounter diff --git a/contracts/wasm/inccounter/src/contract.rs b/contracts/wasm/inccounter/src/contract.rs index 56934259db..1c3a324d99 100644 --- a/contracts/wasm/inccounter/src/contract.rs +++ b/contracts/wasm/inccounter/src/contract.rs @@ -7,8 +7,6 @@ #![allow(dead_code)] -use std::ptr; - use wasmlib::*; use crate::consts::*; @@ -96,128 +94,130 @@ pub struct ScFuncs { } impl ScFuncs { - pub fn call_increment(_ctx: & dyn ScFuncCallContext) -> CallIncrementCall { + pub fn call_increment(_ctx: &dyn ScFuncCallContext) -> CallIncrementCall { CallIncrementCall { func: ScFunc::new(HSC_NAME, HFUNC_CALL_INCREMENT), } } - pub fn call_increment_recurse5x(_ctx: & dyn ScFuncCallContext) -> CallIncrementRecurse5xCall { + pub fn call_increment_recurse5x(_ctx: &dyn ScFuncCallContext) -> CallIncrementRecurse5xCall { CallIncrementRecurse5xCall { func: ScFunc::new(HSC_NAME, HFUNC_CALL_INCREMENT_RECURSE5X), } } - pub fn endless_loop(_ctx: & dyn ScFuncCallContext) -> EndlessLoopCall { + pub fn endless_loop(_ctx: &dyn ScFuncCallContext) -> EndlessLoopCall { EndlessLoopCall { func: ScFunc::new(HSC_NAME, HFUNC_ENDLESS_LOOP), } } - pub fn increment(_ctx: & dyn ScFuncCallContext) -> IncrementCall { + pub fn increment(_ctx: &dyn ScFuncCallContext) -> IncrementCall { IncrementCall { func: ScFunc::new(HSC_NAME, HFUNC_INCREMENT), } } - pub fn increment_with_delay(_ctx: & dyn ScFuncCallContext) -> IncrementWithDelayCall { + pub fn increment_with_delay(_ctx: &dyn ScFuncCallContext) -> IncrementWithDelayCall { let mut f = IncrementWithDelayCall { func: ScFunc::new(HSC_NAME, HFUNC_INCREMENT_WITH_DELAY), - params: MutableIncrementWithDelayParams { id: 0 }, + params: MutableIncrementWithDelayParams { proxy: Proxy::nil() }, }; - f.func.set_ptrs(&mut f.params.id, ptr::null_mut()); + ScFunc::link_params(&mut f.params.proxy, &f.func); f } - pub fn init(_ctx: & dyn ScFuncCallContext) -> InitCall { + pub fn init(_ctx: &dyn ScFuncCallContext) -> InitCall { let mut f = InitCall { func: ScInitFunc::new(HSC_NAME, HFUNC_INIT), - params: MutableInitParams { id: 0 }, + params: MutableInitParams { proxy: Proxy::nil() }, }; - f.func.set_ptrs(&mut f.params.id, ptr::null_mut()); + ScInitFunc::link_params(&mut f.params.proxy, &f.func); f } - pub fn local_state_internal_call(_ctx: & dyn ScFuncCallContext) -> LocalStateInternalCallCall { + pub fn local_state_internal_call(_ctx: &dyn ScFuncCallContext) -> LocalStateInternalCallCall { LocalStateInternalCallCall { func: ScFunc::new(HSC_NAME, HFUNC_LOCAL_STATE_INTERNAL_CALL), } } - pub fn local_state_post(_ctx: & dyn ScFuncCallContext) -> LocalStatePostCall { + pub fn local_state_post(_ctx: &dyn ScFuncCallContext) -> LocalStatePostCall { LocalStatePostCall { func: ScFunc::new(HSC_NAME, HFUNC_LOCAL_STATE_POST), } } - pub fn local_state_sandbox_call(_ctx: & dyn ScFuncCallContext) -> LocalStateSandboxCallCall { + pub fn local_state_sandbox_call(_ctx: &dyn ScFuncCallContext) -> LocalStateSandboxCallCall { LocalStateSandboxCallCall { func: ScFunc::new(HSC_NAME, HFUNC_LOCAL_STATE_SANDBOX_CALL), } } - pub fn post_increment(_ctx: & dyn ScFuncCallContext) -> PostIncrementCall { + pub fn post_increment(_ctx: &dyn ScFuncCallContext) -> PostIncrementCall { PostIncrementCall { func: ScFunc::new(HSC_NAME, HFUNC_POST_INCREMENT), } } - pub fn repeat_many(_ctx: & dyn ScFuncCallContext) -> RepeatManyCall { + pub fn repeat_many(_ctx: &dyn ScFuncCallContext) -> RepeatManyCall { let mut f = RepeatManyCall { func: ScFunc::new(HSC_NAME, HFUNC_REPEAT_MANY), - params: MutableRepeatManyParams { id: 0 }, + params: MutableRepeatManyParams { proxy: Proxy::nil() }, }; - f.func.set_ptrs(&mut f.params.id, ptr::null_mut()); + ScFunc::link_params(&mut f.params.proxy, &f.func); f } - pub fn test_vli_codec(_ctx: & dyn ScFuncCallContext) -> TestVliCodecCall { + pub fn test_vli_codec(_ctx: &dyn ScFuncCallContext) -> TestVliCodecCall { TestVliCodecCall { func: ScFunc::new(HSC_NAME, HFUNC_TEST_VLI_CODEC), } } - pub fn test_vlu_codec(_ctx: & dyn ScFuncCallContext) -> TestVluCodecCall { + pub fn test_vlu_codec(_ctx: &dyn ScFuncCallContext) -> TestVluCodecCall { TestVluCodecCall { func: ScFunc::new(HSC_NAME, HFUNC_TEST_VLU_CODEC), } } - pub fn when_must_increment(_ctx: & dyn ScFuncCallContext) -> WhenMustIncrementCall { + pub fn when_must_increment(_ctx: &dyn ScFuncCallContext) -> WhenMustIncrementCall { let mut f = WhenMustIncrementCall { func: ScFunc::new(HSC_NAME, HFUNC_WHEN_MUST_INCREMENT), - params: MutableWhenMustIncrementParams { id: 0 }, + params: MutableWhenMustIncrementParams { proxy: Proxy::nil() }, }; - f.func.set_ptrs(&mut f.params.id, ptr::null_mut()); + ScFunc::link_params(&mut f.params.proxy, &f.func); f } - pub fn get_counter(_ctx: & dyn ScViewCallContext) -> GetCounterCall { + pub fn get_counter(_ctx: &dyn ScViewCallContext) -> GetCounterCall { let mut f = GetCounterCall { func: ScView::new(HSC_NAME, HVIEW_GET_COUNTER), - results: ImmutableGetCounterResults { id: 0 }, + results: ImmutableGetCounterResults { proxy: Proxy::nil() }, }; - f.func.set_ptrs(ptr::null_mut(), &mut f.results.id); + ScView::link_results(&mut f.results.proxy, &f.func); f } - pub fn get_vli(_ctx: & dyn ScViewCallContext) -> GetVliCall { + pub fn get_vli(_ctx: &dyn ScViewCallContext) -> GetVliCall { let mut f = GetVliCall { func: ScView::new(HSC_NAME, HVIEW_GET_VLI), - params: MutableGetVliParams { id: 0 }, - results: ImmutableGetVliResults { id: 0 }, + params: MutableGetVliParams { proxy: Proxy::nil() }, + results: ImmutableGetVliResults { proxy: Proxy::nil() }, }; - f.func.set_ptrs(&mut f.params.id, &mut f.results.id); + ScView::link_params(&mut f.params.proxy, &f.func); + ScView::link_results(&mut f.results.proxy, &f.func); f } - pub fn get_vlu(_ctx: & dyn ScViewCallContext) -> GetVluCall { + pub fn get_vlu(_ctx: &dyn ScViewCallContext) -> GetVluCall { let mut f = GetVluCall { func: ScView::new(HSC_NAME, HVIEW_GET_VLU), - params: MutableGetVluParams { id: 0 }, - results: ImmutableGetVluResults { id: 0 }, + params: MutableGetVluParams { proxy: Proxy::nil() }, + results: ImmutableGetVluResults { proxy: Proxy::nil() }, }; - f.func.set_ptrs(&mut f.params.id, &mut f.results.id); + ScView::link_params(&mut f.params.proxy, &f.func); + ScView::link_results(&mut f.results.proxy, &f.func); f } } diff --git a/contracts/wasm/inccounter/src/inccounter.rs b/contracts/wasm/inccounter/src/inccounter.rs index a86fc3c75b..676c8ff3d9 100644 --- a/contracts/wasm/inccounter/src/inccounter.rs +++ b/contracts/wasm/inccounter/src/inccounter.rs @@ -167,12 +167,12 @@ pub fn view_get_counter(_ctx: &ScViewContext, f: &GetCounterContext) { } pub fn view_get_vli(_ctx: &ScViewContext, f: &GetVliContext) { - let mut enc = BytesEncoder::new(); + let mut enc = WasmEncoder::new(); let n = f.params.ni64().value(); - enc.int64(n); - let buf = enc.data(); - let mut dec = BytesDecoder::new(&buf); - let x = dec.int64(); + int64_encode(&mut enc,n); + let buf = enc.buf(); + let mut dec = WasmDecoder::new(&buf); + let x = int64_decode(&mut dec); let mut str = n.to_string() + " -"; for b in &buf { @@ -189,12 +189,12 @@ pub fn view_get_vli(_ctx: &ScViewContext, f: &GetVliContext) { } pub fn view_get_vlu(_ctx: &ScViewContext, f: &GetVluContext) { - let mut enc = BytesEncoder::new(); + let mut enc = WasmEncoder::new(); let n = f.params.nu64().value(); - enc.uint64(n); - let buf = enc.data(); - let mut dec = BytesDecoder::new(&buf); - let x = dec.uint64(); + uint64_encode(&mut enc, n); + let buf = enc.buf(); + let mut dec = WasmDecoder::new(&buf); + let x = uint64_decode(&mut dec); let mut str = n.to_string() + " -"; for b in &buf { @@ -220,32 +220,32 @@ fn local_state_post(ctx: &ScFuncContext, nr: i64) { } fn vli_save(ctx: &ScFuncContext, name: &str, value: i64) { - let mut encoder = BytesEncoder::new(); - encoder.int64(value); - let spot = ctx.state().get_bytes(name); - spot.set_value(&encoder.data()); - - let bytes = spot.value(); - let mut decoder = BytesDecoder::new(&bytes); - let retrieved = decoder.int64(); - if retrieved != value { + let mut enc = WasmEncoder::new(); + let state = ctx.raw_state(); + let key = string_to_bytes(name); + state.set(&key, &enc.vli_encode(value).buf()); + + let buf = state.get(&key); + let mut dec = WasmDecoder::new(&buf); + let val = dec.vli_decode(64); + if val != value { ctx.log(&(name.to_string() + " in : " + &value.to_string())); - ctx.log(&(name.to_string() + " out: " + &retrieved.to_string())); + ctx.log(&(name.to_string() + " out: " + &val.to_string())); } } fn vlu_save(ctx: &ScFuncContext, name: &str, value: u64) { - let mut encoder = BytesEncoder::new(); - encoder.uint64(value); - let spot = ctx.state().get_bytes(name); - spot.set_value(&encoder.data()); - - let bytes = spot.value(); - let mut decoder = BytesDecoder::new(&bytes); - let retrieved = decoder.uint64(); - if retrieved != value { + let mut enc = WasmEncoder::new(); + let state = ctx.raw_state(); + let key = string_to_bytes(name); + state.set(&key, &enc.vlu_encode(value).buf()); + + let buf = state.get(&key); + let mut dec = WasmDecoder::new(&buf); + let val = dec.vlu_decode(64); + if val != value { ctx.log(&(name.to_string() + " in : " + &value.to_string())); - ctx.log(&(name.to_string() + " out: " + &retrieved.to_string())); + ctx.log(&(name.to_string() + " out: " + &val.to_string())); } } diff --git a/contracts/wasm/inccounter/src/keys.rs b/contracts/wasm/inccounter/src/keys.rs deleted file mode 100644 index 00e4860fe4..0000000000 --- a/contracts/wasm/inccounter/src/keys.rs +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright 2020 IOTA Stiftung -// SPDX-License-Identifier: Apache-2.0 - -// (Re-)generated by schema tool -// >>>> DO NOT CHANGE THIS FILE! <<<< -// Change the json schema instead - -#![allow(dead_code)] - -use wasmlib::*; - -use crate::*; - -pub(crate) const IDX_PARAM_COUNTER : usize = 0; -pub(crate) const IDX_PARAM_DELAY : usize = 1; -pub(crate) const IDX_PARAM_DUMMY : usize = 2; -pub(crate) const IDX_PARAM_NI64 : usize = 3; -pub(crate) const IDX_PARAM_NU64 : usize = 4; -pub(crate) const IDX_PARAM_NUM_REPEATS : usize = 5; - -pub(crate) const IDX_RESULT_BUF : usize = 6; -pub(crate) const IDX_RESULT_COUNTER : usize = 7; -pub(crate) const IDX_RESULT_NI64 : usize = 8; -pub(crate) const IDX_RESULT_NU64 : usize = 9; -pub(crate) const IDX_RESULT_STR : usize = 10; -pub(crate) const IDX_RESULT_XI64 : usize = 11; -pub(crate) const IDX_RESULT_XU64 : usize = 12; - -pub(crate) const IDX_STATE_COUNTER : usize = 13; -pub(crate) const IDX_STATE_NUM_REPEATS : usize = 14; - -pub const KEY_MAP_LEN: usize = 15; - -pub const KEY_MAP: [&str; KEY_MAP_LEN] = [ - PARAM_COUNTER, - PARAM_DELAY, - PARAM_DUMMY, - PARAM_NI64, - PARAM_NU64, - PARAM_NUM_REPEATS, - RESULT_BUF, - RESULT_COUNTER, - RESULT_NI64, - RESULT_NU64, - RESULT_STR, - RESULT_XI64, - RESULT_XU64, - STATE_COUNTER, - STATE_NUM_REPEATS, -]; - -pub static mut IDX_MAP: [Key32; KEY_MAP_LEN] = [Key32(0); KEY_MAP_LEN]; - -pub fn idx_map(idx: usize) -> Key32 { - unsafe { - IDX_MAP[idx] - } -} diff --git a/contracts/wasm/inccounter/src/lib.rs b/contracts/wasm/inccounter/src/lib.rs index 38d8a76fc8..4f5924dbf5 100644 --- a/contracts/wasm/inccounter/src/lib.rs +++ b/contracts/wasm/inccounter/src/lib.rs @@ -10,17 +10,14 @@ use inccounter::*; use wasmlib::*; -use wasmlib::host::*; use crate::consts::*; -use crate::keys::*; use crate::params::*; use crate::results::*; use crate::state::*; mod consts; mod contract; -mod keys; mod params; mod results; mod state; @@ -46,12 +43,6 @@ fn on_load() { exports.add_view(VIEW_GET_COUNTER, view_get_counter_thunk); exports.add_view(VIEW_GET_VLI, view_get_vli_thunk); exports.add_view(VIEW_GET_VLU, view_get_vlu_thunk); - - unsafe { - for i in 0..KEY_MAP_LEN { - IDX_MAP[i] = get_key_id_from_string(KEY_MAP[i]); - } - } } pub struct CallIncrementContext { @@ -61,9 +52,7 @@ pub struct CallIncrementContext { fn func_call_increment_thunk(ctx: &ScFuncContext) { ctx.log("inccounter.funcCallIncrement"); let f = CallIncrementContext { - state: MutableIncCounterState { - id: OBJ_ID_STATE, - }, + state: MutableIncCounterState { proxy: state_proxy() }, }; func_call_increment(ctx, &f); ctx.log("inccounter.funcCallIncrement ok"); @@ -76,9 +65,7 @@ pub struct CallIncrementRecurse5xContext { fn func_call_increment_recurse5x_thunk(ctx: &ScFuncContext) { ctx.log("inccounter.funcCallIncrementRecurse5x"); let f = CallIncrementRecurse5xContext { - state: MutableIncCounterState { - id: OBJ_ID_STATE, - }, + state: MutableIncCounterState { proxy: state_proxy() }, }; func_call_increment_recurse5x(ctx, &f); ctx.log("inccounter.funcCallIncrementRecurse5x ok"); @@ -91,9 +78,7 @@ pub struct EndlessLoopContext { fn func_endless_loop_thunk(ctx: &ScFuncContext) { ctx.log("inccounter.funcEndlessLoop"); let f = EndlessLoopContext { - state: MutableIncCounterState { - id: OBJ_ID_STATE, - }, + state: MutableIncCounterState { proxy: state_proxy() }, }; func_endless_loop(ctx, &f); ctx.log("inccounter.funcEndlessLoop ok"); @@ -106,9 +91,7 @@ pub struct IncrementContext { fn func_increment_thunk(ctx: &ScFuncContext) { ctx.log("inccounter.funcIncrement"); let f = IncrementContext { - state: MutableIncCounterState { - id: OBJ_ID_STATE, - }, + state: MutableIncCounterState { proxy: state_proxy() }, }; func_increment(ctx, &f); ctx.log("inccounter.funcIncrement ok"); @@ -122,12 +105,8 @@ pub struct IncrementWithDelayContext { fn func_increment_with_delay_thunk(ctx: &ScFuncContext) { ctx.log("inccounter.funcIncrementWithDelay"); let f = IncrementWithDelayContext { - params: ImmutableIncrementWithDelayParams { - id: OBJ_ID_PARAMS, - }, - state: MutableIncCounterState { - id: OBJ_ID_STATE, - }, + params: ImmutableIncrementWithDelayParams { proxy: params_proxy() }, + state: MutableIncCounterState { proxy: state_proxy() }, }; ctx.require(f.params.delay().exists(), "missing mandatory delay"); func_increment_with_delay(ctx, &f); @@ -142,12 +121,8 @@ pub struct InitContext { fn func_init_thunk(ctx: &ScFuncContext) { ctx.log("inccounter.funcInit"); let f = InitContext { - params: ImmutableInitParams { - id: OBJ_ID_PARAMS, - }, - state: MutableIncCounterState { - id: OBJ_ID_STATE, - }, + params: ImmutableInitParams { proxy: params_proxy() }, + state: MutableIncCounterState { proxy: state_proxy() }, }; func_init(ctx, &f); ctx.log("inccounter.funcInit ok"); @@ -160,9 +135,7 @@ pub struct LocalStateInternalCallContext { fn func_local_state_internal_call_thunk(ctx: &ScFuncContext) { ctx.log("inccounter.funcLocalStateInternalCall"); let f = LocalStateInternalCallContext { - state: MutableIncCounterState { - id: OBJ_ID_STATE, - }, + state: MutableIncCounterState { proxy: state_proxy() }, }; func_local_state_internal_call(ctx, &f); ctx.log("inccounter.funcLocalStateInternalCall ok"); @@ -175,9 +148,7 @@ pub struct LocalStatePostContext { fn func_local_state_post_thunk(ctx: &ScFuncContext) { ctx.log("inccounter.funcLocalStatePost"); let f = LocalStatePostContext { - state: MutableIncCounterState { - id: OBJ_ID_STATE, - }, + state: MutableIncCounterState { proxy: state_proxy() }, }; func_local_state_post(ctx, &f); ctx.log("inccounter.funcLocalStatePost ok"); @@ -190,9 +161,7 @@ pub struct LocalStateSandboxCallContext { fn func_local_state_sandbox_call_thunk(ctx: &ScFuncContext) { ctx.log("inccounter.funcLocalStateSandboxCall"); let f = LocalStateSandboxCallContext { - state: MutableIncCounterState { - id: OBJ_ID_STATE, - }, + state: MutableIncCounterState { proxy: state_proxy() }, }; func_local_state_sandbox_call(ctx, &f); ctx.log("inccounter.funcLocalStateSandboxCall ok"); @@ -205,9 +174,7 @@ pub struct PostIncrementContext { fn func_post_increment_thunk(ctx: &ScFuncContext) { ctx.log("inccounter.funcPostIncrement"); let f = PostIncrementContext { - state: MutableIncCounterState { - id: OBJ_ID_STATE, - }, + state: MutableIncCounterState { proxy: state_proxy() }, }; func_post_increment(ctx, &f); ctx.log("inccounter.funcPostIncrement ok"); @@ -221,12 +188,8 @@ pub struct RepeatManyContext { fn func_repeat_many_thunk(ctx: &ScFuncContext) { ctx.log("inccounter.funcRepeatMany"); let f = RepeatManyContext { - params: ImmutableRepeatManyParams { - id: OBJ_ID_PARAMS, - }, - state: MutableIncCounterState { - id: OBJ_ID_STATE, - }, + params: ImmutableRepeatManyParams { proxy: params_proxy() }, + state: MutableIncCounterState { proxy: state_proxy() }, }; func_repeat_many(ctx, &f); ctx.log("inccounter.funcRepeatMany ok"); @@ -239,9 +202,7 @@ pub struct TestVliCodecContext { fn func_test_vli_codec_thunk(ctx: &ScFuncContext) { ctx.log("inccounter.funcTestVliCodec"); let f = TestVliCodecContext { - state: MutableIncCounterState { - id: OBJ_ID_STATE, - }, + state: MutableIncCounterState { proxy: state_proxy() }, }; func_test_vli_codec(ctx, &f); ctx.log("inccounter.funcTestVliCodec ok"); @@ -254,9 +215,7 @@ pub struct TestVluCodecContext { fn func_test_vlu_codec_thunk(ctx: &ScFuncContext) { ctx.log("inccounter.funcTestVluCodec"); let f = TestVluCodecContext { - state: MutableIncCounterState { - id: OBJ_ID_STATE, - }, + state: MutableIncCounterState { proxy: state_proxy() }, }; func_test_vlu_codec(ctx, &f); ctx.log("inccounter.funcTestVluCodec ok"); @@ -270,12 +229,8 @@ pub struct WhenMustIncrementContext { fn func_when_must_increment_thunk(ctx: &ScFuncContext) { ctx.log("inccounter.funcWhenMustIncrement"); let f = WhenMustIncrementContext { - params: ImmutableWhenMustIncrementParams { - id: OBJ_ID_PARAMS, - }, - state: MutableIncCounterState { - id: OBJ_ID_STATE, - }, + params: ImmutableWhenMustIncrementParams { proxy: params_proxy() }, + state: MutableIncCounterState { proxy: state_proxy() }, }; func_when_must_increment(ctx, &f); ctx.log("inccounter.funcWhenMustIncrement ok"); @@ -289,14 +244,11 @@ pub struct GetCounterContext { fn view_get_counter_thunk(ctx: &ScViewContext) { ctx.log("inccounter.viewGetCounter"); let f = GetCounterContext { - results: MutableGetCounterResults { - id: OBJ_ID_RESULTS, - }, - state: ImmutableIncCounterState { - id: OBJ_ID_STATE, - }, + results: MutableGetCounterResults { proxy: results_proxy() }, + state: ImmutableIncCounterState { proxy: state_proxy() }, }; view_get_counter(ctx, &f); + ctx.results(&f.results.proxy.kv_store); ctx.log("inccounter.viewGetCounter ok"); } @@ -309,18 +261,13 @@ pub struct GetVliContext { fn view_get_vli_thunk(ctx: &ScViewContext) { ctx.log("inccounter.viewGetVli"); let f = GetVliContext { - params: ImmutableGetVliParams { - id: OBJ_ID_PARAMS, - }, - results: MutableGetVliResults { - id: OBJ_ID_RESULTS, - }, - state: ImmutableIncCounterState { - id: OBJ_ID_STATE, - }, + params: ImmutableGetVliParams { proxy: params_proxy() }, + results: MutableGetVliResults { proxy: results_proxy() }, + state: ImmutableIncCounterState { proxy: state_proxy() }, }; ctx.require(f.params.ni64().exists(), "missing mandatory ni64"); view_get_vli(ctx, &f); + ctx.results(&f.results.proxy.kv_store); ctx.log("inccounter.viewGetVli ok"); } @@ -333,17 +280,12 @@ pub struct GetVluContext { fn view_get_vlu_thunk(ctx: &ScViewContext) { ctx.log("inccounter.viewGetVlu"); let f = GetVluContext { - params: ImmutableGetVluParams { - id: OBJ_ID_PARAMS, - }, - results: MutableGetVluResults { - id: OBJ_ID_RESULTS, - }, - state: ImmutableIncCounterState { - id: OBJ_ID_STATE, - }, + params: ImmutableGetVluParams { proxy: params_proxy() }, + results: MutableGetVluResults { proxy: results_proxy() }, + state: ImmutableIncCounterState { proxy: state_proxy() }, }; ctx.require(f.params.nu64().exists(), "missing mandatory nu64"); view_get_vlu(ctx, &f); + ctx.results(&f.results.proxy.kv_store); ctx.log("inccounter.viewGetVlu ok"); } diff --git a/contracts/wasm/inccounter/src/params.rs b/contracts/wasm/inccounter/src/params.rs index f402d3c37d..311b1b3527 100644 --- a/contracts/wasm/inccounter/src/params.rs +++ b/contracts/wasm/inccounter/src/params.rs @@ -9,139 +9,136 @@ #![allow(unused_imports)] use wasmlib::*; -use wasmlib::host::*; - use crate::*; -use crate::keys::*; -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableIncrementWithDelayParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableIncrementWithDelayParams { pub fn delay(&self) -> ScImmutableUint32 { - ScImmutableUint32::new(self.id, PARAM_DELAY.get_key_id()) + ScImmutableUint32::new(self.proxy.root(PARAM_DELAY)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableIncrementWithDelayParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableIncrementWithDelayParams { pub fn delay(&self) -> ScMutableUint32 { - ScMutableUint32::new(self.id, PARAM_DELAY.get_key_id()) + ScMutableUint32::new(self.proxy.root(PARAM_DELAY)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableInitParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableInitParams { pub fn counter(&self) -> ScImmutableInt64 { - ScImmutableInt64::new(self.id, idx_map(IDX_PARAM_COUNTER)) + ScImmutableInt64::new(self.proxy.root(PARAM_COUNTER)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableInitParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableInitParams { pub fn counter(&self) -> ScMutableInt64 { - ScMutableInt64::new(self.id, idx_map(IDX_PARAM_COUNTER)) + ScMutableInt64::new(self.proxy.root(PARAM_COUNTER)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableRepeatManyParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableRepeatManyParams { pub fn num_repeats(&self) -> ScImmutableInt64 { - ScImmutableInt64::new(self.id, PARAM_NUM_REPEATS.get_key_id()) + ScImmutableInt64::new(self.proxy.root(PARAM_NUM_REPEATS)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableRepeatManyParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableRepeatManyParams { pub fn num_repeats(&self) -> ScMutableInt64 { - ScMutableInt64::new(self.id, PARAM_NUM_REPEATS.get_key_id()) + ScMutableInt64::new(self.proxy.root(PARAM_NUM_REPEATS)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableWhenMustIncrementParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableWhenMustIncrementParams { pub fn dummy(&self) -> ScImmutableInt64 { - ScImmutableInt64::new(self.id, PARAM_DUMMY.get_key_id()) + ScImmutableInt64::new(self.proxy.root(PARAM_DUMMY)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableWhenMustIncrementParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableWhenMustIncrementParams { pub fn dummy(&self) -> ScMutableInt64 { - ScMutableInt64::new(self.id, PARAM_DUMMY.get_key_id()) + ScMutableInt64::new(self.proxy.root(PARAM_DUMMY)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableGetVliParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableGetVliParams { pub fn ni64(&self) -> ScImmutableInt64 { - ScImmutableInt64::new(self.id, PARAM_NI64.get_key_id()) + ScImmutableInt64::new(self.proxy.root(PARAM_NI64)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableGetVliParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableGetVliParams { pub fn ni64(&self) -> ScMutableInt64 { - ScMutableInt64::new(self.id, PARAM_NI64.get_key_id()) + ScMutableInt64::new(self.proxy.root(PARAM_NI64)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableGetVluParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableGetVluParams { pub fn nu64(&self) -> ScImmutableUint64 { - ScImmutableUint64::new(self.id, PARAM_NU64.get_key_id()) + ScImmutableUint64::new(self.proxy.root(PARAM_NU64)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableGetVluParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableGetVluParams { pub fn nu64(&self) -> ScMutableUint64 { - ScMutableUint64::new(self.id, PARAM_NU64.get_key_id()) + ScMutableUint64::new(self.proxy.root(PARAM_NU64)) } } diff --git a/contracts/wasm/inccounter/src/results.rs b/contracts/wasm/inccounter/src/results.rs index e881f488a0..5afa0ca1b0 100644 --- a/contracts/wasm/inccounter/src/results.rs +++ b/contracts/wasm/inccounter/src/results.rs @@ -9,121 +9,118 @@ #![allow(unused_imports)] use wasmlib::*; -use wasmlib::host::*; - use crate::*; -use crate::keys::*; -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableGetCounterResults { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableGetCounterResults { pub fn counter(&self) -> ScImmutableInt64 { - ScImmutableInt64::new(self.id, RESULT_COUNTER.get_key_id()) + ScImmutableInt64::new(self.proxy.root(RESULT_COUNTER)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableGetCounterResults { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableGetCounterResults { pub fn counter(&self) -> ScMutableInt64 { - ScMutableInt64::new(self.id, RESULT_COUNTER.get_key_id()) + ScMutableInt64::new(self.proxy.root(RESULT_COUNTER)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableGetVliResults { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableGetVliResults { pub fn buf(&self) -> ScImmutableBytes { - ScImmutableBytes::new(self.id, RESULT_BUF.get_key_id()) + ScImmutableBytes::new(self.proxy.root(RESULT_BUF)) } pub fn ni64(&self) -> ScImmutableInt64 { - ScImmutableInt64::new(self.id, RESULT_NI64.get_key_id()) + ScImmutableInt64::new(self.proxy.root(RESULT_NI64)) } pub fn str(&self) -> ScImmutableString { - ScImmutableString::new(self.id, RESULT_STR.get_key_id()) + ScImmutableString::new(self.proxy.root(RESULT_STR)) } pub fn xi64(&self) -> ScImmutableInt64 { - ScImmutableInt64::new(self.id, RESULT_XI64.get_key_id()) + ScImmutableInt64::new(self.proxy.root(RESULT_XI64)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableGetVliResults { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableGetVliResults { pub fn buf(&self) -> ScMutableBytes { - ScMutableBytes::new(self.id, RESULT_BUF.get_key_id()) + ScMutableBytes::new(self.proxy.root(RESULT_BUF)) } pub fn ni64(&self) -> ScMutableInt64 { - ScMutableInt64::new(self.id, RESULT_NI64.get_key_id()) + ScMutableInt64::new(self.proxy.root(RESULT_NI64)) } pub fn str(&self) -> ScMutableString { - ScMutableString::new(self.id, RESULT_STR.get_key_id()) + ScMutableString::new(self.proxy.root(RESULT_STR)) } pub fn xi64(&self) -> ScMutableInt64 { - ScMutableInt64::new(self.id, RESULT_XI64.get_key_id()) + ScMutableInt64::new(self.proxy.root(RESULT_XI64)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableGetVluResults { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableGetVluResults { pub fn buf(&self) -> ScImmutableBytes { - ScImmutableBytes::new(self.id, RESULT_BUF.get_key_id()) + ScImmutableBytes::new(self.proxy.root(RESULT_BUF)) } pub fn nu64(&self) -> ScImmutableUint64 { - ScImmutableUint64::new(self.id, RESULT_NU64.get_key_id()) + ScImmutableUint64::new(self.proxy.root(RESULT_NU64)) } pub fn str(&self) -> ScImmutableString { - ScImmutableString::new(self.id, RESULT_STR.get_key_id()) + ScImmutableString::new(self.proxy.root(RESULT_STR)) } pub fn xu64(&self) -> ScImmutableUint64 { - ScImmutableUint64::new(self.id, RESULT_XU64.get_key_id()) + ScImmutableUint64::new(self.proxy.root(RESULT_XU64)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableGetVluResults { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableGetVluResults { pub fn buf(&self) -> ScMutableBytes { - ScMutableBytes::new(self.id, RESULT_BUF.get_key_id()) + ScMutableBytes::new(self.proxy.root(RESULT_BUF)) } pub fn nu64(&self) -> ScMutableUint64 { - ScMutableUint64::new(self.id, RESULT_NU64.get_key_id()) + ScMutableUint64::new(self.proxy.root(RESULT_NU64)) } pub fn str(&self) -> ScMutableString { - ScMutableString::new(self.id, RESULT_STR.get_key_id()) + ScMutableString::new(self.proxy.root(RESULT_STR)) } pub fn xu64(&self) -> ScMutableUint64 { - ScMutableUint64::new(self.id, RESULT_XU64.get_key_id()) + ScMutableUint64::new(self.proxy.root(RESULT_XU64)) } } diff --git a/contracts/wasm/inccounter/src/state.rs b/contracts/wasm/inccounter/src/state.rs index 908f5c9aeb..193e18a445 100644 --- a/contracts/wasm/inccounter/src/state.rs +++ b/contracts/wasm/inccounter/src/state.rs @@ -9,41 +9,39 @@ #![allow(unused_imports)] use wasmlib::*; -use wasmlib::host::*; use crate::*; -use crate::keys::*; -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableIncCounterState { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableIncCounterState { pub fn counter(&self) -> ScImmutableInt64 { - ScImmutableInt64::new(self.id, STATE_COUNTER.get_key_id()) + ScImmutableInt64::new(self.proxy.root(STATE_COUNTER)) } pub fn num_repeats(&self) -> ScImmutableInt64 { - ScImmutableInt64::new(self.id, STATE_NUM_REPEATS.get_key_id()) + ScImmutableInt64::new(self.proxy.root(STATE_NUM_REPEATS)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableIncCounterState { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableIncCounterState { pub fn as_immutable(&self) -> ImmutableIncCounterState { - ImmutableIncCounterState { id: self.id } + ImmutableIncCounterState { proxy: self.proxy.root("") } } pub fn counter(&self) -> ScMutableInt64 { - ScMutableInt64::new(self.id, STATE_COUNTER.get_key_id()) + ScMutableInt64::new(self.proxy.root(STATE_COUNTER)) } pub fn num_repeats(&self) -> ScMutableInt64 { - ScMutableInt64::new(self.id, STATE_NUM_REPEATS.get_key_id()) + ScMutableInt64::new(self.proxy.root(STATE_NUM_REPEATS)) } } diff --git a/contracts/wasm/inccounter/test/inccounter_bg.wasm b/contracts/wasm/inccounter/test/inccounter_bg.wasm index 87a53859a0cade230719a6b6dcbea18048de448e..813ac6828a72bd66474837464afad98bd57a2675 100644 GIT binary patch literal 62649 zcmeF451d_9b??ugd++?YljH;fge1zj*H|ZokjdW(QOlg+Zv=!23Mxv5WPr@%@604X zRWd+8RKTF9DWamHphCeGD^*&D7A;yt+S-bhrzwy6XdkZ+Uuo4A$@~7+-sjvqe-eV= ztMBt(;Lh1+|KDq`wf0(Tuf0#uH@q*2Ft@?C_6(G=e2! zNG|Kaleo*)1c8foIWJQUml38O5-XOItO{JFGE{MytHNH%Og;Pp%J|%>iNtV6v?yvh zn+~43{``)MHV==SInp=Me`fzkP?;Qk64CAPP0{YC90V;v++MAg!$ab@QYwXEREd&u zFg*$@VTu348Hdh_!^p-Rgb^9SQWRC%N~Ne0l!BI)Fbcx3rL7XSgh8cJDOE}>rBW&A zh$=Hf9)PP-0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D${4njgvGf%r=A#s%vy4-1NCZ8&=I!sYD? z+mp5p>pPeCY+Sx^eInCgLHm*gi`(ZFFYDP%vts+g#a#>ATjY&fupZU)lHRR{wJ%(< Tu#=AKJC-hAzF|pc`@H`NlF_xS diff --git a/contracts/wasm/inccounter/ts/inccounter/inccounter.ts b/contracts/wasm/inccounter/ts/inccounter/inccounter.ts index 8916e2b127..3c3524186b 100644 --- a/contracts/wasm/inccounter/ts/inccounter/inccounter.ts +++ b/contracts/wasm/inccounter/ts/inccounter/inccounter.ts @@ -238,13 +238,14 @@ function localStatePost(ctx: wasmlib.ScFuncContext, nr: i64): void { } function vliSave(ctx: wasmlib.ScFuncContext, name: string, value: i64): void { - let enc = new wasmtypes.WasmEncoder(); + const enc = new wasmtypes.WasmEncoder(); const state = ctx.rawState(); - let key = wasmtypes.stringToBytes(name); + const key = wasmtypes.stringToBytes(name); state.set(key, enc.vliEncode(value).buf()); + const buf = state.get(key); - let dec = new wasmtypes.WasmDecoder(buf == null ? [] : buf); - let val = wasmtypes.int64Decode(dec); + const dec = new wasmtypes.WasmDecoder(buf); + const val = dec.vliDecode(64); if (val != value) { ctx.log(name.toString() + " in : " + value.toString()); ctx.log(name.toString() + " out: " + val.toString()); @@ -252,13 +253,14 @@ function vliSave(ctx: wasmlib.ScFuncContext, name: string, value: i64): void { } function vluSave(ctx: wasmlib.ScFuncContext, name: string, value: u64): void { - let enc = new wasmtypes.WasmEncoder(); + const enc = new wasmtypes.WasmEncoder(); const state = ctx.rawState(); - let key = wasmtypes.stringToBytes(name); + const key = wasmtypes.stringToBytes(name); state.set(key, enc.vluEncode(value).buf()); + const buf = state.get(key); - let dec = new wasmtypes.WasmDecoder(buf == null ? [] : buf); - let val = wasmtypes.uint64Decode(dec); + const dec = new wasmtypes.WasmDecoder(buf); + const val = dec.vluDecode(64); if (val != value) { ctx.log(name.toString() + " in : " + value.toString()); ctx.log(name.toString() + " out: " + val.toString()); diff --git a/contracts/wasm/inccounter/ts/inccounter/keys.ts b/contracts/wasm/inccounter/ts/inccounter/keys.ts deleted file mode 100644 index 2552fa53c5..0000000000 --- a/contracts/wasm/inccounter/ts/inccounter/keys.ts +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2020 IOTA Stiftung -// SPDX-License-Identifier: Apache-2.0 - -// (Re-)generated by schema tool -// >>>> DO NOT CHANGE THIS FILE! <<<< -// Change the json schema instead - - -export const IdxParamCounter = 0; -export const IdxParamDelay = 1; -export const IdxParamDummy = 2; -export const IdxParamNi64 = 3; -export const IdxParamNu64 = 4; -export const IdxParamNumRepeats = 5; diff --git a/contracts/wasm/testcore/go/testcore/keys.go b/contracts/wasm/testcore/go/testcore/keys.go deleted file mode 100644 index 09ac529c6f..0000000000 --- a/contracts/wasm/testcore/go/testcore/keys.go +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright 2020 IOTA Stiftung -// SPDX-License-Identifier: Apache-2.0 - -// (Re-)generated by schema tool -// >>>> DO NOT CHANGE THIS FILE! <<<< -// Change the json schema instead - -package testcore diff --git a/contracts/wasm/testcore/src/contract.rs b/contracts/wasm/testcore/src/contract.rs index a00e5b9eeb..203abd6f5b 100644 --- a/contracts/wasm/testcore/src/contract.rs +++ b/contracts/wasm/testcore/src/contract.rs @@ -7,8 +7,6 @@ #![allow(dead_code)] -use std::ptr; - use wasmlib::*; use crate::consts::*; @@ -172,260 +170,265 @@ pub struct ScFuncs { } impl ScFuncs { - pub fn call_on_chain(_ctx: & dyn ScFuncCallContext) -> CallOnChainCall { + pub fn call_on_chain(_ctx: &dyn ScFuncCallContext) -> CallOnChainCall { let mut f = CallOnChainCall { func: ScFunc::new(HSC_NAME, HFUNC_CALL_ON_CHAIN), - params: MutableCallOnChainParams { id: 0 }, - results: ImmutableCallOnChainResults { id: 0 }, + params: MutableCallOnChainParams { proxy: Proxy::nil() }, + results: ImmutableCallOnChainResults { proxy: Proxy::nil() }, }; - f.func.set_ptrs(&mut f.params.id, &mut f.results.id); + ScFunc::link_params(&mut f.params.proxy, &f.func); + ScFunc::link_results(&mut f.results.proxy, &f.func); f } - pub fn check_context_from_full_ep(_ctx: & dyn ScFuncCallContext) -> CheckContextFromFullEPCall { + pub fn check_context_from_full_ep(_ctx: &dyn ScFuncCallContext) -> CheckContextFromFullEPCall { let mut f = CheckContextFromFullEPCall { func: ScFunc::new(HSC_NAME, HFUNC_CHECK_CONTEXT_FROM_FULL_EP), - params: MutableCheckContextFromFullEPParams { id: 0 }, + params: MutableCheckContextFromFullEPParams { proxy: Proxy::nil() }, }; - f.func.set_ptrs(&mut f.params.id, ptr::null_mut()); + ScFunc::link_params(&mut f.params.proxy, &f.func); f } - pub fn do_nothing(_ctx: & dyn ScFuncCallContext) -> DoNothingCall { + pub fn do_nothing(_ctx: &dyn ScFuncCallContext) -> DoNothingCall { DoNothingCall { func: ScFunc::new(HSC_NAME, HFUNC_DO_NOTHING), } } - pub fn get_minted_supply(_ctx: & dyn ScFuncCallContext) -> GetMintedSupplyCall { + pub fn get_minted_supply(_ctx: &dyn ScFuncCallContext) -> GetMintedSupplyCall { let mut f = GetMintedSupplyCall { func: ScFunc::new(HSC_NAME, HFUNC_GET_MINTED_SUPPLY), - results: ImmutableGetMintedSupplyResults { id: 0 }, + results: ImmutableGetMintedSupplyResults { proxy: Proxy::nil() }, }; - f.func.set_ptrs(ptr::null_mut(), &mut f.results.id); + ScFunc::link_results(&mut f.results.proxy, &f.func); f } - pub fn inc_counter(_ctx: & dyn ScFuncCallContext) -> IncCounterCall { + pub fn inc_counter(_ctx: &dyn ScFuncCallContext) -> IncCounterCall { IncCounterCall { func: ScFunc::new(HSC_NAME, HFUNC_INC_COUNTER), } } - pub fn init(_ctx: & dyn ScFuncCallContext) -> InitCall { + pub fn init(_ctx: &dyn ScFuncCallContext) -> InitCall { let mut f = InitCall { func: ScInitFunc::new(HSC_NAME, HFUNC_INIT), - params: MutableInitParams { id: 0 }, + params: MutableInitParams { proxy: Proxy::nil() }, }; - f.func.set_ptrs(&mut f.params.id, ptr::null_mut()); + ScInitFunc::link_params(&mut f.params.proxy, &f.func); f } - pub fn pass_types_full(_ctx: & dyn ScFuncCallContext) -> PassTypesFullCall { + pub fn pass_types_full(_ctx: &dyn ScFuncCallContext) -> PassTypesFullCall { let mut f = PassTypesFullCall { func: ScFunc::new(HSC_NAME, HFUNC_PASS_TYPES_FULL), - params: MutablePassTypesFullParams { id: 0 }, + params: MutablePassTypesFullParams { proxy: Proxy::nil() }, }; - f.func.set_ptrs(&mut f.params.id, ptr::null_mut()); + ScFunc::link_params(&mut f.params.proxy, &f.func); f } - pub fn run_recursion(_ctx: & dyn ScFuncCallContext) -> RunRecursionCall { + pub fn run_recursion(_ctx: &dyn ScFuncCallContext) -> RunRecursionCall { let mut f = RunRecursionCall { func: ScFunc::new(HSC_NAME, HFUNC_RUN_RECURSION), - params: MutableRunRecursionParams { id: 0 }, - results: ImmutableRunRecursionResults { id: 0 }, + params: MutableRunRecursionParams { proxy: Proxy::nil() }, + results: ImmutableRunRecursionResults { proxy: Proxy::nil() }, }; - f.func.set_ptrs(&mut f.params.id, &mut f.results.id); + ScFunc::link_params(&mut f.params.proxy, &f.func); + ScFunc::link_results(&mut f.results.proxy, &f.func); f } - pub fn send_to_address(_ctx: & dyn ScFuncCallContext) -> SendToAddressCall { + pub fn send_to_address(_ctx: &dyn ScFuncCallContext) -> SendToAddressCall { let mut f = SendToAddressCall { func: ScFunc::new(HSC_NAME, HFUNC_SEND_TO_ADDRESS), - params: MutableSendToAddressParams { id: 0 }, + params: MutableSendToAddressParams { proxy: Proxy::nil() }, }; - f.func.set_ptrs(&mut f.params.id, ptr::null_mut()); + ScFunc::link_params(&mut f.params.proxy, &f.func); f } - pub fn set_int(_ctx: & dyn ScFuncCallContext) -> SetIntCall { + pub fn set_int(_ctx: &dyn ScFuncCallContext) -> SetIntCall { let mut f = SetIntCall { func: ScFunc::new(HSC_NAME, HFUNC_SET_INT), - params: MutableSetIntParams { id: 0 }, + params: MutableSetIntParams { proxy: Proxy::nil() }, }; - f.func.set_ptrs(&mut f.params.id, ptr::null_mut()); + ScFunc::link_params(&mut f.params.proxy, &f.func); f } - pub fn spawn(_ctx: & dyn ScFuncCallContext) -> SpawnCall { + pub fn spawn(_ctx: &dyn ScFuncCallContext) -> SpawnCall { let mut f = SpawnCall { func: ScFunc::new(HSC_NAME, HFUNC_SPAWN), - params: MutableSpawnParams { id: 0 }, + params: MutableSpawnParams { proxy: Proxy::nil() }, }; - f.func.set_ptrs(&mut f.params.id, ptr::null_mut()); + ScFunc::link_params(&mut f.params.proxy, &f.func); f } - pub fn test_block_context1(_ctx: & dyn ScFuncCallContext) -> TestBlockContext1Call { + pub fn test_block_context1(_ctx: &dyn ScFuncCallContext) -> TestBlockContext1Call { TestBlockContext1Call { func: ScFunc::new(HSC_NAME, HFUNC_TEST_BLOCK_CONTEXT1), } } - pub fn test_block_context2(_ctx: & dyn ScFuncCallContext) -> TestBlockContext2Call { + pub fn test_block_context2(_ctx: &dyn ScFuncCallContext) -> TestBlockContext2Call { TestBlockContext2Call { func: ScFunc::new(HSC_NAME, HFUNC_TEST_BLOCK_CONTEXT2), } } - pub fn test_call_panic_full_ep(_ctx: & dyn ScFuncCallContext) -> TestCallPanicFullEPCall { + pub fn test_call_panic_full_ep(_ctx: &dyn ScFuncCallContext) -> TestCallPanicFullEPCall { TestCallPanicFullEPCall { func: ScFunc::new(HSC_NAME, HFUNC_TEST_CALL_PANIC_FULL_EP), } } - pub fn test_call_panic_view_ep_from_full(_ctx: & dyn ScFuncCallContext) -> TestCallPanicViewEPFromFullCall { + pub fn test_call_panic_view_ep_from_full(_ctx: &dyn ScFuncCallContext) -> TestCallPanicViewEPFromFullCall { TestCallPanicViewEPFromFullCall { func: ScFunc::new(HSC_NAME, HFUNC_TEST_CALL_PANIC_VIEW_EP_FROM_FULL), } } - pub fn test_chain_owner_id_full(_ctx: & dyn ScFuncCallContext) -> TestChainOwnerIDFullCall { + pub fn test_chain_owner_id_full(_ctx: &dyn ScFuncCallContext) -> TestChainOwnerIDFullCall { let mut f = TestChainOwnerIDFullCall { func: ScFunc::new(HSC_NAME, HFUNC_TEST_CHAIN_OWNER_ID_FULL), - results: ImmutableTestChainOwnerIDFullResults { id: 0 }, + results: ImmutableTestChainOwnerIDFullResults { proxy: Proxy::nil() }, }; - f.func.set_ptrs(ptr::null_mut(), &mut f.results.id); + ScFunc::link_results(&mut f.results.proxy, &f.func); f } - pub fn test_event_log_deploy(_ctx: & dyn ScFuncCallContext) -> TestEventLogDeployCall { + pub fn test_event_log_deploy(_ctx: &dyn ScFuncCallContext) -> TestEventLogDeployCall { TestEventLogDeployCall { func: ScFunc::new(HSC_NAME, HFUNC_TEST_EVENT_LOG_DEPLOY), } } - pub fn test_event_log_event_data(_ctx: & dyn ScFuncCallContext) -> TestEventLogEventDataCall { + pub fn test_event_log_event_data(_ctx: &dyn ScFuncCallContext) -> TestEventLogEventDataCall { TestEventLogEventDataCall { func: ScFunc::new(HSC_NAME, HFUNC_TEST_EVENT_LOG_EVENT_DATA), } } - pub fn test_event_log_generic_data(_ctx: & dyn ScFuncCallContext) -> TestEventLogGenericDataCall { + pub fn test_event_log_generic_data(_ctx: &dyn ScFuncCallContext) -> TestEventLogGenericDataCall { let mut f = TestEventLogGenericDataCall { func: ScFunc::new(HSC_NAME, HFUNC_TEST_EVENT_LOG_GENERIC_DATA), - params: MutableTestEventLogGenericDataParams { id: 0 }, + params: MutableTestEventLogGenericDataParams { proxy: Proxy::nil() }, }; - f.func.set_ptrs(&mut f.params.id, ptr::null_mut()); + ScFunc::link_params(&mut f.params.proxy, &f.func); f } - pub fn test_panic_full_ep(_ctx: & dyn ScFuncCallContext) -> TestPanicFullEPCall { + pub fn test_panic_full_ep(_ctx: &dyn ScFuncCallContext) -> TestPanicFullEPCall { TestPanicFullEPCall { func: ScFunc::new(HSC_NAME, HFUNC_TEST_PANIC_FULL_EP), } } - pub fn withdraw_to_chain(_ctx: & dyn ScFuncCallContext) -> WithdrawToChainCall { + pub fn withdraw_to_chain(_ctx: &dyn ScFuncCallContext) -> WithdrawToChainCall { let mut f = WithdrawToChainCall { func: ScFunc::new(HSC_NAME, HFUNC_WITHDRAW_TO_CHAIN), - params: MutableWithdrawToChainParams { id: 0 }, + params: MutableWithdrawToChainParams { proxy: Proxy::nil() }, }; - f.func.set_ptrs(&mut f.params.id, ptr::null_mut()); + ScFunc::link_params(&mut f.params.proxy, &f.func); f } - pub fn check_context_from_view_ep(_ctx: & dyn ScViewCallContext) -> CheckContextFromViewEPCall { + pub fn check_context_from_view_ep(_ctx: &dyn ScViewCallContext) -> CheckContextFromViewEPCall { let mut f = CheckContextFromViewEPCall { func: ScView::new(HSC_NAME, HVIEW_CHECK_CONTEXT_FROM_VIEW_EP), - params: MutableCheckContextFromViewEPParams { id: 0 }, + params: MutableCheckContextFromViewEPParams { proxy: Proxy::nil() }, }; - f.func.set_ptrs(&mut f.params.id, ptr::null_mut()); + ScView::link_params(&mut f.params.proxy, &f.func); f } - pub fn fibonacci(_ctx: & dyn ScViewCallContext) -> FibonacciCall { + pub fn fibonacci(_ctx: &dyn ScViewCallContext) -> FibonacciCall { let mut f = FibonacciCall { func: ScView::new(HSC_NAME, HVIEW_FIBONACCI), - params: MutableFibonacciParams { id: 0 }, - results: ImmutableFibonacciResults { id: 0 }, + params: MutableFibonacciParams { proxy: Proxy::nil() }, + results: ImmutableFibonacciResults { proxy: Proxy::nil() }, }; - f.func.set_ptrs(&mut f.params.id, &mut f.results.id); + ScView::link_params(&mut f.params.proxy, &f.func); + ScView::link_results(&mut f.results.proxy, &f.func); f } - pub fn get_counter(_ctx: & dyn ScViewCallContext) -> GetCounterCall { + pub fn get_counter(_ctx: &dyn ScViewCallContext) -> GetCounterCall { let mut f = GetCounterCall { func: ScView::new(HSC_NAME, HVIEW_GET_COUNTER), - results: ImmutableGetCounterResults { id: 0 }, + results: ImmutableGetCounterResults { proxy: Proxy::nil() }, }; - f.func.set_ptrs(ptr::null_mut(), &mut f.results.id); + ScView::link_results(&mut f.results.proxy, &f.func); f } - pub fn get_int(_ctx: & dyn ScViewCallContext) -> GetIntCall { + pub fn get_int(_ctx: &dyn ScViewCallContext) -> GetIntCall { let mut f = GetIntCall { func: ScView::new(HSC_NAME, HVIEW_GET_INT), - params: MutableGetIntParams { id: 0 }, - results: ImmutableGetIntResults { id: 0 }, + params: MutableGetIntParams { proxy: Proxy::nil() }, + results: ImmutableGetIntResults { proxy: Proxy::nil() }, }; - f.func.set_ptrs(&mut f.params.id, &mut f.results.id); + ScView::link_params(&mut f.params.proxy, &f.func); + ScView::link_results(&mut f.results.proxy, &f.func); f } - pub fn get_string_value(_ctx: & dyn ScViewCallContext) -> GetStringValueCall { + pub fn get_string_value(_ctx: &dyn ScViewCallContext) -> GetStringValueCall { let mut f = GetStringValueCall { func: ScView::new(HSC_NAME, HVIEW_GET_STRING_VALUE), - params: MutableGetStringValueParams { id: 0 }, - results: ImmutableGetStringValueResults { id: 0 }, + params: MutableGetStringValueParams { proxy: Proxy::nil() }, + results: ImmutableGetStringValueResults { proxy: Proxy::nil() }, }; - f.func.set_ptrs(&mut f.params.id, &mut f.results.id); + ScView::link_params(&mut f.params.proxy, &f.func); + ScView::link_results(&mut f.results.proxy, &f.func); f } - pub fn just_view(_ctx: & dyn ScViewCallContext) -> JustViewCall { + pub fn just_view(_ctx: &dyn ScViewCallContext) -> JustViewCall { JustViewCall { func: ScView::new(HSC_NAME, HVIEW_JUST_VIEW), } } - pub fn pass_types_view(_ctx: & dyn ScViewCallContext) -> PassTypesViewCall { + pub fn pass_types_view(_ctx: &dyn ScViewCallContext) -> PassTypesViewCall { let mut f = PassTypesViewCall { func: ScView::new(HSC_NAME, HVIEW_PASS_TYPES_VIEW), - params: MutablePassTypesViewParams { id: 0 }, + params: MutablePassTypesViewParams { proxy: Proxy::nil() }, }; - f.func.set_ptrs(&mut f.params.id, ptr::null_mut()); + ScView::link_params(&mut f.params.proxy, &f.func); f } - pub fn test_call_panic_view_ep_from_view(_ctx: & dyn ScViewCallContext) -> TestCallPanicViewEPFromViewCall { + pub fn test_call_panic_view_ep_from_view(_ctx: &dyn ScViewCallContext) -> TestCallPanicViewEPFromViewCall { TestCallPanicViewEPFromViewCall { func: ScView::new(HSC_NAME, HVIEW_TEST_CALL_PANIC_VIEW_EP_FROM_VIEW), } } - pub fn test_chain_owner_id_view(_ctx: & dyn ScViewCallContext) -> TestChainOwnerIDViewCall { + pub fn test_chain_owner_id_view(_ctx: &dyn ScViewCallContext) -> TestChainOwnerIDViewCall { let mut f = TestChainOwnerIDViewCall { func: ScView::new(HSC_NAME, HVIEW_TEST_CHAIN_OWNER_ID_VIEW), - results: ImmutableTestChainOwnerIDViewResults { id: 0 }, + results: ImmutableTestChainOwnerIDViewResults { proxy: Proxy::nil() }, }; - f.func.set_ptrs(ptr::null_mut(), &mut f.results.id); + ScView::link_results(&mut f.results.proxy, &f.func); f } - pub fn test_panic_view_ep(_ctx: & dyn ScViewCallContext) -> TestPanicViewEPCall { + pub fn test_panic_view_ep(_ctx: &dyn ScViewCallContext) -> TestPanicViewEPCall { TestPanicViewEPCall { func: ScView::new(HSC_NAME, HVIEW_TEST_PANIC_VIEW_EP), } } - pub fn test_sandbox_call(_ctx: & dyn ScViewCallContext) -> TestSandboxCallCall { + pub fn test_sandbox_call(_ctx: &dyn ScViewCallContext) -> TestSandboxCallCall { let mut f = TestSandboxCallCall { func: ScView::new(HSC_NAME, HVIEW_TEST_SANDBOX_CALL), - results: ImmutableTestSandboxCallResults { id: 0 }, + results: ImmutableTestSandboxCallResults { proxy: Proxy::nil() }, }; - f.func.set_ptrs(ptr::null_mut(), &mut f.results.id); + ScView::link_results(&mut f.results.proxy, &f.func); f } } diff --git a/contracts/wasm/testcore/src/keys.rs b/contracts/wasm/testcore/src/keys.rs deleted file mode 100644 index 3144450f06..0000000000 --- a/contracts/wasm/testcore/src/keys.rs +++ /dev/null @@ -1,98 +0,0 @@ -// Copyright 2020 IOTA Stiftung -// SPDX-License-Identifier: Apache-2.0 - -// (Re-)generated by schema tool -// >>>> DO NOT CHANGE THIS FILE! <<<< -// Change the json schema instead - -#![allow(dead_code)] - -use wasmlib::*; - -use crate::*; - -pub(crate) const IDX_PARAM_ADDRESS : usize = 0; -pub(crate) const IDX_PARAM_AGENT_ID : usize = 1; -pub(crate) const IDX_PARAM_CALLER : usize = 2; -pub(crate) const IDX_PARAM_CHAIN_ID : usize = 3; -pub(crate) const IDX_PARAM_CHAIN_OWNER_ID : usize = 4; -pub(crate) const IDX_PARAM_CONTRACT_CREATOR : usize = 5; -pub(crate) const IDX_PARAM_CONTRACT_ID : usize = 6; -pub(crate) const IDX_PARAM_COUNTER : usize = 7; -pub(crate) const IDX_PARAM_FAIL : usize = 8; -pub(crate) const IDX_PARAM_HASH : usize = 9; -pub(crate) const IDX_PARAM_HNAME : usize = 10; -pub(crate) const IDX_PARAM_HNAME_CONTRACT : usize = 11; -pub(crate) const IDX_PARAM_HNAME_EP : usize = 12; -pub(crate) const IDX_PARAM_HNAME_ZERO : usize = 13; -pub(crate) const IDX_PARAM_INT64 : usize = 14; -pub(crate) const IDX_PARAM_INT64_ZERO : usize = 15; -pub(crate) const IDX_PARAM_INT_VALUE : usize = 16; -pub(crate) const IDX_PARAM_NAME : usize = 17; -pub(crate) const IDX_PARAM_PROG_HASH : usize = 18; -pub(crate) const IDX_PARAM_STRING : usize = 19; -pub(crate) const IDX_PARAM_STRING_ZERO : usize = 20; -pub(crate) const IDX_PARAM_VAR_NAME : usize = 21; - -pub(crate) const IDX_RESULT_CHAIN_OWNER_ID : usize = 22; -pub(crate) const IDX_RESULT_COUNTER : usize = 23; -pub(crate) const IDX_RESULT_INT_VALUE : usize = 24; -pub(crate) const IDX_RESULT_MINTED_COLOR : usize = 25; -pub(crate) const IDX_RESULT_MINTED_SUPPLY : usize = 26; -pub(crate) const IDX_RESULT_SANDBOX_CALL : usize = 27; -pub(crate) const IDX_RESULT_VALUES : usize = 28; -pub(crate) const IDX_RESULT_VARS : usize = 29; - -pub(crate) const IDX_STATE_COUNTER : usize = 30; -pub(crate) const IDX_STATE_HNAME_EP : usize = 31; -pub(crate) const IDX_STATE_INTS : usize = 32; -pub(crate) const IDX_STATE_MINTED_COLOR : usize = 33; -pub(crate) const IDX_STATE_MINTED_SUPPLY : usize = 34; - -pub const KEY_MAP_LEN: usize = 35; - -pub const KEY_MAP: [&str; KEY_MAP_LEN] = [ - PARAM_ADDRESS, - PARAM_AGENT_ID, - PARAM_CALLER, - PARAM_CHAIN_ID, - PARAM_CHAIN_OWNER_ID, - PARAM_CONTRACT_CREATOR, - PARAM_CONTRACT_ID, - PARAM_COUNTER, - PARAM_FAIL, - PARAM_HASH, - PARAM_HNAME, - PARAM_HNAME_CONTRACT, - PARAM_HNAME_EP, - PARAM_HNAME_ZERO, - PARAM_INT64, - PARAM_INT64_ZERO, - PARAM_INT_VALUE, - PARAM_NAME, - PARAM_PROG_HASH, - PARAM_STRING, - PARAM_STRING_ZERO, - PARAM_VAR_NAME, - RESULT_CHAIN_OWNER_ID, - RESULT_COUNTER, - RESULT_INT_VALUE, - RESULT_MINTED_COLOR, - RESULT_MINTED_SUPPLY, - RESULT_SANDBOX_CALL, - RESULT_VALUES, - RESULT_VARS, - STATE_COUNTER, - STATE_HNAME_EP, - STATE_INTS, - STATE_MINTED_COLOR, - STATE_MINTED_SUPPLY, -]; - -pub static mut IDX_MAP: [Key32; KEY_MAP_LEN] = [Key32(0); KEY_MAP_LEN]; - -pub fn idx_map(idx: usize) -> Key32 { - unsafe { - IDX_MAP[idx] - } -} diff --git a/contracts/wasm/testcore/src/lib.rs b/contracts/wasm/testcore/src/lib.rs index d9e65ea0ae..daa508cfa7 100644 --- a/contracts/wasm/testcore/src/lib.rs +++ b/contracts/wasm/testcore/src/lib.rs @@ -10,17 +10,14 @@ use testcore::*; use wasmlib::*; -use wasmlib::host::*; use crate::consts::*; -use crate::keys::*; use crate::params::*; use crate::results::*; use crate::state::*; mod consts; mod contract; -mod keys; mod params; mod results; mod state; @@ -61,12 +58,6 @@ fn on_load() { exports.add_view(VIEW_TEST_CHAIN_OWNER_ID_VIEW, view_test_chain_owner_id_view_thunk); exports.add_view(VIEW_TEST_PANIC_VIEW_EP, view_test_panic_view_ep_thunk); exports.add_view(VIEW_TEST_SANDBOX_CALL, view_test_sandbox_call_thunk); - - unsafe { - for i in 0..KEY_MAP_LEN { - IDX_MAP[i] = get_key_id_from_string(KEY_MAP[i]); - } - } } pub struct CallOnChainContext { @@ -78,18 +69,13 @@ pub struct CallOnChainContext { fn func_call_on_chain_thunk(ctx: &ScFuncContext) { ctx.log("testcore.funcCallOnChain"); let f = CallOnChainContext { - params: ImmutableCallOnChainParams { - id: OBJ_ID_PARAMS, - }, - results: MutableCallOnChainResults { - id: OBJ_ID_RESULTS, - }, - state: MutableTestCoreState { - id: OBJ_ID_STATE, - }, + params: ImmutableCallOnChainParams { proxy: params_proxy() }, + results: MutableCallOnChainResults { proxy: results_proxy() }, + state: MutableTestCoreState { proxy: state_proxy() }, }; ctx.require(f.params.int_value().exists(), "missing mandatory intValue"); func_call_on_chain(ctx, &f); + ctx.results(&f.results.proxy.kv_store); ctx.log("testcore.funcCallOnChain ok"); } @@ -101,12 +87,8 @@ pub struct CheckContextFromFullEPContext { fn func_check_context_from_full_ep_thunk(ctx: &ScFuncContext) { ctx.log("testcore.funcCheckContextFromFullEP"); let f = CheckContextFromFullEPContext { - params: ImmutableCheckContextFromFullEPParams { - id: OBJ_ID_PARAMS, - }, - state: MutableTestCoreState { - id: OBJ_ID_STATE, - }, + params: ImmutableCheckContextFromFullEPParams { proxy: params_proxy() }, + state: MutableTestCoreState { proxy: state_proxy() }, }; ctx.require(f.params.agent_id().exists(), "missing mandatory agentID"); ctx.require(f.params.caller().exists(), "missing mandatory caller"); @@ -124,9 +106,7 @@ pub struct DoNothingContext { fn func_do_nothing_thunk(ctx: &ScFuncContext) { ctx.log("testcore.funcDoNothing"); let f = DoNothingContext { - state: MutableTestCoreState { - id: OBJ_ID_STATE, - }, + state: MutableTestCoreState { proxy: state_proxy() }, }; func_do_nothing(ctx, &f); ctx.log("testcore.funcDoNothing ok"); @@ -140,14 +120,11 @@ pub struct GetMintedSupplyContext { fn func_get_minted_supply_thunk(ctx: &ScFuncContext) { ctx.log("testcore.funcGetMintedSupply"); let f = GetMintedSupplyContext { - results: MutableGetMintedSupplyResults { - id: OBJ_ID_RESULTS, - }, - state: MutableTestCoreState { - id: OBJ_ID_STATE, - }, + results: MutableGetMintedSupplyResults { proxy: results_proxy() }, + state: MutableTestCoreState { proxy: state_proxy() }, }; func_get_minted_supply(ctx, &f); + ctx.results(&f.results.proxy.kv_store); ctx.log("testcore.funcGetMintedSupply ok"); } @@ -158,9 +135,7 @@ pub struct IncCounterContext { fn func_inc_counter_thunk(ctx: &ScFuncContext) { ctx.log("testcore.funcIncCounter"); let f = IncCounterContext { - state: MutableTestCoreState { - id: OBJ_ID_STATE, - }, + state: MutableTestCoreState { proxy: state_proxy() }, }; func_inc_counter(ctx, &f); ctx.log("testcore.funcIncCounter ok"); @@ -174,12 +149,8 @@ pub struct InitContext { fn func_init_thunk(ctx: &ScFuncContext) { ctx.log("testcore.funcInit"); let f = InitContext { - params: ImmutableInitParams { - id: OBJ_ID_PARAMS, - }, - state: MutableTestCoreState { - id: OBJ_ID_STATE, - }, + params: ImmutableInitParams { proxy: params_proxy() }, + state: MutableTestCoreState { proxy: state_proxy() }, }; func_init(ctx, &f); ctx.log("testcore.funcInit ok"); @@ -193,12 +164,8 @@ pub struct PassTypesFullContext { fn func_pass_types_full_thunk(ctx: &ScFuncContext) { ctx.log("testcore.funcPassTypesFull"); let f = PassTypesFullContext { - params: ImmutablePassTypesFullParams { - id: OBJ_ID_PARAMS, - }, - state: MutableTestCoreState { - id: OBJ_ID_STATE, - }, + params: ImmutablePassTypesFullParams { proxy: params_proxy() }, + state: MutableTestCoreState { proxy: state_proxy() }, }; ctx.require(f.params.address().exists(), "missing mandatory address"); ctx.require(f.params.agent_id().exists(), "missing mandatory agentID"); @@ -224,18 +191,13 @@ pub struct RunRecursionContext { fn func_run_recursion_thunk(ctx: &ScFuncContext) { ctx.log("testcore.funcRunRecursion"); let f = RunRecursionContext { - params: ImmutableRunRecursionParams { - id: OBJ_ID_PARAMS, - }, - results: MutableRunRecursionResults { - id: OBJ_ID_RESULTS, - }, - state: MutableTestCoreState { - id: OBJ_ID_STATE, - }, + params: ImmutableRunRecursionParams { proxy: params_proxy() }, + results: MutableRunRecursionResults { proxy: results_proxy() }, + state: MutableTestCoreState { proxy: state_proxy() }, }; ctx.require(f.params.int_value().exists(), "missing mandatory intValue"); func_run_recursion(ctx, &f); + ctx.results(&f.results.proxy.kv_store); ctx.log("testcore.funcRunRecursion ok"); } @@ -246,16 +208,12 @@ pub struct SendToAddressContext { fn func_send_to_address_thunk(ctx: &ScFuncContext) { ctx.log("testcore.funcSendToAddress"); - ctx.require(ctx.caller() == ctx.contract_creator(), "no permission"); - let f = SendToAddressContext { - params: ImmutableSendToAddressParams { - id: OBJ_ID_PARAMS, - }, - state: MutableTestCoreState { - id: OBJ_ID_STATE, - }, + params: ImmutableSendToAddressParams { proxy: params_proxy() }, + state: MutableTestCoreState { proxy: state_proxy() }, }; + ctx.require(ctx.caller() == ctx.contract_creator(), "no permission"); + ctx.require(f.params.address().exists(), "missing mandatory address"); func_send_to_address(ctx, &f); ctx.log("testcore.funcSendToAddress ok"); @@ -269,12 +227,8 @@ pub struct SetIntContext { fn func_set_int_thunk(ctx: &ScFuncContext) { ctx.log("testcore.funcSetInt"); let f = SetIntContext { - params: ImmutableSetIntParams { - id: OBJ_ID_PARAMS, - }, - state: MutableTestCoreState { - id: OBJ_ID_STATE, - }, + params: ImmutableSetIntParams { proxy: params_proxy() }, + state: MutableTestCoreState { proxy: state_proxy() }, }; ctx.require(f.params.int_value().exists(), "missing mandatory intValue"); ctx.require(f.params.name().exists(), "missing mandatory name"); @@ -290,12 +244,8 @@ pub struct SpawnContext { fn func_spawn_thunk(ctx: &ScFuncContext) { ctx.log("testcore.funcSpawn"); let f = SpawnContext { - params: ImmutableSpawnParams { - id: OBJ_ID_PARAMS, - }, - state: MutableTestCoreState { - id: OBJ_ID_STATE, - }, + params: ImmutableSpawnParams { proxy: params_proxy() }, + state: MutableTestCoreState { proxy: state_proxy() }, }; ctx.require(f.params.prog_hash().exists(), "missing mandatory progHash"); func_spawn(ctx, &f); @@ -309,9 +259,7 @@ pub struct TestBlockContext1Context { fn func_test_block_context1_thunk(ctx: &ScFuncContext) { ctx.log("testcore.funcTestBlockContext1"); let f = TestBlockContext1Context { - state: MutableTestCoreState { - id: OBJ_ID_STATE, - }, + state: MutableTestCoreState { proxy: state_proxy() }, }; func_test_block_context1(ctx, &f); ctx.log("testcore.funcTestBlockContext1 ok"); @@ -324,9 +272,7 @@ pub struct TestBlockContext2Context { fn func_test_block_context2_thunk(ctx: &ScFuncContext) { ctx.log("testcore.funcTestBlockContext2"); let f = TestBlockContext2Context { - state: MutableTestCoreState { - id: OBJ_ID_STATE, - }, + state: MutableTestCoreState { proxy: state_proxy() }, }; func_test_block_context2(ctx, &f); ctx.log("testcore.funcTestBlockContext2 ok"); @@ -339,9 +285,7 @@ pub struct TestCallPanicFullEPContext { fn func_test_call_panic_full_ep_thunk(ctx: &ScFuncContext) { ctx.log("testcore.funcTestCallPanicFullEP"); let f = TestCallPanicFullEPContext { - state: MutableTestCoreState { - id: OBJ_ID_STATE, - }, + state: MutableTestCoreState { proxy: state_proxy() }, }; func_test_call_panic_full_ep(ctx, &f); ctx.log("testcore.funcTestCallPanicFullEP ok"); @@ -354,9 +298,7 @@ pub struct TestCallPanicViewEPFromFullContext { fn func_test_call_panic_view_ep_from_full_thunk(ctx: &ScFuncContext) { ctx.log("testcore.funcTestCallPanicViewEPFromFull"); let f = TestCallPanicViewEPFromFullContext { - state: MutableTestCoreState { - id: OBJ_ID_STATE, - }, + state: MutableTestCoreState { proxy: state_proxy() }, }; func_test_call_panic_view_ep_from_full(ctx, &f); ctx.log("testcore.funcTestCallPanicViewEPFromFull ok"); @@ -370,14 +312,11 @@ pub struct TestChainOwnerIDFullContext { fn func_test_chain_owner_id_full_thunk(ctx: &ScFuncContext) { ctx.log("testcore.funcTestChainOwnerIDFull"); let f = TestChainOwnerIDFullContext { - results: MutableTestChainOwnerIDFullResults { - id: OBJ_ID_RESULTS, - }, - state: MutableTestCoreState { - id: OBJ_ID_STATE, - }, + results: MutableTestChainOwnerIDFullResults { proxy: results_proxy() }, + state: MutableTestCoreState { proxy: state_proxy() }, }; func_test_chain_owner_id_full(ctx, &f); + ctx.results(&f.results.proxy.kv_store); ctx.log("testcore.funcTestChainOwnerIDFull ok"); } @@ -388,9 +327,7 @@ pub struct TestEventLogDeployContext { fn func_test_event_log_deploy_thunk(ctx: &ScFuncContext) { ctx.log("testcore.funcTestEventLogDeploy"); let f = TestEventLogDeployContext { - state: MutableTestCoreState { - id: OBJ_ID_STATE, - }, + state: MutableTestCoreState { proxy: state_proxy() }, }; func_test_event_log_deploy(ctx, &f); ctx.log("testcore.funcTestEventLogDeploy ok"); @@ -403,9 +340,7 @@ pub struct TestEventLogEventDataContext { fn func_test_event_log_event_data_thunk(ctx: &ScFuncContext) { ctx.log("testcore.funcTestEventLogEventData"); let f = TestEventLogEventDataContext { - state: MutableTestCoreState { - id: OBJ_ID_STATE, - }, + state: MutableTestCoreState { proxy: state_proxy() }, }; func_test_event_log_event_data(ctx, &f); ctx.log("testcore.funcTestEventLogEventData ok"); @@ -419,12 +354,8 @@ pub struct TestEventLogGenericDataContext { fn func_test_event_log_generic_data_thunk(ctx: &ScFuncContext) { ctx.log("testcore.funcTestEventLogGenericData"); let f = TestEventLogGenericDataContext { - params: ImmutableTestEventLogGenericDataParams { - id: OBJ_ID_PARAMS, - }, - state: MutableTestCoreState { - id: OBJ_ID_STATE, - }, + params: ImmutableTestEventLogGenericDataParams { proxy: params_proxy() }, + state: MutableTestCoreState { proxy: state_proxy() }, }; ctx.require(f.params.counter().exists(), "missing mandatory counter"); func_test_event_log_generic_data(ctx, &f); @@ -438,9 +369,7 @@ pub struct TestPanicFullEPContext { fn func_test_panic_full_ep_thunk(ctx: &ScFuncContext) { ctx.log("testcore.funcTestPanicFullEP"); let f = TestPanicFullEPContext { - state: MutableTestCoreState { - id: OBJ_ID_STATE, - }, + state: MutableTestCoreState { proxy: state_proxy() }, }; func_test_panic_full_ep(ctx, &f); ctx.log("testcore.funcTestPanicFullEP ok"); @@ -454,12 +383,8 @@ pub struct WithdrawToChainContext { fn func_withdraw_to_chain_thunk(ctx: &ScFuncContext) { ctx.log("testcore.funcWithdrawToChain"); let f = WithdrawToChainContext { - params: ImmutableWithdrawToChainParams { - id: OBJ_ID_PARAMS, - }, - state: MutableTestCoreState { - id: OBJ_ID_STATE, - }, + params: ImmutableWithdrawToChainParams { proxy: params_proxy() }, + state: MutableTestCoreState { proxy: state_proxy() }, }; ctx.require(f.params.chain_id().exists(), "missing mandatory chainID"); func_withdraw_to_chain(ctx, &f); @@ -474,12 +399,8 @@ pub struct CheckContextFromViewEPContext { fn view_check_context_from_view_ep_thunk(ctx: &ScViewContext) { ctx.log("testcore.viewCheckContextFromViewEP"); let f = CheckContextFromViewEPContext { - params: ImmutableCheckContextFromViewEPParams { - id: OBJ_ID_PARAMS, - }, - state: ImmutableTestCoreState { - id: OBJ_ID_STATE, - }, + params: ImmutableCheckContextFromViewEPParams { proxy: params_proxy() }, + state: ImmutableTestCoreState { proxy: state_proxy() }, }; ctx.require(f.params.agent_id().exists(), "missing mandatory agentID"); ctx.require(f.params.chain_id().exists(), "missing mandatory chainID"); @@ -498,18 +419,13 @@ pub struct FibonacciContext { fn view_fibonacci_thunk(ctx: &ScViewContext) { ctx.log("testcore.viewFibonacci"); let f = FibonacciContext { - params: ImmutableFibonacciParams { - id: OBJ_ID_PARAMS, - }, - results: MutableFibonacciResults { - id: OBJ_ID_RESULTS, - }, - state: ImmutableTestCoreState { - id: OBJ_ID_STATE, - }, + params: ImmutableFibonacciParams { proxy: params_proxy() }, + results: MutableFibonacciResults { proxy: results_proxy() }, + state: ImmutableTestCoreState { proxy: state_proxy() }, }; ctx.require(f.params.int_value().exists(), "missing mandatory intValue"); view_fibonacci(ctx, &f); + ctx.results(&f.results.proxy.kv_store); ctx.log("testcore.viewFibonacci ok"); } @@ -521,14 +437,11 @@ pub struct GetCounterContext { fn view_get_counter_thunk(ctx: &ScViewContext) { ctx.log("testcore.viewGetCounter"); let f = GetCounterContext { - results: MutableGetCounterResults { - id: OBJ_ID_RESULTS, - }, - state: ImmutableTestCoreState { - id: OBJ_ID_STATE, - }, + results: MutableGetCounterResults { proxy: results_proxy() }, + state: ImmutableTestCoreState { proxy: state_proxy() }, }; view_get_counter(ctx, &f); + ctx.results(&f.results.proxy.kv_store); ctx.log("testcore.viewGetCounter ok"); } @@ -541,18 +454,13 @@ pub struct GetIntContext { fn view_get_int_thunk(ctx: &ScViewContext) { ctx.log("testcore.viewGetInt"); let f = GetIntContext { - params: ImmutableGetIntParams { - id: OBJ_ID_PARAMS, - }, - results: MutableGetIntResults { - id: OBJ_ID_RESULTS, - }, - state: ImmutableTestCoreState { - id: OBJ_ID_STATE, - }, + params: ImmutableGetIntParams { proxy: params_proxy() }, + results: MutableGetIntResults { proxy: results_proxy() }, + state: ImmutableTestCoreState { proxy: state_proxy() }, }; ctx.require(f.params.name().exists(), "missing mandatory name"); view_get_int(ctx, &f); + ctx.results(&f.results.proxy.kv_store); ctx.log("testcore.viewGetInt ok"); } @@ -565,18 +473,13 @@ pub struct GetStringValueContext { fn view_get_string_value_thunk(ctx: &ScViewContext) { ctx.log("testcore.viewGetStringValue"); let f = GetStringValueContext { - params: ImmutableGetStringValueParams { - id: OBJ_ID_PARAMS, - }, - results: MutableGetStringValueResults { - id: OBJ_ID_RESULTS, - }, - state: ImmutableTestCoreState { - id: OBJ_ID_STATE, - }, + params: ImmutableGetStringValueParams { proxy: params_proxy() }, + results: MutableGetStringValueResults { proxy: results_proxy() }, + state: ImmutableTestCoreState { proxy: state_proxy() }, }; ctx.require(f.params.var_name().exists(), "missing mandatory varName"); view_get_string_value(ctx, &f); + ctx.results(&f.results.proxy.kv_store); ctx.log("testcore.viewGetStringValue ok"); } @@ -587,9 +490,7 @@ pub struct JustViewContext { fn view_just_view_thunk(ctx: &ScViewContext) { ctx.log("testcore.viewJustView"); let f = JustViewContext { - state: ImmutableTestCoreState { - id: OBJ_ID_STATE, - }, + state: ImmutableTestCoreState { proxy: state_proxy() }, }; view_just_view(ctx, &f); ctx.log("testcore.viewJustView ok"); @@ -603,12 +504,8 @@ pub struct PassTypesViewContext { fn view_pass_types_view_thunk(ctx: &ScViewContext) { ctx.log("testcore.viewPassTypesView"); let f = PassTypesViewContext { - params: ImmutablePassTypesViewParams { - id: OBJ_ID_PARAMS, - }, - state: ImmutableTestCoreState { - id: OBJ_ID_STATE, - }, + params: ImmutablePassTypesViewParams { proxy: params_proxy() }, + state: ImmutableTestCoreState { proxy: state_proxy() }, }; ctx.require(f.params.address().exists(), "missing mandatory address"); ctx.require(f.params.agent_id().exists(), "missing mandatory agentID"); @@ -632,9 +529,7 @@ pub struct TestCallPanicViewEPFromViewContext { fn view_test_call_panic_view_ep_from_view_thunk(ctx: &ScViewContext) { ctx.log("testcore.viewTestCallPanicViewEPFromView"); let f = TestCallPanicViewEPFromViewContext { - state: ImmutableTestCoreState { - id: OBJ_ID_STATE, - }, + state: ImmutableTestCoreState { proxy: state_proxy() }, }; view_test_call_panic_view_ep_from_view(ctx, &f); ctx.log("testcore.viewTestCallPanicViewEPFromView ok"); @@ -648,14 +543,11 @@ pub struct TestChainOwnerIDViewContext { fn view_test_chain_owner_id_view_thunk(ctx: &ScViewContext) { ctx.log("testcore.viewTestChainOwnerIDView"); let f = TestChainOwnerIDViewContext { - results: MutableTestChainOwnerIDViewResults { - id: OBJ_ID_RESULTS, - }, - state: ImmutableTestCoreState { - id: OBJ_ID_STATE, - }, + results: MutableTestChainOwnerIDViewResults { proxy: results_proxy() }, + state: ImmutableTestCoreState { proxy: state_proxy() }, }; view_test_chain_owner_id_view(ctx, &f); + ctx.results(&f.results.proxy.kv_store); ctx.log("testcore.viewTestChainOwnerIDView ok"); } @@ -666,9 +558,7 @@ pub struct TestPanicViewEPContext { fn view_test_panic_view_ep_thunk(ctx: &ScViewContext) { ctx.log("testcore.viewTestPanicViewEP"); let f = TestPanicViewEPContext { - state: ImmutableTestCoreState { - id: OBJ_ID_STATE, - }, + state: ImmutableTestCoreState { proxy: state_proxy() }, }; view_test_panic_view_ep(ctx, &f); ctx.log("testcore.viewTestPanicViewEP ok"); @@ -682,13 +572,10 @@ pub struct TestSandboxCallContext { fn view_test_sandbox_call_thunk(ctx: &ScViewContext) { ctx.log("testcore.viewTestSandboxCall"); let f = TestSandboxCallContext { - results: MutableTestSandboxCallResults { - id: OBJ_ID_RESULTS, - }, - state: ImmutableTestCoreState { - id: OBJ_ID_STATE, - }, + results: MutableTestSandboxCallResults { proxy: results_proxy() }, + state: ImmutableTestCoreState { proxy: state_proxy() }, }; view_test_sandbox_call(ctx, &f); + ctx.results(&f.results.proxy.kv_store); ctx.log("testcore.viewTestSandboxCall ok"); } diff --git a/contracts/wasm/testcore/src/params.rs b/contracts/wasm/testcore/src/params.rs index 50c879a7fc..99cf759fd5 100644 --- a/contracts/wasm/testcore/src/params.rs +++ b/contracts/wasm/testcore/src/params.rs @@ -9,577 +9,574 @@ #![allow(unused_imports)] use wasmlib::*; -use wasmlib::host::*; - use crate::*; -use crate::keys::*; -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableCallOnChainParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableCallOnChainParams { pub fn hname_contract(&self) -> ScImmutableHname { - ScImmutableHname::new(self.id, PARAM_HNAME_CONTRACT.get_key_id()) + ScImmutableHname::new(self.proxy.root(PARAM_HNAME_CONTRACT)) } pub fn hname_ep(&self) -> ScImmutableHname { - ScImmutableHname::new(self.id, PARAM_HNAME_EP.get_key_id()) + ScImmutableHname::new(self.proxy.root(PARAM_HNAME_EP)) } pub fn int_value(&self) -> ScImmutableInt64 { - ScImmutableInt64::new(self.id, PARAM_INT_VALUE.get_key_id()) + ScImmutableInt64::new(self.proxy.root(PARAM_INT_VALUE)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableCallOnChainParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableCallOnChainParams { pub fn hname_contract(&self) -> ScMutableHname { - ScMutableHname::new(self.id, PARAM_HNAME_CONTRACT.get_key_id()) + ScMutableHname::new(self.proxy.root(PARAM_HNAME_CONTRACT)) } pub fn hname_ep(&self) -> ScMutableHname { - ScMutableHname::new(self.id, PARAM_HNAME_EP.get_key_id()) + ScMutableHname::new(self.proxy.root(PARAM_HNAME_EP)) } pub fn int_value(&self) -> ScMutableInt64 { - ScMutableInt64::new(self.id, PARAM_INT_VALUE.get_key_id()) + ScMutableInt64::new(self.proxy.root(PARAM_INT_VALUE)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableCheckContextFromFullEPParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableCheckContextFromFullEPParams { pub fn agent_id(&self) -> ScImmutableAgentID { - ScImmutableAgentID::new(self.id, PARAM_AGENT_ID.get_key_id()) + ScImmutableAgentID::new(self.proxy.root(PARAM_AGENT_ID)) } pub fn caller(&self) -> ScImmutableAgentID { - ScImmutableAgentID::new(self.id, PARAM_CALLER.get_key_id()) + ScImmutableAgentID::new(self.proxy.root(PARAM_CALLER)) } pub fn chain_id(&self) -> ScImmutableChainID { - ScImmutableChainID::new(self.id, PARAM_CHAIN_ID.get_key_id()) + ScImmutableChainID::new(self.proxy.root(PARAM_CHAIN_ID)) } pub fn chain_owner_id(&self) -> ScImmutableAgentID { - ScImmutableAgentID::new(self.id, PARAM_CHAIN_OWNER_ID.get_key_id()) + ScImmutableAgentID::new(self.proxy.root(PARAM_CHAIN_OWNER_ID)) } pub fn contract_creator(&self) -> ScImmutableAgentID { - ScImmutableAgentID::new(self.id, PARAM_CONTRACT_CREATOR.get_key_id()) + ScImmutableAgentID::new(self.proxy.root(PARAM_CONTRACT_CREATOR)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableCheckContextFromFullEPParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableCheckContextFromFullEPParams { pub fn agent_id(&self) -> ScMutableAgentID { - ScMutableAgentID::new(self.id, PARAM_AGENT_ID.get_key_id()) + ScMutableAgentID::new(self.proxy.root(PARAM_AGENT_ID)) } pub fn caller(&self) -> ScMutableAgentID { - ScMutableAgentID::new(self.id, PARAM_CALLER.get_key_id()) + ScMutableAgentID::new(self.proxy.root(PARAM_CALLER)) } pub fn chain_id(&self) -> ScMutableChainID { - ScMutableChainID::new(self.id, PARAM_CHAIN_ID.get_key_id()) + ScMutableChainID::new(self.proxy.root(PARAM_CHAIN_ID)) } pub fn chain_owner_id(&self) -> ScMutableAgentID { - ScMutableAgentID::new(self.id, PARAM_CHAIN_OWNER_ID.get_key_id()) + ScMutableAgentID::new(self.proxy.root(PARAM_CHAIN_OWNER_ID)) } pub fn contract_creator(&self) -> ScMutableAgentID { - ScMutableAgentID::new(self.id, PARAM_CONTRACT_CREATOR.get_key_id()) + ScMutableAgentID::new(self.proxy.root(PARAM_CONTRACT_CREATOR)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableInitParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableInitParams { pub fn fail(&self) -> ScImmutableInt64 { - ScImmutableInt64::new(self.id, idx_map(IDX_PARAM_FAIL)) + ScImmutableInt64::new(self.proxy.root(PARAM_FAIL)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableInitParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableInitParams { pub fn fail(&self) -> ScMutableInt64 { - ScMutableInt64::new(self.id, idx_map(IDX_PARAM_FAIL)) + ScMutableInt64::new(self.proxy.root(PARAM_FAIL)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutablePassTypesFullParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutablePassTypesFullParams { pub fn address(&self) -> ScImmutableAddress { - ScImmutableAddress::new(self.id, PARAM_ADDRESS.get_key_id()) + ScImmutableAddress::new(self.proxy.root(PARAM_ADDRESS)) } pub fn agent_id(&self) -> ScImmutableAgentID { - ScImmutableAgentID::new(self.id, PARAM_AGENT_ID.get_key_id()) + ScImmutableAgentID::new(self.proxy.root(PARAM_AGENT_ID)) } pub fn chain_id(&self) -> ScImmutableChainID { - ScImmutableChainID::new(self.id, PARAM_CHAIN_ID.get_key_id()) + ScImmutableChainID::new(self.proxy.root(PARAM_CHAIN_ID)) } pub fn contract_id(&self) -> ScImmutableAgentID { - ScImmutableAgentID::new(self.id, PARAM_CONTRACT_ID.get_key_id()) + ScImmutableAgentID::new(self.proxy.root(PARAM_CONTRACT_ID)) } pub fn hash(&self) -> ScImmutableHash { - ScImmutableHash::new(self.id, PARAM_HASH.get_key_id()) + ScImmutableHash::new(self.proxy.root(PARAM_HASH)) } pub fn hname(&self) -> ScImmutableHname { - ScImmutableHname::new(self.id, PARAM_HNAME.get_key_id()) + ScImmutableHname::new(self.proxy.root(PARAM_HNAME)) } pub fn hname_zero(&self) -> ScImmutableHname { - ScImmutableHname::new(self.id, PARAM_HNAME_ZERO.get_key_id()) + ScImmutableHname::new(self.proxy.root(PARAM_HNAME_ZERO)) } pub fn int64(&self) -> ScImmutableInt64 { - ScImmutableInt64::new(self.id, PARAM_INT64.get_key_id()) + ScImmutableInt64::new(self.proxy.root(PARAM_INT64)) } pub fn int64_zero(&self) -> ScImmutableInt64 { - ScImmutableInt64::new(self.id, PARAM_INT64_ZERO.get_key_id()) + ScImmutableInt64::new(self.proxy.root(PARAM_INT64_ZERO)) } pub fn string(&self) -> ScImmutableString { - ScImmutableString::new(self.id, PARAM_STRING.get_key_id()) + ScImmutableString::new(self.proxy.root(PARAM_STRING)) } pub fn string_zero(&self) -> ScImmutableString { - ScImmutableString::new(self.id, PARAM_STRING_ZERO.get_key_id()) + ScImmutableString::new(self.proxy.root(PARAM_STRING_ZERO)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutablePassTypesFullParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutablePassTypesFullParams { pub fn address(&self) -> ScMutableAddress { - ScMutableAddress::new(self.id, PARAM_ADDRESS.get_key_id()) + ScMutableAddress::new(self.proxy.root(PARAM_ADDRESS)) } pub fn agent_id(&self) -> ScMutableAgentID { - ScMutableAgentID::new(self.id, PARAM_AGENT_ID.get_key_id()) + ScMutableAgentID::new(self.proxy.root(PARAM_AGENT_ID)) } pub fn chain_id(&self) -> ScMutableChainID { - ScMutableChainID::new(self.id, PARAM_CHAIN_ID.get_key_id()) + ScMutableChainID::new(self.proxy.root(PARAM_CHAIN_ID)) } pub fn contract_id(&self) -> ScMutableAgentID { - ScMutableAgentID::new(self.id, PARAM_CONTRACT_ID.get_key_id()) + ScMutableAgentID::new(self.proxy.root(PARAM_CONTRACT_ID)) } pub fn hash(&self) -> ScMutableHash { - ScMutableHash::new(self.id, PARAM_HASH.get_key_id()) + ScMutableHash::new(self.proxy.root(PARAM_HASH)) } pub fn hname(&self) -> ScMutableHname { - ScMutableHname::new(self.id, PARAM_HNAME.get_key_id()) + ScMutableHname::new(self.proxy.root(PARAM_HNAME)) } pub fn hname_zero(&self) -> ScMutableHname { - ScMutableHname::new(self.id, PARAM_HNAME_ZERO.get_key_id()) + ScMutableHname::new(self.proxy.root(PARAM_HNAME_ZERO)) } pub fn int64(&self) -> ScMutableInt64 { - ScMutableInt64::new(self.id, PARAM_INT64.get_key_id()) + ScMutableInt64::new(self.proxy.root(PARAM_INT64)) } pub fn int64_zero(&self) -> ScMutableInt64 { - ScMutableInt64::new(self.id, PARAM_INT64_ZERO.get_key_id()) + ScMutableInt64::new(self.proxy.root(PARAM_INT64_ZERO)) } pub fn string(&self) -> ScMutableString { - ScMutableString::new(self.id, PARAM_STRING.get_key_id()) + ScMutableString::new(self.proxy.root(PARAM_STRING)) } pub fn string_zero(&self) -> ScMutableString { - ScMutableString::new(self.id, PARAM_STRING_ZERO.get_key_id()) + ScMutableString::new(self.proxy.root(PARAM_STRING_ZERO)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableRunRecursionParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableRunRecursionParams { pub fn int_value(&self) -> ScImmutableInt64 { - ScImmutableInt64::new(self.id, PARAM_INT_VALUE.get_key_id()) + ScImmutableInt64::new(self.proxy.root(PARAM_INT_VALUE)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableRunRecursionParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableRunRecursionParams { pub fn int_value(&self) -> ScMutableInt64 { - ScMutableInt64::new(self.id, PARAM_INT_VALUE.get_key_id()) + ScMutableInt64::new(self.proxy.root(PARAM_INT_VALUE)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableSendToAddressParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableSendToAddressParams { pub fn address(&self) -> ScImmutableAddress { - ScImmutableAddress::new(self.id, PARAM_ADDRESS.get_key_id()) + ScImmutableAddress::new(self.proxy.root(PARAM_ADDRESS)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableSendToAddressParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableSendToAddressParams { pub fn address(&self) -> ScMutableAddress { - ScMutableAddress::new(self.id, PARAM_ADDRESS.get_key_id()) + ScMutableAddress::new(self.proxy.root(PARAM_ADDRESS)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableSetIntParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableSetIntParams { pub fn int_value(&self) -> ScImmutableInt64 { - ScImmutableInt64::new(self.id, PARAM_INT_VALUE.get_key_id()) + ScImmutableInt64::new(self.proxy.root(PARAM_INT_VALUE)) } pub fn name(&self) -> ScImmutableString { - ScImmutableString::new(self.id, PARAM_NAME.get_key_id()) + ScImmutableString::new(self.proxy.root(PARAM_NAME)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableSetIntParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableSetIntParams { pub fn int_value(&self) -> ScMutableInt64 { - ScMutableInt64::new(self.id, PARAM_INT_VALUE.get_key_id()) + ScMutableInt64::new(self.proxy.root(PARAM_INT_VALUE)) } pub fn name(&self) -> ScMutableString { - ScMutableString::new(self.id, PARAM_NAME.get_key_id()) + ScMutableString::new(self.proxy.root(PARAM_NAME)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableSpawnParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableSpawnParams { pub fn prog_hash(&self) -> ScImmutableHash { - ScImmutableHash::new(self.id, PARAM_PROG_HASH.get_key_id()) + ScImmutableHash::new(self.proxy.root(PARAM_PROG_HASH)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableSpawnParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableSpawnParams { pub fn prog_hash(&self) -> ScMutableHash { - ScMutableHash::new(self.id, PARAM_PROG_HASH.get_key_id()) + ScMutableHash::new(self.proxy.root(PARAM_PROG_HASH)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableTestEventLogGenericDataParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableTestEventLogGenericDataParams { pub fn counter(&self) -> ScImmutableInt64 { - ScImmutableInt64::new(self.id, PARAM_COUNTER.get_key_id()) + ScImmutableInt64::new(self.proxy.root(PARAM_COUNTER)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableTestEventLogGenericDataParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableTestEventLogGenericDataParams { pub fn counter(&self) -> ScMutableInt64 { - ScMutableInt64::new(self.id, PARAM_COUNTER.get_key_id()) + ScMutableInt64::new(self.proxy.root(PARAM_COUNTER)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableWithdrawToChainParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableWithdrawToChainParams { pub fn chain_id(&self) -> ScImmutableChainID { - ScImmutableChainID::new(self.id, PARAM_CHAIN_ID.get_key_id()) + ScImmutableChainID::new(self.proxy.root(PARAM_CHAIN_ID)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableWithdrawToChainParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableWithdrawToChainParams { pub fn chain_id(&self) -> ScMutableChainID { - ScMutableChainID::new(self.id, PARAM_CHAIN_ID.get_key_id()) + ScMutableChainID::new(self.proxy.root(PARAM_CHAIN_ID)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableCheckContextFromViewEPParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableCheckContextFromViewEPParams { pub fn agent_id(&self) -> ScImmutableAgentID { - ScImmutableAgentID::new(self.id, PARAM_AGENT_ID.get_key_id()) + ScImmutableAgentID::new(self.proxy.root(PARAM_AGENT_ID)) } pub fn chain_id(&self) -> ScImmutableChainID { - ScImmutableChainID::new(self.id, PARAM_CHAIN_ID.get_key_id()) + ScImmutableChainID::new(self.proxy.root(PARAM_CHAIN_ID)) } pub fn chain_owner_id(&self) -> ScImmutableAgentID { - ScImmutableAgentID::new(self.id, PARAM_CHAIN_OWNER_ID.get_key_id()) + ScImmutableAgentID::new(self.proxy.root(PARAM_CHAIN_OWNER_ID)) } pub fn contract_creator(&self) -> ScImmutableAgentID { - ScImmutableAgentID::new(self.id, PARAM_CONTRACT_CREATOR.get_key_id()) + ScImmutableAgentID::new(self.proxy.root(PARAM_CONTRACT_CREATOR)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableCheckContextFromViewEPParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableCheckContextFromViewEPParams { pub fn agent_id(&self) -> ScMutableAgentID { - ScMutableAgentID::new(self.id, PARAM_AGENT_ID.get_key_id()) + ScMutableAgentID::new(self.proxy.root(PARAM_AGENT_ID)) } pub fn chain_id(&self) -> ScMutableChainID { - ScMutableChainID::new(self.id, PARAM_CHAIN_ID.get_key_id()) + ScMutableChainID::new(self.proxy.root(PARAM_CHAIN_ID)) } pub fn chain_owner_id(&self) -> ScMutableAgentID { - ScMutableAgentID::new(self.id, PARAM_CHAIN_OWNER_ID.get_key_id()) + ScMutableAgentID::new(self.proxy.root(PARAM_CHAIN_OWNER_ID)) } pub fn contract_creator(&self) -> ScMutableAgentID { - ScMutableAgentID::new(self.id, PARAM_CONTRACT_CREATOR.get_key_id()) + ScMutableAgentID::new(self.proxy.root(PARAM_CONTRACT_CREATOR)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableFibonacciParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableFibonacciParams { pub fn int_value(&self) -> ScImmutableInt64 { - ScImmutableInt64::new(self.id, PARAM_INT_VALUE.get_key_id()) + ScImmutableInt64::new(self.proxy.root(PARAM_INT_VALUE)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableFibonacciParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableFibonacciParams { pub fn int_value(&self) -> ScMutableInt64 { - ScMutableInt64::new(self.id, PARAM_INT_VALUE.get_key_id()) + ScMutableInt64::new(self.proxy.root(PARAM_INT_VALUE)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableGetIntParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableGetIntParams { pub fn name(&self) -> ScImmutableString { - ScImmutableString::new(self.id, PARAM_NAME.get_key_id()) + ScImmutableString::new(self.proxy.root(PARAM_NAME)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableGetIntParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableGetIntParams { pub fn name(&self) -> ScMutableString { - ScMutableString::new(self.id, PARAM_NAME.get_key_id()) + ScMutableString::new(self.proxy.root(PARAM_NAME)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableGetStringValueParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableGetStringValueParams { pub fn var_name(&self) -> ScImmutableString { - ScImmutableString::new(self.id, PARAM_VAR_NAME.get_key_id()) + ScImmutableString::new(self.proxy.root(PARAM_VAR_NAME)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableGetStringValueParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableGetStringValueParams { pub fn var_name(&self) -> ScMutableString { - ScMutableString::new(self.id, PARAM_VAR_NAME.get_key_id()) + ScMutableString::new(self.proxy.root(PARAM_VAR_NAME)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutablePassTypesViewParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutablePassTypesViewParams { pub fn address(&self) -> ScImmutableAddress { - ScImmutableAddress::new(self.id, PARAM_ADDRESS.get_key_id()) + ScImmutableAddress::new(self.proxy.root(PARAM_ADDRESS)) } pub fn agent_id(&self) -> ScImmutableAgentID { - ScImmutableAgentID::new(self.id, PARAM_AGENT_ID.get_key_id()) + ScImmutableAgentID::new(self.proxy.root(PARAM_AGENT_ID)) } pub fn chain_id(&self) -> ScImmutableChainID { - ScImmutableChainID::new(self.id, PARAM_CHAIN_ID.get_key_id()) + ScImmutableChainID::new(self.proxy.root(PARAM_CHAIN_ID)) } pub fn contract_id(&self) -> ScImmutableAgentID { - ScImmutableAgentID::new(self.id, PARAM_CONTRACT_ID.get_key_id()) + ScImmutableAgentID::new(self.proxy.root(PARAM_CONTRACT_ID)) } pub fn hash(&self) -> ScImmutableHash { - ScImmutableHash::new(self.id, PARAM_HASH.get_key_id()) + ScImmutableHash::new(self.proxy.root(PARAM_HASH)) } pub fn hname(&self) -> ScImmutableHname { - ScImmutableHname::new(self.id, PARAM_HNAME.get_key_id()) + ScImmutableHname::new(self.proxy.root(PARAM_HNAME)) } pub fn hname_zero(&self) -> ScImmutableHname { - ScImmutableHname::new(self.id, PARAM_HNAME_ZERO.get_key_id()) + ScImmutableHname::new(self.proxy.root(PARAM_HNAME_ZERO)) } pub fn int64(&self) -> ScImmutableInt64 { - ScImmutableInt64::new(self.id, PARAM_INT64.get_key_id()) + ScImmutableInt64::new(self.proxy.root(PARAM_INT64)) } pub fn int64_zero(&self) -> ScImmutableInt64 { - ScImmutableInt64::new(self.id, PARAM_INT64_ZERO.get_key_id()) + ScImmutableInt64::new(self.proxy.root(PARAM_INT64_ZERO)) } pub fn string(&self) -> ScImmutableString { - ScImmutableString::new(self.id, PARAM_STRING.get_key_id()) + ScImmutableString::new(self.proxy.root(PARAM_STRING)) } pub fn string_zero(&self) -> ScImmutableString { - ScImmutableString::new(self.id, PARAM_STRING_ZERO.get_key_id()) + ScImmutableString::new(self.proxy.root(PARAM_STRING_ZERO)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutablePassTypesViewParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutablePassTypesViewParams { pub fn address(&self) -> ScMutableAddress { - ScMutableAddress::new(self.id, PARAM_ADDRESS.get_key_id()) + ScMutableAddress::new(self.proxy.root(PARAM_ADDRESS)) } pub fn agent_id(&self) -> ScMutableAgentID { - ScMutableAgentID::new(self.id, PARAM_AGENT_ID.get_key_id()) + ScMutableAgentID::new(self.proxy.root(PARAM_AGENT_ID)) } pub fn chain_id(&self) -> ScMutableChainID { - ScMutableChainID::new(self.id, PARAM_CHAIN_ID.get_key_id()) + ScMutableChainID::new(self.proxy.root(PARAM_CHAIN_ID)) } pub fn contract_id(&self) -> ScMutableAgentID { - ScMutableAgentID::new(self.id, PARAM_CONTRACT_ID.get_key_id()) + ScMutableAgentID::new(self.proxy.root(PARAM_CONTRACT_ID)) } pub fn hash(&self) -> ScMutableHash { - ScMutableHash::new(self.id, PARAM_HASH.get_key_id()) + ScMutableHash::new(self.proxy.root(PARAM_HASH)) } pub fn hname(&self) -> ScMutableHname { - ScMutableHname::new(self.id, PARAM_HNAME.get_key_id()) + ScMutableHname::new(self.proxy.root(PARAM_HNAME)) } pub fn hname_zero(&self) -> ScMutableHname { - ScMutableHname::new(self.id, PARAM_HNAME_ZERO.get_key_id()) + ScMutableHname::new(self.proxy.root(PARAM_HNAME_ZERO)) } pub fn int64(&self) -> ScMutableInt64 { - ScMutableInt64::new(self.id, PARAM_INT64.get_key_id()) + ScMutableInt64::new(self.proxy.root(PARAM_INT64)) } pub fn int64_zero(&self) -> ScMutableInt64 { - ScMutableInt64::new(self.id, PARAM_INT64_ZERO.get_key_id()) + ScMutableInt64::new(self.proxy.root(PARAM_INT64_ZERO)) } pub fn string(&self) -> ScMutableString { - ScMutableString::new(self.id, PARAM_STRING.get_key_id()) + ScMutableString::new(self.proxy.root(PARAM_STRING)) } pub fn string_zero(&self) -> ScMutableString { - ScMutableString::new(self.id, PARAM_STRING_ZERO.get_key_id()) + ScMutableString::new(self.proxy.root(PARAM_STRING_ZERO)) } } diff --git a/contracts/wasm/testcore/src/results.rs b/contracts/wasm/testcore/src/results.rs index bcc9dc8ea4..9beefe60d0 100644 --- a/contracts/wasm/testcore/src/results.rs +++ b/contracts/wasm/testcore/src/results.rs @@ -9,287 +9,284 @@ #![allow(unused_imports)] use wasmlib::*; -use wasmlib::host::*; - use crate::*; -use crate::keys::*; -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableCallOnChainResults { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableCallOnChainResults { pub fn int_value(&self) -> ScImmutableInt64 { - ScImmutableInt64::new(self.id, RESULT_INT_VALUE.get_key_id()) + ScImmutableInt64::new(self.proxy.root(RESULT_INT_VALUE)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableCallOnChainResults { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableCallOnChainResults { pub fn int_value(&self) -> ScMutableInt64 { - ScMutableInt64::new(self.id, RESULT_INT_VALUE.get_key_id()) + ScMutableInt64::new(self.proxy.root(RESULT_INT_VALUE)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableGetMintedSupplyResults { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableGetMintedSupplyResults { pub fn minted_color(&self) -> ScImmutableColor { - ScImmutableColor::new(self.id, RESULT_MINTED_COLOR.get_key_id()) + ScImmutableColor::new(self.proxy.root(RESULT_MINTED_COLOR)) } pub fn minted_supply(&self) -> ScImmutableUint64 { - ScImmutableUint64::new(self.id, RESULT_MINTED_SUPPLY.get_key_id()) + ScImmutableUint64::new(self.proxy.root(RESULT_MINTED_SUPPLY)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableGetMintedSupplyResults { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableGetMintedSupplyResults { pub fn minted_color(&self) -> ScMutableColor { - ScMutableColor::new(self.id, RESULT_MINTED_COLOR.get_key_id()) + ScMutableColor::new(self.proxy.root(RESULT_MINTED_COLOR)) } pub fn minted_supply(&self) -> ScMutableUint64 { - ScMutableUint64::new(self.id, RESULT_MINTED_SUPPLY.get_key_id()) + ScMutableUint64::new(self.proxy.root(RESULT_MINTED_SUPPLY)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableRunRecursionResults { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableRunRecursionResults { pub fn int_value(&self) -> ScImmutableInt64 { - ScImmutableInt64::new(self.id, RESULT_INT_VALUE.get_key_id()) + ScImmutableInt64::new(self.proxy.root(RESULT_INT_VALUE)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableRunRecursionResults { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableRunRecursionResults { pub fn int_value(&self) -> ScMutableInt64 { - ScMutableInt64::new(self.id, RESULT_INT_VALUE.get_key_id()) + ScMutableInt64::new(self.proxy.root(RESULT_INT_VALUE)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableTestChainOwnerIDFullResults { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableTestChainOwnerIDFullResults { pub fn chain_owner_id(&self) -> ScImmutableAgentID { - ScImmutableAgentID::new(self.id, RESULT_CHAIN_OWNER_ID.get_key_id()) + ScImmutableAgentID::new(self.proxy.root(RESULT_CHAIN_OWNER_ID)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableTestChainOwnerIDFullResults { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableTestChainOwnerIDFullResults { pub fn chain_owner_id(&self) -> ScMutableAgentID { - ScMutableAgentID::new(self.id, RESULT_CHAIN_OWNER_ID.get_key_id()) + ScMutableAgentID::new(self.proxy.root(RESULT_CHAIN_OWNER_ID)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableFibonacciResults { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableFibonacciResults { pub fn int_value(&self) -> ScImmutableInt64 { - ScImmutableInt64::new(self.id, RESULT_INT_VALUE.get_key_id()) + ScImmutableInt64::new(self.proxy.root(RESULT_INT_VALUE)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableFibonacciResults { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableFibonacciResults { pub fn int_value(&self) -> ScMutableInt64 { - ScMutableInt64::new(self.id, RESULT_INT_VALUE.get_key_id()) + ScMutableInt64::new(self.proxy.root(RESULT_INT_VALUE)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableGetCounterResults { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableGetCounterResults { pub fn counter(&self) -> ScImmutableInt64 { - ScImmutableInt64::new(self.id, RESULT_COUNTER.get_key_id()) + ScImmutableInt64::new(self.proxy.root(RESULT_COUNTER)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableGetCounterResults { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableGetCounterResults { pub fn counter(&self) -> ScMutableInt64 { - ScMutableInt64::new(self.id, RESULT_COUNTER.get_key_id()) + ScMutableInt64::new(self.proxy.root(RESULT_COUNTER)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MapStringToImmutableInt64 { - pub(crate) obj_id: i32, + pub(crate) proxy: Proxy, } impl MapStringToImmutableInt64 { pub fn get_int64(&self, key: &str) -> ScImmutableInt64 { - ScImmutableInt64::new(self.obj_id, key.get_key_id()) + ScImmutableInt64::new(self.proxy.key(&string_to_bytes(key))) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableGetIntResults { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableGetIntResults { pub fn values(&self) -> MapStringToImmutableInt64 { - MapStringToImmutableInt64 { obj_id: self.id } + MapStringToImmutableInt64 { proxy: self.proxy.clone() } } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MapStringToMutableInt64 { - pub(crate) obj_id: i32, + pub(crate) proxy: Proxy, } impl MapStringToMutableInt64 { pub fn clear(&self) { - clear(self.obj_id); + self.proxy.clear_map(); } pub fn get_int64(&self, key: &str) -> ScMutableInt64 { - ScMutableInt64::new(self.obj_id, key.get_key_id()) + ScMutableInt64::new(self.proxy.key(&string_to_bytes(key))) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableGetIntResults { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableGetIntResults { pub fn values(&self) -> MapStringToMutableInt64 { - MapStringToMutableInt64 { obj_id: self.id } + MapStringToMutableInt64 { proxy: self.proxy.clone() } } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MapStringToImmutableString { - pub(crate) obj_id: i32, + pub(crate) proxy: Proxy, } impl MapStringToImmutableString { pub fn get_string(&self, key: &str) -> ScImmutableString { - ScImmutableString::new(self.obj_id, key.get_key_id()) + ScImmutableString::new(self.proxy.key(&string_to_bytes(key))) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableGetStringValueResults { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableGetStringValueResults { pub fn vars(&self) -> MapStringToImmutableString { - MapStringToImmutableString { obj_id: self.id } + MapStringToImmutableString { proxy: self.proxy.clone() } } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MapStringToMutableString { - pub(crate) obj_id: i32, + pub(crate) proxy: Proxy, } impl MapStringToMutableString { pub fn clear(&self) { - clear(self.obj_id); + self.proxy.clear_map(); } pub fn get_string(&self, key: &str) -> ScMutableString { - ScMutableString::new(self.obj_id, key.get_key_id()) + ScMutableString::new(self.proxy.key(&string_to_bytes(key))) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableGetStringValueResults { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableGetStringValueResults { pub fn vars(&self) -> MapStringToMutableString { - MapStringToMutableString { obj_id: self.id } + MapStringToMutableString { proxy: self.proxy.clone() } } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableTestChainOwnerIDViewResults { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableTestChainOwnerIDViewResults { pub fn chain_owner_id(&self) -> ScImmutableAgentID { - ScImmutableAgentID::new(self.id, RESULT_CHAIN_OWNER_ID.get_key_id()) + ScImmutableAgentID::new(self.proxy.root(RESULT_CHAIN_OWNER_ID)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableTestChainOwnerIDViewResults { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableTestChainOwnerIDViewResults { pub fn chain_owner_id(&self) -> ScMutableAgentID { - ScMutableAgentID::new(self.id, RESULT_CHAIN_OWNER_ID.get_key_id()) + ScMutableAgentID::new(self.proxy.root(RESULT_CHAIN_OWNER_ID)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableTestSandboxCallResults { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableTestSandboxCallResults { pub fn sandbox_call(&self) -> ScImmutableString { - ScImmutableString::new(self.id, RESULT_SANDBOX_CALL.get_key_id()) + ScImmutableString::new(self.proxy.root(RESULT_SANDBOX_CALL)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableTestSandboxCallResults { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableTestSandboxCallResults { pub fn sandbox_call(&self) -> ScMutableString { - ScMutableString::new(self.id, RESULT_SANDBOX_CALL.get_key_id()) + ScMutableString::new(self.proxy.root(RESULT_SANDBOX_CALL)) } } diff --git a/contracts/wasm/testcore/src/state.rs b/contracts/wasm/testcore/src/state.rs index 3aab615757..2322594c6c 100644 --- a/contracts/wasm/testcore/src/state.rs +++ b/contracts/wasm/testcore/src/state.rs @@ -9,67 +9,63 @@ #![allow(unused_imports)] use wasmlib::*; -use wasmlib::host::*; use crate::*; -use crate::keys::*; -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableTestCoreState { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableTestCoreState { pub fn counter(&self) -> ScImmutableInt64 { - ScImmutableInt64::new(self.id, STATE_COUNTER.get_key_id()) + ScImmutableInt64::new(self.proxy.root(STATE_COUNTER)) } pub fn hname_ep(&self) -> ScImmutableHname { - ScImmutableHname::new(self.id, STATE_HNAME_EP.get_key_id()) + ScImmutableHname::new(self.proxy.root(STATE_HNAME_EP)) } pub fn ints(&self) -> MapStringToImmutableInt64 { - let map_id = get_object_id(self.id, STATE_INTS.get_key_id(), TYPE_MAP); - MapStringToImmutableInt64 { obj_id: map_id } + MapStringToImmutableInt64 { proxy: self.proxy.root(STATE_INTS) } } pub fn minted_color(&self) -> ScImmutableColor { - ScImmutableColor::new(self.id, STATE_MINTED_COLOR.get_key_id()) + ScImmutableColor::new(self.proxy.root(STATE_MINTED_COLOR)) } pub fn minted_supply(&self) -> ScImmutableUint64 { - ScImmutableUint64::new(self.id, STATE_MINTED_SUPPLY.get_key_id()) + ScImmutableUint64::new(self.proxy.root(STATE_MINTED_SUPPLY)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableTestCoreState { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableTestCoreState { pub fn as_immutable(&self) -> ImmutableTestCoreState { - ImmutableTestCoreState { id: self.id } + ImmutableTestCoreState { proxy: self.proxy.root("") } } pub fn counter(&self) -> ScMutableInt64 { - ScMutableInt64::new(self.id, STATE_COUNTER.get_key_id()) + ScMutableInt64::new(self.proxy.root(STATE_COUNTER)) } pub fn hname_ep(&self) -> ScMutableHname { - ScMutableHname::new(self.id, STATE_HNAME_EP.get_key_id()) + ScMutableHname::new(self.proxy.root(STATE_HNAME_EP)) } pub fn ints(&self) -> MapStringToMutableInt64 { - let map_id = get_object_id(self.id, STATE_INTS.get_key_id(), TYPE_MAP); - MapStringToMutableInt64 { obj_id: map_id } + MapStringToMutableInt64 { proxy: self.proxy.root(STATE_INTS) } } pub fn minted_color(&self) -> ScMutableColor { - ScMutableColor::new(self.id, STATE_MINTED_COLOR.get_key_id()) + ScMutableColor::new(self.proxy.root(STATE_MINTED_COLOR)) } pub fn minted_supply(&self) -> ScMutableUint64 { - ScMutableUint64::new(self.id, STATE_MINTED_SUPPLY.get_key_id()) + ScMutableUint64::new(self.proxy.root(STATE_MINTED_SUPPLY)) } } diff --git a/contracts/wasm/testcore/src/testcore.rs b/contracts/wasm/testcore/src/testcore.rs index 645f8fd803..0f97c9fee0 100644 --- a/contracts/wasm/testcore/src/testcore.rs +++ b/contracts/wasm/testcore/src/testcore.rs @@ -33,11 +33,12 @@ pub fn func_call_on_chain(ctx: &ScFuncContext, f: &CallOnChainContext) { counter.set_value(counter.value() + 1); - let parms = ScMutableMap::new(); - parms.get_int64(PARAM_INT_VALUE).set_value(param_int); + let parms = ScDict::new(&[]); + let key = string_to_bytes(PARAM_INT_VALUE); + parms.set(&key, &int64_to_bytes(param_int)); let ret = ctx.call(hname_contract, hname_ep, Some(parms), None); - let ret_val = ret.get_int64(RESULT_INT_VALUE); - f.results.int_value().set_value(ret_val.value()); + let ret_val = int64_from_bytes(&ret.get(&key)); + f.results.int_value().set_value(ret_val); } pub fn func_check_context_from_full_ep(ctx: &ScFuncContext, f: &CheckContextFromFullEPContext) { @@ -55,8 +56,8 @@ pub fn func_do_nothing(ctx: &ScFuncContext, _f: &DoNothingContext) { pub fn func_get_minted_supply(ctx: &ScFuncContext, f: &GetMintedSupplyContext) { let minted = ctx.minted(); let minted_colors = minted.colors(); - ctx.require(minted_colors.length() == 1, "test only supports one minted color"); - let color = minted_colors.get_color(0).value(); + ctx.require(minted_colors.len() == 1, "test only supports one minted color"); + let color = minted_colors.get(0).unwrap(); let amount = minted.balance(&color); f.results.minted_supply().set_value(amount); f.results.minted_color().set_value(&color); @@ -80,7 +81,7 @@ pub fn func_pass_types_full(ctx: &ScFuncContext, f: &PassTypesFullContext) { ctx.require(f.params.int64_zero().value() == 0, "int64-0 wrong"); ctx.require(f.params.string().value() == PARAM_STRING, "string wrong"); ctx.require(f.params.string_zero().value() == "", "string-0 wrong"); - ctx.require(f.params.hname().value() == ScHname::new(PARAM_HNAME), "Hname wrong"); + ctx.require(f.params.hname().value() == ctx.utility().hash_name(PARAM_HNAME), "Hname wrong"); ctx.require(f.params.hname_zero().value() == ScHname(0), "Hname-0 wrong"); } @@ -110,9 +111,9 @@ pub fn func_set_int(_ctx: &ScFuncContext, f: &SetIntContext) { pub fn func_spawn(ctx: &ScFuncContext, f: &SpawnContext) { let spawn_name = SC_NAME.to_string() + "_spawned"; let spawn_descr = "spawned contract description"; - ctx.deploy(&f.params.prog_hash().value(), &spawn_name, spawn_descr, None); + ctx.deploy_contract(&f.params.prog_hash().value(), &spawn_name, spawn_descr, None); - let spawn_hname = ScHname::new(&spawn_name); + let spawn_hname = ctx.utility().hash_name(&spawn_name); for _i in 0..5 { ctx.call(spawn_hname, HFUNC_INC_COUNTER, None, None); } @@ -141,7 +142,7 @@ pub fn func_test_chain_owner_id_full(ctx: &ScFuncContext, f: &TestChainOwnerIDFu pub fn func_test_event_log_deploy(ctx: &ScFuncContext, _f: &TestEventLogDeployContext) { // deploy the same contract with another name let program_hash = ctx.utility().hash_blake2b("testcore".as_bytes()); - ctx.deploy(&program_hash, CONTRACT_NAME_DEPLOYED, "test contract deploy log", None); + ctx.deploy_contract(&program_hash, CONTRACT_NAME_DEPLOYED, "test contract deploy log", None); } pub fn func_test_event_log_event_data(ctx: &ScFuncContext, _f: &TestEventLogEventDataContext) { @@ -214,7 +215,7 @@ pub fn view_pass_types_view(ctx: &ScViewContext, f: &PassTypesViewContext) { ctx.require(f.params.int64_zero().value() == 0, "int64-0 wrong"); ctx.require(f.params.string().value() == PARAM_STRING, "string wrong"); ctx.require(f.params.string_zero().value() == "", "string-0 wrong"); - ctx.require(f.params.hname().value() == ScHname::new(PARAM_HNAME), "Hname wrong"); + ctx.require(f.params.hname().value() == ctx.utility().hash_name(PARAM_HNAME), "Hname wrong"); ctx.require(f.params.hname_zero().value() == ScHname(0), "Hname-0 wrong"); } diff --git a/contracts/wasm/testcore/test/testcore_bg.wasm b/contracts/wasm/testcore/test/testcore_bg.wasm index 3409520077719e2851c41081681f8c41eb1107d1..1d9e0158738519f1b11cdc944ad4e5f29a2e0009 100644 GIT binary patch literal 84539 zcmeFa51b`cdFNeq>fYPkbGxCyQ6~(Mx;K+e6JecwLl~C0n?AD&jA&pJH%qelL$dKz zyNxo#1T|5nkx_{vju90UBOpdph-gqrg3>A~D(EC35tSq(l7wX0I5BES7Uli^p668E zy4^j0fXSM?pE%O@RMn|-p7WgN|9Q@->=(}c{EhkJ&(3#bXNMjBC*N^)v17-M z^po+7Vuw3C?&^nM?wx;jrgzTI{8_5QCGGIAXEmvs@kAHr>phw|-vZ_#VJDlI$V15Te4;m#PvlhX^?IFNXQI=Y&O_5VUA&}YGaozTnkK(9b~xEfMhGc%nc z>t=nP`kiczKMG-rCZ=d8E2ikd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t}&!u<2w)@1~qT+;3ZS{NpSlaf(!y7*I zhph+A2`A)ATd#g|t~cKtHWVxGTru>YjRU3i`!5@M-=wCq8x9z{a_e#7LM(YTL}EErRvFB&uH2=4D-c?1B%6lu(^2H&_jnb zZY%6n94BJ=T#i$_q^FKPq+&j!Z17fo(&w|em;OngPvc&`Ppy5jYQ*zup3msNSZ49* zvQ5k`KD}>Uw;UaN$gE`xzn!~j!?}ZfW+9)8`B68vY&)gqT$YQx>+&nS*X^_2o4Eh> z=}pnD>HmIYbj0Cp+mGn`=!zqQ+jbo}{l9n3^q$?m;HEvh7W~EUYWEv&ZlBTI)$#Fh zKU+9^a?7H&X$gH|xyZ{=H`s@F{wvv-<)6{o~7R`&Rt!Vo(SIKX>}NgT`PApDA60u*mWE%tC*95b~){p7S*DCk6W< zN@&fnPO13F$E4226~<>gpz3c9b3ub&2%lj2Kw8vzL8;If_-zx8&b9HJ_gfp9_-;B4!i7`< zM!2{X1UH0!vtQJ7VepN`e%|xH*5ZY4^H)S(VNKxW{KhCaH9+eF`vF1Te@`%FVzd8} z(gEdJVH;};f_=Vvd##$QA$or+2^OoTJ1~|_@HxvR3{&qhs?Q7Wd{r&uL#W4T1 zl9sT)Fv;$yl^^^o@D#XC4bCj7gtx7&wmW1S^In4=Ji}f?1OBzlmGh&<)`IO$AqZ!I zWUmMs{L}UeiW==73QPc=p)O7313&7^^N-HGQunMgmoJrq;`H40yos5cTk^;G`{n)d zj55JS$U~tyueh%0tr*(von(l2-@^cE>dQDWVBAKy!^~{wQhk3>FR~ql~-X12|pIj8Ng!i8Pr tR}B=}X3beRtF1{9_n9kk1>>> DO NOT CHANGE THIS FILE! <<<< -// Change the json schema instead - - -export const IdxParamAddress = 0; -export const IdxParamAgentID = 1; -export const IdxParamCaller = 2; -export const IdxParamChainID = 3; -export const IdxParamChainOwnerID = 4; -export const IdxParamContractCreator = 5; -export const IdxParamContractID = 6; -export const IdxParamCounter = 7; -export const IdxParamFail = 8; -export const IdxParamHash = 9; -export const IdxParamHname = 10; -export const IdxParamHnameContract = 11; -export const IdxParamHnameEP = 12; -export const IdxParamHnameZero = 13; -export const IdxParamInt64 = 14; -export const IdxParamInt64Zero = 15; -export const IdxParamIntValue = 16; -export const IdxParamName = 17; -export const IdxParamProgHash = 18; -export const IdxParamString = 19; -export const IdxParamStringZero = 20; -export const IdxParamVarName = 21; diff --git a/contracts/wasm/testwasmlib/go/testwasmlib/keys.go b/contracts/wasm/testwasmlib/go/testwasmlib/keys.go deleted file mode 100644 index 9a54ee6328..0000000000 --- a/contracts/wasm/testwasmlib/go/testwasmlib/keys.go +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright 2020 IOTA Stiftung -// SPDX-License-Identifier: Apache-2.0 - -// (Re-)generated by schema tool -// >>>> DO NOT CHANGE THIS FILE! <<<< -// Change the json schema instead - -package testwasmlib diff --git a/contracts/wasm/testwasmlib/src/contract.rs b/contracts/wasm/testwasmlib/src/contract.rs index b08cd1741d..671b54ff84 100644 --- a/contracts/wasm/testwasmlib/src/contract.rs +++ b/contracts/wasm/testwasmlib/src/contract.rs @@ -7,8 +7,6 @@ #![allow(dead_code)] -use std::ptr; - use wasmlib::*; use crate::consts::*; @@ -98,140 +96,145 @@ pub struct ScFuncs { } impl ScFuncs { - pub fn array_append(_ctx: & dyn ScFuncCallContext) -> ArrayAppendCall { + pub fn array_append(_ctx: &dyn ScFuncCallContext) -> ArrayAppendCall { let mut f = ArrayAppendCall { func: ScFunc::new(HSC_NAME, HFUNC_ARRAY_APPEND), - params: MutableArrayAppendParams { id: 0 }, + params: MutableArrayAppendParams { proxy: Proxy::nil() }, }; - f.func.set_ptrs(&mut f.params.id, ptr::null_mut()); + ScFunc::link_params(&mut f.params.proxy, &f.func); f } - pub fn array_clear(_ctx: & dyn ScFuncCallContext) -> ArrayClearCall { + pub fn array_clear(_ctx: &dyn ScFuncCallContext) -> ArrayClearCall { let mut f = ArrayClearCall { func: ScFunc::new(HSC_NAME, HFUNC_ARRAY_CLEAR), - params: MutableArrayClearParams { id: 0 }, + params: MutableArrayClearParams { proxy: Proxy::nil() }, }; - f.func.set_ptrs(&mut f.params.id, ptr::null_mut()); + ScFunc::link_params(&mut f.params.proxy, &f.func); f } - pub fn array_set(_ctx: & dyn ScFuncCallContext) -> ArraySetCall { + pub fn array_set(_ctx: &dyn ScFuncCallContext) -> ArraySetCall { let mut f = ArraySetCall { func: ScFunc::new(HSC_NAME, HFUNC_ARRAY_SET), - params: MutableArraySetParams { id: 0 }, + params: MutableArraySetParams { proxy: Proxy::nil() }, }; - f.func.set_ptrs(&mut f.params.id, ptr::null_mut()); + ScFunc::link_params(&mut f.params.proxy, &f.func); f } - pub fn map_clear(_ctx: & dyn ScFuncCallContext) -> MapClearCall { + pub fn map_clear(_ctx: &dyn ScFuncCallContext) -> MapClearCall { let mut f = MapClearCall { func: ScFunc::new(HSC_NAME, HFUNC_MAP_CLEAR), - params: MutableMapClearParams { id: 0 }, + params: MutableMapClearParams { proxy: Proxy::nil() }, }; - f.func.set_ptrs(&mut f.params.id, ptr::null_mut()); + ScFunc::link_params(&mut f.params.proxy, &f.func); f } - pub fn map_set(_ctx: & dyn ScFuncCallContext) -> MapSetCall { + pub fn map_set(_ctx: &dyn ScFuncCallContext) -> MapSetCall { let mut f = MapSetCall { func: ScFunc::new(HSC_NAME, HFUNC_MAP_SET), - params: MutableMapSetParams { id: 0 }, + params: MutableMapSetParams { proxy: Proxy::nil() }, }; - f.func.set_ptrs(&mut f.params.id, ptr::null_mut()); + ScFunc::link_params(&mut f.params.proxy, &f.func); f } - pub fn param_types(_ctx: & dyn ScFuncCallContext) -> ParamTypesCall { + pub fn param_types(_ctx: &dyn ScFuncCallContext) -> ParamTypesCall { let mut f = ParamTypesCall { func: ScFunc::new(HSC_NAME, HFUNC_PARAM_TYPES), - params: MutableParamTypesParams { id: 0 }, + params: MutableParamTypesParams { proxy: Proxy::nil() }, }; - f.func.set_ptrs(&mut f.params.id, ptr::null_mut()); + ScFunc::link_params(&mut f.params.proxy, &f.func); f } - pub fn random(_ctx: & dyn ScFuncCallContext) -> RandomCall { + pub fn random(_ctx: &dyn ScFuncCallContext) -> RandomCall { RandomCall { func: ScFunc::new(HSC_NAME, HFUNC_RANDOM), } } - pub fn trigger_event(_ctx: & dyn ScFuncCallContext) -> TriggerEventCall { + pub fn trigger_event(_ctx: &dyn ScFuncCallContext) -> TriggerEventCall { let mut f = TriggerEventCall { func: ScFunc::new(HSC_NAME, HFUNC_TRIGGER_EVENT), - params: MutableTriggerEventParams { id: 0 }, + params: MutableTriggerEventParams { proxy: Proxy::nil() }, }; - f.func.set_ptrs(&mut f.params.id, ptr::null_mut()); + ScFunc::link_params(&mut f.params.proxy, &f.func); f } - pub fn array_length(_ctx: & dyn ScViewCallContext) -> ArrayLengthCall { + pub fn array_length(_ctx: &dyn ScViewCallContext) -> ArrayLengthCall { let mut f = ArrayLengthCall { func: ScView::new(HSC_NAME, HVIEW_ARRAY_LENGTH), - params: MutableArrayLengthParams { id: 0 }, - results: ImmutableArrayLengthResults { id: 0 }, + params: MutableArrayLengthParams { proxy: Proxy::nil() }, + results: ImmutableArrayLengthResults { proxy: Proxy::nil() }, }; - f.func.set_ptrs(&mut f.params.id, &mut f.results.id); + ScView::link_params(&mut f.params.proxy, &f.func); + ScView::link_results(&mut f.results.proxy, &f.func); f } - pub fn array_value(_ctx: & dyn ScViewCallContext) -> ArrayValueCall { + pub fn array_value(_ctx: &dyn ScViewCallContext) -> ArrayValueCall { let mut f = ArrayValueCall { func: ScView::new(HSC_NAME, HVIEW_ARRAY_VALUE), - params: MutableArrayValueParams { id: 0 }, - results: ImmutableArrayValueResults { id: 0 }, + params: MutableArrayValueParams { proxy: Proxy::nil() }, + results: ImmutableArrayValueResults { proxy: Proxy::nil() }, }; - f.func.set_ptrs(&mut f.params.id, &mut f.results.id); + ScView::link_params(&mut f.params.proxy, &f.func); + ScView::link_results(&mut f.results.proxy, &f.func); f } - pub fn block_record(_ctx: & dyn ScViewCallContext) -> BlockRecordCall { + pub fn block_record(_ctx: &dyn ScViewCallContext) -> BlockRecordCall { let mut f = BlockRecordCall { func: ScView::new(HSC_NAME, HVIEW_BLOCK_RECORD), - params: MutableBlockRecordParams { id: 0 }, - results: ImmutableBlockRecordResults { id: 0 }, + params: MutableBlockRecordParams { proxy: Proxy::nil() }, + results: ImmutableBlockRecordResults { proxy: Proxy::nil() }, }; - f.func.set_ptrs(&mut f.params.id, &mut f.results.id); + ScView::link_params(&mut f.params.proxy, &f.func); + ScView::link_results(&mut f.results.proxy, &f.func); f } - pub fn block_records(_ctx: & dyn ScViewCallContext) -> BlockRecordsCall { + pub fn block_records(_ctx: &dyn ScViewCallContext) -> BlockRecordsCall { let mut f = BlockRecordsCall { func: ScView::new(HSC_NAME, HVIEW_BLOCK_RECORDS), - params: MutableBlockRecordsParams { id: 0 }, - results: ImmutableBlockRecordsResults { id: 0 }, + params: MutableBlockRecordsParams { proxy: Proxy::nil() }, + results: ImmutableBlockRecordsResults { proxy: Proxy::nil() }, }; - f.func.set_ptrs(&mut f.params.id, &mut f.results.id); + ScView::link_params(&mut f.params.proxy, &f.func); + ScView::link_results(&mut f.results.proxy, &f.func); f } - pub fn get_random(_ctx: & dyn ScViewCallContext) -> GetRandomCall { + pub fn get_random(_ctx: &dyn ScViewCallContext) -> GetRandomCall { let mut f = GetRandomCall { func: ScView::new(HSC_NAME, HVIEW_GET_RANDOM), - results: ImmutableGetRandomResults { id: 0 }, + results: ImmutableGetRandomResults { proxy: Proxy::nil() }, }; - f.func.set_ptrs(ptr::null_mut(), &mut f.results.id); + ScView::link_results(&mut f.results.proxy, &f.func); f } - pub fn iota_balance(_ctx: & dyn ScViewCallContext) -> IotaBalanceCall { + pub fn iota_balance(_ctx: &dyn ScViewCallContext) -> IotaBalanceCall { let mut f = IotaBalanceCall { func: ScView::new(HSC_NAME, HVIEW_IOTA_BALANCE), - results: ImmutableIotaBalanceResults { id: 0 }, + results: ImmutableIotaBalanceResults { proxy: Proxy::nil() }, }; - f.func.set_ptrs(ptr::null_mut(), &mut f.results.id); + ScView::link_results(&mut f.results.proxy, &f.func); f } - pub fn map_value(_ctx: & dyn ScViewCallContext) -> MapValueCall { + pub fn map_value(_ctx: &dyn ScViewCallContext) -> MapValueCall { let mut f = MapValueCall { func: ScView::new(HSC_NAME, HVIEW_MAP_VALUE), - params: MutableMapValueParams { id: 0 }, - results: ImmutableMapValueResults { id: 0 }, + params: MutableMapValueParams { proxy: Proxy::nil() }, + results: ImmutableMapValueResults { proxy: Proxy::nil() }, }; - f.func.set_ptrs(&mut f.params.id, &mut f.results.id); + ScView::link_params(&mut f.params.proxy, &f.func); + ScView::link_results(&mut f.results.proxy, &f.func); f } } diff --git a/contracts/wasm/testwasmlib/src/events.rs b/contracts/wasm/testwasmlib/src/events.rs index c190ba68d1..6e42899bbf 100644 --- a/contracts/wasm/testwasmlib/src/events.rs +++ b/contracts/wasm/testwasmlib/src/events.rs @@ -6,6 +6,7 @@ // Change the json schema instead #![allow(dead_code)] +#![allow(unused_mut)] use wasmlib::*; @@ -15,9 +16,9 @@ pub struct TestWasmLibEvents { impl TestWasmLibEvents { pub fn test(&self, address: &ScAddress, name: &str) { - let mut encoder = EventEncoder::new("testwasmlib.test"); - encoder.address(&address); - encoder.string(&name); - encoder.emit(); + let mut evt = EventEncoder::new("testwasmlib.test"); + evt.encode(&address_to_string(&address)); + evt.encode(&string_to_string(&name)); + evt.emit(); } } diff --git a/contracts/wasm/testwasmlib/src/keys.rs b/contracts/wasm/testwasmlib/src/keys.rs deleted file mode 100644 index 7aeff86e99..0000000000 --- a/contracts/wasm/testwasmlib/src/keys.rs +++ /dev/null @@ -1,96 +0,0 @@ -// Copyright 2020 IOTA Stiftung -// SPDX-License-Identifier: Apache-2.0 - -// (Re-)generated by schema tool -// >>>> DO NOT CHANGE THIS FILE! <<<< -// Change the json schema instead - -#![allow(dead_code)] - -use wasmlib::*; - -use crate::*; - -pub(crate) const IDX_PARAM_ADDRESS : usize = 0; -pub(crate) const IDX_PARAM_AGENT_ID : usize = 1; -pub(crate) const IDX_PARAM_BLOCK_INDEX : usize = 2; -pub(crate) const IDX_PARAM_BOOL : usize = 3; -pub(crate) const IDX_PARAM_BYTES : usize = 4; -pub(crate) const IDX_PARAM_CHAIN_ID : usize = 5; -pub(crate) const IDX_PARAM_COLOR : usize = 6; -pub(crate) const IDX_PARAM_HASH : usize = 7; -pub(crate) const IDX_PARAM_HNAME : usize = 8; -pub(crate) const IDX_PARAM_INDEX : usize = 9; -pub(crate) const IDX_PARAM_INT16 : usize = 10; -pub(crate) const IDX_PARAM_INT32 : usize = 11; -pub(crate) const IDX_PARAM_INT64 : usize = 12; -pub(crate) const IDX_PARAM_INT8 : usize = 13; -pub(crate) const IDX_PARAM_KEY : usize = 14; -pub(crate) const IDX_PARAM_NAME : usize = 15; -pub(crate) const IDX_PARAM_PARAM : usize = 16; -pub(crate) const IDX_PARAM_RECORD_INDEX : usize = 17; -pub(crate) const IDX_PARAM_REQUEST_ID : usize = 18; -pub(crate) const IDX_PARAM_STRING : usize = 19; -pub(crate) const IDX_PARAM_UINT16 : usize = 20; -pub(crate) const IDX_PARAM_UINT32 : usize = 21; -pub(crate) const IDX_PARAM_UINT64 : usize = 22; -pub(crate) const IDX_PARAM_UINT8 : usize = 23; -pub(crate) const IDX_PARAM_VALUE : usize = 24; - -pub(crate) const IDX_RESULT_COUNT : usize = 25; -pub(crate) const IDX_RESULT_IOTAS : usize = 26; -pub(crate) const IDX_RESULT_LENGTH : usize = 27; -pub(crate) const IDX_RESULT_RANDOM : usize = 28; -pub(crate) const IDX_RESULT_RECORD : usize = 29; -pub(crate) const IDX_RESULT_VALUE : usize = 30; - -pub(crate) const IDX_STATE_ARRAYS : usize = 31; -pub(crate) const IDX_STATE_MAPS : usize = 32; -pub(crate) const IDX_STATE_RANDOM : usize = 33; - -pub const KEY_MAP_LEN: usize = 34; - -pub const KEY_MAP: [&str; KEY_MAP_LEN] = [ - PARAM_ADDRESS, - PARAM_AGENT_ID, - PARAM_BLOCK_INDEX, - PARAM_BOOL, - PARAM_BYTES, - PARAM_CHAIN_ID, - PARAM_COLOR, - PARAM_HASH, - PARAM_HNAME, - PARAM_INDEX, - PARAM_INT16, - PARAM_INT32, - PARAM_INT64, - PARAM_INT8, - PARAM_KEY, - PARAM_NAME, - PARAM_PARAM, - PARAM_RECORD_INDEX, - PARAM_REQUEST_ID, - PARAM_STRING, - PARAM_UINT16, - PARAM_UINT32, - PARAM_UINT64, - PARAM_UINT8, - PARAM_VALUE, - RESULT_COUNT, - RESULT_IOTAS, - RESULT_LENGTH, - RESULT_RANDOM, - RESULT_RECORD, - RESULT_VALUE, - STATE_ARRAYS, - STATE_MAPS, - STATE_RANDOM, -]; - -pub static mut IDX_MAP: [Key32; KEY_MAP_LEN] = [Key32(0); KEY_MAP_LEN]; - -pub fn idx_map(idx: usize) -> Key32 { - unsafe { - IDX_MAP[idx] - } -} diff --git a/contracts/wasm/testwasmlib/src/lib.rs b/contracts/wasm/testwasmlib/src/lib.rs index 9b9fb445ba..59ec474fb4 100644 --- a/contracts/wasm/testwasmlib/src/lib.rs +++ b/contracts/wasm/testwasmlib/src/lib.rs @@ -10,19 +10,17 @@ use testwasmlib::*; use wasmlib::*; -use wasmlib::host::*; use crate::consts::*; use crate::events::*; -use crate::keys::*; use crate::params::*; use crate::results::*; use crate::state::*; +use crate::typedefs::*; mod consts; mod contract; mod events; -mod keys; mod params; mod results; mod state; @@ -47,12 +45,6 @@ fn on_load() { exports.add_view(VIEW_GET_RANDOM, view_get_random_thunk); exports.add_view(VIEW_IOTA_BALANCE, view_iota_balance_thunk); exports.add_view(VIEW_MAP_VALUE, view_map_value_thunk); - - unsafe { - for i in 0..KEY_MAP_LEN { - IDX_MAP[i] = get_key_id_from_string(KEY_MAP[i]); - } - } } pub struct ArrayAppendContext { @@ -65,12 +57,8 @@ fn func_array_append_thunk(ctx: &ScFuncContext) { ctx.log("testwasmlib.funcArrayAppend"); let f = ArrayAppendContext { events: TestWasmLibEvents {}, - params: ImmutableArrayAppendParams { - id: OBJ_ID_PARAMS, - }, - state: MutableTestWasmLibState { - id: OBJ_ID_STATE, - }, + params: ImmutableArrayAppendParams { proxy: params_proxy() }, + state: MutableTestWasmLibState { proxy: state_proxy() }, }; ctx.require(f.params.name().exists(), "missing mandatory name"); ctx.require(f.params.value().exists(), "missing mandatory value"); @@ -88,12 +76,8 @@ fn func_array_clear_thunk(ctx: &ScFuncContext) { ctx.log("testwasmlib.funcArrayClear"); let f = ArrayClearContext { events: TestWasmLibEvents {}, - params: ImmutableArrayClearParams { - id: OBJ_ID_PARAMS, - }, - state: MutableTestWasmLibState { - id: OBJ_ID_STATE, - }, + params: ImmutableArrayClearParams { proxy: params_proxy() }, + state: MutableTestWasmLibState { proxy: state_proxy() }, }; ctx.require(f.params.name().exists(), "missing mandatory name"); func_array_clear(ctx, &f); @@ -110,12 +94,8 @@ fn func_array_set_thunk(ctx: &ScFuncContext) { ctx.log("testwasmlib.funcArraySet"); let f = ArraySetContext { events: TestWasmLibEvents {}, - params: ImmutableArraySetParams { - id: OBJ_ID_PARAMS, - }, - state: MutableTestWasmLibState { - id: OBJ_ID_STATE, - }, + params: ImmutableArraySetParams { proxy: params_proxy() }, + state: MutableTestWasmLibState { proxy: state_proxy() }, }; ctx.require(f.params.index().exists(), "missing mandatory index"); ctx.require(f.params.name().exists(), "missing mandatory name"); @@ -134,12 +114,8 @@ fn func_map_clear_thunk(ctx: &ScFuncContext) { ctx.log("testwasmlib.funcMapClear"); let f = MapClearContext { events: TestWasmLibEvents {}, - params: ImmutableMapClearParams { - id: OBJ_ID_PARAMS, - }, - state: MutableTestWasmLibState { - id: OBJ_ID_STATE, - }, + params: ImmutableMapClearParams { proxy: params_proxy() }, + state: MutableTestWasmLibState { proxy: state_proxy() }, }; ctx.require(f.params.name().exists(), "missing mandatory name"); func_map_clear(ctx, &f); @@ -156,12 +132,8 @@ fn func_map_set_thunk(ctx: &ScFuncContext) { ctx.log("testwasmlib.funcMapSet"); let f = MapSetContext { events: TestWasmLibEvents {}, - params: ImmutableMapSetParams { - id: OBJ_ID_PARAMS, - }, - state: MutableTestWasmLibState { - id: OBJ_ID_STATE, - }, + params: ImmutableMapSetParams { proxy: params_proxy() }, + state: MutableTestWasmLibState { proxy: state_proxy() }, }; ctx.require(f.params.key().exists(), "missing mandatory key"); ctx.require(f.params.name().exists(), "missing mandatory name"); @@ -180,12 +152,8 @@ fn func_param_types_thunk(ctx: &ScFuncContext) { ctx.log("testwasmlib.funcParamTypes"); let f = ParamTypesContext { events: TestWasmLibEvents {}, - params: ImmutableParamTypesParams { - id: OBJ_ID_PARAMS, - }, - state: MutableTestWasmLibState { - id: OBJ_ID_STATE, - }, + params: ImmutableParamTypesParams { proxy: params_proxy() }, + state: MutableTestWasmLibState { proxy: state_proxy() }, }; func_param_types(ctx, &f); ctx.log("testwasmlib.funcParamTypes ok"); @@ -200,9 +168,7 @@ fn func_random_thunk(ctx: &ScFuncContext) { ctx.log("testwasmlib.funcRandom"); let f = RandomContext { events: TestWasmLibEvents {}, - state: MutableTestWasmLibState { - id: OBJ_ID_STATE, - }, + state: MutableTestWasmLibState { proxy: state_proxy() }, }; func_random(ctx, &f); ctx.log("testwasmlib.funcRandom ok"); @@ -218,12 +184,8 @@ fn func_trigger_event_thunk(ctx: &ScFuncContext) { ctx.log("testwasmlib.funcTriggerEvent"); let f = TriggerEventContext { events: TestWasmLibEvents {}, - params: ImmutableTriggerEventParams { - id: OBJ_ID_PARAMS, - }, - state: MutableTestWasmLibState { - id: OBJ_ID_STATE, - }, + params: ImmutableTriggerEventParams { proxy: params_proxy() }, + state: MutableTestWasmLibState { proxy: state_proxy() }, }; ctx.require(f.params.address().exists(), "missing mandatory address"); ctx.require(f.params.name().exists(), "missing mandatory name"); @@ -240,18 +202,13 @@ pub struct ArrayLengthContext { fn view_array_length_thunk(ctx: &ScViewContext) { ctx.log("testwasmlib.viewArrayLength"); let f = ArrayLengthContext { - params: ImmutableArrayLengthParams { - id: OBJ_ID_PARAMS, - }, - results: MutableArrayLengthResults { - id: OBJ_ID_RESULTS, - }, - state: ImmutableTestWasmLibState { - id: OBJ_ID_STATE, - }, + params: ImmutableArrayLengthParams { proxy: params_proxy() }, + results: MutableArrayLengthResults { proxy: results_proxy() }, + state: ImmutableTestWasmLibState { proxy: state_proxy() }, }; ctx.require(f.params.name().exists(), "missing mandatory name"); view_array_length(ctx, &f); + ctx.results(&f.results.proxy.kv_store); ctx.log("testwasmlib.viewArrayLength ok"); } @@ -264,19 +221,14 @@ pub struct ArrayValueContext { fn view_array_value_thunk(ctx: &ScViewContext) { ctx.log("testwasmlib.viewArrayValue"); let f = ArrayValueContext { - params: ImmutableArrayValueParams { - id: OBJ_ID_PARAMS, - }, - results: MutableArrayValueResults { - id: OBJ_ID_RESULTS, - }, - state: ImmutableTestWasmLibState { - id: OBJ_ID_STATE, - }, + params: ImmutableArrayValueParams { proxy: params_proxy() }, + results: MutableArrayValueResults { proxy: results_proxy() }, + state: ImmutableTestWasmLibState { proxy: state_proxy() }, }; ctx.require(f.params.index().exists(), "missing mandatory index"); ctx.require(f.params.name().exists(), "missing mandatory name"); view_array_value(ctx, &f); + ctx.results(&f.results.proxy.kv_store); ctx.log("testwasmlib.viewArrayValue ok"); } @@ -289,19 +241,14 @@ pub struct BlockRecordContext { fn view_block_record_thunk(ctx: &ScViewContext) { ctx.log("testwasmlib.viewBlockRecord"); let f = BlockRecordContext { - params: ImmutableBlockRecordParams { - id: OBJ_ID_PARAMS, - }, - results: MutableBlockRecordResults { - id: OBJ_ID_RESULTS, - }, - state: ImmutableTestWasmLibState { - id: OBJ_ID_STATE, - }, + params: ImmutableBlockRecordParams { proxy: params_proxy() }, + results: MutableBlockRecordResults { proxy: results_proxy() }, + state: ImmutableTestWasmLibState { proxy: state_proxy() }, }; ctx.require(f.params.block_index().exists(), "missing mandatory blockIndex"); ctx.require(f.params.record_index().exists(), "missing mandatory recordIndex"); view_block_record(ctx, &f); + ctx.results(&f.results.proxy.kv_store); ctx.log("testwasmlib.viewBlockRecord ok"); } @@ -314,18 +261,13 @@ pub struct BlockRecordsContext { fn view_block_records_thunk(ctx: &ScViewContext) { ctx.log("testwasmlib.viewBlockRecords"); let f = BlockRecordsContext { - params: ImmutableBlockRecordsParams { - id: OBJ_ID_PARAMS, - }, - results: MutableBlockRecordsResults { - id: OBJ_ID_RESULTS, - }, - state: ImmutableTestWasmLibState { - id: OBJ_ID_STATE, - }, + params: ImmutableBlockRecordsParams { proxy: params_proxy() }, + results: MutableBlockRecordsResults { proxy: results_proxy() }, + state: ImmutableTestWasmLibState { proxy: state_proxy() }, }; ctx.require(f.params.block_index().exists(), "missing mandatory blockIndex"); view_block_records(ctx, &f); + ctx.results(&f.results.proxy.kv_store); ctx.log("testwasmlib.viewBlockRecords ok"); } @@ -337,14 +279,11 @@ pub struct GetRandomContext { fn view_get_random_thunk(ctx: &ScViewContext) { ctx.log("testwasmlib.viewGetRandom"); let f = GetRandomContext { - results: MutableGetRandomResults { - id: OBJ_ID_RESULTS, - }, - state: ImmutableTestWasmLibState { - id: OBJ_ID_STATE, - }, + results: MutableGetRandomResults { proxy: results_proxy() }, + state: ImmutableTestWasmLibState { proxy: state_proxy() }, }; view_get_random(ctx, &f); + ctx.results(&f.results.proxy.kv_store); ctx.log("testwasmlib.viewGetRandom ok"); } @@ -356,14 +295,11 @@ pub struct IotaBalanceContext { fn view_iota_balance_thunk(ctx: &ScViewContext) { ctx.log("testwasmlib.viewIotaBalance"); let f = IotaBalanceContext { - results: MutableIotaBalanceResults { - id: OBJ_ID_RESULTS, - }, - state: ImmutableTestWasmLibState { - id: OBJ_ID_STATE, - }, + results: MutableIotaBalanceResults { proxy: results_proxy() }, + state: ImmutableTestWasmLibState { proxy: state_proxy() }, }; view_iota_balance(ctx, &f); + ctx.results(&f.results.proxy.kv_store); ctx.log("testwasmlib.viewIotaBalance ok"); } @@ -376,18 +312,13 @@ pub struct MapValueContext { fn view_map_value_thunk(ctx: &ScViewContext) { ctx.log("testwasmlib.viewMapValue"); let f = MapValueContext { - params: ImmutableMapValueParams { - id: OBJ_ID_PARAMS, - }, - results: MutableMapValueResults { - id: OBJ_ID_RESULTS, - }, - state: ImmutableTestWasmLibState { - id: OBJ_ID_STATE, - }, + params: ImmutableMapValueParams { proxy: params_proxy() }, + results: MutableMapValueResults { proxy: results_proxy() }, + state: ImmutableTestWasmLibState { proxy: state_proxy() }, }; ctx.require(f.params.key().exists(), "missing mandatory key"); ctx.require(f.params.name().exists(), "missing mandatory name"); view_map_value(ctx, &f); + ctx.results(&f.results.proxy.kv_store); ctx.log("testwasmlib.viewMapValue ok"); } diff --git a/contracts/wasm/testwasmlib/src/params.rs b/contracts/wasm/testwasmlib/src/params.rs index 855e99b35f..8b95fc56af 100644 --- a/contracts/wasm/testwasmlib/src/params.rs +++ b/contracts/wasm/testwasmlib/src/params.rs @@ -9,514 +9,510 @@ #![allow(unused_imports)] use wasmlib::*; -use wasmlib::host::*; - use crate::*; -use crate::keys::*; -use crate::typedefs::*; -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableArrayAppendParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableArrayAppendParams { pub fn name(&self) -> ScImmutableString { - ScImmutableString::new(self.id, PARAM_NAME.get_key_id()) + ScImmutableString::new(self.proxy.root(PARAM_NAME)) } pub fn value(&self) -> ScImmutableString { - ScImmutableString::new(self.id, PARAM_VALUE.get_key_id()) + ScImmutableString::new(self.proxy.root(PARAM_VALUE)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableArrayAppendParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableArrayAppendParams { pub fn name(&self) -> ScMutableString { - ScMutableString::new(self.id, PARAM_NAME.get_key_id()) + ScMutableString::new(self.proxy.root(PARAM_NAME)) } pub fn value(&self) -> ScMutableString { - ScMutableString::new(self.id, PARAM_VALUE.get_key_id()) + ScMutableString::new(self.proxy.root(PARAM_VALUE)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableArrayClearParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableArrayClearParams { pub fn name(&self) -> ScImmutableString { - ScImmutableString::new(self.id, PARAM_NAME.get_key_id()) + ScImmutableString::new(self.proxy.root(PARAM_NAME)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableArrayClearParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableArrayClearParams { pub fn name(&self) -> ScMutableString { - ScMutableString::new(self.id, PARAM_NAME.get_key_id()) + ScMutableString::new(self.proxy.root(PARAM_NAME)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableArraySetParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableArraySetParams { pub fn index(&self) -> ScImmutableUint32 { - ScImmutableUint32::new(self.id, PARAM_INDEX.get_key_id()) + ScImmutableUint32::new(self.proxy.root(PARAM_INDEX)) } pub fn name(&self) -> ScImmutableString { - ScImmutableString::new(self.id, PARAM_NAME.get_key_id()) + ScImmutableString::new(self.proxy.root(PARAM_NAME)) } pub fn value(&self) -> ScImmutableString { - ScImmutableString::new(self.id, PARAM_VALUE.get_key_id()) + ScImmutableString::new(self.proxy.root(PARAM_VALUE)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableArraySetParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableArraySetParams { pub fn index(&self) -> ScMutableUint32 { - ScMutableUint32::new(self.id, PARAM_INDEX.get_key_id()) + ScMutableUint32::new(self.proxy.root(PARAM_INDEX)) } pub fn name(&self) -> ScMutableString { - ScMutableString::new(self.id, PARAM_NAME.get_key_id()) + ScMutableString::new(self.proxy.root(PARAM_NAME)) } pub fn value(&self) -> ScMutableString { - ScMutableString::new(self.id, PARAM_VALUE.get_key_id()) + ScMutableString::new(self.proxy.root(PARAM_VALUE)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableMapClearParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableMapClearParams { pub fn name(&self) -> ScImmutableString { - ScImmutableString::new(self.id, PARAM_NAME.get_key_id()) + ScImmutableString::new(self.proxy.root(PARAM_NAME)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableMapClearParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableMapClearParams { pub fn name(&self) -> ScMutableString { - ScMutableString::new(self.id, PARAM_NAME.get_key_id()) + ScMutableString::new(self.proxy.root(PARAM_NAME)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableMapSetParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableMapSetParams { pub fn key(&self) -> ScImmutableString { - ScImmutableString::new(self.id, PARAM_KEY.get_key_id()) + ScImmutableString::new(self.proxy.root(PARAM_KEY)) } pub fn name(&self) -> ScImmutableString { - ScImmutableString::new(self.id, PARAM_NAME.get_key_id()) + ScImmutableString::new(self.proxy.root(PARAM_NAME)) } pub fn value(&self) -> ScImmutableString { - ScImmutableString::new(self.id, PARAM_VALUE.get_key_id()) + ScImmutableString::new(self.proxy.root(PARAM_VALUE)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableMapSetParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableMapSetParams { pub fn key(&self) -> ScMutableString { - ScMutableString::new(self.id, PARAM_KEY.get_key_id()) + ScMutableString::new(self.proxy.root(PARAM_KEY)) } pub fn name(&self) -> ScMutableString { - ScMutableString::new(self.id, PARAM_NAME.get_key_id()) + ScMutableString::new(self.proxy.root(PARAM_NAME)) } pub fn value(&self) -> ScMutableString { - ScMutableString::new(self.id, PARAM_VALUE.get_key_id()) + ScMutableString::new(self.proxy.root(PARAM_VALUE)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MapStringToImmutableBytes { - pub(crate) obj_id: i32, + pub(crate) proxy: Proxy, } impl MapStringToImmutableBytes { pub fn get_bytes(&self, key: &str) -> ScImmutableBytes { - ScImmutableBytes::new(self.obj_id, key.get_key_id()) + ScImmutableBytes::new(self.proxy.key(&string_to_bytes(key))) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableParamTypesParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableParamTypesParams { pub fn address(&self) -> ScImmutableAddress { - ScImmutableAddress::new(self.id, PARAM_ADDRESS.get_key_id()) + ScImmutableAddress::new(self.proxy.root(PARAM_ADDRESS)) } pub fn agent_id(&self) -> ScImmutableAgentID { - ScImmutableAgentID::new(self.id, PARAM_AGENT_ID.get_key_id()) + ScImmutableAgentID::new(self.proxy.root(PARAM_AGENT_ID)) } pub fn bool(&self) -> ScImmutableBool { - ScImmutableBool::new(self.id, PARAM_BOOL.get_key_id()) + ScImmutableBool::new(self.proxy.root(PARAM_BOOL)) } pub fn bytes(&self) -> ScImmutableBytes { - ScImmutableBytes::new(self.id, PARAM_BYTES.get_key_id()) + ScImmutableBytes::new(self.proxy.root(PARAM_BYTES)) } pub fn chain_id(&self) -> ScImmutableChainID { - ScImmutableChainID::new(self.id, PARAM_CHAIN_ID.get_key_id()) + ScImmutableChainID::new(self.proxy.root(PARAM_CHAIN_ID)) } pub fn color(&self) -> ScImmutableColor { - ScImmutableColor::new(self.id, PARAM_COLOR.get_key_id()) + ScImmutableColor::new(self.proxy.root(PARAM_COLOR)) } pub fn hash(&self) -> ScImmutableHash { - ScImmutableHash::new(self.id, PARAM_HASH.get_key_id()) + ScImmutableHash::new(self.proxy.root(PARAM_HASH)) } pub fn hname(&self) -> ScImmutableHname { - ScImmutableHname::new(self.id, PARAM_HNAME.get_key_id()) + ScImmutableHname::new(self.proxy.root(PARAM_HNAME)) } pub fn int16(&self) -> ScImmutableInt16 { - ScImmutableInt16::new(self.id, PARAM_INT16.get_key_id()) + ScImmutableInt16::new(self.proxy.root(PARAM_INT16)) } pub fn int32(&self) -> ScImmutableInt32 { - ScImmutableInt32::new(self.id, PARAM_INT32.get_key_id()) + ScImmutableInt32::new(self.proxy.root(PARAM_INT32)) } pub fn int64(&self) -> ScImmutableInt64 { - ScImmutableInt64::new(self.id, PARAM_INT64.get_key_id()) + ScImmutableInt64::new(self.proxy.root(PARAM_INT64)) } pub fn int8(&self) -> ScImmutableInt8 { - ScImmutableInt8::new(self.id, PARAM_INT8.get_key_id()) + ScImmutableInt8::new(self.proxy.root(PARAM_INT8)) } pub fn param(&self) -> MapStringToImmutableBytes { - MapStringToImmutableBytes { obj_id: self.id } + MapStringToImmutableBytes { proxy: self.proxy.clone() } } pub fn request_id(&self) -> ScImmutableRequestID { - ScImmutableRequestID::new(self.id, PARAM_REQUEST_ID.get_key_id()) + ScImmutableRequestID::new(self.proxy.root(PARAM_REQUEST_ID)) } pub fn string(&self) -> ScImmutableString { - ScImmutableString::new(self.id, PARAM_STRING.get_key_id()) + ScImmutableString::new(self.proxy.root(PARAM_STRING)) } pub fn uint16(&self) -> ScImmutableUint16 { - ScImmutableUint16::new(self.id, PARAM_UINT16.get_key_id()) + ScImmutableUint16::new(self.proxy.root(PARAM_UINT16)) } pub fn uint32(&self) -> ScImmutableUint32 { - ScImmutableUint32::new(self.id, PARAM_UINT32.get_key_id()) + ScImmutableUint32::new(self.proxy.root(PARAM_UINT32)) } pub fn uint64(&self) -> ScImmutableUint64 { - ScImmutableUint64::new(self.id, PARAM_UINT64.get_key_id()) + ScImmutableUint64::new(self.proxy.root(PARAM_UINT64)) } pub fn uint8(&self) -> ScImmutableUint8 { - ScImmutableUint8::new(self.id, PARAM_UINT8.get_key_id()) + ScImmutableUint8::new(self.proxy.root(PARAM_UINT8)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MapStringToMutableBytes { - pub(crate) obj_id: i32, + pub(crate) proxy: Proxy, } impl MapStringToMutableBytes { pub fn clear(&self) { - clear(self.obj_id); + self.proxy.clear_map(); } pub fn get_bytes(&self, key: &str) -> ScMutableBytes { - ScMutableBytes::new(self.obj_id, key.get_key_id()) + ScMutableBytes::new(self.proxy.key(&string_to_bytes(key))) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableParamTypesParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableParamTypesParams { pub fn address(&self) -> ScMutableAddress { - ScMutableAddress::new(self.id, PARAM_ADDRESS.get_key_id()) + ScMutableAddress::new(self.proxy.root(PARAM_ADDRESS)) } pub fn agent_id(&self) -> ScMutableAgentID { - ScMutableAgentID::new(self.id, PARAM_AGENT_ID.get_key_id()) + ScMutableAgentID::new(self.proxy.root(PARAM_AGENT_ID)) } pub fn bool(&self) -> ScMutableBool { - ScMutableBool::new(self.id, PARAM_BOOL.get_key_id()) + ScMutableBool::new(self.proxy.root(PARAM_BOOL)) } pub fn bytes(&self) -> ScMutableBytes { - ScMutableBytes::new(self.id, PARAM_BYTES.get_key_id()) + ScMutableBytes::new(self.proxy.root(PARAM_BYTES)) } pub fn chain_id(&self) -> ScMutableChainID { - ScMutableChainID::new(self.id, PARAM_CHAIN_ID.get_key_id()) + ScMutableChainID::new(self.proxy.root(PARAM_CHAIN_ID)) } pub fn color(&self) -> ScMutableColor { - ScMutableColor::new(self.id, PARAM_COLOR.get_key_id()) + ScMutableColor::new(self.proxy.root(PARAM_COLOR)) } pub fn hash(&self) -> ScMutableHash { - ScMutableHash::new(self.id, PARAM_HASH.get_key_id()) + ScMutableHash::new(self.proxy.root(PARAM_HASH)) } pub fn hname(&self) -> ScMutableHname { - ScMutableHname::new(self.id, PARAM_HNAME.get_key_id()) + ScMutableHname::new(self.proxy.root(PARAM_HNAME)) } pub fn int16(&self) -> ScMutableInt16 { - ScMutableInt16::new(self.id, PARAM_INT16.get_key_id()) + ScMutableInt16::new(self.proxy.root(PARAM_INT16)) } pub fn int32(&self) -> ScMutableInt32 { - ScMutableInt32::new(self.id, PARAM_INT32.get_key_id()) + ScMutableInt32::new(self.proxy.root(PARAM_INT32)) } pub fn int64(&self) -> ScMutableInt64 { - ScMutableInt64::new(self.id, PARAM_INT64.get_key_id()) + ScMutableInt64::new(self.proxy.root(PARAM_INT64)) } pub fn int8(&self) -> ScMutableInt8 { - ScMutableInt8::new(self.id, PARAM_INT8.get_key_id()) + ScMutableInt8::new(self.proxy.root(PARAM_INT8)) } pub fn param(&self) -> MapStringToMutableBytes { - MapStringToMutableBytes { obj_id: self.id } + MapStringToMutableBytes { proxy: self.proxy.clone() } } pub fn request_id(&self) -> ScMutableRequestID { - ScMutableRequestID::new(self.id, PARAM_REQUEST_ID.get_key_id()) + ScMutableRequestID::new(self.proxy.root(PARAM_REQUEST_ID)) } pub fn string(&self) -> ScMutableString { - ScMutableString::new(self.id, PARAM_STRING.get_key_id()) + ScMutableString::new(self.proxy.root(PARAM_STRING)) } pub fn uint16(&self) -> ScMutableUint16 { - ScMutableUint16::new(self.id, PARAM_UINT16.get_key_id()) + ScMutableUint16::new(self.proxy.root(PARAM_UINT16)) } pub fn uint32(&self) -> ScMutableUint32 { - ScMutableUint32::new(self.id, PARAM_UINT32.get_key_id()) + ScMutableUint32::new(self.proxy.root(PARAM_UINT32)) } pub fn uint64(&self) -> ScMutableUint64 { - ScMutableUint64::new(self.id, PARAM_UINT64.get_key_id()) + ScMutableUint64::new(self.proxy.root(PARAM_UINT64)) } pub fn uint8(&self) -> ScMutableUint8 { - ScMutableUint8::new(self.id, PARAM_UINT8.get_key_id()) + ScMutableUint8::new(self.proxy.root(PARAM_UINT8)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableTriggerEventParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableTriggerEventParams { pub fn address(&self) -> ScImmutableAddress { - ScImmutableAddress::new(self.id, PARAM_ADDRESS.get_key_id()) + ScImmutableAddress::new(self.proxy.root(PARAM_ADDRESS)) } pub fn name(&self) -> ScImmutableString { - ScImmutableString::new(self.id, PARAM_NAME.get_key_id()) + ScImmutableString::new(self.proxy.root(PARAM_NAME)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableTriggerEventParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableTriggerEventParams { pub fn address(&self) -> ScMutableAddress { - ScMutableAddress::new(self.id, PARAM_ADDRESS.get_key_id()) + ScMutableAddress::new(self.proxy.root(PARAM_ADDRESS)) } pub fn name(&self) -> ScMutableString { - ScMutableString::new(self.id, PARAM_NAME.get_key_id()) + ScMutableString::new(self.proxy.root(PARAM_NAME)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableArrayLengthParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableArrayLengthParams { pub fn name(&self) -> ScImmutableString { - ScImmutableString::new(self.id, PARAM_NAME.get_key_id()) + ScImmutableString::new(self.proxy.root(PARAM_NAME)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableArrayLengthParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableArrayLengthParams { pub fn name(&self) -> ScMutableString { - ScMutableString::new(self.id, PARAM_NAME.get_key_id()) + ScMutableString::new(self.proxy.root(PARAM_NAME)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableArrayValueParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableArrayValueParams { pub fn index(&self) -> ScImmutableUint32 { - ScImmutableUint32::new(self.id, PARAM_INDEX.get_key_id()) + ScImmutableUint32::new(self.proxy.root(PARAM_INDEX)) } pub fn name(&self) -> ScImmutableString { - ScImmutableString::new(self.id, PARAM_NAME.get_key_id()) + ScImmutableString::new(self.proxy.root(PARAM_NAME)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableArrayValueParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableArrayValueParams { pub fn index(&self) -> ScMutableUint32 { - ScMutableUint32::new(self.id, PARAM_INDEX.get_key_id()) + ScMutableUint32::new(self.proxy.root(PARAM_INDEX)) } pub fn name(&self) -> ScMutableString { - ScMutableString::new(self.id, PARAM_NAME.get_key_id()) + ScMutableString::new(self.proxy.root(PARAM_NAME)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableBlockRecordParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableBlockRecordParams { pub fn block_index(&self) -> ScImmutableUint32 { - ScImmutableUint32::new(self.id, PARAM_BLOCK_INDEX.get_key_id()) + ScImmutableUint32::new(self.proxy.root(PARAM_BLOCK_INDEX)) } pub fn record_index(&self) -> ScImmutableUint32 { - ScImmutableUint32::new(self.id, PARAM_RECORD_INDEX.get_key_id()) + ScImmutableUint32::new(self.proxy.root(PARAM_RECORD_INDEX)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableBlockRecordParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableBlockRecordParams { pub fn block_index(&self) -> ScMutableUint32 { - ScMutableUint32::new(self.id, PARAM_BLOCK_INDEX.get_key_id()) + ScMutableUint32::new(self.proxy.root(PARAM_BLOCK_INDEX)) } pub fn record_index(&self) -> ScMutableUint32 { - ScMutableUint32::new(self.id, PARAM_RECORD_INDEX.get_key_id()) + ScMutableUint32::new(self.proxy.root(PARAM_RECORD_INDEX)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableBlockRecordsParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableBlockRecordsParams { pub fn block_index(&self) -> ScImmutableUint32 { - ScImmutableUint32::new(self.id, PARAM_BLOCK_INDEX.get_key_id()) + ScImmutableUint32::new(self.proxy.root(PARAM_BLOCK_INDEX)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableBlockRecordsParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableBlockRecordsParams { pub fn block_index(&self) -> ScMutableUint32 { - ScMutableUint32::new(self.id, PARAM_BLOCK_INDEX.get_key_id()) + ScMutableUint32::new(self.proxy.root(PARAM_BLOCK_INDEX)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableMapValueParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableMapValueParams { pub fn key(&self) -> ScImmutableString { - ScImmutableString::new(self.id, PARAM_KEY.get_key_id()) + ScImmutableString::new(self.proxy.root(PARAM_KEY)) } pub fn name(&self) -> ScImmutableString { - ScImmutableString::new(self.id, PARAM_NAME.get_key_id()) + ScImmutableString::new(self.proxy.root(PARAM_NAME)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableMapValueParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableMapValueParams { pub fn key(&self) -> ScMutableString { - ScMutableString::new(self.id, PARAM_KEY.get_key_id()) + ScMutableString::new(self.proxy.root(PARAM_KEY)) } pub fn name(&self) -> ScMutableString { - ScMutableString::new(self.id, PARAM_NAME.get_key_id()) + ScMutableString::new(self.proxy.root(PARAM_NAME)) } } diff --git a/contracts/wasm/testwasmlib/src/results.rs b/contracts/wasm/testwasmlib/src/results.rs index 977c05598d..2188072279 100644 --- a/contracts/wasm/testwasmlib/src/results.rs +++ b/contracts/wasm/testwasmlib/src/results.rs @@ -9,162 +9,158 @@ #![allow(unused_imports)] use wasmlib::*; -use wasmlib::host::*; - use crate::*; -use crate::keys::*; -use crate::typedefs::*; -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableArrayLengthResults { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableArrayLengthResults { pub fn length(&self) -> ScImmutableUint32 { - ScImmutableUint32::new(self.id, RESULT_LENGTH.get_key_id()) + ScImmutableUint32::new(self.proxy.root(RESULT_LENGTH)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableArrayLengthResults { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableArrayLengthResults { pub fn length(&self) -> ScMutableUint32 { - ScMutableUint32::new(self.id, RESULT_LENGTH.get_key_id()) + ScMutableUint32::new(self.proxy.root(RESULT_LENGTH)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableArrayValueResults { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableArrayValueResults { pub fn value(&self) -> ScImmutableString { - ScImmutableString::new(self.id, RESULT_VALUE.get_key_id()) + ScImmutableString::new(self.proxy.root(RESULT_VALUE)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableArrayValueResults { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableArrayValueResults { pub fn value(&self) -> ScMutableString { - ScMutableString::new(self.id, RESULT_VALUE.get_key_id()) + ScMutableString::new(self.proxy.root(RESULT_VALUE)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableBlockRecordResults { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableBlockRecordResults { pub fn record(&self) -> ScImmutableBytes { - ScImmutableBytes::new(self.id, RESULT_RECORD.get_key_id()) + ScImmutableBytes::new(self.proxy.root(RESULT_RECORD)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableBlockRecordResults { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableBlockRecordResults { pub fn record(&self) -> ScMutableBytes { - ScMutableBytes::new(self.id, RESULT_RECORD.get_key_id()) + ScMutableBytes::new(self.proxy.root(RESULT_RECORD)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableBlockRecordsResults { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableBlockRecordsResults { pub fn count(&self) -> ScImmutableUint32 { - ScImmutableUint32::new(self.id, RESULT_COUNT.get_key_id()) + ScImmutableUint32::new(self.proxy.root(RESULT_COUNT)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableBlockRecordsResults { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableBlockRecordsResults { pub fn count(&self) -> ScMutableUint32 { - ScMutableUint32::new(self.id, RESULT_COUNT.get_key_id()) + ScMutableUint32::new(self.proxy.root(RESULT_COUNT)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableGetRandomResults { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableGetRandomResults { pub fn random(&self) -> ScImmutableUint64 { - ScImmutableUint64::new(self.id, RESULT_RANDOM.get_key_id()) + ScImmutableUint64::new(self.proxy.root(RESULT_RANDOM)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableGetRandomResults { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableGetRandomResults { pub fn random(&self) -> ScMutableUint64 { - ScMutableUint64::new(self.id, RESULT_RANDOM.get_key_id()) + ScMutableUint64::new(self.proxy.root(RESULT_RANDOM)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableIotaBalanceResults { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableIotaBalanceResults { pub fn iotas(&self) -> ScImmutableUint64 { - ScImmutableUint64::new(self.id, RESULT_IOTAS.get_key_id()) + ScImmutableUint64::new(self.proxy.root(RESULT_IOTAS)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableIotaBalanceResults { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableIotaBalanceResults { pub fn iotas(&self) -> ScMutableUint64 { - ScMutableUint64::new(self.id, RESULT_IOTAS.get_key_id()) + ScMutableUint64::new(self.proxy.root(RESULT_IOTAS)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableMapValueResults { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableMapValueResults { pub fn value(&self) -> ScImmutableString { - ScImmutableString::new(self.id, RESULT_VALUE.get_key_id()) + ScImmutableString::new(self.proxy.root(RESULT_VALUE)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableMapValueResults { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableMapValueResults { pub fn value(&self) -> ScMutableString { - ScMutableString::new(self.id, RESULT_VALUE.get_key_id()) + ScMutableString::new(self.proxy.root(RESULT_VALUE)) } } diff --git a/contracts/wasm/testwasmlib/src/state.rs b/contracts/wasm/testwasmlib/src/state.rs index 720601ef25..e6167cb418 100644 --- a/contracts/wasm/testwasmlib/src/state.rs +++ b/contracts/wasm/testwasmlib/src/state.rs @@ -9,110 +9,99 @@ #![allow(unused_imports)] use wasmlib::*; -use wasmlib::host::*; use crate::*; -use crate::keys::*; -use crate::typedefs::*; -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MapStringToImmutableStringArray { - pub(crate) obj_id: i32, + pub(crate) proxy: Proxy, } impl MapStringToImmutableStringArray { pub fn get_string_array(&self, key: &str) -> ImmutableStringArray { - let sub_id = get_object_id(self.obj_id, key.get_key_id(), TYPE_ARRAY | TYPE_STRING); - ImmutableStringArray { obj_id: sub_id } + ImmutableStringArray { proxy: self.proxy.key(&string_to_bytes(key)) } } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MapStringToImmutableStringMap { - pub(crate) obj_id: i32, + pub(crate) proxy: Proxy, } impl MapStringToImmutableStringMap { pub fn get_string_map(&self, key: &str) -> ImmutableStringMap { - let sub_id = get_object_id(self.obj_id, key.get_key_id(), TYPE_MAP); - ImmutableStringMap { obj_id: sub_id } + ImmutableStringMap { proxy: self.proxy.key(&string_to_bytes(key)) } } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableTestWasmLibState { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableTestWasmLibState { pub fn arrays(&self) -> MapStringToImmutableStringArray { - let map_id = get_object_id(self.id, STATE_ARRAYS.get_key_id(), TYPE_MAP); - MapStringToImmutableStringArray { obj_id: map_id } + MapStringToImmutableStringArray { proxy: self.proxy.root(STATE_ARRAYS) } } pub fn maps(&self) -> MapStringToImmutableStringMap { - let map_id = get_object_id(self.id, STATE_MAPS.get_key_id(), TYPE_MAP); - MapStringToImmutableStringMap { obj_id: map_id } + MapStringToImmutableStringMap { proxy: self.proxy.root(STATE_MAPS) } } pub fn random(&self) -> ScImmutableUint64 { - ScImmutableUint64::new(self.id, STATE_RANDOM.get_key_id()) + ScImmutableUint64::new(self.proxy.root(STATE_RANDOM)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MapStringToMutableStringArray { - pub(crate) obj_id: i32, + pub(crate) proxy: Proxy, } impl MapStringToMutableStringArray { pub fn clear(&self) { - clear(self.obj_id); + self.proxy.clear_map(); } pub fn get_string_array(&self, key: &str) -> MutableStringArray { - let sub_id = get_object_id(self.obj_id, key.get_key_id(), TYPE_ARRAY | TYPE_STRING); - MutableStringArray { obj_id: sub_id } + MutableStringArray { proxy: self.proxy.key(&string_to_bytes(key)) } } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MapStringToMutableStringMap { - pub(crate) obj_id: i32, + pub(crate) proxy: Proxy, } impl MapStringToMutableStringMap { pub fn clear(&self) { - clear(self.obj_id); + self.proxy.clear_map(); } pub fn get_string_map(&self, key: &str) -> MutableStringMap { - let sub_id = get_object_id(self.obj_id, key.get_key_id(), TYPE_MAP); - MutableStringMap { obj_id: sub_id } + MutableStringMap { proxy: self.proxy.key(&string_to_bytes(key)) } } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableTestWasmLibState { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableTestWasmLibState { pub fn as_immutable(&self) -> ImmutableTestWasmLibState { - ImmutableTestWasmLibState { id: self.id } + ImmutableTestWasmLibState { proxy: self.proxy.root("") } } pub fn arrays(&self) -> MapStringToMutableStringArray { - let map_id = get_object_id(self.id, STATE_ARRAYS.get_key_id(), TYPE_MAP); - MapStringToMutableStringArray { obj_id: map_id } + MapStringToMutableStringArray { proxy: self.proxy.root(STATE_ARRAYS) } } pub fn maps(&self) -> MapStringToMutableStringMap { - let map_id = get_object_id(self.id, STATE_MAPS.get_key_id(), TYPE_MAP); - MapStringToMutableStringMap { obj_id: map_id } + MapStringToMutableStringMap { proxy: self.proxy.root(STATE_MAPS) } } pub fn random(&self) -> ScMutableUint64 { - ScMutableUint64::new(self.id, STATE_RANDOM.get_key_id()) + ScMutableUint64::new(self.proxy.root(STATE_RANDOM)) } } diff --git a/contracts/wasm/testwasmlib/src/testwasmlib.rs b/contracts/wasm/testwasmlib/src/testwasmlib.rs index 825d7ba5b4..bceec5fc3d 100644 --- a/contracts/wasm/testwasmlib/src/testwasmlib.rs +++ b/contracts/wasm/testwasmlib/src/testwasmlib.rs @@ -5,7 +5,11 @@ use wasmlib::*; use crate::*; -pub fn func_array_append(_ctx: &ScFuncContext, _f: &ArrayAppendContext) { +pub fn func_array_append(_ctx: &ScFuncContext, f: &ArrayAppendContext) { + let name = f.params.name().value(); + let array = f.state.arrays().get_string_array(&name); + let value = f.params.value().value(); + array.append_string().set_value(&value); } pub fn func_array_clear(_ctx: &ScFuncContext, f: &ArrayClearContext) { @@ -22,10 +26,18 @@ pub fn func_array_set(_ctx: &ScFuncContext, f: &ArraySetContext) { array.get_string(index).set_value(&value); } -pub fn func_map_clear(_ctx: &ScFuncContext, _f: &MapClearContext) { +pub fn func_map_clear(_ctx: &ScFuncContext, f: &MapClearContext) { + let name = f.params.name().value(); + let my_map = f.state.maps().get_string_map(&name); + my_map.clear(); } -pub fn func_map_set(_ctx: &ScFuncContext, _f: &MapSetContext) { +pub fn func_map_set(_ctx: &ScFuncContext, f: &MapSetContext) { + let name = f.params.name().value(); + let my_map = f.state.maps().get_string_map(&name); + let key = f.params.key().value(); + let value = f.params.value().value(); + my_map.get_string(&key).set_value(&value); } pub fn func_param_types(ctx: &ScFuncContext, f: &ParamTypesContext) { @@ -46,11 +58,11 @@ pub fn func_param_types(ctx: &ScFuncContext, f: &ParamTypesContext) { ctx.require(f.params.chain_id().value() == ctx.chain_id(), "mismatch: ChainID"); } if f.params.color().exists() { - let color = ScColor::from_bytes("RedGreenBlueYellowCyanBlackWhite".as_bytes()); + let color = color_from_bytes("RedGreenBlueYellowCyanBlackWhite".as_bytes()); ctx.require(f.params.color().value() == color, "mismatch: Color"); } if f.params.hash().exists() { - let hash = ScHash::from_bytes("0123456789abcdeffedcba9876543210".as_bytes()); + let hash = hash_from_bytes("0123456789abcdeffedcba9876543210".as_bytes()); ctx.require(f.params.hash().value() == hash, "mismatch: Hash"); } if f.params.hname().exists() { @@ -69,7 +81,7 @@ pub fn func_param_types(ctx: &ScFuncContext, f: &ParamTypesContext) { ctx.require(f.params.int64().value() == -1234567890123456789, "mismatch: Int64"); } if f.params.request_id().exists() { - let request_id = ScRequestID::from_bytes("abcdefghijklmnopqrstuvwxyz123456\x00\x00".as_bytes()); + let request_id = request_id_from_bytes("abcdefghijklmnopqrstuvwxyz123456\x00\x00".as_bytes()); ctx.require(f.params.request_id().value() == request_id, "mismatch: RequestID"); } if f.params.string().exists() { diff --git a/contracts/wasm/testwasmlib/src/typedefs.rs b/contracts/wasm/testwasmlib/src/typedefs.rs index 0e75ea6cbc..2c0b589ed6 100644 --- a/contracts/wasm/testwasmlib/src/typedefs.rs +++ b/contracts/wasm/testwasmlib/src/typedefs.rs @@ -8,71 +8,74 @@ #![allow(dead_code)] use wasmlib::*; -use wasmlib::host::*; -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ArrayOfImmutableString { - pub(crate) obj_id: i32, + pub(crate) proxy: Proxy, } impl ArrayOfImmutableString { pub fn length(&self) -> u32 { - get_length(self.obj_id) + self.proxy.length() } pub fn get_string(&self, index: u32) -> ScImmutableString { - ScImmutableString::new(self.obj_id, Key32(index as i32)) + ScImmutableString::new(self.proxy.index(index)) } } pub type ImmutableStringArray = ArrayOfImmutableString; -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ArrayOfMutableString { - pub(crate) obj_id: i32, + pub(crate) proxy: Proxy, } impl ArrayOfMutableString { - pub fn clear(&self) { - clear(self.obj_id); + pub fn append_string(&self) -> ScMutableString { + ScMutableString::new(self.proxy.append()) + } + + pub fn clear(&self) { + self.proxy.clear_array(); } pub fn length(&self) -> u32 { - get_length(self.obj_id) + self.proxy.length() } pub fn get_string(&self, index: u32) -> ScMutableString { - ScMutableString::new(self.obj_id, Key32(index as i32)) + ScMutableString::new(self.proxy.index(index)) } } pub type MutableStringArray = ArrayOfMutableString; -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MapStringToImmutableString { - pub(crate) obj_id: i32, + pub(crate) proxy: Proxy, } impl MapStringToImmutableString { pub fn get_string(&self, key: &str) -> ScImmutableString { - ScImmutableString::new(self.obj_id, key.get_key_id()) + ScImmutableString::new(self.proxy.key(&string_to_bytes(key))) } } pub type ImmutableStringMap = MapStringToImmutableString; -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MapStringToMutableString { - pub(crate) obj_id: i32, + pub(crate) proxy: Proxy, } impl MapStringToMutableString { pub fn clear(&self) { - clear(self.obj_id); + self.proxy.clear_map(); } pub fn get_string(&self, key: &str) -> ScMutableString { - ScMutableString::new(self.obj_id, key.get_key_id()) + ScMutableString::new(self.proxy.key(&string_to_bytes(key))) } } diff --git a/contracts/wasm/testwasmlib/test/testwasmlib_bg.wasm b/contracts/wasm/testwasmlib/test/testwasmlib_bg.wasm index c5324e4ade2755599bf53ef3cccaf232b28ba374..7e5e23f34514fa94d660e91ae972ff4251d31334 100644 GIT binary patch literal 83586 zcmdqK54>e{UH7}zZ|%L$K4+f;3mtW0DAwLhw;|y=&wX(nF8TPJ-&_SoH0;kU>gg%$ z&(+Q$b;b$p5t)OGii$WI7AhJk1}P{eDkjMhFfqv{rNktihl;{2Vet&E2 zwa=V$7+@&x73b{r=lA#f`~Lraf4`Nz;AOv zdmg=pr-i8>W0=qVg`b&y(Mw*o`-gYGVE51e@XzngdIvu~mB-V?pNFr9Zk|o$MW-{} z>1G>xMW^U>2AxipbwV%CLw;1=&5jIHw2|BYI=yU=b;_rNPWHqin+w@2k296*WL9hH zNg?lbs6Erk^G-fBl?C2r8BO&0ljlAD*O}^c2Hnu>JR!?FolgE_wUKq`k(-SFhmbLd zS(@Zoo)z?xb-LXiE6}4Zy?6Vx&V{OX`Cp&^chs9WUOQN3x9BQ7m1XM?F@i{3B({4c&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yqGU@YaqT@XoO`h)E9a(hgFXo*l?7`Rst}WUy|o zZQ43GuwnapVwIrC=HnIH$@cn@l7e0fRqNRm@7*wO-8ErO8M*bxES$fzeSUk~wtijb z(w+@VH>`^lI?QWdG;d-1-27ENn`oAApTDqcetU~@#`D(U0+XsZtbP8X`JHrJ*Rgo% L()Eiv+vonjMXBpr diff --git a/contracts/wasm/testwasmlib/ts/testwasmlib/keys.ts b/contracts/wasm/testwasmlib/ts/testwasmlib/keys.ts deleted file mode 100644 index 0c38cb7e7d..0000000000 --- a/contracts/wasm/testwasmlib/ts/testwasmlib/keys.ts +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2020 IOTA Stiftung -// SPDX-License-Identifier: Apache-2.0 - -// (Re-)generated by schema tool -// >>>> DO NOT CHANGE THIS FILE! <<<< -// Change the json schema instead - - -export const IdxParamAddress = 0; -export const IdxParamAgentID = 1; -export const IdxParamBlockIndex = 2; -export const IdxParamBool = 3; -export const IdxParamBytes = 4; -export const IdxParamChainID = 5; -export const IdxParamColor = 6; -export const IdxParamHash = 7; -export const IdxParamHname = 8; -export const IdxParamIndex = 9; -export const IdxParamInt16 = 10; -export const IdxParamInt32 = 11; -export const IdxParamInt64 = 12; -export const IdxParamInt8 = 13; -export const IdxParamKey = 14; -export const IdxParamName = 15; -export const IdxParamParam = 16; -export const IdxParamRecordIndex = 17; -export const IdxParamRequestID = 18; -export const IdxParamString = 19; -export const IdxParamUint16 = 20; -export const IdxParamUint32 = 21; -export const IdxParamUint64 = 22; -export const IdxParamUint8 = 23; -export const IdxParamValue = 24; diff --git a/contracts/wasm/timestamp/go/timestamp/keys.go b/contracts/wasm/timestamp/go/timestamp/keys.go deleted file mode 100644 index ddfdc850c0..0000000000 --- a/contracts/wasm/timestamp/go/timestamp/keys.go +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright 2020 IOTA Stiftung -// SPDX-License-Identifier: Apache-2.0 - -// (Re-)generated by schema tool -// >>>> DO NOT CHANGE THIS FILE! <<<< -// Change the json schema instead - -package timestamp diff --git a/contracts/wasm/timestamp/src/contract.rs b/contracts/wasm/timestamp/src/contract.rs index 91ec41f186..2c0c95db40 100644 --- a/contracts/wasm/timestamp/src/contract.rs +++ b/contracts/wasm/timestamp/src/contract.rs @@ -7,8 +7,6 @@ #![allow(dead_code)] -use std::ptr; - use wasmlib::*; use crate::consts::*; @@ -27,18 +25,18 @@ pub struct ScFuncs { } impl ScFuncs { - pub fn now(_ctx: & dyn ScFuncCallContext) -> NowCall { + pub fn now(_ctx: &dyn ScFuncCallContext) -> NowCall { NowCall { func: ScFunc::new(HSC_NAME, HFUNC_NOW), } } - pub fn get_timestamp(_ctx: & dyn ScViewCallContext) -> GetTimestampCall { + pub fn get_timestamp(_ctx: &dyn ScViewCallContext) -> GetTimestampCall { let mut f = GetTimestampCall { func: ScView::new(HSC_NAME, HVIEW_GET_TIMESTAMP), - results: ImmutableGetTimestampResults { id: 0 }, + results: ImmutableGetTimestampResults { proxy: Proxy::nil() }, }; - f.func.set_ptrs(ptr::null_mut(), &mut f.results.id); + ScView::link_results(&mut f.results.proxy, &f.func); f } } diff --git a/contracts/wasm/timestamp/src/keys.rs b/contracts/wasm/timestamp/src/keys.rs deleted file mode 100644 index 52cdcdbbb8..0000000000 --- a/contracts/wasm/timestamp/src/keys.rs +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2020 IOTA Stiftung -// SPDX-License-Identifier: Apache-2.0 - -// (Re-)generated by schema tool -// >>>> DO NOT CHANGE THIS FILE! <<<< -// Change the json schema instead - -#![allow(dead_code)] - -use wasmlib::*; - -use crate::*; - - -pub(crate) const IDX_RESULT_TIMESTAMP : usize = 0; - -pub(crate) const IDX_STATE_TIMESTAMP : usize = 1; - -pub const KEY_MAP_LEN: usize = 2; - -pub const KEY_MAP: [&str; KEY_MAP_LEN] = [ - RESULT_TIMESTAMP, - STATE_TIMESTAMP, -]; - -pub static mut IDX_MAP: [Key32; KEY_MAP_LEN] = [Key32(0); KEY_MAP_LEN]; - -pub fn idx_map(idx: usize) -> Key32 { - unsafe { - IDX_MAP[idx] - } -} diff --git a/contracts/wasm/timestamp/src/lib.rs b/contracts/wasm/timestamp/src/lib.rs index e50f6ade0a..06dfdc5102 100644 --- a/contracts/wasm/timestamp/src/lib.rs +++ b/contracts/wasm/timestamp/src/lib.rs @@ -10,16 +10,13 @@ use timestamp::*; use wasmlib::*; -use wasmlib::host::*; use crate::consts::*; -use crate::keys::*; use crate::results::*; use crate::state::*; mod consts; mod contract; -mod keys; mod results; mod state; mod timestamp; @@ -29,12 +26,6 @@ fn on_load() { let exports = ScExports::new(); exports.add_func(FUNC_NOW, func_now_thunk); exports.add_view(VIEW_GET_TIMESTAMP, view_get_timestamp_thunk); - - unsafe { - for i in 0..KEY_MAP_LEN { - IDX_MAP[i] = get_key_id_from_string(KEY_MAP[i]); - } - } } pub struct NowContext { @@ -44,9 +35,7 @@ pub struct NowContext { fn func_now_thunk(ctx: &ScFuncContext) { ctx.log("timestamp.funcNow"); let f = NowContext { - state: MutabletimestampState { - id: OBJ_ID_STATE, - }, + state: MutabletimestampState { proxy: state_proxy() }, }; func_now(ctx, &f); ctx.log("timestamp.funcNow ok"); @@ -60,13 +49,10 @@ pub struct GetTimestampContext { fn view_get_timestamp_thunk(ctx: &ScViewContext) { ctx.log("timestamp.viewGetTimestamp"); let f = GetTimestampContext { - results: MutableGetTimestampResults { - id: OBJ_ID_RESULTS, - }, - state: ImmutabletimestampState { - id: OBJ_ID_STATE, - }, + results: MutableGetTimestampResults { proxy: results_proxy() }, + state: ImmutabletimestampState { proxy: state_proxy() }, }; view_get_timestamp(ctx, &f); + ctx.results(&f.results.proxy.kv_store); ctx.log("timestamp.viewGetTimestamp ok"); } diff --git a/contracts/wasm/timestamp/src/results.rs b/contracts/wasm/timestamp/src/results.rs index bfe1f7008f..115284a700 100644 --- a/contracts/wasm/timestamp/src/results.rs +++ b/contracts/wasm/timestamp/src/results.rs @@ -9,29 +9,26 @@ #![allow(unused_imports)] use wasmlib::*; -use wasmlib::host::*; - use crate::*; -use crate::keys::*; -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableGetTimestampResults { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableGetTimestampResults { pub fn timestamp(&self) -> ScImmutableUint64 { - ScImmutableUint64::new(self.id, RESULT_TIMESTAMP.get_key_id()) + ScImmutableUint64::new(self.proxy.root(RESULT_TIMESTAMP)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableGetTimestampResults { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableGetTimestampResults { pub fn timestamp(&self) -> ScMutableUint64 { - ScMutableUint64::new(self.id, RESULT_TIMESTAMP.get_key_id()) + ScMutableUint64::new(self.proxy.root(RESULT_TIMESTAMP)) } } diff --git a/contracts/wasm/timestamp/src/state.rs b/contracts/wasm/timestamp/src/state.rs index 003e40975d..704666f724 100644 --- a/contracts/wasm/timestamp/src/state.rs +++ b/contracts/wasm/timestamp/src/state.rs @@ -9,33 +9,31 @@ #![allow(unused_imports)] use wasmlib::*; -use wasmlib::host::*; use crate::*; -use crate::keys::*; -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutabletimestampState { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutabletimestampState { pub fn timestamp(&self) -> ScImmutableUint64 { - ScImmutableUint64::new(self.id, STATE_TIMESTAMP.get_key_id()) + ScImmutableUint64::new(self.proxy.root(STATE_TIMESTAMP)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutabletimestampState { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutabletimestampState { pub fn as_immutable(&self) -> ImmutabletimestampState { - ImmutabletimestampState { id: self.id } + ImmutabletimestampState { proxy: self.proxy.root("") } } pub fn timestamp(&self) -> ScMutableUint64 { - ScMutableUint64::new(self.id, STATE_TIMESTAMP.get_key_id()) + ScMutableUint64::new(self.proxy.root(STATE_TIMESTAMP)) } } diff --git a/contracts/wasm/timestamp/test/timestamp_bg.wasm b/contracts/wasm/timestamp/test/timestamp_bg.wasm index fafa3e7bbf9f5670ae5a79613dfb7b6c6e82c991..2435b0c5528dbad747a7dc378fc8bccfd6c22535 100644 GIT binary patch literal 38927 zcmc(|3!Gk6eeb>3-ut=CJTu7-1PDn8`+1Bqfm|lHnMpvI9Zf>ys(^Tjl1Vaz%p{p) zW|BZvGJ#l8K!Q@GiWn4yDhjstl(w|S_n_6*qxd;mQE5eAdtTqSzLuWSQ(G@N-`{`j z{me5-@KW`22s3-{b^WjZ{r_KU?+FIRcDf)4+>TQ=g$E9}1Nt3oiVoPl%Ws2CPE|3b zl$3Pg8U((C8me#FRJL*|!UH!^OR;aML2pw3fJU0+rf^AExrUi9*}l2s`jN5mE5`@M z2d^9)56UMNucx>zddPjml`2u#R&vwAuVkPCsb+{;s;?%Z=rkqc&&+dxby4gRpv$Ior60^MsEy* z%E+#3cZ>{d4MudgWnjmS;F7j=F34PM!S)M2;ud{`)!xj{E&Qyy%{|EFt!~=YA9gpM zy>R#)?uHM!2i$wyZEi#IZud4SKkRDfyyhM^|5f+7_P73&f{jT9smsOKPZaABnUz7a$qhoIz%J%Qc-aOO@GX}8YEF2%EPnfz5 zbJF0_&XCdKA*-s#+4nzjH0TP0wVf^t(s;NYX}<7)9}(#69XnRJm z*9g;iLuUY3@i6z%<=j)BhK;B*pk>q%)fjoEjTEM38U|@4J8NGS?-|MxKf(Grs+dzR zQ{$K+4LXBbT4vsIJ?IE)sp|}Dnl^K3NkAmGx?;t9w6-V>lDpjXQ^BUV7J>8BQ46Fl zjW6dOILm3YVNZhz9rH$-Spyts*tBk~CVTFahR+80yBs7^PshvWbV4+hB_DA05`E@{ z{b`gF2*RpW@-Bc(qvW8YW+GIn9_MNuQ5NlMxGWmaegM6O>SZYOJx@6(&Di4&w@1tF z3acHiW_5rZj`oB>TCN$qrJk@#8J7+QF8hn4kPgfrrSVYmCho*yQD>-O63;3*AH8uX z4KALOGY(9me+Trt2?|IOpa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gB!q_uBEv$$vJ)oOZ+Q!i@%=fFI(^Wdmq z@x(9-A|J>bS#Oj%cW~;YiUbS;lnoeG-i~+Z@f+Rt~q>!nzh@l1xN_?|s(%Np8lZlg|&3FqEvNzNkf^D~OBh zMZ{Rtr?Etw3p{`FW#z&Qs*;)i2YqxIi%YT#$Pm~BD z@@)aIYUhsitF~-j*R*5jMBoeu&R9IqyD)qDyL`0&dgaQM0zUc|GT#~emW0{D+Ys54JJ+ESW~&?SUuh?ws_IzC5){H`2M_b^W#-T~lG6Q#Wkwo7%H$D<%9o z)~dyvEbcL~+;d;o9)AwT$@j3B`RTFArT3vr3GR)Vy2r+=<1sV;v6;iZjZw<Ddg`-*w& HnFs$5sSQ9U diff --git a/contracts/wasm/timestamp/ts/timestamp/keys.ts b/contracts/wasm/timestamp/ts/timestamp/keys.ts deleted file mode 100644 index c8806d28c4..0000000000 --- a/contracts/wasm/timestamp/ts/timestamp/keys.ts +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright 2020 IOTA Stiftung -// SPDX-License-Identifier: Apache-2.0 - -// (Re-)generated by schema tool -// >>>> DO NOT CHANGE THIS FILE! <<<< -// Change the json schema instead - - diff --git a/contracts/wasm/tokenregistry/go/tokenregistry/keys.go b/contracts/wasm/tokenregistry/go/tokenregistry/keys.go deleted file mode 100644 index 8b3b04d0c9..0000000000 --- a/contracts/wasm/tokenregistry/go/tokenregistry/keys.go +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright 2020 IOTA Stiftung -// SPDX-License-Identifier: Apache-2.0 - -// (Re-)generated by schema tool -// >>>> DO NOT CHANGE THIS FILE! <<<< -// Change the json schema instead - -package tokenregistry diff --git a/contracts/wasm/tokenregistry/src/contract.rs b/contracts/wasm/tokenregistry/src/contract.rs index d99016a400..abf1544fb1 100644 --- a/contracts/wasm/tokenregistry/src/contract.rs +++ b/contracts/wasm/tokenregistry/src/contract.rs @@ -7,8 +7,6 @@ #![allow(dead_code)] -use std::ptr; - use wasmlib::*; use crate::consts::*; @@ -38,39 +36,39 @@ pub struct ScFuncs { } impl ScFuncs { - pub fn mint_supply(_ctx: & dyn ScFuncCallContext) -> MintSupplyCall { + pub fn mint_supply(_ctx: &dyn ScFuncCallContext) -> MintSupplyCall { let mut f = MintSupplyCall { func: ScFunc::new(HSC_NAME, HFUNC_MINT_SUPPLY), - params: MutableMintSupplyParams { id: 0 }, + params: MutableMintSupplyParams { proxy: Proxy::nil() }, }; - f.func.set_ptrs(&mut f.params.id, ptr::null_mut()); + ScFunc::link_params(&mut f.params.proxy, &f.func); f } - pub fn transfer_ownership(_ctx: & dyn ScFuncCallContext) -> TransferOwnershipCall { + pub fn transfer_ownership(_ctx: &dyn ScFuncCallContext) -> TransferOwnershipCall { let mut f = TransferOwnershipCall { func: ScFunc::new(HSC_NAME, HFUNC_TRANSFER_OWNERSHIP), - params: MutableTransferOwnershipParams { id: 0 }, + params: MutableTransferOwnershipParams { proxy: Proxy::nil() }, }; - f.func.set_ptrs(&mut f.params.id, ptr::null_mut()); + ScFunc::link_params(&mut f.params.proxy, &f.func); f } - pub fn update_metadata(_ctx: & dyn ScFuncCallContext) -> UpdateMetadataCall { + pub fn update_metadata(_ctx: &dyn ScFuncCallContext) -> UpdateMetadataCall { let mut f = UpdateMetadataCall { func: ScFunc::new(HSC_NAME, HFUNC_UPDATE_METADATA), - params: MutableUpdateMetadataParams { id: 0 }, + params: MutableUpdateMetadataParams { proxy: Proxy::nil() }, }; - f.func.set_ptrs(&mut f.params.id, ptr::null_mut()); + ScFunc::link_params(&mut f.params.proxy, &f.func); f } - pub fn get_info(_ctx: & dyn ScViewCallContext) -> GetInfoCall { + pub fn get_info(_ctx: &dyn ScViewCallContext) -> GetInfoCall { let mut f = GetInfoCall { func: ScView::new(HSC_NAME, HVIEW_GET_INFO), - params: MutableGetInfoParams { id: 0 }, + params: MutableGetInfoParams { proxy: Proxy::nil() }, }; - f.func.set_ptrs(&mut f.params.id, ptr::null_mut()); + ScView::link_params(&mut f.params.proxy, &f.func); f } } diff --git a/contracts/wasm/tokenregistry/src/keys.rs b/contracts/wasm/tokenregistry/src/keys.rs deleted file mode 100644 index 4d155e37c3..0000000000 --- a/contracts/wasm/tokenregistry/src/keys.rs +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright 2020 IOTA Stiftung -// SPDX-License-Identifier: Apache-2.0 - -// (Re-)generated by schema tool -// >>>> DO NOT CHANGE THIS FILE! <<<< -// Change the json schema instead - -#![allow(dead_code)] - -use wasmlib::*; - -use crate::*; - -pub(crate) const IDX_PARAM_COLOR : usize = 0; -pub(crate) const IDX_PARAM_DESCRIPTION : usize = 1; -pub(crate) const IDX_PARAM_USER_DEFINED : usize = 2; - - -pub(crate) const IDX_STATE_COLOR_LIST : usize = 3; -pub(crate) const IDX_STATE_REGISTRY : usize = 4; - -pub const KEY_MAP_LEN: usize = 5; - -pub const KEY_MAP: [&str; KEY_MAP_LEN] = [ - PARAM_COLOR, - PARAM_DESCRIPTION, - PARAM_USER_DEFINED, - STATE_COLOR_LIST, - STATE_REGISTRY, -]; - -pub static mut IDX_MAP: [Key32; KEY_MAP_LEN] = [Key32(0); KEY_MAP_LEN]; - -pub fn idx_map(idx: usize) -> Key32 { - unsafe { - IDX_MAP[idx] - } -} diff --git a/contracts/wasm/tokenregistry/src/lib.rs b/contracts/wasm/tokenregistry/src/lib.rs index 629e025911..34ef9544ce 100644 --- a/contracts/wasm/tokenregistry/src/lib.rs +++ b/contracts/wasm/tokenregistry/src/lib.rs @@ -10,16 +10,14 @@ use tokenregistry::*; use wasmlib::*; -use wasmlib::host::*; use crate::consts::*; -use crate::keys::*; use crate::params::*; use crate::state::*; +use crate::structs::*; mod consts; mod contract; -mod keys; mod params; mod state; mod structs; @@ -32,12 +30,6 @@ fn on_load() { exports.add_func(FUNC_TRANSFER_OWNERSHIP, func_transfer_ownership_thunk); exports.add_func(FUNC_UPDATE_METADATA, func_update_metadata_thunk); exports.add_view(VIEW_GET_INFO, view_get_info_thunk); - - unsafe { - for i in 0..KEY_MAP_LEN { - IDX_MAP[i] = get_key_id_from_string(KEY_MAP[i]); - } - } } pub struct MintSupplyContext { @@ -48,12 +40,8 @@ pub struct MintSupplyContext { fn func_mint_supply_thunk(ctx: &ScFuncContext) { ctx.log("tokenregistry.funcMintSupply"); let f = MintSupplyContext { - params: ImmutableMintSupplyParams { - id: OBJ_ID_PARAMS, - }, - state: MutableTokenRegistryState { - id: OBJ_ID_STATE, - }, + params: ImmutableMintSupplyParams { proxy: params_proxy() }, + state: MutableTokenRegistryState { proxy: state_proxy() }, }; func_mint_supply(ctx, &f); ctx.log("tokenregistry.funcMintSupply ok"); @@ -66,18 +54,14 @@ pub struct TransferOwnershipContext { fn func_transfer_ownership_thunk(ctx: &ScFuncContext) { ctx.log("tokenregistry.funcTransferOwnership"); + let f = TransferOwnershipContext { + params: ImmutableTransferOwnershipParams { proxy: params_proxy() }, + state: MutableTokenRegistryState { proxy: state_proxy() }, + }; // TODO the one who can transfer token ownership ctx.require(ctx.caller() == ctx.contract_creator(), "no permission"); - let f = TransferOwnershipContext { - params: ImmutableTransferOwnershipParams { - id: OBJ_ID_PARAMS, - }, - state: MutableTokenRegistryState { - id: OBJ_ID_STATE, - }, - }; ctx.require(f.params.color().exists(), "missing mandatory color"); func_transfer_ownership(ctx, &f); ctx.log("tokenregistry.funcTransferOwnership ok"); @@ -90,18 +74,14 @@ pub struct UpdateMetadataContext { fn func_update_metadata_thunk(ctx: &ScFuncContext) { ctx.log("tokenregistry.funcUpdateMetadata"); + let f = UpdateMetadataContext { + params: ImmutableUpdateMetadataParams { proxy: params_proxy() }, + state: MutableTokenRegistryState { proxy: state_proxy() }, + }; // TODO the one who can change the token info ctx.require(ctx.caller() == ctx.contract_creator(), "no permission"); - let f = UpdateMetadataContext { - params: ImmutableUpdateMetadataParams { - id: OBJ_ID_PARAMS, - }, - state: MutableTokenRegistryState { - id: OBJ_ID_STATE, - }, - }; ctx.require(f.params.color().exists(), "missing mandatory color"); func_update_metadata(ctx, &f); ctx.log("tokenregistry.funcUpdateMetadata ok"); @@ -115,12 +95,8 @@ pub struct GetInfoContext { fn view_get_info_thunk(ctx: &ScViewContext) { ctx.log("tokenregistry.viewGetInfo"); let f = GetInfoContext { - params: ImmutableGetInfoParams { - id: OBJ_ID_PARAMS, - }, - state: ImmutableTokenRegistryState { - id: OBJ_ID_STATE, - }, + params: ImmutableGetInfoParams { proxy: params_proxy() }, + state: ImmutableTokenRegistryState { proxy: state_proxy() }, }; ctx.require(f.params.color().exists(), "missing mandatory color"); view_get_info(ctx, &f); diff --git a/contracts/wasm/tokenregistry/src/params.rs b/contracts/wasm/tokenregistry/src/params.rs index 324f58e091..4979e3097e 100644 --- a/contracts/wasm/tokenregistry/src/params.rs +++ b/contracts/wasm/tokenregistry/src/params.rs @@ -9,104 +9,100 @@ #![allow(unused_imports)] use wasmlib::*; -use wasmlib::host::*; - use crate::*; -use crate::keys::*; -use crate::structs::*; -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableMintSupplyParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableMintSupplyParams { pub fn description(&self) -> ScImmutableString { - ScImmutableString::new(self.id, PARAM_DESCRIPTION.get_key_id()) + ScImmutableString::new(self.proxy.root(PARAM_DESCRIPTION)) } pub fn user_defined(&self) -> ScImmutableString { - ScImmutableString::new(self.id, PARAM_USER_DEFINED.get_key_id()) + ScImmutableString::new(self.proxy.root(PARAM_USER_DEFINED)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableMintSupplyParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableMintSupplyParams { pub fn description(&self) -> ScMutableString { - ScMutableString::new(self.id, PARAM_DESCRIPTION.get_key_id()) + ScMutableString::new(self.proxy.root(PARAM_DESCRIPTION)) } pub fn user_defined(&self) -> ScMutableString { - ScMutableString::new(self.id, PARAM_USER_DEFINED.get_key_id()) + ScMutableString::new(self.proxy.root(PARAM_USER_DEFINED)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableTransferOwnershipParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableTransferOwnershipParams { pub fn color(&self) -> ScImmutableColor { - ScImmutableColor::new(self.id, PARAM_COLOR.get_key_id()) + ScImmutableColor::new(self.proxy.root(PARAM_COLOR)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableTransferOwnershipParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableTransferOwnershipParams { pub fn color(&self) -> ScMutableColor { - ScMutableColor::new(self.id, PARAM_COLOR.get_key_id()) + ScMutableColor::new(self.proxy.root(PARAM_COLOR)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableUpdateMetadataParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableUpdateMetadataParams { pub fn color(&self) -> ScImmutableColor { - ScImmutableColor::new(self.id, PARAM_COLOR.get_key_id()) + ScImmutableColor::new(self.proxy.root(PARAM_COLOR)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableUpdateMetadataParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableUpdateMetadataParams { pub fn color(&self) -> ScMutableColor { - ScMutableColor::new(self.id, PARAM_COLOR.get_key_id()) + ScMutableColor::new(self.proxy.root(PARAM_COLOR)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableGetInfoParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableGetInfoParams { pub fn color(&self) -> ScImmutableColor { - ScImmutableColor::new(self.id, PARAM_COLOR.get_key_id()) + ScImmutableColor::new(self.proxy.root(PARAM_COLOR)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableGetInfoParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableGetInfoParams { pub fn color(&self) -> ScMutableColor { - ScMutableColor::new(self.id, PARAM_COLOR.get_key_id()) + ScMutableColor::new(self.proxy.root(PARAM_COLOR)) } } diff --git a/contracts/wasm/tokenregistry/src/state.rs b/contracts/wasm/tokenregistry/src/state.rs index dac3d17a47..00431b229f 100644 --- a/contracts/wasm/tokenregistry/src/state.rs +++ b/contracts/wasm/tokenregistry/src/state.rs @@ -9,106 +9,103 @@ #![allow(unused_imports)] use wasmlib::*; -use wasmlib::host::*; use crate::*; -use crate::keys::*; -use crate::structs::*; -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ArrayOfImmutableColor { - pub(crate) obj_id: i32, + pub(crate) proxy: Proxy, } impl ArrayOfImmutableColor { pub fn length(&self) -> u32 { - get_length(self.obj_id) + self.proxy.length() } pub fn get_color(&self, index: u32) -> ScImmutableColor { - ScImmutableColor::new(self.obj_id, Key32(index as i32)) + ScImmutableColor::new(self.proxy.index(index)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MapColorToImmutableToken { - pub(crate) obj_id: i32, + pub(crate) proxy: Proxy, } impl MapColorToImmutableToken { pub fn get_token(&self, key: &ScColor) -> ImmutableToken { - ImmutableToken { obj_id: self.obj_id, key_id: key.get_key_id() } + ImmutableToken { proxy: self.proxy.key(&color_to_bytes(key)) } } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableTokenRegistryState { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableTokenRegistryState { pub fn color_list(&self) -> ArrayOfImmutableColor { - let arr_id = get_object_id(self.id, STATE_COLOR_LIST.get_key_id(), TYPE_ARRAY | TYPE_COLOR); - ArrayOfImmutableColor { obj_id: arr_id } + ArrayOfImmutableColor { proxy: self.proxy.root(STATE_COLOR_LIST) } } pub fn registry(&self) -> MapColorToImmutableToken { - let map_id = get_object_id(self.id, STATE_REGISTRY.get_key_id(), TYPE_MAP); - MapColorToImmutableToken { obj_id: map_id } + MapColorToImmutableToken { proxy: self.proxy.root(STATE_REGISTRY) } } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ArrayOfMutableColor { - pub(crate) obj_id: i32, + pub(crate) proxy: Proxy, } impl ArrayOfMutableColor { - pub fn clear(&self) { - clear(self.obj_id); + pub fn append_color(&self) -> ScMutableColor { + ScMutableColor::new(self.proxy.append()) + } + + pub fn clear(&self) { + self.proxy.clear_array(); } pub fn length(&self) -> u32 { - get_length(self.obj_id) + self.proxy.length() } pub fn get_color(&self, index: u32) -> ScMutableColor { - ScMutableColor::new(self.obj_id, Key32(index as i32)) + ScMutableColor::new(self.proxy.index(index)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MapColorToMutableToken { - pub(crate) obj_id: i32, + pub(crate) proxy: Proxy, } impl MapColorToMutableToken { pub fn clear(&self) { - clear(self.obj_id); + self.proxy.clear_map(); } pub fn get_token(&self, key: &ScColor) -> MutableToken { - MutableToken { obj_id: self.obj_id, key_id: key.get_key_id() } + MutableToken { proxy: self.proxy.key(&color_to_bytes(key)) } } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableTokenRegistryState { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableTokenRegistryState { pub fn as_immutable(&self) -> ImmutableTokenRegistryState { - ImmutableTokenRegistryState { id: self.id } + ImmutableTokenRegistryState { proxy: self.proxy.root("") } } pub fn color_list(&self) -> ArrayOfMutableColor { - let arr_id = get_object_id(self.id, STATE_COLOR_LIST.get_key_id(), TYPE_ARRAY | TYPE_COLOR); - ArrayOfMutableColor { obj_id: arr_id } + ArrayOfMutableColor { proxy: self.proxy.root(STATE_COLOR_LIST) } } pub fn registry(&self) -> MapColorToMutableToken { - let map_id = get_object_id(self.id, STATE_REGISTRY.get_key_id(), TYPE_MAP); - MapColorToMutableToken { obj_id: map_id } + MapColorToMutableToken { proxy: self.proxy.root(STATE_REGISTRY) } } } diff --git a/contracts/wasm/tokenregistry/src/structs.rs b/contracts/wasm/tokenregistry/src/structs.rs index 34b5bf68be..0546a78af7 100644 --- a/contracts/wasm/tokenregistry/src/structs.rs +++ b/contracts/wasm/tokenregistry/src/structs.rs @@ -9,7 +9,6 @@ #![allow(unused_imports)] use wasmlib::*; -use wasmlib::host::*; #[derive(Clone)] pub struct Token { @@ -24,67 +23,65 @@ pub struct Token { impl Token { pub fn from_bytes(bytes: &[u8]) -> Token { - let mut decode = BytesDecoder::new(bytes); + let mut dec = WasmDecoder::new(bytes); Token { - created : decode.uint64(), - description : decode.string(), - minted_by : decode.agent_id(), - owner : decode.agent_id(), - supply : decode.uint64(), - updated : decode.uint64(), - user_defined : decode.string(), + created : uint64_decode(&mut dec), + description : string_decode(&mut dec), + minted_by : agent_id_decode(&mut dec), + owner : agent_id_decode(&mut dec), + supply : uint64_decode(&mut dec), + updated : uint64_decode(&mut dec), + user_defined : string_decode(&mut dec), } } pub fn to_bytes(&self) -> Vec { - let mut encode = BytesEncoder::new(); - encode.uint64(self.created); - encode.string(&self.description); - encode.agent_id(&self.minted_by); - encode.agent_id(&self.owner); - encode.uint64(self.supply); - encode.uint64(self.updated); - encode.string(&self.user_defined); - return encode.data(); + let mut enc = WasmEncoder::new(); + uint64_encode(&mut enc, self.created); + string_encode(&mut enc, &self.description); + agent_id_encode(&mut enc, &self.minted_by); + agent_id_encode(&mut enc, &self.owner); + uint64_encode(&mut enc, self.supply); + uint64_encode(&mut enc, self.updated); + string_encode(&mut enc, &self.user_defined); + enc.buf() } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableToken { - pub(crate) obj_id: i32, - pub(crate) key_id: Key32, + pub(crate) proxy: Proxy, } impl ImmutableToken { pub fn exists(&self) -> bool { - exists(self.obj_id, self.key_id, TYPE_BYTES) + self.proxy.exists() } pub fn value(&self) -> Token { - Token::from_bytes(&get_bytes(self.obj_id, self.key_id, TYPE_BYTES)) + Token::from_bytes(&self.proxy.get()) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableToken { - pub(crate) obj_id: i32, - pub(crate) key_id: Key32, + pub(crate) proxy: Proxy, } impl MutableToken { pub fn delete(&self) { - del_key(self.obj_id, self.key_id, TYPE_BYTES); + self.proxy.delete(); } pub fn exists(&self) -> bool { - exists(self.obj_id, self.key_id, TYPE_BYTES) + self.proxy.exists() } pub fn set_value(&self, value: &Token) { - set_bytes(self.obj_id, self.key_id, TYPE_BYTES, &value.to_bytes()); + self.proxy.set(&value.to_bytes()); } pub fn value(&self) -> Token { - Token::from_bytes(&get_bytes(self.obj_id, self.key_id, TYPE_BYTES)) + Token::from_bytes(&self.proxy.get()) } } diff --git a/contracts/wasm/tokenregistry/src/tokenregistry.rs b/contracts/wasm/tokenregistry/src/tokenregistry.rs index 52058a4c8d..b3adf35eb6 100644 --- a/contracts/wasm/tokenregistry/src/tokenregistry.rs +++ b/contracts/wasm/tokenregistry/src/tokenregistry.rs @@ -9,8 +9,8 @@ use crate::structs::*; pub fn func_mint_supply(ctx: &ScFuncContext, f: &MintSupplyContext) { let minted = ctx.minted(); let minted_colors = minted.colors(); - ctx.require(minted_colors.length() == 1, "need single minted color"); - let minted_color = minted_colors.get_color(0).value(); + ctx.require(minted_colors.len() == 1, "need single minted color"); + let minted_color = minted_colors.get(0).unwrap(); let current_token = f.state.registry().get_token(&minted_color); if current_token.exists() { // should never happen, because transaction id is unique @@ -30,7 +30,7 @@ pub fn func_mint_supply(ctx: &ScFuncContext, f: &MintSupplyContext) { } current_token.set_value(&token); let color_list = f.state.color_list(); - color_list.get_color(color_list.length()).set_value(&minted_color); + color_list.append_color().set_value(&minted_color); } pub fn func_transfer_ownership(_ctx: &ScFuncContext, _f: &TransferOwnershipContext) { diff --git a/contracts/wasm/tokenregistry/test/tokenregistry_bg.wasm b/contracts/wasm/tokenregistry/test/tokenregistry_bg.wasm index f1b0f91374765b0672ece508bf02f7a722955d0f..060c7d501417a1b9d5b00fc2be2042a6c22be479 100644 GIT binary patch literal 54414 zcmdqK3xFL}neSVxs`jIMcPAAH5Rw43w-Gv!N9Wm{fYKEq5P2#fs3-|Z1L@AQyAxnk z(m+&HlsGa2gNVUFK?Pw(R7O$TGw7f)igTS29cGLioZ;T#I-Gl)GtTjm^ZS3RYWMC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R`h+`buxc?dYHRzAPC*E`< zo<~J}N{a^(i7I?X;}g?Sjc2ZjVYok(YJL0qjnnbJ?AEQA4mF#;zWttMck6L)SB*Ix z;ZOzUQ=^too928AX#u)Kbb5_56FvT07mbcLJxfll{>9rZrF$?FVDv~zfA#i6)GP+j znSf_%@g#f#{QEEhy#)O%K5>5rp2@FZQ)xqKLlA5V?hEd#E3Ip&FJ1cm82=UP)^`~6 zZ(q|peeGRqAeOeY?~vpUe8}6z4UPKGe)Y}>;t>>> DO NOT CHANGE THIS FILE! <<<< -// Change the json schema instead - - -export const IdxParamColor = 0; -export const IdxParamDescription = 1; -export const IdxParamUserDefined = 2; diff --git a/documentation/tutorial-examples/src/lib.rs b/documentation/tutorial-examples/src/lib.rs index 4519d685cc..0ecc073e87 100644 --- a/documentation/tutorial-examples/src/lib.rs +++ b/documentation/tutorial-examples/src/lib.rs @@ -20,14 +20,17 @@ fn on_load() { // panics if parameter is not provided fn store_string(ctx: &ScFuncContext) { // take parameter paramString - let par = ctx.params().get_string(PARAM_STRING); - // require parameter exists - ctx.require(par.exists(), "string parameter not found"); + let params = ctx.params(); + let param_string = string_to_bytes(PARAM_STRING); + ctx.require(params.exists(¶m_string), "string parameter not found"); + let state = ctx.raw_state(); // store the string in "storedString" variable - ctx.state().get_string(VAR_STRING).set_value(&par.value()); - // log the text - let msg = "Message stored: ".to_string() + &par.value(); + let var_string = string_to_bytes(VAR_STRING); + let value = params.get(¶m_string); + state.set(&var_string, &value); + // log the text + let msg = "Message stored: ".to_string() + &string_from_bytes(&value); ctx.log(&msg); } @@ -36,9 +39,14 @@ fn store_string(ctx: &ScFuncContext) { // the returned value in the result is under key 'paramString' fn get_string(ctx: &ScViewContext) { // take the stored string - let s = ctx.state().get_string(VAR_STRING).value(); + let state = ctx.raw_state(); + let var_string = string_to_bytes(VAR_STRING); + let value = state.get(&var_string); // return the string value in the result dictionary - ctx.results().get_string(PARAM_STRING).set_value(&s); + let results = ScDict::new(&[]); + let param_string = string_to_bytes(PARAM_STRING); + results.set(¶m_string, &value); + ctx.results(&results); } // withdraw_iota sends all iotas contained in the contract's account @@ -55,6 +63,6 @@ fn withdraw_iota(ctx: &ScFuncContext) { let bal = ctx.balances().balance(&ScColor::IOTA); if bal > 0 { - ctx.transfer_to_address(&caller.address(), ScTransfers::transfer(&ScColor::IOTA, bal)) + ctx.transfer_to_address(&caller.address(), ScTransfers::iotas(bal)) } } diff --git a/documentation/tutorial-examples/test/example_tutorial_bg.wasm b/documentation/tutorial-examples/test/example_tutorial_bg.wasm index 7ff582a07c37c08e38c1bea2f22e8b212a9d7423..3e0159b5b1dfc50877147859d94f8571d37eb52d 100644 GIT binary patch literal 51609 zcmeIb3!GhLdGEh&`!;*eWDNvJG6}4`jWU5;CbyYMK$#UyLI^hn1eHpLWPr>hnPf5v zP?by|R+NiDX{AavT3V>0Vymat(mMVRT5LUv|3fQUPK_M;Km7m4V`+~)rAJE6_xHSO z?b(xrTea=~d_D)AtlPWZ_j#ZD^SsZywl}zYyYG3Pe@*A6VBbD}pZ@hWh5PJW2XB*a ze>{q~)DSA1)-)K z6x6Oz2#ee(R6H*z@Sh$P3Twv7&M@rHD^d2rh{@6yUT-%I`K8MpXzmcH&2{=g@gss8uw_uS$i;yB@Vz5V0< z_`-9pd#}IyUjH}zgZ?f4n@|0qe=`q1?w`2)%Den!@A!z{_UK;(pYZRj2QfH*jhDtF zjp}?a7zhRuFa3M}qG%xX;*a_bKk?IYeA7re(;Z@Wc<#u%hSTeJrSBPT1SxOpZW@e_ z&^}1~4PA+ML3=qx7CXnDn{>Z*9AudPy`=4>eSD!uOyC%s|1Yt;YfQm*q4=>`J=Sk2A+dW!_wXjOZGp(Z_DbmnOO6k14X|!uNja~oi zyY!%|UgU|-2#MG3Rg)sa7VBOus3v}UP}Q)hpA-Z{yx-3!yh~FH6EFUNf8BJbxm^vx zcH;9CNc|+bh;!g9CgFx%4F>cXH`K`L;Kqgx>#x;d_dRUrY=FLtz#-3h@uIGF$fbMn zJ$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55JS$U~tyueh%0tr*(von(l2-@^cE>dQDWVBAKy!^~{wQhk3>FR~ql~-X12|pIj8Ng!i8Pr tR}B=}X3beRtF1{9_n9kk1 ledgerstate.MaxOutputCount - if buf[ScHashLength] > 127 || buf[ScHashLength+1] != 0 { + if buf[ScRequestIDLength-2] > 127 || buf[ScRequestIDLength-1] != 0 { panic("invalid RequestID: output index > 127") } return requestIDFromBytesUnchecked(buf) diff --git a/packages/wasmvm/wasmlib/src/assets.rs b/packages/wasmvm/wasmlib/src/assets.rs new file mode 100644 index 0000000000..c9aa834ffd --- /dev/null +++ b/packages/wasmvm/wasmlib/src/assets.rs @@ -0,0 +1,123 @@ +// Copyright 2020 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +use std::collections::BTreeMap; + +use crate::*; + +fn read_bytes(assets: &mut BTreeMap, u64>, buf: &[u8]) { + if buf.len() != 0 { + let mut dec = WasmDecoder::new(buf); + let size = uint32_from_bytes(&dec.fixed_bytes(SC_UINT32_LENGTH)); + for _i in 0..size { + let color = color_decode(&mut dec); + let amount_buf = dec.fixed_bytes(SC_UINT64_LENGTH); + let amount = uint64_from_bytes(&amount_buf); + assets.insert(color.to_bytes(), amount); + } + } +} + +#[derive(Clone)] +pub struct ScAssets { + assets: BTreeMap, u64>, +} + +impl ScAssets { + pub fn new(buf: &[u8]) -> ScAssets { + let mut assets = ScAssets { assets: BTreeMap::new() }; + read_bytes(&mut assets.assets, buf); + assets + } + + pub fn balances(&self) -> ScBalances { + ScBalances { assets: self.assets.clone() } + } + + pub fn to_bytes(&self) -> Vec { + let dict = &self.assets; + if dict.len() == 0 { + return vec![0; SC_UINT32_LENGTH]; + } + + let mut enc = WasmEncoder::new(); + enc.fixed_bytes(&uint32_to_bytes(dict.len() as u32), SC_UINT32_LENGTH); + for (key, val) in dict.iter() { + enc.fixed_bytes(key, SC_COLOR_LENGTH); + enc.fixed_bytes(&uint64_to_bytes(*val), SC_UINT64_LENGTH); + } + return enc.buf(); + } +} + +#[derive(Clone)] +pub struct ScBalances { + assets: BTreeMap, u64>, +} + +impl ScBalances { + pub fn balance(&self, color: &ScColor) -> u64 { + let key = color.to_bytes(); + if !self.assets.contains_key(&key) { + return 0; + } + *self.assets.get(&key).unwrap() + } + + pub fn colors(&self) -> Vec { + let mut colors: Vec = Vec::new(); + for color in self.assets.keys() { + colors.push(color_from_bytes(color)); + } + colors + } +} + +#[derive(Clone)] +pub struct ScTransfers { + assets: BTreeMap, u64>, +} + +impl ScTransfers { + pub fn new(buf: &[u8]) -> ScTransfers { + let mut assets = ScTransfers { assets: BTreeMap::new() }; + read_bytes(&mut assets.assets, buf); + assets + } + + pub fn from_balances(balances: ScBalances) -> ScTransfers { + let mut transfers = ScTransfers { assets: BTreeMap::new() }; + let colors = balances.colors(); + for i in 0..colors.len() { + let color = colors.get(i).unwrap(); + transfers.set(color, balances.balance(color)) + } + transfers + } + + pub fn iotas(amount: u64) -> ScTransfers { + ScTransfers::transfer(&ScColor::IOTA, amount) + } + + pub fn transfer(color: &ScColor, amount: u64) ->ScTransfers { + let mut transfers = ScTransfers { assets: BTreeMap::new() }; + transfers.set(color, amount); + transfers + } + + pub fn as_assets(&self) -> ScAssets { + ScAssets { assets: self.assets.clone() } + } + + pub fn balances(&self) -> ScBalances { + ScBalances { assets: self.assets.clone() } + } + + pub fn set(&mut self, color: &ScColor, amount: u64) { + self.assets.insert(color.to_bytes(), amount); + } + + pub fn to_bytes(&self) -> Vec { + self.as_assets().to_bytes() + } +} diff --git a/packages/wasmvm/wasmlib/src/context.rs b/packages/wasmvm/wasmlib/src/context.rs index 42e49fad7a..34b8f5371e 100644 --- a/packages/wasmvm/wasmlib/src/context.rs +++ b/packages/wasmvm/wasmlib/src/context.rs @@ -3,250 +3,7 @@ // encapsulates standard host entities into a simple interface -use std::convert::TryInto; - -use crate::bytes::*; -use crate::contract::*; -use crate::hashtypes::*; -use crate::host::*; -use crate::immutable::*; -use crate::keys::*; -use crate::mutable::*; - -// all access to the objects in host's object tree starts here -pub(crate) static ROOT: ScMutableMap = ScMutableMap { obj_id: OBJ_ID_ROOT }; - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -// retrieves any information that is related to colored token balances -pub struct ScBalances { - balances: ScImmutableMap, -} - -impl ScBalances { - // retrieve the balance for the specified token color - pub fn balance(&self, color: &ScColor) -> u64 { - self.balances.get_uint64(color).value() - } - - // retrieve an array of all token colors that have a non-zero balance - pub fn colors(&self) -> ScImmutableColorArray { - self.balances.get_color_array(&KEY_COLOR) - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -// passes token transfer information to a function call -#[derive(Clone, Copy)] -pub struct ScTransfers { - pub(crate) transfers: ScMutableMap, -} - -impl ScTransfers { - // create a new transfers object ready to add token transfers - pub fn new() -> ScTransfers { - ScTransfers { transfers: ScMutableMap::new() } - } - - // create a new transfers object from a balances object - pub fn from_balances(balances: ScBalances) -> ScTransfers { - let transfers = ScTransfers::new(); - let colors = balances.colors(); - for i in 0..colors.length() { - let color = colors.get_color(i).value(); - transfers.set(&color, balances.balance(&color)); - } - transfers - } - - // create a new transfers object and initialize it with the specified amount of iotas - pub fn iotas(amount: u64) -> ScTransfers { - ScTransfers::transfer(&ScColor::IOTA, amount) - } - - // create a new transfers object and initialize it with the specified token transfer - pub fn transfer(color: &ScColor, amount: u64) -> ScTransfers { - let transfer = ScTransfers::new(); - transfer.set(color, amount); - transfer - } - - // set the specified colored token transfer in the transfers object - // note that this will overwrite any previous amount for the specified color - pub fn set(&self, color: &ScColor, amount: u64) { - self.transfers.get_uint64(color).set_value(amount); - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -// provides access to utility functions that are handled by the host -pub struct ScUtility { - utility: ScMutableMap, -} - -impl ScUtility { - // decodes the specified base58-encoded string value to its original bytes - pub fn base58_decode(&self, value: &str) -> Vec { - self.utility.call_func(KEY_BASE58_DECODE, value.as_bytes()) - } - - // encodes the specified bytes to a base-58-encoded string - pub fn base58_encode(&self, value: &[u8]) -> String { - let result = self.utility.call_func(KEY_BASE58_ENCODE, value); - unsafe { String::from_utf8_unchecked(result) } - } - - // retrieves the address for the specified BLS public key - pub fn bls_address_from_pubkey(&self, pub_key: &[u8]) -> ScAddress { - let result = self.utility.call_func(KEY_BLS_ADDRESS, pub_key); - ScAddress::from_bytes(&result) - } - - // aggregates the specified multiple BLS signatures and public keys into a single one - pub fn bls_aggregate_signatures(&self, pub_keys_bin: &[&[u8]], sigs_bin: &[&[u8]]) -> (Vec, Vec) { - let mut encode = BytesEncoder::new(); - encode.int32(pub_keys_bin.len() as i32); - for pub_key in pub_keys_bin { - encode.bytes(pub_key); - } - encode.int32(sigs_bin.len() as i32); - for sig in sigs_bin { - encode.bytes(sig); - } - let result = self.utility.call_func(KEY_BLS_AGGREGATE, &encode.data()); - let mut decode = BytesDecoder::new(&result); - return (decode.bytes().to_vec(), decode.bytes().to_vec()); - } - - // checks if the specified BLS signature is valid - pub fn bls_valid_signature(&self, data: &[u8], pub_key: &[u8], signature: &[u8]) -> bool { - let mut encode = BytesEncoder::new(); - encode.bytes(data); - encode.bytes(pub_key); - encode.bytes(signature); - let result = self.utility.call_func(KEY_BLS_VALID, &encode.data()); - (result[0] & 0x01) != 0 - } - - // retrieves the address for the specified ED25519 public key - pub fn ed25519_address_from_pubkey(&self, pub_key: &[u8]) -> ScAddress { - let result = self.utility.call_func(KEY_ED25519_ADDRESS, pub_key); - ScAddress::from_bytes(&result) - } - - // checks if the specified ED25519 signature is valid - pub fn ed25519_valid_signature(&self, data: &[u8], pub_key: &[u8], signature: &[u8]) -> bool { - let mut encode = BytesEncoder::new(); - encode.bytes(data); - encode.bytes(pub_key); - encode.bytes(signature); - let result = self.utility.call_func(KEY_ED25519_VALID, &encode.data()); - (result[0] & 0x01) != 0 - } - - // hashes the specified value bytes using BLAKE2b hashing and returns the resulting 32-byte hash - pub fn hash_blake2b(&self, value: &[u8]) -> ScHash { - let hash = self.utility.call_func(KEY_HASH_BLAKE2B, value); - ScHash::from_bytes(&hash) - } - - // hashes the specified value bytes using SHA3 hashing and returns the resulting 32-byte hash - pub fn hash_sha3(&self, value: &[u8]) -> ScHash { - let hash = self.utility.call_func(KEY_HASH_SHA3, value); - ScHash::from_bytes(&hash) - } - - // calculates 32-bit hash for the specified name string - pub fn hname(&self, value: &str) -> ScHname { - let result = self.utility.call_func(KEY_HNAME, value.as_bytes()); - ScHname::from_bytes(&result) - } -} - -// wrapper function for simplified internal access to base58 encoding -pub(crate) fn base58_encode(bytes: &[u8]) -> String { - ScFuncContext {}.utility().base58_encode(bytes) -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -// shared interface part of ScFuncContext and ScViewContext -pub trait ScBaseContext { - // retrieve the agent id of this contract account - fn account_id(&self) -> ScAgentID { - ROOT.get_agent_id(&KEY_ACCOUNT_ID).value() - } - - // access the current balances for all token colors - fn balances(&self) -> ScBalances { - ScBalances { balances: ROOT.get_map(&KEY_BALANCES).immutable() } - } - - // retrieve the chain id of the chain this contract lives on - fn chain_id(&self) -> ScChainID { - ROOT.get_chain_id(&KEY_CHAIN_ID).value() - } - - // retrieve the agent id of the owner of the chain this contract lives on - fn chain_owner_id(&self) -> ScAgentID { - ROOT.get_agent_id(&KEY_CHAIN_OWNER_ID).value() - } - - // retrieve the hname of this contract - fn contract(&self) -> ScHname { - ROOT.get_hname(&KEY_CONTRACT).value() - } - - // retrieve the agent id of the creator of this contract - fn contract_creator(&self) -> ScAgentID { - ROOT.get_agent_id(&KEY_CONTRACT_CREATOR).value() - } - - // logs informational text message in the log on the host - fn log(&self, text: &str) { - log(text); - } - - // logs error text message in the log on the host and then panics - fn panic(&self, text: &str) { - panic(text); - } - - // retrieve parameters that were passed to the smart contract function - fn params(&self) -> ScImmutableMap { - ROOT.get_map(&KEY_PARAMS).immutable() - } - - // panics with specified message if specified condition is not satisfied - fn require(&self, cond: bool, msg: &str) { - if !cond { - panic(msg); - } - } - - // map that holds any results returned by the smart contract function - fn results(&self) -> ScMutableMap { - ROOT.get_map(&KEY_RESULTS) - } - - // deterministic time stamp fixed at the moment of calling the smart contract - fn timestamp(&self) -> u64 { - ROOT.get_uint64(&KEY_TIMESTAMP).value() - } - - // logs debugging trace text message in the log on the host - // similar to log() except this will only show in the log in a special debug mode - fn trace(&self, text: &str) { - trace(text); - } - - // access diverse utility functions provided by the host - fn utility(&self) -> ScUtility { - ScUtility { utility: ROOT.get_map(&KEY_UTILITY) } - } -} +use crate::*; // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ @@ -255,7 +12,8 @@ pub trait ScBaseContext { pub struct ScFuncContext {} // reuse shared part of interface -impl ScBaseContext for ScFuncContext {} +impl ScSandbox for ScFuncContext {} +impl ScSandboxFunc for ScFuncContext {} impl ScFuncCallContext for ScFuncContext { fn can_call_func(&self) { @@ -270,115 +28,14 @@ impl ScViewCallContext for ScFuncContext { } impl ScFuncContext { - // synchronously calls the specified smart contract function, - // passing the provided parameters and token transfers to it - pub fn call(&self, hcontract: ScHname, hfunction: ScHname, params: Option, transfer: Option) -> ScImmutableMap { - let mut encode = BytesEncoder::new(); - encode.hname(hcontract); - encode.hname(hfunction); - if let Some(params) = params { - encode.int32(params.map_id()); - } else { - encode.int32(0); - } - if let Some(transfer) = transfer { - encode.int32(transfer.transfers.map_id()); - } else { - encode.int32(0); - } - ROOT.get_bytes(&KEY_CALL).set_value(&encode.data()); - ROOT.get_map(&KEY_RETURN).immutable() - } - - // retrieve the agent id of the caller of the smart contract - pub fn caller(&self) -> ScAgentID { - ROOT.get_agent_id(&KEY_CALLER).value() - } - - // deploys a new instance of the specified smart contract on the current chain - // the provided parameters are passed to the smart contract "init" function - pub fn deploy(&self, program_hash: &ScHash, name: &str, description: &str, params: Option) { - let mut encode = BytesEncoder::new(); - encode.hash(program_hash); - encode.string(name); - encode.string(description); - if let Some(params) = params { - encode.int32(params.map_id()); - } else { - encode.int32(0); - } - ROOT.get_bytes(&KEY_DEPLOY).set_value(&encode.data()); - } - - // signals an event on the host that external entities can subscribe to - pub fn event(&self, text: &str) { - ROOT.get_string(&KEY_EVENT).set_value(text); - } - - // access the incoming balances for all token colors pub fn incoming(&self) -> ScBalances { - ScBalances { balances: ROOT.get_map(&KEY_INCOMING).immutable() } + self.incoming_transfer() } - // retrieve the tokens that were minted in this transaction - pub fn minted(&self) -> ScBalances { - ScBalances { balances: ROOT.get_map(&KEY_MINTED).immutable() } - } - - // asynchronously calls the specified smart contract function, - // passing the provided parameters and token transfers to it - // it is possible to schedule the call for a later execution by specifying a delay - pub fn post(&self, chain_id: &ScChainID, hcontract: ScHname, hfunction: ScHname, params: Option, transfer: ScTransfers, delay: u32) { - let mut encode = BytesEncoder::new(); - encode.chain_id(chain_id); - encode.hname(hcontract); - encode.hname(hfunction); - if let Some(params) = params { - encode.int32(params.map_id()); - } else { - encode.int32(0); - } - encode.int32(transfer.transfers.map_id()); - encode.uint32(delay); - ROOT.get_bytes(&KEY_POST).set_value(&encode.data()); - } - - // generates a random value from 0 to max (exclusive max) using a deterministic RNG - pub fn random(&self, max: u64) -> u64 { - if max == 0 { - self.panic("random: max parameter should be non-zero"); - } - let state = ScMutableMap { obj_id: OBJ_ID_STATE }; - let rnd = state.get_bytes(&KEY_RANDOM); - let mut seed = rnd.value(); - if seed.is_empty() { - // get initial entropy from sandbox - seed = ROOT.get_bytes(&KEY_RANDOM).value(); - } - rnd.set_value(&self.utility().hash_sha3(&seed).to_bytes()); - let rnd = u64::from_le_bytes(seed[0..8].try_into().expect("invalid u64 length")); - rnd % max - } - - // retrieve the request id of this transaction - pub fn request_id(&self) -> ScRequestID { - ROOT.get_request_id(&KEY_REQUEST_ID).value() - } - - // access mutable state storage on the host - pub fn state(&self) -> ScMutableMap { - ROOT.get_map(&KEY_STATE) - } - - // transfers the specified tokens to the specified Tangle ledger address pub fn transfer_to_address(&self, address: &ScAddress, transfer: ScTransfers) { - let transfers = ROOT.get_map_array(&KEY_TRANSFERS); - let tx = transfers.get_map(transfers.length()); - tx.get_address(&KEY_ADDRESS).set_value(address); - tx.get_int32(&KEY_BALANCES).set_value(transfer.transfers.map_id()); + self.send(address, &transfer) } } - // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // smart contract view interface which has only immutable access to state @@ -386,33 +43,11 @@ impl ScFuncContext { pub struct ScViewContext {} // reuse shared part of interface -impl ScBaseContext for ScViewContext {} +impl ScSandbox for ScViewContext {} +impl ScSandboxView for ScViewContext {} impl ScViewCallContext for ScViewContext { fn can_call_view(&self) { panic!("can_call_view"); } } - -impl ScViewContext { - // synchronously calls the specified smart contract view, - // passing the provided parameters to it - pub fn call(&self, hcontract: ScHname, hfunction: ScHname, params: Option) -> ScImmutableMap { - let mut encode = BytesEncoder::new(); - encode.hname(hcontract); - encode.hname(hfunction); - if let Some(params) = params { - encode.int32(params.map_id()); - } else { - encode.int32(0); - } - encode.int32(0); - ROOT.get_bytes(&KEY_CALL).set_value(&encode.data()); - ROOT.get_map(&KEY_RETURN).immutable() - } - - // access immutable state storage on the host - pub fn state(&self) -> ScImmutableMap { - ROOT.get_map(&KEY_STATE).immutable() - } -} diff --git a/packages/wasmvm/wasmlib/src/contract.rs b/packages/wasmvm/wasmlib/src/contract.rs index b1e9a8a49b..0b29a52c1c 100644 --- a/packages/wasmvm/wasmlib/src/contract.rs +++ b/packages/wasmvm/wasmlib/src/contract.rs @@ -3,14 +3,10 @@ // base contract objects -use std::ptr; +use std::rc::Rc; -use crate::bytes::*; -use crate::context::*; -use crate::hashtypes::*; +use crate::*; use crate::host::*; -use crate::keys::*; -use crate::mutable::*; pub trait ScFuncCallContext { fn can_call_func(&self); @@ -22,12 +18,12 @@ pub trait ScViewCallContext { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ScView { h_contract: ScHname, h_function: ScHname, - params_id: *mut i32, - results_id: *mut i32, + params: Rc, + results: Rc, } impl ScView { @@ -35,39 +31,35 @@ impl ScView { ScView { h_contract: h_contract, h_function: h_function, - params_id: ptr::null_mut(), - results_id: ptr::null_mut(), + params: Rc::new(ScDict::new(&[])), + results: Rc::new(ScDict::new(&[])), } } - pub fn set_ptrs(&mut self, params_id: *mut i32, results_id: *mut i32) { - self.params_id = params_id; - self.results_id = results_id; - - unsafe { - if params_id != ptr::null_mut() { - *params_id = ScMutableMap::new().map_id(); - } - } + pub fn link_params(proxy: &mut Proxy, view: &ScView) { + Proxy::link(proxy, &view.params); } - pub fn call(&self) { - self.call_with_transfer(0); + pub fn link_results(proxy: &mut Proxy, view: &ScView) { + Proxy::link(proxy, &view.results); } - fn call_with_transfer(&self, transfer_id: i32) { - let mut encode = BytesEncoder::new(); - encode.hname(self.h_contract); - encode.hname(self.h_function); - encode.int32(self.id(self.params_id)); - encode.int32(transfer_id); - ROOT.get_bytes(&KEY_CALL).set_value(&encode.data()); - - unsafe { - if self.results_id != ptr::null_mut() { - *self.results_id = get_object_id(1, KEY_RETURN, TYPE_MAP); - } + pub fn call(&self) { + self.call_with_transfer(None); + } + + fn call_with_transfer(&self, transfer: Option) { + let mut req = wasmrequests::CallRequest { + contract: self.h_contract, + function: self.h_function, + params: self.params.to_bytes(), + transfer: vec![0; SC_UINT32_LENGTH], + }; + if let Some(transfer) = transfer { + req.transfer = transfer.to_bytes(); } + let res = sandbox(FN_CALL, &req.to_bytes()); + self.results.copy(&res); } pub fn of_contract(&self, h_contract: ScHname) -> ScView { @@ -75,20 +67,11 @@ impl ScView { ret.h_contract = h_contract; ret } - - fn id(&self, params_id: *mut i32) -> i32 { - unsafe { - if params_id == ptr::null_mut() { - return 0; - } - *params_id - } - } } // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ScInitFunc { view: ScView, } @@ -100,8 +83,12 @@ impl ScInitFunc { } } - pub fn set_ptrs(&mut self, params_id: *mut i32, results_id: *mut i32) { - self.view.set_ptrs(params_id, results_id); + pub fn link_params(proxy: &mut Proxy, func: &ScInitFunc) { + ScView::link_params(proxy, &func.view); + } + + pub fn link_results(proxy: &mut Proxy, func: &ScInitFunc) { + ScView::link_results(proxy, &func.view); } pub fn call(&self) { @@ -117,11 +104,11 @@ impl ScInitFunc { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ScFunc { - view: ScView, + pub view: ScView, delay: u32, - transfer_id: i32, + transfer: ScAssets, } impl ScFunc { @@ -129,19 +116,23 @@ impl ScFunc { ScFunc { view: ScView::new(h_contract, h_function), delay: 0, - transfer_id: 0, + transfer: ScAssets::new(&[]), } } - pub fn set_ptrs(&mut self, params_id: *mut i32, results_id: *mut i32) { - self.view.set_ptrs(params_id, results_id); + pub fn link_params(proxy: &mut Proxy, func: &ScFunc) { + ScView::link_params(proxy, &func.view); + } + + pub fn link_results(proxy: &mut Proxy, func: &ScFunc) { + ScView::link_results(proxy, &func.view); } pub fn call(&self) { if self.delay != 0 { panic("cannot delay a call") } - self.view.call_with_transfer(self.transfer_id); + self.view.call_with_transfer(Some(self.transfer.clone())); } pub fn delay(&self, seconds: u32) -> ScFunc { @@ -157,23 +148,25 @@ impl ScFunc { } pub fn post(&self) { - self.post_to_chain(ROOT.get_chain_id(&KEY_CHAIN_ID).value()) + self.post_to_chain(ScFuncContext {}.chain_id()) } pub fn post_to_chain(&self, chain_id: ScChainID) { - let mut encode = BytesEncoder::new(); - encode.chain_id(&chain_id); - encode.hname(self.view.h_contract); - encode.hname(self.view.h_function); - encode.int32(self.view.id(self.view.params_id)); - encode.int32(self.transfer_id); - encode.uint32(self.delay); - ROOT.get_bytes(&KEY_POST).set_value(&encode.data()); + let req = wasmrequests::PostRequest { + chain_id: chain_id, + contract: self.view.h_contract, + function: self.view.h_function, + params: self.view.params.to_bytes(), + transfer: self.transfer.to_bytes(), + delay: self.delay, + }; + let res = sandbox(FN_POST, &req.to_bytes()); + self.view.results.copy(&res); } pub fn transfer(&self, transfer: ScTransfers) -> ScFunc { let mut ret = self.clone(); - ret.transfer_id = transfer.transfers.obj_id; + ret.transfer = transfer.as_assets(); ret } diff --git a/packages/wasmvm/wasmlib/src/coreaccounts/contract.rs b/packages/wasmvm/wasmlib/src/coreaccounts/contract.rs index 8b6e25016e..76100505b6 100644 --- a/packages/wasmvm/wasmlib/src/coreaccounts/contract.rs +++ b/packages/wasmvm/wasmlib/src/coreaccounts/contract.rs @@ -7,8 +7,6 @@ #![allow(dead_code)] -use std::ptr; - use crate::*; use crate::coreaccounts::*; @@ -52,65 +50,67 @@ pub struct ScFuncs { } impl ScFuncs { - pub fn deposit(_ctx: & dyn ScFuncCallContext) -> DepositCall { + pub fn deposit(_ctx: &dyn ScFuncCallContext) -> DepositCall { let mut f = DepositCall { func: ScFunc::new(HSC_NAME, HFUNC_DEPOSIT), - params: MutableDepositParams { id: 0 }, + params: MutableDepositParams { proxy: Proxy::nil() }, }; - f.func.set_ptrs(&mut f.params.id, ptr::null_mut()); + ScFunc::link_params(&mut f.params.proxy, &f.func); f } - pub fn harvest(_ctx: & dyn ScFuncCallContext) -> HarvestCall { + pub fn harvest(_ctx: &dyn ScFuncCallContext) -> HarvestCall { let mut f = HarvestCall { func: ScFunc::new(HSC_NAME, HFUNC_HARVEST), - params: MutableHarvestParams { id: 0 }, + params: MutableHarvestParams { proxy: Proxy::nil() }, }; - f.func.set_ptrs(&mut f.params.id, ptr::null_mut()); + ScFunc::link_params(&mut f.params.proxy, &f.func); f } - pub fn withdraw(_ctx: & dyn ScFuncCallContext) -> WithdrawCall { + pub fn withdraw(_ctx: &dyn ScFuncCallContext) -> WithdrawCall { WithdrawCall { func: ScFunc::new(HSC_NAME, HFUNC_WITHDRAW), } } - pub fn accounts(_ctx: & dyn ScViewCallContext) -> AccountsCall { + pub fn accounts(_ctx: &dyn ScViewCallContext) -> AccountsCall { let mut f = AccountsCall { func: ScView::new(HSC_NAME, HVIEW_ACCOUNTS), - results: ImmutableAccountsResults { id: 0 }, + results: ImmutableAccountsResults { proxy: Proxy::nil() }, }; - f.func.set_ptrs(ptr::null_mut(), &mut f.results.id); + ScView::link_results(&mut f.results.proxy, &f.func); f } - pub fn balance(_ctx: & dyn ScViewCallContext) -> BalanceCall { + pub fn balance(_ctx: &dyn ScViewCallContext) -> BalanceCall { let mut f = BalanceCall { func: ScView::new(HSC_NAME, HVIEW_BALANCE), - params: MutableBalanceParams { id: 0 }, - results: ImmutableBalanceResults { id: 0 }, + params: MutableBalanceParams { proxy: Proxy::nil() }, + results: ImmutableBalanceResults { proxy: Proxy::nil() }, }; - f.func.set_ptrs(&mut f.params.id, &mut f.results.id); + ScView::link_params(&mut f.params.proxy, &f.func); + ScView::link_results(&mut f.results.proxy, &f.func); f } - pub fn get_account_nonce(_ctx: & dyn ScViewCallContext) -> GetAccountNonceCall { + pub fn get_account_nonce(_ctx: &dyn ScViewCallContext) -> GetAccountNonceCall { let mut f = GetAccountNonceCall { func: ScView::new(HSC_NAME, HVIEW_GET_ACCOUNT_NONCE), - params: MutableGetAccountNonceParams { id: 0 }, - results: ImmutableGetAccountNonceResults { id: 0 }, + params: MutableGetAccountNonceParams { proxy: Proxy::nil() }, + results: ImmutableGetAccountNonceResults { proxy: Proxy::nil() }, }; - f.func.set_ptrs(&mut f.params.id, &mut f.results.id); + ScView::link_params(&mut f.params.proxy, &f.func); + ScView::link_results(&mut f.results.proxy, &f.func); f } - pub fn total_assets(_ctx: & dyn ScViewCallContext) -> TotalAssetsCall { + pub fn total_assets(_ctx: &dyn ScViewCallContext) -> TotalAssetsCall { let mut f = TotalAssetsCall { func: ScView::new(HSC_NAME, HVIEW_TOTAL_ASSETS), - results: ImmutableTotalAssetsResults { id: 0 }, + results: ImmutableTotalAssetsResults { proxy: Proxy::nil() }, }; - f.func.set_ptrs(ptr::null_mut(), &mut f.results.id); + ScView::link_results(&mut f.results.proxy, &f.func); f } } diff --git a/packages/wasmvm/wasmlib/src/coreaccounts/params.rs b/packages/wasmvm/wasmlib/src/coreaccounts/params.rs index 5c61b19e05..4eb0d3e283 100644 --- a/packages/wasmvm/wasmlib/src/coreaccounts/params.rs +++ b/packages/wasmvm/wasmlib/src/coreaccounts/params.rs @@ -8,102 +8,101 @@ #![allow(dead_code)] #![allow(unused_imports)] -use crate::*; use crate::coreaccounts::*; -use crate::host::*; +use crate::*; -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableDepositParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableDepositParams { pub fn agent_id(&self) -> ScImmutableAgentID { - ScImmutableAgentID::new(self.id, PARAM_AGENT_ID.get_key_id()) + ScImmutableAgentID::new(self.proxy.root(PARAM_AGENT_ID)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableDepositParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableDepositParams { pub fn agent_id(&self) -> ScMutableAgentID { - ScMutableAgentID::new(self.id, PARAM_AGENT_ID.get_key_id()) + ScMutableAgentID::new(self.proxy.root(PARAM_AGENT_ID)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableHarvestParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableHarvestParams { pub fn withdraw_amount(&self) -> ScImmutableInt64 { - ScImmutableInt64::new(self.id, PARAM_WITHDRAW_AMOUNT.get_key_id()) + ScImmutableInt64::new(self.proxy.root(PARAM_WITHDRAW_AMOUNT)) } pub fn withdraw_color(&self) -> ScImmutableColor { - ScImmutableColor::new(self.id, PARAM_WITHDRAW_COLOR.get_key_id()) + ScImmutableColor::new(self.proxy.root(PARAM_WITHDRAW_COLOR)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableHarvestParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableHarvestParams { pub fn withdraw_amount(&self) -> ScMutableInt64 { - ScMutableInt64::new(self.id, PARAM_WITHDRAW_AMOUNT.get_key_id()) + ScMutableInt64::new(self.proxy.root(PARAM_WITHDRAW_AMOUNT)) } pub fn withdraw_color(&self) -> ScMutableColor { - ScMutableColor::new(self.id, PARAM_WITHDRAW_COLOR.get_key_id()) + ScMutableColor::new(self.proxy.root(PARAM_WITHDRAW_COLOR)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableBalanceParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableBalanceParams { pub fn agent_id(&self) -> ScImmutableAgentID { - ScImmutableAgentID::new(self.id, PARAM_AGENT_ID.get_key_id()) + ScImmutableAgentID::new(self.proxy.root(PARAM_AGENT_ID)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableBalanceParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableBalanceParams { pub fn agent_id(&self) -> ScMutableAgentID { - ScMutableAgentID::new(self.id, PARAM_AGENT_ID.get_key_id()) + ScMutableAgentID::new(self.proxy.root(PARAM_AGENT_ID)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableGetAccountNonceParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableGetAccountNonceParams { pub fn agent_id(&self) -> ScImmutableAgentID { - ScImmutableAgentID::new(self.id, PARAM_AGENT_ID.get_key_id()) + ScImmutableAgentID::new(self.proxy.root(PARAM_AGENT_ID)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableGetAccountNonceParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableGetAccountNonceParams { pub fn agent_id(&self) -> ScMutableAgentID { - ScMutableAgentID::new(self.id, PARAM_AGENT_ID.get_key_id()) + ScMutableAgentID::new(self.proxy.root(PARAM_AGENT_ID)) } } diff --git a/packages/wasmvm/wasmlib/src/coreaccounts/results.rs b/packages/wasmvm/wasmlib/src/coreaccounts/results.rs index 463868574a..a41a76f297 100644 --- a/packages/wasmvm/wasmlib/src/coreaccounts/results.rs +++ b/packages/wasmvm/wasmlib/src/coreaccounts/results.rs @@ -8,146 +8,145 @@ #![allow(dead_code)] #![allow(unused_imports)] -use crate::*; use crate::coreaccounts::*; -use crate::host::*; +use crate::*; -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MapAgentIDToImmutableBytes { - pub(crate) obj_id: i32, + pub(crate) proxy: Proxy, } impl MapAgentIDToImmutableBytes { pub fn get_bytes(&self, key: &ScAgentID) -> ScImmutableBytes { - ScImmutableBytes::new(self.obj_id, key.get_key_id()) + ScImmutableBytes::new(self.proxy.key(&agent_id_to_bytes(key))) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableAccountsResults { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableAccountsResults { pub fn agents(&self) -> MapAgentIDToImmutableBytes { - MapAgentIDToImmutableBytes { obj_id: self.id } + MapAgentIDToImmutableBytes { proxy: self.proxy.clone() } } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MapAgentIDToMutableBytes { - pub(crate) obj_id: i32, + pub(crate) proxy: Proxy, } impl MapAgentIDToMutableBytes { pub fn clear(&self) { - clear(self.obj_id); + self.proxy.clear_map(); } pub fn get_bytes(&self, key: &ScAgentID) -> ScMutableBytes { - ScMutableBytes::new(self.obj_id, key.get_key_id()) + ScMutableBytes::new(self.proxy.key(&agent_id_to_bytes(key))) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableAccountsResults { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableAccountsResults { pub fn agents(&self) -> MapAgentIDToMutableBytes { - MapAgentIDToMutableBytes { obj_id: self.id } + MapAgentIDToMutableBytes { proxy: self.proxy.clone() } } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MapColorToImmutableInt64 { - pub(crate) obj_id: i32, + pub(crate) proxy: Proxy, } impl MapColorToImmutableInt64 { pub fn get_int64(&self, key: &ScColor) -> ScImmutableInt64 { - ScImmutableInt64::new(self.obj_id, key.get_key_id()) + ScImmutableInt64::new(self.proxy.key(&color_to_bytes(key))) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableBalanceResults { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableBalanceResults { pub fn balances(&self) -> MapColorToImmutableInt64 { - MapColorToImmutableInt64 { obj_id: self.id } + MapColorToImmutableInt64 { proxy: self.proxy.clone() } } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MapColorToMutableInt64 { - pub(crate) obj_id: i32, + pub(crate) proxy: Proxy, } impl MapColorToMutableInt64 { pub fn clear(&self) { - clear(self.obj_id); + self.proxy.clear_map(); } pub fn get_int64(&self, key: &ScColor) -> ScMutableInt64 { - ScMutableInt64::new(self.obj_id, key.get_key_id()) + ScMutableInt64::new(self.proxy.key(&color_to_bytes(key))) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableBalanceResults { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableBalanceResults { pub fn balances(&self) -> MapColorToMutableInt64 { - MapColorToMutableInt64 { obj_id: self.id } + MapColorToMutableInt64 { proxy: self.proxy.clone() } } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableGetAccountNonceResults { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableGetAccountNonceResults { pub fn account_nonce(&self) -> ScImmutableInt64 { - ScImmutableInt64::new(self.id, RESULT_ACCOUNT_NONCE.get_key_id()) + ScImmutableInt64::new(self.proxy.root(RESULT_ACCOUNT_NONCE)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableGetAccountNonceResults { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableGetAccountNonceResults { pub fn account_nonce(&self) -> ScMutableInt64 { - ScMutableInt64::new(self.id, RESULT_ACCOUNT_NONCE.get_key_id()) + ScMutableInt64::new(self.proxy.root(RESULT_ACCOUNT_NONCE)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableTotalAssetsResults { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableTotalAssetsResults { pub fn balances(&self) -> MapColorToImmutableInt64 { - MapColorToImmutableInt64 { obj_id: self.id } + MapColorToImmutableInt64 { proxy: self.proxy.clone() } } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableTotalAssetsResults { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableTotalAssetsResults { pub fn balances(&self) -> MapColorToMutableInt64 { - MapColorToMutableInt64 { obj_id: self.id } + MapColorToMutableInt64 { proxy: self.proxy.clone() } } } diff --git a/packages/wasmvm/wasmlib/src/coreblob/contract.rs b/packages/wasmvm/wasmlib/src/coreblob/contract.rs index 0f080a4c02..1b0b67aa40 100644 --- a/packages/wasmvm/wasmlib/src/coreblob/contract.rs +++ b/packages/wasmvm/wasmlib/src/coreblob/contract.rs @@ -7,8 +7,6 @@ #![allow(dead_code)] -use std::ptr; - use crate::*; use crate::coreblob::*; @@ -39,42 +37,45 @@ pub struct ScFuncs { } impl ScFuncs { - pub fn store_blob(_ctx: & dyn ScFuncCallContext) -> StoreBlobCall { + pub fn store_blob(_ctx: &dyn ScFuncCallContext) -> StoreBlobCall { let mut f = StoreBlobCall { func: ScFunc::new(HSC_NAME, HFUNC_STORE_BLOB), - params: MutableStoreBlobParams { id: 0 }, - results: ImmutableStoreBlobResults { id: 0 }, + params: MutableStoreBlobParams { proxy: Proxy::nil() }, + results: ImmutableStoreBlobResults { proxy: Proxy::nil() }, }; - f.func.set_ptrs(&mut f.params.id, &mut f.results.id); + ScFunc::link_params(&mut f.params.proxy, &f.func); + ScFunc::link_results(&mut f.results.proxy, &f.func); f } - pub fn get_blob_field(_ctx: & dyn ScViewCallContext) -> GetBlobFieldCall { + pub fn get_blob_field(_ctx: &dyn ScViewCallContext) -> GetBlobFieldCall { let mut f = GetBlobFieldCall { func: ScView::new(HSC_NAME, HVIEW_GET_BLOB_FIELD), - params: MutableGetBlobFieldParams { id: 0 }, - results: ImmutableGetBlobFieldResults { id: 0 }, + params: MutableGetBlobFieldParams { proxy: Proxy::nil() }, + results: ImmutableGetBlobFieldResults { proxy: Proxy::nil() }, }; - f.func.set_ptrs(&mut f.params.id, &mut f.results.id); + ScView::link_params(&mut f.params.proxy, &f.func); + ScView::link_results(&mut f.results.proxy, &f.func); f } - pub fn get_blob_info(_ctx: & dyn ScViewCallContext) -> GetBlobInfoCall { + pub fn get_blob_info(_ctx: &dyn ScViewCallContext) -> GetBlobInfoCall { let mut f = GetBlobInfoCall { func: ScView::new(HSC_NAME, HVIEW_GET_BLOB_INFO), - params: MutableGetBlobInfoParams { id: 0 }, - results: ImmutableGetBlobInfoResults { id: 0 }, + params: MutableGetBlobInfoParams { proxy: Proxy::nil() }, + results: ImmutableGetBlobInfoResults { proxy: Proxy::nil() }, }; - f.func.set_ptrs(&mut f.params.id, &mut f.results.id); + ScView::link_params(&mut f.params.proxy, &f.func); + ScView::link_results(&mut f.results.proxy, &f.func); f } - pub fn list_blobs(_ctx: & dyn ScViewCallContext) -> ListBlobsCall { + pub fn list_blobs(_ctx: &dyn ScViewCallContext) -> ListBlobsCall { let mut f = ListBlobsCall { func: ScView::new(HSC_NAME, HVIEW_LIST_BLOBS), - results: ImmutableListBlobsResults { id: 0 }, + results: ImmutableListBlobsResults { proxy: Proxy::nil() }, }; - f.func.set_ptrs(ptr::null_mut(), &mut f.results.id); + ScView::link_results(&mut f.results.proxy, &f.func); f } } diff --git a/packages/wasmvm/wasmlib/src/coreblob/params.rs b/packages/wasmvm/wasmlib/src/coreblob/params.rs index 736edcdcfd..e57029ccfd 100644 --- a/packages/wasmvm/wasmlib/src/coreblob/params.rs +++ b/packages/wasmvm/wasmlib/src/coreblob/params.rs @@ -8,106 +8,105 @@ #![allow(dead_code)] #![allow(unused_imports)] -use crate::*; use crate::coreblob::*; -use crate::host::*; +use crate::*; -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MapStringToImmutableBytes { - pub(crate) obj_id: i32, + pub(crate) proxy: Proxy, } impl MapStringToImmutableBytes { pub fn get_bytes(&self, key: &str) -> ScImmutableBytes { - ScImmutableBytes::new(self.obj_id, key.get_key_id()) + ScImmutableBytes::new(self.proxy.key(&string_to_bytes(key))) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableStoreBlobParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableStoreBlobParams { pub fn blobs(&self) -> MapStringToImmutableBytes { - MapStringToImmutableBytes { obj_id: self.id } + MapStringToImmutableBytes { proxy: self.proxy.clone() } } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MapStringToMutableBytes { - pub(crate) obj_id: i32, + pub(crate) proxy: Proxy, } impl MapStringToMutableBytes { pub fn clear(&self) { - clear(self.obj_id); + self.proxy.clear_map(); } pub fn get_bytes(&self, key: &str) -> ScMutableBytes { - ScMutableBytes::new(self.obj_id, key.get_key_id()) + ScMutableBytes::new(self.proxy.key(&string_to_bytes(key))) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableStoreBlobParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableStoreBlobParams { pub fn blobs(&self) -> MapStringToMutableBytes { - MapStringToMutableBytes { obj_id: self.id } + MapStringToMutableBytes { proxy: self.proxy.clone() } } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableGetBlobFieldParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableGetBlobFieldParams { pub fn field(&self) -> ScImmutableString { - ScImmutableString::new(self.id, PARAM_FIELD.get_key_id()) + ScImmutableString::new(self.proxy.root(PARAM_FIELD)) } pub fn hash(&self) -> ScImmutableHash { - ScImmutableHash::new(self.id, PARAM_HASH.get_key_id()) + ScImmutableHash::new(self.proxy.root(PARAM_HASH)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableGetBlobFieldParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableGetBlobFieldParams { pub fn field(&self) -> ScMutableString { - ScMutableString::new(self.id, PARAM_FIELD.get_key_id()) + ScMutableString::new(self.proxy.root(PARAM_FIELD)) } pub fn hash(&self) -> ScMutableHash { - ScMutableHash::new(self.id, PARAM_HASH.get_key_id()) + ScMutableHash::new(self.proxy.root(PARAM_HASH)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableGetBlobInfoParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableGetBlobInfoParams { pub fn hash(&self) -> ScImmutableHash { - ScImmutableHash::new(self.id, PARAM_HASH.get_key_id()) + ScImmutableHash::new(self.proxy.root(PARAM_HASH)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableGetBlobInfoParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableGetBlobInfoParams { pub fn hash(&self) -> ScMutableHash { - ScMutableHash::new(self.id, PARAM_HASH.get_key_id()) + ScMutableHash::new(self.proxy.root(PARAM_HASH)) } } diff --git a/packages/wasmvm/wasmlib/src/coreblob/results.rs b/packages/wasmvm/wasmlib/src/coreblob/results.rs index c040ca1241..5cf71cd7ec 100644 --- a/packages/wasmvm/wasmlib/src/coreblob/results.rs +++ b/packages/wasmvm/wasmlib/src/coreblob/results.rs @@ -8,146 +8,145 @@ #![allow(dead_code)] #![allow(unused_imports)] -use crate::*; use crate::coreblob::*; -use crate::host::*; +use crate::*; -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableStoreBlobResults { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableStoreBlobResults { pub fn hash(&self) -> ScImmutableHash { - ScImmutableHash::new(self.id, RESULT_HASH.get_key_id()) + ScImmutableHash::new(self.proxy.root(RESULT_HASH)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableStoreBlobResults { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableStoreBlobResults { pub fn hash(&self) -> ScMutableHash { - ScMutableHash::new(self.id, RESULT_HASH.get_key_id()) + ScMutableHash::new(self.proxy.root(RESULT_HASH)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableGetBlobFieldResults { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableGetBlobFieldResults { pub fn bytes(&self) -> ScImmutableBytes { - ScImmutableBytes::new(self.id, RESULT_BYTES.get_key_id()) + ScImmutableBytes::new(self.proxy.root(RESULT_BYTES)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableGetBlobFieldResults { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableGetBlobFieldResults { pub fn bytes(&self) -> ScMutableBytes { - ScMutableBytes::new(self.id, RESULT_BYTES.get_key_id()) + ScMutableBytes::new(self.proxy.root(RESULT_BYTES)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MapStringToImmutableInt32 { - pub(crate) obj_id: i32, + pub(crate) proxy: Proxy, } impl MapStringToImmutableInt32 { pub fn get_int32(&self, key: &str) -> ScImmutableInt32 { - ScImmutableInt32::new(self.obj_id, key.get_key_id()) + ScImmutableInt32::new(self.proxy.key(&string_to_bytes(key))) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableGetBlobInfoResults { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableGetBlobInfoResults { pub fn blob_sizes(&self) -> MapStringToImmutableInt32 { - MapStringToImmutableInt32 { obj_id: self.id } + MapStringToImmutableInt32 { proxy: self.proxy.clone() } } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MapStringToMutableInt32 { - pub(crate) obj_id: i32, + pub(crate) proxy: Proxy, } impl MapStringToMutableInt32 { pub fn clear(&self) { - clear(self.obj_id); + self.proxy.clear_map(); } pub fn get_int32(&self, key: &str) -> ScMutableInt32 { - ScMutableInt32::new(self.obj_id, key.get_key_id()) + ScMutableInt32::new(self.proxy.key(&string_to_bytes(key))) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableGetBlobInfoResults { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableGetBlobInfoResults { pub fn blob_sizes(&self) -> MapStringToMutableInt32 { - MapStringToMutableInt32 { obj_id: self.id } + MapStringToMutableInt32 { proxy: self.proxy.clone() } } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MapHashToImmutableInt32 { - pub(crate) obj_id: i32, + pub(crate) proxy: Proxy, } impl MapHashToImmutableInt32 { pub fn get_int32(&self, key: &ScHash) -> ScImmutableInt32 { - ScImmutableInt32::new(self.obj_id, key.get_key_id()) + ScImmutableInt32::new(self.proxy.key(&hash_to_bytes(key))) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableListBlobsResults { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableListBlobsResults { pub fn blob_sizes(&self) -> MapHashToImmutableInt32 { - MapHashToImmutableInt32 { obj_id: self.id } + MapHashToImmutableInt32 { proxy: self.proxy.clone() } } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MapHashToMutableInt32 { - pub(crate) obj_id: i32, + pub(crate) proxy: Proxy, } impl MapHashToMutableInt32 { pub fn clear(&self) { - clear(self.obj_id); + self.proxy.clear_map(); } pub fn get_int32(&self, key: &ScHash) -> ScMutableInt32 { - ScMutableInt32::new(self.obj_id, key.get_key_id()) + ScMutableInt32::new(self.proxy.key(&hash_to_bytes(key))) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableListBlobsResults { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableListBlobsResults { pub fn blob_sizes(&self) -> MapHashToMutableInt32 { - MapHashToMutableInt32 { obj_id: self.id } + MapHashToMutableInt32 { proxy: self.proxy.clone() } } } diff --git a/packages/wasmvm/wasmlib/src/coreblocklog/contract.rs b/packages/wasmvm/wasmlib/src/coreblocklog/contract.rs index e8bad48177..c6e03dbe64 100644 --- a/packages/wasmvm/wasmlib/src/coreblocklog/contract.rs +++ b/packages/wasmvm/wasmlib/src/coreblocklog/contract.rs @@ -7,8 +7,6 @@ #![allow(dead_code)] -use std::ptr; - use crate::*; use crate::coreblocklog::*; @@ -74,101 +72,109 @@ pub struct ScFuncs { } impl ScFuncs { - pub fn control_addresses(_ctx: & dyn ScViewCallContext) -> ControlAddressesCall { + pub fn control_addresses(_ctx: &dyn ScViewCallContext) -> ControlAddressesCall { let mut f = ControlAddressesCall { func: ScView::new(HSC_NAME, HVIEW_CONTROL_ADDRESSES), - results: ImmutableControlAddressesResults { id: 0 }, + results: ImmutableControlAddressesResults { proxy: Proxy::nil() }, }; - f.func.set_ptrs(ptr::null_mut(), &mut f.results.id); + ScView::link_results(&mut f.results.proxy, &f.func); f } - pub fn get_block_info(_ctx: & dyn ScViewCallContext) -> GetBlockInfoCall { + pub fn get_block_info(_ctx: &dyn ScViewCallContext) -> GetBlockInfoCall { let mut f = GetBlockInfoCall { func: ScView::new(HSC_NAME, HVIEW_GET_BLOCK_INFO), - params: MutableGetBlockInfoParams { id: 0 }, - results: ImmutableGetBlockInfoResults { id: 0 }, + params: MutableGetBlockInfoParams { proxy: Proxy::nil() }, + results: ImmutableGetBlockInfoResults { proxy: Proxy::nil() }, }; - f.func.set_ptrs(&mut f.params.id, &mut f.results.id); + ScView::link_params(&mut f.params.proxy, &f.func); + ScView::link_results(&mut f.results.proxy, &f.func); f } - pub fn get_events_for_block(_ctx: & dyn ScViewCallContext) -> GetEventsForBlockCall { + pub fn get_events_for_block(_ctx: &dyn ScViewCallContext) -> GetEventsForBlockCall { let mut f = GetEventsForBlockCall { func: ScView::new(HSC_NAME, HVIEW_GET_EVENTS_FOR_BLOCK), - params: MutableGetEventsForBlockParams { id: 0 }, - results: ImmutableGetEventsForBlockResults { id: 0 }, + params: MutableGetEventsForBlockParams { proxy: Proxy::nil() }, + results: ImmutableGetEventsForBlockResults { proxy: Proxy::nil() }, }; - f.func.set_ptrs(&mut f.params.id, &mut f.results.id); + ScView::link_params(&mut f.params.proxy, &f.func); + ScView::link_results(&mut f.results.proxy, &f.func); f } - pub fn get_events_for_contract(_ctx: & dyn ScViewCallContext) -> GetEventsForContractCall { + pub fn get_events_for_contract(_ctx: &dyn ScViewCallContext) -> GetEventsForContractCall { let mut f = GetEventsForContractCall { func: ScView::new(HSC_NAME, HVIEW_GET_EVENTS_FOR_CONTRACT), - params: MutableGetEventsForContractParams { id: 0 }, - results: ImmutableGetEventsForContractResults { id: 0 }, + params: MutableGetEventsForContractParams { proxy: Proxy::nil() }, + results: ImmutableGetEventsForContractResults { proxy: Proxy::nil() }, }; - f.func.set_ptrs(&mut f.params.id, &mut f.results.id); + ScView::link_params(&mut f.params.proxy, &f.func); + ScView::link_results(&mut f.results.proxy, &f.func); f } - pub fn get_events_for_request(_ctx: & dyn ScViewCallContext) -> GetEventsForRequestCall { + pub fn get_events_for_request(_ctx: &dyn ScViewCallContext) -> GetEventsForRequestCall { let mut f = GetEventsForRequestCall { func: ScView::new(HSC_NAME, HVIEW_GET_EVENTS_FOR_REQUEST), - params: MutableGetEventsForRequestParams { id: 0 }, - results: ImmutableGetEventsForRequestResults { id: 0 }, + params: MutableGetEventsForRequestParams { proxy: Proxy::nil() }, + results: ImmutableGetEventsForRequestResults { proxy: Proxy::nil() }, }; - f.func.set_ptrs(&mut f.params.id, &mut f.results.id); + ScView::link_params(&mut f.params.proxy, &f.func); + ScView::link_results(&mut f.results.proxy, &f.func); f } - pub fn get_latest_block_info(_ctx: & dyn ScViewCallContext) -> GetLatestBlockInfoCall { + pub fn get_latest_block_info(_ctx: &dyn ScViewCallContext) -> GetLatestBlockInfoCall { let mut f = GetLatestBlockInfoCall { func: ScView::new(HSC_NAME, HVIEW_GET_LATEST_BLOCK_INFO), - results: ImmutableGetLatestBlockInfoResults { id: 0 }, + results: ImmutableGetLatestBlockInfoResults { proxy: Proxy::nil() }, }; - f.func.set_ptrs(ptr::null_mut(), &mut f.results.id); + ScView::link_results(&mut f.results.proxy, &f.func); f } - pub fn get_request_i_ds_for_block(_ctx: & dyn ScViewCallContext) -> GetRequestIDsForBlockCall { + pub fn get_request_i_ds_for_block(_ctx: &dyn ScViewCallContext) -> GetRequestIDsForBlockCall { let mut f = GetRequestIDsForBlockCall { func: ScView::new(HSC_NAME, HVIEW_GET_REQUEST_I_DS_FOR_BLOCK), - params: MutableGetRequestIDsForBlockParams { id: 0 }, - results: ImmutableGetRequestIDsForBlockResults { id: 0 }, + params: MutableGetRequestIDsForBlockParams { proxy: Proxy::nil() }, + results: ImmutableGetRequestIDsForBlockResults { proxy: Proxy::nil() }, }; - f.func.set_ptrs(&mut f.params.id, &mut f.results.id); + ScView::link_params(&mut f.params.proxy, &f.func); + ScView::link_results(&mut f.results.proxy, &f.func); f } - pub fn get_request_receipt(_ctx: & dyn ScViewCallContext) -> GetRequestReceiptCall { + pub fn get_request_receipt(_ctx: &dyn ScViewCallContext) -> GetRequestReceiptCall { let mut f = GetRequestReceiptCall { func: ScView::new(HSC_NAME, HVIEW_GET_REQUEST_RECEIPT), - params: MutableGetRequestReceiptParams { id: 0 }, - results: ImmutableGetRequestReceiptResults { id: 0 }, + params: MutableGetRequestReceiptParams { proxy: Proxy::nil() }, + results: ImmutableGetRequestReceiptResults { proxy: Proxy::nil() }, }; - f.func.set_ptrs(&mut f.params.id, &mut f.results.id); + ScView::link_params(&mut f.params.proxy, &f.func); + ScView::link_results(&mut f.results.proxy, &f.func); f } - pub fn get_request_receipts_for_block(_ctx: & dyn ScViewCallContext) -> GetRequestReceiptsForBlockCall { + pub fn get_request_receipts_for_block(_ctx: &dyn ScViewCallContext) -> GetRequestReceiptsForBlockCall { let mut f = GetRequestReceiptsForBlockCall { func: ScView::new(HSC_NAME, HVIEW_GET_REQUEST_RECEIPTS_FOR_BLOCK), - params: MutableGetRequestReceiptsForBlockParams { id: 0 }, - results: ImmutableGetRequestReceiptsForBlockResults { id: 0 }, + params: MutableGetRequestReceiptsForBlockParams { proxy: Proxy::nil() }, + results: ImmutableGetRequestReceiptsForBlockResults { proxy: Proxy::nil() }, }; - f.func.set_ptrs(&mut f.params.id, &mut f.results.id); + ScView::link_params(&mut f.params.proxy, &f.func); + ScView::link_results(&mut f.results.proxy, &f.func); f } - pub fn is_request_processed(_ctx: & dyn ScViewCallContext) -> IsRequestProcessedCall { + pub fn is_request_processed(_ctx: &dyn ScViewCallContext) -> IsRequestProcessedCall { let mut f = IsRequestProcessedCall { func: ScView::new(HSC_NAME, HVIEW_IS_REQUEST_PROCESSED), - params: MutableIsRequestProcessedParams { id: 0 }, - results: ImmutableIsRequestProcessedResults { id: 0 }, + params: MutableIsRequestProcessedParams { proxy: Proxy::nil() }, + results: ImmutableIsRequestProcessedResults { proxy: Proxy::nil() }, }; - f.func.set_ptrs(&mut f.params.id, &mut f.results.id); + ScView::link_params(&mut f.params.proxy, &f.func); + ScView::link_results(&mut f.results.proxy, &f.func); f } } diff --git a/packages/wasmvm/wasmlib/src/coreblocklog/params.rs b/packages/wasmvm/wasmlib/src/coreblocklog/params.rs index e6af86d16c..ff71589a85 100644 --- a/packages/wasmvm/wasmlib/src/coreblocklog/params.rs +++ b/packages/wasmvm/wasmlib/src/coreblocklog/params.rs @@ -8,198 +8,197 @@ #![allow(dead_code)] #![allow(unused_imports)] -use crate::*; use crate::coreblocklog::*; -use crate::host::*; +use crate::*; -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableGetBlockInfoParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableGetBlockInfoParams { pub fn block_index(&self) -> ScImmutableUint32 { - ScImmutableUint32::new(self.id, PARAM_BLOCK_INDEX.get_key_id()) + ScImmutableUint32::new(self.proxy.root(PARAM_BLOCK_INDEX)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableGetBlockInfoParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableGetBlockInfoParams { pub fn block_index(&self) -> ScMutableUint32 { - ScMutableUint32::new(self.id, PARAM_BLOCK_INDEX.get_key_id()) + ScMutableUint32::new(self.proxy.root(PARAM_BLOCK_INDEX)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableGetEventsForBlockParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableGetEventsForBlockParams { pub fn block_index(&self) -> ScImmutableUint32 { - ScImmutableUint32::new(self.id, PARAM_BLOCK_INDEX.get_key_id()) + ScImmutableUint32::new(self.proxy.root(PARAM_BLOCK_INDEX)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableGetEventsForBlockParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableGetEventsForBlockParams { pub fn block_index(&self) -> ScMutableUint32 { - ScMutableUint32::new(self.id, PARAM_BLOCK_INDEX.get_key_id()) + ScMutableUint32::new(self.proxy.root(PARAM_BLOCK_INDEX)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableGetEventsForContractParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableGetEventsForContractParams { pub fn contract_hname(&self) -> ScImmutableHname { - ScImmutableHname::new(self.id, PARAM_CONTRACT_HNAME.get_key_id()) + ScImmutableHname::new(self.proxy.root(PARAM_CONTRACT_HNAME)) } pub fn from_block(&self) -> ScImmutableUint32 { - ScImmutableUint32::new(self.id, PARAM_FROM_BLOCK.get_key_id()) + ScImmutableUint32::new(self.proxy.root(PARAM_FROM_BLOCK)) } pub fn to_block(&self) -> ScImmutableUint32 { - ScImmutableUint32::new(self.id, PARAM_TO_BLOCK.get_key_id()) + ScImmutableUint32::new(self.proxy.root(PARAM_TO_BLOCK)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableGetEventsForContractParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableGetEventsForContractParams { pub fn contract_hname(&self) -> ScMutableHname { - ScMutableHname::new(self.id, PARAM_CONTRACT_HNAME.get_key_id()) + ScMutableHname::new(self.proxy.root(PARAM_CONTRACT_HNAME)) } pub fn from_block(&self) -> ScMutableUint32 { - ScMutableUint32::new(self.id, PARAM_FROM_BLOCK.get_key_id()) + ScMutableUint32::new(self.proxy.root(PARAM_FROM_BLOCK)) } pub fn to_block(&self) -> ScMutableUint32 { - ScMutableUint32::new(self.id, PARAM_TO_BLOCK.get_key_id()) + ScMutableUint32::new(self.proxy.root(PARAM_TO_BLOCK)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableGetEventsForRequestParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableGetEventsForRequestParams { pub fn request_id(&self) -> ScImmutableRequestID { - ScImmutableRequestID::new(self.id, PARAM_REQUEST_ID.get_key_id()) + ScImmutableRequestID::new(self.proxy.root(PARAM_REQUEST_ID)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableGetEventsForRequestParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableGetEventsForRequestParams { pub fn request_id(&self) -> ScMutableRequestID { - ScMutableRequestID::new(self.id, PARAM_REQUEST_ID.get_key_id()) + ScMutableRequestID::new(self.proxy.root(PARAM_REQUEST_ID)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableGetRequestIDsForBlockParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableGetRequestIDsForBlockParams { pub fn block_index(&self) -> ScImmutableUint32 { - ScImmutableUint32::new(self.id, PARAM_BLOCK_INDEX.get_key_id()) + ScImmutableUint32::new(self.proxy.root(PARAM_BLOCK_INDEX)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableGetRequestIDsForBlockParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableGetRequestIDsForBlockParams { pub fn block_index(&self) -> ScMutableUint32 { - ScMutableUint32::new(self.id, PARAM_BLOCK_INDEX.get_key_id()) + ScMutableUint32::new(self.proxy.root(PARAM_BLOCK_INDEX)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableGetRequestReceiptParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableGetRequestReceiptParams { pub fn request_id(&self) -> ScImmutableRequestID { - ScImmutableRequestID::new(self.id, PARAM_REQUEST_ID.get_key_id()) + ScImmutableRequestID::new(self.proxy.root(PARAM_REQUEST_ID)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableGetRequestReceiptParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableGetRequestReceiptParams { pub fn request_id(&self) -> ScMutableRequestID { - ScMutableRequestID::new(self.id, PARAM_REQUEST_ID.get_key_id()) + ScMutableRequestID::new(self.proxy.root(PARAM_REQUEST_ID)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableGetRequestReceiptsForBlockParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableGetRequestReceiptsForBlockParams { pub fn block_index(&self) -> ScImmutableUint32 { - ScImmutableUint32::new(self.id, PARAM_BLOCK_INDEX.get_key_id()) + ScImmutableUint32::new(self.proxy.root(PARAM_BLOCK_INDEX)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableGetRequestReceiptsForBlockParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableGetRequestReceiptsForBlockParams { pub fn block_index(&self) -> ScMutableUint32 { - ScMutableUint32::new(self.id, PARAM_BLOCK_INDEX.get_key_id()) + ScMutableUint32::new(self.proxy.root(PARAM_BLOCK_INDEX)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableIsRequestProcessedParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableIsRequestProcessedParams { pub fn request_id(&self) -> ScImmutableRequestID { - ScImmutableRequestID::new(self.id, PARAM_REQUEST_ID.get_key_id()) + ScImmutableRequestID::new(self.proxy.root(PARAM_REQUEST_ID)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableIsRequestProcessedParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableIsRequestProcessedParams { pub fn request_id(&self) -> ScMutableRequestID { - ScMutableRequestID::new(self.id, PARAM_REQUEST_ID.get_key_id()) + ScMutableRequestID::new(self.proxy.root(PARAM_REQUEST_ID)) } } diff --git a/packages/wasmvm/wasmlib/src/coreblocklog/results.rs b/packages/wasmvm/wasmlib/src/coreblocklog/results.rs index fb13f646eb..983409e75a 100644 --- a/packages/wasmvm/wasmlib/src/coreblocklog/results.rs +++ b/packages/wasmvm/wasmlib/src/coreblocklog/results.rs @@ -8,344 +8,341 @@ #![allow(dead_code)] #![allow(unused_imports)] -use crate::*; use crate::coreblocklog::*; -use crate::host::*; +use crate::*; -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableControlAddressesResults { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableControlAddressesResults { pub fn block_index(&self) -> ScImmutableUint32 { - ScImmutableUint32::new(self.id, RESULT_BLOCK_INDEX.get_key_id()) + ScImmutableUint32::new(self.proxy.root(RESULT_BLOCK_INDEX)) } pub fn governing_address(&self) -> ScImmutableAddress { - ScImmutableAddress::new(self.id, RESULT_GOVERNING_ADDRESS.get_key_id()) + ScImmutableAddress::new(self.proxy.root(RESULT_GOVERNING_ADDRESS)) } pub fn state_controller_address(&self) -> ScImmutableAddress { - ScImmutableAddress::new(self.id, RESULT_STATE_CONTROLLER_ADDRESS.get_key_id()) + ScImmutableAddress::new(self.proxy.root(RESULT_STATE_CONTROLLER_ADDRESS)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableControlAddressesResults { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableControlAddressesResults { pub fn block_index(&self) -> ScMutableUint32 { - ScMutableUint32::new(self.id, RESULT_BLOCK_INDEX.get_key_id()) + ScMutableUint32::new(self.proxy.root(RESULT_BLOCK_INDEX)) } pub fn governing_address(&self) -> ScMutableAddress { - ScMutableAddress::new(self.id, RESULT_GOVERNING_ADDRESS.get_key_id()) + ScMutableAddress::new(self.proxy.root(RESULT_GOVERNING_ADDRESS)) } pub fn state_controller_address(&self) -> ScMutableAddress { - ScMutableAddress::new(self.id, RESULT_STATE_CONTROLLER_ADDRESS.get_key_id()) + ScMutableAddress::new(self.proxy.root(RESULT_STATE_CONTROLLER_ADDRESS)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableGetBlockInfoResults { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableGetBlockInfoResults { pub fn block_info(&self) -> ScImmutableBytes { - ScImmutableBytes::new(self.id, RESULT_BLOCK_INFO.get_key_id()) + ScImmutableBytes::new(self.proxy.root(RESULT_BLOCK_INFO)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableGetBlockInfoResults { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableGetBlockInfoResults { pub fn block_info(&self) -> ScMutableBytes { - ScMutableBytes::new(self.id, RESULT_BLOCK_INFO.get_key_id()) + ScMutableBytes::new(self.proxy.root(RESULT_BLOCK_INFO)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ArrayOfImmutableBytes { - pub(crate) obj_id: i32, + pub(crate) proxy: Proxy, } impl ArrayOfImmutableBytes { pub fn length(&self) -> u32 { - get_length(self.obj_id) + self.proxy.length() } pub fn get_bytes(&self, index: u32) -> ScImmutableBytes { - ScImmutableBytes::new(self.obj_id, Key32(index as i32)) + ScImmutableBytes::new(self.proxy.index(index)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableGetEventsForBlockResults { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableGetEventsForBlockResults { pub fn event(&self) -> ArrayOfImmutableBytes { - let arr_id = get_object_id(self.id, RESULT_EVENT.get_key_id(), TYPE_ARRAY16 | TYPE_BYTES); - ArrayOfImmutableBytes { obj_id: arr_id } + ArrayOfImmutableBytes { proxy: self.proxy.root(RESULT_EVENT) } } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ArrayOfMutableBytes { - pub(crate) obj_id: i32, + pub(crate) proxy: Proxy, } impl ArrayOfMutableBytes { - pub fn clear(&self) { - clear(self.obj_id); + pub fn append_bytes(&self) -> ScMutableBytes { + ScMutableBytes::new(self.proxy.append()) + } + + pub fn clear(&self) { + self.proxy.clear_array(); } pub fn length(&self) -> u32 { - get_length(self.obj_id) + self.proxy.length() } pub fn get_bytes(&self, index: u32) -> ScMutableBytes { - ScMutableBytes::new(self.obj_id, Key32(index as i32)) + ScMutableBytes::new(self.proxy.index(index)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableGetEventsForBlockResults { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableGetEventsForBlockResults { pub fn event(&self) -> ArrayOfMutableBytes { - let arr_id = get_object_id(self.id, RESULT_EVENT.get_key_id(), TYPE_ARRAY16 | TYPE_BYTES); - ArrayOfMutableBytes { obj_id: arr_id } + ArrayOfMutableBytes { proxy: self.proxy.root(RESULT_EVENT) } } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableGetEventsForContractResults { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableGetEventsForContractResults { pub fn event(&self) -> ArrayOfImmutableBytes { - let arr_id = get_object_id(self.id, RESULT_EVENT.get_key_id(), TYPE_ARRAY16 | TYPE_BYTES); - ArrayOfImmutableBytes { obj_id: arr_id } + ArrayOfImmutableBytes { proxy: self.proxy.root(RESULT_EVENT) } } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableGetEventsForContractResults { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableGetEventsForContractResults { pub fn event(&self) -> ArrayOfMutableBytes { - let arr_id = get_object_id(self.id, RESULT_EVENT.get_key_id(), TYPE_ARRAY16 | TYPE_BYTES); - ArrayOfMutableBytes { obj_id: arr_id } + ArrayOfMutableBytes { proxy: self.proxy.root(RESULT_EVENT) } } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableGetEventsForRequestResults { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableGetEventsForRequestResults { pub fn event(&self) -> ArrayOfImmutableBytes { - let arr_id = get_object_id(self.id, RESULT_EVENT.get_key_id(), TYPE_ARRAY16 | TYPE_BYTES); - ArrayOfImmutableBytes { obj_id: arr_id } + ArrayOfImmutableBytes { proxy: self.proxy.root(RESULT_EVENT) } } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableGetEventsForRequestResults { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableGetEventsForRequestResults { pub fn event(&self) -> ArrayOfMutableBytes { - let arr_id = get_object_id(self.id, RESULT_EVENT.get_key_id(), TYPE_ARRAY16 | TYPE_BYTES); - ArrayOfMutableBytes { obj_id: arr_id } + ArrayOfMutableBytes { proxy: self.proxy.root(RESULT_EVENT) } } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableGetLatestBlockInfoResults { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableGetLatestBlockInfoResults { pub fn block_index(&self) -> ScImmutableUint32 { - ScImmutableUint32::new(self.id, RESULT_BLOCK_INDEX.get_key_id()) + ScImmutableUint32::new(self.proxy.root(RESULT_BLOCK_INDEX)) } pub fn block_info(&self) -> ScImmutableBytes { - ScImmutableBytes::new(self.id, RESULT_BLOCK_INFO.get_key_id()) + ScImmutableBytes::new(self.proxy.root(RESULT_BLOCK_INFO)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableGetLatestBlockInfoResults { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableGetLatestBlockInfoResults { pub fn block_index(&self) -> ScMutableUint32 { - ScMutableUint32::new(self.id, RESULT_BLOCK_INDEX.get_key_id()) + ScMutableUint32::new(self.proxy.root(RESULT_BLOCK_INDEX)) } pub fn block_info(&self) -> ScMutableBytes { - ScMutableBytes::new(self.id, RESULT_BLOCK_INFO.get_key_id()) + ScMutableBytes::new(self.proxy.root(RESULT_BLOCK_INFO)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ArrayOfImmutableRequestID { - pub(crate) obj_id: i32, + pub(crate) proxy: Proxy, } impl ArrayOfImmutableRequestID { pub fn length(&self) -> u32 { - get_length(self.obj_id) + self.proxy.length() } pub fn get_request_id(&self, index: u32) -> ScImmutableRequestID { - ScImmutableRequestID::new(self.obj_id, Key32(index as i32)) + ScImmutableRequestID::new(self.proxy.index(index)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableGetRequestIDsForBlockResults { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableGetRequestIDsForBlockResults { pub fn request_id(&self) -> ArrayOfImmutableRequestID { - let arr_id = get_object_id(self.id, RESULT_REQUEST_ID.get_key_id(), TYPE_ARRAY16 | TYPE_REQUEST_ID); - ArrayOfImmutableRequestID { obj_id: arr_id } + ArrayOfImmutableRequestID { proxy: self.proxy.root(RESULT_REQUEST_ID) } } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ArrayOfMutableRequestID { - pub(crate) obj_id: i32, + pub(crate) proxy: Proxy, } impl ArrayOfMutableRequestID { - pub fn clear(&self) { - clear(self.obj_id); + pub fn append_request_id(&self) -> ScMutableRequestID { + ScMutableRequestID::new(self.proxy.append()) + } + + pub fn clear(&self) { + self.proxy.clear_array(); } pub fn length(&self) -> u32 { - get_length(self.obj_id) + self.proxy.length() } pub fn get_request_id(&self, index: u32) -> ScMutableRequestID { - ScMutableRequestID::new(self.obj_id, Key32(index as i32)) + ScMutableRequestID::new(self.proxy.index(index)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableGetRequestIDsForBlockResults { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableGetRequestIDsForBlockResults { pub fn request_id(&self) -> ArrayOfMutableRequestID { - let arr_id = get_object_id(self.id, RESULT_REQUEST_ID.get_key_id(), TYPE_ARRAY16 | TYPE_REQUEST_ID); - ArrayOfMutableRequestID { obj_id: arr_id } + ArrayOfMutableRequestID { proxy: self.proxy.root(RESULT_REQUEST_ID) } } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableGetRequestReceiptResults { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableGetRequestReceiptResults { pub fn block_index(&self) -> ScImmutableUint32 { - ScImmutableUint32::new(self.id, RESULT_BLOCK_INDEX.get_key_id()) + ScImmutableUint32::new(self.proxy.root(RESULT_BLOCK_INDEX)) } pub fn request_index(&self) -> ScImmutableUint16 { - ScImmutableUint16::new(self.id, RESULT_REQUEST_INDEX.get_key_id()) + ScImmutableUint16::new(self.proxy.root(RESULT_REQUEST_INDEX)) } pub fn request_record(&self) -> ScImmutableBytes { - ScImmutableBytes::new(self.id, RESULT_REQUEST_RECORD.get_key_id()) + ScImmutableBytes::new(self.proxy.root(RESULT_REQUEST_RECORD)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableGetRequestReceiptResults { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableGetRequestReceiptResults { pub fn block_index(&self) -> ScMutableUint32 { - ScMutableUint32::new(self.id, RESULT_BLOCK_INDEX.get_key_id()) + ScMutableUint32::new(self.proxy.root(RESULT_BLOCK_INDEX)) } pub fn request_index(&self) -> ScMutableUint16 { - ScMutableUint16::new(self.id, RESULT_REQUEST_INDEX.get_key_id()) + ScMutableUint16::new(self.proxy.root(RESULT_REQUEST_INDEX)) } pub fn request_record(&self) -> ScMutableBytes { - ScMutableBytes::new(self.id, RESULT_REQUEST_RECORD.get_key_id()) + ScMutableBytes::new(self.proxy.root(RESULT_REQUEST_RECORD)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableGetRequestReceiptsForBlockResults { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableGetRequestReceiptsForBlockResults { pub fn request_record(&self) -> ArrayOfImmutableBytes { - let arr_id = get_object_id(self.id, RESULT_REQUEST_RECORD.get_key_id(), TYPE_ARRAY16 | TYPE_BYTES); - ArrayOfImmutableBytes { obj_id: arr_id } + ArrayOfImmutableBytes { proxy: self.proxy.root(RESULT_REQUEST_RECORD) } } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableGetRequestReceiptsForBlockResults { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableGetRequestReceiptsForBlockResults { pub fn request_record(&self) -> ArrayOfMutableBytes { - let arr_id = get_object_id(self.id, RESULT_REQUEST_RECORD.get_key_id(), TYPE_ARRAY16 | TYPE_BYTES); - ArrayOfMutableBytes { obj_id: arr_id } + ArrayOfMutableBytes { proxy: self.proxy.root(RESULT_REQUEST_RECORD) } } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableIsRequestProcessedResults { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableIsRequestProcessedResults { pub fn request_processed(&self) -> ScImmutableString { - ScImmutableString::new(self.id, RESULT_REQUEST_PROCESSED.get_key_id()) + ScImmutableString::new(self.proxy.root(RESULT_REQUEST_PROCESSED)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableIsRequestProcessedResults { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableIsRequestProcessedResults { pub fn request_processed(&self) -> ScMutableString { - ScMutableString::new(self.id, RESULT_REQUEST_PROCESSED.get_key_id()) + ScMutableString::new(self.proxy.root(RESULT_REQUEST_PROCESSED)) } } diff --git a/packages/wasmvm/wasmlib/src/coregovernance/contract.rs b/packages/wasmvm/wasmlib/src/coregovernance/contract.rs index 333b15d675..4a45b3c799 100644 --- a/packages/wasmvm/wasmlib/src/coregovernance/contract.rs +++ b/packages/wasmvm/wasmlib/src/coregovernance/contract.rs @@ -7,8 +7,6 @@ #![allow(dead_code)] -use std::ptr; - use crate::*; use crate::coregovernance::*; @@ -76,109 +74,110 @@ pub struct ScFuncs { } impl ScFuncs { - pub fn add_allowed_state_controller_address(_ctx: & dyn ScFuncCallContext) -> AddAllowedStateControllerAddressCall { + pub fn add_allowed_state_controller_address(_ctx: &dyn ScFuncCallContext) -> AddAllowedStateControllerAddressCall { let mut f = AddAllowedStateControllerAddressCall { func: ScFunc::new(HSC_NAME, HFUNC_ADD_ALLOWED_STATE_CONTROLLER_ADDRESS), - params: MutableAddAllowedStateControllerAddressParams { id: 0 }, + params: MutableAddAllowedStateControllerAddressParams { proxy: Proxy::nil() }, }; - f.func.set_ptrs(&mut f.params.id, ptr::null_mut()); + ScFunc::link_params(&mut f.params.proxy, &f.func); f } - pub fn claim_chain_ownership(_ctx: & dyn ScFuncCallContext) -> ClaimChainOwnershipCall { + pub fn claim_chain_ownership(_ctx: &dyn ScFuncCallContext) -> ClaimChainOwnershipCall { ClaimChainOwnershipCall { func: ScFunc::new(HSC_NAME, HFUNC_CLAIM_CHAIN_OWNERSHIP), } } - pub fn delegate_chain_ownership(_ctx: & dyn ScFuncCallContext) -> DelegateChainOwnershipCall { + pub fn delegate_chain_ownership(_ctx: &dyn ScFuncCallContext) -> DelegateChainOwnershipCall { let mut f = DelegateChainOwnershipCall { func: ScFunc::new(HSC_NAME, HFUNC_DELEGATE_CHAIN_OWNERSHIP), - params: MutableDelegateChainOwnershipParams { id: 0 }, + params: MutableDelegateChainOwnershipParams { proxy: Proxy::nil() }, }; - f.func.set_ptrs(&mut f.params.id, ptr::null_mut()); + ScFunc::link_params(&mut f.params.proxy, &f.func); f } - pub fn remove_allowed_state_controller_address(_ctx: & dyn ScFuncCallContext) -> RemoveAllowedStateControllerAddressCall { + pub fn remove_allowed_state_controller_address(_ctx: &dyn ScFuncCallContext) -> RemoveAllowedStateControllerAddressCall { let mut f = RemoveAllowedStateControllerAddressCall { func: ScFunc::new(HSC_NAME, HFUNC_REMOVE_ALLOWED_STATE_CONTROLLER_ADDRESS), - params: MutableRemoveAllowedStateControllerAddressParams { id: 0 }, + params: MutableRemoveAllowedStateControllerAddressParams { proxy: Proxy::nil() }, }; - f.func.set_ptrs(&mut f.params.id, ptr::null_mut()); + ScFunc::link_params(&mut f.params.proxy, &f.func); f } - pub fn rotate_state_controller(_ctx: & dyn ScFuncCallContext) -> RotateStateControllerCall { + pub fn rotate_state_controller(_ctx: &dyn ScFuncCallContext) -> RotateStateControllerCall { let mut f = RotateStateControllerCall { func: ScFunc::new(HSC_NAME, HFUNC_ROTATE_STATE_CONTROLLER), - params: MutableRotateStateControllerParams { id: 0 }, + params: MutableRotateStateControllerParams { proxy: Proxy::nil() }, }; - f.func.set_ptrs(&mut f.params.id, ptr::null_mut()); + ScFunc::link_params(&mut f.params.proxy, &f.func); f } - pub fn set_chain_info(_ctx: & dyn ScFuncCallContext) -> SetChainInfoCall { + pub fn set_chain_info(_ctx: &dyn ScFuncCallContext) -> SetChainInfoCall { let mut f = SetChainInfoCall { func: ScFunc::new(HSC_NAME, HFUNC_SET_CHAIN_INFO), - params: MutableSetChainInfoParams { id: 0 }, + params: MutableSetChainInfoParams { proxy: Proxy::nil() }, }; - f.func.set_ptrs(&mut f.params.id, ptr::null_mut()); + ScFunc::link_params(&mut f.params.proxy, &f.func); f } - pub fn set_contract_fee(_ctx: & dyn ScFuncCallContext) -> SetContractFeeCall { + pub fn set_contract_fee(_ctx: &dyn ScFuncCallContext) -> SetContractFeeCall { let mut f = SetContractFeeCall { func: ScFunc::new(HSC_NAME, HFUNC_SET_CONTRACT_FEE), - params: MutableSetContractFeeParams { id: 0 }, + params: MutableSetContractFeeParams { proxy: Proxy::nil() }, }; - f.func.set_ptrs(&mut f.params.id, ptr::null_mut()); + ScFunc::link_params(&mut f.params.proxy, &f.func); f } - pub fn set_default_fee(_ctx: & dyn ScFuncCallContext) -> SetDefaultFeeCall { + pub fn set_default_fee(_ctx: &dyn ScFuncCallContext) -> SetDefaultFeeCall { let mut f = SetDefaultFeeCall { func: ScFunc::new(HSC_NAME, HFUNC_SET_DEFAULT_FEE), - params: MutableSetDefaultFeeParams { id: 0 }, + params: MutableSetDefaultFeeParams { proxy: Proxy::nil() }, }; - f.func.set_ptrs(&mut f.params.id, ptr::null_mut()); + ScFunc::link_params(&mut f.params.proxy, &f.func); f } - pub fn get_allowed_state_controller_addresses(_ctx: & dyn ScViewCallContext) -> GetAllowedStateControllerAddressesCall { + pub fn get_allowed_state_controller_addresses(_ctx: &dyn ScViewCallContext) -> GetAllowedStateControllerAddressesCall { let mut f = GetAllowedStateControllerAddressesCall { func: ScView::new(HSC_NAME, HVIEW_GET_ALLOWED_STATE_CONTROLLER_ADDRESSES), - results: ImmutableGetAllowedStateControllerAddressesResults { id: 0 }, + results: ImmutableGetAllowedStateControllerAddressesResults { proxy: Proxy::nil() }, }; - f.func.set_ptrs(ptr::null_mut(), &mut f.results.id); + ScView::link_results(&mut f.results.proxy, &f.func); f } - pub fn get_chain_info(_ctx: & dyn ScViewCallContext) -> GetChainInfoCall { + pub fn get_chain_info(_ctx: &dyn ScViewCallContext) -> GetChainInfoCall { let mut f = GetChainInfoCall { func: ScView::new(HSC_NAME, HVIEW_GET_CHAIN_INFO), - results: ImmutableGetChainInfoResults { id: 0 }, + results: ImmutableGetChainInfoResults { proxy: Proxy::nil() }, }; - f.func.set_ptrs(ptr::null_mut(), &mut f.results.id); + ScView::link_results(&mut f.results.proxy, &f.func); f } - pub fn get_fee_info(_ctx: & dyn ScViewCallContext) -> GetFeeInfoCall { + pub fn get_fee_info(_ctx: &dyn ScViewCallContext) -> GetFeeInfoCall { let mut f = GetFeeInfoCall { func: ScView::new(HSC_NAME, HVIEW_GET_FEE_INFO), - params: MutableGetFeeInfoParams { id: 0 }, - results: ImmutableGetFeeInfoResults { id: 0 }, + params: MutableGetFeeInfoParams { proxy: Proxy::nil() }, + results: ImmutableGetFeeInfoResults { proxy: Proxy::nil() }, }; - f.func.set_ptrs(&mut f.params.id, &mut f.results.id); + ScView::link_params(&mut f.params.proxy, &f.func); + ScView::link_results(&mut f.results.proxy, &f.func); f } - pub fn get_max_blob_size(_ctx: & dyn ScViewCallContext) -> GetMaxBlobSizeCall { + pub fn get_max_blob_size(_ctx: &dyn ScViewCallContext) -> GetMaxBlobSizeCall { let mut f = GetMaxBlobSizeCall { func: ScView::new(HSC_NAME, HVIEW_GET_MAX_BLOB_SIZE), - results: ImmutableGetMaxBlobSizeResults { id: 0 }, + results: ImmutableGetMaxBlobSizeResults { proxy: Proxy::nil() }, }; - f.func.set_ptrs(ptr::null_mut(), &mut f.results.id); + ScView::link_results(&mut f.results.proxy, &f.func); f } } diff --git a/packages/wasmvm/wasmlib/src/coregovernance/params.rs b/packages/wasmvm/wasmlib/src/coregovernance/params.rs index e995d10b14..95fed7c058 100644 --- a/packages/wasmvm/wasmlib/src/coregovernance/params.rs +++ b/packages/wasmvm/wasmlib/src/coregovernance/params.rs @@ -8,254 +8,253 @@ #![allow(dead_code)] #![allow(unused_imports)] -use crate::*; use crate::coregovernance::*; -use crate::host::*; +use crate::*; -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableAddAllowedStateControllerAddressParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableAddAllowedStateControllerAddressParams { pub fn chain_owner(&self) -> ScImmutableAgentID { - ScImmutableAgentID::new(self.id, PARAM_CHAIN_OWNER.get_key_id()) + ScImmutableAgentID::new(self.proxy.root(PARAM_CHAIN_OWNER)) } pub fn fee_color(&self) -> ScImmutableColor { - ScImmutableColor::new(self.id, PARAM_FEE_COLOR.get_key_id()) + ScImmutableColor::new(self.proxy.root(PARAM_FEE_COLOR)) } pub fn state_controller_address(&self) -> ScImmutableAddress { - ScImmutableAddress::new(self.id, PARAM_STATE_CONTROLLER_ADDRESS.get_key_id()) + ScImmutableAddress::new(self.proxy.root(PARAM_STATE_CONTROLLER_ADDRESS)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableAddAllowedStateControllerAddressParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableAddAllowedStateControllerAddressParams { pub fn chain_owner(&self) -> ScMutableAgentID { - ScMutableAgentID::new(self.id, PARAM_CHAIN_OWNER.get_key_id()) + ScMutableAgentID::new(self.proxy.root(PARAM_CHAIN_OWNER)) } pub fn fee_color(&self) -> ScMutableColor { - ScMutableColor::new(self.id, PARAM_FEE_COLOR.get_key_id()) + ScMutableColor::new(self.proxy.root(PARAM_FEE_COLOR)) } pub fn state_controller_address(&self) -> ScMutableAddress { - ScMutableAddress::new(self.id, PARAM_STATE_CONTROLLER_ADDRESS.get_key_id()) + ScMutableAddress::new(self.proxy.root(PARAM_STATE_CONTROLLER_ADDRESS)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableDelegateChainOwnershipParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableDelegateChainOwnershipParams { pub fn chain_owner(&self) -> ScImmutableAgentID { - ScImmutableAgentID::new(self.id, PARAM_CHAIN_OWNER.get_key_id()) + ScImmutableAgentID::new(self.proxy.root(PARAM_CHAIN_OWNER)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableDelegateChainOwnershipParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableDelegateChainOwnershipParams { pub fn chain_owner(&self) -> ScMutableAgentID { - ScMutableAgentID::new(self.id, PARAM_CHAIN_OWNER.get_key_id()) + ScMutableAgentID::new(self.proxy.root(PARAM_CHAIN_OWNER)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableRemoveAllowedStateControllerAddressParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableRemoveAllowedStateControllerAddressParams { pub fn state_controller_address(&self) -> ScImmutableAddress { - ScImmutableAddress::new(self.id, PARAM_STATE_CONTROLLER_ADDRESS.get_key_id()) + ScImmutableAddress::new(self.proxy.root(PARAM_STATE_CONTROLLER_ADDRESS)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableRemoveAllowedStateControllerAddressParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableRemoveAllowedStateControllerAddressParams { pub fn state_controller_address(&self) -> ScMutableAddress { - ScMutableAddress::new(self.id, PARAM_STATE_CONTROLLER_ADDRESS.get_key_id()) + ScMutableAddress::new(self.proxy.root(PARAM_STATE_CONTROLLER_ADDRESS)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableRotateStateControllerParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableRotateStateControllerParams { pub fn state_controller_address(&self) -> ScImmutableAddress { - ScImmutableAddress::new(self.id, PARAM_STATE_CONTROLLER_ADDRESS.get_key_id()) + ScImmutableAddress::new(self.proxy.root(PARAM_STATE_CONTROLLER_ADDRESS)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableRotateStateControllerParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableRotateStateControllerParams { pub fn state_controller_address(&self) -> ScMutableAddress { - ScMutableAddress::new(self.id, PARAM_STATE_CONTROLLER_ADDRESS.get_key_id()) + ScMutableAddress::new(self.proxy.root(PARAM_STATE_CONTROLLER_ADDRESS)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableSetChainInfoParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableSetChainInfoParams { pub fn max_blob_size(&self) -> ScImmutableInt32 { - ScImmutableInt32::new(self.id, PARAM_MAX_BLOB_SIZE.get_key_id()) + ScImmutableInt32::new(self.proxy.root(PARAM_MAX_BLOB_SIZE)) } pub fn max_event_size(&self) -> ScImmutableInt16 { - ScImmutableInt16::new(self.id, PARAM_MAX_EVENT_SIZE.get_key_id()) + ScImmutableInt16::new(self.proxy.root(PARAM_MAX_EVENT_SIZE)) } pub fn max_events_per_req(&self) -> ScImmutableInt16 { - ScImmutableInt16::new(self.id, PARAM_MAX_EVENTS_PER_REQ.get_key_id()) + ScImmutableInt16::new(self.proxy.root(PARAM_MAX_EVENTS_PER_REQ)) } pub fn owner_fee(&self) -> ScImmutableInt64 { - ScImmutableInt64::new(self.id, PARAM_OWNER_FEE.get_key_id()) + ScImmutableInt64::new(self.proxy.root(PARAM_OWNER_FEE)) } pub fn validator_fee(&self) -> ScImmutableInt64 { - ScImmutableInt64::new(self.id, PARAM_VALIDATOR_FEE.get_key_id()) + ScImmutableInt64::new(self.proxy.root(PARAM_VALIDATOR_FEE)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableSetChainInfoParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableSetChainInfoParams { pub fn max_blob_size(&self) -> ScMutableInt32 { - ScMutableInt32::new(self.id, PARAM_MAX_BLOB_SIZE.get_key_id()) + ScMutableInt32::new(self.proxy.root(PARAM_MAX_BLOB_SIZE)) } pub fn max_event_size(&self) -> ScMutableInt16 { - ScMutableInt16::new(self.id, PARAM_MAX_EVENT_SIZE.get_key_id()) + ScMutableInt16::new(self.proxy.root(PARAM_MAX_EVENT_SIZE)) } pub fn max_events_per_req(&self) -> ScMutableInt16 { - ScMutableInt16::new(self.id, PARAM_MAX_EVENTS_PER_REQ.get_key_id()) + ScMutableInt16::new(self.proxy.root(PARAM_MAX_EVENTS_PER_REQ)) } pub fn owner_fee(&self) -> ScMutableInt64 { - ScMutableInt64::new(self.id, PARAM_OWNER_FEE.get_key_id()) + ScMutableInt64::new(self.proxy.root(PARAM_OWNER_FEE)) } pub fn validator_fee(&self) -> ScMutableInt64 { - ScMutableInt64::new(self.id, PARAM_VALIDATOR_FEE.get_key_id()) + ScMutableInt64::new(self.proxy.root(PARAM_VALIDATOR_FEE)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableSetContractFeeParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableSetContractFeeParams { pub fn hname(&self) -> ScImmutableHname { - ScImmutableHname::new(self.id, PARAM_HNAME.get_key_id()) + ScImmutableHname::new(self.proxy.root(PARAM_HNAME)) } pub fn owner_fee(&self) -> ScImmutableInt64 { - ScImmutableInt64::new(self.id, PARAM_OWNER_FEE.get_key_id()) + ScImmutableInt64::new(self.proxy.root(PARAM_OWNER_FEE)) } pub fn validator_fee(&self) -> ScImmutableInt64 { - ScImmutableInt64::new(self.id, PARAM_VALIDATOR_FEE.get_key_id()) + ScImmutableInt64::new(self.proxy.root(PARAM_VALIDATOR_FEE)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableSetContractFeeParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableSetContractFeeParams { pub fn hname(&self) -> ScMutableHname { - ScMutableHname::new(self.id, PARAM_HNAME.get_key_id()) + ScMutableHname::new(self.proxy.root(PARAM_HNAME)) } pub fn owner_fee(&self) -> ScMutableInt64 { - ScMutableInt64::new(self.id, PARAM_OWNER_FEE.get_key_id()) + ScMutableInt64::new(self.proxy.root(PARAM_OWNER_FEE)) } pub fn validator_fee(&self) -> ScMutableInt64 { - ScMutableInt64::new(self.id, PARAM_VALIDATOR_FEE.get_key_id()) + ScMutableInt64::new(self.proxy.root(PARAM_VALIDATOR_FEE)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableSetDefaultFeeParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableSetDefaultFeeParams { pub fn owner_fee(&self) -> ScImmutableInt64 { - ScImmutableInt64::new(self.id, PARAM_OWNER_FEE.get_key_id()) + ScImmutableInt64::new(self.proxy.root(PARAM_OWNER_FEE)) } pub fn validator_fee(&self) -> ScImmutableInt64 { - ScImmutableInt64::new(self.id, PARAM_VALIDATOR_FEE.get_key_id()) + ScImmutableInt64::new(self.proxy.root(PARAM_VALIDATOR_FEE)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableSetDefaultFeeParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableSetDefaultFeeParams { pub fn owner_fee(&self) -> ScMutableInt64 { - ScMutableInt64::new(self.id, PARAM_OWNER_FEE.get_key_id()) + ScMutableInt64::new(self.proxy.root(PARAM_OWNER_FEE)) } pub fn validator_fee(&self) -> ScMutableInt64 { - ScMutableInt64::new(self.id, PARAM_VALIDATOR_FEE.get_key_id()) + ScMutableInt64::new(self.proxy.root(PARAM_VALIDATOR_FEE)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableGetFeeInfoParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableGetFeeInfoParams { pub fn hname(&self) -> ScImmutableHname { - ScImmutableHname::new(self.id, PARAM_HNAME.get_key_id()) + ScImmutableHname::new(self.proxy.root(PARAM_HNAME)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableGetFeeInfoParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableGetFeeInfoParams { pub fn hname(&self) -> ScMutableHname { - ScMutableHname::new(self.id, PARAM_HNAME.get_key_id()) + ScMutableHname::new(self.proxy.root(PARAM_HNAME)) } } diff --git a/packages/wasmvm/wasmlib/src/coregovernance/results.rs b/packages/wasmvm/wasmlib/src/coregovernance/results.rs index b4ff21b487..f9a0e6ef23 100644 --- a/packages/wasmvm/wasmlib/src/coregovernance/results.rs +++ b/packages/wasmvm/wasmlib/src/coregovernance/results.rs @@ -8,210 +8,211 @@ #![allow(dead_code)] #![allow(unused_imports)] -use crate::*; use crate::coregovernance::*; -use crate::host::*; +use crate::*; -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ArrayOfImmutableBytes { - pub(crate) obj_id: i32, + pub(crate) proxy: Proxy, } impl ArrayOfImmutableBytes { pub fn length(&self) -> u32 { - get_length(self.obj_id) + self.proxy.length() } pub fn get_bytes(&self, index: u32) -> ScImmutableBytes { - ScImmutableBytes::new(self.obj_id, Key32(index as i32)) + ScImmutableBytes::new(self.proxy.index(index)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableGetAllowedStateControllerAddressesResults { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableGetAllowedStateControllerAddressesResults { pub fn allowed_state_controller_addresses(&self) -> ArrayOfImmutableBytes { - let arr_id = get_object_id(self.id, RESULT_ALLOWED_STATE_CONTROLLER_ADDRESSES.get_key_id(), TYPE_ARRAY16 | TYPE_BYTES); - ArrayOfImmutableBytes { obj_id: arr_id } + ArrayOfImmutableBytes { proxy: self.proxy.root(RESULT_ALLOWED_STATE_CONTROLLER_ADDRESSES) } } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ArrayOfMutableBytes { - pub(crate) obj_id: i32, + pub(crate) proxy: Proxy, } impl ArrayOfMutableBytes { - pub fn clear(&self) { - clear(self.obj_id); + pub fn append_bytes(&self) -> ScMutableBytes { + ScMutableBytes::new(self.proxy.append()) + } + + pub fn clear(&self) { + self.proxy.clear_array(); } pub fn length(&self) -> u32 { - get_length(self.obj_id) + self.proxy.length() } pub fn get_bytes(&self, index: u32) -> ScMutableBytes { - ScMutableBytes::new(self.obj_id, Key32(index as i32)) + ScMutableBytes::new(self.proxy.index(index)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableGetAllowedStateControllerAddressesResults { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableGetAllowedStateControllerAddressesResults { pub fn allowed_state_controller_addresses(&self) -> ArrayOfMutableBytes { - let arr_id = get_object_id(self.id, RESULT_ALLOWED_STATE_CONTROLLER_ADDRESSES.get_key_id(), TYPE_ARRAY16 | TYPE_BYTES); - ArrayOfMutableBytes { obj_id: arr_id } + ArrayOfMutableBytes { proxy: self.proxy.root(RESULT_ALLOWED_STATE_CONTROLLER_ADDRESSES) } } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableGetChainInfoResults { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableGetChainInfoResults { pub fn chain_id(&self) -> ScImmutableChainID { - ScImmutableChainID::new(self.id, RESULT_CHAIN_ID.get_key_id()) + ScImmutableChainID::new(self.proxy.root(RESULT_CHAIN_ID)) } pub fn chain_owner_id(&self) -> ScImmutableAgentID { - ScImmutableAgentID::new(self.id, RESULT_CHAIN_OWNER_ID.get_key_id()) + ScImmutableAgentID::new(self.proxy.root(RESULT_CHAIN_OWNER_ID)) } pub fn default_owner_fee(&self) -> ScImmutableInt64 { - ScImmutableInt64::new(self.id, RESULT_DEFAULT_OWNER_FEE.get_key_id()) + ScImmutableInt64::new(self.proxy.root(RESULT_DEFAULT_OWNER_FEE)) } pub fn default_validator_fee(&self) -> ScImmutableInt64 { - ScImmutableInt64::new(self.id, RESULT_DEFAULT_VALIDATOR_FEE.get_key_id()) + ScImmutableInt64::new(self.proxy.root(RESULT_DEFAULT_VALIDATOR_FEE)) } pub fn description(&self) -> ScImmutableString { - ScImmutableString::new(self.id, RESULT_DESCRIPTION.get_key_id()) + ScImmutableString::new(self.proxy.root(RESULT_DESCRIPTION)) } pub fn fee_color(&self) -> ScImmutableColor { - ScImmutableColor::new(self.id, RESULT_FEE_COLOR.get_key_id()) + ScImmutableColor::new(self.proxy.root(RESULT_FEE_COLOR)) } pub fn max_blob_size(&self) -> ScImmutableInt32 { - ScImmutableInt32::new(self.id, RESULT_MAX_BLOB_SIZE.get_key_id()) + ScImmutableInt32::new(self.proxy.root(RESULT_MAX_BLOB_SIZE)) } pub fn max_event_size(&self) -> ScImmutableInt16 { - ScImmutableInt16::new(self.id, RESULT_MAX_EVENT_SIZE.get_key_id()) + ScImmutableInt16::new(self.proxy.root(RESULT_MAX_EVENT_SIZE)) } pub fn max_events_per_req(&self) -> ScImmutableInt16 { - ScImmutableInt16::new(self.id, RESULT_MAX_EVENTS_PER_REQ.get_key_id()) + ScImmutableInt16::new(self.proxy.root(RESULT_MAX_EVENTS_PER_REQ)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableGetChainInfoResults { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableGetChainInfoResults { pub fn chain_id(&self) -> ScMutableChainID { - ScMutableChainID::new(self.id, RESULT_CHAIN_ID.get_key_id()) + ScMutableChainID::new(self.proxy.root(RESULT_CHAIN_ID)) } pub fn chain_owner_id(&self) -> ScMutableAgentID { - ScMutableAgentID::new(self.id, RESULT_CHAIN_OWNER_ID.get_key_id()) + ScMutableAgentID::new(self.proxy.root(RESULT_CHAIN_OWNER_ID)) } pub fn default_owner_fee(&self) -> ScMutableInt64 { - ScMutableInt64::new(self.id, RESULT_DEFAULT_OWNER_FEE.get_key_id()) + ScMutableInt64::new(self.proxy.root(RESULT_DEFAULT_OWNER_FEE)) } pub fn default_validator_fee(&self) -> ScMutableInt64 { - ScMutableInt64::new(self.id, RESULT_DEFAULT_VALIDATOR_FEE.get_key_id()) + ScMutableInt64::new(self.proxy.root(RESULT_DEFAULT_VALIDATOR_FEE)) } pub fn description(&self) -> ScMutableString { - ScMutableString::new(self.id, RESULT_DESCRIPTION.get_key_id()) + ScMutableString::new(self.proxy.root(RESULT_DESCRIPTION)) } pub fn fee_color(&self) -> ScMutableColor { - ScMutableColor::new(self.id, RESULT_FEE_COLOR.get_key_id()) + ScMutableColor::new(self.proxy.root(RESULT_FEE_COLOR)) } pub fn max_blob_size(&self) -> ScMutableInt32 { - ScMutableInt32::new(self.id, RESULT_MAX_BLOB_SIZE.get_key_id()) + ScMutableInt32::new(self.proxy.root(RESULT_MAX_BLOB_SIZE)) } pub fn max_event_size(&self) -> ScMutableInt16 { - ScMutableInt16::new(self.id, RESULT_MAX_EVENT_SIZE.get_key_id()) + ScMutableInt16::new(self.proxy.root(RESULT_MAX_EVENT_SIZE)) } pub fn max_events_per_req(&self) -> ScMutableInt16 { - ScMutableInt16::new(self.id, RESULT_MAX_EVENTS_PER_REQ.get_key_id()) + ScMutableInt16::new(self.proxy.root(RESULT_MAX_EVENTS_PER_REQ)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableGetFeeInfoResults { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableGetFeeInfoResults { pub fn fee_color(&self) -> ScImmutableColor { - ScImmutableColor::new(self.id, RESULT_FEE_COLOR.get_key_id()) + ScImmutableColor::new(self.proxy.root(RESULT_FEE_COLOR)) } pub fn owner_fee(&self) -> ScImmutableInt64 { - ScImmutableInt64::new(self.id, RESULT_OWNER_FEE.get_key_id()) + ScImmutableInt64::new(self.proxy.root(RESULT_OWNER_FEE)) } pub fn validator_fee(&self) -> ScImmutableInt64 { - ScImmutableInt64::new(self.id, RESULT_VALIDATOR_FEE.get_key_id()) + ScImmutableInt64::new(self.proxy.root(RESULT_VALIDATOR_FEE)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableGetFeeInfoResults { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableGetFeeInfoResults { pub fn fee_color(&self) -> ScMutableColor { - ScMutableColor::new(self.id, RESULT_FEE_COLOR.get_key_id()) + ScMutableColor::new(self.proxy.root(RESULT_FEE_COLOR)) } pub fn owner_fee(&self) -> ScMutableInt64 { - ScMutableInt64::new(self.id, RESULT_OWNER_FEE.get_key_id()) + ScMutableInt64::new(self.proxy.root(RESULT_OWNER_FEE)) } pub fn validator_fee(&self) -> ScMutableInt64 { - ScMutableInt64::new(self.id, RESULT_VALIDATOR_FEE.get_key_id()) + ScMutableInt64::new(self.proxy.root(RESULT_VALIDATOR_FEE)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableGetMaxBlobSizeResults { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableGetMaxBlobSizeResults { pub fn max_blob_size(&self) -> ScImmutableInt32 { - ScImmutableInt32::new(self.id, RESULT_MAX_BLOB_SIZE.get_key_id()) + ScImmutableInt32::new(self.proxy.root(RESULT_MAX_BLOB_SIZE)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableGetMaxBlobSizeResults { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableGetMaxBlobSizeResults { pub fn max_blob_size(&self) -> ScMutableInt32 { - ScMutableInt32::new(self.id, RESULT_MAX_BLOB_SIZE.get_key_id()) + ScMutableInt32::new(self.proxy.root(RESULT_MAX_BLOB_SIZE)) } } diff --git a/packages/wasmvm/wasmlib/src/coreroot/contract.rs b/packages/wasmvm/wasmlib/src/coreroot/contract.rs index 99fb71ce4c..5380321a18 100644 --- a/packages/wasmvm/wasmlib/src/coreroot/contract.rs +++ b/packages/wasmvm/wasmlib/src/coreroot/contract.rs @@ -7,8 +7,6 @@ #![allow(dead_code)] -use std::ptr; - use crate::*; use crate::coreroot::*; @@ -42,49 +40,50 @@ pub struct ScFuncs { } impl ScFuncs { - pub fn deploy_contract(_ctx: & dyn ScFuncCallContext) -> DeployContractCall { + pub fn deploy_contract(_ctx: &dyn ScFuncCallContext) -> DeployContractCall { let mut f = DeployContractCall { func: ScFunc::new(HSC_NAME, HFUNC_DEPLOY_CONTRACT), - params: MutableDeployContractParams { id: 0 }, + params: MutableDeployContractParams { proxy: Proxy::nil() }, }; - f.func.set_ptrs(&mut f.params.id, ptr::null_mut()); + ScFunc::link_params(&mut f.params.proxy, &f.func); f } - pub fn grant_deploy_permission(_ctx: & dyn ScFuncCallContext) -> GrantDeployPermissionCall { + pub fn grant_deploy_permission(_ctx: &dyn ScFuncCallContext) -> GrantDeployPermissionCall { let mut f = GrantDeployPermissionCall { func: ScFunc::new(HSC_NAME, HFUNC_GRANT_DEPLOY_PERMISSION), - params: MutableGrantDeployPermissionParams { id: 0 }, + params: MutableGrantDeployPermissionParams { proxy: Proxy::nil() }, }; - f.func.set_ptrs(&mut f.params.id, ptr::null_mut()); + ScFunc::link_params(&mut f.params.proxy, &f.func); f } - pub fn revoke_deploy_permission(_ctx: & dyn ScFuncCallContext) -> RevokeDeployPermissionCall { + pub fn revoke_deploy_permission(_ctx: &dyn ScFuncCallContext) -> RevokeDeployPermissionCall { let mut f = RevokeDeployPermissionCall { func: ScFunc::new(HSC_NAME, HFUNC_REVOKE_DEPLOY_PERMISSION), - params: MutableRevokeDeployPermissionParams { id: 0 }, + params: MutableRevokeDeployPermissionParams { proxy: Proxy::nil() }, }; - f.func.set_ptrs(&mut f.params.id, ptr::null_mut()); + ScFunc::link_params(&mut f.params.proxy, &f.func); f } - pub fn find_contract(_ctx: & dyn ScViewCallContext) -> FindContractCall { + pub fn find_contract(_ctx: &dyn ScViewCallContext) -> FindContractCall { let mut f = FindContractCall { func: ScView::new(HSC_NAME, HVIEW_FIND_CONTRACT), - params: MutableFindContractParams { id: 0 }, - results: ImmutableFindContractResults { id: 0 }, + params: MutableFindContractParams { proxy: Proxy::nil() }, + results: ImmutableFindContractResults { proxy: Proxy::nil() }, }; - f.func.set_ptrs(&mut f.params.id, &mut f.results.id); + ScView::link_params(&mut f.params.proxy, &f.func); + ScView::link_results(&mut f.results.proxy, &f.func); f } - pub fn get_contract_records(_ctx: & dyn ScViewCallContext) -> GetContractRecordsCall { + pub fn get_contract_records(_ctx: &dyn ScViewCallContext) -> GetContractRecordsCall { let mut f = GetContractRecordsCall { func: ScView::new(HSC_NAME, HVIEW_GET_CONTRACT_RECORDS), - results: ImmutableGetContractRecordsResults { id: 0 }, + results: ImmutableGetContractRecordsResults { proxy: Proxy::nil() }, }; - f.func.set_ptrs(ptr::null_mut(), &mut f.results.id); + ScView::link_results(&mut f.results.proxy, &f.func); f } } diff --git a/packages/wasmvm/wasmlib/src/coreroot/params.rs b/packages/wasmvm/wasmlib/src/coreroot/params.rs index 59257f5334..fb83c178db 100644 --- a/packages/wasmvm/wasmlib/src/coreroot/params.rs +++ b/packages/wasmvm/wasmlib/src/coreroot/params.rs @@ -8,110 +8,109 @@ #![allow(dead_code)] #![allow(unused_imports)] -use crate::*; use crate::coreroot::*; -use crate::host::*; +use crate::*; -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableDeployContractParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableDeployContractParams { pub fn description(&self) -> ScImmutableString { - ScImmutableString::new(self.id, PARAM_DESCRIPTION.get_key_id()) + ScImmutableString::new(self.proxy.root(PARAM_DESCRIPTION)) } pub fn name(&self) -> ScImmutableString { - ScImmutableString::new(self.id, PARAM_NAME.get_key_id()) + ScImmutableString::new(self.proxy.root(PARAM_NAME)) } pub fn program_hash(&self) -> ScImmutableHash { - ScImmutableHash::new(self.id, PARAM_PROGRAM_HASH.get_key_id()) + ScImmutableHash::new(self.proxy.root(PARAM_PROGRAM_HASH)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableDeployContractParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableDeployContractParams { pub fn description(&self) -> ScMutableString { - ScMutableString::new(self.id, PARAM_DESCRIPTION.get_key_id()) + ScMutableString::new(self.proxy.root(PARAM_DESCRIPTION)) } pub fn name(&self) -> ScMutableString { - ScMutableString::new(self.id, PARAM_NAME.get_key_id()) + ScMutableString::new(self.proxy.root(PARAM_NAME)) } pub fn program_hash(&self) -> ScMutableHash { - ScMutableHash::new(self.id, PARAM_PROGRAM_HASH.get_key_id()) + ScMutableHash::new(self.proxy.root(PARAM_PROGRAM_HASH)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableGrantDeployPermissionParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableGrantDeployPermissionParams { pub fn deployer(&self) -> ScImmutableAgentID { - ScImmutableAgentID::new(self.id, PARAM_DEPLOYER.get_key_id()) + ScImmutableAgentID::new(self.proxy.root(PARAM_DEPLOYER)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableGrantDeployPermissionParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableGrantDeployPermissionParams { pub fn deployer(&self) -> ScMutableAgentID { - ScMutableAgentID::new(self.id, PARAM_DEPLOYER.get_key_id()) + ScMutableAgentID::new(self.proxy.root(PARAM_DEPLOYER)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableRevokeDeployPermissionParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableRevokeDeployPermissionParams { pub fn deployer(&self) -> ScImmutableAgentID { - ScImmutableAgentID::new(self.id, PARAM_DEPLOYER.get_key_id()) + ScImmutableAgentID::new(self.proxy.root(PARAM_DEPLOYER)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableRevokeDeployPermissionParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableRevokeDeployPermissionParams { pub fn deployer(&self) -> ScMutableAgentID { - ScMutableAgentID::new(self.id, PARAM_DEPLOYER.get_key_id()) + ScMutableAgentID::new(self.proxy.root(PARAM_DEPLOYER)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableFindContractParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableFindContractParams { pub fn hname(&self) -> ScImmutableHname { - ScImmutableHname::new(self.id, PARAM_HNAME.get_key_id()) + ScImmutableHname::new(self.proxy.root(PARAM_HNAME)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableFindContractParams { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableFindContractParams { pub fn hname(&self) -> ScMutableHname { - ScMutableHname::new(self.id, PARAM_HNAME.get_key_id()) + ScMutableHname::new(self.proxy.root(PARAM_HNAME)) } } diff --git a/packages/wasmvm/wasmlib/src/coreroot/results.rs b/packages/wasmvm/wasmlib/src/coreroot/results.rs index 933c193392..6a758f705d 100644 --- a/packages/wasmvm/wasmlib/src/coreroot/results.rs +++ b/packages/wasmvm/wasmlib/src/coreroot/results.rs @@ -8,86 +8,83 @@ #![allow(dead_code)] #![allow(unused_imports)] -use crate::*; use crate::coreroot::*; -use crate::host::*; +use crate::*; -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableFindContractResults { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableFindContractResults { pub fn contract_found(&self) -> ScImmutableBytes { - ScImmutableBytes::new(self.id, RESULT_CONTRACT_FOUND.get_key_id()) + ScImmutableBytes::new(self.proxy.root(RESULT_CONTRACT_FOUND)) } pub fn contract_rec_data(&self) -> ScImmutableBytes { - ScImmutableBytes::new(self.id, RESULT_CONTRACT_REC_DATA.get_key_id()) + ScImmutableBytes::new(self.proxy.root(RESULT_CONTRACT_REC_DATA)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableFindContractResults { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableFindContractResults { pub fn contract_found(&self) -> ScMutableBytes { - ScMutableBytes::new(self.id, RESULT_CONTRACT_FOUND.get_key_id()) + ScMutableBytes::new(self.proxy.root(RESULT_CONTRACT_FOUND)) } pub fn contract_rec_data(&self) -> ScMutableBytes { - ScMutableBytes::new(self.id, RESULT_CONTRACT_REC_DATA.get_key_id()) + ScMutableBytes::new(self.proxy.root(RESULT_CONTRACT_REC_DATA)) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MapHnameToImmutableBytes { - pub(crate) obj_id: i32, + pub(crate) proxy: Proxy, } impl MapHnameToImmutableBytes { pub fn get_bytes(&self, key: ScHname) -> ScImmutableBytes { - ScImmutableBytes::new(self.obj_id, key.get_key_id()) + ScImmutableBytes::new(self.proxy.key(&hname_to_bytes(key))) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableGetContractRecordsResults { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl ImmutableGetContractRecordsResults { pub fn contract_registry(&self) -> MapHnameToImmutableBytes { - let map_id = get_object_id(self.id, RESULT_CONTRACT_REGISTRY.get_key_id(), TYPE_MAP); - MapHnameToImmutableBytes { obj_id: map_id } + MapHnameToImmutableBytes { proxy: self.proxy.root(RESULT_CONTRACT_REGISTRY) } } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MapHnameToMutableBytes { - pub(crate) obj_id: i32, + pub(crate) proxy: Proxy, } impl MapHnameToMutableBytes { pub fn clear(&self) { - clear(self.obj_id); + self.proxy.clear_map(); } pub fn get_bytes(&self, key: ScHname) -> ScMutableBytes { - ScMutableBytes::new(self.obj_id, key.get_key_id()) + ScMutableBytes::new(self.proxy.key(&hname_to_bytes(key))) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableGetContractRecordsResults { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl MutableGetContractRecordsResults { pub fn contract_registry(&self) -> MapHnameToMutableBytes { - let map_id = get_object_id(self.id, RESULT_CONTRACT_REGISTRY.get_key_id(), TYPE_MAP); - MapHnameToMutableBytes { obj_id: map_id } + MapHnameToMutableBytes { proxy: self.proxy.root(RESULT_CONTRACT_REGISTRY) } } } diff --git a/packages/wasmvm/wasmlib/src/dict.rs b/packages/wasmvm/wasmlib/src/dict.rs index 8cb29fd831..c418cefdcb 100644 --- a/packages/wasmvm/wasmlib/src/dict.rs +++ b/packages/wasmvm/wasmlib/src/dict.rs @@ -1,56 +1,116 @@ // Copyright 2020 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 -use std::collections::HashMap; +use std::cell::RefCell; +use std::collections::BTreeMap; +use crate::*; use crate::host::*; -use crate::wasmtypes::IKvStore; -pub struct ScImmutableDict<'a> { - dict: &'a HashMap,Vec>, +pub struct ScImmutableDict { + dict: ScDict, } -impl ScImmutableDict<'_> { - pub fn from_dict(dict: &ScDict)-> ScImmutableDict { - ScImmutableDict{ dict: &dict.dict } +impl ScImmutableDict { + pub fn new(dict: ScDict) -> ScImmutableDict { + ScImmutableDict { dict } } pub fn exists(&self, key: &[u8]) -> bool { - self.dict.contains_key(key) + self.dict.exists(key) } - pub fn get(&self, key: &[u8]) -> Option<&Vec> { + pub fn get(&self, key: &[u8]) -> Vec { self.dict.get(key) } } +#[derive(Clone)] pub struct ScDict { - dict: HashMap,Vec>, + dict: RefCell, Vec>>, + state: bool, } impl ScDict { pub fn new(buf: &[u8]) -> ScDict { - ScDict { dict: HashMap::new(), } + let dict = ScDict { dict: RefCell::new(BTreeMap::new()), state: false }; + dict.read_bytes(buf); + dict } -} -impl IKvStore for ScDict { - fn delete(& mut self, key: &[u8]) { - self.dict.remove(key); + pub fn state() -> ScDict { + ScDict { dict: RefCell::new(BTreeMap::new()), state: true } } - fn exists(&self, key: &[u8]) -> bool { - self.dict.contains_key(key) + pub fn copy(&self, buf: &[u8]) { + self.dict.borrow_mut().clear(); + self.read_bytes(buf); } - fn get(&self, key: &[u8]) -> Vec { - if !self.dict.contains_key(key) { + pub fn delete(&self, key: &[u8]) { + if self.state { + state_delete(key); + return; + } + self.dict.borrow_mut().remove(key); + } + + pub fn exists(&self, key: &[u8]) -> bool { + if self.state { + return state_exists(key); + } + self.dict.borrow().contains_key(key) + } + + pub fn get(&self, key: &[u8]) -> Vec { + if self.state { + return state_get(key); + } + let dict = self.dict.borrow(); + if !dict.contains_key(key) { return Vec::new(); } - self.dict.get(key).unwrap().to_vec() + dict.get(key).unwrap().to_vec() } - fn set(& mut self, key: &[u8], value: &[u8]) { - self.dict.insert(key.to_vec(), value.to_vec()); + pub fn set(&self, key: &[u8], value: &[u8]) { + if self.state { + state_set(key, value); + return; + } + self.dict.borrow_mut().insert(key.to_vec(), value.to_vec()); + } + + fn read_bytes(&self, buf: &[u8]) { + if buf.len() != 0 { + let mut dec = WasmDecoder::new(buf); + let size = uint32_from_bytes(&dec.fixed_bytes(SC_UINT32_LENGTH)); + for _i in 0..size { + let key_buf = dec.fixed_bytes(SC_UINT16_LENGTH); + let key_len = uint16_from_bytes(&key_buf); + let key = dec.fixed_bytes(key_len as usize); + let val_buf = dec.fixed_bytes(SC_UINT32_LENGTH); + let val_len = uint32_from_bytes(&val_buf); + let val = dec.fixed_bytes(val_len as usize); + self.set(&key, &val); + } + } + } + + pub fn to_bytes(&self) -> Vec { + let dict = self.dict.borrow(); + if dict.len() == 0 { + return vec![0; SC_UINT32_LENGTH]; + } + + let mut enc = WasmEncoder::new(); + enc.fixed_bytes(&uint32_to_bytes(dict.len() as u32), SC_UINT32_LENGTH); + for (key, val) in dict.iter() { + enc.fixed_bytes(&uint16_to_bytes(key.len() as u16), SC_UINT16_LENGTH); + enc.fixed_bytes(key, key.len()); + enc.fixed_bytes(&uint32_to_bytes(val.len() as u32), SC_UINT32_LENGTH); + enc.fixed_bytes(val, val.len()); + } + return enc.buf(); } } diff --git a/packages/wasmvm/wasmlib/src/events.rs b/packages/wasmvm/wasmlib/src/events.rs index 19d74cb1df..92e929ccc4 100644 --- a/packages/wasmvm/wasmlib/src/events.rs +++ b/packages/wasmvm/wasmlib/src/events.rs @@ -1,9 +1,7 @@ // Copyright 2020 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 -use crate::context::*; -use crate::hashtypes::*; -use crate::keys::*; +use crate::*; // encodes separate entities into a byte buffer pub struct EventEncoder { @@ -11,107 +9,21 @@ pub struct EventEncoder { } impl EventEncoder { - // constructs an encoder pub fn new(event_name: &str) -> EventEncoder { let mut e = EventEncoder { event: event_name.to_string() }; - let timestamp = ROOT.get_int64(&KEY_TIMESTAMP).value(); - e.int64(timestamp / 1_000_000_000); + let timestamp = ScFuncContext{}.timestamp(); + e.encode(&uint64_to_string(timestamp / 1_000_000_000)); e } - // encodes an ScAddress into the byte buffer - pub fn address(&mut self, value: &ScAddress) -> &EventEncoder { - self.string(&value.to_string()) - } - - // encodes an ScAgentID into the byte buffer - pub fn agent_id(&mut self, value: &ScAgentID) -> &EventEncoder { - self.string(&value.to_string()) - } - - // encodes a Bool as 0/1 into the byte buffer - pub fn bool(&mut self, value: bool) -> &EventEncoder { - self.uint8(value as u8) - } - - // encodes a substring of bytes into the byte buffer - pub fn bytes(&mut self, value: &[u8]) -> &EventEncoder { - self.string(&base58_encode(value)) - } - - // encodes an ScChainID into the byte buffer - pub fn chain_id(&mut self, value: &ScChainID) -> &EventEncoder { - self.string(&value.to_string()) - } - - // encodes an ScColor into the byte buffer - pub fn color(&mut self, value: &ScColor) -> &EventEncoder { - self.string(&value.to_string()) - } - - // retrieve the encoded byte buffer pub fn emit(&self) { - ROOT.get_string(&KEY_EVENT).set_value(&self.event); - } - - // encodes an ScHash into the byte buffer - pub fn hash(&mut self, value: &ScHash) -> &EventEncoder { - self.string(&value.to_string()) - } - - // encodes an ScHname into the byte buffer - pub fn hname(&mut self, value: ScHname) -> &EventEncoder { - self.string(&value.to_string()) - } - - // encodes an Int8 into the byte buffer - pub fn int8(&mut self, value: i8) -> &EventEncoder { - self.string(&value.to_string()) - } - - // encodes an Int16 into the byte buffer - pub fn int16(&mut self, value: i16) -> &EventEncoder { - self.string(&value.to_string()) - } - - // encodes an Int32 into the byte buffer - pub fn int32(&mut self, value: i32) -> &EventEncoder { - self.string(&value.to_string()) - } - - // encodes an Int64 into the byte buffer - pub fn int64(&mut self, value: i64) -> &EventEncoder { - self.string(&value.to_string()) - } - - // encodes an ScRequestID into the byte buffer - pub fn request_id(&mut self, value: &ScRequestID) -> &EventEncoder { - self.string(&value.to_string()) + ScFuncContext{}.event(&self.event); } - // encodes an UTF-8 text string into the byte buffer - pub fn string(&mut self, value: &str) -> &EventEncoder { - self.event += &("|".to_owned() + value); + pub fn encode(&mut self, value: &str) -> &EventEncoder { + // TODO encode potential vertical bars that are present in the value string + self.event += "|"; + self.event += &value; self } - - // encodes an Uint8 into the byte buffer - pub fn uint8(&mut self, value: u8) -> &EventEncoder { - self.string(&value.to_string()) - } - - // encodes an Uint16 into the byte buffer - pub fn uint16(&mut self, value: u16) -> &EventEncoder { - self.string(&value.to_string()) - } - - // encodes an Uint32 into the byte buffer - pub fn uint32(&mut self, value: u32) -> &EventEncoder { - self.string(&value.to_string()) - } - - // encodes an Uint64 into the byte buffer - pub fn uint64(&mut self, value: u64) -> &EventEncoder { - self.string(&value.to_string()) - } } diff --git a/packages/wasmvm/wasmlib/src/exports.rs b/packages/wasmvm/wasmlib/src/exports.rs index cc6fa22540..0db9c7f5bd 100644 --- a/packages/wasmvm/wasmlib/src/exports.rs +++ b/packages/wasmvm/wasmlib/src/exports.rs @@ -31,7 +31,7 @@ fn on_call(index: i32) { } // mutable full function, invoke with a func context - FUNCS[index as usize](&ctx); + FUNCS[index as usize](&ScFuncContext {}); } } diff --git a/packages/wasmvm/wasmlib/src/lib.rs b/packages/wasmvm/wasmlib/src/lib.rs index 5950dd5916..cb3a6becc4 100644 --- a/packages/wasmvm/wasmlib/src/lib.rs +++ b/packages/wasmvm/wasmlib/src/lib.rs @@ -3,25 +3,31 @@ #![allow(dead_code)] -// pub use context::*; -// pub use contract::*; -// pub use events::*; +pub use context::*; +pub use assets::*; +pub use contract::*; +pub use dict::*; +pub use events::*; pub use exports::ScExports; +pub use sandbox::*; +pub use sandboxutils::*; +pub use wasmtypes::*; -// mod context; -// mod contract; -// pub mod coreaccounts; -// pub mod coreblob; -// pub mod coreblocklog; -// pub mod coregovernance; -// pub mod coreroot; +pub mod context; +pub mod assets; +pub mod contract; +pub mod coreaccounts; +pub mod coreblob; +pub mod coreblocklog; +pub mod coregovernance; +pub mod coreroot; pub mod dict; -// mod events; -mod exports; +pub mod events; +pub mod exports; pub mod host; pub mod sandbox; -pub mod state; -//pub mod wasmrequests; +pub mod sandboxutils; +pub mod wasmrequests; pub mod wasmtypes; // When the `wee_alloc` feature is enabled, diff --git a/packages/wasmvm/wasmlib/src/sandbox.rs b/packages/wasmvm/wasmlib/src/sandbox.rs index 15d48a5373..b84491d022 100644 --- a/packages/wasmvm/wasmlib/src/sandbox.rs +++ b/packages/wasmvm/wasmlib/src/sandbox.rs @@ -1,8 +1,9 @@ // Copyright 2020 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 +use crate::*; use crate::host::*; -use crate::wasmtypes; +use std::rc::Rc; // @formatter:off pub const FN_ACCOUNT_ID : i32 = -1; @@ -58,115 +59,253 @@ pub fn trace(text: &str) { sandbox(FN_TRACE, text.as_bytes()); } -pub struct ScSandbox {} +pub fn params_proxy() -> Proxy { + let buf = sandbox(FN_PARAMS, &[]); + Proxy::new(&Rc::new(ScDict::new(&buf))) +} + +pub fn results_proxy() -> Proxy { + Proxy::new(&Rc::new(ScDict::new(&[]))) +} -impl ScSandbox { - // retrieve the agent id of this contract account - pub fn accountID() -> wasmtypes::ScAgentID { - wasmtypes::agent_id_from_bytes(sandbox(FN_ACCOUNT_ID, null)) +pub fn state_proxy() -> Proxy { + Proxy::new(&Rc::new(ScDict::state())) +} + +pub trait ScSandbox { + // retrieve the agent id of self contract account + fn account_id(&self) -> ScAgentID { + agent_id_from_bytes(&sandbox(FN_ACCOUNT_ID, &[])) } - pub fn balance(color: wasmtypes::ScColor) -> u64 { - wasmtypes::uint64_from_bytes(sandbox(FN_BALANCE, &color.toBytes())) + fn balance(&self, color: ScColor) -> u64 { + uint64_from_bytes(&sandbox(FN_BALANCE, &color.to_bytes())) } // access the current balances for all assets - pub fn balances() -> ScBalances { - return ScAssets::new(sandbox(FN_BALANCES, null)).balances() + fn balances(&self) -> ScBalances { + ScAssets::new(&sandbox(FN_BALANCES, &[])).balances() } // calls a smart contract function - fn callWithTransfer(hContract: wasmtypes::ScHname, hFunction: wasmtypes::ScHname, params: Option, transfer: Option) -> ScImmutableDict { - if (params == None) { - params = new ScDict([]); - } - if (transfer == None) { - transfer = new ScTransfers(); - } - const req = new wasmrequests.CallRequest(); - req.contract = hContract; - req.function = hFunction; - req.params = params.toBytes(); - req.transfer = transfer.toBytes(); - const res = sandbox(FN_CALL, req.bytes()); - return new ScDict(res).immutable() + fn call_with_transfer(&self, h_contract: ScHname, h_function: ScHname, params: Option, transfer: Option) -> ScImmutableDict { + let mut req = wasmrequests::CallRequest { + contract: h_contract, + function: h_function, + params: vec![0; SC_UINT32_LENGTH], + transfer: vec![0; SC_UINT32_LENGTH], + }; + if let Some(params) = params { + req.params = params.to_bytes(); + } + if let Some(transfer) = transfer { + req.transfer = transfer.to_bytes(); + } + let buf = sandbox(FN_CALL, &req.to_bytes()); + ScImmutableDict::new(ScDict::new(&buf)) } - // retrieve the chain id of the chain this contract lives on - pub fn chainID() -> wasmtypes::ScChainID { - return wasmtypes::chainIDFromBytes(sandbox(FN_CHAIN_ID, null)) + // retrieve the chain id of the chain self contract lives on + fn chain_id(&self) -> ScChainID { + chain_id_from_bytes(&sandbox(FN_CHAIN_ID, &[])) } - // retrieve the agent id of the owner of the chain this contract lives on - pub fn chainOwnerID() -> wasmtypes::ScAgentID { - return wasmtypes::agentIDFromBytes(sandbox(FN_CHAIN_OWNER_ID, null)) + // retrieve the agent id of the owner of the chain self contract lives on + fn chain_owner_id(&self) -> ScAgentID { + agent_id_from_bytes(&sandbox(FN_CHAIN_OWNER_ID, &[])) } - // retrieve the hname of this contract - pub fn contract() -> wasmtypes::ScHname { - return wasmtypes::hnameFromBytes(sandbox(FN_CONTRACT, null)) + // retrieve the hname of self contract + fn contract(&self) -> ScHname { + hname_from_bytes(&sandbox(FN_CONTRACT, &[])) } - // retrieve the agent id of the creator of this contract - pub fn contractCreator() -> wasmtypes::ScAgentID { - return wasmtypes::agentIDFromBytes(sandbox(FN_CONTRACT_CREATOR, null)) + // retrieve the agent id of the creator of self contract + fn contract_creator(&self) -> ScAgentID { + agent_id_from_bytes(&sandbox(FN_CONTRACT_CREATOR, &[])) } // logs informational text message - pub fn log(text: string) -> void { - sandbox(FN_LOG, wasmtypes::stringToBytes(text)) + fn log(&self, text: &str) { + sandbox(FN_LOG, &string_to_bytes(text)); } // logs error text message and then panics - pub fn panic(text: string) -> void { - sandbox(FN_PANIC, wasmtypes::stringToBytes(text)) + fn panic(&self, text: &str) { + sandbox(FN_PANIC, &string_to_bytes(text)); } // retrieve parameters passed to the smart contract function that was called - pub fn params() -> ScImmutableDict { - return new - ScDict(sandbox(FN_PARAMS, null)).immutable() + fn params(&self) -> ScImmutableDict { + let buf = sandbox(FN_PARAMS, &[]); + ScImmutableDict::new(ScDict::new(&buf)) } // panics if condition is not satisfied - pub fn require(cond: bool, msg: string) -> void { - if (!cond) { - this.panic(msg) + fn require(&self, cond: bool, msg: &str) { + if !cond { + panic(msg) } } - pub fn results(results: ScDict) -> void { - sandbox(FN_RESULTS, results.toBytes()) + fn results(&self, results: &ScDict) { + sandbox(FN_RESULTS, &results.to_bytes()); } // deterministic time stamp fixed at the moment of calling the smart contract - pub fn timestamp() -> u64 { - return wasmtypes::uint64FromBytes(sandbox(FN_TIMESTAMP, null)) + fn timestamp(&self) -> u64 { + uint64_from_bytes(&sandbox(FN_TIMESTAMP, &[])) } // logs debugging trace text message - pub fn trace(text: string) -> void { - sandbox(FN_TRACE, wasmtypes::stringToBytes(text)); + fn trace(&self, text: &str) { + sandbox(FN_TRACE, &string_to_bytes(text)); } // access diverse utility functions - pub fn utility() -> ScSandboxUtils { - return ScSandboxUtils {}; + fn utility(&self) -> ScSandboxUtils { + ScSandboxUtils {} } } -pub struct ScSandboxView {} +pub trait ScSandboxView: ScSandbox { + // calls a smart contract view + fn call(&self, h_contract: ScHname, h_function: ScHname, params: Option) -> ScImmutableDict { + return self.call_with_transfer(h_contract, h_function, params, None); + } -impl ScSandboxView { - pub fn rawState() -> ScImmutableState { - return ScImmutableState {}; + fn raw_state(&self) -> ScImmutableDict { + ScImmutableDict::new(ScDict::state()) } } -pub struct ScSandboxFunc {} +pub trait ScSandboxFunc: ScSandbox { + //fn blockContext(&self, construct func(sandbox: ScSandbox) interface{}, onClose func(interface{})) -> interface{} { + // panic("implement me") + //} + + // calls a smart contract func or view + fn call(&self, h_contract: ScHname, h_function: ScHname, params: Option, transfer: Option) -> ScImmutableDict { + return self.call_with_transfer(h_contract, h_function, params, transfer); + } + + // retrieve the agent id of the caller of the smart contract + fn caller(&self) -> ScAgentID { + return agent_id_from_bytes(&sandbox(FN_CALLER, &[])); + } + + // deploys a smart contract + fn deploy_contract(&self, program_hash: &ScHash, name: &str, description: &str, init_params: Option) { + let mut req = wasmrequests::DeployRequest { + prog_hash: program_hash.clone(), + name: name.to_string(), + description: description.to_string(), + params: vec![0; SC_UINT32_LENGTH], + }; + if let Some(init_params) = init_params { + req.params = init_params.to_bytes(); + } + sandbox(FN_DEPLOY_CONTRACT, &req.to_bytes()); + } + + // returns random entropy data for current request. + fn entropy(&self) -> ScHash { + return hash_from_bytes(&sandbox(FN_ENTROPY, &[])); + } + + // signals an event on the node that external entities can subscribe to + fn event(&self, msg: &str) { + sandbox(FN_EVENT, &string_to_bytes(msg)); + } -impl ScSandboxFunc { - pub fn rawState() -> ScState { - return ScState {}; + // access the incoming balances for all assets + fn incoming_transfer(&self) -> ScBalances { + let buf = sandbox(FN_INCOMING_TRANSFER, &[]); + return ScAssets::new(&buf).balances(); } + + // retrieve the assets that were minted in self transaction + fn minted(&self) -> ScBalances { + let buf = sandbox(FN_MINTED, &[]); + return ScAssets::new(&buf).balances(); + } + + // (delayed) posts a smart contract function request + fn post(&self, chain_id: ScChainID, h_contract: ScHname, h_function: ScHname, params: ScDict, transfer: ScTransfers, delay: u32) { + if transfer.balances().colors().len() == 0 { + self.panic("missing transfer"); + } + let req = wasmrequests::PostRequest { + chain_id, + contract: h_contract, + function: h_function, + params: params.to_bytes(), + transfer: transfer.to_bytes(), + delay: delay, + }; + sandbox(FN_POST, &req.to_bytes()); + } + + // generates a random value from 0 to max (exclusive: max) using a deterministic RNG + fn random(&self, max: u64) -> u64 { + if max == 0 { + self.panic("random: max parameter should be non-zero"); + } + unsafe { + static mut ENTROPY: Vec = Vec::new(); + static mut OFFSET: usize = 0; + // note that entropy gets reset for every request + if ENTROPY.len() == 0 { + // first time in self: request, initialize with current request entropy + ENTROPY = self.entropy().to_bytes(); + OFFSET = 0; + } + if OFFSET == 32 { + // ran out of entropy: data, hash entropy for next pseudo-random entropy + ENTROPY = self.utility().hash_blake2b(&ENTROPY).to_bytes(); + OFFSET = 0; + } + let rnd = uint64_from_bytes(&ENTROPY[OFFSET..OFFSET + 8]) % max; + OFFSET += 8; + return rnd; + } + } + + fn raw_state(&self) -> ScDict { + ScDict::state() + } + + //fn request(&self) -> ScRequest { + // panic("implement me"); + //} + + // retrieve the request id of self transaction + fn request_id(&self) -> ScRequestID { + return request_id_from_bytes(&sandbox(FN_REQUEST_ID, &[])); + } + + // transfer assetss to the specified Tangle ledger address + fn send(&self, address: &ScAddress, transfer: &ScTransfers) { + // we need some assets to send + let mut assets: u64 = 0; + let colors = transfer.balances().colors(); + for i in 0..colors.len() { + let color = colors.get(i).unwrap(); + assets += transfer.balances().balance(color); + } + if assets == 0 { + // only try to send when non-zero assets + return; + } + + let req = wasmrequests::SendRequest { + address: address.clone(), + transfer: transfer.to_bytes(), + }; + sandbox(FN_SEND, &req.to_bytes()); + } + + //fn stateAnchor(&self) -> interface{} { + // panic("implement me") + //} } diff --git a/packages/wasmvm/wasmlib/src/sandboxutils.rs b/packages/wasmvm/wasmlib/src/sandboxutils.rs index 526dad8eb7..7d9ddffc87 100644 --- a/packages/wasmvm/wasmlib/src/sandboxutils.rs +++ b/packages/wasmvm/wasmlib/src/sandboxutils.rs @@ -1,67 +1,73 @@ // Copyright 2020 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 +use crate::*; use crate::host::*; -use crate::wasmtypes; pub struct ScSandboxUtils {} impl ScSandboxUtils { // decodes the specified base58-encoded string value to its original bytes - pub fn base58Decode(value: string) -> &[u8] { - return sandbox(util.FnUtilsBase58Decode, wasmtypes.stringToBytes(value)); + pub fn base58_ecode(&self, value: &str) -> Vec { + sandbox(FN_UTILS_BASE58_DECODE, &string_to_bytes(value)) } // encodes the specified bytes to a base-58-encoded string - pub fn base58Encode(bytes: &[u8]) -> string { - return wasmtypes.bytesToString(sandbox(util.FnUtilsBase58Encode, bytes)); + pub fn base58_encode(&self, bytes: &[u8]) -> String { + bytes_to_string(&sandbox(FN_UTILS_BASE58_ENCODE, bytes)) } - pub fn blsAddressFromPubKey(pubKey: &[u8]) -> wasmtypes.ScAddress { - return wasmtypes.addressFromBytes(sandbox(util.FnUtilsBlsAddress, pubKey)); + pub fn bls_address_from_pub_key(&self, pub_key: &[u8]) -> ScAddress { + address_from_bytes(&sandbox(FN_UTILS_BLS_ADDRESS, pub_key)) } - pub fn blsAggregateSignatures(pubKeys: &[u8][], sigs: &[u8][]) -> &[u8][] { - const enc = new wasmtypes.WasmEncoder(); - wasmtypes.uint32Encode(enc, pubKeys.length as u32); - for (let i = 0; i < pubKeys.length; i++) { - enc.bytes(pubKeys[i]); - } - wasmtypes.uint32Encode(enc, sigs.length as u32); - for (let i = 0; i < sigs.length; i++) { - enc.bytes(sigs[i]); - } - const result = sandbox(util.FnUtilsBlsAggregate, enc.buf()); - const decode = new wasmtypes.WasmDecoder(result); - return [decode.bytes(), decode.bytes()]; + pub fn bls_aggregate_signatures(&self, pub_keys: &[&[u8]], sigs: &[&[u8]]) -> Vec> { + let mut enc = WasmEncoder::new(); + uint32_encode(&mut enc, pub_keys.len() as u32); + for i in 0..pub_keys.len() { + enc.bytes(pub_keys[i]); + } + uint32_encode(&mut enc, sigs.len() as u32); + for i in 0..sigs.len() { + enc.bytes(sigs[i]); + } + let res = sandbox(FN_UTILS_BLS_AGGREGATE, &enc.buf()); + let mut dec = WasmDecoder::new(&res); + return [dec.bytes(), dec.bytes()].to_vec(); } - pub fn blsValidSignature(data: &[u8], pubKey: &[u8], signature: &[u8]) -> bool { - const enc = new wasmtypes.WasmEncoder().bytes(data).bytes(pubKey).bytes(signature); - return wasmtypes.boolFromBytes(sandbox(util.FnUtilsBlsValid, enc.buf())); -} + pub fn bls_valid_signature(&self, data: &[u8], pub_key: &[u8], signature: &[u8]) -> bool { + let mut enc = WasmEncoder::new(); + enc.bytes(data); + enc.bytes(pub_key); + enc.bytes(signature); + bool_from_bytes(&sandbox(FN_UTILS_BLS_VALID, &enc.buf())) + } -pub fn ed25519AddressFromPubKey(pubKey: &[u8]) -> wasmtypes.ScAddress { -return wasmtypes.addressFromBytes(sandbox(util.FnUtilsEd25519Address, pubKey)); -} + pub fn ed25519_address_from_pub_key(&self, pub_key: &[u8]) -> ScAddress { + address_from_bytes(&sandbox(FN_UTILS_ED25519_ADDRESS, pub_key)) + } -pub fn ed25519ValidSignature(data: &[u8], pubKey: &[u8], signature: &[u8]) -> bool { -const enc = new wasmtypes.WasmEncoder().bytes(data).bytes(pubKey).bytes(signature); -return wasmtypes.boolFromBytes(sandbox(util.FnUtilsEd25519Valid, enc.buf())); -} + pub fn ed25519_valid_signature(&self, data: &[u8], pub_key: &[u8], signature: &[u8]) -> bool { + let mut enc = WasmEncoder::new(); + enc.bytes(data); + enc.bytes(pub_key); + enc.bytes(signature); + bool_from_bytes(&sandbox(FN_UTILS_ED25519_VALID, &enc.buf())) + } -// hashes the specified value bytes using blake2b hashing and returns the resulting 32-byte hash -pub fn hashBlake2b(value: &[u8]) -> wasmtypes.ScHash { -return wasmtypes.hashFromBytes(sandbox(util.FnUtilsHashBlake2b, value)); -} + // hashes the specified value bytes using blake2b hashing and returns the resulting 32-byte hash + pub fn hash_blake2b(&self, value: &[u8]) -> ScHash { + hash_from_bytes(&sandbox(FN_UTILS_HASH_BLAKE2B, value)) + } -// hashes the specified value bytes using sha3 hashing and returns the resulting 32-byte hash -pub fn hashSha3(value: &[u8]) -> wasmtypes.ScHash { -return wasmtypes.hashFromBytes(sandbox(util.FnUtilsHashSha3, value)); -} + // hashes the specified value bytes using sha3 hashing and returns the resulting 32-byte hash + pub fn hash_sha3(&self, value: &[u8]) -> ScHash { + hash_from_bytes(&sandbox(FN_UTILS_HASH_SHA3, value)) + } -// hashes the specified value bytes using blake2b hashing and returns the resulting 32-byte hash -pub fn hname(value: string) -> wasmtypes.ScHname { -return wasmtypes.hnameFromBytes(sandbox(util.FnUtilsHashName, wasmtypes.stringToBytes(value))); -} + // hashes the specified value bytes using blake2b hashing and returns the resulting 32-byte hash + pub fn hash_name(&self, value: &str) -> ScHname { + hname_from_bytes(&sandbox(FN_UTILS_HASH_NAME, &string_to_bytes(value))) + } } \ No newline at end of file diff --git a/packages/wasmvm/wasmlib/src/state.rs b/packages/wasmvm/wasmlib/src/state.rs deleted file mode 100644 index 9d4dd44367..0000000000 --- a/packages/wasmvm/wasmlib/src/state.rs +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright 2020 IOTA Stiftung -// SPDX-License-Identifier: Apache-2.0 - -use crate::host::*; -use crate::wasmtypes::IKvStore; - -pub struct ScImmutableState {} - -impl ScImmutableState { - pub fn exists(&self, key: &[u8]) -> bool { - state_exists(key) - } - - pub fn get(&self, key: &[u8]) -> Vec { - state_get(key) - } -} - -pub struct ScState {} - -impl IKvStore for ScState { - fn delete(&mut self, key: &[u8]) { - state_delete(key); - } - - fn exists(&self, key: &[u8]) -> bool { - state_exists(key) - } - - fn get(&self, key: &[u8]) -> Vec { - state_get(key) - } - - fn set(&mut self, key: &[u8], value: &[u8]) { - state_set(key, value); - } -} diff --git a/packages/wasmvm/wasmlib/src/wasmrequests/contract.rs b/packages/wasmvm/wasmlib/src/wasmrequests/contract.rs index 95592dc87f..b12151f2d7 100644 --- a/packages/wasmvm/wasmlib/src/wasmrequests/contract.rs +++ b/packages/wasmvm/wasmlib/src/wasmrequests/contract.rs @@ -7,8 +7,6 @@ #![allow(dead_code)] -use std::ptr; - use crate::*; use crate::wasmrequests::*; diff --git a/packages/wasmvm/wasmlib/src/wasmrequests/structs.rs b/packages/wasmvm/wasmlib/src/wasmrequests/structs.rs index 71d09fc67d..b5a9f3f61e 100644 --- a/packages/wasmvm/wasmlib/src/wasmrequests/structs.rs +++ b/packages/wasmvm/wasmlib/src/wasmrequests/structs.rs @@ -9,7 +9,6 @@ #![allow(unused_imports)] use crate::*; -use wasmlib::host::*; #[derive(Clone)] pub struct CallRequest { @@ -21,62 +20,60 @@ pub struct CallRequest { impl CallRequest { pub fn from_bytes(bytes: &[u8]) -> CallRequest { - let mut decode = BytesDecoder::new(bytes); + let mut dec = WasmDecoder::new(bytes); CallRequest { - contract : decode.hname(), - function : decode.hname(), - params : decode.bytes(), - transfer : decode.bytes(), + contract : hname_decode(&mut dec), + function : hname_decode(&mut dec), + params : bytes_decode(&mut dec), + transfer : bytes_decode(&mut dec), } } pub fn to_bytes(&self) -> Vec { - let mut encode = BytesEncoder::new(); - encode.hname(self.contract); - encode.hname(self.function); - encode.bytes(self.params); - encode.bytes(self.transfer); - return encode.data(); + let mut enc = WasmEncoder::new(); + hname_encode(&mut enc, self.contract); + hname_encode(&mut enc, self.function); + bytes_encode(&mut enc, &self.params); + bytes_encode(&mut enc, &self.transfer); + enc.buf() } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableCallRequest { - pub(crate) obj_id: i32, - pub(crate) key_id: Key32, + pub(crate) proxy: Proxy, } impl ImmutableCallRequest { pub fn exists(&self) -> bool { - exists(self.obj_id, self.key_id, TYPE_BYTES) + self.proxy.exists() } pub fn value(&self) -> CallRequest { - CallRequest::from_bytes(&get_bytes(self.obj_id, self.key_id, TYPE_BYTES)) + CallRequest::from_bytes(&self.proxy.get()) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableCallRequest { - pub(crate) obj_id: i32, - pub(crate) key_id: Key32, + pub(crate) proxy: Proxy, } impl MutableCallRequest { pub fn delete(&self) { - del_key(self.obj_id, self.key_id, TYPE_BYTES); + self.proxy.delete(); } pub fn exists(&self) -> bool { - exists(self.obj_id, self.key_id, TYPE_BYTES) + self.proxy.exists() } pub fn set_value(&self, value: &CallRequest) { - set_bytes(self.obj_id, self.key_id, TYPE_BYTES, &value.to_bytes()); + self.proxy.set(&value.to_bytes()); } pub fn value(&self) -> CallRequest { - CallRequest::from_bytes(&get_bytes(self.obj_id, self.key_id, TYPE_BYTES)) + CallRequest::from_bytes(&self.proxy.get()) } } @@ -90,62 +87,60 @@ pub struct DeployRequest { impl DeployRequest { pub fn from_bytes(bytes: &[u8]) -> DeployRequest { - let mut decode = BytesDecoder::new(bytes); + let mut dec = WasmDecoder::new(bytes); DeployRequest { - description : decode.string(), - name : decode.string(), - params : decode.bytes(), - prog_hash : decode.hash(), + description : string_decode(&mut dec), + name : string_decode(&mut dec), + params : bytes_decode(&mut dec), + prog_hash : hash_decode(&mut dec), } } pub fn to_bytes(&self) -> Vec { - let mut encode = BytesEncoder::new(); - encode.string(&self.description); - encode.string(&self.name); - encode.bytes(self.params); - encode.hash(&self.prog_hash); - return encode.data(); + let mut enc = WasmEncoder::new(); + string_encode(&mut enc, &self.description); + string_encode(&mut enc, &self.name); + bytes_encode(&mut enc, &self.params); + hash_encode(&mut enc, &self.prog_hash); + enc.buf() } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableDeployRequest { - pub(crate) obj_id: i32, - pub(crate) key_id: Key32, + pub(crate) proxy: Proxy, } impl ImmutableDeployRequest { pub fn exists(&self) -> bool { - exists(self.obj_id, self.key_id, TYPE_BYTES) + self.proxy.exists() } pub fn value(&self) -> DeployRequest { - DeployRequest::from_bytes(&get_bytes(self.obj_id, self.key_id, TYPE_BYTES)) + DeployRequest::from_bytes(&self.proxy.get()) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableDeployRequest { - pub(crate) obj_id: i32, - pub(crate) key_id: Key32, + pub(crate) proxy: Proxy, } impl MutableDeployRequest { pub fn delete(&self) { - del_key(self.obj_id, self.key_id, TYPE_BYTES); + self.proxy.delete(); } pub fn exists(&self) -> bool { - exists(self.obj_id, self.key_id, TYPE_BYTES) + self.proxy.exists() } pub fn set_value(&self, value: &DeployRequest) { - set_bytes(self.obj_id, self.key_id, TYPE_BYTES, &value.to_bytes()); + self.proxy.set(&value.to_bytes()); } pub fn value(&self) -> DeployRequest { - DeployRequest::from_bytes(&get_bytes(self.obj_id, self.key_id, TYPE_BYTES)) + DeployRequest::from_bytes(&self.proxy.get()) } } @@ -161,66 +156,64 @@ pub struct PostRequest { impl PostRequest { pub fn from_bytes(bytes: &[u8]) -> PostRequest { - let mut decode = BytesDecoder::new(bytes); + let mut dec = WasmDecoder::new(bytes); PostRequest { - chain_id : decode.chain_id(), - contract : decode.hname(), - delay : decode.uint32(), - function : decode.hname(), - params : decode.bytes(), - transfer : decode.bytes(), + chain_id : chain_id_decode(&mut dec), + contract : hname_decode(&mut dec), + delay : uint32_decode(&mut dec), + function : hname_decode(&mut dec), + params : bytes_decode(&mut dec), + transfer : bytes_decode(&mut dec), } } pub fn to_bytes(&self) -> Vec { - let mut encode = BytesEncoder::new(); - encode.chain_id(&self.chain_id); - encode.hname(self.contract); - encode.uint32(self.delay); - encode.hname(self.function); - encode.bytes(self.params); - encode.bytes(self.transfer); - return encode.data(); + let mut enc = WasmEncoder::new(); + chain_id_encode(&mut enc, &self.chain_id); + hname_encode(&mut enc, self.contract); + uint32_encode(&mut enc, self.delay); + hname_encode(&mut enc, self.function); + bytes_encode(&mut enc, &self.params); + bytes_encode(&mut enc, &self.transfer); + enc.buf() } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutablePostRequest { - pub(crate) obj_id: i32, - pub(crate) key_id: Key32, + pub(crate) proxy: Proxy, } impl ImmutablePostRequest { pub fn exists(&self) -> bool { - exists(self.obj_id, self.key_id, TYPE_BYTES) + self.proxy.exists() } pub fn value(&self) -> PostRequest { - PostRequest::from_bytes(&get_bytes(self.obj_id, self.key_id, TYPE_BYTES)) + PostRequest::from_bytes(&self.proxy.get()) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutablePostRequest { - pub(crate) obj_id: i32, - pub(crate) key_id: Key32, + pub(crate) proxy: Proxy, } impl MutablePostRequest { pub fn delete(&self) { - del_key(self.obj_id, self.key_id, TYPE_BYTES); + self.proxy.delete(); } pub fn exists(&self) -> bool { - exists(self.obj_id, self.key_id, TYPE_BYTES) + self.proxy.exists() } pub fn set_value(&self, value: &PostRequest) { - set_bytes(self.obj_id, self.key_id, TYPE_BYTES, &value.to_bytes()); + self.proxy.set(&value.to_bytes()); } pub fn value(&self) -> PostRequest { - PostRequest::from_bytes(&get_bytes(self.obj_id, self.key_id, TYPE_BYTES)) + PostRequest::from_bytes(&self.proxy.get()) } } @@ -232,57 +225,55 @@ pub struct SendRequest { impl SendRequest { pub fn from_bytes(bytes: &[u8]) -> SendRequest { - let mut decode = BytesDecoder::new(bytes); + let mut dec = WasmDecoder::new(bytes); SendRequest { - address : decode.address(), - transfer : decode.bytes(), + address : address_decode(&mut dec), + transfer : bytes_decode(&mut dec), } } pub fn to_bytes(&self) -> Vec { - let mut encode = BytesEncoder::new(); - encode.address(&self.address); - encode.bytes(self.transfer); - return encode.data(); + let mut enc = WasmEncoder::new(); + address_encode(&mut enc, &self.address); + bytes_encode(&mut enc, &self.transfer); + enc.buf() } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct ImmutableSendRequest { - pub(crate) obj_id: i32, - pub(crate) key_id: Key32, + pub(crate) proxy: Proxy, } impl ImmutableSendRequest { pub fn exists(&self) -> bool { - exists(self.obj_id, self.key_id, TYPE_BYTES) + self.proxy.exists() } pub fn value(&self) -> SendRequest { - SendRequest::from_bytes(&get_bytes(self.obj_id, self.key_id, TYPE_BYTES)) + SendRequest::from_bytes(&self.proxy.get()) } } -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct MutableSendRequest { - pub(crate) obj_id: i32, - pub(crate) key_id: Key32, + pub(crate) proxy: Proxy, } impl MutableSendRequest { pub fn delete(&self) { - del_key(self.obj_id, self.key_id, TYPE_BYTES); + self.proxy.delete(); } pub fn exists(&self) -> bool { - exists(self.obj_id, self.key_id, TYPE_BYTES) + self.proxy.exists() } pub fn set_value(&self, value: &SendRequest) { - set_bytes(self.obj_id, self.key_id, TYPE_BYTES, &value.to_bytes()); + self.proxy.set(&value.to_bytes()); } pub fn value(&self) -> SendRequest { - SendRequest::from_bytes(&get_bytes(self.obj_id, self.key_id, TYPE_BYTES)) + SendRequest::from_bytes(&self.proxy.get()) } } diff --git a/packages/wasmvm/wasmlib/src/wasmtypes/proxy.rs b/packages/wasmvm/wasmlib/src/wasmtypes/proxy.rs index 9e836c8461..f69a69a81e 100644 --- a/packages/wasmvm/wasmlib/src/wasmtypes/proxy.rs +++ b/packages/wasmvm/wasmlib/src/wasmtypes/proxy.rs @@ -1,33 +1,37 @@ // Copyright 2020 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 -use crate::sandbox::*; -use crate::wasmtypes::*; - -pub trait IKvStore { - fn delete(&mut self, key: &[u8]); - fn exists(&self, key: &[u8]) -> bool; - fn get(&self, key: &[u8]) -> Vec; - fn set(&mut self, key: &[u8], value: &[u8]); -} +use std::cell::RefCell; +use std::rc::Rc; + +use crate::*; -pub struct Proxy<'a> { +#[derive(Clone)] +pub struct Proxy { key: Vec, - kv_store: &'a dyn IKvStore, + pub kv_store: Rc, } -impl Proxy<'_> { - pub fn new(kv_store: &dyn IKvStore) -> Proxy { - Proxy { kv_store, key: Vec::new() } +impl Proxy { + pub fn new(kv_store: &Rc) -> Proxy { + Proxy { kv_store: Rc::clone(kv_store), key: Vec::new() } + } + + pub fn nil() -> Proxy { + Proxy::new(&Rc::new(ScDict::new(&[]))) + } + + pub fn link(proxy: &mut Proxy, kv_store: &Rc) { + proxy.kv_store = Rc::clone(kv_store); } - pub fn append(&mut self) -> Proxy { + pub fn append(&self) -> Proxy { let length = self.length(); self.expand(length + 1); self.element(length) } - pub fn clear_array(&mut self) { + pub fn clear_array(&self) { let mut length = self.length(); while length != 0 { length -= 1; @@ -38,14 +42,14 @@ impl Proxy<'_> { self.delete(); } - pub fn clear_map(&mut self) { + pub fn clear_map(&self) { // TODO clear prefix // clear the length counter self.delete(); } - pub fn delete(&mut self) { + pub fn delete(&self) { self.kv_store.delete(&self.key); } @@ -60,7 +64,7 @@ impl Proxy<'_> { self.kv_store.exists(&self.key) } - pub fn expand(&mut self, length: u32) { + pub fn expand(&self, length: u32) { // update the length counter let mut enc = WasmEncoder::new(); uint32_encode(&mut enc, length); @@ -97,20 +101,20 @@ impl Proxy<'_> { } pub fn root(&self, key: &str) -> Proxy { - Proxy { kv_store: self.kv_store, key: string_to_bytes(key).to_vec() } + Proxy { kv_store: Rc::clone(&self.kv_store), key: string_to_bytes(key).to_vec() } } - pub fn set(&mut self, value: &[u8]) { + pub fn set(&self, value: &[u8]) { self.kv_store.set(&self.key, value); } fn sub(&self, sep: u8, key: &[u8]) -> Proxy { if self.key.len() == 0 { - return Proxy { kv_store: self.kv_store, key: key.to_vec() }; + return Proxy { kv_store: Rc::clone(&self.kv_store), key: key.to_vec() }; } let mut buf: Vec = self.key.clone(); buf.push(sep); buf.extend_from_slice(key); - Proxy { kv_store: self.kv_store, key: buf } + Proxy { kv_store: Rc::clone(&self.kv_store), key: buf } } } diff --git a/packages/wasmvm/wasmlib/src/wasmtypes/scaddress.rs b/packages/wasmvm/wasmlib/src/wasmtypes/scaddress.rs index f3380f4e5a..add073a048 100644 --- a/packages/wasmvm/wasmlib/src/wasmtypes/scaddress.rs +++ b/packages/wasmvm/wasmlib/src/wasmtypes/scaddress.rs @@ -4,7 +4,6 @@ use std::convert::TryInto; use crate::*; -use crate::wasmtypes::*; // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ @@ -21,7 +20,7 @@ impl ScAddress { } pub fn as_agent_id(&self) -> ScAgentID { - ScAgentID::new(self, &ScHname(0)) + ScAgentID::new(self, ScHname(0)) } pub fn to_bytes(&self) -> Vec { @@ -44,7 +43,17 @@ pub fn address_encode(enc: &mut WasmEncoder, value: &ScAddress) { } pub fn address_from_bytes(buf: &[u8]) -> ScAddress { - ScAddress { id: buf.try_into().expect("invalid Address length") } + if buf.len() == 0 { + return ScAddress { id: [0;SC_ADDRESS_LENGTH] }; + } + if buf.len() != SC_ADDRESS_LENGTH { + panic("invalid Address length"); + } + // max ledgerstate.AliasAddressType + if buf[0] > 2 { + panic("invalid Address: address type > 2"); + } + ScAddress { id: buf.try_into().expect("WTF?") } } pub fn address_to_bytes(value: &ScAddress) -> Vec { @@ -62,11 +71,11 @@ fn address_from_bytes_unchecked(buf: &[u8]) -> ScAddress { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -pub struct ScImmutableAddress<'a> { - proxy: Proxy<'a>, +pub struct ScImmutableAddress { + proxy: Proxy, } -impl ScImmutableAddress<'_> { +impl ScImmutableAddress { pub fn new(proxy: Proxy) -> ScImmutableAddress { ScImmutableAddress { proxy } } @@ -87,16 +96,16 @@ impl ScImmutableAddress<'_> { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // value proxy for mutable ScAddress in host container -pub struct ScMutableAddress<'a> { - proxy: Proxy<'a>, +pub struct ScMutableAddress { + proxy: Proxy, } -impl ScMutableAddress<'_> { +impl ScMutableAddress { pub fn new(proxy: Proxy) -> ScMutableAddress { ScMutableAddress { proxy } } - pub fn delete(&mut self) { + pub fn delete(&self) { self.proxy.delete(); } @@ -104,7 +113,7 @@ impl ScMutableAddress<'_> { self.proxy.exists() } - pub fn set_value(&mut self, value: &ScAddress) { + pub fn set_value(&self, value: &ScAddress) { self.proxy.set(&address_to_bytes(&value)); } diff --git a/packages/wasmvm/wasmlib/src/wasmtypes/scagentid.rs b/packages/wasmvm/wasmlib/src/wasmtypes/scagentid.rs index 3ca028f751..f5bed4c97e 100644 --- a/packages/wasmvm/wasmlib/src/wasmtypes/scagentid.rs +++ b/packages/wasmvm/wasmlib/src/wasmtypes/scagentid.rs @@ -4,8 +4,6 @@ use std::convert::TryInto; use crate::*; -use crate::sandbox::*; -use crate::wasmtypes::*; // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ @@ -18,7 +16,7 @@ pub struct ScAgentID { } impl ScAgentID { - pub fn new(address: &ScAddress, hname: &ScHname) -> ScAgentID { + pub fn new(address: &ScAddress, hname: ScHname) -> ScAgentID { ScAgentID { address: address_from_bytes(&address.to_bytes()), hname: hname_from_bytes(&hname.to_bytes()) } } @@ -26,12 +24,12 @@ impl ScAgentID { agent_id_from_bytes(buf) } - pub fn address(&self) -> &ScAddress { - &self.address + pub fn address(&self) -> ScAddress { + self.address.clone() } - pub fn hname(&self) -> &ScHname { - &self.hname + pub fn hname(&self) -> ScHname { + self.hname } pub fn is_address(&self) -> bool { @@ -54,7 +52,7 @@ pub fn agent_id_decode(dec: &mut WasmDecoder) -> ScAgentID { } pub fn agent_id_encode(enc: &mut WasmEncoder, value: &ScAgentID) { - address_encode(enc, value.address()); + address_encode(enc, &value.address()); hname_encode(enc, value.hname()); } @@ -63,7 +61,7 @@ pub fn agent_id_from_bytes(buf: &[u8]) -> ScAgentID { return ScAgentID { address: address_from_bytes(buf), hname: hname_from_bytes(buf) }; } if buf.len() != SC_AGENT_ID_LENGTH { - panic("invalid AgentId length"); + panic("invalid AgentID length"); } // max ledgerstate.AliasAddressType if buf[0] > 2 { @@ -88,13 +86,13 @@ pub fn agent_id_to_string(value: &ScAgentID) -> String { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -pub struct ScImmutableAgentId<'a> { - proxy: Proxy<'a>, +pub struct ScImmutableAgentID { + proxy: Proxy, } -impl ScImmutableAgentId<'_> { - pub fn new(proxy: Proxy) -> ScImmutableAgentId { - ScImmutableAgentId { proxy } +impl ScImmutableAgentID { + pub fn new(proxy: Proxy) -> ScImmutableAgentID { + ScImmutableAgentID { proxy } } pub fn exists(&self) -> bool { @@ -112,17 +110,17 @@ impl ScImmutableAgentId<'_> { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -// value proxy for mutable ScAgentId in host container -pub struct ScMutableAgentId<'a> { - proxy: Proxy<'a>, +// value proxy for mutable ScAgentID in host container +pub struct ScMutableAgentID { + proxy: Proxy, } -impl ScMutableAgentId<'_> { - pub fn new(proxy: Proxy) -> ScMutableAgentId { - ScMutableAgentId { proxy } +impl ScMutableAgentID { + pub fn new(proxy: Proxy) -> ScMutableAgentID { + ScMutableAgentID { proxy } } - pub fn delete(&mut self) { + pub fn delete(&self) { self.proxy.delete(); } @@ -130,7 +128,7 @@ impl ScMutableAgentId<'_> { self.proxy.exists() } - pub fn set_value(&mut self, value: &ScAgentID) { + pub fn set_value(&self, value: &ScAgentID) { self.proxy.set(&agent_id_to_bytes(&value)); } diff --git a/packages/wasmvm/wasmlib/src/wasmtypes/scbool.rs b/packages/wasmvm/wasmlib/src/wasmtypes/scbool.rs index f21632f3c8..999b526aa0 100644 --- a/packages/wasmvm/wasmlib/src/wasmtypes/scbool.rs +++ b/packages/wasmvm/wasmlib/src/wasmtypes/scbool.rs @@ -3,8 +3,7 @@ use std::convert::TryInto; -use crate::sandbox::*; -use crate::wasmtypes::*; +use crate::*; // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ @@ -36,7 +35,7 @@ pub fn bool_from_bytes(buf: &[u8]) -> bool { if buf[0] == SC_BOOL_FALSE { return false; } - if buf[0] != SC_BOOL_FALSE { + if buf[0] != SC_BOOL_TRUE { panic("invalid Bool value"); } return true; @@ -58,11 +57,11 @@ pub fn bool_to_string(value: bool) -> String { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -pub struct ScImmutableBool<'a> { - proxy: Proxy<'a>, +pub struct ScImmutableBool { + proxy: Proxy, } -impl ScImmutableBool<'_> { +impl ScImmutableBool { pub fn new(proxy: Proxy) -> ScImmutableBool { ScImmutableBool { proxy } } @@ -83,16 +82,16 @@ impl ScImmutableBool<'_> { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // value proxy for mutable bool in host container -pub struct ScMutableBool<'a> { - proxy: Proxy<'a>, +pub struct ScMutableBool { + proxy: Proxy, } -impl ScMutableBool<'_> { +impl ScMutableBool { pub fn new(proxy: Proxy) -> ScMutableBool { ScMutableBool { proxy } } - pub fn delete(&mut self) { + pub fn delete(&self) { self.proxy.delete(); } @@ -100,7 +99,7 @@ impl ScMutableBool<'_> { self.proxy.exists() } - pub fn set_value(&mut self, value: bool) { + pub fn set_value(&self, value: bool) { self.proxy.set(&bool_to_bytes(value)); } diff --git a/packages/wasmvm/wasmlib/src/wasmtypes/scbytes.rs b/packages/wasmvm/wasmlib/src/wasmtypes/scbytes.rs index 159670863d..a732b2ac20 100644 --- a/packages/wasmvm/wasmlib/src/wasmtypes/scbytes.rs +++ b/packages/wasmvm/wasmlib/src/wasmtypes/scbytes.rs @@ -3,7 +3,7 @@ use std::convert::TryInto; -use crate::wasmtypes::*; +use crate::*; // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ @@ -30,11 +30,11 @@ pub fn bytes_to_string(value: &[u8]) -> String { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -pub struct ScImmutableBytes<'a> { - proxy: Proxy<'a>, +pub struct ScImmutableBytes { + proxy: Proxy } -impl ScImmutableBytes<'_> { +impl ScImmutableBytes { pub fn new(proxy: Proxy) -> ScImmutableBytes { ScImmutableBytes { proxy } } @@ -55,16 +55,16 @@ impl ScImmutableBytes<'_> { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // value proxy for mutable ScBytes in host container -pub struct ScMutableBytes<'a> { - proxy: Proxy<'a>, +pub struct ScMutableBytes { + proxy: Proxy } -impl ScMutableBytes<'_> { +impl ScMutableBytes { pub fn new(proxy: Proxy) -> ScMutableBytes { ScMutableBytes { proxy } } - pub fn delete(&mut self) { + pub fn delete(&self) { self.proxy.delete(); } @@ -72,7 +72,7 @@ impl ScMutableBytes<'_> { self.proxy.exists() } - pub fn set_value(&mut self, value: &[u8]) { + pub fn set_value(&self, value: &[u8]) { self.proxy.set(&bytes_to_bytes(value)); } diff --git a/packages/wasmvm/wasmlib/src/wasmtypes/scchainid.rs b/packages/wasmvm/wasmlib/src/wasmtypes/scchainid.rs index d063c7036f..cb0b339305 100644 --- a/packages/wasmvm/wasmlib/src/wasmtypes/scchainid.rs +++ b/packages/wasmvm/wasmlib/src/wasmtypes/scchainid.rs @@ -4,7 +4,6 @@ use std::convert::TryInto; use crate::*; -use crate::wasmtypes::*; // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ @@ -44,7 +43,19 @@ pub fn chain_id_encode(enc: &mut WasmEncoder, value: &ScChainID) { } pub fn chain_id_from_bytes(buf: &[u8]) -> ScChainID { - ScChainID { id: buf.try_into().expect("invalid ChainId length") } + if buf.len() == 0 { + let mut chain_id = ScChainID { id: [0;SC_CHAIN_ID_LENGTH] }; + chain_id.id[0] = 2; // ledgerstate.AliasAddressType + return chain_id; + } + if buf.len() != SC_CHAIN_ID_LENGTH { + panic("invalid ChainID length"); + } + // must be ledgerstate.AliasAddressType + if buf[0] != 2 { + panic("invalid ChainID: not an alias address"); + } + ScChainID { id: buf.try_into().expect("WTF?") } } pub fn chain_id_to_bytes(value: &ScChainID) -> Vec { @@ -57,18 +68,18 @@ pub fn chain_id_to_string(value: &ScChainID) -> String { } fn chain_id_from_bytes_unchecked(buf: &[u8]) -> ScChainID { - ScChainID { id: buf.try_into().expect("invalid ChainId length") } + ScChainID { id: buf.try_into().expect("invalid ChainID length") } } // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -pub struct ScImmutableChainId<'a> { - proxy: Proxy<'a>, +pub struct ScImmutableChainID { + proxy: Proxy } -impl ScImmutableChainId<'_> { - pub fn new(proxy: Proxy) -> ScImmutableChainId { - ScImmutableChainId { proxy } +impl ScImmutableChainID { + pub fn new(proxy: Proxy) -> ScImmutableChainID { + ScImmutableChainID { proxy } } pub fn exists(&self) -> bool { @@ -86,17 +97,17 @@ impl ScImmutableChainId<'_> { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -// value proxy for mutable ScChainId in host container -pub struct ScMutableChainId<'a> { - proxy: Proxy<'a>, +// value proxy for mutable ScChainID in host container +pub struct ScMutableChainID { + proxy: Proxy } -impl ScMutableChainId<'_> { - pub fn new(proxy: Proxy) -> ScMutableChainId { - ScMutableChainId { proxy } +impl ScMutableChainID { + pub fn new(proxy: Proxy) -> ScMutableChainID { + ScMutableChainID { proxy } } - pub fn delete(&mut self) { + pub fn delete(&self) { self.proxy.delete(); } @@ -104,7 +115,7 @@ impl ScMutableChainId<'_> { self.proxy.exists() } - pub fn set_value(&mut self, value: &ScChainID) { + pub fn set_value(&self, value: &ScChainID) { self.proxy.set(&chain_id_to_bytes(&value)); } diff --git a/packages/wasmvm/wasmlib/src/wasmtypes/sccolor.rs b/packages/wasmvm/wasmlib/src/wasmtypes/sccolor.rs index f427fd9980..b2a8fec3a0 100644 --- a/packages/wasmvm/wasmlib/src/wasmtypes/sccolor.rs +++ b/packages/wasmvm/wasmlib/src/wasmtypes/sccolor.rs @@ -3,13 +3,13 @@ use std::convert::TryInto; -use crate::wasmtypes::*; +use crate::*; // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ pub const SC_COLOR_LENGTH: usize = 32; -#[derive(PartialEq, Clone)] +#[derive(PartialEq, Clone, Copy, Eq, Hash)] pub struct ScColor { id: [u8; SC_COLOR_LENGTH], } @@ -42,7 +42,13 @@ pub fn color_encode(enc: &mut WasmEncoder, value: &ScColor) { } pub fn color_from_bytes(buf: &[u8]) -> ScColor { - ScColor { id: buf.try_into().expect("invalid Color length") } + if buf.len() == 0 { + return ScColor { id: [0;SC_COLOR_LENGTH] }; + } + if buf.len() != SC_COLOR_LENGTH { + panic("invalid Color length"); + } + ScColor { id: buf.try_into().expect("WTF?") } } pub fn color_to_bytes(value: &ScColor) -> Vec { @@ -60,11 +66,11 @@ fn color_from_bytes_unchecked(buf: &[u8]) -> ScColor { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -pub struct ScImmutableColor<'a> { - proxy: Proxy<'a>, +pub struct ScImmutableColor { + proxy: Proxy } -impl ScImmutableColor<'_> { +impl ScImmutableColor { pub fn new(proxy: Proxy) -> ScImmutableColor { ScImmutableColor { proxy } } @@ -85,16 +91,16 @@ impl ScImmutableColor<'_> { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // value proxy for mutable ScColor in host container -pub struct ScMutableColor<'a> { - proxy: Proxy<'a>, +pub struct ScMutableColor { + proxy: Proxy } -impl ScMutableColor<'_> { +impl ScMutableColor { pub fn new(proxy: Proxy) -> ScMutableColor { ScMutableColor { proxy } } - pub fn delete(&mut self) { + pub fn delete(&self) { self.proxy.delete(); } @@ -102,7 +108,7 @@ impl ScMutableColor<'_> { self.proxy.exists() } - pub fn set_value(&mut self, value: &ScColor) { + pub fn set_value(&self, value: &ScColor) { self.proxy.set(&color_to_bytes(&value)); } diff --git a/packages/wasmvm/wasmlib/src/wasmtypes/schash.rs b/packages/wasmvm/wasmlib/src/wasmtypes/schash.rs index aba1837beb..bb1b41bb3e 100644 --- a/packages/wasmvm/wasmlib/src/wasmtypes/schash.rs +++ b/packages/wasmvm/wasmlib/src/wasmtypes/schash.rs @@ -3,7 +3,7 @@ use std::convert::TryInto; -use crate::wasmtypes::*; +use crate::*; // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ @@ -39,7 +39,13 @@ pub fn hash_encode(enc: &mut WasmEncoder, value: &ScHash) { } pub fn hash_from_bytes(buf: &[u8]) -> ScHash { - ScHash { id: buf.try_into().expect("invalid Hash length") } + if buf.len() == 0 { + return ScHash { id: [0;SC_HASH_LENGTH] }; + } + if buf.len() != SC_HASH_LENGTH { + panic("invalid Hash length"); + } + ScHash { id: buf.try_into().expect("WTF?") } } pub fn hash_to_bytes(value: &ScHash) -> Vec { @@ -57,11 +63,11 @@ fn hash_from_bytes_unchecked(buf: &[u8]) -> ScHash { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -pub struct ScImmutableHash<'a> { - proxy: Proxy<'a>, +pub struct ScImmutableHash { + proxy: Proxy } -impl ScImmutableHash<'_> { +impl ScImmutableHash { pub fn new(proxy: Proxy) -> ScImmutableHash { ScImmutableHash { proxy } } @@ -82,16 +88,16 @@ impl ScImmutableHash<'_> { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // value proxy for mutable ScHash in host container -pub struct ScMutableHash<'a> { - proxy: Proxy<'a>, +pub struct ScMutableHash { + proxy: Proxy } -impl ScMutableHash<'_> { +impl ScMutableHash { pub fn new(proxy: Proxy) -> ScMutableHash { ScMutableHash { proxy } } - pub fn delete(&mut self) { + pub fn delete(&self) { self.proxy.delete(); } @@ -99,7 +105,7 @@ impl ScMutableHash<'_> { self.proxy.exists() } - pub fn set_value(&mut self, value: &ScHash) { + pub fn set_value(&self, value: &ScHash) { self.proxy.set(&hash_to_bytes(&value)); } diff --git a/packages/wasmvm/wasmlib/src/wasmtypes/schname.rs b/packages/wasmvm/wasmlib/src/wasmtypes/schname.rs index 465624836b..b4933850e2 100644 --- a/packages/wasmvm/wasmlib/src/wasmtypes/schname.rs +++ b/packages/wasmvm/wasmlib/src/wasmtypes/schname.rs @@ -3,13 +3,13 @@ use std::convert::TryInto; -use crate::wasmtypes::*; +use crate::*; // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ pub const SC_HNAME_LENGTH: usize = 4; -#[derive(PartialEq, Clone)] +#[derive(PartialEq, Clone, Copy)] pub struct ScHname(pub u32); impl ScHname { @@ -18,11 +18,11 @@ impl ScHname { } pub fn to_bytes(&self) -> Vec { - hname_to_bytes(self) + hname_to_bytes(*self) } pub fn to_string(&self) -> String { - hname_to_string(self) + hname_to_string(*self) } } @@ -32,7 +32,7 @@ pub fn hname_decode(dec: &mut WasmDecoder) -> ScHname { hname_from_bytes(&dec.fixed_bytes(SC_HNAME_LENGTH)) } -pub fn hname_encode(enc: &mut WasmEncoder, value: &ScHname) { +pub fn hname_encode(enc: &mut WasmEncoder, value: ScHname) { enc.fixed_bytes(&hname_to_bytes(value), SC_HNAME_LENGTH); } @@ -40,14 +40,17 @@ pub fn hname_from_bytes(buf: &[u8]) -> ScHname { if buf.len() == 0 { return ScHname(0); } - ScHname(u32::from_le_bytes(buf.try_into().expect("invalid Hname length"))) + if buf.len() != SC_HNAME_LENGTH { + panic("invalid Hname length"); + } + ScHname(u32::from_le_bytes(buf.try_into().expect("WTF?"))) } -pub fn hname_to_bytes(value: &ScHname) -> Vec { +pub fn hname_to_bytes(value: ScHname) -> Vec { value.0.to_le_bytes().to_vec() } -pub fn hname_to_string(value: &ScHname) -> String { +pub fn hname_to_string(value: ScHname) -> String { let hexa = "0123456789abcdef".as_bytes(); let mut res = [0u8; 8]; let mut val = value.0; @@ -60,11 +63,11 @@ pub fn hname_to_string(value: &ScHname) -> String { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -pub struct ScImmutableHname<'a> { - proxy: Proxy<'a>, +pub struct ScImmutableHname { + proxy: Proxy } -impl ScImmutableHname<'_> { +impl ScImmutableHname { pub fn new(proxy: Proxy) -> ScImmutableHname { ScImmutableHname { proxy } } @@ -74,7 +77,7 @@ impl ScImmutableHname<'_> { } pub fn to_string(&self) -> String { - hname_to_string(&self.value()) + hname_to_string(self.value()) } pub fn value(&self) -> ScHname { @@ -85,16 +88,16 @@ impl ScImmutableHname<'_> { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // value proxy for mutable ScHname in host container -pub struct ScMutableHname<'a> { - proxy: Proxy<'a>, +pub struct ScMutableHname { + proxy: Proxy } -impl ScMutableHname<'_> { +impl ScMutableHname { pub fn new(proxy: Proxy) -> ScMutableHname { ScMutableHname { proxy } } - pub fn delete(&mut self) { + pub fn delete(&self) { self.proxy.delete(); } @@ -102,12 +105,12 @@ impl ScMutableHname<'_> { self.proxy.exists() } - pub fn set_value(&mut self, value: &ScHname) { - self.proxy.set(&hname_to_bytes(&value)); + pub fn set_value(&self, value: ScHname) { + self.proxy.set(&hname_to_bytes(value)); } pub fn to_string(&self) -> String { - hname_to_string(&self.value()) + hname_to_string(self.value()) } pub fn value(&self) -> ScHname { diff --git a/packages/wasmvm/wasmlib/src/wasmtypes/scint16.rs b/packages/wasmvm/wasmlib/src/wasmtypes/scint16.rs index f54c07555b..6570ee38ac 100644 --- a/packages/wasmvm/wasmlib/src/wasmtypes/scint16.rs +++ b/packages/wasmvm/wasmlib/src/wasmtypes/scint16.rs @@ -3,7 +3,7 @@ use std::convert::TryInto; -use crate::wasmtypes::*; +use crate::*; // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ @@ -23,7 +23,10 @@ pub fn int16_from_bytes(buf: &[u8]) -> i16 { if buf.len() == 0 { return 0; } - i16::from_le_bytes(buf.try_into().expect("invalid Int16 length")) + if buf.len() != SC_INT16_LENGTH { + panic("invalid Int16 length"); + } + i16::from_le_bytes(buf.try_into().expect("WTF?")) } pub fn int16_to_bytes(value: i16) -> Vec { @@ -36,11 +39,11 @@ pub fn int16_to_string(value: i16) -> String { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -pub struct ScImmutableInt16<'a> { - proxy: Proxy<'a>, +pub struct ScImmutableInt16 { + proxy: Proxy } -impl ScImmutableInt16<'_> { +impl ScImmutableInt16 { pub fn new(proxy: Proxy) -> ScImmutableInt16 { ScImmutableInt16 { proxy } } @@ -61,16 +64,16 @@ impl ScImmutableInt16<'_> { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // value proxy for mutable i16 in host container -pub struct ScMutableInt16<'a> { - proxy: Proxy<'a>, +pub struct ScMutableInt16 { + proxy: Proxy } -impl ScMutableInt16<'_> { +impl ScMutableInt16 { pub fn new(proxy: Proxy) -> ScMutableInt16 { ScMutableInt16 { proxy } } - pub fn delete(&mut self) { + pub fn delete(&self) { self.proxy.delete(); } @@ -78,7 +81,7 @@ impl ScMutableInt16<'_> { self.proxy.exists() } - pub fn set_value(&mut self, value: i16) { + pub fn set_value(&self, value: i16) { self.proxy.set(&int16_to_bytes(value)); } diff --git a/packages/wasmvm/wasmlib/src/wasmtypes/scint32.rs b/packages/wasmvm/wasmlib/src/wasmtypes/scint32.rs index 17652d3122..37d864f2a6 100644 --- a/packages/wasmvm/wasmlib/src/wasmtypes/scint32.rs +++ b/packages/wasmvm/wasmlib/src/wasmtypes/scint32.rs @@ -3,7 +3,7 @@ use std::convert::TryInto; -use crate::wasmtypes::*; +use crate::*; // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ @@ -23,7 +23,10 @@ pub fn int32_from_bytes(buf: &[u8]) -> i32 { if buf.len() == 0 { return 0; } - i32::from_le_bytes(buf.try_into().expect("invalid Int32 length")) + if buf.len() != SC_INT32_LENGTH { + panic("invalid Int32 length"); + } + i32::from_le_bytes(buf.try_into().expect("WTF?")) } pub fn int32_to_bytes(value: i32) -> Vec { @@ -36,11 +39,11 @@ pub fn int32_to_string(value: i32) -> String { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -pub struct ScImmutableInt32<'a> { - proxy: Proxy<'a>, +pub struct ScImmutableInt32 { + proxy: Proxy } -impl ScImmutableInt32<'_> { +impl ScImmutableInt32 { pub fn new(proxy: Proxy) -> ScImmutableInt32 { ScImmutableInt32 { proxy } } @@ -61,16 +64,16 @@ impl ScImmutableInt32<'_> { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // value proxy for mutable i32 in host container -pub struct ScMutableInt32<'a> { - proxy: Proxy<'a>, +pub struct ScMutableInt32 { + proxy: Proxy } -impl ScMutableInt32<'_> { +impl ScMutableInt32 { pub fn new(proxy: Proxy) -> ScMutableInt32 { ScMutableInt32 { proxy } } - pub fn delete(&mut self) { + pub fn delete(&self) { self.proxy.delete(); } @@ -78,7 +81,7 @@ impl ScMutableInt32<'_> { self.proxy.exists() } - pub fn set_value(&mut self, value: i32) { + pub fn set_value(&self, value: i32) { self.proxy.set(&int32_to_bytes(value)); } diff --git a/packages/wasmvm/wasmlib/src/wasmtypes/scint64.rs b/packages/wasmvm/wasmlib/src/wasmtypes/scint64.rs index a31b694bc4..a1f6536667 100644 --- a/packages/wasmvm/wasmlib/src/wasmtypes/scint64.rs +++ b/packages/wasmvm/wasmlib/src/wasmtypes/scint64.rs @@ -3,7 +3,7 @@ use std::convert::TryInto; -use crate::wasmtypes::*; +use crate::*; // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ @@ -23,7 +23,10 @@ pub fn int64_from_bytes(buf: &[u8]) -> i64 { if buf.len() == 0 { return 0; } - i64::from_le_bytes(buf.try_into().expect("invalid Int64 length")) + if buf.len() != SC_INT64_LENGTH { + panic("invalid Int64 length"); + } + i64::from_le_bytes(buf.try_into().expect("WTF?")) } pub fn int64_to_bytes(value: i64) -> Vec { @@ -36,11 +39,11 @@ pub fn int64_to_string(value: i64) -> String { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -pub struct ScImmutableInt64<'a> { - proxy: Proxy<'a>, +pub struct ScImmutableInt64 { + proxy: Proxy } -impl ScImmutableInt64<'_> { +impl ScImmutableInt64 { pub fn new(proxy: Proxy) -> ScImmutableInt64 { ScImmutableInt64 { proxy } } @@ -61,16 +64,16 @@ impl ScImmutableInt64<'_> { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // value proxy for mutable i64 in host container -pub struct ScMutableInt64<'a> { - proxy: Proxy<'a>, +pub struct ScMutableInt64 { + proxy: Proxy } -impl ScMutableInt64<'_> { +impl ScMutableInt64 { pub fn new(proxy: Proxy) -> ScMutableInt64 { ScMutableInt64 { proxy } } - pub fn delete(&mut self) { + pub fn delete(&self) { self.proxy.delete(); } @@ -78,7 +81,7 @@ impl ScMutableInt64<'_> { self.proxy.exists() } - pub fn set_value(&mut self, value: i64) { + pub fn set_value(&self, value: i64) { self.proxy.set(&int64_to_bytes(value)); } diff --git a/packages/wasmvm/wasmlib/src/wasmtypes/scint8.rs b/packages/wasmvm/wasmlib/src/wasmtypes/scint8.rs index cd2b14291c..6b135bbf53 100644 --- a/packages/wasmvm/wasmlib/src/wasmtypes/scint8.rs +++ b/packages/wasmvm/wasmlib/src/wasmtypes/scint8.rs @@ -3,8 +3,7 @@ use std::convert::TryInto; -use crate::sandbox::*; -use crate::wasmtypes::*; +use crate::*; // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ @@ -40,11 +39,11 @@ pub fn int8_to_string(value: i8) -> String { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -pub struct ScImmutableInt8<'a> { - proxy: Proxy<'a>, +pub struct ScImmutableInt8 { + proxy: Proxy } -impl ScImmutableInt8<'_> { +impl ScImmutableInt8 { pub fn new(proxy: Proxy) -> ScImmutableInt8 { ScImmutableInt8 { proxy } } @@ -65,16 +64,16 @@ impl ScImmutableInt8<'_> { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // value proxy for mutable i8 in host container -pub struct ScMutableInt8<'a> { - proxy: Proxy<'a>, +pub struct ScMutableInt8 { + proxy: Proxy } -impl ScMutableInt8<'_> { +impl ScMutableInt8 { pub fn new(proxy: Proxy) -> ScMutableInt8 { ScMutableInt8 { proxy } } - pub fn delete(&mut self) { + pub fn delete(&self) { self.proxy.delete(); } @@ -82,7 +81,7 @@ impl ScMutableInt8<'_> { self.proxy.exists() } - pub fn set_value(&mut self, value: i8) { + pub fn set_value(&self, value: i8) { self.proxy.set(&int8_to_bytes(value)); } diff --git a/packages/wasmvm/wasmlib/src/wasmtypes/screquestid.rs b/packages/wasmvm/wasmlib/src/wasmtypes/screquestid.rs index 726c47eb42..d5aab01675 100644 --- a/packages/wasmvm/wasmlib/src/wasmtypes/screquestid.rs +++ b/packages/wasmvm/wasmlib/src/wasmtypes/screquestid.rs @@ -3,7 +3,7 @@ use std::convert::TryInto; -use crate::wasmtypes::*; +use crate::*; // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ @@ -39,7 +39,17 @@ pub fn request_id_encode(enc: &mut WasmEncoder, value: &ScRequestID) { } pub fn request_id_from_bytes(buf: &[u8]) -> ScRequestID { - ScRequestID { id: buf.try_into().expect("invalid RequestId length") } + if buf.len() == 0 { + return ScRequestID { id: [0;SC_REQUEST_ID_LENGTH] }; + } + if buf.len() != SC_REQUEST_ID_LENGTH { + panic("invalid RequestID length"); + } + // final uint16 output index must be > ledgerstate.MaxOutputCount + if buf[SC_REQUEST_ID_LENGTH - 2] > 127 || buf[SC_REQUEST_ID_LENGTH - 1] != 0 { + panic("invalid RequestID: output index > 127"); + } + ScRequestID { id: buf.try_into().expect("WTF?") } } pub fn request_id_to_bytes(value: &ScRequestID) -> Vec { @@ -52,18 +62,18 @@ pub fn request_id_to_string(value: &ScRequestID) -> String { } fn request_id_from_bytes_unchecked(buf: &[u8]) -> ScRequestID { - ScRequestID { id: buf.try_into().expect("invalid RequestId length") } + ScRequestID { id: buf.try_into().expect("invalid RequestID length") } } // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -pub struct ScImmutableRequestId<'a> { - proxy: Proxy<'a>, +pub struct ScImmutableRequestID { + proxy: Proxy } -impl ScImmutableRequestId<'_> { - pub fn new(proxy: Proxy) -> ScImmutableRequestId { - ScImmutableRequestId { proxy } +impl ScImmutableRequestID { + pub fn new(proxy: Proxy) -> ScImmutableRequestID { + ScImmutableRequestID { proxy } } pub fn exists(&self) -> bool { @@ -81,17 +91,17 @@ impl ScImmutableRequestId<'_> { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -// value proxy for mutable ScRequestId in host container -pub struct ScMutableRequestId<'a> { - proxy: Proxy<'a>, +// value proxy for mutable ScRequestID in host container +pub struct ScMutableRequestID { + proxy: Proxy } -impl ScMutableRequestId<'_> { - pub fn new(proxy: Proxy) -> ScMutableRequestId { - ScMutableRequestId { proxy } +impl ScMutableRequestID { + pub fn new(proxy: Proxy) -> ScMutableRequestID { + ScMutableRequestID { proxy } } - pub fn delete(&mut self) { + pub fn delete(&self) { self.proxy.delete(); } @@ -99,7 +109,7 @@ impl ScMutableRequestId<'_> { self.proxy.exists() } - pub fn set_value(&mut self, value: &ScRequestID) { + pub fn set_value(&self, value: &ScRequestID) { self.proxy.set(&request_id_to_bytes(&value)); } diff --git a/packages/wasmvm/wasmlib/src/wasmtypes/scstring.rs b/packages/wasmvm/wasmlib/src/wasmtypes/scstring.rs index 9b9ca735ba..2362373d5f 100644 --- a/packages/wasmvm/wasmlib/src/wasmtypes/scstring.rs +++ b/packages/wasmvm/wasmlib/src/wasmtypes/scstring.rs @@ -3,7 +3,7 @@ use std::convert::TryInto; -use crate::wasmtypes::*; +use crate::*; // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ @@ -20,7 +20,7 @@ pub fn string_from_bytes(buf: &[u8]) -> String { } pub fn string_to_bytes(value: &str) -> Vec { - value.to_vec() + value.as_bytes().to_vec() } pub fn string_to_string(value: &str) -> String { @@ -29,11 +29,11 @@ pub fn string_to_string(value: &str) -> String { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -pub struct ScImmutableString<'a> { - proxy: Proxy<'a>, +pub struct ScImmutableString { + proxy: Proxy } -impl ScImmutableString<'_> { +impl ScImmutableString { pub fn new(proxy: Proxy) -> ScImmutableString { ScImmutableString { proxy } } @@ -54,16 +54,16 @@ impl ScImmutableString<'_> { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // value proxy for mutable ScString in host container -pub struct ScMutableString<'a> { - proxy: Proxy<'a>, +pub struct ScMutableString { + proxy: Proxy } -impl ScMutableString<'_> { +impl ScMutableString { pub fn new(proxy: Proxy) -> ScMutableString { ScMutableString { proxy } } - pub fn delete(&mut self) { + pub fn delete(&self) { self.proxy.delete(); } @@ -71,7 +71,7 @@ impl ScMutableString<'_> { self.proxy.exists() } - pub fn set_value(&mut self, value: &str) { + pub fn set_value(&self, value: &str) { self.proxy.set(&string_to_bytes(value)); } diff --git a/packages/wasmvm/wasmlib/src/wasmtypes/scuint16.rs b/packages/wasmvm/wasmlib/src/wasmtypes/scuint16.rs index 1bc523210c..9ed61695c3 100644 --- a/packages/wasmvm/wasmlib/src/wasmtypes/scuint16.rs +++ b/packages/wasmvm/wasmlib/src/wasmtypes/scuint16.rs @@ -3,7 +3,7 @@ use std::convert::TryInto; -use crate::wasmtypes::*; +use crate::*; // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ @@ -23,7 +23,10 @@ pub fn uint16_from_bytes(buf: &[u8]) -> u16 { if buf.len() == 0 { return 0; } - u16::from_le_bytes(buf.try_into().expect("invalid Uint16 length")) + if buf.len() != SC_UINT16_LENGTH { + panic("invalid Uint16 length"); + } + u16::from_le_bytes(buf.try_into().expect("WTF?")) } pub fn uint16_to_bytes(value: u16) -> Vec { @@ -36,11 +39,11 @@ pub fn uint16_to_string(value: u16) -> String { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -pub struct ScImmutableUint16<'a> { - proxy: Proxy<'a>, +pub struct ScImmutableUint16 { + proxy: Proxy } -impl ScImmutableUint16<'_> { +impl ScImmutableUint16 { pub fn new(proxy: Proxy) -> ScImmutableUint16 { ScImmutableUint16 { proxy } } @@ -61,16 +64,16 @@ impl ScImmutableUint16<'_> { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // value proxy for mutable u16 in host container -pub struct ScMutableUint16<'a> { - proxy: Proxy<'a>, +pub struct ScMutableUint16 { + proxy: Proxy } -impl ScMutableUint16<'_> { +impl ScMutableUint16 { pub fn new(proxy: Proxy) -> ScMutableUint16 { ScMutableUint16 { proxy } } - pub fn delete(&mut self) { + pub fn delete(&self) { self.proxy.delete(); } @@ -78,7 +81,7 @@ impl ScMutableUint16<'_> { self.proxy.exists() } - pub fn set_value(&mut self, value: u16) { + pub fn set_value(&self, value: u16) { self.proxy.set(&uint16_to_bytes(value)); } diff --git a/packages/wasmvm/wasmlib/src/wasmtypes/scuint32.rs b/packages/wasmvm/wasmlib/src/wasmtypes/scuint32.rs index 90666b1815..05d1f3363a 100644 --- a/packages/wasmvm/wasmlib/src/wasmtypes/scuint32.rs +++ b/packages/wasmvm/wasmlib/src/wasmtypes/scuint32.rs @@ -3,7 +3,7 @@ use std::convert::TryInto; -use crate::wasmtypes::*; +use crate::*; // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ @@ -23,7 +23,10 @@ pub fn uint32_from_bytes(buf: &[u8]) -> u32 { if buf.len() == 0 { return 0; } - u32::from_le_bytes(buf.try_into().expect("invalid Uint32 length")) + if buf.len() != SC_UINT32_LENGTH { + panic("invalid Uint32 length"); + } + u32::from_le_bytes(buf.try_into().expect("WTF?")) } pub fn uint32_to_bytes(value: u32) -> Vec { @@ -36,11 +39,11 @@ pub fn uint32_to_string(value: u32) -> String { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -pub struct ScImmutableUint32<'a> { - proxy: Proxy<'a>, +pub struct ScImmutableUint32 { + proxy: Proxy } -impl ScImmutableUint32<'_> { +impl ScImmutableUint32 { pub fn new(proxy: Proxy) -> ScImmutableUint32 { ScImmutableUint32 { proxy } } @@ -61,16 +64,16 @@ impl ScImmutableUint32<'_> { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // value proxy for mutable u32 in host container -pub struct ScMutableUint32<'a> { - proxy: Proxy<'a>, +pub struct ScMutableUint32 { + proxy: Proxy } -impl ScMutableUint32<'_> { +impl ScMutableUint32 { pub fn new(proxy: Proxy) -> ScMutableUint32 { ScMutableUint32 { proxy } } - pub fn delete(&mut self) { + pub fn delete(&self) { self.proxy.delete(); } @@ -78,7 +81,7 @@ impl ScMutableUint32<'_> { self.proxy.exists() } - pub fn set_value(&mut self, value: u32) { + pub fn set_value(&self, value: u32) { self.proxy.set(&uint32_to_bytes(value)); } diff --git a/packages/wasmvm/wasmlib/src/wasmtypes/scuint64.rs b/packages/wasmvm/wasmlib/src/wasmtypes/scuint64.rs index 1bd90a134c..5ee07d660e 100644 --- a/packages/wasmvm/wasmlib/src/wasmtypes/scuint64.rs +++ b/packages/wasmvm/wasmlib/src/wasmtypes/scuint64.rs @@ -3,7 +3,7 @@ use std::convert::TryInto; -use crate::wasmtypes::*; +use crate::*; // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ @@ -23,7 +23,10 @@ pub fn uint64_from_bytes(buf: &[u8]) -> u64 { if buf.len() == 0 { return 0; } - u64::from_le_bytes(buf.try_into().expect("invalid Uint64 length")) + if buf.len() != SC_UINT64_LENGTH { + panic("invalid Uint64 length"); + } + u64::from_le_bytes(buf.try_into().expect("WTF?")) } pub fn uint64_to_bytes(value: u64) -> Vec { @@ -36,11 +39,11 @@ pub fn uint64_to_string(value: u64) -> String { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -pub struct ScImmutableUint64<'a> { - proxy: Proxy<'a>, +pub struct ScImmutableUint64 { + proxy: Proxy } -impl ScImmutableUint64<'_> { +impl ScImmutableUint64 { pub fn new(proxy: Proxy) -> ScImmutableUint64 { ScImmutableUint64 { proxy } } @@ -61,16 +64,16 @@ impl ScImmutableUint64<'_> { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // value proxy for mutable u64 in host container -pub struct ScMutableUint64<'a> { - proxy: Proxy<'a>, +pub struct ScMutableUint64 { + proxy: Proxy } -impl ScMutableUint64<'_> { +impl ScMutableUint64 { pub fn new(proxy: Proxy) -> ScMutableUint64 { ScMutableUint64 { proxy } } - pub fn delete(&mut self) { + pub fn delete(&self) { self.proxy.delete(); } @@ -78,7 +81,7 @@ impl ScMutableUint64<'_> { self.proxy.exists() } - pub fn set_value(&mut self, value: u64) { + pub fn set_value(&self, value: u64) { self.proxy.set(&uint64_to_bytes(value)); } diff --git a/packages/wasmvm/wasmlib/src/wasmtypes/scuint8.rs b/packages/wasmvm/wasmlib/src/wasmtypes/scuint8.rs index c2e55407e8..3ff1192111 100644 --- a/packages/wasmvm/wasmlib/src/wasmtypes/scuint8.rs +++ b/packages/wasmvm/wasmlib/src/wasmtypes/scuint8.rs @@ -3,8 +3,7 @@ use std::convert::TryInto; -use crate::sandbox::*; -use crate::wasmtypes::*; +use crate::*; // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ @@ -40,11 +39,11 @@ pub fn uint8_to_string(value: u8) -> String { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -pub struct ScImmutableUint8<'a> { - proxy: Proxy<'a>, +pub struct ScImmutableUint8 { + proxy: Proxy } -impl ScImmutableUint8<'_> { +impl ScImmutableUint8 { pub fn new(proxy: Proxy) -> ScImmutableUint8 { ScImmutableUint8 { proxy } } @@ -65,16 +64,16 @@ impl ScImmutableUint8<'_> { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // value proxy for mutable u8 in host container -pub struct ScMutableUint8<'a> { - proxy: Proxy<'a>, +pub struct ScMutableUint8 { + proxy: Proxy } -impl ScMutableUint8<'_> { +impl ScMutableUint8 { pub fn new(proxy: Proxy) -> ScMutableUint8 { ScMutableUint8 { proxy } } - pub fn delete(&mut self) { + pub fn delete(&self) { self.proxy.delete(); } @@ -82,7 +81,7 @@ impl ScMutableUint8<'_> { self.proxy.exists() } - pub fn set_value(&mut self, value: u8) { + pub fn set_value(&self, value: u8) { self.proxy.set(&uint8_to_bytes(value)); } diff --git a/packages/wasmvm/wasmlib/ts/wasmlib/assets.ts b/packages/wasmvm/wasmlib/ts/wasmlib/assets.ts index 812ab1bddb..958f0da455 100644 --- a/packages/wasmvm/wasmlib/ts/wasmlib/assets.ts +++ b/packages/wasmvm/wasmlib/ts/wasmlib/assets.ts @@ -63,7 +63,6 @@ export class ScBalances { } export class ScTransfers extends ScAssets { - public constructor() { super([]); } diff --git a/packages/wasmvm/wasmlib/ts/wasmlib/events.ts b/packages/wasmvm/wasmlib/ts/wasmlib/events.ts index 30db9907e6..fce092e5cf 100644 --- a/packages/wasmvm/wasmlib/ts/wasmlib/events.ts +++ b/packages/wasmvm/wasmlib/ts/wasmlib/events.ts @@ -2,21 +2,20 @@ // SPDX-License-Identifier: Apache-2.0 import * as wasmtypes from "./wasmtypes" -import {ScSandboxFunc} from "./sandbox"; +import {ScFuncContext} from "./context"; export class EventEncoder { event: string; - // constructs an encoder constructor(eventName: string) { this.event = eventName; - let timestamp = new ScSandboxFunc().timestamp(); + let timestamp = new ScFuncContext().timestamp(); // convert nanoseconds to seconds this.encode(wasmtypes.uint64ToString(timestamp / 1_000_000_000)); } emit(): void { - new ScSandboxFunc().event(this.event); + new ScFuncContext().event(this.event); } encode(value: string): void { diff --git a/packages/wasmvm/wasmlib/ts/wasmlib/sandbox.ts b/packages/wasmvm/wasmlib/ts/wasmlib/sandbox.ts index b2e60699b9..2a5cdbd05d 100644 --- a/packages/wasmvm/wasmlib/ts/wasmlib/sandbox.ts +++ b/packages/wasmvm/wasmlib/ts/wasmlib/sandbox.ts @@ -278,10 +278,10 @@ export class ScSandboxFunc extends ScSandbox { public send(address: wasmtypes.ScAddress, transfer: ScTransfers): void { // we need some assets to send let assets: u64 = 0; - const balances = transfer.balances(); - const colors = balances.colors(); + const colors = transfer.balances().colors(); for (let i = 0; i < colors.length; i++) { - assets += balances.balance(colors[i]); + const color = colors[i]; + assets += transfer.balances().balance(color); } if (assets == 0) { // only try to send when non-zero assets diff --git a/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/scchainid.ts b/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/scchainid.ts index 683108d374..30df0694bb 100644 --- a/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/scchainid.ts +++ b/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/scchainid.ts @@ -45,7 +45,9 @@ export function chainIDEncode(enc: WasmEncoder, value: ScChainID): void { export function chainIDFromBytes(buf: u8[]): ScChainID { if (buf.length == 0) { - return new ScChainID(); + const chainID = new ScChainID(); + chainID.id[0] = 2; // ledgerstate.AliasAddressType + return chainID; } if (buf.length != ScChainIDLength) { panic("invalid ChainID length"); diff --git a/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/screquestid.ts b/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/screquestid.ts index 07c6b897a8..d8cb3e21e5 100644 --- a/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/screquestid.ts +++ b/packages/wasmvm/wasmlib/ts/wasmlib/wasmtypes/screquestid.ts @@ -47,7 +47,7 @@ export function requestIDFromBytes(buf: u8[]): ScRequestID { panic("invalid RequestID length"); } // final uint16 output index must be > ledgerstate.MaxOutputCount - if (buf[ScHashLength] > 127 || buf[ScHashLength + 1] != 0) { + if (buf[ScRequestIDLength - 2] > 127 || buf[ScRequestIDLength - 1] != 0) { panic("invalid RequestID: output index > 127"); } return requestIDFromBytesUnchecked(buf); diff --git a/tools/cluster/tests/wasm/inccounter_bg.wasm b/tools/cluster/tests/wasm/inccounter_bg.wasm index 87a53859a0cade230719a6b6dcbea18048de448e..813ac6828a72bd66474837464afad98bd57a2675 100644 GIT binary patch literal 62649 zcmeF451d_9b??ugd++?YljH;fge1zj*H|ZokjdW(QOlg+Zv=!23Mxv5WPr@%@604X zRWd+8RKTF9DWamHphCeGD^*&D7A;yt+S-bhrzwy6XdkZ+Uuo4A$@~7+-sjvqe-eV= ztMBt(;Lh1+|KDq`wf0(Tuf0#uH@q*2Ft@?C_6(G=e2! zNG|Kaleo*)1c8foIWJQUml38O5-XOItO{JFGE{MytHNH%Og;Pp%J|%>iNtV6v?yvh zn+~43{``)MHV==SInp=Me`fzkP?;Qk64CAPP0{YC90V;v++MAg!$ab@QYwXEREd&u zF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e4Nrx=6_L9)j`lkNMjIx;9}w7)7c0eFVGG?fqhh#t>BC3>aOtTQT< z%R%Xw=smoD8Z9aNQ~VJX6TD${4njgvGf%r=A#s%vy4-1NCZ8&=I!sYD? z+mp5p>pPeCY+Sx^eInCgLHm*gi`(ZFFYDP%vts+g#a#>ATjY&fupZU)lHRR{wJ%(< Tu#=AKJC-hAzF|pc`@H`NlF_xS diff --git a/tools/schema/generator/generator.go b/tools/schema/generator/generator.go index 106ed72eb9..190c45486d 100644 --- a/tools/schema/generator/generator.go +++ b/tools/schema/generator/generator.go @@ -153,10 +153,6 @@ func (g *GenBase) generateCode() error { if err != nil { return err } - err = g.createSourceFile("keys", !g.s.CoreContracts) - if err != nil { - return err - } err = g.createSourceFile("events", len(g.s.Events) != 0) if err != nil { return err diff --git a/tools/schema/generator/gotemplates/alltemplates.go b/tools/schema/generator/gotemplates/alltemplates.go index 7460299451..1f99d81295 100644 --- a/tools/schema/generator/gotemplates/alltemplates.go +++ b/tools/schema/generator/gotemplates/alltemplates.go @@ -16,7 +16,6 @@ var Templates = []map[string]string{ contractGo, eventsGo, funcsGo, - keysGo, libGo, mainGo, paramsGo, diff --git a/tools/schema/generator/gotemplates/events.go b/tools/schema/generator/gotemplates/events.go index fc92002364..0483037315 100644 --- a/tools/schema/generator/gotemplates/events.go +++ b/tools/schema/generator/gotemplates/events.go @@ -14,8 +14,8 @@ $#each events eventFunc `, // ******************************* "eventFunc": ` -$#set params $#set separator +$#set params $#each event eventParam func (e $TypeName) $EvtName($params) { diff --git a/tools/schema/generator/gotemplates/keys.go b/tools/schema/generator/gotemplates/keys.go deleted file mode 100644 index efde033401..0000000000 --- a/tools/schema/generator/gotemplates/keys.go +++ /dev/null @@ -1,8 +0,0 @@ -package gotemplates - -var keysGo = map[string]string{ - // ******************************* - "keys.go": ` -$#emit goPackage -`, -} diff --git a/tools/schema/generator/rstemplates/alltemplates.go b/tools/schema/generator/rstemplates/alltemplates.go index 02f1fb4a6c..1e8e2f52df 100644 --- a/tools/schema/generator/rstemplates/alltemplates.go +++ b/tools/schema/generator/rstemplates/alltemplates.go @@ -17,7 +17,6 @@ var Templates = []map[string]string{ contractRs, eventsRs, funcsRs, - keysRs, libRs, modRs, paramsRs, @@ -49,49 +48,11 @@ var TypeDependent = model.StringMapMap{ "Uint32": "u32", "Uint64": "u64", }, - "fldTypeID": { - "Address": "TYPE_ADDRESS", - "AgentID": "TYPE_AGENT_ID", - "Bool": "TYPE_BOOL", - "ChainID": "TYPE_CHAIN_ID", - "Color": "TYPE_COLOR", - "Hash": "TYPE_HASH", - "Hname": "TYPE_HNAME", - "Int8": "TYPE_INT8", - "Int16": "TYPE_INT16", - "Int32": "TYPE_INT32", - "Int64": "TYPE_INT64", - "RequestID": "TYPE_REQUEST_ID", - "String": "TYPE_STRING", - "Uint8": "TYPE_INT8", - "Uint16": "TYPE_INT16", - "Uint32": "TYPE_INT32", - "Uint64": "TYPE_INT64", - "": "TYPE_BYTES", - }, - "fldToKey32": { - "Address": "key.get_key_id()", - "AgentID": "key.get_key_id()", - "Bool": "???cannot use Bool as map key", - "ChainID": "key.get_key_id()", - "Color": "key.get_key_id()", - "Hash": "key.get_key_id()", - "Hname": "key.get_key_id()", - "Int8": "get_key_id_from_uint64(key as u64, 1)", - "Int16": "get_key_id_from_uint64(key as u64, 2)", - "Int32": "get_key_id_from_uint64(key as u64, 4)", - "Int64": "get_key_id_from_uint64(key as u64, 8)", - "RequestID": "key.get_key_id()", - "String": "key.get_key_id()", - "Uint8": "get_key_id_from_uint64(key as u64, 1)", - "Uint16": "get_key_id_from_uint64(key as u64, 2)", - "Uint32": "get_key_id_from_uint64(key as u64, 4)", - "Uint64": "get_key_id_from_uint64(key, 8)", - }, "fldParamLangType": { "Address": "ScAddress", "AgentID": "ScAgentID", "Bool": "bool", + "Bytes": "[u8]", "ChainID": "ScChainID", "Color": "ScColor", "Hash": "ScHash", @@ -109,6 +70,7 @@ var TypeDependent = model.StringMapMap{ }, "fldRef": { "Address": "&", + "Bytes": "&", "AgentID": "&", "ChainID": "&", "Color": "&", @@ -121,13 +83,11 @@ var TypeDependent = model.StringMapMap{ var common = map[string]string{ // ******************************* "initGlobals": ` -$#set arrayTypeID TYPE_ARRAY $#set crate -$#if core setArrayTypeID +$#if core setCrate `, // ******************************* - "setArrayTypeID": ` -$#set arrayTypeID TYPE_ARRAY16 + "setCrate": ` $#set crate (crate) `, // ******************************* @@ -155,12 +115,16 @@ mod structs; mod typedefs; `, // ******************************* - "useCrate": ` -use crate::*; + "useConsts": ` +use crate::consts::*; `, // ******************************* "useCoreContract": ` use crate::$package::*; +`, + // ******************************* + "useCrate": ` +use crate::*; `, // ******************************* "useEvents": ` @@ -183,20 +147,11 @@ use crate::results::*; use crate::structs::*; `, // ******************************* - "useTypeDefs": ` + "useTypedefs": ` use crate::typedefs::*; `, // ******************************* "useWasmLib": ` use wasmlib::*; -`, - // ******************************* - "setVarType": ` -$#set varType TYPE_MAP -$#if array setVarTypeArray -`, - // ******************************* - "setVarTypeArray": ` -$#set varType $arrayTypeID | $fldTypeID `, } diff --git a/tools/schema/generator/rstemplates/contract.go b/tools/schema/generator/rstemplates/contract.go index f43624e968..01d2c69121 100644 --- a/tools/schema/generator/rstemplates/contract.go +++ b/tools/schema/generator/rstemplates/contract.go @@ -5,8 +5,6 @@ var contractRs = map[string]string{ "contract.rs": ` #![allow(dead_code)] -use std::ptr; - $#if core useCrate useWasmLib $#if core useCoreContract contractUses $#each func FuncNameCall @@ -49,11 +47,7 @@ $#if result ImmutableFuncNameResults $#emit setupInitFunc $#if separator newline $#set separator $true - pub fn $func_name(_ctx: & dyn Sc$Kind$+CallContext) -> $FuncName$+Call { -$#set paramsID ptr::null_mut() -$#set resultsID ptr::null_mut() -$#if param setParamsID -$#if result setResultsID + pub fn $func_name(_ctx: &dyn Sc$Kind$+CallContext) -> $FuncName$+Call { $#if ptrs setPtrs noPtrs } `, @@ -64,24 +58,25 @@ $#if ptrs setPtrs noPtrs $#if param FuncNameParamsInit $#if result FuncNameResultsInit }; - f.func.set_ptrs($paramsID, $resultsID); +$#if param FuncNameParamsLink +$#if result FuncNameResultsLink f `, // ******************************* "FuncNameParamsInit": ` - params: Mutable$FuncName$+Params { id: 0 }, + params: Mutable$FuncName$+Params { proxy: Proxy::nil() }, `, // ******************************* "FuncNameResultsInit": ` - results: Immutable$FuncName$+Results { id: 0 }, + results: Immutable$FuncName$+Results { proxy: Proxy::nil() }, `, // ******************************* - "setParamsID": ` -$#set paramsID &mut f.params.id + "FuncNameParamsLink": ` + Sc$initFunc$Kind::link_params(&mut f.params.proxy, &f.func); `, // ******************************* - "setResultsID": ` -$#set resultsID &mut f.results.id + "FuncNameResultsLink": ` + Sc$initFunc$Kind::link_results(&mut f.results.proxy, &f.func); `, // ******************************* "noPtrs": ` diff --git a/tools/schema/generator/rstemplates/events.go b/tools/schema/generator/rstemplates/events.go index 6d203ac398..9c5de2339c 100644 --- a/tools/schema/generator/rstemplates/events.go +++ b/tools/schema/generator/rstemplates/events.go @@ -4,6 +4,7 @@ var eventsRs = map[string]string{ // ******************************* "events.rs": ` #![allow(dead_code)] +#![allow(unused_mut)] use wasmlib::*; @@ -21,25 +22,17 @@ $#set params $#each event eventParam pub fn $evt_name(&self$params) { -$#if event eventParams eventParamNone + let mut evt = EventEncoder::new("$package.$evtName"); +$#each event eventEmit + evt.emit(); } `, // ******************************* "eventParam": ` $#set params $params, $fld_name: $fldRef$fldParamLangType -`, - // ******************************* - "eventParamNone": ` - EventEncoder::new("$package.$evtName").emit(); -`, - // ******************************* - "eventParams": ` - let mut encoder = EventEncoder::new("$package.$evtName"); -$#each event eventEmit - encoder.emit(); `, // ******************************* "eventEmit": ` - encoder.$fld_type($fldRef$fld_name); + evt.encode(&$fld_type$+_to_string($fldRef$fld_name)); `, } diff --git a/tools/schema/generator/rstemplates/funcs.go b/tools/schema/generator/rstemplates/funcs.go index 0ea4fb2983..43f2c2954f 100644 --- a/tools/schema/generator/rstemplates/funcs.go +++ b/tools/schema/generator/rstemplates/funcs.go @@ -7,7 +7,7 @@ use wasmlib::*; use crate::*; $#if structs useStructs -$#if typedefs useTypeDefs +$#if typedefs useTypedefs $#each func funcSignature `, // ******************************* diff --git a/tools/schema/generator/rstemplates/keys.go b/tools/schema/generator/rstemplates/keys.go deleted file mode 100644 index 6099c04e59..0000000000 --- a/tools/schema/generator/rstemplates/keys.go +++ /dev/null @@ -1,48 +0,0 @@ -package rstemplates - -var keysRs = map[string]string{ - // ******************************* - "keys.rs": ` -#![allow(dead_code)] - -use wasmlib::*; - -use crate::*; - -$#set constPrefix PARAM_ -$#each params constFieldIdx - -$#set constPrefix RESULT_ -$#each results constFieldIdx - -$#set constPrefix STATE_ -$#each state constFieldIdx - -pub const KEY_MAP_LEN: usize = $maxIndex; - -pub const KEY_MAP: [&str; KEY_MAP_LEN] = [ -$#set constPrefix PARAM_ -$#each params constFieldKey -$#set constPrefix RESULT_ -$#each results constFieldKey -$#set constPrefix STATE_ -$#each state constFieldKey -]; - -pub static mut IDX_MAP: [Key32; KEY_MAP_LEN] = [Key32(0); KEY_MAP_LEN]; - -pub fn idx_map(idx: usize) -> Key32 { - unsafe { - IDX_MAP[idx] - } -} -`, - // ******************************* - "constFieldIdx": ` -pub(crate) const IDX_$constPrefix$FLD_NAME$fld_pad : usize = $fldIndex; -`, - // ******************************* - "constFieldKey": ` - $constPrefix$FLD_NAME, -`, -} diff --git a/tools/schema/generator/rstemplates/lib.go b/tools/schema/generator/rstemplates/lib.go index b7b599232f..b59f07b73f 100644 --- a/tools/schema/generator/rstemplates/lib.go +++ b/tools/schema/generator/rstemplates/lib.go @@ -8,19 +8,18 @@ var libRs = map[string]string{ use $package::*; use wasmlib::*; -use wasmlib::host::*; use crate::consts::*; $#if events useEvents -use crate::keys::*; $#if params useParams $#if results useResults use crate::state::*; +$#if structs useStructs +$#if typedefs useTypedefs mod consts; mod contract; $#if events modEvents -mod keys; $#if params modParams $#if results modResults mod state; @@ -32,12 +31,6 @@ mod $package; fn on_load() { let exports = ScExports::new(); $#each func libExportFunc - - unsafe { - for i in 0..KEY_MAP_LEN { - IDX_MAP[i] = get_key_id_from_string(KEY_MAP[i]); - } - } } $#each func libThunk `, @@ -58,7 +51,6 @@ $#if view ImmutablePackageState fn $kind$+_$func_name$+_thunk(ctx: &Sc$Kind$+Context) { ctx.log("$package.$kind$FuncName"); -$#emit accessCheck let f = $FuncName$+Context { $#if func PackageEventsInit $#if param ImmutableFuncNameParamsInit @@ -66,10 +58,16 @@ $#if result MutableFuncNameResultsInit $#if func MutablePackageStateInit $#if view ImmutablePackageStateInit }; +$#emit accessCheck $#each mandatory requireMandatory $kind$+_$func_name(ctx, &f); +$#if result sendResults ctx.log("$package.$kind$FuncName ok"); } +`, + // ******************************* + "sendResults": ` + ctx.results(&f.results.proxy.kv_store); `, // ******************************* "PackageEvents": ` @@ -93,9 +91,7 @@ $#if events PackageEventsInitExist `, // ******************************* "ImmutableFuncNameParamsInit": ` - params: Immutable$FuncName$+Params { - id: OBJ_ID_PARAMS, - }, + params: Immutable$FuncName$+Params { proxy: params_proxy() }, `, // ******************************* "MutableFuncNameResults": ` @@ -103,9 +99,7 @@ $#if events PackageEventsInitExist `, // ******************************* "MutableFuncNameResultsInit": ` - results: Mutable$FuncName$+Results { - id: OBJ_ID_RESULTS, - }, + results: Mutable$FuncName$+Results { proxy: results_proxy() }, `, // ******************************* "MutablePackageState": ` @@ -113,9 +107,7 @@ $#if events PackageEventsInitExist `, // ******************************* "MutablePackageStateInit": ` - state: Mutable$Package$+State { - id: OBJ_ID_STATE, - }, + state: Mutable$Package$+State { proxy: state_proxy() }, `, // ******************************* "ImmutablePackageState": ` @@ -123,15 +115,12 @@ $#if events PackageEventsInitExist `, // ******************************* "ImmutablePackageStateInit": ` - state: Immutable$Package$+State { - id: OBJ_ID_STATE, - }, + state: Immutable$Package$+State { proxy: state_proxy() }, `, // ******************************* "requireMandatory": ` ctx.require(f.params.$fld_name().exists(), "missing mandatory $fldName"); `, - // ******************************* "accessCheck": ` $#set accessFinalize accessOther @@ -166,7 +155,7 @@ $#set accessFinalize accessDone // ******************************* "accessOther": ` $#if funcAccessComment accessComment - let access = ctx.state().get_agent_id("$funcAccess"); + let access = f.state.$func_access(); ctx.require(access.exists(), "access not set: $funcAccess"); ctx.require(ctx.caller() == access.value(), "no permission"); diff --git a/tools/schema/generator/rstemplates/params.go b/tools/schema/generator/rstemplates/params.go index 81c9a9253b..6da140a2d6 100644 --- a/tools/schema/generator/rstemplates/params.go +++ b/tools/schema/generator/rstemplates/params.go @@ -6,19 +6,9 @@ var paramsRs = map[string]string{ #![allow(dead_code)] #![allow(unused_imports)] -$#if core useCrate useWasmLib -$#if core useCoreContract -$#if core useHost paramsUses -$#each func paramsFunc -`, - // ******************************* - "paramsUses": ` -use wasmlib::host::*; - +$#if core useCoreContract useWasmLib use crate::*; -use crate::keys::*; -$#if structs useStructs -$#if typedefs useTypeDefs +$#each func paramsFunc `, // ******************************* "paramsFunc": ` @@ -37,9 +27,9 @@ $#if param paramsProxyStruct $#set TypeName $mut$FuncName$+Params $#each param proxyContainers -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct $TypeName { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl $TypeName { diff --git a/tools/schema/generator/rstemplates/proxy.go b/tools/schema/generator/rstemplates/proxy.go index 11073ee7cc..3103db67d3 100644 --- a/tools/schema/generator/rstemplates/proxy.go +++ b/tools/schema/generator/rstemplates/proxy.go @@ -10,14 +10,7 @@ $#if map typedefProxyMap "proxyMethods": ` $#if separator newline $#set separator $true -$#set varID $Kind$FLD_NAME.get_key_id() -$#if init setInitVarID -$#if core setCoreVarID $#if array proxyArray proxyMethods2 -`, - // ******************************* - "setInitVarID": ` -$#set varID idx_map(IDX_$Kind$FLD_NAME) `, // ******************************* "proxyMethods2": ` @@ -28,18 +21,14 @@ $#if map proxyMap proxyMethods3 $#if basetype proxyBaseType proxyMethods4 `, // ******************************* + // TODO when will this be called, and if so, fix it "proxyMethods4": ` $#if typedef proxyTypeDef proxyStruct -`, - // ******************************* - "setCoreVarID": ` -$#set varID $Kind$FLD_NAME.get_key_id() `, // ******************************* "proxyArray": ` pub fn $fld_name(&self) -> ArrayOf$mut$FldType { - let arr_id = get_object_id(self.id, $varID, $arrayTypeID | $fldTypeID); - ArrayOf$mut$FldType { obj_id: arr_id } + ArrayOf$mut$FldType { proxy: self.proxy.root($Kind$FLD_NAME) } } `, // ******************************* @@ -49,23 +38,23 @@ $#if this proxyMapThis proxyMapOther // ******************************* "proxyMapThis": ` pub fn $fld_name(&self) -> Map$FldMapKey$+To$mut$FldType { - Map$FldMapKey$+To$mut$FldType { obj_id: self.id } + Map$FldMapKey$+To$mut$FldType { proxy: self.proxy.clone() } } `, // ******************************* "proxyMapOther": ` pub fn $fld_name(&self) -> Map$FldMapKey$+To$mut$FldType { - let map_id = get_object_id(self.id, $varID, TYPE_MAP); - Map$FldMapKey$+To$mut$FldType { obj_id: map_id } + Map$FldMapKey$+To$mut$FldType { proxy: self.proxy.root($Kind$FLD_NAME) } } `, // ******************************* "proxyBaseType": ` pub fn $fld_name(&self) -> Sc$mut$FldType { - Sc$mut$FldType::new(self.id, $varID) + Sc$mut$FldType::new(self.proxy.root($Kind$FLD_NAME)) } `, // ******************************* + // TODO when will this be called, and if so, fix it "proxyTypeDef": ` $#emit setVarType pub fn $old_name(&self) -> $mut$OldType { @@ -74,6 +63,7 @@ $#emit setVarType } `, // ******************************* + // TODO when will this be called, and if so, fix it "proxyStruct": ` pub fn $fld_name(&self) -> $mut$FldType { $mut$FldType { obj_id: self.id, key_id: $varID } diff --git a/tools/schema/generator/rstemplates/results.go b/tools/schema/generator/rstemplates/results.go index 80b11aa37a..2fcdc2951f 100644 --- a/tools/schema/generator/rstemplates/results.go +++ b/tools/schema/generator/rstemplates/results.go @@ -6,19 +6,9 @@ var resultsRs = map[string]string{ #![allow(dead_code)] #![allow(unused_imports)] -$#if core useCrate useWasmLib -$#if core useCoreContract -$#if core useHost resultsUses -$#each func resultsFunc -`, - // ******************************* - "resultsUses": ` -use wasmlib::host::*; - +$#if core useCoreContract useWasmLib use crate::*; -use crate::keys::*; -$#if structs useStructs -$#if typedefs useTypeDefs +$#each func resultsFunc `, // ******************************* "resultsFunc": ` @@ -37,9 +27,9 @@ $#if result resultsProxyStruct $#set TypeName $mut$FuncName$+Results $#each result proxyContainers -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct $TypeName { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } impl $TypeName { diff --git a/tools/schema/generator/rstemplates/state.go b/tools/schema/generator/rstemplates/state.go index b5aa40fd8a..b6c83263fe 100644 --- a/tools/schema/generator/rstemplates/state.go +++ b/tools/schema/generator/rstemplates/state.go @@ -7,12 +7,8 @@ var stateRs = map[string]string{ #![allow(unused_imports)] use wasmlib::*; -use wasmlib::host::*; use crate::*; -use crate::keys::*; -$#if structs useStructs -$#if typedefs useTypeDefs $#set Kind STATE_ $#set mut Immutable $#emit stateProxyStruct @@ -24,9 +20,9 @@ $#emit stateProxyStruct $#set TypeName $mut$Package$+State $#each state proxyContainers -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct $TypeName { - pub(crate) id: i32, + pub(crate) proxy: Proxy, } $#if state stateProxyImpl `, @@ -43,7 +39,7 @@ $#each state proxyMethods "stateProxyImmutableFunc": ` $#set separator $true pub fn as_immutable(&self) -> Immutable$Package$+State { - Immutable$Package$+State { id: self.id } + Immutable$Package$+State { proxy: self.proxy.root("") } } `, } diff --git a/tools/schema/generator/rstemplates/structs.go b/tools/schema/generator/rstemplates/structs.go index 7c76433933..9f479f7aac 100644 --- a/tools/schema/generator/rstemplates/structs.go +++ b/tools/schema/generator/rstemplates/structs.go @@ -7,8 +7,7 @@ var structsRs = map[string]string{ #![allow(unused_imports)] $#if core useCrate useWasmLib -use wasmlib::host::*; -$#if typedefs useTypeDefs +$#if typedefs useTypedefs $#each structs structType `, // ******************************* @@ -21,16 +20,16 @@ $#each struct structField impl $StrName { pub fn from_bytes(bytes: &[u8]) -> $StrName { - let mut decode = BytesDecoder::new(bytes); + let mut dec = WasmDecoder::new(bytes); $StrName { $#each struct structDecode } } pub fn to_bytes(&self) -> Vec { - let mut encode = BytesEncoder::new(); + let mut enc = WasmEncoder::new(); $#each struct structEncode - return encode.data(); + enc.buf() } } $#set mut Immutable @@ -44,37 +43,36 @@ $#emit structMethods `, // ******************************* "structDecode": ` - $fld_name$fld_pad : decode.$fld_type(), + $fld_name$fld_pad : $fld_type$+_decode(&mut dec), `, // ******************************* "structEncode": ` - encode.$fld_type($fldRef$+self.$fld_name); + $fld_type$+_encode(&mut enc, $fldRef$+self.$fld_name); `, // ******************************* "structMethods": ` -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct $mut$StrName { - pub(crate) obj_id: i32, - pub(crate) key_id: Key32, + pub(crate) proxy: Proxy, } impl $mut$StrName { $#if mut structMethodDelete pub fn exists(&self) -> bool { - exists(self.obj_id, self.key_id, TYPE_BYTES) + self.proxy.exists() } $#if mut structMethodSetValue pub fn value(&self) -> $StrName { - $StrName::from_bytes(&get_bytes(self.obj_id, self.key_id, TYPE_BYTES)) + $StrName::from_bytes(&self.proxy.get()) } } `, // ******************************* "structMethodDelete": ` pub fn delete(&self) { - del_key(self.obj_id, self.key_id, TYPE_BYTES); + self.proxy.delete(); } `, @@ -82,7 +80,7 @@ $#if mut structMethodSetValue "structMethodSetValue": ` pub fn set_value(&self, value: &$StrName) { - set_bytes(self.obj_id, self.key_id, TYPE_BYTES, &value.to_bytes()); + self.proxy.set(&value.to_bytes()); } `, } diff --git a/tools/schema/generator/rstemplates/typedefs.go b/tools/schema/generator/rstemplates/typedefs.go index d5e2677c24..c33382ce4e 100644 --- a/tools/schema/generator/rstemplates/typedefs.go +++ b/tools/schema/generator/rstemplates/typedefs.go @@ -6,7 +6,6 @@ var typedefsRs = map[string]string{ #![allow(dead_code)] use wasmlib::*; -use wasmlib::host::*; $#if structs useStructs $#each typedef typedefProxy `, @@ -36,15 +35,15 @@ $#if exist else typedefProxyArrayNew // ******************************* "typedefProxyArrayNew": ` -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct $proxy { - pub(crate) obj_id: i32, + pub(crate) proxy: Proxy, } impl $proxy { -$#if mut typedefProxyArrayClear +$#if mut typedefProxyArrayMut pub fn length(&self) -> u32 { - get_length(self.obj_id) + self.proxy.length() } $#if basetype typedefProxyArrayNewBaseType typedefProxyArrayNewOtherType @@ -52,34 +51,38 @@ $#if basetype typedefProxyArrayNewBaseType typedefProxyArrayNewOtherType $#set exist $proxy `, // ******************************* - "typedefProxyArrayClear": ` - pub fn clear(&self) { - clear(self.obj_id); + "typedefProxyArrayMut": ` +$#if basetype typedefProxyArrayAppendBaseType typedefProxyArrayAppendOtherType + pub fn clear(&self) { + self.proxy.clear_array(); } `, // ******************************* - "typedefProxyArrayNewBaseType": ` - pub fn get_$fld_type(&self, index: u32) -> Sc$mut$FldType { - Sc$mut$FldType::new(self.obj_id, Key32(index as i32)) - } + "typedefProxyArrayAppendBaseType": ` + pub fn append_$fld_type(&self) -> Sc$mut$FldType { + Sc$mut$FldType::new(self.proxy.append()) + } + `, // ******************************* - "typedefProxyArrayNewOtherType": ` -$#if typedef typedefProxyArrayNewOtherTypeTypeDef typedefProxyArrayNewOtherTypeStruct + "typedefProxyArrayAppendOtherType": ` + + pub fn append_$fld_type(&self) -> $mut$FldType { + $mut$FldType { proxy: self.proxy.append() } + } `, // ******************************* - "typedefProxyArrayNewOtherTypeTypeDef": ` -$#emit setVarType - pub fn get_$old_type(&self, index: u32) -> $mut$OldType { - let sub_id = get_object_id(self.obj_id, Key32(index as i32), $varType); - $mut$OldType { obj_id: sub_id } - } + "typedefProxyArrayNewBaseType": ` + pub fn get_$fld_type(&self, index: u32) -> Sc$mut$FldType { + Sc$mut$FldType::new(self.proxy.index(index)) + } `, // ******************************* - "typedefProxyArrayNewOtherTypeStruct": ` + "typedefProxyArrayNewOtherType": ` + pub fn get_$fld_type(&self, index: u32) -> $mut$FldType { - $mut$FldType { obj_id: self.obj_id, key_id: Key32(index as i32) } + $mut$FldType { proxy: self.proxy.index(index) } } `, // ******************************* @@ -90,46 +93,34 @@ $#if exist else typedefProxyMapNew // ******************************* "typedefProxyMapNew": ` -#[derive(Clone, Copy)] +#[derive(Clone)] pub struct $proxy { - pub(crate) obj_id: i32, + pub(crate) proxy: Proxy, } impl $proxy { -$#if mut typedefProxyMapClear +$#if mut typedefProxyMapMut $#if basetype typedefProxyMapNewBaseType typedefProxyMapNewOtherType } $#set exist $proxy `, // ******************************* - "typedefProxyMapClear": ` + "typedefProxyMapMut": ` pub fn clear(&self) { - clear(self.obj_id); + self.proxy.clear_map(); } `, // ******************************* "typedefProxyMapNewBaseType": ` pub fn get_$fld_type(&self, key: $fldKeyRef$fldKeyParamLangType) -> Sc$mut$FldType { - Sc$mut$FldType::new(self.obj_id, $fldKeyToKey32) + Sc$mut$FldType::new(self.proxy.key(&$fld_map_key$+_to_bytes(key))) } `, // ******************************* "typedefProxyMapNewOtherType": ` -$#if typedef typedefProxyMapNewOtherTypeTypeDef typedefProxyMapNewOtherTypeStruct -`, - // ******************************* - "typedefProxyMapNewOtherTypeTypeDef": ` -$#emit setVarType - pub fn get_$old_type(&self, key: $oldKeyRef$oldKeyParamLangType) -> $mut$OldType { - let sub_id = get_object_id(self.obj_id, $oldKeyToKey32, $varType); - $mut$OldType { obj_id: sub_id } - } -`, - // ******************************* - "typedefProxyMapNewOtherTypeStruct": ` pub fn get_$fld_type(&self, key: $fldKeyRef$fldKeyParamLangType) -> $mut$FldType { - $mut$FldType { obj_id: self.obj_id, key_id: $fldKeyToKey32 } + $mut$FldType { proxy: self.proxy.key(&$fld_map_key$+_to_bytes(key)) } } `, } diff --git a/tools/schema/generator/tstemplates/alltemplates.go b/tools/schema/generator/tstemplates/alltemplates.go index d4826bf462..1262251c34 100644 --- a/tools/schema/generator/tstemplates/alltemplates.go +++ b/tools/schema/generator/tstemplates/alltemplates.go @@ -17,7 +17,6 @@ var Templates = []map[string]string{ eventsTs, funcsTs, indexTs, - keysTs, libTs, paramsTs, proxyTs, diff --git a/tools/schema/generator/tstemplates/events.go b/tools/schema/generator/tstemplates/events.go index b89140e08b..7d9495dc17 100644 --- a/tools/schema/generator/tstemplates/events.go +++ b/tools/schema/generator/tstemplates/events.go @@ -13,8 +13,8 @@ $#each events eventFunc `, // ******************************* "eventFunc": ` -$#set params $#set separator +$#set params $#each event eventParam $evtName($params): void { diff --git a/tools/schema/generator/tstemplates/keys.go b/tools/schema/generator/tstemplates/keys.go deleted file mode 100644 index 18c57b1788..0000000000 --- a/tools/schema/generator/tstemplates/keys.go +++ /dev/null @@ -1,13 +0,0 @@ -package tstemplates - -var keysTs = map[string]string{ - // ******************************* - "keys.ts": ` - -$#each params constFieldIdx -`, - // ******************************* - "constFieldIdx": ` -export const IdxParam$FldName$fldPad = $fldIndex; -`, -} From b88c49c60e2dde7c7f046be69ab4b55e518b00e1 Mon Sep 17 00:00:00 2001 From: Eric Hop Date: Thu, 3 Feb 2022 19:29:22 -0800 Subject: [PATCH 060/111] Cleaned up module references in Rust generated code --- contracts/wasm/dividend/src/contract.rs | 5 +- contracts/wasm/dividend/src/lib.rs | 1 + .../wasm/donatewithfeedback/src/contract.rs | 5 +- contracts/wasm/donatewithfeedback/src/lib.rs | 1 + contracts/wasm/erc20/src/contract.rs | 5 +- contracts/wasm/erc20/src/lib.rs | 1 + contracts/wasm/erc20/src/typedefs.rs | 1 + contracts/wasm/erc721/src/contract.rs | 5 +- contracts/wasm/erc721/src/lib.rs | 1 + contracts/wasm/erc721/src/typedefs.rs | 1 + contracts/wasm/fairauction/src/contract.rs | 5 +- contracts/wasm/fairauction/src/lib.rs | 1 + contracts/wasm/fairauction/src/structs.rs | 1 - contracts/wasm/fairauction/src/typedefs.rs | 2 +- contracts/wasm/fairroulette/src/contract.rs | 5 +- contracts/wasm/fairroulette/src/lib.rs | 1 + contracts/wasm/helloworld/src/contract.rs | 4 +- contracts/wasm/helloworld/src/lib.rs | 1 + contracts/wasm/inccounter/src/contract.rs | 5 +- contracts/wasm/inccounter/src/lib.rs | 1 + contracts/wasm/testcore/src/contract.rs | 5 +- contracts/wasm/testcore/src/lib.rs | 1 + contracts/wasm/testwasmlib/src/contract.rs | 5 +- contracts/wasm/testwasmlib/src/lib.rs | 1 + contracts/wasm/testwasmlib/src/typedefs.rs | 1 + contracts/wasm/timestamp/src/contract.rs | 4 +- contracts/wasm/timestamp/src/lib.rs | 1 + contracts/wasm/tokenregistry/src/contract.rs | 4 +- contracts/wasm/tokenregistry/src/lib.rs | 1 + .../wasmlib/src/coreaccounts/contract.rs | 2 +- .../wasmvm/wasmlib/src/coreblob/contract.rs | 2 +- .../wasmlib/src/coreblocklog/contract.rs | 2 +- .../wasmlib/src/coregovernance/contract.rs | 2 +- .../wasmvm/wasmlib/src/coreroot/contract.rs | 2 +- .../wasmlib/src/wasmrequests/contract.rs | 2 +- .../generator/rstemplates/alltemplates.go | 52 ------------------- .../schema/generator/rstemplates/contract.go | 11 +--- tools/schema/generator/rstemplates/events.go | 2 +- tools/schema/generator/rstemplates/funcs.go | 2 - tools/schema/generator/rstemplates/lib.go | 39 ++++++++++---- tools/schema/generator/rstemplates/structs.go | 1 - .../schema/generator/rstemplates/typedefs.go | 4 +- 42 files changed, 68 insertions(+), 130 deletions(-) diff --git a/contracts/wasm/dividend/src/contract.rs b/contracts/wasm/dividend/src/contract.rs index 6ff7e103c7..05adf83dbc 100644 --- a/contracts/wasm/dividend/src/contract.rs +++ b/contracts/wasm/dividend/src/contract.rs @@ -8,10 +8,7 @@ #![allow(dead_code)] use wasmlib::*; - -use crate::consts::*; -use crate::params::*; -use crate::results::*; +use crate::*; pub struct DivideCall { pub func: ScFunc, diff --git a/contracts/wasm/dividend/src/lib.rs b/contracts/wasm/dividend/src/lib.rs index c31c49e88c..2182f8a64c 100644 --- a/contracts/wasm/dividend/src/lib.rs +++ b/contracts/wasm/dividend/src/lib.rs @@ -21,6 +21,7 @@ mod contract; mod params; mod results; mod state; + mod dividend; #[no_mangle] diff --git a/contracts/wasm/donatewithfeedback/src/contract.rs b/contracts/wasm/donatewithfeedback/src/contract.rs index 02b5198919..1139f47a34 100644 --- a/contracts/wasm/donatewithfeedback/src/contract.rs +++ b/contracts/wasm/donatewithfeedback/src/contract.rs @@ -8,10 +8,7 @@ #![allow(dead_code)] use wasmlib::*; - -use crate::consts::*; -use crate::params::*; -use crate::results::*; +use crate::*; pub struct DonateCall { pub func: ScFunc, diff --git a/contracts/wasm/donatewithfeedback/src/lib.rs b/contracts/wasm/donatewithfeedback/src/lib.rs index 694df46136..c8cc21b401 100644 --- a/contracts/wasm/donatewithfeedback/src/lib.rs +++ b/contracts/wasm/donatewithfeedback/src/lib.rs @@ -23,6 +23,7 @@ mod params; mod results; mod state; mod structs; + mod donatewithfeedback; #[no_mangle] diff --git a/contracts/wasm/erc20/src/contract.rs b/contracts/wasm/erc20/src/contract.rs index 0b46fdb182..2d7cec5958 100644 --- a/contracts/wasm/erc20/src/contract.rs +++ b/contracts/wasm/erc20/src/contract.rs @@ -8,10 +8,7 @@ #![allow(dead_code)] use wasmlib::*; - -use crate::consts::*; -use crate::params::*; -use crate::results::*; +use crate::*; pub struct ApproveCall { pub func: ScFunc, diff --git a/contracts/wasm/erc20/src/lib.rs b/contracts/wasm/erc20/src/lib.rs index ee59283ca1..882616aaae 100644 --- a/contracts/wasm/erc20/src/lib.rs +++ b/contracts/wasm/erc20/src/lib.rs @@ -25,6 +25,7 @@ mod params; mod results; mod state; mod typedefs; + mod erc20; #[no_mangle] diff --git a/contracts/wasm/erc20/src/typedefs.rs b/contracts/wasm/erc20/src/typedefs.rs index 28aa811c16..631a76063a 100644 --- a/contracts/wasm/erc20/src/typedefs.rs +++ b/contracts/wasm/erc20/src/typedefs.rs @@ -8,6 +8,7 @@ #![allow(dead_code)] use wasmlib::*; +use crate::*; #[derive(Clone)] pub struct MapAgentIDToImmutableUint64 { diff --git a/contracts/wasm/erc721/src/contract.rs b/contracts/wasm/erc721/src/contract.rs index c57cef147a..7dd5a240ea 100644 --- a/contracts/wasm/erc721/src/contract.rs +++ b/contracts/wasm/erc721/src/contract.rs @@ -8,10 +8,7 @@ #![allow(dead_code)] use wasmlib::*; - -use crate::consts::*; -use crate::params::*; -use crate::results::*; +use crate::*; pub struct ApproveCall { pub func: ScFunc, diff --git a/contracts/wasm/erc721/src/lib.rs b/contracts/wasm/erc721/src/lib.rs index 6318a9e84e..ec577cf7a3 100644 --- a/contracts/wasm/erc721/src/lib.rs +++ b/contracts/wasm/erc721/src/lib.rs @@ -25,6 +25,7 @@ mod params; mod results; mod state; mod typedefs; + mod erc721; #[no_mangle] diff --git a/contracts/wasm/erc721/src/typedefs.rs b/contracts/wasm/erc721/src/typedefs.rs index 792f1c820f..67f2f69ea0 100644 --- a/contracts/wasm/erc721/src/typedefs.rs +++ b/contracts/wasm/erc721/src/typedefs.rs @@ -8,6 +8,7 @@ #![allow(dead_code)] use wasmlib::*; +use crate::*; #[derive(Clone)] pub struct MapAgentIDToImmutableBool { diff --git a/contracts/wasm/fairauction/src/contract.rs b/contracts/wasm/fairauction/src/contract.rs index 6cd44328a3..92d96f2b31 100644 --- a/contracts/wasm/fairauction/src/contract.rs +++ b/contracts/wasm/fairauction/src/contract.rs @@ -8,10 +8,7 @@ #![allow(dead_code)] use wasmlib::*; - -use crate::consts::*; -use crate::params::*; -use crate::results::*; +use crate::*; pub struct FinalizeAuctionCall { pub func: ScFunc, diff --git a/contracts/wasm/fairauction/src/lib.rs b/contracts/wasm/fairauction/src/lib.rs index fb3ac5a603..c934bb377d 100644 --- a/contracts/wasm/fairauction/src/lib.rs +++ b/contracts/wasm/fairauction/src/lib.rs @@ -25,6 +25,7 @@ mod results; mod state; mod structs; mod typedefs; + mod fairauction; #[no_mangle] diff --git a/contracts/wasm/fairauction/src/structs.rs b/contracts/wasm/fairauction/src/structs.rs index 27ee703b4f..026b1171a3 100644 --- a/contracts/wasm/fairauction/src/structs.rs +++ b/contracts/wasm/fairauction/src/structs.rs @@ -9,7 +9,6 @@ #![allow(unused_imports)] use wasmlib::*; -use crate::typedefs::*; #[derive(Clone)] pub struct Auction { diff --git a/contracts/wasm/fairauction/src/typedefs.rs b/contracts/wasm/fairauction/src/typedefs.rs index 3d72f5d290..c9ce72b805 100644 --- a/contracts/wasm/fairauction/src/typedefs.rs +++ b/contracts/wasm/fairauction/src/typedefs.rs @@ -8,7 +8,7 @@ #![allow(dead_code)] use wasmlib::*; -use crate::structs::*; +use crate::*; #[derive(Clone)] pub struct ArrayOfImmutableAgentID { diff --git a/contracts/wasm/fairroulette/src/contract.rs b/contracts/wasm/fairroulette/src/contract.rs index 93e41a2410..c674bb5c12 100644 --- a/contracts/wasm/fairroulette/src/contract.rs +++ b/contracts/wasm/fairroulette/src/contract.rs @@ -8,10 +8,7 @@ #![allow(dead_code)] use wasmlib::*; - -use crate::consts::*; -use crate::params::*; -use crate::results::*; +use crate::*; pub struct ForcePayoutCall { pub func: ScFunc, diff --git a/contracts/wasm/fairroulette/src/lib.rs b/contracts/wasm/fairroulette/src/lib.rs index a68f8e7911..44cfe47129 100644 --- a/contracts/wasm/fairroulette/src/lib.rs +++ b/contracts/wasm/fairroulette/src/lib.rs @@ -25,6 +25,7 @@ mod params; mod results; mod state; mod structs; + mod fairroulette; #[no_mangle] diff --git a/contracts/wasm/helloworld/src/contract.rs b/contracts/wasm/helloworld/src/contract.rs index 27ed5ecc8d..97c2b5c1f1 100644 --- a/contracts/wasm/helloworld/src/contract.rs +++ b/contracts/wasm/helloworld/src/contract.rs @@ -8,9 +8,7 @@ #![allow(dead_code)] use wasmlib::*; - -use crate::consts::*; -use crate::results::*; +use crate::*; pub struct HelloWorldCall { pub func: ScFunc, diff --git a/contracts/wasm/helloworld/src/lib.rs b/contracts/wasm/helloworld/src/lib.rs index 2633ab21f2..434c7bc302 100644 --- a/contracts/wasm/helloworld/src/lib.rs +++ b/contracts/wasm/helloworld/src/lib.rs @@ -19,6 +19,7 @@ mod consts; mod contract; mod results; mod state; + mod helloworld; #[no_mangle] diff --git a/contracts/wasm/inccounter/src/contract.rs b/contracts/wasm/inccounter/src/contract.rs index 1c3a324d99..02ece4b5da 100644 --- a/contracts/wasm/inccounter/src/contract.rs +++ b/contracts/wasm/inccounter/src/contract.rs @@ -8,10 +8,7 @@ #![allow(dead_code)] use wasmlib::*; - -use crate::consts::*; -use crate::params::*; -use crate::results::*; +use crate::*; pub struct CallIncrementCall { pub func: ScFunc, diff --git a/contracts/wasm/inccounter/src/lib.rs b/contracts/wasm/inccounter/src/lib.rs index 4f5924dbf5..51748d644c 100644 --- a/contracts/wasm/inccounter/src/lib.rs +++ b/contracts/wasm/inccounter/src/lib.rs @@ -21,6 +21,7 @@ mod contract; mod params; mod results; mod state; + mod inccounter; #[no_mangle] diff --git a/contracts/wasm/testcore/src/contract.rs b/contracts/wasm/testcore/src/contract.rs index 203abd6f5b..fd89948907 100644 --- a/contracts/wasm/testcore/src/contract.rs +++ b/contracts/wasm/testcore/src/contract.rs @@ -8,10 +8,7 @@ #![allow(dead_code)] use wasmlib::*; - -use crate::consts::*; -use crate::params::*; -use crate::results::*; +use crate::*; pub struct CallOnChainCall { pub func: ScFunc, diff --git a/contracts/wasm/testcore/src/lib.rs b/contracts/wasm/testcore/src/lib.rs index daa508cfa7..9a4feaf2ef 100644 --- a/contracts/wasm/testcore/src/lib.rs +++ b/contracts/wasm/testcore/src/lib.rs @@ -21,6 +21,7 @@ mod contract; mod params; mod results; mod state; + mod testcore; #[no_mangle] diff --git a/contracts/wasm/testwasmlib/src/contract.rs b/contracts/wasm/testwasmlib/src/contract.rs index 671b54ff84..b8ede236dc 100644 --- a/contracts/wasm/testwasmlib/src/contract.rs +++ b/contracts/wasm/testwasmlib/src/contract.rs @@ -8,10 +8,7 @@ #![allow(dead_code)] use wasmlib::*; - -use crate::consts::*; -use crate::params::*; -use crate::results::*; +use crate::*; pub struct ArrayAppendCall { pub func: ScFunc, diff --git a/contracts/wasm/testwasmlib/src/lib.rs b/contracts/wasm/testwasmlib/src/lib.rs index 59ec474fb4..1e329906a8 100644 --- a/contracts/wasm/testwasmlib/src/lib.rs +++ b/contracts/wasm/testwasmlib/src/lib.rs @@ -25,6 +25,7 @@ mod params; mod results; mod state; mod typedefs; + mod testwasmlib; #[no_mangle] diff --git a/contracts/wasm/testwasmlib/src/typedefs.rs b/contracts/wasm/testwasmlib/src/typedefs.rs index 2c0b589ed6..f217502412 100644 --- a/contracts/wasm/testwasmlib/src/typedefs.rs +++ b/contracts/wasm/testwasmlib/src/typedefs.rs @@ -8,6 +8,7 @@ #![allow(dead_code)] use wasmlib::*; +use crate::*; #[derive(Clone)] pub struct ArrayOfImmutableString { diff --git a/contracts/wasm/timestamp/src/contract.rs b/contracts/wasm/timestamp/src/contract.rs index 2c0c95db40..7462ad0067 100644 --- a/contracts/wasm/timestamp/src/contract.rs +++ b/contracts/wasm/timestamp/src/contract.rs @@ -8,9 +8,7 @@ #![allow(dead_code)] use wasmlib::*; - -use crate::consts::*; -use crate::results::*; +use crate::*; pub struct NowCall { pub func: ScFunc, diff --git a/contracts/wasm/timestamp/src/lib.rs b/contracts/wasm/timestamp/src/lib.rs index 06dfdc5102..00f6e6d56b 100644 --- a/contracts/wasm/timestamp/src/lib.rs +++ b/contracts/wasm/timestamp/src/lib.rs @@ -19,6 +19,7 @@ mod consts; mod contract; mod results; mod state; + mod timestamp; #[no_mangle] diff --git a/contracts/wasm/tokenregistry/src/contract.rs b/contracts/wasm/tokenregistry/src/contract.rs index abf1544fb1..2bd333ef37 100644 --- a/contracts/wasm/tokenregistry/src/contract.rs +++ b/contracts/wasm/tokenregistry/src/contract.rs @@ -8,9 +8,7 @@ #![allow(dead_code)] use wasmlib::*; - -use crate::consts::*; -use crate::params::*; +use crate::*; pub struct MintSupplyCall { pub func: ScFunc, diff --git a/contracts/wasm/tokenregistry/src/lib.rs b/contracts/wasm/tokenregistry/src/lib.rs index 34ef9544ce..3960dc751e 100644 --- a/contracts/wasm/tokenregistry/src/lib.rs +++ b/contracts/wasm/tokenregistry/src/lib.rs @@ -21,6 +21,7 @@ mod contract; mod params; mod state; mod structs; + mod tokenregistry; #[no_mangle] diff --git a/packages/wasmvm/wasmlib/src/coreaccounts/contract.rs b/packages/wasmvm/wasmlib/src/coreaccounts/contract.rs index 76100505b6..fa86cc14b8 100644 --- a/packages/wasmvm/wasmlib/src/coreaccounts/contract.rs +++ b/packages/wasmvm/wasmlib/src/coreaccounts/contract.rs @@ -7,8 +7,8 @@ #![allow(dead_code)] -use crate::*; use crate::coreaccounts::*; +use crate::*; pub struct DepositCall { pub func: ScFunc, diff --git a/packages/wasmvm/wasmlib/src/coreblob/contract.rs b/packages/wasmvm/wasmlib/src/coreblob/contract.rs index 1b0b67aa40..f1f94cefd3 100644 --- a/packages/wasmvm/wasmlib/src/coreblob/contract.rs +++ b/packages/wasmvm/wasmlib/src/coreblob/contract.rs @@ -7,8 +7,8 @@ #![allow(dead_code)] -use crate::*; use crate::coreblob::*; +use crate::*; pub struct StoreBlobCall { pub func: ScFunc, diff --git a/packages/wasmvm/wasmlib/src/coreblocklog/contract.rs b/packages/wasmvm/wasmlib/src/coreblocklog/contract.rs index c6e03dbe64..40b9faee86 100644 --- a/packages/wasmvm/wasmlib/src/coreblocklog/contract.rs +++ b/packages/wasmvm/wasmlib/src/coreblocklog/contract.rs @@ -7,8 +7,8 @@ #![allow(dead_code)] -use crate::*; use crate::coreblocklog::*; +use crate::*; pub struct ControlAddressesCall { pub func: ScView, diff --git a/packages/wasmvm/wasmlib/src/coregovernance/contract.rs b/packages/wasmvm/wasmlib/src/coregovernance/contract.rs index 4a45b3c799..b3a24a56ce 100644 --- a/packages/wasmvm/wasmlib/src/coregovernance/contract.rs +++ b/packages/wasmvm/wasmlib/src/coregovernance/contract.rs @@ -7,8 +7,8 @@ #![allow(dead_code)] -use crate::*; use crate::coregovernance::*; +use crate::*; pub struct AddAllowedStateControllerAddressCall { pub func: ScFunc, diff --git a/packages/wasmvm/wasmlib/src/coreroot/contract.rs b/packages/wasmvm/wasmlib/src/coreroot/contract.rs index 5380321a18..038c957b54 100644 --- a/packages/wasmvm/wasmlib/src/coreroot/contract.rs +++ b/packages/wasmvm/wasmlib/src/coreroot/contract.rs @@ -7,8 +7,8 @@ #![allow(dead_code)] -use crate::*; use crate::coreroot::*; +use crate::*; pub struct DeployContractCall { pub func: ScFunc, diff --git a/packages/wasmvm/wasmlib/src/wasmrequests/contract.rs b/packages/wasmvm/wasmlib/src/wasmrequests/contract.rs index b12151f2d7..a25e10ee4e 100644 --- a/packages/wasmvm/wasmlib/src/wasmrequests/contract.rs +++ b/packages/wasmvm/wasmlib/src/wasmrequests/contract.rs @@ -7,8 +7,8 @@ #![allow(dead_code)] -use crate::*; use crate::wasmrequests::*; +use crate::*; pub struct ScFuncs { } diff --git a/tools/schema/generator/rstemplates/alltemplates.go b/tools/schema/generator/rstemplates/alltemplates.go index 1e8e2f52df..3e69725083 100644 --- a/tools/schema/generator/rstemplates/alltemplates.go +++ b/tools/schema/generator/rstemplates/alltemplates.go @@ -89,34 +89,6 @@ $#if core setCrate // ******************************* "setCrate": ` $#set crate (crate) -`, - // ******************************* - "rsHeader": ` -$#if core useCrate useWasmLib -`, - // ******************************* - "modEvents": ` -mod events; -`, - // ******************************* - "modParams": ` -mod params; -`, - // ******************************* - "modResults": ` -mod results; -`, - // ******************************* - "modStructs": ` -mod structs; -`, - // ******************************* - "modTypeDefs": ` -mod typedefs; -`, - // ******************************* - "useConsts": ` -use crate::consts::*; `, // ******************************* "useCoreContract": ` @@ -125,30 +97,6 @@ use crate::$package::*; // ******************************* "useCrate": ` use crate::*; -`, - // ******************************* - "useEvents": ` -use crate::events::*; -`, - // ******************************* - "useHost": ` -use crate::host::*; -`, - // ******************************* - "useParams": ` -use crate::params::*; -`, - // ******************************* - "useResults": ` -use crate::results::*; -`, - // ******************************* - "useStructs": ` -use crate::structs::*; -`, - // ******************************* - "useTypedefs": ` -use crate::typedefs::*; `, // ******************************* "useWasmLib": ` diff --git a/tools/schema/generator/rstemplates/contract.go b/tools/schema/generator/rstemplates/contract.go index 01d2c69121..e94f3fcd28 100644 --- a/tools/schema/generator/rstemplates/contract.go +++ b/tools/schema/generator/rstemplates/contract.go @@ -5,8 +5,8 @@ var contractRs = map[string]string{ "contract.rs": ` #![allow(dead_code)] -$#if core useCrate useWasmLib -$#if core useCoreContract contractUses +$#if core useCoreContract useWasmLib +use crate::*; $#each func FuncNameCall pub struct ScFuncs { @@ -16,13 +16,6 @@ impl ScFuncs { $#set separator $false $#each func FuncNameForCall } -`, - // ******************************* - "contractUses": ` - -use crate::consts::*; -$#if params useParams -$#if results useResults `, // ******************************* "FuncNameCall": ` diff --git a/tools/schema/generator/rstemplates/events.go b/tools/schema/generator/rstemplates/events.go index 9c5de2339c..9b4add2255 100644 --- a/tools/schema/generator/rstemplates/events.go +++ b/tools/schema/generator/rstemplates/events.go @@ -6,7 +6,7 @@ var eventsRs = map[string]string{ #![allow(dead_code)] #![allow(unused_mut)] -use wasmlib::*; +$#if core useCrate useWasmLib $#set TypeName $Package$+Events pub struct $TypeName { diff --git a/tools/schema/generator/rstemplates/funcs.go b/tools/schema/generator/rstemplates/funcs.go index 43f2c2954f..244e345954 100644 --- a/tools/schema/generator/rstemplates/funcs.go +++ b/tools/schema/generator/rstemplates/funcs.go @@ -6,8 +6,6 @@ var funcsRs = map[string]string{ use wasmlib::*; use crate::*; -$#if structs useStructs -$#if typedefs useTypedefs $#each func funcSignature `, // ******************************* diff --git a/tools/schema/generator/rstemplates/lib.go b/tools/schema/generator/rstemplates/lib.go index b59f07b73f..03d141ee57 100644 --- a/tools/schema/generator/rstemplates/lib.go +++ b/tools/schema/generator/rstemplates/lib.go @@ -10,21 +10,32 @@ use $package::*; use wasmlib::*; use crate::consts::*; -$#if events useEvents -$#if params useParams -$#if results useResults +$#set moduleName events +$#if events useModule +$#set moduleName params +$#if params useModule +$#set moduleName results +$#if results useModule use crate::state::*; -$#if structs useStructs -$#if typedefs useTypedefs +$#set moduleName structs +$#if structs useModule +$#set moduleName typedefs +$#if typedefs useModule mod consts; mod contract; -$#if events modEvents -$#if params modParams -$#if results modResults +$#set moduleName events +$#if events modModule +$#set moduleName params +$#if params modModule +$#set moduleName results +$#if results modModule mod state; -$#if structs modStructs -$#if typedefs modTypeDefs +$#set moduleName structs +$#if structs modModule +$#set moduleName typedefs +$#if typedefs modModule + mod $package; #[no_mangle] @@ -33,6 +44,14 @@ fn on_load() { $#each func libExportFunc } $#each func libThunk +`, + // ******************************* + "useModule": ` +use crate::$moduleName::*; +`, + // ******************************* + "modModule": ` +mod $moduleName; `, // ******************************* "libExportFunc": ` diff --git a/tools/schema/generator/rstemplates/structs.go b/tools/schema/generator/rstemplates/structs.go index 9f479f7aac..43128acb5b 100644 --- a/tools/schema/generator/rstemplates/structs.go +++ b/tools/schema/generator/rstemplates/structs.go @@ -7,7 +7,6 @@ var structsRs = map[string]string{ #![allow(unused_imports)] $#if core useCrate useWasmLib -$#if typedefs useTypedefs $#each structs structType `, // ******************************* diff --git a/tools/schema/generator/rstemplates/typedefs.go b/tools/schema/generator/rstemplates/typedefs.go index c33382ce4e..a9436db0c1 100644 --- a/tools/schema/generator/rstemplates/typedefs.go +++ b/tools/schema/generator/rstemplates/typedefs.go @@ -5,8 +5,8 @@ var typedefsRs = map[string]string{ "typedefs.rs": ` #![allow(dead_code)] -use wasmlib::*; -$#if structs useStructs +$#if core else useWasmLib +use crate::*; $#each typedef typedefProxy `, // ******************************* From 0146632aa1e33e0594b3731b9e9f8e175395b716 Mon Sep 17 00:00:00 2001 From: Eric Hop Date: Thu, 3 Feb 2022 22:01:34 -0800 Subject: [PATCH 061/111] Removed obsolete host-provided Wasm linker functions --- packages/wasmvm/wasmhost/wasmedgevm.go | 40 ------------------ packages/wasmvm/wasmhost/wasmervm.go | 41 ------------------ packages/wasmvm/wasmhost/wasmtimevm.go | 17 -------- packages/wasmvm/wasmhost/wasmvm.go | 42 ++++--------------- .../wasmvm/wasmlib/src/wasmrequests/consts.rs | 2 - .../wasmlib/ts/wasmlib/wasmrequests/consts.ts | 2 - packages/wasmvm/wasmvmhost/host.go | 2 +- tools/schema/generator/rstemplates/consts.go | 12 ++++-- tools/schema/generator/rstemplates/events.go | 2 + tools/schema/generator/tstemplates/consts.go | 12 ++++-- 10 files changed, 28 insertions(+), 144 deletions(-) diff --git a/packages/wasmvm/wasmhost/wasmedgevm.go b/packages/wasmvm/wasmhost/wasmedgevm.go index 1a6388d091..c76c37a918 100644 --- a/packages/wasmvm/wasmhost/wasmedgevm.go +++ b/packages/wasmvm/wasmhost/wasmedgevm.go @@ -66,11 +66,6 @@ func (vm *WasmEdgeVM) LinkHost(impl WasmVM, host *WasmHost) error { _ = vm.WasmVMBase.LinkHost(impl, host) vm.importModule(ModuleWasmLib) - vm.importFunc(5, 1, FuncHostGetBytes, vm.exportHostGetBytes) - vm.importFunc(2, 1, FuncHostGetKeyID, vm.exportHostGetKeyID) - vm.importFunc(3, 1, FuncHostGetObjectID, vm.exportHostGetObjectID) - vm.importFunc(5, 0, FuncHostSetBytes, vm.exportHostSetBytes) - vm.importFunc(4, 1, FuncHostStateGet, vm.exportHostStateGet) vm.importFunc(4, 0, FuncHostStateSet, vm.exportHostStateSet) err := vm.edge.RegisterImport(vm.module) @@ -184,41 +179,6 @@ func (vm *WasmEdgeVM) exportFdWrite(args []interface{}) []interface{} { return []interface{}{ret} } -func (vm *WasmEdgeVM) exportHostGetBytes(args []interface{}) []interface{} { - objID := args[0].(int32) - keyID := args[1].(int32) - typeID := args[2].(int32) - stringRef := args[3].(int32) - size := args[4].(int32) - ret := vm.HostGetBytes(objID, keyID, typeID, stringRef, size) - return []interface{}{ret} -} - -func (vm *WasmEdgeVM) exportHostGetKeyID(args []interface{}) []interface{} { - keyRef := args[0].(int32) - size := args[1].(int32) - ret := vm.HostGetKeyID(keyRef, size) - return []interface{}{ret} -} - -func (vm *WasmEdgeVM) exportHostGetObjectID(args []interface{}) []interface{} { - objID := args[0].(int32) - keyID := args[1].(int32) - typeID := args[2].(int32) - ret := vm.HostGetObjectID(objID, keyID, typeID) - return []interface{}{ret} -} - -func (vm *WasmEdgeVM) exportHostSetBytes(args []interface{}) []interface{} { - objID := args[0].(int32) - keyID := args[1].(int32) - typeID := args[2].(int32) - stringRef := args[3].(int32) - size := args[4].(int32) - vm.HostSetBytes(objID, keyID, typeID, stringRef, size) - return nil -} - func (vm *WasmEdgeVM) exportHostStateGet(args []interface{}) []interface{} { keyRef := args[0].(int32) keyLen := args[1].(int32) diff --git a/packages/wasmvm/wasmhost/wasmervm.go b/packages/wasmvm/wasmhost/wasmervm.go index d40639f39d..60c32110fc 100644 --- a/packages/wasmvm/wasmhost/wasmervm.go +++ b/packages/wasmvm/wasmhost/wasmervm.go @@ -40,12 +40,6 @@ func (vm *WasmerVM) LinkHost(impl WasmVM, host *WasmHost) error { _ = vm.WasmVMBase.LinkHost(impl, host) funcs := map[string]wasmer.IntoExtern{ - FuncHostGetBytes: vm.importFunc(5, 1, vm.exportHostGetBytes), - FuncHostGetKeyID: vm.importFunc(2, 1, vm.exportHostGetKeyID), - FuncHostGetObjectID: vm.importFunc(3, 1, vm.exportHostGetObjectID), - FuncHostSetBytes: vm.importFunc(5, 0, vm.exportHostSetBytes), - - // new Wasm VM interface FuncHostStateGet: vm.importFunc(4, 1, vm.exportHostStateGet), FuncHostStateSet: vm.importFunc(4, 0, vm.exportHostStateSet), } @@ -133,41 +127,6 @@ func (vm *WasmerVM) exportFdWrite(args []wasmer.Value) ([]wasmer.Value, error) { return []wasmer.Value{wasmer.NewI32(ret)}, nil } -func (vm *WasmerVM) exportHostGetBytes(args []wasmer.Value) ([]wasmer.Value, error) { - objID := args[0].I32() - keyID := args[1].I32() - typeID := args[2].I32() - stringRef := args[3].I32() - size := args[4].I32() - ret := vm.HostGetBytes(objID, keyID, typeID, stringRef, size) - return []wasmer.Value{wasmer.NewI32(ret)}, nil -} - -func (vm *WasmerVM) exportHostGetKeyID(args []wasmer.Value) ([]wasmer.Value, error) { - keyRef := args[0].I32() - size := args[1].I32() - ret := vm.HostGetKeyID(keyRef, size) - return []wasmer.Value{wasmer.NewI32(ret)}, nil -} - -func (vm *WasmerVM) exportHostGetObjectID(args []wasmer.Value) ([]wasmer.Value, error) { - objID := args[0].I32() - keyID := args[1].I32() - typeID := args[2].I32() - ret := vm.HostGetObjectID(objID, keyID, typeID) - return []wasmer.Value{wasmer.NewI32(ret)}, nil -} - -func (vm *WasmerVM) exportHostSetBytes(args []wasmer.Value) ([]wasmer.Value, error) { - objID := args[0].I32() - keyID := args[1].I32() - typeID := args[2].I32() - stringRef := args[3].I32() - size := args[4].I32() - vm.HostSetBytes(objID, keyID, typeID, stringRef, size) - return nil, nil -} - func (vm *WasmerVM) exportHostStateGet(args []wasmer.Value) ([]wasmer.Value, error) { keyRef := args[0].I32() keyLen := args[1].I32() diff --git a/packages/wasmvm/wasmhost/wasmtimevm.go b/packages/wasmvm/wasmhost/wasmtimevm.go index 9dc9823c2d..df2ccea825 100644 --- a/packages/wasmvm/wasmhost/wasmtimevm.go +++ b/packages/wasmvm/wasmhost/wasmtimevm.go @@ -46,23 +46,6 @@ func (vm *WasmTimeVM) LinkHost(impl WasmVM, host *WasmHost) (err error) { vm.linker = wasmtime.NewLinker(vm.engine) _ = vm.WasmVMBase.LinkHost(impl, host) - err = vm.linker.DefineFunc(vm.store, ModuleWasmLib, FuncHostGetBytes, vm.HostGetBytes) - if err != nil { - return err - } - err = vm.linker.DefineFunc(vm.store, ModuleWasmLib, FuncHostGetKeyID, vm.HostGetKeyID) - if err != nil { - return err - } - err = vm.linker.DefineFunc(vm.store, ModuleWasmLib, FuncHostGetObjectID, vm.HostGetObjectID) - if err != nil { - return err - } - err = vm.linker.DefineFunc(vm.store, ModuleWasmLib, FuncHostSetBytes, vm.HostSetBytes) - if err != nil { - return err - } - // new Wasm VM interface err = vm.linker.DefineFunc(vm.store, ModuleWasmLib, FuncHostStateGet, vm.HostStateGet) if err != nil { diff --git a/packages/wasmvm/wasmhost/wasmvm.go b/packages/wasmvm/wasmhost/wasmvm.go index 06e39b2daf..da9dd98a90 100644 --- a/packages/wasmvm/wasmhost/wasmvm.go +++ b/packages/wasmvm/wasmhost/wasmvm.go @@ -14,19 +14,15 @@ import ( ) const ( - defaultTimeout = 5 * time.Second - FuncAbort = "abort" - FuncFdWrite = "fd_write" - FuncHostGetBytes = "hostGetBytes" - FuncHostGetKeyID = "hostGetKeyID" - FuncHostGetObjectID = "hostGetObjectID" - FuncHostSetBytes = "hostSetBytes" - FuncHostStateGet = "hostStateGet" - FuncHostStateSet = "hostStateSet" - ModuleEnv = "env" - ModuleWasi1 = "wasi_unstable" - ModuleWasi2 = "wasi_snapshot_preview1" - ModuleWasmLib = "WasmLib" + defaultTimeout = 5 * time.Second + FuncAbort = "abort" + FuncFdWrite = "fd_write" + FuncHostStateGet = "hostStateGet" + FuncHostStateSet = "hostStateSet" + ModuleEnv = "env" + ModuleWasi1 = "wasi_unstable" + ModuleWasi2 = "wasi_snapshot_preview1" + ModuleWasmLib = "WasmLib" ) var ( @@ -133,26 +129,6 @@ func (vm *WasmVMBase) HostFdWrite(_fd, iovs, _size, written int32) int32 { return size } -func (vm *WasmVMBase) HostGetBytes(objID, keyID, typeID, stringRef, size int32) int32 { - defer vm.catchPanicMessage() - panic("deprecated: HostGetBytes") -} - -func (vm *WasmVMBase) HostGetKeyID(keyRef, size int32) int32 { - defer vm.catchPanicMessage() - panic("deprecated: HostGetKeyID") -} - -func (vm *WasmVMBase) HostGetObjectID(objID, keyID, typeID int32) int32 { - defer vm.catchPanicMessage() - panic("deprecated: HostGetObjectID") -} - -func (vm *WasmVMBase) HostSetBytes(objID, keyID, typeID, stringRef, size int32) { - defer vm.catchPanicMessage() - panic("deprecated: HostSetBytes") -} - func (vm *WasmVMBase) HostStateGet(keyRef, keyLen, valRef, valLen int32) int32 { defer vm.catchPanicMessage() diff --git a/packages/wasmvm/wasmlib/src/wasmrequests/consts.rs b/packages/wasmvm/wasmlib/src/wasmrequests/consts.rs index 23352c9ef5..ad4856cf07 100644 --- a/packages/wasmvm/wasmlib/src/wasmrequests/consts.rs +++ b/packages/wasmvm/wasmlib/src/wasmrequests/consts.rs @@ -12,5 +12,3 @@ use crate::*; pub const SC_NAME : &str = "requests"; pub const SC_DESCRIPTION : &str = "WasmLib request structures"; pub const HSC_NAME : ScHname = ScHname(0x98e19453); - - diff --git a/packages/wasmvm/wasmlib/ts/wasmlib/wasmrequests/consts.ts b/packages/wasmvm/wasmlib/ts/wasmlib/wasmrequests/consts.ts index b5f82978f6..2533b5bc75 100644 --- a/packages/wasmvm/wasmlib/ts/wasmlib/wasmrequests/consts.ts +++ b/packages/wasmvm/wasmlib/ts/wasmlib/wasmrequests/consts.ts @@ -10,5 +10,3 @@ import * as wasmtypes from "wasmlib/wasmtypes"; export const ScName = "requests"; export const ScDescription = "WasmLib request structures"; export const HScName = new wasmtypes.ScHname(0x98e19453); - - diff --git a/packages/wasmvm/wasmvmhost/host.go b/packages/wasmvm/wasmvmhost/host.go index 40735424bb..41dea40c8f 100644 --- a/packages/wasmvm/wasmvmhost/host.go +++ b/packages/wasmvm/wasmvmhost/host.go @@ -104,7 +104,7 @@ func (w *WasmVMHost) StateExists(key []byte) bool { func (w *WasmVMHost) StateGet(key []byte) []byte { //TODO optimize when type size is known in advance? - // or maybe pass in a larger buffer that will fit most rsults? + // or maybe pass in a larger buffer that will fit most results? //size := int32(len(value)) //if size != 0 { // // size known in advance, just get the data diff --git a/tools/schema/generator/rstemplates/consts.go b/tools/schema/generator/rstemplates/consts.go index 95913a1a8d..bdf4a2b1c4 100644 --- a/tools/schema/generator/rstemplates/consts.go +++ b/tools/schema/generator/rstemplates/consts.go @@ -13,10 +13,7 @@ pub const HSC_NAME : ScHname = ScHname(0x$hscName); $#if params constParams $#if results constResults $#if state constState - -$#each func constFunc - -$#each func constHFunc +$#if funcs constFuncs `, // ******************************* "constParams": ` @@ -35,6 +32,13 @@ $#each results constField $#set constPrefix STATE_ $#each state constField +`, + // ******************************* + "constFuncs": ` + +$#each func constFunc + +$#each func constHFunc `, // ******************************* "constField": ` diff --git a/tools/schema/generator/rstemplates/events.go b/tools/schema/generator/rstemplates/events.go index 9b4add2255..b6251872a7 100644 --- a/tools/schema/generator/rstemplates/events.go +++ b/tools/schema/generator/rstemplates/events.go @@ -18,6 +18,7 @@ $#each events eventFunc `, // ******************************* "eventFunc": ` +$#set separator $#set params $#each event eventParam @@ -30,6 +31,7 @@ $#each event eventEmit // ******************************* "eventParam": ` $#set params $params, $fld_name: $fldRef$fldParamLangType +$#set separator , `, // ******************************* "eventEmit": ` diff --git a/tools/schema/generator/tstemplates/consts.go b/tools/schema/generator/tstemplates/consts.go index 62c2f4ef0f..7b9e45e808 100644 --- a/tools/schema/generator/tstemplates/consts.go +++ b/tools/schema/generator/tstemplates/consts.go @@ -11,10 +11,7 @@ export const HScName = new wasmtypes.ScHname(0x$hscName); $#if params constParams $#if results constResults $#if state constState - -$#each func constFunc - -$#each func constHFunc +$#if funcs constFuncs `, // ******************************* "constParams": ` @@ -33,6 +30,13 @@ $#each results constField $#set constPrefix State $#each state constField +`, + // ******************************* + "constFuncs": ` + +$#each func constFunc + +$#each func constHFunc `, // ******************************* "constField": ` From 077351ae6d1c76b4c62658c12ce4525a291bed08 Mon Sep 17 00:00:00 2001 From: Eric Hop Date: Fri, 4 Feb 2022 06:51:32 -0800 Subject: [PATCH 062/111] Clean up unused TS imports --- .../wasm/dividend/ts/dividend/contract.ts | 13 +- contracts/wasm/dividend/ts/dividend/lib.ts | 1 - contracts/wasm/dividend/ts/dividend/params.ts | 1 - .../wasm/dividend/ts/dividend/results.ts | 1 - contracts/wasm/dividend/ts/dividend/state.ts | 1 - .../ts/donatewithfeedback/contract.ts | 9 +- .../ts/donatewithfeedback/lib.ts | 1 - .../ts/donatewithfeedback/params.ts | 1 - .../ts/donatewithfeedback/results.ts | 1 - .../ts/donatewithfeedback/state.ts | 1 - .../ts/donatewithfeedback/structs.ts | 1 - contracts/wasm/erc20/ts/erc20/contract.ts | 15 +- contracts/wasm/erc20/ts/erc20/lib.ts | 1 - contracts/wasm/erc20/ts/erc20/params.ts | 1 - contracts/wasm/erc20/ts/erc20/results.ts | 1 - contracts/wasm/erc20/ts/erc20/state.ts | 1 - contracts/wasm/erc20/ts/erc20/typedefs.ts | 5 +- contracts/wasm/erc721/ts/erc721/contract.ts | 29 +- contracts/wasm/erc721/ts/erc721/lib.ts | 1 - contracts/wasm/erc721/ts/erc721/params.ts | 1 - contracts/wasm/erc721/ts/erc721/results.ts | 1 - contracts/wasm/erc721/ts/erc721/state.ts | 1 - contracts/wasm/erc721/ts/erc721/typedefs.ts | 5 +- .../fairauction/ts/fairauction/contract.ts | 11 +- .../wasm/fairauction/ts/fairauction/lib.ts | 1 - .../wasm/fairauction/ts/fairauction/params.ts | 1 - .../fairauction/ts/fairauction/results.ts | 1 - .../wasm/fairauction/ts/fairauction/state.ts | 1 - .../fairauction/ts/fairauction/structs.ts | 1 - .../fairauction/ts/fairauction/typedefs.ts | 9 +- .../fairroulette/ts/fairroulette/contract.ts | 19 +- .../wasm/fairroulette/ts/fairroulette/lib.ts | 1 - .../fairroulette/ts/fairroulette/params.ts | 1 - .../fairroulette/ts/fairroulette/results.ts | 1 - .../fairroulette/ts/fairroulette/state.ts | 1 - .../fairroulette/ts/fairroulette/structs.ts | 1 - .../wasm/helloworld/ts/helloworld/contract.ts | 5 +- .../wasm/helloworld/ts/helloworld/lib.ts | 1 - .../wasm/helloworld/ts/helloworld/results.ts | 1 - .../wasm/helloworld/ts/helloworld/state.ts | 1 - .../wasm/inccounter/ts/inccounter/contract.ts | 35 +-- .../wasm/inccounter/ts/inccounter/lib.ts | 1 - .../wasm/inccounter/ts/inccounter/params.ts | 1 - .../wasm/inccounter/ts/inccounter/results.ts | 1 - .../wasm/inccounter/ts/inccounter/state.ts | 1 - .../wasm/testcore/ts/testcore/contract.ts | 65 ++-- contracts/wasm/testcore/ts/testcore/lib.ts | 1 - contracts/wasm/testcore/ts/testcore/params.ts | 1 - .../wasm/testcore/ts/testcore/results.ts | 1 - contracts/wasm/testcore/ts/testcore/state.ts | 1 - contracts/wasm/testwasmlib/src/structs.rs | 289 ----------------- .../testwasmlib/ts/testwasmlib/contract.ts | 31 +- .../wasm/testwasmlib/ts/testwasmlib/lib.ts | 1 - .../wasm/testwasmlib/ts/testwasmlib/params.ts | 1 - .../testwasmlib/ts/testwasmlib/results.ts | 1 - .../wasm/testwasmlib/ts/testwasmlib/state.ts | 1 - .../testwasmlib/ts/testwasmlib/structs.ts | 292 ------------------ .../testwasmlib/ts/testwasmlib/typedefs.ts | 9 +- .../wasm/timestamp/ts/timestamp/contract.ts | 5 +- contracts/wasm/timestamp/ts/timestamp/lib.ts | 1 - .../wasm/timestamp/ts/timestamp/results.ts | 1 - .../wasm/timestamp/ts/timestamp/state.ts | 1 - .../ts/tokenregistry/contract.ts | 9 +- .../tokenregistry/ts/tokenregistry/lib.ts | 1 - .../tokenregistry/ts/tokenregistry/params.ts | 1 - .../tokenregistry/ts/tokenregistry/state.ts | 1 - .../tokenregistry/ts/tokenregistry/structs.ts | 1 - .../ts/wasmlib/coreaccounts/contract.ts | 15 +- .../wasmlib/ts/wasmlib/coreaccounts/params.ts | 1 - .../ts/wasmlib/coreaccounts/results.ts | 1 - .../wasmlib/ts/wasmlib/coreblob/contract.ts | 9 +- .../wasmlib/ts/wasmlib/coreblob/params.ts | 1 - .../wasmlib/ts/wasmlib/coreblob/results.ts | 1 - .../ts/wasmlib/coreblocklog/contract.ts | 21 +- .../wasmlib/ts/wasmlib/coreblocklog/params.ts | 1 - .../ts/wasmlib/coreblocklog/results.ts | 1 - .../ts/wasmlib/coregovernance/contract.ts | 25 +- .../ts/wasmlib/coregovernance/params.ts | 1 - .../ts/wasmlib/coregovernance/results.ts | 1 - .../wasmlib/ts/wasmlib/coreroot/contract.ts | 11 +- .../wasmlib/ts/wasmlib/coreroot/params.ts | 1 - .../wasmlib/ts/wasmlib/coreroot/results.ts | 1 - .../ts/wasmlib/wasmrequests/contract.ts | 1 - .../ts/wasmlib/wasmrequests/structs.ts | 1 - .../generator/tstemplates/alltemplates.go | 6 - .../schema/generator/tstemplates/contract.go | 5 +- tools/schema/generator/tstemplates/funcs.go | 4 +- tools/schema/generator/tstemplates/lib.go | 3 +- tools/schema/generator/tstemplates/params.go | 3 +- tools/schema/generator/tstemplates/results.go | 3 +- tools/schema/generator/tstemplates/state.go | 3 +- tools/schema/generator/tstemplates/structs.go | 1 - .../schema/generator/tstemplates/typedefs.go | 5 +- 93 files changed, 184 insertions(+), 846 deletions(-) delete mode 100644 contracts/wasm/testwasmlib/src/structs.rs delete mode 100644 contracts/wasm/testwasmlib/ts/testwasmlib/structs.ts diff --git a/contracts/wasm/dividend/ts/dividend/contract.ts b/contracts/wasm/dividend/ts/dividend/contract.ts index 3a88624118..d1d27a8d16 100644 --- a/contracts/wasm/dividend/ts/dividend/contract.ts +++ b/contracts/wasm/dividend/ts/dividend/contract.ts @@ -6,7 +6,6 @@ // Change the json schema instead import * as wasmlib from "wasmlib"; -import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; export class DivideCall { @@ -70,36 +69,36 @@ export class GetOwnerContext { } export class ScFuncs { - static divide(ctx: wasmlib.ScFuncCallContext): DivideCall { + static divide(_ctx: wasmlib.ScFuncCallContext): DivideCall { return new DivideCall(); } - static init(ctx: wasmlib.ScFuncCallContext): InitCall { + static init(_ctx: wasmlib.ScFuncCallContext): InitCall { const f = new InitCall(); f.params = new sc.MutableInitParams(wasmlib.newCallParamsProxy(f.func)); return f; } - static member(ctx: wasmlib.ScFuncCallContext): MemberCall { + static member(_ctx: wasmlib.ScFuncCallContext): MemberCall { const f = new MemberCall(); f.params = new sc.MutableMemberParams(wasmlib.newCallParamsProxy(f.func)); return f; } - static setOwner(ctx: wasmlib.ScFuncCallContext): SetOwnerCall { + static setOwner(_ctx: wasmlib.ScFuncCallContext): SetOwnerCall { const f = new SetOwnerCall(); f.params = new sc.MutableSetOwnerParams(wasmlib.newCallParamsProxy(f.func)); return f; } - static getFactor(ctx: wasmlib.ScViewCallContext): GetFactorCall { + static getFactor(_ctx: wasmlib.ScViewCallContext): GetFactorCall { const f = new GetFactorCall(); f.params = new sc.MutableGetFactorParams(wasmlib.newCallParamsProxy(f.func)); f.results = new sc.ImmutableGetFactorResults(wasmlib.newCallResultsProxy(f.func)); return f; } - static getOwner(ctx: wasmlib.ScViewCallContext): GetOwnerCall { + static getOwner(_ctx: wasmlib.ScViewCallContext): GetOwnerCall { const f = new GetOwnerCall(); f.results = new sc.ImmutableGetOwnerResults(wasmlib.newCallResultsProxy(f.func)); return f; diff --git a/contracts/wasm/dividend/ts/dividend/lib.ts b/contracts/wasm/dividend/ts/dividend/lib.ts index 04083b5d0f..a64cf5fa6f 100644 --- a/contracts/wasm/dividend/ts/dividend/lib.ts +++ b/contracts/wasm/dividend/ts/dividend/lib.ts @@ -6,7 +6,6 @@ // Change the json schema instead import * as wasmlib from "wasmlib"; -import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; export function on_call(index: i32): void { diff --git a/contracts/wasm/dividend/ts/dividend/params.ts b/contracts/wasm/dividend/ts/dividend/params.ts index 391c91ed62..59e981b964 100644 --- a/contracts/wasm/dividend/ts/dividend/params.ts +++ b/contracts/wasm/dividend/ts/dividend/params.ts @@ -5,7 +5,6 @@ // >>>> DO NOT CHANGE THIS FILE! <<<< // Change the json schema instead -import * as wasmlib from "wasmlib"; import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; diff --git a/contracts/wasm/dividend/ts/dividend/results.ts b/contracts/wasm/dividend/ts/dividend/results.ts index 84accfd03a..290289251f 100644 --- a/contracts/wasm/dividend/ts/dividend/results.ts +++ b/contracts/wasm/dividend/ts/dividend/results.ts @@ -5,7 +5,6 @@ // >>>> DO NOT CHANGE THIS FILE! <<<< // Change the json schema instead -import * as wasmlib from "wasmlib"; import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; diff --git a/contracts/wasm/dividend/ts/dividend/state.ts b/contracts/wasm/dividend/ts/dividend/state.ts index d05a26a58a..5ad7f3a66d 100644 --- a/contracts/wasm/dividend/ts/dividend/state.ts +++ b/contracts/wasm/dividend/ts/dividend/state.ts @@ -5,7 +5,6 @@ // >>>> DO NOT CHANGE THIS FILE! <<<< // Change the json schema instead -import * as wasmlib from "wasmlib"; import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; diff --git a/contracts/wasm/donatewithfeedback/ts/donatewithfeedback/contract.ts b/contracts/wasm/donatewithfeedback/ts/donatewithfeedback/contract.ts index 0656179cdb..21e956946e 100644 --- a/contracts/wasm/donatewithfeedback/ts/donatewithfeedback/contract.ts +++ b/contracts/wasm/donatewithfeedback/ts/donatewithfeedback/contract.ts @@ -6,7 +6,6 @@ // Change the json schema instead import * as wasmlib from "wasmlib"; -import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; export class DonateCall { @@ -52,26 +51,26 @@ export class DonationInfoContext { } export class ScFuncs { - static donate(ctx: wasmlib.ScFuncCallContext): DonateCall { + static donate(_ctx: wasmlib.ScFuncCallContext): DonateCall { const f = new DonateCall(); f.params = new sc.MutableDonateParams(wasmlib.newCallParamsProxy(f.func)); return f; } - static withdraw(ctx: wasmlib.ScFuncCallContext): WithdrawCall { + static withdraw(_ctx: wasmlib.ScFuncCallContext): WithdrawCall { const f = new WithdrawCall(); f.params = new sc.MutableWithdrawParams(wasmlib.newCallParamsProxy(f.func)); return f; } - static donation(ctx: wasmlib.ScViewCallContext): DonationCall { + static donation(_ctx: wasmlib.ScViewCallContext): DonationCall { const f = new DonationCall(); f.params = new sc.MutableDonationParams(wasmlib.newCallParamsProxy(f.func)); f.results = new sc.ImmutableDonationResults(wasmlib.newCallResultsProxy(f.func)); return f; } - static donationInfo(ctx: wasmlib.ScViewCallContext): DonationInfoCall { + static donationInfo(_ctx: wasmlib.ScViewCallContext): DonationInfoCall { const f = new DonationInfoCall(); f.results = new sc.ImmutableDonationInfoResults(wasmlib.newCallResultsProxy(f.func)); return f; diff --git a/contracts/wasm/donatewithfeedback/ts/donatewithfeedback/lib.ts b/contracts/wasm/donatewithfeedback/ts/donatewithfeedback/lib.ts index ee7ec5bdc7..813aa6a215 100644 --- a/contracts/wasm/donatewithfeedback/ts/donatewithfeedback/lib.ts +++ b/contracts/wasm/donatewithfeedback/ts/donatewithfeedback/lib.ts @@ -6,7 +6,6 @@ // Change the json schema instead import * as wasmlib from "wasmlib"; -import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; export function on_call(index: i32): void { diff --git a/contracts/wasm/donatewithfeedback/ts/donatewithfeedback/params.ts b/contracts/wasm/donatewithfeedback/ts/donatewithfeedback/params.ts index 5f2f7b4c0e..9a12bc0755 100644 --- a/contracts/wasm/donatewithfeedback/ts/donatewithfeedback/params.ts +++ b/contracts/wasm/donatewithfeedback/ts/donatewithfeedback/params.ts @@ -5,7 +5,6 @@ // >>>> DO NOT CHANGE THIS FILE! <<<< // Change the json schema instead -import * as wasmlib from "wasmlib"; import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; diff --git a/contracts/wasm/donatewithfeedback/ts/donatewithfeedback/results.ts b/contracts/wasm/donatewithfeedback/ts/donatewithfeedback/results.ts index b8999a4769..b66c1e766b 100644 --- a/contracts/wasm/donatewithfeedback/ts/donatewithfeedback/results.ts +++ b/contracts/wasm/donatewithfeedback/ts/donatewithfeedback/results.ts @@ -5,7 +5,6 @@ // >>>> DO NOT CHANGE THIS FILE! <<<< // Change the json schema instead -import * as wasmlib from "wasmlib"; import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; diff --git a/contracts/wasm/donatewithfeedback/ts/donatewithfeedback/state.ts b/contracts/wasm/donatewithfeedback/ts/donatewithfeedback/state.ts index d15aefad92..54d2ff010b 100644 --- a/contracts/wasm/donatewithfeedback/ts/donatewithfeedback/state.ts +++ b/contracts/wasm/donatewithfeedback/ts/donatewithfeedback/state.ts @@ -5,7 +5,6 @@ // >>>> DO NOT CHANGE THIS FILE! <<<< // Change the json schema instead -import * as wasmlib from "wasmlib"; import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; diff --git a/contracts/wasm/donatewithfeedback/ts/donatewithfeedback/structs.ts b/contracts/wasm/donatewithfeedback/ts/donatewithfeedback/structs.ts index 12b01ac1c4..2290e6e853 100644 --- a/contracts/wasm/donatewithfeedback/ts/donatewithfeedback/structs.ts +++ b/contracts/wasm/donatewithfeedback/ts/donatewithfeedback/structs.ts @@ -5,7 +5,6 @@ // >>>> DO NOT CHANGE THIS FILE! <<<< // Change the json schema instead -import * as wasmlib from "wasmlib"; import * as wasmtypes from "wasmlib/wasmtypes"; export class Donation { diff --git a/contracts/wasm/erc20/ts/erc20/contract.ts b/contracts/wasm/erc20/ts/erc20/contract.ts index 1fab6fec87..51e57e73ed 100644 --- a/contracts/wasm/erc20/ts/erc20/contract.ts +++ b/contracts/wasm/erc20/ts/erc20/contract.ts @@ -6,7 +6,6 @@ // Change the json schema instead import * as wasmlib from "wasmlib"; -import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; export class ApproveCall { @@ -88,45 +87,45 @@ export class TotalSupplyContext { } export class ScFuncs { - static approve(ctx: wasmlib.ScFuncCallContext): ApproveCall { + static approve(_ctx: wasmlib.ScFuncCallContext): ApproveCall { const f = new ApproveCall(); f.params = new sc.MutableApproveParams(wasmlib.newCallParamsProxy(f.func)); return f; } - static init(ctx: wasmlib.ScFuncCallContext): InitCall { + static init(_ctx: wasmlib.ScFuncCallContext): InitCall { const f = new InitCall(); f.params = new sc.MutableInitParams(wasmlib.newCallParamsProxy(f.func)); return f; } - static transfer(ctx: wasmlib.ScFuncCallContext): TransferCall { + static transfer(_ctx: wasmlib.ScFuncCallContext): TransferCall { const f = new TransferCall(); f.params = new sc.MutableTransferParams(wasmlib.newCallParamsProxy(f.func)); return f; } - static transferFrom(ctx: wasmlib.ScFuncCallContext): TransferFromCall { + static transferFrom(_ctx: wasmlib.ScFuncCallContext): TransferFromCall { const f = new TransferFromCall(); f.params = new sc.MutableTransferFromParams(wasmlib.newCallParamsProxy(f.func)); return f; } - static allowance(ctx: wasmlib.ScViewCallContext): AllowanceCall { + static allowance(_ctx: wasmlib.ScViewCallContext): AllowanceCall { const f = new AllowanceCall(); f.params = new sc.MutableAllowanceParams(wasmlib.newCallParamsProxy(f.func)); f.results = new sc.ImmutableAllowanceResults(wasmlib.newCallResultsProxy(f.func)); return f; } - static balanceOf(ctx: wasmlib.ScViewCallContext): BalanceOfCall { + static balanceOf(_ctx: wasmlib.ScViewCallContext): BalanceOfCall { const f = new BalanceOfCall(); f.params = new sc.MutableBalanceOfParams(wasmlib.newCallParamsProxy(f.func)); f.results = new sc.ImmutableBalanceOfResults(wasmlib.newCallResultsProxy(f.func)); return f; } - static totalSupply(ctx: wasmlib.ScViewCallContext): TotalSupplyCall { + static totalSupply(_ctx: wasmlib.ScViewCallContext): TotalSupplyCall { const f = new TotalSupplyCall(); f.results = new sc.ImmutableTotalSupplyResults(wasmlib.newCallResultsProxy(f.func)); return f; diff --git a/contracts/wasm/erc20/ts/erc20/lib.ts b/contracts/wasm/erc20/ts/erc20/lib.ts index b1b0d22bd0..857f441e60 100644 --- a/contracts/wasm/erc20/ts/erc20/lib.ts +++ b/contracts/wasm/erc20/ts/erc20/lib.ts @@ -6,7 +6,6 @@ // Change the json schema instead import * as wasmlib from "wasmlib"; -import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; export function on_call(index: i32): void { diff --git a/contracts/wasm/erc20/ts/erc20/params.ts b/contracts/wasm/erc20/ts/erc20/params.ts index 6ec5bab74b..203ff173c1 100644 --- a/contracts/wasm/erc20/ts/erc20/params.ts +++ b/contracts/wasm/erc20/ts/erc20/params.ts @@ -5,7 +5,6 @@ // >>>> DO NOT CHANGE THIS FILE! <<<< // Change the json schema instead -import * as wasmlib from "wasmlib"; import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; diff --git a/contracts/wasm/erc20/ts/erc20/results.ts b/contracts/wasm/erc20/ts/erc20/results.ts index 98d97c9930..8e309e72da 100644 --- a/contracts/wasm/erc20/ts/erc20/results.ts +++ b/contracts/wasm/erc20/ts/erc20/results.ts @@ -5,7 +5,6 @@ // >>>> DO NOT CHANGE THIS FILE! <<<< // Change the json schema instead -import * as wasmlib from "wasmlib"; import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; diff --git a/contracts/wasm/erc20/ts/erc20/state.ts b/contracts/wasm/erc20/ts/erc20/state.ts index 4cd3a8dafc..3a4cf0c0a3 100644 --- a/contracts/wasm/erc20/ts/erc20/state.ts +++ b/contracts/wasm/erc20/ts/erc20/state.ts @@ -5,7 +5,6 @@ // >>>> DO NOT CHANGE THIS FILE! <<<< // Change the json schema instead -import * as wasmlib from "wasmlib"; import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; diff --git a/contracts/wasm/erc20/ts/erc20/typedefs.ts b/contracts/wasm/erc20/ts/erc20/typedefs.ts index 9daabad509..513753d4b7 100644 --- a/contracts/wasm/erc20/ts/erc20/typedefs.ts +++ b/contracts/wasm/erc20/ts/erc20/typedefs.ts @@ -5,7 +5,6 @@ // >>>> DO NOT CHANGE THIS FILE! <<<< // Change the json schema instead -import * as wasmlib from "wasmlib"; import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; @@ -17,7 +16,7 @@ export class MapAgentIDToImmutableUint64 extends wasmtypes.ScProxy { } export class ImmutableAllowancesForAgent extends MapAgentIDToImmutableUint64 { -}; +} export class MapAgentIDToMutableUint64 extends wasmtypes.ScProxy { @@ -31,4 +30,4 @@ export class MapAgentIDToMutableUint64 extends wasmtypes.ScProxy { } export class MutableAllowancesForAgent extends MapAgentIDToMutableUint64 { -}; +} diff --git a/contracts/wasm/erc721/ts/erc721/contract.ts b/contracts/wasm/erc721/ts/erc721/contract.ts index 26b5462bdc..af69e98b0d 100644 --- a/contracts/wasm/erc721/ts/erc721/contract.ts +++ b/contracts/wasm/erc721/ts/erc721/contract.ts @@ -6,7 +6,6 @@ // Change the json schema instead import * as wasmlib from "wasmlib"; -import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; export class ApproveCall { @@ -167,89 +166,89 @@ export class TokenURIContext { } export class ScFuncs { - static approve(ctx: wasmlib.ScFuncCallContext): ApproveCall { + static approve(_ctx: wasmlib.ScFuncCallContext): ApproveCall { const f = new ApproveCall(); f.params = new sc.MutableApproveParams(wasmlib.newCallParamsProxy(f.func)); return f; } - static burn(ctx: wasmlib.ScFuncCallContext): BurnCall { + static burn(_ctx: wasmlib.ScFuncCallContext): BurnCall { const f = new BurnCall(); f.params = new sc.MutableBurnParams(wasmlib.newCallParamsProxy(f.func)); return f; } - static init(ctx: wasmlib.ScFuncCallContext): InitCall { + static init(_ctx: wasmlib.ScFuncCallContext): InitCall { const f = new InitCall(); f.params = new sc.MutableInitParams(wasmlib.newCallParamsProxy(f.func)); return f; } - static mint(ctx: wasmlib.ScFuncCallContext): MintCall { + static mint(_ctx: wasmlib.ScFuncCallContext): MintCall { const f = new MintCall(); f.params = new sc.MutableMintParams(wasmlib.newCallParamsProxy(f.func)); return f; } - static safeTransferFrom(ctx: wasmlib.ScFuncCallContext): SafeTransferFromCall { + static safeTransferFrom(_ctx: wasmlib.ScFuncCallContext): SafeTransferFromCall { const f = new SafeTransferFromCall(); f.params = new sc.MutableSafeTransferFromParams(wasmlib.newCallParamsProxy(f.func)); return f; } - static setApprovalForAll(ctx: wasmlib.ScFuncCallContext): SetApprovalForAllCall { + static setApprovalForAll(_ctx: wasmlib.ScFuncCallContext): SetApprovalForAllCall { const f = new SetApprovalForAllCall(); f.params = new sc.MutableSetApprovalForAllParams(wasmlib.newCallParamsProxy(f.func)); return f; } - static transferFrom(ctx: wasmlib.ScFuncCallContext): TransferFromCall { + static transferFrom(_ctx: wasmlib.ScFuncCallContext): TransferFromCall { const f = new TransferFromCall(); f.params = new sc.MutableTransferFromParams(wasmlib.newCallParamsProxy(f.func)); return f; } - static balanceOf(ctx: wasmlib.ScViewCallContext): BalanceOfCall { + static balanceOf(_ctx: wasmlib.ScViewCallContext): BalanceOfCall { const f = new BalanceOfCall(); f.params = new sc.MutableBalanceOfParams(wasmlib.newCallParamsProxy(f.func)); f.results = new sc.ImmutableBalanceOfResults(wasmlib.newCallResultsProxy(f.func)); return f; } - static getApproved(ctx: wasmlib.ScViewCallContext): GetApprovedCall { + static getApproved(_ctx: wasmlib.ScViewCallContext): GetApprovedCall { const f = new GetApprovedCall(); f.params = new sc.MutableGetApprovedParams(wasmlib.newCallParamsProxy(f.func)); f.results = new sc.ImmutableGetApprovedResults(wasmlib.newCallResultsProxy(f.func)); return f; } - static isApprovedForAll(ctx: wasmlib.ScViewCallContext): IsApprovedForAllCall { + static isApprovedForAll(_ctx: wasmlib.ScViewCallContext): IsApprovedForAllCall { const f = new IsApprovedForAllCall(); f.params = new sc.MutableIsApprovedForAllParams(wasmlib.newCallParamsProxy(f.func)); f.results = new sc.ImmutableIsApprovedForAllResults(wasmlib.newCallResultsProxy(f.func)); return f; } - static name(ctx: wasmlib.ScViewCallContext): NameCall { + static name(_ctx: wasmlib.ScViewCallContext): NameCall { const f = new NameCall(); f.results = new sc.ImmutableNameResults(wasmlib.newCallResultsProxy(f.func)); return f; } - static ownerOf(ctx: wasmlib.ScViewCallContext): OwnerOfCall { + static ownerOf(_ctx: wasmlib.ScViewCallContext): OwnerOfCall { const f = new OwnerOfCall(); f.params = new sc.MutableOwnerOfParams(wasmlib.newCallParamsProxy(f.func)); f.results = new sc.ImmutableOwnerOfResults(wasmlib.newCallResultsProxy(f.func)); return f; } - static symbol(ctx: wasmlib.ScViewCallContext): SymbolCall { + static symbol(_ctx: wasmlib.ScViewCallContext): SymbolCall { const f = new SymbolCall(); f.results = new sc.ImmutableSymbolResults(wasmlib.newCallResultsProxy(f.func)); return f; } - static tokenURI(ctx: wasmlib.ScViewCallContext): TokenURICall { + static tokenURI(_ctx: wasmlib.ScViewCallContext): TokenURICall { const f = new TokenURICall(); f.params = new sc.MutableTokenURIParams(wasmlib.newCallParamsProxy(f.func)); f.results = new sc.ImmutableTokenURIResults(wasmlib.newCallResultsProxy(f.func)); diff --git a/contracts/wasm/erc721/ts/erc721/lib.ts b/contracts/wasm/erc721/ts/erc721/lib.ts index ba3529d2c3..bb89579df4 100644 --- a/contracts/wasm/erc721/ts/erc721/lib.ts +++ b/contracts/wasm/erc721/ts/erc721/lib.ts @@ -6,7 +6,6 @@ // Change the json schema instead import * as wasmlib from "wasmlib"; -import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; export function on_call(index: i32): void { diff --git a/contracts/wasm/erc721/ts/erc721/params.ts b/contracts/wasm/erc721/ts/erc721/params.ts index 436b9d3c76..caba1d5d53 100644 --- a/contracts/wasm/erc721/ts/erc721/params.ts +++ b/contracts/wasm/erc721/ts/erc721/params.ts @@ -5,7 +5,6 @@ // >>>> DO NOT CHANGE THIS FILE! <<<< // Change the json schema instead -import * as wasmlib from "wasmlib"; import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; diff --git a/contracts/wasm/erc721/ts/erc721/results.ts b/contracts/wasm/erc721/ts/erc721/results.ts index dc29deb69c..ce3772a182 100644 --- a/contracts/wasm/erc721/ts/erc721/results.ts +++ b/contracts/wasm/erc721/ts/erc721/results.ts @@ -5,7 +5,6 @@ // >>>> DO NOT CHANGE THIS FILE! <<<< // Change the json schema instead -import * as wasmlib from "wasmlib"; import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; diff --git a/contracts/wasm/erc721/ts/erc721/state.ts b/contracts/wasm/erc721/ts/erc721/state.ts index c92539f251..48b997c999 100644 --- a/contracts/wasm/erc721/ts/erc721/state.ts +++ b/contracts/wasm/erc721/ts/erc721/state.ts @@ -5,7 +5,6 @@ // >>>> DO NOT CHANGE THIS FILE! <<<< // Change the json schema instead -import * as wasmlib from "wasmlib"; import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; diff --git a/contracts/wasm/erc721/ts/erc721/typedefs.ts b/contracts/wasm/erc721/ts/erc721/typedefs.ts index 8248b4511f..16eb0d855b 100644 --- a/contracts/wasm/erc721/ts/erc721/typedefs.ts +++ b/contracts/wasm/erc721/ts/erc721/typedefs.ts @@ -5,7 +5,6 @@ // >>>> DO NOT CHANGE THIS FILE! <<<< // Change the json schema instead -import * as wasmlib from "wasmlib"; import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; @@ -17,7 +16,7 @@ export class MapAgentIDToImmutableBool extends wasmtypes.ScProxy { } export class ImmutableOperators extends MapAgentIDToImmutableBool { -}; +} export class MapAgentIDToMutableBool extends wasmtypes.ScProxy { @@ -31,4 +30,4 @@ export class MapAgentIDToMutableBool extends wasmtypes.ScProxy { } export class MutableOperators extends MapAgentIDToMutableBool { -}; +} diff --git a/contracts/wasm/fairauction/ts/fairauction/contract.ts b/contracts/wasm/fairauction/ts/fairauction/contract.ts index df5087c256..d7dfb45101 100644 --- a/contracts/wasm/fairauction/ts/fairauction/contract.ts +++ b/contracts/wasm/fairauction/ts/fairauction/contract.ts @@ -6,7 +6,6 @@ // Change the json schema instead import * as wasmlib from "wasmlib"; -import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; export class FinalizeAuctionCall { @@ -62,31 +61,31 @@ export class GetInfoContext { } export class ScFuncs { - static finalizeAuction(ctx: wasmlib.ScFuncCallContext): FinalizeAuctionCall { + static finalizeAuction(_ctx: wasmlib.ScFuncCallContext): FinalizeAuctionCall { const f = new FinalizeAuctionCall(); f.params = new sc.MutableFinalizeAuctionParams(wasmlib.newCallParamsProxy(f.func)); return f; } - static placeBid(ctx: wasmlib.ScFuncCallContext): PlaceBidCall { + static placeBid(_ctx: wasmlib.ScFuncCallContext): PlaceBidCall { const f = new PlaceBidCall(); f.params = new sc.MutablePlaceBidParams(wasmlib.newCallParamsProxy(f.func)); return f; } - static setOwnerMargin(ctx: wasmlib.ScFuncCallContext): SetOwnerMarginCall { + static setOwnerMargin(_ctx: wasmlib.ScFuncCallContext): SetOwnerMarginCall { const f = new SetOwnerMarginCall(); f.params = new sc.MutableSetOwnerMarginParams(wasmlib.newCallParamsProxy(f.func)); return f; } - static startAuction(ctx: wasmlib.ScFuncCallContext): StartAuctionCall { + static startAuction(_ctx: wasmlib.ScFuncCallContext): StartAuctionCall { const f = new StartAuctionCall(); f.params = new sc.MutableStartAuctionParams(wasmlib.newCallParamsProxy(f.func)); return f; } - static getInfo(ctx: wasmlib.ScViewCallContext): GetInfoCall { + static getInfo(_ctx: wasmlib.ScViewCallContext): GetInfoCall { const f = new GetInfoCall(); f.params = new sc.MutableGetInfoParams(wasmlib.newCallParamsProxy(f.func)); f.results = new sc.ImmutableGetInfoResults(wasmlib.newCallResultsProxy(f.func)); diff --git a/contracts/wasm/fairauction/ts/fairauction/lib.ts b/contracts/wasm/fairauction/ts/fairauction/lib.ts index 59e151bcda..4fc3d9145c 100644 --- a/contracts/wasm/fairauction/ts/fairauction/lib.ts +++ b/contracts/wasm/fairauction/ts/fairauction/lib.ts @@ -6,7 +6,6 @@ // Change the json schema instead import * as wasmlib from "wasmlib"; -import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; export function on_call(index: i32): void { diff --git a/contracts/wasm/fairauction/ts/fairauction/params.ts b/contracts/wasm/fairauction/ts/fairauction/params.ts index 72c8191161..376b21b44d 100644 --- a/contracts/wasm/fairauction/ts/fairauction/params.ts +++ b/contracts/wasm/fairauction/ts/fairauction/params.ts @@ -5,7 +5,6 @@ // >>>> DO NOT CHANGE THIS FILE! <<<< // Change the json schema instead -import * as wasmlib from "wasmlib"; import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; diff --git a/contracts/wasm/fairauction/ts/fairauction/results.ts b/contracts/wasm/fairauction/ts/fairauction/results.ts index 05e66d893b..9314f1c7eb 100644 --- a/contracts/wasm/fairauction/ts/fairauction/results.ts +++ b/contracts/wasm/fairauction/ts/fairauction/results.ts @@ -5,7 +5,6 @@ // >>>> DO NOT CHANGE THIS FILE! <<<< // Change the json schema instead -import * as wasmlib from "wasmlib"; import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; diff --git a/contracts/wasm/fairauction/ts/fairauction/state.ts b/contracts/wasm/fairauction/ts/fairauction/state.ts index 1942ba6ff2..11069e4ada 100644 --- a/contracts/wasm/fairauction/ts/fairauction/state.ts +++ b/contracts/wasm/fairauction/ts/fairauction/state.ts @@ -5,7 +5,6 @@ // >>>> DO NOT CHANGE THIS FILE! <<<< // Change the json schema instead -import * as wasmlib from "wasmlib"; import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; diff --git a/contracts/wasm/fairauction/ts/fairauction/structs.ts b/contracts/wasm/fairauction/ts/fairauction/structs.ts index 484db9e693..0e59cfe67c 100644 --- a/contracts/wasm/fairauction/ts/fairauction/structs.ts +++ b/contracts/wasm/fairauction/ts/fairauction/structs.ts @@ -5,7 +5,6 @@ // >>>> DO NOT CHANGE THIS FILE! <<<< // Change the json schema instead -import * as wasmlib from "wasmlib"; import * as wasmtypes from "wasmlib/wasmtypes"; export class Auction { diff --git a/contracts/wasm/fairauction/ts/fairauction/typedefs.ts b/contracts/wasm/fairauction/ts/fairauction/typedefs.ts index 4c1da8a0b7..eaf757bec0 100644 --- a/contracts/wasm/fairauction/ts/fairauction/typedefs.ts +++ b/contracts/wasm/fairauction/ts/fairauction/typedefs.ts @@ -5,7 +5,6 @@ // >>>> DO NOT CHANGE THIS FILE! <<<< // Change the json schema instead -import * as wasmlib from "wasmlib"; import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; @@ -21,7 +20,7 @@ export class ArrayOfImmutableAgentID extends wasmtypes.ScProxy { } export class ImmutableBidderList extends ArrayOfImmutableAgentID { -}; +} export class ArrayOfMutableAgentID extends wasmtypes.ScProxy { @@ -43,7 +42,7 @@ export class ArrayOfMutableAgentID extends wasmtypes.ScProxy { } export class MutableBidderList extends ArrayOfMutableAgentID { -}; +} export class MapAgentIDToImmutableBid extends wasmtypes.ScProxy { @@ -53,7 +52,7 @@ export class MapAgentIDToImmutableBid extends wasmtypes.ScProxy { } export class ImmutableBids extends MapAgentIDToImmutableBid { -}; +} export class MapAgentIDToMutableBid extends wasmtypes.ScProxy { @@ -67,4 +66,4 @@ export class MapAgentIDToMutableBid extends wasmtypes.ScProxy { } export class MutableBids extends MapAgentIDToMutableBid { -}; +} diff --git a/contracts/wasm/fairroulette/ts/fairroulette/contract.ts b/contracts/wasm/fairroulette/ts/fairroulette/contract.ts index 6dc14c6451..fb02a8c93f 100644 --- a/contracts/wasm/fairroulette/ts/fairroulette/contract.ts +++ b/contracts/wasm/fairroulette/ts/fairroulette/contract.ts @@ -6,7 +6,6 @@ // Change the json schema instead import * as wasmlib from "wasmlib"; -import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; export class ForcePayoutCall { @@ -99,49 +98,49 @@ export class RoundStatusContext { } export class ScFuncs { - static forcePayout(ctx: wasmlib.ScFuncCallContext): ForcePayoutCall { + static forcePayout(_ctx: wasmlib.ScFuncCallContext): ForcePayoutCall { return new ForcePayoutCall(); } - static forceReset(ctx: wasmlib.ScFuncCallContext): ForceResetCall { + static forceReset(_ctx: wasmlib.ScFuncCallContext): ForceResetCall { return new ForceResetCall(); } - static payWinners(ctx: wasmlib.ScFuncCallContext): PayWinnersCall { + static payWinners(_ctx: wasmlib.ScFuncCallContext): PayWinnersCall { return new PayWinnersCall(); } - static placeBet(ctx: wasmlib.ScFuncCallContext): PlaceBetCall { + static placeBet(_ctx: wasmlib.ScFuncCallContext): PlaceBetCall { const f = new PlaceBetCall(); f.params = new sc.MutablePlaceBetParams(wasmlib.newCallParamsProxy(f.func)); return f; } - static playPeriod(ctx: wasmlib.ScFuncCallContext): PlayPeriodCall { + static playPeriod(_ctx: wasmlib.ScFuncCallContext): PlayPeriodCall { const f = new PlayPeriodCall(); f.params = new sc.MutablePlayPeriodParams(wasmlib.newCallParamsProxy(f.func)); return f; } - static lastWinningNumber(ctx: wasmlib.ScViewCallContext): LastWinningNumberCall { + static lastWinningNumber(_ctx: wasmlib.ScViewCallContext): LastWinningNumberCall { const f = new LastWinningNumberCall(); f.results = new sc.ImmutableLastWinningNumberResults(wasmlib.newCallResultsProxy(f.func)); return f; } - static roundNumber(ctx: wasmlib.ScViewCallContext): RoundNumberCall { + static roundNumber(_ctx: wasmlib.ScViewCallContext): RoundNumberCall { const f = new RoundNumberCall(); f.results = new sc.ImmutableRoundNumberResults(wasmlib.newCallResultsProxy(f.func)); return f; } - static roundStartedAt(ctx: wasmlib.ScViewCallContext): RoundStartedAtCall { + static roundStartedAt(_ctx: wasmlib.ScViewCallContext): RoundStartedAtCall { const f = new RoundStartedAtCall(); f.results = new sc.ImmutableRoundStartedAtResults(wasmlib.newCallResultsProxy(f.func)); return f; } - static roundStatus(ctx: wasmlib.ScViewCallContext): RoundStatusCall { + static roundStatus(_ctx: wasmlib.ScViewCallContext): RoundStatusCall { const f = new RoundStatusCall(); f.results = new sc.ImmutableRoundStatusResults(wasmlib.newCallResultsProxy(f.func)); return f; diff --git a/contracts/wasm/fairroulette/ts/fairroulette/lib.ts b/contracts/wasm/fairroulette/ts/fairroulette/lib.ts index 744c8d2c39..c0f4cd9979 100644 --- a/contracts/wasm/fairroulette/ts/fairroulette/lib.ts +++ b/contracts/wasm/fairroulette/ts/fairroulette/lib.ts @@ -6,7 +6,6 @@ // Change the json schema instead import * as wasmlib from "wasmlib"; -import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; export function on_call(index: i32): void { diff --git a/contracts/wasm/fairroulette/ts/fairroulette/params.ts b/contracts/wasm/fairroulette/ts/fairroulette/params.ts index 027f894572..6681aabf17 100644 --- a/contracts/wasm/fairroulette/ts/fairroulette/params.ts +++ b/contracts/wasm/fairroulette/ts/fairroulette/params.ts @@ -5,7 +5,6 @@ // >>>> DO NOT CHANGE THIS FILE! <<<< // Change the json schema instead -import * as wasmlib from "wasmlib"; import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; diff --git a/contracts/wasm/fairroulette/ts/fairroulette/results.ts b/contracts/wasm/fairroulette/ts/fairroulette/results.ts index 8fe98adab7..b54675f8ae 100644 --- a/contracts/wasm/fairroulette/ts/fairroulette/results.ts +++ b/contracts/wasm/fairroulette/ts/fairroulette/results.ts @@ -5,7 +5,6 @@ // >>>> DO NOT CHANGE THIS FILE! <<<< // Change the json schema instead -import * as wasmlib from "wasmlib"; import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; diff --git a/contracts/wasm/fairroulette/ts/fairroulette/state.ts b/contracts/wasm/fairroulette/ts/fairroulette/state.ts index 29f44c82ae..f246191694 100644 --- a/contracts/wasm/fairroulette/ts/fairroulette/state.ts +++ b/contracts/wasm/fairroulette/ts/fairroulette/state.ts @@ -5,7 +5,6 @@ // >>>> DO NOT CHANGE THIS FILE! <<<< // Change the json schema instead -import * as wasmlib from "wasmlib"; import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; diff --git a/contracts/wasm/fairroulette/ts/fairroulette/structs.ts b/contracts/wasm/fairroulette/ts/fairroulette/structs.ts index c58ebb04a9..71277e99a0 100644 --- a/contracts/wasm/fairroulette/ts/fairroulette/structs.ts +++ b/contracts/wasm/fairroulette/ts/fairroulette/structs.ts @@ -5,7 +5,6 @@ // >>>> DO NOT CHANGE THIS FILE! <<<< // Change the json schema instead -import * as wasmlib from "wasmlib"; import * as wasmtypes from "wasmlib/wasmtypes"; export class Bet { diff --git a/contracts/wasm/helloworld/ts/helloworld/contract.ts b/contracts/wasm/helloworld/ts/helloworld/contract.ts index 686743fdc8..f9fdad2a3c 100644 --- a/contracts/wasm/helloworld/ts/helloworld/contract.ts +++ b/contracts/wasm/helloworld/ts/helloworld/contract.ts @@ -6,7 +6,6 @@ // Change the json schema instead import * as wasmlib from "wasmlib"; -import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; export class HelloWorldCall { @@ -28,11 +27,11 @@ export class GetHelloWorldContext { } export class ScFuncs { - static helloWorld(ctx: wasmlib.ScFuncCallContext): HelloWorldCall { + static helloWorld(_ctx: wasmlib.ScFuncCallContext): HelloWorldCall { return new HelloWorldCall(); } - static getHelloWorld(ctx: wasmlib.ScViewCallContext): GetHelloWorldCall { + static getHelloWorld(_ctx: wasmlib.ScViewCallContext): GetHelloWorldCall { const f = new GetHelloWorldCall(); f.results = new sc.ImmutableGetHelloWorldResults(wasmlib.newCallResultsProxy(f.func)); return f; diff --git a/contracts/wasm/helloworld/ts/helloworld/lib.ts b/contracts/wasm/helloworld/ts/helloworld/lib.ts index 8233f26911..83e228fe2b 100644 --- a/contracts/wasm/helloworld/ts/helloworld/lib.ts +++ b/contracts/wasm/helloworld/ts/helloworld/lib.ts @@ -6,7 +6,6 @@ // Change the json schema instead import * as wasmlib from "wasmlib"; -import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; export function on_call(index: i32): void { diff --git a/contracts/wasm/helloworld/ts/helloworld/results.ts b/contracts/wasm/helloworld/ts/helloworld/results.ts index dd49d1b081..1044c7584f 100644 --- a/contracts/wasm/helloworld/ts/helloworld/results.ts +++ b/contracts/wasm/helloworld/ts/helloworld/results.ts @@ -5,7 +5,6 @@ // >>>> DO NOT CHANGE THIS FILE! <<<< // Change the json schema instead -import * as wasmlib from "wasmlib"; import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; diff --git a/contracts/wasm/helloworld/ts/helloworld/state.ts b/contracts/wasm/helloworld/ts/helloworld/state.ts index 7f7c3807fe..b8e6c0aabe 100644 --- a/contracts/wasm/helloworld/ts/helloworld/state.ts +++ b/contracts/wasm/helloworld/ts/helloworld/state.ts @@ -5,7 +5,6 @@ // >>>> DO NOT CHANGE THIS FILE! <<<< // Change the json schema instead -import * as wasmlib from "wasmlib"; import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; diff --git a/contracts/wasm/inccounter/ts/inccounter/contract.ts b/contracts/wasm/inccounter/ts/inccounter/contract.ts index c780921434..03727f0179 100644 --- a/contracts/wasm/inccounter/ts/inccounter/contract.ts +++ b/contracts/wasm/inccounter/ts/inccounter/contract.ts @@ -6,7 +6,6 @@ // Change the json schema instead import * as wasmlib from "wasmlib"; -import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; export class CallIncrementCall { @@ -164,84 +163,84 @@ export class GetVluContext { } export class ScFuncs { - static callIncrement(ctx: wasmlib.ScFuncCallContext): CallIncrementCall { + static callIncrement(_ctx: wasmlib.ScFuncCallContext): CallIncrementCall { return new CallIncrementCall(); } - static callIncrementRecurse5x(ctx: wasmlib.ScFuncCallContext): CallIncrementRecurse5xCall { + static callIncrementRecurse5x(_ctx: wasmlib.ScFuncCallContext): CallIncrementRecurse5xCall { return new CallIncrementRecurse5xCall(); } - static endlessLoop(ctx: wasmlib.ScFuncCallContext): EndlessLoopCall { + static endlessLoop(_ctx: wasmlib.ScFuncCallContext): EndlessLoopCall { return new EndlessLoopCall(); } - static increment(ctx: wasmlib.ScFuncCallContext): IncrementCall { + static increment(_ctx: wasmlib.ScFuncCallContext): IncrementCall { return new IncrementCall(); } - static incrementWithDelay(ctx: wasmlib.ScFuncCallContext): IncrementWithDelayCall { + static incrementWithDelay(_ctx: wasmlib.ScFuncCallContext): IncrementWithDelayCall { const f = new IncrementWithDelayCall(); f.params = new sc.MutableIncrementWithDelayParams(wasmlib.newCallParamsProxy(f.func)); return f; } - static init(ctx: wasmlib.ScFuncCallContext): InitCall { + static init(_ctx: wasmlib.ScFuncCallContext): InitCall { const f = new InitCall(); f.params = new sc.MutableInitParams(wasmlib.newCallParamsProxy(f.func)); return f; } - static localStateInternalCall(ctx: wasmlib.ScFuncCallContext): LocalStateInternalCallCall { + static localStateInternalCall(_ctx: wasmlib.ScFuncCallContext): LocalStateInternalCallCall { return new LocalStateInternalCallCall(); } - static localStatePost(ctx: wasmlib.ScFuncCallContext): LocalStatePostCall { + static localStatePost(_ctx: wasmlib.ScFuncCallContext): LocalStatePostCall { return new LocalStatePostCall(); } - static localStateSandboxCall(ctx: wasmlib.ScFuncCallContext): LocalStateSandboxCallCall { + static localStateSandboxCall(_ctx: wasmlib.ScFuncCallContext): LocalStateSandboxCallCall { return new LocalStateSandboxCallCall(); } - static postIncrement(ctx: wasmlib.ScFuncCallContext): PostIncrementCall { + static postIncrement(_ctx: wasmlib.ScFuncCallContext): PostIncrementCall { return new PostIncrementCall(); } - static repeatMany(ctx: wasmlib.ScFuncCallContext): RepeatManyCall { + static repeatMany(_ctx: wasmlib.ScFuncCallContext): RepeatManyCall { const f = new RepeatManyCall(); f.params = new sc.MutableRepeatManyParams(wasmlib.newCallParamsProxy(f.func)); return f; } - static testVliCodec(ctx: wasmlib.ScFuncCallContext): TestVliCodecCall { + static testVliCodec(_ctx: wasmlib.ScFuncCallContext): TestVliCodecCall { return new TestVliCodecCall(); } - static testVluCodec(ctx: wasmlib.ScFuncCallContext): TestVluCodecCall { + static testVluCodec(_ctx: wasmlib.ScFuncCallContext): TestVluCodecCall { return new TestVluCodecCall(); } - static whenMustIncrement(ctx: wasmlib.ScFuncCallContext): WhenMustIncrementCall { + static whenMustIncrement(_ctx: wasmlib.ScFuncCallContext): WhenMustIncrementCall { const f = new WhenMustIncrementCall(); f.params = new sc.MutableWhenMustIncrementParams(wasmlib.newCallParamsProxy(f.func)); return f; } - static getCounter(ctx: wasmlib.ScViewCallContext): GetCounterCall { + static getCounter(_ctx: wasmlib.ScViewCallContext): GetCounterCall { const f = new GetCounterCall(); f.results = new sc.ImmutableGetCounterResults(wasmlib.newCallResultsProxy(f.func)); return f; } - static getVli(ctx: wasmlib.ScViewCallContext): GetVliCall { + static getVli(_ctx: wasmlib.ScViewCallContext): GetVliCall { const f = new GetVliCall(); f.params = new sc.MutableGetVliParams(wasmlib.newCallParamsProxy(f.func)); f.results = new sc.ImmutableGetVliResults(wasmlib.newCallResultsProxy(f.func)); return f; } - static getVlu(ctx: wasmlib.ScViewCallContext): GetVluCall { + static getVlu(_ctx: wasmlib.ScViewCallContext): GetVluCall { const f = new GetVluCall(); f.params = new sc.MutableGetVluParams(wasmlib.newCallParamsProxy(f.func)); f.results = new sc.ImmutableGetVluResults(wasmlib.newCallResultsProxy(f.func)); diff --git a/contracts/wasm/inccounter/ts/inccounter/lib.ts b/contracts/wasm/inccounter/ts/inccounter/lib.ts index 921b434d3f..1e38cba122 100644 --- a/contracts/wasm/inccounter/ts/inccounter/lib.ts +++ b/contracts/wasm/inccounter/ts/inccounter/lib.ts @@ -6,7 +6,6 @@ // Change the json schema instead import * as wasmlib from "wasmlib"; -import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; export function on_call(index: i32): void { diff --git a/contracts/wasm/inccounter/ts/inccounter/params.ts b/contracts/wasm/inccounter/ts/inccounter/params.ts index 4848b39f5b..6afc496e27 100644 --- a/contracts/wasm/inccounter/ts/inccounter/params.ts +++ b/contracts/wasm/inccounter/ts/inccounter/params.ts @@ -5,7 +5,6 @@ // >>>> DO NOT CHANGE THIS FILE! <<<< // Change the json schema instead -import * as wasmlib from "wasmlib"; import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; diff --git a/contracts/wasm/inccounter/ts/inccounter/results.ts b/contracts/wasm/inccounter/ts/inccounter/results.ts index 4900372c82..2a8ab12875 100644 --- a/contracts/wasm/inccounter/ts/inccounter/results.ts +++ b/contracts/wasm/inccounter/ts/inccounter/results.ts @@ -5,7 +5,6 @@ // >>>> DO NOT CHANGE THIS FILE! <<<< // Change the json schema instead -import * as wasmlib from "wasmlib"; import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; diff --git a/contracts/wasm/inccounter/ts/inccounter/state.ts b/contracts/wasm/inccounter/ts/inccounter/state.ts index 4e824c41d8..d2d8a7c161 100644 --- a/contracts/wasm/inccounter/ts/inccounter/state.ts +++ b/contracts/wasm/inccounter/ts/inccounter/state.ts @@ -5,7 +5,6 @@ // >>>> DO NOT CHANGE THIS FILE! <<<< // Change the json schema instead -import * as wasmlib from "wasmlib"; import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; diff --git a/contracts/wasm/testcore/ts/testcore/contract.ts b/contracts/wasm/testcore/ts/testcore/contract.ts index ef57c564f3..68087ce909 100644 --- a/contracts/wasm/testcore/ts/testcore/contract.ts +++ b/contracts/wasm/testcore/ts/testcore/contract.ts @@ -6,7 +6,6 @@ // Change the json schema instead import * as wasmlib from "wasmlib"; -import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; export class CallOnChainCall { @@ -316,174 +315,174 @@ export class TestSandboxCallContext { } export class ScFuncs { - static callOnChain(ctx: wasmlib.ScFuncCallContext): CallOnChainCall { + static callOnChain(_ctx: wasmlib.ScFuncCallContext): CallOnChainCall { const f = new CallOnChainCall(); f.params = new sc.MutableCallOnChainParams(wasmlib.newCallParamsProxy(f.func)); f.results = new sc.ImmutableCallOnChainResults(wasmlib.newCallResultsProxy(f.func)); return f; } - static checkContextFromFullEP(ctx: wasmlib.ScFuncCallContext): CheckContextFromFullEPCall { + static checkContextFromFullEP(_ctx: wasmlib.ScFuncCallContext): CheckContextFromFullEPCall { const f = new CheckContextFromFullEPCall(); f.params = new sc.MutableCheckContextFromFullEPParams(wasmlib.newCallParamsProxy(f.func)); return f; } - static doNothing(ctx: wasmlib.ScFuncCallContext): DoNothingCall { + static doNothing(_ctx: wasmlib.ScFuncCallContext): DoNothingCall { return new DoNothingCall(); } - static getMintedSupply(ctx: wasmlib.ScFuncCallContext): GetMintedSupplyCall { + static getMintedSupply(_ctx: wasmlib.ScFuncCallContext): GetMintedSupplyCall { const f = new GetMintedSupplyCall(); f.results = new sc.ImmutableGetMintedSupplyResults(wasmlib.newCallResultsProxy(f.func)); return f; } - static incCounter(ctx: wasmlib.ScFuncCallContext): IncCounterCall { + static incCounter(_ctx: wasmlib.ScFuncCallContext): IncCounterCall { return new IncCounterCall(); } - static init(ctx: wasmlib.ScFuncCallContext): InitCall { + static init(_ctx: wasmlib.ScFuncCallContext): InitCall { const f = new InitCall(); f.params = new sc.MutableInitParams(wasmlib.newCallParamsProxy(f.func)); return f; } - static passTypesFull(ctx: wasmlib.ScFuncCallContext): PassTypesFullCall { + static passTypesFull(_ctx: wasmlib.ScFuncCallContext): PassTypesFullCall { const f = new PassTypesFullCall(); f.params = new sc.MutablePassTypesFullParams(wasmlib.newCallParamsProxy(f.func)); return f; } - static runRecursion(ctx: wasmlib.ScFuncCallContext): RunRecursionCall { + static runRecursion(_ctx: wasmlib.ScFuncCallContext): RunRecursionCall { const f = new RunRecursionCall(); f.params = new sc.MutableRunRecursionParams(wasmlib.newCallParamsProxy(f.func)); f.results = new sc.ImmutableRunRecursionResults(wasmlib.newCallResultsProxy(f.func)); return f; } - static sendToAddress(ctx: wasmlib.ScFuncCallContext): SendToAddressCall { + static sendToAddress(_ctx: wasmlib.ScFuncCallContext): SendToAddressCall { const f = new SendToAddressCall(); f.params = new sc.MutableSendToAddressParams(wasmlib.newCallParamsProxy(f.func)); return f; } - static setInt(ctx: wasmlib.ScFuncCallContext): SetIntCall { + static setInt(_ctx: wasmlib.ScFuncCallContext): SetIntCall { const f = new SetIntCall(); f.params = new sc.MutableSetIntParams(wasmlib.newCallParamsProxy(f.func)); return f; } - static spawn(ctx: wasmlib.ScFuncCallContext): SpawnCall { + static spawn(_ctx: wasmlib.ScFuncCallContext): SpawnCall { const f = new SpawnCall(); f.params = new sc.MutableSpawnParams(wasmlib.newCallParamsProxy(f.func)); return f; } - static testBlockContext1(ctx: wasmlib.ScFuncCallContext): TestBlockContext1Call { + static testBlockContext1(_ctx: wasmlib.ScFuncCallContext): TestBlockContext1Call { return new TestBlockContext1Call(); } - static testBlockContext2(ctx: wasmlib.ScFuncCallContext): TestBlockContext2Call { + static testBlockContext2(_ctx: wasmlib.ScFuncCallContext): TestBlockContext2Call { return new TestBlockContext2Call(); } - static testCallPanicFullEP(ctx: wasmlib.ScFuncCallContext): TestCallPanicFullEPCall { + static testCallPanicFullEP(_ctx: wasmlib.ScFuncCallContext): TestCallPanicFullEPCall { return new TestCallPanicFullEPCall(); } - static testCallPanicViewEPFromFull(ctx: wasmlib.ScFuncCallContext): TestCallPanicViewEPFromFullCall { + static testCallPanicViewEPFromFull(_ctx: wasmlib.ScFuncCallContext): TestCallPanicViewEPFromFullCall { return new TestCallPanicViewEPFromFullCall(); } - static testChainOwnerIDFull(ctx: wasmlib.ScFuncCallContext): TestChainOwnerIDFullCall { + static testChainOwnerIDFull(_ctx: wasmlib.ScFuncCallContext): TestChainOwnerIDFullCall { const f = new TestChainOwnerIDFullCall(); f.results = new sc.ImmutableTestChainOwnerIDFullResults(wasmlib.newCallResultsProxy(f.func)); return f; } - static testEventLogDeploy(ctx: wasmlib.ScFuncCallContext): TestEventLogDeployCall { + static testEventLogDeploy(_ctx: wasmlib.ScFuncCallContext): TestEventLogDeployCall { return new TestEventLogDeployCall(); } - static testEventLogEventData(ctx: wasmlib.ScFuncCallContext): TestEventLogEventDataCall { + static testEventLogEventData(_ctx: wasmlib.ScFuncCallContext): TestEventLogEventDataCall { return new TestEventLogEventDataCall(); } - static testEventLogGenericData(ctx: wasmlib.ScFuncCallContext): TestEventLogGenericDataCall { + static testEventLogGenericData(_ctx: wasmlib.ScFuncCallContext): TestEventLogGenericDataCall { const f = new TestEventLogGenericDataCall(); f.params = new sc.MutableTestEventLogGenericDataParams(wasmlib.newCallParamsProxy(f.func)); return f; } - static testPanicFullEP(ctx: wasmlib.ScFuncCallContext): TestPanicFullEPCall { + static testPanicFullEP(_ctx: wasmlib.ScFuncCallContext): TestPanicFullEPCall { return new TestPanicFullEPCall(); } - static withdrawToChain(ctx: wasmlib.ScFuncCallContext): WithdrawToChainCall { + static withdrawToChain(_ctx: wasmlib.ScFuncCallContext): WithdrawToChainCall { const f = new WithdrawToChainCall(); f.params = new sc.MutableWithdrawToChainParams(wasmlib.newCallParamsProxy(f.func)); return f; } - static checkContextFromViewEP(ctx: wasmlib.ScViewCallContext): CheckContextFromViewEPCall { + static checkContextFromViewEP(_ctx: wasmlib.ScViewCallContext): CheckContextFromViewEPCall { const f = new CheckContextFromViewEPCall(); f.params = new sc.MutableCheckContextFromViewEPParams(wasmlib.newCallParamsProxy(f.func)); return f; } - static fibonacci(ctx: wasmlib.ScViewCallContext): FibonacciCall { + static fibonacci(_ctx: wasmlib.ScViewCallContext): FibonacciCall { const f = new FibonacciCall(); f.params = new sc.MutableFibonacciParams(wasmlib.newCallParamsProxy(f.func)); f.results = new sc.ImmutableFibonacciResults(wasmlib.newCallResultsProxy(f.func)); return f; } - static getCounter(ctx: wasmlib.ScViewCallContext): GetCounterCall { + static getCounter(_ctx: wasmlib.ScViewCallContext): GetCounterCall { const f = new GetCounterCall(); f.results = new sc.ImmutableGetCounterResults(wasmlib.newCallResultsProxy(f.func)); return f; } - static getInt(ctx: wasmlib.ScViewCallContext): GetIntCall { + static getInt(_ctx: wasmlib.ScViewCallContext): GetIntCall { const f = new GetIntCall(); f.params = new sc.MutableGetIntParams(wasmlib.newCallParamsProxy(f.func)); f.results = new sc.ImmutableGetIntResults(wasmlib.newCallResultsProxy(f.func)); return f; } - static getStringValue(ctx: wasmlib.ScViewCallContext): GetStringValueCall { + static getStringValue(_ctx: wasmlib.ScViewCallContext): GetStringValueCall { const f = new GetStringValueCall(); f.params = new sc.MutableGetStringValueParams(wasmlib.newCallParamsProxy(f.func)); f.results = new sc.ImmutableGetStringValueResults(wasmlib.newCallResultsProxy(f.func)); return f; } - static justView(ctx: wasmlib.ScViewCallContext): JustViewCall { + static justView(_ctx: wasmlib.ScViewCallContext): JustViewCall { return new JustViewCall(); } - static passTypesView(ctx: wasmlib.ScViewCallContext): PassTypesViewCall { + static passTypesView(_ctx: wasmlib.ScViewCallContext): PassTypesViewCall { const f = new PassTypesViewCall(); f.params = new sc.MutablePassTypesViewParams(wasmlib.newCallParamsProxy(f.func)); return f; } - static testCallPanicViewEPFromView(ctx: wasmlib.ScViewCallContext): TestCallPanicViewEPFromViewCall { + static testCallPanicViewEPFromView(_ctx: wasmlib.ScViewCallContext): TestCallPanicViewEPFromViewCall { return new TestCallPanicViewEPFromViewCall(); } - static testChainOwnerIDView(ctx: wasmlib.ScViewCallContext): TestChainOwnerIDViewCall { + static testChainOwnerIDView(_ctx: wasmlib.ScViewCallContext): TestChainOwnerIDViewCall { const f = new TestChainOwnerIDViewCall(); f.results = new sc.ImmutableTestChainOwnerIDViewResults(wasmlib.newCallResultsProxy(f.func)); return f; } - static testPanicViewEP(ctx: wasmlib.ScViewCallContext): TestPanicViewEPCall { + static testPanicViewEP(_ctx: wasmlib.ScViewCallContext): TestPanicViewEPCall { return new TestPanicViewEPCall(); } - static testSandboxCall(ctx: wasmlib.ScViewCallContext): TestSandboxCallCall { + static testSandboxCall(_ctx: wasmlib.ScViewCallContext): TestSandboxCallCall { const f = new TestSandboxCallCall(); f.results = new sc.ImmutableTestSandboxCallResults(wasmlib.newCallResultsProxy(f.func)); return f; diff --git a/contracts/wasm/testcore/ts/testcore/lib.ts b/contracts/wasm/testcore/ts/testcore/lib.ts index b1fdf1995d..7b191ff568 100644 --- a/contracts/wasm/testcore/ts/testcore/lib.ts +++ b/contracts/wasm/testcore/ts/testcore/lib.ts @@ -6,7 +6,6 @@ // Change the json schema instead import * as wasmlib from "wasmlib"; -import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; export function on_call(index: i32): void { diff --git a/contracts/wasm/testcore/ts/testcore/params.ts b/contracts/wasm/testcore/ts/testcore/params.ts index 721ffa2bb8..dc037e601f 100644 --- a/contracts/wasm/testcore/ts/testcore/params.ts +++ b/contracts/wasm/testcore/ts/testcore/params.ts @@ -5,7 +5,6 @@ // >>>> DO NOT CHANGE THIS FILE! <<<< // Change the json schema instead -import * as wasmlib from "wasmlib"; import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; diff --git a/contracts/wasm/testcore/ts/testcore/results.ts b/contracts/wasm/testcore/ts/testcore/results.ts index c4ca687a3b..20a8260ff2 100644 --- a/contracts/wasm/testcore/ts/testcore/results.ts +++ b/contracts/wasm/testcore/ts/testcore/results.ts @@ -5,7 +5,6 @@ // >>>> DO NOT CHANGE THIS FILE! <<<< // Change the json schema instead -import * as wasmlib from "wasmlib"; import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; diff --git a/contracts/wasm/testcore/ts/testcore/state.ts b/contracts/wasm/testcore/ts/testcore/state.ts index 8e60c99562..ffcc2860d7 100644 --- a/contracts/wasm/testcore/ts/testcore/state.ts +++ b/contracts/wasm/testcore/ts/testcore/state.ts @@ -5,7 +5,6 @@ // >>>> DO NOT CHANGE THIS FILE! <<<< // Change the json schema instead -import * as wasmlib from "wasmlib"; import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; diff --git a/contracts/wasm/testwasmlib/src/structs.rs b/contracts/wasm/testwasmlib/src/structs.rs deleted file mode 100644 index 0166c45640..0000000000 --- a/contracts/wasm/testwasmlib/src/structs.rs +++ /dev/null @@ -1,289 +0,0 @@ -// Copyright 2020 IOTA Stiftung -// SPDX-License-Identifier: Apache-2.0 - -// (Re-)generated by schema tool -// >>>> DO NOT CHANGE THIS FILE! <<<< -// Change the json schema instead - -#![allow(dead_code)] -#![allow(unused_imports)] - -use wasmlib::*; -use wasmlib::host::*; -use crate::typedefs::*; - -#[derive(Clone)] -pub struct CallRequest { - pub contract : ScHname, - pub function : ScHname, - pub params : , - pub transfer : , -} - -impl CallRequest { - pub fn from_bytes(bytes: &[u8]) -> CallRequest { - let mut decode = BytesDecoder::new(bytes); - CallRequest { - contract : decode.hname(), - function : decode.hname(), - params : decode.bytes(), - transfer : decode.bytes(), - } - } - - pub fn to_bytes(&self) -> Vec { - let mut encode = BytesEncoder::new(); - encode.hname(self.contract); - encode.hname(self.function); - encode.bytes(self.params); - encode.bytes(self.transfer); - return encode.data(); - } -} - -#[derive(Clone, Copy)] -pub struct ImmutableCallRequest { - pub(crate) obj_id: i32, - pub(crate) key_id: Key32, -} - -impl ImmutableCallRequest { - pub fn exists(&self) -> bool { - exists(self.obj_id, self.key_id, TYPE_BYTES) - } - - pub fn value(&self) -> CallRequest { - CallRequest::from_bytes(&get_bytes(self.obj_id, self.key_id, TYPE_BYTES)) - } -} - -#[derive(Clone, Copy)] -pub struct MutableCallRequest { - pub(crate) obj_id: i32, - pub(crate) key_id: Key32, -} - -impl MutableCallRequest { - pub fn delete(&self) { - del_key(self.obj_id, self.key_id, TYPE_BYTES); - } - - pub fn exists(&self) -> bool { - exists(self.obj_id, self.key_id, TYPE_BYTES) - } - - pub fn set_value(&self, value: &CallRequest) { - set_bytes(self.obj_id, self.key_id, TYPE_BYTES, &value.to_bytes()); - } - - pub fn value(&self) -> CallRequest { - CallRequest::from_bytes(&get_bytes(self.obj_id, self.key_id, TYPE_BYTES)) - } -} - -#[derive(Clone)] -pub struct DeployRequest { - pub description : String, - pub name : String, - pub params : , - pub prog_hash : ScHash, -} - -impl DeployRequest { - pub fn from_bytes(bytes: &[u8]) -> DeployRequest { - let mut decode = BytesDecoder::new(bytes); - DeployRequest { - description : decode.string(), - name : decode.string(), - params : decode.bytes(), - prog_hash : decode.hash(), - } - } - - pub fn to_bytes(&self) -> Vec { - let mut encode = BytesEncoder::new(); - encode.string(&self.description); - encode.string(&self.name); - encode.bytes(self.params); - encode.hash(&self.prog_hash); - return encode.data(); - } -} - -#[derive(Clone, Copy)] -pub struct ImmutableDeployRequest { - pub(crate) obj_id: i32, - pub(crate) key_id: Key32, -} - -impl ImmutableDeployRequest { - pub fn exists(&self) -> bool { - exists(self.obj_id, self.key_id, TYPE_BYTES) - } - - pub fn value(&self) -> DeployRequest { - DeployRequest::from_bytes(&get_bytes(self.obj_id, self.key_id, TYPE_BYTES)) - } -} - -#[derive(Clone, Copy)] -pub struct MutableDeployRequest { - pub(crate) obj_id: i32, - pub(crate) key_id: Key32, -} - -impl MutableDeployRequest { - pub fn delete(&self) { - del_key(self.obj_id, self.key_id, TYPE_BYTES); - } - - pub fn exists(&self) -> bool { - exists(self.obj_id, self.key_id, TYPE_BYTES) - } - - pub fn set_value(&self, value: &DeployRequest) { - set_bytes(self.obj_id, self.key_id, TYPE_BYTES, &value.to_bytes()); - } - - pub fn value(&self) -> DeployRequest { - DeployRequest::from_bytes(&get_bytes(self.obj_id, self.key_id, TYPE_BYTES)) - } -} - -#[derive(Clone)] -pub struct PostRequest { - pub chain_id : ScChainID, - pub contract : ScHname, - pub delay : u32, - pub function : ScHname, - pub params : , - pub transfer : , -} - -impl PostRequest { - pub fn from_bytes(bytes: &[u8]) -> PostRequest { - let mut decode = BytesDecoder::new(bytes); - PostRequest { - chain_id : decode.chain_id(), - contract : decode.hname(), - delay : decode.uint32(), - function : decode.hname(), - params : decode.bytes(), - transfer : decode.bytes(), - } - } - - pub fn to_bytes(&self) -> Vec { - let mut encode = BytesEncoder::new(); - encode.chain_id(&self.chain_id); - encode.hname(self.contract); - encode.uint32(self.delay); - encode.hname(self.function); - encode.bytes(self.params); - encode.bytes(self.transfer); - return encode.data(); - } -} - -#[derive(Clone, Copy)] -pub struct ImmutablePostRequest { - pub(crate) obj_id: i32, - pub(crate) key_id: Key32, -} - -impl ImmutablePostRequest { - pub fn exists(&self) -> bool { - exists(self.obj_id, self.key_id, TYPE_BYTES) - } - - pub fn value(&self) -> PostRequest { - PostRequest::from_bytes(&get_bytes(self.obj_id, self.key_id, TYPE_BYTES)) - } -} - -#[derive(Clone, Copy)] -pub struct MutablePostRequest { - pub(crate) obj_id: i32, - pub(crate) key_id: Key32, -} - -impl MutablePostRequest { - pub fn delete(&self) { - del_key(self.obj_id, self.key_id, TYPE_BYTES); - } - - pub fn exists(&self) -> bool { - exists(self.obj_id, self.key_id, TYPE_BYTES) - } - - pub fn set_value(&self, value: &PostRequest) { - set_bytes(self.obj_id, self.key_id, TYPE_BYTES, &value.to_bytes()); - } - - pub fn value(&self) -> PostRequest { - PostRequest::from_bytes(&get_bytes(self.obj_id, self.key_id, TYPE_BYTES)) - } -} - -#[derive(Clone)] -pub struct SendRequest { - pub address : ScAddress, - pub transfer : , -} - -impl SendRequest { - pub fn from_bytes(bytes: &[u8]) -> SendRequest { - let mut decode = BytesDecoder::new(bytes); - SendRequest { - address : decode.address(), - transfer : decode.bytes(), - } - } - - pub fn to_bytes(&self) -> Vec { - let mut encode = BytesEncoder::new(); - encode.address(&self.address); - encode.bytes(self.transfer); - return encode.data(); - } -} - -#[derive(Clone, Copy)] -pub struct ImmutableSendRequest { - pub(crate) obj_id: i32, - pub(crate) key_id: Key32, -} - -impl ImmutableSendRequest { - pub fn exists(&self) -> bool { - exists(self.obj_id, self.key_id, TYPE_BYTES) - } - - pub fn value(&self) -> SendRequest { - SendRequest::from_bytes(&get_bytes(self.obj_id, self.key_id, TYPE_BYTES)) - } -} - -#[derive(Clone, Copy)] -pub struct MutableSendRequest { - pub(crate) obj_id: i32, - pub(crate) key_id: Key32, -} - -impl MutableSendRequest { - pub fn delete(&self) { - del_key(self.obj_id, self.key_id, TYPE_BYTES); - } - - pub fn exists(&self) -> bool { - exists(self.obj_id, self.key_id, TYPE_BYTES) - } - - pub fn set_value(&self, value: &SendRequest) { - set_bytes(self.obj_id, self.key_id, TYPE_BYTES, &value.to_bytes()); - } - - pub fn value(&self) -> SendRequest { - SendRequest::from_bytes(&get_bytes(self.obj_id, self.key_id, TYPE_BYTES)) - } -} diff --git a/contracts/wasm/testwasmlib/ts/testwasmlib/contract.ts b/contracts/wasm/testwasmlib/ts/testwasmlib/contract.ts index e8c5d3c508..4972c93f73 100644 --- a/contracts/wasm/testwasmlib/ts/testwasmlib/contract.ts +++ b/contracts/wasm/testwasmlib/ts/testwasmlib/contract.ts @@ -6,7 +6,6 @@ // Change the json schema instead import * as wasmlib from "wasmlib"; -import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; export class ArrayAppendCall { @@ -176,93 +175,93 @@ export class MapValueContext { } export class ScFuncs { - static arrayAppend(ctx: wasmlib.ScFuncCallContext): ArrayAppendCall { + static arrayAppend(_ctx: wasmlib.ScFuncCallContext): ArrayAppendCall { const f = new ArrayAppendCall(); f.params = new sc.MutableArrayAppendParams(wasmlib.newCallParamsProxy(f.func)); return f; } - static arrayClear(ctx: wasmlib.ScFuncCallContext): ArrayClearCall { + static arrayClear(_ctx: wasmlib.ScFuncCallContext): ArrayClearCall { const f = new ArrayClearCall(); f.params = new sc.MutableArrayClearParams(wasmlib.newCallParamsProxy(f.func)); return f; } - static arraySet(ctx: wasmlib.ScFuncCallContext): ArraySetCall { + static arraySet(_ctx: wasmlib.ScFuncCallContext): ArraySetCall { const f = new ArraySetCall(); f.params = new sc.MutableArraySetParams(wasmlib.newCallParamsProxy(f.func)); return f; } - static mapClear(ctx: wasmlib.ScFuncCallContext): MapClearCall { + static mapClear(_ctx: wasmlib.ScFuncCallContext): MapClearCall { const f = new MapClearCall(); f.params = new sc.MutableMapClearParams(wasmlib.newCallParamsProxy(f.func)); return f; } - static mapSet(ctx: wasmlib.ScFuncCallContext): MapSetCall { + static mapSet(_ctx: wasmlib.ScFuncCallContext): MapSetCall { const f = new MapSetCall(); f.params = new sc.MutableMapSetParams(wasmlib.newCallParamsProxy(f.func)); return f; } - static paramTypes(ctx: wasmlib.ScFuncCallContext): ParamTypesCall { + static paramTypes(_ctx: wasmlib.ScFuncCallContext): ParamTypesCall { const f = new ParamTypesCall(); f.params = new sc.MutableParamTypesParams(wasmlib.newCallParamsProxy(f.func)); return f; } - static random(ctx: wasmlib.ScFuncCallContext): RandomCall { + static random(_ctx: wasmlib.ScFuncCallContext): RandomCall { return new RandomCall(); } - static triggerEvent(ctx: wasmlib.ScFuncCallContext): TriggerEventCall { + static triggerEvent(_ctx: wasmlib.ScFuncCallContext): TriggerEventCall { const f = new TriggerEventCall(); f.params = new sc.MutableTriggerEventParams(wasmlib.newCallParamsProxy(f.func)); return f; } - static arrayLength(ctx: wasmlib.ScViewCallContext): ArrayLengthCall { + static arrayLength(_ctx: wasmlib.ScViewCallContext): ArrayLengthCall { const f = new ArrayLengthCall(); f.params = new sc.MutableArrayLengthParams(wasmlib.newCallParamsProxy(f.func)); f.results = new sc.ImmutableArrayLengthResults(wasmlib.newCallResultsProxy(f.func)); return f; } - static arrayValue(ctx: wasmlib.ScViewCallContext): ArrayValueCall { + static arrayValue(_ctx: wasmlib.ScViewCallContext): ArrayValueCall { const f = new ArrayValueCall(); f.params = new sc.MutableArrayValueParams(wasmlib.newCallParamsProxy(f.func)); f.results = new sc.ImmutableArrayValueResults(wasmlib.newCallResultsProxy(f.func)); return f; } - static blockRecord(ctx: wasmlib.ScViewCallContext): BlockRecordCall { + static blockRecord(_ctx: wasmlib.ScViewCallContext): BlockRecordCall { const f = new BlockRecordCall(); f.params = new sc.MutableBlockRecordParams(wasmlib.newCallParamsProxy(f.func)); f.results = new sc.ImmutableBlockRecordResults(wasmlib.newCallResultsProxy(f.func)); return f; } - static blockRecords(ctx: wasmlib.ScViewCallContext): BlockRecordsCall { + static blockRecords(_ctx: wasmlib.ScViewCallContext): BlockRecordsCall { const f = new BlockRecordsCall(); f.params = new sc.MutableBlockRecordsParams(wasmlib.newCallParamsProxy(f.func)); f.results = new sc.ImmutableBlockRecordsResults(wasmlib.newCallResultsProxy(f.func)); return f; } - static getRandom(ctx: wasmlib.ScViewCallContext): GetRandomCall { + static getRandom(_ctx: wasmlib.ScViewCallContext): GetRandomCall { const f = new GetRandomCall(); f.results = new sc.ImmutableGetRandomResults(wasmlib.newCallResultsProxy(f.func)); return f; } - static iotaBalance(ctx: wasmlib.ScViewCallContext): IotaBalanceCall { + static iotaBalance(_ctx: wasmlib.ScViewCallContext): IotaBalanceCall { const f = new IotaBalanceCall(); f.results = new sc.ImmutableIotaBalanceResults(wasmlib.newCallResultsProxy(f.func)); return f; } - static mapValue(ctx: wasmlib.ScViewCallContext): MapValueCall { + static mapValue(_ctx: wasmlib.ScViewCallContext): MapValueCall { const f = new MapValueCall(); f.params = new sc.MutableMapValueParams(wasmlib.newCallParamsProxy(f.func)); f.results = new sc.ImmutableMapValueResults(wasmlib.newCallResultsProxy(f.func)); diff --git a/contracts/wasm/testwasmlib/ts/testwasmlib/lib.ts b/contracts/wasm/testwasmlib/ts/testwasmlib/lib.ts index 1b63ed38bb..4db9a7a3b0 100644 --- a/contracts/wasm/testwasmlib/ts/testwasmlib/lib.ts +++ b/contracts/wasm/testwasmlib/ts/testwasmlib/lib.ts @@ -6,7 +6,6 @@ // Change the json schema instead import * as wasmlib from "wasmlib"; -import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; export function on_call(index: i32): void { diff --git a/contracts/wasm/testwasmlib/ts/testwasmlib/params.ts b/contracts/wasm/testwasmlib/ts/testwasmlib/params.ts index 6f3ea91e16..330499ae83 100644 --- a/contracts/wasm/testwasmlib/ts/testwasmlib/params.ts +++ b/contracts/wasm/testwasmlib/ts/testwasmlib/params.ts @@ -5,7 +5,6 @@ // >>>> DO NOT CHANGE THIS FILE! <<<< // Change the json schema instead -import * as wasmlib from "wasmlib"; import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; diff --git a/contracts/wasm/testwasmlib/ts/testwasmlib/results.ts b/contracts/wasm/testwasmlib/ts/testwasmlib/results.ts index 78d950db79..8009fa2dd1 100644 --- a/contracts/wasm/testwasmlib/ts/testwasmlib/results.ts +++ b/contracts/wasm/testwasmlib/ts/testwasmlib/results.ts @@ -5,7 +5,6 @@ // >>>> DO NOT CHANGE THIS FILE! <<<< // Change the json schema instead -import * as wasmlib from "wasmlib"; import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; diff --git a/contracts/wasm/testwasmlib/ts/testwasmlib/state.ts b/contracts/wasm/testwasmlib/ts/testwasmlib/state.ts index 9ff83d6549..be41bc19d4 100644 --- a/contracts/wasm/testwasmlib/ts/testwasmlib/state.ts +++ b/contracts/wasm/testwasmlib/ts/testwasmlib/state.ts @@ -5,7 +5,6 @@ // >>>> DO NOT CHANGE THIS FILE! <<<< // Change the json schema instead -import * as wasmlib from "wasmlib"; import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; diff --git a/contracts/wasm/testwasmlib/ts/testwasmlib/structs.ts b/contracts/wasm/testwasmlib/ts/testwasmlib/structs.ts deleted file mode 100644 index dde968d18d..0000000000 --- a/contracts/wasm/testwasmlib/ts/testwasmlib/structs.ts +++ /dev/null @@ -1,292 +0,0 @@ -// Copyright 2020 IOTA Stiftung -// SPDX-License-Identifier: Apache-2.0 - -// (Re-)generated by schema tool -// >>>> DO NOT CHANGE THIS FILE! <<<< -// Change the json schema instead - -import * as wasmlib from "wasmlib"; - -export class CallRequest { - contract : wasmlib.ScHname = new wasmlib.ScHname(0); - function : wasmlib.ScHname = new wasmlib.ScHname(0); - params : = ; - transfer : = ; - - static fromBytes(bytes: u8[]): CallRequest { - let decode = new wasmlib.BytesDecoder(bytes); - let data = new CallRequest(); - data.contract = decode.hname(); - data.function = decode.hname(); - data.params = decode.bytes(); - data.transfer = decode.bytes(); - decode.close(); - return data; - } - - bytes(): u8[] { - return new wasmlib.BytesEncoder(). - hname(this.contract). - hname(this.function). - bytes(this.params). - bytes(this.transfer). - data(); - } -} - -export class ImmutableCallRequest { - objID: i32; - keyID: wasmlib.Key32; - - constructor(objID: i32, keyID: wasmlib.Key32) { - this.objID = objID; - this.keyID = keyID; - } - - exists(): boolean { - return wasmlib.exists(this.objID, this.keyID, wasmlib.TYPE_BYTES); - } - - value(): CallRequest { - return CallRequest.fromBytes(wasmlib.getBytes(this.objID, this.keyID, wasmlib.TYPE_BYTES)); - } -} - -export class MutableCallRequest { - objID: i32; - keyID: wasmlib.Key32; - - constructor(objID: i32, keyID: wasmlib.Key32) { - this.objID = objID; - this.keyID = keyID; - } - - delete(): void { - wasmlib.delKey(this.objID, this.keyID, wasmlib.TYPE_BYTES); - } - - exists(): boolean { - return wasmlib.exists(this.objID, this.keyID, wasmlib.TYPE_BYTES); - } - - setValue(value: CallRequest): void { - wasmlib.setBytes(this.objID, this.keyID, wasmlib.TYPE_BYTES, value.bytes()); - } - - value(): CallRequest { - return CallRequest.fromBytes(wasmlib.getBytes(this.objID, this.keyID, wasmlib.TYPE_BYTES)); - } -} - -export class DeployRequest { - description : string = ""; - name : string = ""; - params : = ; - progHash : wasmlib.ScHash = new wasmlib.ScHash(); - - static fromBytes(bytes: u8[]): DeployRequest { - let decode = new wasmlib.BytesDecoder(bytes); - let data = new DeployRequest(); - data.description = decode.string(); - data.name = decode.string(); - data.params = decode.bytes(); - data.progHash = decode.hash(); - decode.close(); - return data; - } - - bytes(): u8[] { - return new wasmlib.BytesEncoder(). - string(this.description). - string(this.name). - bytes(this.params). - hash(this.progHash). - data(); - } -} - -export class ImmutableDeployRequest { - objID: i32; - keyID: wasmlib.Key32; - - constructor(objID: i32, keyID: wasmlib.Key32) { - this.objID = objID; - this.keyID = keyID; - } - - exists(): boolean { - return wasmlib.exists(this.objID, this.keyID, wasmlib.TYPE_BYTES); - } - - value(): DeployRequest { - return DeployRequest.fromBytes(wasmlib.getBytes(this.objID, this.keyID, wasmlib.TYPE_BYTES)); - } -} - -export class MutableDeployRequest { - objID: i32; - keyID: wasmlib.Key32; - - constructor(objID: i32, keyID: wasmlib.Key32) { - this.objID = objID; - this.keyID = keyID; - } - - delete(): void { - wasmlib.delKey(this.objID, this.keyID, wasmlib.TYPE_BYTES); - } - - exists(): boolean { - return wasmlib.exists(this.objID, this.keyID, wasmlib.TYPE_BYTES); - } - - setValue(value: DeployRequest): void { - wasmlib.setBytes(this.objID, this.keyID, wasmlib.TYPE_BYTES, value.bytes()); - } - - value(): DeployRequest { - return DeployRequest.fromBytes(wasmlib.getBytes(this.objID, this.keyID, wasmlib.TYPE_BYTES)); - } -} - -export class PostRequest { - chainID : wasmlib.ScChainID = new wasmlib.ScChainID(); - contract : wasmlib.ScHname = new wasmlib.ScHname(0); - delay : u32 = 0; - function : wasmlib.ScHname = new wasmlib.ScHname(0); - params : = ; - transfer : = ; - - static fromBytes(bytes: u8[]): PostRequest { - let decode = new wasmlib.BytesDecoder(bytes); - let data = new PostRequest(); - data.chainID = decode.chainID(); - data.contract = decode.hname(); - data.delay = decode.uint32(); - data.function = decode.hname(); - data.params = decode.bytes(); - data.transfer = decode.bytes(); - decode.close(); - return data; - } - - bytes(): u8[] { - return new wasmlib.BytesEncoder(). - chainID(this.chainID). - hname(this.contract). - uint32(this.delay). - hname(this.function). - bytes(this.params). - bytes(this.transfer). - data(); - } -} - -export class ImmutablePostRequest { - objID: i32; - keyID: wasmlib.Key32; - - constructor(objID: i32, keyID: wasmlib.Key32) { - this.objID = objID; - this.keyID = keyID; - } - - exists(): boolean { - return wasmlib.exists(this.objID, this.keyID, wasmlib.TYPE_BYTES); - } - - value(): PostRequest { - return PostRequest.fromBytes(wasmlib.getBytes(this.objID, this.keyID, wasmlib.TYPE_BYTES)); - } -} - -export class MutablePostRequest { - objID: i32; - keyID: wasmlib.Key32; - - constructor(objID: i32, keyID: wasmlib.Key32) { - this.objID = objID; - this.keyID = keyID; - } - - delete(): void { - wasmlib.delKey(this.objID, this.keyID, wasmlib.TYPE_BYTES); - } - - exists(): boolean { - return wasmlib.exists(this.objID, this.keyID, wasmlib.TYPE_BYTES); - } - - setValue(value: PostRequest): void { - wasmlib.setBytes(this.objID, this.keyID, wasmlib.TYPE_BYTES, value.bytes()); - } - - value(): PostRequest { - return PostRequest.fromBytes(wasmlib.getBytes(this.objID, this.keyID, wasmlib.TYPE_BYTES)); - } -} - -export class SendRequest { - address : wasmlib.ScAddress = new wasmlib.ScAddress(); - transfer : = ; - - static fromBytes(bytes: u8[]): SendRequest { - let decode = new wasmlib.BytesDecoder(bytes); - let data = new SendRequest(); - data.address = decode.address(); - data.transfer = decode.bytes(); - decode.close(); - return data; - } - - bytes(): u8[] { - return new wasmlib.BytesEncoder(). - address(this.address). - bytes(this.transfer). - data(); - } -} - -export class ImmutableSendRequest { - objID: i32; - keyID: wasmlib.Key32; - - constructor(objID: i32, keyID: wasmlib.Key32) { - this.objID = objID; - this.keyID = keyID; - } - - exists(): boolean { - return wasmlib.exists(this.objID, this.keyID, wasmlib.TYPE_BYTES); - } - - value(): SendRequest { - return SendRequest.fromBytes(wasmlib.getBytes(this.objID, this.keyID, wasmlib.TYPE_BYTES)); - } -} - -export class MutableSendRequest { - objID: i32; - keyID: wasmlib.Key32; - - constructor(objID: i32, keyID: wasmlib.Key32) { - this.objID = objID; - this.keyID = keyID; - } - - delete(): void { - wasmlib.delKey(this.objID, this.keyID, wasmlib.TYPE_BYTES); - } - - exists(): boolean { - return wasmlib.exists(this.objID, this.keyID, wasmlib.TYPE_BYTES); - } - - setValue(value: SendRequest): void { - wasmlib.setBytes(this.objID, this.keyID, wasmlib.TYPE_BYTES, value.bytes()); - } - - value(): SendRequest { - return SendRequest.fromBytes(wasmlib.getBytes(this.objID, this.keyID, wasmlib.TYPE_BYTES)); - } -} diff --git a/contracts/wasm/testwasmlib/ts/testwasmlib/typedefs.ts b/contracts/wasm/testwasmlib/ts/testwasmlib/typedefs.ts index 34f269a501..2fbb121c13 100644 --- a/contracts/wasm/testwasmlib/ts/testwasmlib/typedefs.ts +++ b/contracts/wasm/testwasmlib/ts/testwasmlib/typedefs.ts @@ -5,7 +5,6 @@ // >>>> DO NOT CHANGE THIS FILE! <<<< // Change the json schema instead -import * as wasmlib from "wasmlib"; import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; @@ -21,7 +20,7 @@ export class ArrayOfImmutableString extends wasmtypes.ScProxy { } export class ImmutableStringArray extends ArrayOfImmutableString { -}; +} export class ArrayOfMutableString extends wasmtypes.ScProxy { @@ -43,7 +42,7 @@ export class ArrayOfMutableString extends wasmtypes.ScProxy { } export class MutableStringArray extends ArrayOfMutableString { -}; +} export class MapStringToImmutableString extends wasmtypes.ScProxy { @@ -53,7 +52,7 @@ export class MapStringToImmutableString extends wasmtypes.ScProxy { } export class ImmutableStringMap extends MapStringToImmutableString { -}; +} export class MapStringToMutableString extends wasmtypes.ScProxy { @@ -67,4 +66,4 @@ export class MapStringToMutableString extends wasmtypes.ScProxy { } export class MutableStringMap extends MapStringToMutableString { -}; +} diff --git a/contracts/wasm/timestamp/ts/timestamp/contract.ts b/contracts/wasm/timestamp/ts/timestamp/contract.ts index bdb16297af..a5bc415b6a 100644 --- a/contracts/wasm/timestamp/ts/timestamp/contract.ts +++ b/contracts/wasm/timestamp/ts/timestamp/contract.ts @@ -6,7 +6,6 @@ // Change the json schema instead import * as wasmlib from "wasmlib"; -import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; export class NowCall { @@ -28,11 +27,11 @@ export class GetTimestampContext { } export class ScFuncs { - static now(ctx: wasmlib.ScFuncCallContext): NowCall { + static now(_ctx: wasmlib.ScFuncCallContext): NowCall { return new NowCall(); } - static getTimestamp(ctx: wasmlib.ScViewCallContext): GetTimestampCall { + static getTimestamp(_ctx: wasmlib.ScViewCallContext): GetTimestampCall { const f = new GetTimestampCall(); f.results = new sc.ImmutableGetTimestampResults(wasmlib.newCallResultsProxy(f.func)); return f; diff --git a/contracts/wasm/timestamp/ts/timestamp/lib.ts b/contracts/wasm/timestamp/ts/timestamp/lib.ts index 81c857cfd0..5e04d04a6d 100644 --- a/contracts/wasm/timestamp/ts/timestamp/lib.ts +++ b/contracts/wasm/timestamp/ts/timestamp/lib.ts @@ -6,7 +6,6 @@ // Change the json schema instead import * as wasmlib from "wasmlib"; -import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; export function on_call(index: i32): void { diff --git a/contracts/wasm/timestamp/ts/timestamp/results.ts b/contracts/wasm/timestamp/ts/timestamp/results.ts index 3c8b1060d4..bc3bd8bf91 100644 --- a/contracts/wasm/timestamp/ts/timestamp/results.ts +++ b/contracts/wasm/timestamp/ts/timestamp/results.ts @@ -5,7 +5,6 @@ // >>>> DO NOT CHANGE THIS FILE! <<<< // Change the json schema instead -import * as wasmlib from "wasmlib"; import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; diff --git a/contracts/wasm/timestamp/ts/timestamp/state.ts b/contracts/wasm/timestamp/ts/timestamp/state.ts index 0c9315e915..9443a39aa5 100644 --- a/contracts/wasm/timestamp/ts/timestamp/state.ts +++ b/contracts/wasm/timestamp/ts/timestamp/state.ts @@ -5,7 +5,6 @@ // >>>> DO NOT CHANGE THIS FILE! <<<< // Change the json schema instead -import * as wasmlib from "wasmlib"; import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; diff --git a/contracts/wasm/tokenregistry/ts/tokenregistry/contract.ts b/contracts/wasm/tokenregistry/ts/tokenregistry/contract.ts index e3e9fa4965..5f778631aa 100644 --- a/contracts/wasm/tokenregistry/ts/tokenregistry/contract.ts +++ b/contracts/wasm/tokenregistry/ts/tokenregistry/contract.ts @@ -6,7 +6,6 @@ // Change the json schema instead import * as wasmlib from "wasmlib"; -import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; export class MintSupplyCall { @@ -50,25 +49,25 @@ export class GetInfoContext { } export class ScFuncs { - static mintSupply(ctx: wasmlib.ScFuncCallContext): MintSupplyCall { + static mintSupply(_ctx: wasmlib.ScFuncCallContext): MintSupplyCall { const f = new MintSupplyCall(); f.params = new sc.MutableMintSupplyParams(wasmlib.newCallParamsProxy(f.func)); return f; } - static transferOwnership(ctx: wasmlib.ScFuncCallContext): TransferOwnershipCall { + static transferOwnership(_ctx: wasmlib.ScFuncCallContext): TransferOwnershipCall { const f = new TransferOwnershipCall(); f.params = new sc.MutableTransferOwnershipParams(wasmlib.newCallParamsProxy(f.func)); return f; } - static updateMetadata(ctx: wasmlib.ScFuncCallContext): UpdateMetadataCall { + static updateMetadata(_ctx: wasmlib.ScFuncCallContext): UpdateMetadataCall { const f = new UpdateMetadataCall(); f.params = new sc.MutableUpdateMetadataParams(wasmlib.newCallParamsProxy(f.func)); return f; } - static getInfo(ctx: wasmlib.ScViewCallContext): GetInfoCall { + static getInfo(_ctx: wasmlib.ScViewCallContext): GetInfoCall { const f = new GetInfoCall(); f.params = new sc.MutableGetInfoParams(wasmlib.newCallParamsProxy(f.func)); return f; diff --git a/contracts/wasm/tokenregistry/ts/tokenregistry/lib.ts b/contracts/wasm/tokenregistry/ts/tokenregistry/lib.ts index a49d4de43e..8d1c749dab 100644 --- a/contracts/wasm/tokenregistry/ts/tokenregistry/lib.ts +++ b/contracts/wasm/tokenregistry/ts/tokenregistry/lib.ts @@ -6,7 +6,6 @@ // Change the json schema instead import * as wasmlib from "wasmlib"; -import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; export function on_call(index: i32): void { diff --git a/contracts/wasm/tokenregistry/ts/tokenregistry/params.ts b/contracts/wasm/tokenregistry/ts/tokenregistry/params.ts index 897598da51..8c7a996e7a 100644 --- a/contracts/wasm/tokenregistry/ts/tokenregistry/params.ts +++ b/contracts/wasm/tokenregistry/ts/tokenregistry/params.ts @@ -5,7 +5,6 @@ // >>>> DO NOT CHANGE THIS FILE! <<<< // Change the json schema instead -import * as wasmlib from "wasmlib"; import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; diff --git a/contracts/wasm/tokenregistry/ts/tokenregistry/state.ts b/contracts/wasm/tokenregistry/ts/tokenregistry/state.ts index 858d13588c..cca93575d6 100644 --- a/contracts/wasm/tokenregistry/ts/tokenregistry/state.ts +++ b/contracts/wasm/tokenregistry/ts/tokenregistry/state.ts @@ -5,7 +5,6 @@ // >>>> DO NOT CHANGE THIS FILE! <<<< // Change the json schema instead -import * as wasmlib from "wasmlib"; import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; diff --git a/contracts/wasm/tokenregistry/ts/tokenregistry/structs.ts b/contracts/wasm/tokenregistry/ts/tokenregistry/structs.ts index ed98aeddb6..fe8b012869 100644 --- a/contracts/wasm/tokenregistry/ts/tokenregistry/structs.ts +++ b/contracts/wasm/tokenregistry/ts/tokenregistry/structs.ts @@ -5,7 +5,6 @@ // >>>> DO NOT CHANGE THIS FILE! <<<< // Change the json schema instead -import * as wasmlib from "wasmlib"; import * as wasmtypes from "wasmlib/wasmtypes"; export class Token { diff --git a/packages/wasmvm/wasmlib/ts/wasmlib/coreaccounts/contract.ts b/packages/wasmvm/wasmlib/ts/wasmlib/coreaccounts/contract.ts index 15ec996c5f..0a455ad314 100644 --- a/packages/wasmvm/wasmlib/ts/wasmlib/coreaccounts/contract.ts +++ b/packages/wasmvm/wasmlib/ts/wasmlib/coreaccounts/contract.ts @@ -6,7 +6,6 @@ // Change the json schema instead import * as wasmlib from "wasmlib"; -import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; export class DepositCall { @@ -46,43 +45,43 @@ export class TotalAssetsCall { } export class ScFuncs { - static deposit(ctx: wasmlib.ScFuncCallContext): DepositCall { + static deposit(_ctx: wasmlib.ScFuncCallContext): DepositCall { const f = new DepositCall(); f.params = new sc.MutableDepositParams(wasmlib.newCallParamsProxy(f.func)); return f; } - static harvest(ctx: wasmlib.ScFuncCallContext): HarvestCall { + static harvest(_ctx: wasmlib.ScFuncCallContext): HarvestCall { const f = new HarvestCall(); f.params = new sc.MutableHarvestParams(wasmlib.newCallParamsProxy(f.func)); return f; } - static withdraw(ctx: wasmlib.ScFuncCallContext): WithdrawCall { + static withdraw(_ctx: wasmlib.ScFuncCallContext): WithdrawCall { return new WithdrawCall(); } - static accounts(ctx: wasmlib.ScViewCallContext): AccountsCall { + static accounts(_ctx: wasmlib.ScViewCallContext): AccountsCall { const f = new AccountsCall(); f.results = new sc.ImmutableAccountsResults(wasmlib.newCallResultsProxy(f.func)); return f; } - static balance(ctx: wasmlib.ScViewCallContext): BalanceCall { + static balance(_ctx: wasmlib.ScViewCallContext): BalanceCall { const f = new BalanceCall(); f.params = new sc.MutableBalanceParams(wasmlib.newCallParamsProxy(f.func)); f.results = new sc.ImmutableBalanceResults(wasmlib.newCallResultsProxy(f.func)); return f; } - static getAccountNonce(ctx: wasmlib.ScViewCallContext): GetAccountNonceCall { + static getAccountNonce(_ctx: wasmlib.ScViewCallContext): GetAccountNonceCall { const f = new GetAccountNonceCall(); f.params = new sc.MutableGetAccountNonceParams(wasmlib.newCallParamsProxy(f.func)); f.results = new sc.ImmutableGetAccountNonceResults(wasmlib.newCallResultsProxy(f.func)); return f; } - static totalAssets(ctx: wasmlib.ScViewCallContext): TotalAssetsCall { + static totalAssets(_ctx: wasmlib.ScViewCallContext): TotalAssetsCall { const f = new TotalAssetsCall(); f.results = new sc.ImmutableTotalAssetsResults(wasmlib.newCallResultsProxy(f.func)); return f; diff --git a/packages/wasmvm/wasmlib/ts/wasmlib/coreaccounts/params.ts b/packages/wasmvm/wasmlib/ts/wasmlib/coreaccounts/params.ts index e178f2268f..e2ac23ac00 100644 --- a/packages/wasmvm/wasmlib/ts/wasmlib/coreaccounts/params.ts +++ b/packages/wasmvm/wasmlib/ts/wasmlib/coreaccounts/params.ts @@ -5,7 +5,6 @@ // >>>> DO NOT CHANGE THIS FILE! <<<< // Change the json schema instead -import * as wasmlib from "wasmlib"; import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; diff --git a/packages/wasmvm/wasmlib/ts/wasmlib/coreaccounts/results.ts b/packages/wasmvm/wasmlib/ts/wasmlib/coreaccounts/results.ts index 4240c44101..2382d7696c 100644 --- a/packages/wasmvm/wasmlib/ts/wasmlib/coreaccounts/results.ts +++ b/packages/wasmvm/wasmlib/ts/wasmlib/coreaccounts/results.ts @@ -5,7 +5,6 @@ // >>>> DO NOT CHANGE THIS FILE! <<<< // Change the json schema instead -import * as wasmlib from "wasmlib"; import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; diff --git a/packages/wasmvm/wasmlib/ts/wasmlib/coreblob/contract.ts b/packages/wasmvm/wasmlib/ts/wasmlib/coreblob/contract.ts index 8e3fe48cd7..5197de9db7 100644 --- a/packages/wasmvm/wasmlib/ts/wasmlib/coreblob/contract.ts +++ b/packages/wasmvm/wasmlib/ts/wasmlib/coreblob/contract.ts @@ -6,7 +6,6 @@ // Change the json schema instead import * as wasmlib from "wasmlib"; -import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; export class StoreBlobCall { @@ -33,28 +32,28 @@ export class ListBlobsCall { } export class ScFuncs { - static storeBlob(ctx: wasmlib.ScFuncCallContext): StoreBlobCall { + static storeBlob(_ctx: wasmlib.ScFuncCallContext): StoreBlobCall { const f = new StoreBlobCall(); f.params = new sc.MutableStoreBlobParams(wasmlib.newCallParamsProxy(f.func)); f.results = new sc.ImmutableStoreBlobResults(wasmlib.newCallResultsProxy(f.func)); return f; } - static getBlobField(ctx: wasmlib.ScViewCallContext): GetBlobFieldCall { + static getBlobField(_ctx: wasmlib.ScViewCallContext): GetBlobFieldCall { const f = new GetBlobFieldCall(); f.params = new sc.MutableGetBlobFieldParams(wasmlib.newCallParamsProxy(f.func)); f.results = new sc.ImmutableGetBlobFieldResults(wasmlib.newCallResultsProxy(f.func)); return f; } - static getBlobInfo(ctx: wasmlib.ScViewCallContext): GetBlobInfoCall { + static getBlobInfo(_ctx: wasmlib.ScViewCallContext): GetBlobInfoCall { const f = new GetBlobInfoCall(); f.params = new sc.MutableGetBlobInfoParams(wasmlib.newCallParamsProxy(f.func)); f.results = new sc.ImmutableGetBlobInfoResults(wasmlib.newCallResultsProxy(f.func)); return f; } - static listBlobs(ctx: wasmlib.ScViewCallContext): ListBlobsCall { + static listBlobs(_ctx: wasmlib.ScViewCallContext): ListBlobsCall { const f = new ListBlobsCall(); f.results = new sc.ImmutableListBlobsResults(wasmlib.newCallResultsProxy(f.func)); return f; diff --git a/packages/wasmvm/wasmlib/ts/wasmlib/coreblob/params.ts b/packages/wasmvm/wasmlib/ts/wasmlib/coreblob/params.ts index 0319775753..9191afc99e 100644 --- a/packages/wasmvm/wasmlib/ts/wasmlib/coreblob/params.ts +++ b/packages/wasmvm/wasmlib/ts/wasmlib/coreblob/params.ts @@ -5,7 +5,6 @@ // >>>> DO NOT CHANGE THIS FILE! <<<< // Change the json schema instead -import * as wasmlib from "wasmlib"; import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; diff --git a/packages/wasmvm/wasmlib/ts/wasmlib/coreblob/results.ts b/packages/wasmvm/wasmlib/ts/wasmlib/coreblob/results.ts index cf0d7fc40d..27742b507c 100644 --- a/packages/wasmvm/wasmlib/ts/wasmlib/coreblob/results.ts +++ b/packages/wasmvm/wasmlib/ts/wasmlib/coreblob/results.ts @@ -5,7 +5,6 @@ // >>>> DO NOT CHANGE THIS FILE! <<<< // Change the json schema instead -import * as wasmlib from "wasmlib"; import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; diff --git a/packages/wasmvm/wasmlib/ts/wasmlib/coreblocklog/contract.ts b/packages/wasmvm/wasmlib/ts/wasmlib/coreblocklog/contract.ts index 1b399b29eb..9b60433221 100644 --- a/packages/wasmvm/wasmlib/ts/wasmlib/coreblocklog/contract.ts +++ b/packages/wasmvm/wasmlib/ts/wasmlib/coreblocklog/contract.ts @@ -6,7 +6,6 @@ // Change the json schema instead import * as wasmlib from "wasmlib"; -import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; export class ControlAddressesCall { @@ -68,68 +67,68 @@ export class IsRequestProcessedCall { } export class ScFuncs { - static controlAddresses(ctx: wasmlib.ScViewCallContext): ControlAddressesCall { + static controlAddresses(_ctx: wasmlib.ScViewCallContext): ControlAddressesCall { const f = new ControlAddressesCall(); f.results = new sc.ImmutableControlAddressesResults(wasmlib.newCallResultsProxy(f.func)); return f; } - static getBlockInfo(ctx: wasmlib.ScViewCallContext): GetBlockInfoCall { + static getBlockInfo(_ctx: wasmlib.ScViewCallContext): GetBlockInfoCall { const f = new GetBlockInfoCall(); f.params = new sc.MutableGetBlockInfoParams(wasmlib.newCallParamsProxy(f.func)); f.results = new sc.ImmutableGetBlockInfoResults(wasmlib.newCallResultsProxy(f.func)); return f; } - static getEventsForBlock(ctx: wasmlib.ScViewCallContext): GetEventsForBlockCall { + static getEventsForBlock(_ctx: wasmlib.ScViewCallContext): GetEventsForBlockCall { const f = new GetEventsForBlockCall(); f.params = new sc.MutableGetEventsForBlockParams(wasmlib.newCallParamsProxy(f.func)); f.results = new sc.ImmutableGetEventsForBlockResults(wasmlib.newCallResultsProxy(f.func)); return f; } - static getEventsForContract(ctx: wasmlib.ScViewCallContext): GetEventsForContractCall { + static getEventsForContract(_ctx: wasmlib.ScViewCallContext): GetEventsForContractCall { const f = new GetEventsForContractCall(); f.params = new sc.MutableGetEventsForContractParams(wasmlib.newCallParamsProxy(f.func)); f.results = new sc.ImmutableGetEventsForContractResults(wasmlib.newCallResultsProxy(f.func)); return f; } - static getEventsForRequest(ctx: wasmlib.ScViewCallContext): GetEventsForRequestCall { + static getEventsForRequest(_ctx: wasmlib.ScViewCallContext): GetEventsForRequestCall { const f = new GetEventsForRequestCall(); f.params = new sc.MutableGetEventsForRequestParams(wasmlib.newCallParamsProxy(f.func)); f.results = new sc.ImmutableGetEventsForRequestResults(wasmlib.newCallResultsProxy(f.func)); return f; } - static getLatestBlockInfo(ctx: wasmlib.ScViewCallContext): GetLatestBlockInfoCall { + static getLatestBlockInfo(_ctx: wasmlib.ScViewCallContext): GetLatestBlockInfoCall { const f = new GetLatestBlockInfoCall(); f.results = new sc.ImmutableGetLatestBlockInfoResults(wasmlib.newCallResultsProxy(f.func)); return f; } - static getRequestIDsForBlock(ctx: wasmlib.ScViewCallContext): GetRequestIDsForBlockCall { + static getRequestIDsForBlock(_ctx: wasmlib.ScViewCallContext): GetRequestIDsForBlockCall { const f = new GetRequestIDsForBlockCall(); f.params = new sc.MutableGetRequestIDsForBlockParams(wasmlib.newCallParamsProxy(f.func)); f.results = new sc.ImmutableGetRequestIDsForBlockResults(wasmlib.newCallResultsProxy(f.func)); return f; } - static getRequestReceipt(ctx: wasmlib.ScViewCallContext): GetRequestReceiptCall { + static getRequestReceipt(_ctx: wasmlib.ScViewCallContext): GetRequestReceiptCall { const f = new GetRequestReceiptCall(); f.params = new sc.MutableGetRequestReceiptParams(wasmlib.newCallParamsProxy(f.func)); f.results = new sc.ImmutableGetRequestReceiptResults(wasmlib.newCallResultsProxy(f.func)); return f; } - static getRequestReceiptsForBlock(ctx: wasmlib.ScViewCallContext): GetRequestReceiptsForBlockCall { + static getRequestReceiptsForBlock(_ctx: wasmlib.ScViewCallContext): GetRequestReceiptsForBlockCall { const f = new GetRequestReceiptsForBlockCall(); f.params = new sc.MutableGetRequestReceiptsForBlockParams(wasmlib.newCallParamsProxy(f.func)); f.results = new sc.ImmutableGetRequestReceiptsForBlockResults(wasmlib.newCallResultsProxy(f.func)); return f; } - static isRequestProcessed(ctx: wasmlib.ScViewCallContext): IsRequestProcessedCall { + static isRequestProcessed(_ctx: wasmlib.ScViewCallContext): IsRequestProcessedCall { const f = new IsRequestProcessedCall(); f.params = new sc.MutableIsRequestProcessedParams(wasmlib.newCallParamsProxy(f.func)); f.results = new sc.ImmutableIsRequestProcessedResults(wasmlib.newCallResultsProxy(f.func)); diff --git a/packages/wasmvm/wasmlib/ts/wasmlib/coreblocklog/params.ts b/packages/wasmvm/wasmlib/ts/wasmlib/coreblocklog/params.ts index 217837ec0e..1fb32f8ce3 100644 --- a/packages/wasmvm/wasmlib/ts/wasmlib/coreblocklog/params.ts +++ b/packages/wasmvm/wasmlib/ts/wasmlib/coreblocklog/params.ts @@ -5,7 +5,6 @@ // >>>> DO NOT CHANGE THIS FILE! <<<< // Change the json schema instead -import * as wasmlib from "wasmlib"; import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; diff --git a/packages/wasmvm/wasmlib/ts/wasmlib/coreblocklog/results.ts b/packages/wasmvm/wasmlib/ts/wasmlib/coreblocklog/results.ts index ac4f341d57..3efc770521 100644 --- a/packages/wasmvm/wasmlib/ts/wasmlib/coreblocklog/results.ts +++ b/packages/wasmvm/wasmlib/ts/wasmlib/coreblocklog/results.ts @@ -5,7 +5,6 @@ // >>>> DO NOT CHANGE THIS FILE! <<<< // Change the json schema instead -import * as wasmlib from "wasmlib"; import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; diff --git a/packages/wasmvm/wasmlib/ts/wasmlib/coregovernance/contract.ts b/packages/wasmvm/wasmlib/ts/wasmlib/coregovernance/contract.ts index eb958607f4..f195b29b8a 100644 --- a/packages/wasmvm/wasmlib/ts/wasmlib/coregovernance/contract.ts +++ b/packages/wasmvm/wasmlib/ts/wasmlib/coregovernance/contract.ts @@ -6,7 +6,6 @@ // Change the json schema instead import * as wasmlib from "wasmlib"; -import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; export class AddAllowedStateControllerAddressCall { @@ -70,72 +69,72 @@ export class GetMaxBlobSizeCall { } export class ScFuncs { - static addAllowedStateControllerAddress(ctx: wasmlib.ScFuncCallContext): AddAllowedStateControllerAddressCall { + static addAllowedStateControllerAddress(_ctx: wasmlib.ScFuncCallContext): AddAllowedStateControllerAddressCall { const f = new AddAllowedStateControllerAddressCall(); f.params = new sc.MutableAddAllowedStateControllerAddressParams(wasmlib.newCallParamsProxy(f.func)); return f; } - static claimChainOwnership(ctx: wasmlib.ScFuncCallContext): ClaimChainOwnershipCall { + static claimChainOwnership(_ctx: wasmlib.ScFuncCallContext): ClaimChainOwnershipCall { return new ClaimChainOwnershipCall(); } - static delegateChainOwnership(ctx: wasmlib.ScFuncCallContext): DelegateChainOwnershipCall { + static delegateChainOwnership(_ctx: wasmlib.ScFuncCallContext): DelegateChainOwnershipCall { const f = new DelegateChainOwnershipCall(); f.params = new sc.MutableDelegateChainOwnershipParams(wasmlib.newCallParamsProxy(f.func)); return f; } - static removeAllowedStateControllerAddress(ctx: wasmlib.ScFuncCallContext): RemoveAllowedStateControllerAddressCall { + static removeAllowedStateControllerAddress(_ctx: wasmlib.ScFuncCallContext): RemoveAllowedStateControllerAddressCall { const f = new RemoveAllowedStateControllerAddressCall(); f.params = new sc.MutableRemoveAllowedStateControllerAddressParams(wasmlib.newCallParamsProxy(f.func)); return f; } - static rotateStateController(ctx: wasmlib.ScFuncCallContext): RotateStateControllerCall { + static rotateStateController(_ctx: wasmlib.ScFuncCallContext): RotateStateControllerCall { const f = new RotateStateControllerCall(); f.params = new sc.MutableRotateStateControllerParams(wasmlib.newCallParamsProxy(f.func)); return f; } - static setChainInfo(ctx: wasmlib.ScFuncCallContext): SetChainInfoCall { + static setChainInfo(_ctx: wasmlib.ScFuncCallContext): SetChainInfoCall { const f = new SetChainInfoCall(); f.params = new sc.MutableSetChainInfoParams(wasmlib.newCallParamsProxy(f.func)); return f; } - static setContractFee(ctx: wasmlib.ScFuncCallContext): SetContractFeeCall { + static setContractFee(_ctx: wasmlib.ScFuncCallContext): SetContractFeeCall { const f = new SetContractFeeCall(); f.params = new sc.MutableSetContractFeeParams(wasmlib.newCallParamsProxy(f.func)); return f; } - static setDefaultFee(ctx: wasmlib.ScFuncCallContext): SetDefaultFeeCall { + static setDefaultFee(_ctx: wasmlib.ScFuncCallContext): SetDefaultFeeCall { const f = new SetDefaultFeeCall(); f.params = new sc.MutableSetDefaultFeeParams(wasmlib.newCallParamsProxy(f.func)); return f; } - static getAllowedStateControllerAddresses(ctx: wasmlib.ScViewCallContext): GetAllowedStateControllerAddressesCall { + static getAllowedStateControllerAddresses(_ctx: wasmlib.ScViewCallContext): GetAllowedStateControllerAddressesCall { const f = new GetAllowedStateControllerAddressesCall(); f.results = new sc.ImmutableGetAllowedStateControllerAddressesResults(wasmlib.newCallResultsProxy(f.func)); return f; } - static getChainInfo(ctx: wasmlib.ScViewCallContext): GetChainInfoCall { + static getChainInfo(_ctx: wasmlib.ScViewCallContext): GetChainInfoCall { const f = new GetChainInfoCall(); f.results = new sc.ImmutableGetChainInfoResults(wasmlib.newCallResultsProxy(f.func)); return f; } - static getFeeInfo(ctx: wasmlib.ScViewCallContext): GetFeeInfoCall { + static getFeeInfo(_ctx: wasmlib.ScViewCallContext): GetFeeInfoCall { const f = new GetFeeInfoCall(); f.params = new sc.MutableGetFeeInfoParams(wasmlib.newCallParamsProxy(f.func)); f.results = new sc.ImmutableGetFeeInfoResults(wasmlib.newCallResultsProxy(f.func)); return f; } - static getMaxBlobSize(ctx: wasmlib.ScViewCallContext): GetMaxBlobSizeCall { + static getMaxBlobSize(_ctx: wasmlib.ScViewCallContext): GetMaxBlobSizeCall { const f = new GetMaxBlobSizeCall(); f.results = new sc.ImmutableGetMaxBlobSizeResults(wasmlib.newCallResultsProxy(f.func)); return f; diff --git a/packages/wasmvm/wasmlib/ts/wasmlib/coregovernance/params.ts b/packages/wasmvm/wasmlib/ts/wasmlib/coregovernance/params.ts index c504ac74f3..7ce1f8ac89 100644 --- a/packages/wasmvm/wasmlib/ts/wasmlib/coregovernance/params.ts +++ b/packages/wasmvm/wasmlib/ts/wasmlib/coregovernance/params.ts @@ -5,7 +5,6 @@ // >>>> DO NOT CHANGE THIS FILE! <<<< // Change the json schema instead -import * as wasmlib from "wasmlib"; import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; diff --git a/packages/wasmvm/wasmlib/ts/wasmlib/coregovernance/results.ts b/packages/wasmvm/wasmlib/ts/wasmlib/coregovernance/results.ts index 00ff0db5d7..70f5454673 100644 --- a/packages/wasmvm/wasmlib/ts/wasmlib/coregovernance/results.ts +++ b/packages/wasmvm/wasmlib/ts/wasmlib/coregovernance/results.ts @@ -5,7 +5,6 @@ // >>>> DO NOT CHANGE THIS FILE! <<<< // Change the json schema instead -import * as wasmlib from "wasmlib"; import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; diff --git a/packages/wasmvm/wasmlib/ts/wasmlib/coreroot/contract.ts b/packages/wasmvm/wasmlib/ts/wasmlib/coreroot/contract.ts index e092db33b9..76475372c1 100644 --- a/packages/wasmvm/wasmlib/ts/wasmlib/coreroot/contract.ts +++ b/packages/wasmvm/wasmlib/ts/wasmlib/coreroot/contract.ts @@ -6,7 +6,6 @@ // Change the json schema instead import * as wasmlib from "wasmlib"; -import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; export class DeployContractCall { @@ -36,32 +35,32 @@ export class GetContractRecordsCall { } export class ScFuncs { - static deployContract(ctx: wasmlib.ScFuncCallContext): DeployContractCall { + static deployContract(_ctx: wasmlib.ScFuncCallContext): DeployContractCall { const f = new DeployContractCall(); f.params = new sc.MutableDeployContractParams(wasmlib.newCallParamsProxy(f.func)); return f; } - static grantDeployPermission(ctx: wasmlib.ScFuncCallContext): GrantDeployPermissionCall { + static grantDeployPermission(_ctx: wasmlib.ScFuncCallContext): GrantDeployPermissionCall { const f = new GrantDeployPermissionCall(); f.params = new sc.MutableGrantDeployPermissionParams(wasmlib.newCallParamsProxy(f.func)); return f; } - static revokeDeployPermission(ctx: wasmlib.ScFuncCallContext): RevokeDeployPermissionCall { + static revokeDeployPermission(_ctx: wasmlib.ScFuncCallContext): RevokeDeployPermissionCall { const f = new RevokeDeployPermissionCall(); f.params = new sc.MutableRevokeDeployPermissionParams(wasmlib.newCallParamsProxy(f.func)); return f; } - static findContract(ctx: wasmlib.ScViewCallContext): FindContractCall { + static findContract(_ctx: wasmlib.ScViewCallContext): FindContractCall { const f = new FindContractCall(); f.params = new sc.MutableFindContractParams(wasmlib.newCallParamsProxy(f.func)); f.results = new sc.ImmutableFindContractResults(wasmlib.newCallResultsProxy(f.func)); return f; } - static getContractRecords(ctx: wasmlib.ScViewCallContext): GetContractRecordsCall { + static getContractRecords(_ctx: wasmlib.ScViewCallContext): GetContractRecordsCall { const f = new GetContractRecordsCall(); f.results = new sc.ImmutableGetContractRecordsResults(wasmlib.newCallResultsProxy(f.func)); return f; diff --git a/packages/wasmvm/wasmlib/ts/wasmlib/coreroot/params.ts b/packages/wasmvm/wasmlib/ts/wasmlib/coreroot/params.ts index a06c8a699f..10a1ed4d0d 100644 --- a/packages/wasmvm/wasmlib/ts/wasmlib/coreroot/params.ts +++ b/packages/wasmvm/wasmlib/ts/wasmlib/coreroot/params.ts @@ -5,7 +5,6 @@ // >>>> DO NOT CHANGE THIS FILE! <<<< // Change the json schema instead -import * as wasmlib from "wasmlib"; import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; diff --git a/packages/wasmvm/wasmlib/ts/wasmlib/coreroot/results.ts b/packages/wasmvm/wasmlib/ts/wasmlib/coreroot/results.ts index b35ef2e0b3..08d99bede2 100644 --- a/packages/wasmvm/wasmlib/ts/wasmlib/coreroot/results.ts +++ b/packages/wasmvm/wasmlib/ts/wasmlib/coreroot/results.ts @@ -5,7 +5,6 @@ // >>>> DO NOT CHANGE THIS FILE! <<<< // Change the json schema instead -import * as wasmlib from "wasmlib"; import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; diff --git a/packages/wasmvm/wasmlib/ts/wasmlib/wasmrequests/contract.ts b/packages/wasmvm/wasmlib/ts/wasmlib/wasmrequests/contract.ts index 2ca7e6369c..227f20d89d 100644 --- a/packages/wasmvm/wasmlib/ts/wasmlib/wasmrequests/contract.ts +++ b/packages/wasmvm/wasmlib/ts/wasmlib/wasmrequests/contract.ts @@ -6,7 +6,6 @@ // Change the json schema instead import * as wasmlib from "wasmlib"; -import * as wasmtypes from "wasmlib/wasmtypes"; import * as sc from "./index"; export class ScFuncs { diff --git a/packages/wasmvm/wasmlib/ts/wasmlib/wasmrequests/structs.ts b/packages/wasmvm/wasmlib/ts/wasmlib/wasmrequests/structs.ts index f54abe9321..07764cac3f 100644 --- a/packages/wasmvm/wasmlib/ts/wasmlib/wasmrequests/structs.ts +++ b/packages/wasmvm/wasmlib/ts/wasmlib/wasmrequests/structs.ts @@ -5,7 +5,6 @@ // >>>> DO NOT CHANGE THIS FILE! <<<< // Change the json schema instead -import * as wasmlib from "wasmlib"; import * as wasmtypes from "wasmlib/wasmtypes"; export class CallRequest { diff --git a/tools/schema/generator/tstemplates/alltemplates.go b/tools/schema/generator/tstemplates/alltemplates.go index 1262251c34..ef8a9304d3 100644 --- a/tools/schema/generator/tstemplates/alltemplates.go +++ b/tools/schema/generator/tstemplates/alltemplates.go @@ -81,12 +81,6 @@ import * as wasmtypes from "wasmlib/wasmtypes"; // ******************************* "importSc": ` import * as sc from "./index"; -`, - // ******************************* - "tsImports": ` -$#emit importWasmLib -$#emit importWasmTypes -$#emit importSc `, // ******************************* "tsconfig.json": ` diff --git a/tools/schema/generator/tstemplates/contract.go b/tools/schema/generator/tstemplates/contract.go index 7bd087692d..9c5baf6f5d 100644 --- a/tools/schema/generator/tstemplates/contract.go +++ b/tools/schema/generator/tstemplates/contract.go @@ -3,7 +3,8 @@ package tstemplates var contractTs = map[string]string{ // ******************************* "contract.ts": ` -$#emit tsImports +$#emit importWasmLib +$#emit importSc $#each func FuncNameCall export class ScFuncs { @@ -70,7 +71,7 @@ $#if events PackageEventsExist $#emit setupInitFunc $#if separator newline $#set separator $true - static $funcName(ctx: wasmlib.Sc$Kind$+CallContext): $FuncName$+Call { + static $funcName(_ctx: wasmlib.Sc$Kind$+CallContext): $FuncName$+Call { $#if ptrs setPtrs noPtrs } `, diff --git a/tools/schema/generator/tstemplates/funcs.go b/tools/schema/generator/tstemplates/funcs.go index 271f248056..3ed3f8e471 100644 --- a/tools/schema/generator/tstemplates/funcs.go +++ b/tools/schema/generator/tstemplates/funcs.go @@ -3,7 +3,9 @@ package tstemplates var funcsTs = map[string]string{ // ******************************* "funcs.ts": ` -$#emit tsImports +$#emit importWasmLib +$#emit importWasmTypes +$#emit importSc $#each func funcSignature `, // ******************************* diff --git a/tools/schema/generator/tstemplates/lib.go b/tools/schema/generator/tstemplates/lib.go index 4a13c90a59..1cfb792ec4 100644 --- a/tools/schema/generator/tstemplates/lib.go +++ b/tools/schema/generator/tstemplates/lib.go @@ -3,7 +3,8 @@ package tstemplates var libTs = map[string]string{ // ******************************* "lib.ts": ` -$#emit tsImports +$#emit importWasmLib +$#emit importSc export function on_call(index: i32): void { return wasmlib.onCall(index); diff --git a/tools/schema/generator/tstemplates/params.go b/tools/schema/generator/tstemplates/params.go index 1ed8053884..b82de4d04f 100644 --- a/tools/schema/generator/tstemplates/params.go +++ b/tools/schema/generator/tstemplates/params.go @@ -3,7 +3,8 @@ package tstemplates var paramsTs = map[string]string{ // ******************************* "params.ts": ` -$#emit tsImports +$#emit importWasmTypes +$#emit importSc $#each func paramsFunc `, // ******************************* diff --git a/tools/schema/generator/tstemplates/results.go b/tools/schema/generator/tstemplates/results.go index f0594f6c56..c517a24222 100644 --- a/tools/schema/generator/tstemplates/results.go +++ b/tools/schema/generator/tstemplates/results.go @@ -3,7 +3,8 @@ package tstemplates var resultsTs = map[string]string{ // ******************************* "results.ts": ` -$#emit tsImports +$#emit importWasmTypes +$#emit importSc $#each func resultsFunc `, // ******************************* diff --git a/tools/schema/generator/tstemplates/state.go b/tools/schema/generator/tstemplates/state.go index b44d6e5908..bea2f31fbe 100644 --- a/tools/schema/generator/tstemplates/state.go +++ b/tools/schema/generator/tstemplates/state.go @@ -3,7 +3,8 @@ package tstemplates var stateTs = map[string]string{ // ******************************* "state.ts": ` -$#emit tsImports +$#emit importWasmTypes +$#emit importSc $#set Kind State $#set mut Immutable $#emit stateProxyStruct diff --git a/tools/schema/generator/tstemplates/structs.go b/tools/schema/generator/tstemplates/structs.go index 3ff7cb126f..b240727156 100644 --- a/tools/schema/generator/tstemplates/structs.go +++ b/tools/schema/generator/tstemplates/structs.go @@ -3,7 +3,6 @@ package tstemplates var structsTs = map[string]string{ // ******************************* "structs.ts": ` -$#emit importWasmLib $#emit importWasmTypes $#each structs structType `, diff --git a/tools/schema/generator/tstemplates/typedefs.go b/tools/schema/generator/tstemplates/typedefs.go index 2d7f8a74cc..47826fe417 100644 --- a/tools/schema/generator/tstemplates/typedefs.go +++ b/tools/schema/generator/tstemplates/typedefs.go @@ -3,7 +3,8 @@ package tstemplates var typedefsTs = map[string]string{ // ******************************* "typedefs.ts": ` -$#emit tsImports +$#emit importWasmTypes +$#emit importSc $#each typedef typedefProxy `, // ******************************* @@ -23,7 +24,7 @@ $#if map typedefProxyAlias "typedefProxyAlias": ` export class $mut$FldName extends $proxy { -}; +} `, // ******************************* "typedefProxyArray": ` From 58f3a198b3b731fd8abd7461cc5a7c396d63d89d Mon Sep 17 00:00:00 2001 From: Eric Hop Date: Fri, 4 Feb 2022 07:46:03 -0800 Subject: [PATCH 063/111] Cleaned up wasmhost sandbox code --- packages/wasmvm/wasmhost/wasmcontext.go | 4 +- packages/wasmvm/wasmhost/wasmhostsandbox.go | 415 ++++++++++++++++++ packages/wasmvm/wasmhost/wasmtosandbox.go | 301 ------------- .../wasmvm/wasmhost/wasmtosandboxtrace.go | 60 --- .../wasmvm/wasmhost/wasmtosandboxutils.go | 78 ---- packages/wasmvm/wasmhost/wasmvm.go | 13 +- packages/wasmvm/wasmvmhost/host.go | 2 +- tools/schema/generator/gotemplates/lib.go | 9 +- tools/schema/generator/rstemplates/lib.go | 10 +- tools/schema/generator/rstemplates/proxy.go | 4 +- 10 files changed, 441 insertions(+), 455 deletions(-) create mode 100644 packages/wasmvm/wasmhost/wasmhostsandbox.go delete mode 100644 packages/wasmvm/wasmhost/wasmtosandbox.go delete mode 100644 packages/wasmvm/wasmhost/wasmtosandboxtrace.go delete mode 100644 packages/wasmvm/wasmhost/wasmtosandboxutils.go diff --git a/packages/wasmvm/wasmhost/wasmcontext.go b/packages/wasmvm/wasmhost/wasmcontext.go index 9d1241abef..8835d5e494 100644 --- a/packages/wasmvm/wasmhost/wasmcontext.go +++ b/packages/wasmvm/wasmhost/wasmcontext.go @@ -21,7 +21,7 @@ type WasmContext struct { host *WasmHost mini ISandbox proc *WasmProcessor - sandbox *WasmToSandbox + sandbox *WasmHostSandbox results dict.Dict } @@ -53,7 +53,7 @@ func (wc *WasmContext) Call(ctx interface{}) (dict.Dict, error) { panic("Context id is zero") } - wc.sandbox = NewWasmToSandbox(wc, ctx) + wc.sandbox = NewWasmHostSandbox(wc, ctx) wc.mini = wc.sandbox wcSaved := Connect(wc) diff --git a/packages/wasmvm/wasmhost/wasmhostsandbox.go b/packages/wasmvm/wasmhost/wasmhostsandbox.go new file mode 100644 index 0000000000..a974f80819 --- /dev/null +++ b/packages/wasmvm/wasmhost/wasmhostsandbox.go @@ -0,0 +1,415 @@ +// Copyright 2020 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +package wasmhost + +import ( + "time" + + "github.com/iotaledger/goshimmer/packages/ledgerstate" + "github.com/iotaledger/wasp/packages/hashing" + "github.com/iotaledger/wasp/packages/iscp" + "github.com/iotaledger/wasp/packages/iscp/colored" + "github.com/iotaledger/wasp/packages/kv/codec" + "github.com/iotaledger/wasp/packages/kv/dict" + "github.com/iotaledger/wasp/packages/wasmvm/wasmlib/go/wasmlib/wasmrequests" + "github.com/iotaledger/wasp/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes" +) + +// NOTE: These functions correspond to the Sandbox fnXxx constants in WasmLib +var sandboxFunctions = []func(*WasmHostSandbox, []byte) []byte{ + nil, + (*WasmHostSandbox).fnAccountID, + (*WasmHostSandbox).fnBalance, + (*WasmHostSandbox).fnBalances, + (*WasmHostSandbox).fnBlockContext, + (*WasmHostSandbox).fnCall, + (*WasmHostSandbox).fnCaller, + (*WasmHostSandbox).fnChainID, + (*WasmHostSandbox).fnChainOwnerID, + (*WasmHostSandbox).fnContract, + (*WasmHostSandbox).fnContractCreator, + (*WasmHostSandbox).fnDeployContract, + (*WasmHostSandbox).fnEntropy, + (*WasmHostSandbox).fnEvent, + (*WasmHostSandbox).fnIncomingTransfer, + (*WasmHostSandbox).fnLog, + (*WasmHostSandbox).fnMinted, + (*WasmHostSandbox).fnPanic, + (*WasmHostSandbox).fnParams, + (*WasmHostSandbox).fnPost, + (*WasmHostSandbox).fnRequest, + (*WasmHostSandbox).fnRequestID, + (*WasmHostSandbox).fnResults, + (*WasmHostSandbox).fnSend, + (*WasmHostSandbox).fnStateAnchor, + (*WasmHostSandbox).fnTimestamp, + (*WasmHostSandbox).fnTrace, + (*WasmHostSandbox).fnUtilsBase58Decode, + (*WasmHostSandbox).fnUtilsBase58Encode, + (*WasmHostSandbox).fnUtilsBlsAddress, + (*WasmHostSandbox).fnUtilsBlsAggregate, + (*WasmHostSandbox).fnUtilsBlsValid, + (*WasmHostSandbox).fnUtilsEd25519Address, + (*WasmHostSandbox).fnUtilsEd25519Valid, + (*WasmHostSandbox).fnUtilsHashBlake2b, + (*WasmHostSandbox).fnUtilsHashName, + (*WasmHostSandbox).fnUtilsHashSha3, +} + +// '$' prefix indicates a string param +// '$' prefix indicates a bytes param +// otherwise there is no param +// NOTE: These strings correspond to the Sandbox fnXxx constants in WasmLib +var sandboxFuncNames = []string{ + "nil", + "FnAccountID", + "#FnBalance", + "FnBalances", + "FnBlockContext", + "FnCall", + "FnCaller", + "FnChainID", + "FnChainOwnerID", + "FnContract", + "FnContractCreator", + "#FnDeployContract", + "FnEntropy", + "$FnEvent", + "FnIncomingTransfer", + "$FnLog", + "FnMinted", + "$FnPanic", + "FnParams", + "#FnPost", + "FnRequest", + "FnRequestID", + "#FnResults", + "#FnSend", + "#FnStateAnchor", + "FnTimestamp", + "$FnTrace", + "$FnUtilsBase58Decode", + "#FnUtilsBase58Encode", + "#FnUtilsBlsAddress", + "#FnUtilsBlsAggregate", + "#FnUtilsBlsValid", + "#FnUtilsEd25519Address", + "#FnUtilsEd25519Valid", + "#FnUtilsHashBlake2b", + "$FnUtilsHashName", + "#FnUtilsHashSha3", +} + +type WasmHostSandbox struct { + common iscp.SandboxBase + ctx iscp.Sandbox + ctxView iscp.SandboxView + wc *WasmContext +} + +var _ ISandbox = new(WasmHostSandbox) + +func NewWasmHostSandbox(wc *WasmContext, ctx interface{}) *WasmHostSandbox { + s := new(WasmHostSandbox) + s.wc = wc + switch tctx := ctx.(type) { + case iscp.Sandbox: + s.common = tctx + s.ctx = tctx + case iscp.SandboxView: + s.common = tctx + s.ctxView = tctx + default: + panic(iscp.ErrWrongTypeEntryPoint) + } + return s +} + +func (s *WasmHostSandbox) Call(funcNr int32, params []byte) []byte { + return sandboxFunctions[-funcNr](s, params) +} + +func (s *WasmHostSandbox) checkErr(err error) { + if err != nil { + s.Panicf(err.Error()) + } +} + +func (s *WasmHostSandbox) Panicf(format string, args ...interface{}) { + s.common.Log().Panicf(format, args...) +} + +func (s *WasmHostSandbox) Tracef(format string, args ...interface{}) { + s.common.Log().Debugf(format, args...) +} + +//////////////////// sandbox functions \\\\\\\\\\\\\\\\\\\\ + +func (s *WasmHostSandbox) fnAccountID(args []byte) []byte { + return s.common.AccountID().Bytes() +} + +func (s *WasmHostSandbox) fnBalance(args []byte) []byte { + color, err := colored.ColorFromBytes(args) + s.checkErr(err) + return codec.EncodeUint64(s.ctx.Balance(color)) +} + +func (s *WasmHostSandbox) fnBalances(args []byte) []byte { + return s.common.Balances().Bytes() +} + +func (s *WasmHostSandbox) fnBlockContext(args []byte) []byte { + panic("implement me") +} + +func (s *WasmHostSandbox) fnCall(args []byte) []byte { + req := wasmrequests.NewCallRequestFromBytes(args) + contract, err := iscp.HnameFromBytes(req.Contract.Bytes()) + s.checkErr(err) + function, err := iscp.HnameFromBytes(req.Function.Bytes()) + s.checkErr(err) + params, err := dict.FromBytes(req.Params) + s.checkErr(err) + transfer, err := colored.BalancesFromBytes(req.Transfer) + s.checkErr(err) + s.Tracef("CALL hContract '%s, hFunction %s", contract.String(), function.String()) + results, err := s.callUnlocked(contract, function, params, transfer) + s.checkErr(err) + return results.Bytes() +} + +func (s *WasmHostSandbox) callUnlocked(contract, function iscp.Hname, params dict.Dict, transfer colored.Balances) (dict.Dict, error) { + s.wc.proc.instanceLock.Unlock() + defer s.wc.proc.instanceLock.Lock() + + if s.ctx != nil { + return s.ctx.Call(contract, function, params, transfer) + } + return s.ctxView.Call(contract, function, params) +} + +func (s *WasmHostSandbox) fnCaller(args []byte) []byte { + return s.ctx.Caller().Bytes() +} + +func (s *WasmHostSandbox) fnChainID(args []byte) []byte { + return s.common.ChainID().Bytes() +} + +func (s *WasmHostSandbox) fnChainOwnerID(args []byte) []byte { + return s.common.ChainOwnerID().Bytes() +} + +func (s *WasmHostSandbox) fnContract(args []byte) []byte { + return s.common.Contract().Bytes() +} + +func (s *WasmHostSandbox) fnContractCreator(args []byte) []byte { + return s.common.ContractCreator().Bytes() +} + +func (s *WasmHostSandbox) fnDeployContract(args []byte) []byte { + req := wasmrequests.NewDeployRequestFromBytes(args) + programHash, err := hashing.HashValueFromBytes(req.ProgHash.Bytes()) + s.checkErr(err) + initParams, err := dict.FromBytes(req.Params) + s.checkErr(err) + s.Tracef("DEPLOY %s: %s", req.Name, req.Description) + err = s.deployUnlocked(programHash, req.Name, req.Description, initParams) + s.checkErr(err) + return nil +} + +func (s *WasmHostSandbox) deployUnlocked(programHash hashing.HashValue, name, description string, params dict.Dict) error { + s.wc.proc.instanceLock.Unlock() + defer s.wc.proc.instanceLock.Lock() + + return s.ctx.DeployContract(programHash, name, description, params) +} + +func (s *WasmHostSandbox) fnEntropy(args []byte) []byte { + return s.ctx.GetEntropy().Bytes() +} + +func (s *WasmHostSandbox) fnEvent(args []byte) []byte { + s.ctx.Event(string(args)) + return nil +} + +func (s *WasmHostSandbox) fnIncomingTransfer(args []byte) []byte { + return s.ctx.IncomingTransfer().Bytes() +} + +func (s *WasmHostSandbox) fnLog(args []byte) []byte { + s.common.Log().Infof(string(args)) + return nil +} + +func (s *WasmHostSandbox) fnMinted(args []byte) []byte { + return s.ctx.Minted().Bytes() +} + +func (s *WasmHostSandbox) fnPanic(args []byte) []byte { + s.common.Log().Panicf("WASM panic: %s", string(args)) + return nil +} + +func (s *WasmHostSandbox) fnParams(args []byte) []byte { + return s.common.Params().Bytes() +} + +func (s *WasmHostSandbox) fnPost(args []byte) []byte { + req := wasmrequests.NewPostRequestFromBytes(args) + chainID, err := iscp.ChainIDFromBytes(req.ChainID.Bytes()) + s.checkErr(err) + contract, err := iscp.HnameFromBytes(req.Contract.Bytes()) + s.checkErr(err) + function, err := iscp.HnameFromBytes(req.Function.Bytes()) + s.checkErr(err) + params, err := dict.FromBytes(req.Params) + s.checkErr(err) + transfer, err := colored.BalancesFromBytes(req.Transfer) + s.checkErr(err) + if len(transfer) == 0 { + s.Panicf("transfer is required for post") + } + + s.Tracef("POST hContract '%s, hFunction %s, chain ", contract.String(), function.String(), chainID.String()) + metadata := &iscp.SendMetadata{ + TargetContract: contract, + EntryPoint: function, + Args: params, + } + if req.Delay == 0 { + if !s.ctx.Send(chainID.AsAddress(), transfer, metadata) { + s.Panicf("failed to send to %s", chainID.AsAddress().String()) + } + return nil + } + + timeLock := time.Unix(0, s.ctx.GetTimestamp()) + timeLock = timeLock.Add(time.Duration(req.Delay) * time.Second) + options := iscp.SendOptions{ + TimeLock: uint32(timeLock.Unix()), + } + if !s.ctx.Send(chainID.AsAddress(), transfer, metadata, options) { + s.Panicf("failed to send to %s", chainID.AsAddress().String()) + } + return nil +} + +func (s *WasmHostSandbox) fnRequest(args []byte) []byte { + return s.ctx.Request().Bytes() +} + +func (s *WasmHostSandbox) fnRequestID(args []byte) []byte { + return s.ctx.Request().ID().Bytes() +} + +func (s *WasmHostSandbox) fnResults(args []byte) []byte { + results, err := dict.FromBytes(args) + if err != nil { + s.Panicf("call results: %s", err.Error()) + } + s.wc.results = results + return nil +} + +// transfer tokens to address +func (s *WasmHostSandbox) fnSend(args []byte) []byte { + req := wasmrequests.NewSendRequestFromBytes(args) + address, _, err := ledgerstate.AddressFromBytes(req.Address.Bytes()) + s.checkErr(err) + transfer, err := colored.BalancesFromBytes(req.Transfer) + s.checkErr(err) + if len(transfer) != 0 { + if !s.ctx.Send(address, transfer, nil) { + s.Panicf("failed to send to %s", address.String()) + } + } + return nil +} + +func (s *WasmHostSandbox) fnStateAnchor(args []byte) []byte { + panic("implement me") +} + +func (s *WasmHostSandbox) fnTimestamp(args []byte) []byte { + return codec.EncodeInt64(s.common.GetTimestamp()) +} + +func (s *WasmHostSandbox) fnTrace(args []byte) []byte { + s.common.Log().Debugf(string(args)) + return nil +} + +func (s WasmHostSandbox) fnUtilsBase58Decode(args []byte) []byte { + bytes, err := s.common.Utils().Base58().Decode(string(args)) + s.checkErr(err) + return bytes +} + +func (s WasmHostSandbox) fnUtilsBase58Encode(args []byte) []byte { + return []byte(s.common.Utils().Base58().Encode(args)) +} + +func (s WasmHostSandbox) fnUtilsBlsAddress(args []byte) []byte { + address, err := s.common.Utils().BLS().AddressFromPublicKey(args) + s.checkErr(err) + return address.Bytes() +} + +func (s WasmHostSandbox) fnUtilsBlsAggregate(args []byte) []byte { + dec := wasmtypes.NewWasmDecoder(args) + count := wasmtypes.Uint32Decode(dec) + pubKeysBin := make([][]byte, count) + for i := uint32(0); i < count; i++ { + pubKeysBin[i] = dec.Bytes() + } + count = wasmtypes.Uint32Decode(dec) + sigsBin := make([][]byte, count) + for i := uint32(0); i < count; i++ { + sigsBin[i] = dec.Bytes() + } + pubKeyBin, sigBin, err := s.common.Utils().BLS().AggregateBLSSignatures(pubKeysBin, sigsBin) + s.checkErr(err) + return wasmtypes.NewWasmEncoder().Bytes(pubKeyBin).Bytes(sigBin).Buf() +} + +func (s WasmHostSandbox) fnUtilsBlsValid(args []byte) []byte { + dec := wasmtypes.NewWasmDecoder(args) + data := dec.Bytes() + pubKey := dec.Bytes() + signature := dec.Bytes() + valid := s.common.Utils().BLS().ValidSignature(data, pubKey, signature) + return codec.EncodeBool(valid) +} + +func (s WasmHostSandbox) fnUtilsEd25519Address(args []byte) []byte { + address, err := s.common.Utils().ED25519().AddressFromPublicKey(args) + s.checkErr(err) + return address.Bytes() +} + +func (s WasmHostSandbox) fnUtilsEd25519Valid(args []byte) []byte { + dec := wasmtypes.NewWasmDecoder(args) + data := dec.Bytes() + pubKey := dec.Bytes() + signature := dec.Bytes() + valid := s.common.Utils().ED25519().ValidSignature(data, pubKey, signature) + return codec.EncodeBool(valid) +} + +func (s WasmHostSandbox) fnUtilsHashBlake2b(args []byte) []byte { + return s.common.Utils().Hashing().Blake2b(args).Bytes() +} + +func (s WasmHostSandbox) fnUtilsHashName(args []byte) []byte { + return codec.EncodeHname(s.common.Utils().Hashing().Hname(string(args))) +} + +func (s WasmHostSandbox) fnUtilsHashSha3(args []byte) []byte { + return s.common.Utils().Hashing().Sha3(args).Bytes() +} diff --git a/packages/wasmvm/wasmhost/wasmtosandbox.go b/packages/wasmvm/wasmhost/wasmtosandbox.go deleted file mode 100644 index 23cf2cf70a..0000000000 --- a/packages/wasmvm/wasmhost/wasmtosandbox.go +++ /dev/null @@ -1,301 +0,0 @@ -// Copyright 2020 IOTA Stiftung -// SPDX-License-Identifier: Apache-2.0 - -package wasmhost - -import ( - "time" - - "github.com/iotaledger/goshimmer/packages/ledgerstate" - "github.com/iotaledger/wasp/packages/hashing" - "github.com/iotaledger/wasp/packages/iscp" - "github.com/iotaledger/wasp/packages/iscp/colored" - "github.com/iotaledger/wasp/packages/kv/codec" - "github.com/iotaledger/wasp/packages/kv/dict" - "github.com/iotaledger/wasp/packages/wasmvm/wasmlib/go/wasmlib/wasmrequests" -) - -// NOTE: These functions correspond to the Sandbox fnXxx constants in WasmLib -var sandboxFunctions = []func(*WasmToSandbox, []byte) []byte{ - nil, - (*WasmToSandbox).fnAccountID, - (*WasmToSandbox).fnBalance, - (*WasmToSandbox).fnBalances, - (*WasmToSandbox).fnBlockContext, - (*WasmToSandbox).fnCall, - (*WasmToSandbox).fnCaller, - (*WasmToSandbox).fnChainID, - (*WasmToSandbox).fnChainOwnerID, - (*WasmToSandbox).fnContract, - (*WasmToSandbox).fnContractCreator, - (*WasmToSandbox).fnDeployContract, - (*WasmToSandbox).fnEntropy, - (*WasmToSandbox).fnEvent, - (*WasmToSandbox).fnIncomingTransfer, - (*WasmToSandbox).fnLog, - (*WasmToSandbox).fnMinted, - (*WasmToSandbox).fnPanic, - (*WasmToSandbox).fnParams, - (*WasmToSandbox).fnPost, - (*WasmToSandbox).fnRequest, - (*WasmToSandbox).fnRequestID, - (*WasmToSandbox).fnResults, - (*WasmToSandbox).fnSend, - (*WasmToSandbox).fnStateAnchor, - (*WasmToSandbox).fnTimestamp, - (*WasmToSandbox).fnTrace, - (*WasmToSandbox).fnUtilsBase58Decode, - (*WasmToSandbox).fnUtilsBase58Encode, - (*WasmToSandbox).fnUtilsBlsAddress, - (*WasmToSandbox).fnUtilsBlsAggregate, - (*WasmToSandbox).fnUtilsBlsValid, - (*WasmToSandbox).fnUtilsEd25519Address, - (*WasmToSandbox).fnUtilsEd25519Valid, - (*WasmToSandbox).fnUtilsHashBlake2b, - (*WasmToSandbox).fnUtilsHashName, - (*WasmToSandbox).fnUtilsHashSha3, -} - -type WasmToSandbox struct { - common iscp.SandboxBase - ctx iscp.Sandbox - ctxView iscp.SandboxView - wc *WasmContext -} - -var _ ISandbox = new(WasmToSandbox) - -func NewWasmToSandbox(wc *WasmContext, ctx interface{}) *WasmToSandbox { - s := new(WasmToSandbox) - s.wc = wc - switch tctx := ctx.(type) { - case iscp.Sandbox: - s.common = tctx - s.ctx = tctx - case iscp.SandboxView: - s.common = tctx - s.ctxView = tctx - default: - panic(iscp.ErrWrongTypeEntryPoint) - } - return s -} - -func (s *WasmToSandbox) Call(funcNr int32, params []byte) []byte { - return sandboxFunctions[-funcNr](s, params) -} - -func (s *WasmToSandbox) checkErr(err error) { - if err != nil { - s.Panicf(err.Error()) - } -} - -func (s *WasmToSandbox) Panicf(format string, args ...interface{}) { - s.common.Log().Panicf(format, args...) -} - -func (s *WasmToSandbox) Tracef(format string, args ...interface{}) { - s.common.Log().Debugf(format, args...) -} - -//////////////////// sandbox functions \\\\\\\\\\\\\\\\\\\\ - -func (s *WasmToSandbox) fnAccountID(args []byte) []byte { - return s.common.AccountID().Bytes() -} - -func (s *WasmToSandbox) fnBalance(args []byte) []byte { - color, err := colored.ColorFromBytes(args) - s.checkErr(err) - return codec.EncodeUint64(s.ctx.Balance(color)) -} - -func (s *WasmToSandbox) fnBalances(args []byte) []byte { - return s.common.Balances().Bytes() -} - -func (s *WasmToSandbox) fnBlockContext(args []byte) []byte { - panic("implement me") -} - -func (s *WasmToSandbox) fnCall(args []byte) []byte { - req := wasmrequests.NewCallRequestFromBytes(args) - contract, err := iscp.HnameFromBytes(req.Contract.Bytes()) - s.checkErr(err) - function, err := iscp.HnameFromBytes(req.Function.Bytes()) - s.checkErr(err) - params, err := dict.FromBytes(req.Params) - s.checkErr(err) - transfer, err := colored.BalancesFromBytes(req.Transfer) - s.checkErr(err) - s.Tracef("CALL hContract '%s, hFunction %s", contract.String(), function.String()) - results, err := s.callUnlocked(contract, function, params, transfer) - s.checkErr(err) - return results.Bytes() -} - -func (s *WasmToSandbox) callUnlocked(contract, function iscp.Hname, params dict.Dict, transfer colored.Balances) (dict.Dict, error) { - s.wc.proc.instanceLock.Unlock() - defer s.wc.proc.instanceLock.Lock() - - if s.ctx != nil { - return s.ctx.Call(contract, function, params, transfer) - } - return s.ctxView.Call(contract, function, params) -} - -func (s *WasmToSandbox) fnCaller(args []byte) []byte { - return s.ctx.Caller().Bytes() -} - -func (s *WasmToSandbox) fnChainID(args []byte) []byte { - return s.common.ChainID().Bytes() -} - -func (s *WasmToSandbox) fnChainOwnerID(args []byte) []byte { - return s.common.ChainOwnerID().Bytes() -} - -func (s *WasmToSandbox) fnContract(args []byte) []byte { - return s.common.Contract().Bytes() -} - -func (s *WasmToSandbox) fnContractCreator(args []byte) []byte { - return s.common.ContractCreator().Bytes() -} - -func (s *WasmToSandbox) fnDeployContract(args []byte) []byte { - req := wasmrequests.NewDeployRequestFromBytes(args) - programHash, err := hashing.HashValueFromBytes(req.ProgHash.Bytes()) - s.checkErr(err) - initParams, err := dict.FromBytes(req.Params) - s.checkErr(err) - s.Tracef("DEPLOY %s: %s", req.Name, req.Description) - err = s.deployUnlocked(programHash, req.Name, req.Description, initParams) - s.checkErr(err) - return nil -} - -func (s *WasmToSandbox) deployUnlocked(programHash hashing.HashValue, name, description string, params dict.Dict) error { - s.wc.proc.instanceLock.Unlock() - defer s.wc.proc.instanceLock.Lock() - - return s.ctx.DeployContract(programHash, name, description, params) -} - -func (s *WasmToSandbox) fnEntropy(args []byte) []byte { - return s.ctx.GetEntropy().Bytes() -} - -func (s *WasmToSandbox) fnEvent(args []byte) []byte { - s.ctx.Event(string(args)) - return nil -} - -func (s *WasmToSandbox) fnIncomingTransfer(args []byte) []byte { - return s.ctx.IncomingTransfer().Bytes() -} - -func (s *WasmToSandbox) fnLog(args []byte) []byte { - s.common.Log().Infof(string(args)) - return nil -} - -func (s *WasmToSandbox) fnMinted(args []byte) []byte { - return s.ctx.Minted().Bytes() -} - -func (s *WasmToSandbox) fnPanic(args []byte) []byte { - s.common.Log().Panicf("WASM panic: %s", string(args)) - return nil -} - -func (s *WasmToSandbox) fnParams(args []byte) []byte { - return s.common.Params().Bytes() -} - -func (s *WasmToSandbox) fnPost(args []byte) []byte { - req := wasmrequests.NewPostRequestFromBytes(args) - chainID, err := iscp.ChainIDFromBytes(req.ChainID.Bytes()) - s.checkErr(err) - contract, err := iscp.HnameFromBytes(req.Contract.Bytes()) - s.checkErr(err) - function, err := iscp.HnameFromBytes(req.Function.Bytes()) - s.checkErr(err) - params, err := dict.FromBytes(req.Params) - s.checkErr(err) - transfer, err := colored.BalancesFromBytes(req.Transfer) - s.checkErr(err) - if len(transfer) == 0 { - s.Panicf("transfer is required for post") - } - - s.Tracef("POST hContract '%s, hFunction %s, chain ", contract.String(), function.String(), chainID.String()) - metadata := &iscp.SendMetadata{ - TargetContract: contract, - EntryPoint: function, - Args: params, - } - if req.Delay == 0 { - if !s.ctx.Send(chainID.AsAddress(), transfer, metadata) { - s.Panicf("failed to send to %s", chainID.AsAddress().String()) - } - return nil - } - - timeLock := time.Unix(0, s.ctx.GetTimestamp()) - timeLock = timeLock.Add(time.Duration(req.Delay) * time.Second) - options := iscp.SendOptions{ - TimeLock: uint32(timeLock.Unix()), - } - if !s.ctx.Send(chainID.AsAddress(), transfer, metadata, options) { - s.Panicf("failed to send to %s", chainID.AsAddress().String()) - } - return nil -} - -func (s *WasmToSandbox) fnRequest(args []byte) []byte { - return s.ctx.Request().Bytes() -} - -func (s *WasmToSandbox) fnRequestID(args []byte) []byte { - return s.ctx.Request().ID().Bytes() -} - -func (s *WasmToSandbox) fnResults(args []byte) []byte { - results, err := dict.FromBytes(args) - if err != nil { - s.Panicf("call results: %s", err.Error()) - } - s.wc.results = results - return nil -} - -// transfer tokens to address -func (s *WasmToSandbox) fnSend(args []byte) []byte { - req := wasmrequests.NewSendRequestFromBytes(args) - address, _, err := ledgerstate.AddressFromBytes(req.Address.Bytes()) - s.checkErr(err) - transfer, err := colored.BalancesFromBytes(req.Transfer) - s.checkErr(err) - if len(transfer) != 0 { - if !s.ctx.Send(address, transfer, nil) { - s.Panicf("failed to send to %s", address.String()) - } - } - return nil -} - -func (s *WasmToSandbox) fnStateAnchor(args []byte) []byte { - panic("implement me") -} - -func (s *WasmToSandbox) fnTimestamp(args []byte) []byte { - return codec.EncodeInt64(s.common.GetTimestamp()) -} - -func (s *WasmToSandbox) fnTrace(args []byte) []byte { - s.common.Log().Debugf(string(args)) - return nil -} diff --git a/packages/wasmvm/wasmhost/wasmtosandboxtrace.go b/packages/wasmvm/wasmhost/wasmtosandboxtrace.go deleted file mode 100644 index fa52c0ccf1..0000000000 --- a/packages/wasmvm/wasmhost/wasmtosandboxtrace.go +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright 2020 IOTA Stiftung -// SPDX-License-Identifier: Apache-2.0 - -package wasmhost - -import ( - "github.com/iotaledger/wasp/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes" -) - -// NOTE: These strings correspond to the Sandbox fnXxx constants in WasmLib -var sandboxFuncNames = []string{ - "nil", - "FnAccountID", - "#FnBalance", - "FnBalances", - "FnBlockContext", - "FnCall", - "FnCaller", - "FnChainID", - "FnChainOwnerID", - "FnContract", - "FnContractCreator", - "#FnDeployContract", - "FnEntropy", - "$FnEvent", - "FnIncomingTransfer", - "$FnLog", - "FnMinted", - "$FnPanic", - "FnParams", - "#FnPost", - "FnRequest", - "FnRequestID", - "#FnResults", - "#FnSend", - "#FnStateAnchor", - "FnTimestamp", - "$FnTrace", - "$FnUtilsBase58Decode", - "#FnUtilsBase58Encode", - "#FnUtilsBlsAddress", - "#FnUtilsBlsAggregate", - "#FnUtilsBlsValid", - "#FnUtilsEd25519Address", - "#FnUtilsEd25519Valid", - "#FnUtilsHashBlake2b", - "$FnUtilsHashName", - "#FnUtilsHashSha3", -} - -func traceSandbox(funcNr int32, params []byte) string { - name := sandboxFuncNames[-funcNr] - if name[0] == '$' { - return name[1:] + ", " + string(params) - } - if name[0] != '#' { - return name - } - return name[1:] + ", " + wasmtypes.Hex(params) -} diff --git a/packages/wasmvm/wasmhost/wasmtosandboxutils.go b/packages/wasmvm/wasmhost/wasmtosandboxutils.go deleted file mode 100644 index c5dce35806..0000000000 --- a/packages/wasmvm/wasmhost/wasmtosandboxutils.go +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright 2020 IOTA Stiftung -// SPDX-License-Identifier: Apache-2.0 - -package wasmhost - -import ( - "github.com/iotaledger/wasp/packages/kv/codec" - "github.com/iotaledger/wasp/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes" -) - -func (s WasmToSandbox) fnUtilsBase58Decode(args []byte) []byte { - bytes, err := s.common.Utils().Base58().Decode(string(args)) - s.checkErr(err) - return bytes -} - -func (s WasmToSandbox) fnUtilsBase58Encode(args []byte) []byte { - return []byte(s.common.Utils().Base58().Encode(args)) -} - -func (s WasmToSandbox) fnUtilsBlsAddress(args []byte) []byte { - address, err := s.common.Utils().BLS().AddressFromPublicKey(args) - s.checkErr(err) - return address.Bytes() -} - -func (s WasmToSandbox) fnUtilsBlsAggregate(args []byte) []byte { - dec := wasmtypes.NewWasmDecoder(args) - count := wasmtypes.Uint32Decode(dec) - pubKeysBin := make([][]byte, count) - for i := uint32(0); i < count; i++ { - pubKeysBin[i] = dec.Bytes() - } - count = wasmtypes.Uint32Decode(dec) - sigsBin := make([][]byte, count) - for i := uint32(0); i < count; i++ { - sigsBin[i] = dec.Bytes() - } - pubKeyBin, sigBin, err := s.common.Utils().BLS().AggregateBLSSignatures(pubKeysBin, sigsBin) - s.checkErr(err) - return wasmtypes.NewWasmEncoder().Bytes(pubKeyBin).Bytes(sigBin).Buf() -} - -func (s WasmToSandbox) fnUtilsBlsValid(args []byte) []byte { - dec := wasmtypes.NewWasmDecoder(args) - data := dec.Bytes() - pubKey := dec.Bytes() - signature := dec.Bytes() - valid := s.common.Utils().BLS().ValidSignature(data, pubKey, signature) - return codec.EncodeBool(valid) -} - -func (s WasmToSandbox) fnUtilsEd25519Address(args []byte) []byte { - address, err := s.common.Utils().ED25519().AddressFromPublicKey(args) - s.checkErr(err) - return address.Bytes() -} - -func (s WasmToSandbox) fnUtilsEd25519Valid(args []byte) []byte { - dec := wasmtypes.NewWasmDecoder(args) - data := dec.Bytes() - pubKey := dec.Bytes() - signature := dec.Bytes() - valid := s.common.Utils().ED25519().ValidSignature(data, pubKey, signature) - return codec.EncodeBool(valid) -} - -func (s WasmToSandbox) fnUtilsHashBlake2b(args []byte) []byte { - return s.common.Utils().Hashing().Blake2b(args).Bytes() -} - -func (s WasmToSandbox) fnUtilsHashName(args []byte) []byte { - return codec.EncodeHname(s.common.Utils().Hashing().Hname(string(args))) -} - -func (s WasmToSandbox) fnUtilsHashSha3(args []byte) []byte { - return s.common.Utils().Hashing().Sha3(args).Bytes() -} diff --git a/packages/wasmvm/wasmhost/wasmvm.go b/packages/wasmvm/wasmhost/wasmvm.go index da9dd98a90..84958a9de9 100644 --- a/packages/wasmvm/wasmhost/wasmvm.go +++ b/packages/wasmvm/wasmhost/wasmvm.go @@ -314,7 +314,18 @@ func (vm *WasmVMBase) traceGet(ctx *WasmContext, keyRef, keyLen, valRef, valLen return } params := vm.impl.VMGetBytes(valRef, valLen) - ctx.log().Debugf("Sandbox(%s)", traceSandbox(keyLen, params)) + ctx.log().Debugf("Sandbox(%s)", vm.traceSandbox(keyLen, params)) +} + +func (vm *WasmVMBase) traceSandbox(funcNr int32, params []byte) string { + name := sandboxFuncNames[-funcNr] + if name[0] == '$' { + return name[1:] + ", " + string(params) + } + if name[0] != '#' { + return name + } + return name[1:] + ", " + wasmtypes.Hex(params) } func (vm *WasmVMBase) traceSet(ctx *WasmContext, keyRef, keyLen, valRef, valLen int32) { diff --git a/packages/wasmvm/wasmvmhost/host.go b/packages/wasmvm/wasmvmhost/host.go index 41dea40c8f..4b410b6676 100644 --- a/packages/wasmvm/wasmvmhost/host.go +++ b/packages/wasmvm/wasmvmhost/host.go @@ -1,7 +1,7 @@ // Copyright 2020 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 -// go:build wasm +//go:build wasm // +build wasm package wasmvmhost diff --git a/tools/schema/generator/gotemplates/lib.go b/tools/schema/generator/gotemplates/lib.go index f05bd55688..65180a85c9 100644 --- a/tools/schema/generator/gotemplates/lib.go +++ b/tools/schema/generator/gotemplates/lib.go @@ -46,10 +46,6 @@ $#if result returnResultDict // ******************************* "initResultDict": ` results := wasmlib.NewScDict() -`, - // ******************************* - "returnResultDict": ` - ctx.Results(results) `, // ******************************* "PackageEvents": ` @@ -98,12 +94,15 @@ $#if events PackageEventsExist State: Immutable$Package$+State{ proxy: wasmlib.NewStateProxy(), }, +`, + // ******************************* + "returnResultDict": ` + ctx.Results(results) `, // ******************************* "requireMandatory": ` ctx.Require(f.Params.$FldName().Exists(), "missing mandatory $fldName") `, - // ******************************* "accessCheck": ` $#set accessFinalize accessOther diff --git a/tools/schema/generator/rstemplates/lib.go b/tools/schema/generator/rstemplates/lib.go index 03d141ee57..d71447f97b 100644 --- a/tools/schema/generator/rstemplates/lib.go +++ b/tools/schema/generator/rstemplates/lib.go @@ -80,13 +80,9 @@ $#if view ImmutablePackageStateInit $#emit accessCheck $#each mandatory requireMandatory $kind$+_$func_name(ctx, &f); -$#if result sendResults +$#if result returnResultDict ctx.log("$package.$kind$FuncName ok"); } -`, - // ******************************* - "sendResults": ` - ctx.results(&f.results.proxy.kv_store); `, // ******************************* "PackageEvents": ` @@ -135,6 +131,10 @@ $#if events PackageEventsInitExist // ******************************* "ImmutablePackageStateInit": ` state: Immutable$Package$+State { proxy: state_proxy() }, +`, + // ******************************* + "returnResultDict": ` + ctx.results(&f.results.proxy.kv_store); `, // ******************************* "requireMandatory": ` diff --git a/tools/schema/generator/rstemplates/proxy.go b/tools/schema/generator/rstemplates/proxy.go index 3103db67d3..7637ee3241 100644 --- a/tools/schema/generator/rstemplates/proxy.go +++ b/tools/schema/generator/rstemplates/proxy.go @@ -18,11 +18,11 @@ $#if map proxyMap proxyMethods3 `, // ******************************* "proxyMethods3": ` -$#if basetype proxyBaseType proxyMethods4 +$#if basetype proxyBaseType proxyOtherType `, // ******************************* // TODO when will this be called, and if so, fix it - "proxyMethods4": ` + "proxyOtherType": ` $#if typedef proxyTypeDef proxyStruct `, // ******************************* From 5c383c881182057ec85ca6ddc71bb2acc462b833 Mon Sep 17 00:00:00 2001 From: Ivange Larry Date: Sat, 5 Feb 2022 00:56:00 +0100 Subject: [PATCH 064/111] Fix bug in metrics.tmpl (#786) --- packages/dashboard/templates/metrics.tmpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/dashboard/templates/metrics.tmpl b/packages/dashboard/templates/metrics.tmpl index 8c5c429eb5..c8a138c676 100644 --- a/packages/dashboard/templates/metrics.tmpl +++ b/packages/dashboard/templates/metrics.tmpl @@ -10,7 +10,7 @@

Chain metrics

GieSZNLj5TrPeN+F!gk)O#ucWB^aGhe>s} z_3PUut>w>gZw^Vt`;&YaZUP4?_rbf(ozR&@4Wl5?!;r3gMqby+bpRhY10Z|=V7Lvs z^_X||tnJziE1o!fu3gv;>f`OUvz-N>GP*ou#tZ;d*Vd};F(=;Lde zq1sbDSBRF>ySY|+O#LNy{M<~MKcb;*Z}73!U`?d_7|_Q%ydZTCo&@)zFNEWP=*>; ztu#M}zKV$#0h0tDP;d3#bB($7R^M%kFV*_dkFvV|B2jtk`CW?#wZ&uWbfg;=OBN%3 z7=Az0h-CSUmSr(2qMpj~Z`yW{&!~3>ntounwNz9<#W5bjmkIU zl`jRFvpYJPwC3zk%vl?ZZHA|0%oC4!%G7znV}Yivo;}flgPBIpF$e$X#L5Gae1G^h z4XQiC1K{x8;jht9tu%6)ZRX%06Y(Ci$d`>|q|LQi4}`olp@g=e69Ix$7?f4eQu^l_!vEw+l>)3Ie#f}{k3EGrn zKv=TWiljJgA5svgM1v5OK%oc~1QHi5sECKkAn}4w1aBZBmAfh)fHy!?f^X)mtu`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@_E<5XSyLV=YhMvm?))_sLhbczxE!&alPf45!&0}E}CK;_$Qcz{>+cfu2NK|c&3$FH=?Lu6;gegB7V@fZ^r$MJc687_{h;F<@IBnQSz0mNhUOVZ??sDDIx~8d>3+-RX9w0Ywyo7v z>)seNPf`}v&sV|<5zZk|^`+xXC01BBFW6=e>zc+~F z#IzA=F)pIQO6u=stw~JlU-j3~CHICr z)h`ZwC4V;JP=S%Yk;0T78hkU`pCr)%09SSKkl$Z9x_3C94b zZYqBlC^>>QOIjpA!7y$RRsrr%^&&!2*9ABHNOGE|O>!!0O2_=dL`O)T4(e||;&t76 zb*xurnB4d37_Ts5owA~y98&MZ>9a%kX}|6{)enhXJM~dISo!&>DK_1K{Ianq*g<{4 zDq3-2md)$spJr^Ae#!`!9E6P!`|&##-qV(XmqxC34if(yWk|co9HfN-Pa5_eQI(vT kuIl_~q(3&Q>42tV^ZvT9#fo}9smo&@qP>+LkNqR{KLqs|4FCWD diff --git a/packages/vm/core/testcore/sbtests/sbtestsc/testcore_bg.wasm b/packages/vm/core/testcore/sbtests/sbtestsc/testcore_bg.wasm index dcd2246ddbdbf599898624805a74c5c348c22218..a1f953082be192416751cf1e9dfabf5e0089941d 100644 GIT binary patch delta 3228 zcmai03sjX=7XJ77FNj{y%LM`x@V|ia4od{XG!L#y!v{J(a%$8RV!9X#8mpXfq!CdF z6WwZzy6VdKKt}@m%P0_T=7W-%bXLt`T1?}srIR|r>#{+ssc@9fhX$|*$G@R84;L7J}n=$5{ZU!y-ol!?7mCf18?;4(3(Or&+w^JSuh z-lc9b%SC;l@0GXQnylhU!8fUqT_I6CGh{a1GF>6(iQ2d*bQ*P;&7n>!T`*&#XXv7_ zmG{Ix99iLZYmWs8f3h07A*Kab3|-cUtN3mv*V z!jZA}(M6sSJ8t;Jlgf)`Rc`HKaM(2 z^T^m_(fc8d@&uu1|l6n)pWg1Zw8E z@e@Gj03T-;a0_>OaM*(rsFmk>a22qd+aF9Nw@DeJ2Ej$FydTpR0yp!^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}dc5p@G!}N~X+n8+^b&E}e(&f3 zM|_w~yC44p>w+{b1Zy&2IKTo(1f+1ov3b0$HCA+laZ_s|-_@29rfI1^F)QRU?^5I0 zaGQ2BG!Fry0Dis^^aKDmd+y@Qwx|HmS_Cg>%SpXXk@yiH4Un!F{1ksZU?LzKpuT4k zA8sqAZ#lL-0eF@VyL|X*A8u=phx~kdn*27xrroM`!Ho)>0YHL2FPT`g0NK}g<#{sT z27uothu>{kZm)^7X|o|63kU|(MDk6ZSibD741F-lrbR>a2?C74`XE2{`r9;?=f6=x z$NAVBH{sO2d1C?H%eNlS9=hr`HrQwy{>&WD9ohlT0C$1kKRz=wX!HQ55_JHAcw)x_ zsxlwzh$Py{J5S7<&=qad>`=XrH4f{Vd{=RiQRFH#?sXLwJ!IHoY?=!2J_mLt4^0O* z65K4#>8uKT(c{&ullXM!NIus&gg@$x!k?-B&hb>pFBa9ocs!gld^=9&@ zGvHJ+oX4ul^AT1RU=_de<`jp2Pt+KjHXhPxSXJR>VGZ value data bytes of type from the // into the host container object , under key . pub fn hostSetBytes(obj_id: i32, key_id: i32, type_id: i32, buffer: *const u8, size: i32); + + pub fn hostStateGet(key_ref: *const u8, key_len: i32, val_ref: *const u8, val_len: i32) -> i32; + + pub fn hostStateSet(key_ref: *const u8, key_len: i32, val_ref: *const u8, val_len: i32); } pub fn call_func(obj_id: i32, key_id: Key32, params: &[u8]) -> Vec { @@ -82,7 +86,7 @@ pub fn call_func(obj_id: i32, key_id: Key32, params: &[u8]) -> Vec { // and let the host copy the actual data bytes into this Wasm byte array let mut result = vec![0_u8; size as usize]; hostGetBytes(obj_id, key_id.0, TYPE_CALL + 1, result.as_mut_ptr(), size); - return result; + result } } @@ -90,7 +94,7 @@ pub fn call_func(obj_id: i32, key_id: Key32, params: &[u8]) -> Vec { // Removes all its sub-objects as well. pub fn clear(obj_id: i32) { // special key "length" is used with integer value zero - set_bytes(obj_id, KEY_LENGTH, TYPE_INT32, &0_i32.to_le_bytes()) + set_bytes(obj_id, KEY_LENGTH, TYPE_INT32, &0_i32.to_le_bytes()); } // Delete the value with the specified key and type from the specified container object. @@ -98,7 +102,7 @@ pub fn del_key(obj_id: i32, key_id: Key32, type_id: i32) { unsafe { // size -1 means delete // this removes the need for a separate hostDelete function - hostSetBytes(obj_id, key_id.0, type_id, std::ptr::null_mut(), -1); + hostSetBytes(obj_id, key_id.0, type_id, std::ptr::null(), -1); } } @@ -108,7 +112,7 @@ pub fn exists(obj_id: i32, key_id: Key32, type_id: i32) -> bool { // size -1 means only test for existence // returned size -1 indicates keyID not found (or error) // this removes the need for a separate hostExists function - hostGetBytes(obj_id, key_id.0, type_id, std::ptr::null_mut(), -1) >= 0 + hostGetBytes(obj_id, key_id.0, type_id, std::ptr::null(), -1) >= 0 } } @@ -121,7 +125,7 @@ pub fn get_bytes(obj_id: i32, key_id: Key32, type_id: i32) -> Vec { if size == 0 { // variable-sized type, first query expected length of bytes array // (pass zero-length buffer) - size = hostGetBytes(obj_id, key_id.0, type_id, std::ptr::null_mut(), 0); + size = hostGetBytes(obj_id, key_id.0, type_id, std::ptr::null(), 0); // -1 means non-existent, so return default value for type if size < 0 { @@ -133,7 +137,7 @@ pub fn get_bytes(obj_id: i32, key_id: Key32, type_id: i32) -> Vec { // and let the host copy the actual data bytes into this Wasm byte array let mut result = vec![0_u8; size as usize]; hostGetBytes(obj_id, key_id.0, type_id, result.as_mut_ptr(), size); - return result; + result } } @@ -177,12 +181,12 @@ pub fn get_object_id(obj_id: i32, key_id: Key32, type_id: i32) -> i32 { // Direct logging of informational text to host log pub fn log(text: &str) { - set_bytes(1, KEY_LOG, TYPE_STRING, text.as_bytes()) + set_bytes(1, KEY_LOG, TYPE_STRING, text.as_bytes()); } // Direct logging of error to host log, followed by panicking out of the Wasm code pub fn panic(text: &str) { - set_bytes(1, KEY_PANIC, TYPE_STRING, text.as_bytes()) + set_bytes(1, KEY_PANIC, TYPE_STRING, text.as_bytes()); } // Store the provided value bytes of specified type in the specified container object @@ -190,7 +194,7 @@ pub fn panic(text: &str) { // create it first. pub fn set_bytes(obj_id: i32, key_id: Key32, type_id: i32, value: &[u8]) { unsafe { - hostSetBytes(obj_id, key_id.0, type_id, value.as_ptr(), value.len() as i32) + hostSetBytes(obj_id, key_id.0, type_id, value.as_ptr(), value.len() as i32); } } @@ -198,3 +202,64 @@ pub fn set_bytes(obj_id: i32, key_id: Key32, type_id: i32, value: &[u8]) { pub fn trace(text: &str) { set_bytes(1, KEY_TRACE, TYPE_STRING, text.as_bytes()) } + +pub fn sandbox(func_nr: i32, params: &[u8]) -> Vec { + unsafe { + // call sandbox function, result value will be cached by host + // always negative funcNr as keyLen indicates sandbox call + // this removes the need for a separate hostSandbox function + let size = hostStateGet(std::ptr::null(), func_nr, params.as_ptr(), params.len() as i32); + + // zero length, no need to retrieve cached value + if size == 0 { + return vec![0_u8; 0]; + } + + // retrieve cached value from host + let mut result = vec![0_u8; size as usize]; + hostStateGet(std::ptr::null(), 0, result.as_mut_ptr(), size); + result + } +} + +pub fn state_delete(key: &[u8]) { + unsafe { + hostStateSet(key.as_ptr(), key.len() as i32, std::ptr::null(), -1); + } +} + +pub fn state_exists(key: &[u8]) -> bool { + unsafe { + hostStateGet(key.as_ptr(), key.len() as i32, std::ptr::null(), -1) >= 0 + } +} + +pub fn state_get(key: &[u8]) -> Option> { + unsafe { + // variable sized result expected, + // query size first by passing zero length buffer + // value will be cached by host + let size = hostStateGet(key.as_ptr(), key.len() as i32, std::ptr::null(), 0); + + // -1 means non-existent + if size < 0 { + return None; + } + + // zero length, no need to retrieve cached value + if size == 0 { + return Some(vec![0_u8; 0]); + } + + // retrieve cached value from host + let mut result = vec![0_u8; size as usize]; + hostStateGet(std::ptr::null(), 0, result.as_mut_ptr(), size); + Some(result) + } +} + +pub fn state_set(key: &[u8], value: &[u8]) { + unsafe { + hostStateSet(key.as_ptr(), key.len() as i32, value.as_ptr(), value.len() as i32); + } +} diff --git a/packages/vm/wasmlib/ts/wasmlib/host.ts b/packages/vm/wasmlib/ts/wasmlib/host.ts index 4337d407fc..f8373e909f 100644 --- a/packages/vm/wasmlib/ts/wasmlib/host.ts +++ b/packages/vm/wasmlib/ts/wasmlib/host.ts @@ -5,8 +5,8 @@ // all type id values should exactly match their counterpart values on the host! -import {Key32} from "./keys"; import * as keys from "./keys"; +import {Key32} from "./keys"; import {Convert} from "./convert"; export const TYPE_ARRAY: i32 = 0x20; @@ -63,7 +63,13 @@ export declare function hostGetObjectID(objID: i32, keyID: i32, typeID: i32): i3 // copy the value data bytes of type from the // into the host container object , under key . @external("WasmLib", "hostSetBytes") -export declare function hostSetBytes(objID: i32, keyID: i32, typeID: i32, buffer: usize, size: i32):void; +export declare function hostSetBytes(objID: i32, keyID: i32, typeID: i32, buffer: usize, size: i32): void; + +@external("WasmLib", "hostStateGet") +export declare function hostStateGet(keyRef: usize, keyLen: i32, valRef: usize, valLen: i32): i32; + +@external("WasmLib", "hostStateSet") +export declare function hostStateSet(keyRef: usize, keyLen: i32, valRef: usize, valLen: i32): void; export function callFunc(objID: i32, keyID: Key32, params: u8[]): u8[] { @@ -78,7 +84,7 @@ export function callFunc(objID: i32, keyID: Key32, params: u8[]): u8[] { // allocate a sufficient length byte array in Wasm memory // and let the host copy the actual data bytes into this Wasm byte array - let result:u8[] = new Array(size); + let result: u8[] = new Array(size); hostGetBytes(objID, keyID.keyID, TYPE_CALL + 1, result.dataStart, size); return result; } @@ -123,13 +129,13 @@ export function getBytes(objID: i32, keyID: Key32, typeID: i32): u8[] { // allocate a sufficient length byte array in Wasm memory // and let the host copy the actual data bytes into this Wasm byte array - let result:u8[] = new Array(size); + let result: u8[] = new Array(size); hostGetBytes(objID, keyID.keyID, typeID, result.dataStart, size); return result; } // Retrieve the key id that the host has associated with the specified bytes key -export function getKeyID(bytes: u8[], size:i32): Key32 { +export function getKeyID(bytes: u8[], size: i32): Key32 { // negative size indicates this is a bytes key return new Key32(hostGetKeyID(bytes.dataStart, size)); } @@ -187,3 +193,54 @@ export function setBytes(objID: i32, keyID: Key32, typeID: i32, value: u8[]): vo export function trace(text: string): void { setBytes(1, keys.KEY_TRACE, TYPE_STRING, Convert.fromString(text)); } + +export function sandbox(funcNr: i32, params: u8[]): u8[] { + // call sandbox function, result value will be cached by host + // always negative funcNr as keyLen indicates sandbox call + // this removes the need for a separate hostSandbox function + let size = hostStateGet(0, funcNr, params.dataStart, params.length as i32); + + // zero length, no need to retrieve cached value + if (size == 0) { + return []; + } + + // retrieve cached value from host + let result: u8[] = new Array(size); + hostStateGet(0, 0, result.dataStart, size); + return result; +} + +export function stateDelete(key: u8[]): void { + hostStateSet(key.dataStart, key.length as i32, 0, -1); +} + +export function stateExistst(key: u8[]): bool { + return hostStateGet(key.dataStart, key.length as i32, 0, -1) >= 0; +} + +export function stateGet(key: u8[]): u8[] | null { + // variable sized result expected, + // query size first by passing zero length buffer + // value will be cached by host + let size = hostStateGet(key.dataStart, key.length as i32, 0, 0); + + // -1 means non-existent + if (size < 0) { + return null; + } + + // zero length, no need to retrieve cached value + if (size == 0) { + return []; + } + + // retrieve cached value from host + let result: u8[] = new Array(size); + hostStateGet(0, 0, result.dataStart, size); + return result; +} + +export function stateSet(key: u8[], value: u8[]): void { + hostStateSet(key.dataStart, key.length as i32, value.dataStart, value.length as i32); +} diff --git a/packages/vm/wasmvmhost/host.go b/packages/vm/wasmvmhost/host.go index 94d045c78f..d0be1e756d 100644 --- a/packages/vm/wasmvmhost/host.go +++ b/packages/vm/wasmvmhost/host.go @@ -36,6 +36,17 @@ func hostStateSet(keyRef *byte, keyLen int32, valRef *byte, valLen int32) // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ +// ptr returns pointer to slice or nil when slice is empty +func ptr(buf []byte) *byte { + // &buf[0] will panic on zero length slice, so use nil instead + if len(buf) == 0 { + return nil + } + return &buf[0] +} + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + type WasmVMHost struct { funcs []wasmlib.ScFuncContextFunction views []wasmlib.ScViewContextFunction @@ -63,14 +74,8 @@ func (w *WasmVMHost) ConnectWasmHost() { } func (w *WasmVMHost) CallFunc(objID, keyID int32, params []byte) []byte { - args := (*byte)(nil) - size := int32(len(params)) - if size != 0 { - args = ¶ms[0] - } - // pass params and query expected length of result - size = hostGetBytes(objID, keyID, wasmlib.TYPE_CALL, args, size) + size := hostGetBytes(objID, keyID, wasmlib.TYPE_CALL, ptr(params), int32(len(params))) // -1 means non-existent, so return default value for type if size <= 0 { @@ -153,17 +158,10 @@ func (w *WasmVMHost) SetBytes(objID, keyID, typeID int32, value []byte) { } func (w *WasmVMHost) Sandbox(funcNr int32, params []byte) []byte { - // ¶ms[0] will panic on zero length slice, so use nil instead - par := (*byte)(nil) - size := int32(len(params)) - if size != 0 { - par = ¶ms[0] - } - // call sandbox function, result value will be cached by host // always negative funcNr as keyLen indicates sandbox call // this removes the need for a separate hostSandbox function - size = hostStateGet(nil, funcNr, par, size) + size := hostStateGet(nil, funcNr, ptr(params), int32(len(params))) // zero length, no need to retrieve cached value if size == 0 { @@ -221,11 +219,5 @@ func (w *WasmVMHost) StateGet(key []byte) []byte { } func (w *WasmVMHost) StateSet(key []byte, value []byte) { - // &value[0] will panic on zero length slice, so use nil instead - val := (*byte)(nil) - size := int32(len(value)) - if size != 0 { - val = &value[0] - } - hostStateSet(&key[0], int32(len(key)), val, size) + hostStateSet(&key[0], int32(len(key)), ptr(value), int32(len(value))) } diff --git a/tools/cluster/tests/wasm/inccounter_bg.wasm b/tools/cluster/tests/wasm/inccounter_bg.wasm index 17a9b75f301da132c42d5c306d77d69b15ef615d..c92255512777682979b30ec89b755ab80e5b300f 100644 GIT binary patch delta 553 zcmZ9HPiPZC6vk(sDHuYjfk%C2p5sV;G6oryfP&|52@KC7-ksJc{;2WwSKKSvz_sz$fnQ#fhC3qSG ztI4l5c$4=vc~66@4wyIsEl*AN7q>yHhQE$Kpr+;Yy9Cb<0QslmeY z&CsZ$S@NMatL~M$0e%GP-B1aV0qV7s6J=TVNzWrbIX{tX{O>O#u9U}70 zaEim-5HDBU48em8Cy*o<)H}BDck6{p4LG^t1oY3#5Ap Jbvum3e*@Buv3&pl delta 547 zcmZ9HL1+_E5Qg6yS4gsrS+ht|Ym!Cmp{?L87g2mjReF*h6j2hFGz8N$QW2~z!5&gU zESTNdts4*w7(`K|@DBDM5;X`VMG!*o-ikfigP@4>s9rkoG5kogq^YF+rJ6xhpD~&JV{L%?>jrm~JtPi^Zm#%)i|a zeGm1b3$K0ov^WgVNBOx_1oNk(&Qi`Qi{A~>%PzjTQ8S;od*-Vyekm`Qn|t$Hj=VNK z$l(v-ol4ydJlY%Ez1LOxoi7i}*jzn0Tm1;;clEV|1tM7%4W;XWJU4qf4BIZ=pU*-U z<@@>VFl;sORXqb87dPr{_<{1)(pUXZ!LC+s-nOQS75lDbTLrsPVM*L^reQgRwtG~y zrQP<@b)goHYs%`aI~5rd60#^#75@!!87Jwo6koZ}l9@=m4>lU2ouA>xQK wRLZCDx>riIbc0QhTOdY>G@< Date: Wed, 19 Jan 2022 07:59:21 +0100 Subject: [PATCH 028/111] Fix case where we return undefined string where string is expected --- packages/vm/wasmlib/ts/wasmclient/event.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/vm/wasmlib/ts/wasmclient/event.ts b/packages/vm/wasmlib/ts/wasmclient/event.ts index f23c08220f..1ae52896b8 100644 --- a/packages/vm/wasmlib/ts/wasmclient/event.ts +++ b/packages/vm/wasmlib/ts/wasmclient/event.ts @@ -15,7 +15,7 @@ export class Event { } private next(): string { - return this.msg[this.index++]; + return this.msg[this.index++] ?? ""; } protected nextAddress(): wasmclient.Address { From c0c923cacc8593faf9a8234c69a845a61668728f Mon Sep 17 00:00:00 2001 From: Eric Hop Date: Wed, 19 Jan 2022 13:20:53 -0800 Subject: [PATCH 029/111] Fixed 2 problems with schema tool --- packages/vm/wasmlib/go/wasmlib/proxy.go | 64 +++++++++++++++++++ .../vm/wasmlib/go/wasmlib/sandboxtypes.go | 6 +- tools/schema/main.go | 10 ++- 3 files changed, 76 insertions(+), 4 deletions(-) create mode 100644 packages/vm/wasmlib/go/wasmlib/proxy.go diff --git a/packages/vm/wasmlib/go/wasmlib/proxy.go b/packages/vm/wasmlib/go/wasmlib/proxy.go new file mode 100644 index 0000000000..62818663d4 --- /dev/null +++ b/packages/vm/wasmlib/go/wasmlib/proxy.go @@ -0,0 +1,64 @@ +package wasmlib + +type Proxy struct { + key []byte + kvStore IKvStore +} + +var _ IKvStore = new(Proxy) + +func (p Proxy) Buf(key []byte) *BytesDecoder { + return NewBytesDecoder(p.Get(key)) +} + +func (p Proxy) Delete(key []byte) { + p.kvStore.Delete(key) +} + +func (p Proxy) Exists(key []byte) bool { + return p.kvStore.Exists(key) +} + +func (p Proxy) Get(key []byte) []byte { + return p.kvStore.Get(key) +} + +func (p Proxy) Set(key, value []byte) { + p.kvStore.Set(key, value) +} + +type ArrayProxy struct { + proxy Proxy +} + +func (a ArrayProxy) Clear() { + a.proxy.Set(a.proxy.key, []byte{0}) +} + +func (a ArrayProxy) Length() uint32 { + return a.proxy.Buf(a.proxy.key).Uint32() +} + +type ItemProxy struct { + proxy Proxy +} + +func (a ItemProxy) Clear() { + a.proxy.Set(a.proxy.key, []byte{0}) +} + +func (a ItemProxy) Length() uint32 { + return a.proxy.Buf(a.proxy.key).Uint32() +} + +type MapProxy struct { + proxy Proxy +} + +func (m MapProxy) Clear() { + m.proxy.Set(m.proxy.key, []byte{0}) +} + +func (m MapProxy) Length() uint32 { + return m.proxy.Buf(m.proxy.key).Uint32() +} diff --git a/packages/vm/wasmlib/go/wasmlib/sandboxtypes.go b/packages/vm/wasmlib/go/wasmlib/sandboxtypes.go index 206a811c5d..33d9270e7b 100644 --- a/packages/vm/wasmlib/go/wasmlib/sandboxtypes.go +++ b/packages/vm/wasmlib/go/wasmlib/sandboxtypes.go @@ -8,7 +8,7 @@ import ( "sort" ) -type Map interface { +type IKvStore interface { Delete(key []byte) Exists(key []byte) bool Get(key []byte) []byte @@ -49,7 +49,7 @@ func (a ScAssets) Bytes() []byte { type ScDict map[string][]byte -var _ Map = new(ScDict) +var _ IKvStore = new(ScDict) func NewScDict() ScDict { return make(ScDict) @@ -111,7 +111,7 @@ func (d ScDict) Set(key, value []byte) { type ScState struct{} -var _ Map = new(ScState) +var _ IKvStore = new(ScState) func (d ScState) Delete(key []byte) { StateDelete(key) diff --git a/tools/schema/main.go b/tools/schema/main.go index 3595845ca3..ab375cadbe 100644 --- a/tools/schema/main.go +++ b/tools/schema/main.go @@ -114,7 +114,11 @@ func generateSchema(file *os.File) error { s.SchemaTime = info.ModTime() // also force regeneration when schema tool itself is newer - info, err = os.Stat(os.Args[0]) + exe, err := os.Executable() + if err != nil { + return err + } + info, err = os.Stat(exe) if err != nil { return err } @@ -123,6 +127,10 @@ func generateSchema(file *os.File) error { } } + if *flagClient && !*flagGo && !*flagTs { + return errors.New("missing language specification") + } + if *flagGo { g := generator.NewGoGenerator(s) err = g.Generate() From f43c91b290d6571f159bb72f530684f69bb36767 Mon Sep 17 00:00:00 2001 From: Eric Hop Date: Wed, 19 Jan 2022 14:07:59 -0800 Subject: [PATCH 030/111] small fix to schema tool --- packages/vm/wasmlib/go/wasmlib/proxy.go | 52 +++++++++++++------ .../generator/tsclienttemplates/index.go | 6 ++- 2 files changed, 40 insertions(+), 18 deletions(-) diff --git a/packages/vm/wasmlib/go/wasmlib/proxy.go b/packages/vm/wasmlib/go/wasmlib/proxy.go index 62818663d4..4e843d5a23 100644 --- a/packages/vm/wasmlib/go/wasmlib/proxy.go +++ b/packages/vm/wasmlib/go/wasmlib/proxy.go @@ -5,38 +5,52 @@ type Proxy struct { kvStore IKvStore } -var _ IKvStore = new(Proxy) +func makeKey(key []byte, sep byte, subKey []byte) []byte { + if len(key) == 0 { + return subKey + } + return append(append(key, sep), subKey...) +} + +func subProxy(proxy Proxy, sep byte, subKey []byte) Proxy { + return Proxy{key: makeKey(proxy.key, sep, subKey), kvStore: proxy.kvStore} +} -func (p Proxy) Buf(key []byte) *BytesDecoder { - return NewBytesDecoder(p.Get(key)) +func (p Proxy) Buf() *BytesDecoder { + return NewBytesDecoder(p.Get()) } -func (p Proxy) Delete(key []byte) { - p.kvStore.Delete(key) +func (p Proxy) Delete() { + p.kvStore.Delete(p.key) } -func (p Proxy) Exists(key []byte) bool { - return p.kvStore.Exists(key) +func (p Proxy) Exists() bool { + return p.kvStore.Exists(p.key) } -func (p Proxy) Get(key []byte) []byte { - return p.kvStore.Get(key) +func (p Proxy) Get() []byte { + return p.kvStore.Get(p.key) } -func (p Proxy) Set(key, value []byte) { - p.kvStore.Set(key, value) +func (p Proxy) Set(value []byte) { + p.kvStore.Set(p.key, value) } type ArrayProxy struct { proxy Proxy } +func (a ArrayProxy) NewProxy(index uint32) Proxy { + subKey := NewBytesEncoder().Uint32(index).Data() + return subProxy(a.proxy, '*', subKey) +} + func (a ArrayProxy) Clear() { - a.proxy.Set(a.proxy.key, []byte{0}) + a.proxy.Set([]byte{0}) } func (a ArrayProxy) Length() uint32 { - return a.proxy.Buf(a.proxy.key).Uint32() + return a.proxy.Buf().Uint32() } type ItemProxy struct { @@ -44,21 +58,25 @@ type ItemProxy struct { } func (a ItemProxy) Clear() { - a.proxy.Set(a.proxy.key, []byte{0}) + a.proxy.Set([]byte{0}) } func (a ItemProxy) Length() uint32 { - return a.proxy.Buf(a.proxy.key).Uint32() + return a.proxy.Buf().Uint32() } type MapProxy struct { proxy Proxy } +func (m MapProxy) NewProxy(subKey []byte) Proxy { + return subProxy(m.proxy, '.', subKey) +} + func (m MapProxy) Clear() { - m.proxy.Set(m.proxy.key, []byte{0}) + m.proxy.Set([]byte{0}) } func (m MapProxy) Length() uint32 { - return m.proxy.Buf(m.proxy.key).Uint32() + return m.proxy.Buf().Uint32() } diff --git a/tools/schema/generator/tsclienttemplates/index.go b/tools/schema/generator/tsclienttemplates/index.go index 33431528a6..b3ee09d122 100644 --- a/tools/schema/generator/tsclienttemplates/index.go +++ b/tools/schema/generator/tsclienttemplates/index.go @@ -3,7 +3,11 @@ package tsclienttemplates var indexTs = map[string]string{ // ******************************* "index.ts": ` -export * from "./events"; +$#if events exportEvents export * from "./service"; +`, + // ******************************* + "exportEvents": ` +export * from "./events"; `, } From d50f2d02581e1f0e0d0de0ac31c13d7d623e0d11 Mon Sep 17 00:00:00 2001 From: Eric Hop Date: Wed, 19 Jan 2022 16:52:06 -0800 Subject: [PATCH 031/111] Removed obsolete proxy arrays --- contracts/wasm/dividend/test/dividend_bg.wasm | Bin 32407 -> 32407 bytes .../test/donatewithfeedback_bg.wasm | Bin 36882 -> 36882 bytes contracts/wasm/erc20/test/erc20_bg.wasm | Bin 35584 -> 35584 bytes contracts/wasm/erc721/test/erc721_bg.wasm | Bin 40104 -> 40104 bytes .../wasm/fairauction/test/fairauction_bg.wasm | Bin 43245 -> 43245 bytes .../fairroulette/test/fairroulette_bg.wasm | Bin 40291 -> 40291 bytes .../wasm/inccounter/test/inccounter_bg.wasm | Bin 42133 -> 42133 bytes contracts/wasm/testcore/test/testcore_bg.wasm | Bin 53815 -> 53815 bytes .../wasm/testwasmlib/test/testwasmlib_bg.wasm | Bin 44764 -> 44764 bytes .../wasm/timestamp/test/timestamp_bg.wasm | Bin 28192 -> 28192 bytes .../tokenregistry/test/tokenregistry_bg.wasm | Bin 32223 -> 32223 bytes .../sbtests/sbtestsc/testcore_bg.wasm | Bin 53815 -> 53815 bytes packages/vm/wasmlib/go/wasmlib/immutable.go | 304 -------- packages/vm/wasmlib/go/wasmlib/mutable.go | 459 ------------ packages/vm/wasmlib/go/wasmlib/proxy.go | 27 +- packages/vm/wasmlib/src/immutable.rs | 400 ----------- packages/vm/wasmlib/src/mutable.rs | 612 ---------------- packages/vm/wasmlib/ts/wasmlib/immutable.ts | 432 ------------ packages/vm/wasmlib/ts/wasmlib/mutable.ts | 663 ------------------ tools/cluster/tests/wasm/inccounter_bg.wasm | Bin 42133 -> 42133 bytes .../generator/goclienttemplates/service.go | 13 +- .../generator/tsclienttemplates/service.go | 13 +- 22 files changed, 32 insertions(+), 2891 deletions(-) diff --git a/contracts/wasm/dividend/test/dividend_bg.wasm b/contracts/wasm/dividend/test/dividend_bg.wasm index db94fc27811e7bec8a4490d8518f287538fccc65..0f2efc4648d4784cd913470b6eb7c0c5bdbef544 100644 GIT binary patch delta 25 hcmbRKmvQ=E#tqRqOivj%$L1(7GF3BfuFsVa1OSeQ32guX delta 25 hcmbRKmvQ=E#tqRqO!~~5V{;T3nJk$$*XK$I0sw+B2zUSh diff --git a/contracts/wasm/donatewithfeedback/test/donatewithfeedback_bg.wasm b/contracts/wasm/donatewithfeedback/test/donatewithfeedback_bg.wasm index bd0c2907b689d412adc5114bcd99e623ed446646..c7b96a05ff13d38c5dd7473156b63ff45b211281 100644 GIT binary patch delta 25 hcmbQVfN9bKrVY2MnVvFkzEiEh$W+a^`CpBQFaVGj3R3_8 delta 25 hcmbQVfN9bKrVY2Mne>@A->Ft$WU^%1{I5nt7yyI830?pI diff --git a/contracts/wasm/erc20/test/erc20_bg.wasm b/contracts/wasm/erc20/test/erc20_bg.wasm index 6131d1b1f60a4735607c604380c2fe42f5c25733..a329940537a07fa34fdc64b7714c9ba602f4b7cc 100644 GIT binary patch delta 25 hcmZpe#?&y4X+u~A(^JOH5f#rEnW`B#J5(JI004nb3A_LR delta 25 hcmZpe#?&y4X+u~AlRoq2h>B;7OqNWW9jXop004CO2*&^b diff --git a/contracts/wasm/erc721/test/erc721_bg.wasm b/contracts/wasm/erc721/test/erc721_bg.wasm index 514e7725e76b48948f4c3dfc75176c84834b5cd9..e505977cbbdec59650d47e33f807039fa99a841f 100644 GIT binary patch delta 44 zcmV+{0Mq}dxdN!U0kEAQ#Iq}+^G%10N=q38UO$Q delta 32 ocmaERk?HM4rVXl7nDm)9t4~p2Wa40&>^W75$&zVv?$ich0LkVG(EtDd diff --git a/contracts/wasm/fairroulette/test/fairroulette_bg.wasm b/contracts/wasm/fairroulette/test/fairroulette_bg.wasm index cb620bfaee435decf21e13cea397a552db36c27a..316763e8da75c21bed214b1480c8a1a6455d9437 100644 GIT binary patch delta 45 zcmV+|0Mh^Cx&q_60iCKaiC*OS(YBLWBlllzJy0yzS+AB#j1 D delta 39 ucmbPwl4@An@==gWa40&oH@AOYWY-#AL~|dHdc55deVl36KB) diff --git a/contracts/wasm/testwasmlib/test/testwasmlib_bg.wasm b/contracts/wasm/testwasmlib/test/testwasmlib_bg.wasm index 5ad46c09bc701b7bf51461663919e295d98a886e..be70aa0f7862e4e1f77152c8c6e7da516dea01f2 100644 GIT binary patch delta 97 zcmca}m+8)3rVY1dFg<15d}qcjCc$_H1_n+bw&4+A@B-3`laJ3 pIZ8s+j0_CANJ?s$CcDg0Vw%M?IRi-TV4Bb--Y`c;2ms869E<<} delta 97 zcmca}m+8)3rVY1dFzGXIzBA(%lVB?Y0|O@z+wcf5cme5UlaJ3n4U6j{u3j`$W+a^St5=@005aC3C;ij delta 25 hcmZ2*hjGCj#tpw>nDm)9|A~=eWU^%1ED^^c004}~2-yGt diff --git a/contracts/wasm/tokenregistry/test/tokenregistry_bg.wasm b/contracts/wasm/tokenregistry/test/tokenregistry_bg.wasm index 90a2ccf970e57d12a6b45654b5690a59e95a521f..fea472d1b88d7292ec79112959b061139390739e 100644 GIT binary patch delta 25 hcmccroALf{#tkd8nVvFkUY#w)$W+a^`FM_mAONLK3e*4q delta 25 hcmccroALf{#tkd8ne>@Aug;cYWU^%1d^|@&5CE9?3Euz! diff --git a/packages/vm/core/testcore/sbtests/sbtestsc/testcore_bg.wasm b/packages/vm/core/testcore/sbtests/sbtestsc/testcore_bg.wasm index a1f953082be192416751cf1e9dfabf5e0089941d..926ca33bd093df86570cabdece8d7f0a3bb136aa 100644 GIT binary patch delta 25 hcmdnKgn9cC<_+SznVvFkmfSsuiK&`#^Y*@AOYWY-#AL~|dHdc55deVl36KB) diff --git a/packages/vm/wasmlib/go/wasmlib/immutable.go b/packages/vm/wasmlib/go/wasmlib/immutable.go index 2dbc8ea7de..c8290ed720 100644 --- a/packages/vm/wasmlib/go/wasmlib/immutable.go +++ b/packages/vm/wasmlib/go/wasmlib/immutable.go @@ -31,20 +31,6 @@ func (o ScImmutableAddress) Value() ScAddress { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -type ScImmutableAddressArray struct { - objID int32 -} - -func (o ScImmutableAddressArray) GetAddress(index int32) ScImmutableAddress { - return ScImmutableAddress{objID: o.objID, keyID: Key32(index)} -} - -func (o ScImmutableAddressArray) Length() int32 { - return GetLength(o.objID) -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - type ScImmutableAgentID struct { objID int32 keyID Key32 @@ -68,20 +54,6 @@ func (o ScImmutableAgentID) Value() ScAgentID { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -type ScImmutableAgentIDArray struct { - objID int32 -} - -func (o ScImmutableAgentIDArray) GetAgentID(index int32) ScImmutableAgentID { - return ScImmutableAgentID{objID: o.objID, keyID: Key32(index)} -} - -func (o ScImmutableAgentIDArray) Length() int32 { - return GetLength(o.objID) -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - type ScImmutableBool struct { objID int32 keyID Key32 @@ -109,20 +81,6 @@ func (o ScImmutableBool) Value() bool { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -type ScImmutableBoolArray struct { - objID int32 -} - -func (o ScImmutableBoolArray) GetBool(index int32) ScImmutableBool { - return ScImmutableBool{objID: o.objID, keyID: Key32(index)} -} - -func (o ScImmutableBoolArray) Length() int32 { - return GetLength(o.objID) -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - type ScImmutableBytes struct { objID int32 keyID Key32 @@ -146,20 +104,6 @@ func (o ScImmutableBytes) Value() []byte { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -type ScImmutableBytesArray struct { - objID int32 -} - -func (o ScImmutableBytesArray) GetBytes(index int32) ScImmutableBytes { - return ScImmutableBytes{objID: o.objID, keyID: Key32(index)} -} - -func (o ScImmutableBytesArray) Length() int32 { - return GetLength(o.objID) -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - type ScImmutableChainID struct { objID int32 keyID Key32 @@ -183,20 +127,6 @@ func (o ScImmutableChainID) Value() ScChainID { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -type ScImmutableChainIDArray struct { - objID int32 -} - -func (o ScImmutableChainIDArray) GetChainID(index int32) ScImmutableChainID { - return ScImmutableChainID{objID: o.objID, keyID: Key32(index)} -} - -func (o ScImmutableChainIDArray) Length() int32 { - return GetLength(o.objID) -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - type ScImmutableColor struct { objID int32 keyID Key32 @@ -257,20 +187,6 @@ func (o ScImmutableHash) Value() ScHash { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -type ScImmutableHashArray struct { - objID int32 -} - -func (o ScImmutableHashArray) GetHash(index int32) ScImmutableHash { - return ScImmutableHash{objID: o.objID, keyID: Key32(index)} -} - -func (o ScImmutableHashArray) Length() int32 { - return GetLength(o.objID) -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - type ScImmutableHname struct { objID int32 keyID Key32 @@ -294,20 +210,6 @@ func (o ScImmutableHname) Value() ScHname { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -type ScImmutableHnameArray struct { - objID int32 -} - -func (o ScImmutableHnameArray) GetHname(index int32) ScImmutableHname { - return ScImmutableHname{objID: o.objID, keyID: Key32(index)} -} - -func (o ScImmutableHnameArray) Length() int32 { - return GetLength(o.objID) -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - type ScImmutableInt8 struct { objID int32 keyID Key32 @@ -332,20 +234,6 @@ func (o ScImmutableInt8) Value() int8 { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -type ScImmutableInt8Array struct { - objID int32 -} - -func (o ScImmutableInt8Array) GetInt8(index int32) ScImmutableInt8 { - return ScImmutableInt8{objID: o.objID, keyID: Key32(index)} -} - -func (o ScImmutableInt8Array) Length() int32 { - return GetLength(o.objID) -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - type ScImmutableInt16 struct { objID int32 keyID Key32 @@ -370,20 +258,6 @@ func (o ScImmutableInt16) Value() int16 { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -type ScImmutableInt16Array struct { - objID int32 -} - -func (o ScImmutableInt16Array) GetInt16(index int32) ScImmutableInt16 { - return ScImmutableInt16{objID: o.objID, keyID: Key32(index)} -} - -func (o ScImmutableInt16Array) Length() int32 { - return GetLength(o.objID) -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - type ScImmutableInt32 struct { objID int32 keyID Key32 @@ -408,20 +282,6 @@ func (o ScImmutableInt32) Value() int32 { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -type ScImmutableInt32Array struct { - objID int32 -} - -func (o ScImmutableInt32Array) GetInt32(index int32) ScImmutableInt32 { - return ScImmutableInt32{objID: o.objID, keyID: Key32(index)} -} - -func (o ScImmutableInt32Array) Length() int32 { - return GetLength(o.objID) -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - type ScImmutableInt64 struct { objID int32 keyID Key32 @@ -446,20 +306,6 @@ func (o ScImmutableInt64) Value() int64 { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -type ScImmutableInt64Array struct { - objID int32 -} - -func (o ScImmutableInt64Array) GetInt64(index int32) ScImmutableInt64 { - return ScImmutableInt64{objID: o.objID, keyID: Key32(index)} -} - -func (o ScImmutableInt64Array) Length() int32 { - return GetLength(o.objID) -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - type ScImmutableMap struct { objID int32 } @@ -472,47 +318,22 @@ func (o ScImmutableMap) GetAddress(key MapKey) ScImmutableAddress { return ScImmutableAddress{objID: o.objID, keyID: key.KeyID()} } -func (o ScImmutableMap) GetAddressArray(key MapKey) ScImmutableAddressArray { - arrID := GetObjectID(o.objID, key.KeyID(), TYPE_ADDRESS|TYPE_ARRAY) - return ScImmutableAddressArray{objID: arrID} -} - func (o ScImmutableMap) GetAgentID(key MapKey) ScImmutableAgentID { return ScImmutableAgentID{objID: o.objID, keyID: key.KeyID()} } -func (o ScImmutableMap) GetAgentIDArray(key MapKey) ScImmutableAgentIDArray { - arrID := GetObjectID(o.objID, key.KeyID(), TYPE_AGENT_ID|TYPE_ARRAY) - return ScImmutableAgentIDArray{objID: arrID} -} - func (o ScImmutableMap) GetBool(key MapKey) ScImmutableBool { return ScImmutableBool{objID: o.objID, keyID: key.KeyID()} } -func (o ScImmutableMap) GetBoolArray(key MapKey) ScImmutableBoolArray { - arrID := GetObjectID(o.objID, key.KeyID(), TYPE_BOOL|TYPE_ARRAY) - return ScImmutableBoolArray{objID: arrID} -} - func (o ScImmutableMap) GetBytes(key MapKey) ScImmutableBytes { return ScImmutableBytes{objID: o.objID, keyID: key.KeyID()} } -func (o ScImmutableMap) GetBytesArray(key MapKey) ScImmutableBytesArray { - arrID := GetObjectID(o.objID, key.KeyID(), TYPE_BYTES|TYPE_ARRAY) - return ScImmutableBytesArray{objID: arrID} -} - func (o ScImmutableMap) GetChainID(key MapKey) ScImmutableChainID { return ScImmutableChainID{objID: o.objID, keyID: key.KeyID()} } -func (o ScImmutableMap) GetChainIDArray(key MapKey) ScImmutableChainIDArray { - arrID := GetObjectID(o.objID, key.KeyID(), TYPE_CHAIN_ID|TYPE_ARRAY) - return ScImmutableChainIDArray{objID: arrID} -} - func (o ScImmutableMap) GetColor(key MapKey) ScImmutableColor { return ScImmutableColor{objID: o.objID, keyID: key.KeyID()} } @@ -526,56 +347,26 @@ func (o ScImmutableMap) GetHash(key MapKey) ScImmutableHash { return ScImmutableHash{objID: o.objID, keyID: key.KeyID()} } -func (o ScImmutableMap) GetHashArray(key MapKey) ScImmutableHashArray { - arrID := GetObjectID(o.objID, key.KeyID(), TYPE_HASH|TYPE_ARRAY) - return ScImmutableHashArray{objID: arrID} -} - func (o ScImmutableMap) GetHname(key MapKey) ScImmutableHname { return ScImmutableHname{objID: o.objID, keyID: key.KeyID()} } -func (o ScImmutableMap) GetHnameArray(key MapKey) ScImmutableHnameArray { - arrID := GetObjectID(o.objID, key.KeyID(), TYPE_HNAME|TYPE_ARRAY) - return ScImmutableHnameArray{objID: arrID} -} - func (o ScImmutableMap) GetInt8(key MapKey) ScImmutableInt8 { return ScImmutableInt8{objID: o.objID, keyID: key.KeyID()} } -func (o ScImmutableMap) GetInt8Array(key MapKey) ScImmutableInt8Array { - arrID := GetObjectID(o.objID, key.KeyID(), TYPE_INT8|TYPE_ARRAY) - return ScImmutableInt8Array{objID: arrID} -} - func (o ScImmutableMap) GetInt16(key MapKey) ScImmutableInt16 { return ScImmutableInt16{objID: o.objID, keyID: key.KeyID()} } -func (o ScImmutableMap) GetInt16Array(key MapKey) ScImmutableInt16Array { - arrID := GetObjectID(o.objID, key.KeyID(), TYPE_INT16|TYPE_ARRAY) - return ScImmutableInt16Array{objID: arrID} -} - func (o ScImmutableMap) GetInt32(key MapKey) ScImmutableInt32 { return ScImmutableInt32{objID: o.objID, keyID: key.KeyID()} } -func (o ScImmutableMap) GetInt32Array(key MapKey) ScImmutableInt32Array { - arrID := GetObjectID(o.objID, key.KeyID(), TYPE_INT32|TYPE_ARRAY) - return ScImmutableInt32Array{objID: arrID} -} - func (o ScImmutableMap) GetInt64(key MapKey) ScImmutableInt64 { return ScImmutableInt64{objID: o.objID, keyID: key.KeyID()} } -func (o ScImmutableMap) GetInt64Array(key MapKey) ScImmutableInt64Array { - arrID := GetObjectID(o.objID, key.KeyID(), TYPE_INT64|TYPE_ARRAY) - return ScImmutableInt64Array{objID: arrID} -} - func (o ScImmutableMap) GetMap(key MapKey) ScImmutableMap { mapID := GetObjectID(o.objID, key.KeyID(), TYPE_MAP) return ScImmutableMap{objID: mapID} @@ -590,11 +381,6 @@ func (o ScImmutableMap) GetRequestID(key MapKey) ScImmutableRequestID { return ScImmutableRequestID{objID: o.objID, keyID: key.KeyID()} } -func (o ScImmutableMap) GetRequestIDArray(key MapKey) ScImmutableRequestIDArray { - arrID := GetObjectID(o.objID, key.KeyID(), TYPE_REQUEST_ID|TYPE_ARRAY) - return ScImmutableRequestIDArray{objID: arrID} -} - func (o ScImmutableMap) GetString(key MapKey) ScImmutableString { return ScImmutableString{objID: o.objID, keyID: key.KeyID()} } @@ -608,38 +394,18 @@ func (o ScImmutableMap) GetUint8(key MapKey) ScImmutableUint8 { return ScImmutableUint8{objID: o.objID, keyID: key.KeyID()} } -func (o ScImmutableMap) GetUint8Array(key MapKey) ScImmutableUint8Array { - arrID := GetObjectID(o.objID, key.KeyID(), TYPE_INT8|TYPE_ARRAY) - return ScImmutableUint8Array{objID: arrID} -} - func (o ScImmutableMap) GetUint16(key MapKey) ScImmutableUint16 { return ScImmutableUint16{objID: o.objID, keyID: key.KeyID()} } -func (o ScImmutableMap) GetUint16Array(key MapKey) ScImmutableUint16Array { - arrID := GetObjectID(o.objID, key.KeyID(), TYPE_INT16|TYPE_ARRAY) - return ScImmutableUint16Array{objID: arrID} -} - func (o ScImmutableMap) GetUint32(key MapKey) ScImmutableUint32 { return ScImmutableUint32{objID: o.objID, keyID: key.KeyID()} } -func (o ScImmutableMap) GetUint32Array(key MapKey) ScImmutableUint32Array { - arrID := GetObjectID(o.objID, key.KeyID(), TYPE_INT32|TYPE_ARRAY) - return ScImmutableUint32Array{objID: arrID} -} - func (o ScImmutableMap) GetUint64(key MapKey) ScImmutableUint64 { return ScImmutableUint64{objID: o.objID, keyID: key.KeyID()} } -func (o ScImmutableMap) GetUint64Array(key MapKey) ScImmutableUint64Array { - arrID := GetObjectID(o.objID, key.KeyID(), TYPE_INT64|TYPE_ARRAY) - return ScImmutableUint64Array{objID: arrID} -} - func (o ScImmutableMap) MapID() int32 { return o.objID } @@ -684,20 +450,6 @@ func (o ScImmutableRequestID) Value() ScRequestID { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -type ScImmutableRequestIDArray struct { - objID int32 -} - -func (o ScImmutableRequestIDArray) GetRequestID(index int32) ScImmutableRequestID { - return ScImmutableRequestID{objID: o.objID, keyID: Key32(index)} -} - -func (o ScImmutableRequestIDArray) Length() int32 { - return GetLength(o.objID) -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - type ScImmutableString struct { objID int32 keyID Key32 @@ -763,20 +515,6 @@ func (o ScImmutableUint8) Value() uint8 { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -type ScImmutableUint8Array struct { - objID int32 -} - -func (o ScImmutableUint8Array) GetUint8(index int32) ScImmutableUint8 { - return ScImmutableUint8{objID: o.objID, keyID: Key32(index)} -} - -func (o ScImmutableUint8Array) Length() int32 { - return GetLength(o.objID) -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - type ScImmutableUint16 struct { objID int32 keyID Key32 @@ -801,20 +539,6 @@ func (o ScImmutableUint16) Value() uint16 { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -type ScImmutableUint16Array struct { - objID int32 -} - -func (o ScImmutableUint16Array) GetUint16(index int32) ScImmutableUint16 { - return ScImmutableUint16{objID: o.objID, keyID: Key32(index)} -} - -func (o ScImmutableUint16Array) Length() int32 { - return GetLength(o.objID) -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - type ScImmutableUint32 struct { objID int32 keyID Key32 @@ -839,20 +563,6 @@ func (o ScImmutableUint32) Value() uint32 { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -type ScImmutableUint32Array struct { - objID int32 -} - -func (o ScImmutableUint32Array) GetUint32(index int32) ScImmutableUint32 { - return ScImmutableUint32{objID: o.objID, keyID: Key32(index)} -} - -func (o ScImmutableUint32Array) Length() int32 { - return GetLength(o.objID) -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - type ScImmutableUint64 struct { objID int32 keyID Key32 @@ -874,17 +584,3 @@ func (o ScImmutableUint64) Value() uint64 { bytes := GetBytes(o.objID, o.keyID, TYPE_INT64) return binary.LittleEndian.Uint64(bytes) } - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -type ScImmutableUint64Array struct { - objID int32 -} - -func (o ScImmutableUint64Array) GetUint64(index int32) ScImmutableUint64 { - return ScImmutableUint64{objID: o.objID, keyID: Key32(index)} -} - -func (o ScImmutableUint64Array) Length() int32 { - return GetLength(o.objID) -} diff --git a/packages/vm/wasmlib/go/wasmlib/mutable.go b/packages/vm/wasmlib/go/wasmlib/mutable.go index e9c8f909e2..e45d459b83 100644 --- a/packages/vm/wasmlib/go/wasmlib/mutable.go +++ b/packages/vm/wasmlib/go/wasmlib/mutable.go @@ -43,28 +43,6 @@ func (o ScMutableAddress) Value() ScAddress { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -type ScMutableAddressArray struct { - objID int32 -} - -func (o ScMutableAddressArray) Clear() { - Clear(o.objID) -} - -func (o ScMutableAddressArray) GetAddress(index int32) ScMutableAddress { - return ScMutableAddress{objID: o.objID, keyID: Key32(index)} -} - -func (o ScMutableAddressArray) Immutable() ScImmutableAddressArray { - return ScImmutableAddressArray(o) -} - -func (o ScMutableAddressArray) Length() int32 { - return GetLength(o.objID) -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - type ScMutableAgentID struct { objID int32 keyID Key32 @@ -96,28 +74,6 @@ func (o ScMutableAgentID) Value() ScAgentID { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -type ScMutableAgentIDArray struct { - objID int32 -} - -func (o ScMutableAgentIDArray) Clear() { - Clear(o.objID) -} - -func (o ScMutableAgentIDArray) GetAgentID(index int32) ScMutableAgentID { - return ScMutableAgentID{objID: o.objID, keyID: Key32(index)} -} - -func (o ScMutableAgentIDArray) Immutable() ScImmutableAgentIDArray { - return ScImmutableAgentIDArray(o) -} - -func (o ScMutableAgentIDArray) Length() int32 { - return GetLength(o.objID) -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - type ScMutableBool struct { objID int32 keyID Key32 @@ -157,28 +113,6 @@ func (o ScMutableBool) Value() bool { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -type ScMutableBoolArray struct { - objID int32 -} - -func (o ScMutableBoolArray) Clear() { - Clear(o.objID) -} - -func (o ScMutableBoolArray) GetBool(index int32) ScMutableBool { - return ScMutableBool{objID: o.objID, keyID: Key32(index)} -} - -func (o ScMutableBoolArray) Immutable() ScImmutableBoolArray { - return ScImmutableBoolArray(o) -} - -func (o ScMutableBoolArray) Length() int32 { - return GetLength(o.objID) -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - type ScMutableBytes struct { objID int32 keyID Key32 @@ -210,28 +144,6 @@ func (o ScMutableBytes) Value() []byte { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -type ScMutableBytesArray struct { - objID int32 -} - -func (o ScMutableBytesArray) Clear() { - Clear(o.objID) -} - -func (o ScMutableBytesArray) GetBytes(index int32) ScMutableBytes { - return ScMutableBytes{objID: o.objID, keyID: Key32(index)} -} - -func (o ScMutableBytesArray) Immutable() ScImmutableBytesArray { - return ScImmutableBytesArray(o) -} - -func (o ScMutableBytesArray) Length() int32 { - return GetLength(o.objID) -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - type ScMutableChainID struct { objID int32 keyID Key32 @@ -263,28 +175,6 @@ func (o ScMutableChainID) Value() ScChainID { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -type ScMutableChainIDArray struct { - objID int32 -} - -func (o ScMutableChainIDArray) Clear() { - Clear(o.objID) -} - -func (o ScMutableChainIDArray) GetChainID(index int32) ScMutableChainID { - return ScMutableChainID{objID: o.objID, keyID: Key32(index)} -} - -func (o ScMutableChainIDArray) Immutable() ScImmutableChainIDArray { - return ScImmutableChainIDArray(o) -} - -func (o ScMutableChainIDArray) Length() int32 { - return GetLength(o.objID) -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - type ScMutableColor struct { objID int32 keyID Key32 @@ -316,28 +206,6 @@ func (o ScMutableColor) Value() ScColor { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -type ScMutableColorArray struct { - objID int32 -} - -func (o ScMutableColorArray) Clear() { - Clear(o.objID) -} - -func (o ScMutableColorArray) GetColor(index int32) ScMutableColor { - return ScMutableColor{objID: o.objID, keyID: Key32(index)} -} - -func (o ScMutableColorArray) Immutable() ScImmutableColorArray { - return ScImmutableColorArray(o) -} - -func (o ScMutableColorArray) Length() int32 { - return GetLength(o.objID) -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - type ScMutableHash struct { objID int32 keyID Key32 @@ -369,28 +237,6 @@ func (o ScMutableHash) Value() ScHash { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -type ScMutableHashArray struct { - objID int32 -} - -func (o ScMutableHashArray) Clear() { - Clear(o.objID) -} - -func (o ScMutableHashArray) GetHash(index int32) ScMutableHash { - return ScMutableHash{objID: o.objID, keyID: Key32(index)} -} - -func (o ScMutableHashArray) Immutable() ScImmutableHashArray { - return ScImmutableHashArray(o) -} - -func (o ScMutableHashArray) Length() int32 { - return GetLength(o.objID) -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - type ScMutableHname struct { objID int32 keyID Key32 @@ -422,28 +268,6 @@ func (o ScMutableHname) Value() ScHname { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -type ScMutableHnameArray struct { - objID int32 -} - -func (o ScMutableHnameArray) Clear() { - Clear(o.objID) -} - -func (o ScMutableHnameArray) GetHname(index int32) ScMutableHname { - return ScMutableHname{objID: o.objID, keyID: Key32(index)} -} - -func (o ScMutableHnameArray) Immutable() ScImmutableHnameArray { - return ScImmutableHnameArray(o) -} - -func (o ScMutableHnameArray) Length() int32 { - return GetLength(o.objID) -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - type ScMutableInt8 struct { objID int32 keyID Key32 @@ -478,28 +302,6 @@ func (o ScMutableInt8) Value() int8 { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -type ScMutableInt8Array struct { - objID int32 -} - -func (o ScMutableInt8Array) Clear() { - Clear(o.objID) -} - -func (o ScMutableInt8Array) GetInt8(index int32) ScMutableInt8 { - return ScMutableInt8{objID: o.objID, keyID: Key32(index)} -} - -func (o ScMutableInt8Array) Immutable() ScImmutableInt8Array { - return ScImmutableInt8Array(o) -} - -func (o ScMutableInt8Array) Length() int32 { - return GetLength(o.objID) -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - type ScMutableInt16 struct { objID int32 keyID Key32 @@ -534,28 +336,6 @@ func (o ScMutableInt16) Value() int16 { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -type ScMutableInt16Array struct { - objID int32 -} - -func (o ScMutableInt16Array) Clear() { - Clear(o.objID) -} - -func (o ScMutableInt16Array) GetInt16(index int32) ScMutableInt16 { - return ScMutableInt16{objID: o.objID, keyID: Key32(index)} -} - -func (o ScMutableInt16Array) Immutable() ScImmutableInt16Array { - return ScImmutableInt16Array(o) -} - -func (o ScMutableInt16Array) Length() int32 { - return GetLength(o.objID) -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - type ScMutableInt32 struct { objID int32 keyID Key32 @@ -590,28 +370,6 @@ func (o ScMutableInt32) Value() int32 { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -type ScMutableInt32Array struct { - objID int32 -} - -func (o ScMutableInt32Array) Clear() { - Clear(o.objID) -} - -func (o ScMutableInt32Array) GetInt32(index int32) ScMutableInt32 { - return ScMutableInt32{objID: o.objID, keyID: Key32(index)} -} - -func (o ScMutableInt32Array) Immutable() ScImmutableInt32Array { - return ScImmutableInt32Array(o) -} - -func (o ScMutableInt32Array) Length() int32 { - return GetLength(o.objID) -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - type ScMutableInt64 struct { objID int32 keyID Key32 @@ -646,28 +404,6 @@ func (o ScMutableInt64) Value() int64 { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -type ScMutableInt64Array struct { - objID int32 -} - -func (o ScMutableInt64Array) Clear() { - Clear(o.objID) -} - -func (o ScMutableInt64Array) GetInt64(index int32) ScMutableInt64 { - return ScMutableInt64{objID: o.objID, keyID: Key32(index)} -} - -func (o ScMutableInt64Array) Immutable() ScImmutableInt64Array { - return ScImmutableInt64Array(o) -} - -func (o ScMutableInt64Array) Length() int32 { - return GetLength(o.objID) -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - type ScMutableMap struct { objID int32 } @@ -689,110 +425,50 @@ func (o ScMutableMap) GetAddress(key MapKey) ScMutableAddress { return ScMutableAddress{objID: o.objID, keyID: key.KeyID()} } -func (o ScMutableMap) GetAddressArray(key MapKey) ScMutableAddressArray { - arrID := GetObjectID(o.objID, key.KeyID(), TYPE_ADDRESS|TYPE_ARRAY) - return ScMutableAddressArray{objID: arrID} -} - func (o ScMutableMap) GetAgentID(key MapKey) ScMutableAgentID { return ScMutableAgentID{objID: o.objID, keyID: key.KeyID()} } -func (o ScMutableMap) GetAgentIDArray(key MapKey) ScMutableAgentIDArray { - arrID := GetObjectID(o.objID, key.KeyID(), TYPE_AGENT_ID|TYPE_ARRAY) - return ScMutableAgentIDArray{objID: arrID} -} - func (o ScMutableMap) GetBool(key MapKey) ScMutableBool { return ScMutableBool{objID: o.objID, keyID: key.KeyID()} } -func (o ScMutableMap) GetBoolArray(key MapKey) ScMutableBoolArray { - arrID := GetObjectID(o.objID, key.KeyID(), TYPE_BOOL|TYPE_ARRAY) - return ScMutableBoolArray{objID: arrID} -} - func (o ScMutableMap) GetBytes(key MapKey) ScMutableBytes { return ScMutableBytes{objID: o.objID, keyID: key.KeyID()} } -func (o ScMutableMap) GetBytesArray(key MapKey) ScMutableBytesArray { - arrID := GetObjectID(o.objID, key.KeyID(), TYPE_BYTES|TYPE_ARRAY) - return ScMutableBytesArray{objID: arrID} -} - func (o ScMutableMap) GetChainID(key MapKey) ScMutableChainID { return ScMutableChainID{objID: o.objID, keyID: key.KeyID()} } -func (o ScMutableMap) GetChainIDArray(key MapKey) ScMutableChainIDArray { - arrID := GetObjectID(o.objID, key.KeyID(), TYPE_CHAIN_ID|TYPE_ARRAY) - return ScMutableChainIDArray{objID: arrID} -} - func (o ScMutableMap) GetColor(key MapKey) ScMutableColor { return ScMutableColor{objID: o.objID, keyID: key.KeyID()} } -func (o ScMutableMap) GetColorArray(key MapKey) ScMutableColorArray { - arrID := GetObjectID(o.objID, key.KeyID(), TYPE_COLOR|TYPE_ARRAY) - return ScMutableColorArray{objID: arrID} -} - func (o ScMutableMap) GetHash(key MapKey) ScMutableHash { return ScMutableHash{objID: o.objID, keyID: key.KeyID()} } -func (o ScMutableMap) GetHashArray(key MapKey) ScMutableHashArray { - arrID := GetObjectID(o.objID, key.KeyID(), TYPE_HASH|TYPE_ARRAY) - return ScMutableHashArray{objID: arrID} -} - func (o ScMutableMap) GetHname(key MapKey) ScMutableHname { return ScMutableHname{objID: o.objID, keyID: key.KeyID()} } -func (o ScMutableMap) GetHnameArray(key MapKey) ScMutableHnameArray { - arrID := GetObjectID(o.objID, key.KeyID(), TYPE_HNAME|TYPE_ARRAY) - return ScMutableHnameArray{objID: arrID} -} - func (o ScMutableMap) GetInt8(key MapKey) ScMutableInt8 { return ScMutableInt8{objID: o.objID, keyID: key.KeyID()} } -func (o ScMutableMap) GetInt8Array(key MapKey) ScMutableInt8Array { - arrID := GetObjectID(o.objID, key.KeyID(), TYPE_INT8|TYPE_ARRAY) - return ScMutableInt8Array{objID: arrID} -} - func (o ScMutableMap) GetInt16(key MapKey) ScMutableInt16 { return ScMutableInt16{objID: o.objID, keyID: key.KeyID()} } -func (o ScMutableMap) GetInt16Array(key MapKey) ScMutableInt16Array { - arrID := GetObjectID(o.objID, key.KeyID(), TYPE_INT16|TYPE_ARRAY) - return ScMutableInt16Array{objID: arrID} -} - func (o ScMutableMap) GetInt32(key MapKey) ScMutableInt32 { return ScMutableInt32{objID: o.objID, keyID: key.KeyID()} } -func (o ScMutableMap) GetInt32Array(key MapKey) ScMutableInt32Array { - arrID := GetObjectID(o.objID, key.KeyID(), TYPE_INT32|TYPE_ARRAY) - return ScMutableInt32Array{objID: arrID} -} - func (o ScMutableMap) GetInt64(key MapKey) ScMutableInt64 { return ScMutableInt64{objID: o.objID, keyID: key.KeyID()} } -func (o ScMutableMap) GetInt64Array(key MapKey) ScMutableInt64Array { - arrID := GetObjectID(o.objID, key.KeyID(), TYPE_INT64|TYPE_ARRAY) - return ScMutableInt64Array{objID: arrID} -} - func (o ScMutableMap) GetMap(key MapKey) ScMutableMap { mapID := GetObjectID(o.objID, key.KeyID(), TYPE_MAP) return ScMutableMap{objID: mapID} @@ -807,11 +483,6 @@ func (o ScMutableMap) GetRequestID(key MapKey) ScMutableRequestID { return ScMutableRequestID{objID: o.objID, keyID: key.KeyID()} } -func (o ScMutableMap) GetRequestIDArray(key MapKey) ScMutableRequestIDArray { - arrID := GetObjectID(o.objID, key.KeyID(), TYPE_REQUEST_ID|TYPE_ARRAY) - return ScMutableRequestIDArray{objID: arrID} -} - func (o ScMutableMap) GetString(key MapKey) ScMutableString { return ScMutableString{objID: o.objID, keyID: key.KeyID()} } @@ -825,38 +496,18 @@ func (o ScMutableMap) GetUint8(key MapKey) ScMutableUint8 { return ScMutableUint8{objID: o.objID, keyID: key.KeyID()} } -func (o ScMutableMap) GetUint8Array(key MapKey) ScMutableUint8Array { - arrID := GetObjectID(o.objID, key.KeyID(), TYPE_INT8|TYPE_ARRAY) - return ScMutableUint8Array{objID: arrID} -} - func (o ScMutableMap) GetUint16(key MapKey) ScMutableUint16 { return ScMutableUint16{objID: o.objID, keyID: key.KeyID()} } -func (o ScMutableMap) GetUint16Array(key MapKey) ScMutableUint16Array { - arrID := GetObjectID(o.objID, key.KeyID(), TYPE_INT16|TYPE_ARRAY) - return ScMutableUint16Array{objID: arrID} -} - func (o ScMutableMap) GetUint32(key MapKey) ScMutableUint32 { return ScMutableUint32{objID: o.objID, keyID: key.KeyID()} } -func (o ScMutableMap) GetUint32Array(key MapKey) ScMutableUint32Array { - arrID := GetObjectID(o.objID, key.KeyID(), TYPE_INT32|TYPE_ARRAY) - return ScMutableUint32Array{objID: arrID} -} - func (o ScMutableMap) GetUint64(key MapKey) ScMutableUint64 { return ScMutableUint64{objID: o.objID, keyID: key.KeyID()} } -func (o ScMutableMap) GetUint64Array(key MapKey) ScMutableUint64Array { - arrID := GetObjectID(o.objID, key.KeyID(), TYPE_INT64|TYPE_ARRAY) - return ScMutableUint64Array{objID: arrID} -} - func (o ScMutableMap) Immutable() ScImmutableMap { return ScImmutableMap(o) } @@ -921,28 +572,6 @@ func (o ScMutableRequestID) Value() ScRequestID { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -type ScMutableRequestIDArray struct { - objID int32 -} - -func (o ScMutableRequestIDArray) Clear() { - Clear(o.objID) -} - -func (o ScMutableRequestIDArray) GetRequestID(index int32) ScMutableRequestID { - return ScMutableRequestID{objID: o.objID, keyID: Key32(index)} -} - -func (o ScMutableRequestIDArray) Immutable() ScImmutableRequestIDArray { - return ScImmutableRequestIDArray(o) -} - -func (o ScMutableRequestIDArray) Length() int32 { - return GetLength(o.objID) -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - type ScMutableString struct { objID int32 keyID Key32 @@ -1034,28 +663,6 @@ func (o ScMutableUint8) Value() uint8 { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -type ScMutableUint8Array struct { - objID int32 -} - -func (o ScMutableUint8Array) Clear() { - Clear(o.objID) -} - -func (o ScMutableUint8Array) GetUint8(index int32) ScMutableUint8 { - return ScMutableUint8{objID: o.objID, keyID: Key32(index)} -} - -func (o ScMutableUint8Array) Immutable() ScImmutableUint8Array { - return ScImmutableUint8Array(o) -} - -func (o ScMutableUint8Array) Length() int32 { - return GetLength(o.objID) -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - type ScMutableUint16 struct { objID int32 keyID Key32 @@ -1090,28 +697,6 @@ func (o ScMutableUint16) Value() uint16 { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -type ScMutableUint16Array struct { - objID int32 -} - -func (o ScMutableUint16Array) Clear() { - Clear(o.objID) -} - -func (o ScMutableUint16Array) GetUint16(index int32) ScMutableUint16 { - return ScMutableUint16{objID: o.objID, keyID: Key32(index)} -} - -func (o ScMutableUint16Array) Immutable() ScImmutableUint16Array { - return ScImmutableUint16Array(o) -} - -func (o ScMutableUint16Array) Length() int32 { - return GetLength(o.objID) -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - type ScMutableUint32 struct { objID int32 keyID Key32 @@ -1146,28 +731,6 @@ func (o ScMutableUint32) Value() uint32 { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -type ScMutableUint32Array struct { - objID int32 -} - -func (o ScMutableUint32Array) Clear() { - Clear(o.objID) -} - -func (o ScMutableUint32Array) GetUint32(index int32) ScMutableUint32 { - return ScMutableUint32{objID: o.objID, keyID: Key32(index)} -} - -func (o ScMutableUint32Array) Immutable() ScImmutableUint32Array { - return ScImmutableUint32Array(o) -} - -func (o ScMutableUint32Array) Length() int32 { - return GetLength(o.objID) -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - type ScMutableUint64 struct { objID int32 keyID Key32 @@ -1199,25 +762,3 @@ func (o ScMutableUint64) Value() uint64 { bytes := GetBytes(o.objID, o.keyID, TYPE_INT64) return binary.LittleEndian.Uint64(bytes) } - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -type ScMutableUint64Array struct { - objID int32 -} - -func (o ScMutableUint64Array) Clear() { - Clear(o.objID) -} - -func (o ScMutableUint64Array) GetUint64(index int32) ScMutableUint64 { - return ScMutableUint64{objID: o.objID, keyID: Key32(index)} -} - -func (o ScMutableUint64Array) Immutable() ScImmutableUint64Array { - return ScImmutableUint64Array(o) -} - -func (o ScMutableUint64Array) Length() int32 { - return GetLength(o.objID) -} diff --git a/packages/vm/wasmlib/go/wasmlib/proxy.go b/packages/vm/wasmlib/go/wasmlib/proxy.go index 4e843d5a23..23fee722f8 100644 --- a/packages/vm/wasmlib/go/wasmlib/proxy.go +++ b/packages/vm/wasmlib/go/wasmlib/proxy.go @@ -42,7 +42,7 @@ type ArrayProxy struct { func (a ArrayProxy) NewProxy(index uint32) Proxy { subKey := NewBytesEncoder().Uint32(index).Data() - return subProxy(a.proxy, '*', subKey) + return subProxy(a.proxy, '#', subKey) } func (a ArrayProxy) Clear() { @@ -53,18 +53,6 @@ func (a ArrayProxy) Length() uint32 { return a.proxy.Buf().Uint32() } -type ItemProxy struct { - proxy Proxy -} - -func (a ItemProxy) Clear() { - a.proxy.Set([]byte{0}) -} - -func (a ItemProxy) Length() uint32 { - return a.proxy.Buf().Uint32() -} - type MapProxy struct { proxy Proxy } @@ -73,10 +61,11 @@ func (m MapProxy) NewProxy(subKey []byte) Proxy { return subProxy(m.proxy, '.', subKey) } -func (m MapProxy) Clear() { - m.proxy.Set([]byte{0}) -} +//TODO hidden array of keys? +//func (m MapProxy) Clear() { +// m.proxy.Set([]byte{0}) +//} -func (m MapProxy) Length() uint32 { - return m.proxy.Buf().Uint32() -} +//func (m MapProxy) Length() uint32 { +// return m.proxy.Buf().Uint32() +//} diff --git a/packages/vm/wasmlib/src/immutable.rs b/packages/vm/wasmlib/src/immutable.rs index 577c1b0a00..1a6cbba717 100644 --- a/packages/vm/wasmlib/src/immutable.rs +++ b/packages/vm/wasmlib/src/immutable.rs @@ -39,25 +39,6 @@ impl ScImmutableAddress { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -// array proxy for immutable array of ScAddress -pub struct ScImmutableAddressArray { - pub(crate) obj_id: i32, -} - -impl ScImmutableAddressArray { - // get value proxy for item at index, index can be 0..length()-1 - pub fn get_address(&self, index: i32) -> ScImmutableAddress { - ScImmutableAddress { obj_id: self.obj_id, key_id: Key32(index) } - } - - // number of items in array - pub fn length(&self) -> i32 { - get_length(self.obj_id) - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - // value proxy for immutable ScAgentID in host container pub struct ScImmutableAgentID { obj_id: i32, @@ -87,25 +68,6 @@ impl ScImmutableAgentID { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -// array proxy for immutable array of ScAgentID -pub struct ScImmutableAgentIDArray { - pub(crate) obj_id: i32, -} - -impl ScImmutableAgentIDArray { - // get value proxy for item at index, index can be 0..length()-1 - pub fn get_agent_id(&self, index: i32) -> ScImmutableAgentID { - ScImmutableAgentID { obj_id: self.obj_id, key_id: Key32(index) } - } - - // number of items in array - pub fn length(&self) -> i32 { - get_length(self.obj_id) - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - // value proxy for immutable Bool in host container pub struct ScImmutableBool { obj_id: i32, @@ -136,25 +98,6 @@ impl ScImmutableBool { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -// array proxy for immutable array of Bool -pub struct ScImmutableBoolArray { - pub(crate) obj_id: i32, -} - -impl ScImmutableBoolArray { - // get value proxy for item at index, index can be 0..length()-1 - pub fn get_bool(&self, index: i32) -> ScImmutableBool { - ScImmutableBool { obj_id: self.obj_id, key_id: Key32(index) } - } - - // number of items in array - pub fn length(&self) -> i32 { - get_length(self.obj_id) - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - // value proxy for immutable bytes array in host container pub struct ScImmutableBytes { obj_id: i32, @@ -184,25 +127,6 @@ impl ScImmutableBytes { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -// array proxy for immutable array of byte array -pub struct ScImmutableBytesArray { - pub(crate) obj_id: i32, -} - -impl ScImmutableBytesArray { - // get value proxy for item at index, index can be 0..length()-1 - pub fn get_bytes(&self, index: i32) -> ScImmutableBytes { - ScImmutableBytes { obj_id: self.obj_id, key_id: Key32(index) } - } - - // number of items in array - pub fn length(&self) -> i32 { - get_length(self.obj_id) - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - // value proxy for immutable ScChainID in host container pub struct ScImmutableChainID { obj_id: i32, @@ -232,25 +156,6 @@ impl ScImmutableChainID { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -// array proxy for immutable array of ScChainID -pub struct ScImmutableChainIDArray { - pub(crate) obj_id: i32, -} - -impl ScImmutableChainIDArray { - // get value proxy for item at index, index can be 0..length()-1 - pub fn get_chain_id(&self, index: i32) -> ScImmutableChainID { - ScImmutableChainID { obj_id: self.obj_id, key_id: Key32(index) } - } - - // number of items in array - pub fn length(&self) -> i32 { - get_length(self.obj_id) - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - // value proxy for immutable ScColor in host container pub struct ScImmutableColor { obj_id: i32, @@ -328,25 +233,6 @@ impl ScImmutableHash { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -// array proxy for immutable array of ScHash -pub struct ScImmutableHashArray { - pub(crate) obj_id: i32, -} - -impl ScImmutableHashArray { - // get value proxy for item at index, index can be 0..length()-1 - pub fn get_hash(&self, index: i32) -> ScImmutableHash { - ScImmutableHash { obj_id: self.obj_id, key_id: Key32(index) } - } - - // number of items in array - pub fn length(&self) -> i32 { - get_length(self.obj_id) - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - // value proxy for immutable ScHname in host container pub struct ScImmutableHname { obj_id: i32, @@ -376,25 +262,6 @@ impl ScImmutableHname { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -// array proxy for immutable array of ScHname -pub struct ScImmutableHnameArray { - pub(crate) obj_id: i32, -} - -impl ScImmutableHnameArray { - // get value proxy for item at index, index can be 0..length()-1 - pub fn get_hname(&self, index: i32) -> ScImmutableHname { - ScImmutableHname { obj_id: self.obj_id, key_id: Key32(index) } - } - - // number of items in array - pub fn length(&self) -> i32 { - get_length(self.obj_id) - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - // value proxy for immutable Int8 in host container pub struct ScImmutableInt8 { obj_id: i32, @@ -425,25 +292,6 @@ impl ScImmutableInt8 { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -// array proxy for immutable array of Int8 -pub struct ScImmutableInt8Array { - pub(crate) obj_id: i32, -} - -impl ScImmutableInt8Array { - // get value proxy for item at index, index can be 0..length()-1 - pub fn get_int8(&self, index: i32) -> ScImmutableInt8 { - ScImmutableInt8 { obj_id: self.obj_id, key_id: Key32(index) } - } - - // number of items in array - pub fn length(&self) -> i32 { - get_length(self.obj_id) - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - // value proxy for immutable Int16 in host container pub struct ScImmutableInt16 { obj_id: i32, @@ -474,25 +322,6 @@ impl ScImmutableInt16 { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -// array proxy for immutable array of Int16 -pub struct ScImmutableInt16Array { - pub(crate) obj_id: i32, -} - -impl ScImmutableInt16Array { - // get value proxy for item at index, index can be 0..length()-1 - pub fn get_int16(&self, index: i32) -> ScImmutableInt16 { - ScImmutableInt16 { obj_id: self.obj_id, key_id: Key32(index) } - } - - // number of items in array - pub fn length(&self) -> i32 { - get_length(self.obj_id) - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - // value proxy for immutable Int32 in host container pub struct ScImmutableInt32 { obj_id: i32, @@ -523,25 +352,6 @@ impl ScImmutableInt32 { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -// array proxy for immutable array of Int32 -pub struct ScImmutableInt32Array { - pub(crate) obj_id: i32, -} - -impl ScImmutableInt32Array { - // get value proxy for item at index, index can be 0..length()-1 - pub fn get_int32(&self, index: i32) -> ScImmutableInt32 { - ScImmutableInt32 { obj_id: self.obj_id, key_id: Key32(index) } - } - - // number of items in array - pub fn length(&self) -> i32 { - get_length(self.obj_id) - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - // value proxy for immutable Int64 in host container pub struct ScImmutableInt64 { obj_id: i32, @@ -572,25 +382,6 @@ impl ScImmutableInt64 { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -// array proxy for immutable array of Int64 -pub struct ScImmutableInt64Array { - pub(crate) obj_id: i32, -} - -impl ScImmutableInt64Array { - // get value proxy for item at index, index can be 0..length()-1 - pub fn get_int64(&self, index: i32) -> ScImmutableInt64 { - ScImmutableInt64 { obj_id: self.obj_id, key_id: Key32(index) } - } - - // number of items in array - pub fn length(&self) -> i32 { - get_length(self.obj_id) - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - // map proxy for immutable map pub struct ScImmutableMap { pub(crate) obj_id: i32, @@ -606,56 +397,26 @@ impl ScImmutableMap { ScImmutableAddress { obj_id: self.obj_id, key_id: key.get_key_id() } } - // get array proxy for ScImmutableAddressArray specified by key - pub fn get_address_array(&self, key: &T) -> ScImmutableAddressArray { - let arr_id = get_object_id(self.obj_id, key.get_key_id(), TYPE_ADDRESS | TYPE_ARRAY); - ScImmutableAddressArray { obj_id: arr_id } - } - // get value proxy for immutable ScAgentID field specified by key pub fn get_agent_id(&self, key: &T) -> ScImmutableAgentID { ScImmutableAgentID { obj_id: self.obj_id, key_id: key.get_key_id() } } - // get array proxy for ScImmutableAgentIDArray specified by key - pub fn get_agent_id_array(&self, key: &T) -> ScImmutableAgentIDArray { - let arr_id = get_object_id(self.obj_id, key.get_key_id(), TYPE_AGENT_ID | TYPE_ARRAY); - ScImmutableAgentIDArray { obj_id: arr_id } - } - // get value proxy for immutable Bool field specified by key pub fn get_bool(&self, key: &T) -> ScImmutableBool { ScImmutableBool { obj_id: self.obj_id, key_id: key.get_key_id() } } - // get array proxy for ScImmutableBoolArray specified by key - pub fn get_bool_array(&self, key: &T) -> ScImmutableBoolArray { - let arr_id = get_object_id(self.obj_id, key.get_key_id(), TYPE_BOOL | TYPE_ARRAY); - ScImmutableBoolArray { obj_id: arr_id } - } - // get value proxy for immutable bytes array field specified by key pub fn get_bytes(&self, key: &T) -> ScImmutableBytes { ScImmutableBytes { obj_id: self.obj_id, key_id: key.get_key_id() } } - // get array proxy for ScImmutableBytesArray specified by key - pub fn get_bytes_array(&self, key: &T) -> ScImmutableBytesArray { - let arr_id = get_object_id(self.obj_id, key.get_key_id(), TYPE_BYTES | TYPE_ARRAY); - ScImmutableBytesArray { obj_id: arr_id } - } - // get value proxy for immutable ScChainID field specified by key pub fn get_chain_id(&self, key: &T) -> ScImmutableChainID { ScImmutableChainID { obj_id: self.obj_id, key_id: key.get_key_id() } } - // get array proxy for ScImmutableChainIDArray specified by key - pub fn get_chain_id_array(&self, key: &T) -> ScImmutableChainIDArray { - let arr_id = get_object_id(self.obj_id, key.get_key_id(), TYPE_CHAIN_ID | TYPE_ARRAY); - ScImmutableChainIDArray { obj_id: arr_id } - } - // get value proxy for immutable ScColor field specified by key pub fn get_color(&self, key: &T) -> ScImmutableColor { ScImmutableColor { obj_id: self.obj_id, key_id: key.get_key_id() } @@ -672,67 +433,31 @@ impl ScImmutableMap { ScImmutableHash { obj_id: self.obj_id, key_id: key.get_key_id() } } - // get array proxy for ScImmutableHashArray specified by key - pub fn get_hash_array(&self, key: &T) -> ScImmutableHashArray { - let arr_id = get_object_id(self.obj_id, key.get_key_id(), TYPE_HASH | TYPE_ARRAY); - ScImmutableHashArray { obj_id: arr_id } - } - // get value proxy for immutable ScHname field specified by key pub fn get_hname(&self, key: &T) -> ScImmutableHname { ScImmutableHname { obj_id: self.obj_id, key_id: key.get_key_id() } } - // get array proxy for ScImmutableHnameArray specified by key - pub fn get_hname_array(&self, key: &T) -> ScImmutableHnameArray { - let arr_id = get_object_id(self.obj_id, key.get_key_id(), TYPE_HNAME | TYPE_ARRAY); - ScImmutableHnameArray { obj_id: arr_id } - } - // get value proxy for immutable Int8 field specified by key pub fn get_int8(&self, key: &T) -> ScImmutableInt8 { ScImmutableInt8 { obj_id: self.obj_id, key_id: key.get_key_id() } } - // get array proxy for ScImmutableInt8Array specified by key - pub fn get_int8_array(&self, key: &T) -> ScImmutableInt8Array { - let arr_id = get_object_id(self.obj_id, key.get_key_id(), TYPE_INT8 | TYPE_ARRAY); - ScImmutableInt8Array { obj_id: arr_id } - } - // get value proxy for immutable Int16 field specified by key pub fn get_int16(&self, key: &T) -> ScImmutableInt16 { ScImmutableInt16 { obj_id: self.obj_id, key_id: key.get_key_id() } } - // get array proxy for ScImmutableInt16Array specified by key - pub fn get_int16_array(&self, key: &T) -> ScImmutableInt16Array { - let arr_id = get_object_id(self.obj_id, key.get_key_id(), TYPE_INT16 | TYPE_ARRAY); - ScImmutableInt16Array { obj_id: arr_id } - } - // get value proxy for immutable Int32 field specified by key pub fn get_int32(&self, key: &T) -> ScImmutableInt32 { ScImmutableInt32 { obj_id: self.obj_id, key_id: key.get_key_id() } } - // get array proxy for ScImmutableInt32Array specified by key - pub fn get_int32_array(&self, key: &T) -> ScImmutableInt32Array { - let arr_id = get_object_id(self.obj_id, key.get_key_id(), TYPE_INT32 | TYPE_ARRAY); - ScImmutableInt32Array { obj_id: arr_id } - } - // get value proxy for immutable Int64 field specified by key pub fn get_int64(&self, key: &T) -> ScImmutableInt64 { ScImmutableInt64 { obj_id: self.obj_id, key_id: key.get_key_id() } } - // get array proxy for ScImmutableInt64Array specified by key - pub fn get_int64_array(&self, key: &T) -> ScImmutableInt64Array { - let arr_id = get_object_id(self.obj_id, key.get_key_id(), TYPE_INT64 | TYPE_ARRAY); - ScImmutableInt64Array { obj_id: arr_id } - } - // get map proxy for ScImmutableMap specified by key pub fn get_map(&self, key: &T) -> ScImmutableMap { let map_id = get_object_id(self.obj_id, key.get_key_id(), TYPE_MAP); @@ -750,12 +475,6 @@ impl ScImmutableMap { ScImmutableRequestID { obj_id: self.obj_id, key_id: key.get_key_id() } } - // get array proxy for ScImmutableRequestIDArray specified by key - pub fn get_request_id_array(&self, key: &T) -> ScImmutableRequestIDArray { - let arr_id = get_object_id(self.obj_id, key.get_key_id(), TYPE_REQUEST_ID | TYPE_ARRAY); - ScImmutableRequestIDArray { obj_id: arr_id } - } - // get value proxy for immutable UTF-8 text string field specified by key pub fn get_string(&self, key: &T) -> ScImmutableString { ScImmutableString { obj_id: self.obj_id, key_id: key.get_key_id() } @@ -772,45 +491,21 @@ impl ScImmutableMap { ScImmutableUint8 { obj_id: self.obj_id, key_id: key.get_key_id() } } - // get array proxy for ScImmutableUint8Array specified by key - pub fn get_uint8_array(&self, key: &T) -> ScImmutableUint8Array { - let arr_id = get_object_id(self.obj_id, key.get_key_id(), TYPE_INT8 | TYPE_ARRAY); - ScImmutableUint8Array { obj_id: arr_id } - } - // get value proxy for immutable Uint16 field specified by key pub fn get_uint16(&self, key: &T) -> ScImmutableUint16 { ScImmutableUint16 { obj_id: self.obj_id, key_id: key.get_key_id() } } - // get array proxy for ScImmutableUint16Array specified by key - pub fn get_uint16_array(&self, key: &T) -> ScImmutableUint16Array { - let arr_id = get_object_id(self.obj_id, key.get_key_id(), TYPE_INT16 | TYPE_ARRAY); - ScImmutableUint16Array { obj_id: arr_id } - } - // get value proxy for immutable Uint32 field specified by key pub fn get_uint32(&self, key: &T) -> ScImmutableUint32 { ScImmutableUint32 { obj_id: self.obj_id, key_id: key.get_key_id() } } - // get array proxy for ScImmutableUint32Array specified by key - pub fn get_uint32_array(&self, key: &T) -> ScImmutableUint32Array { - let arr_id = get_object_id(self.obj_id, key.get_key_id(), TYPE_INT32 | TYPE_ARRAY); - ScImmutableUint32Array { obj_id: arr_id } - } - // get value proxy for immutable Uint64 field specified by key pub fn get_uint64(&self, key: &T) -> ScImmutableUint64 { ScImmutableUint64 { obj_id: self.obj_id, key_id: key.get_key_id() } } - // get array proxy for ScImmutableUint64Array specified by key - pub fn get_uint64_array(&self, key: &T) -> ScImmutableUint64Array { - let arr_id = get_object_id(self.obj_id, key.get_key_id(), TYPE_INT64 | TYPE_ARRAY); - ScImmutableUint64Array { obj_id: arr_id } - } - pub fn map_id(&self) -> i32 { self.obj_id } @@ -865,25 +560,6 @@ impl ScImmutableRequestID { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -// array proxy for immutable array of ScRequestID -pub struct ScImmutableRequestIDArray { - pub(crate) obj_id: i32, -} - -impl ScImmutableRequestIDArray { - // get value proxy for item at index, index can be 0..length()-1 - pub fn get_request_id(&self, index: i32) -> ScImmutableRequestID { - ScImmutableRequestID { obj_id: self.obj_id, key_id: Key32(index) } - } - - // number of items in array - pub fn length(&self) -> i32 { - get_length(self.obj_id) - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - // value proxy for immutable UTF-8 text string in host container pub struct ScImmutableString { obj_id: i32, @@ -963,25 +639,6 @@ impl ScImmutableUint8 { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -// array proxy for immutable array of Uint8 -pub struct ScImmutableUint8Array { - pub(crate) obj_id: i32, -} - -impl ScImmutableUint8Array { - // get value proxy for item at index, index can be 0..length()-1 - pub fn get_uint8(&self, index: i32) -> ScImmutableUint8 { - ScImmutableUint8 { obj_id: self.obj_id, key_id: Key32(index) } - } - - // number of items in array - pub fn length(&self) -> i32 { - get_length(self.obj_id) - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - // value proxy for immutable Uint16 in host container pub struct ScImmutableUint16 { obj_id: i32, @@ -1012,25 +669,6 @@ impl ScImmutableUint16 { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -// array proxy for immutable array of Uint16 -pub struct ScImmutableUint16Array { - pub(crate) obj_id: i32, -} - -impl ScImmutableUint16Array { - // get value proxy for item at index, index can be 0..length()-1 - pub fn get_uint16(&self, index: i32) -> ScImmutableUint16 { - ScImmutableUint16 { obj_id: self.obj_id, key_id: Key32(index) } - } - - // number of items in array - pub fn length(&self) -> i32 { - get_length(self.obj_id) - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - // value proxy for immutable Uint32 in host container pub struct ScImmutableUint32 { obj_id: i32, @@ -1061,25 +699,6 @@ impl ScImmutableUint32 { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -// array proxy for immutable array of Uint32 -pub struct ScImmutableUint32Array { - pub(crate) obj_id: i32, -} - -impl ScImmutableUint32Array { - // get value proxy for item at index, index can be 0..length()-1 - pub fn get_uint32(&self, index: i32) -> ScImmutableUint32 { - ScImmutableUint32 { obj_id: self.obj_id, key_id: Key32(index) } - } - - // number of items in array - pub fn length(&self) -> i32 { - get_length(self.obj_id) - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - // value proxy for immutable Uint64 in host container pub struct ScImmutableUint64 { obj_id: i32, @@ -1107,22 +726,3 @@ impl ScImmutableUint64 { u64::from_le_bytes(bytes.try_into().expect("invalid u64 length")) } } - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -// array proxy for immutable array of Uint64 -pub struct ScImmutableUint64Array { - pub(crate) obj_id: i32, -} - -impl ScImmutableUint64Array { - // get value proxy for item at index, index can be 0..length()-1 - pub fn get_uint64(&self, index: i32) -> ScImmutableUint64 { - ScImmutableUint64 { obj_id: self.obj_id, key_id: Key32(index) } - } - - // number of items in array - pub fn length(&self) -> i32 { - get_length(self.obj_id) - } -} diff --git a/packages/vm/wasmlib/src/mutable.rs b/packages/vm/wasmlib/src/mutable.rs index 8ffaca21b0..29b95286db 100644 --- a/packages/vm/wasmlib/src/mutable.rs +++ b/packages/vm/wasmlib/src/mutable.rs @@ -52,36 +52,6 @@ impl ScMutableAddress { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -// array proxy for mutable array of ScAddress -pub struct ScMutableAddressArray { - pub(crate) obj_id: i32, -} - -impl ScMutableAddressArray { - // empty the array - pub fn clear(&self) { - clear(self.obj_id); - } - - // get value proxy for item at index, index can be 0..length() - // when index equals length() a new item is appended - pub fn get_address(&self, index: i32) -> ScMutableAddress { - ScMutableAddress { obj_id: self.obj_id, key_id: Key32(index) } - } - - // get immutable version of array proxy - pub fn immutable(&self) -> ScImmutableAddressArray { - ScImmutableAddressArray { obj_id: self.obj_id } - } - - // number of items in array - pub fn length(&self) -> i32 { - get_length(self.obj_id) - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - // value proxy for mutable ScAgentID in host container pub struct ScMutableAgentID { obj_id: i32, @@ -121,36 +91,6 @@ impl ScMutableAgentID { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -// array proxy for mutable array of ScAgentID -pub struct ScMutableAgentIDArray { - pub(crate) obj_id: i32, -} - -impl ScMutableAgentIDArray { - // empty the array - pub fn clear(&self) { - clear(self.obj_id); - } - - // get value proxy for item at index, index can be 0..length() - // when index equals length() a new item is appended - pub fn get_agent_id(&self, index: i32) -> ScMutableAgentID { - ScMutableAgentID { obj_id: self.obj_id, key_id: Key32(index) } - } - - // get immutable version of array proxy - pub fn immutable(&self) -> ScImmutableAgentIDArray { - ScImmutableAgentIDArray { obj_id: self.obj_id } - } - - // number of items in array - pub fn length(&self) -> i32 { - get_length(self.obj_id) - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - // value proxy for mutable Bool in host container pub struct ScMutableBool { obj_id: i32, @@ -192,36 +132,6 @@ impl ScMutableBool { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -// array proxy for mutable array of Bool -pub struct ScMutableBoolArray { - pub(crate) obj_id: i32, -} - -impl ScMutableBoolArray { - // empty the array - pub fn clear(&self) { - clear(self.obj_id); - } - - // get value proxy for item at index, index can be 0..length() - // when index equals length() a new item is appended - pub fn get_bool(&self, index: i32) -> ScMutableBool { - ScMutableBool { obj_id: self.obj_id, key_id: Key32(index) } - } - - // get immutable version of array proxy - pub fn immutable(&self) -> ScImmutableBoolArray { - ScImmutableBoolArray { obj_id: self.obj_id } - } - - // number of items in array - pub fn length(&self) -> i32 { - get_length(self.obj_id) - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - // value proxy for mutable bytes array in host container pub struct ScMutableBytes { obj_id: i32, @@ -261,36 +171,6 @@ impl ScMutableBytes { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -// array proxy for mutable array of byte array -pub struct ScMutableBytesArray { - pub(crate) obj_id: i32, -} - -impl ScMutableBytesArray { - // empty the array - pub fn clear(&self) { - clear(self.obj_id); - } - - // get value proxy for item at index, index can be 0..length() - // when index equals length() a new item is appended - pub fn get_bytes(&self, index: i32) -> ScMutableBytes { - ScMutableBytes { obj_id: self.obj_id, key_id: Key32(index) } - } - - // get immutable version of array proxy - pub fn immutable(&self) -> ScImmutableBytesArray { - ScImmutableBytesArray { obj_id: self.obj_id } - } - - // number of items in array - pub fn length(&self) -> i32 { - get_length(self.obj_id) - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - // value proxy for mutable ScChainID in host container pub struct ScMutableChainID { obj_id: i32, @@ -330,36 +210,6 @@ impl ScMutableChainID { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -// array proxy for mutable array of ScChainID -pub struct ScMutableChainIDArray { - pub(crate) obj_id: i32, -} - -impl ScMutableChainIDArray { - // empty the array - pub fn clear(&self) { - clear(self.obj_id); - } - - // get value proxy for item at index, index can be 0..length() - // when index equals length() a new item is appended - pub fn get_chain_id(&self, index: i32) -> ScMutableChainID { - ScMutableChainID { obj_id: self.obj_id, key_id: Key32(index) } - } - - // get immutable version of array proxy - pub fn immutable(&self) -> ScImmutableChainIDArray { - ScImmutableChainIDArray { obj_id: self.obj_id } - } - - // number of items in array - pub fn length(&self) -> i32 { - get_length(self.obj_id) - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - // value proxy for mutable ScColor in host container pub struct ScMutableColor { obj_id: i32, @@ -399,36 +249,6 @@ impl ScMutableColor { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -// array proxy for mutable array of ScColor -pub struct ScMutableColorArray { - pub(crate) obj_id: i32, -} - -impl ScMutableColorArray { - // empty the array - pub fn clear(&self) { - clear(self.obj_id); - } - - // get value proxy for item at index, index can be 0..length() - // when index equals length() a new item is appended - pub fn get_color(&self, index: i32) -> ScMutableColor { - ScMutableColor { obj_id: self.obj_id, key_id: Key32(index) } - } - - // get immutable version of array proxy - pub fn immutable(&self) -> ScImmutableColorArray { - ScImmutableColorArray { obj_id: self.obj_id } - } - - // number of items in array - pub fn length(&self) -> i32 { - get_length(self.obj_id) - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - // value proxy for mutable ScHash in host container pub struct ScMutableHash { obj_id: i32, @@ -468,36 +288,6 @@ impl ScMutableHash { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -// array proxy for mutable array of ScHash -pub struct ScMutableHashArray { - pub(crate) obj_id: i32, -} - -impl ScMutableHashArray { - // empty the array - pub fn clear(&self) { - clear(self.obj_id); - } - - // get value proxy for item at index, index can be 0..length() - // when index equals length() a new item is appended - pub fn get_hash(&self, index: i32) -> ScMutableHash { - ScMutableHash { obj_id: self.obj_id, key_id: Key32(index) } - } - - // get immutable version of array proxy - pub fn immutable(&self) -> ScImmutableHashArray { - ScImmutableHashArray { obj_id: self.obj_id } - } - - // number of items in array - pub fn length(&self) -> i32 { - get_length(self.obj_id) - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - // value proxy for mutable ScHname in host container pub struct ScMutableHname { obj_id: i32, @@ -537,36 +327,6 @@ impl ScMutableHname { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -// array proxy for mutable array of ScHname -pub struct ScMutableHnameArray { - pub(crate) obj_id: i32, -} - -impl ScMutableHnameArray { - // empty the array - pub fn clear(&self) { - clear(self.obj_id); - } - - // get value proxy for item at index, index can be 0..length() - // when index equals length() a new item is appended - pub fn get_hname(&self, index: i32) -> ScMutableHname { - ScMutableHname { obj_id: self.obj_id, key_id: Key32(index) } - } - - // get immutable version of array proxy - pub fn immutable(&self) -> ScImmutableHnameArray { - ScImmutableHnameArray { obj_id: self.obj_id } - } - - // number of items in array - pub fn length(&self) -> i32 { - get_length(self.obj_id) - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - // value proxy for mutable Int8 in host container pub struct ScMutableInt8 { obj_id: i32, @@ -608,36 +368,6 @@ impl ScMutableInt8 { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -// array proxy for mutable array of Int8 -pub struct ScMutableInt8Array { - pub(crate) obj_id: i32, -} - -impl ScMutableInt8Array { - // empty the array - pub fn clear(&self) { - clear(self.obj_id); - } - - // get value proxy for item at index, index can be 0..length() - // when index equals length() a new item is appended - pub fn get_int8(&self, index: i32) -> ScMutableInt8 { - ScMutableInt8 { obj_id: self.obj_id, key_id: Key32(index) } - } - - // get immutable version of array proxy - pub fn immutable(&self) -> ScImmutableInt8Array { - ScImmutableInt8Array { obj_id: self.obj_id } - } - - // number of items in array - pub fn length(&self) -> i32 { - get_length(self.obj_id) - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - // value proxy for mutable Int16 in host container pub struct ScMutableInt16 { obj_id: i32, @@ -678,36 +408,6 @@ impl ScMutableInt16 { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -// array proxy for mutable array of Int16 -pub struct ScMutableInt16Array { - pub(crate) obj_id: i32, -} - -impl ScMutableInt16Array { - // empty the array - pub fn clear(&self) { - clear(self.obj_id); - } - - // get value proxy for item at index, index can be 0..length() - // when index equals length() a new item is appended - pub fn get_int16(&self, index: i32) -> ScMutableInt16 { - ScMutableInt16 { obj_id: self.obj_id, key_id: Key32(index) } - } - - // get immutable version of array proxy - pub fn immutable(&self) -> ScImmutableInt16Array { - ScImmutableInt16Array { obj_id: self.obj_id } - } - - // number of items in array - pub fn length(&self) -> i32 { - get_length(self.obj_id) - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - // value proxy for mutable Int32 in host container pub struct ScMutableInt32 { obj_id: i32, @@ -748,36 +448,6 @@ impl ScMutableInt32 { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -// array proxy for mutable array of Int32 -pub struct ScMutableInt32Array { - pub(crate) obj_id: i32, -} - -impl ScMutableInt32Array { - // empty the array - pub fn clear(&self) { - clear(self.obj_id); - } - - // get value proxy for item at index, index can be 0..length() - // when index equals length() a new item is appended - pub fn get_int32(&self, index: i32) -> ScMutableInt32 { - ScMutableInt32 { obj_id: self.obj_id, key_id: Key32(index) } - } - - // get immutable version of array proxy - pub fn immutable(&self) -> ScImmutableInt32Array { - ScImmutableInt32Array { obj_id: self.obj_id } - } - - // number of items in array - pub fn length(&self) -> i32 { - get_length(self.obj_id) - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - // value proxy for mutable Int64 in host container pub struct ScMutableInt64 { obj_id: i32, @@ -818,36 +488,6 @@ impl ScMutableInt64 { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -// array proxy for mutable array of Int64 -pub struct ScMutableInt64Array { - pub(crate) obj_id: i32, -} - -impl ScMutableInt64Array { - // empty the array - pub fn clear(&self) { - clear(self.obj_id); - } - - // get value proxy for item at index, index can be 0..length() - // when index equals length() a new item is appended - pub fn get_int64(&self, index: i32) -> ScMutableInt64 { - ScMutableInt64 { obj_id: self.obj_id, key_id: Key32(index) } - } - - // get immutable version of array proxy - pub fn immutable(&self) -> ScImmutableInt64Array { - ScImmutableInt64Array { obj_id: self.obj_id } - } - - // number of items in array - pub fn length(&self) -> i32 { - get_length(self.obj_id) - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - // map proxy for mutable map #[derive(Clone, Copy)] pub struct ScMutableMap { @@ -875,133 +515,61 @@ impl ScMutableMap { ScMutableAddress { obj_id: self.obj_id, key_id: key.get_key_id() } } - // get array proxy for ScMutableAddressArray specified by key - pub fn get_address_array(&self, key: &T) -> ScMutableAddressArray { - let arr_id = get_object_id(self.obj_id, key.get_key_id(), TYPE_ADDRESS | TYPE_ARRAY); - ScMutableAddressArray { obj_id: arr_id } - } - // get value proxy for mutable ScAgentID field specified by key pub fn get_agent_id(&self, key: &T) -> ScMutableAgentID { ScMutableAgentID { obj_id: self.obj_id, key_id: key.get_key_id() } } - // get array proxy for ScMutableAgentIDArray specified by key - pub fn get_agent_id_array(&self, key: &T) -> ScMutableAgentIDArray { - let arr_id = get_object_id(self.obj_id, key.get_key_id(), TYPE_AGENT_ID | TYPE_ARRAY); - ScMutableAgentIDArray { obj_id: arr_id } - } - // get value proxy for mutable Bool field specified by key pub fn get_bool(&self, key: &T) -> ScMutableBool { ScMutableBool { obj_id: self.obj_id, key_id: key.get_key_id() } } - // get array proxy for ScMutableBoolArray specified by key - pub fn get_bool_array(&self, key: &T) -> ScMutableBoolArray { - let arr_id = get_object_id(self.obj_id, key.get_key_id(), TYPE_BOOL | TYPE_ARRAY); - ScMutableBoolArray { obj_id: arr_id } - } - // get value proxy for mutable bytes array field specified by key pub fn get_bytes(&self, key: &T) -> ScMutableBytes { ScMutableBytes { obj_id: self.obj_id, key_id: key.get_key_id() } } - // get array proxy for ScMutableBytesArray specified by key - pub fn get_bytes_array(&self, key: &T) -> ScMutableBytesArray { - let arr_id = get_object_id(self.obj_id, key.get_key_id(), TYPE_BYTES | TYPE_ARRAY); - ScMutableBytesArray { obj_id: arr_id } - } - // get value proxy for mutable ScChainID field specified by key pub fn get_chain_id(&self, key: &T) -> ScMutableChainID { ScMutableChainID { obj_id: self.obj_id, key_id: key.get_key_id() } } - // get array proxy for ScMutableChainIDArray specified by key - pub fn get_chain_id_array(&self, key: &T) -> ScMutableChainIDArray { - let arr_id = get_object_id(self.obj_id, key.get_key_id(), TYPE_CHAIN_ID | TYPE_ARRAY); - ScMutableChainIDArray { obj_id: arr_id } - } - // get value proxy for mutable ScColor field specified by key pub fn get_color(&self, key: &T) -> ScMutableColor { ScMutableColor { obj_id: self.obj_id, key_id: key.get_key_id() } } - // get array proxy for ScMutableColorArray specified by key - pub fn get_color_array(&self, key: &T) -> ScMutableColorArray { - let arr_id = get_object_id(self.obj_id, key.get_key_id(), TYPE_COLOR | TYPE_ARRAY); - ScMutableColorArray { obj_id: arr_id } - } - // get value proxy for mutable ScHash field specified by key pub fn get_hash(&self, key: &T) -> ScMutableHash { ScMutableHash { obj_id: self.obj_id, key_id: key.get_key_id() } } - // get array proxy for ScMutableHashArray specified by key - pub fn get_hash_array(&self, key: &T) -> ScMutableHashArray { - let arr_id = get_object_id(self.obj_id, key.get_key_id(), TYPE_HASH | TYPE_ARRAY); - ScMutableHashArray { obj_id: arr_id } - } - // get value proxy for mutable ScHname field specified by key pub fn get_hname(&self, key: &T) -> ScMutableHname { ScMutableHname { obj_id: self.obj_id, key_id: key.get_key_id() } } - // get array proxy for ScMutableHnameArray specified by key - pub fn get_hname_array(&self, key: &T) -> ScMutableHnameArray { - let arr_id = get_object_id(self.obj_id, key.get_key_id(), TYPE_HNAME | TYPE_ARRAY); - ScMutableHnameArray { obj_id: arr_id } - } - // get value proxy for mutable Int8 field specified by key pub fn get_int8(&self, key: &T) -> ScMutableInt8 { ScMutableInt8 { obj_id: self.obj_id, key_id: key.get_key_id() } } - // get array proxy for ScMutableInt8Array specified by key - pub fn get_int8_array(&self, key: &T) -> ScMutableInt8Array { - let arr_id = get_object_id(self.obj_id, key.get_key_id(), TYPE_INT8 | TYPE_ARRAY); - ScMutableInt8Array { obj_id: arr_id } - } - // get value proxy for mutable Int16 field specified by key pub fn get_int16(&self, key: &T) -> ScMutableInt16 { ScMutableInt16 { obj_id: self.obj_id, key_id: key.get_key_id() } } - // get array proxy for ScMutableInt16Array specified by key - pub fn get_int16_array(&self, key: &T) -> ScMutableInt16Array { - let arr_id = get_object_id(self.obj_id, key.get_key_id(), TYPE_INT16 | TYPE_ARRAY); - ScMutableInt16Array { obj_id: arr_id } - } - // get value proxy for mutable Int32 field specified by key pub fn get_int32(&self, key: &T) -> ScMutableInt32 { ScMutableInt32 { obj_id: self.obj_id, key_id: key.get_key_id() } } - // get array proxy for ScMutableInt32Array specified by key - pub fn get_int32_array(&self, key: &T) -> ScMutableInt32Array { - let arr_id = get_object_id(self.obj_id, key.get_key_id(), TYPE_INT32 | TYPE_ARRAY); - ScMutableInt32Array { obj_id: arr_id } - } - // get value proxy for mutable Int64 field specified by key pub fn get_int64(&self, key: &T) -> ScMutableInt64 { ScMutableInt64 { obj_id: self.obj_id, key_id: key.get_key_id() } } - // get array proxy for ScMutableInt64Array specified by key - pub fn get_int64_array(&self, key: &T) -> ScMutableInt64Array { - let arr_id = get_object_id(self.obj_id, key.get_key_id(), TYPE_INT64 | TYPE_ARRAY); - ScMutableInt64Array { obj_id: arr_id } - } - // get map proxy for ScMutableMap specified by key pub fn get_map(&self, key: &T) -> ScMutableMap { let map_id = get_object_id(self.obj_id, key.get_key_id(), TYPE_MAP); @@ -1019,12 +587,6 @@ impl ScMutableMap { ScMutableRequestID { obj_id: self.obj_id, key_id: key.get_key_id() } } - // get array proxy for ScMutableRequestIDArray specified by key - pub fn get_request_id_array(&self, key: &T) -> ScMutableRequestIDArray { - let arr_id = get_object_id(self.obj_id, key.get_key_id(), TYPE_REQUEST_ID | TYPE_ARRAY); - ScMutableRequestIDArray { obj_id: arr_id } - } - // get value proxy for mutable UTF-8 text string field specified by key pub fn get_string(&self, key: &T) -> ScMutableString { ScMutableString { obj_id: self.obj_id, key_id: key.get_key_id() } @@ -1041,45 +603,21 @@ impl ScMutableMap { ScMutableUint8 { obj_id: self.obj_id, key_id: key.get_key_id() } } - // get array proxy for ScMutableUint8Array specified by key - pub fn get_uint8_array(&self, key: &T) -> ScMutableUint8Array { - let arr_id = get_object_id(self.obj_id, key.get_key_id(), TYPE_INT8 | TYPE_ARRAY); - ScMutableUint8Array { obj_id: arr_id } - } - // get value proxy for mutable Uint16 field specified by key pub fn get_uint16(&self, key: &T) -> ScMutableUint16 { ScMutableUint16 { obj_id: self.obj_id, key_id: key.get_key_id() } } - // get array proxy for ScMutableUint16Array specified by key - pub fn get_uint16_array(&self, key: &T) -> ScMutableUint16Array { - let arr_id = get_object_id(self.obj_id, key.get_key_id(), TYPE_INT16 | TYPE_ARRAY); - ScMutableUint16Array { obj_id: arr_id } - } - // get value proxy for mutable Uint32 field specified by key pub fn get_uint32(&self, key: &T) -> ScMutableUint32 { ScMutableUint32 { obj_id: self.obj_id, key_id: key.get_key_id() } } - // get array proxy for ScMutableUint32Array specified by key - pub fn get_uint32_array(&self, key: &T) -> ScMutableUint32Array { - let arr_id = get_object_id(self.obj_id, key.get_key_id(), TYPE_INT32 | TYPE_ARRAY); - ScMutableUint32Array { obj_id: arr_id } - } - // get value proxy for mutable Uint64 field specified by key pub fn get_uint64(&self, key: &T) -> ScMutableUint64 { ScMutableUint64 { obj_id: self.obj_id, key_id: key.get_key_id() } } - // get array proxy for ScMutableUint64Array specified by key - pub fn get_uint64_array(&self, key: &T) -> ScMutableUint64Array { - let arr_id = get_object_id(self.obj_id, key.get_key_id(), TYPE_INT64 | TYPE_ARRAY); - ScMutableUint64Array { obj_id: arr_id } - } - // get immutable version of map proxy pub fn immutable(&self) -> ScImmutableMap { ScImmutableMap { obj_id: self.obj_id } @@ -1162,36 +700,6 @@ impl ScMutableRequestID { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -// array proxy for mutable array of ScRequestID -pub struct ScMutableRequestIDArray { - pub(crate) obj_id: i32, -} - -impl ScMutableRequestIDArray { - // empty the array - pub fn clear(&self) { - clear(self.obj_id); - } - - // get value proxy for item at index, index can be 0..length() - // when index equals length() a new item is appended - pub fn get_request_id(&self, index: i32) -> ScMutableRequestID { - ScMutableRequestID { obj_id: self.obj_id, key_id: Key32(index) } - } - - // get immutable version of array proxy - pub fn immutable(&self) -> ScImmutableRequestIDArray { - ScImmutableRequestIDArray { obj_id: self.obj_id } - } - - // number of items in array - pub fn length(&self) -> i32 { - get_length(self.obj_id) - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - // value proxy for mutable UTF-8 text string in host container pub struct ScMutableString { obj_id: i32, @@ -1303,36 +811,6 @@ impl ScMutableUint8 { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -// array proxy for mutable array of Uint8 -pub struct ScMutableUint8Array { - pub(crate) obj_id: i32, -} - -impl ScMutableUint8Array { - // empty the array - pub fn clear(&self) { - clear(self.obj_id); - } - - // get value proxy for item at index, index can be 0..length() - // when index equals length() a new item is appended - pub fn get_uint8(&self, index: i32) -> ScMutableUint8 { - ScMutableUint8 { obj_id: self.obj_id, key_id: Key32(index) } - } - - // get immutable version of array proxy - pub fn immutable(&self) -> ScImmutableUint8Array { - ScImmutableUint8Array { obj_id: self.obj_id } - } - - // number of items in array - pub fn length(&self) -> i32 { - get_length(self.obj_id) - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - // value proxy for mutable Uint16 in host container pub struct ScMutableUint16 { obj_id: i32, @@ -1373,36 +851,6 @@ impl ScMutableUint16 { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -// array proxy for mutable array of Uint16 -pub struct ScMutableUint16Array { - pub(crate) obj_id: i32, -} - -impl ScMutableUint16Array { - // empty the array - pub fn clear(&self) { - clear(self.obj_id); - } - - // get value proxy for item at index, index can be 0..length() - // when index equals length() a new item is appended - pub fn get_uint16(&self, index: i32) -> ScMutableUint16 { - ScMutableUint16 { obj_id: self.obj_id, key_id: Key32(index) } - } - - // get immutable version of array proxy - pub fn immutable(&self) -> ScImmutableUint16Array { - ScImmutableUint16Array { obj_id: self.obj_id } - } - - // number of items in array - pub fn length(&self) -> i32 { - get_length(self.obj_id) - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - // value proxy for mutable Uint32 in host container pub struct ScMutableUint32 { obj_id: i32, @@ -1443,36 +891,6 @@ impl ScMutableUint32 { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -// array proxy for mutable array of Uint32 -pub struct ScMutableUint32Array { - pub(crate) obj_id: i32, -} - -impl ScMutableUint32Array { - // empty the array - pub fn clear(&self) { - clear(self.obj_id); - } - - // get value proxy for item at index, index can be 0..length() - // when index equals length() a new item is appended - pub fn get_uint32(&self, index: i32) -> ScMutableUint32 { - ScMutableUint32 { obj_id: self.obj_id, key_id: Key32(index) } - } - - // get immutable version of array proxy - pub fn immutable(&self) -> ScImmutableUint32Array { - ScImmutableUint32Array { obj_id: self.obj_id } - } - - // number of items in array - pub fn length(&self) -> i32 { - get_length(self.obj_id) - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - // value proxy for mutable Uint64 in host container pub struct ScMutableUint64 { obj_id: i32, @@ -1510,33 +928,3 @@ impl ScMutableUint64 { u64::from_le_bytes(bytes.try_into().expect("invalid ui64 length")) } } - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -// value proxy for mutable Uint64 -pub struct ScMutableUint64Array { - pub(crate) obj_id: i32, -} - -impl ScMutableUint64Array { - // empty the array - pub fn clear(&self) { - clear(self.obj_id); - } - - // get value proxy for item at index, index can be 0..length() - // when index equals length() a new item is appended - pub fn get_uint64(&self, index: i32) -> ScMutableUint64 { - ScMutableUint64 { obj_id: self.obj_id, key_id: Key32(index) } - } - - // get immutable version of array proxy - pub fn immutable(&self) -> ScImmutableUint64Array { - ScImmutableUint64Array { obj_id: self.obj_id } - } - - // number of items in array - pub fn length(&self) -> i32 { - get_length(self.obj_id) - } -} diff --git a/packages/vm/wasmlib/ts/wasmlib/immutable.ts b/packages/vm/wasmlib/ts/wasmlib/immutable.ts index 78519b84cd..b6617fed89 100644 --- a/packages/vm/wasmlib/ts/wasmlib/immutable.ts +++ b/packages/vm/wasmlib/ts/wasmlib/immutable.ts @@ -37,27 +37,6 @@ export class ScImmutableAddress { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -// array proxy for immutable array of ScAddress -export class ScImmutableAddressArray { - objID: i32; - - constructor(id: i32) { - this.objID = id; - } - - // get value proxy for item at index, index can be 0..length()-1 - getAddress(index: i32): ScImmutableAddress { - return new ScImmutableAddress(this.objID, new Key32(index)); - } - - // number of items in array - length(): i32 { - return host.getLength(this.objID); - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - // value proxy for immutable ScAgentID in host container export class ScImmutableAgentID { objID: i32; @@ -86,27 +65,6 @@ export class ScImmutableAgentID { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -// array proxy for immutable array of ScAgentID -export class ScImmutableAgentIDArray { - objID: i32; - - constructor(id: i32) { - this.objID = id; - } - - // get value proxy for item at index, index can be 0..length()-1 - getAgentID(index: i32): ScImmutableAgentID { - return new ScImmutableAgentID(this.objID, new Key32(index)); - } - - // number of items in array - length(): i32 { - return host.getLength(this.objID); - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - // value proxy for immutable Bool in host container export class ScImmutableBool { objID: i32; @@ -136,27 +94,6 @@ export class ScImmutableBool { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -// array proxy for immutable array of Bool -export class ScImmutableBoolArray { - objID: i32; - - constructor(id: i32) { - this.objID = id; - } - - // get value proxy for item at index, index can be 0..length()-1 - getBool(index: i32): ScImmutableBool { - return new ScImmutableBool(this.objID, new Key32(index)); - } - - // number of items in array - length(): i32 { - return host.getLength(this.objID); - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - // value proxy for immutable bytes array in host container export class ScImmutableBytes { objID: i32; @@ -185,27 +122,6 @@ export class ScImmutableBytes { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -// array proxy for immutable array of byte array -export class ScImmutableBytesArray { - objID: i32; - - constructor(id: i32) { - this.objID = id; - } - - // get value proxy for item at index, index can be 0..length()-1 - getBytes(index: i32): ScImmutableBytes { - return new ScImmutableBytes(this.objID, new Key32(index)); - } - - // number of items in array - length(): i32 { - return host.getLength(this.objID); - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - // value proxy for immutable ScChainID in host container export class ScImmutableChainID { objID: i32; @@ -234,27 +150,6 @@ export class ScImmutableChainID { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -// array proxy for immutable array of ScChainID -export class ScImmutableChainIDArray { - objID: i32; - - constructor(id: i32) { - this.objID = id; - } - - // get value proxy for item at index, index can be 0..length()-1 - getChainID(index: i32): ScImmutableChainID { - return new ScImmutableChainID(this.objID, new Key32(index)); - } - - // number of items in array - length(): i32 { - return host.getLength(this.objID); - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - // value proxy for immutable ScColor in host container export class ScImmutableColor { objID: i32; @@ -332,27 +227,6 @@ export class ScImmutableHash { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -// array proxy for immutable array of ScHash -export class ScImmutableHashArray { - objID: i32; - - constructor(id: i32) { - this.objID = id; - } - - // get value proxy for item at index, index can be 0..length()-1 - getHash(index: i32): ScImmutableHash { - return new ScImmutableHash(this.objID, new Key32(index)); - } - - // number of items in array - length(): i32 { - return host.getLength(this.objID); - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - // value proxy for immutable ScHname in host container export class ScImmutableHname { objID: i32; @@ -381,27 +255,6 @@ export class ScImmutableHname { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -// array proxy for immutable array of ScHname -export class ScImmutableHnameArray { - objID: i32; - - constructor(id: i32) { - this.objID = id; - } - - // get value proxy for item at index, index can be 0..length()-1 - getHname(index: i32): ScImmutableHname { - return new ScImmutableHname(this.objID, new Key32(index)); - } - - // number of items in array - length(): i32 { - return host.getLength(this.objID); - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - // value proxy for immutable Int8 in host container export class ScImmutableInt8 { objID: i32; @@ -431,27 +284,6 @@ export class ScImmutableInt8 { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -// array proxy for immutable array of Int8 -export class ScImmutableInt8Array { - objID: i32; - - constructor(id: i32) { - this.objID = id; - } - - // get value proxy for item at index, index can be 0..length()-1 - getInt8(index: i32): ScImmutableInt8 { - return new ScImmutableInt8(this.objID, new Key32(index)); - } - - // number of items in array - length(): i32 { - return host.getLength(this.objID); - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - // value proxy for immutable Int16 in host container export class ScImmutableInt16 { objID: i32; @@ -481,27 +313,6 @@ export class ScImmutableInt16 { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -// array proxy for immutable array of Int16 -export class ScImmutableInt16Array { - objID: i32; - - constructor(id: i32) { - this.objID = id; - } - - // get value proxy for item at index, index can be 0..length()-1 - getInt16(index: i32): ScImmutableInt16 { - return new ScImmutableInt16(this.objID, new Key32(index)); - } - - // number of items in array - length(): i32 { - return host.getLength(this.objID); - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - // value proxy for immutable Int32 in host container export class ScImmutableInt32 { objID: i32; @@ -531,27 +342,6 @@ export class ScImmutableInt32 { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -// array proxy for immutable array of Int32 -export class ScImmutableInt32Array { - objID: i32; - - constructor(id: i32) { - this.objID = id; - } - - // get value proxy for item at index, index can be 0..length()-1 - getInt32(index: i32): ScImmutableInt32 { - return new ScImmutableInt32(this.objID, new Key32(index)); - } - - // number of items in array - length(): i32 { - return host.getLength(this.objID); - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - // value proxy for immutable Int64 in host container export class ScImmutableInt64 { objID: i32; @@ -581,27 +371,6 @@ export class ScImmutableInt64 { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -// array proxy for immutable array of Int64 -export class ScImmutableInt64Array { - objID: i32; - - constructor(id: i32) { - this.objID = id; - } - - // get value proxy for item at index, index can be 0..length()-1 - getInt64(index: i32): ScImmutableInt64 { - return new ScImmutableInt64(this.objID, new Key32(index)); - } - - // number of items in array - length(): i32 { - return host.getLength(this.objID); - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - // map proxy for immutable map export class ScImmutableMap { objID: i32; @@ -619,56 +388,26 @@ export class ScImmutableMap { return new ScImmutableAddress(this.objID, key.getKeyID()); } - // get array proxy for ScImmutableAddressArray specified by key - getAddressArray(key: MapKey): ScImmutableAddressArray { - let arrID = host.getObjectID(this.objID, key.getKeyID(), host.TYPE_ADDRESS | host.TYPE_ARRAY); - return new ScImmutableAddressArray(arrID); - } - // get value proxy for immutable ScAgentID field specified by key getAgentID(key: MapKey): ScImmutableAgentID { return new ScImmutableAgentID(this.objID, key.getKeyID()); } - // get array proxy for ScImmutableAgentIDArray specified by key - getAgentIDArray(key: MapKey): ScImmutableAgentIDArray { - let arrID = host.getObjectID(this.objID, key.getKeyID(), host.TYPE_AGENT_ID | host.TYPE_ARRAY); - return new ScImmutableAgentIDArray(arrID); - } - // get value proxy for immutable Bool field specified by key getBool(key: MapKey): ScImmutableBool { return new ScImmutableBool(this.objID, key.getKeyID()); } - // get array proxy for ScImmutableBoolArray specified by key - getBoolArray(key: MapKey): ScImmutableBoolArray { - let arrID = host.getObjectID(this.objID, key.getKeyID(), host.TYPE_BOOL | host.TYPE_ARRAY); - return new ScImmutableBoolArray(arrID); - } - // get value proxy for immutable bytes array field specified by key getBytes(key: MapKey): ScImmutableBytes { return new ScImmutableBytes(this.objID, key.getKeyID()); } - // get array proxy for ScImmutableBytesArray specified by key - getBytesArray(key: MapKey): ScImmutableBytesArray { - let arrID = host.getObjectID(this.objID, key.getKeyID(), host.TYPE_BYTES | host.TYPE_ARRAY); - return new ScImmutableBytesArray(arrID); - } - // get value proxy for immutable ScChainID field specified by key getChainID(key: MapKey): ScImmutableChainID { return new ScImmutableChainID(this.objID, key.getKeyID()); } - // get array proxy for ScImmutableChainIDArray specified by key - getChainIDArray(key: MapKey): ScImmutableChainIDArray { - let arrID = host.getObjectID(this.objID, key.getKeyID(), host.TYPE_CHAIN_ID | host.TYPE_ARRAY); - return new ScImmutableChainIDArray(arrID); - } - // get value proxy for immutable ScColor field specified by key getColor(key: MapKey): ScImmutableColor { return new ScImmutableColor(this.objID, key.getKeyID()); @@ -685,67 +424,31 @@ export class ScImmutableMap { return new ScImmutableHash(this.objID, key.getKeyID()); } - // get array proxy for ScImmutableHashArray specified by key - getHashArray(key: MapKey): ScImmutableHashArray { - let arrID = host.getObjectID(this.objID, key.getKeyID(), host.TYPE_HASH | host.TYPE_ARRAY); - return new ScImmutableHashArray(arrID); - } - // get value proxy for immutable ScHname field specified by key getHname(key: MapKey): ScImmutableHname { return new ScImmutableHname(this.objID, key.getKeyID()); } - // get array proxy for ScImmutableHnameArray specified by key - getHnameArray(key: MapKey): ScImmutableHnameArray { - let arrID = host.getObjectID(this.objID, key.getKeyID(), host.TYPE_HNAME | host.TYPE_ARRAY); - return new ScImmutableHnameArray(arrID); - } - // get value proxy for immutable Int8 field specified by key getInt8(key: MapKey): ScImmutableInt8 { return new ScImmutableInt8(this.objID, key.getKeyID()); } - // get array proxy for ScImmutableInt8Array specified by key - getInt8Array(key: MapKey): ScImmutableInt8Array { - let arrID = host.getObjectID(this.objID, key.getKeyID(), host.TYPE_INT8 | host.TYPE_ARRAY); - return new ScImmutableInt8Array(arrID); - } - // get value proxy for immutable Int16 field specified by key getInt16(key: MapKey): ScImmutableInt16 { return new ScImmutableInt16(this.objID, key.getKeyID()); } - // get array proxy for ScImmutableInt16Array specified by key - getInt16Array(key: MapKey): ScImmutableInt16Array { - let arrID = host.getObjectID(this.objID, key.getKeyID(), host.TYPE_INT16 | host.TYPE_ARRAY); - return new ScImmutableInt16Array(arrID); - } - // get value proxy for immutable Int32 field specified by key getInt32(key: MapKey): ScImmutableInt32 { return new ScImmutableInt32(this.objID, key.getKeyID()); } - // get array proxy for ScImmutableInt32Array specified by key - getInt32Array(key: MapKey): ScImmutableInt32Array { - let arrID = host.getObjectID(this.objID, key.getKeyID(), host.TYPE_INT32 | host.TYPE_ARRAY); - return new ScImmutableInt32Array(arrID); - } - // get value proxy for immutable Int64 field specified by key getInt64(key: MapKey): ScImmutableInt64 { return new ScImmutableInt64(this.objID, key.getKeyID()); } - // get array proxy for ScImmutableInt64Array specified by key - getInt64Array(key: MapKey): ScImmutableInt64Array { - let arrID = host.getObjectID(this.objID, key.getKeyID(), host.TYPE_INT64 | host.TYPE_ARRAY); - return new ScImmutableInt64Array(arrID); - } - // get map proxy for ScImmutableMap specified by key getMap(key: MapKey): ScImmutableMap { let mapID = host.getObjectID(this.objID, key.getKeyID(), host.TYPE_MAP); @@ -763,12 +466,6 @@ export class ScImmutableMap { return new ScImmutableRequestID(this.objID, key.getKeyID()); } - // get array proxy for ScImmutableRequestIDArray specified by key - getRequestIDArray(key: MapKey): ScImmutableRequestIDArray { - let arrID = host.getObjectID(this.objID, key.getKeyID(), host.TYPE_REQUEST_ID | host.TYPE_ARRAY); - return new ScImmutableRequestIDArray(arrID); - } - // get value proxy for immutable UTF-8 text string field specified by key getString(key: MapKey): ScImmutableString { return new ScImmutableString(this.objID, key.getKeyID()); @@ -785,45 +482,21 @@ export class ScImmutableMap { return new ScImmutableUint8(this.objID, key.getKeyID()); } - // get array proxy for ScImmutableUint8Array specified by key - getUint8Array(key: MapKey): ScImmutableUint8Array { - let arrID = host.getObjectID(this.objID, key.getKeyID(), host.TYPE_INT8 | host.TYPE_ARRAY); - return new ScImmutableUint8Array(arrID); - } - // get value proxy for immutable Uint16 field specified by key getUint16(key: MapKey): ScImmutableUint16 { return new ScImmutableUint16(this.objID, key.getKeyID()); } - // get array proxy for ScImmutableUint16Array specified by key - getUint16Array(key: MapKey): ScImmutableUint16Array { - let arrID = host.getObjectID(this.objID, key.getKeyID(), host.TYPE_INT16 | host.TYPE_ARRAY); - return new ScImmutableUint16Array(arrID); - } - // get value proxy for immutable Uint32 field specified by key getUint32(key: MapKey): ScImmutableUint32 { return new ScImmutableUint32(this.objID, key.getKeyID()); } - // get array proxy for ScImmutableUint32Array specified by key - getUint32Array(key: MapKey): ScImmutableUint32Array { - let arrID = host.getObjectID(this.objID, key.getKeyID(), host.TYPE_INT32 | host.TYPE_ARRAY); - return new ScImmutableUint32Array(arrID); - } - // get value proxy for immutable Uint64 field specified by key getUint64(key: MapKey): ScImmutableUint64 { return new ScImmutableUint64(this.objID, key.getKeyID()); } - // get array proxy for ScImmutableUint64Array specified by key - getUint64Array(key: MapKey): ScImmutableUint64Array { - let arrID = host.getObjectID(this.objID, key.getKeyID(), host.TYPE_INT64 | host.TYPE_ARRAY); - return new ScImmutableUint64Array(arrID); - } - mapID(): i32 { return this.objID; } @@ -879,27 +552,6 @@ export class ScImmutableRequestID { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -// array proxy for immutable array of ScRequestID -export class ScImmutableRequestIDArray { - objID: i32; - - constructor(id: i32) { - this.objID = id; - } - - // get value proxy for item at index, index can be 0..length()-1 - getRequestID(index: i32): ScImmutableRequestID { - return new ScImmutableRequestID(this.objID, new Key32(index)); - } - - // number of items in array - length(): i32 { - return host.getLength(this.objID); - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - // value proxy for immutable UTF-8 text string in host container export class ScImmutableString { objID: i32; @@ -979,27 +631,6 @@ export class ScImmutableUint8 { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -// array proxy for immutable array of Uint8 -export class ScImmutableUint8Array { - objID: i32; - - constructor(id: i32) { - this.objID = id; - } - - // get value proxy for item at index, index can be 0..length()-1 - getUint8(index: i32): ScImmutableUint8 { - return new ScImmutableUint8(this.objID, new Key32(index)); - } - - // number of items in array - length(): u32 { - return host.getLength(this.objID); - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - // value proxy for immutable Uint16 in host container export class ScImmutableUint16 { objID: i32; @@ -1029,27 +660,6 @@ export class ScImmutableUint16 { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -// array proxy for immutable array of Uint16 -export class ScImmutableUint16Array { - objID: i32; - - constructor(id: i32) { - this.objID = id; - } - - // get value proxy for item at index, index can be 0..length()-1 - getUint16(index: i32): ScImmutableUint16 { - return new ScImmutableUint16(this.objID, new Key32(index)); - } - - // number of items in array - length(): i32 { - return host.getLength(this.objID); - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - // value proxy for immutable Uint32 in host container export class ScImmutableUint32 { objID: i32; @@ -1079,27 +689,6 @@ export class ScImmutableUint32 { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -// array proxy for immutable array of Uint32 -export class ScImmutableUint32Array { - objID: i32; - - constructor(id: i32) { - this.objID = id; - } - - // get value proxy for item at index, index can be 0..length()-1 - getUint32(index: i32): ScImmutableUint32 { - return new ScImmutableUint32(this.objID, new Key32(index)); - } - - // number of items in array - length(): i32 { - return host.getLength(this.objID); - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - // value proxy for immutable Uint64 in host container export class ScImmutableUint64 { objID: i32; @@ -1126,24 +715,3 @@ export class ScImmutableUint64 { return Convert.toI64(bytes) as u64; } } - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -// array proxy for immutable array of Uint64 -export class ScImmutableUint64Array { - objID: i32; - - constructor(id: i32) { - this.objID = id; - } - - // get value proxy for item at index, index can be 0..length()-1 - getUint64(index: i32): ScImmutableUint64 { - return new ScImmutableUint64(this.objID, new Key32(index)); - } - - // number of items in array - length(): i32 { - return host.getLength(this.objID); - } -} diff --git a/packages/vm/wasmlib/ts/wasmlib/mutable.ts b/packages/vm/wasmlib/ts/wasmlib/mutable.ts index 6bb0923a10..12e33406f2 100644 --- a/packages/vm/wasmlib/ts/wasmlib/mutable.ts +++ b/packages/vm/wasmlib/ts/wasmlib/mutable.ts @@ -8,26 +8,9 @@ import {Convert} from "./convert"; import {ScAddress, ScAgentID, ScChainID, ScColor, ScHash, ScHname, ScRequestID} from "./hashtypes"; import * as host from "./host"; import { - ScImmutableAddressArray, - ScImmutableAgentIDArray, - ScImmutableBoolArray, - ScImmutableBytesArray, - ScImmutableChainIDArray, - ScImmutableColorArray, - ScImmutableHashArray, - ScImmutableHnameArray, - ScImmutableInt8Array, - ScImmutableInt16Array, - ScImmutableInt32Array, - ScImmutableInt64Array, ScImmutableMap, ScImmutableMapArray, - ScImmutableRequestIDArray, ScImmutableStringArray, - ScImmutableUint8Array, - ScImmutableUint16Array, - ScImmutableUint32Array, - ScImmutableUint64Array, } from "./immutable"; import {Key32, KEY_MAPS, MapKey} from "./keys"; @@ -71,38 +54,6 @@ export class ScMutableAddress { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -// array proxy for mutable array of ScAddress -export class ScMutableAddressArray { - objID: i32; - - constructor(id: i32) { - this.objID = id; - } - - // empty the array - clear(): void { - host.clear(this.objID); - } - - // get value proxy for item at index, index can be 0..length() - // when index equals length() a new item is appended - getAddress(index: i32): ScMutableAddress { - return new ScMutableAddress(this.objID, new Key32(index)); - } - - // get immutable version of array proxy - immutable(): ScImmutableAddressArray { - return new ScImmutableAddressArray(this.objID); - } - - // number of items in array - length(): i32 { - return host.getLength(this.objID); - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - // value proxy for mutable ScAgentID in host container export class ScMutableAgentID { objID: i32; @@ -141,38 +92,6 @@ export class ScMutableAgentID { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -// array proxy for mutable array of ScAgentID -export class ScMutableAgentIDArray { - objID: i32; - - constructor(id: i32) { - this.objID = id; - } - - // empty the array - clear(): void { - host.clear(this.objID); - } - - // get value proxy for item at index, index can be 0..length() - // when index equals length() a new item is appended - getAgentID(index: i32): ScMutableAgentID { - return new ScMutableAgentID(this.objID, new Key32(index)); - } - - // get immutable version of array proxy - immutable(): ScImmutableAgentIDArray { - return new ScImmutableAgentIDArray(this.objID); - } - - // number of items in array - length(): i32 { - return host.getLength(this.objID); - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - // value proxy for mutable Bool in host container export class ScMutableBool { objID: i32; @@ -213,38 +132,6 @@ export class ScMutableBool { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -// array proxy for mutable array of Bool -export class ScMutableBoolArray { - objID: i32; - - constructor(id: i32) { - this.objID = id; - } - - // empty the array - clear(): void { - host.clear(this.objID); - } - - // get value proxy for item at index, index can be 0..length() - // when index equals length() a new item is appended - getBool(index: i32): ScMutableBool { - return new ScMutableBool(this.objID, new Key32(index)); - } - - // get immutable version of array proxy - immutable(): ScImmutableBoolArray { - return new ScImmutableBoolArray(this.objID); - } - - // number of items in array - length(): i32 { - return host.getLength(this.objID); - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - // value proxy for mutable bytes array in host container export class ScMutableBytes { objID: i32; @@ -283,38 +170,6 @@ export class ScMutableBytes { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -// array proxy for mutable array of byte array -export class ScMutableBytesArray { - objID: i32; - - constructor(id: i32) { - this.objID = id; - } - - // empty the array - clear(): void { - host.clear(this.objID); - } - - // get value proxy for item at index, index can be 0..length() - // when index equals length() a new item is appended - getBytes(index: i32): ScMutableBytes { - return new ScMutableBytes(this.objID, new Key32(index)); - } - - // get immutable version of array proxy - immutable(): ScImmutableBytesArray { - return new ScImmutableBytesArray(this.objID); - } - - // number of items in array - length(): i32 { - return host.getLength(this.objID); - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - // value proxy for mutable ScChainID in host container export class ScMutableChainID { objID: i32; @@ -353,38 +208,6 @@ export class ScMutableChainID { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -// array proxy for mutable array of ScChainID -export class ScMutableChainIDArray { - objID: i32; - - constructor(id: i32) { - this.objID = id; - } - - // empty the array - clear(): void { - host.clear(this.objID); - } - - // get value proxy for item at index, index can be 0..length() - // when index equals length() a new item is appended - getChainID(index: i32): ScMutableChainID { - return new ScMutableChainID(this.objID, new Key32(index)); - } - - // get immutable version of array proxy - immutable(): ScImmutableChainIDArray { - return new ScImmutableChainIDArray(this.objID); - } - - // number of items in array - length(): i32 { - return host.getLength(this.objID); - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - // value proxy for mutable ScColor in host container export class ScMutableColor { objID: i32; @@ -423,38 +246,6 @@ export class ScMutableColor { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -// array proxy for mutable array of ScColor -export class ScMutableColorArray { - objID: i32; - - constructor(id: i32) { - this.objID = id; - } - - // empty the array - clear(): void { - host.clear(this.objID); - } - - // get value proxy for item at index, index can be 0..length() - // when index equals length() a new item is appended - getColor(index: i32): ScMutableColor { - return new ScMutableColor(this.objID, new Key32(index)); - } - - // get immutable version of array proxy - immutable(): ScImmutableColorArray { - return new ScImmutableColorArray(this.objID); - } - - // number of items in array - length(): i32 { - return host.getLength(this.objID); - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - // value proxy for mutable ScHash in host container export class ScMutableHash { objID: i32; @@ -493,38 +284,6 @@ export class ScMutableHash { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -// array proxy for mutable array of ScHash -export class ScMutableHashArray { - objID: i32; - - constructor(id: i32) { - this.objID = id; - } - - // empty the array - clear(): void { - host.clear(this.objID); - } - - // get value proxy for item at index, index can be 0..length() - // when index equals length() a new item is appended - getHash(index: i32): ScMutableHash { - return new ScMutableHash(this.objID, new Key32(index)); - } - - // get immutable version of array proxy - immutable(): ScImmutableHashArray { - return new ScImmutableHashArray(this.objID); - } - - // number of items in array - length(): i32 { - return host.getLength(this.objID); - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - // value proxy for mutable ScHname in host container export class ScMutableHname { objID: i32; @@ -563,38 +322,6 @@ export class ScMutableHname { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -// array proxy for mutable array of ScHname -export class ScMutableHnameArray { - objID: i32; - - constructor(id: i32) { - this.objID = id; - } - - // empty the array - clear(): void { - host.clear(this.objID); - } - - // get value proxy for item at index, index can be 0..length() - // when index equals length() a new item is appended - getHname(index: i32): ScMutableHname { - return new ScMutableHname(this.objID, new Key32(index)); - } - - // get immutable version of array proxy - immutable(): ScImmutableHnameArray { - return new ScImmutableHnameArray(this.objID); - } - - // number of items in array - length(): i32 { - return host.getLength(this.objID); - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - // value proxy for mutable Int8 in host container export class ScMutableInt8 { objID: i32; @@ -635,38 +362,6 @@ export class ScMutableInt8 { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -// array proxy for mutable array of Int8 -export class ScMutableInt8Array { - objID: i32; - - constructor(id: i32) { - this.objID = id; - } - - // empty the array - clear(): void { - host.clear(this.objID); - } - - // get value proxy for item at index, index can be 0..length() - // when index equals length() a new item is appended - getInt8(index: i32): ScMutableInt8 { - return new ScMutableInt8(this.objID, new Key32(index)); - } - - // get immutable version of array proxy - immutable(): ScImmutableInt8Array { - return new ScImmutableInt8Array(this.objID); - } - - // number of items in array - length(): i32 { - return host.getLength(this.objID); - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - // value proxy for mutable Int16 in host container export class ScMutableInt16 { objID: i32; @@ -705,38 +400,6 @@ export class ScMutableInt16 { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -// array proxy for mutable array of Int16 -export class ScMutableInt16Array { - objID: i32; - - constructor(id: i32) { - this.objID = id; - } - - // empty the array - clear(): void { - host.clear(this.objID); - } - - // get value proxy for item at index, index can be 0..length() - // when index equals length() a new item is appended - getInt16(index: i32): ScMutableInt16 { - return new ScMutableInt16(this.objID, new Key32(index)); - } - - // get immutable version of array proxy - immutable(): ScImmutableInt16Array { - return new ScImmutableInt16Array(this.objID); - } - - // number of items in array - length(): i32 { - return host.getLength(this.objID); - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - // value proxy for mutable Int32 in host container export class ScMutableInt32 { objID: i32; @@ -775,38 +438,6 @@ export class ScMutableInt32 { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -// array proxy for mutable array of Int32 -export class ScMutableInt32Array { - objID: i32; - - constructor(id: i32) { - this.objID = id; - } - - // empty the array - clear(): void { - host.clear(this.objID); - } - - // get value proxy for item at index, index can be 0..length() - // when index equals length() a new item is appended - getInt32(index: i32): ScMutableInt32 { - return new ScMutableInt32(this.objID, new Key32(index)); - } - - // get immutable version of array proxy - immutable(): ScImmutableInt32Array { - return new ScImmutableInt32Array(this.objID); - } - - // number of items in array - length(): i32 { - return host.getLength(this.objID); - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - // value proxy for mutable Int64 in host container export class ScMutableInt64 { objID: i32; @@ -845,38 +476,6 @@ export class ScMutableInt64 { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -// array proxy for mutable array of Int64 -export class ScMutableInt64Array { - objID: i32; - - constructor(id: i32) { - this.objID = id; - } - - // empty the array - clear(): void { - host.clear(this.objID); - } - - // get value proxy for item at index, index can be 0..length() - // when index equals length() a new item is appended - getInt64(index: i32): ScMutableInt64 { - return new ScMutableInt64(this.objID, new Key32(index)); - } - - // get immutable version of array proxy - immutable(): ScImmutableInt64Array { - return new ScImmutableInt64Array(this.objID); - } - - // number of items in array - length(): i32 { - return host.getLength(this.objID); - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - // map proxy for mutable map export class ScMutableMap { objID: i32; @@ -905,133 +504,61 @@ export class ScMutableMap { return new ScMutableAddress(this.objID, key.getKeyID()); } - // get array proxy for ScMutableAddressArray specified by key - getAddressArray(key: MapKey): ScMutableAddressArray { - let arrID = host.getObjectID(this.objID, key.getKeyID(), host.TYPE_ADDRESS | host.TYPE_ARRAY); - return new ScMutableAddressArray(arrID); - } - // get value proxy for mutable ScAgentID field specified by key getAgentID(key: MapKey): ScMutableAgentID { return new ScMutableAgentID(this.objID, key.getKeyID()); } - // get array proxy for ScMutableAgentIDArray specified by key - getAgentIDArray(key: MapKey): ScMutableAgentIDArray { - let arrID = host.getObjectID(this.objID, key.getKeyID(), host.TYPE_AGENT_ID | host.TYPE_ARRAY); - return new ScMutableAgentIDArray(arrID); - } - // get value proxy for mutable Bool field specified by key getBool(key: MapKey): ScMutableBool { return new ScMutableBool(this.objID, key.getKeyID()); } - // get array proxy for ScMutableBoolArray specified by key - getBoolArray(key: MapKey): ScMutableBoolArray { - let arrID = host.getObjectID(this.objID, key.getKeyID(), host.TYPE_BOOL | host.TYPE_ARRAY); - return new ScMutableBoolArray(arrID); - } - // get value proxy for mutable Bytes array field specified by key getBytes(key: MapKey): ScMutableBytes { return new ScMutableBytes(this.objID, key.getKeyID()); } - // get array proxy for ScMutableBytesArray specified by key - getBytesArray(key: MapKey): ScMutableBytesArray { - let arrID = host.getObjectID(this.objID, key.getKeyID(), host.TYPE_BYTES | host.TYPE_ARRAY); - return new ScMutableBytesArray(arrID); - } - // get value proxy for mutable ScChainID field specified by key getChainID(key: MapKey): ScMutableChainID { return new ScMutableChainID(this.objID, key.getKeyID()); } - // get array proxy for ScMutableChainIDArray specified by key - getChainIDArray(key: MapKey): ScMutableChainIDArray { - let arrID = host.getObjectID(this.objID, key.getKeyID(), host.TYPE_CHAIN_ID | host.TYPE_ARRAY); - return new ScMutableChainIDArray(arrID); - } - // get value proxy for mutable ScColor field specified by key getColor(key: MapKey): ScMutableColor { return new ScMutableColor(this.objID, key.getKeyID()); } - // get array proxy for ScMutableColorArray specified by key - getColorArray(key: MapKey): ScMutableColorArray { - let arrID = host.getObjectID(this.objID, key.getKeyID(), host.TYPE_COLOR | host.TYPE_ARRAY); - return new ScMutableColorArray(arrID); - } - // get value proxy for mutable ScHash field specified by key getHash(key: MapKey): ScMutableHash { return new ScMutableHash(this.objID, key.getKeyID()); } - // get array proxy for ScMutableHashArray specified by key - getHashArray(key: MapKey): ScMutableHashArray { - let arrID = host.getObjectID(this.objID, key.getKeyID(), host.TYPE_HASH | host.TYPE_ARRAY); - return new ScMutableHashArray(arrID); - } - // get value proxy for mutable ScHname field specified by key getHname(key: MapKey): ScMutableHname { return new ScMutableHname(this.objID, key.getKeyID()); } - // get array proxy for ScMutableHnameArray specified by key - getHnameArray(key: MapKey): ScMutableHnameArray { - let arrID = host.getObjectID(this.objID, key.getKeyID(), host.TYPE_HNAME | host.TYPE_ARRAY); - return new ScMutableHnameArray(arrID); - } - // get value proxy for mutable Int8 field specified by key getInt8(key: MapKey): ScMutableInt8 { return new ScMutableInt8(this.objID, key.getKeyID()); } - // get array proxy for ScMutableInt8Array specified by key - getInt8Array(key: MapKey): ScMutableInt8Array { - let arrID = host.getObjectID(this.objID, key.getKeyID(), host.TYPE_INT8 | host.TYPE_ARRAY); - return new ScMutableInt8Array(arrID); - } - // get value proxy for mutable Int16 field specified by key getInt16(key: MapKey): ScMutableInt16 { return new ScMutableInt16(this.objID, key.getKeyID()); } - // get array proxy for ScMutableInt16Array specified by key - getInt16Array(key: MapKey): ScMutableInt16Array { - let arrID = host.getObjectID(this.objID, key.getKeyID(), host.TYPE_INT16 | host.TYPE_ARRAY); - return new ScMutableInt16Array(arrID); - } - // get value proxy for mutable Int32 field specified by key getInt32(key: MapKey): ScMutableInt32 { return new ScMutableInt32(this.objID, key.getKeyID()); } - // get array proxy for ScMutableInt32Array specified by key - getInt32Array(key: MapKey): ScMutableInt32Array { - let arrID = host.getObjectID(this.objID, key.getKeyID(), host.TYPE_INT32 | host.TYPE_ARRAY); - return new ScMutableInt32Array(arrID); - } - // get value proxy for mutable Int64 field specified by key getInt64(key: MapKey): ScMutableInt64 { return new ScMutableInt64(this.objID, key.getKeyID()); } - // get array proxy for ScMutableInt64Array specified by key - getInt64Array(key: MapKey): ScMutableInt64Array { - let arrID = host.getObjectID(this.objID, key.getKeyID(), host.TYPE_INT64 | host.TYPE_ARRAY); - return new ScMutableInt64Array(arrID); - } - // get map proxy for ScMutableMap specified by key getMap(key: MapKey): ScMutableMap { let mapID = host.getObjectID(this.objID, key.getKeyID(), host.TYPE_MAP); @@ -1049,12 +576,6 @@ export class ScMutableMap { return new ScMutableRequestID(this.objID, key.getKeyID()); } - // get array proxy for ScMutableRequestIDArray specified by key - getRequestIDArray(key: MapKey): ScMutableRequestIDArray { - let arrID = host.getObjectID(this.objID, key.getKeyID(), host.TYPE_REQUEST_ID | host.TYPE_ARRAY); - return new ScMutableRequestIDArray(arrID); - } - // get value proxy for mutable UTF-8 text string field specified by key getString(key: MapKey): ScMutableString { return new ScMutableString(this.objID, key.getKeyID()); @@ -1071,45 +592,21 @@ export class ScMutableMap { return new ScMutableUint8(this.objID, key.getKeyID()); } - // get array proxy for ScMutableUint8Array specified by key - getUint8Array(key: MapKey): ScMutableUint8Array { - let arrID = host.getObjectID(this.objID, key.getKeyID(), host.TYPE_INT8 | host.TYPE_ARRAY); - return new ScMutableUint8Array(arrID); - } - // get value proxy for mutable Uint16 field specified by key getUint16(key: MapKey): ScMutableUint16 { return new ScMutableUint16(this.objID, key.getKeyID()); } - // get array proxy for ScMutableUint16Array specified by key - getUint16Array(key: MapKey): ScMutableUint16Array { - let arrID = host.getObjectID(this.objID, key.getKeyID(), host.TYPE_INT16 | host.TYPE_ARRAY); - return new ScMutableUint16Array(arrID); - } - // get value proxy for mutable Uint32 field specified by key getUint32(key: MapKey): ScMutableUint32 { return new ScMutableUint32(this.objID, key.getKeyID()); } - // get array proxy for ScMutableUint32Array specified by key - getUint32Array(key: MapKey): ScMutableUint32Array { - let arrID = host.getObjectID(this.objID, key.getKeyID(), host.TYPE_INT32 | host.TYPE_ARRAY); - return new ScMutableUint32Array(arrID); - } - // get value proxy for mutable Uint64 field specified by key getUint64(key: MapKey): ScMutableUint64 { return new ScMutableUint64(this.objID, key.getKeyID()); } - // get array proxy for ScMutableUint64Array specified by key - getUint64Array(key: MapKey): ScMutableUint64Array { - let arrID = host.getObjectID(this.objID, key.getKeyID(), host.TYPE_INT64 | host.TYPE_ARRAY); - return new ScMutableUint64Array(arrID); - } - // get immutable version of map proxy immutable(): ScImmutableMap { return new ScImmutableMap(this.objID); @@ -1193,38 +690,6 @@ export class ScMutableRequestID { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -// array proxy for mutable array of ScRequestID -export class ScMutableRequestIDArray { - objID: i32; - - constructor(id: i32) { - this.objID = id; - } - - // empty the array - clear(): void { - host.clear(this.objID); - } - - // get value proxy for item at index, index can be 0..length() - // when index equals length() a new item is appended - getRequestID(index: i32): ScMutableRequestID { - return new ScMutableRequestID(this.objID, new Key32(index)); - } - - // get immutable version of array proxy - immutable(): ScImmutableRequestIDArray { - return new ScImmutableRequestIDArray(this.objID); - } - - // number of items in array - length(): i32 { - return host.getLength(this.objID); - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - // value proxy for mutable UTF-8 text string in host container export class ScMutableString { objID: i32; @@ -1336,38 +801,6 @@ export class ScMutableUint8 { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -// array proxy for mutable array of Uint8 -export class ScMutableUint8Array { - objID: i32; - - constructor(id: i32) { - this.objID = id; - } - - // empty the array - clear(): void { - host.clear(this.objID); - } - - // get value proxy for item at index, index can be 0..length() - // when index equals length() a new item is appended - getUint8(index: i32): ScMutableUint8 { - return new ScMutableUint8(this.objID, new Key32(index)); - } - - // get immutable version of array proxy - immutable(): ScImmutableUint8Array { - return new ScImmutableUint8Array(this.objID); - } - - // number of items in array - length(): i32 { - return host.getLength(this.objID); - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - // value proxy for mutable Uint16 in host container export class ScMutableUint16 { objID: i32; @@ -1407,38 +840,6 @@ export class ScMutableUint16 { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -// array proxy for mutable array of Uint16 -export class ScMutableUint16Array { - objID: i32; - - constructor(id: i32) { - this.objID = id; - } - - // empty the array - clear(): void { - host.clear(this.objID); - } - - // get value proxy for item at index, index can be 0..length() - // when index equals length() a new item is appended - getUint16(index: i32): ScMutableUint16 { - return new ScMutableUint16(this.objID, new Key32(index)); - } - - // get immutable version of array proxy - immutable(): ScImmutableUint16Array { - return new ScImmutableUint16Array(this.objID); - } - - // number of items in array - length(): i32 { - return host.getLength(this.objID); - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - // value proxy for mutable Uint32 in host container export class ScMutableUint32 { objID: i32; @@ -1478,38 +879,6 @@ export class ScMutableUint32 { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -// array proxy for mutable array of Uint32 -export class ScMutableUint32Array { - objID: i32; - - constructor(id: i32) { - this.objID = id; - } - - // empty the array - clear(): void { - host.clear(this.objID); - } - - // get value proxy for item at index, index can be 0..length() - // when index equals length() a new item is appended - getUint32(index: i32): ScMutableUint32 { - return new ScMutableUint32(this.objID, new Key32(index)); - } - - // get immutable version of array proxy - immutable(): ScImmutableUint32Array { - return new ScImmutableUint32Array(this.objID); - } - - // number of items in array - length(): i32 { - return host.getLength(this.objID); - } -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - // value proxy for mutable Uint64 in host container export class ScMutableUint64 { objID: i32; @@ -1546,35 +915,3 @@ export class ScMutableUint64 { return Convert.toI64(bytes) as u64; } } - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -// array proxy for mutable array of Uint64 -export class ScMutableUint64Array { - objID: i32; - - constructor(id: i32) { - this.objID = id; - } - - // empty the array - clear(): void { - host.clear(this.objID); - } - - // get value proxy for item at index, index can be 0..length() - // when index equals length() a new item is appended - getUint64(index: i32): ScMutableUint64 { - return new ScMutableUint64(this.objID, new Key32(index)); - } - - // get immutable version of array proxy - immutable(): ScImmutableUint64Array { - return new ScImmutableUint64Array(this.objID); - } - - // number of items in array - length(): i32 { - return host.getLength(this.objID); - } -} diff --git a/tools/cluster/tests/wasm/inccounter_bg.wasm b/tools/cluster/tests/wasm/inccounter_bg.wasm index c92255512777682979b30ec89b755ab80e5b300f..ae1937db526f66951a7f2aa742ed3e65e10f983c 100644 GIT binary patch delta 39 ucmbPwl4 delta 39 ucmbPwl4@An@==gWa40&oH Date: Thu, 20 Jan 2022 06:18:30 +0100 Subject: [PATCH 032/111] minor change --- packages/vm/wasmlib/ts/wasmclient/goshimmer/goshimmerclient.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/vm/wasmlib/ts/wasmclient/goshimmer/goshimmerclient.ts b/packages/vm/wasmlib/ts/wasmclient/goshimmer/goshimmerclient.ts index f66c8be61c..c82c0c5c1e 100644 --- a/packages/vm/wasmlib/ts/wasmclient/goshimmer/goshimmerclient.ts +++ b/packages/vm/wasmlib/ts/wasmclient/goshimmer/goshimmerclient.ts @@ -123,7 +123,7 @@ export class GoShimmerClient { public async postOnLedgerRequest( chainId: string, payload: IOnLedger, - transfer: bigint = 1n, + transfer = 1n, keyPair: IKeyPair ): Promise { if (transfer <= 0) { From 000bfe59d21c6ab9fa7aed03e3c1ab847e6dc1d8 Mon Sep 17 00:00:00 2001 From: "Bruno A. dos Santos" Date: Thu, 20 Jan 2022 06:19:21 +0100 Subject: [PATCH 033/111] minor change 2 --- packages/vm/wasmlib/ts/wasmclient/service.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/vm/wasmlib/ts/wasmclient/service.ts b/packages/vm/wasmlib/ts/wasmclient/service.ts index 9512b37ca6..a66a576d82 100644 --- a/packages/vm/wasmlib/ts/wasmclient/service.ts +++ b/packages/vm/wasmlib/ts/wasmclient/service.ts @@ -17,7 +17,7 @@ export class Service { public keyPair: IKeyPair | null = null; private eventHandlers: Array = []; public scHname: wasmclient.Hname; - private waspWebSocketUrl: string = ""; + private waspWebSocketUrl = ""; constructor(client: wasmclient.ServiceClient, scHname: wasmclient.Hname) { this.serviceClient = client; From fd84ce243a8990471f94b9bf0b1c8866a8335844 Mon Sep 17 00:00:00 2001 From: "Bruno A. dos Santos" Date: Thu, 20 Jan 2022 06:24:43 +0100 Subject: [PATCH 034/111] fix @typescript-eslint/no-non-null-assertion --- packages/vm/wasmlib/ts/wasmclient/waspclient.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/vm/wasmlib/ts/wasmclient/waspclient.ts b/packages/vm/wasmlib/ts/wasmclient/waspclient.ts index 49c0067e13..b81f0570b8 100644 --- a/packages/vm/wasmlib/ts/wasmclient/waspclient.ts +++ b/packages/vm/wasmlib/ts/wasmclient/waspclient.ts @@ -100,10 +100,10 @@ export class WaspClient { const result = await balanceView.call(); const balances = result.balances(); const iotaBalance = balances.has(Colors.IOTA_COLOR_STRING) - ? balances.get(Colors.IOTA_COLOR_STRING)! + ? balances.get(Colors.IOTA_COLOR_STRING) : balances.has(Colors.IOTA_COLOR) - ? balances.get(Colors.IOTA_COLOR)! + ? balances.get(Colors.IOTA_COLOR) : 0n; - return iotaBalance; + return iotaBalance ?? 0n; } } From 13ab4662e893104390c7d9716dceb4b5816f07f1 Mon Sep 17 00:00:00 2001 From: "Bruno A. dos Santos" Date: Thu, 20 Jan 2022 06:31:20 +0100 Subject: [PATCH 035/111] more fixes for @typescript-eslint/no-non-null-assertion --- packages/vm/wasmlib/ts/wasmclient/goshimmer/goshimmerclient.ts | 3 ++- .../wasmclient/goshimmer/pow_web_worker/pow_worker_manager.ts | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/vm/wasmlib/ts/wasmclient/goshimmer/goshimmerclient.ts b/packages/vm/wasmlib/ts/wasmclient/goshimmer/goshimmerclient.ts index c82c0c5c1e..d6920cab4c 100644 --- a/packages/vm/wasmlib/ts/wasmclient/goshimmer/goshimmerclient.ts +++ b/packages/vm/wasmlib/ts/wasmclient/goshimmer/goshimmerclient.ts @@ -46,8 +46,9 @@ export class GoShimmerClient { const unspents = await this.unspentOutputs({ addresses: [address] }); const currentUnspent = unspents.unspentOutputs.find((x) => x.address.base58 == address); + if (!currentUnspent) throw new Error("current unspent not found"); - const balance = currentUnspent!.outputs + const balance = currentUnspent.outputs .filter( (o) => ["ExtendedLockedOutputType", "SigLockedColoredOutputType"].includes(o.output.type) && diff --git a/packages/vm/wasmlib/ts/wasmclient/goshimmer/pow_web_worker/pow_worker_manager.ts b/packages/vm/wasmlib/ts/wasmclient/goshimmer/pow_web_worker/pow_worker_manager.ts index 18dded42f8..9c0b050a7c 100644 --- a/packages/vm/wasmlib/ts/wasmclient/goshimmer/pow_web_worker/pow_worker_manager.ts +++ b/packages/vm/wasmlib/ts/wasmclient/goshimmer/pow_web_worker/pow_worker_manager.ts @@ -29,7 +29,7 @@ export class PoWWorkerManager { const message: PowWorkerResponse = e.data; if (message.type == 'pow_response' && message.uuid == requestId) { - this.powWorker!.removeEventListener('message', responseHandler); + this.powWorker.removeEventListener('message', responseHandler); if (!message.error) { resolve(message.data); From 6e1ace752b832bd6146ed9ff2ec88835ee9905d5 Mon Sep 17 00:00:00 2001 From: Eric Hop Date: Wed, 19 Jan 2022 22:20:40 -0800 Subject: [PATCH 036/111] Disabled lint warnings for TS --- tools/schema/generator/tsclienttemplates/events.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/schema/generator/tsclienttemplates/events.go b/tools/schema/generator/tsclienttemplates/events.go index 93bf4d792f..bd0b5b5712 100644 --- a/tools/schema/generator/tsclienttemplates/events.go +++ b/tools/schema/generator/tsclienttemplates/events.go @@ -10,7 +10,9 @@ $#each events eventHandler ]); export class $PkgName$+Events implements wasmclient.IEventHandler { +/* eslint-disable @typescript-eslint/no-empty-function */ $#each events eventHandlerMember +/* eslint-enable @typescript-eslint/no-empty-function */ public callHandler(topic: string, params: string[]): void { const handler = $pkgName$+Handlers.get(topic); From 35707b236f889b463329b9a2c0eeb31c488a19fd Mon Sep 17 00:00:00 2001 From: "Bruno A. dos Santos" Date: Sat, 22 Jan 2022 04:24:42 +0100 Subject: [PATCH 037/111] Added more event handlers to websocket --- packages/vm/wasmlib/ts/wasmclient/service.ts | 38 ++++++++++++-------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/packages/vm/wasmlib/ts/wasmclient/service.ts b/packages/vm/wasmlib/ts/wasmclient/service.ts index a66a576d82..7175b2665f 100644 --- a/packages/vm/wasmlib/ts/wasmclient/service.ts +++ b/packages/vm/wasmlib/ts/wasmclient/service.ts @@ -2,10 +2,10 @@ // SPDX-License-Identifier: Apache-2.0 import * as wasmclient from "./index"; -import {Hash, IKeyPair} from "./crypto"; -import {IOnLedger} from "./goshimmer/models/on_ledger"; -import {Colors} from "./colors"; -import {Buffer} from './buffer'; +import { Hash, IKeyPair } from "./crypto"; +import { IOnLedger } from "./goshimmer/models/on_ledger"; +import { Colors } from "./colors"; +import { Buffer } from "./buffer"; export interface IEventHandler { callHandler(topic: string, params: string[]): void; @@ -42,7 +42,7 @@ export class Service { onLedger: boolean ): Promise { const chainId = this.serviceClient.configuration.chainId; - if (! onLedger) { + if (!onLedger) { // requested off-ledger request const requestID = await this.serviceClient.waspClient.postOffLedgerRequest(chainId, this.scHname, hFuncName, args, transfer, keyPair); return requestID; @@ -62,9 +62,8 @@ export class Service { } public register(handler: IEventHandler): void { - if(this.eventHandlers.length === 0) - this.configureWebSocketsEventHandlers(); - + if (this.eventHandlers.length === 0) this.configureWebSocketsEventHandlers(); + for (let i = 0; i < this.eventHandlers.length; i++) { if (this.eventHandlers[i] === handler) { return; @@ -75,9 +74,8 @@ export class Service { public unregister(handler: IEventHandler): void { // remove handler - this.eventHandlers = this.eventHandlers.filter(h => h !== handler); - if(this.eventHandlers.length === 0) - this.webSocket?.close(); + this.eventHandlers = this.eventHandlers.filter((h) => h !== handler); + if (this.eventHandlers.length === 0) this.webSocket?.close(); } // overrides default contract name @@ -103,11 +101,23 @@ export class Service { } private connectWebSocket(): void { - // eslint-disable-next-line no-console - console.log(`Connecting to Websocket => ${this.waspWebSocketUrl}`); this.webSocket = new WebSocket(this.waspWebSocketUrl); + this.webSocket.addEventListener("open", () => this.handleOpenWebSocket()); + this.webSocket.addEventListener("close", () => this.handleCloseWebSocket()); + this.webSocket.addEventListener("error", (x) => this.handleErrorWebSocket(x)); this.webSocket.addEventListener("message", (x) => this.handleIncomingMessage(x)); - this.webSocket.addEventListener("close", () => setTimeout(this.connectWebSocket.bind(this), 1000)); + } + + private handleOpenWebSocket(): void { + console.log(`Connected to Websocket => ${this.waspWebSocketUrl}`); + } + + private handleCloseWebSocket(): void { + console.log(`Disconnected from Websocket => ${this.waspWebSocketUrl}`); + } + + private handleErrorWebSocket(event: Event): void { + console.error(`Web socket error => ${this.waspWebSocketUrl} => ${event}`); } private handleIncomingMessage(message: MessageEvent): void { From 64b4f032ba4c0a543b24a6b9dcefd6d6fa922a6c Mon Sep 17 00:00:00 2001 From: "Bruno A. dos Santos" Date: Sun, 23 Jan 2022 05:38:05 +0100 Subject: [PATCH 038/111] Corrected error message --- packages/vm/core/governance/governanceimpl/chaininfo.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/vm/core/governance/governanceimpl/chaininfo.go b/packages/vm/core/governance/governanceimpl/chaininfo.go index 8b2c8f3a64..aa8f81be36 100644 --- a/packages/vm/core/governance/governanceimpl/chaininfo.go +++ b/packages/vm/core/governance/governanceimpl/chaininfo.go @@ -40,7 +40,7 @@ func getChainInfo(ctx iscp.SandboxView) (dict.Dict, error) { // - ParamValidatorFee - int64 non-negative value of the contract fee. func setChainInfo(ctx iscp.Sandbox) (dict.Dict, error) { a := assert.NewAssert(ctx.Log()) - a.Require(governance.CheckAuthorizationByChainOwner(ctx.State(), ctx.Caller()), "governance.setContractFee: not authorized") + a.Require(governance.CheckAuthorizationByChainOwner(ctx.State(), ctx.Caller()), "governance.setChainInfo: not authorized") params := kvdecoder.New(ctx.Params(), ctx.Log()) From e756d6b0f24ee4b0adb080e858c5f757fb4db781 Mon Sep 17 00:00:00 2001 From: Eric Hop Date: Mon, 24 Jan 2022 17:52:05 -0800 Subject: [PATCH 039/111] Initial new Wasm VM --- contracts/wasm/dividend/go/dividend/consts.go | 16 +- .../wasm/dividend/go/dividend/contract.go | 13 +- .../wasm/dividend/go/dividend/dividend.go | 63 +- contracts/wasm/dividend/go/dividend/keys.go | 32 - contracts/wasm/dividend/go/dividend/lib.go | 52 +- contracts/wasm/dividend/go/dividend/params.go | 58 +- .../wasm/dividend/go/dividend/results.go | 26 +- contracts/wasm/dividend/go/dividend/state.go | 84 +- contracts/wasm/dividend/schema.yaml | 8 +- contracts/wasm/dividend/src/dividend.rs | 43 +- contracts/wasm/dividend/src/params.rs | 8 +- contracts/wasm/dividend/src/results.rs | 8 +- contracts/wasm/dividend/src/state.rs | 44 +- contracts/wasm/dividend/test/dividend_bg.wasm | Bin 32407 -> 32299 bytes contracts/wasm/dividend/test/dividend_test.go | 6 +- .../wasm/dividend/ts/dividend/dividend.ts | 49 +- contracts/wasm/dividend/ts/dividend/params.ts | 8 +- .../wasm/dividend/ts/dividend/results.ts | 8 +- contracts/wasm/dividend/ts/dividend/state.ts | 40 +- .../go/donatewithfeedback/consts.go | 12 +- .../go/donatewithfeedback/contract.go | 9 +- .../donatewithfeedback/donatewithfeedback.go | 15 +- .../go/donatewithfeedback/keys.go | 42 - .../go/donatewithfeedback/lib.go | 30 +- .../go/donatewithfeedback/params.go | 38 +- .../go/donatewithfeedback/results.go | 74 +- .../go/donatewithfeedback/state.go | 54 +- .../go/donatewithfeedback/structs.go | 63 +- contracts/wasm/donatewithfeedback/schema.yaml | 22 +- .../src/donatewithfeedback.rs | 4 +- .../wasm/donatewithfeedback/src/params.rs | 16 +- .../wasm/donatewithfeedback/src/results.rs | 40 +- .../wasm/donatewithfeedback/src/state.rs | 28 +- .../wasm/donatewithfeedback/src/structs.rs | 12 +- .../test/donatewithfeedback_bg.wasm | Bin 36882 -> 36806 bytes .../donatewithfeedback/donatewithfeedback.ts | 4 +- .../ts/donatewithfeedback/params.ts | 16 +- .../ts/donatewithfeedback/results.ts | 40 +- .../ts/donatewithfeedback/state.ts | 28 +- .../ts/donatewithfeedback/structs.ts | 12 +- contracts/wasm/erc20/go/erc20/consts.go | 18 +- contracts/wasm/erc20/go/erc20/contract.go | 18 +- contracts/wasm/erc20/go/erc20/erc20.go | 25 +- contracts/wasm/erc20/go/erc20/events.go | 13 +- contracts/wasm/erc20/go/erc20/keys.go | 36 - contracts/wasm/erc20/go/erc20/lib.go | 36 +- contracts/wasm/erc20/go/erc20/params.go | 122 +-- contracts/wasm/erc20/go/erc20/results.go | 38 +- contracts/wasm/erc20/go/erc20/state.go | 46 +- contracts/wasm/erc20/go/erc20/typedefs.go | 26 +- contracts/wasm/erc20/schema.yaml | 24 +- contracts/wasm/erc20/src/erc20.rs | 36 +- contracts/wasm/erc20/src/events.rs | 8 +- contracts/wasm/erc20/src/params.rs | 32 +- contracts/wasm/erc20/src/results.rs | 24 +- contracts/wasm/erc20/src/state.rs | 16 +- contracts/wasm/erc20/src/typedefs.rs | 20 +- contracts/wasm/erc20/test/erc20_bg.wasm | Bin 35584 -> 35689 bytes contracts/wasm/erc20/test/erc20_test.go | 6 +- contracts/wasm/erc20/ts/erc20/erc20.ts | 35 +- contracts/wasm/erc20/ts/erc20/events.ts | 8 +- contracts/wasm/erc20/ts/erc20/params.ts | 32 +- contracts/wasm/erc20/ts/erc20/results.ts | 24 +- contracts/wasm/erc20/ts/erc20/state.ts | 16 +- contracts/wasm/erc20/ts/erc20/typedefs.ts | 16 +- contracts/wasm/erc721/go/erc721/consts.go | 32 +- contracts/wasm/erc721/go/erc721/contract.go | 35 +- contracts/wasm/erc721/go/erc721/erc721.go | 13 +- contracts/wasm/erc721/go/erc721/events.go | 13 +- contracts/wasm/erc721/go/erc721/keys.go | 64 -- contracts/wasm/erc721/go/erc721/lib.go | 70 +- contracts/wasm/erc721/go/erc721/params.go | 226 +++--- contracts/wasm/erc721/go/erc721/results.go | 86 +- contracts/wasm/erc721/go/erc721/state.go | 110 ++- contracts/wasm/erc721/go/erc721/typedefs.go | 16 +- .../wasm/erc721/go/erc721client/events.go | 146 ++++ .../wasm/erc721/go/erc721client/service.go | 446 ++++++++++ contracts/wasm/erc721/test/erc721_test.go | 20 +- .../wasm/erc721/ts/erc721client/events.ts | 116 +++ .../wasm/erc721/ts/erc721client/index.ts | 9 + .../wasm/erc721/ts/erc721client/service.ts | 426 ++++++++++ .../wasm/erc721/ts/erc721client/tsconfig.json | 11 + .../wasm/fairauction/go/fairauction/consts.go | 14 +- .../fairauction/go/fairauction/contract.go | 11 +- .../fairauction/go/fairauction/fairauction.go | 33 +- .../wasm/fairauction/go/fairauction/keys.go | 56 -- .../wasm/fairauction/go/fairauction/lib.go | 42 +- .../wasm/fairauction/go/fairauction/params.go | 86 +- .../fairauction/go/fairauction/results.go | 102 +-- .../wasm/fairauction/go/fairauction/state.go | 78 +- .../fairauction/go/fairauction/structs.go | 149 ++-- .../fairauction/go/fairauction/typedefs.go | 42 +- contracts/wasm/fairauction/schema.yaml | 44 +- contracts/wasm/fairauction/src/fairauction.rs | 18 +- contracts/wasm/fairauction/src/params.rs | 24 +- contracts/wasm/fairauction/src/results.rs | 64 +- contracts/wasm/fairauction/src/state.rs | 8 +- contracts/wasm/fairauction/src/structs.rs | 60 +- contracts/wasm/fairauction/src/typedefs.rs | 12 +- .../wasm/fairauction/test/fairauction_bg.wasm | Bin 43245 -> 43080 bytes .../wasm/fairauction/test/fairauction_test.go | 8 +- .../fairauction/ts/fairauction/fairauction.ts | 18 +- .../wasm/fairauction/ts/fairauction/params.ts | 24 +- .../fairauction/ts/fairauction/results.ts | 64 +- .../wasm/fairauction/ts/fairauction/state.ts | 8 +- .../fairauction/ts/fairauction/structs.ts | 60 +- .../fairauction/ts/fairauction/typedefs.ts | 12 +- .../fairroulette/go/fairroulette/consts.go | 22 +- .../fairroulette/go/fairroulette/contract.go | 12 +- .../fairroulette/go/fairroulette/events.go | 24 +- .../go/fairroulette/fairroulette.go | 27 +- .../wasm/fairroulette/go/fairroulette/keys.go | 38 - .../wasm/fairroulette/go/fairroulette/lib.go | 66 +- .../fairroulette/go/fairroulette/params.go | 26 +- .../fairroulette/go/fairroulette/results.go | 50 +- .../fairroulette/go/fairroulette/state.go | 78 +- .../fairroulette/go/fairroulette/structs.go | 51 +- contracts/wasm/fairroulette/schema.yaml | 36 +- contracts/wasm/fairroulette/src/events.rs | 18 +- .../wasm/fairroulette/src/fairroulette.rs | 34 +- contracts/wasm/fairroulette/src/params.rs | 16 +- contracts/wasm/fairroulette/src/results.rs | 32 +- contracts/wasm/fairroulette/src/state.rs | 52 +- contracts/wasm/fairroulette/src/structs.rs | 12 +- .../fairroulette/test/fairroulette_bg.wasm | Bin 40291 -> 41098 bytes .../fairroulette/ts/fairroulette/events.ts | 18 +- .../ts/fairroulette/fairroulette.ts | 42 +- .../fairroulette/ts/fairroulette/params.ts | 16 +- .../fairroulette/ts/fairroulette/results.ts | 32 +- .../fairroulette/ts/fairroulette/state.ts | 52 +- .../fairroulette/ts/fairroulette/structs.ts | 12 +- .../wasm/helloworld/go/helloworld/consts.go | 8 +- .../wasm/helloworld/go/helloworld/contract.go | 2 +- .../wasm/helloworld/go/helloworld/keys.go | 14 - .../wasm/helloworld/go/helloworld/lib.go | 10 +- .../wasm/helloworld/go/helloworld/results.go | 14 +- .../wasm/helloworld/go/helloworld/state.go | 6 +- .../wasm/inccounter/go/inccounter/consts.go | 38 +- .../wasm/inccounter/go/inccounter/contract.go | 18 +- .../inccounter/go/inccounter/inccounter.go | 50 +- .../wasm/inccounter/go/inccounter/keys.go | 44 - .../wasm/inccounter/go/inccounter/lib.go | 56 +- .../wasm/inccounter/go/inccounter/params.go | 74 +- .../wasm/inccounter/go/inccounter/results.go | 86 +- .../wasm/inccounter/go/inccounter/state.go | 22 +- contracts/wasm/inccounter/schema.yaml | 2 +- contracts/wasm/inccounter/src/params.rs | 8 +- .../wasm/inccounter/test/inccounter_bg.wasm | Bin 42133 -> 42137 bytes .../wasm/inccounter/ts/inccounter/params.ts | 8 +- contracts/wasm/testcore/go/testcore/consts.go | 68 +- .../wasm/testcore/go/testcore/contract.go | 47 +- contracts/wasm/testcore/go/testcore/keys.go | 84 -- contracts/wasm/testcore/go/testcore/lib.go | 122 ++- contracts/wasm/testcore/go/testcore/params.go | 422 +++++----- .../wasm/testcore/go/testcore/results.go | 154 ++-- contracts/wasm/testcore/go/testcore/state.go | 44 +- .../wasm/testcore/go/testcore/testcore.go | 25 +- contracts/wasm/testcore/schema.yaml | 4 +- contracts/wasm/testcore/src/results.rs | 8 +- contracts/wasm/testcore/src/state.rs | 8 +- contracts/wasm/testcore/test/testcore_bg.wasm | Bin 53815 -> 53958 bytes contracts/wasm/testcore/test/testcore_test.go | 2 +- contracts/wasm/testcore/test/types_test.go | 10 +- .../wasm/testcore/ts/testcore/results.ts | 8 +- contracts/wasm/testcore/ts/testcore/state.ts | 8 +- .../wasm/testwasmlib/go/testwasmlib/consts.go | 38 +- .../testwasmlib/go/testwasmlib/contract.go | 60 +- .../wasm/testwasmlib/go/testwasmlib/events.go | 7 +- .../wasm/testwasmlib/go/testwasmlib/keys.go | 82 -- .../wasm/testwasmlib/go/testwasmlib/lib.go | 129 ++- .../wasm/testwasmlib/go/testwasmlib/params.go | 398 +++++---- .../testwasmlib/go/testwasmlib/results.go | 86 +- .../wasm/testwasmlib/go/testwasmlib/state.go | 50 +- .../testwasmlib/go/testwasmlib/structs.go | 250 +++++- .../testwasmlib/go/testwasmlib/testwasmlib.go | 124 ++- .../testwasmlib/go/testwasmlib/typedefs.go | 42 +- .../go/testwasmlibclient/service.go | 89 +- contracts/wasm/testwasmlib/schema.yaml | 29 +- contracts/wasm/testwasmlib/src/consts.rs | 6 +- contracts/wasm/testwasmlib/src/contract.rs | 38 +- contracts/wasm/testwasmlib/src/lib.rs | 58 +- contracts/wasm/testwasmlib/src/params.rs | 86 +- contracts/wasm/testwasmlib/src/results.rs | 32 +- contracts/wasm/testwasmlib/src/state.rs | 8 +- contracts/wasm/testwasmlib/src/structs.rs | 254 +++++- contracts/wasm/testwasmlib/src/testwasmlib.rs | 42 +- contracts/wasm/testwasmlib/src/typedefs.rs | 12 +- .../wasm/testwasmlib/test/testwasmlib_bg.wasm | Bin 44764 -> 44634 bytes .../wasm/testwasmlib/test/testwasmlib_test.go | 29 +- .../wasm/testwasmlib/ts/testwasmlib/consts.ts | 6 +- .../testwasmlib/ts/testwasmlib/contract.ts | 45 +- .../wasm/testwasmlib/ts/testwasmlib/lib.ts | 34 +- .../wasm/testwasmlib/ts/testwasmlib/params.ts | 68 +- .../testwasmlib/ts/testwasmlib/results.ts | 32 +- .../wasm/testwasmlib/ts/testwasmlib/state.ts | 8 +- .../testwasmlib/ts/testwasmlib/structs.ts | 251 +++++- .../testwasmlib/ts/testwasmlib/testwasmlib.ts | 42 +- .../testwasmlib/ts/testwasmlib/typedefs.ts | 12 +- .../ts/testwasmlibclient/events.ts | 10 +- .../testwasmlib/ts/testwasmlibclient/index.ts | 1 - .../ts/testwasmlibclient/service.ts | 80 +- .../wasm/timestamp/go/timestamp/consts.go | 8 +- .../wasm/timestamp/go/timestamp/contract.go | 2 +- contracts/wasm/timestamp/go/timestamp/keys.go | 17 - contracts/wasm/timestamp/go/timestamp/lib.go | 10 +- .../wasm/timestamp/go/timestamp/results.go | 14 +- .../wasm/timestamp/go/timestamp/state.go | 14 +- contracts/wasm/timestamp/schema.yaml | 4 +- contracts/wasm/timestamp/src/results.rs | 8 +- contracts/wasm/timestamp/src/state.rs | 8 +- .../wasm/timestamp/test/timestamp_bg.wasm | Bin 28192 -> 28186 bytes .../wasm/timestamp/ts/timestamp/results.ts | 8 +- .../wasm/timestamp/ts/timestamp/state.ts | 8 +- .../tokenregistry/go/tokenregistry/consts.go | 12 +- .../go/tokenregistry/contract.go | 8 +- .../tokenregistry/go/tokenregistry/keys.go | 23 - .../tokenregistry/go/tokenregistry/lib.go | 36 +- .../tokenregistry/go/tokenregistry/params.go | 58 +- .../tokenregistry/go/tokenregistry/state.go | 58 +- .../tokenregistry/go/tokenregistry/structs.go | 75 +- .../go/tokenregistry/tokenregistry.go | 6 +- contracts/wasm/tokenregistry/schema.yaml | 6 +- contracts/wasm/tokenregistry/src/state.rs | 12 +- contracts/wasm/tokenregistry/src/structs.rs | 18 +- .../tokenregistry/test/tokenregistry_bg.wasm | Bin 32223 -> 32035 bytes .../tokenregistry/ts/tokenregistry/state.ts | 12 +- .../tokenregistry/ts/tokenregistry/structs.ts | 18 +- .../test/example_tutorial_bg.wasm | Bin 16810 -> 16809 bytes packages/solo/solo.go | 4 +- .../sbtests/sbtestsc/testcore_bg.wasm | Bin 53815 -> 53958 bytes packages/vm/wasmhost/kvstorehost.go | 341 -------- .../vm/{wasmproc => wasmhost}/wasmcontext.go | 127 +-- packages/vm/wasmhost/wasmhost.go | 19 +- packages/vm/wasmhost/wasmkeys.go | 108 --- .../{wasmproc => wasmhost}/wasmprocessor.go | 25 +- packages/vm/wasmhost/wasmtosandbox.go | 291 +++++++ packages/vm/wasmhost/wasmtosandboxutils.go | 79 ++ packages/vm/wasmhost/wasmvm.go | 115 +-- .../go/wasmclient/coreblocklog/service.go | 40 +- .../go/wasmclient/wasmrequests/service.go | 8 + packages/vm/wasmlib/go/wasmlib/assets.go | 95 +++ packages/vm/wasmlib/go/wasmlib/bytes.go | 303 ------- packages/vm/wasmlib/go/wasmlib/context.go | 345 +------- packages/vm/wasmlib/go/wasmlib/contract.go | 157 ++-- .../wasmlib/go/wasmlib/coreaccounts/consts.go | 18 +- .../go/wasmlib/coreaccounts/contract.go | 14 +- .../wasmlib/go/wasmlib/coreaccounts/params.go | 58 +- .../go/wasmlib/coreaccounts/results.go | 72 +- .../vm/wasmlib/go/wasmlib/coreblob/consts.go | 12 +- .../wasmlib/go/wasmlib/coreblob/contract.go | 11 +- .../vm/wasmlib/go/wasmlib/coreblob/params.go | 58 +- .../vm/wasmlib/go/wasmlib/coreblob/results.go | 74 +- .../wasmlib/go/wasmlib/coreblocklog/consts.go | 24 +- .../go/wasmlib/coreblocklog/contract.go | 28 +- .../wasmlib/go/wasmlib/coreblocklog/params.go | 114 +-- .../go/wasmlib/coreblocklog/results.go | 204 +++-- .../go/wasmlib/coregovernance/consts.go | 28 +- .../go/wasmlib/coregovernance/contract.go | 23 +- .../go/wasmlib/coregovernance/params.go | 170 ++-- .../go/wasmlib/coregovernance/results.go | 154 ++-- .../vm/wasmlib/go/wasmlib/coreroot/consts.go | 14 +- .../wasmlib/go/wasmlib/coreroot/contract.go | 11 +- .../vm/wasmlib/go/wasmlib/coreroot/params.go | 66 +- .../vm/wasmlib/go/wasmlib/coreroot/results.go | 46 +- packages/vm/wasmlib/go/wasmlib/dict.go | 95 +++ packages/vm/wasmlib/go/wasmlib/events.go | 22 +- packages/vm/wasmlib/go/wasmlib/exports.go | 22 +- packages/vm/wasmlib/go/wasmlib/hashtypes.go | 254 ------ packages/vm/wasmlib/go/wasmlib/host.go | 105 +-- packages/vm/wasmlib/go/wasmlib/immutable.go | 586 -------------- packages/vm/wasmlib/go/wasmlib/inithost.go | 68 +- packages/vm/wasmlib/go/wasmlib/keys.go | 70 -- packages/vm/wasmlib/go/wasmlib/mutable.go | 764 ------------------ packages/vm/wasmlib/go/wasmlib/proxy.go | 71 -- packages/vm/wasmlib/go/wasmlib/sandbox.go | 258 ++++-- .../vm/wasmlib/go/wasmlib/sandboxtypes.go | 223 ----- .../vm/wasmlib/go/wasmlib/sandboxutils.go | 63 +- packages/vm/wasmlib/go/wasmlib/state.go | 40 + .../vm/wasmlib/go/wasmlib/wasmcodec/buffer.go | 99 +++ .../vm/wasmlib/go/wasmlib/wasmcodec/codec.go | 183 +++++ .../wasmlib/go/wasmlib/wasmrequests/consts.go | 16 + .../go/wasmlib/wasmrequests/contract.go | 8 + .../go/wasmlib/wasmrequests/structs.go | 249 ++++++ .../wasmlib/go/wasmlib/wasmtypes/address.go | 91 +++ .../wasmlib/go/wasmlib/wasmtypes/agentid.go | 107 +++ .../vm/wasmlib/go/wasmlib/wasmtypes/bool.go | 83 ++ .../vm/wasmlib/go/wasmlib/wasmtypes/bytes.go | 62 ++ .../wasmlib/go/wasmlib/wasmtypes/chainid.go | 90 +++ .../vm/wasmlib/go/wasmlib/wasmtypes/color.go | 97 +++ .../vm/wasmlib/go/wasmlib/wasmtypes/hash.go | 87 ++ .../vm/wasmlib/go/wasmlib/wasmtypes/hname.go | 90 +++ .../vm/wasmlib/go/wasmlib/wasmtypes/int16.go | 79 ++ .../vm/wasmlib/go/wasmlib/wasmtypes/int32.go | 79 ++ .../vm/wasmlib/go/wasmlib/wasmtypes/int64.go | 78 ++ .../vm/wasmlib/go/wasmlib/wasmtypes/int8.go | 75 ++ .../vm/wasmlib/go/wasmlib/wasmtypes/proxy.go | 134 +++ .../wasmlib/go/wasmlib/wasmtypes/requestid.go | 87 ++ .../vm/wasmlib/go/wasmlib/wasmtypes/string.go | 70 ++ .../vm/wasmlib/go/wasmlib/wasmtypes/uint16.go | 79 ++ .../vm/wasmlib/go/wasmlib/wasmtypes/uint32.go | 79 ++ .../vm/wasmlib/go/wasmlib/wasmtypes/uint64.go | 78 ++ .../vm/wasmlib/go/wasmlib/wasmtypes/uint8.go | 75 ++ .../vm/wasmlib/go/wasmlib/wasmtypes/utils.go | 28 + .../vm/wasmlib/interfaces/coreblocklog.yaml | 20 +- .../vm/wasmlib/interfaces/wasmrequests.yaml | 32 + packages/vm/wasmlib/src/context.rs | 26 +- packages/vm/wasmlib/src/contract.rs | 8 +- .../vm/wasmlib/src/coreblocklog/params.rs | 48 +- .../vm/wasmlib/src/coreblocklog/results.rs | 56 +- .../vm/wasmlib/src/coregovernance/results.rs | 12 +- packages/vm/wasmlib/src/exports.rs | 6 +- packages/vm/wasmlib/src/host.rs | 4 +- packages/vm/wasmlib/src/immutable.rs | 18 +- packages/vm/wasmlib/src/mutable.rs | 12 +- .../vm/wasmlib/src/wasmrequests/consts.rs | 16 + .../vm/wasmlib/src/wasmrequests/contract.rs | 19 + packages/vm/wasmlib/src/wasmrequests/mod.rs | 18 + .../vm/wasmlib/src/wasmrequests/structs.rs | 288 +++++++ .../vm/wasmlib/ts/wasmclient/clientfunc.ts | 2 + .../ts/wasmclient/coreblocklog/service.ts | 40 +- .../ts/wasmclient/wasmrequests/service.ts | 19 + packages/vm/wasmlib/ts/wasmlib/context.ts | 22 +- packages/vm/wasmlib/ts/wasmlib/contract.ts | 6 +- .../wasmlib/ts/wasmlib/coreblocklog/params.ts | 48 +- .../ts/wasmlib/coreblocklog/results.ts | 56 +- .../ts/wasmlib/coregovernance/results.ts | 12 +- packages/vm/wasmlib/ts/wasmlib/host.ts | 4 +- packages/vm/wasmlib/ts/wasmlib/immutable.ts | 18 +- packages/vm/wasmlib/ts/wasmlib/mutable.ts | 12 +- .../wasmlib/ts/wasmlib/wasmrequests/consts.ts | 14 + .../ts/wasmlib/wasmrequests/contract.ts | 12 + .../wasmlib/ts/wasmlib/wasmrequests/index.ts | 9 + .../ts/wasmlib/wasmrequests/structs.ts | 292 +++++++ .../ts/wasmlib/wasmrequests/tsconfig.json | 4 + packages/vm/wasmproc/scbalances.go | 54 -- packages/vm/wasmproc/sccontext.go | 285 ------- packages/vm/wasmproc/scdict.go | 330 -------- packages/vm/wasmproc/scexports.go | 17 - packages/vm/wasmproc/scmaps.go | 27 - packages/vm/wasmproc/scsandbox.go | 30 - packages/vm/wasmproc/sctransfer.go | 87 -- packages/vm/wasmproc/scutility.go | 121 --- packages/vm/wasmproc/scviewstate.go | 76 -- packages/vm/wasmproc/wasmtosandbox.go | 313 ------- packages/vm/wasmproc/wasmtosandboxutils.go | 78 -- packages/vm/wasmsolo/soloagent.go | 16 +- packages/vm/wasmsolo/solocontext.go | 41 +- packages/vm/wasmsolo/soloconvertor.go | 30 +- packages/vm/wasmsolo/solosandbox.go | 274 +++++++ packages/vm/wasmsolo/solosandboxutils.go | 79 ++ packages/vm/wasmsolo/solosccontext.go | 235 ------ packages/vm/wasmvmhost/host.go | 105 +-- plugins/wasmtimevm/plugin.go | 4 +- tools/cluster/tests/wasm/inccounter_bg.wasm | Bin 42133 -> 42137 bytes tools/schema/generator/emitter.go | 16 +- .../generator/goclienttemplates/service.go | 8 +- .../generator/gotemplates/alltemplates.go | 101 +-- tools/schema/generator/gotemplates/consts.go | 28 +- .../schema/generator/gotemplates/contract.go | 46 +- tools/schema/generator/gotemplates/events.go | 1 + tools/schema/generator/gotemplates/keys.go | 34 +- tools/schema/generator/gotemplates/lib.go | 16 +- tools/schema/generator/gotemplates/params.go | 6 +- tools/schema/generator/gotemplates/proxy.go | 32 +- tools/schema/generator/gotemplates/results.go | 6 +- tools/schema/generator/gotemplates/state.go | 5 +- tools/schema/generator/gotemplates/structs.go | 30 +- .../schema/generator/gotemplates/typedefs.go | 71 +- .../schema/generator/rstemplates/typedefs.go | 14 +- tools/schema/generator/templates.go | 2 - .../schema/generator/tstemplates/typedefs.go | 14 +- tools/schema/generator/utils.go | 6 + tools/schema/model/field.go | 47 +- 373 files changed, 10915 insertions(+), 10920 deletions(-) create mode 100644 contracts/wasm/erc721/go/erc721client/events.go create mode 100644 contracts/wasm/erc721/go/erc721client/service.go create mode 100644 contracts/wasm/erc721/ts/erc721client/events.ts create mode 100644 contracts/wasm/erc721/ts/erc721client/index.ts create mode 100644 contracts/wasm/erc721/ts/erc721client/service.ts create mode 100644 contracts/wasm/erc721/ts/erc721client/tsconfig.json delete mode 100644 packages/vm/wasmhost/kvstorehost.go rename packages/vm/{wasmproc => wasmhost}/wasmcontext.go (50%) delete mode 100644 packages/vm/wasmhost/wasmkeys.go rename packages/vm/{wasmproc => wasmhost}/wasmprocessor.go (83%) create mode 100644 packages/vm/wasmhost/wasmtosandbox.go create mode 100644 packages/vm/wasmhost/wasmtosandboxutils.go create mode 100644 packages/vm/wasmlib/go/wasmclient/wasmrequests/service.go create mode 100644 packages/vm/wasmlib/go/wasmlib/assets.go delete mode 100644 packages/vm/wasmlib/go/wasmlib/bytes.go create mode 100644 packages/vm/wasmlib/go/wasmlib/dict.go delete mode 100644 packages/vm/wasmlib/go/wasmlib/hashtypes.go delete mode 100644 packages/vm/wasmlib/go/wasmlib/immutable.go delete mode 100644 packages/vm/wasmlib/go/wasmlib/keys.go delete mode 100644 packages/vm/wasmlib/go/wasmlib/mutable.go delete mode 100644 packages/vm/wasmlib/go/wasmlib/proxy.go delete mode 100644 packages/vm/wasmlib/go/wasmlib/sandboxtypes.go create mode 100644 packages/vm/wasmlib/go/wasmlib/state.go create mode 100644 packages/vm/wasmlib/go/wasmlib/wasmcodec/buffer.go create mode 100644 packages/vm/wasmlib/go/wasmlib/wasmcodec/codec.go create mode 100644 packages/vm/wasmlib/go/wasmlib/wasmrequests/consts.go create mode 100644 packages/vm/wasmlib/go/wasmlib/wasmrequests/contract.go create mode 100644 packages/vm/wasmlib/go/wasmlib/wasmrequests/structs.go create mode 100644 packages/vm/wasmlib/go/wasmlib/wasmtypes/address.go create mode 100644 packages/vm/wasmlib/go/wasmlib/wasmtypes/agentid.go create mode 100644 packages/vm/wasmlib/go/wasmlib/wasmtypes/bool.go create mode 100644 packages/vm/wasmlib/go/wasmlib/wasmtypes/bytes.go create mode 100644 packages/vm/wasmlib/go/wasmlib/wasmtypes/chainid.go create mode 100644 packages/vm/wasmlib/go/wasmlib/wasmtypes/color.go create mode 100644 packages/vm/wasmlib/go/wasmlib/wasmtypes/hash.go create mode 100644 packages/vm/wasmlib/go/wasmlib/wasmtypes/hname.go create mode 100644 packages/vm/wasmlib/go/wasmlib/wasmtypes/int16.go create mode 100644 packages/vm/wasmlib/go/wasmlib/wasmtypes/int32.go create mode 100644 packages/vm/wasmlib/go/wasmlib/wasmtypes/int64.go create mode 100644 packages/vm/wasmlib/go/wasmlib/wasmtypes/int8.go create mode 100644 packages/vm/wasmlib/go/wasmlib/wasmtypes/proxy.go create mode 100644 packages/vm/wasmlib/go/wasmlib/wasmtypes/requestid.go create mode 100644 packages/vm/wasmlib/go/wasmlib/wasmtypes/string.go create mode 100644 packages/vm/wasmlib/go/wasmlib/wasmtypes/uint16.go create mode 100644 packages/vm/wasmlib/go/wasmlib/wasmtypes/uint32.go create mode 100644 packages/vm/wasmlib/go/wasmlib/wasmtypes/uint64.go create mode 100644 packages/vm/wasmlib/go/wasmlib/wasmtypes/uint8.go create mode 100644 packages/vm/wasmlib/go/wasmlib/wasmtypes/utils.go create mode 100644 packages/vm/wasmlib/interfaces/wasmrequests.yaml create mode 100644 packages/vm/wasmlib/src/wasmrequests/consts.rs create mode 100644 packages/vm/wasmlib/src/wasmrequests/contract.rs create mode 100644 packages/vm/wasmlib/src/wasmrequests/mod.rs create mode 100644 packages/vm/wasmlib/src/wasmrequests/structs.rs create mode 100644 packages/vm/wasmlib/ts/wasmclient/wasmrequests/service.ts create mode 100644 packages/vm/wasmlib/ts/wasmlib/wasmrequests/consts.ts create mode 100644 packages/vm/wasmlib/ts/wasmlib/wasmrequests/contract.ts create mode 100644 packages/vm/wasmlib/ts/wasmlib/wasmrequests/index.ts create mode 100644 packages/vm/wasmlib/ts/wasmlib/wasmrequests/structs.ts create mode 100644 packages/vm/wasmlib/ts/wasmlib/wasmrequests/tsconfig.json delete mode 100644 packages/vm/wasmproc/scbalances.go delete mode 100644 packages/vm/wasmproc/sccontext.go delete mode 100644 packages/vm/wasmproc/scdict.go delete mode 100644 packages/vm/wasmproc/scexports.go delete mode 100644 packages/vm/wasmproc/scmaps.go delete mode 100644 packages/vm/wasmproc/scsandbox.go delete mode 100644 packages/vm/wasmproc/sctransfer.go delete mode 100644 packages/vm/wasmproc/scutility.go delete mode 100644 packages/vm/wasmproc/scviewstate.go delete mode 100644 packages/vm/wasmproc/wasmtosandbox.go delete mode 100644 packages/vm/wasmproc/wasmtosandboxutils.go create mode 100644 packages/vm/wasmsolo/solosandbox.go create mode 100644 packages/vm/wasmsolo/solosandboxutils.go delete mode 100644 packages/vm/wasmsolo/solosccontext.go diff --git a/contracts/wasm/dividend/go/dividend/consts.go b/contracts/wasm/dividend/go/dividend/consts.go index 2e90e341e5..0e4eafd67f 100644 --- a/contracts/wasm/dividend/go/dividend/consts.go +++ b/contracts/wasm/dividend/go/dividend/consts.go @@ -7,12 +7,12 @@ package dividend -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" +import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" const ( ScName = "dividend" ScDescription = "Simple dividend smart contract" - HScName = wasmlib.ScHname(0xcce2e239) + HScName = wasmtypes.ScHname(0xcce2e239) ) const ( @@ -43,10 +43,10 @@ const ( ) const ( - HFuncDivide = wasmlib.ScHname(0xc7878107) - HFuncInit = wasmlib.ScHname(0x1f44d644) - HFuncMember = wasmlib.ScHname(0xc07da2cb) - HFuncSetOwner = wasmlib.ScHname(0x2a15fe7b) - HViewGetFactor = wasmlib.ScHname(0x0ee668fe) - HViewGetOwner = wasmlib.ScHname(0x137107a6) + HFuncDivide = wasmtypes.ScHname(0xc7878107) + HFuncInit = wasmtypes.ScHname(0x1f44d644) + HFuncMember = wasmtypes.ScHname(0xc07da2cb) + HFuncSetOwner = wasmtypes.ScHname(0x2a15fe7b) + HViewGetFactor = wasmtypes.ScHname(0x0ee668fe) + HViewGetOwner = wasmtypes.ScHname(0x137107a6) ) diff --git a/contracts/wasm/dividend/go/dividend/contract.go b/contracts/wasm/dividend/go/dividend/contract.go index 603f113e47..3d15ba00c4 100644 --- a/contracts/wasm/dividend/go/dividend/contract.go +++ b/contracts/wasm/dividend/go/dividend/contract.go @@ -48,31 +48,32 @@ func (sc Funcs) Divide(ctx wasmlib.ScFuncCallContext) *DivideCall { } func (sc Funcs) Init(ctx wasmlib.ScFuncCallContext) *InitCall { - f := &InitCall{Func: wasmlib.NewScInitFunc(ctx, HScName, HFuncInit, keyMap[:], idxMap[:])} - f.Func.SetPtrs(&f.Params.id, nil) + f := &InitCall{Func: wasmlib.NewScInitFunc(ctx, HScName, HFuncInit)} + f.Params.proxy = wasmlib.NewCallParamsProxy(&f.Func.ScView) return f } func (sc Funcs) Member(ctx wasmlib.ScFuncCallContext) *MemberCall { f := &MemberCall{Func: wasmlib.NewScFunc(ctx, HScName, HFuncMember)} - f.Func.SetPtrs(&f.Params.id, nil) + f.Params.proxy = wasmlib.NewCallParamsProxy(&f.Func.ScView) return f } func (sc Funcs) SetOwner(ctx wasmlib.ScFuncCallContext) *SetOwnerCall { f := &SetOwnerCall{Func: wasmlib.NewScFunc(ctx, HScName, HFuncSetOwner)} - f.Func.SetPtrs(&f.Params.id, nil) + f.Params.proxy = wasmlib.NewCallParamsProxy(&f.Func.ScView) return f } func (sc Funcs) GetFactor(ctx wasmlib.ScViewCallContext) *GetFactorCall { f := &GetFactorCall{Func: wasmlib.NewScView(ctx, HScName, HViewGetFactor)} - f.Func.SetPtrs(&f.Params.id, &f.Results.id) + f.Params.proxy = wasmlib.NewCallParamsProxy(f.Func) + wasmlib.NewCallResultsProxy(f.Func, &f.Results.proxy) return f } func (sc Funcs) GetOwner(ctx wasmlib.ScViewCallContext) *GetOwnerCall { f := &GetOwnerCall{Func: wasmlib.NewScView(ctx, HScName, HViewGetOwner)} - f.Func.SetPtrs(nil, &f.Results.id) + wasmlib.NewCallResultsProxy(f.Func, &f.Results.proxy) return f } diff --git a/contracts/wasm/dividend/go/dividend/dividend.go b/contracts/wasm/dividend/go/dividend/dividend.go index 7752295c0d..54ac3539c2 100644 --- a/contracts/wasm/dividend/go/dividend/dividend.go +++ b/contracts/wasm/dividend/go/dividend/dividend.go @@ -16,6 +16,7 @@ package dividend import ( "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" + "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" ) // 'init' is used as a way to initialize a smart contract. It is an optional @@ -31,7 +32,7 @@ func funcInit(ctx wasmlib.ScFuncContext, f *InitContext) { // First we set up a default value for the owner in case the optional // 'owner' parameter was omitted. - var owner wasmlib.ScAgentID = ctx.ContractCreator() + var owner wasmtypes.ScAgentID = ctx.ContractCreator() // Now we check if the optional 'owner' parameter is present in the params map. if f.Params.Owner().Exists() { @@ -64,33 +65,24 @@ func funcMember(ctx wasmlib.ScFuncContext, f *MemberContext) { // So once we get to this point in the code we can take that as a given. // Since we are sure that the 'factor' parameter actually exists we can - // retrieve its actual value into an int64. Note that we use Go's built-in + // retrieve its actual value into an uint64. Note that we use Go's built-in // data types when manipulating Int64, String, or Bytes value objects. - var factor int64 = f.Params.Factor().Value() - - // As an extra requirement we check that the 'factor' parameter value is not - // negative. If it is, we panic out with an error message. - // Note how we avoid an if expression like this one here: - // if factor < 0 { - // ctx.Panic("negative factor") - // } - // Using the require() method instead reduces typing and enhances readability. - ctx.Require(factor >= 0, "negative factor") + var factor uint64 = f.Params.Factor().Value() // Since we are sure that the 'address' parameter actually exists we can // retrieve its actual value into an ScAddress value type. - var address wasmlib.ScAddress = f.Params.Address().Value() + var address wasmtypes.ScAddress = f.Params.Address().Value() // We will store the address/factor combinations in a key/value sub-map of the // state storage named 'members'. The schema tool has generated an appropriately // type-checked proxy map for us from the schema.json state storage definition. // If there is no 'members' map present yet in state storage an empty map will // automatically be created on the host. - var members MapAddressToMutableInt64 = f.State.Members() + var members MapAddressToMutableUint64 = f.State.Members() - // Now we create an ScMutableInt64 proxy for the value stored in the 'members' + // Now we create an ScMutableUint64 proxy for the value stored in the 'members' // map under the key defined by the 'address' parameter we retrieved earlier. - var currentFactor wasmlib.ScMutableInt64 = members.GetInt64(address) + var currentFactor wasmtypes.ScMutableUint64 = members.GetUint64(address) // We check to see if this key/value combination exists in the 'members' map. if !currentFactor.Exists() { @@ -102,12 +94,9 @@ func funcMember(ctx wasmlib.ScFuncContext, f *MemberContext) { var memberList ArrayOfMutableAddress = f.State.MemberList() // Now we will append the new address to the memberList array. - // First we determine the current length of the array. - var length int32 = memberList.Length() - - // Next we create an ScMutableAddress proxy to the address value that lives - // at that index in the memberList array (no value, since we're appending). - var newAddress wasmlib.ScMutableAddress = memberList.GetAddress(length) + // We create an ScMutableAddress proxy to an address value that lives + // at the end of the memberList array (no value yet, since we're appending). + var newAddress wasmtypes.ScMutableAddress = memberList.AppendAddress() // And finally we append the new address to the array by telling the proxy // to update the value it refers to with the 'address' parameter. @@ -117,10 +106,10 @@ func funcMember(ctx wasmlib.ScFuncContext, f *MemberContext) { // memberList.GetAddress(memberList.Length()).SetValue(&address) } - // Create an ScMutableInt64 proxy named 'totalFactor' for an Int64 value in + // Create an ScMutableUint64 proxy named 'totalFactor' for an Uint64 value in // state storage. Note that we don't care whether this value exists or not, // because WasmLib will treat it as if it has the default value of zero. - var totalFactor wasmlib.ScMutableInt64 = f.State.TotalFactor() + var totalFactor wasmtypes.ScMutableUint64 = f.State.TotalFactor() // Now we calculate the new running total sum of factors by first getting the // current value of 'totalFactor' from the state storage, then subtracting the @@ -128,7 +117,7 @@ func funcMember(ctx wasmlib.ScFuncContext, f *MemberContext) { // exists. Again, if the associated value doesn't exist, WasmLib will assume it // to be zero. Finally we add the factor retrieved from the parameters, // resulting in the new totalFactor. - var newTotalFactor int64 = totalFactor.Value() - currentFactor.Value() + factor + var newTotalFactor uint64 = totalFactor.Value() - currentFactor.Value() + factor // Now we store the new totalFactor in the state storage. totalFactor.SetValue(newTotalFactor) @@ -154,31 +143,31 @@ func funcDivide(ctx wasmlib.ScFuncContext, f *DivideContext) { var balances wasmlib.ScBalances = ctx.Balances() // Retrieve the amount of plain iota tokens from the account balance - var amount int64 = balances.Balance(wasmlib.IOTA) + var amount uint64 = balances.Balance(wasmtypes.IOTA) // Retrieve the pre-calculated totalFactor value from the state storage. - var totalFactor int64 = f.State.TotalFactor().Value() + var totalFactor uint64 = f.State.TotalFactor().Value() // Get the proxy to the 'members' map in the state storage. - var members MapAddressToMutableInt64 = f.State.Members() + var members MapAddressToMutableUint64 = f.State.Members() // Get the proxy to the 'memberList' array in the state storage. var memberList ArrayOfMutableAddress = f.State.MemberList() // Determine the current length of the memberList array. - var size int32 = memberList.Length() + var size uint32 = memberList.Length() // Loop through all indexes of the memberList array. - for i := int32(0); i < size; i++ { + for i := uint32(0); i < size; i++ { // Retrieve the next indexed address from the memberList array. - var address wasmlib.ScAddress = memberList.GetAddress(i).Value() + var address wasmtypes.ScAddress = memberList.GetAddress(i).Value() // Retrieve the factor associated with the address from the members map. - var factor int64 = members.GetInt64(address).Value() + var factor uint64 = members.GetUint64(address).Value() // Calculate the fair share of iotas to disperse to this member based on the // factor we just retrieved. Note that the result will been truncated. - var share int64 = amount * factor / totalFactor + var share uint64 = amount * factor / totalFactor // Is there anything to disperse to this member? if share > 0 { @@ -194,7 +183,7 @@ func funcDivide(ctx wasmlib.ScFuncContext, f *DivideContext) { // member address. The transfer_to_address() method receives the address // value and the proxy to the new transfers map on the host, and will // call the corresponding host sandbox function with these values. - ctx.TransferToAddress(address, transfers) + ctx.Send(address, transfers) } } } @@ -218,15 +207,15 @@ func funcSetOwner(ctx wasmlib.ScFuncContext, f *SetOwnerContext) { func viewGetFactor(ctx wasmlib.ScViewContext, f *GetFactorContext) { // Since we are sure that the 'address' parameter actually exists we can // retrieve its actual value into an ScAddress value type. - var address wasmlib.ScAddress = f.Params.Address().Value() + var address wasmtypes.ScAddress = f.Params.Address().Value() // Create an ScImmutableMap proxy to the 'members' map in the state storage. // Note that for views this is an *immutable* map as opposed to the *mutable* // map we can access from the *mutable* state that gets passed to funcs. - var members MapAddressToImmutableInt64 = f.State.Members() + var members MapAddressToImmutableUint64 = f.State.Members() // Retrieve the factor associated with the address parameter. - var factor int64 = members.GetInt64(address).Value() + var factor uint64 = members.GetUint64(address).Value() // Set the factor in the results map of the function context. // The contents of this results map is returned to the caller of the function. diff --git a/contracts/wasm/dividend/go/dividend/keys.go b/contracts/wasm/dividend/go/dividend/keys.go index d195ce5296..708a8a2be6 100644 --- a/contracts/wasm/dividend/go/dividend/keys.go +++ b/contracts/wasm/dividend/go/dividend/keys.go @@ -6,35 +6,3 @@ // Change the json schema instead package dividend - -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" - -const ( - IdxParamAddress = 0 - IdxParamFactor = 1 - IdxParamOwner = 2 - - IdxResultFactor = 3 - IdxResultOwner = 4 - - IdxStateMemberList = 5 - IdxStateMembers = 6 - IdxStateOwner = 7 - IdxStateTotalFactor = 8 -) - -const keyMapLen = 9 - -var keyMap = [keyMapLen]wasmlib.Key{ - ParamAddress, - ParamFactor, - ParamOwner, - ResultFactor, - ResultOwner, - StateMemberList, - StateMembers, - StateOwner, - StateTotalFactor, -} - -var idxMap [keyMapLen]wasmlib.Key32 diff --git a/contracts/wasm/dividend/go/dividend/lib.go b/contracts/wasm/dividend/go/dividend/lib.go index ea83c8abb5..470be11717 100644 --- a/contracts/wasm/dividend/go/dividend/lib.go +++ b/contracts/wasm/dividend/go/dividend/lib.go @@ -17,10 +17,6 @@ func OnLoad() { exports.AddFunc(FuncSetOwner, funcSetOwnerThunk) exports.AddView(ViewGetFactor, viewGetFactorThunk) exports.AddView(ViewGetOwner, viewGetOwnerThunk) - - for i, key := range keyMap { - idxMap[i] = key.KeyID() - } } type DivideContext struct { @@ -31,7 +27,7 @@ func funcDivideThunk(ctx wasmlib.ScFuncContext) { ctx.Log("dividend.funcDivide") f := &DivideContext{ State: MutableDividendState{ - id: wasmlib.OBJ_ID_STATE, + proxy: wasmlib.NewStateProxy(), }, } funcDivide(ctx, f) @@ -47,10 +43,10 @@ func funcInitThunk(ctx wasmlib.ScFuncContext) { ctx.Log("dividend.funcInit") f := &InitContext{ Params: ImmutableInitParams{ - id: wasmlib.OBJ_ID_PARAMS, + proxy: wasmlib.NewParamsProxy(), }, State: MutableDividendState{ - id: wasmlib.OBJ_ID_STATE, + proxy: wasmlib.NewStateProxy(), }, } funcInit(ctx, f) @@ -64,20 +60,20 @@ type MemberContext struct { func funcMemberThunk(ctx wasmlib.ScFuncContext) { ctx.Log("dividend.funcMember") - - // only defined owner of contract can add members - access := ctx.State().GetAgentID(wasmlib.Key("owner")) - ctx.Require(access.Exists(), "access not set: owner") - ctx.Require(ctx.Caller() == access.Value(), "no permission") - f := &MemberContext{ Params: ImmutableMemberParams{ - id: wasmlib.OBJ_ID_PARAMS, + proxy: wasmlib.NewParamsProxy(), }, State: MutableDividendState{ - id: wasmlib.OBJ_ID_STATE, + proxy: wasmlib.NewStateProxy(), }, } + + // only defined owner of contract can add members + access := f.State.Owner() + ctx.Require(access.Exists(), "access not set: owner") + ctx.Require(ctx.Caller() == access.Value(), "no permission") + ctx.Require(f.Params.Address().Exists(), "missing mandatory address") ctx.Require(f.Params.Factor().Exists(), "missing mandatory factor") funcMember(ctx, f) @@ -91,20 +87,20 @@ type SetOwnerContext struct { func funcSetOwnerThunk(ctx wasmlib.ScFuncContext) { ctx.Log("dividend.funcSetOwner") - - // only defined owner of contract can change owner - access := ctx.State().GetAgentID(wasmlib.Key("owner")) - ctx.Require(access.Exists(), "access not set: owner") - ctx.Require(ctx.Caller() == access.Value(), "no permission") - f := &SetOwnerContext{ Params: ImmutableSetOwnerParams{ - id: wasmlib.OBJ_ID_PARAMS, + proxy: wasmlib.NewParamsProxy(), }, State: MutableDividendState{ - id: wasmlib.OBJ_ID_STATE, + proxy: wasmlib.NewStateProxy(), }, } + + // only defined owner of contract can change owner + access := f.State.Owner() + ctx.Require(access.Exists(), "access not set: owner") + ctx.Require(ctx.Caller() == access.Value(), "no permission") + ctx.Require(f.Params.Owner().Exists(), "missing mandatory owner") funcSetOwner(ctx, f) ctx.Log("dividend.funcSetOwner ok") @@ -120,13 +116,13 @@ func viewGetFactorThunk(ctx wasmlib.ScViewContext) { ctx.Log("dividend.viewGetFactor") f := &GetFactorContext{ Params: ImmutableGetFactorParams{ - id: wasmlib.OBJ_ID_PARAMS, + proxy: wasmlib.NewParamsProxy(), }, Results: MutableGetFactorResults{ - id: wasmlib.OBJ_ID_RESULTS, + proxy: wasmlib.NewResultsProxy(), }, State: ImmutableDividendState{ - id: wasmlib.OBJ_ID_STATE, + proxy: wasmlib.NewStateProxy(), }, } ctx.Require(f.Params.Address().Exists(), "missing mandatory address") @@ -143,10 +139,10 @@ func viewGetOwnerThunk(ctx wasmlib.ScViewContext) { ctx.Log("dividend.viewGetOwner") f := &GetOwnerContext{ Results: MutableGetOwnerResults{ - id: wasmlib.OBJ_ID_RESULTS, + proxy: wasmlib.NewResultsProxy(), }, State: ImmutableDividendState{ - id: wasmlib.OBJ_ID_STATE, + proxy: wasmlib.NewStateProxy(), }, } viewGetOwner(ctx, f) diff --git a/contracts/wasm/dividend/go/dividend/params.go b/contracts/wasm/dividend/go/dividend/params.go index 55d5460569..92dd61d3af 100644 --- a/contracts/wasm/dividend/go/dividend/params.go +++ b/contracts/wasm/dividend/go/dividend/params.go @@ -7,76 +7,76 @@ package dividend -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" +import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" type ImmutableInitParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableInitParams) Owner() wasmlib.ScImmutableAgentID { - return wasmlib.NewScImmutableAgentID(s.id, idxMap[IdxParamOwner]) +func (s ImmutableInitParams) Owner() wasmtypes.ScImmutableAgentID { + return wasmtypes.NewScImmutableAgentID(s.proxy.Root(ParamOwner)) } type MutableInitParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableInitParams) Owner() wasmlib.ScMutableAgentID { - return wasmlib.NewScMutableAgentID(s.id, idxMap[IdxParamOwner]) +func (s MutableInitParams) Owner() wasmtypes.ScMutableAgentID { + return wasmtypes.NewScMutableAgentID(s.proxy.Root(ParamOwner)) } type ImmutableMemberParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableMemberParams) Address() wasmlib.ScImmutableAddress { - return wasmlib.NewScImmutableAddress(s.id, wasmlib.KeyID(ParamAddress)) +func (s ImmutableMemberParams) Address() wasmtypes.ScImmutableAddress { + return wasmtypes.NewScImmutableAddress(s.proxy.Root(ParamAddress)) } -func (s ImmutableMemberParams) Factor() wasmlib.ScImmutableInt64 { - return wasmlib.NewScImmutableInt64(s.id, wasmlib.KeyID(ParamFactor)) +func (s ImmutableMemberParams) Factor() wasmtypes.ScImmutableUint64 { + return wasmtypes.NewScImmutableUint64(s.proxy.Root(ParamFactor)) } type MutableMemberParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableMemberParams) Address() wasmlib.ScMutableAddress { - return wasmlib.NewScMutableAddress(s.id, wasmlib.KeyID(ParamAddress)) +func (s MutableMemberParams) Address() wasmtypes.ScMutableAddress { + return wasmtypes.NewScMutableAddress(s.proxy.Root(ParamAddress)) } -func (s MutableMemberParams) Factor() wasmlib.ScMutableInt64 { - return wasmlib.NewScMutableInt64(s.id, wasmlib.KeyID(ParamFactor)) +func (s MutableMemberParams) Factor() wasmtypes.ScMutableUint64 { + return wasmtypes.NewScMutableUint64(s.proxy.Root(ParamFactor)) } type ImmutableSetOwnerParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableSetOwnerParams) Owner() wasmlib.ScImmutableAgentID { - return wasmlib.NewScImmutableAgentID(s.id, wasmlib.KeyID(ParamOwner)) +func (s ImmutableSetOwnerParams) Owner() wasmtypes.ScImmutableAgentID { + return wasmtypes.NewScImmutableAgentID(s.proxy.Root(ParamOwner)) } type MutableSetOwnerParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableSetOwnerParams) Owner() wasmlib.ScMutableAgentID { - return wasmlib.NewScMutableAgentID(s.id, wasmlib.KeyID(ParamOwner)) +func (s MutableSetOwnerParams) Owner() wasmtypes.ScMutableAgentID { + return wasmtypes.NewScMutableAgentID(s.proxy.Root(ParamOwner)) } type ImmutableGetFactorParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableGetFactorParams) Address() wasmlib.ScImmutableAddress { - return wasmlib.NewScImmutableAddress(s.id, wasmlib.KeyID(ParamAddress)) +func (s ImmutableGetFactorParams) Address() wasmtypes.ScImmutableAddress { + return wasmtypes.NewScImmutableAddress(s.proxy.Root(ParamAddress)) } type MutableGetFactorParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableGetFactorParams) Address() wasmlib.ScMutableAddress { - return wasmlib.NewScMutableAddress(s.id, wasmlib.KeyID(ParamAddress)) +func (s MutableGetFactorParams) Address() wasmtypes.ScMutableAddress { + return wasmtypes.NewScMutableAddress(s.proxy.Root(ParamAddress)) } diff --git a/contracts/wasm/dividend/go/dividend/results.go b/contracts/wasm/dividend/go/dividend/results.go index 987b0fec57..e66bbf78d2 100644 --- a/contracts/wasm/dividend/go/dividend/results.go +++ b/contracts/wasm/dividend/go/dividend/results.go @@ -7,36 +7,36 @@ package dividend -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" +import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" type ImmutableGetFactorResults struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableGetFactorResults) Factor() wasmlib.ScImmutableInt64 { - return wasmlib.NewScImmutableInt64(s.id, wasmlib.KeyID(ResultFactor)) +func (s ImmutableGetFactorResults) Factor() wasmtypes.ScImmutableUint64 { + return wasmtypes.NewScImmutableUint64(s.proxy.Root(ResultFactor)) } type MutableGetFactorResults struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableGetFactorResults) Factor() wasmlib.ScMutableInt64 { - return wasmlib.NewScMutableInt64(s.id, wasmlib.KeyID(ResultFactor)) +func (s MutableGetFactorResults) Factor() wasmtypes.ScMutableUint64 { + return wasmtypes.NewScMutableUint64(s.proxy.Root(ResultFactor)) } type ImmutableGetOwnerResults struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableGetOwnerResults) Owner() wasmlib.ScImmutableAgentID { - return wasmlib.NewScImmutableAgentID(s.id, wasmlib.KeyID(ResultOwner)) +func (s ImmutableGetOwnerResults) Owner() wasmtypes.ScImmutableAgentID { + return wasmtypes.NewScImmutableAgentID(s.proxy.Root(ResultOwner)) } type MutableGetOwnerResults struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableGetOwnerResults) Owner() wasmlib.ScMutableAgentID { - return wasmlib.NewScMutableAgentID(s.id, wasmlib.KeyID(ResultOwner)) +func (s MutableGetOwnerResults) Owner() wasmtypes.ScMutableAgentID { + return wasmtypes.NewScMutableAgentID(s.proxy.Root(ResultOwner)) } diff --git a/contracts/wasm/dividend/go/dividend/state.go b/contracts/wasm/dividend/go/dividend/state.go index b63408d3a3..a136855912 100644 --- a/contracts/wasm/dividend/go/dividend/state.go +++ b/contracts/wasm/dividend/go/dividend/state.go @@ -7,80 +7,82 @@ package dividend -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" +import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" type ArrayOfImmutableAddress struct { - objID int32 + proxy wasmtypes.Proxy } -func (a ArrayOfImmutableAddress) Length() int32 { - return wasmlib.GetLength(a.objID) +func (a ArrayOfImmutableAddress) Length() uint32 { + return a.proxy.Length() } -func (a ArrayOfImmutableAddress) GetAddress(index int32) wasmlib.ScImmutableAddress { - return wasmlib.NewScImmutableAddress(a.objID, wasmlib.Key32(index)) +func (a ArrayOfImmutableAddress) GetAddress(index uint32) wasmtypes.ScImmutableAddress { + return wasmtypes.NewScImmutableAddress(a.proxy.Index(index)) } -type MapAddressToImmutableInt64 struct { - objID int32 +type MapAddressToImmutableUint64 struct { + proxy wasmtypes.Proxy } -func (m MapAddressToImmutableInt64) GetInt64(key wasmlib.ScAddress) wasmlib.ScImmutableInt64 { - return wasmlib.NewScImmutableInt64(m.objID, key.KeyID()) +func (m MapAddressToImmutableUint64) GetUint64(key wasmtypes.ScAddress) wasmtypes.ScImmutableUint64 { + return wasmtypes.NewScImmutableUint64(m.proxy.Key(key.Bytes())) } type ImmutableDividendState struct { - id int32 + proxy wasmtypes.Proxy } func (s ImmutableDividendState) MemberList() ArrayOfImmutableAddress { - arrID := wasmlib.GetObjectID(s.id, wasmlib.KeyID(StateMemberList), wasmlib.TYPE_ARRAY|wasmlib.TYPE_ADDRESS) - return ArrayOfImmutableAddress{objID: arrID} + return ArrayOfImmutableAddress{proxy: s.proxy.Root(StateMemberList)} } -func (s ImmutableDividendState) Members() MapAddressToImmutableInt64 { - mapID := wasmlib.GetObjectID(s.id, wasmlib.KeyID(StateMembers), wasmlib.TYPE_MAP) - return MapAddressToImmutableInt64{objID: mapID} +func (s ImmutableDividendState) Members() MapAddressToImmutableUint64 { + return MapAddressToImmutableUint64{proxy: s.proxy.Root(StateMembers)} } -func (s ImmutableDividendState) Owner() wasmlib.ScImmutableAgentID { - return wasmlib.NewScImmutableAgentID(s.id, wasmlib.KeyID(StateOwner)) +func (s ImmutableDividendState) Owner() wasmtypes.ScImmutableAgentID { + return wasmtypes.NewScImmutableAgentID(s.proxy.Root(StateOwner)) } -func (s ImmutableDividendState) TotalFactor() wasmlib.ScImmutableInt64 { - return wasmlib.NewScImmutableInt64(s.id, wasmlib.KeyID(StateTotalFactor)) +func (s ImmutableDividendState) TotalFactor() wasmtypes.ScImmutableUint64 { + return wasmtypes.NewScImmutableUint64(s.proxy.Root(StateTotalFactor)) } type ArrayOfMutableAddress struct { - objID int32 + proxy wasmtypes.Proxy +} + +func (a ArrayOfMutableAddress) AppendAddress() wasmtypes.ScMutableAddress { + return wasmtypes.NewScMutableAddress(a.proxy.Append()) } func (a ArrayOfMutableAddress) Clear() { - wasmlib.Clear(a.objID) + a.proxy.ClearArray() } -func (a ArrayOfMutableAddress) Length() int32 { - return wasmlib.GetLength(a.objID) +func (a ArrayOfMutableAddress) Length() uint32 { + return a.proxy.Length() } -func (a ArrayOfMutableAddress) GetAddress(index int32) wasmlib.ScMutableAddress { - return wasmlib.NewScMutableAddress(a.objID, wasmlib.Key32(index)) +func (a ArrayOfMutableAddress) GetAddress(index uint32) wasmtypes.ScMutableAddress { + return wasmtypes.NewScMutableAddress(a.proxy.Index(index)) } -type MapAddressToMutableInt64 struct { - objID int32 +type MapAddressToMutableUint64 struct { + proxy wasmtypes.Proxy } -func (m MapAddressToMutableInt64) Clear() { - wasmlib.Clear(m.objID) +func (m MapAddressToMutableUint64) Clear() { + m.proxy.ClearMap() } -func (m MapAddressToMutableInt64) GetInt64(key wasmlib.ScAddress) wasmlib.ScMutableInt64 { - return wasmlib.NewScMutableInt64(m.objID, key.KeyID()) +func (m MapAddressToMutableUint64) GetUint64(key wasmtypes.ScAddress) wasmtypes.ScMutableUint64 { + return wasmtypes.NewScMutableUint64(m.proxy.Key(key.Bytes())) } type MutableDividendState struct { - id int32 + proxy wasmtypes.Proxy } func (s MutableDividendState) AsImmutable() ImmutableDividendState { @@ -88,19 +90,17 @@ func (s MutableDividendState) AsImmutable() ImmutableDividendState { } func (s MutableDividendState) MemberList() ArrayOfMutableAddress { - arrID := wasmlib.GetObjectID(s.id, wasmlib.KeyID(StateMemberList), wasmlib.TYPE_ARRAY|wasmlib.TYPE_ADDRESS) - return ArrayOfMutableAddress{objID: arrID} + return ArrayOfMutableAddress{proxy: s.proxy.Root(StateMemberList)} } -func (s MutableDividendState) Members() MapAddressToMutableInt64 { - mapID := wasmlib.GetObjectID(s.id, wasmlib.KeyID(StateMembers), wasmlib.TYPE_MAP) - return MapAddressToMutableInt64{objID: mapID} +func (s MutableDividendState) Members() MapAddressToMutableUint64 { + return MapAddressToMutableUint64{proxy: s.proxy.Root(StateMembers)} } -func (s MutableDividendState) Owner() wasmlib.ScMutableAgentID { - return wasmlib.NewScMutableAgentID(s.id, wasmlib.KeyID(StateOwner)) +func (s MutableDividendState) Owner() wasmtypes.ScMutableAgentID { + return wasmtypes.NewScMutableAgentID(s.proxy.Root(StateOwner)) } -func (s MutableDividendState) TotalFactor() wasmlib.ScMutableInt64 { - return wasmlib.NewScMutableInt64(s.id, wasmlib.KeyID(StateTotalFactor)) +func (s MutableDividendState) TotalFactor() wasmtypes.ScMutableUint64 { + return wasmtypes.NewScMutableUint64(s.proxy.Root(StateTotalFactor)) } diff --git a/contracts/wasm/dividend/schema.yaml b/contracts/wasm/dividend/schema.yaml index 6b06220315..14e2f41a76 100644 --- a/contracts/wasm/dividend/schema.yaml +++ b/contracts/wasm/dividend/schema.yaml @@ -4,9 +4,9 @@ structs: {} typedefs: {} state: memberList: Address[] // array with all the recipients of this dividend - members: map[Address]Int64 // map with all the recipient factors of this dividend + members: map[Address]Uint64 // map with all the recipient factors of this dividend owner: AgentID // owner of contract, the only one who can call 'member' func - totalFactor: Int64 // sum of all recipient factors + totalFactor: Uint64 // sum of all recipient factors funcs: divide: {} init: @@ -16,7 +16,7 @@ funcs: access: owner // only defined owner of contract can add members params: address: Address // address of dividend recipient - factor: Int64 // relative division factor + factor: Uint64 // relative division factor setOwner: access: owner // only defined owner of contract can change owner params: @@ -26,7 +26,7 @@ views: params: address: Address // address of dividend recipient results: - factor: Int64 // relative division factor + factor: Uint64 // relative division factor getOwner: results: owner: AgentID // current owner of this smart contract diff --git a/contracts/wasm/dividend/src/dividend.rs b/contracts/wasm/dividend/src/dividend.rs index 929463cca4..8154f0334c 100644 --- a/contracts/wasm/dividend/src/dividend.rs +++ b/contracts/wasm/dividend/src/dividend.rs @@ -55,7 +55,7 @@ pub fn func_init(ctx: &ScFuncContext, f: &InitContext) { // The 'member' function will save the address/factor combination in state storage // and also calculate and store a running sum of all factors so that the 'divide' // function can simply start using these precalculated values when called. -pub fn func_member(ctx: &ScFuncContext, f: &MemberContext) { +pub fn func_member(_ctx: &ScFuncContext, f: &MemberContext) { // Note that the schema tool has already dealt with making sure that this function // can only be called by the owner and that the required parameters are present. // So once we get to this point in the code we can take that as a given. @@ -63,16 +63,7 @@ pub fn func_member(ctx: &ScFuncContext, f: &MemberContext) { // Since we are sure that the 'factor' parameter actually exists we can // retrieve its actual value into an i64. Note that we use Rust's built-in // data types when manipulating Int64, String, or Bytes value objects. - let factor: i64 = f.params.factor().value(); - - // As an extra requirement we check that the 'factor' parameter value is not - // negative. If it is, we panic out with an error message. - // Note how we avoid an if expression like this one here: - // if factor < 0 { - // ctx.panic("negative factor"); - // } - // Using the require() method instead reduces typing and enhances readability. - ctx.require(factor >= 0, "negative factor"); + let factor: u64 = f.params.factor().value(); // Since we are sure that the 'address' parameter actually exists we can // retrieve its actual value into an ScAddress value type. @@ -83,11 +74,11 @@ pub fn func_member(ctx: &ScFuncContext, f: &MemberContext) { // type-checked proxy map for us from the schema.json state storage definition. // If there is no 'members' map present yet in state storage an empty map will // automatically be created on the host. - let members: MapAddressToMutableInt64 = f.state.members(); + let members: MapAddressToMutableUint64 = f.state.members(); - // Now we create an ScMutableInt64 proxy for the value stored in the 'members' + // Now we create an ScMutableUint64 proxy for the value stored in the 'members' // map under the key defined by the 'address' parameter we retrieved earlier. - let current_factor: ScMutableInt64 = members.get_int64(&address); + let current_factor: ScMutableUint64 = members.get_uint64(&address); // We check to see if this key/value combination exists in the 'members' map. if !current_factor.exists() { @@ -100,7 +91,7 @@ pub fn func_member(ctx: &ScFuncContext, f: &MemberContext) { // Now we will append the new address to the memberList array. // First we determine the current length of the array. - let length: i32 = member_list.length(); + let length: u32 = member_list.length(); // Next we create an ScMutableAddress proxy to the address value that lives // at that index in the memberList array (no value, since we're appending). @@ -114,10 +105,10 @@ pub fn func_member(ctx: &ScFuncContext, f: &MemberContext) { // member_list.get_address(member_list.length()).set_value(&address); } - // Create an ScMutableInt64 proxy named 'totalFactor' for an Int64 value in + // Create an ScMutableUint64 proxy named 'totalFactor' for an Int64 value in // state storage. Note that we don't care whether this value exists or not, // because WasmLib will treat it as if it has the default value of zero. - let total_factor: ScMutableInt64 = f.state.total_factor(); + let total_factor: ScMutableUint64 = f.state.total_factor(); // Now we calculate the new running total sum of factors by first getting the // current value of 'totalFactor' from the state storage, then subtracting the @@ -125,7 +116,7 @@ pub fn func_member(ctx: &ScFuncContext, f: &MemberContext) { // exists. Again, if the associated value doesn't exist, WasmLib will assume it // to be zero. Finally we add the factor retrieved from the parameters, // resulting in the new totalFactor. - let new_total_factor: i64 = total_factor.value() - current_factor.value() + factor; + let new_total_factor: u64 = total_factor.value() - current_factor.value() + factor; // Now we store the new totalFactor in the state storage. total_factor.set_value(new_total_factor); @@ -152,19 +143,19 @@ pub fn func_divide(ctx: &ScFuncContext, f: &DivideContext) { let balances: ScBalances = ctx.balances(); // Retrieve the amount of plain iota tokens from the account balance. - let amount: i64 = balances.balance(&ScColor::IOTA); + let amount: u64 = balances.balance(&ScColor::IOTA); // Retrieve the pre-calculated totalFactor value from the state storage. - let total_factor: i64 = f.state.total_factor().value(); + let total_factor: u64 = f.state.total_factor().value(); // Get the proxy to the 'members' map in the state storage. - let members: MapAddressToMutableInt64 = f.state.members(); + let members: MapAddressToMutableUint64 = f.state.members(); // Get the proxy to the 'memberList' array in the state storage. let member_list: ArrayOfMutableAddress = f.state.member_list(); // Determine the current length of the memberList array. - let size: i32 = member_list.length(); + let size: u32 = member_list.length(); // Loop through all indexes of the memberList array. for i in 0..size { @@ -172,11 +163,11 @@ pub fn func_divide(ctx: &ScFuncContext, f: &DivideContext) { let address: ScAddress = member_list.get_address(i).value(); // Retrieve the factor associated with the address from the members map. - let factor: i64 = members.get_int64(&address).value(); + let factor: u64 = members.get_uint64(&address).value(); // Calculate the fair share of iotas to disperse to this member based on the // factor we just retrieved. Note that the result will be truncated. - let share: i64 = amount * factor / total_factor; + let share: u64 = amount * factor / total_factor; // Is there anything to disperse to this member? if share > 0 { @@ -222,10 +213,10 @@ pub fn view_get_factor(_ctx: &ScViewContext, f: &GetFactorContext) { // Create an ScImmutableMap proxy to the 'members' map in the state storage. // Note that for views this is an *immutable* map as opposed to the *mutable* // map we can access from the *mutable* state that gets passed to funcs. - let members: MapAddressToImmutableInt64 = f.state.members(); + let members: MapAddressToImmutableUint64 = f.state.members(); // Retrieve the factor associated with the address parameter. - let factor: i64 = members.get_int64(&address).value(); + let factor: u64 = members.get_uint64(&address).value(); // Set the factor in the results map of the function context. // The contents of this results map is returned to the caller of the function. diff --git a/contracts/wasm/dividend/src/params.rs b/contracts/wasm/dividend/src/params.rs index abea99eece..513767bdbc 100644 --- a/contracts/wasm/dividend/src/params.rs +++ b/contracts/wasm/dividend/src/params.rs @@ -46,8 +46,8 @@ impl ImmutableMemberParams { ScImmutableAddress::new(self.id, PARAM_ADDRESS.get_key_id()) } - pub fn factor(&self) -> ScImmutableInt64 { - ScImmutableInt64::new(self.id, PARAM_FACTOR.get_key_id()) + pub fn factor(&self) -> ScImmutableUint64 { + ScImmutableUint64::new(self.id, PARAM_FACTOR.get_key_id()) } } @@ -61,8 +61,8 @@ impl MutableMemberParams { ScMutableAddress::new(self.id, PARAM_ADDRESS.get_key_id()) } - pub fn factor(&self) -> ScMutableInt64 { - ScMutableInt64::new(self.id, PARAM_FACTOR.get_key_id()) + pub fn factor(&self) -> ScMutableUint64 { + ScMutableUint64::new(self.id, PARAM_FACTOR.get_key_id()) } } diff --git a/contracts/wasm/dividend/src/results.rs b/contracts/wasm/dividend/src/results.rs index 9e6680e864..433d9451a3 100644 --- a/contracts/wasm/dividend/src/results.rs +++ b/contracts/wasm/dividend/src/results.rs @@ -20,8 +20,8 @@ pub struct ImmutableGetFactorResults { } impl ImmutableGetFactorResults { - pub fn factor(&self) -> ScImmutableInt64 { - ScImmutableInt64::new(self.id, RESULT_FACTOR.get_key_id()) + pub fn factor(&self) -> ScImmutableUint64 { + ScImmutableUint64::new(self.id, RESULT_FACTOR.get_key_id()) } } @@ -31,8 +31,8 @@ pub struct MutableGetFactorResults { } impl MutableGetFactorResults { - pub fn factor(&self) -> ScMutableInt64 { - ScMutableInt64::new(self.id, RESULT_FACTOR.get_key_id()) + pub fn factor(&self) -> ScMutableUint64 { + ScMutableUint64::new(self.id, RESULT_FACTOR.get_key_id()) } } diff --git a/contracts/wasm/dividend/src/state.rs b/contracts/wasm/dividend/src/state.rs index 4cb5424635..edc7818dbc 100644 --- a/contracts/wasm/dividend/src/state.rs +++ b/contracts/wasm/dividend/src/state.rs @@ -20,23 +20,23 @@ pub struct ArrayOfImmutableAddress { } impl ArrayOfImmutableAddress { - pub fn length(&self) -> i32 { + pub fn length(&self) -> u32 { get_length(self.obj_id) } - pub fn get_address(&self, index: i32) -> ScImmutableAddress { - ScImmutableAddress::new(self.obj_id, Key32(index)) + pub fn get_address(&self, index: u32) -> ScImmutableAddress { + ScImmutableAddress::new(self.obj_id, Key32(index as i32)) } } #[derive(Clone, Copy)] -pub struct MapAddressToImmutableInt64 { +pub struct MapAddressToImmutableUint64 { pub(crate) obj_id: i32, } -impl MapAddressToImmutableInt64 { - pub fn get_int64(&self, key: &ScAddress) -> ScImmutableInt64 { - ScImmutableInt64::new(self.obj_id, key.get_key_id()) +impl MapAddressToImmutableUint64 { + pub fn get_uint64(&self, key: &ScAddress) -> ScImmutableUint64 { + ScImmutableUint64::new(self.obj_id, key.get_key_id()) } } @@ -51,17 +51,17 @@ impl ImmutableDividendState { ArrayOfImmutableAddress { obj_id: arr_id } } - pub fn members(&self) -> MapAddressToImmutableInt64 { + pub fn members(&self) -> MapAddressToImmutableUint64 { let map_id = get_object_id(self.id, STATE_MEMBERS.get_key_id(), TYPE_MAP); - MapAddressToImmutableInt64 { obj_id: map_id } + MapAddressToImmutableUint64 { obj_id: map_id } } pub fn owner(&self) -> ScImmutableAgentID { ScImmutableAgentID::new(self.id, STATE_OWNER.get_key_id()) } - pub fn total_factor(&self) -> ScImmutableInt64 { - ScImmutableInt64::new(self.id, STATE_TOTAL_FACTOR.get_key_id()) + pub fn total_factor(&self) -> ScImmutableUint64 { + ScImmutableUint64::new(self.id, STATE_TOTAL_FACTOR.get_key_id()) } } @@ -75,27 +75,27 @@ impl ArrayOfMutableAddress { clear(self.obj_id); } - pub fn length(&self) -> i32 { + pub fn length(&self) -> u32 { get_length(self.obj_id) } - pub fn get_address(&self, index: i32) -> ScMutableAddress { - ScMutableAddress::new(self.obj_id, Key32(index)) + pub fn get_address(&self, index: u32) -> ScMutableAddress { + ScMutableAddress::new(self.obj_id, Key32(index as i32)) } } #[derive(Clone, Copy)] -pub struct MapAddressToMutableInt64 { +pub struct MapAddressToMutableUint64 { pub(crate) obj_id: i32, } -impl MapAddressToMutableInt64 { +impl MapAddressToMutableUint64 { pub fn clear(&self) { clear(self.obj_id); } - pub fn get_int64(&self, key: &ScAddress) -> ScMutableInt64 { - ScMutableInt64::new(self.obj_id, key.get_key_id()) + pub fn get_uint64(&self, key: &ScAddress) -> ScMutableUint64 { + ScMutableUint64::new(self.obj_id, key.get_key_id()) } } @@ -114,16 +114,16 @@ impl MutableDividendState { ArrayOfMutableAddress { obj_id: arr_id } } - pub fn members(&self) -> MapAddressToMutableInt64 { + pub fn members(&self) -> MapAddressToMutableUint64 { let map_id = get_object_id(self.id, STATE_MEMBERS.get_key_id(), TYPE_MAP); - MapAddressToMutableInt64 { obj_id: map_id } + MapAddressToMutableUint64 { obj_id: map_id } } pub fn owner(&self) -> ScMutableAgentID { ScMutableAgentID::new(self.id, STATE_OWNER.get_key_id()) } - pub fn total_factor(&self) -> ScMutableInt64 { - ScMutableInt64::new(self.id, STATE_TOTAL_FACTOR.get_key_id()) + pub fn total_factor(&self) -> ScMutableUint64 { + ScMutableUint64::new(self.id, STATE_TOTAL_FACTOR.get_key_id()) } } diff --git a/contracts/wasm/dividend/test/dividend_bg.wasm b/contracts/wasm/dividend/test/dividend_bg.wasm index 0f2efc4648d4784cd913470b6eb7c0c5bdbef544..21b499b830d5ecdeb77a0e66e309123da7f42460 100644 GIT binary patch delta 5169 zcmai13viXi75;bs`%3P;$)DHd=25cuCP08B(f|n{g={EqB9DrIDJTjR6CR01s#Zy& z6kV;*erI@GPzXrP@jBk#I7TQ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83SaQ^FITCs4B7*0I1utMN2 zKeMRSZVRYrajta%2Wu_mq}M${Ux?GZ#TUc~{m0_DKK{7D;L0T*h@14gCGSie?B^Gn zi7;?_U_?WEW#VSTW|3iot3OVw8z-0DKXZnV$vYMfh+c?Of8z{*=kBtt1^3OejFKca zsCwCMc{EO^mz9@YI+g_E=l#Uv^v}zZe(sy4`AKyBRjm*|rk_7BKRe=Sj6JOXyBC|u zu{y|Hc{?%KR4T+J8d`oz+(>L#(Ix1QD^KN(d=n-!figgOoclxc+N!T%?}g2qacc`z(b#1ktY%n+iS*0s!8IE3};JPT(b^fsMkA;WkqtlgJ zZKau}q@k8j!8K$PV+5~7+@nrLU8Rp(3d_dsYj86NeC6^*Yr7mJwK|-0{9yjm_oZ!G*I2?EHT7GC~W*QG81+03H!Kmwl01dshddjli7x}y=A|g)D z(ia?mD1osD@m69M3q?uek3yT(7hMyN8Po5cBWq2Syl{?|togF|dy22wm;XFh5~)P4 z;Q5qCe=|-6Ynvo8c+1)<+#%msTPbcO-d?MP_=Ik)>larOJrBJlf+?g59L(kQlW5)g zZJ!Y)F0Y>@@@_oG$ACDfs2%h4*=lG3ShXQ%_x$*nBLyFBLCIrF+m7QRLef@_wFAvupd?}M3gri{a*NO)1T7Igi#P=W17P5DM-g{!Zc$Z3AaS0xy2U{=5qetm(YklM- z(1=&cbrAcN0yloApt_oyv|-y*q9F0BZJR}K#Ev`Pm2f$4$255|p4hfys*n^DT(xE+vC*B{s#k7o7kpH!y{Jn>8 z5y$sl7C)kgI;Nt1y5o)9UY}(&!QdJEc&WWq(;3TMnqe7b;QkX6mV+*(pLQNA9CoE4 z1j`HQ6E!u4*H4@G)lD${76gW|kY3r>JmCp&3S19;yl+|Vpv%pMB#hr6HFhnP1rriS zx(bDyl1bm*-#C3^re)+o83m1i?r-hb*`^RywYy_S+t<{qknr6kLJ20c<39#8OUM<5J`?2gm?= 0, "negative factor"); + // retrieve its actual value into an u64. Note that we use Rust's built-in + // data types when manipulating Uint64, String, or Bytes value objects. + let factor: u64 = f.params.factor().value(); // Since we are sure that the 'address' parameter actually exists we can // retrieve its actual value into an ScAddress value type. @@ -82,11 +73,11 @@ export function funcMember(ctx: wasmlib.ScFuncContext, f: sc.MemberContext): voi // type-checked proxy map for us from the schema.json state storage definition. // If there is no 'members' map present yet in state storage an empty map will // automatically be created on the host. - let members: sc.MapAddressToMutableInt64 = f.state.members(); + let members: sc.MapAddressToMutableUint64 = f.state.members(); - // Now we create an ScMutableInt64 proxy for the value stored in the 'members' + // Now we create an ScMutableUint64 proxy for the value stored in the 'members' // map under the key defined by the 'address' parameter we retrieved earlier. - let currentFactor: wasmlib.ScMutableInt64 = members.getInt64(address); + let currentFactor: wasmlib.ScMutableUint64 = members.getUint64(address); // We check to see if this key/value combination exists in the 'members' map. if (!currentFactor.exists()) { @@ -99,7 +90,7 @@ export function funcMember(ctx: wasmlib.ScFuncContext, f: sc.MemberContext): voi // Now we will append the new address to the memberList array. // First we determine the current length of the array. - let length: i32 = memberList.length(); + let length: u32 = memberList.length(); // Next we create an ScMutableAddress proxy to the address value that lives // at that index in the memberList array (no value, since we're appending). @@ -113,10 +104,10 @@ export function funcMember(ctx: wasmlib.ScFuncContext, f: sc.MemberContext): voi // memberList.getAddress(memberList.length()).setValue(address); } - // Create an ScMutableInt64 proxy named 'totalFactor' for an Int64 value in + // Create an ScMutableUint64 proxy named 'totalFactor' for an Uint64 value in // state storage. Note that we don't care whether this value exists or not, // because WasmLib will treat it as if it has the default value of zero. - let totalFactor: wasmlib.ScMutableInt64 = f.state.totalFactor(); + let totalFactor: wasmlib.ScMutableUint64 = f.state.totalFactor(); // Now we calculate the new running total sum of factors by first getting the // current value of 'totalFactor' from the state storage, then subtracting the @@ -124,7 +115,7 @@ export function funcMember(ctx: wasmlib.ScFuncContext, f: sc.MemberContext): voi // exists. Again, if the associated value doesn't exist, WasmLib will assume it // to be zero. Finally we add the factor retrieved from the parameters, // resulting in the new totalFactor. - let newTotalFactor: i64 = totalFactor.value() - currentFactor.value() + factor; + let newTotalFactor: u64 = totalFactor.value() - currentFactor.value() + factor; // Now we store the new totalFactor in the state storage. totalFactor.setValue(newTotalFactor); @@ -151,31 +142,31 @@ export function funcDivide(ctx: wasmlib.ScFuncContext, f: sc.DivideContext): voi let balances: wasmlib.ScBalances = ctx.balances(); // Retrieve the amount of plain iota tokens from the account balance. - let amount: i64 = balances.balance(wasmlib.ScColor.IOTA); + let amount: u64 = balances.balance(wasmlib.ScColor.IOTA); // Retrieve the pre-calculated totalFactor value from the state storage. - let totalFactor: i64 = f.state.totalFactor().value(); + let totalFactor: u64 = f.state.totalFactor().value(); // Get the proxy to the 'members' map in the state storage. - let members: sc.MapAddressToMutableInt64 = f.state.members(); + let members: sc.MapAddressToMutableUint64 = f.state.members(); // Get the proxy to the 'memberList' array in the state storage. let memberList: sc.ArrayOfMutableAddress = f.state.memberList(); // Determine the current length of the memberList array. - let size: i32 = memberList.length(); + let size: u32 = memberList.length(); // Loop through all indexes of the memberList array. - for (let i = 0; i < size; i++) { + for (let i: u32 = 0; i < size; i++) { // Retrieve the next indexed address from the memberList array. let address: wasmlib.ScAddress = memberList.getAddress(i).value(); // Retrieve the factor associated with the address from the members map. - let factor: i64 = members.getInt64(address).value(); + let factor: u64 = members.getUint64(address).value(); // Calculate the fair share of iotas to disperse to this member based on the // factor we just retrieved. Note that the result will be truncated. - let share: i64 = amount * factor / totalFactor; + let share: u64 = amount * factor / totalFactor; // Is there anything to disperse to this member? if (share > 0) { @@ -221,10 +212,10 @@ export function viewGetFactor(ctx: wasmlib.ScViewContext, f: sc.GetFactorContext // Create an ScImmutableMap proxy to the 'members' map in the state storage. // Note that for views this is an *immutable* map as opposed to the *mutable* // map we can access from the *mutable* state that gets passed to funcs. - let members: sc.MapAddressToImmutableInt64 = f.state.members(); + let members: sc.MapAddressToImmutableUint64 = f.state.members(); // Retrieve the factor associated with the address parameter. - let factor: i64 = members.getInt64(address).value(); + let factor: u64 = members.getUint64(address).value(); // Set the factor in the results map of the function context. // The contents of this results map is returned to the caller of the function. diff --git a/contracts/wasm/dividend/ts/dividend/params.ts b/contracts/wasm/dividend/ts/dividend/params.ts index 7186afa1ec..7a6334d72f 100644 --- a/contracts/wasm/dividend/ts/dividend/params.ts +++ b/contracts/wasm/dividend/ts/dividend/params.ts @@ -25,8 +25,8 @@ export class ImmutableMemberParams extends wasmlib.ScMapID { return new wasmlib.ScImmutableAddress(this.mapID, wasmlib.Key32.fromString(sc.ParamAddress)); } - factor(): wasmlib.ScImmutableInt64 { - return new wasmlib.ScImmutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ParamFactor)); + factor(): wasmlib.ScImmutableUint64 { + return new wasmlib.ScImmutableUint64(this.mapID, wasmlib.Key32.fromString(sc.ParamFactor)); } } @@ -35,8 +35,8 @@ export class MutableMemberParams extends wasmlib.ScMapID { return new wasmlib.ScMutableAddress(this.mapID, wasmlib.Key32.fromString(sc.ParamAddress)); } - factor(): wasmlib.ScMutableInt64 { - return new wasmlib.ScMutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ParamFactor)); + factor(): wasmlib.ScMutableUint64 { + return new wasmlib.ScMutableUint64(this.mapID, wasmlib.Key32.fromString(sc.ParamFactor)); } } diff --git a/contracts/wasm/dividend/ts/dividend/results.ts b/contracts/wasm/dividend/ts/dividend/results.ts index bf8821b726..afdd4d83e1 100644 --- a/contracts/wasm/dividend/ts/dividend/results.ts +++ b/contracts/wasm/dividend/ts/dividend/results.ts @@ -9,14 +9,14 @@ import * as wasmlib from "wasmlib"; import * as sc from "./index"; export class ImmutableGetFactorResults extends wasmlib.ScMapID { - factor(): wasmlib.ScImmutableInt64 { - return new wasmlib.ScImmutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ResultFactor)); + factor(): wasmlib.ScImmutableUint64 { + return new wasmlib.ScImmutableUint64(this.mapID, wasmlib.Key32.fromString(sc.ResultFactor)); } } export class MutableGetFactorResults extends wasmlib.ScMapID { - factor(): wasmlib.ScMutableInt64 { - return new wasmlib.ScMutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ResultFactor)); + factor(): wasmlib.ScMutableUint64 { + return new wasmlib.ScMutableUint64(this.mapID, wasmlib.Key32.fromString(sc.ResultFactor)); } } diff --git a/contracts/wasm/dividend/ts/dividend/state.ts b/contracts/wasm/dividend/ts/dividend/state.ts index 0bd4aed4b3..92a0981f41 100644 --- a/contracts/wasm/dividend/ts/dividend/state.ts +++ b/contracts/wasm/dividend/ts/dividend/state.ts @@ -15,24 +15,24 @@ export class ArrayOfImmutableAddress { this.objID = objID; } - length(): i32 { + length(): u32 { return wasmlib.getLength(this.objID); } - getAddress(index: i32): wasmlib.ScImmutableAddress { - return new wasmlib.ScImmutableAddress(this.objID, new wasmlib.Key32(index)); + getAddress(index: u32): wasmlib.ScImmutableAddress { + return new wasmlib.ScImmutableAddress(this.objID, new wasmlib.Key32(index as i32)); } } -export class MapAddressToImmutableInt64 { +export class MapAddressToImmutableUint64 { objID: i32; constructor(objID: i32) { this.objID = objID; } - getInt64(key: wasmlib.ScAddress): wasmlib.ScImmutableInt64 { - return new wasmlib.ScImmutableInt64(this.objID, key.getKeyID()); + getUint64(key: wasmlib.ScAddress): wasmlib.ScImmutableUint64 { + return new wasmlib.ScImmutableUint64(this.objID, key.getKeyID()); } } @@ -42,17 +42,17 @@ export class ImmutableDividendState extends wasmlib.ScMapID { return new sc.ArrayOfImmutableAddress(arrID); } - members(): sc.MapAddressToImmutableInt64 { + members(): sc.MapAddressToImmutableUint64 { let mapID = wasmlib.getObjectID(this.mapID, wasmlib.Key32.fromString(sc.StateMembers), wasmlib.TYPE_MAP); - return new sc.MapAddressToImmutableInt64(mapID); + return new sc.MapAddressToImmutableUint64(mapID); } owner(): wasmlib.ScImmutableAgentID { return new wasmlib.ScImmutableAgentID(this.mapID, wasmlib.Key32.fromString(sc.StateOwner)); } - totalFactor(): wasmlib.ScImmutableInt64 { - return new wasmlib.ScImmutableInt64(this.mapID, wasmlib.Key32.fromString(sc.StateTotalFactor)); + totalFactor(): wasmlib.ScImmutableUint64 { + return new wasmlib.ScImmutableUint64(this.mapID, wasmlib.Key32.fromString(sc.StateTotalFactor)); } } @@ -67,16 +67,16 @@ export class ArrayOfMutableAddress { wasmlib.clear(this.objID); } - length(): i32 { + length(): u32 { return wasmlib.getLength(this.objID); } - getAddress(index: i32): wasmlib.ScMutableAddress { - return new wasmlib.ScMutableAddress(this.objID, new wasmlib.Key32(index)); + getAddress(index: u32): wasmlib.ScMutableAddress { + return new wasmlib.ScMutableAddress(this.objID, new wasmlib.Key32(index as i32)); } } -export class MapAddressToMutableInt64 { +export class MapAddressToMutableUint64 { objID: i32; constructor(objID: i32) { @@ -87,8 +87,8 @@ export class MapAddressToMutableInt64 { wasmlib.clear(this.objID); } - getInt64(key: wasmlib.ScAddress): wasmlib.ScMutableInt64 { - return new wasmlib.ScMutableInt64(this.objID, key.getKeyID()); + getUint64(key: wasmlib.ScAddress): wasmlib.ScMutableUint64 { + return new wasmlib.ScMutableUint64(this.objID, key.getKeyID()); } } @@ -104,16 +104,16 @@ export class MutableDividendState extends wasmlib.ScMapID { return new sc.ArrayOfMutableAddress(arrID); } - members(): sc.MapAddressToMutableInt64 { + members(): sc.MapAddressToMutableUint64 { let mapID = wasmlib.getObjectID(this.mapID, wasmlib.Key32.fromString(sc.StateMembers), wasmlib.TYPE_MAP); - return new sc.MapAddressToMutableInt64(mapID); + return new sc.MapAddressToMutableUint64(mapID); } owner(): wasmlib.ScMutableAgentID { return new wasmlib.ScMutableAgentID(this.mapID, wasmlib.Key32.fromString(sc.StateOwner)); } - totalFactor(): wasmlib.ScMutableInt64 { - return new wasmlib.ScMutableInt64(this.mapID, wasmlib.Key32.fromString(sc.StateTotalFactor)); + totalFactor(): wasmlib.ScMutableUint64 { + return new wasmlib.ScMutableUint64(this.mapID, wasmlib.Key32.fromString(sc.StateTotalFactor)); } } diff --git a/contracts/wasm/donatewithfeedback/go/donatewithfeedback/consts.go b/contracts/wasm/donatewithfeedback/go/donatewithfeedback/consts.go index d6c691a71e..970c4599b3 100644 --- a/contracts/wasm/donatewithfeedback/go/donatewithfeedback/consts.go +++ b/contracts/wasm/donatewithfeedback/go/donatewithfeedback/consts.go @@ -7,12 +7,12 @@ package donatewithfeedback -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" +import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" const ( ScName = "donatewithfeedback" ScDescription = "" - HScName = wasmlib.ScHname(0x696d7f66) + HScName = wasmtypes.ScHname(0x696d7f66) ) const ( @@ -46,8 +46,8 @@ const ( ) const ( - HFuncDonate = wasmlib.ScHname(0xdc9b133a) - HFuncWithdraw = wasmlib.ScHname(0x9dcc0f41) - HViewDonation = wasmlib.ScHname(0xbdb245ba) - HViewDonationInfo = wasmlib.ScHname(0xc8f7c726) + HFuncDonate = wasmtypes.ScHname(0xdc9b133a) + HFuncWithdraw = wasmtypes.ScHname(0x9dcc0f41) + HViewDonation = wasmtypes.ScHname(0xbdb245ba) + HViewDonationInfo = wasmtypes.ScHname(0xc8f7c726) ) diff --git a/contracts/wasm/donatewithfeedback/go/donatewithfeedback/contract.go b/contracts/wasm/donatewithfeedback/go/donatewithfeedback/contract.go index 11d419e9a6..419f9f2597 100644 --- a/contracts/wasm/donatewithfeedback/go/donatewithfeedback/contract.go +++ b/contracts/wasm/donatewithfeedback/go/donatewithfeedback/contract.go @@ -36,24 +36,25 @@ var ScFuncs Funcs func (sc Funcs) Donate(ctx wasmlib.ScFuncCallContext) *DonateCall { f := &DonateCall{Func: wasmlib.NewScFunc(ctx, HScName, HFuncDonate)} - f.Func.SetPtrs(&f.Params.id, nil) + f.Params.proxy = wasmlib.NewCallParamsProxy(&f.Func.ScView) return f } func (sc Funcs) Withdraw(ctx wasmlib.ScFuncCallContext) *WithdrawCall { f := &WithdrawCall{Func: wasmlib.NewScFunc(ctx, HScName, HFuncWithdraw)} - f.Func.SetPtrs(&f.Params.id, nil) + f.Params.proxy = wasmlib.NewCallParamsProxy(&f.Func.ScView) return f } func (sc Funcs) Donation(ctx wasmlib.ScViewCallContext) *DonationCall { f := &DonationCall{Func: wasmlib.NewScView(ctx, HScName, HViewDonation)} - f.Func.SetPtrs(&f.Params.id, &f.Results.id) + f.Params.proxy = wasmlib.NewCallParamsProxy(f.Func) + wasmlib.NewCallResultsProxy(f.Func, &f.Results.proxy) return f } func (sc Funcs) DonationInfo(ctx wasmlib.ScViewCallContext) *DonationInfoCall { f := &DonationInfoCall{Func: wasmlib.NewScView(ctx, HScName, HViewDonationInfo)} - f.Func.SetPtrs(nil, &f.Results.id) + wasmlib.NewCallResultsProxy(f.Func, &f.Results.proxy) return f } diff --git a/contracts/wasm/donatewithfeedback/go/donatewithfeedback/donatewithfeedback.go b/contracts/wasm/donatewithfeedback/go/donatewithfeedback/donatewithfeedback.go index 4df9cda20d..5bc7597f91 100644 --- a/contracts/wasm/donatewithfeedback/go/donatewithfeedback/donatewithfeedback.go +++ b/contracts/wasm/donatewithfeedback/go/donatewithfeedback/donatewithfeedback.go @@ -5,11 +5,12 @@ package donatewithfeedback import ( "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" + "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" ) func funcDonate(ctx wasmlib.ScFuncContext, f *DonateContext) { donation := &Donation{ - Amount: ctx.Incoming().Balance(wasmlib.IOTA), + Amount: ctx.IncomingTransfer().Balance(wasmtypes.IOTA), Donator: ctx.Caller(), Error: "", Feedback: f.Params.Feedback().Value(), @@ -18,12 +19,12 @@ func funcDonate(ctx wasmlib.ScFuncContext, f *DonateContext) { if donation.Amount == 0 || donation.Feedback == "" { donation.Error = "error: empty feedback or donated amount = 0" if donation.Amount > 0 { - ctx.TransferToAddress(donation.Donator.Address(), wasmlib.NewScTransferIotas(donation.Amount)) + ctx.Send(donation.Donator.Address(), wasmlib.NewScTransferIotas(donation.Amount)) donation.Amount = 0 } } log := f.State.Log() - log.GetDonation(log.Length()).SetValue(donation) + log.AppendDonation().SetValue(donation) largestDonation := f.State.MaxDonation() totalDonated := f.State.TotalDonation() @@ -34,7 +35,7 @@ func funcDonate(ctx wasmlib.ScFuncContext, f *DonateContext) { } func funcWithdraw(ctx wasmlib.ScFuncContext, f *WithdrawContext) { - balance := ctx.Balances().Balance(wasmlib.IOTA) + balance := ctx.Balances().Balance(wasmtypes.IOTA) amount := f.Params.Amount().Value() if amount == 0 || amount > balance { amount = balance @@ -45,11 +46,11 @@ func funcWithdraw(ctx wasmlib.ScFuncContext, f *WithdrawContext) { } scCreator := ctx.ContractCreator().Address() - ctx.TransferToAddress(scCreator, wasmlib.NewScTransferIotas(amount)) + ctx.Send(scCreator, wasmlib.NewScTransferIotas(amount)) } func viewDonation(ctx wasmlib.ScViewContext, f *DonationContext) { - nr := int32(f.Params.Nr().Value()) + nr := f.Params.Nr().Value() donation := f.State.Log().GetDonation(nr).Value() f.Results.Amount().SetValue(donation.Amount) f.Results.Donator().SetValue(donation.Donator) @@ -61,5 +62,5 @@ func viewDonation(ctx wasmlib.ScViewContext, f *DonationContext) { func viewDonationInfo(ctx wasmlib.ScViewContext, f *DonationInfoContext) { f.Results.MaxDonation().SetValue(f.State.MaxDonation().Value()) f.Results.TotalDonation().SetValue(f.State.TotalDonation().Value()) - f.Results.Count().SetValue(int64(f.State.Log().Length())) + f.Results.Count().SetValue(f.State.Log().Length()) } diff --git a/contracts/wasm/donatewithfeedback/go/donatewithfeedback/keys.go b/contracts/wasm/donatewithfeedback/go/donatewithfeedback/keys.go index a6939d46b7..94694d46f8 100644 --- a/contracts/wasm/donatewithfeedback/go/donatewithfeedback/keys.go +++ b/contracts/wasm/donatewithfeedback/go/donatewithfeedback/keys.go @@ -6,45 +6,3 @@ // Change the json schema instead package donatewithfeedback - -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" - -const ( - IdxParamAmount = 0 - IdxParamFeedback = 1 - IdxParamNr = 2 - - IdxResultAmount = 3 - IdxResultCount = 4 - IdxResultDonator = 5 - IdxResultError = 6 - IdxResultFeedback = 7 - IdxResultMaxDonation = 8 - IdxResultTimestamp = 9 - IdxResultTotalDonation = 10 - - IdxStateLog = 11 - IdxStateMaxDonation = 12 - IdxStateTotalDonation = 13 -) - -const keyMapLen = 14 - -var keyMap = [keyMapLen]wasmlib.Key{ - ParamAmount, - ParamFeedback, - ParamNr, - ResultAmount, - ResultCount, - ResultDonator, - ResultError, - ResultFeedback, - ResultMaxDonation, - ResultTimestamp, - ResultTotalDonation, - StateLog, - StateMaxDonation, - StateTotalDonation, -} - -var idxMap [keyMapLen]wasmlib.Key32 diff --git a/contracts/wasm/donatewithfeedback/go/donatewithfeedback/lib.go b/contracts/wasm/donatewithfeedback/go/donatewithfeedback/lib.go index e24d6693b9..bbf65a3b33 100644 --- a/contracts/wasm/donatewithfeedback/go/donatewithfeedback/lib.go +++ b/contracts/wasm/donatewithfeedback/go/donatewithfeedback/lib.go @@ -15,10 +15,6 @@ func OnLoad() { exports.AddFunc(FuncWithdraw, funcWithdrawThunk) exports.AddView(ViewDonation, viewDonationThunk) exports.AddView(ViewDonationInfo, viewDonationInfoThunk) - - for i, key := range keyMap { - idxMap[i] = key.KeyID() - } } type DonateContext struct { @@ -30,10 +26,10 @@ func funcDonateThunk(ctx wasmlib.ScFuncContext) { ctx.Log("donatewithfeedback.funcDonate") f := &DonateContext{ Params: ImmutableDonateParams{ - id: wasmlib.OBJ_ID_PARAMS, + proxy: wasmlib.NewParamsProxy(), }, State: MutableDonateWithFeedbackState{ - id: wasmlib.OBJ_ID_STATE, + proxy: wasmlib.NewStateProxy(), }, } funcDonate(ctx, f) @@ -47,18 +43,18 @@ type WithdrawContext struct { func funcWithdrawThunk(ctx wasmlib.ScFuncContext) { ctx.Log("donatewithfeedback.funcWithdraw") - - // only SC creator can withdraw donated funds - ctx.Require(ctx.Caller() == ctx.ContractCreator(), "no permission") - f := &WithdrawContext{ Params: ImmutableWithdrawParams{ - id: wasmlib.OBJ_ID_PARAMS, + proxy: wasmlib.NewParamsProxy(), }, State: MutableDonateWithFeedbackState{ - id: wasmlib.OBJ_ID_STATE, + proxy: wasmlib.NewStateProxy(), }, } + + // only SC creator can withdraw donated funds + ctx.Require(ctx.Caller() == ctx.ContractCreator(), "no permission") + funcWithdraw(ctx, f) ctx.Log("donatewithfeedback.funcWithdraw ok") } @@ -73,13 +69,13 @@ func viewDonationThunk(ctx wasmlib.ScViewContext) { ctx.Log("donatewithfeedback.viewDonation") f := &DonationContext{ Params: ImmutableDonationParams{ - id: wasmlib.OBJ_ID_PARAMS, + proxy: wasmlib.NewParamsProxy(), }, Results: MutableDonationResults{ - id: wasmlib.OBJ_ID_RESULTS, + proxy: wasmlib.NewResultsProxy(), }, State: ImmutableDonateWithFeedbackState{ - id: wasmlib.OBJ_ID_STATE, + proxy: wasmlib.NewStateProxy(), }, } ctx.Require(f.Params.Nr().Exists(), "missing mandatory nr") @@ -96,10 +92,10 @@ func viewDonationInfoThunk(ctx wasmlib.ScViewContext) { ctx.Log("donatewithfeedback.viewDonationInfo") f := &DonationInfoContext{ Results: MutableDonationInfoResults{ - id: wasmlib.OBJ_ID_RESULTS, + proxy: wasmlib.NewResultsProxy(), }, State: ImmutableDonateWithFeedbackState{ - id: wasmlib.OBJ_ID_STATE, + proxy: wasmlib.NewStateProxy(), }, } viewDonationInfo(ctx, f) diff --git a/contracts/wasm/donatewithfeedback/go/donatewithfeedback/params.go b/contracts/wasm/donatewithfeedback/go/donatewithfeedback/params.go index caa10267bc..1030106b63 100644 --- a/contracts/wasm/donatewithfeedback/go/donatewithfeedback/params.go +++ b/contracts/wasm/donatewithfeedback/go/donatewithfeedback/params.go @@ -7,52 +7,52 @@ package donatewithfeedback -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" +import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" type ImmutableDonateParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableDonateParams) Feedback() wasmlib.ScImmutableString { - return wasmlib.NewScImmutableString(s.id, wasmlib.KeyID(ParamFeedback)) +func (s ImmutableDonateParams) Feedback() wasmtypes.ScImmutableString { + return wasmtypes.NewScImmutableString(s.proxy.Root(ParamFeedback)) } type MutableDonateParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableDonateParams) Feedback() wasmlib.ScMutableString { - return wasmlib.NewScMutableString(s.id, wasmlib.KeyID(ParamFeedback)) +func (s MutableDonateParams) Feedback() wasmtypes.ScMutableString { + return wasmtypes.NewScMutableString(s.proxy.Root(ParamFeedback)) } type ImmutableWithdrawParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableWithdrawParams) Amount() wasmlib.ScImmutableInt64 { - return wasmlib.NewScImmutableInt64(s.id, wasmlib.KeyID(ParamAmount)) +func (s ImmutableWithdrawParams) Amount() wasmtypes.ScImmutableUint64 { + return wasmtypes.NewScImmutableUint64(s.proxy.Root(ParamAmount)) } type MutableWithdrawParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableWithdrawParams) Amount() wasmlib.ScMutableInt64 { - return wasmlib.NewScMutableInt64(s.id, wasmlib.KeyID(ParamAmount)) +func (s MutableWithdrawParams) Amount() wasmtypes.ScMutableUint64 { + return wasmtypes.NewScMutableUint64(s.proxy.Root(ParamAmount)) } type ImmutableDonationParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableDonationParams) Nr() wasmlib.ScImmutableInt64 { - return wasmlib.NewScImmutableInt64(s.id, wasmlib.KeyID(ParamNr)) +func (s ImmutableDonationParams) Nr() wasmtypes.ScImmutableUint32 { + return wasmtypes.NewScImmutableUint32(s.proxy.Root(ParamNr)) } type MutableDonationParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableDonationParams) Nr() wasmlib.ScMutableInt64 { - return wasmlib.NewScMutableInt64(s.id, wasmlib.KeyID(ParamNr)) +func (s MutableDonationParams) Nr() wasmtypes.ScMutableUint32 { + return wasmtypes.NewScMutableUint32(s.proxy.Root(ParamNr)) } diff --git a/contracts/wasm/donatewithfeedback/go/donatewithfeedback/results.go b/contracts/wasm/donatewithfeedback/go/donatewithfeedback/results.go index 85fa71ca2c..31ebebb2fe 100644 --- a/contracts/wasm/donatewithfeedback/go/donatewithfeedback/results.go +++ b/contracts/wasm/donatewithfeedback/go/donatewithfeedback/results.go @@ -7,84 +7,84 @@ package donatewithfeedback -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" +import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" type ImmutableDonationResults struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableDonationResults) Amount() wasmlib.ScImmutableInt64 { - return wasmlib.NewScImmutableInt64(s.id, wasmlib.KeyID(ResultAmount)) +func (s ImmutableDonationResults) Amount() wasmtypes.ScImmutableUint64 { + return wasmtypes.NewScImmutableUint64(s.proxy.Root(ResultAmount)) } -func (s ImmutableDonationResults) Donator() wasmlib.ScImmutableAgentID { - return wasmlib.NewScImmutableAgentID(s.id, wasmlib.KeyID(ResultDonator)) +func (s ImmutableDonationResults) Donator() wasmtypes.ScImmutableAgentID { + return wasmtypes.NewScImmutableAgentID(s.proxy.Root(ResultDonator)) } -func (s ImmutableDonationResults) Error() wasmlib.ScImmutableString { - return wasmlib.NewScImmutableString(s.id, wasmlib.KeyID(ResultError)) +func (s ImmutableDonationResults) Error() wasmtypes.ScImmutableString { + return wasmtypes.NewScImmutableString(s.proxy.Root(ResultError)) } -func (s ImmutableDonationResults) Feedback() wasmlib.ScImmutableString { - return wasmlib.NewScImmutableString(s.id, wasmlib.KeyID(ResultFeedback)) +func (s ImmutableDonationResults) Feedback() wasmtypes.ScImmutableString { + return wasmtypes.NewScImmutableString(s.proxy.Root(ResultFeedback)) } -func (s ImmutableDonationResults) Timestamp() wasmlib.ScImmutableInt64 { - return wasmlib.NewScImmutableInt64(s.id, wasmlib.KeyID(ResultTimestamp)) +func (s ImmutableDonationResults) Timestamp() wasmtypes.ScImmutableUint64 { + return wasmtypes.NewScImmutableUint64(s.proxy.Root(ResultTimestamp)) } type MutableDonationResults struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableDonationResults) Amount() wasmlib.ScMutableInt64 { - return wasmlib.NewScMutableInt64(s.id, wasmlib.KeyID(ResultAmount)) +func (s MutableDonationResults) Amount() wasmtypes.ScMutableUint64 { + return wasmtypes.NewScMutableUint64(s.proxy.Root(ResultAmount)) } -func (s MutableDonationResults) Donator() wasmlib.ScMutableAgentID { - return wasmlib.NewScMutableAgentID(s.id, wasmlib.KeyID(ResultDonator)) +func (s MutableDonationResults) Donator() wasmtypes.ScMutableAgentID { + return wasmtypes.NewScMutableAgentID(s.proxy.Root(ResultDonator)) } -func (s MutableDonationResults) Error() wasmlib.ScMutableString { - return wasmlib.NewScMutableString(s.id, wasmlib.KeyID(ResultError)) +func (s MutableDonationResults) Error() wasmtypes.ScMutableString { + return wasmtypes.NewScMutableString(s.proxy.Root(ResultError)) } -func (s MutableDonationResults) Feedback() wasmlib.ScMutableString { - return wasmlib.NewScMutableString(s.id, wasmlib.KeyID(ResultFeedback)) +func (s MutableDonationResults) Feedback() wasmtypes.ScMutableString { + return wasmtypes.NewScMutableString(s.proxy.Root(ResultFeedback)) } -func (s MutableDonationResults) Timestamp() wasmlib.ScMutableInt64 { - return wasmlib.NewScMutableInt64(s.id, wasmlib.KeyID(ResultTimestamp)) +func (s MutableDonationResults) Timestamp() wasmtypes.ScMutableUint64 { + return wasmtypes.NewScMutableUint64(s.proxy.Root(ResultTimestamp)) } type ImmutableDonationInfoResults struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableDonationInfoResults) Count() wasmlib.ScImmutableInt64 { - return wasmlib.NewScImmutableInt64(s.id, wasmlib.KeyID(ResultCount)) +func (s ImmutableDonationInfoResults) Count() wasmtypes.ScImmutableUint32 { + return wasmtypes.NewScImmutableUint32(s.proxy.Root(ResultCount)) } -func (s ImmutableDonationInfoResults) MaxDonation() wasmlib.ScImmutableInt64 { - return wasmlib.NewScImmutableInt64(s.id, wasmlib.KeyID(ResultMaxDonation)) +func (s ImmutableDonationInfoResults) MaxDonation() wasmtypes.ScImmutableUint64 { + return wasmtypes.NewScImmutableUint64(s.proxy.Root(ResultMaxDonation)) } -func (s ImmutableDonationInfoResults) TotalDonation() wasmlib.ScImmutableInt64 { - return wasmlib.NewScImmutableInt64(s.id, wasmlib.KeyID(ResultTotalDonation)) +func (s ImmutableDonationInfoResults) TotalDonation() wasmtypes.ScImmutableUint64 { + return wasmtypes.NewScImmutableUint64(s.proxy.Root(ResultTotalDonation)) } type MutableDonationInfoResults struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableDonationInfoResults) Count() wasmlib.ScMutableInt64 { - return wasmlib.NewScMutableInt64(s.id, wasmlib.KeyID(ResultCount)) +func (s MutableDonationInfoResults) Count() wasmtypes.ScMutableUint32 { + return wasmtypes.NewScMutableUint32(s.proxy.Root(ResultCount)) } -func (s MutableDonationInfoResults) MaxDonation() wasmlib.ScMutableInt64 { - return wasmlib.NewScMutableInt64(s.id, wasmlib.KeyID(ResultMaxDonation)) +func (s MutableDonationInfoResults) MaxDonation() wasmtypes.ScMutableUint64 { + return wasmtypes.NewScMutableUint64(s.proxy.Root(ResultMaxDonation)) } -func (s MutableDonationInfoResults) TotalDonation() wasmlib.ScMutableInt64 { - return wasmlib.NewScMutableInt64(s.id, wasmlib.KeyID(ResultTotalDonation)) +func (s MutableDonationInfoResults) TotalDonation() wasmtypes.ScMutableUint64 { + return wasmtypes.NewScMutableUint64(s.proxy.Root(ResultTotalDonation)) } diff --git a/contracts/wasm/donatewithfeedback/go/donatewithfeedback/state.go b/contracts/wasm/donatewithfeedback/go/donatewithfeedback/state.go index c74fcc94c1..00bfaeb9e6 100644 --- a/contracts/wasm/donatewithfeedback/go/donatewithfeedback/state.go +++ b/contracts/wasm/donatewithfeedback/go/donatewithfeedback/state.go @@ -7,55 +7,58 @@ package donatewithfeedback -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" +import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" type ArrayOfImmutableDonation struct { - objID int32 + proxy wasmtypes.Proxy } -func (a ArrayOfImmutableDonation) Length() int32 { - return wasmlib.GetLength(a.objID) +func (a ArrayOfImmutableDonation) Length() uint32 { + return a.proxy.Length() } -func (a ArrayOfImmutableDonation) GetDonation(index int32) ImmutableDonation { - return ImmutableDonation{objID: a.objID, keyID: wasmlib.Key32(index)} +func (a ArrayOfImmutableDonation) GetDonation(index uint32) ImmutableDonation { + return ImmutableDonation{proxy: a.proxy.Index(index)} } type ImmutableDonateWithFeedbackState struct { - id int32 + proxy wasmtypes.Proxy } func (s ImmutableDonateWithFeedbackState) Log() ArrayOfImmutableDonation { - arrID := wasmlib.GetObjectID(s.id, wasmlib.KeyID(StateLog), wasmlib.TYPE_ARRAY|wasmlib.TYPE_BYTES) - return ArrayOfImmutableDonation{objID: arrID} + return ArrayOfImmutableDonation{proxy: s.proxy.Root(StateLog)} } -func (s ImmutableDonateWithFeedbackState) MaxDonation() wasmlib.ScImmutableInt64 { - return wasmlib.NewScImmutableInt64(s.id, wasmlib.KeyID(StateMaxDonation)) +func (s ImmutableDonateWithFeedbackState) MaxDonation() wasmtypes.ScImmutableUint64 { + return wasmtypes.NewScImmutableUint64(s.proxy.Root(StateMaxDonation)) } -func (s ImmutableDonateWithFeedbackState) TotalDonation() wasmlib.ScImmutableInt64 { - return wasmlib.NewScImmutableInt64(s.id, wasmlib.KeyID(StateTotalDonation)) +func (s ImmutableDonateWithFeedbackState) TotalDonation() wasmtypes.ScImmutableUint64 { + return wasmtypes.NewScImmutableUint64(s.proxy.Root(StateTotalDonation)) } type ArrayOfMutableDonation struct { - objID int32 + proxy wasmtypes.Proxy +} + +func (a ArrayOfMutableDonation) AppendDonation() MutableDonation { + return MutableDonation{proxy: a.proxy.Append()} } func (a ArrayOfMutableDonation) Clear() { - wasmlib.Clear(a.objID) + a.proxy.ClearArray() } -func (a ArrayOfMutableDonation) Length() int32 { - return wasmlib.GetLength(a.objID) +func (a ArrayOfMutableDonation) Length() uint32 { + return a.proxy.Length() } -func (a ArrayOfMutableDonation) GetDonation(index int32) MutableDonation { - return MutableDonation{objID: a.objID, keyID: wasmlib.Key32(index)} +func (a ArrayOfMutableDonation) GetDonation(index uint32) MutableDonation { + return MutableDonation{proxy: a.proxy.Index(index)} } type MutableDonateWithFeedbackState struct { - id int32 + proxy wasmtypes.Proxy } func (s MutableDonateWithFeedbackState) AsImmutable() ImmutableDonateWithFeedbackState { @@ -63,14 +66,13 @@ func (s MutableDonateWithFeedbackState) AsImmutable() ImmutableDonateWithFeedbac } func (s MutableDonateWithFeedbackState) Log() ArrayOfMutableDonation { - arrID := wasmlib.GetObjectID(s.id, wasmlib.KeyID(StateLog), wasmlib.TYPE_ARRAY|wasmlib.TYPE_BYTES) - return ArrayOfMutableDonation{objID: arrID} + return ArrayOfMutableDonation{proxy: s.proxy.Root(StateLog)} } -func (s MutableDonateWithFeedbackState) MaxDonation() wasmlib.ScMutableInt64 { - return wasmlib.NewScMutableInt64(s.id, wasmlib.KeyID(StateMaxDonation)) +func (s MutableDonateWithFeedbackState) MaxDonation() wasmtypes.ScMutableUint64 { + return wasmtypes.NewScMutableUint64(s.proxy.Root(StateMaxDonation)) } -func (s MutableDonateWithFeedbackState) TotalDonation() wasmlib.ScMutableInt64 { - return wasmlib.NewScMutableInt64(s.id, wasmlib.KeyID(StateTotalDonation)) +func (s MutableDonateWithFeedbackState) TotalDonation() wasmtypes.ScMutableUint64 { + return wasmtypes.NewScMutableUint64(s.proxy.Root(StateTotalDonation)) } diff --git a/contracts/wasm/donatewithfeedback/go/donatewithfeedback/structs.go b/contracts/wasm/donatewithfeedback/go/donatewithfeedback/structs.go index 40d6b63f13..c52180a38f 100644 --- a/contracts/wasm/donatewithfeedback/go/donatewithfeedback/structs.go +++ b/contracts/wasm/donatewithfeedback/go/donatewithfeedback/structs.go @@ -7,68 +7,69 @@ package donatewithfeedback -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" +import ( + "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmcodec" + "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" +) type Donation struct { - Amount int64 // amount donated - Donator wasmlib.ScAgentID // who donated - Error string // error to be reported to donator if anything goes wrong - Feedback string // the feedback for the person donated to - Timestamp int64 // when the donation took place + Amount uint64 // amount donated + Donator wasmtypes.ScAgentID // who donated + Error string // error to be reported to donator if anything goes wrong + Feedback string // the feedback for the person donated to + Timestamp uint64 // when the donation took place } -func NewDonationFromBytes(bytes []byte) *Donation { - decode := wasmlib.NewBytesDecoder(bytes) +func NewDonationFromBytes(buf []byte) *Donation { + dec := wasmcodec.NewWasmDecoder(buf) data := &Donation{} - data.Amount = decode.Int64() - data.Donator = decode.AgentID() - data.Error = decode.String() - data.Feedback = decode.String() - data.Timestamp = decode.Int64() - decode.Close() + data.Amount = wasmtypes.DecodeUint64(dec) + data.Donator = wasmtypes.DecodeAgentID(dec) + data.Error = wasmtypes.DecodeString(dec) + data.Feedback = wasmtypes.DecodeString(dec) + data.Timestamp = wasmtypes.DecodeUint64(dec) + dec.Close() return data } func (o *Donation) Bytes() []byte { - return wasmlib.NewBytesEncoder(). - Int64(o.Amount). - AgentID(o.Donator). - String(o.Error). - String(o.Feedback). - Int64(o.Timestamp). - Data() + enc := wasmcodec.NewWasmEncoder() + wasmtypes.EncodeUint64(enc, o.Amount) + wasmtypes.EncodeAgentID(enc, o.Donator) + wasmtypes.EncodeString(enc, o.Error) + wasmtypes.EncodeString(enc, o.Feedback) + wasmtypes.EncodeUint64(enc, o.Timestamp) + return enc.Buf() } type ImmutableDonation struct { - objID int32 - keyID wasmlib.Key32 + proxy wasmtypes.Proxy } func (o ImmutableDonation) Exists() bool { - return wasmlib.Exists(o.objID, o.keyID, wasmlib.TYPE_BYTES) + return o.proxy.Exists() } func (o ImmutableDonation) Value() *Donation { - return NewDonationFromBytes(wasmlib.GetBytes(o.objID, o.keyID, wasmlib.TYPE_BYTES)) + return NewDonationFromBytes(o.proxy.Get()) } type MutableDonation struct { - objID int32 - keyID wasmlib.Key32 + proxy wasmtypes.Proxy } func (o MutableDonation) Delete() { - wasmlib.DelKey(o.objID, o.keyID, wasmlib.TYPE_BYTES) + o.proxy.Delete() } func (o MutableDonation) Exists() bool { - return wasmlib.Exists(o.objID, o.keyID, wasmlib.TYPE_BYTES) + return o.proxy.Exists() } func (o MutableDonation) SetValue(value *Donation) { - wasmlib.SetBytes(o.objID, o.keyID, wasmlib.TYPE_BYTES, value.Bytes()) + o.proxy.Set(value.Bytes()) } func (o MutableDonation) Value() *Donation { - return NewDonationFromBytes(wasmlib.GetBytes(o.objID, o.keyID, wasmlib.TYPE_BYTES)) + return NewDonationFromBytes(o.proxy.Get()) } diff --git a/contracts/wasm/donatewithfeedback/schema.yaml b/contracts/wasm/donatewithfeedback/schema.yaml index e15fea8721..50a2de738c 100644 --- a/contracts/wasm/donatewithfeedback/schema.yaml +++ b/contracts/wasm/donatewithfeedback/schema.yaml @@ -2,16 +2,16 @@ name: DonateWithFeedback description: "" structs: Donation: - amount: Int64 // amount donated + amount: Uint64 // amount donated donator: AgentID // who donated error: String // error to be reported to donator if anything goes wrong feedback: String // the feedback for the person donated to - timestamp: Int64 // when the donation took place + timestamp: Uint64 // when the donation took place typedefs: {} state: log: Donation[] - maxDonation: Int64 - totalDonation: Int64 + maxDonation: Uint64 + totalDonation: Uint64 funcs: donate: params: @@ -19,19 +19,19 @@ funcs: withdraw: access: creator // only SC creator can withdraw donated funds params: - amount: Int64? // amount to withdraw + amount: Uint64? // amount to withdraw views: donation: params: - nr: Int64 + nr: Uint32 results: - amount: Int64 // amount donated + amount: Uint64 // amount donated donator: AgentID // who donated error: String // error to be reported to donator if anything goes wrong feedback: String // the feedback for the person donated to - timestamp: Int64 // when the donation took place + timestamp: Uint64 // when the donation took place donationInfo: results: - count: Int64 - maxDonation: Int64 - totalDonation: Int64 + count: Uint32 + maxDonation: Uint64 + totalDonation: Uint64 diff --git a/contracts/wasm/donatewithfeedback/src/donatewithfeedback.rs b/contracts/wasm/donatewithfeedback/src/donatewithfeedback.rs index 66a15acc75..ca49e35551 100644 --- a/contracts/wasm/donatewithfeedback/src/donatewithfeedback.rs +++ b/contracts/wasm/donatewithfeedback/src/donatewithfeedback.rs @@ -48,7 +48,7 @@ pub fn func_withdraw(ctx: &ScFuncContext, f: &WithdrawContext) { } pub fn view_donation(_ctx: &ScViewContext, f: &DonationContext) { - let nr = (f.params.nr().value()) as i32; + let nr = f.params.nr().value(); let donation = f.state.log().get_donation(nr).value(); f.results.amount().set_value(donation.amount); f.results.donator().set_value(&donation.donator); @@ -60,5 +60,5 @@ pub fn view_donation(_ctx: &ScViewContext, f: &DonationContext) { pub fn view_donation_info(_ctx: &ScViewContext, f: &DonationInfoContext) { f.results.max_donation().set_value(f.state.max_donation().value()); f.results.total_donation().set_value(f.state.total_donation().value()); - f.results.count().set_value(f.state.log().length() as i64); + f.results.count().set_value(f.state.log().length()); } diff --git a/contracts/wasm/donatewithfeedback/src/params.rs b/contracts/wasm/donatewithfeedback/src/params.rs index 9352539ea7..83c963d1e7 100644 --- a/contracts/wasm/donatewithfeedback/src/params.rs +++ b/contracts/wasm/donatewithfeedback/src/params.rs @@ -43,8 +43,8 @@ pub struct ImmutableWithdrawParams { } impl ImmutableWithdrawParams { - pub fn amount(&self) -> ScImmutableInt64 { - ScImmutableInt64::new(self.id, PARAM_AMOUNT.get_key_id()) + pub fn amount(&self) -> ScImmutableUint64 { + ScImmutableUint64::new(self.id, PARAM_AMOUNT.get_key_id()) } } @@ -54,8 +54,8 @@ pub struct MutableWithdrawParams { } impl MutableWithdrawParams { - pub fn amount(&self) -> ScMutableInt64 { - ScMutableInt64::new(self.id, PARAM_AMOUNT.get_key_id()) + pub fn amount(&self) -> ScMutableUint64 { + ScMutableUint64::new(self.id, PARAM_AMOUNT.get_key_id()) } } @@ -65,8 +65,8 @@ pub struct ImmutableDonationParams { } impl ImmutableDonationParams { - pub fn nr(&self) -> ScImmutableInt64 { - ScImmutableInt64::new(self.id, PARAM_NR.get_key_id()) + pub fn nr(&self) -> ScImmutableUint32 { + ScImmutableUint32::new(self.id, PARAM_NR.get_key_id()) } } @@ -76,7 +76,7 @@ pub struct MutableDonationParams { } impl MutableDonationParams { - pub fn nr(&self) -> ScMutableInt64 { - ScMutableInt64::new(self.id, PARAM_NR.get_key_id()) + pub fn nr(&self) -> ScMutableUint32 { + ScMutableUint32::new(self.id, PARAM_NR.get_key_id()) } } diff --git a/contracts/wasm/donatewithfeedback/src/results.rs b/contracts/wasm/donatewithfeedback/src/results.rs index 22e641f04f..26e61646b0 100644 --- a/contracts/wasm/donatewithfeedback/src/results.rs +++ b/contracts/wasm/donatewithfeedback/src/results.rs @@ -21,8 +21,8 @@ pub struct ImmutableDonationResults { } impl ImmutableDonationResults { - pub fn amount(&self) -> ScImmutableInt64 { - ScImmutableInt64::new(self.id, RESULT_AMOUNT.get_key_id()) + pub fn amount(&self) -> ScImmutableUint64 { + ScImmutableUint64::new(self.id, RESULT_AMOUNT.get_key_id()) } pub fn donator(&self) -> ScImmutableAgentID { @@ -37,8 +37,8 @@ impl ImmutableDonationResults { ScImmutableString::new(self.id, RESULT_FEEDBACK.get_key_id()) } - pub fn timestamp(&self) -> ScImmutableInt64 { - ScImmutableInt64::new(self.id, RESULT_TIMESTAMP.get_key_id()) + pub fn timestamp(&self) -> ScImmutableUint64 { + ScImmutableUint64::new(self.id, RESULT_TIMESTAMP.get_key_id()) } } @@ -48,8 +48,8 @@ pub struct MutableDonationResults { } impl MutableDonationResults { - pub fn amount(&self) -> ScMutableInt64 { - ScMutableInt64::new(self.id, RESULT_AMOUNT.get_key_id()) + pub fn amount(&self) -> ScMutableUint64 { + ScMutableUint64::new(self.id, RESULT_AMOUNT.get_key_id()) } pub fn donator(&self) -> ScMutableAgentID { @@ -64,8 +64,8 @@ impl MutableDonationResults { ScMutableString::new(self.id, RESULT_FEEDBACK.get_key_id()) } - pub fn timestamp(&self) -> ScMutableInt64 { - ScMutableInt64::new(self.id, RESULT_TIMESTAMP.get_key_id()) + pub fn timestamp(&self) -> ScMutableUint64 { + ScMutableUint64::new(self.id, RESULT_TIMESTAMP.get_key_id()) } } @@ -75,16 +75,16 @@ pub struct ImmutableDonationInfoResults { } impl ImmutableDonationInfoResults { - pub fn count(&self) -> ScImmutableInt64 { - ScImmutableInt64::new(self.id, RESULT_COUNT.get_key_id()) + pub fn count(&self) -> ScImmutableUint32 { + ScImmutableUint32::new(self.id, RESULT_COUNT.get_key_id()) } - pub fn max_donation(&self) -> ScImmutableInt64 { - ScImmutableInt64::new(self.id, RESULT_MAX_DONATION.get_key_id()) + pub fn max_donation(&self) -> ScImmutableUint64 { + ScImmutableUint64::new(self.id, RESULT_MAX_DONATION.get_key_id()) } - pub fn total_donation(&self) -> ScImmutableInt64 { - ScImmutableInt64::new(self.id, RESULT_TOTAL_DONATION.get_key_id()) + pub fn total_donation(&self) -> ScImmutableUint64 { + ScImmutableUint64::new(self.id, RESULT_TOTAL_DONATION.get_key_id()) } } @@ -94,15 +94,15 @@ pub struct MutableDonationInfoResults { } impl MutableDonationInfoResults { - pub fn count(&self) -> ScMutableInt64 { - ScMutableInt64::new(self.id, RESULT_COUNT.get_key_id()) + pub fn count(&self) -> ScMutableUint32 { + ScMutableUint32::new(self.id, RESULT_COUNT.get_key_id()) } - pub fn max_donation(&self) -> ScMutableInt64 { - ScMutableInt64::new(self.id, RESULT_MAX_DONATION.get_key_id()) + pub fn max_donation(&self) -> ScMutableUint64 { + ScMutableUint64::new(self.id, RESULT_MAX_DONATION.get_key_id()) } - pub fn total_donation(&self) -> ScMutableInt64 { - ScMutableInt64::new(self.id, RESULT_TOTAL_DONATION.get_key_id()) + pub fn total_donation(&self) -> ScMutableUint64 { + ScMutableUint64::new(self.id, RESULT_TOTAL_DONATION.get_key_id()) } } diff --git a/contracts/wasm/donatewithfeedback/src/state.rs b/contracts/wasm/donatewithfeedback/src/state.rs index 5f8dc08729..bb871adbae 100644 --- a/contracts/wasm/donatewithfeedback/src/state.rs +++ b/contracts/wasm/donatewithfeedback/src/state.rs @@ -21,12 +21,12 @@ pub struct ArrayOfImmutableDonation { } impl ArrayOfImmutableDonation { - pub fn length(&self) -> i32 { + pub fn length(&self) -> u32 { get_length(self.obj_id) } - pub fn get_donation(&self, index: i32) -> ImmutableDonation { - ImmutableDonation { obj_id: self.obj_id, key_id: Key32(index) } + pub fn get_donation(&self, index: u32) -> ImmutableDonation { + ImmutableDonation { obj_id: self.obj_id, key_id: Key32(index as i32) } } } @@ -41,12 +41,12 @@ impl ImmutableDonateWithFeedbackState { ArrayOfImmutableDonation { obj_id: arr_id } } - pub fn max_donation(&self) -> ScImmutableInt64 { - ScImmutableInt64::new(self.id, STATE_MAX_DONATION.get_key_id()) + pub fn max_donation(&self) -> ScImmutableUint64 { + ScImmutableUint64::new(self.id, STATE_MAX_DONATION.get_key_id()) } - pub fn total_donation(&self) -> ScImmutableInt64 { - ScImmutableInt64::new(self.id, STATE_TOTAL_DONATION.get_key_id()) + pub fn total_donation(&self) -> ScImmutableUint64 { + ScImmutableUint64::new(self.id, STATE_TOTAL_DONATION.get_key_id()) } } @@ -60,12 +60,12 @@ impl ArrayOfMutableDonation { clear(self.obj_id); } - pub fn length(&self) -> i32 { + pub fn length(&self) -> u32 { get_length(self.obj_id) } - pub fn get_donation(&self, index: i32) -> MutableDonation { - MutableDonation { obj_id: self.obj_id, key_id: Key32(index) } + pub fn get_donation(&self, index: u32) -> MutableDonation { + MutableDonation { obj_id: self.obj_id, key_id: Key32(index as i32) } } } @@ -84,11 +84,11 @@ impl MutableDonateWithFeedbackState { ArrayOfMutableDonation { obj_id: arr_id } } - pub fn max_donation(&self) -> ScMutableInt64 { - ScMutableInt64::new(self.id, STATE_MAX_DONATION.get_key_id()) + pub fn max_donation(&self) -> ScMutableUint64 { + ScMutableUint64::new(self.id, STATE_MAX_DONATION.get_key_id()) } - pub fn total_donation(&self) -> ScMutableInt64 { - ScMutableInt64::new(self.id, STATE_TOTAL_DONATION.get_key_id()) + pub fn total_donation(&self) -> ScMutableUint64 { + ScMutableUint64::new(self.id, STATE_TOTAL_DONATION.get_key_id()) } } diff --git a/contracts/wasm/donatewithfeedback/src/structs.rs b/contracts/wasm/donatewithfeedback/src/structs.rs index b1ebbda1da..873f41a6ef 100644 --- a/contracts/wasm/donatewithfeedback/src/structs.rs +++ b/contracts/wasm/donatewithfeedback/src/structs.rs @@ -13,32 +13,32 @@ use wasmlib::host::*; #[derive(Clone)] pub struct Donation { - pub amount : i64, // amount donated + pub amount : u64, // amount donated pub donator : ScAgentID, // who donated pub error : String, // error to be reported to donator if anything goes wrong pub feedback : String, // the feedback for the person donated to - pub timestamp : i64, // when the donation took place + pub timestamp : u64, // when the donation took place } impl Donation { pub fn from_bytes(bytes: &[u8]) -> Donation { let mut decode = BytesDecoder::new(bytes); Donation { - amount : decode.int64(), + amount : decode.uint64(), donator : decode.agent_id(), error : decode.string(), feedback : decode.string(), - timestamp : decode.int64(), + timestamp : decode.uint64(), } } pub fn to_bytes(&self) -> Vec { let mut encode = BytesEncoder::new(); - encode.int64(self.amount); + encode.uint64(self.amount); encode.agent_id(&self.donator); encode.string(&self.error); encode.string(&self.feedback); - encode.int64(self.timestamp); + encode.uint64(self.timestamp); return encode.data(); } } diff --git a/contracts/wasm/donatewithfeedback/test/donatewithfeedback_bg.wasm b/contracts/wasm/donatewithfeedback/test/donatewithfeedback_bg.wasm index c7b96a05ff13d38c5dd7473156b63ff45b211281..a4f9ce75523457118aa888ab38920fa3f1cec26c 100644 GIT binary patch delta 7537 zcmai23v^XgdOrJ{b8l{PbCZ(?B;-N%y^xRx;StD#AS9cZ@FwAnAPDll!AK+^4#*8p z6&W7+<7)(rf+MctBA9eF?V!e4w522MLWQZdbVP@l+A%G3m3A!4k$(R<_lAo)on+m; z_rLeQ|NZa(y-!<*{x`4aUTwvuM}($nBA9%{tMXkT{u80)dT58XTyq9!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-(t5AZO#tb)3E%ZC2ny^lyLKs;6+2`S8y})k)Kz+4X-yLawC% diff --git a/contracts/wasm/donatewithfeedback/ts/donatewithfeedback/donatewithfeedback.ts b/contracts/wasm/donatewithfeedback/ts/donatewithfeedback/donatewithfeedback.ts index c15e3bda21..465d98f9fb 100644 --- a/contracts/wasm/donatewithfeedback/ts/donatewithfeedback/donatewithfeedback.ts +++ b/contracts/wasm/donatewithfeedback/ts/donatewithfeedback/donatewithfeedback.ts @@ -45,7 +45,7 @@ export function funcWithdraw(ctx: wasmlib.ScFuncContext, f: sc.WithdrawContext): } export function viewDonation(ctx: wasmlib.ScViewContext, f: sc.DonationContext): void { - let nr = (f.params.nr().value()) as i32; + let nr = f.params.nr().value(); let donation = f.state.log().getDonation(nr).value(); f.results.amount().setValue(donation.amount); f.results.donator().setValue(donation.donator); @@ -57,5 +57,5 @@ export function viewDonation(ctx: wasmlib.ScViewContext, f: sc.DonationContext): export function viewDonationInfo(ctx: wasmlib.ScViewContext, f: sc.DonationInfoContext): void { f.results.maxDonation().setValue(f.state.maxDonation().value()); f.results.totalDonation().setValue(f.state.totalDonation().value()); - f.results.count().setValue(f.state.log().length() as i64); + f.results.count().setValue(f.state.log().length()); } diff --git a/contracts/wasm/donatewithfeedback/ts/donatewithfeedback/params.ts b/contracts/wasm/donatewithfeedback/ts/donatewithfeedback/params.ts index 6e57022c41..d07a82a5a9 100644 --- a/contracts/wasm/donatewithfeedback/ts/donatewithfeedback/params.ts +++ b/contracts/wasm/donatewithfeedback/ts/donatewithfeedback/params.ts @@ -21,25 +21,25 @@ export class MutableDonateParams extends wasmlib.ScMapID { } export class ImmutableWithdrawParams extends wasmlib.ScMapID { - amount(): wasmlib.ScImmutableInt64 { - return new wasmlib.ScImmutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ParamAmount)); + amount(): wasmlib.ScImmutableUint64 { + return new wasmlib.ScImmutableUint64(this.mapID, wasmlib.Key32.fromString(sc.ParamAmount)); } } export class MutableWithdrawParams extends wasmlib.ScMapID { - amount(): wasmlib.ScMutableInt64 { - return new wasmlib.ScMutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ParamAmount)); + amount(): wasmlib.ScMutableUint64 { + return new wasmlib.ScMutableUint64(this.mapID, wasmlib.Key32.fromString(sc.ParamAmount)); } } export class ImmutableDonationParams extends wasmlib.ScMapID { - nr(): wasmlib.ScImmutableInt64 { - return new wasmlib.ScImmutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ParamNr)); + nr(): wasmlib.ScImmutableUint32 { + return new wasmlib.ScImmutableUint32(this.mapID, wasmlib.Key32.fromString(sc.ParamNr)); } } export class MutableDonationParams extends wasmlib.ScMapID { - nr(): wasmlib.ScMutableInt64 { - return new wasmlib.ScMutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ParamNr)); + nr(): wasmlib.ScMutableUint32 { + return new wasmlib.ScMutableUint32(this.mapID, wasmlib.Key32.fromString(sc.ParamNr)); } } diff --git a/contracts/wasm/donatewithfeedback/ts/donatewithfeedback/results.ts b/contracts/wasm/donatewithfeedback/ts/donatewithfeedback/results.ts index 308ef3d0b7..c2e188f273 100644 --- a/contracts/wasm/donatewithfeedback/ts/donatewithfeedback/results.ts +++ b/contracts/wasm/donatewithfeedback/ts/donatewithfeedback/results.ts @@ -9,8 +9,8 @@ import * as wasmlib from "wasmlib"; import * as sc from "./index"; export class ImmutableDonationResults extends wasmlib.ScMapID { - amount(): wasmlib.ScImmutableInt64 { - return new wasmlib.ScImmutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ResultAmount)); + amount(): wasmlib.ScImmutableUint64 { + return new wasmlib.ScImmutableUint64(this.mapID, wasmlib.Key32.fromString(sc.ResultAmount)); } donator(): wasmlib.ScImmutableAgentID { @@ -25,14 +25,14 @@ export class ImmutableDonationResults extends wasmlib.ScMapID { return new wasmlib.ScImmutableString(this.mapID, wasmlib.Key32.fromString(sc.ResultFeedback)); } - timestamp(): wasmlib.ScImmutableInt64 { - return new wasmlib.ScImmutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ResultTimestamp)); + timestamp(): wasmlib.ScImmutableUint64 { + return new wasmlib.ScImmutableUint64(this.mapID, wasmlib.Key32.fromString(sc.ResultTimestamp)); } } export class MutableDonationResults extends wasmlib.ScMapID { - amount(): wasmlib.ScMutableInt64 { - return new wasmlib.ScMutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ResultAmount)); + amount(): wasmlib.ScMutableUint64 { + return new wasmlib.ScMutableUint64(this.mapID, wasmlib.Key32.fromString(sc.ResultAmount)); } donator(): wasmlib.ScMutableAgentID { @@ -47,35 +47,35 @@ export class MutableDonationResults extends wasmlib.ScMapID { return new wasmlib.ScMutableString(this.mapID, wasmlib.Key32.fromString(sc.ResultFeedback)); } - timestamp(): wasmlib.ScMutableInt64 { - return new wasmlib.ScMutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ResultTimestamp)); + timestamp(): wasmlib.ScMutableUint64 { + return new wasmlib.ScMutableUint64(this.mapID, wasmlib.Key32.fromString(sc.ResultTimestamp)); } } export class ImmutableDonationInfoResults extends wasmlib.ScMapID { - count(): wasmlib.ScImmutableInt64 { - return new wasmlib.ScImmutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ResultCount)); + count(): wasmlib.ScImmutableUint32 { + return new wasmlib.ScImmutableUint32(this.mapID, wasmlib.Key32.fromString(sc.ResultCount)); } - maxDonation(): wasmlib.ScImmutableInt64 { - return new wasmlib.ScImmutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ResultMaxDonation)); + maxDonation(): wasmlib.ScImmutableUint64 { + return new wasmlib.ScImmutableUint64(this.mapID, wasmlib.Key32.fromString(sc.ResultMaxDonation)); } - totalDonation(): wasmlib.ScImmutableInt64 { - return new wasmlib.ScImmutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ResultTotalDonation)); + totalDonation(): wasmlib.ScImmutableUint64 { + return new wasmlib.ScImmutableUint64(this.mapID, wasmlib.Key32.fromString(sc.ResultTotalDonation)); } } export class MutableDonationInfoResults extends wasmlib.ScMapID { - count(): wasmlib.ScMutableInt64 { - return new wasmlib.ScMutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ResultCount)); + count(): wasmlib.ScMutableUint32 { + return new wasmlib.ScMutableUint32(this.mapID, wasmlib.Key32.fromString(sc.ResultCount)); } - maxDonation(): wasmlib.ScMutableInt64 { - return new wasmlib.ScMutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ResultMaxDonation)); + maxDonation(): wasmlib.ScMutableUint64 { + return new wasmlib.ScMutableUint64(this.mapID, wasmlib.Key32.fromString(sc.ResultMaxDonation)); } - totalDonation(): wasmlib.ScMutableInt64 { - return new wasmlib.ScMutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ResultTotalDonation)); + totalDonation(): wasmlib.ScMutableUint64 { + return new wasmlib.ScMutableUint64(this.mapID, wasmlib.Key32.fromString(sc.ResultTotalDonation)); } } diff --git a/contracts/wasm/donatewithfeedback/ts/donatewithfeedback/state.ts b/contracts/wasm/donatewithfeedback/ts/donatewithfeedback/state.ts index 50b1f395d0..7603bfb78d 100644 --- a/contracts/wasm/donatewithfeedback/ts/donatewithfeedback/state.ts +++ b/contracts/wasm/donatewithfeedback/ts/donatewithfeedback/state.ts @@ -15,12 +15,12 @@ export class ArrayOfImmutableDonation { this.objID = objID; } - length(): i32 { + length(): u32 { return wasmlib.getLength(this.objID); } - getDonation(index: i32): sc.ImmutableDonation { - return new sc.ImmutableDonation(this.objID, new wasmlib.Key32(index)); + getDonation(index: u32): sc.ImmutableDonation { + return new sc.ImmutableDonation(this.objID, new wasmlib.Key32(index as i32)); } } @@ -30,12 +30,12 @@ export class ImmutableDonateWithFeedbackState extends wasmlib.ScMapID { return new sc.ArrayOfImmutableDonation(arrID); } - maxDonation(): wasmlib.ScImmutableInt64 { - return new wasmlib.ScImmutableInt64(this.mapID, wasmlib.Key32.fromString(sc.StateMaxDonation)); + maxDonation(): wasmlib.ScImmutableUint64 { + return new wasmlib.ScImmutableUint64(this.mapID, wasmlib.Key32.fromString(sc.StateMaxDonation)); } - totalDonation(): wasmlib.ScImmutableInt64 { - return new wasmlib.ScImmutableInt64(this.mapID, wasmlib.Key32.fromString(sc.StateTotalDonation)); + totalDonation(): wasmlib.ScImmutableUint64 { + return new wasmlib.ScImmutableUint64(this.mapID, wasmlib.Key32.fromString(sc.StateTotalDonation)); } } @@ -50,12 +50,12 @@ export class ArrayOfMutableDonation { wasmlib.clear(this.objID); } - length(): i32 { + length(): u32 { return wasmlib.getLength(this.objID); } - getDonation(index: i32): sc.MutableDonation { - return new sc.MutableDonation(this.objID, new wasmlib.Key32(index)); + getDonation(index: u32): sc.MutableDonation { + return new sc.MutableDonation(this.objID, new wasmlib.Key32(index as i32)); } } @@ -71,11 +71,11 @@ export class MutableDonateWithFeedbackState extends wasmlib.ScMapID { return new sc.ArrayOfMutableDonation(arrID); } - maxDonation(): wasmlib.ScMutableInt64 { - return new wasmlib.ScMutableInt64(this.mapID, wasmlib.Key32.fromString(sc.StateMaxDonation)); + maxDonation(): wasmlib.ScMutableUint64 { + return new wasmlib.ScMutableUint64(this.mapID, wasmlib.Key32.fromString(sc.StateMaxDonation)); } - totalDonation(): wasmlib.ScMutableInt64 { - return new wasmlib.ScMutableInt64(this.mapID, wasmlib.Key32.fromString(sc.StateTotalDonation)); + totalDonation(): wasmlib.ScMutableUint64 { + return new wasmlib.ScMutableUint64(this.mapID, wasmlib.Key32.fromString(sc.StateTotalDonation)); } } diff --git a/contracts/wasm/donatewithfeedback/ts/donatewithfeedback/structs.ts b/contracts/wasm/donatewithfeedback/ts/donatewithfeedback/structs.ts index 91ecb4b41c..5f5e490869 100644 --- a/contracts/wasm/donatewithfeedback/ts/donatewithfeedback/structs.ts +++ b/contracts/wasm/donatewithfeedback/ts/donatewithfeedback/structs.ts @@ -8,31 +8,31 @@ import * as wasmlib from "wasmlib"; export class Donation { - amount : i64 = 0; // amount donated + amount : u64 = 0; // amount donated donator : wasmlib.ScAgentID = new wasmlib.ScAgentID(); // who donated error : string = ""; // error to be reported to donator if anything goes wrong feedback : string = ""; // the feedback for the person donated to - timestamp : i64 = 0; // when the donation took place + timestamp : u64 = 0; // when the donation took place static fromBytes(bytes: u8[]): Donation { let decode = new wasmlib.BytesDecoder(bytes); let data = new Donation(); - data.amount = decode.int64(); + data.amount = decode.uint64(); data.donator = decode.agentID(); data.error = decode.string(); data.feedback = decode.string(); - data.timestamp = decode.int64(); + data.timestamp = decode.uint64(); decode.close(); return data; } bytes(): u8[] { return new wasmlib.BytesEncoder(). - int64(this.amount). + uint64(this.amount). agentID(this.donator). string(this.error). string(this.feedback). - int64(this.timestamp). + uint64(this.timestamp). data(); } } diff --git a/contracts/wasm/erc20/go/erc20/consts.go b/contracts/wasm/erc20/go/erc20/consts.go index b958c9f6e4..6adda5ce04 100644 --- a/contracts/wasm/erc20/go/erc20/consts.go +++ b/contracts/wasm/erc20/go/erc20/consts.go @@ -7,12 +7,12 @@ package erc20 -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" +import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" const ( ScName = "erc20" ScDescription = "ERC-20 PoC for IOTA Smart Contracts" - HScName = wasmlib.ScHname(0x200e3733) + HScName = wasmtypes.ScHname(0x200e3733) ) const ( @@ -46,11 +46,11 @@ const ( ) const ( - HFuncApprove = wasmlib.ScHname(0xa0661268) - HFuncInit = wasmlib.ScHname(0x1f44d644) - HFuncTransfer = wasmlib.ScHname(0xa15da184) - HFuncTransferFrom = wasmlib.ScHname(0xd5e0a602) - HViewAllowance = wasmlib.ScHname(0x5e16006a) - HViewBalanceOf = wasmlib.ScHname(0x67ef8df4) - HViewTotalSupply = wasmlib.ScHname(0x9505e6ca) + HFuncApprove = wasmtypes.ScHname(0xa0661268) + HFuncInit = wasmtypes.ScHname(0x1f44d644) + HFuncTransfer = wasmtypes.ScHname(0xa15da184) + HFuncTransferFrom = wasmtypes.ScHname(0xd5e0a602) + HViewAllowance = wasmtypes.ScHname(0x5e16006a) + HViewBalanceOf = wasmtypes.ScHname(0x67ef8df4) + HViewTotalSupply = wasmtypes.ScHname(0x9505e6ca) ) diff --git a/contracts/wasm/erc20/go/erc20/contract.go b/contracts/wasm/erc20/go/erc20/contract.go index 7a085bfe48..cf2cdf1a0d 100644 --- a/contracts/wasm/erc20/go/erc20/contract.go +++ b/contracts/wasm/erc20/go/erc20/contract.go @@ -52,42 +52,44 @@ var ScFuncs Funcs func (sc Funcs) Approve(ctx wasmlib.ScFuncCallContext) *ApproveCall { f := &ApproveCall{Func: wasmlib.NewScFunc(ctx, HScName, HFuncApprove)} - f.Func.SetPtrs(&f.Params.id, nil) + f.Params.proxy = wasmlib.NewCallParamsProxy(&f.Func.ScView) return f } func (sc Funcs) Init(ctx wasmlib.ScFuncCallContext) *InitCall { - f := &InitCall{Func: wasmlib.NewScInitFunc(ctx, HScName, HFuncInit, keyMap[:], idxMap[:])} - f.Func.SetPtrs(&f.Params.id, nil) + f := &InitCall{Func: wasmlib.NewScInitFunc(ctx, HScName, HFuncInit)} + f.Params.proxy = wasmlib.NewCallParamsProxy(&f.Func.ScView) return f } func (sc Funcs) Transfer(ctx wasmlib.ScFuncCallContext) *TransferCall { f := &TransferCall{Func: wasmlib.NewScFunc(ctx, HScName, HFuncTransfer)} - f.Func.SetPtrs(&f.Params.id, nil) + f.Params.proxy = wasmlib.NewCallParamsProxy(&f.Func.ScView) return f } func (sc Funcs) TransferFrom(ctx wasmlib.ScFuncCallContext) *TransferFromCall { f := &TransferFromCall{Func: wasmlib.NewScFunc(ctx, HScName, HFuncTransferFrom)} - f.Func.SetPtrs(&f.Params.id, nil) + f.Params.proxy = wasmlib.NewCallParamsProxy(&f.Func.ScView) return f } func (sc Funcs) Allowance(ctx wasmlib.ScViewCallContext) *AllowanceCall { f := &AllowanceCall{Func: wasmlib.NewScView(ctx, HScName, HViewAllowance)} - f.Func.SetPtrs(&f.Params.id, &f.Results.id) + f.Params.proxy = wasmlib.NewCallParamsProxy(f.Func) + wasmlib.NewCallResultsProxy(f.Func, &f.Results.proxy) return f } func (sc Funcs) BalanceOf(ctx wasmlib.ScViewCallContext) *BalanceOfCall { f := &BalanceOfCall{Func: wasmlib.NewScView(ctx, HScName, HViewBalanceOf)} - f.Func.SetPtrs(&f.Params.id, &f.Results.id) + f.Params.proxy = wasmlib.NewCallParamsProxy(f.Func) + wasmlib.NewCallResultsProxy(f.Func, &f.Results.proxy) return f } func (sc Funcs) TotalSupply(ctx wasmlib.ScViewCallContext) *TotalSupplyCall { f := &TotalSupplyCall{Func: wasmlib.NewScView(ctx, HScName, HViewTotalSupply)} - f.Func.SetPtrs(nil, &f.Results.id) + wasmlib.NewCallResultsProxy(f.Func, &f.Results.proxy) return f } diff --git a/contracts/wasm/erc20/go/erc20/erc20.go b/contracts/wasm/erc20/go/erc20/erc20.go index fb6ef50a97..4cf93a97e4 100644 --- a/contracts/wasm/erc20/go/erc20/erc20.go +++ b/contracts/wasm/erc20/go/erc20/erc20.go @@ -17,11 +17,10 @@ import ( func funcApprove(ctx wasmlib.ScFuncContext, f *ApproveContext) { delegation := f.Params.Delegation().Value() amount := f.Params.Amount().Value() - ctx.Require(amount >= 0, "erc20.approve.fail: wrong 'amount' parameter") // all allowances are in the map under the name of he owner allowances := f.State.AllAllowances().GetAllowancesForAgent(ctx.Caller()) - allowances.GetInt64(delegation).SetValue(amount) + allowances.GetUint64(delegation).SetValue(amount) f.Events.Approval(amount, ctx.Caller(), delegation) } @@ -39,7 +38,7 @@ func funcInit(ctx wasmlib.ScFuncContext, f *InitContext) { // so, owner of the initial supply must be provided as a parameter PARAM_CREATOR to constructor (on_init) // assign the whole supply to creator creator := f.Params.Creator().Value() - f.State.Balances().GetInt64(creator).SetValue(supply) + f.State.Balances().GetUint64(creator).SetValue(supply) t := "erc20.on_init.success. Supply: " + f.Params.Supply().String() + ", creator:" + creator.String() @@ -53,17 +52,14 @@ func funcInit(ctx wasmlib.ScFuncContext, f *InitContext) { // - PARAM_AMOUNT: i64 func funcTransfer(ctx wasmlib.ScFuncContext, f *TransferContext) { amount := f.Params.Amount().Value() - ctx.Require(amount >= 0, "erc20.transfer.fail: wrong 'amount' parameter") balances := f.State.Balances() sourceAgent := ctx.Caller() - sourceBalance := balances.GetInt64(sourceAgent) + sourceBalance := balances.GetUint64(sourceAgent) ctx.Require(sourceBalance.Value() >= amount, "erc20.transfer.fail: not enough funds") targetAgent := f.Params.Account().Value() - targetBalance := balances.GetInt64(targetAgent) - result := targetBalance.Value() + amount - ctx.Require(result >= 0, "erc20.transfer.fail: overflow") + targetBalance := balances.GetUint64(targetAgent) sourceBalance.SetValue(sourceBalance.Value() - amount) targetBalance.SetValue(targetBalance.Value() + amount) @@ -81,22 +77,19 @@ func funcTransfer(ctx wasmlib.ScFuncContext, f *TransferContext) { func funcTransferFrom(ctx wasmlib.ScFuncContext, f *TransferFromContext) { // validate parameters amount := f.Params.Amount().Value() - ctx.Require(amount >= 0, "erc20.transfer_from.fail: wrong 'amount' parameter") // allowances are in the map under the name of the account sourceAgent := f.Params.Account().Value() allowances := f.State.AllAllowances().GetAllowancesForAgent(sourceAgent) - allowance := allowances.GetInt64(ctx.Caller()) + allowance := allowances.GetUint64(ctx.Caller()) ctx.Require(allowance.Value() >= amount, "erc20.transfer_from.fail: not enough allowance") balances := f.State.Balances() - sourceBalance := balances.GetInt64(sourceAgent) + sourceBalance := balances.GetUint64(sourceAgent) ctx.Require(sourceBalance.Value() >= amount, "erc20.transfer_from.fail: not enough funds") targetAgent := f.Params.Recipient().Value() - targetBalance := balances.GetInt64(targetAgent) - result := targetBalance.Value() + amount - ctx.Require(result >= 0, "erc20.transfer_from.fail: overflow") + targetBalance := balances.GetUint64(targetAgent) sourceBalance.SetValue(sourceBalance.Value() - amount) targetBalance.SetValue(targetBalance.Value() + amount) @@ -115,7 +108,7 @@ func funcTransferFrom(ctx wasmlib.ScFuncContext, f *TransferFromContext) { func viewAllowance(ctx wasmlib.ScViewContext, f *AllowanceContext) { // all allowances of the address 'owner' are stored in the map of the same name allowances := f.State.AllAllowances().GetAllowancesForAgent(f.Params.Account().Value()) - allow := allowances.GetInt64(f.Params.Delegation().Value()).Value() + allow := allowances.GetUint64(f.Params.Delegation().Value()).Value() f.Results.Amount().SetValue(allow) } @@ -124,7 +117,7 @@ func viewAllowance(ctx wasmlib.ScViewContext, f *AllowanceContext) { // - PARAM_ACCOUNT: agentID func viewBalanceOf(ctx wasmlib.ScViewContext, f *BalanceOfContext) { balances := f.State.Balances() - balance := balances.GetInt64(f.Params.Account().Value()) + balance := balances.GetUint64(f.Params.Account().Value()) f.Results.Amount().SetValue(balance.Value()) } diff --git a/contracts/wasm/erc20/go/erc20/events.go b/contracts/wasm/erc20/go/erc20/events.go index 7de35ec0a2..341776b4aa 100644 --- a/contracts/wasm/erc20/go/erc20/events.go +++ b/contracts/wasm/erc20/go/erc20/events.go @@ -8,21 +8,24 @@ //nolint:gocritic package erc20 -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" +import ( + "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" + "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" +) type Erc20Events struct{} -func (e Erc20Events) Approval(amount int64, owner wasmlib.ScAgentID, spender wasmlib.ScAgentID) { +func (e Erc20Events) Approval(amount uint64, owner wasmtypes.ScAgentID, spender wasmtypes.ScAgentID) { wasmlib.NewEventEncoder("erc20.approval"). - Int64(amount). + Uint64(amount). AgentID(owner). AgentID(spender). Emit() } -func (e Erc20Events) Transfer(amount int64, from wasmlib.ScAgentID, to wasmlib.ScAgentID) { +func (e Erc20Events) Transfer(amount uint64, from wasmtypes.ScAgentID, to wasmtypes.ScAgentID) { wasmlib.NewEventEncoder("erc20.transfer"). - Int64(amount). + Uint64(amount). AgentID(from). AgentID(to). Emit() diff --git a/contracts/wasm/erc20/go/erc20/keys.go b/contracts/wasm/erc20/go/erc20/keys.go index d23df24110..cd095ce0e0 100644 --- a/contracts/wasm/erc20/go/erc20/keys.go +++ b/contracts/wasm/erc20/go/erc20/keys.go @@ -6,39 +6,3 @@ // Change the json schema instead package erc20 - -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" - -const ( - IdxParamAccount = 0 - IdxParamAmount = 1 - IdxParamCreator = 2 - IdxParamDelegation = 3 - IdxParamRecipient = 4 - IdxParamSupply = 5 - - IdxResultAmount = 6 - IdxResultSupply = 7 - - IdxStateAllAllowances = 8 - IdxStateBalances = 9 - IdxStateSupply = 10 -) - -const keyMapLen = 11 - -var keyMap = [keyMapLen]wasmlib.Key{ - ParamAccount, - ParamAmount, - ParamCreator, - ParamDelegation, - ParamRecipient, - ParamSupply, - ResultAmount, - ResultSupply, - StateAllAllowances, - StateBalances, - StateSupply, -} - -var idxMap [keyMapLen]wasmlib.Key32 diff --git a/contracts/wasm/erc20/go/erc20/lib.go b/contracts/wasm/erc20/go/erc20/lib.go index 5970c162bd..bf42f90b78 100644 --- a/contracts/wasm/erc20/go/erc20/lib.go +++ b/contracts/wasm/erc20/go/erc20/lib.go @@ -18,10 +18,6 @@ func OnLoad() { exports.AddView(ViewAllowance, viewAllowanceThunk) exports.AddView(ViewBalanceOf, viewBalanceOfThunk) exports.AddView(ViewTotalSupply, viewTotalSupplyThunk) - - for i, key := range keyMap { - idxMap[i] = key.KeyID() - } } type ApproveContext struct { @@ -34,10 +30,10 @@ func funcApproveThunk(ctx wasmlib.ScFuncContext) { ctx.Log("erc20.funcApprove") f := &ApproveContext{ Params: ImmutableApproveParams{ - id: wasmlib.OBJ_ID_PARAMS, + proxy: wasmlib.NewParamsProxy(), }, State: MutableErc20State{ - id: wasmlib.OBJ_ID_STATE, + proxy: wasmlib.NewStateProxy(), }, } ctx.Require(f.Params.Amount().Exists(), "missing mandatory amount") @@ -56,10 +52,10 @@ func funcInitThunk(ctx wasmlib.ScFuncContext) { ctx.Log("erc20.funcInit") f := &InitContext{ Params: ImmutableInitParams{ - id: wasmlib.OBJ_ID_PARAMS, + proxy: wasmlib.NewParamsProxy(), }, State: MutableErc20State{ - id: wasmlib.OBJ_ID_STATE, + proxy: wasmlib.NewStateProxy(), }, } ctx.Require(f.Params.Creator().Exists(), "missing mandatory creator") @@ -78,10 +74,10 @@ func funcTransferThunk(ctx wasmlib.ScFuncContext) { ctx.Log("erc20.funcTransfer") f := &TransferContext{ Params: ImmutableTransferParams{ - id: wasmlib.OBJ_ID_PARAMS, + proxy: wasmlib.NewParamsProxy(), }, State: MutableErc20State{ - id: wasmlib.OBJ_ID_STATE, + proxy: wasmlib.NewStateProxy(), }, } ctx.Require(f.Params.Account().Exists(), "missing mandatory account") @@ -100,10 +96,10 @@ func funcTransferFromThunk(ctx wasmlib.ScFuncContext) { ctx.Log("erc20.funcTransferFrom") f := &TransferFromContext{ Params: ImmutableTransferFromParams{ - id: wasmlib.OBJ_ID_PARAMS, + proxy: wasmlib.NewParamsProxy(), }, State: MutableErc20State{ - id: wasmlib.OBJ_ID_STATE, + proxy: wasmlib.NewStateProxy(), }, } ctx.Require(f.Params.Account().Exists(), "missing mandatory account") @@ -123,13 +119,13 @@ func viewAllowanceThunk(ctx wasmlib.ScViewContext) { ctx.Log("erc20.viewAllowance") f := &AllowanceContext{ Params: ImmutableAllowanceParams{ - id: wasmlib.OBJ_ID_PARAMS, + proxy: wasmlib.NewParamsProxy(), }, Results: MutableAllowanceResults{ - id: wasmlib.OBJ_ID_RESULTS, + proxy: wasmlib.NewResultsProxy(), }, State: ImmutableErc20State{ - id: wasmlib.OBJ_ID_STATE, + proxy: wasmlib.NewStateProxy(), }, } ctx.Require(f.Params.Account().Exists(), "missing mandatory account") @@ -148,13 +144,13 @@ func viewBalanceOfThunk(ctx wasmlib.ScViewContext) { ctx.Log("erc20.viewBalanceOf") f := &BalanceOfContext{ Params: ImmutableBalanceOfParams{ - id: wasmlib.OBJ_ID_PARAMS, + proxy: wasmlib.NewParamsProxy(), }, Results: MutableBalanceOfResults{ - id: wasmlib.OBJ_ID_RESULTS, + proxy: wasmlib.NewResultsProxy(), }, State: ImmutableErc20State{ - id: wasmlib.OBJ_ID_STATE, + proxy: wasmlib.NewStateProxy(), }, } ctx.Require(f.Params.Account().Exists(), "missing mandatory account") @@ -171,10 +167,10 @@ func viewTotalSupplyThunk(ctx wasmlib.ScViewContext) { ctx.Log("erc20.viewTotalSupply") f := &TotalSupplyContext{ Results: MutableTotalSupplyResults{ - id: wasmlib.OBJ_ID_RESULTS, + proxy: wasmlib.NewResultsProxy(), }, State: ImmutableErc20State{ - id: wasmlib.OBJ_ID_STATE, + proxy: wasmlib.NewStateProxy(), }, } viewTotalSupply(ctx, f) diff --git a/contracts/wasm/erc20/go/erc20/params.go b/contracts/wasm/erc20/go/erc20/params.go index 2a1edfa0b7..44cb25afa6 100644 --- a/contracts/wasm/erc20/go/erc20/params.go +++ b/contracts/wasm/erc20/go/erc20/params.go @@ -7,148 +7,148 @@ package erc20 -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" +import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" type ImmutableApproveParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableApproveParams) Amount() wasmlib.ScImmutableInt64 { - return wasmlib.NewScImmutableInt64(s.id, wasmlib.KeyID(ParamAmount)) +func (s ImmutableApproveParams) Amount() wasmtypes.ScImmutableUint64 { + return wasmtypes.NewScImmutableUint64(s.proxy.Root(ParamAmount)) } -func (s ImmutableApproveParams) Delegation() wasmlib.ScImmutableAgentID { - return wasmlib.NewScImmutableAgentID(s.id, wasmlib.KeyID(ParamDelegation)) +func (s ImmutableApproveParams) Delegation() wasmtypes.ScImmutableAgentID { + return wasmtypes.NewScImmutableAgentID(s.proxy.Root(ParamDelegation)) } type MutableApproveParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableApproveParams) Amount() wasmlib.ScMutableInt64 { - return wasmlib.NewScMutableInt64(s.id, wasmlib.KeyID(ParamAmount)) +func (s MutableApproveParams) Amount() wasmtypes.ScMutableUint64 { + return wasmtypes.NewScMutableUint64(s.proxy.Root(ParamAmount)) } -func (s MutableApproveParams) Delegation() wasmlib.ScMutableAgentID { - return wasmlib.NewScMutableAgentID(s.id, wasmlib.KeyID(ParamDelegation)) +func (s MutableApproveParams) Delegation() wasmtypes.ScMutableAgentID { + return wasmtypes.NewScMutableAgentID(s.proxy.Root(ParamDelegation)) } type ImmutableInitParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableInitParams) Creator() wasmlib.ScImmutableAgentID { - return wasmlib.NewScImmutableAgentID(s.id, idxMap[IdxParamCreator]) +func (s ImmutableInitParams) Creator() wasmtypes.ScImmutableAgentID { + return wasmtypes.NewScImmutableAgentID(s.proxy.Root(ParamCreator)) } -func (s ImmutableInitParams) Supply() wasmlib.ScImmutableInt64 { - return wasmlib.NewScImmutableInt64(s.id, idxMap[IdxParamSupply]) +func (s ImmutableInitParams) Supply() wasmtypes.ScImmutableUint64 { + return wasmtypes.NewScImmutableUint64(s.proxy.Root(ParamSupply)) } type MutableInitParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableInitParams) Creator() wasmlib.ScMutableAgentID { - return wasmlib.NewScMutableAgentID(s.id, idxMap[IdxParamCreator]) +func (s MutableInitParams) Creator() wasmtypes.ScMutableAgentID { + return wasmtypes.NewScMutableAgentID(s.proxy.Root(ParamCreator)) } -func (s MutableInitParams) Supply() wasmlib.ScMutableInt64 { - return wasmlib.NewScMutableInt64(s.id, idxMap[IdxParamSupply]) +func (s MutableInitParams) Supply() wasmtypes.ScMutableUint64 { + return wasmtypes.NewScMutableUint64(s.proxy.Root(ParamSupply)) } type ImmutableTransferParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableTransferParams) Account() wasmlib.ScImmutableAgentID { - return wasmlib.NewScImmutableAgentID(s.id, wasmlib.KeyID(ParamAccount)) +func (s ImmutableTransferParams) Account() wasmtypes.ScImmutableAgentID { + return wasmtypes.NewScImmutableAgentID(s.proxy.Root(ParamAccount)) } -func (s ImmutableTransferParams) Amount() wasmlib.ScImmutableInt64 { - return wasmlib.NewScImmutableInt64(s.id, wasmlib.KeyID(ParamAmount)) +func (s ImmutableTransferParams) Amount() wasmtypes.ScImmutableUint64 { + return wasmtypes.NewScImmutableUint64(s.proxy.Root(ParamAmount)) } type MutableTransferParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableTransferParams) Account() wasmlib.ScMutableAgentID { - return wasmlib.NewScMutableAgentID(s.id, wasmlib.KeyID(ParamAccount)) +func (s MutableTransferParams) Account() wasmtypes.ScMutableAgentID { + return wasmtypes.NewScMutableAgentID(s.proxy.Root(ParamAccount)) } -func (s MutableTransferParams) Amount() wasmlib.ScMutableInt64 { - return wasmlib.NewScMutableInt64(s.id, wasmlib.KeyID(ParamAmount)) +func (s MutableTransferParams) Amount() wasmtypes.ScMutableUint64 { + return wasmtypes.NewScMutableUint64(s.proxy.Root(ParamAmount)) } type ImmutableTransferFromParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableTransferFromParams) Account() wasmlib.ScImmutableAgentID { - return wasmlib.NewScImmutableAgentID(s.id, wasmlib.KeyID(ParamAccount)) +func (s ImmutableTransferFromParams) Account() wasmtypes.ScImmutableAgentID { + return wasmtypes.NewScImmutableAgentID(s.proxy.Root(ParamAccount)) } -func (s ImmutableTransferFromParams) Amount() wasmlib.ScImmutableInt64 { - return wasmlib.NewScImmutableInt64(s.id, wasmlib.KeyID(ParamAmount)) +func (s ImmutableTransferFromParams) Amount() wasmtypes.ScImmutableUint64 { + return wasmtypes.NewScImmutableUint64(s.proxy.Root(ParamAmount)) } -func (s ImmutableTransferFromParams) Recipient() wasmlib.ScImmutableAgentID { - return wasmlib.NewScImmutableAgentID(s.id, wasmlib.KeyID(ParamRecipient)) +func (s ImmutableTransferFromParams) Recipient() wasmtypes.ScImmutableAgentID { + return wasmtypes.NewScImmutableAgentID(s.proxy.Root(ParamRecipient)) } type MutableTransferFromParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableTransferFromParams) Account() wasmlib.ScMutableAgentID { - return wasmlib.NewScMutableAgentID(s.id, wasmlib.KeyID(ParamAccount)) +func (s MutableTransferFromParams) Account() wasmtypes.ScMutableAgentID { + return wasmtypes.NewScMutableAgentID(s.proxy.Root(ParamAccount)) } -func (s MutableTransferFromParams) Amount() wasmlib.ScMutableInt64 { - return wasmlib.NewScMutableInt64(s.id, wasmlib.KeyID(ParamAmount)) +func (s MutableTransferFromParams) Amount() wasmtypes.ScMutableUint64 { + return wasmtypes.NewScMutableUint64(s.proxy.Root(ParamAmount)) } -func (s MutableTransferFromParams) Recipient() wasmlib.ScMutableAgentID { - return wasmlib.NewScMutableAgentID(s.id, wasmlib.KeyID(ParamRecipient)) +func (s MutableTransferFromParams) Recipient() wasmtypes.ScMutableAgentID { + return wasmtypes.NewScMutableAgentID(s.proxy.Root(ParamRecipient)) } type ImmutableAllowanceParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableAllowanceParams) Account() wasmlib.ScImmutableAgentID { - return wasmlib.NewScImmutableAgentID(s.id, wasmlib.KeyID(ParamAccount)) +func (s ImmutableAllowanceParams) Account() wasmtypes.ScImmutableAgentID { + return wasmtypes.NewScImmutableAgentID(s.proxy.Root(ParamAccount)) } -func (s ImmutableAllowanceParams) Delegation() wasmlib.ScImmutableAgentID { - return wasmlib.NewScImmutableAgentID(s.id, wasmlib.KeyID(ParamDelegation)) +func (s ImmutableAllowanceParams) Delegation() wasmtypes.ScImmutableAgentID { + return wasmtypes.NewScImmutableAgentID(s.proxy.Root(ParamDelegation)) } type MutableAllowanceParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableAllowanceParams) Account() wasmlib.ScMutableAgentID { - return wasmlib.NewScMutableAgentID(s.id, wasmlib.KeyID(ParamAccount)) +func (s MutableAllowanceParams) Account() wasmtypes.ScMutableAgentID { + return wasmtypes.NewScMutableAgentID(s.proxy.Root(ParamAccount)) } -func (s MutableAllowanceParams) Delegation() wasmlib.ScMutableAgentID { - return wasmlib.NewScMutableAgentID(s.id, wasmlib.KeyID(ParamDelegation)) +func (s MutableAllowanceParams) Delegation() wasmtypes.ScMutableAgentID { + return wasmtypes.NewScMutableAgentID(s.proxy.Root(ParamDelegation)) } type ImmutableBalanceOfParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableBalanceOfParams) Account() wasmlib.ScImmutableAgentID { - return wasmlib.NewScImmutableAgentID(s.id, wasmlib.KeyID(ParamAccount)) +func (s ImmutableBalanceOfParams) Account() wasmtypes.ScImmutableAgentID { + return wasmtypes.NewScImmutableAgentID(s.proxy.Root(ParamAccount)) } type MutableBalanceOfParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableBalanceOfParams) Account() wasmlib.ScMutableAgentID { - return wasmlib.NewScMutableAgentID(s.id, wasmlib.KeyID(ParamAccount)) +func (s MutableBalanceOfParams) Account() wasmtypes.ScMutableAgentID { + return wasmtypes.NewScMutableAgentID(s.proxy.Root(ParamAccount)) } diff --git a/contracts/wasm/erc20/go/erc20/results.go b/contracts/wasm/erc20/go/erc20/results.go index 88b9fb4763..1ca736ab22 100644 --- a/contracts/wasm/erc20/go/erc20/results.go +++ b/contracts/wasm/erc20/go/erc20/results.go @@ -7,52 +7,52 @@ package erc20 -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" +import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" type ImmutableAllowanceResults struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableAllowanceResults) Amount() wasmlib.ScImmutableInt64 { - return wasmlib.NewScImmutableInt64(s.id, wasmlib.KeyID(ResultAmount)) +func (s ImmutableAllowanceResults) Amount() wasmtypes.ScImmutableUint64 { + return wasmtypes.NewScImmutableUint64(s.proxy.Root(ResultAmount)) } type MutableAllowanceResults struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableAllowanceResults) Amount() wasmlib.ScMutableInt64 { - return wasmlib.NewScMutableInt64(s.id, wasmlib.KeyID(ResultAmount)) +func (s MutableAllowanceResults) Amount() wasmtypes.ScMutableUint64 { + return wasmtypes.NewScMutableUint64(s.proxy.Root(ResultAmount)) } type ImmutableBalanceOfResults struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableBalanceOfResults) Amount() wasmlib.ScImmutableInt64 { - return wasmlib.NewScImmutableInt64(s.id, wasmlib.KeyID(ResultAmount)) +func (s ImmutableBalanceOfResults) Amount() wasmtypes.ScImmutableUint64 { + return wasmtypes.NewScImmutableUint64(s.proxy.Root(ResultAmount)) } type MutableBalanceOfResults struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableBalanceOfResults) Amount() wasmlib.ScMutableInt64 { - return wasmlib.NewScMutableInt64(s.id, wasmlib.KeyID(ResultAmount)) +func (s MutableBalanceOfResults) Amount() wasmtypes.ScMutableUint64 { + return wasmtypes.NewScMutableUint64(s.proxy.Root(ResultAmount)) } type ImmutableTotalSupplyResults struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableTotalSupplyResults) Supply() wasmlib.ScImmutableInt64 { - return wasmlib.NewScImmutableInt64(s.id, wasmlib.KeyID(ResultSupply)) +func (s ImmutableTotalSupplyResults) Supply() wasmtypes.ScImmutableUint64 { + return wasmtypes.NewScImmutableUint64(s.proxy.Root(ResultSupply)) } type MutableTotalSupplyResults struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableTotalSupplyResults) Supply() wasmlib.ScMutableInt64 { - return wasmlib.NewScMutableInt64(s.id, wasmlib.KeyID(ResultSupply)) +func (s MutableTotalSupplyResults) Supply() wasmtypes.ScMutableUint64 { + return wasmtypes.NewScMutableUint64(s.proxy.Root(ResultSupply)) } diff --git a/contracts/wasm/erc20/go/erc20/state.go b/contracts/wasm/erc20/go/erc20/state.go index 9d33d8ba92..cd70d0c367 100644 --- a/contracts/wasm/erc20/go/erc20/state.go +++ b/contracts/wasm/erc20/go/erc20/state.go @@ -7,50 +7,46 @@ package erc20 -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" +import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" type MapAgentIDToImmutableAllowancesForAgent struct { - objID int32 + proxy wasmtypes.Proxy } -func (m MapAgentIDToImmutableAllowancesForAgent) GetAllowancesForAgent(key wasmlib.ScAgentID) ImmutableAllowancesForAgent { - subID := wasmlib.GetObjectID(m.objID, key.KeyID(), wasmlib.TYPE_MAP) - return ImmutableAllowancesForAgent{objID: subID} +func (m MapAgentIDToImmutableAllowancesForAgent) GetAllowancesForAgent(key wasmtypes.ScAgentID) ImmutableAllowancesForAgent { + return ImmutableAllowancesForAgent{proxy: m.proxy.Key(key.Bytes())} } type ImmutableErc20State struct { - id int32 + proxy wasmtypes.Proxy } func (s ImmutableErc20State) AllAllowances() MapAgentIDToImmutableAllowancesForAgent { - mapID := wasmlib.GetObjectID(s.id, wasmlib.KeyID(StateAllAllowances), wasmlib.TYPE_MAP) - return MapAgentIDToImmutableAllowancesForAgent{objID: mapID} + return MapAgentIDToImmutableAllowancesForAgent{proxy: s.proxy.Root(StateAllAllowances)} } -func (s ImmutableErc20State) Balances() MapAgentIDToImmutableInt64 { - mapID := wasmlib.GetObjectID(s.id, wasmlib.KeyID(StateBalances), wasmlib.TYPE_MAP) - return MapAgentIDToImmutableInt64{objID: mapID} +func (s ImmutableErc20State) Balances() MapAgentIDToImmutableUint64 { + return MapAgentIDToImmutableUint64{proxy: s.proxy.Root(StateBalances)} } -func (s ImmutableErc20State) Supply() wasmlib.ScImmutableInt64 { - return wasmlib.NewScImmutableInt64(s.id, wasmlib.KeyID(StateSupply)) +func (s ImmutableErc20State) Supply() wasmtypes.ScImmutableUint64 { + return wasmtypes.NewScImmutableUint64(s.proxy.Root(StateSupply)) } type MapAgentIDToMutableAllowancesForAgent struct { - objID int32 + proxy wasmtypes.Proxy } func (m MapAgentIDToMutableAllowancesForAgent) Clear() { - wasmlib.Clear(m.objID) + m.proxy.ClearMap() } -func (m MapAgentIDToMutableAllowancesForAgent) GetAllowancesForAgent(key wasmlib.ScAgentID) MutableAllowancesForAgent { - subID := wasmlib.GetObjectID(m.objID, key.KeyID(), wasmlib.TYPE_MAP) - return MutableAllowancesForAgent{objID: subID} +func (m MapAgentIDToMutableAllowancesForAgent) GetAllowancesForAgent(key wasmtypes.ScAgentID) MutableAllowancesForAgent { + return MutableAllowancesForAgent{proxy: m.proxy.Key(key.Bytes())} } type MutableErc20State struct { - id int32 + proxy wasmtypes.Proxy } func (s MutableErc20State) AsImmutable() ImmutableErc20State { @@ -58,15 +54,13 @@ func (s MutableErc20State) AsImmutable() ImmutableErc20State { } func (s MutableErc20State) AllAllowances() MapAgentIDToMutableAllowancesForAgent { - mapID := wasmlib.GetObjectID(s.id, wasmlib.KeyID(StateAllAllowances), wasmlib.TYPE_MAP) - return MapAgentIDToMutableAllowancesForAgent{objID: mapID} + return MapAgentIDToMutableAllowancesForAgent{proxy: s.proxy.Root(StateAllAllowances)} } -func (s MutableErc20State) Balances() MapAgentIDToMutableInt64 { - mapID := wasmlib.GetObjectID(s.id, wasmlib.KeyID(StateBalances), wasmlib.TYPE_MAP) - return MapAgentIDToMutableInt64{objID: mapID} +func (s MutableErc20State) Balances() MapAgentIDToMutableUint64 { + return MapAgentIDToMutableUint64{proxy: s.proxy.Root(StateBalances)} } -func (s MutableErc20State) Supply() wasmlib.ScMutableInt64 { - return wasmlib.NewScMutableInt64(s.id, wasmlib.KeyID(StateSupply)) +func (s MutableErc20State) Supply() wasmtypes.ScMutableUint64 { + return wasmtypes.NewScMutableUint64(s.proxy.Root(StateSupply)) } diff --git a/contracts/wasm/erc20/go/erc20/typedefs.go b/contracts/wasm/erc20/go/erc20/typedefs.go index bdbfe132a8..6d0bc76dd8 100644 --- a/contracts/wasm/erc20/go/erc20/typedefs.go +++ b/contracts/wasm/erc20/go/erc20/typedefs.go @@ -7,28 +7,28 @@ package erc20 -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" +import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" -type MapAgentIDToImmutableInt64 struct { - objID int32 +type MapAgentIDToImmutableUint64 struct { + proxy wasmtypes.Proxy } -func (m MapAgentIDToImmutableInt64) GetInt64(key wasmlib.ScAgentID) wasmlib.ScImmutableInt64 { - return wasmlib.NewScImmutableInt64(m.objID, key.KeyID()) +func (m MapAgentIDToImmutableUint64) GetUint64(key wasmtypes.ScAgentID) wasmtypes.ScImmutableUint64 { + return wasmtypes.NewScImmutableUint64(m.proxy.Key(key.Bytes())) } -type ImmutableAllowancesForAgent = MapAgentIDToImmutableInt64 +type ImmutableAllowancesForAgent = MapAgentIDToImmutableUint64 -type MapAgentIDToMutableInt64 struct { - objID int32 +type MapAgentIDToMutableUint64 struct { + proxy wasmtypes.Proxy } -func (m MapAgentIDToMutableInt64) Clear() { - wasmlib.Clear(m.objID) +func (m MapAgentIDToMutableUint64) Clear() { + m.proxy.ClearMap() } -func (m MapAgentIDToMutableInt64) GetInt64(key wasmlib.ScAgentID) wasmlib.ScMutableInt64 { - return wasmlib.NewScMutableInt64(m.objID, key.KeyID()) +func (m MapAgentIDToMutableUint64) GetUint64(key wasmtypes.ScAgentID) wasmtypes.ScMutableUint64 { + return wasmtypes.NewScMutableUint64(m.proxy.Key(key.Bytes())) } -type MutableAllowancesForAgent = MapAgentIDToMutableInt64 +type MutableAllowancesForAgent = MapAgentIDToMutableUint64 diff --git a/contracts/wasm/erc20/schema.yaml b/contracts/wasm/erc20/schema.yaml index dc54a60a38..d0ad7cbdb3 100644 --- a/contracts/wasm/erc20/schema.yaml +++ b/contracts/wasm/erc20/schema.yaml @@ -2,37 +2,37 @@ name: Erc20 description: ERC-20 PoC for IOTA Smart Contracts events: approval: - amount: Int64 + amount: Uint64 owner: AgentID spender: AgentID transfer: - amount: Int64 + amount: Uint64 from: AgentID to: AgentID structs: {} typedefs: - AllowancesForAgent: map[AgentID]Int64 + AllowancesForAgent: map[AgentID]Uint64 state: allAllowances=a: map[AgentID]AllowancesForAgent - balances=b: map[AgentID]Int64 // balances per account - supply=s: Int64 // total supply of the token + balances=b: map[AgentID]Uint64 // balances per account + supply=s: Uint64 // total supply of the token funcs: approve: params: - amount=am: Int64 // allowance value for delegated account + amount=am: Uint64 // allowance value for delegated account delegation=d: AgentID // delegated account init: params: creator=c: AgentID // creator/owner of the initial supply - supply=s: Int64 // initial token supply + supply=s: Uint64 // initial token supply transfer: params: account=ac: AgentID // target account - amount=am: Int64 // amount of tokens to transfer + amount=am: Uint64 // amount of tokens to transfer transferFrom: params: account=ac: AgentID // sender account - amount=am: Int64 // amount of tokens to transfer + amount=am: Uint64 // amount of tokens to transfer recipient=r: AgentID // recipient account views: allowance: @@ -40,12 +40,12 @@ views: account=ac: AgentID // sender account delegation=d: AgentID // delegated account results: - amount=am: Int64 + amount=am: Uint64 balanceOf: params: account=ac: AgentID // sender account results: - amount=am: Int64 + amount=am: Uint64 totalSupply: results: - supply=s: Int64 + supply=s: Uint64 diff --git a/contracts/wasm/erc20/src/erc20.rs b/contracts/wasm/erc20/src/erc20.rs index f056e80706..958919f791 100644 --- a/contracts/wasm/erc20/src/erc20.rs +++ b/contracts/wasm/erc20/src/erc20.rs @@ -11,15 +11,14 @@ use crate::*; // Sets the allowance value for delegated account // inputs: // - PARAM_DELEGATION: agentID -// - PARAM_AMOUNT: i64 +// - PARAM_AMOUNT: u64 pub fn func_approve(ctx: &ScFuncContext, f: &ApproveContext) { let delegation = f.params.delegation().value(); let amount = f.params.amount().value(); - ctx.require(amount >= 0, "erc20.approve.fail: wrong 'amount' parameter"); // all allowances are in the map under the name of he owner let allowances = f.state.all_allowances().get_allowances_for_agent(&ctx.caller()); - allowances.get_int64(&delegation).set_value(amount); + allowances.get_uint64(&delegation).set_value(amount); f.events.approval(amount, &ctx.caller(), &delegation); } @@ -37,7 +36,7 @@ pub fn func_init(ctx: &ScFuncContext, f: &InitContext) { // so, owner of the initial supply must be provided as a parameter PARAM_CREATOR to constructor (on_init) // assign the whole supply to creator let creator = f.params.creator().value(); - f.state.balances().get_int64(&creator).set_value(supply); + f.state.balances().get_uint64(&creator).set_value(supply); let t = "erc20.on_init.success. Supply: ".to_string() + &supply.to_string() + &", creator:".to_string() + &creator.to_string(); @@ -48,21 +47,17 @@ pub fn func_init(ctx: &ScFuncContext, f: &InitContext) { // This function emits the Transfer event. // Input: // - PARAM_ACCOUNT: agentID -// - PARAM_AMOUNT: i64 +// - PARAM_AMOUNT: u64 pub fn func_transfer(ctx: &ScFuncContext, f: &TransferContext) { let amount = f.params.amount().value(); - ctx.require(amount >= 0, "erc20.transfer.fail: wrong 'amount' parameter"); let balances = f.state.balances(); let source_agent = ctx.caller(); - let source_balance = balances.get_int64(&source_agent); + let source_balance = balances.get_uint64(&source_agent); ctx.require(source_balance.value() >= amount, "erc20.transfer.fail: not enough funds"); let target_agent = f.params.account().value(); - let target_balance = balances.get_int64(&target_agent); - let result = target_balance.value() + amount; - ctx.require(result >= 0, "erc20.transfer.fail: overflow"); - + let target_balance = balances.get_uint64(&target_agent); source_balance.set_value(source_balance.value() - amount); target_balance.set_value(target_balance.value() + amount); @@ -75,26 +70,23 @@ pub fn func_transfer(ctx: &ScFuncContext, f: &TransferContext) { // Input: // - PARAM_ACCOUNT: agentID the spender // - PARAM_RECIPIENT: agentID the target -// - PARAM_AMOUNT: i64 +// - PARAM_AMOUNT: u64 pub fn func_transfer_from(ctx: &ScFuncContext, f: &TransferFromContext) { // validate parameters let amount = f.params.amount().value(); - ctx.require(amount >= 0, "erc20.transfer_from.fail: wrong 'amount' parameter"); // allowances are in the map under the name of the account let source_agent = f.params.account().value(); let allowances = f.state.all_allowances().get_allowances_for_agent(&source_agent); - let allowance = allowances.get_int64(&ctx.caller()); + let allowance = allowances.get_uint64(&ctx.caller()); ctx.require(allowance.value() >= amount, "erc20.transfer_from.fail: not enough allowance"); let balances = f.state.balances(); - let source_balance = balances.get_int64(&source_agent); + let source_balance = balances.get_uint64(&source_agent); ctx.require(source_balance.value() >= amount, "erc20.transfer_from.fail: not enough funds"); let target_agent = f.params.recipient().value(); - let target_balance = balances.get_int64(&target_agent); - let result = target_balance.value() + amount; - ctx.require(result >= 0, "erc20.transfer_from.fail: overflow"); + let target_balance = balances.get_uint64(&target_agent); source_balance.set_value(source_balance.value() - amount); target_balance.set_value(target_balance.value() + amount); @@ -109,11 +101,11 @@ pub fn func_transfer_from(ctx: &ScFuncContext, f: &TransferFromContext) { // - PARAM_ACCOUNT: agentID // - PARAM_DELEGATION: agentID // Output: -// - PARAM_AMOUNT: i64 +// - PARAM_AMOUNT: u64 pub fn view_allowance(_ctx: &ScViewContext, f: &AllowanceContext) { // all allowances of the address 'owner' are stored in the map of the same name let allowances = f.state.all_allowances().get_allowances_for_agent(&f.params.account().value()); - let allow = allowances.get_int64(&f.params.delegation().value()).value(); + let allow = allowances.get_uint64(&f.params.delegation().value()).value(); f.results.amount().set_value(allow); } @@ -122,13 +114,13 @@ pub fn view_allowance(_ctx: &ScViewContext, f: &AllowanceContext) { // - PARAM_ACCOUNT: agentID pub fn view_balance_of(_ctx: &ScViewContext, f: &BalanceOfContext) { let balances = f.state.balances(); - let balance = balances.get_int64(&f.params.account().value()); + let balance = balances.get_uint64(&f.params.account().value()); f.results.amount().set_value(balance.value()); } // the view returns total supply set when creating the contract (a constant). // Output: -// - PARAM_SUPPLY: i64 +// - PARAM_SUPPLY: u64 pub fn view_total_supply(_ctx: &ScViewContext, f: &TotalSupplyContext) { f.results.supply().set_value(f.state.supply().value()); } diff --git a/contracts/wasm/erc20/src/events.rs b/contracts/wasm/erc20/src/events.rs index 74bf775813..125ae3544a 100644 --- a/contracts/wasm/erc20/src/events.rs +++ b/contracts/wasm/erc20/src/events.rs @@ -14,17 +14,17 @@ pub struct Erc20Events { impl Erc20Events { - pub fn approval(&self, amount: i64, owner: &ScAgentID, spender: &ScAgentID) { + pub fn approval(&self, amount: u64, owner: &ScAgentID, spender: &ScAgentID) { let mut encoder = EventEncoder::new("erc20.approval"); - encoder.int64(amount); + encoder.uint64(amount); encoder.agent_id(&owner); encoder.agent_id(&spender); encoder.emit(); } - pub fn transfer(&self, amount: i64, from: &ScAgentID, to: &ScAgentID) { + pub fn transfer(&self, amount: u64, from: &ScAgentID, to: &ScAgentID) { let mut encoder = EventEncoder::new("erc20.transfer"); - encoder.int64(amount); + encoder.uint64(amount); encoder.agent_id(&from); encoder.agent_id(&to); encoder.emit(); diff --git a/contracts/wasm/erc20/src/params.rs b/contracts/wasm/erc20/src/params.rs index a491640560..2af088ec14 100644 --- a/contracts/wasm/erc20/src/params.rs +++ b/contracts/wasm/erc20/src/params.rs @@ -21,8 +21,8 @@ pub struct ImmutableApproveParams { } impl ImmutableApproveParams { - pub fn amount(&self) -> ScImmutableInt64 { - ScImmutableInt64::new(self.id, PARAM_AMOUNT.get_key_id()) + pub fn amount(&self) -> ScImmutableUint64 { + ScImmutableUint64::new(self.id, PARAM_AMOUNT.get_key_id()) } pub fn delegation(&self) -> ScImmutableAgentID { @@ -36,8 +36,8 @@ pub struct MutableApproveParams { } impl MutableApproveParams { - pub fn amount(&self) -> ScMutableInt64 { - ScMutableInt64::new(self.id, PARAM_AMOUNT.get_key_id()) + pub fn amount(&self) -> ScMutableUint64 { + ScMutableUint64::new(self.id, PARAM_AMOUNT.get_key_id()) } pub fn delegation(&self) -> ScMutableAgentID { @@ -55,8 +55,8 @@ impl ImmutableInitParams { ScImmutableAgentID::new(self.id, idx_map(IDX_PARAM_CREATOR)) } - pub fn supply(&self) -> ScImmutableInt64 { - ScImmutableInt64::new(self.id, idx_map(IDX_PARAM_SUPPLY)) + pub fn supply(&self) -> ScImmutableUint64 { + ScImmutableUint64::new(self.id, idx_map(IDX_PARAM_SUPPLY)) } } @@ -70,8 +70,8 @@ impl MutableInitParams { ScMutableAgentID::new(self.id, idx_map(IDX_PARAM_CREATOR)) } - pub fn supply(&self) -> ScMutableInt64 { - ScMutableInt64::new(self.id, idx_map(IDX_PARAM_SUPPLY)) + pub fn supply(&self) -> ScMutableUint64 { + ScMutableUint64::new(self.id, idx_map(IDX_PARAM_SUPPLY)) } } @@ -85,8 +85,8 @@ impl ImmutableTransferParams { ScImmutableAgentID::new(self.id, PARAM_ACCOUNT.get_key_id()) } - pub fn amount(&self) -> ScImmutableInt64 { - ScImmutableInt64::new(self.id, PARAM_AMOUNT.get_key_id()) + pub fn amount(&self) -> ScImmutableUint64 { + ScImmutableUint64::new(self.id, PARAM_AMOUNT.get_key_id()) } } @@ -100,8 +100,8 @@ impl MutableTransferParams { ScMutableAgentID::new(self.id, PARAM_ACCOUNT.get_key_id()) } - pub fn amount(&self) -> ScMutableInt64 { - ScMutableInt64::new(self.id, PARAM_AMOUNT.get_key_id()) + pub fn amount(&self) -> ScMutableUint64 { + ScMutableUint64::new(self.id, PARAM_AMOUNT.get_key_id()) } } @@ -115,8 +115,8 @@ impl ImmutableTransferFromParams { ScImmutableAgentID::new(self.id, PARAM_ACCOUNT.get_key_id()) } - pub fn amount(&self) -> ScImmutableInt64 { - ScImmutableInt64::new(self.id, PARAM_AMOUNT.get_key_id()) + pub fn amount(&self) -> ScImmutableUint64 { + ScImmutableUint64::new(self.id, PARAM_AMOUNT.get_key_id()) } pub fn recipient(&self) -> ScImmutableAgentID { @@ -134,8 +134,8 @@ impl MutableTransferFromParams { ScMutableAgentID::new(self.id, PARAM_ACCOUNT.get_key_id()) } - pub fn amount(&self) -> ScMutableInt64 { - ScMutableInt64::new(self.id, PARAM_AMOUNT.get_key_id()) + pub fn amount(&self) -> ScMutableUint64 { + ScMutableUint64::new(self.id, PARAM_AMOUNT.get_key_id()) } pub fn recipient(&self) -> ScMutableAgentID { diff --git a/contracts/wasm/erc20/src/results.rs b/contracts/wasm/erc20/src/results.rs index dd77540b94..e3a962fa2e 100644 --- a/contracts/wasm/erc20/src/results.rs +++ b/contracts/wasm/erc20/src/results.rs @@ -21,8 +21,8 @@ pub struct ImmutableAllowanceResults { } impl ImmutableAllowanceResults { - pub fn amount(&self) -> ScImmutableInt64 { - ScImmutableInt64::new(self.id, RESULT_AMOUNT.get_key_id()) + pub fn amount(&self) -> ScImmutableUint64 { + ScImmutableUint64::new(self.id, RESULT_AMOUNT.get_key_id()) } } @@ -32,8 +32,8 @@ pub struct MutableAllowanceResults { } impl MutableAllowanceResults { - pub fn amount(&self) -> ScMutableInt64 { - ScMutableInt64::new(self.id, RESULT_AMOUNT.get_key_id()) + pub fn amount(&self) -> ScMutableUint64 { + ScMutableUint64::new(self.id, RESULT_AMOUNT.get_key_id()) } } @@ -43,8 +43,8 @@ pub struct ImmutableBalanceOfResults { } impl ImmutableBalanceOfResults { - pub fn amount(&self) -> ScImmutableInt64 { - ScImmutableInt64::new(self.id, RESULT_AMOUNT.get_key_id()) + pub fn amount(&self) -> ScImmutableUint64 { + ScImmutableUint64::new(self.id, RESULT_AMOUNT.get_key_id()) } } @@ -54,8 +54,8 @@ pub struct MutableBalanceOfResults { } impl MutableBalanceOfResults { - pub fn amount(&self) -> ScMutableInt64 { - ScMutableInt64::new(self.id, RESULT_AMOUNT.get_key_id()) + pub fn amount(&self) -> ScMutableUint64 { + ScMutableUint64::new(self.id, RESULT_AMOUNT.get_key_id()) } } @@ -65,8 +65,8 @@ pub struct ImmutableTotalSupplyResults { } impl ImmutableTotalSupplyResults { - pub fn supply(&self) -> ScImmutableInt64 { - ScImmutableInt64::new(self.id, RESULT_SUPPLY.get_key_id()) + pub fn supply(&self) -> ScImmutableUint64 { + ScImmutableUint64::new(self.id, RESULT_SUPPLY.get_key_id()) } } @@ -76,7 +76,7 @@ pub struct MutableTotalSupplyResults { } impl MutableTotalSupplyResults { - pub fn supply(&self) -> ScMutableInt64 { - ScMutableInt64::new(self.id, RESULT_SUPPLY.get_key_id()) + pub fn supply(&self) -> ScMutableUint64 { + ScMutableUint64::new(self.id, RESULT_SUPPLY.get_key_id()) } } diff --git a/contracts/wasm/erc20/src/state.rs b/contracts/wasm/erc20/src/state.rs index e1e0ff3283..d9e39d1dc2 100644 --- a/contracts/wasm/erc20/src/state.rs +++ b/contracts/wasm/erc20/src/state.rs @@ -38,13 +38,13 @@ impl ImmutableErc20State { MapAgentIDToImmutableAllowancesForAgent { obj_id: map_id } } - pub fn balances(&self) -> MapAgentIDToImmutableInt64 { + pub fn balances(&self) -> MapAgentIDToImmutableUint64 { let map_id = get_object_id(self.id, STATE_BALANCES.get_key_id(), TYPE_MAP); - MapAgentIDToImmutableInt64 { obj_id: map_id } + MapAgentIDToImmutableUint64 { obj_id: map_id } } - pub fn supply(&self) -> ScImmutableInt64 { - ScImmutableInt64::new(self.id, STATE_SUPPLY.get_key_id()) + pub fn supply(&self) -> ScImmutableUint64 { + ScImmutableUint64::new(self.id, STATE_SUPPLY.get_key_id()) } } @@ -79,12 +79,12 @@ impl MutableErc20State { MapAgentIDToMutableAllowancesForAgent { obj_id: map_id } } - pub fn balances(&self) -> MapAgentIDToMutableInt64 { + pub fn balances(&self) -> MapAgentIDToMutableUint64 { let map_id = get_object_id(self.id, STATE_BALANCES.get_key_id(), TYPE_MAP); - MapAgentIDToMutableInt64 { obj_id: map_id } + MapAgentIDToMutableUint64 { obj_id: map_id } } - pub fn supply(&self) -> ScMutableInt64 { - ScMutableInt64::new(self.id, STATE_SUPPLY.get_key_id()) + pub fn supply(&self) -> ScMutableUint64 { + ScMutableUint64::new(self.id, STATE_SUPPLY.get_key_id()) } } diff --git a/contracts/wasm/erc20/src/typedefs.rs b/contracts/wasm/erc20/src/typedefs.rs index dc638d395a..e0af7ebc3f 100644 --- a/contracts/wasm/erc20/src/typedefs.rs +++ b/contracts/wasm/erc20/src/typedefs.rs @@ -11,31 +11,31 @@ use wasmlib::*; use wasmlib::host::*; #[derive(Clone, Copy)] -pub struct MapAgentIDToImmutableInt64 { +pub struct MapAgentIDToImmutableUint64 { pub(crate) obj_id: i32, } -impl MapAgentIDToImmutableInt64 { - pub fn get_int64(&self, key: &ScAgentID) -> ScImmutableInt64 { - ScImmutableInt64::new(self.obj_id, key.get_key_id()) +impl MapAgentIDToImmutableUint64 { + pub fn get_uint64(&self, key: &ScAgentID) -> ScImmutableUint64 { + ScImmutableUint64::new(self.obj_id, key.get_key_id()) } } -pub type ImmutableAllowancesForAgent = MapAgentIDToImmutableInt64; +pub type ImmutableAllowancesForAgent = MapAgentIDToImmutableUint64; #[derive(Clone, Copy)] -pub struct MapAgentIDToMutableInt64 { +pub struct MapAgentIDToMutableUint64 { pub(crate) obj_id: i32, } -impl MapAgentIDToMutableInt64 { +impl MapAgentIDToMutableUint64 { pub fn clear(&self) { clear(self.obj_id); } - pub fn get_int64(&self, key: &ScAgentID) -> ScMutableInt64 { - ScMutableInt64::new(self.obj_id, key.get_key_id()) + pub fn get_uint64(&self, key: &ScAgentID) -> ScMutableUint64 { + ScMutableUint64::new(self.obj_id, key.get_key_id()) } } -pub type MutableAllowancesForAgent = MapAgentIDToMutableInt64; +pub type MutableAllowancesForAgent = MapAgentIDToMutableUint64; diff --git a/contracts/wasm/erc20/test/erc20_bg.wasm b/contracts/wasm/erc20/test/erc20_bg.wasm index a329940537a07fa34fdc64b7714c9ba602f4b7cc..54e4add5288403991f08ead39374ff41de74b0f5 100644 GIT binary patch delta 12682 zcmbtb3v^Z0nLc};b05jg;{*ca0m-?S011$XJQ5xP*@5s75Tr&CK?pD5hF8)c2qyPx zK~Yfyo7A9agQDPwiiB3Db!s|eyBO=5p=+EeZRslGP=`*LCGEJ@q^l_N{d=Eta|6-U zH4W>Yeg3`w{qMd1{r}(p?|n4>ZT`D&^EQ#eW39$2D~3N7TV)(rv~S7@_A0Z2CQG$4 z88f+IScb{{b~;C4_&E2448!z+^5dV8lH&JKY52^5%wz@kr25j*z?EV$(+5WCWpQqr zrr`^4%Q7tsQjAo_nT1Xehe`vL7Q`~h!8@^_5pRJ&0Ns6T8>_04d)bKl!-1_^R<5bv zw8KWrEELz>p)}CPNo<&VNex)bas1qzUblz(q9%h;IkF#z0 zBUe1mw!VTjO17WX*az9S(0H7s4Zr;mi!6ANrT+9k*sC&wJ7q7k2y>VS+AR$tTNk!2 zdamz|iXDxj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e+vUcN^hvfXW zoG%_Qzilxg_~Y2GwA~ZYv>$U*1Hsxqx#dq$GQbzz@*TJQXSa;u#o(X0?U!!DThp>? zT*b0&EvuGo+|XFovaM7%H52oW!7~<*>hIb5;0Qh_%VTP_X!YuW2bLQ}NJ`HlyP)W%2eoa`(d- z85=4mSR2=DUe~%_^O@Q`=-a{MD-ZAD8-225$E4x7hf_ZqIT%m61FD%aWOTetW1HB^@38K#Nu;KYXOh>_(3T=mJXOlZcBq5B)GeN!@DdL-h z@)wbsq^_W|;v3S6W+r_Ah-iI7R!2tk9P0!Ou3S7YQ=!-@K70p7okoh#^430PsNkC?>l;;`= 0, "erc20.approve.fail: wrong 'amount' parameter"); // all allowances are in the map under the name of he owner let allowances = f.state.allAllowances().getAllowancesForAgent(ctx.caller()); - allowances.getInt64(delegation).setValue(amount); + allowances.getUint64(delegation).setValue(amount); f.events.approval(amount, ctx.caller(), delegation) } @@ -36,7 +35,7 @@ export function funcInit(ctx: wasmlib.ScFuncContext, f: sc.InitContext): void { // so, owner of the initial supply must be provided as a parameter PARAM_CREATOR to constructor (onInit) // assign the whole supply to creator let creator = f.params.creator().value(); - f.state.balances().getInt64(creator).setValue(supply); + f.state.balances().getUint64(creator).setValue(supply); let t = "erc20.onInit.success. Supply: " + supply.toString() + ", creator:" + creator.toString(); @@ -47,20 +46,17 @@ export function funcInit(ctx: wasmlib.ScFuncContext, f: sc.InitContext): void { // This function emits the Transfer event. // Input: // - PARAM_ACCOUNT: agentID -// - PARAM_AMOUNT: i64 +// - PARAM_AMOUNT: u64 export function funcTransfer(ctx: wasmlib.ScFuncContext, f: sc.TransferContext): void { let amount = f.params.amount().value(); - ctx.require(amount >= 0, "erc20.transfer.fail: wrong 'amount' parameter"); let balances = f.state.balances(); let sourceAgent = ctx.caller(); - let sourceBalance = balances.getInt64(sourceAgent); + let sourceBalance = balances.getUint64(sourceAgent); ctx.require(sourceBalance.value() >= amount, "erc20.transfer.fail: not enough funds"); let targetAgent = f.params.account().value(); - let targetBalance = balances.getInt64(targetAgent); - let result = targetBalance.value() + amount; - ctx.require(result >= 0, "erc20.transfer.fail: overflow"); + let targetBalance = balances.getUint64(targetAgent); sourceBalance.setValue(sourceBalance.value() - amount); targetBalance.setValue(targetBalance.value() + amount); @@ -74,26 +70,23 @@ export function funcTransfer(ctx: wasmlib.ScFuncContext, f: sc.TransferContext): // Input: // - PARAM_ACCOUNT: agentID the spender // - PARAM_RECIPIENT: agentID the target -// - PARAM_AMOUNT: i64 +// - PARAM_AMOUNT: u64 export function funcTransferFrom(ctx: wasmlib.ScFuncContext, f: sc.TransferFromContext): void { // validate parameters let amount = f.params.amount().value(); - ctx.require(amount >= 0, "erc20.transferFrom.fail: wrong 'amount' parameter"); // allowances are in the map under the name of the account let sourceAgent = f.params.account().value(); let allowances = f.state.allAllowances().getAllowancesForAgent(sourceAgent); - let allowance = allowances.getInt64(ctx.caller()); + let allowance = allowances.getUint64(ctx.caller()); ctx.require(allowance.value() >= amount, "erc20.transferFrom.fail: not enough allowance"); let balances = f.state.balances(); - let sourceBalance = balances.getInt64(sourceAgent); + let sourceBalance = balances.getUint64(sourceAgent); ctx.require(sourceBalance.value() >= amount, "erc20.transferFrom.fail: not enough funds"); let targetAgent = f.params.recipient().value(); - let recipientBalance = balances.getInt64(targetAgent); - let result = recipientBalance.value() + amount; - ctx.require(result >= 0, "erc20.transferFrom.fail: overflow"); + let recipientBalance = balances.getUint64(targetAgent); sourceBalance.setValue(sourceBalance.value() - amount); recipientBalance.setValue(recipientBalance.value() + amount); @@ -108,11 +101,11 @@ export function funcTransferFrom(ctx: wasmlib.ScFuncContext, f: sc.TransferFromC // - PARAM_ACCOUNT: agentID // - PARAM_DELEGATION: agentID // Output: -// - PARAM_AMOUNT: i64 +// - PARAM_AMOUNT: u64 export function viewAllowance(ctx: wasmlib.ScViewContext, f: sc.AllowanceContext): void { // all allowances of the address 'owner' are stored in the map of the same name let allowances = f.state.allAllowances().getAllowancesForAgent(f.params.account().value()); - let allow = allowances.getInt64(f.params.delegation().value()).value(); + let allow = allowances.getUint64(f.params.delegation().value()).value(); f.results.amount().setValue(allow); } @@ -121,13 +114,13 @@ export function viewAllowance(ctx: wasmlib.ScViewContext, f: sc.AllowanceContext // - PARAM_ACCOUNT: agentID export function viewBalanceOf(ctx: wasmlib.ScViewContext, f: sc.BalanceOfContext): void { let balances = f.state.balances(); - let balance = balances.getInt64(f.params.account().value()); + let balance = balances.getUint64(f.params.account().value()); f.results.amount().setValue(balance.value()); } // the view returns total supply set when creating the contract (a constant). // Output: -// - PARAM_SUPPLY: i64 +// - PARAM_SUPPLY: u64 export function viewTotalSupply(ctx: wasmlib.ScViewContext, f: sc.TotalSupplyContext): void { f.results.supply().setValue(f.state.supply().value()); } diff --git a/contracts/wasm/erc20/ts/erc20/events.ts b/contracts/wasm/erc20/ts/erc20/events.ts index a8dd067940..cf030a0464 100644 --- a/contracts/wasm/erc20/ts/erc20/events.ts +++ b/contracts/wasm/erc20/ts/erc20/events.ts @@ -9,17 +9,17 @@ import * as wasmlib from "wasmlib"; export class Erc20Events { - approval(amount: i64, owner: wasmlib.ScAgentID, spender: wasmlib.ScAgentID): void { + approval(amount: u64, owner: wasmlib.ScAgentID, spender: wasmlib.ScAgentID): void { new wasmlib.EventEncoder("erc20.approval"). - int64(amount). + uint64(amount). agentID(owner). agentID(spender). emit(); } - transfer(amount: i64, from: wasmlib.ScAgentID, to: wasmlib.ScAgentID): void { + transfer(amount: u64, from: wasmlib.ScAgentID, to: wasmlib.ScAgentID): void { new wasmlib.EventEncoder("erc20.transfer"). - int64(amount). + uint64(amount). agentID(from). agentID(to). emit(); diff --git a/contracts/wasm/erc20/ts/erc20/params.ts b/contracts/wasm/erc20/ts/erc20/params.ts index 00e4d9d20e..15b05bdcc6 100644 --- a/contracts/wasm/erc20/ts/erc20/params.ts +++ b/contracts/wasm/erc20/ts/erc20/params.ts @@ -9,8 +9,8 @@ import * as wasmlib from "wasmlib"; import * as sc from "./index"; export class ImmutableApproveParams extends wasmlib.ScMapID { - amount(): wasmlib.ScImmutableInt64 { - return new wasmlib.ScImmutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ParamAmount)); + amount(): wasmlib.ScImmutableUint64 { + return new wasmlib.ScImmutableUint64(this.mapID, wasmlib.Key32.fromString(sc.ParamAmount)); } delegation(): wasmlib.ScImmutableAgentID { @@ -19,8 +19,8 @@ export class ImmutableApproveParams extends wasmlib.ScMapID { } export class MutableApproveParams extends wasmlib.ScMapID { - amount(): wasmlib.ScMutableInt64 { - return new wasmlib.ScMutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ParamAmount)); + amount(): wasmlib.ScMutableUint64 { + return new wasmlib.ScMutableUint64(this.mapID, wasmlib.Key32.fromString(sc.ParamAmount)); } delegation(): wasmlib.ScMutableAgentID { @@ -33,8 +33,8 @@ export class ImmutableInitParams extends wasmlib.ScMapID { return new wasmlib.ScImmutableAgentID(this.mapID, sc.idxMap[sc.IdxParamCreator]); } - supply(): wasmlib.ScImmutableInt64 { - return new wasmlib.ScImmutableInt64(this.mapID, sc.idxMap[sc.IdxParamSupply]); + supply(): wasmlib.ScImmutableUint64 { + return new wasmlib.ScImmutableUint64(this.mapID, sc.idxMap[sc.IdxParamSupply]); } } @@ -43,8 +43,8 @@ export class MutableInitParams extends wasmlib.ScMapID { return new wasmlib.ScMutableAgentID(this.mapID, sc.idxMap[sc.IdxParamCreator]); } - supply(): wasmlib.ScMutableInt64 { - return new wasmlib.ScMutableInt64(this.mapID, sc.idxMap[sc.IdxParamSupply]); + supply(): wasmlib.ScMutableUint64 { + return new wasmlib.ScMutableUint64(this.mapID, sc.idxMap[sc.IdxParamSupply]); } } @@ -53,8 +53,8 @@ export class ImmutableTransferParams extends wasmlib.ScMapID { return new wasmlib.ScImmutableAgentID(this.mapID, wasmlib.Key32.fromString(sc.ParamAccount)); } - amount(): wasmlib.ScImmutableInt64 { - return new wasmlib.ScImmutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ParamAmount)); + amount(): wasmlib.ScImmutableUint64 { + return new wasmlib.ScImmutableUint64(this.mapID, wasmlib.Key32.fromString(sc.ParamAmount)); } } @@ -63,8 +63,8 @@ export class MutableTransferParams extends wasmlib.ScMapID { return new wasmlib.ScMutableAgentID(this.mapID, wasmlib.Key32.fromString(sc.ParamAccount)); } - amount(): wasmlib.ScMutableInt64 { - return new wasmlib.ScMutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ParamAmount)); + amount(): wasmlib.ScMutableUint64 { + return new wasmlib.ScMutableUint64(this.mapID, wasmlib.Key32.fromString(sc.ParamAmount)); } } @@ -73,8 +73,8 @@ export class ImmutableTransferFromParams extends wasmlib.ScMapID { return new wasmlib.ScImmutableAgentID(this.mapID, wasmlib.Key32.fromString(sc.ParamAccount)); } - amount(): wasmlib.ScImmutableInt64 { - return new wasmlib.ScImmutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ParamAmount)); + amount(): wasmlib.ScImmutableUint64 { + return new wasmlib.ScImmutableUint64(this.mapID, wasmlib.Key32.fromString(sc.ParamAmount)); } recipient(): wasmlib.ScImmutableAgentID { @@ -87,8 +87,8 @@ export class MutableTransferFromParams extends wasmlib.ScMapID { return new wasmlib.ScMutableAgentID(this.mapID, wasmlib.Key32.fromString(sc.ParamAccount)); } - amount(): wasmlib.ScMutableInt64 { - return new wasmlib.ScMutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ParamAmount)); + amount(): wasmlib.ScMutableUint64 { + return new wasmlib.ScMutableUint64(this.mapID, wasmlib.Key32.fromString(sc.ParamAmount)); } recipient(): wasmlib.ScMutableAgentID { diff --git a/contracts/wasm/erc20/ts/erc20/results.ts b/contracts/wasm/erc20/ts/erc20/results.ts index 21b795a702..e2e03d5909 100644 --- a/contracts/wasm/erc20/ts/erc20/results.ts +++ b/contracts/wasm/erc20/ts/erc20/results.ts @@ -9,37 +9,37 @@ import * as wasmlib from "wasmlib"; import * as sc from "./index"; export class ImmutableAllowanceResults extends wasmlib.ScMapID { - amount(): wasmlib.ScImmutableInt64 { - return new wasmlib.ScImmutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ResultAmount)); + amount(): wasmlib.ScImmutableUint64 { + return new wasmlib.ScImmutableUint64(this.mapID, wasmlib.Key32.fromString(sc.ResultAmount)); } } export class MutableAllowanceResults extends wasmlib.ScMapID { - amount(): wasmlib.ScMutableInt64 { - return new wasmlib.ScMutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ResultAmount)); + amount(): wasmlib.ScMutableUint64 { + return new wasmlib.ScMutableUint64(this.mapID, wasmlib.Key32.fromString(sc.ResultAmount)); } } export class ImmutableBalanceOfResults extends wasmlib.ScMapID { - amount(): wasmlib.ScImmutableInt64 { - return new wasmlib.ScImmutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ResultAmount)); + amount(): wasmlib.ScImmutableUint64 { + return new wasmlib.ScImmutableUint64(this.mapID, wasmlib.Key32.fromString(sc.ResultAmount)); } } export class MutableBalanceOfResults extends wasmlib.ScMapID { - amount(): wasmlib.ScMutableInt64 { - return new wasmlib.ScMutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ResultAmount)); + amount(): wasmlib.ScMutableUint64 { + return new wasmlib.ScMutableUint64(this.mapID, wasmlib.Key32.fromString(sc.ResultAmount)); } } export class ImmutableTotalSupplyResults extends wasmlib.ScMapID { - supply(): wasmlib.ScImmutableInt64 { - return new wasmlib.ScImmutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ResultSupply)); + supply(): wasmlib.ScImmutableUint64 { + return new wasmlib.ScImmutableUint64(this.mapID, wasmlib.Key32.fromString(sc.ResultSupply)); } } export class MutableTotalSupplyResults extends wasmlib.ScMapID { - supply(): wasmlib.ScMutableInt64 { - return new wasmlib.ScMutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ResultSupply)); + supply(): wasmlib.ScMutableUint64 { + return new wasmlib.ScMutableUint64(this.mapID, wasmlib.Key32.fromString(sc.ResultSupply)); } } diff --git a/contracts/wasm/erc20/ts/erc20/state.ts b/contracts/wasm/erc20/ts/erc20/state.ts index 9b91699eb3..8a4742b78e 100644 --- a/contracts/wasm/erc20/ts/erc20/state.ts +++ b/contracts/wasm/erc20/ts/erc20/state.ts @@ -27,13 +27,13 @@ export class ImmutableErc20State extends wasmlib.ScMapID { return new sc.MapAgentIDToImmutableAllowancesForAgent(mapID); } - balances(): sc.MapAgentIDToImmutableInt64 { + balances(): sc.MapAgentIDToImmutableUint64 { let mapID = wasmlib.getObjectID(this.mapID, wasmlib.Key32.fromString(sc.StateBalances), wasmlib.TYPE_MAP); - return new sc.MapAgentIDToImmutableInt64(mapID); + return new sc.MapAgentIDToImmutableUint64(mapID); } - supply(): wasmlib.ScImmutableInt64 { - return new wasmlib.ScImmutableInt64(this.mapID, wasmlib.Key32.fromString(sc.StateSupply)); + supply(): wasmlib.ScImmutableUint64 { + return new wasmlib.ScImmutableUint64(this.mapID, wasmlib.Key32.fromString(sc.StateSupply)); } } @@ -66,12 +66,12 @@ export class MutableErc20State extends wasmlib.ScMapID { return new sc.MapAgentIDToMutableAllowancesForAgent(mapID); } - balances(): sc.MapAgentIDToMutableInt64 { + balances(): sc.MapAgentIDToMutableUint64 { let mapID = wasmlib.getObjectID(this.mapID, wasmlib.Key32.fromString(sc.StateBalances), wasmlib.TYPE_MAP); - return new sc.MapAgentIDToMutableInt64(mapID); + return new sc.MapAgentIDToMutableUint64(mapID); } - supply(): wasmlib.ScMutableInt64 { - return new wasmlib.ScMutableInt64(this.mapID, wasmlib.Key32.fromString(sc.StateSupply)); + supply(): wasmlib.ScMutableUint64 { + return new wasmlib.ScMutableUint64(this.mapID, wasmlib.Key32.fromString(sc.StateSupply)); } } diff --git a/contracts/wasm/erc20/ts/erc20/typedefs.ts b/contracts/wasm/erc20/ts/erc20/typedefs.ts index 2d09733fac..ad2dfc36e0 100644 --- a/contracts/wasm/erc20/ts/erc20/typedefs.ts +++ b/contracts/wasm/erc20/ts/erc20/typedefs.ts @@ -8,22 +8,22 @@ import * as wasmlib from "wasmlib"; import * as sc from "./index"; -export class MapAgentIDToImmutableInt64 { +export class MapAgentIDToImmutableUint64 { objID: i32; constructor(objID: i32) { this.objID = objID; } - getInt64(key: wasmlib.ScAgentID): wasmlib.ScImmutableInt64 { - return new wasmlib.ScImmutableInt64(this.objID, key.getKeyID()); + getUint64(key: wasmlib.ScAgentID): wasmlib.ScImmutableUint64 { + return new wasmlib.ScImmutableUint64(this.objID, key.getKeyID()); } } -export class ImmutableAllowancesForAgent extends MapAgentIDToImmutableInt64 { +export class ImmutableAllowancesForAgent extends MapAgentIDToImmutableUint64 { }; -export class MapAgentIDToMutableInt64 { +export class MapAgentIDToMutableUint64 { objID: i32; constructor(objID: i32) { @@ -34,10 +34,10 @@ export class MapAgentIDToMutableInt64 { wasmlib.clear(this.objID); } - getInt64(key: wasmlib.ScAgentID): wasmlib.ScMutableInt64 { - return new wasmlib.ScMutableInt64(this.objID, key.getKeyID()); + getUint64(key: wasmlib.ScAgentID): wasmlib.ScMutableUint64 { + return new wasmlib.ScMutableUint64(this.objID, key.getKeyID()); } } -export class MutableAllowancesForAgent extends MapAgentIDToMutableInt64 { +export class MutableAllowancesForAgent extends MapAgentIDToMutableUint64 { }; diff --git a/contracts/wasm/erc721/go/erc721/consts.go b/contracts/wasm/erc721/go/erc721/consts.go index a40a421910..5c83fab6d4 100644 --- a/contracts/wasm/erc721/go/erc721/consts.go +++ b/contracts/wasm/erc721/go/erc721/consts.go @@ -7,12 +7,12 @@ package erc721 -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" +import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" const ( ScName = "erc721" ScDescription = "ERC-721 NFT PoC for IOTA Smart Contracts" - HScName = wasmlib.ScHname(0xd967c216) + HScName = wasmtypes.ScHname(0xd967c216) ) const ( @@ -67,18 +67,18 @@ const ( ) const ( - HFuncApprove = wasmlib.ScHname(0xa0661268) - HFuncBurn = wasmlib.ScHname(0x7bc1efb1) - HFuncInit = wasmlib.ScHname(0x1f44d644) - HFuncMint = wasmlib.ScHname(0xa29addcf) - HFuncSafeTransferFrom = wasmlib.ScHname(0x130ce158) - HFuncSetApprovalForAll = wasmlib.ScHname(0xb8d8c776) - HFuncTransferFrom = wasmlib.ScHname(0xd5e0a602) - HViewBalanceOf = wasmlib.ScHname(0x67ef8df4) - HViewGetApproved = wasmlib.ScHname(0xbe34b6ba) - HViewIsApprovedForAll = wasmlib.ScHname(0x3251b0f0) - HViewName = wasmlib.ScHname(0x0df7da3a) - HViewOwnerOf = wasmlib.ScHname(0x1246f5ad) - HViewSymbol = wasmlib.ScHname(0x3e93d19b) - HViewTokenURI = wasmlib.ScHname(0x4e1a7397) + HFuncApprove = wasmtypes.ScHname(0xa0661268) + HFuncBurn = wasmtypes.ScHname(0x7bc1efb1) + HFuncInit = wasmtypes.ScHname(0x1f44d644) + HFuncMint = wasmtypes.ScHname(0xa29addcf) + HFuncSafeTransferFrom = wasmtypes.ScHname(0x130ce158) + HFuncSetApprovalForAll = wasmtypes.ScHname(0xb8d8c776) + HFuncTransferFrom = wasmtypes.ScHname(0xd5e0a602) + HViewBalanceOf = wasmtypes.ScHname(0x67ef8df4) + HViewGetApproved = wasmtypes.ScHname(0xbe34b6ba) + HViewIsApprovedForAll = wasmtypes.ScHname(0x3251b0f0) + HViewName = wasmtypes.ScHname(0x0df7da3a) + HViewOwnerOf = wasmtypes.ScHname(0x1246f5ad) + HViewSymbol = wasmtypes.ScHname(0x3e93d19b) + HViewTokenURI = wasmtypes.ScHname(0x4e1a7397) ) diff --git a/contracts/wasm/erc721/go/erc721/contract.go b/contracts/wasm/erc721/go/erc721/contract.go index 258858e677..909e7392a5 100644 --- a/contracts/wasm/erc721/go/erc721/contract.go +++ b/contracts/wasm/erc721/go/erc721/contract.go @@ -90,84 +90,89 @@ var ScFuncs Funcs func (sc Funcs) Approve(ctx wasmlib.ScFuncCallContext) *ApproveCall { f := &ApproveCall{Func: wasmlib.NewScFunc(ctx, HScName, HFuncApprove)} - f.Func.SetPtrs(&f.Params.id, nil) + f.Params.proxy = wasmlib.NewCallParamsProxy(&f.Func.ScView) return f } func (sc Funcs) Burn(ctx wasmlib.ScFuncCallContext) *BurnCall { f := &BurnCall{Func: wasmlib.NewScFunc(ctx, HScName, HFuncBurn)} - f.Func.SetPtrs(&f.Params.id, nil) + f.Params.proxy = wasmlib.NewCallParamsProxy(&f.Func.ScView) return f } func (sc Funcs) Init(ctx wasmlib.ScFuncCallContext) *InitCall { - f := &InitCall{Func: wasmlib.NewScInitFunc(ctx, HScName, HFuncInit, keyMap[:], idxMap[:])} - f.Func.SetPtrs(&f.Params.id, nil) + f := &InitCall{Func: wasmlib.NewScInitFunc(ctx, HScName, HFuncInit)} + f.Params.proxy = wasmlib.NewCallParamsProxy(&f.Func.ScView) return f } func (sc Funcs) Mint(ctx wasmlib.ScFuncCallContext) *MintCall { f := &MintCall{Func: wasmlib.NewScFunc(ctx, HScName, HFuncMint)} - f.Func.SetPtrs(&f.Params.id, nil) + f.Params.proxy = wasmlib.NewCallParamsProxy(&f.Func.ScView) return f } func (sc Funcs) SafeTransferFrom(ctx wasmlib.ScFuncCallContext) *SafeTransferFromCall { f := &SafeTransferFromCall{Func: wasmlib.NewScFunc(ctx, HScName, HFuncSafeTransferFrom)} - f.Func.SetPtrs(&f.Params.id, nil) + f.Params.proxy = wasmlib.NewCallParamsProxy(&f.Func.ScView) return f } func (sc Funcs) SetApprovalForAll(ctx wasmlib.ScFuncCallContext) *SetApprovalForAllCall { f := &SetApprovalForAllCall{Func: wasmlib.NewScFunc(ctx, HScName, HFuncSetApprovalForAll)} - f.Func.SetPtrs(&f.Params.id, nil) + f.Params.proxy = wasmlib.NewCallParamsProxy(&f.Func.ScView) return f } func (sc Funcs) TransferFrom(ctx wasmlib.ScFuncCallContext) *TransferFromCall { f := &TransferFromCall{Func: wasmlib.NewScFunc(ctx, HScName, HFuncTransferFrom)} - f.Func.SetPtrs(&f.Params.id, nil) + f.Params.proxy = wasmlib.NewCallParamsProxy(&f.Func.ScView) return f } func (sc Funcs) BalanceOf(ctx wasmlib.ScViewCallContext) *BalanceOfCall { f := &BalanceOfCall{Func: wasmlib.NewScView(ctx, HScName, HViewBalanceOf)} - f.Func.SetPtrs(&f.Params.id, &f.Results.id) + f.Params.proxy = wasmlib.NewCallParamsProxy(f.Func) + wasmlib.NewCallResultsProxy(f.Func, &f.Results.proxy) return f } func (sc Funcs) GetApproved(ctx wasmlib.ScViewCallContext) *GetApprovedCall { f := &GetApprovedCall{Func: wasmlib.NewScView(ctx, HScName, HViewGetApproved)} - f.Func.SetPtrs(&f.Params.id, &f.Results.id) + f.Params.proxy = wasmlib.NewCallParamsProxy(f.Func) + wasmlib.NewCallResultsProxy(f.Func, &f.Results.proxy) return f } func (sc Funcs) IsApprovedForAll(ctx wasmlib.ScViewCallContext) *IsApprovedForAllCall { f := &IsApprovedForAllCall{Func: wasmlib.NewScView(ctx, HScName, HViewIsApprovedForAll)} - f.Func.SetPtrs(&f.Params.id, &f.Results.id) + f.Params.proxy = wasmlib.NewCallParamsProxy(f.Func) + wasmlib.NewCallResultsProxy(f.Func, &f.Results.proxy) return f } func (sc Funcs) Name(ctx wasmlib.ScViewCallContext) *NameCall { f := &NameCall{Func: wasmlib.NewScView(ctx, HScName, HViewName)} - f.Func.SetPtrs(nil, &f.Results.id) + wasmlib.NewCallResultsProxy(f.Func, &f.Results.proxy) return f } func (sc Funcs) OwnerOf(ctx wasmlib.ScViewCallContext) *OwnerOfCall { f := &OwnerOfCall{Func: wasmlib.NewScView(ctx, HScName, HViewOwnerOf)} - f.Func.SetPtrs(&f.Params.id, &f.Results.id) + f.Params.proxy = wasmlib.NewCallParamsProxy(f.Func) + wasmlib.NewCallResultsProxy(f.Func, &f.Results.proxy) return f } func (sc Funcs) Symbol(ctx wasmlib.ScViewCallContext) *SymbolCall { f := &SymbolCall{Func: wasmlib.NewScView(ctx, HScName, HViewSymbol)} - f.Func.SetPtrs(nil, &f.Results.id) + wasmlib.NewCallResultsProxy(f.Func, &f.Results.proxy) return f } func (sc Funcs) TokenURI(ctx wasmlib.ScViewCallContext) *TokenURICall { f := &TokenURICall{Func: wasmlib.NewScView(ctx, HScName, HViewTokenURI)} - f.Func.SetPtrs(&f.Params.id, &f.Results.id) + f.Params.proxy = wasmlib.NewCallParamsProxy(f.Func) + wasmlib.NewCallResultsProxy(f.Func, &f.Results.proxy) return f } diff --git a/contracts/wasm/erc721/go/erc721/erc721.go b/contracts/wasm/erc721/go/erc721/erc721.go index 81b8cf78f1..514e4d5619 100644 --- a/contracts/wasm/erc721/go/erc721/erc721.go +++ b/contracts/wasm/erc721/go/erc721/erc721.go @@ -3,7 +3,10 @@ package erc721 -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" +import ( + "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" + "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" +) // Follows ERC-721 standard as closely as possible // https//eips.Ethereum.Org/EIPS/eip-721 @@ -18,12 +21,12 @@ import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" // set the required base URI, to which the base58 encoded token ID will be concatenated const baseURI = "my/special/base/uri/" -var zero = wasmlib.ScAgentID{} +var zero = wasmtypes.ScAgentID{} /////////////////////////// HELPER FUNCTIONS //////////////////////////// // checks if caller is owner, or one of its delegated operators -func canOperate(state MutableErc721State, caller, owner wasmlib.ScAgentID) bool { +func canOperate(state MutableErc721State, caller, owner wasmtypes.ScAgentID) bool { if caller == owner { return true } @@ -33,7 +36,7 @@ func canOperate(state MutableErc721State, caller, owner wasmlib.ScAgentID) bool } // checks if caller is owner, or one of its delegated operators, or approved account for tokenID -func canTransfer(state MutableErc721State, caller, owner wasmlib.ScAgentID, tokenID wasmlib.ScHash) bool { +func canTransfer(state MutableErc721State, caller, owner wasmtypes.ScAgentID, tokenID wasmtypes.ScHash) bool { if canOperate(state, caller, owner) { return true } @@ -43,7 +46,7 @@ func canTransfer(state MutableErc721State, caller, owner wasmlib.ScAgentID, toke } // common code for safeTransferFrom and transferFrom -func transfer(ctx wasmlib.ScFuncContext, state MutableErc721State, from, to wasmlib.ScAgentID, tokenID wasmlib.ScHash) { +func transfer(ctx wasmlib.ScFuncContext, state MutableErc721State, from, to wasmtypes.ScAgentID, tokenID wasmtypes.ScHash) { tokenOwner := state.Owners().GetAgentID(tokenID) ctx.Require(tokenOwner.Exists(), "tokenID does not exist") diff --git a/contracts/wasm/erc721/go/erc721/events.go b/contracts/wasm/erc721/go/erc721/events.go index ab863646b5..1c14a5b748 100644 --- a/contracts/wasm/erc721/go/erc721/events.go +++ b/contracts/wasm/erc721/go/erc721/events.go @@ -8,11 +8,14 @@ //nolint:gocritic package erc721 -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" +import ( + "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" + "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" +) type Erc721Events struct{} -func (e Erc721Events) Approval(approved wasmlib.ScAgentID, owner wasmlib.ScAgentID, tokenID wasmlib.ScHash) { +func (e Erc721Events) Approval(approved wasmtypes.ScAgentID, owner wasmtypes.ScAgentID, tokenID wasmtypes.ScHash) { wasmlib.NewEventEncoder("erc721.approval"). AgentID(approved). AgentID(owner). @@ -20,7 +23,7 @@ func (e Erc721Events) Approval(approved wasmlib.ScAgentID, owner wasmlib.ScAgent Emit() } -func (e Erc721Events) ApprovalForAll(approval bool, operator wasmlib.ScAgentID, owner wasmlib.ScAgentID) { +func (e Erc721Events) ApprovalForAll(approval bool, operator wasmtypes.ScAgentID, owner wasmtypes.ScAgentID) { wasmlib.NewEventEncoder("erc721.approvalForAll"). Bool(approval). AgentID(operator). @@ -35,7 +38,7 @@ func (e Erc721Events) Init(name string, symbol string) { Emit() } -func (e Erc721Events) Mint(balance uint64, owner wasmlib.ScAgentID, tokenID wasmlib.ScHash) { +func (e Erc721Events) Mint(balance uint64, owner wasmtypes.ScAgentID, tokenID wasmtypes.ScHash) { wasmlib.NewEventEncoder("erc721.mint"). Uint64(balance). AgentID(owner). @@ -43,7 +46,7 @@ func (e Erc721Events) Mint(balance uint64, owner wasmlib.ScAgentID, tokenID wasm Emit() } -func (e Erc721Events) Transfer(from wasmlib.ScAgentID, to wasmlib.ScAgentID, tokenID wasmlib.ScHash) { +func (e Erc721Events) Transfer(from wasmtypes.ScAgentID, to wasmtypes.ScAgentID, tokenID wasmtypes.ScHash) { wasmlib.NewEventEncoder("erc721.transfer"). AgentID(from). AgentID(to). diff --git a/contracts/wasm/erc721/go/erc721/keys.go b/contracts/wasm/erc721/go/erc721/keys.go index a1f47ba9f4..3fdcc944a6 100644 --- a/contracts/wasm/erc721/go/erc721/keys.go +++ b/contracts/wasm/erc721/go/erc721/keys.go @@ -6,67 +6,3 @@ // Change the json schema instead package erc721 - -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" - -const ( - IdxParamApproval = 0 - IdxParamApproved = 1 - IdxParamData = 2 - IdxParamFrom = 3 - IdxParamName = 4 - IdxParamOperator = 5 - IdxParamOwner = 6 - IdxParamSymbol = 7 - IdxParamTo = 8 - IdxParamTokenID = 9 - IdxParamTokenURI = 10 - - IdxResultAmount = 11 - IdxResultApproval = 12 - IdxResultApproved = 13 - IdxResultName = 14 - IdxResultOwner = 15 - IdxResultSymbol = 16 - IdxResultTokenURI = 17 - - IdxStateApprovedAccounts = 18 - IdxStateApprovedOperators = 19 - IdxStateBalances = 20 - IdxStateName = 21 - IdxStateOwners = 22 - IdxStateSymbol = 23 - IdxStateTokenURIs = 24 -) - -const keyMapLen = 25 - -var keyMap = [keyMapLen]wasmlib.Key{ - ParamApproval, - ParamApproved, - ParamData, - ParamFrom, - ParamName, - ParamOperator, - ParamOwner, - ParamSymbol, - ParamTo, - ParamTokenID, - ParamTokenURI, - ResultAmount, - ResultApproval, - ResultApproved, - ResultName, - ResultOwner, - ResultSymbol, - ResultTokenURI, - StateApprovedAccounts, - StateApprovedOperators, - StateBalances, - StateName, - StateOwners, - StateSymbol, - StateTokenURIs, -} - -var idxMap [keyMapLen]wasmlib.Key32 diff --git a/contracts/wasm/erc721/go/erc721/lib.go b/contracts/wasm/erc721/go/erc721/lib.go index 60498f3a9e..44e48b89d0 100644 --- a/contracts/wasm/erc721/go/erc721/lib.go +++ b/contracts/wasm/erc721/go/erc721/lib.go @@ -25,10 +25,6 @@ func OnLoad() { exports.AddView(ViewOwnerOf, viewOwnerOfThunk) exports.AddView(ViewSymbol, viewSymbolThunk) exports.AddView(ViewTokenURI, viewTokenURIThunk) - - for i, key := range keyMap { - idxMap[i] = key.KeyID() - } } type ApproveContext struct { @@ -41,10 +37,10 @@ func funcApproveThunk(ctx wasmlib.ScFuncContext) { ctx.Log("erc721.funcApprove") f := &ApproveContext{ Params: ImmutableApproveParams{ - id: wasmlib.OBJ_ID_PARAMS, + proxy: wasmlib.NewParamsProxy(), }, State: MutableErc721State{ - id: wasmlib.OBJ_ID_STATE, + proxy: wasmlib.NewStateProxy(), }, } ctx.Require(f.Params.TokenID().Exists(), "missing mandatory tokenID") @@ -62,10 +58,10 @@ func funcBurnThunk(ctx wasmlib.ScFuncContext) { ctx.Log("erc721.funcBurn") f := &BurnContext{ Params: ImmutableBurnParams{ - id: wasmlib.OBJ_ID_PARAMS, + proxy: wasmlib.NewParamsProxy(), }, State: MutableErc721State{ - id: wasmlib.OBJ_ID_STATE, + proxy: wasmlib.NewStateProxy(), }, } ctx.Require(f.Params.TokenID().Exists(), "missing mandatory tokenID") @@ -83,10 +79,10 @@ func funcInitThunk(ctx wasmlib.ScFuncContext) { ctx.Log("erc721.funcInit") f := &InitContext{ Params: ImmutableInitParams{ - id: wasmlib.OBJ_ID_PARAMS, + proxy: wasmlib.NewParamsProxy(), }, State: MutableErc721State{ - id: wasmlib.OBJ_ID_STATE, + proxy: wasmlib.NewStateProxy(), }, } ctx.Require(f.Params.Name().Exists(), "missing mandatory name") @@ -105,10 +101,10 @@ func funcMintThunk(ctx wasmlib.ScFuncContext) { ctx.Log("erc721.funcMint") f := &MintContext{ Params: ImmutableMintParams{ - id: wasmlib.OBJ_ID_PARAMS, + proxy: wasmlib.NewParamsProxy(), }, State: MutableErc721State{ - id: wasmlib.OBJ_ID_STATE, + proxy: wasmlib.NewStateProxy(), }, } ctx.Require(f.Params.TokenID().Exists(), "missing mandatory tokenID") @@ -126,10 +122,10 @@ func funcSafeTransferFromThunk(ctx wasmlib.ScFuncContext) { ctx.Log("erc721.funcSafeTransferFrom") f := &SafeTransferFromContext{ Params: ImmutableSafeTransferFromParams{ - id: wasmlib.OBJ_ID_PARAMS, + proxy: wasmlib.NewParamsProxy(), }, State: MutableErc721State{ - id: wasmlib.OBJ_ID_STATE, + proxy: wasmlib.NewStateProxy(), }, } ctx.Require(f.Params.From().Exists(), "missing mandatory from") @@ -149,10 +145,10 @@ func funcSetApprovalForAllThunk(ctx wasmlib.ScFuncContext) { ctx.Log("erc721.funcSetApprovalForAll") f := &SetApprovalForAllContext{ Params: ImmutableSetApprovalForAllParams{ - id: wasmlib.OBJ_ID_PARAMS, + proxy: wasmlib.NewParamsProxy(), }, State: MutableErc721State{ - id: wasmlib.OBJ_ID_STATE, + proxy: wasmlib.NewStateProxy(), }, } ctx.Require(f.Params.Approval().Exists(), "missing mandatory approval") @@ -171,10 +167,10 @@ func funcTransferFromThunk(ctx wasmlib.ScFuncContext) { ctx.Log("erc721.funcTransferFrom") f := &TransferFromContext{ Params: ImmutableTransferFromParams{ - id: wasmlib.OBJ_ID_PARAMS, + proxy: wasmlib.NewParamsProxy(), }, State: MutableErc721State{ - id: wasmlib.OBJ_ID_STATE, + proxy: wasmlib.NewStateProxy(), }, } ctx.Require(f.Params.From().Exists(), "missing mandatory from") @@ -194,13 +190,13 @@ func viewBalanceOfThunk(ctx wasmlib.ScViewContext) { ctx.Log("erc721.viewBalanceOf") f := &BalanceOfContext{ Params: ImmutableBalanceOfParams{ - id: wasmlib.OBJ_ID_PARAMS, + proxy: wasmlib.NewParamsProxy(), }, Results: MutableBalanceOfResults{ - id: wasmlib.OBJ_ID_RESULTS, + proxy: wasmlib.NewResultsProxy(), }, State: ImmutableErc721State{ - id: wasmlib.OBJ_ID_STATE, + proxy: wasmlib.NewStateProxy(), }, } ctx.Require(f.Params.Owner().Exists(), "missing mandatory owner") @@ -218,13 +214,13 @@ func viewGetApprovedThunk(ctx wasmlib.ScViewContext) { ctx.Log("erc721.viewGetApproved") f := &GetApprovedContext{ Params: ImmutableGetApprovedParams{ - id: wasmlib.OBJ_ID_PARAMS, + proxy: wasmlib.NewParamsProxy(), }, Results: MutableGetApprovedResults{ - id: wasmlib.OBJ_ID_RESULTS, + proxy: wasmlib.NewResultsProxy(), }, State: ImmutableErc721State{ - id: wasmlib.OBJ_ID_STATE, + proxy: wasmlib.NewStateProxy(), }, } ctx.Require(f.Params.TokenID().Exists(), "missing mandatory tokenID") @@ -242,13 +238,13 @@ func viewIsApprovedForAllThunk(ctx wasmlib.ScViewContext) { ctx.Log("erc721.viewIsApprovedForAll") f := &IsApprovedForAllContext{ Params: ImmutableIsApprovedForAllParams{ - id: wasmlib.OBJ_ID_PARAMS, + proxy: wasmlib.NewParamsProxy(), }, Results: MutableIsApprovedForAllResults{ - id: wasmlib.OBJ_ID_RESULTS, + proxy: wasmlib.NewResultsProxy(), }, State: ImmutableErc721State{ - id: wasmlib.OBJ_ID_STATE, + proxy: wasmlib.NewStateProxy(), }, } ctx.Require(f.Params.Operator().Exists(), "missing mandatory operator") @@ -266,10 +262,10 @@ func viewNameThunk(ctx wasmlib.ScViewContext) { ctx.Log("erc721.viewName") f := &NameContext{ Results: MutableNameResults{ - id: wasmlib.OBJ_ID_RESULTS, + proxy: wasmlib.NewResultsProxy(), }, State: ImmutableErc721State{ - id: wasmlib.OBJ_ID_STATE, + proxy: wasmlib.NewStateProxy(), }, } viewName(ctx, f) @@ -286,13 +282,13 @@ func viewOwnerOfThunk(ctx wasmlib.ScViewContext) { ctx.Log("erc721.viewOwnerOf") f := &OwnerOfContext{ Params: ImmutableOwnerOfParams{ - id: wasmlib.OBJ_ID_PARAMS, + proxy: wasmlib.NewParamsProxy(), }, Results: MutableOwnerOfResults{ - id: wasmlib.OBJ_ID_RESULTS, + proxy: wasmlib.NewResultsProxy(), }, State: ImmutableErc721State{ - id: wasmlib.OBJ_ID_STATE, + proxy: wasmlib.NewStateProxy(), }, } ctx.Require(f.Params.TokenID().Exists(), "missing mandatory tokenID") @@ -309,10 +305,10 @@ func viewSymbolThunk(ctx wasmlib.ScViewContext) { ctx.Log("erc721.viewSymbol") f := &SymbolContext{ Results: MutableSymbolResults{ - id: wasmlib.OBJ_ID_RESULTS, + proxy: wasmlib.NewResultsProxy(), }, State: ImmutableErc721State{ - id: wasmlib.OBJ_ID_STATE, + proxy: wasmlib.NewStateProxy(), }, } viewSymbol(ctx, f) @@ -329,13 +325,13 @@ func viewTokenURIThunk(ctx wasmlib.ScViewContext) { ctx.Log("erc721.viewTokenURI") f := &TokenURIContext{ Params: ImmutableTokenURIParams{ - id: wasmlib.OBJ_ID_PARAMS, + proxy: wasmlib.NewParamsProxy(), }, Results: MutableTokenURIResults{ - id: wasmlib.OBJ_ID_RESULTS, + proxy: wasmlib.NewResultsProxy(), }, State: ImmutableErc721State{ - id: wasmlib.OBJ_ID_STATE, + proxy: wasmlib.NewStateProxy(), }, } ctx.Require(f.Params.TokenID().Exists(), "missing mandatory tokenID") diff --git a/contracts/wasm/erc721/go/erc721/params.go b/contracts/wasm/erc721/go/erc721/params.go index 63a30646d2..5fe1bf7d3a 100644 --- a/contracts/wasm/erc721/go/erc721/params.go +++ b/contracts/wasm/erc721/go/erc721/params.go @@ -7,276 +7,276 @@ package erc721 -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" +import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" type ImmutableApproveParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableApproveParams) Approved() wasmlib.ScImmutableAgentID { - return wasmlib.NewScImmutableAgentID(s.id, wasmlib.KeyID(ParamApproved)) +func (s ImmutableApproveParams) Approved() wasmtypes.ScImmutableAgentID { + return wasmtypes.NewScImmutableAgentID(s.proxy.Root(ParamApproved)) } -func (s ImmutableApproveParams) TokenID() wasmlib.ScImmutableHash { - return wasmlib.NewScImmutableHash(s.id, wasmlib.KeyID(ParamTokenID)) +func (s ImmutableApproveParams) TokenID() wasmtypes.ScImmutableHash { + return wasmtypes.NewScImmutableHash(s.proxy.Root(ParamTokenID)) } type MutableApproveParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableApproveParams) Approved() wasmlib.ScMutableAgentID { - return wasmlib.NewScMutableAgentID(s.id, wasmlib.KeyID(ParamApproved)) +func (s MutableApproveParams) Approved() wasmtypes.ScMutableAgentID { + return wasmtypes.NewScMutableAgentID(s.proxy.Root(ParamApproved)) } -func (s MutableApproveParams) TokenID() wasmlib.ScMutableHash { - return wasmlib.NewScMutableHash(s.id, wasmlib.KeyID(ParamTokenID)) +func (s MutableApproveParams) TokenID() wasmtypes.ScMutableHash { + return wasmtypes.NewScMutableHash(s.proxy.Root(ParamTokenID)) } type ImmutableBurnParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableBurnParams) TokenID() wasmlib.ScImmutableHash { - return wasmlib.NewScImmutableHash(s.id, wasmlib.KeyID(ParamTokenID)) +func (s ImmutableBurnParams) TokenID() wasmtypes.ScImmutableHash { + return wasmtypes.NewScImmutableHash(s.proxy.Root(ParamTokenID)) } type MutableBurnParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableBurnParams) TokenID() wasmlib.ScMutableHash { - return wasmlib.NewScMutableHash(s.id, wasmlib.KeyID(ParamTokenID)) +func (s MutableBurnParams) TokenID() wasmtypes.ScMutableHash { + return wasmtypes.NewScMutableHash(s.proxy.Root(ParamTokenID)) } type ImmutableInitParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableInitParams) Name() wasmlib.ScImmutableString { - return wasmlib.NewScImmutableString(s.id, idxMap[IdxParamName]) +func (s ImmutableInitParams) Name() wasmtypes.ScImmutableString { + return wasmtypes.NewScImmutableString(s.proxy.Root(ParamName)) } -func (s ImmutableInitParams) Symbol() wasmlib.ScImmutableString { - return wasmlib.NewScImmutableString(s.id, idxMap[IdxParamSymbol]) +func (s ImmutableInitParams) Symbol() wasmtypes.ScImmutableString { + return wasmtypes.NewScImmutableString(s.proxy.Root(ParamSymbol)) } type MutableInitParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableInitParams) Name() wasmlib.ScMutableString { - return wasmlib.NewScMutableString(s.id, idxMap[IdxParamName]) +func (s MutableInitParams) Name() wasmtypes.ScMutableString { + return wasmtypes.NewScMutableString(s.proxy.Root(ParamName)) } -func (s MutableInitParams) Symbol() wasmlib.ScMutableString { - return wasmlib.NewScMutableString(s.id, idxMap[IdxParamSymbol]) +func (s MutableInitParams) Symbol() wasmtypes.ScMutableString { + return wasmtypes.NewScMutableString(s.proxy.Root(ParamSymbol)) } type ImmutableMintParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableMintParams) TokenID() wasmlib.ScImmutableHash { - return wasmlib.NewScImmutableHash(s.id, wasmlib.KeyID(ParamTokenID)) +func (s ImmutableMintParams) TokenID() wasmtypes.ScImmutableHash { + return wasmtypes.NewScImmutableHash(s.proxy.Root(ParamTokenID)) } -func (s ImmutableMintParams) TokenURI() wasmlib.ScImmutableString { - return wasmlib.NewScImmutableString(s.id, wasmlib.KeyID(ParamTokenURI)) +func (s ImmutableMintParams) TokenURI() wasmtypes.ScImmutableString { + return wasmtypes.NewScImmutableString(s.proxy.Root(ParamTokenURI)) } type MutableMintParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableMintParams) TokenID() wasmlib.ScMutableHash { - return wasmlib.NewScMutableHash(s.id, wasmlib.KeyID(ParamTokenID)) +func (s MutableMintParams) TokenID() wasmtypes.ScMutableHash { + return wasmtypes.NewScMutableHash(s.proxy.Root(ParamTokenID)) } -func (s MutableMintParams) TokenURI() wasmlib.ScMutableString { - return wasmlib.NewScMutableString(s.id, wasmlib.KeyID(ParamTokenURI)) +func (s MutableMintParams) TokenURI() wasmtypes.ScMutableString { + return wasmtypes.NewScMutableString(s.proxy.Root(ParamTokenURI)) } type ImmutableSafeTransferFromParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableSafeTransferFromParams) Data() wasmlib.ScImmutableBytes { - return wasmlib.NewScImmutableBytes(s.id, wasmlib.KeyID(ParamData)) +func (s ImmutableSafeTransferFromParams) Data() wasmtypes.ScImmutableBytes { + return wasmtypes.NewScImmutableBytes(s.proxy.Root(ParamData)) } -func (s ImmutableSafeTransferFromParams) From() wasmlib.ScImmutableAgentID { - return wasmlib.NewScImmutableAgentID(s.id, wasmlib.KeyID(ParamFrom)) +func (s ImmutableSafeTransferFromParams) From() wasmtypes.ScImmutableAgentID { + return wasmtypes.NewScImmutableAgentID(s.proxy.Root(ParamFrom)) } -func (s ImmutableSafeTransferFromParams) To() wasmlib.ScImmutableAgentID { - return wasmlib.NewScImmutableAgentID(s.id, wasmlib.KeyID(ParamTo)) +func (s ImmutableSafeTransferFromParams) To() wasmtypes.ScImmutableAgentID { + return wasmtypes.NewScImmutableAgentID(s.proxy.Root(ParamTo)) } -func (s ImmutableSafeTransferFromParams) TokenID() wasmlib.ScImmutableHash { - return wasmlib.NewScImmutableHash(s.id, wasmlib.KeyID(ParamTokenID)) +func (s ImmutableSafeTransferFromParams) TokenID() wasmtypes.ScImmutableHash { + return wasmtypes.NewScImmutableHash(s.proxy.Root(ParamTokenID)) } type MutableSafeTransferFromParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableSafeTransferFromParams) Data() wasmlib.ScMutableBytes { - return wasmlib.NewScMutableBytes(s.id, wasmlib.KeyID(ParamData)) +func (s MutableSafeTransferFromParams) Data() wasmtypes.ScMutableBytes { + return wasmtypes.NewScMutableBytes(s.proxy.Root(ParamData)) } -func (s MutableSafeTransferFromParams) From() wasmlib.ScMutableAgentID { - return wasmlib.NewScMutableAgentID(s.id, wasmlib.KeyID(ParamFrom)) +func (s MutableSafeTransferFromParams) From() wasmtypes.ScMutableAgentID { + return wasmtypes.NewScMutableAgentID(s.proxy.Root(ParamFrom)) } -func (s MutableSafeTransferFromParams) To() wasmlib.ScMutableAgentID { - return wasmlib.NewScMutableAgentID(s.id, wasmlib.KeyID(ParamTo)) +func (s MutableSafeTransferFromParams) To() wasmtypes.ScMutableAgentID { + return wasmtypes.NewScMutableAgentID(s.proxy.Root(ParamTo)) } -func (s MutableSafeTransferFromParams) TokenID() wasmlib.ScMutableHash { - return wasmlib.NewScMutableHash(s.id, wasmlib.KeyID(ParamTokenID)) +func (s MutableSafeTransferFromParams) TokenID() wasmtypes.ScMutableHash { + return wasmtypes.NewScMutableHash(s.proxy.Root(ParamTokenID)) } type ImmutableSetApprovalForAllParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableSetApprovalForAllParams) Approval() wasmlib.ScImmutableBool { - return wasmlib.NewScImmutableBool(s.id, wasmlib.KeyID(ParamApproval)) +func (s ImmutableSetApprovalForAllParams) Approval() wasmtypes.ScImmutableBool { + return wasmtypes.NewScImmutableBool(s.proxy.Root(ParamApproval)) } -func (s ImmutableSetApprovalForAllParams) Operator() wasmlib.ScImmutableAgentID { - return wasmlib.NewScImmutableAgentID(s.id, wasmlib.KeyID(ParamOperator)) +func (s ImmutableSetApprovalForAllParams) Operator() wasmtypes.ScImmutableAgentID { + return wasmtypes.NewScImmutableAgentID(s.proxy.Root(ParamOperator)) } type MutableSetApprovalForAllParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableSetApprovalForAllParams) Approval() wasmlib.ScMutableBool { - return wasmlib.NewScMutableBool(s.id, wasmlib.KeyID(ParamApproval)) +func (s MutableSetApprovalForAllParams) Approval() wasmtypes.ScMutableBool { + return wasmtypes.NewScMutableBool(s.proxy.Root(ParamApproval)) } -func (s MutableSetApprovalForAllParams) Operator() wasmlib.ScMutableAgentID { - return wasmlib.NewScMutableAgentID(s.id, wasmlib.KeyID(ParamOperator)) +func (s MutableSetApprovalForAllParams) Operator() wasmtypes.ScMutableAgentID { + return wasmtypes.NewScMutableAgentID(s.proxy.Root(ParamOperator)) } type ImmutableTransferFromParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableTransferFromParams) From() wasmlib.ScImmutableAgentID { - return wasmlib.NewScImmutableAgentID(s.id, wasmlib.KeyID(ParamFrom)) +func (s ImmutableTransferFromParams) From() wasmtypes.ScImmutableAgentID { + return wasmtypes.NewScImmutableAgentID(s.proxy.Root(ParamFrom)) } -func (s ImmutableTransferFromParams) To() wasmlib.ScImmutableAgentID { - return wasmlib.NewScImmutableAgentID(s.id, wasmlib.KeyID(ParamTo)) +func (s ImmutableTransferFromParams) To() wasmtypes.ScImmutableAgentID { + return wasmtypes.NewScImmutableAgentID(s.proxy.Root(ParamTo)) } -func (s ImmutableTransferFromParams) TokenID() wasmlib.ScImmutableHash { - return wasmlib.NewScImmutableHash(s.id, wasmlib.KeyID(ParamTokenID)) +func (s ImmutableTransferFromParams) TokenID() wasmtypes.ScImmutableHash { + return wasmtypes.NewScImmutableHash(s.proxy.Root(ParamTokenID)) } type MutableTransferFromParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableTransferFromParams) From() wasmlib.ScMutableAgentID { - return wasmlib.NewScMutableAgentID(s.id, wasmlib.KeyID(ParamFrom)) +func (s MutableTransferFromParams) From() wasmtypes.ScMutableAgentID { + return wasmtypes.NewScMutableAgentID(s.proxy.Root(ParamFrom)) } -func (s MutableTransferFromParams) To() wasmlib.ScMutableAgentID { - return wasmlib.NewScMutableAgentID(s.id, wasmlib.KeyID(ParamTo)) +func (s MutableTransferFromParams) To() wasmtypes.ScMutableAgentID { + return wasmtypes.NewScMutableAgentID(s.proxy.Root(ParamTo)) } -func (s MutableTransferFromParams) TokenID() wasmlib.ScMutableHash { - return wasmlib.NewScMutableHash(s.id, wasmlib.KeyID(ParamTokenID)) +func (s MutableTransferFromParams) TokenID() wasmtypes.ScMutableHash { + return wasmtypes.NewScMutableHash(s.proxy.Root(ParamTokenID)) } type ImmutableBalanceOfParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableBalanceOfParams) Owner() wasmlib.ScImmutableAgentID { - return wasmlib.NewScImmutableAgentID(s.id, wasmlib.KeyID(ParamOwner)) +func (s ImmutableBalanceOfParams) Owner() wasmtypes.ScImmutableAgentID { + return wasmtypes.NewScImmutableAgentID(s.proxy.Root(ParamOwner)) } type MutableBalanceOfParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableBalanceOfParams) Owner() wasmlib.ScMutableAgentID { - return wasmlib.NewScMutableAgentID(s.id, wasmlib.KeyID(ParamOwner)) +func (s MutableBalanceOfParams) Owner() wasmtypes.ScMutableAgentID { + return wasmtypes.NewScMutableAgentID(s.proxy.Root(ParamOwner)) } type ImmutableGetApprovedParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableGetApprovedParams) TokenID() wasmlib.ScImmutableHash { - return wasmlib.NewScImmutableHash(s.id, wasmlib.KeyID(ParamTokenID)) +func (s ImmutableGetApprovedParams) TokenID() wasmtypes.ScImmutableHash { + return wasmtypes.NewScImmutableHash(s.proxy.Root(ParamTokenID)) } type MutableGetApprovedParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableGetApprovedParams) TokenID() wasmlib.ScMutableHash { - return wasmlib.NewScMutableHash(s.id, wasmlib.KeyID(ParamTokenID)) +func (s MutableGetApprovedParams) TokenID() wasmtypes.ScMutableHash { + return wasmtypes.NewScMutableHash(s.proxy.Root(ParamTokenID)) } type ImmutableIsApprovedForAllParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableIsApprovedForAllParams) Operator() wasmlib.ScImmutableAgentID { - return wasmlib.NewScImmutableAgentID(s.id, wasmlib.KeyID(ParamOperator)) +func (s ImmutableIsApprovedForAllParams) Operator() wasmtypes.ScImmutableAgentID { + return wasmtypes.NewScImmutableAgentID(s.proxy.Root(ParamOperator)) } -func (s ImmutableIsApprovedForAllParams) Owner() wasmlib.ScImmutableAgentID { - return wasmlib.NewScImmutableAgentID(s.id, wasmlib.KeyID(ParamOwner)) +func (s ImmutableIsApprovedForAllParams) Owner() wasmtypes.ScImmutableAgentID { + return wasmtypes.NewScImmutableAgentID(s.proxy.Root(ParamOwner)) } type MutableIsApprovedForAllParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableIsApprovedForAllParams) Operator() wasmlib.ScMutableAgentID { - return wasmlib.NewScMutableAgentID(s.id, wasmlib.KeyID(ParamOperator)) +func (s MutableIsApprovedForAllParams) Operator() wasmtypes.ScMutableAgentID { + return wasmtypes.NewScMutableAgentID(s.proxy.Root(ParamOperator)) } -func (s MutableIsApprovedForAllParams) Owner() wasmlib.ScMutableAgentID { - return wasmlib.NewScMutableAgentID(s.id, wasmlib.KeyID(ParamOwner)) +func (s MutableIsApprovedForAllParams) Owner() wasmtypes.ScMutableAgentID { + return wasmtypes.NewScMutableAgentID(s.proxy.Root(ParamOwner)) } type ImmutableOwnerOfParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableOwnerOfParams) TokenID() wasmlib.ScImmutableHash { - return wasmlib.NewScImmutableHash(s.id, wasmlib.KeyID(ParamTokenID)) +func (s ImmutableOwnerOfParams) TokenID() wasmtypes.ScImmutableHash { + return wasmtypes.NewScImmutableHash(s.proxy.Root(ParamTokenID)) } type MutableOwnerOfParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableOwnerOfParams) TokenID() wasmlib.ScMutableHash { - return wasmlib.NewScMutableHash(s.id, wasmlib.KeyID(ParamTokenID)) +func (s MutableOwnerOfParams) TokenID() wasmtypes.ScMutableHash { + return wasmtypes.NewScMutableHash(s.proxy.Root(ParamTokenID)) } type ImmutableTokenURIParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableTokenURIParams) TokenID() wasmlib.ScImmutableHash { - return wasmlib.NewScImmutableHash(s.id, wasmlib.KeyID(ParamTokenID)) +func (s ImmutableTokenURIParams) TokenID() wasmtypes.ScImmutableHash { + return wasmtypes.NewScImmutableHash(s.proxy.Root(ParamTokenID)) } type MutableTokenURIParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableTokenURIParams) TokenID() wasmlib.ScMutableHash { - return wasmlib.NewScMutableHash(s.id, wasmlib.KeyID(ParamTokenID)) +func (s MutableTokenURIParams) TokenID() wasmtypes.ScMutableHash { + return wasmtypes.NewScMutableHash(s.proxy.Root(ParamTokenID)) } diff --git a/contracts/wasm/erc721/go/erc721/results.go b/contracts/wasm/erc721/go/erc721/results.go index ff831db9c0..78ed3a0797 100644 --- a/contracts/wasm/erc721/go/erc721/results.go +++ b/contracts/wasm/erc721/go/erc721/results.go @@ -7,116 +7,116 @@ package erc721 -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" +import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" type ImmutableBalanceOfResults struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableBalanceOfResults) Amount() wasmlib.ScImmutableUint64 { - return wasmlib.NewScImmutableUint64(s.id, wasmlib.KeyID(ResultAmount)) +func (s ImmutableBalanceOfResults) Amount() wasmtypes.ScImmutableUint64 { + return wasmtypes.NewScImmutableUint64(s.proxy.Root(ResultAmount)) } type MutableBalanceOfResults struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableBalanceOfResults) Amount() wasmlib.ScMutableUint64 { - return wasmlib.NewScMutableUint64(s.id, wasmlib.KeyID(ResultAmount)) +func (s MutableBalanceOfResults) Amount() wasmtypes.ScMutableUint64 { + return wasmtypes.NewScMutableUint64(s.proxy.Root(ResultAmount)) } type ImmutableGetApprovedResults struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableGetApprovedResults) Approved() wasmlib.ScImmutableAgentID { - return wasmlib.NewScImmutableAgentID(s.id, wasmlib.KeyID(ResultApproved)) +func (s ImmutableGetApprovedResults) Approved() wasmtypes.ScImmutableAgentID { + return wasmtypes.NewScImmutableAgentID(s.proxy.Root(ResultApproved)) } type MutableGetApprovedResults struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableGetApprovedResults) Approved() wasmlib.ScMutableAgentID { - return wasmlib.NewScMutableAgentID(s.id, wasmlib.KeyID(ResultApproved)) +func (s MutableGetApprovedResults) Approved() wasmtypes.ScMutableAgentID { + return wasmtypes.NewScMutableAgentID(s.proxy.Root(ResultApproved)) } type ImmutableIsApprovedForAllResults struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableIsApprovedForAllResults) Approval() wasmlib.ScImmutableBool { - return wasmlib.NewScImmutableBool(s.id, wasmlib.KeyID(ResultApproval)) +func (s ImmutableIsApprovedForAllResults) Approval() wasmtypes.ScImmutableBool { + return wasmtypes.NewScImmutableBool(s.proxy.Root(ResultApproval)) } type MutableIsApprovedForAllResults struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableIsApprovedForAllResults) Approval() wasmlib.ScMutableBool { - return wasmlib.NewScMutableBool(s.id, wasmlib.KeyID(ResultApproval)) +func (s MutableIsApprovedForAllResults) Approval() wasmtypes.ScMutableBool { + return wasmtypes.NewScMutableBool(s.proxy.Root(ResultApproval)) } type ImmutableNameResults struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableNameResults) Name() wasmlib.ScImmutableString { - return wasmlib.NewScImmutableString(s.id, wasmlib.KeyID(ResultName)) +func (s ImmutableNameResults) Name() wasmtypes.ScImmutableString { + return wasmtypes.NewScImmutableString(s.proxy.Root(ResultName)) } type MutableNameResults struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableNameResults) Name() wasmlib.ScMutableString { - return wasmlib.NewScMutableString(s.id, wasmlib.KeyID(ResultName)) +func (s MutableNameResults) Name() wasmtypes.ScMutableString { + return wasmtypes.NewScMutableString(s.proxy.Root(ResultName)) } type ImmutableOwnerOfResults struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableOwnerOfResults) Owner() wasmlib.ScImmutableAgentID { - return wasmlib.NewScImmutableAgentID(s.id, wasmlib.KeyID(ResultOwner)) +func (s ImmutableOwnerOfResults) Owner() wasmtypes.ScImmutableAgentID { + return wasmtypes.NewScImmutableAgentID(s.proxy.Root(ResultOwner)) } type MutableOwnerOfResults struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableOwnerOfResults) Owner() wasmlib.ScMutableAgentID { - return wasmlib.NewScMutableAgentID(s.id, wasmlib.KeyID(ResultOwner)) +func (s MutableOwnerOfResults) Owner() wasmtypes.ScMutableAgentID { + return wasmtypes.NewScMutableAgentID(s.proxy.Root(ResultOwner)) } type ImmutableSymbolResults struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableSymbolResults) Symbol() wasmlib.ScImmutableString { - return wasmlib.NewScImmutableString(s.id, wasmlib.KeyID(ResultSymbol)) +func (s ImmutableSymbolResults) Symbol() wasmtypes.ScImmutableString { + return wasmtypes.NewScImmutableString(s.proxy.Root(ResultSymbol)) } type MutableSymbolResults struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableSymbolResults) Symbol() wasmlib.ScMutableString { - return wasmlib.NewScMutableString(s.id, wasmlib.KeyID(ResultSymbol)) +func (s MutableSymbolResults) Symbol() wasmtypes.ScMutableString { + return wasmtypes.NewScMutableString(s.proxy.Root(ResultSymbol)) } type ImmutableTokenURIResults struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableTokenURIResults) TokenURI() wasmlib.ScImmutableString { - return wasmlib.NewScImmutableString(s.id, wasmlib.KeyID(ResultTokenURI)) +func (s ImmutableTokenURIResults) TokenURI() wasmtypes.ScImmutableString { + return wasmtypes.NewScImmutableString(s.proxy.Root(ResultTokenURI)) } type MutableTokenURIResults struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableTokenURIResults) TokenURI() wasmlib.ScMutableString { - return wasmlib.NewScMutableString(s.id, wasmlib.KeyID(ResultTokenURI)) +func (s MutableTokenURIResults) TokenURI() wasmtypes.ScMutableString { + return wasmtypes.NewScMutableString(s.proxy.Root(ResultTokenURI)) } diff --git a/contracts/wasm/erc721/go/erc721/state.go b/contracts/wasm/erc721/go/erc721/state.go index e2204b0108..f282488665 100644 --- a/contracts/wasm/erc721/go/erc721/state.go +++ b/contracts/wasm/erc721/go/erc721/state.go @@ -7,129 +7,122 @@ package erc721 -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" +import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" type MapHashToImmutableAgentID struct { - objID int32 + proxy wasmtypes.Proxy } -func (m MapHashToImmutableAgentID) GetAgentID(key wasmlib.ScHash) wasmlib.ScImmutableAgentID { - return wasmlib.NewScImmutableAgentID(m.objID, key.KeyID()) +func (m MapHashToImmutableAgentID) GetAgentID(key wasmtypes.ScHash) wasmtypes.ScImmutableAgentID { + return wasmtypes.NewScImmutableAgentID(m.proxy.Key(key.Bytes())) } type MapAgentIDToImmutableOperators struct { - objID int32 + proxy wasmtypes.Proxy } -func (m MapAgentIDToImmutableOperators) GetOperators(key wasmlib.ScAgentID) ImmutableOperators { - subID := wasmlib.GetObjectID(m.objID, key.KeyID(), wasmlib.TYPE_MAP) - return ImmutableOperators{objID: subID} +func (m MapAgentIDToImmutableOperators) GetOperators(key wasmtypes.ScAgentID) ImmutableOperators { + return ImmutableOperators{proxy: m.proxy.Key(key.Bytes())} } type MapAgentIDToImmutableUint64 struct { - objID int32 + proxy wasmtypes.Proxy } -func (m MapAgentIDToImmutableUint64) GetUint64(key wasmlib.ScAgentID) wasmlib.ScImmutableUint64 { - return wasmlib.NewScImmutableUint64(m.objID, key.KeyID()) +func (m MapAgentIDToImmutableUint64) GetUint64(key wasmtypes.ScAgentID) wasmtypes.ScImmutableUint64 { + return wasmtypes.NewScImmutableUint64(m.proxy.Key(key.Bytes())) } type MapHashToImmutableString struct { - objID int32 + proxy wasmtypes.Proxy } -func (m MapHashToImmutableString) GetString(key wasmlib.ScHash) wasmlib.ScImmutableString { - return wasmlib.NewScImmutableString(m.objID, key.KeyID()) +func (m MapHashToImmutableString) GetString(key wasmtypes.ScHash) wasmtypes.ScImmutableString { + return wasmtypes.NewScImmutableString(m.proxy.Key(key.Bytes())) } type ImmutableErc721State struct { - id int32 + proxy wasmtypes.Proxy } func (s ImmutableErc721State) ApprovedAccounts() MapHashToImmutableAgentID { - mapID := wasmlib.GetObjectID(s.id, wasmlib.KeyID(StateApprovedAccounts), wasmlib.TYPE_MAP) - return MapHashToImmutableAgentID{objID: mapID} + return MapHashToImmutableAgentID{proxy: s.proxy.Root(StateApprovedAccounts)} } func (s ImmutableErc721State) ApprovedOperators() MapAgentIDToImmutableOperators { - mapID := wasmlib.GetObjectID(s.id, wasmlib.KeyID(StateApprovedOperators), wasmlib.TYPE_MAP) - return MapAgentIDToImmutableOperators{objID: mapID} + return MapAgentIDToImmutableOperators{proxy: s.proxy.Root(StateApprovedOperators)} } func (s ImmutableErc721State) Balances() MapAgentIDToImmutableUint64 { - mapID := wasmlib.GetObjectID(s.id, wasmlib.KeyID(StateBalances), wasmlib.TYPE_MAP) - return MapAgentIDToImmutableUint64{objID: mapID} + return MapAgentIDToImmutableUint64{proxy: s.proxy.Root(StateBalances)} } -func (s ImmutableErc721State) Name() wasmlib.ScImmutableString { - return wasmlib.NewScImmutableString(s.id, wasmlib.KeyID(StateName)) +func (s ImmutableErc721State) Name() wasmtypes.ScImmutableString { + return wasmtypes.NewScImmutableString(s.proxy.Root(StateName)) } func (s ImmutableErc721State) Owners() MapHashToImmutableAgentID { - mapID := wasmlib.GetObjectID(s.id, wasmlib.KeyID(StateOwners), wasmlib.TYPE_MAP) - return MapHashToImmutableAgentID{objID: mapID} + return MapHashToImmutableAgentID{proxy: s.proxy.Root(StateOwners)} } -func (s ImmutableErc721State) Symbol() wasmlib.ScImmutableString { - return wasmlib.NewScImmutableString(s.id, wasmlib.KeyID(StateSymbol)) +func (s ImmutableErc721State) Symbol() wasmtypes.ScImmutableString { + return wasmtypes.NewScImmutableString(s.proxy.Root(StateSymbol)) } func (s ImmutableErc721State) TokenURIs() MapHashToImmutableString { - mapID := wasmlib.GetObjectID(s.id, wasmlib.KeyID(StateTokenURIs), wasmlib.TYPE_MAP) - return MapHashToImmutableString{objID: mapID} + return MapHashToImmutableString{proxy: s.proxy.Root(StateTokenURIs)} } type MapHashToMutableAgentID struct { - objID int32 + proxy wasmtypes.Proxy } func (m MapHashToMutableAgentID) Clear() { - wasmlib.Clear(m.objID) + m.proxy.ClearMap() } -func (m MapHashToMutableAgentID) GetAgentID(key wasmlib.ScHash) wasmlib.ScMutableAgentID { - return wasmlib.NewScMutableAgentID(m.objID, key.KeyID()) +func (m MapHashToMutableAgentID) GetAgentID(key wasmtypes.ScHash) wasmtypes.ScMutableAgentID { + return wasmtypes.NewScMutableAgentID(m.proxy.Key(key.Bytes())) } type MapAgentIDToMutableOperators struct { - objID int32 + proxy wasmtypes.Proxy } func (m MapAgentIDToMutableOperators) Clear() { - wasmlib.Clear(m.objID) + m.proxy.ClearMap() } -func (m MapAgentIDToMutableOperators) GetOperators(key wasmlib.ScAgentID) MutableOperators { - subID := wasmlib.GetObjectID(m.objID, key.KeyID(), wasmlib.TYPE_MAP) - return MutableOperators{objID: subID} +func (m MapAgentIDToMutableOperators) GetOperators(key wasmtypes.ScAgentID) MutableOperators { + return MutableOperators{proxy: m.proxy.Key(key.Bytes())} } type MapAgentIDToMutableUint64 struct { - objID int32 + proxy wasmtypes.Proxy } func (m MapAgentIDToMutableUint64) Clear() { - wasmlib.Clear(m.objID) + m.proxy.ClearMap() } -func (m MapAgentIDToMutableUint64) GetUint64(key wasmlib.ScAgentID) wasmlib.ScMutableUint64 { - return wasmlib.NewScMutableUint64(m.objID, key.KeyID()) +func (m MapAgentIDToMutableUint64) GetUint64(key wasmtypes.ScAgentID) wasmtypes.ScMutableUint64 { + return wasmtypes.NewScMutableUint64(m.proxy.Key(key.Bytes())) } type MapHashToMutableString struct { - objID int32 + proxy wasmtypes.Proxy } func (m MapHashToMutableString) Clear() { - wasmlib.Clear(m.objID) + m.proxy.ClearMap() } -func (m MapHashToMutableString) GetString(key wasmlib.ScHash) wasmlib.ScMutableString { - return wasmlib.NewScMutableString(m.objID, key.KeyID()) +func (m MapHashToMutableString) GetString(key wasmtypes.ScHash) wasmtypes.ScMutableString { + return wasmtypes.NewScMutableString(m.proxy.Key(key.Bytes())) } type MutableErc721State struct { - id int32 + proxy wasmtypes.Proxy } func (s MutableErc721State) AsImmutable() ImmutableErc721State { @@ -137,34 +130,29 @@ func (s MutableErc721State) AsImmutable() ImmutableErc721State { } func (s MutableErc721State) ApprovedAccounts() MapHashToMutableAgentID { - mapID := wasmlib.GetObjectID(s.id, wasmlib.KeyID(StateApprovedAccounts), wasmlib.TYPE_MAP) - return MapHashToMutableAgentID{objID: mapID} + return MapHashToMutableAgentID{proxy: s.proxy.Root(StateApprovedAccounts)} } func (s MutableErc721State) ApprovedOperators() MapAgentIDToMutableOperators { - mapID := wasmlib.GetObjectID(s.id, wasmlib.KeyID(StateApprovedOperators), wasmlib.TYPE_MAP) - return MapAgentIDToMutableOperators{objID: mapID} + return MapAgentIDToMutableOperators{proxy: s.proxy.Root(StateApprovedOperators)} } func (s MutableErc721State) Balances() MapAgentIDToMutableUint64 { - mapID := wasmlib.GetObjectID(s.id, wasmlib.KeyID(StateBalances), wasmlib.TYPE_MAP) - return MapAgentIDToMutableUint64{objID: mapID} + return MapAgentIDToMutableUint64{proxy: s.proxy.Root(StateBalances)} } -func (s MutableErc721State) Name() wasmlib.ScMutableString { - return wasmlib.NewScMutableString(s.id, wasmlib.KeyID(StateName)) +func (s MutableErc721State) Name() wasmtypes.ScMutableString { + return wasmtypes.NewScMutableString(s.proxy.Root(StateName)) } func (s MutableErc721State) Owners() MapHashToMutableAgentID { - mapID := wasmlib.GetObjectID(s.id, wasmlib.KeyID(StateOwners), wasmlib.TYPE_MAP) - return MapHashToMutableAgentID{objID: mapID} + return MapHashToMutableAgentID{proxy: s.proxy.Root(StateOwners)} } -func (s MutableErc721State) Symbol() wasmlib.ScMutableString { - return wasmlib.NewScMutableString(s.id, wasmlib.KeyID(StateSymbol)) +func (s MutableErc721State) Symbol() wasmtypes.ScMutableString { + return wasmtypes.NewScMutableString(s.proxy.Root(StateSymbol)) } func (s MutableErc721State) TokenURIs() MapHashToMutableString { - mapID := wasmlib.GetObjectID(s.id, wasmlib.KeyID(StateTokenURIs), wasmlib.TYPE_MAP) - return MapHashToMutableString{objID: mapID} + return MapHashToMutableString{proxy: s.proxy.Root(StateTokenURIs)} } diff --git a/contracts/wasm/erc721/go/erc721/typedefs.go b/contracts/wasm/erc721/go/erc721/typedefs.go index b9f771d048..c115aa21fc 100644 --- a/contracts/wasm/erc721/go/erc721/typedefs.go +++ b/contracts/wasm/erc721/go/erc721/typedefs.go @@ -7,28 +7,28 @@ package erc721 -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" +import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" type MapAgentIDToImmutableBool struct { - objID int32 + proxy wasmtypes.Proxy } -func (m MapAgentIDToImmutableBool) GetBool(key wasmlib.ScAgentID) wasmlib.ScImmutableBool { - return wasmlib.NewScImmutableBool(m.objID, key.KeyID()) +func (m MapAgentIDToImmutableBool) GetBool(key wasmtypes.ScAgentID) wasmtypes.ScImmutableBool { + return wasmtypes.NewScImmutableBool(m.proxy.Key(key.Bytes())) } type ImmutableOperators = MapAgentIDToImmutableBool type MapAgentIDToMutableBool struct { - objID int32 + proxy wasmtypes.Proxy } func (m MapAgentIDToMutableBool) Clear() { - wasmlib.Clear(m.objID) + m.proxy.ClearMap() } -func (m MapAgentIDToMutableBool) GetBool(key wasmlib.ScAgentID) wasmlib.ScMutableBool { - return wasmlib.NewScMutableBool(m.objID, key.KeyID()) +func (m MapAgentIDToMutableBool) GetBool(key wasmtypes.ScAgentID) wasmtypes.ScMutableBool { + return wasmtypes.NewScMutableBool(m.proxy.Key(key.Bytes())) } type MutableOperators = MapAgentIDToMutableBool diff --git a/contracts/wasm/erc721/go/erc721client/events.go b/contracts/wasm/erc721/go/erc721client/events.go new file mode 100644 index 0000000000..9a1b3a691f --- /dev/null +++ b/contracts/wasm/erc721/go/erc721client/events.go @@ -0,0 +1,146 @@ +// Copyright 2020 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +// (Re-)generated by schema tool +// >>>> DO NOT CHANGE THIS FILE! <<<< +// Change the json schema instead + +package erc721client + +import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmclient" + +var erc721Handlers = map[string]func(*Erc721Events, []string){ + "erc721.approval": func(evt *Erc721Events, msg []string) { evt.onErc721ApprovalThunk(msg) }, + "erc721.approvalForAll": func(evt *Erc721Events, msg []string) { evt.onErc721ApprovalForAllThunk(msg) }, + "erc721.init": func(evt *Erc721Events, msg []string) { evt.onErc721InitThunk(msg) }, + "erc721.mint": func(evt *Erc721Events, msg []string) { evt.onErc721MintThunk(msg) }, + "erc721.transfer": func(evt *Erc721Events, msg []string) { evt.onErc721TransferThunk(msg) }, +} + +type Erc721Events struct { + approval func(e *EventApproval) + approvalForAll func(e *EventApprovalForAll) + init func(e *EventInit) + mint func(e *EventMint) + transfer func(e *EventTransfer) +} + +func (h *Erc721Events) CallHandler(topic string, params []string) { + handler := erc721Handlers[topic] + if handler != nil { + handler(h, params) + } +} + +func (h *Erc721Events) OnErc721Approval(handler func(e *EventApproval)) { + h.approval = handler +} + +func (h *Erc721Events) OnErc721ApprovalForAll(handler func(e *EventApprovalForAll)) { + h.approvalForAll = handler +} + +func (h *Erc721Events) OnErc721Init(handler func(e *EventInit)) { + h.init = handler +} + +func (h *Erc721Events) OnErc721Mint(handler func(e *EventMint)) { + h.mint = handler +} + +func (h *Erc721Events) OnErc721Transfer(handler func(e *EventTransfer)) { + h.transfer = handler +} + +type EventApproval struct { + wasmclient.Event + Approved wasmclient.AgentID + Owner wasmclient.AgentID + TokenID wasmclient.Hash +} + +func (h *Erc721Events) onErc721ApprovalThunk(message []string) { + if h.approval == nil { + return + } + e := &EventApproval{} + e.Init(message) + e.Approved = e.NextAgentID() + e.Owner = e.NextAgentID() + e.TokenID = e.NextHash() + h.approval(e) +} + +type EventApprovalForAll struct { + wasmclient.Event + Approval bool + Operator wasmclient.AgentID + Owner wasmclient.AgentID +} + +func (h *Erc721Events) onErc721ApprovalForAllThunk(message []string) { + if h.approvalForAll == nil { + return + } + e := &EventApprovalForAll{} + e.Init(message) + e.Approval = e.NextBool() + e.Operator = e.NextAgentID() + e.Owner = e.NextAgentID() + h.approvalForAll(e) +} + +type EventInit struct { + wasmclient.Event + Name string + Symbol string +} + +func (h *Erc721Events) onErc721InitThunk(message []string) { + if h.init == nil { + return + } + e := &EventInit{} + e.Init(message) + e.Name = e.NextString() + e.Symbol = e.NextString() + h.init(e) +} + +type EventMint struct { + wasmclient.Event + Balance uint64 + Owner wasmclient.AgentID + TokenID wasmclient.Hash +} + +func (h *Erc721Events) onErc721MintThunk(message []string) { + if h.mint == nil { + return + } + e := &EventMint{} + e.Init(message) + e.Balance = e.NextUint64() + e.Owner = e.NextAgentID() + e.TokenID = e.NextHash() + h.mint(e) +} + +type EventTransfer struct { + wasmclient.Event + From wasmclient.AgentID + To wasmclient.AgentID + TokenID wasmclient.Hash +} + +func (h *Erc721Events) onErc721TransferThunk(message []string) { + if h.transfer == nil { + return + } + e := &EventTransfer{} + e.Init(message) + e.From = e.NextAgentID() + e.To = e.NextAgentID() + e.TokenID = e.NextHash() + h.transfer(e) +} diff --git a/contracts/wasm/erc721/go/erc721client/service.go b/contracts/wasm/erc721/go/erc721client/service.go new file mode 100644 index 0000000000..3e9f540bbd --- /dev/null +++ b/contracts/wasm/erc721/go/erc721client/service.go @@ -0,0 +1,446 @@ +// Copyright 2020 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +// (Re-)generated by schema tool +// >>>> DO NOT CHANGE THIS FILE! <<<< +// Change the json schema instead + +package erc721client + +import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmclient" + +const ( + ArgApproval = "approval" + ArgApproved = "approved" + ArgData = "data" + ArgFrom = "from" + ArgName = "n" + ArgOperator = "operator" + ArgOwner = "owner" + ArgSymbol = "s" + ArgTo = "to" + ArgTokenID = "tokenID" + ArgTokenURI = "tokenURI" + + ResAmount = "amount" + ResApproval = "approval" + ResApproved = "approved" + ResName = "name" + ResOwner = "owner" + ResSymbol = "symbol" + ResTokenURI = "tokenURI" +) + +///////////////////////////// approve ///////////////////////////// + +type ApproveFunc struct { + wasmclient.ClientFunc + args wasmclient.Arguments +} + +func (f *ApproveFunc) Approved(v wasmclient.AgentID) { + f.args.Set(ArgApproved, f.args.FromAgentID(v)) +} + +func (f *ApproveFunc) TokenID(v wasmclient.Hash) { + f.args.Set(ArgTokenID, f.args.FromHash(v)) +} + +func (f *ApproveFunc) Post() wasmclient.Request { + f.args.Mandatory(ArgTokenID) + return f.ClientFunc.Post(0xa0661268, &f.args) +} + +///////////////////////////// burn ///////////////////////////// + +type BurnFunc struct { + wasmclient.ClientFunc + args wasmclient.Arguments +} + +func (f *BurnFunc) TokenID(v wasmclient.Hash) { + f.args.Set(ArgTokenID, f.args.FromHash(v)) +} + +func (f *BurnFunc) Post() wasmclient.Request { + f.args.Mandatory(ArgTokenID) + return f.ClientFunc.Post(0x7bc1efb1, &f.args) +} + +///////////////////////////// init ///////////////////////////// + +type InitFunc struct { + wasmclient.ClientFunc + args wasmclient.Arguments +} + +func (f *InitFunc) Name(v string) { + f.args.Set(ArgName, f.args.FromString(v)) +} + +func (f *InitFunc) Symbol(v string) { + f.args.Set(ArgSymbol, f.args.FromString(v)) +} + +func (f *InitFunc) Post() wasmclient.Request { + f.args.Mandatory(ArgName) + f.args.Mandatory(ArgSymbol) + return f.ClientFunc.Post(0x1f44d644, &f.args) +} + +///////////////////////////// mint ///////////////////////////// + +type MintFunc struct { + wasmclient.ClientFunc + args wasmclient.Arguments +} + +func (f *MintFunc) TokenID(v wasmclient.Hash) { + f.args.Set(ArgTokenID, f.args.FromHash(v)) +} + +func (f *MintFunc) TokenURI(v string) { + f.args.Set(ArgTokenURI, f.args.FromString(v)) +} + +func (f *MintFunc) Post() wasmclient.Request { + f.args.Mandatory(ArgTokenID) + return f.ClientFunc.Post(0xa29addcf, &f.args) +} + +///////////////////////////// safeTransferFrom ///////////////////////////// + +type SafeTransferFromFunc struct { + wasmclient.ClientFunc + args wasmclient.Arguments +} + +func (f *SafeTransferFromFunc) Data(v []byte) { + f.args.Set(ArgData, f.args.FromBytes(v)) +} + +func (f *SafeTransferFromFunc) From(v wasmclient.AgentID) { + f.args.Set(ArgFrom, f.args.FromAgentID(v)) +} + +func (f *SafeTransferFromFunc) To(v wasmclient.AgentID) { + f.args.Set(ArgTo, f.args.FromAgentID(v)) +} + +func (f *SafeTransferFromFunc) TokenID(v wasmclient.Hash) { + f.args.Set(ArgTokenID, f.args.FromHash(v)) +} + +func (f *SafeTransferFromFunc) Post() wasmclient.Request { + f.args.Mandatory(ArgFrom) + f.args.Mandatory(ArgTo) + f.args.Mandatory(ArgTokenID) + return f.ClientFunc.Post(0x130ce158, &f.args) +} + +///////////////////////////// setApprovalForAll ///////////////////////////// + +type SetApprovalForAllFunc struct { + wasmclient.ClientFunc + args wasmclient.Arguments +} + +func (f *SetApprovalForAllFunc) Approval(v bool) { + f.args.Set(ArgApproval, f.args.FromBool(v)) +} + +func (f *SetApprovalForAllFunc) Operator(v wasmclient.AgentID) { + f.args.Set(ArgOperator, f.args.FromAgentID(v)) +} + +func (f *SetApprovalForAllFunc) Post() wasmclient.Request { + f.args.Mandatory(ArgApproval) + f.args.Mandatory(ArgOperator) + return f.ClientFunc.Post(0xb8d8c776, &f.args) +} + +///////////////////////////// transferFrom ///////////////////////////// + +type TransferFromFunc struct { + wasmclient.ClientFunc + args wasmclient.Arguments +} + +func (f *TransferFromFunc) From(v wasmclient.AgentID) { + f.args.Set(ArgFrom, f.args.FromAgentID(v)) +} + +func (f *TransferFromFunc) To(v wasmclient.AgentID) { + f.args.Set(ArgTo, f.args.FromAgentID(v)) +} + +func (f *TransferFromFunc) TokenID(v wasmclient.Hash) { + f.args.Set(ArgTokenID, f.args.FromHash(v)) +} + +func (f *TransferFromFunc) Post() wasmclient.Request { + f.args.Mandatory(ArgFrom) + f.args.Mandatory(ArgTo) + f.args.Mandatory(ArgTokenID) + return f.ClientFunc.Post(0xd5e0a602, &f.args) +} + +///////////////////////////// balanceOf ///////////////////////////// + +type BalanceOfView struct { + wasmclient.ClientView + args wasmclient.Arguments +} + +func (f *BalanceOfView) Owner(v wasmclient.AgentID) { + f.args.Set(ArgOwner, f.args.FromAgentID(v)) +} + +func (f *BalanceOfView) Call() BalanceOfResults { + f.args.Mandatory(ArgOwner) + f.ClientView.Call("balanceOf", &f.args) + return BalanceOfResults{res: f.Results()} +} + +type BalanceOfResults struct { + res wasmclient.Results +} + +func (r *BalanceOfResults) AmountExists() bool { + return r.res.Exists(ResAmount) +} + +func (r *BalanceOfResults) Amount() uint64 { + return r.res.ToUint64(r.res.Get(ResAmount)) +} + +///////////////////////////// getApproved ///////////////////////////// + +type GetApprovedView struct { + wasmclient.ClientView + args wasmclient.Arguments +} + +func (f *GetApprovedView) TokenID(v wasmclient.Hash) { + f.args.Set(ArgTokenID, f.args.FromHash(v)) +} + +func (f *GetApprovedView) Call() GetApprovedResults { + f.args.Mandatory(ArgTokenID) + f.ClientView.Call("getApproved", &f.args) + return GetApprovedResults{res: f.Results()} +} + +type GetApprovedResults struct { + res wasmclient.Results +} + +func (r *GetApprovedResults) ApprovedExists() bool { + return r.res.Exists(ResApproved) +} + +func (r *GetApprovedResults) Approved() wasmclient.AgentID { + return r.res.ToAgentID(r.res.Get(ResApproved)) +} + +///////////////////////////// isApprovedForAll ///////////////////////////// + +type IsApprovedForAllView struct { + wasmclient.ClientView + args wasmclient.Arguments +} + +func (f *IsApprovedForAllView) Operator(v wasmclient.AgentID) { + f.args.Set(ArgOperator, f.args.FromAgentID(v)) +} + +func (f *IsApprovedForAllView) Owner(v wasmclient.AgentID) { + f.args.Set(ArgOwner, f.args.FromAgentID(v)) +} + +func (f *IsApprovedForAllView) Call() IsApprovedForAllResults { + f.args.Mandatory(ArgOperator) + f.args.Mandatory(ArgOwner) + f.ClientView.Call("isApprovedForAll", &f.args) + return IsApprovedForAllResults{res: f.Results()} +} + +type IsApprovedForAllResults struct { + res wasmclient.Results +} + +func (r *IsApprovedForAllResults) ApprovalExists() bool { + return r.res.Exists(ResApproval) +} + +func (r *IsApprovedForAllResults) Approval() bool { + return r.res.ToBool(r.res.Get(ResApproval)) +} + +///////////////////////////// name ///////////////////////////// + +type NameView struct { + wasmclient.ClientView +} + +func (f *NameView) Call() NameResults { + f.ClientView.Call("name", nil) + return NameResults{res: f.Results()} +} + +type NameResults struct { + res wasmclient.Results +} + +func (r *NameResults) Name() string { + return r.res.ToString(r.res.Get(ResName)) +} + +///////////////////////////// ownerOf ///////////////////////////// + +type OwnerOfView struct { + wasmclient.ClientView + args wasmclient.Arguments +} + +func (f *OwnerOfView) TokenID(v wasmclient.Hash) { + f.args.Set(ArgTokenID, f.args.FromHash(v)) +} + +func (f *OwnerOfView) Call() OwnerOfResults { + f.args.Mandatory(ArgTokenID) + f.ClientView.Call("ownerOf", &f.args) + return OwnerOfResults{res: f.Results()} +} + +type OwnerOfResults struct { + res wasmclient.Results +} + +func (r *OwnerOfResults) OwnerExists() bool { + return r.res.Exists(ResOwner) +} + +func (r *OwnerOfResults) Owner() wasmclient.AgentID { + return r.res.ToAgentID(r.res.Get(ResOwner)) +} + +///////////////////////////// symbol ///////////////////////////// + +type SymbolView struct { + wasmclient.ClientView +} + +func (f *SymbolView) Call() SymbolResults { + f.ClientView.Call("symbol", nil) + return SymbolResults{res: f.Results()} +} + +type SymbolResults struct { + res wasmclient.Results +} + +func (r *SymbolResults) Symbol() string { + return r.res.ToString(r.res.Get(ResSymbol)) +} + +///////////////////////////// tokenURI ///////////////////////////// + +type TokenURIView struct { + wasmclient.ClientView + args wasmclient.Arguments +} + +func (f *TokenURIView) TokenID(v wasmclient.Hash) { + f.args.Set(ArgTokenID, f.args.FromHash(v)) +} + +func (f *TokenURIView) Call() TokenURIResults { + f.args.Mandatory(ArgTokenID) + f.ClientView.Call("tokenURI", &f.args) + return TokenURIResults{res: f.Results()} +} + +type TokenURIResults struct { + res wasmclient.Results +} + +func (r *TokenURIResults) TokenURIExists() bool { + return r.res.Exists(ResTokenURI) +} + +func (r *TokenURIResults) TokenURI() string { + return r.res.ToString(r.res.Get(ResTokenURI)) +} + +///////////////////////////// Erc721Service ///////////////////////////// + +type Erc721Service struct { + wasmclient.Service +} + +func NewErc721Service(cl *wasmclient.ServiceClient, chainID string) (*Erc721Service, error) { + s := &Erc721Service{} + err := s.Service.Init(cl, chainID, 0xd967c216) + return s, err +} + +func (s *Erc721Service) NewEventHandler() *Erc721Events { + return &Erc721Events{} +} + +func (s *Erc721Service) Approve() ApproveFunc { + return ApproveFunc{ClientFunc: s.AsClientFunc()} +} + +func (s *Erc721Service) Burn() BurnFunc { + return BurnFunc{ClientFunc: s.AsClientFunc()} +} + +func (s *Erc721Service) Init() InitFunc { + return InitFunc{ClientFunc: s.AsClientFunc()} +} + +func (s *Erc721Service) Mint() MintFunc { + return MintFunc{ClientFunc: s.AsClientFunc()} +} + +func (s *Erc721Service) SafeTransferFrom() SafeTransferFromFunc { + return SafeTransferFromFunc{ClientFunc: s.AsClientFunc()} +} + +func (s *Erc721Service) SetApprovalForAll() SetApprovalForAllFunc { + return SetApprovalForAllFunc{ClientFunc: s.AsClientFunc()} +} + +func (s *Erc721Service) TransferFrom() TransferFromFunc { + return TransferFromFunc{ClientFunc: s.AsClientFunc()} +} + +func (s *Erc721Service) BalanceOf() BalanceOfView { + return BalanceOfView{ClientView: s.AsClientView()} +} + +func (s *Erc721Service) GetApproved() GetApprovedView { + return GetApprovedView{ClientView: s.AsClientView()} +} + +func (s *Erc721Service) IsApprovedForAll() IsApprovedForAllView { + return IsApprovedForAllView{ClientView: s.AsClientView()} +} + +func (s *Erc721Service) Name() NameView { + return NameView{ClientView: s.AsClientView()} +} + +func (s *Erc721Service) OwnerOf() OwnerOfView { + return OwnerOfView{ClientView: s.AsClientView()} +} + +func (s *Erc721Service) Symbol() SymbolView { + return SymbolView{ClientView: s.AsClientView()} +} + +func (s *Erc721Service) TokenURI() TokenURIView { + return TokenURIView{ClientView: s.AsClientView()} +} diff --git a/contracts/wasm/erc721/test/erc721_test.go b/contracts/wasm/erc721/test/erc721_test.go index b1f33b11ce..188c5eb13a 100644 --- a/contracts/wasm/erc721/test/erc721_test.go +++ b/contracts/wasm/erc721/test/erc721_test.go @@ -7,7 +7,7 @@ import ( "testing" "github.com/iotaledger/wasp/contracts/wasm/erc721/go/erc721" - "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" + "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" "github.com/iotaledger/wasp/packages/vm/wasmsolo" "github.com/stretchr/testify/require" ) @@ -20,7 +20,7 @@ func TestDeploy(t *testing.T) { func TestMint(t *testing.T) { ctx := setup(t) owner := ctx.NewSoloAgent() - tokenID := wasmlib.NewScHashFromBytes(owner.ScAgentID().Bytes()[:32]) + tokenID := wasmtypes.HashFromBytes(owner.ScAgentID().Bytes()[:32]) mint(ctx, owner, tokenID) require.NoError(t, ctx.Err) } @@ -28,7 +28,7 @@ func TestMint(t *testing.T) { func TestApprove(t *testing.T) { ctx := setup(t) owner := ctx.NewSoloAgent() - tokenID := wasmlib.NewScHashFromBytes(owner.ScAgentID().Bytes()[:32]) + tokenID := wasmtypes.HashFromBytes(owner.ScAgentID().Bytes()[:32]) mint(ctx, owner, tokenID) require.NoError(t, ctx.Err) @@ -58,7 +58,7 @@ func TestApprove(t *testing.T) { func TestApproveAll(t *testing.T) { ctx := setup(t) owner := ctx.NewSoloAgent() - tokenID := wasmlib.NewScHashFromBytes(owner.ScAgentID().Bytes()[:32]) + tokenID := wasmtypes.HashFromBytes(owner.ScAgentID().Bytes()[:32]) mint(ctx, owner, tokenID) require.NoError(t, ctx.Err) @@ -100,7 +100,7 @@ func TestApproveAll(t *testing.T) { func TestTransferFrom(t *testing.T) { ctx := setup(t) owner := ctx.NewSoloAgent() - tokenID := wasmlib.NewScHashFromBytes(owner.ScAgentID().Bytes()[:32]) + tokenID := wasmtypes.HashFromBytes(owner.ScAgentID().Bytes()[:32]) mint(ctx, owner, tokenID) require.NoError(t, ctx.Err) @@ -155,7 +155,7 @@ func setup(t *testing.T) *wasmsolo.SoloContext { return ctx } -func approve(ctx *wasmsolo.SoloContext, owner, approved *wasmsolo.SoloAgent, tokenID wasmlib.ScHash) { +func approve(ctx *wasmsolo.SoloContext, owner, approved *wasmsolo.SoloAgent, tokenID wasmtypes.ScHash) { f := erc721.ScFuncs.Approve(ctx.Sign(owner)) if approved != nil { f.Params.Approved().SetValue(approved.ScAgentID()) @@ -164,7 +164,7 @@ func approve(ctx *wasmsolo.SoloContext, owner, approved *wasmsolo.SoloAgent, tok f.Func.TransferIotas(1).Post() } -func getApproved(t *testing.T, ctx *wasmsolo.SoloContext, tokenID wasmlib.ScHash) *wasmlib.ScAgentID { +func getApproved(t *testing.T, ctx *wasmsolo.SoloContext, tokenID wasmtypes.ScHash) *wasmtypes.ScAgentID { v := erc721.ScFuncs.GetApproved(ctx) v.Params.TokenID().SetValue(tokenID) v.Func.Call() @@ -186,13 +186,13 @@ func isApprovedForAll(t *testing.T, ctx *wasmsolo.SoloContext, owner, friend *wa return v.Results.Approval().Value() } -func mint(ctx *wasmsolo.SoloContext, owner *wasmsolo.SoloAgent, tokenID wasmlib.ScHash) { +func mint(ctx *wasmsolo.SoloContext, owner *wasmsolo.SoloAgent, tokenID wasmtypes.ScHash) { f := erc721.ScFuncs.Mint(ctx.Sign(owner)) f.Params.TokenID().SetValue(tokenID) f.Func.TransferIotas(1).Post() } -func ownerOf(t *testing.T, ctx *wasmsolo.SoloContext, tokenID wasmlib.ScHash) wasmlib.ScAgentID { +func ownerOf(t *testing.T, ctx *wasmsolo.SoloContext, tokenID wasmtypes.ScHash) wasmtypes.ScAgentID { v := erc721.ScFuncs.OwnerOf(ctx) v.Params.TokenID().SetValue(tokenID) v.Func.Call() @@ -207,7 +207,7 @@ func setApprovalForAll(ctx *wasmsolo.SoloContext, owner, operator *wasmsolo.Solo f.Func.TransferIotas(1).Post() } -func transferFrom(ctx *wasmsolo.SoloContext, sender, from, to *wasmsolo.SoloAgent, tokenID wasmlib.ScHash) { +func transferFrom(ctx *wasmsolo.SoloContext, sender, from, to *wasmsolo.SoloAgent, tokenID wasmtypes.ScHash) { f := erc721.ScFuncs.TransferFrom(ctx.Sign(sender)) f.Params.From().SetValue(from.ScAgentID()) f.Params.To().SetValue(to.ScAgentID()) diff --git a/contracts/wasm/erc721/ts/erc721client/events.ts b/contracts/wasm/erc721/ts/erc721client/events.ts new file mode 100644 index 0000000000..7da84f52ec --- /dev/null +++ b/contracts/wasm/erc721/ts/erc721client/events.ts @@ -0,0 +1,116 @@ +// Copyright 2020 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +// (Re-)generated by schema tool +// >>>> DO NOT CHANGE THIS FILE! <<<< +// Change the json schema instead + +import * as wasmclient from "wasmclient" + +const erc721Handlers = new Map void>([ + ["erc721.approval", (evt: Erc721Events, msg: string[]) => evt.approval(new EventApproval(msg))], + ["erc721.approvalForAll", (evt: Erc721Events, msg: string[]) => evt.approvalForAll(new EventApprovalForAll(msg))], + ["erc721.init", (evt: Erc721Events, msg: string[]) => evt.init(new EventInit(msg))], + ["erc721.mint", (evt: Erc721Events, msg: string[]) => evt.mint(new EventMint(msg))], + ["erc721.transfer", (evt: Erc721Events, msg: string[]) => evt.transfer(new EventTransfer(msg))], +]); + +export class Erc721Events implements wasmclient.IEventHandler { +/* eslint-disable @typescript-eslint/no-empty-function */ + approval: (evt: EventApproval) => void = () => {}; + approvalForAll: (evt: EventApprovalForAll) => void = () => {}; + init: (evt: EventInit) => void = () => {}; + mint: (evt: EventMint) => void = () => {}; + transfer: (evt: EventTransfer) => void = () => {}; +/* eslint-enable @typescript-eslint/no-empty-function */ + + public callHandler(topic: string, params: string[]): void { + const handler = erc721Handlers.get(topic); + if (handler) { + handler(this, params); + } + } + + public onErc721Approval(handler: (evt: EventApproval) => void): void { + this.approval = handler; + } + + public onErc721ApprovalForAll(handler: (evt: EventApprovalForAll) => void): void { + this.approvalForAll = handler; + } + + public onErc721Init(handler: (evt: EventInit) => void): void { + this.init = handler; + } + + public onErc721Mint(handler: (evt: EventMint) => void): void { + this.mint = handler; + } + + public onErc721Transfer(handler: (evt: EventTransfer) => void): void { + this.transfer = handler; + } +} + +export class EventApproval extends wasmclient.Event { + public readonly approved: wasmclient.AgentID; + public readonly owner: wasmclient.AgentID; + public readonly tokenID: wasmclient.Hash; + + public constructor(msg: string[]) { + super(msg); + this.approved = this.nextAgentID(); + this.owner = this.nextAgentID(); + this.tokenID = this.nextHash(); + } +} + +export class EventApprovalForAll extends wasmclient.Event { + public readonly approval: wasmclient.Bool; + public readonly operator: wasmclient.AgentID; + public readonly owner: wasmclient.AgentID; + + public constructor(msg: string[]) { + super(msg); + this.approval = this.nextBool(); + this.operator = this.nextAgentID(); + this.owner = this.nextAgentID(); + } +} + +export class EventInit extends wasmclient.Event { + public readonly name: wasmclient.String; + public readonly symbol: wasmclient.String; + + public constructor(msg: string[]) { + super(msg); + this.name = this.nextString(); + this.symbol = this.nextString(); + } +} + +export class EventMint extends wasmclient.Event { + public readonly balance: wasmclient.Uint64; + public readonly owner: wasmclient.AgentID; + public readonly tokenID: wasmclient.Hash; + + public constructor(msg: string[]) { + super(msg); + this.balance = this.nextUint64(); + this.owner = this.nextAgentID(); + this.tokenID = this.nextHash(); + } +} + +export class EventTransfer extends wasmclient.Event { + public readonly from: wasmclient.AgentID; + public readonly to: wasmclient.AgentID; + public readonly tokenID: wasmclient.Hash; + + public constructor(msg: string[]) { + super(msg); + this.from = this.nextAgentID(); + this.to = this.nextAgentID(); + this.tokenID = this.nextHash(); + } +} diff --git a/contracts/wasm/erc721/ts/erc721client/index.ts b/contracts/wasm/erc721/ts/erc721client/index.ts new file mode 100644 index 0000000000..1c2d312bca --- /dev/null +++ b/contracts/wasm/erc721/ts/erc721client/index.ts @@ -0,0 +1,9 @@ +// Copyright 2020 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +// (Re-)generated by schema tool +// >>>> DO NOT CHANGE THIS FILE! <<<< +// Change the json schema instead + +export * from "./events"; +export * from "./service"; diff --git a/contracts/wasm/erc721/ts/erc721client/service.ts b/contracts/wasm/erc721/ts/erc721client/service.ts new file mode 100644 index 0000000000..6d9d89a3f4 --- /dev/null +++ b/contracts/wasm/erc721/ts/erc721client/service.ts @@ -0,0 +1,426 @@ +// Copyright 2020 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +// (Re-)generated by schema tool +// >>>> DO NOT CHANGE THIS FILE! <<<< +// Change the json schema instead + +import * as wasmclient from "wasmclient" +import * as events from "./events" + +const ArgApproval = "approval"; +const ArgApproved = "approved"; +const ArgData = "data"; +const ArgFrom = "from"; +const ArgName = "n"; +const ArgOperator = "operator"; +const ArgOwner = "owner"; +const ArgSymbol = "s"; +const ArgTo = "to"; +const ArgTokenID = "tokenID"; +const ArgTokenURI = "tokenURI"; + +const ResAmount = "amount"; +const ResApproval = "approval"; +const ResApproved = "approved"; +const ResName = "name"; +const ResOwner = "owner"; +const ResSymbol = "symbol"; +const ResTokenURI = "tokenURI"; + +///////////////////////////// approve ///////////////////////////// + +export class ApproveFunc extends wasmclient.ClientFunc { + private args: wasmclient.Arguments = new wasmclient.Arguments(); + + public approved(v: wasmclient.AgentID): void { + this.args.set(ArgApproved, this.args.fromAgentID(v)); + } + + public tokenID(v: wasmclient.Hash): void { + this.args.set(ArgTokenID, this.args.fromHash(v)); + } + + public async post(): Promise { + this.args.mandatory(ArgTokenID); + return await super.post(0xa0661268, this.args); + } +} + +///////////////////////////// burn ///////////////////////////// + +export class BurnFunc extends wasmclient.ClientFunc { + private args: wasmclient.Arguments = new wasmclient.Arguments(); + + public tokenID(v: wasmclient.Hash): void { + this.args.set(ArgTokenID, this.args.fromHash(v)); + } + + public async post(): Promise { + this.args.mandatory(ArgTokenID); + return await super.post(0x7bc1efb1, this.args); + } +} + +///////////////////////////// init ///////////////////////////// + +export class InitFunc extends wasmclient.ClientFunc { + private args: wasmclient.Arguments = new wasmclient.Arguments(); + + public name(v: string): void { + this.args.set(ArgName, this.args.fromString(v)); + } + + public symbol(v: string): void { + this.args.set(ArgSymbol, this.args.fromString(v)); + } + + public async post(): Promise { + this.args.mandatory(ArgName); + this.args.mandatory(ArgSymbol); + return await super.post(0x1f44d644, this.args); + } +} + +///////////////////////////// mint ///////////////////////////// + +export class MintFunc extends wasmclient.ClientFunc { + private args: wasmclient.Arguments = new wasmclient.Arguments(); + + public tokenID(v: wasmclient.Hash): void { + this.args.set(ArgTokenID, this.args.fromHash(v)); + } + + public tokenURI(v: string): void { + this.args.set(ArgTokenURI, this.args.fromString(v)); + } + + public async post(): Promise { + this.args.mandatory(ArgTokenID); + return await super.post(0xa29addcf, this.args); + } +} + +///////////////////////////// safeTransferFrom ///////////////////////////// + +export class SafeTransferFromFunc extends wasmclient.ClientFunc { + private args: wasmclient.Arguments = new wasmclient.Arguments(); + + public data(v: wasmclient.Bytes): void { + this.args.set(ArgData, this.args.fromBytes(v)); + } + + public from(v: wasmclient.AgentID): void { + this.args.set(ArgFrom, this.args.fromAgentID(v)); + } + + public to(v: wasmclient.AgentID): void { + this.args.set(ArgTo, this.args.fromAgentID(v)); + } + + public tokenID(v: wasmclient.Hash): void { + this.args.set(ArgTokenID, this.args.fromHash(v)); + } + + public async post(): Promise { + this.args.mandatory(ArgFrom); + this.args.mandatory(ArgTo); + this.args.mandatory(ArgTokenID); + return await super.post(0x130ce158, this.args); + } +} + +///////////////////////////// setApprovalForAll ///////////////////////////// + +export class SetApprovalForAllFunc extends wasmclient.ClientFunc { + private args: wasmclient.Arguments = new wasmclient.Arguments(); + + public approval(v: boolean): void { + this.args.set(ArgApproval, this.args.fromBool(v)); + } + + public operator(v: wasmclient.AgentID): void { + this.args.set(ArgOperator, this.args.fromAgentID(v)); + } + + public async post(): Promise { + this.args.mandatory(ArgApproval); + this.args.mandatory(ArgOperator); + return await super.post(0xb8d8c776, this.args); + } +} + +///////////////////////////// transferFrom ///////////////////////////// + +export class TransferFromFunc extends wasmclient.ClientFunc { + private args: wasmclient.Arguments = new wasmclient.Arguments(); + + public from(v: wasmclient.AgentID): void { + this.args.set(ArgFrom, this.args.fromAgentID(v)); + } + + public to(v: wasmclient.AgentID): void { + this.args.set(ArgTo, this.args.fromAgentID(v)); + } + + public tokenID(v: wasmclient.Hash): void { + this.args.set(ArgTokenID, this.args.fromHash(v)); + } + + public async post(): Promise { + this.args.mandatory(ArgFrom); + this.args.mandatory(ArgTo); + this.args.mandatory(ArgTokenID); + return await super.post(0xd5e0a602, this.args); + } +} + +///////////////////////////// balanceOf ///////////////////////////// + +export class BalanceOfView extends wasmclient.ClientView { + private args: wasmclient.Arguments = new wasmclient.Arguments(); + + public owner(v: wasmclient.AgentID): void { + this.args.set(ArgOwner, this.args.fromAgentID(v)); + } + + public async call(): Promise { + this.args.mandatory(ArgOwner); + const res = new BalanceOfResults(); + await this.callView("balanceOf", this.args, res); + return res; + } +} + +export class BalanceOfResults extends wasmclient.Results { + + amountExists(): boolean { + return this.exists(ResAmount) + } + + amount(): wasmclient.Uint64 { + return this.toUint64(this.get(ResAmount)); + } +} + +///////////////////////////// getApproved ///////////////////////////// + +export class GetApprovedView extends wasmclient.ClientView { + private args: wasmclient.Arguments = new wasmclient.Arguments(); + + public tokenID(v: wasmclient.Hash): void { + this.args.set(ArgTokenID, this.args.fromHash(v)); + } + + public async call(): Promise { + this.args.mandatory(ArgTokenID); + const res = new GetApprovedResults(); + await this.callView("getApproved", this.args, res); + return res; + } +} + +export class GetApprovedResults extends wasmclient.Results { + + approvedExists(): boolean { + return this.exists(ResApproved) + } + + approved(): wasmclient.AgentID { + return this.toAgentID(this.get(ResApproved)); + } +} + +///////////////////////////// isApprovedForAll ///////////////////////////// + +export class IsApprovedForAllView extends wasmclient.ClientView { + private args: wasmclient.Arguments = new wasmclient.Arguments(); + + public operator(v: wasmclient.AgentID): void { + this.args.set(ArgOperator, this.args.fromAgentID(v)); + } + + public owner(v: wasmclient.AgentID): void { + this.args.set(ArgOwner, this.args.fromAgentID(v)); + } + + public async call(): Promise { + this.args.mandatory(ArgOperator); + this.args.mandatory(ArgOwner); + const res = new IsApprovedForAllResults(); + await this.callView("isApprovedForAll", this.args, res); + return res; + } +} + +export class IsApprovedForAllResults extends wasmclient.Results { + + approvalExists(): boolean { + return this.exists(ResApproval) + } + + approval(): boolean { + return this.toBool(this.get(ResApproval)); + } +} + +///////////////////////////// name ///////////////////////////// + +export class NameView extends wasmclient.ClientView { + + public async call(): Promise { + const res = new NameResults(); + await this.callView("name", null, res); + return res; + } +} + +export class NameResults extends wasmclient.Results { + + name(): string { + return this.toString(this.get(ResName)); + } +} + +///////////////////////////// ownerOf ///////////////////////////// + +export class OwnerOfView extends wasmclient.ClientView { + private args: wasmclient.Arguments = new wasmclient.Arguments(); + + public tokenID(v: wasmclient.Hash): void { + this.args.set(ArgTokenID, this.args.fromHash(v)); + } + + public async call(): Promise { + this.args.mandatory(ArgTokenID); + const res = new OwnerOfResults(); + await this.callView("ownerOf", this.args, res); + return res; + } +} + +export class OwnerOfResults extends wasmclient.Results { + + ownerExists(): boolean { + return this.exists(ResOwner) + } + + owner(): wasmclient.AgentID { + return this.toAgentID(this.get(ResOwner)); + } +} + +///////////////////////////// symbol ///////////////////////////// + +export class SymbolView extends wasmclient.ClientView { + + public async call(): Promise { + const res = new SymbolResults(); + await this.callView("symbol", null, res); + return res; + } +} + +export class SymbolResults extends wasmclient.Results { + + symbol(): string { + return this.toString(this.get(ResSymbol)); + } +} + +///////////////////////////// tokenURI ///////////////////////////// + +export class TokenURIView extends wasmclient.ClientView { + private args: wasmclient.Arguments = new wasmclient.Arguments(); + + public tokenID(v: wasmclient.Hash): void { + this.args.set(ArgTokenID, this.args.fromHash(v)); + } + + public async call(): Promise { + this.args.mandatory(ArgTokenID); + const res = new TokenURIResults(); + await this.callView("tokenURI", this.args, res); + return res; + } +} + +export class TokenURIResults extends wasmclient.Results { + + tokenURIExists(): boolean { + return this.exists(ResTokenURI) + } + + tokenURI(): string { + return this.toString(this.get(ResTokenURI)); + } +} + +///////////////////////////// Erc721Service ///////////////////////////// + +export class Erc721Service extends wasmclient.Service { + + public constructor(cl: wasmclient.ServiceClient) { + super(cl, 0xd967c216); + } + + public newEventHandler(): events.Erc721Events { + return new events.Erc721Events(); + } + + public approve(): ApproveFunc { + return new ApproveFunc(this); + } + + public burn(): BurnFunc { + return new BurnFunc(this); + } + + public init(): InitFunc { + return new InitFunc(this); + } + + public mint(): MintFunc { + return new MintFunc(this); + } + + public safeTransferFrom(): SafeTransferFromFunc { + return new SafeTransferFromFunc(this); + } + + public setApprovalForAll(): SetApprovalForAllFunc { + return new SetApprovalForAllFunc(this); + } + + public transferFrom(): TransferFromFunc { + return new TransferFromFunc(this); + } + + public balanceOf(): BalanceOfView { + return new BalanceOfView(this); + } + + public getApproved(): GetApprovedView { + return new GetApprovedView(this); + } + + public isApprovedForAll(): IsApprovedForAllView { + return new IsApprovedForAllView(this); + } + + public name(): NameView { + return new NameView(this); + } + + public ownerOf(): OwnerOfView { + return new OwnerOfView(this); + } + + public symbol(): SymbolView { + return new SymbolView(this); + } + + public tokenURI(): TokenURIView { + return new TokenURIView(this); + } +} diff --git a/contracts/wasm/erc721/ts/erc721client/tsconfig.json b/contracts/wasm/erc721/ts/erc721client/tsconfig.json new file mode 100644 index 0000000000..bc17186726 --- /dev/null +++ b/contracts/wasm/erc721/ts/erc721client/tsconfig.json @@ -0,0 +1,11 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": ["es2020"], + "target": "es2020", + "sourceMap": true + }, + "exclude": [ + "node_modules" + ], +} diff --git a/contracts/wasm/fairauction/go/fairauction/consts.go b/contracts/wasm/fairauction/go/fairauction/consts.go index a64184d793..81f6323d4b 100644 --- a/contracts/wasm/fairauction/go/fairauction/consts.go +++ b/contracts/wasm/fairauction/go/fairauction/consts.go @@ -7,12 +7,12 @@ package fairauction -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" +import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" const ( ScName = "fairauction" ScDescription = "Decentralized auction to securely sell tokens to the highest bidder" - HScName = wasmlib.ScHname(0x1b5c43b1) + HScName = wasmtypes.ScHname(0x1b5c43b1) ) const ( @@ -54,9 +54,9 @@ const ( ) const ( - HFuncFinalizeAuction = wasmlib.ScHname(0x8d534ddc) - HFuncPlaceBid = wasmlib.ScHname(0x9bd72fa9) - HFuncSetOwnerMargin = wasmlib.ScHname(0x1774461a) - HFuncStartAuction = wasmlib.ScHname(0xd5b7bacb) - HViewGetInfo = wasmlib.ScHname(0xcfedba5f) + HFuncFinalizeAuction = wasmtypes.ScHname(0x8d534ddc) + HFuncPlaceBid = wasmtypes.ScHname(0x9bd72fa9) + HFuncSetOwnerMargin = wasmtypes.ScHname(0x1774461a) + HFuncStartAuction = wasmtypes.ScHname(0xd5b7bacb) + HViewGetInfo = wasmtypes.ScHname(0xcfedba5f) ) diff --git a/contracts/wasm/fairauction/go/fairauction/contract.go b/contracts/wasm/fairauction/go/fairauction/contract.go index 2d5922d91b..3336b197cd 100644 --- a/contracts/wasm/fairauction/go/fairauction/contract.go +++ b/contracts/wasm/fairauction/go/fairauction/contract.go @@ -41,30 +41,31 @@ var ScFuncs Funcs func (sc Funcs) FinalizeAuction(ctx wasmlib.ScFuncCallContext) *FinalizeAuctionCall { f := &FinalizeAuctionCall{Func: wasmlib.NewScFunc(ctx, HScName, HFuncFinalizeAuction)} - f.Func.SetPtrs(&f.Params.id, nil) + f.Params.proxy = wasmlib.NewCallParamsProxy(&f.Func.ScView) return f } func (sc Funcs) PlaceBid(ctx wasmlib.ScFuncCallContext) *PlaceBidCall { f := &PlaceBidCall{Func: wasmlib.NewScFunc(ctx, HScName, HFuncPlaceBid)} - f.Func.SetPtrs(&f.Params.id, nil) + f.Params.proxy = wasmlib.NewCallParamsProxy(&f.Func.ScView) return f } func (sc Funcs) SetOwnerMargin(ctx wasmlib.ScFuncCallContext) *SetOwnerMarginCall { f := &SetOwnerMarginCall{Func: wasmlib.NewScFunc(ctx, HScName, HFuncSetOwnerMargin)} - f.Func.SetPtrs(&f.Params.id, nil) + f.Params.proxy = wasmlib.NewCallParamsProxy(&f.Func.ScView) return f } func (sc Funcs) StartAuction(ctx wasmlib.ScFuncCallContext) *StartAuctionCall { f := &StartAuctionCall{Func: wasmlib.NewScFunc(ctx, HScName, HFuncStartAuction)} - f.Func.SetPtrs(&f.Params.id, nil) + f.Params.proxy = wasmlib.NewCallParamsProxy(&f.Func.ScView) return f } func (sc Funcs) GetInfo(ctx wasmlib.ScViewCallContext) *GetInfoCall { f := &GetInfoCall{Func: wasmlib.NewScView(ctx, HScName, HViewGetInfo)} - f.Func.SetPtrs(&f.Params.id, &f.Results.id) + f.Params.proxy = wasmlib.NewCallParamsProxy(f.Func) + wasmlib.NewCallResultsProxy(f.Func, &f.Results.proxy) return f } diff --git a/contracts/wasm/fairauction/go/fairauction/fairauction.go b/contracts/wasm/fairauction/go/fairauction/fairauction.go index c987fcc0a0..26bf25fc9c 100644 --- a/contracts/wasm/fairauction/go/fairauction/fairauction.go +++ b/contracts/wasm/fairauction/go/fairauction/fairauction.go @@ -5,6 +5,7 @@ package fairauction import ( "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" + "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" ) const ( @@ -22,16 +23,16 @@ func funcFinalizeAuction(ctx wasmlib.ScFuncContext, f *FinalizeAuctionContext) { currentAuction := f.State.Auctions().GetAuction(color) ctx.Require(currentAuction.Exists(), "Missing auction info") auction := currentAuction.Value() - if auction.HighestBid < 0 { + if auction.HighestBid == 0 { ctx.Log("No one bid on " + color.String()) ownerFee := auction.MinimumBid * auction.OwnerMargin / 1000 if ownerFee == 0 { ownerFee = 1 } // finalizeAuction request token was probably not confirmed yet - transferTokens(ctx, ctx.ContractCreator(), wasmlib.IOTA, ownerFee-1) + transferTokens(ctx, ctx.ContractCreator(), wasmtypes.IOTA, ownerFee-1) transferTokens(ctx, auction.Creator, auction.Color, auction.NumTokens) - transferTokens(ctx, auction.Creator, wasmlib.IOTA, auction.Deposit-ownerFee) + transferTokens(ctx, auction.Creator, wasmtypes.IOTA, auction.Deposit-ownerFee) return } @@ -44,22 +45,22 @@ func funcFinalizeAuction(ctx wasmlib.ScFuncContext, f *FinalizeAuctionContext) { bids := f.State.Bids().GetBids(color) bidderList := f.State.BidderList().GetBidderList(color) size := bidderList.Length() - for i := int32(0); i < size; i++ { + for i := uint32(0); i < size; i++ { loser := bidderList.GetAgentID(i).Value() if loser != auction.HighestBidder { bid := bids.GetBid(loser).Value() - transferTokens(ctx, loser, wasmlib.IOTA, bid.Amount) + transferTokens(ctx, loser, wasmtypes.IOTA, bid.Amount) } } // finalizeAuction request token was probably not confirmed yet - transferTokens(ctx, ctx.ContractCreator(), wasmlib.IOTA, ownerFee-1) + transferTokens(ctx, ctx.ContractCreator(), wasmtypes.IOTA, ownerFee-1) transferTokens(ctx, auction.HighestBidder, auction.Color, auction.NumTokens) - transferTokens(ctx, auction.Creator, wasmlib.IOTA, auction.Deposit+auction.HighestBid-ownerFee) + transferTokens(ctx, auction.Creator, wasmtypes.IOTA, auction.Deposit+auction.HighestBid-ownerFee) } func funcPlaceBid(ctx wasmlib.ScFuncContext, f *PlaceBidContext) { - bidAmount := ctx.Incoming().Balance(wasmlib.IOTA) + bidAmount := ctx.Incoming().Balance(wasmtypes.IOTA) ctx.Require(bidAmount > 0, "Missing bid amount") color := f.Params.Color().Value() @@ -82,7 +83,7 @@ func funcPlaceBid(ctx wasmlib.ScFuncContext, f *PlaceBidContext) { ctx.Require(bidAmount >= auction.MinimumBid, "Insufficient bid amount") ctx.Log("New bid from: " + caller.String()) index := bidderList.Length() - bidderList.GetAgentID(index).SetValue(caller) + bidderList.AppendAgentID().SetValue(caller) bid := &Bid{ Index: index, Amount: bidAmount, @@ -111,7 +112,7 @@ func funcSetOwnerMargin(ctx wasmlib.ScFuncContext, f *SetOwnerMarginContext) { func funcStartAuction(ctx wasmlib.ScFuncContext, f *StartAuctionContext) { color := f.Params.Color().Value() - if color == wasmlib.IOTA || color == wasmlib.MINT { + if color == wasmtypes.IOTA || color == wasmtypes.MINT { ctx.Panic("Reserved auction token color") } numTokens := ctx.Incoming().Balance(color) @@ -152,7 +153,7 @@ func funcStartAuction(ctx wasmlib.ScFuncContext, f *StartAuctionContext) { if margin == 0 { margin = 1 } - deposit := ctx.Incoming().Balance(wasmlib.IOTA) + deposit := ctx.Incoming().Balance(wasmtypes.IOTA) if deposit < margin { ctx.Panic("Insufficient deposit") } @@ -168,8 +169,8 @@ func funcStartAuction(ctx wasmlib.ScFuncContext, f *StartAuctionContext) { Deposit: deposit, Description: description, Duration: duration, - HighestBid: -1, - HighestBidder: wasmlib.ScAgentID{}, + HighestBid: 0, + HighestBidder: wasmtypes.ScAgentID{}, MinimumBid: minimumBid, NumTokens: numTokens, OwnerMargin: ownerMargin, @@ -206,13 +207,13 @@ func viewGetInfo(ctx wasmlib.ScViewContext, f *GetInfoContext) { f.Results.Bidders().SetValue(bidderList.Length()) } -func transferTokens(ctx wasmlib.ScFuncContext, agent wasmlib.ScAgentID, color wasmlib.ScColor, amount int64) { +func transferTokens(ctx wasmlib.ScFuncContext, agent wasmtypes.ScAgentID, color wasmtypes.ScColor, amount uint64) { if agent.IsAddress() { // send back to original Tangle address - ctx.TransferToAddress(agent.Address(), wasmlib.NewScTransfer(color, amount)) + ctx.Send(agent.Address(), wasmlib.NewScTransfer(color, amount)) return } // TODO not an address, deposit into account on chain - ctx.TransferToAddress(agent.Address(), wasmlib.NewScTransfer(color, amount)) + ctx.Send(agent.Address(), wasmlib.NewScTransfer(color, amount)) } diff --git a/contracts/wasm/fairauction/go/fairauction/keys.go b/contracts/wasm/fairauction/go/fairauction/keys.go index c66bce5659..c0165dc247 100644 --- a/contracts/wasm/fairauction/go/fairauction/keys.go +++ b/contracts/wasm/fairauction/go/fairauction/keys.go @@ -6,59 +6,3 @@ // Change the json schema instead package fairauction - -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" - -const ( - IdxParamColor = 0 - IdxParamDescription = 1 - IdxParamDuration = 2 - IdxParamMinimumBid = 3 - IdxParamOwnerMargin = 4 - - IdxResultBidders = 5 - IdxResultColor = 6 - IdxResultCreator = 7 - IdxResultDeposit = 8 - IdxResultDescription = 9 - IdxResultDuration = 10 - IdxResultHighestBid = 11 - IdxResultHighestBidder = 12 - IdxResultMinimumBid = 13 - IdxResultNumTokens = 14 - IdxResultOwnerMargin = 15 - IdxResultWhenStarted = 16 - - IdxStateAuctions = 17 - IdxStateBidderList = 18 - IdxStateBids = 19 - IdxStateOwnerMargin = 20 -) - -const keyMapLen = 21 - -var keyMap = [keyMapLen]wasmlib.Key{ - ParamColor, - ParamDescription, - ParamDuration, - ParamMinimumBid, - ParamOwnerMargin, - ResultBidders, - ResultColor, - ResultCreator, - ResultDeposit, - ResultDescription, - ResultDuration, - ResultHighestBid, - ResultHighestBidder, - ResultMinimumBid, - ResultNumTokens, - ResultOwnerMargin, - ResultWhenStarted, - StateAuctions, - StateBidderList, - StateBids, - StateOwnerMargin, -} - -var idxMap [keyMapLen]wasmlib.Key32 diff --git a/contracts/wasm/fairauction/go/fairauction/lib.go b/contracts/wasm/fairauction/go/fairauction/lib.go index 7e27fcdd01..4c25061f29 100644 --- a/contracts/wasm/fairauction/go/fairauction/lib.go +++ b/contracts/wasm/fairauction/go/fairauction/lib.go @@ -16,10 +16,6 @@ func OnLoad() { exports.AddFunc(FuncSetOwnerMargin, funcSetOwnerMarginThunk) exports.AddFunc(FuncStartAuction, funcStartAuctionThunk) exports.AddView(ViewGetInfo, viewGetInfoThunk) - - for i, key := range keyMap { - idxMap[i] = key.KeyID() - } } type FinalizeAuctionContext struct { @@ -29,18 +25,18 @@ type FinalizeAuctionContext struct { func funcFinalizeAuctionThunk(ctx wasmlib.ScFuncContext) { ctx.Log("fairauction.funcFinalizeAuction") - - // only SC itself can invoke this function - ctx.Require(ctx.Caller() == ctx.AccountID(), "no permission") - f := &FinalizeAuctionContext{ Params: ImmutableFinalizeAuctionParams{ - id: wasmlib.OBJ_ID_PARAMS, + proxy: wasmlib.NewParamsProxy(), }, State: MutableFairAuctionState{ - id: wasmlib.OBJ_ID_STATE, + proxy: wasmlib.NewStateProxy(), }, } + + // only SC itself can invoke this function + ctx.Require(ctx.Caller() == ctx.AccountID(), "no permission") + ctx.Require(f.Params.Color().Exists(), "missing mandatory color") funcFinalizeAuction(ctx, f) ctx.Log("fairauction.funcFinalizeAuction ok") @@ -55,10 +51,10 @@ func funcPlaceBidThunk(ctx wasmlib.ScFuncContext) { ctx.Log("fairauction.funcPlaceBid") f := &PlaceBidContext{ Params: ImmutablePlaceBidParams{ - id: wasmlib.OBJ_ID_PARAMS, + proxy: wasmlib.NewParamsProxy(), }, State: MutableFairAuctionState{ - id: wasmlib.OBJ_ID_STATE, + proxy: wasmlib.NewStateProxy(), }, } ctx.Require(f.Params.Color().Exists(), "missing mandatory color") @@ -73,18 +69,18 @@ type SetOwnerMarginContext struct { func funcSetOwnerMarginThunk(ctx wasmlib.ScFuncContext) { ctx.Log("fairauction.funcSetOwnerMargin") - - // only SC creator can set owner margin - ctx.Require(ctx.Caller() == ctx.ContractCreator(), "no permission") - f := &SetOwnerMarginContext{ Params: ImmutableSetOwnerMarginParams{ - id: wasmlib.OBJ_ID_PARAMS, + proxy: wasmlib.NewParamsProxy(), }, State: MutableFairAuctionState{ - id: wasmlib.OBJ_ID_STATE, + proxy: wasmlib.NewStateProxy(), }, } + + // only SC creator can set owner margin + ctx.Require(ctx.Caller() == ctx.ContractCreator(), "no permission") + ctx.Require(f.Params.OwnerMargin().Exists(), "missing mandatory ownerMargin") funcSetOwnerMargin(ctx, f) ctx.Log("fairauction.funcSetOwnerMargin ok") @@ -99,10 +95,10 @@ func funcStartAuctionThunk(ctx wasmlib.ScFuncContext) { ctx.Log("fairauction.funcStartAuction") f := &StartAuctionContext{ Params: ImmutableStartAuctionParams{ - id: wasmlib.OBJ_ID_PARAMS, + proxy: wasmlib.NewParamsProxy(), }, State: MutableFairAuctionState{ - id: wasmlib.OBJ_ID_STATE, + proxy: wasmlib.NewStateProxy(), }, } ctx.Require(f.Params.Color().Exists(), "missing mandatory color") @@ -121,13 +117,13 @@ func viewGetInfoThunk(ctx wasmlib.ScViewContext) { ctx.Log("fairauction.viewGetInfo") f := &GetInfoContext{ Params: ImmutableGetInfoParams{ - id: wasmlib.OBJ_ID_PARAMS, + proxy: wasmlib.NewParamsProxy(), }, Results: MutableGetInfoResults{ - id: wasmlib.OBJ_ID_RESULTS, + proxy: wasmlib.NewResultsProxy(), }, State: ImmutableFairAuctionState{ - id: wasmlib.OBJ_ID_STATE, + proxy: wasmlib.NewStateProxy(), }, } ctx.Require(f.Params.Color().Exists(), "missing mandatory color") diff --git a/contracts/wasm/fairauction/go/fairauction/params.go b/contracts/wasm/fairauction/go/fairauction/params.go index 2174a6361a..269c62b4af 100644 --- a/contracts/wasm/fairauction/go/fairauction/params.go +++ b/contracts/wasm/fairauction/go/fairauction/params.go @@ -7,108 +7,108 @@ package fairauction -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" +import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" type ImmutableFinalizeAuctionParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableFinalizeAuctionParams) Color() wasmlib.ScImmutableColor { - return wasmlib.NewScImmutableColor(s.id, wasmlib.KeyID(ParamColor)) +func (s ImmutableFinalizeAuctionParams) Color() wasmtypes.ScImmutableColor { + return wasmtypes.NewScImmutableColor(s.proxy.Root(ParamColor)) } type MutableFinalizeAuctionParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableFinalizeAuctionParams) Color() wasmlib.ScMutableColor { - return wasmlib.NewScMutableColor(s.id, wasmlib.KeyID(ParamColor)) +func (s MutableFinalizeAuctionParams) Color() wasmtypes.ScMutableColor { + return wasmtypes.NewScMutableColor(s.proxy.Root(ParamColor)) } type ImmutablePlaceBidParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutablePlaceBidParams) Color() wasmlib.ScImmutableColor { - return wasmlib.NewScImmutableColor(s.id, wasmlib.KeyID(ParamColor)) +func (s ImmutablePlaceBidParams) Color() wasmtypes.ScImmutableColor { + return wasmtypes.NewScImmutableColor(s.proxy.Root(ParamColor)) } type MutablePlaceBidParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutablePlaceBidParams) Color() wasmlib.ScMutableColor { - return wasmlib.NewScMutableColor(s.id, wasmlib.KeyID(ParamColor)) +func (s MutablePlaceBidParams) Color() wasmtypes.ScMutableColor { + return wasmtypes.NewScMutableColor(s.proxy.Root(ParamColor)) } type ImmutableSetOwnerMarginParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableSetOwnerMarginParams) OwnerMargin() wasmlib.ScImmutableInt64 { - return wasmlib.NewScImmutableInt64(s.id, wasmlib.KeyID(ParamOwnerMargin)) +func (s ImmutableSetOwnerMarginParams) OwnerMargin() wasmtypes.ScImmutableUint64 { + return wasmtypes.NewScImmutableUint64(s.proxy.Root(ParamOwnerMargin)) } type MutableSetOwnerMarginParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableSetOwnerMarginParams) OwnerMargin() wasmlib.ScMutableInt64 { - return wasmlib.NewScMutableInt64(s.id, wasmlib.KeyID(ParamOwnerMargin)) +func (s MutableSetOwnerMarginParams) OwnerMargin() wasmtypes.ScMutableUint64 { + return wasmtypes.NewScMutableUint64(s.proxy.Root(ParamOwnerMargin)) } type ImmutableStartAuctionParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableStartAuctionParams) Color() wasmlib.ScImmutableColor { - return wasmlib.NewScImmutableColor(s.id, wasmlib.KeyID(ParamColor)) +func (s ImmutableStartAuctionParams) Color() wasmtypes.ScImmutableColor { + return wasmtypes.NewScImmutableColor(s.proxy.Root(ParamColor)) } -func (s ImmutableStartAuctionParams) Description() wasmlib.ScImmutableString { - return wasmlib.NewScImmutableString(s.id, wasmlib.KeyID(ParamDescription)) +func (s ImmutableStartAuctionParams) Description() wasmtypes.ScImmutableString { + return wasmtypes.NewScImmutableString(s.proxy.Root(ParamDescription)) } -func (s ImmutableStartAuctionParams) Duration() wasmlib.ScImmutableInt32 { - return wasmlib.NewScImmutableInt32(s.id, wasmlib.KeyID(ParamDuration)) +func (s ImmutableStartAuctionParams) Duration() wasmtypes.ScImmutableUint32 { + return wasmtypes.NewScImmutableUint32(s.proxy.Root(ParamDuration)) } -func (s ImmutableStartAuctionParams) MinimumBid() wasmlib.ScImmutableInt64 { - return wasmlib.NewScImmutableInt64(s.id, wasmlib.KeyID(ParamMinimumBid)) +func (s ImmutableStartAuctionParams) MinimumBid() wasmtypes.ScImmutableUint64 { + return wasmtypes.NewScImmutableUint64(s.proxy.Root(ParamMinimumBid)) } type MutableStartAuctionParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableStartAuctionParams) Color() wasmlib.ScMutableColor { - return wasmlib.NewScMutableColor(s.id, wasmlib.KeyID(ParamColor)) +func (s MutableStartAuctionParams) Color() wasmtypes.ScMutableColor { + return wasmtypes.NewScMutableColor(s.proxy.Root(ParamColor)) } -func (s MutableStartAuctionParams) Description() wasmlib.ScMutableString { - return wasmlib.NewScMutableString(s.id, wasmlib.KeyID(ParamDescription)) +func (s MutableStartAuctionParams) Description() wasmtypes.ScMutableString { + return wasmtypes.NewScMutableString(s.proxy.Root(ParamDescription)) } -func (s MutableStartAuctionParams) Duration() wasmlib.ScMutableInt32 { - return wasmlib.NewScMutableInt32(s.id, wasmlib.KeyID(ParamDuration)) +func (s MutableStartAuctionParams) Duration() wasmtypes.ScMutableUint32 { + return wasmtypes.NewScMutableUint32(s.proxy.Root(ParamDuration)) } -func (s MutableStartAuctionParams) MinimumBid() wasmlib.ScMutableInt64 { - return wasmlib.NewScMutableInt64(s.id, wasmlib.KeyID(ParamMinimumBid)) +func (s MutableStartAuctionParams) MinimumBid() wasmtypes.ScMutableUint64 { + return wasmtypes.NewScMutableUint64(s.proxy.Root(ParamMinimumBid)) } type ImmutableGetInfoParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableGetInfoParams) Color() wasmlib.ScImmutableColor { - return wasmlib.NewScImmutableColor(s.id, wasmlib.KeyID(ParamColor)) +func (s ImmutableGetInfoParams) Color() wasmtypes.ScImmutableColor { + return wasmtypes.NewScImmutableColor(s.proxy.Root(ParamColor)) } type MutableGetInfoParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableGetInfoParams) Color() wasmlib.ScMutableColor { - return wasmlib.NewScMutableColor(s.id, wasmlib.KeyID(ParamColor)) +func (s MutableGetInfoParams) Color() wasmtypes.ScMutableColor { + return wasmtypes.NewScMutableColor(s.proxy.Root(ParamColor)) } diff --git a/contracts/wasm/fairauction/go/fairauction/results.go b/contracts/wasm/fairauction/go/fairauction/results.go index 033177634d..52d73fbc92 100644 --- a/contracts/wasm/fairauction/go/fairauction/results.go +++ b/contracts/wasm/fairauction/go/fairauction/results.go @@ -7,108 +7,108 @@ package fairauction -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" +import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" type ImmutableGetInfoResults struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableGetInfoResults) Bidders() wasmlib.ScImmutableInt32 { - return wasmlib.NewScImmutableInt32(s.id, wasmlib.KeyID(ResultBidders)) +func (s ImmutableGetInfoResults) Bidders() wasmtypes.ScImmutableUint32 { + return wasmtypes.NewScImmutableUint32(s.proxy.Root(ResultBidders)) } -func (s ImmutableGetInfoResults) Color() wasmlib.ScImmutableColor { - return wasmlib.NewScImmutableColor(s.id, wasmlib.KeyID(ResultColor)) +func (s ImmutableGetInfoResults) Color() wasmtypes.ScImmutableColor { + return wasmtypes.NewScImmutableColor(s.proxy.Root(ResultColor)) } -func (s ImmutableGetInfoResults) Creator() wasmlib.ScImmutableAgentID { - return wasmlib.NewScImmutableAgentID(s.id, wasmlib.KeyID(ResultCreator)) +func (s ImmutableGetInfoResults) Creator() wasmtypes.ScImmutableAgentID { + return wasmtypes.NewScImmutableAgentID(s.proxy.Root(ResultCreator)) } -func (s ImmutableGetInfoResults) Deposit() wasmlib.ScImmutableInt64 { - return wasmlib.NewScImmutableInt64(s.id, wasmlib.KeyID(ResultDeposit)) +func (s ImmutableGetInfoResults) Deposit() wasmtypes.ScImmutableUint64 { + return wasmtypes.NewScImmutableUint64(s.proxy.Root(ResultDeposit)) } -func (s ImmutableGetInfoResults) Description() wasmlib.ScImmutableString { - return wasmlib.NewScImmutableString(s.id, wasmlib.KeyID(ResultDescription)) +func (s ImmutableGetInfoResults) Description() wasmtypes.ScImmutableString { + return wasmtypes.NewScImmutableString(s.proxy.Root(ResultDescription)) } -func (s ImmutableGetInfoResults) Duration() wasmlib.ScImmutableInt32 { - return wasmlib.NewScImmutableInt32(s.id, wasmlib.KeyID(ResultDuration)) +func (s ImmutableGetInfoResults) Duration() wasmtypes.ScImmutableUint32 { + return wasmtypes.NewScImmutableUint32(s.proxy.Root(ResultDuration)) } -func (s ImmutableGetInfoResults) HighestBid() wasmlib.ScImmutableInt64 { - return wasmlib.NewScImmutableInt64(s.id, wasmlib.KeyID(ResultHighestBid)) +func (s ImmutableGetInfoResults) HighestBid() wasmtypes.ScImmutableUint64 { + return wasmtypes.NewScImmutableUint64(s.proxy.Root(ResultHighestBid)) } -func (s ImmutableGetInfoResults) HighestBidder() wasmlib.ScImmutableAgentID { - return wasmlib.NewScImmutableAgentID(s.id, wasmlib.KeyID(ResultHighestBidder)) +func (s ImmutableGetInfoResults) HighestBidder() wasmtypes.ScImmutableAgentID { + return wasmtypes.NewScImmutableAgentID(s.proxy.Root(ResultHighestBidder)) } -func (s ImmutableGetInfoResults) MinimumBid() wasmlib.ScImmutableInt64 { - return wasmlib.NewScImmutableInt64(s.id, wasmlib.KeyID(ResultMinimumBid)) +func (s ImmutableGetInfoResults) MinimumBid() wasmtypes.ScImmutableUint64 { + return wasmtypes.NewScImmutableUint64(s.proxy.Root(ResultMinimumBid)) } -func (s ImmutableGetInfoResults) NumTokens() wasmlib.ScImmutableInt64 { - return wasmlib.NewScImmutableInt64(s.id, wasmlib.KeyID(ResultNumTokens)) +func (s ImmutableGetInfoResults) NumTokens() wasmtypes.ScImmutableUint64 { + return wasmtypes.NewScImmutableUint64(s.proxy.Root(ResultNumTokens)) } -func (s ImmutableGetInfoResults) OwnerMargin() wasmlib.ScImmutableInt64 { - return wasmlib.NewScImmutableInt64(s.id, wasmlib.KeyID(ResultOwnerMargin)) +func (s ImmutableGetInfoResults) OwnerMargin() wasmtypes.ScImmutableUint64 { + return wasmtypes.NewScImmutableUint64(s.proxy.Root(ResultOwnerMargin)) } -func (s ImmutableGetInfoResults) WhenStarted() wasmlib.ScImmutableInt64 { - return wasmlib.NewScImmutableInt64(s.id, wasmlib.KeyID(ResultWhenStarted)) +func (s ImmutableGetInfoResults) WhenStarted() wasmtypes.ScImmutableUint64 { + return wasmtypes.NewScImmutableUint64(s.proxy.Root(ResultWhenStarted)) } type MutableGetInfoResults struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableGetInfoResults) Bidders() wasmlib.ScMutableInt32 { - return wasmlib.NewScMutableInt32(s.id, wasmlib.KeyID(ResultBidders)) +func (s MutableGetInfoResults) Bidders() wasmtypes.ScMutableUint32 { + return wasmtypes.NewScMutableUint32(s.proxy.Root(ResultBidders)) } -func (s MutableGetInfoResults) Color() wasmlib.ScMutableColor { - return wasmlib.NewScMutableColor(s.id, wasmlib.KeyID(ResultColor)) +func (s MutableGetInfoResults) Color() wasmtypes.ScMutableColor { + return wasmtypes.NewScMutableColor(s.proxy.Root(ResultColor)) } -func (s MutableGetInfoResults) Creator() wasmlib.ScMutableAgentID { - return wasmlib.NewScMutableAgentID(s.id, wasmlib.KeyID(ResultCreator)) +func (s MutableGetInfoResults) Creator() wasmtypes.ScMutableAgentID { + return wasmtypes.NewScMutableAgentID(s.proxy.Root(ResultCreator)) } -func (s MutableGetInfoResults) Deposit() wasmlib.ScMutableInt64 { - return wasmlib.NewScMutableInt64(s.id, wasmlib.KeyID(ResultDeposit)) +func (s MutableGetInfoResults) Deposit() wasmtypes.ScMutableUint64 { + return wasmtypes.NewScMutableUint64(s.proxy.Root(ResultDeposit)) } -func (s MutableGetInfoResults) Description() wasmlib.ScMutableString { - return wasmlib.NewScMutableString(s.id, wasmlib.KeyID(ResultDescription)) +func (s MutableGetInfoResults) Description() wasmtypes.ScMutableString { + return wasmtypes.NewScMutableString(s.proxy.Root(ResultDescription)) } -func (s MutableGetInfoResults) Duration() wasmlib.ScMutableInt32 { - return wasmlib.NewScMutableInt32(s.id, wasmlib.KeyID(ResultDuration)) +func (s MutableGetInfoResults) Duration() wasmtypes.ScMutableUint32 { + return wasmtypes.NewScMutableUint32(s.proxy.Root(ResultDuration)) } -func (s MutableGetInfoResults) HighestBid() wasmlib.ScMutableInt64 { - return wasmlib.NewScMutableInt64(s.id, wasmlib.KeyID(ResultHighestBid)) +func (s MutableGetInfoResults) HighestBid() wasmtypes.ScMutableUint64 { + return wasmtypes.NewScMutableUint64(s.proxy.Root(ResultHighestBid)) } -func (s MutableGetInfoResults) HighestBidder() wasmlib.ScMutableAgentID { - return wasmlib.NewScMutableAgentID(s.id, wasmlib.KeyID(ResultHighestBidder)) +func (s MutableGetInfoResults) HighestBidder() wasmtypes.ScMutableAgentID { + return wasmtypes.NewScMutableAgentID(s.proxy.Root(ResultHighestBidder)) } -func (s MutableGetInfoResults) MinimumBid() wasmlib.ScMutableInt64 { - return wasmlib.NewScMutableInt64(s.id, wasmlib.KeyID(ResultMinimumBid)) +func (s MutableGetInfoResults) MinimumBid() wasmtypes.ScMutableUint64 { + return wasmtypes.NewScMutableUint64(s.proxy.Root(ResultMinimumBid)) } -func (s MutableGetInfoResults) NumTokens() wasmlib.ScMutableInt64 { - return wasmlib.NewScMutableInt64(s.id, wasmlib.KeyID(ResultNumTokens)) +func (s MutableGetInfoResults) NumTokens() wasmtypes.ScMutableUint64 { + return wasmtypes.NewScMutableUint64(s.proxy.Root(ResultNumTokens)) } -func (s MutableGetInfoResults) OwnerMargin() wasmlib.ScMutableInt64 { - return wasmlib.NewScMutableInt64(s.id, wasmlib.KeyID(ResultOwnerMargin)) +func (s MutableGetInfoResults) OwnerMargin() wasmtypes.ScMutableUint64 { + return wasmtypes.NewScMutableUint64(s.proxy.Root(ResultOwnerMargin)) } -func (s MutableGetInfoResults) WhenStarted() wasmlib.ScMutableInt64 { - return wasmlib.NewScMutableInt64(s.id, wasmlib.KeyID(ResultWhenStarted)) +func (s MutableGetInfoResults) WhenStarted() wasmtypes.ScMutableUint64 { + return wasmtypes.NewScMutableUint64(s.proxy.Root(ResultWhenStarted)) } diff --git a/contracts/wasm/fairauction/go/fairauction/state.go b/contracts/wasm/fairauction/go/fairauction/state.go index 4fce8d8fba..ef75841723 100644 --- a/contracts/wasm/fairauction/go/fairauction/state.go +++ b/contracts/wasm/fairauction/go/fairauction/state.go @@ -7,97 +7,90 @@ package fairauction -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" +import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" type MapColorToImmutableAuction struct { - objID int32 + proxy wasmtypes.Proxy } -func (m MapColorToImmutableAuction) GetAuction(key wasmlib.ScColor) ImmutableAuction { - return ImmutableAuction{objID: m.objID, keyID: key.KeyID()} +func (m MapColorToImmutableAuction) GetAuction(key wasmtypes.ScColor) ImmutableAuction { + return ImmutableAuction{proxy: m.proxy.Key(key.Bytes())} } type MapColorToImmutableBidderList struct { - objID int32 + proxy wasmtypes.Proxy } -func (m MapColorToImmutableBidderList) GetBidderList(key wasmlib.ScColor) ImmutableBidderList { - subID := wasmlib.GetObjectID(m.objID, key.KeyID(), wasmlib.TYPE_ARRAY|wasmlib.TYPE_AGENT_ID) - return ImmutableBidderList{objID: subID} +func (m MapColorToImmutableBidderList) GetBidderList(key wasmtypes.ScColor) ImmutableBidderList { + return ImmutableBidderList{proxy: m.proxy.Key(key.Bytes())} } type MapColorToImmutableBids struct { - objID int32 + proxy wasmtypes.Proxy } -func (m MapColorToImmutableBids) GetBids(key wasmlib.ScColor) ImmutableBids { - subID := wasmlib.GetObjectID(m.objID, key.KeyID(), wasmlib.TYPE_MAP) - return ImmutableBids{objID: subID} +func (m MapColorToImmutableBids) GetBids(key wasmtypes.ScColor) ImmutableBids { + return ImmutableBids{proxy: m.proxy.Key(key.Bytes())} } type ImmutableFairAuctionState struct { - id int32 + proxy wasmtypes.Proxy } func (s ImmutableFairAuctionState) Auctions() MapColorToImmutableAuction { - mapID := wasmlib.GetObjectID(s.id, wasmlib.KeyID(StateAuctions), wasmlib.TYPE_MAP) - return MapColorToImmutableAuction{objID: mapID} + return MapColorToImmutableAuction{proxy: s.proxy.Root(StateAuctions)} } func (s ImmutableFairAuctionState) BidderList() MapColorToImmutableBidderList { - mapID := wasmlib.GetObjectID(s.id, wasmlib.KeyID(StateBidderList), wasmlib.TYPE_MAP) - return MapColorToImmutableBidderList{objID: mapID} + return MapColorToImmutableBidderList{proxy: s.proxy.Root(StateBidderList)} } func (s ImmutableFairAuctionState) Bids() MapColorToImmutableBids { - mapID := wasmlib.GetObjectID(s.id, wasmlib.KeyID(StateBids), wasmlib.TYPE_MAP) - return MapColorToImmutableBids{objID: mapID} + return MapColorToImmutableBids{proxy: s.proxy.Root(StateBids)} } -func (s ImmutableFairAuctionState) OwnerMargin() wasmlib.ScImmutableInt64 { - return wasmlib.NewScImmutableInt64(s.id, wasmlib.KeyID(StateOwnerMargin)) +func (s ImmutableFairAuctionState) OwnerMargin() wasmtypes.ScImmutableUint64 { + return wasmtypes.NewScImmutableUint64(s.proxy.Root(StateOwnerMargin)) } type MapColorToMutableAuction struct { - objID int32 + proxy wasmtypes.Proxy } func (m MapColorToMutableAuction) Clear() { - wasmlib.Clear(m.objID) + m.proxy.ClearMap() } -func (m MapColorToMutableAuction) GetAuction(key wasmlib.ScColor) MutableAuction { - return MutableAuction{objID: m.objID, keyID: key.KeyID()} +func (m MapColorToMutableAuction) GetAuction(key wasmtypes.ScColor) MutableAuction { + return MutableAuction{proxy: m.proxy.Key(key.Bytes())} } type MapColorToMutableBidderList struct { - objID int32 + proxy wasmtypes.Proxy } func (m MapColorToMutableBidderList) Clear() { - wasmlib.Clear(m.objID) + m.proxy.ClearMap() } -func (m MapColorToMutableBidderList) GetBidderList(key wasmlib.ScColor) MutableBidderList { - subID := wasmlib.GetObjectID(m.objID, key.KeyID(), wasmlib.TYPE_ARRAY|wasmlib.TYPE_AGENT_ID) - return MutableBidderList{objID: subID} +func (m MapColorToMutableBidderList) GetBidderList(key wasmtypes.ScColor) MutableBidderList { + return MutableBidderList{proxy: m.proxy.Key(key.Bytes())} } type MapColorToMutableBids struct { - objID int32 + proxy wasmtypes.Proxy } func (m MapColorToMutableBids) Clear() { - wasmlib.Clear(m.objID) + m.proxy.ClearMap() } -func (m MapColorToMutableBids) GetBids(key wasmlib.ScColor) MutableBids { - subID := wasmlib.GetObjectID(m.objID, key.KeyID(), wasmlib.TYPE_MAP) - return MutableBids{objID: subID} +func (m MapColorToMutableBids) GetBids(key wasmtypes.ScColor) MutableBids { + return MutableBids{proxy: m.proxy.Key(key.Bytes())} } type MutableFairAuctionState struct { - id int32 + proxy wasmtypes.Proxy } func (s MutableFairAuctionState) AsImmutable() ImmutableFairAuctionState { @@ -105,20 +98,17 @@ func (s MutableFairAuctionState) AsImmutable() ImmutableFairAuctionState { } func (s MutableFairAuctionState) Auctions() MapColorToMutableAuction { - mapID := wasmlib.GetObjectID(s.id, wasmlib.KeyID(StateAuctions), wasmlib.TYPE_MAP) - return MapColorToMutableAuction{objID: mapID} + return MapColorToMutableAuction{proxy: s.proxy.Root(StateAuctions)} } func (s MutableFairAuctionState) BidderList() MapColorToMutableBidderList { - mapID := wasmlib.GetObjectID(s.id, wasmlib.KeyID(StateBidderList), wasmlib.TYPE_MAP) - return MapColorToMutableBidderList{objID: mapID} + return MapColorToMutableBidderList{proxy: s.proxy.Root(StateBidderList)} } func (s MutableFairAuctionState) Bids() MapColorToMutableBids { - mapID := wasmlib.GetObjectID(s.id, wasmlib.KeyID(StateBids), wasmlib.TYPE_MAP) - return MapColorToMutableBids{objID: mapID} + return MapColorToMutableBids{proxy: s.proxy.Root(StateBids)} } -func (s MutableFairAuctionState) OwnerMargin() wasmlib.ScMutableInt64 { - return wasmlib.NewScMutableInt64(s.id, wasmlib.KeyID(StateOwnerMargin)) +func (s MutableFairAuctionState) OwnerMargin() wasmtypes.ScMutableUint64 { + return wasmtypes.NewScMutableUint64(s.proxy.Root(StateOwnerMargin)) } diff --git a/contracts/wasm/fairauction/go/fairauction/structs.go b/contracts/wasm/fairauction/go/fairauction/structs.go index ef4c7a49d2..2baa66e008 100644 --- a/contracts/wasm/fairauction/go/fairauction/structs.go +++ b/contracts/wasm/fairauction/go/fairauction/structs.go @@ -7,144 +7,143 @@ package fairauction -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" +import ( + "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmcodec" + "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" +) type Auction struct { - Color wasmlib.ScColor // color of tokens for sale - Creator wasmlib.ScAgentID // issuer of start_auction transaction - Deposit int64 // deposit by auction owner to cover the SC fees - Description string // auction description - Duration int32 // auction duration in minutes - HighestBid int64 // the current highest bid amount - HighestBidder wasmlib.ScAgentID // the current highest bidder - MinimumBid int64 // minimum bid amount - NumTokens int64 // number of tokens for sale - OwnerMargin int64 // auction owner's margin in promilles - WhenStarted int64 // timestamp when auction started -} - -func NewAuctionFromBytes(bytes []byte) *Auction { - decode := wasmlib.NewBytesDecoder(bytes) + Color wasmtypes.ScColor // color of tokens for sale + Creator wasmtypes.ScAgentID // issuer of start_auction transaction + Deposit uint64 // deposit by auction owner to cover the SC fees + Description string // auction description + Duration uint32 // auction duration in minutes + HighestBid uint64 // the current highest bid amount + HighestBidder wasmtypes.ScAgentID // the current highest bidder + MinimumBid uint64 // minimum bid amount + NumTokens uint64 // number of tokens for sale + OwnerMargin uint64 // auction owner's margin in promilles + WhenStarted uint64 // timestamp when auction started +} + +func NewAuctionFromBytes(buf []byte) *Auction { + dec := wasmcodec.NewWasmDecoder(buf) data := &Auction{} - data.Color = decode.Color() - data.Creator = decode.AgentID() - data.Deposit = decode.Int64() - data.Description = decode.String() - data.Duration = decode.Int32() - data.HighestBid = decode.Int64() - data.HighestBidder = decode.AgentID() - data.MinimumBid = decode.Int64() - data.NumTokens = decode.Int64() - data.OwnerMargin = decode.Int64() - data.WhenStarted = decode.Int64() - decode.Close() + data.Color = wasmtypes.DecodeColor(dec) + data.Creator = wasmtypes.DecodeAgentID(dec) + data.Deposit = wasmtypes.DecodeUint64(dec) + data.Description = wasmtypes.DecodeString(dec) + data.Duration = wasmtypes.DecodeUint32(dec) + data.HighestBid = wasmtypes.DecodeUint64(dec) + data.HighestBidder = wasmtypes.DecodeAgentID(dec) + data.MinimumBid = wasmtypes.DecodeUint64(dec) + data.NumTokens = wasmtypes.DecodeUint64(dec) + data.OwnerMargin = wasmtypes.DecodeUint64(dec) + data.WhenStarted = wasmtypes.DecodeUint64(dec) + dec.Close() return data } func (o *Auction) Bytes() []byte { - return wasmlib.NewBytesEncoder(). - Color(o.Color). - AgentID(o.Creator). - Int64(o.Deposit). - String(o.Description). - Int32(o.Duration). - Int64(o.HighestBid). - AgentID(o.HighestBidder). - Int64(o.MinimumBid). - Int64(o.NumTokens). - Int64(o.OwnerMargin). - Int64(o.WhenStarted). - Data() + enc := wasmcodec.NewWasmEncoder() + wasmtypes.EncodeColor(enc, o.Color) + wasmtypes.EncodeAgentID(enc, o.Creator) + wasmtypes.EncodeUint64(enc, o.Deposit) + wasmtypes.EncodeString(enc, o.Description) + wasmtypes.EncodeUint32(enc, o.Duration) + wasmtypes.EncodeUint64(enc, o.HighestBid) + wasmtypes.EncodeAgentID(enc, o.HighestBidder) + wasmtypes.EncodeUint64(enc, o.MinimumBid) + wasmtypes.EncodeUint64(enc, o.NumTokens) + wasmtypes.EncodeUint64(enc, o.OwnerMargin) + wasmtypes.EncodeUint64(enc, o.WhenStarted) + return enc.Buf() } type ImmutableAuction struct { - objID int32 - keyID wasmlib.Key32 + proxy wasmtypes.Proxy } func (o ImmutableAuction) Exists() bool { - return wasmlib.Exists(o.objID, o.keyID, wasmlib.TYPE_BYTES) + return o.proxy.Exists() } func (o ImmutableAuction) Value() *Auction { - return NewAuctionFromBytes(wasmlib.GetBytes(o.objID, o.keyID, wasmlib.TYPE_BYTES)) + return NewAuctionFromBytes(o.proxy.Get()) } type MutableAuction struct { - objID int32 - keyID wasmlib.Key32 + proxy wasmtypes.Proxy } func (o MutableAuction) Delete() { - wasmlib.DelKey(o.objID, o.keyID, wasmlib.TYPE_BYTES) + o.proxy.Delete() } func (o MutableAuction) Exists() bool { - return wasmlib.Exists(o.objID, o.keyID, wasmlib.TYPE_BYTES) + return o.proxy.Exists() } func (o MutableAuction) SetValue(value *Auction) { - wasmlib.SetBytes(o.objID, o.keyID, wasmlib.TYPE_BYTES, value.Bytes()) + o.proxy.Set(value.Bytes()) } func (o MutableAuction) Value() *Auction { - return NewAuctionFromBytes(wasmlib.GetBytes(o.objID, o.keyID, wasmlib.TYPE_BYTES)) + return NewAuctionFromBytes(o.proxy.Get()) } type Bid struct { - Amount int64 // cumulative amount of bids from same bidder - Index int32 // index of bidder in bidder list - Timestamp int64 // timestamp of most recent bid + Amount uint64 // cumulative amount of bids from same bidder + Index uint32 // index of bidder in bidder list + Timestamp uint64 // timestamp of most recent bid } -func NewBidFromBytes(bytes []byte) *Bid { - decode := wasmlib.NewBytesDecoder(bytes) +func NewBidFromBytes(buf []byte) *Bid { + dec := wasmcodec.NewWasmDecoder(buf) data := &Bid{} - data.Amount = decode.Int64() - data.Index = decode.Int32() - data.Timestamp = decode.Int64() - decode.Close() + data.Amount = wasmtypes.DecodeUint64(dec) + data.Index = wasmtypes.DecodeUint32(dec) + data.Timestamp = wasmtypes.DecodeUint64(dec) + dec.Close() return data } func (o *Bid) Bytes() []byte { - return wasmlib.NewBytesEncoder(). - Int64(o.Amount). - Int32(o.Index). - Int64(o.Timestamp). - Data() + enc := wasmcodec.NewWasmEncoder() + wasmtypes.EncodeUint64(enc, o.Amount) + wasmtypes.EncodeUint32(enc, o.Index) + wasmtypes.EncodeUint64(enc, o.Timestamp) + return enc.Buf() } type ImmutableBid struct { - objID int32 - keyID wasmlib.Key32 + proxy wasmtypes.Proxy } func (o ImmutableBid) Exists() bool { - return wasmlib.Exists(o.objID, o.keyID, wasmlib.TYPE_BYTES) + return o.proxy.Exists() } func (o ImmutableBid) Value() *Bid { - return NewBidFromBytes(wasmlib.GetBytes(o.objID, o.keyID, wasmlib.TYPE_BYTES)) + return NewBidFromBytes(o.proxy.Get()) } type MutableBid struct { - objID int32 - keyID wasmlib.Key32 + proxy wasmtypes.Proxy } func (o MutableBid) Delete() { - wasmlib.DelKey(o.objID, o.keyID, wasmlib.TYPE_BYTES) + o.proxy.Delete() } func (o MutableBid) Exists() bool { - return wasmlib.Exists(o.objID, o.keyID, wasmlib.TYPE_BYTES) + return o.proxy.Exists() } func (o MutableBid) SetValue(value *Bid) { - wasmlib.SetBytes(o.objID, o.keyID, wasmlib.TYPE_BYTES, value.Bytes()) + o.proxy.Set(value.Bytes()) } func (o MutableBid) Value() *Bid { - return NewBidFromBytes(wasmlib.GetBytes(o.objID, o.keyID, wasmlib.TYPE_BYTES)) + return NewBidFromBytes(o.proxy.Get()) } diff --git a/contracts/wasm/fairauction/go/fairauction/typedefs.go b/contracts/wasm/fairauction/go/fairauction/typedefs.go index 719567b083..4defcbafbb 100644 --- a/contracts/wasm/fairauction/go/fairauction/typedefs.go +++ b/contracts/wasm/fairauction/go/fairauction/typedefs.go @@ -7,60 +7,64 @@ package fairauction -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" +import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" type ArrayOfImmutableAgentID struct { - objID int32 + proxy wasmtypes.Proxy } -func (a ArrayOfImmutableAgentID) Length() int32 { - return wasmlib.GetLength(a.objID) +func (a ArrayOfImmutableAgentID) Length() uint32 { + return a.proxy.Length() } -func (a ArrayOfImmutableAgentID) GetAgentID(index int32) wasmlib.ScImmutableAgentID { - return wasmlib.NewScImmutableAgentID(a.objID, wasmlib.Key32(index)) +func (a ArrayOfImmutableAgentID) GetAgentID(index uint32) wasmtypes.ScImmutableAgentID { + return wasmtypes.NewScImmutableAgentID(a.proxy.Index(index)) } type ImmutableBidderList = ArrayOfImmutableAgentID type ArrayOfMutableAgentID struct { - objID int32 + proxy wasmtypes.Proxy +} + +func (a ArrayOfMutableAgentID) AppendAgentID() wasmtypes.ScMutableAgentID { + return wasmtypes.NewScMutableAgentID(a.proxy.Append()) } func (a ArrayOfMutableAgentID) Clear() { - wasmlib.Clear(a.objID) + a.proxy.ClearArray() } -func (a ArrayOfMutableAgentID) Length() int32 { - return wasmlib.GetLength(a.objID) +func (a ArrayOfMutableAgentID) Length() uint32 { + return a.proxy.Length() } -func (a ArrayOfMutableAgentID) GetAgentID(index int32) wasmlib.ScMutableAgentID { - return wasmlib.NewScMutableAgentID(a.objID, wasmlib.Key32(index)) +func (a ArrayOfMutableAgentID) GetAgentID(index uint32) wasmtypes.ScMutableAgentID { + return wasmtypes.NewScMutableAgentID(a.proxy.Index(index)) } type MutableBidderList = ArrayOfMutableAgentID type MapAgentIDToImmutableBid struct { - objID int32 + proxy wasmtypes.Proxy } -func (m MapAgentIDToImmutableBid) GetBid(key wasmlib.ScAgentID) ImmutableBid { - return ImmutableBid{objID: m.objID, keyID: key.KeyID()} +func (m MapAgentIDToImmutableBid) GetBid(key wasmtypes.ScAgentID) ImmutableBid { + return ImmutableBid{proxy: m.proxy.Key(key.Bytes())} } type ImmutableBids = MapAgentIDToImmutableBid type MapAgentIDToMutableBid struct { - objID int32 + proxy wasmtypes.Proxy } func (m MapAgentIDToMutableBid) Clear() { - wasmlib.Clear(m.objID) + m.proxy.ClearMap() } -func (m MapAgentIDToMutableBid) GetBid(key wasmlib.ScAgentID) MutableBid { - return MutableBid{objID: m.objID, keyID: key.KeyID()} +func (m MapAgentIDToMutableBid) GetBid(key wasmtypes.ScAgentID) MutableBid { + return MutableBid{proxy: m.proxy.Key(key.Bytes())} } type MutableBids = MapAgentIDToMutableBid diff --git a/contracts/wasm/fairauction/schema.yaml b/contracts/wasm/fairauction/schema.yaml index d75cf891cd..bb890b6b15 100644 --- a/contracts/wasm/fairauction/schema.yaml +++ b/contracts/wasm/fairauction/schema.yaml @@ -4,19 +4,19 @@ structs: Auction: color: Color // color of tokens for sale creator: AgentID // issuer of start_auction transaction - deposit: Int64 // deposit by auction owner to cover the SC fees + deposit: Uint64 // deposit by auction owner to cover the SC fees description: String // auction description - duration: Int32 // auction duration in minutes - highestBid: Int64 // the current highest bid amount + duration: Uint32 // auction duration in minutes + highestBid: Uint64 // the current highest bid amount highestBidder: AgentID // the current highest bidder - minimumBid: Int64 // minimum bid amount - numTokens: Int64 // number of tokens for sale - ownerMargin: Int64 // auction owner's margin in promilles - whenStarted: Int64 // timestamp when auction started + minimumBid: Uint64 // minimum bid amount + numTokens: Uint64 // number of tokens for sale + ownerMargin: Uint64 // auction owner's margin in promilles + whenStarted: Uint64 // timestamp when auction started Bid: - amount: Int64 // cumulative amount of bids from same bidder - index: Int32 // index of bidder in bidder list - timestamp: Int64 // timestamp of most recent bid + amount: Uint64 // cumulative amount of bids from same bidder + index: Uint32 // index of bidder in bidder list + timestamp: Uint64 // timestamp of most recent bid typedefs: BidderList: AgentID[] Bids: map[AgentID]Bid @@ -24,7 +24,7 @@ state: auctions: map[Color]Auction bidderList: map[Color]BidderList bids: map[Color]Bids - ownerMargin: Int64 // default auction owner's margin in promilles + ownerMargin: Uint64 // default auction owner's margin in promilles funcs: finalizeAuction: access: self // only SC itself can invoke this function @@ -36,27 +36,27 @@ funcs: setOwnerMargin: access: creator // only SC creator can set owner margin params: - ownerMargin: Int64 // new SC owner margin in promilles + ownerMargin: Uint64 // new SC owner margin in promilles startAuction: params: color: Color // color of the tokens being auctioned description: String? // description of the tokens being auctioned - duration: Int32? // duration of auction in minutes - minimumBid: Int64 // minimum required amount for any bid + duration: Uint32? // duration of auction in minutes + minimumBid: Uint64 // minimum required amount for any bid views: getInfo: params: color: Color // color identifies the auction results: - bidders: Int32 // nr of bidders + bidders: Uint32 // nr of bidders color: Color // color of tokens for sale creator: AgentID // issuer of start_auction transaction - deposit: Int64 // deposit by auction owner to cover the SC fees + deposit: Uint64 // deposit by auction owner to cover the SC fees description: String // auction description - duration: Int32 // auction duration in minutes - highestBid: Int64 // the current highest bid amount + duration: Uint32 // auction duration in minutes + highestBid: Uint64 // the current highest bid amount highestBidder: AgentID // the current highest bidder - minimumBid: Int64 // minimum bid amount - numTokens: Int64 // number of tokens for sale - ownerMargin: Int64 // auction owner's margin in promilles - whenStarted: Int64 // timestamp when auction started + minimumBid: Uint64 // minimum bid amount + numTokens: Uint64 // number of tokens for sale + ownerMargin: Uint64 // auction owner's margin in promilles + whenStarted: Uint64 // timestamp when auction started diff --git a/contracts/wasm/fairauction/src/fairauction.rs b/contracts/wasm/fairauction/src/fairauction.rs index 822eed784b..8c951d38bc 100644 --- a/contracts/wasm/fairauction/src/fairauction.rs +++ b/contracts/wasm/fairauction/src/fairauction.rs @@ -7,20 +7,20 @@ use crate::*; use crate::contract::*; use crate::structs::*; -const DURATION_DEFAULT: i32 = 60; -const DURATION_MIN: i32 = 1; -const DURATION_MAX: i32 = 120; +const DURATION_DEFAULT: u32 = 60; +const DURATION_MIN: u32 = 1; +const DURATION_MAX: u32 = 120; const MAX_DESCRIPTION_LENGTH: usize = 150; -const OWNER_MARGIN_DEFAULT: i64 = 50; -const OWNER_MARGIN_MIN: i64 = 5; -const OWNER_MARGIN_MAX: i64 = 100; +const OWNER_MARGIN_DEFAULT: u64 = 50; +const OWNER_MARGIN_MIN: u64 = 5; +const OWNER_MARGIN_MAX: u64 = 100; pub fn func_finalize_auction(ctx: &ScFuncContext, f: &FinalizeAuctionContext) { let color = f.params.color().value(); let current_auction = f.state.auctions().get_auction(&color); ctx.require(current_auction.exists(), "Missing auction info"); let auction = current_auction.value(); - if auction.highest_bid < 0 { + if auction.highest_bid == 0 { ctx.log(&("No one bid on ".to_string() + &color.to_string())); let mut owner_fee = auction.minimum_bid * auction.owner_margin / 1000; if owner_fee == 0 { @@ -166,7 +166,7 @@ pub fn func_start_auction(ctx: &ScFuncContext, f: &StartAuctionContext) { deposit: deposit, description: description, duration: duration, - highest_bid: -1, + highest_bid: 0, highest_bidder: ScAgentID::from_bytes(&[0; 37]), minimum_bid: minimum_bid, num_tokens: num_tokens, @@ -202,7 +202,7 @@ pub fn view_get_info(ctx: &ScViewContext, f: &GetInfoContext) { f.results.bidders().set_value(bidder_list.length()); } -fn transfer_tokens(ctx: &ScFuncContext, agent: &ScAgentID, color: &ScColor, amount: i64) { +fn transfer_tokens(ctx: &ScFuncContext, agent: &ScAgentID, color: &ScColor, amount: u64) { if agent.is_address() { // send back to original Tangle address ctx.transfer_to_address(&agent.address(), ScTransfers::transfer(color, amount)); diff --git a/contracts/wasm/fairauction/src/params.rs b/contracts/wasm/fairauction/src/params.rs index bcc902b795..9a8424ee55 100644 --- a/contracts/wasm/fairauction/src/params.rs +++ b/contracts/wasm/fairauction/src/params.rs @@ -66,8 +66,8 @@ pub struct ImmutableSetOwnerMarginParams { } impl ImmutableSetOwnerMarginParams { - pub fn owner_margin(&self) -> ScImmutableInt64 { - ScImmutableInt64::new(self.id, PARAM_OWNER_MARGIN.get_key_id()) + pub fn owner_margin(&self) -> ScImmutableUint64 { + ScImmutableUint64::new(self.id, PARAM_OWNER_MARGIN.get_key_id()) } } @@ -77,8 +77,8 @@ pub struct MutableSetOwnerMarginParams { } impl MutableSetOwnerMarginParams { - pub fn owner_margin(&self) -> ScMutableInt64 { - ScMutableInt64::new(self.id, PARAM_OWNER_MARGIN.get_key_id()) + pub fn owner_margin(&self) -> ScMutableUint64 { + ScMutableUint64::new(self.id, PARAM_OWNER_MARGIN.get_key_id()) } } @@ -96,12 +96,12 @@ impl ImmutableStartAuctionParams { ScImmutableString::new(self.id, PARAM_DESCRIPTION.get_key_id()) } - pub fn duration(&self) -> ScImmutableInt32 { - ScImmutableInt32::new(self.id, PARAM_DURATION.get_key_id()) + pub fn duration(&self) -> ScImmutableUint32 { + ScImmutableUint32::new(self.id, PARAM_DURATION.get_key_id()) } - pub fn minimum_bid(&self) -> ScImmutableInt64 { - ScImmutableInt64::new(self.id, PARAM_MINIMUM_BID.get_key_id()) + pub fn minimum_bid(&self) -> ScImmutableUint64 { + ScImmutableUint64::new(self.id, PARAM_MINIMUM_BID.get_key_id()) } } @@ -119,12 +119,12 @@ impl MutableStartAuctionParams { ScMutableString::new(self.id, PARAM_DESCRIPTION.get_key_id()) } - pub fn duration(&self) -> ScMutableInt32 { - ScMutableInt32::new(self.id, PARAM_DURATION.get_key_id()) + pub fn duration(&self) -> ScMutableUint32 { + ScMutableUint32::new(self.id, PARAM_DURATION.get_key_id()) } - pub fn minimum_bid(&self) -> ScMutableInt64 { - ScMutableInt64::new(self.id, PARAM_MINIMUM_BID.get_key_id()) + pub fn minimum_bid(&self) -> ScMutableUint64 { + ScMutableUint64::new(self.id, PARAM_MINIMUM_BID.get_key_id()) } } diff --git a/contracts/wasm/fairauction/src/results.rs b/contracts/wasm/fairauction/src/results.rs index 649bd85b43..b9635d084b 100644 --- a/contracts/wasm/fairauction/src/results.rs +++ b/contracts/wasm/fairauction/src/results.rs @@ -22,8 +22,8 @@ pub struct ImmutableGetInfoResults { } impl ImmutableGetInfoResults { - pub fn bidders(&self) -> ScImmutableInt32 { - ScImmutableInt32::new(self.id, RESULT_BIDDERS.get_key_id()) + pub fn bidders(&self) -> ScImmutableUint32 { + ScImmutableUint32::new(self.id, RESULT_BIDDERS.get_key_id()) } pub fn color(&self) -> ScImmutableColor { @@ -34,40 +34,40 @@ impl ImmutableGetInfoResults { ScImmutableAgentID::new(self.id, RESULT_CREATOR.get_key_id()) } - pub fn deposit(&self) -> ScImmutableInt64 { - ScImmutableInt64::new(self.id, RESULT_DEPOSIT.get_key_id()) + pub fn deposit(&self) -> ScImmutableUint64 { + ScImmutableUint64::new(self.id, RESULT_DEPOSIT.get_key_id()) } pub fn description(&self) -> ScImmutableString { ScImmutableString::new(self.id, RESULT_DESCRIPTION.get_key_id()) } - pub fn duration(&self) -> ScImmutableInt32 { - ScImmutableInt32::new(self.id, RESULT_DURATION.get_key_id()) + pub fn duration(&self) -> ScImmutableUint32 { + ScImmutableUint32::new(self.id, RESULT_DURATION.get_key_id()) } - pub fn highest_bid(&self) -> ScImmutableInt64 { - ScImmutableInt64::new(self.id, RESULT_HIGHEST_BID.get_key_id()) + pub fn highest_bid(&self) -> ScImmutableUint64 { + ScImmutableUint64::new(self.id, RESULT_HIGHEST_BID.get_key_id()) } pub fn highest_bidder(&self) -> ScImmutableAgentID { ScImmutableAgentID::new(self.id, RESULT_HIGHEST_BIDDER.get_key_id()) } - pub fn minimum_bid(&self) -> ScImmutableInt64 { - ScImmutableInt64::new(self.id, RESULT_MINIMUM_BID.get_key_id()) + pub fn minimum_bid(&self) -> ScImmutableUint64 { + ScImmutableUint64::new(self.id, RESULT_MINIMUM_BID.get_key_id()) } - pub fn num_tokens(&self) -> ScImmutableInt64 { - ScImmutableInt64::new(self.id, RESULT_NUM_TOKENS.get_key_id()) + pub fn num_tokens(&self) -> ScImmutableUint64 { + ScImmutableUint64::new(self.id, RESULT_NUM_TOKENS.get_key_id()) } - pub fn owner_margin(&self) -> ScImmutableInt64 { - ScImmutableInt64::new(self.id, RESULT_OWNER_MARGIN.get_key_id()) + pub fn owner_margin(&self) -> ScImmutableUint64 { + ScImmutableUint64::new(self.id, RESULT_OWNER_MARGIN.get_key_id()) } - pub fn when_started(&self) -> ScImmutableInt64 { - ScImmutableInt64::new(self.id, RESULT_WHEN_STARTED.get_key_id()) + pub fn when_started(&self) -> ScImmutableUint64 { + ScImmutableUint64::new(self.id, RESULT_WHEN_STARTED.get_key_id()) } } @@ -77,8 +77,8 @@ pub struct MutableGetInfoResults { } impl MutableGetInfoResults { - pub fn bidders(&self) -> ScMutableInt32 { - ScMutableInt32::new(self.id, RESULT_BIDDERS.get_key_id()) + pub fn bidders(&self) -> ScMutableUint32 { + ScMutableUint32::new(self.id, RESULT_BIDDERS.get_key_id()) } pub fn color(&self) -> ScMutableColor { @@ -89,39 +89,39 @@ impl MutableGetInfoResults { ScMutableAgentID::new(self.id, RESULT_CREATOR.get_key_id()) } - pub fn deposit(&self) -> ScMutableInt64 { - ScMutableInt64::new(self.id, RESULT_DEPOSIT.get_key_id()) + pub fn deposit(&self) -> ScMutableUint64 { + ScMutableUint64::new(self.id, RESULT_DEPOSIT.get_key_id()) } pub fn description(&self) -> ScMutableString { ScMutableString::new(self.id, RESULT_DESCRIPTION.get_key_id()) } - pub fn duration(&self) -> ScMutableInt32 { - ScMutableInt32::new(self.id, RESULT_DURATION.get_key_id()) + pub fn duration(&self) -> ScMutableUint32 { + ScMutableUint32::new(self.id, RESULT_DURATION.get_key_id()) } - pub fn highest_bid(&self) -> ScMutableInt64 { - ScMutableInt64::new(self.id, RESULT_HIGHEST_BID.get_key_id()) + pub fn highest_bid(&self) -> ScMutableUint64 { + ScMutableUint64::new(self.id, RESULT_HIGHEST_BID.get_key_id()) } pub fn highest_bidder(&self) -> ScMutableAgentID { ScMutableAgentID::new(self.id, RESULT_HIGHEST_BIDDER.get_key_id()) } - pub fn minimum_bid(&self) -> ScMutableInt64 { - ScMutableInt64::new(self.id, RESULT_MINIMUM_BID.get_key_id()) + pub fn minimum_bid(&self) -> ScMutableUint64 { + ScMutableUint64::new(self.id, RESULT_MINIMUM_BID.get_key_id()) } - pub fn num_tokens(&self) -> ScMutableInt64 { - ScMutableInt64::new(self.id, RESULT_NUM_TOKENS.get_key_id()) + pub fn num_tokens(&self) -> ScMutableUint64 { + ScMutableUint64::new(self.id, RESULT_NUM_TOKENS.get_key_id()) } - pub fn owner_margin(&self) -> ScMutableInt64 { - ScMutableInt64::new(self.id, RESULT_OWNER_MARGIN.get_key_id()) + pub fn owner_margin(&self) -> ScMutableUint64 { + ScMutableUint64::new(self.id, RESULT_OWNER_MARGIN.get_key_id()) } - pub fn when_started(&self) -> ScMutableInt64 { - ScMutableInt64::new(self.id, RESULT_WHEN_STARTED.get_key_id()) + pub fn when_started(&self) -> ScMutableUint64 { + ScMutableUint64::new(self.id, RESULT_WHEN_STARTED.get_key_id()) } } diff --git a/contracts/wasm/fairauction/src/state.rs b/contracts/wasm/fairauction/src/state.rs index 8f7b0007f1..e78565a455 100644 --- a/contracts/wasm/fairauction/src/state.rs +++ b/contracts/wasm/fairauction/src/state.rs @@ -72,8 +72,8 @@ impl ImmutableFairAuctionState { MapColorToImmutableBids { obj_id: map_id } } - pub fn owner_margin(&self) -> ScImmutableInt64 { - ScImmutableInt64::new(self.id, STATE_OWNER_MARGIN.get_key_id()) + pub fn owner_margin(&self) -> ScImmutableUint64 { + ScImmutableUint64::new(self.id, STATE_OWNER_MARGIN.get_key_id()) } } @@ -149,7 +149,7 @@ impl MutableFairAuctionState { MapColorToMutableBids { obj_id: map_id } } - pub fn owner_margin(&self) -> ScMutableInt64 { - ScMutableInt64::new(self.id, STATE_OWNER_MARGIN.get_key_id()) + pub fn owner_margin(&self) -> ScMutableUint64 { + ScMutableUint64::new(self.id, STATE_OWNER_MARGIN.get_key_id()) } } diff --git a/contracts/wasm/fairauction/src/structs.rs b/contracts/wasm/fairauction/src/structs.rs index 8a0f7e7194..18935b7857 100644 --- a/contracts/wasm/fairauction/src/structs.rs +++ b/contracts/wasm/fairauction/src/structs.rs @@ -16,15 +16,15 @@ use crate::typedefs::*; pub struct Auction { pub color : ScColor, // color of tokens for sale pub creator : ScAgentID, // issuer of start_auction transaction - pub deposit : i64, // deposit by auction owner to cover the SC fees + pub deposit : u64, // deposit by auction owner to cover the SC fees pub description : String, // auction description - pub duration : i32, // auction duration in minutes - pub highest_bid : i64, // the current highest bid amount + pub duration : u32, // auction duration in minutes + pub highest_bid : u64, // the current highest bid amount pub highest_bidder : ScAgentID, // the current highest bidder - pub minimum_bid : i64, // minimum bid amount - pub num_tokens : i64, // number of tokens for sale - pub owner_margin : i64, // auction owner's margin in promilles - pub when_started : i64, // timestamp when auction started + pub minimum_bid : u64, // minimum bid amount + pub num_tokens : u64, // number of tokens for sale + pub owner_margin : u64, // auction owner's margin in promilles + pub when_started : u64, // timestamp when auction started } impl Auction { @@ -33,15 +33,15 @@ impl Auction { Auction { color : decode.color(), creator : decode.agent_id(), - deposit : decode.int64(), + deposit : decode.uint64(), description : decode.string(), - duration : decode.int32(), - highest_bid : decode.int64(), + duration : decode.uint32(), + highest_bid : decode.uint64(), highest_bidder : decode.agent_id(), - minimum_bid : decode.int64(), - num_tokens : decode.int64(), - owner_margin : decode.int64(), - when_started : decode.int64(), + minimum_bid : decode.uint64(), + num_tokens : decode.uint64(), + owner_margin : decode.uint64(), + when_started : decode.uint64(), } } @@ -49,15 +49,15 @@ impl Auction { let mut encode = BytesEncoder::new(); encode.color(&self.color); encode.agent_id(&self.creator); - encode.int64(self.deposit); + encode.uint64(self.deposit); encode.string(&self.description); - encode.int32(self.duration); - encode.int64(self.highest_bid); + encode.uint32(self.duration); + encode.uint64(self.highest_bid); encode.agent_id(&self.highest_bidder); - encode.int64(self.minimum_bid); - encode.int64(self.num_tokens); - encode.int64(self.owner_margin); - encode.int64(self.when_started); + encode.uint64(self.minimum_bid); + encode.uint64(self.num_tokens); + encode.uint64(self.owner_margin); + encode.uint64(self.when_started); return encode.data(); } } @@ -104,26 +104,26 @@ impl MutableAuction { #[derive(Clone)] pub struct Bid { - pub amount : i64, // cumulative amount of bids from same bidder - pub index : i32, // index of bidder in bidder list - pub timestamp : i64, // timestamp of most recent bid + pub amount : u64, // cumulative amount of bids from same bidder + pub index : u32, // index of bidder in bidder list + pub timestamp : u64, // timestamp of most recent bid } impl Bid { pub fn from_bytes(bytes: &[u8]) -> Bid { let mut decode = BytesDecoder::new(bytes); Bid { - amount : decode.int64(), - index : decode.int32(), - timestamp : decode.int64(), + amount : decode.uint64(), + index : decode.uint32(), + timestamp : decode.uint64(), } } pub fn to_bytes(&self) -> Vec { let mut encode = BytesEncoder::new(); - encode.int64(self.amount); - encode.int32(self.index); - encode.int64(self.timestamp); + encode.uint64(self.amount); + encode.uint32(self.index); + encode.uint64(self.timestamp); return encode.data(); } } diff --git a/contracts/wasm/fairauction/src/typedefs.rs b/contracts/wasm/fairauction/src/typedefs.rs index 83938d4385..123f38eec8 100644 --- a/contracts/wasm/fairauction/src/typedefs.rs +++ b/contracts/wasm/fairauction/src/typedefs.rs @@ -17,12 +17,12 @@ pub struct ArrayOfImmutableAgentID { } impl ArrayOfImmutableAgentID { - pub fn length(&self) -> i32 { + pub fn length(&self) -> u32 { get_length(self.obj_id) } - pub fn get_agent_id(&self, index: i32) -> ScImmutableAgentID { - ScImmutableAgentID::new(self.obj_id, Key32(index)) + pub fn get_agent_id(&self, index: u32) -> ScImmutableAgentID { + ScImmutableAgentID::new(self.obj_id, Key32(index as i32)) } } @@ -38,12 +38,12 @@ impl ArrayOfMutableAgentID { clear(self.obj_id); } - pub fn length(&self) -> i32 { + pub fn length(&self) -> u32 { get_length(self.obj_id) } - pub fn get_agent_id(&self, index: i32) -> ScMutableAgentID { - ScMutableAgentID::new(self.obj_id, Key32(index)) + pub fn get_agent_id(&self, index: u32) -> ScMutableAgentID { + ScMutableAgentID::new(self.obj_id, Key32(index as i32)) } } diff --git a/contracts/wasm/fairauction/test/fairauction_bg.wasm b/contracts/wasm/fairau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nj|EHd@uVz?Uca9zRpa7fR^z3Sk@8!FuCb*op`H7s)$u3faI zZe@d0*RXWujFryHh9%B@b&K%@8h+Fa|AA6BKQc70q;B*mXT_3+Wowoj#`rv8Og0ST uQ%Y@9MO0OH<4AvReLxsfv2za@#t?k#8Xj1<0{C)IXJ9r`>ipx)H~c@+0oSVl diff --git a/contracts/wasm/fairauction/test/fairauction_test.go b/contracts/wasm/fairauction/test/fairauction_test.go index 389ea409ad..c8e5ca8022 100644 --- a/contracts/wasm/fairauction/test/fairauction_test.go +++ b/contracts/wasm/fairauction/test/fairauction_test.go @@ -9,14 +9,14 @@ import ( "github.com/iotaledger/wasp/contracts/wasm/fairauction/go/fairauction" "github.com/iotaledger/wasp/packages/solo" - "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" + "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" "github.com/iotaledger/wasp/packages/vm/wasmsolo" "github.com/stretchr/testify/require" ) var ( auctioneer *wasmsolo.SoloAgent - tokenColor wasmlib.ScColor + tokenColor wasmtypes.ScColor ) func startAuction(t *testing.T) *wasmsolo.SoloContext { @@ -35,8 +35,8 @@ func startAuction(t *testing.T) *wasmsolo.SoloContext { sa.Params.MinimumBid().SetValue(500) sa.Params.Description().SetValue("Cool tokens for sale!") transfer := ctx.Transfer() - transfer.Set(wasmlib.IOTA, 25) // deposit, must be >=minimum*margin - transfer.Set(tokenColor, 10) // the tokens to auction + transfer.Set(wasmtypes.IOTA, 25) // deposit, must be >=minimum*margin + transfer.Set(tokenColor, 10) // the tokens to auction sa.Func.Transfer(transfer).Post() require.NoError(t, ctx.Err) return ctx diff --git a/contracts/wasm/fairauction/ts/fairauction/fairauction.ts b/contracts/wasm/fairauction/ts/fairauction/fairauction.ts index 936a50dddc..4f9bf15c1a 100644 --- a/contracts/wasm/fairauction/ts/fairauction/fairauction.ts +++ b/contracts/wasm/fairauction/ts/fairauction/fairauction.ts @@ -4,20 +4,20 @@ import * as wasmlib from "wasmlib" import * as sc from "./index"; -const DURATION_DEFAULT: i32 = 60; -const DURATION_MIN: i32 = 1; -const DURATION_MAX: i32 = 120; +const DURATION_DEFAULT: u32 = 60; +const DURATION_MIN: u32 = 1; +const DURATION_MAX: u32 = 120; const MAX_DESCRIPTION_LENGTH: i32 = 150; -const OWNER_MARGIN_DEFAULT: i64 = 50; -const OWNER_MARGIN_MIN: i64 = 5; -const OWNER_MARGIN_MAX: i64 = 100; +const OWNER_MARGIN_DEFAULT: u64 = 50; +const OWNER_MARGIN_MIN: u64 = 5; +const OWNER_MARGIN_MAX: u64 = 100; export function funcFinalizeAuction(ctx: wasmlib.ScFuncContext, f: sc.FinalizeAuctionContext): void { let color = f.params.color().value(); let currentAuction = f.state.auctions().getAuction(color); ctx.require(currentAuction.exists(), "Missing auction info"); let auction = currentAuction.value(); - if (auction.highestBid < 0) { + if (auction.highestBid == 0) { ctx.log("No one bid on " + color.toString()); let ownerFee = auction.minimumBid * auction.ownerMargin / 1000; if (ownerFee == 0) { @@ -39,7 +39,7 @@ export function funcFinalizeAuction(ctx: wasmlib.ScFuncContext, f: sc.FinalizeAu let bids = f.state.bids().getBids(color); let bidderList = f.state.bidderList().getBidderList(color); let size = bidderList.length(); - for (let i = 0; i < size; i++) { + for (let i: u32 = 0; i < size; i++) { let loser = bidderList.getAgentID(i).value(); if (loser != auction.highestBidder) { let bid = bids.getBid(loser).value(); @@ -161,7 +161,7 @@ export function funcStartAuction(ctx: wasmlib.ScFuncContext, f: sc.StartAuctionC auction.deposit = deposit; auction.description = description; auction.duration = duration; - auction.highestBid = -1; + auction.highestBid = 0; auction.highestBidder = new wasmlib.ScAgentID(); auction.minimumBid = minimumBid; auction.numTokens = numTokens; diff --git a/contracts/wasm/fairauction/ts/fairauction/params.ts b/contracts/wasm/fairauction/ts/fairauction/params.ts index ee3ad774c6..34d1eca8dd 100644 --- a/contracts/wasm/fairauction/ts/fairauction/params.ts +++ b/contracts/wasm/fairauction/ts/fairauction/params.ts @@ -33,14 +33,14 @@ export class MutablePlaceBidParams extends wasmlib.ScMapID { } export class ImmutableSetOwnerMarginParams extends wasmlib.ScMapID { - ownerMargin(): wasmlib.ScImmutableInt64 { - return new wasmlib.ScImmutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ParamOwnerMargin)); + ownerMargin(): wasmlib.ScImmutableUint64 { + return new wasmlib.ScImmutableUint64(this.mapID, wasmlib.Key32.fromString(sc.ParamOwnerMargin)); } } export class MutableSetOwnerMarginParams extends wasmlib.ScMapID { - ownerMargin(): wasmlib.ScMutableInt64 { - return new wasmlib.ScMutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ParamOwnerMargin)); + ownerMargin(): wasmlib.ScMutableUint64 { + return new wasmlib.ScMutableUint64(this.mapID, wasmlib.Key32.fromString(sc.ParamOwnerMargin)); } } @@ -53,12 +53,12 @@ export class ImmutableStartAuctionParams extends wasmlib.ScMapID { return new wasmlib.ScImmutableString(this.mapID, wasmlib.Key32.fromString(sc.ParamDescription)); } - duration(): wasmlib.ScImmutableInt32 { - return new wasmlib.ScImmutableInt32(this.mapID, wasmlib.Key32.fromString(sc.ParamDuration)); + duration(): wasmlib.ScImmutableUint32 { + return new wasmlib.ScImmutableUint32(this.mapID, wasmlib.Key32.fromString(sc.ParamDuration)); } - minimumBid(): wasmlib.ScImmutableInt64 { - return new wasmlib.ScImmutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ParamMinimumBid)); + minimumBid(): wasmlib.ScImmutableUint64 { + return new wasmlib.ScImmutableUint64(this.mapID, wasmlib.Key32.fromString(sc.ParamMinimumBid)); } } @@ -71,12 +71,12 @@ export class MutableStartAuctionParams extends wasmlib.ScMapID { return new wasmlib.ScMutableString(this.mapID, wasmlib.Key32.fromString(sc.ParamDescription)); } - duration(): wasmlib.ScMutableInt32 { - return new wasmlib.ScMutableInt32(this.mapID, wasmlib.Key32.fromString(sc.ParamDuration)); + duration(): wasmlib.ScMutableUint32 { + return new wasmlib.ScMutableUint32(this.mapID, wasmlib.Key32.fromString(sc.ParamDuration)); } - minimumBid(): wasmlib.ScMutableInt64 { - return new wasmlib.ScMutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ParamMinimumBid)); + minimumBid(): wasmlib.ScMutableUint64 { + return new wasmlib.ScMutableUint64(this.mapID, wasmlib.Key32.fromString(sc.ParamMinimumBid)); } } diff --git a/contracts/wasm/fairauction/ts/fairauction/results.ts b/contracts/wasm/fairauction/ts/fairauction/results.ts index 659f739093..7aa0227bf4 100644 --- a/contracts/wasm/fairauction/ts/fairauction/results.ts +++ b/contracts/wasm/fairauction/ts/fairauction/results.ts @@ -9,8 +9,8 @@ import * as wasmlib from "wasmlib"; import * as sc from "./index"; export class ImmutableGetInfoResults extends wasmlib.ScMapID { - bidders(): wasmlib.ScImmutableInt32 { - return new wasmlib.ScImmutableInt32(this.mapID, wasmlib.Key32.fromString(sc.ResultBidders)); + bidders(): wasmlib.ScImmutableUint32 { + return new wasmlib.ScImmutableUint32(this.mapID, wasmlib.Key32.fromString(sc.ResultBidders)); } color(): wasmlib.ScImmutableColor { @@ -21,46 +21,46 @@ export class ImmutableGetInfoResults extends wasmlib.ScMapID { return new wasmlib.ScImmutableAgentID(this.mapID, wasmlib.Key32.fromString(sc.ResultCreator)); } - deposit(): wasmlib.ScImmutableInt64 { - return new wasmlib.ScImmutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ResultDeposit)); + deposit(): wasmlib.ScImmutableUint64 { + return new wasmlib.ScImmutableUint64(this.mapID, wasmlib.Key32.fromString(sc.ResultDeposit)); } description(): wasmlib.ScImmutableString { return new wasmlib.ScImmutableString(this.mapID, wasmlib.Key32.fromString(sc.ResultDescription)); } - duration(): wasmlib.ScImmutableInt32 { - return new wasmlib.ScImmutableInt32(this.mapID, wasmlib.Key32.fromString(sc.ResultDuration)); + duration(): wasmlib.ScImmutableUint32 { + return new wasmlib.ScImmutableUint32(this.mapID, wasmlib.Key32.fromString(sc.ResultDuration)); } - highestBid(): wasmlib.ScImmutableInt64 { - return new wasmlib.ScImmutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ResultHighestBid)); + highestBid(): wasmlib.ScImmutableUint64 { + return new wasmlib.ScImmutableUint64(this.mapID, wasmlib.Key32.fromString(sc.ResultHighestBid)); } highestBidder(): wasmlib.ScImmutableAgentID { return new wasmlib.ScImmutableAgentID(this.mapID, wasmlib.Key32.fromString(sc.ResultHighestBidder)); } - minimumBid(): wasmlib.ScImmutableInt64 { - return new wasmlib.ScImmutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ResultMinimumBid)); + minimumBid(): wasmlib.ScImmutableUint64 { + return new wasmlib.ScImmutableUint64(this.mapID, wasmlib.Key32.fromString(sc.ResultMinimumBid)); } - numTokens(): wasmlib.ScImmutableInt64 { - return new wasmlib.ScImmutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ResultNumTokens)); + numTokens(): wasmlib.ScImmutableUint64 { + return new wasmlib.ScImmutableUint64(this.mapID, wasmlib.Key32.fromString(sc.ResultNumTokens)); } - ownerMargin(): wasmlib.ScImmutableInt64 { - return new wasmlib.ScImmutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ResultOwnerMargin)); + ownerMargin(): wasmlib.ScImmutableUint64 { + return new wasmlib.ScImmutableUint64(this.mapID, wasmlib.Key32.fromString(sc.ResultOwnerMargin)); } - whenStarted(): wasmlib.ScImmutableInt64 { - return new wasmlib.ScImmutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ResultWhenStarted)); + whenStarted(): wasmlib.ScImmutableUint64 { + return new wasmlib.ScImmutableUint64(this.mapID, wasmlib.Key32.fromString(sc.ResultWhenStarted)); } } export class MutableGetInfoResults extends wasmlib.ScMapID { - bidders(): wasmlib.ScMutableInt32 { - return new wasmlib.ScMutableInt32(this.mapID, wasmlib.Key32.fromString(sc.ResultBidders)); + bidders(): wasmlib.ScMutableUint32 { + return new wasmlib.ScMutableUint32(this.mapID, wasmlib.Key32.fromString(sc.ResultBidders)); } color(): wasmlib.ScMutableColor { @@ -71,39 +71,39 @@ export class MutableGetInfoResults extends wasmlib.ScMapID { return new wasmlib.ScMutableAgentID(this.mapID, wasmlib.Key32.fromString(sc.ResultCreator)); } - deposit(): wasmlib.ScMutableInt64 { - return new wasmlib.ScMutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ResultDeposit)); + deposit(): wasmlib.ScMutableUint64 { + return new wasmlib.ScMutableUint64(this.mapID, wasmlib.Key32.fromString(sc.ResultDeposit)); } description(): wasmlib.ScMutableString { return new wasmlib.ScMutableString(this.mapID, wasmlib.Key32.fromString(sc.ResultDescription)); } - duration(): wasmlib.ScMutableInt32 { - return new wasmlib.ScMutableInt32(this.mapID, wasmlib.Key32.fromString(sc.ResultDuration)); + duration(): wasmlib.ScMutableUint32 { + return new wasmlib.ScMutableUint32(this.mapID, wasmlib.Key32.fromString(sc.ResultDuration)); } - highestBid(): wasmlib.ScMutableInt64 { - return new wasmlib.ScMutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ResultHighestBid)); + highestBid(): wasmlib.ScMutableUint64 { + return new wasmlib.ScMutableUint64(this.mapID, wasmlib.Key32.fromString(sc.ResultHighestBid)); } highestBidder(): wasmlib.ScMutableAgentID { return new wasmlib.ScMutableAgentID(this.mapID, wasmlib.Key32.fromString(sc.ResultHighestBidder)); } - minimumBid(): wasmlib.ScMutableInt64 { - return new wasmlib.ScMutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ResultMinimumBid)); + minimumBid(): wasmlib.ScMutableUint64 { + return new wasmlib.ScMutableUint64(this.mapID, wasmlib.Key32.fromString(sc.ResultMinimumBid)); } - numTokens(): wasmlib.ScMutableInt64 { - return new wasmlib.ScMutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ResultNumTokens)); + numTokens(): wasmlib.ScMutableUint64 { + return new wasmlib.ScMutableUint64(this.mapID, wasmlib.Key32.fromString(sc.ResultNumTokens)); } - ownerMargin(): wasmlib.ScMutableInt64 { - return new wasmlib.ScMutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ResultOwnerMargin)); + ownerMargin(): wasmlib.ScMutableUint64 { + return new wasmlib.ScMutableUint64(this.mapID, wasmlib.Key32.fromString(sc.ResultOwnerMargin)); } - whenStarted(): wasmlib.ScMutableInt64 { - return new wasmlib.ScMutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ResultWhenStarted)); + whenStarted(): wasmlib.ScMutableUint64 { + return new wasmlib.ScMutableUint64(this.mapID, wasmlib.Key32.fromString(sc.ResultWhenStarted)); } } diff --git a/contracts/wasm/fairauction/ts/fairauction/state.ts b/contracts/wasm/fairauction/ts/fairauction/state.ts index 5c87258728..0f07971c70 100644 --- a/contracts/wasm/fairauction/ts/fairauction/state.ts +++ b/contracts/wasm/fairauction/ts/fairauction/state.ts @@ -62,8 +62,8 @@ export class ImmutableFairAuctionState extends wasmlib.ScMapID { return new sc.MapColorToImmutableBids(mapID); } - ownerMargin(): wasmlib.ScImmutableInt64 { - return new wasmlib.ScImmutableInt64(this.mapID, wasmlib.Key32.fromString(sc.StateOwnerMargin)); + ownerMargin(): wasmlib.ScImmutableUint64 { + return new wasmlib.ScImmutableUint64(this.mapID, wasmlib.Key32.fromString(sc.StateOwnerMargin)); } } @@ -139,7 +139,7 @@ export class MutableFairAuctionState extends wasmlib.ScMapID { return new sc.MapColorToMutableBids(mapID); } - ownerMargin(): wasmlib.ScMutableInt64 { - return new wasmlib.ScMutableInt64(this.mapID, wasmlib.Key32.fromString(sc.StateOwnerMargin)); + ownerMargin(): wasmlib.ScMutableUint64 { + return new wasmlib.ScMutableUint64(this.mapID, wasmlib.Key32.fromString(sc.StateOwnerMargin)); } } diff --git a/contracts/wasm/fairauction/ts/fairauction/structs.ts b/contracts/wasm/fairauction/ts/fairauction/structs.ts index 2325e38180..ea4d18fd7d 100644 --- a/contracts/wasm/fairauction/ts/fairauction/structs.ts +++ b/contracts/wasm/fairauction/ts/fairauction/structs.ts @@ -10,30 +10,30 @@ import * as wasmlib from "wasmlib"; export class Auction { color : wasmlib.ScColor = new wasmlib.ScColor(0); // color of tokens for sale creator : wasmlib.ScAgentID = new wasmlib.ScAgentID(); // issuer of start_auction transaction - deposit : i64 = 0; // deposit by auction owner to cover the SC fees + deposit : u64 = 0; // deposit by auction owner to cover the SC fees description : string = ""; // auction description - duration : i32 = 0; // auction duration in minutes - highestBid : i64 = 0; // the current highest bid amount + duration : u32 = 0; // auction duration in minutes + highestBid : u64 = 0; // the current highest bid amount highestBidder : wasmlib.ScAgentID = new wasmlib.ScAgentID(); // the current highest bidder - minimumBid : i64 = 0; // minimum bid amount - numTokens : i64 = 0; // number of tokens for sale - ownerMargin : i64 = 0; // auction owner's margin in promilles - whenStarted : i64 = 0; // timestamp when auction started + minimumBid : u64 = 0; // minimum bid amount + numTokens : u64 = 0; // number of tokens for sale + ownerMargin : u64 = 0; // auction owner's margin in promilles + whenStarted : u64 = 0; // timestamp when auction started static fromBytes(bytes: u8[]): Auction { let decode = new wasmlib.BytesDecoder(bytes); let data = new Auction(); data.color = decode.color(); data.creator = decode.agentID(); - data.deposit = decode.int64(); + data.deposit = decode.uint64(); data.description = decode.string(); - data.duration = decode.int32(); - data.highestBid = decode.int64(); + data.duration = decode.uint32(); + data.highestBid = decode.uint64(); data.highestBidder = decode.agentID(); - data.minimumBid = decode.int64(); - data.numTokens = decode.int64(); - data.ownerMargin = decode.int64(); - data.whenStarted = decode.int64(); + data.minimumBid = decode.uint64(); + data.numTokens = decode.uint64(); + data.ownerMargin = decode.uint64(); + data.whenStarted = decode.uint64(); decode.close(); return data; } @@ -42,15 +42,15 @@ export class Auction { return new wasmlib.BytesEncoder(). color(this.color). agentID(this.creator). - int64(this.deposit). + uint64(this.deposit). string(this.description). - int32(this.duration). - int64(this.highestBid). + uint32(this.duration). + uint64(this.highestBid). agentID(this.highestBidder). - int64(this.minimumBid). - int64(this.numTokens). - int64(this.ownerMargin). - int64(this.whenStarted). + uint64(this.minimumBid). + uint64(this.numTokens). + uint64(this.ownerMargin). + uint64(this.whenStarted). data(); } } @@ -100,25 +100,25 @@ export class MutableAuction { } export class Bid { - amount : i64 = 0; // cumulative amount of bids from same bidder - index : i32 = 0; // index of bidder in bidder list - timestamp : i64 = 0; // timestamp of most recent bid + amount : u64 = 0; // cumulative amount of bids from same bidder + index : u32 = 0; // index of bidder in bidder list + timestamp : u64 = 0; // timestamp of most recent bid static fromBytes(bytes: u8[]): Bid { let decode = new wasmlib.BytesDecoder(bytes); let data = new Bid(); - data.amount = decode.int64(); - data.index = decode.int32(); - data.timestamp = decode.int64(); + data.amount = decode.uint64(); + data.index = decode.uint32(); + data.timestamp = decode.uint64(); decode.close(); return data; } bytes(): u8[] { return new wasmlib.BytesEncoder(). - int64(this.amount). - int32(this.index). - int64(this.timestamp). + uint64(this.amount). + uint32(this.index). + uint64(this.timestamp). data(); } } diff --git a/contracts/wasm/fairauction/ts/fairauction/typedefs.ts b/contracts/wasm/fairauction/ts/fairauction/typedefs.ts index 246878fa3c..c642ed281a 100644 --- a/contracts/wasm/fairauction/ts/fairauction/typedefs.ts +++ b/contracts/wasm/fairauction/ts/fairauction/typedefs.ts @@ -15,12 +15,12 @@ export class ArrayOfImmutableAgentID { this.objID = objID; } - length(): i32 { + length(): u32 { return wasmlib.getLength(this.objID); } - getAgentID(index: i32): wasmlib.ScImmutableAgentID { - return new wasmlib.ScImmutableAgentID(this.objID, new wasmlib.Key32(index)); + getAgentID(index: u32): wasmlib.ScImmutableAgentID { + return new wasmlib.ScImmutableAgentID(this.objID, new wasmlib.Key32(index as i32)); } } @@ -38,12 +38,12 @@ export class ArrayOfMutableAgentID { wasmlib.clear(this.objID); } - length(): i32 { + length(): u32 { return wasmlib.getLength(this.objID); } - getAgentID(index: i32): wasmlib.ScMutableAgentID { - return new wasmlib.ScMutableAgentID(this.objID, new wasmlib.Key32(index)); + getAgentID(index: u32): wasmlib.ScMutableAgentID { + return new wasmlib.ScMutableAgentID(this.objID, new wasmlib.Key32(index as i32)); } } diff --git a/contracts/wasm/fairroulette/go/fairroulette/consts.go b/contracts/wasm/fairroulette/go/fairroulette/consts.go index 69bdc218e0..6a10f04f91 100644 --- a/contracts/wasm/fairroulette/go/fairroulette/consts.go +++ b/contracts/wasm/fairroulette/go/fairroulette/consts.go @@ -7,12 +7,12 @@ package fairroulette -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" +import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" const ( ScName = "fairroulette" ScDescription = "" - HScName = wasmlib.ScHname(0xdf79d138) + HScName = wasmtypes.ScHname(0xdf79d138) ) const ( @@ -49,13 +49,13 @@ const ( ) const ( - HFuncForcePayout = wasmlib.ScHname(0x555a4c4f) - HFuncForceReset = wasmlib.ScHname(0xa331951e) - HFuncPayWinners = wasmlib.ScHname(0xfb2b0144) - HFuncPlaceBet = wasmlib.ScHname(0xdfba7d1b) - HFuncPlayPeriod = wasmlib.ScHname(0xcb94b293) - HViewLastWinningNumber = wasmlib.ScHname(0x2f5f09fe) - HViewRoundNumber = wasmlib.ScHname(0x0dcfe520) - HViewRoundStartedAt = wasmlib.ScHname(0x725de8b4) - HViewRoundStatus = wasmlib.ScHname(0x145053b5) + HFuncForcePayout = wasmtypes.ScHname(0x555a4c4f) + HFuncForceReset = wasmtypes.ScHname(0xa331951e) + HFuncPayWinners = wasmtypes.ScHname(0xfb2b0144) + HFuncPlaceBet = wasmtypes.ScHname(0xdfba7d1b) + HFuncPlayPeriod = wasmtypes.ScHname(0xcb94b293) + HViewLastWinningNumber = wasmtypes.ScHname(0x2f5f09fe) + HViewRoundNumber = wasmtypes.ScHname(0x0dcfe520) + HViewRoundStartedAt = wasmtypes.ScHname(0x725de8b4) + HViewRoundStatus = wasmtypes.ScHname(0x145053b5) ) diff --git a/contracts/wasm/fairroulette/go/fairroulette/contract.go b/contracts/wasm/fairroulette/go/fairroulette/contract.go index 6f324490b1..bcd7a7643d 100644 --- a/contracts/wasm/fairroulette/go/fairroulette/contract.go +++ b/contracts/wasm/fairroulette/go/fairroulette/contract.go @@ -69,36 +69,36 @@ func (sc Funcs) PayWinners(ctx wasmlib.ScFuncCallContext) *PayWinnersCall { func (sc Funcs) PlaceBet(ctx wasmlib.ScFuncCallContext) *PlaceBetCall { f := &PlaceBetCall{Func: wasmlib.NewScFunc(ctx, HScName, HFuncPlaceBet)} - f.Func.SetPtrs(&f.Params.id, nil) + f.Params.proxy = wasmlib.NewCallParamsProxy(&f.Func.ScView) return f } func (sc Funcs) PlayPeriod(ctx wasmlib.ScFuncCallContext) *PlayPeriodCall { f := &PlayPeriodCall{Func: wasmlib.NewScFunc(ctx, HScName, HFuncPlayPeriod)} - f.Func.SetPtrs(&f.Params.id, nil) + f.Params.proxy = wasmlib.NewCallParamsProxy(&f.Func.ScView) return f } func (sc Funcs) LastWinningNumber(ctx wasmlib.ScViewCallContext) *LastWinningNumberCall { f := &LastWinningNumberCall{Func: wasmlib.NewScView(ctx, HScName, HViewLastWinningNumber)} - f.Func.SetPtrs(nil, &f.Results.id) + wasmlib.NewCallResultsProxy(f.Func, &f.Results.proxy) return f } func (sc Funcs) RoundNumber(ctx wasmlib.ScViewCallContext) *RoundNumberCall { f := &RoundNumberCall{Func: wasmlib.NewScView(ctx, HScName, HViewRoundNumber)} - f.Func.SetPtrs(nil, &f.Results.id) + wasmlib.NewCallResultsProxy(f.Func, &f.Results.proxy) return f } func (sc Funcs) RoundStartedAt(ctx wasmlib.ScViewCallContext) *RoundStartedAtCall { f := &RoundStartedAtCall{Func: wasmlib.NewScView(ctx, HScName, HViewRoundStartedAt)} - f.Func.SetPtrs(nil, &f.Results.id) + wasmlib.NewCallResultsProxy(f.Func, &f.Results.proxy) return f } func (sc Funcs) RoundStatus(ctx wasmlib.ScViewCallContext) *RoundStatusCall { f := &RoundStatusCall{Func: wasmlib.NewScView(ctx, HScName, HViewRoundStatus)} - f.Func.SetPtrs(nil, &f.Results.id) + wasmlib.NewCallResultsProxy(f.Func, &f.Results.proxy) return f } diff --git a/contracts/wasm/fairroulette/go/fairroulette/events.go b/contracts/wasm/fairroulette/go/fairroulette/events.go index 353c75c871..0159e09921 100644 --- a/contracts/wasm/fairroulette/go/fairroulette/events.go +++ b/contracts/wasm/fairroulette/go/fairroulette/events.go @@ -5,31 +5,33 @@ // >>>> DO NOT CHANGE THIS FILE! <<<< // Change the json schema instead -//nolint:gocritic package fairroulette -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" +import ( + "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" + "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" +) type FairRouletteEvents struct{} -func (e FairRouletteEvents) Bet(address wasmlib.ScAddress, amount int64, number int64) { +func (e FairRouletteEvents) Bet(address wasmtypes.ScAddress, amount uint64, number uint16) { wasmlib.NewEventEncoder("fairroulette.bet"). Address(address). - Int64(amount). - Int64(number). + Uint64(amount). + Uint16(number). Emit() } -func (e FairRouletteEvents) Payout(address wasmlib.ScAddress, amount int64) { +func (e FairRouletteEvents) Payout(address wasmtypes.ScAddress, amount uint64) { wasmlib.NewEventEncoder("fairroulette.payout"). Address(address). - Int64(amount). + Uint64(amount). Emit() } -func (e FairRouletteEvents) Round(number int64) { +func (e FairRouletteEvents) Round(number uint32) { wasmlib.NewEventEncoder("fairroulette.round"). - Int64(number). + Uint32(number). Emit() } @@ -43,8 +45,8 @@ func (e FairRouletteEvents) Stop() { Emit() } -func (e FairRouletteEvents) Winner(number int64) { +func (e FairRouletteEvents) Winner(number uint16) { wasmlib.NewEventEncoder("fairroulette.winner"). - Int64(number). + Uint16(number). Emit() } diff --git a/contracts/wasm/fairroulette/go/fairroulette/fairroulette.go b/contracts/wasm/fairroulette/go/fairroulette/fairroulette.go index 729953c23c..5ed3739a45 100644 --- a/contracts/wasm/fairroulette/go/fairroulette/fairroulette.go +++ b/contracts/wasm/fairroulette/go/fairroulette/fairroulette.go @@ -11,6 +11,7 @@ package fairroulette import ( "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" + "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" ) // Define some default configuration parameters. @@ -39,7 +40,8 @@ func funcPlaceBet(ctx wasmlib.ScFuncContext, f *PlaceBetContext) { // Get the array of current bets from state storage. bets := f.State.Bets() - for i := int32(0); i < bets.Length(); i++ { + nrOfBets := bets.Length() + for i := uint32(0); i < nrOfBets; i++ { bet := bets.GetBet(i).Value() if bet.Better.Address() == ctx.Caller().Address() { @@ -60,7 +62,7 @@ func funcPlaceBet(ctx wasmlib.ScFuncContext, f *PlaceBetContext) { incoming := ctx.Incoming() // Retrieve the amount of plain iota tokens that are part of the incoming balance. - amount := incoming.Balance(wasmlib.IOTA) + amount := incoming.Balance(wasmtypes.IOTA) // Require that there are actually some plain iotas there ctx.Require(amount > 0, "empty bet") @@ -74,17 +76,14 @@ func funcPlaceBet(ctx wasmlib.ScFuncContext, f *PlaceBetContext) { Number: number, } - // Determine what the next bet number is by retrieving the length of the bets array. - betNr := bets.Length() - // Append the bet data to the bets array. The bet array will automatically take care // of serializing the bet struct into a bytes representation. - bets.GetBet(betNr).SetValue(bet) + bets.AppendBet().SetValue(bet) f.Events.Bet(bet.Better.Address(), bet.Amount, bet.Number) // Was this the first bet of this round? - if betNr == 0 { + if nrOfBets == 0 { // Yes it was, query the state for the length of the playing period in seconds by // retrieving the playPeriod value from state storage playPeriod := f.State.PlayPeriod().Value() @@ -100,7 +99,7 @@ func funcPlaceBet(ctx wasmlib.ScFuncContext, f *PlaceBetContext) { f.State.RoundStatus().SetValue(1) // timestamp is nanotime, divide by NanoTimeDivider to get seconds => common unix timestamp - timestamp := int32(ctx.Timestamp() / NanoTimeDivider) + timestamp := uint32(ctx.Timestamp() / NanoTimeDivider) f.State.RoundStartedAt().SetValue(timestamp) f.Events.Start() @@ -130,7 +129,7 @@ func funcPayWinners(ctx wasmlib.ScFuncContext, f *PayWinnersContext) { // generator will use the next 8 bytes from the hash as its random Int64 number and once // it runs out of data it simply hashes the previous hash for a next pseudo-random sequence. // Here we determine the winning number for this round in the range of 1 thru MaxNumber. - winningNumber := ctx.Random(MaxNumber-1) + 1 + winningNumber := uint16(ctx.Random(MaxNumber-1) + 1) // Save the last winning number in state storage under 'lastWinningNumber' so that there // is (limited) time for people to call the 'getLastWinningNumber' View to verify the last @@ -143,18 +142,18 @@ func funcPayWinners(ctx wasmlib.ScFuncContext, f *PayWinnersContext) { // Keep track of the total bet amount, the total win amount, and all the winners. // Note how we decided to keep the winners in a local vector instead of creating // yet another array in state storage or having to go through lockedBets again. - totalBetAmount := int64(0) - totalWinAmount := int64(0) + totalBetAmount := uint64(0) + totalWinAmount := uint64(0) winners := make([]*Bet, 0) // Get the 'bets' array in state storage. bets := f.State.Bets() // Determine the amount of bets in the 'bets' array. - nrBets := bets.Length() + nrOfBets := bets.Length() // Loop through all indexes of the 'bets' array. - for i := int32(0); i < nrBets; i++ { + for i := uint32(0); i < nrOfBets; i++ { // Retrieve the bet stored at the next index bet := bets.GetBet(i).Value() @@ -186,7 +185,7 @@ func funcPayWinners(ctx wasmlib.ScFuncContext, f *PayWinnersContext) { // a small percentage that would go to the owner of the smart contract as hosting payment. // Keep track of the total payout so we can calculate the remainder after truncation. - totalPayout := int64(0) + totalPayout := uint64(0) // Loop through all winners. size := len(winners) diff --git a/contracts/wasm/fairroulette/go/fairroulette/keys.go b/contracts/wasm/fairroulette/go/fairroulette/keys.go index 3f95a7a418..2882306527 100644 --- a/contracts/wasm/fairroulette/go/fairroulette/keys.go +++ b/contracts/wasm/fairroulette/go/fairroulette/keys.go @@ -6,41 +6,3 @@ // Change the json schema instead package fairroulette - -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" - -const ( - IdxParamNumber = 0 - IdxParamPlayPeriod = 1 - - IdxResultLastWinningNumber = 2 - IdxResultRoundNumber = 3 - IdxResultRoundStartedAt = 4 - IdxResultRoundStatus = 5 - - IdxStateBets = 6 - IdxStateLastWinningNumber = 7 - IdxStatePlayPeriod = 8 - IdxStateRoundNumber = 9 - IdxStateRoundStartedAt = 10 - IdxStateRoundStatus = 11 -) - -const keyMapLen = 12 - -var keyMap = [keyMapLen]wasmlib.Key{ - ParamNumber, - ParamPlayPeriod, - ResultLastWinningNumber, - ResultRoundNumber, - ResultRoundStartedAt, - ResultRoundStatus, - StateBets, - StateLastWinningNumber, - StatePlayPeriod, - StateRoundNumber, - StateRoundStartedAt, - StateRoundStatus, -} - -var idxMap [keyMapLen]wasmlib.Key32 diff --git a/contracts/wasm/fairroulette/go/fairroulette/lib.go b/contracts/wasm/fairroulette/go/fairroulette/lib.go index 5ca3bb14f4..cee12a9e9d 100644 --- a/contracts/wasm/fairroulette/go/fairroulette/lib.go +++ b/contracts/wasm/fairroulette/go/fairroulette/lib.go @@ -20,10 +20,6 @@ func OnLoad() { exports.AddView(ViewRoundNumber, viewRoundNumberThunk) exports.AddView(ViewRoundStartedAt, viewRoundStartedAtThunk) exports.AddView(ViewRoundStatus, viewRoundStatusThunk) - - for i, key := range keyMap { - idxMap[i] = key.KeyID() - } } type ForcePayoutContext struct { @@ -33,15 +29,15 @@ type ForcePayoutContext struct { func funcForcePayoutThunk(ctx wasmlib.ScFuncContext) { ctx.Log("fairroulette.funcForcePayout") - - // only SC creator can restart the round forcefully - ctx.Require(ctx.Caller() == ctx.ContractCreator(), "no permission") - f := &ForcePayoutContext{ State: MutableFairRouletteState{ - id: wasmlib.OBJ_ID_STATE, + proxy: wasmlib.NewStateProxy(), }, } + + // only SC creator can restart the round forcefully + ctx.Require(ctx.Caller() == ctx.ContractCreator(), "no permission") + funcForcePayout(ctx, f) ctx.Log("fairroulette.funcForcePayout ok") } @@ -53,15 +49,15 @@ type ForceResetContext struct { func funcForceResetThunk(ctx wasmlib.ScFuncContext) { ctx.Log("fairroulette.funcForceReset") - - // only SC creator can restart the round forcefully - ctx.Require(ctx.Caller() == ctx.ContractCreator(), "no permission") - f := &ForceResetContext{ State: MutableFairRouletteState{ - id: wasmlib.OBJ_ID_STATE, + proxy: wasmlib.NewStateProxy(), }, } + + // only SC creator can restart the round forcefully + ctx.Require(ctx.Caller() == ctx.ContractCreator(), "no permission") + funcForceReset(ctx, f) ctx.Log("fairroulette.funcForceReset ok") } @@ -73,15 +69,15 @@ type PayWinnersContext struct { func funcPayWinnersThunk(ctx wasmlib.ScFuncContext) { ctx.Log("fairroulette.funcPayWinners") - - // only SC itself can invoke this function - ctx.Require(ctx.Caller() == ctx.AccountID(), "no permission") - f := &PayWinnersContext{ State: MutableFairRouletteState{ - id: wasmlib.OBJ_ID_STATE, + proxy: wasmlib.NewStateProxy(), }, } + + // only SC itself can invoke this function + ctx.Require(ctx.Caller() == ctx.AccountID(), "no permission") + funcPayWinners(ctx, f) ctx.Log("fairroulette.funcPayWinners ok") } @@ -96,10 +92,10 @@ func funcPlaceBetThunk(ctx wasmlib.ScFuncContext) { ctx.Log("fairroulette.funcPlaceBet") f := &PlaceBetContext{ Params: ImmutablePlaceBetParams{ - id: wasmlib.OBJ_ID_PARAMS, + proxy: wasmlib.NewParamsProxy(), }, State: MutableFairRouletteState{ - id: wasmlib.OBJ_ID_STATE, + proxy: wasmlib.NewStateProxy(), }, } ctx.Require(f.Params.Number().Exists(), "missing mandatory number") @@ -115,18 +111,18 @@ type PlayPeriodContext struct { func funcPlayPeriodThunk(ctx wasmlib.ScFuncContext) { ctx.Log("fairroulette.funcPlayPeriod") - - // only SC creator can update the play period - ctx.Require(ctx.Caller() == ctx.ContractCreator(), "no permission") - f := &PlayPeriodContext{ Params: ImmutablePlayPeriodParams{ - id: wasmlib.OBJ_ID_PARAMS, + proxy: wasmlib.NewParamsProxy(), }, State: MutableFairRouletteState{ - id: wasmlib.OBJ_ID_STATE, + proxy: wasmlib.NewStateProxy(), }, } + + // only SC creator can update the play period + ctx.Require(ctx.Caller() == ctx.ContractCreator(), "no permission") + ctx.Require(f.Params.PlayPeriod().Exists(), "missing mandatory playPeriod") funcPlayPeriod(ctx, f) ctx.Log("fairroulette.funcPlayPeriod ok") @@ -141,10 +137,10 @@ func viewLastWinningNumberThunk(ctx wasmlib.ScViewContext) { ctx.Log("fairroulette.viewLastWinningNumber") f := &LastWinningNumberContext{ Results: MutableLastWinningNumberResults{ - id: wasmlib.OBJ_ID_RESULTS, + proxy: wasmlib.NewResultsProxy(), }, State: ImmutableFairRouletteState{ - id: wasmlib.OBJ_ID_STATE, + proxy: wasmlib.NewStateProxy(), }, } viewLastWinningNumber(ctx, f) @@ -160,10 +156,10 @@ func viewRoundNumberThunk(ctx wasmlib.ScViewContext) { ctx.Log("fairroulette.viewRoundNumber") f := &RoundNumberContext{ Results: MutableRoundNumberResults{ - id: wasmlib.OBJ_ID_RESULTS, + proxy: wasmlib.NewResultsProxy(), }, State: ImmutableFairRouletteState{ - id: wasmlib.OBJ_ID_STATE, + proxy: wasmlib.NewStateProxy(), }, } viewRoundNumber(ctx, f) @@ -179,10 +175,10 @@ func viewRoundStartedAtThunk(ctx wasmlib.ScViewContext) { ctx.Log("fairroulette.viewRoundStartedAt") f := &RoundStartedAtContext{ Results: MutableRoundStartedAtResults{ - id: wasmlib.OBJ_ID_RESULTS, + proxy: wasmlib.NewResultsProxy(), }, State: ImmutableFairRouletteState{ - id: wasmlib.OBJ_ID_STATE, + proxy: wasmlib.NewStateProxy(), }, } viewRoundStartedAt(ctx, f) @@ -198,10 +194,10 @@ func viewRoundStatusThunk(ctx wasmlib.ScViewContext) { ctx.Log("fairroulette.viewRoundStatus") f := &RoundStatusContext{ Results: MutableRoundStatusResults{ - id: wasmlib.OBJ_ID_RESULTS, + proxy: wasmlib.NewResultsProxy(), }, State: ImmutableFairRouletteState{ - id: wasmlib.OBJ_ID_STATE, + proxy: wasmlib.NewStateProxy(), }, } viewRoundStatus(ctx, f) diff --git a/contracts/wasm/fairroulette/go/fairroulette/params.go b/contracts/wasm/fairroulette/go/fairroulette/params.go index 7a02cc2470..6fc42edd48 100644 --- a/contracts/wasm/fairroulette/go/fairroulette/params.go +++ b/contracts/wasm/fairroulette/go/fairroulette/params.go @@ -7,36 +7,36 @@ package fairroulette -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" +import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" type ImmutablePlaceBetParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutablePlaceBetParams) Number() wasmlib.ScImmutableInt64 { - return wasmlib.NewScImmutableInt64(s.id, wasmlib.KeyID(ParamNumber)) +func (s ImmutablePlaceBetParams) Number() wasmtypes.ScImmutableUint16 { + return wasmtypes.NewScImmutableUint16(s.proxy.Root(ParamNumber)) } type MutablePlaceBetParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutablePlaceBetParams) Number() wasmlib.ScMutableInt64 { - return wasmlib.NewScMutableInt64(s.id, wasmlib.KeyID(ParamNumber)) +func (s MutablePlaceBetParams) Number() wasmtypes.ScMutableUint16 { + return wasmtypes.NewScMutableUint16(s.proxy.Root(ParamNumber)) } type ImmutablePlayPeriodParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutablePlayPeriodParams) PlayPeriod() wasmlib.ScImmutableInt32 { - return wasmlib.NewScImmutableInt32(s.id, wasmlib.KeyID(ParamPlayPeriod)) +func (s ImmutablePlayPeriodParams) PlayPeriod() wasmtypes.ScImmutableUint32 { + return wasmtypes.NewScImmutableUint32(s.proxy.Root(ParamPlayPeriod)) } type MutablePlayPeriodParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutablePlayPeriodParams) PlayPeriod() wasmlib.ScMutableInt32 { - return wasmlib.NewScMutableInt32(s.id, wasmlib.KeyID(ParamPlayPeriod)) +func (s MutablePlayPeriodParams) PlayPeriod() wasmtypes.ScMutableUint32 { + return wasmtypes.NewScMutableUint32(s.proxy.Root(ParamPlayPeriod)) } diff --git a/contracts/wasm/fairroulette/go/fairroulette/results.go b/contracts/wasm/fairroulette/go/fairroulette/results.go index 8f4946533c..df04d86849 100644 --- a/contracts/wasm/fairroulette/go/fairroulette/results.go +++ b/contracts/wasm/fairroulette/go/fairroulette/results.go @@ -7,68 +7,68 @@ package fairroulette -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" +import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" type ImmutableLastWinningNumberResults struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableLastWinningNumberResults) LastWinningNumber() wasmlib.ScImmutableInt64 { - return wasmlib.NewScImmutableInt64(s.id, wasmlib.KeyID(ResultLastWinningNumber)) +func (s ImmutableLastWinningNumberResults) LastWinningNumber() wasmtypes.ScImmutableUint16 { + return wasmtypes.NewScImmutableUint16(s.proxy.Root(ResultLastWinningNumber)) } type MutableLastWinningNumberResults struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableLastWinningNumberResults) LastWinningNumber() wasmlib.ScMutableInt64 { - return wasmlib.NewScMutableInt64(s.id, wasmlib.KeyID(ResultLastWinningNumber)) +func (s MutableLastWinningNumberResults) LastWinningNumber() wasmtypes.ScMutableUint16 { + return wasmtypes.NewScMutableUint16(s.proxy.Root(ResultLastWinningNumber)) } type ImmutableRoundNumberResults struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableRoundNumberResults) RoundNumber() wasmlib.ScImmutableInt64 { - return wasmlib.NewScImmutableInt64(s.id, wasmlib.KeyID(ResultRoundNumber)) +func (s ImmutableRoundNumberResults) RoundNumber() wasmtypes.ScImmutableUint32 { + return wasmtypes.NewScImmutableUint32(s.proxy.Root(ResultRoundNumber)) } type MutableRoundNumberResults struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableRoundNumberResults) RoundNumber() wasmlib.ScMutableInt64 { - return wasmlib.NewScMutableInt64(s.id, wasmlib.KeyID(ResultRoundNumber)) +func (s MutableRoundNumberResults) RoundNumber() wasmtypes.ScMutableUint32 { + return wasmtypes.NewScMutableUint32(s.proxy.Root(ResultRoundNumber)) } type ImmutableRoundStartedAtResults struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableRoundStartedAtResults) RoundStartedAt() wasmlib.ScImmutableInt32 { - return wasmlib.NewScImmutableInt32(s.id, wasmlib.KeyID(ResultRoundStartedAt)) +func (s ImmutableRoundStartedAtResults) RoundStartedAt() wasmtypes.ScImmutableUint32 { + return wasmtypes.NewScImmutableUint32(s.proxy.Root(ResultRoundStartedAt)) } type MutableRoundStartedAtResults struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableRoundStartedAtResults) RoundStartedAt() wasmlib.ScMutableInt32 { - return wasmlib.NewScMutableInt32(s.id, wasmlib.KeyID(ResultRoundStartedAt)) +func (s MutableRoundStartedAtResults) RoundStartedAt() wasmtypes.ScMutableUint32 { + return wasmtypes.NewScMutableUint32(s.proxy.Root(ResultRoundStartedAt)) } type ImmutableRoundStatusResults struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableRoundStatusResults) RoundStatus() wasmlib.ScImmutableInt16 { - return wasmlib.NewScImmutableInt16(s.id, wasmlib.KeyID(ResultRoundStatus)) +func (s ImmutableRoundStatusResults) RoundStatus() wasmtypes.ScImmutableUint16 { + return wasmtypes.NewScImmutableUint16(s.proxy.Root(ResultRoundStatus)) } type MutableRoundStatusResults struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableRoundStatusResults) RoundStatus() wasmlib.ScMutableInt16 { - return wasmlib.NewScMutableInt16(s.id, wasmlib.KeyID(ResultRoundStatus)) +func (s MutableRoundStatusResults) RoundStatus() wasmtypes.ScMutableUint16 { + return wasmtypes.NewScMutableUint16(s.proxy.Root(ResultRoundStatus)) } diff --git a/contracts/wasm/fairroulette/go/fairroulette/state.go b/contracts/wasm/fairroulette/go/fairroulette/state.go index e7ce804afe..ec31dee948 100644 --- a/contracts/wasm/fairroulette/go/fairroulette/state.go +++ b/contracts/wasm/fairroulette/go/fairroulette/state.go @@ -7,67 +7,70 @@ package fairroulette -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" +import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" type ArrayOfImmutableBet struct { - objID int32 + proxy wasmtypes.Proxy } -func (a ArrayOfImmutableBet) Length() int32 { - return wasmlib.GetLength(a.objID) +func (a ArrayOfImmutableBet) Length() uint32 { + return a.proxy.Length() } -func (a ArrayOfImmutableBet) GetBet(index int32) ImmutableBet { - return ImmutableBet{objID: a.objID, keyID: wasmlib.Key32(index)} +func (a ArrayOfImmutableBet) GetBet(index uint32) ImmutableBet { + return ImmutableBet{proxy: a.proxy.Index(index)} } type ImmutableFairRouletteState struct { - id int32 + proxy wasmtypes.Proxy } func (s ImmutableFairRouletteState) Bets() ArrayOfImmutableBet { - arrID := wasmlib.GetObjectID(s.id, wasmlib.KeyID(StateBets), wasmlib.TYPE_ARRAY|wasmlib.TYPE_BYTES) - return ArrayOfImmutableBet{objID: arrID} + return ArrayOfImmutableBet{proxy: s.proxy.Root(StateBets)} } -func (s ImmutableFairRouletteState) LastWinningNumber() wasmlib.ScImmutableInt64 { - return wasmlib.NewScImmutableInt64(s.id, wasmlib.KeyID(StateLastWinningNumber)) +func (s ImmutableFairRouletteState) LastWinningNumber() wasmtypes.ScImmutableUint16 { + return wasmtypes.NewScImmutableUint16(s.proxy.Root(StateLastWinningNumber)) } -func (s ImmutableFairRouletteState) PlayPeriod() wasmlib.ScImmutableInt32 { - return wasmlib.NewScImmutableInt32(s.id, wasmlib.KeyID(StatePlayPeriod)) +func (s ImmutableFairRouletteState) PlayPeriod() wasmtypes.ScImmutableUint32 { + return wasmtypes.NewScImmutableUint32(s.proxy.Root(StatePlayPeriod)) } -func (s ImmutableFairRouletteState) RoundNumber() wasmlib.ScImmutableInt64 { - return wasmlib.NewScImmutableInt64(s.id, wasmlib.KeyID(StateRoundNumber)) +func (s ImmutableFairRouletteState) RoundNumber() wasmtypes.ScImmutableUint32 { + return wasmtypes.NewScImmutableUint32(s.proxy.Root(StateRoundNumber)) } -func (s ImmutableFairRouletteState) RoundStartedAt() wasmlib.ScImmutableInt32 { - return wasmlib.NewScImmutableInt32(s.id, wasmlib.KeyID(StateRoundStartedAt)) +func (s ImmutableFairRouletteState) RoundStartedAt() wasmtypes.ScImmutableUint32 { + return wasmtypes.NewScImmutableUint32(s.proxy.Root(StateRoundStartedAt)) } -func (s ImmutableFairRouletteState) RoundStatus() wasmlib.ScImmutableInt16 { - return wasmlib.NewScImmutableInt16(s.id, wasmlib.KeyID(StateRoundStatus)) +func (s ImmutableFairRouletteState) RoundStatus() wasmtypes.ScImmutableUint16 { + return wasmtypes.NewScImmutableUint16(s.proxy.Root(StateRoundStatus)) } type ArrayOfMutableBet struct { - objID int32 + proxy wasmtypes.Proxy +} + +func (a ArrayOfMutableBet) AppendBet() MutableBet { + return MutableBet{proxy: a.proxy.Append()} } func (a ArrayOfMutableBet) Clear() { - wasmlib.Clear(a.objID) + a.proxy.ClearArray() } -func (a ArrayOfMutableBet) Length() int32 { - return wasmlib.GetLength(a.objID) +func (a ArrayOfMutableBet) Length() uint32 { + return a.proxy.Length() } -func (a ArrayOfMutableBet) GetBet(index int32) MutableBet { - return MutableBet{objID: a.objID, keyID: wasmlib.Key32(index)} +func (a ArrayOfMutableBet) GetBet(index uint32) MutableBet { + return MutableBet{proxy: a.proxy.Index(index)} } type MutableFairRouletteState struct { - id int32 + proxy wasmtypes.Proxy } func (s MutableFairRouletteState) AsImmutable() ImmutableFairRouletteState { @@ -75,26 +78,25 @@ func (s MutableFairRouletteState) AsImmutable() ImmutableFairRouletteState { } func (s MutableFairRouletteState) Bets() ArrayOfMutableBet { - arrID := wasmlib.GetObjectID(s.id, wasmlib.KeyID(StateBets), wasmlib.TYPE_ARRAY|wasmlib.TYPE_BYTES) - return ArrayOfMutableBet{objID: arrID} + return ArrayOfMutableBet{proxy: s.proxy.Root(StateBets)} } -func (s MutableFairRouletteState) LastWinningNumber() wasmlib.ScMutableInt64 { - return wasmlib.NewScMutableInt64(s.id, wasmlib.KeyID(StateLastWinningNumber)) +func (s MutableFairRouletteState) LastWinningNumber() wasmtypes.ScMutableUint16 { + return wasmtypes.NewScMutableUint16(s.proxy.Root(StateLastWinningNumber)) } -func (s MutableFairRouletteState) PlayPeriod() wasmlib.ScMutableInt32 { - return wasmlib.NewScMutableInt32(s.id, wasmlib.KeyID(StatePlayPeriod)) +func (s MutableFairRouletteState) PlayPeriod() wasmtypes.ScMutableUint32 { + return wasmtypes.NewScMutableUint32(s.proxy.Root(StatePlayPeriod)) } -func (s MutableFairRouletteState) RoundNumber() wasmlib.ScMutableInt64 { - return wasmlib.NewScMutableInt64(s.id, wasmlib.KeyID(StateRoundNumber)) +func (s MutableFairRouletteState) RoundNumber() wasmtypes.ScMutableUint32 { + return wasmtypes.NewScMutableUint32(s.proxy.Root(StateRoundNumber)) } -func (s MutableFairRouletteState) RoundStartedAt() wasmlib.ScMutableInt32 { - return wasmlib.NewScMutableInt32(s.id, wasmlib.KeyID(StateRoundStartedAt)) +func (s MutableFairRouletteState) RoundStartedAt() wasmtypes.ScMutableUint32 { + return wasmtypes.NewScMutableUint32(s.proxy.Root(StateRoundStartedAt)) } -func (s MutableFairRouletteState) RoundStatus() wasmlib.ScMutableInt16 { - return wasmlib.NewScMutableInt16(s.id, wasmlib.KeyID(StateRoundStatus)) +func (s MutableFairRouletteState) RoundStatus() wasmtypes.ScMutableUint16 { + return wasmtypes.NewScMutableUint16(s.proxy.Root(StateRoundStatus)) } diff --git a/contracts/wasm/fairroulette/go/fairroulette/structs.go b/contracts/wasm/fairroulette/go/fairroulette/structs.go index 944ed41420..f96f3ac96f 100644 --- a/contracts/wasm/fairroulette/go/fairroulette/structs.go +++ b/contracts/wasm/fairroulette/go/fairroulette/structs.go @@ -7,62 +7,63 @@ package fairroulette -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" +import ( + "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmcodec" + "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" +) type Bet struct { - Amount int64 - Better wasmlib.ScAgentID - Number int64 + Amount uint64 + Better wasmtypes.ScAgentID + Number uint16 } -func NewBetFromBytes(bytes []byte) *Bet { - decode := wasmlib.NewBytesDecoder(bytes) +func NewBetFromBytes(buf []byte) *Bet { + dec := wasmcodec.NewWasmDecoder(buf) data := &Bet{} - data.Amount = decode.Int64() - data.Better = decode.AgentID() - data.Number = decode.Int64() - decode.Close() + data.Amount = wasmtypes.DecodeUint64(dec) + data.Better = wasmtypes.DecodeAgentID(dec) + data.Number = wasmtypes.DecodeUint16(dec) + dec.Close() return data } func (o *Bet) Bytes() []byte { - return wasmlib.NewBytesEncoder(). - Int64(o.Amount). - AgentID(o.Better). - Int64(o.Number). - Data() + enc := wasmcodec.NewWasmEncoder() + wasmtypes.EncodeUint64(enc, o.Amount) + wasmtypes.EncodeAgentID(enc, o.Better) + wasmtypes.EncodeUint16(enc, o.Number) + return enc.Buf() } type ImmutableBet struct { - objID int32 - keyID wasmlib.Key32 + proxy wasmtypes.Proxy } func (o ImmutableBet) Exists() bool { - return wasmlib.Exists(o.objID, o.keyID, wasmlib.TYPE_BYTES) + return o.proxy.Exists() } func (o ImmutableBet) Value() *Bet { - return NewBetFromBytes(wasmlib.GetBytes(o.objID, o.keyID, wasmlib.TYPE_BYTES)) + return NewBetFromBytes(o.proxy.Get()) } type MutableBet struct { - objID int32 - keyID wasmlib.Key32 + proxy wasmtypes.Proxy } func (o MutableBet) Delete() { - wasmlib.DelKey(o.objID, o.keyID, wasmlib.TYPE_BYTES) + o.proxy.Delete() } func (o MutableBet) Exists() bool { - return wasmlib.Exists(o.objID, o.keyID, wasmlib.TYPE_BYTES) + return o.proxy.Exists() } func (o MutableBet) SetValue(value *Bet) { - wasmlib.SetBytes(o.objID, o.keyID, wasmlib.TYPE_BYTES, value.Bytes()) + o.proxy.Set(value.Bytes()) } func (o MutableBet) Value() *Bet { - return NewBetFromBytes(wasmlib.GetBytes(o.objID, o.keyID, wasmlib.TYPE_BYTES)) + return NewBetFromBytes(o.proxy.Get()) } diff --git a/contracts/wasm/fairroulette/schema.yaml b/contracts/wasm/fairroulette/schema.yaml index d895358ffe..571eec7685 100644 --- a/contracts/wasm/fairroulette/schema.yaml +++ b/contracts/wasm/fairroulette/schema.yaml @@ -3,36 +3,36 @@ description: "" events: bet: address: Address // address of better - amount: Int64 // amount of iotas to bet - number: Int64 // number to bet on + amount: Uint64 // amount of iotas to bet + number: Uint16 // number to bet on payout: address: Address // address of winner - amount: Int64 // amount of iotas won + amount: Uint64 // amount of iotas won round: - number: Int64 // current betting round number + number: Uint32 // current betting round number start: stop: winner: - number: Int64 // the winning number + number: Uint16 // the winning number structs: Bet: - amount: Int64 + amount: Uint64 better: AgentID - number: Int64 + number: Uint16 typedefs: {} state: bets: Bet[] - lastWinningNumber: Int64 - playPeriod: Int32 - roundNumber: Int64 - roundStartedAt: Int32 - roundStatus: Int16 + lastWinningNumber: Uint16 + playPeriod: Uint32 + roundNumber: Uint32 + roundStartedAt: Uint32 + roundStatus: Uint16 funcs: payWinners: access: self // only SC itself can invoke this function placeBet: params: - number: Int64 // the number a better bets on + number: Uint16 // the number a better bets on forceReset: access: creator // only SC creator can restart the round forcefully forcePayout: @@ -40,17 +40,17 @@ funcs: playPeriod: access: creator // only SC creator can update the play period params: - playPeriod: Int32 // number of minutes in one playing round + playPeriod: Uint32 // number of minutes in one playing round views: lastWinningNumber: results: - lastWinningNumber: Int64 + lastWinningNumber: Uint16 roundNumber: results: - roundNumber: Int64 + roundNumber: Uint32 roundStartedAt: results: - roundStartedAt: Int32 + roundStartedAt: Uint32 roundStatus: results: - roundStatus: Int16 + roundStatus: Uint16 diff --git a/contracts/wasm/fairroulette/src/events.rs b/contracts/wasm/fairroulette/src/events.rs index be639f0726..838e1e032d 100644 --- a/contracts/wasm/fairroulette/src/events.rs +++ b/contracts/wasm/fairroulette/src/events.rs @@ -14,24 +14,24 @@ pub struct FairRouletteEvents { impl FairRouletteEvents { - pub fn bet(&self, address: &ScAddress, amount: i64, number: i64) { + pub fn bet(&self, address: &ScAddress, amount: u64, number: u16) { let mut encoder = EventEncoder::new("fairroulette.bet"); encoder.address(&address); - encoder.int64(amount); - encoder.int64(number); + encoder.uint64(amount); + encoder.uint16(number); encoder.emit(); } - pub fn payout(&self, address: &ScAddress, amount: i64) { + pub fn payout(&self, address: &ScAddress, amount: u64) { let mut encoder = EventEncoder::new("fairroulette.payout"); encoder.address(&address); - encoder.int64(amount); + encoder.uint64(amount); encoder.emit(); } - pub fn round(&self, number: i64) { + pub fn round(&self, number: u32) { let mut encoder = EventEncoder::new("fairroulette.round"); - encoder.int64(number); + encoder.uint32(number); encoder.emit(); } @@ -43,9 +43,9 @@ impl FairRouletteEvents { EventEncoder::new("fairroulette.stop").emit(); } - pub fn winner(&self, number: i64) { + pub fn winner(&self, number: u16) { let mut encoder = EventEncoder::new("fairroulette.winner"); - encoder.int64(number); + encoder.uint16(number); encoder.emit(); } } diff --git a/contracts/wasm/fairroulette/src/fairroulette.rs b/contracts/wasm/fairroulette/src/fairroulette.rs index 7b2bc95955..1ba07ef5bd 100644 --- a/contracts/wasm/fairroulette/src/fairroulette.rs +++ b/contracts/wasm/fairroulette/src/fairroulette.rs @@ -16,16 +16,16 @@ use crate::structs::*; // Define some default configuration parameters. // The maximum number one can bet on. The range of numbers starts at 1. -const MAX_NUMBER: i64 = 8; +const MAX_NUMBER: u16 = 8; // The default playing period of one betting round in seconds. -const DEFAULT_PLAY_PERIOD: i32 = 60; +const DEFAULT_PLAY_PERIOD: u32 = 60; // Enable this if you deploy the contract to an actual node. It will pay out the prize after a certain timeout. const ENABLE_SELF_POST: bool = true; // The number to divide nano seconds to seconds. -const NANO_TIME_DIVIDER: i64 = 1_000_000_000; +const NANO_TIME_DIVIDER: u64 = 1_000_000_000; // 'placeBet' is used by betters to place a bet on a number from 1 to MAX_NUMBER. The first // incoming bet triggers a betting round of configurable duration. After the playing period @@ -48,8 +48,8 @@ pub fn func_place_bet(ctx: &ScFuncContext, f: &PlaceBetContext) { } // Since we are sure that the 'number' parameter actually exists we can - // retrieve its actual value into an i64. - let number: i64 = f.params.number().value(); + // retrieve its actual value into an u16. + let number: u16 = f.params.number().value(); // Require that the number is a valid number to bet on, otherwise panic out. ctx.require(number >= 1 && number <= MAX_NUMBER, "invalid number"); @@ -60,7 +60,7 @@ pub fn func_place_bet(ctx: &ScFuncContext, f: &PlaceBetContext) { let incoming: ScBalances = ctx.incoming(); // Retrieve the amount of plain iota tokens that are part of the incoming balance. - let amount: i64 = incoming.balance(&ScColor::IOTA); + let amount: u64 = incoming.balance(&ScColor::IOTA); // Require that there are actually some plain iotas there ctx.require(amount > 0, "empty bet"); @@ -75,7 +75,7 @@ pub fn func_place_bet(ctx: &ScFuncContext, f: &PlaceBetContext) { }; // Determine what the next bet number is by retrieving the length of the bets array. - let bet_nr: i32 = bets.length(); + let bet_nr: u32 = bets.length(); // Append the bet data to the bets array. The bet array will automatically take care // of serializing the bet struct into a bytes representation. @@ -87,7 +87,7 @@ pub fn func_place_bet(ctx: &ScFuncContext, f: &PlaceBetContext) { if bet_nr == 0 { // Yes it was, query the state for the length of the playing period in seconds by // retrieving the playPeriod value from state storage - let mut play_period: i32 = f.state.play_period().value(); + let mut play_period: u32 = f.state.play_period().value(); // if the play period is less than 10 seconds we override it with the default duration. // Note that this will also happen when the play period was not set yet because in that @@ -101,7 +101,7 @@ pub fn func_place_bet(ctx: &ScFuncContext, f: &PlaceBetContext) { f.state.round_status().set_value(1); // timestamp is nanotime, divide by NANO_TIME_DIVIDER to get seconds => common unix timestamp - let timestamp = (ctx.timestamp() / NANO_TIME_DIVIDER) as i32; + let timestamp = (ctx.timestamp() / NANO_TIME_DIVIDER) as u32; f.state.round_started_at().set_value(timestamp); f.events.start(); @@ -133,7 +133,7 @@ pub fn func_pay_winners(ctx: &ScFuncContext, f: &PayWinnersContext) { // generator will use the next 8 bytes from the hash as its random Int64 number and once // it runs out of data it simply hashes the previous hash for a next pseudo-random sequence. // Here we determine the winning number for this round in the range of 1 thru MAX_NUMBER. - let winning_number: i64 = ctx.random(MAX_NUMBER - 1) + 1; + let winning_number: u16 = (ctx.random(MAX_NUMBER as u64 - 1) + 1) as u16; // Save the last winning number in state storage under 'lastWinningNumber' so that there // is (limited) time for people to call the 'getLastWinningNumber' View to verify the last @@ -146,15 +146,15 @@ pub fn func_pay_winners(ctx: &ScFuncContext, f: &PayWinnersContext) { // Keep track of the total bet amount, the total win amount, and all the winners. // Note how we decided to keep the winners in a local vector instead of creating // yet another array in state storage or having to go through lockedBets again. - let mut total_bet_amount: i64 = 0_i64; - let mut total_win_amount: i64 = 0_i64; + let mut total_bet_amount: u64 = 0_u64; + let mut total_win_amount: u64 = 0_u64; let mut winners: Vec = Vec::new(); // Get the 'bets' array in state storage. let bets: ArrayOfMutableBet = f.state.bets(); // Determine the amount of bets in the 'bets' array. - let nr_bets: i32 = bets.length(); + let nr_bets: u32 = bets.length(); // Loop through all indexes of the 'bets' array. for i in 0..nr_bets { @@ -190,7 +190,7 @@ pub fn func_pay_winners(ctx: &ScFuncContext, f: &PayWinnersContext) { // a small percentage that would go to the owner of the smart contract as hosting payment. // Keep track of the total payout so we can calculate the remainder after truncation. - let mut total_payout: i64 = 0_i64; + let mut total_payout: u64 = 0_u64; // Loop through all winners. let size: usize = winners.len(); @@ -199,7 +199,7 @@ pub fn func_pay_winners(ctx: &ScFuncContext, f: &PayWinnersContext) { let bet: &Bet = &winners[i]; // Determine the proportional win amount (we could take our percentage here) - let payout: i64 = total_bet_amount * bet.amount / total_win_amount; + let payout: u64 = total_bet_amount * bet.amount / total_win_amount; // Anything to pay to the winner? if payout != 0 { @@ -226,7 +226,7 @@ pub fn func_pay_winners(ctx: &ScFuncContext, f: &PayWinnersContext) { // This is where we transfer the remainder after payout to the creator of the smart contract. // The bank always wins :-P - let remainder: i64 = total_bet_amount - total_payout; + let remainder: u64 = total_bet_amount - total_payout; if remainder != 0 { // We have a remainder. First create a transfer for the remainder. let transfers: ScTransfers = ScTransfers::iotas(remainder); @@ -258,7 +258,7 @@ pub fn func_force_reset(_ctx: &ScFuncContext, f: &ForceResetContext) { pub fn func_play_period(ctx: &ScFuncContext, f: &PlayPeriodContext) { // Since we are sure that the 'playPeriod' parameter actually exists we can // retrieve its actual value into an i32 value. - let play_period: i32 = f.params.play_period().value(); + let play_period: u32 = f.params.play_period().value(); // Require that the play period (in seconds) is not ridiculously low. // Otherwise, panic out with an error message. diff --git a/contracts/wasm/fairroulette/src/params.rs b/contracts/wasm/fairroulette/src/params.rs index cfb876a057..0df4fb72e3 100644 --- a/contracts/wasm/fairroulette/src/params.rs +++ b/contracts/wasm/fairroulette/src/params.rs @@ -21,8 +21,8 @@ pub struct ImmutablePlaceBetParams { } impl ImmutablePlaceBetParams { - pub fn number(&self) -> ScImmutableInt64 { - ScImmutableInt64::new(self.id, PARAM_NUMBER.get_key_id()) + pub fn number(&self) -> ScImmutableUint16 { + ScImmutableUint16::new(self.id, PARAM_NUMBER.get_key_id()) } } @@ -32,8 +32,8 @@ pub struct MutablePlaceBetParams { } impl MutablePlaceBetParams { - pub fn number(&self) -> ScMutableInt64 { - ScMutableInt64::new(self.id, PARAM_NUMBER.get_key_id()) + pub fn number(&self) -> ScMutableUint16 { + ScMutableUint16::new(self.id, PARAM_NUMBER.get_key_id()) } } @@ -43,8 +43,8 @@ pub struct ImmutablePlayPeriodParams { } impl ImmutablePlayPeriodParams { - pub fn play_period(&self) -> ScImmutableInt32 { - ScImmutableInt32::new(self.id, PARAM_PLAY_PERIOD.get_key_id()) + pub fn play_period(&self) -> ScImmutableUint32 { + ScImmutableUint32::new(self.id, PARAM_PLAY_PERIOD.get_key_id()) } } @@ -54,7 +54,7 @@ pub struct MutablePlayPeriodParams { } impl MutablePlayPeriodParams { - pub fn play_period(&self) -> ScMutableInt32 { - ScMutableInt32::new(self.id, PARAM_PLAY_PERIOD.get_key_id()) + pub fn play_period(&self) -> ScMutableUint32 { + ScMutableUint32::new(self.id, PARAM_PLAY_PERIOD.get_key_id()) } } diff --git a/contracts/wasm/fairroulette/src/results.rs b/contracts/wasm/fairroulette/src/results.rs index 3786d0f879..8c0a904962 100644 --- a/contracts/wasm/fairroulette/src/results.rs +++ b/contracts/wasm/fairroulette/src/results.rs @@ -21,8 +21,8 @@ pub struct ImmutableLastWinningNumberResults { } impl ImmutableLastWinningNumberResults { - pub fn last_winning_number(&self) -> ScImmutableInt64 { - ScImmutableInt64::new(self.id, RESULT_LAST_WINNING_NUMBER.get_key_id()) + pub fn last_winning_number(&self) -> ScImmutableUint16 { + ScImmutableUint16::new(self.id, RESULT_LAST_WINNING_NUMBER.get_key_id()) } } @@ -32,8 +32,8 @@ pub struct MutableLastWinningNumberResults { } impl MutableLastWinningNumberResults { - pub fn last_winning_number(&self) -> ScMutableInt64 { - ScMutableInt64::new(self.id, RESULT_LAST_WINNING_NUMBER.get_key_id()) + pub fn last_winning_number(&self) -> ScMutableUint16 { + ScMutableUint16::new(self.id, RESULT_LAST_WINNING_NUMBER.get_key_id()) } } @@ -43,8 +43,8 @@ pub struct ImmutableRoundNumberResults { } impl ImmutableRoundNumberResults { - pub fn round_number(&self) -> ScImmutableInt64 { - ScImmutableInt64::new(self.id, RESULT_ROUND_NUMBER.get_key_id()) + pub fn round_number(&self) -> ScImmutableUint32 { + ScImmutableUint32::new(self.id, RESULT_ROUND_NUMBER.get_key_id()) } } @@ -54,8 +54,8 @@ pub struct MutableRoundNumberResults { } impl MutableRoundNumberResults { - pub fn round_number(&self) -> ScMutableInt64 { - ScMutableInt64::new(self.id, RESULT_ROUND_NUMBER.get_key_id()) + pub fn round_number(&self) -> ScMutableUint32 { + ScMutableUint32::new(self.id, RESULT_ROUND_NUMBER.get_key_id()) } } @@ -65,8 +65,8 @@ pub struct ImmutableRoundStartedAtResults { } impl ImmutableRoundStartedAtResults { - pub fn round_started_at(&self) -> ScImmutableInt32 { - ScImmutableInt32::new(self.id, RESULT_ROUND_STARTED_AT.get_key_id()) + pub fn round_started_at(&self) -> ScImmutableUint32 { + ScImmutableUint32::new(self.id, RESULT_ROUND_STARTED_AT.get_key_id()) } } @@ -76,8 +76,8 @@ pub struct MutableRoundStartedAtResults { } impl MutableRoundStartedAtResults { - pub fn round_started_at(&self) -> ScMutableInt32 { - ScMutableInt32::new(self.id, RESULT_ROUND_STARTED_AT.get_key_id()) + pub fn round_started_at(&self) -> ScMutableUint32 { + ScMutableUint32::new(self.id, RESULT_ROUND_STARTED_AT.get_key_id()) } } @@ -87,8 +87,8 @@ pub struct ImmutableRoundStatusResults { } impl ImmutableRoundStatusResults { - pub fn round_status(&self) -> ScImmutableInt16 { - ScImmutableInt16::new(self.id, RESULT_ROUND_STATUS.get_key_id()) + pub fn round_status(&self) -> ScImmutableUint16 { + ScImmutableUint16::new(self.id, RESULT_ROUND_STATUS.get_key_id()) } } @@ -98,7 +98,7 @@ pub struct MutableRoundStatusResults { } impl MutableRoundStatusResults { - pub fn round_status(&self) -> ScMutableInt16 { - ScMutableInt16::new(self.id, RESULT_ROUND_STATUS.get_key_id()) + pub fn round_status(&self) -> ScMutableUint16 { + ScMutableUint16::new(self.id, RESULT_ROUND_STATUS.get_key_id()) } } diff --git a/contracts/wasm/fairroulette/src/state.rs b/contracts/wasm/fairroulette/src/state.rs index 1eab6abc50..20f12b0ef7 100644 --- a/contracts/wasm/fairroulette/src/state.rs +++ b/contracts/wasm/fairroulette/src/state.rs @@ -21,12 +21,12 @@ pub struct ArrayOfImmutableBet { } impl ArrayOfImmutableBet { - pub fn length(&self) -> i32 { + pub fn length(&self) -> u32 { get_length(self.obj_id) } - pub fn get_bet(&self, index: i32) -> ImmutableBet { - ImmutableBet { obj_id: self.obj_id, key_id: Key32(index) } + pub fn get_bet(&self, index: u32) -> ImmutableBet { + ImmutableBet { obj_id: self.obj_id, key_id: Key32(index as i32) } } } @@ -41,24 +41,24 @@ impl ImmutableFairRouletteState { ArrayOfImmutableBet { obj_id: arr_id } } - pub fn last_winning_number(&self) -> ScImmutableInt64 { - ScImmutableInt64::new(self.id, STATE_LAST_WINNING_NUMBER.get_key_id()) + pub fn last_winning_number(&self) -> ScImmutableUint16 { + ScImmutableUint16::new(self.id, STATE_LAST_WINNING_NUMBER.get_key_id()) } - pub fn play_period(&self) -> ScImmutableInt32 { - ScImmutableInt32::new(self.id, STATE_PLAY_PERIOD.get_key_id()) + pub fn play_period(&self) -> ScImmutableUint32 { + ScImmutableUint32::new(self.id, STATE_PLAY_PERIOD.get_key_id()) } - pub fn round_number(&self) -> ScImmutableInt64 { - ScImmutableInt64::new(self.id, STATE_ROUND_NUMBER.get_key_id()) + pub fn round_number(&self) -> ScImmutableUint32 { + ScImmutableUint32::new(self.id, STATE_ROUND_NUMBER.get_key_id()) } - pub fn round_started_at(&self) -> ScImmutableInt32 { - ScImmutableInt32::new(self.id, STATE_ROUND_STARTED_AT.get_key_id()) + pub fn round_started_at(&self) -> ScImmutableUint32 { + ScImmutableUint32::new(self.id, STATE_ROUND_STARTED_AT.get_key_id()) } - pub fn round_status(&self) -> ScImmutableInt16 { - ScImmutableInt16::new(self.id, STATE_ROUND_STATUS.get_key_id()) + pub fn round_status(&self) -> ScImmutableUint16 { + ScImmutableUint16::new(self.id, STATE_ROUND_STATUS.get_key_id()) } } @@ -72,12 +72,12 @@ impl ArrayOfMutableBet { clear(self.obj_id); } - pub fn length(&self) -> i32 { + pub fn length(&self) -> u32 { get_length(self.obj_id) } - pub fn get_bet(&self, index: i32) -> MutableBet { - MutableBet { obj_id: self.obj_id, key_id: Key32(index) } + pub fn get_bet(&self, index: u32) -> MutableBet { + MutableBet { obj_id: self.obj_id, key_id: Key32(index as i32) } } } @@ -96,23 +96,23 @@ impl MutableFairRouletteState { ArrayOfMutableBet { obj_id: arr_id } } - pub fn last_winning_number(&self) -> ScMutableInt64 { - ScMutableInt64::new(self.id, STATE_LAST_WINNING_NUMBER.get_key_id()) + pub fn last_winning_number(&self) -> ScMutableUint16 { + ScMutableUint16::new(self.id, STATE_LAST_WINNING_NUMBER.get_key_id()) } - pub fn play_period(&self) -> ScMutableInt32 { - ScMutableInt32::new(self.id, STATE_PLAY_PERIOD.get_key_id()) + pub fn play_period(&self) -> ScMutableUint32 { + ScMutableUint32::new(self.id, STATE_PLAY_PERIOD.get_key_id()) } - pub fn round_number(&self) -> ScMutableInt64 { - ScMutableInt64::new(self.id, STATE_ROUND_NUMBER.get_key_id()) + pub fn round_number(&self) -> ScMutableUint32 { + ScMutableUint32::new(self.id, STATE_ROUND_NUMBER.get_key_id()) } - pub fn round_started_at(&self) -> ScMutableInt32 { - ScMutableInt32::new(self.id, STATE_ROUND_STARTED_AT.get_key_id()) + pub fn round_started_at(&self) -> ScMutableUint32 { + ScMutableUint32::new(self.id, STATE_ROUND_STARTED_AT.get_key_id()) } - pub fn round_status(&self) -> ScMutableInt16 { - ScMutableInt16::new(self.id, STATE_ROUND_STATUS.get_key_id()) + pub fn round_status(&self) -> ScMutableUint16 { + ScMutableUint16::new(self.id, STATE_ROUND_STATUS.get_key_id()) } } diff --git a/contracts/wasm/fairroulette/src/structs.rs b/contracts/wasm/fairroulette/src/structs.rs index 4bd7f082bc..1e4ba4c7ff 100644 --- a/contracts/wasm/fairroulette/src/structs.rs +++ b/contracts/wasm/fairroulette/src/structs.rs @@ -13,26 +13,26 @@ use wasmlib::host::*; #[derive(Clone)] pub struct Bet { - pub amount : i64, + pub amount : u64, pub better : ScAgentID, - pub number : i64, + pub number : u16, } impl Bet { pub fn from_bytes(bytes: &[u8]) -> Bet { let mut decode = BytesDecoder::new(bytes); Bet { - amount : decode.int64(), + amount : decode.uint64(), better : decode.agent_id(), - number : decode.int64(), + number : decode.uint16(), } } pub fn to_bytes(&self) -> Vec { let mut encode = BytesEncoder::new(); - encode.int64(self.amount); + encode.uint64(self.amount); encode.agent_id(&self.better); - encode.int64(self.number); + encode.uint16(self.number); return encode.data(); } } diff --git a/contracts/wasm/fairroulette/test/fairroulette_bg.wasm b/contracts/wasm/fairroulette/test/fairroulette_bg.wasm index 316763e8da75c21bed214b1480c8a1a6455d9437..f9f6095b5b2dbac1d82fdfd9178b3bae1002fe45 100644 GIT binary patch delta 13989 zcmcIqdw5mFwcoS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{YSXs87@Dxd;54Rk)n(cv*}kwfnBTr7pJd2`v3p{ diff --git a/contracts/wasm/fairroulette/ts/fairroulette/events.ts b/contracts/wasm/fairroulette/ts/fairroulette/events.ts index bef3fbce6f..7c544d63bd 100644 --- a/contracts/wasm/fairroulette/ts/fairroulette/events.ts +++ b/contracts/wasm/fairroulette/ts/fairroulette/events.ts @@ -9,24 +9,24 @@ import * as wasmlib from "wasmlib"; export class FairRouletteEvents { - bet(address: wasmlib.ScAddress, amount: i64, number: i64): void { + bet(address: wasmlib.ScAddress, amount: u64, number: u16): void { new wasmlib.EventEncoder("fairroulette.bet"). address(address). - int64(amount). - int64(number). + uint64(amount). + uint16(number). emit(); } - payout(address: wasmlib.ScAddress, amount: i64): void { + payout(address: wasmlib.ScAddress, amount: u64): void { new wasmlib.EventEncoder("fairroulette.payout"). address(address). - int64(amount). + uint64(amount). emit(); } - round(number: i64): void { + round(number: u32): void { new wasmlib.EventEncoder("fairroulette.round"). - int64(number). + uint32(number). emit(); } @@ -40,9 +40,9 @@ export class FairRouletteEvents { emit(); } - winner(number: i64): void { + winner(number: u16): void { new wasmlib.EventEncoder("fairroulette.winner"). - int64(number). + uint16(number). emit(); } } diff --git a/contracts/wasm/fairroulette/ts/fairroulette/fairroulette.ts b/contracts/wasm/fairroulette/ts/fairroulette/fairroulette.ts index 6319c393de..860b5f05f0 100644 --- a/contracts/wasm/fairroulette/ts/fairroulette/fairroulette.ts +++ b/contracts/wasm/fairroulette/ts/fairroulette/fairroulette.ts @@ -13,16 +13,16 @@ import * as sc from "./index"; // Define some default configuration parameters. // The maximum number one can bet on. The range of numbers starts at 1. -const MAX_NUMBER: i64 = 8; +const MAX_NUMBER: u16 = 8; // The default playing period of one betting round in seconds. -const DEFAULT_PLAY_PERIOD: i32 = 60; +const DEFAULT_PLAY_PERIOD: u32 = 60; // Enable this if you deploy the contract to an actual node. It will pay out the prize after a certain timeout. const ENABLE_SELF_POST: boolean = true; // The number to divide nano seconds to seconds. -const NANO_TIME_DIVIDER: i64 = 1000000000; +const NANO_TIME_DIVIDER: u64 = 1000000000; // 'placeBet' is used by betters to place a bet on a number from 1 to MAX_NUMBER. The first // incoming bet triggers a betting round of configurable duration. After the playing period @@ -36,7 +36,7 @@ export function funcPlaceBet(ctx: wasmlib.ScFuncContext, f: sc.PlaceBetContext): // Get the array of current bets from state storage. let bets: sc.ArrayOfMutableBet = f.state.bets(); - for (let i = 0; i < bets.length(); i++) { + for (let i: u32 = 0; i < bets.length(); i++) { let bet: sc.Bet = bets.getBet(i).value(); if (bet.better.address() == ctx.caller().address()) { @@ -46,7 +46,7 @@ export function funcPlaceBet(ctx: wasmlib.ScFuncContext, f: sc.PlaceBetContext): // Since we are sure that the 'number' parameter actually exists we can // retrieve its actual value into an i64. - let number: i64 = f.params.number().value(); + let number: u16 = f.params.number().value(); // Require that the number is a valid number to bet on, otherwise panic out. ctx.require(number >= 1 && number <= MAX_NUMBER, "invalid number"); @@ -57,7 +57,7 @@ export function funcPlaceBet(ctx: wasmlib.ScFuncContext, f: sc.PlaceBetContext): let incoming: wasmlib.ScBalances = ctx.incoming(); // Retrieve the amount of plain iota tokens that are part of the incoming balance. - let amount: i64 = incoming.balance(wasmlib.ScColor.IOTA); + let amount: u64 = incoming.balance(wasmlib.ScColor.IOTA); // Require that there are actually some plain iotas there ctx.require(amount > 0, "empty bet"); @@ -71,7 +71,7 @@ export function funcPlaceBet(ctx: wasmlib.ScFuncContext, f: sc.PlaceBetContext): bet.number = number; // Determine what the next bet number is by retrieving the length of the bets array. - let betNr: i32 = bets.length(); + let betNr: u32 = bets.length(); // Append the bet data to the bets array. The bet array will automatically take care // of serializing the bet struct into a bytes representation. @@ -83,7 +83,7 @@ export function funcPlaceBet(ctx: wasmlib.ScFuncContext, f: sc.PlaceBetContext): if (betNr == 0) { // Yes it was, query the state for the length of the playing period in seconds by // retrieving the playPeriod value from state storage - let playPeriod: i32 = f.state.playPeriod().value(); + let playPeriod: u32 = f.state.playPeriod().value(); // if the play period is less than 10 seconds we override it with the default duration. // Note that this will also happen when the play period was not set yet because in that @@ -97,7 +97,7 @@ export function funcPlaceBet(ctx: wasmlib.ScFuncContext, f: sc.PlaceBetContext): f.state.roundStatus().setValue(1); // timestamp is nanotime, divide by NANO_TIME_DIVIDER to get seconds => common unix timestamp - let timestamp = (ctx.timestamp() / NANO_TIME_DIVIDER) as i32; + let timestamp = (ctx.timestamp() / NANO_TIME_DIVIDER) as u32; f.state.roundStartedAt().setValue(timestamp); f.events.start(); @@ -129,7 +129,7 @@ export function funcPayWinners(ctx: wasmlib.ScFuncContext, f: sc.PayWinnersConte // generator will use the next 8 bytes from the hash as its random Int64 number and once // it runs out of data it simply hashes the previous hash for a next pseudo-random sequence. // Here we determine the winning number for this round in the range of 1 thru MAX_NUMBER. - let winningNumber: i64 = ctx.random(MAX_NUMBER - 1) + 1; + let winningNumber: u16 = (ctx.random(MAX_NUMBER - 1) + 1) as u16; // Save the last winning number in state storage under 'lastWinningNumber' so that there // is (limited) time for people to call the 'getLastWinningNumber' View to verify the last @@ -142,18 +142,18 @@ export function funcPayWinners(ctx: wasmlib.ScFuncContext, f: sc.PayWinnersConte // Keep track of the total bet amount, the total win amount, and all the winners. // Note how we decided to keep the winners in a local vector instead of creating // yet another array in state storage or having to go through lockedBets again. - let totalBetAmount: i64 = 0; - let totalWinAmount: i64 = 0; + let totalBetAmount: u64 = 0; + let totalWinAmount: u64 = 0; let winners: sc.Bet[] = []; // Get the 'bets' array in state storage. let bets: sc.ArrayOfMutableBet = f.state.bets(); // Determine the amount of bets in the 'bets' array. - let nrBets: i32 = bets.length(); + let nrBets: u32 = bets.length(); // Loop through all indexes of the 'bets' array. - for (let i = 0; i < nrBets; i++) { + for (let i: u32 = 0; i < nrBets; i++) { // Retrieve the bet stored at the next index let bet: sc.Bet = bets.getBet(i).value(); @@ -186,7 +186,7 @@ export function funcPayWinners(ctx: wasmlib.ScFuncContext, f: sc.PayWinnersConte // a small percentage that would go to the owner of the smart contract as hosting payment. // Keep track of the total payout so we can calculate the remainder after truncation. - let totalPayout: i64 = 0; + let totalPayout: u64 = 0; // Loop through all winners. let size = winners.length; @@ -195,7 +195,7 @@ export function funcPayWinners(ctx: wasmlib.ScFuncContext, f: sc.PayWinnersConte let bet: sc.Bet = winners[i]; // Determine the proportional win amount (we could take our percentage here) - let payout: i64 = totalBetAmount * bet.amount / totalWinAmount; + let payout: u64 = totalBetAmount * bet.amount / totalWinAmount; // Anything to pay to the winner? if (payout != 0) { @@ -222,7 +222,7 @@ export function funcPayWinners(ctx: wasmlib.ScFuncContext, f: sc.PayWinnersConte // This is where we transfer the remainder after payout to the creator of the smart contract. // The bank always wins :-P - let remainder: i64 = totalBetAmount - totalPayout; + let remainder: u64 = totalBetAmount - totalPayout; if (remainder != 0) { // We have a remainder. First create a transfer for the remainder. let transfers: wasmlib.ScTransfers = wasmlib.ScTransfers.iotas(remainder); @@ -254,7 +254,7 @@ export function funcForceReset(ctx: wasmlib.ScFuncContext, f: sc.ForceResetConte export function funcPlayPeriod(ctx: wasmlib.ScFuncContext, f: sc.PlayPeriodContext): void { // Since we are sure that the 'playPeriod' parameter actually exists we can // retrieve its actual value into an i32 value. - let playPeriod: i32 = f.params.playPeriod().value(); + let playPeriod: u32 = f.params.playPeriod().value(); // Require that the play period (in seconds) is not ridiculously low. // Otherwise, panic out with an error message. @@ -275,7 +275,7 @@ export function viewLastWinningNumber(ctx: wasmlib.ScViewContext, f: sc.LastWinn } export function viewRoundNumber(ctx: wasmlib.ScViewContext, f: sc.RoundNumberContext): void { - // Get the 'roundNumber' int64 value from state storage. + // Get the 'roundNumber' uint32 value from state storage. let roundNumber = f.state.roundNumber().value(); // Set the 'roundNumber' in results to the value from state storage. @@ -283,7 +283,7 @@ export function viewRoundNumber(ctx: wasmlib.ScViewContext, f: sc.RoundNumberCon } export function viewRoundStatus(ctx: wasmlib.ScViewContext, f: sc.RoundStatusContext): void { - // Get the 'roundStatus' int16 value from state storage. + // Get the 'roundStatus' uint16 value from state storage. let roundStatus = f.state.roundStatus().value(); // Set the 'roundStatus' in results to the value from state storage. @@ -291,7 +291,7 @@ export function viewRoundStatus(ctx: wasmlib.ScViewContext, f: sc.RoundStatusCon } export function viewRoundStartedAt(ctx: wasmlib.ScViewContext, f: sc.RoundStartedAtContext): void { - // Get the 'roundStartedAt' int32 value from state storage. + // Get the 'roundStartedAt' uint32 value from state storage. let roundStartedAt = f.state.roundStartedAt().value(); // Set the 'roundStartedAt' in results to the value from state storage. diff --git a/contracts/wasm/fairroulette/ts/fairroulette/params.ts b/contracts/wasm/fairroulette/ts/fairroulette/params.ts index ca1af44b4a..0fd690ffc8 100644 --- a/contracts/wasm/fairroulette/ts/fairroulette/params.ts +++ b/contracts/wasm/fairroulette/ts/fairroulette/params.ts @@ -9,25 +9,25 @@ import * as wasmlib from "wasmlib"; import * as sc from "./index"; export class ImmutablePlaceBetParams extends wasmlib.ScMapID { - number(): wasmlib.ScImmutableInt64 { - return new wasmlib.ScImmutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ParamNumber)); + number(): wasmlib.ScImmutableUint16 { + return new wasmlib.ScImmutableUint16(this.mapID, wasmlib.Key32.fromString(sc.ParamNumber)); } } export class MutablePlaceBetParams extends wasmlib.ScMapID { - number(): wasmlib.ScMutableInt64 { - return new wasmlib.ScMutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ParamNumber)); + number(): wasmlib.ScMutableUint16 { + return new wasmlib.ScMutableUint16(this.mapID, wasmlib.Key32.fromString(sc.ParamNumber)); } } export class ImmutablePlayPeriodParams extends wasmlib.ScMapID { - playPeriod(): wasmlib.ScImmutableInt32 { - return new wasmlib.ScImmutableInt32(this.mapID, wasmlib.Key32.fromString(sc.ParamPlayPeriod)); + playPeriod(): wasmlib.ScImmutableUint32 { + return new wasmlib.ScImmutableUint32(this.mapID, wasmlib.Key32.fromString(sc.ParamPlayPeriod)); } } export class MutablePlayPeriodParams extends wasmlib.ScMapID { - playPeriod(): wasmlib.ScMutableInt32 { - return new wasmlib.ScMutableInt32(this.mapID, wasmlib.Key32.fromString(sc.ParamPlayPeriod)); + playPeriod(): wasmlib.ScMutableUint32 { + return new wasmlib.ScMutableUint32(this.mapID, wasmlib.Key32.fromString(sc.ParamPlayPeriod)); } } diff --git a/contracts/wasm/fairroulette/ts/fairroulette/results.ts b/contracts/wasm/fairroulette/ts/fairroulette/results.ts index 719f1acc2c..8482f00d34 100644 --- a/contracts/wasm/fairroulette/ts/fairroulette/results.ts +++ b/contracts/wasm/fairroulette/ts/fairroulette/results.ts @@ -9,49 +9,49 @@ import * as wasmlib from "wasmlib"; import * as sc from "./index"; export class ImmutableLastWinningNumberResults extends wasmlib.ScMapID { - lastWinningNumber(): wasmlib.ScImmutableInt64 { - return new wasmlib.ScImmutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ResultLastWinningNumber)); + lastWinningNumber(): wasmlib.ScImmutableUint16 { + return new wasmlib.ScImmutableUint16(this.mapID, wasmlib.Key32.fromString(sc.ResultLastWinningNumber)); } } export class MutableLastWinningNumberResults extends wasmlib.ScMapID { - lastWinningNumber(): wasmlib.ScMutableInt64 { - return new wasmlib.ScMutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ResultLastWinningNumber)); + lastWinningNumber(): wasmlib.ScMutableUint16 { + return new wasmlib.ScMutableUint16(this.mapID, wasmlib.Key32.fromString(sc.ResultLastWinningNumber)); } } export class ImmutableRoundNumberResults extends wasmlib.ScMapID { - roundNumber(): wasmlib.ScImmutableInt64 { - return new wasmlib.ScImmutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ResultRoundNumber)); + roundNumber(): wasmlib.ScImmutableUint32 { + return new wasmlib.ScImmutableUint32(this.mapID, wasmlib.Key32.fromString(sc.ResultRoundNumber)); } } export class MutableRoundNumberResults extends wasmlib.ScMapID { - roundNumber(): wasmlib.ScMutableInt64 { - return new wasmlib.ScMutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ResultRoundNumber)); + roundNumber(): wasmlib.ScMutableUint32 { + return new wasmlib.ScMutableUint32(this.mapID, wasmlib.Key32.fromString(sc.ResultRoundNumber)); } } export class ImmutableRoundStartedAtResults extends wasmlib.ScMapID { - roundStartedAt(): wasmlib.ScImmutableInt32 { - return new wasmlib.ScImmutableInt32(this.mapID, wasmlib.Key32.fromString(sc.ResultRoundStartedAt)); + roundStartedAt(): wasmlib.ScImmutableUint32 { + return new wasmlib.ScImmutableUint32(this.mapID, wasmlib.Key32.fromString(sc.ResultRoundStartedAt)); } } export class MutableRoundStartedAtResults extends wasmlib.ScMapID { - roundStartedAt(): wasmlib.ScMutableInt32 { - return new wasmlib.ScMutableInt32(this.mapID, wasmlib.Key32.fromString(sc.ResultRoundStartedAt)); + roundStartedAt(): wasmlib.ScMutableUint32 { + return new wasmlib.ScMutableUint32(this.mapID, wasmlib.Key32.fromString(sc.ResultRoundStartedAt)); } } export class ImmutableRoundStatusResults extends wasmlib.ScMapID { - roundStatus(): wasmlib.ScImmutableInt16 { - return new wasmlib.ScImmutableInt16(this.mapID, wasmlib.Key32.fromString(sc.ResultRoundStatus)); + roundStatus(): wasmlib.ScImmutableUint16 { + return new wasmlib.ScImmutableUint16(this.mapID, wasmlib.Key32.fromString(sc.ResultRoundStatus)); } } export class MutableRoundStatusResults extends wasmlib.ScMapID { - roundStatus(): wasmlib.ScMutableInt16 { - return new wasmlib.ScMutableInt16(this.mapID, wasmlib.Key32.fromString(sc.ResultRoundStatus)); + roundStatus(): wasmlib.ScMutableUint16 { + return new wasmlib.ScMutableUint16(this.mapID, wasmlib.Key32.fromString(sc.ResultRoundStatus)); } } diff --git a/contracts/wasm/fairroulette/ts/fairroulette/state.ts b/contracts/wasm/fairroulette/ts/fairroulette/state.ts index f3eb652c35..90bfaee63b 100644 --- a/contracts/wasm/fairroulette/ts/fairroulette/state.ts +++ b/contracts/wasm/fairroulette/ts/fairroulette/state.ts @@ -15,12 +15,12 @@ export class ArrayOfImmutableBet { this.objID = objID; } - length(): i32 { + length(): u32 { return wasmlib.getLength(this.objID); } - getBet(index: i32): sc.ImmutableBet { - return new sc.ImmutableBet(this.objID, new wasmlib.Key32(index)); + getBet(index: u32): sc.ImmutableBet { + return new sc.ImmutableBet(this.objID, new wasmlib.Key32(index as i32)); } } @@ -30,24 +30,24 @@ export class ImmutableFairRouletteState extends wasmlib.ScMapID { return new sc.ArrayOfImmutableBet(arrID); } - lastWinningNumber(): wasmlib.ScImmutableInt64 { - return new wasmlib.ScImmutableInt64(this.mapID, wasmlib.Key32.fromString(sc.StateLastWinningNumber)); + lastWinningNumber(): wasmlib.ScImmutableUint16 { + return new wasmlib.ScImmutableUint16(this.mapID, wasmlib.Key32.fromString(sc.StateLastWinningNumber)); } - playPeriod(): wasmlib.ScImmutableInt32 { - return new wasmlib.ScImmutableInt32(this.mapID, wasmlib.Key32.fromString(sc.StatePlayPeriod)); + playPeriod(): wasmlib.ScImmutableUint32 { + return new wasmlib.ScImmutableUint32(this.mapID, wasmlib.Key32.fromString(sc.StatePlayPeriod)); } - roundNumber(): wasmlib.ScImmutableInt64 { - return new wasmlib.ScImmutableInt64(this.mapID, wasmlib.Key32.fromString(sc.StateRoundNumber)); + roundNumber(): wasmlib.ScImmutableUint32 { + return new wasmlib.ScImmutableUint32(this.mapID, wasmlib.Key32.fromString(sc.StateRoundNumber)); } - roundStartedAt(): wasmlib.ScImmutableInt32 { - return new wasmlib.ScImmutableInt32(this.mapID, wasmlib.Key32.fromString(sc.StateRoundStartedAt)); + roundStartedAt(): wasmlib.ScImmutableUint32 { + return new wasmlib.ScImmutableUint32(this.mapID, wasmlib.Key32.fromString(sc.StateRoundStartedAt)); } - roundStatus(): wasmlib.ScImmutableInt16 { - return new wasmlib.ScImmutableInt16(this.mapID, wasmlib.Key32.fromString(sc.StateRoundStatus)); + roundStatus(): wasmlib.ScImmutableUint16 { + return new wasmlib.ScImmutableUint16(this.mapID, wasmlib.Key32.fromString(sc.StateRoundStatus)); } } @@ -62,12 +62,12 @@ export class ArrayOfMutableBet { wasmlib.clear(this.objID); } - length(): i32 { + length(): u32 { return wasmlib.getLength(this.objID); } - getBet(index: i32): sc.MutableBet { - return new sc.MutableBet(this.objID, new wasmlib.Key32(index)); + getBet(index: u32): sc.MutableBet { + return new sc.MutableBet(this.objID, new wasmlib.Key32(index as i32)); } } @@ -83,23 +83,23 @@ export class MutableFairRouletteState extends wasmlib.ScMapID { return new sc.ArrayOfMutableBet(arrID); } - lastWinningNumber(): wasmlib.ScMutableInt64 { - return new wasmlib.ScMutableInt64(this.mapID, wasmlib.Key32.fromString(sc.StateLastWinningNumber)); + lastWinningNumber(): wasmlib.ScMutableUint16 { + return new wasmlib.ScMutableUint16(this.mapID, wasmlib.Key32.fromString(sc.StateLastWinningNumber)); } - playPeriod(): wasmlib.ScMutableInt32 { - return new wasmlib.ScMutableInt32(this.mapID, wasmlib.Key32.fromString(sc.StatePlayPeriod)); + playPeriod(): wasmlib.ScMutableUint32 { + return new wasmlib.ScMutableUint32(this.mapID, wasmlib.Key32.fromString(sc.StatePlayPeriod)); } - roundNumber(): wasmlib.ScMutableInt64 { - return new wasmlib.ScMutableInt64(this.mapID, wasmlib.Key32.fromString(sc.StateRoundNumber)); + roundNumber(): wasmlib.ScMutableUint32 { + return new wasmlib.ScMutableUint32(this.mapID, wasmlib.Key32.fromString(sc.StateRoundNumber)); } - roundStartedAt(): wasmlib.ScMutableInt32 { - return new wasmlib.ScMutableInt32(this.mapID, wasmlib.Key32.fromString(sc.StateRoundStartedAt)); + roundStartedAt(): wasmlib.ScMutableUint32 { + return new wasmlib.ScMutableUint32(this.mapID, wasmlib.Key32.fromString(sc.StateRoundStartedAt)); } - roundStatus(): wasmlib.ScMutableInt16 { - return new wasmlib.ScMutableInt16(this.mapID, wasmlib.Key32.fromString(sc.StateRoundStatus)); + roundStatus(): wasmlib.ScMutableUint16 { + return new wasmlib.ScMutableUint16(this.mapID, wasmlib.Key32.fromString(sc.StateRoundStatus)); } } diff --git a/contracts/wasm/fairroulette/ts/fairroulette/structs.ts b/contracts/wasm/fairroulette/ts/fairroulette/structs.ts index a0c749f141..1c4f21646b 100644 --- a/contracts/wasm/fairroulette/ts/fairroulette/structs.ts +++ b/contracts/wasm/fairroulette/ts/fairroulette/structs.ts @@ -8,25 +8,25 @@ import * as wasmlib from "wasmlib"; export class Bet { - amount : i64 = 0; + amount : u64 = 0; better : wasmlib.ScAgentID = new wasmlib.ScAgentID(); - number : i64 = 0; + number : u16 = 0; static fromBytes(bytes: u8[]): Bet { let decode = new wasmlib.BytesDecoder(bytes); let data = new Bet(); - data.amount = decode.int64(); + data.amount = decode.uint64(); data.better = decode.agentID(); - data.number = decode.int64(); + data.number = decode.uint16(); decode.close(); return data; } bytes(): u8[] { return new wasmlib.BytesEncoder(). - int64(this.amount). + uint64(this.amount). agentID(this.better). - int64(this.number). + uint16(this.number). data(); } } diff --git a/contracts/wasm/helloworld/go/helloworld/consts.go b/contracts/wasm/helloworld/go/helloworld/consts.go index bb14625014..afc4bb4101 100644 --- a/contracts/wasm/helloworld/go/helloworld/consts.go +++ b/contracts/wasm/helloworld/go/helloworld/consts.go @@ -7,12 +7,12 @@ package helloworld -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" +import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" const ( ScName = "helloworld" ScDescription = "The ubiquitous hello world demo" - HScName = wasmlib.ScHname(0x0683223c) + HScName = wasmtypes.ScHname(0x0683223c) ) const ( @@ -25,6 +25,6 @@ const ( ) const ( - HFuncHelloWorld = wasmlib.ScHname(0x9d042e65) - HViewGetHelloWorld = wasmlib.ScHname(0x210439ce) + HFuncHelloWorld = wasmtypes.ScHname(0x9d042e65) + HViewGetHelloWorld = wasmtypes.ScHname(0x210439ce) ) diff --git a/contracts/wasm/helloworld/go/helloworld/contract.go b/contracts/wasm/helloworld/go/helloworld/contract.go index 3423976513..dad20fabb0 100644 --- a/contracts/wasm/helloworld/go/helloworld/contract.go +++ b/contracts/wasm/helloworld/go/helloworld/contract.go @@ -28,6 +28,6 @@ func (sc Funcs) HelloWorld(ctx wasmlib.ScFuncCallContext) *HelloWorldCall { func (sc Funcs) GetHelloWorld(ctx wasmlib.ScViewCallContext) *GetHelloWorldCall { f := &GetHelloWorldCall{Func: wasmlib.NewScView(ctx, HScName, HViewGetHelloWorld)} - f.Func.SetPtrs(nil, &f.Results.id) + wasmlib.NewCallResultsProxy(f.Func, &f.Results.proxy) return f } diff --git a/contracts/wasm/helloworld/go/helloworld/keys.go b/contracts/wasm/helloworld/go/helloworld/keys.go index 149a75fad1..9346abb4e0 100644 --- a/contracts/wasm/helloworld/go/helloworld/keys.go +++ b/contracts/wasm/helloworld/go/helloworld/keys.go @@ -6,17 +6,3 @@ // Change the json schema instead package helloworld - -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" - -const ( - IdxResultHelloWorld = 0 -) - -const keyMapLen = 1 - -var keyMap = [keyMapLen]wasmlib.Key{ - ResultHelloWorld, -} - -var idxMap [keyMapLen]wasmlib.Key32 diff --git a/contracts/wasm/helloworld/go/helloworld/lib.go b/contracts/wasm/helloworld/go/helloworld/lib.go index 9292b24c0a..b797aa785d 100644 --- a/contracts/wasm/helloworld/go/helloworld/lib.go +++ b/contracts/wasm/helloworld/go/helloworld/lib.go @@ -13,10 +13,6 @@ func OnLoad() { exports := wasmlib.NewScExports() exports.AddFunc(FuncHelloWorld, funcHelloWorldThunk) exports.AddView(ViewGetHelloWorld, viewGetHelloWorldThunk) - - for i, key := range keyMap { - idxMap[i] = key.KeyID() - } } type HelloWorldContext struct { @@ -27,7 +23,7 @@ func funcHelloWorldThunk(ctx wasmlib.ScFuncContext) { ctx.Log("helloworld.funcHelloWorld") f := &HelloWorldContext{ State: MutableHelloWorldState{ - id: wasmlib.OBJ_ID_STATE, + proxy: wasmlib.NewStateProxy(), }, } funcHelloWorld(ctx, f) @@ -43,10 +39,10 @@ func viewGetHelloWorldThunk(ctx wasmlib.ScViewContext) { ctx.Log("helloworld.viewGetHelloWorld") f := &GetHelloWorldContext{ Results: MutableGetHelloWorldResults{ - id: wasmlib.OBJ_ID_RESULTS, + proxy: wasmlib.NewResultsProxy(), }, State: ImmutableHelloWorldState{ - id: wasmlib.OBJ_ID_STATE, + proxy: wasmlib.NewStateProxy(), }, } viewGetHelloWorld(ctx, f) diff --git a/contracts/wasm/helloworld/go/helloworld/results.go b/contracts/wasm/helloworld/go/helloworld/results.go index 94e77f318a..eb63b45d11 100644 --- a/contracts/wasm/helloworld/go/helloworld/results.go +++ b/contracts/wasm/helloworld/go/helloworld/results.go @@ -7,20 +7,20 @@ package helloworld -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" +import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" type ImmutableGetHelloWorldResults struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableGetHelloWorldResults) HelloWorld() wasmlib.ScImmutableString { - return wasmlib.NewScImmutableString(s.id, wasmlib.KeyID(ResultHelloWorld)) +func (s ImmutableGetHelloWorldResults) HelloWorld() wasmtypes.ScImmutableString { + return wasmtypes.NewScImmutableString(s.proxy.Root(ResultHelloWorld)) } type MutableGetHelloWorldResults struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableGetHelloWorldResults) HelloWorld() wasmlib.ScMutableString { - return wasmlib.NewScMutableString(s.id, wasmlib.KeyID(ResultHelloWorld)) +func (s MutableGetHelloWorldResults) HelloWorld() wasmtypes.ScMutableString { + return wasmtypes.NewScMutableString(s.proxy.Root(ResultHelloWorld)) } diff --git a/contracts/wasm/helloworld/go/helloworld/state.go b/contracts/wasm/helloworld/go/helloworld/state.go index 0b1fb82fcb..7490209793 100644 --- a/contracts/wasm/helloworld/go/helloworld/state.go +++ b/contracts/wasm/helloworld/go/helloworld/state.go @@ -7,12 +7,14 @@ package helloworld +import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" + type ImmutableHelloWorldState struct { - id int32 + proxy wasmtypes.Proxy } type MutableHelloWorldState struct { - id int32 + proxy wasmtypes.Proxy } func (s MutableHelloWorldState) AsImmutable() ImmutableHelloWorldState { diff --git a/contracts/wasm/inccounter/go/inccounter/consts.go b/contracts/wasm/inccounter/go/inccounter/consts.go index d719837956..cdf72e5dae 100644 --- a/contracts/wasm/inccounter/go/inccounter/consts.go +++ b/contracts/wasm/inccounter/go/inccounter/consts.go @@ -7,12 +7,12 @@ package inccounter -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" +import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" const ( ScName = "inccounter" ScDescription = "" - HScName = wasmlib.ScHname(0xaf2438e9) + HScName = wasmtypes.ScHname(0xaf2438e9) ) const ( @@ -60,21 +60,21 @@ const ( ) const ( - HFuncCallIncrement = wasmlib.ScHname(0xeb5dcacd) - HFuncCallIncrementRecurse5x = wasmlib.ScHname(0x8749fbff) - HFuncEndlessLoop = wasmlib.ScHname(0x365f0929) - HFuncIncrement = wasmlib.ScHname(0xd351bd12) - HFuncIncrementWithDelay = wasmlib.ScHname(0xa235bba7) - HFuncInit = wasmlib.ScHname(0x1f44d644) - HFuncLocalStateInternalCall = wasmlib.ScHname(0xecfc5d33) - HFuncLocalStatePost = wasmlib.ScHname(0x3fd54d13) - HFuncLocalStateSandboxCall = wasmlib.ScHname(0x7bd22c53) - HFuncPostIncrement = wasmlib.ScHname(0x81c772f5) - HFuncRepeatMany = wasmlib.ScHname(0x4ff450d3) - HFuncTestVliCodec = wasmlib.ScHname(0xd5356012) - HFuncTestVluCodec = wasmlib.ScHname(0x9f7f63e6) - HFuncWhenMustIncrement = wasmlib.ScHname(0xb4c3e7a6) - HViewGetCounter = wasmlib.ScHname(0xb423e607) - HViewGetVli = wasmlib.ScHname(0x0ee16f89) - HViewGetVlu = wasmlib.ScHname(0x54d624e6) + HFuncCallIncrement = wasmtypes.ScHname(0xeb5dcacd) + HFuncCallIncrementRecurse5x = wasmtypes.ScHname(0x8749fbff) + HFuncEndlessLoop = wasmtypes.ScHname(0x365f0929) + HFuncIncrement = wasmtypes.ScHname(0xd351bd12) + HFuncIncrementWithDelay = wasmtypes.ScHname(0xa235bba7) + HFuncInit = wasmtypes.ScHname(0x1f44d644) + HFuncLocalStateInternalCall = wasmtypes.ScHname(0xecfc5d33) + HFuncLocalStatePost = wasmtypes.ScHname(0x3fd54d13) + HFuncLocalStateSandboxCall = wasmtypes.ScHname(0x7bd22c53) + HFuncPostIncrement = wasmtypes.ScHname(0x81c772f5) + HFuncRepeatMany = wasmtypes.ScHname(0x4ff450d3) + HFuncTestVliCodec = wasmtypes.ScHname(0xd5356012) + HFuncTestVluCodec = wasmtypes.ScHname(0x9f7f63e6) + HFuncWhenMustIncrement = wasmtypes.ScHname(0xb4c3e7a6) + HViewGetCounter = wasmtypes.ScHname(0xb423e607) + HViewGetVli = wasmtypes.ScHname(0x0ee16f89) + HViewGetVlu = wasmtypes.ScHname(0x54d624e6) ) diff --git a/contracts/wasm/inccounter/go/inccounter/contract.go b/contracts/wasm/inccounter/go/inccounter/contract.go index 3cec4024ef..29ec2b9e45 100644 --- a/contracts/wasm/inccounter/go/inccounter/contract.go +++ b/contracts/wasm/inccounter/go/inccounter/contract.go @@ -108,13 +108,13 @@ func (sc Funcs) Increment(ctx wasmlib.ScFuncCallContext) *IncrementCall { func (sc Funcs) IncrementWithDelay(ctx wasmlib.ScFuncCallContext) *IncrementWithDelayCall { f := &IncrementWithDelayCall{Func: wasmlib.NewScFunc(ctx, HScName, HFuncIncrementWithDelay)} - f.Func.SetPtrs(&f.Params.id, nil) + f.Params.proxy = wasmlib.NewCallParamsProxy(&f.Func.ScView) return f } func (sc Funcs) Init(ctx wasmlib.ScFuncCallContext) *InitCall { - f := &InitCall{Func: wasmlib.NewScInitFunc(ctx, HScName, HFuncInit, keyMap[:], idxMap[:])} - f.Func.SetPtrs(&f.Params.id, nil) + f := &InitCall{Func: wasmlib.NewScInitFunc(ctx, HScName, HFuncInit)} + f.Params.proxy = wasmlib.NewCallParamsProxy(&f.Func.ScView) return f } @@ -136,7 +136,7 @@ func (sc Funcs) PostIncrement(ctx wasmlib.ScFuncCallContext) *PostIncrementCall func (sc Funcs) RepeatMany(ctx wasmlib.ScFuncCallContext) *RepeatManyCall { f := &RepeatManyCall{Func: wasmlib.NewScFunc(ctx, HScName, HFuncRepeatMany)} - f.Func.SetPtrs(&f.Params.id, nil) + f.Params.proxy = wasmlib.NewCallParamsProxy(&f.Func.ScView) return f } @@ -150,24 +150,26 @@ func (sc Funcs) TestVluCodec(ctx wasmlib.ScFuncCallContext) *TestVluCodecCall { func (sc Funcs) WhenMustIncrement(ctx wasmlib.ScFuncCallContext) *WhenMustIncrementCall { f := &WhenMustIncrementCall{Func: wasmlib.NewScFunc(ctx, HScName, HFuncWhenMustIncrement)} - f.Func.SetPtrs(&f.Params.id, nil) + f.Params.proxy = wasmlib.NewCallParamsProxy(&f.Func.ScView) return f } func (sc Funcs) GetCounter(ctx wasmlib.ScViewCallContext) *GetCounterCall { f := &GetCounterCall{Func: wasmlib.NewScView(ctx, HScName, HViewGetCounter)} - f.Func.SetPtrs(nil, &f.Results.id) + wasmlib.NewCallResultsProxy(f.Func, &f.Results.proxy) return f } func (sc Funcs) GetVli(ctx wasmlib.ScViewCallContext) *GetVliCall { f := &GetVliCall{Func: wasmlib.NewScView(ctx, HScName, HViewGetVli)} - f.Func.SetPtrs(&f.Params.id, &f.Results.id) + f.Params.proxy = wasmlib.NewCallParamsProxy(f.Func) + wasmlib.NewCallResultsProxy(f.Func, &f.Results.proxy) return f } func (sc Funcs) GetVlu(ctx wasmlib.ScViewCallContext) *GetVluCall { f := &GetVluCall{Func: wasmlib.NewScView(ctx, HScName, HViewGetVlu)} - f.Func.SetPtrs(&f.Params.id, &f.Results.id) + f.Params.proxy = wasmlib.NewCallParamsProxy(f.Func) + wasmlib.NewCallResultsProxy(f.Func, &f.Results.proxy) return f } diff --git a/contracts/wasm/inccounter/go/inccounter/inccounter.go b/contracts/wasm/inccounter/go/inccounter/inccounter.go index 99b69b561b..fdf2031b67 100644 --- a/contracts/wasm/inccounter/go/inccounter/inccounter.go +++ b/contracts/wasm/inccounter/go/inccounter/inccounter.go @@ -7,6 +7,8 @@ import ( "strconv" "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" + "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmcodec" + "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" ) const hex = "0123456789abcdef" @@ -167,12 +169,11 @@ func viewGetCounter(ctx wasmlib.ScViewContext, f *GetCounterContext) { //nolint:dupl func viewGetVli(ctx wasmlib.ScViewContext, f *GetVliContext) { - enc := wasmlib.NewBytesEncoder() + enc := wasmcodec.NewWasmEncoder() n := f.Params.Ni64().Value() - enc = enc.Int64(n) - buf := enc.Data() - dec := wasmlib.NewBytesDecoder(buf) - x := dec.Int64() + buf := enc.VliEncode(n).Buf() + dec := wasmcodec.NewWasmDecoder(buf) + x := wasmtypes.DecodeInt64(dec) str := strconv.FormatInt(n, 10) + " -" for j := 0; j < len(buf); j++ { @@ -189,12 +190,11 @@ func viewGetVli(ctx wasmlib.ScViewContext, f *GetVliContext) { //nolint:dupl func viewGetVlu(ctx wasmlib.ScViewContext, f *GetVluContext) { - enc := wasmlib.NewBytesEncoder() + enc := wasmcodec.NewWasmEncoder() n := f.Params.Nu64().Value() - enc = enc.Uint64(n) - buf := enc.Data() - dec := wasmlib.NewBytesDecoder(buf) - x := dec.Uint64() + buf := enc.VluEncode(n).Buf() + dec := wasmcodec.NewWasmDecoder(buf) + x := wasmtypes.DecodeUint64(dec) str := strconv.FormatUint(n, 10) + " -" for j := 0; j < len(buf); j++ { @@ -219,14 +219,13 @@ func localStatePost(ctx wasmlib.ScFuncContext, nr int64) { } func vliSave(ctx wasmlib.ScFuncContext, name string, value int64) { - encoder := wasmlib.NewBytesEncoder() - encoder.Int64(value) - spot := ctx.State().GetBytes(wasmlib.Key(name)) - spot.SetValue(encoder.Data()) - - bytes := spot.Value() - decoder := wasmlib.NewBytesDecoder(bytes) - retrieved := decoder.Int64() + enc := wasmcodec.NewWasmEncoder() + state := wasmlib.ScState{} + state.Set([]byte(name), enc.VliEncode(value).Buf()) + + buf := state.Get([]byte(name)) + dec := wasmcodec.NewWasmDecoder(buf) + retrieved := wasmtypes.DecodeInt64(dec) if retrieved != value { ctx.Log(name + " in : " + ctx.Utility().String(value)) ctx.Log(name + " out: " + ctx.Utility().String(retrieved)) @@ -234,14 +233,13 @@ func vliSave(ctx wasmlib.ScFuncContext, name string, value int64) { } func vluSave(ctx wasmlib.ScFuncContext, name string, value uint64) { - encoder := wasmlib.NewBytesEncoder() - encoder.Uint64(value) - spot := ctx.State().GetBytes(wasmlib.Key(name)) - spot.SetValue(encoder.Data()) - - bytes := spot.Value() - decoder := wasmlib.NewBytesDecoder(bytes) - retrieved := decoder.Uint64() + enc := wasmcodec.NewWasmEncoder() + state := wasmlib.ScState{} + state.Set([]byte(name), enc.VluEncode(value).Buf()) + + buf := state.Get([]byte(name)) + dec := wasmcodec.NewWasmDecoder(buf) + retrieved := wasmtypes.DecodeUint64(dec) if retrieved != value { ctx.Log(name + " in : " + ctx.Utility().String(int64(value))) ctx.Log(name + " out: " + ctx.Utility().String(int64(retrieved))) diff --git a/contracts/wasm/inccounter/go/inccounter/keys.go b/contracts/wasm/inccounter/go/inccounter/keys.go index 610bac8cf6..7d83ea0649 100644 --- a/contracts/wasm/inccounter/go/inccounter/keys.go +++ b/contracts/wasm/inccounter/go/inccounter/keys.go @@ -6,47 +6,3 @@ // Change the json schema instead package inccounter - -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" - -const ( - IdxParamCounter = 0 - IdxParamDelay = 1 - IdxParamDummy = 2 - IdxParamNi64 = 3 - IdxParamNu64 = 4 - IdxParamNumRepeats = 5 - - IdxResultBuf = 6 - IdxResultCounter = 7 - IdxResultNi64 = 8 - IdxResultNu64 = 9 - IdxResultStr = 10 - IdxResultXi64 = 11 - IdxResultXu64 = 12 - - IdxStateCounter = 13 - IdxStateNumRepeats = 14 -) - -const keyMapLen = 15 - -var keyMap = [keyMapLen]wasmlib.Key{ - ParamCounter, - ParamDelay, - ParamDummy, - ParamNi64, - ParamNu64, - ParamNumRepeats, - ResultBuf, - ResultCounter, - ResultNi64, - ResultNu64, - ResultStr, - ResultXi64, - ResultXu64, - StateCounter, - StateNumRepeats, -} - -var idxMap [keyMapLen]wasmlib.Key32 diff --git a/contracts/wasm/inccounter/go/inccounter/lib.go b/contracts/wasm/inccounter/go/inccounter/lib.go index e1760a0dd6..d1e105a0ab 100644 --- a/contracts/wasm/inccounter/go/inccounter/lib.go +++ b/contracts/wasm/inccounter/go/inccounter/lib.go @@ -28,10 +28,6 @@ func OnLoad() { exports.AddView(ViewGetCounter, viewGetCounterThunk) exports.AddView(ViewGetVli, viewGetVliThunk) exports.AddView(ViewGetVlu, viewGetVluThunk) - - for i, key := range keyMap { - idxMap[i] = key.KeyID() - } } type CallIncrementContext struct { @@ -42,7 +38,7 @@ func funcCallIncrementThunk(ctx wasmlib.ScFuncContext) { ctx.Log("inccounter.funcCallIncrement") f := &CallIncrementContext{ State: MutableIncCounterState{ - id: wasmlib.OBJ_ID_STATE, + proxy: wasmlib.NewStateProxy(), }, } funcCallIncrement(ctx, f) @@ -57,7 +53,7 @@ func funcCallIncrementRecurse5xThunk(ctx wasmlib.ScFuncContext) { ctx.Log("inccounter.funcCallIncrementRecurse5x") f := &CallIncrementRecurse5xContext{ State: MutableIncCounterState{ - id: wasmlib.OBJ_ID_STATE, + proxy: wasmlib.NewStateProxy(), }, } funcCallIncrementRecurse5x(ctx, f) @@ -72,7 +68,7 @@ func funcEndlessLoopThunk(ctx wasmlib.ScFuncContext) { ctx.Log("inccounter.funcEndlessLoop") f := &EndlessLoopContext{ State: MutableIncCounterState{ - id: wasmlib.OBJ_ID_STATE, + proxy: wasmlib.NewStateProxy(), }, } funcEndlessLoop(ctx, f) @@ -87,7 +83,7 @@ func funcIncrementThunk(ctx wasmlib.ScFuncContext) { ctx.Log("inccounter.funcIncrement") f := &IncrementContext{ State: MutableIncCounterState{ - id: wasmlib.OBJ_ID_STATE, + proxy: wasmlib.NewStateProxy(), }, } funcIncrement(ctx, f) @@ -103,10 +99,10 @@ func funcIncrementWithDelayThunk(ctx wasmlib.ScFuncContext) { ctx.Log("inccounter.funcIncrementWithDelay") f := &IncrementWithDelayContext{ Params: ImmutableIncrementWithDelayParams{ - id: wasmlib.OBJ_ID_PARAMS, + proxy: wasmlib.NewParamsProxy(), }, State: MutableIncCounterState{ - id: wasmlib.OBJ_ID_STATE, + proxy: wasmlib.NewStateProxy(), }, } ctx.Require(f.Params.Delay().Exists(), "missing mandatory delay") @@ -123,10 +119,10 @@ func funcInitThunk(ctx wasmlib.ScFuncContext) { ctx.Log("inccounter.funcInit") f := &InitContext{ Params: ImmutableInitParams{ - id: wasmlib.OBJ_ID_PARAMS, + proxy: wasmlib.NewParamsProxy(), }, State: MutableIncCounterState{ - id: wasmlib.OBJ_ID_STATE, + proxy: wasmlib.NewStateProxy(), }, } funcInit(ctx, f) @@ -141,7 +137,7 @@ func funcLocalStateInternalCallThunk(ctx wasmlib.ScFuncContext) { ctx.Log("inccounter.funcLocalStateInternalCall") f := &LocalStateInternalCallContext{ State: MutableIncCounterState{ - id: wasmlib.OBJ_ID_STATE, + proxy: wasmlib.NewStateProxy(), }, } funcLocalStateInternalCall(ctx, f) @@ -156,7 +152,7 @@ func funcLocalStatePostThunk(ctx wasmlib.ScFuncContext) { ctx.Log("inccounter.funcLocalStatePost") f := &LocalStatePostContext{ State: MutableIncCounterState{ - id: wasmlib.OBJ_ID_STATE, + proxy: wasmlib.NewStateProxy(), }, } funcLocalStatePost(ctx, f) @@ -171,7 +167,7 @@ func funcLocalStateSandboxCallThunk(ctx wasmlib.ScFuncContext) { ctx.Log("inccounter.funcLocalStateSandboxCall") f := &LocalStateSandboxCallContext{ State: MutableIncCounterState{ - id: wasmlib.OBJ_ID_STATE, + proxy: wasmlib.NewStateProxy(), }, } funcLocalStateSandboxCall(ctx, f) @@ -186,7 +182,7 @@ func funcPostIncrementThunk(ctx wasmlib.ScFuncContext) { ctx.Log("inccounter.funcPostIncrement") f := &PostIncrementContext{ State: MutableIncCounterState{ - id: wasmlib.OBJ_ID_STATE, + proxy: wasmlib.NewStateProxy(), }, } funcPostIncrement(ctx, f) @@ -202,10 +198,10 @@ func funcRepeatManyThunk(ctx wasmlib.ScFuncContext) { ctx.Log("inccounter.funcRepeatMany") f := &RepeatManyContext{ Params: ImmutableRepeatManyParams{ - id: wasmlib.OBJ_ID_PARAMS, + proxy: wasmlib.NewParamsProxy(), }, State: MutableIncCounterState{ - id: wasmlib.OBJ_ID_STATE, + proxy: wasmlib.NewStateProxy(), }, } funcRepeatMany(ctx, f) @@ -220,7 +216,7 @@ func funcTestVliCodecThunk(ctx wasmlib.ScFuncContext) { ctx.Log("inccounter.funcTestVliCodec") f := &TestVliCodecContext{ State: MutableIncCounterState{ - id: wasmlib.OBJ_ID_STATE, + proxy: wasmlib.NewStateProxy(), }, } funcTestVliCodec(ctx, f) @@ -235,7 +231,7 @@ func funcTestVluCodecThunk(ctx wasmlib.ScFuncContext) { ctx.Log("inccounter.funcTestVluCodec") f := &TestVluCodecContext{ State: MutableIncCounterState{ - id: wasmlib.OBJ_ID_STATE, + proxy: wasmlib.NewStateProxy(), }, } funcTestVluCodec(ctx, f) @@ -251,10 +247,10 @@ func funcWhenMustIncrementThunk(ctx wasmlib.ScFuncContext) { ctx.Log("inccounter.funcWhenMustIncrement") f := &WhenMustIncrementContext{ Params: ImmutableWhenMustIncrementParams{ - id: wasmlib.OBJ_ID_PARAMS, + proxy: wasmlib.NewParamsProxy(), }, State: MutableIncCounterState{ - id: wasmlib.OBJ_ID_STATE, + proxy: wasmlib.NewStateProxy(), }, } funcWhenMustIncrement(ctx, f) @@ -270,10 +266,10 @@ func viewGetCounterThunk(ctx wasmlib.ScViewContext) { ctx.Log("inccounter.viewGetCounter") f := &GetCounterContext{ Results: MutableGetCounterResults{ - id: wasmlib.OBJ_ID_RESULTS, + proxy: wasmlib.NewResultsProxy(), }, State: ImmutableIncCounterState{ - id: wasmlib.OBJ_ID_STATE, + proxy: wasmlib.NewStateProxy(), }, } viewGetCounter(ctx, f) @@ -290,13 +286,13 @@ func viewGetVliThunk(ctx wasmlib.ScViewContext) { ctx.Log("inccounter.viewGetVli") f := &GetVliContext{ Params: ImmutableGetVliParams{ - id: wasmlib.OBJ_ID_PARAMS, + proxy: wasmlib.NewParamsProxy(), }, Results: MutableGetVliResults{ - id: wasmlib.OBJ_ID_RESULTS, + proxy: wasmlib.NewResultsProxy(), }, State: ImmutableIncCounterState{ - id: wasmlib.OBJ_ID_STATE, + proxy: wasmlib.NewStateProxy(), }, } ctx.Require(f.Params.Ni64().Exists(), "missing mandatory ni64") @@ -314,13 +310,13 @@ func viewGetVluThunk(ctx wasmlib.ScViewContext) { ctx.Log("inccounter.viewGetVlu") f := &GetVluContext{ Params: ImmutableGetVluParams{ - id: wasmlib.OBJ_ID_PARAMS, + proxy: wasmlib.NewParamsProxy(), }, Results: MutableGetVluResults{ - id: wasmlib.OBJ_ID_RESULTS, + proxy: wasmlib.NewResultsProxy(), }, State: ImmutableIncCounterState{ - id: wasmlib.OBJ_ID_STATE, + proxy: wasmlib.NewStateProxy(), }, } ctx.Require(f.Params.Nu64().Exists(), "missing mandatory nu64") diff --git a/contracts/wasm/inccounter/go/inccounter/params.go b/contracts/wasm/inccounter/go/inccounter/params.go index a6eb77a0e6..42df13c5bd 100644 --- a/contracts/wasm/inccounter/go/inccounter/params.go +++ b/contracts/wasm/inccounter/go/inccounter/params.go @@ -7,100 +7,100 @@ package inccounter -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" +import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" type ImmutableIncrementWithDelayParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableIncrementWithDelayParams) Delay() wasmlib.ScImmutableInt32 { - return wasmlib.NewScImmutableInt32(s.id, wasmlib.KeyID(ParamDelay)) +func (s ImmutableIncrementWithDelayParams) Delay() wasmtypes.ScImmutableUint32 { + return wasmtypes.NewScImmutableUint32(s.proxy.Root(ParamDelay)) } type MutableIncrementWithDelayParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableIncrementWithDelayParams) Delay() wasmlib.ScMutableInt32 { - return wasmlib.NewScMutableInt32(s.id, wasmlib.KeyID(ParamDelay)) +func (s MutableIncrementWithDelayParams) Delay() wasmtypes.ScMutableUint32 { + return wasmtypes.NewScMutableUint32(s.proxy.Root(ParamDelay)) } type ImmutableInitParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableInitParams) Counter() wasmlib.ScImmutableInt64 { - return wasmlib.NewScImmutableInt64(s.id, idxMap[IdxParamCounter]) +func (s ImmutableInitParams) Counter() wasmtypes.ScImmutableInt64 { + return wasmtypes.NewScImmutableInt64(s.proxy.Root(ParamCounter)) } type MutableInitParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableInitParams) Counter() wasmlib.ScMutableInt64 { - return wasmlib.NewScMutableInt64(s.id, idxMap[IdxParamCounter]) +func (s MutableInitParams) Counter() wasmtypes.ScMutableInt64 { + return wasmtypes.NewScMutableInt64(s.proxy.Root(ParamCounter)) } type ImmutableRepeatManyParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableRepeatManyParams) NumRepeats() wasmlib.ScImmutableInt64 { - return wasmlib.NewScImmutableInt64(s.id, wasmlib.KeyID(ParamNumRepeats)) +func (s ImmutableRepeatManyParams) NumRepeats() wasmtypes.ScImmutableInt64 { + return wasmtypes.NewScImmutableInt64(s.proxy.Root(ParamNumRepeats)) } type MutableRepeatManyParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableRepeatManyParams) NumRepeats() wasmlib.ScMutableInt64 { - return wasmlib.NewScMutableInt64(s.id, wasmlib.KeyID(ParamNumRepeats)) +func (s MutableRepeatManyParams) NumRepeats() wasmtypes.ScMutableInt64 { + return wasmtypes.NewScMutableInt64(s.proxy.Root(ParamNumRepeats)) } type ImmutableWhenMustIncrementParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableWhenMustIncrementParams) Dummy() wasmlib.ScImmutableInt64 { - return wasmlib.NewScImmutableInt64(s.id, wasmlib.KeyID(ParamDummy)) +func (s ImmutableWhenMustIncrementParams) Dummy() wasmtypes.ScImmutableInt64 { + return wasmtypes.NewScImmutableInt64(s.proxy.Root(ParamDummy)) } type MutableWhenMustIncrementParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableWhenMustIncrementParams) Dummy() wasmlib.ScMutableInt64 { - return wasmlib.NewScMutableInt64(s.id, wasmlib.KeyID(ParamDummy)) +func (s MutableWhenMustIncrementParams) Dummy() wasmtypes.ScMutableInt64 { + return wasmtypes.NewScMutableInt64(s.proxy.Root(ParamDummy)) } type ImmutableGetVliParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableGetVliParams) Ni64() wasmlib.ScImmutableInt64 { - return wasmlib.NewScImmutableInt64(s.id, wasmlib.KeyID(ParamNi64)) +func (s ImmutableGetVliParams) Ni64() wasmtypes.ScImmutableInt64 { + return wasmtypes.NewScImmutableInt64(s.proxy.Root(ParamNi64)) } type MutableGetVliParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableGetVliParams) Ni64() wasmlib.ScMutableInt64 { - return wasmlib.NewScMutableInt64(s.id, wasmlib.KeyID(ParamNi64)) +func (s MutableGetVliParams) Ni64() wasmtypes.ScMutableInt64 { + return wasmtypes.NewScMutableInt64(s.proxy.Root(ParamNi64)) } type ImmutableGetVluParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableGetVluParams) Nu64() wasmlib.ScImmutableUint64 { - return wasmlib.NewScImmutableUint64(s.id, wasmlib.KeyID(ParamNu64)) +func (s ImmutableGetVluParams) Nu64() wasmtypes.ScImmutableUint64 { + return wasmtypes.NewScImmutableUint64(s.proxy.Root(ParamNu64)) } type MutableGetVluParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableGetVluParams) Nu64() wasmlib.ScMutableUint64 { - return wasmlib.NewScMutableUint64(s.id, wasmlib.KeyID(ParamNu64)) +func (s MutableGetVluParams) Nu64() wasmtypes.ScMutableUint64 { + return wasmtypes.NewScMutableUint64(s.proxy.Root(ParamNu64)) } diff --git a/contracts/wasm/inccounter/go/inccounter/results.go b/contracts/wasm/inccounter/go/inccounter/results.go index adef8f3c81..5f3aaa7d2e 100644 --- a/contracts/wasm/inccounter/go/inccounter/results.go +++ b/contracts/wasm/inccounter/go/inccounter/results.go @@ -7,100 +7,100 @@ package inccounter -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" +import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" type ImmutableGetCounterResults struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableGetCounterResults) Counter() wasmlib.ScImmutableInt64 { - return wasmlib.NewScImmutableInt64(s.id, wasmlib.KeyID(ResultCounter)) +func (s ImmutableGetCounterResults) Counter() wasmtypes.ScImmutableInt64 { + return wasmtypes.NewScImmutableInt64(s.proxy.Root(ResultCounter)) } type MutableGetCounterResults struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableGetCounterResults) Counter() wasmlib.ScMutableInt64 { - return wasmlib.NewScMutableInt64(s.id, wasmlib.KeyID(ResultCounter)) +func (s MutableGetCounterResults) Counter() wasmtypes.ScMutableInt64 { + return wasmtypes.NewScMutableInt64(s.proxy.Root(ResultCounter)) } type ImmutableGetVliResults struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableGetVliResults) Buf() wasmlib.ScImmutableBytes { - return wasmlib.NewScImmutableBytes(s.id, wasmlib.KeyID(ResultBuf)) +func (s ImmutableGetVliResults) Buf() wasmtypes.ScImmutableBytes { + return wasmtypes.NewScImmutableBytes(s.proxy.Root(ResultBuf)) } -func (s ImmutableGetVliResults) Ni64() wasmlib.ScImmutableInt64 { - return wasmlib.NewScImmutableInt64(s.id, wasmlib.KeyID(ResultNi64)) +func (s ImmutableGetVliResults) Ni64() wasmtypes.ScImmutableInt64 { + return wasmtypes.NewScImmutableInt64(s.proxy.Root(ResultNi64)) } -func (s ImmutableGetVliResults) Str() wasmlib.ScImmutableString { - return wasmlib.NewScImmutableString(s.id, wasmlib.KeyID(ResultStr)) +func (s ImmutableGetVliResults) Str() wasmtypes.ScImmutableString { + return wasmtypes.NewScImmutableString(s.proxy.Root(ResultStr)) } -func (s ImmutableGetVliResults) Xi64() wasmlib.ScImmutableInt64 { - return wasmlib.NewScImmutableInt64(s.id, wasmlib.KeyID(ResultXi64)) +func (s ImmutableGetVliResults) Xi64() wasmtypes.ScImmutableInt64 { + return wasmtypes.NewScImmutableInt64(s.proxy.Root(ResultXi64)) } type MutableGetVliResults struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableGetVliResults) Buf() wasmlib.ScMutableBytes { - return wasmlib.NewScMutableBytes(s.id, wasmlib.KeyID(ResultBuf)) +func (s MutableGetVliResults) Buf() wasmtypes.ScMutableBytes { + return wasmtypes.NewScMutableBytes(s.proxy.Root(ResultBuf)) } -func (s MutableGetVliResults) Ni64() wasmlib.ScMutableInt64 { - return wasmlib.NewScMutableInt64(s.id, wasmlib.KeyID(ResultNi64)) +func (s MutableGetVliResults) Ni64() wasmtypes.ScMutableInt64 { + return wasmtypes.NewScMutableInt64(s.proxy.Root(ResultNi64)) } -func (s MutableGetVliResults) Str() wasmlib.ScMutableString { - return wasmlib.NewScMutableString(s.id, wasmlib.KeyID(ResultStr)) +func (s MutableGetVliResults) Str() wasmtypes.ScMutableString { + return wasmtypes.NewScMutableString(s.proxy.Root(ResultStr)) } -func (s MutableGetVliResults) Xi64() wasmlib.ScMutableInt64 { - return wasmlib.NewScMutableInt64(s.id, wasmlib.KeyID(ResultXi64)) +func (s MutableGetVliResults) Xi64() wasmtypes.ScMutableInt64 { + return wasmtypes.NewScMutableInt64(s.proxy.Root(ResultXi64)) } type ImmutableGetVluResults struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableGetVluResults) Buf() wasmlib.ScImmutableBytes { - return wasmlib.NewScImmutableBytes(s.id, wasmlib.KeyID(ResultBuf)) +func (s ImmutableGetVluResults) Buf() wasmtypes.ScImmutableBytes { + return wasmtypes.NewScImmutableBytes(s.proxy.Root(ResultBuf)) } -func (s ImmutableGetVluResults) Nu64() wasmlib.ScImmutableUint64 { - return wasmlib.NewScImmutableUint64(s.id, wasmlib.KeyID(ResultNu64)) +func (s ImmutableGetVluResults) Nu64() wasmtypes.ScImmutableUint64 { + return wasmtypes.NewScImmutableUint64(s.proxy.Root(ResultNu64)) } -func (s ImmutableGetVluResults) Str() wasmlib.ScImmutableString { - return wasmlib.NewScImmutableString(s.id, wasmlib.KeyID(ResultStr)) +func (s ImmutableGetVluResults) Str() wasmtypes.ScImmutableString { + return wasmtypes.NewScImmutableString(s.proxy.Root(ResultStr)) } -func (s ImmutableGetVluResults) Xu64() wasmlib.ScImmutableUint64 { - return wasmlib.NewScImmutableUint64(s.id, wasmlib.KeyID(ResultXu64)) +func (s ImmutableGetVluResults) Xu64() wasmtypes.ScImmutableUint64 { + return wasmtypes.NewScImmutableUint64(s.proxy.Root(ResultXu64)) } type MutableGetVluResults struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableGetVluResults) Buf() wasmlib.ScMutableBytes { - return wasmlib.NewScMutableBytes(s.id, wasmlib.KeyID(ResultBuf)) +func (s MutableGetVluResults) Buf() wasmtypes.ScMutableBytes { + return wasmtypes.NewScMutableBytes(s.proxy.Root(ResultBuf)) } -func (s MutableGetVluResults) Nu64() wasmlib.ScMutableUint64 { - return wasmlib.NewScMutableUint64(s.id, wasmlib.KeyID(ResultNu64)) +func (s MutableGetVluResults) Nu64() wasmtypes.ScMutableUint64 { + return wasmtypes.NewScMutableUint64(s.proxy.Root(ResultNu64)) } -func (s MutableGetVluResults) Str() wasmlib.ScMutableString { - return wasmlib.NewScMutableString(s.id, wasmlib.KeyID(ResultStr)) +func (s MutableGetVluResults) Str() wasmtypes.ScMutableString { + return wasmtypes.NewScMutableString(s.proxy.Root(ResultStr)) } -func (s MutableGetVluResults) Xu64() wasmlib.ScMutableUint64 { - return wasmlib.NewScMutableUint64(s.id, wasmlib.KeyID(ResultXu64)) +func (s MutableGetVluResults) Xu64() wasmtypes.ScMutableUint64 { + return wasmtypes.NewScMutableUint64(s.proxy.Root(ResultXu64)) } diff --git a/contracts/wasm/inccounter/go/inccounter/state.go b/contracts/wasm/inccounter/go/inccounter/state.go index f406babfb8..d22480973f 100644 --- a/contracts/wasm/inccounter/go/inccounter/state.go +++ b/contracts/wasm/inccounter/go/inccounter/state.go @@ -7,32 +7,32 @@ package inccounter -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" +import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" type ImmutableIncCounterState struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableIncCounterState) Counter() wasmlib.ScImmutableInt64 { - return wasmlib.NewScImmutableInt64(s.id, wasmlib.KeyID(StateCounter)) +func (s ImmutableIncCounterState) Counter() wasmtypes.ScImmutableInt64 { + return wasmtypes.NewScImmutableInt64(s.proxy.Root(StateCounter)) } -func (s ImmutableIncCounterState) NumRepeats() wasmlib.ScImmutableInt64 { - return wasmlib.NewScImmutableInt64(s.id, wasmlib.KeyID(StateNumRepeats)) +func (s ImmutableIncCounterState) NumRepeats() wasmtypes.ScImmutableInt64 { + return wasmtypes.NewScImmutableInt64(s.proxy.Root(StateNumRepeats)) } type MutableIncCounterState struct { - id int32 + proxy wasmtypes.Proxy } func (s MutableIncCounterState) AsImmutable() ImmutableIncCounterState { return ImmutableIncCounterState(s) } -func (s MutableIncCounterState) Counter() wasmlib.ScMutableInt64 { - return wasmlib.NewScMutableInt64(s.id, wasmlib.KeyID(StateCounter)) +func (s MutableIncCounterState) Counter() wasmtypes.ScMutableInt64 { + return wasmtypes.NewScMutableInt64(s.proxy.Root(StateCounter)) } -func (s MutableIncCounterState) NumRepeats() wasmlib.ScMutableInt64 { - return wasmlib.NewScMutableInt64(s.id, wasmlib.KeyID(StateNumRepeats)) +func (s MutableIncCounterState) NumRepeats() wasmtypes.ScMutableInt64 { + return wasmtypes.NewScMutableInt64(s.proxy.Root(StateNumRepeats)) } diff --git a/contracts/wasm/inccounter/schema.yaml b/contracts/wasm/inccounter/schema.yaml index 9779881237..91ec5304c5 100644 --- a/contracts/wasm/inccounter/schema.yaml +++ b/contracts/wasm/inccounter/schema.yaml @@ -12,7 +12,7 @@ funcs: increment: {} incrementWithDelay: params: - delay: Int32 // delay in seconds + delay: Uint32 // delay in seconds init: params: counter: Int64? // value to initialize state counter with diff --git a/contracts/wasm/inccounter/src/params.rs b/contracts/wasm/inccounter/src/params.rs index 3c90233bd7..f402d3c37d 100644 --- a/contracts/wasm/inccounter/src/params.rs +++ b/contracts/wasm/inccounter/src/params.rs @@ -20,8 +20,8 @@ pub struct ImmutableIncrementWithDelayParams { } impl ImmutableIncrementWithDelayParams { - pub fn delay(&self) -> ScImmutableInt32 { - ScImmutableInt32::new(self.id, PARAM_DELAY.get_key_id()) + pub fn delay(&self) -> ScImmutableUint32 { + ScImmutableUint32::new(self.id, PARAM_DELAY.get_key_id()) } } @@ -31,8 +31,8 @@ pub struct MutableIncrementWithDelayParams { } impl MutableIncrementWithDelayParams { - pub fn delay(&self) -> ScMutableInt32 { - ScMutableInt32::new(self.id, PARAM_DELAY.get_key_id()) + pub fn delay(&self) -> ScMutableUint32 { + ScMutableUint32::new(self.id, PARAM_DELAY.get_key_id()) } } diff --git a/contracts/wasm/inccounter/test/inccounter_bg.wasm b/contracts/wasm/inccounter/test/inccounter_bg.wasm index ae1937db526f66951a7f2aa742ed3e65e10f983c..e9884aa9c0a08667b433fcb83befa5867674d40f 100644 GIT binary patch delta 206 zcmbPwl4<5irU{WUjP(gj^>qvhj6lp<4+20DHZY@pVyPvgz{K?qjDizC$TRXz7GM-- zA) zOg8hSXfrV`nrxM}fJuR2^R2W%=EDN)XGw2P$^N8fZf2s8lbV-alA*yV pz~IHez);P|z@Q7HGxN$4b23vDN{x-6Di|1GYIZPf?w!OT1ONopJcIxM delta 182 zcmbPvl4gy(!S~BuaT<^drF!6&tqu^u#MsY^I$r_9*jJ%V58UHiR z-0aJAQIxTDvb;pt5&ATObNiwdQ?5VHGXtH^sQI;XA36p?;-e!RmZ6?MAlWo!# zY`&Kk$UNCMTY9rs7Bk~y{VeIt8QGuI%#Do{a#HisOENS#1sJ>-7#Lz185nedbY@;z ZVoqj?LZ+DsR0RVAOieZ8=82Oyga9mvH4Oj& diff --git a/contracts/wasm/inccounter/ts/inccounter/params.ts b/contracts/wasm/inccounter/ts/inccounter/params.ts index 3670ea1fab..6c2d8ed128 100644 --- a/contracts/wasm/inccounter/ts/inccounter/params.ts +++ b/contracts/wasm/inccounter/ts/inccounter/params.ts @@ -9,14 +9,14 @@ import * as wasmlib from "wasmlib"; import * as sc from "./index"; export class ImmutableIncrementWithDelayParams extends wasmlib.ScMapID { - delay(): wasmlib.ScImmutableInt32 { - return new wasmlib.ScImmutableInt32(this.mapID, wasmlib.Key32.fromString(sc.ParamDelay)); + delay(): wasmlib.ScImmutableUint32 { + return new wasmlib.ScImmutableUint32(this.mapID, wasmlib.Key32.fromString(sc.ParamDelay)); } } export class MutableIncrementWithDelayParams extends wasmlib.ScMapID { - delay(): wasmlib.ScMutableInt32 { - return new wasmlib.ScMutableInt32(this.mapID, wasmlib.Key32.fromString(sc.ParamDelay)); + delay(): wasmlib.ScMutableUint32 { + return new wasmlib.ScMutableUint32(this.mapID, wasmlib.Key32.fromString(sc.ParamDelay)); } } diff --git a/contracts/wasm/testcore/go/testcore/consts.go b/contracts/wasm/testcore/go/testcore/consts.go index d1e82b1b9c..6fd5a600de 100644 --- a/contracts/wasm/testcore/go/testcore/consts.go +++ b/contracts/wasm/testcore/go/testcore/consts.go @@ -7,12 +7,12 @@ package testcore -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" +import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" const ( ScName = "testcore" ScDescription = "Core test for ISCP wasmlib Rust/Wasm library" - HScName = wasmlib.ScHname(0x370d33ad) + HScName = wasmtypes.ScHname(0x370d33ad) ) const ( @@ -95,36 +95,36 @@ const ( ) const ( - HFuncCallOnChain = wasmlib.ScHname(0x95a3d123) - HFuncCheckContextFromFullEP = wasmlib.ScHname(0xa56c24ba) - HFuncDoNothing = wasmlib.ScHname(0xdda4a6de) - HFuncGetMintedSupply = wasmlib.ScHname(0x0c2d113c) - HFuncIncCounter = wasmlib.ScHname(0x7b287419) - HFuncInit = wasmlib.ScHname(0x1f44d644) - HFuncPassTypesFull = wasmlib.ScHname(0x733ea0ea) - HFuncRunRecursion = wasmlib.ScHname(0x833425fd) - HFuncSendToAddress = wasmlib.ScHname(0x63ce4634) - HFuncSetInt = wasmlib.ScHname(0x62056f74) - HFuncSpawn = wasmlib.ScHname(0xec929d12) - HFuncTestBlockContext1 = wasmlib.ScHname(0x796d4136) - HFuncTestBlockContext2 = wasmlib.ScHname(0x758b0452) - HFuncTestCallPanicFullEP = wasmlib.ScHname(0x4c878834) - HFuncTestCallPanicViewEPFromFull = wasmlib.ScHname(0xfd7e8c1d) - HFuncTestChainOwnerIDFull = wasmlib.ScHname(0x2aff1167) - HFuncTestEventLogDeploy = wasmlib.ScHname(0x96ff760a) - HFuncTestEventLogEventData = wasmlib.ScHname(0x0efcf939) - HFuncTestEventLogGenericData = wasmlib.ScHname(0x6a16629d) - HFuncTestPanicFullEP = wasmlib.ScHname(0x24fdef07) - HFuncWithdrawToChain = wasmlib.ScHname(0x437bc026) - HViewCheckContextFromViewEP = wasmlib.ScHname(0x88ff0167) - HViewFibonacci = wasmlib.ScHname(0x7940873c) - HViewGetCounter = wasmlib.ScHname(0xb423e607) - HViewGetInt = wasmlib.ScHname(0x1887e5ef) - HViewGetStringValue = wasmlib.ScHname(0xcf0a4d32) - HViewJustView = wasmlib.ScHname(0x33b8972e) - HViewPassTypesView = wasmlib.ScHname(0x1a5b87ea) - HViewTestCallPanicViewEPFromView = wasmlib.ScHname(0x91b10c99) - HViewTestChainOwnerIDView = wasmlib.ScHname(0x26586c33) - HViewTestPanicViewEP = wasmlib.ScHname(0x22bc4d72) - HViewTestSandboxCall = wasmlib.ScHname(0x42d72b63) + HFuncCallOnChain = wasmtypes.ScHname(0x95a3d123) + HFuncCheckContextFromFullEP = wasmtypes.ScHname(0xa56c24ba) + HFuncDoNothing = wasmtypes.ScHname(0xdda4a6de) + HFuncGetMintedSupply = wasmtypes.ScHname(0x0c2d113c) + HFuncIncCounter = wasmtypes.ScHname(0x7b287419) + HFuncInit = wasmtypes.ScHname(0x1f44d644) + HFuncPassTypesFull = wasmtypes.ScHname(0x733ea0ea) + HFuncRunRecursion = wasmtypes.ScHname(0x833425fd) + HFuncSendToAddress = wasmtypes.ScHname(0x63ce4634) + HFuncSetInt = wasmtypes.ScHname(0x62056f74) + HFuncSpawn = wasmtypes.ScHname(0xec929d12) + HFuncTestBlockContext1 = wasmtypes.ScHname(0x796d4136) + HFuncTestBlockContext2 = wasmtypes.ScHname(0x758b0452) + HFuncTestCallPanicFullEP = wasmtypes.ScHname(0x4c878834) + HFuncTestCallPanicViewEPFromFull = wasmtypes.ScHname(0xfd7e8c1d) + HFuncTestChainOwnerIDFull = wasmtypes.ScHname(0x2aff1167) + HFuncTestEventLogDeploy = wasmtypes.ScHname(0x96ff760a) + HFuncTestEventLogEventData = wasmtypes.ScHname(0x0efcf939) + HFuncTestEventLogGenericData = wasmtypes.ScHname(0x6a16629d) + HFuncTestPanicFullEP = wasmtypes.ScHname(0x24fdef07) + HFuncWithdrawToChain = wasmtypes.ScHname(0x437bc026) + HViewCheckContextFromViewEP = wasmtypes.ScHname(0x88ff0167) + HViewFibonacci = wasmtypes.ScHname(0x7940873c) + HViewGetCounter = wasmtypes.ScHname(0xb423e607) + HViewGetInt = wasmtypes.ScHname(0x1887e5ef) + HViewGetStringValue = wasmtypes.ScHname(0xcf0a4d32) + HViewJustView = wasmtypes.ScHname(0x33b8972e) + HViewPassTypesView = wasmtypes.ScHname(0x1a5b87ea) + HViewTestCallPanicViewEPFromView = wasmtypes.ScHname(0x91b10c99) + HViewTestChainOwnerIDView = wasmtypes.ScHname(0x26586c33) + HViewTestPanicViewEP = wasmtypes.ScHname(0x22bc4d72) + HViewTestSandboxCall = wasmtypes.ScHname(0x42d72b63) ) diff --git a/contracts/wasm/testcore/go/testcore/contract.go b/contracts/wasm/testcore/go/testcore/contract.go index 6799a98352..57c0844acf 100644 --- a/contracts/wasm/testcore/go/testcore/contract.go +++ b/contracts/wasm/testcore/go/testcore/contract.go @@ -168,13 +168,14 @@ var ScFuncs Funcs func (sc Funcs) CallOnChain(ctx wasmlib.ScFuncCallContext) *CallOnChainCall { f := &CallOnChainCall{Func: wasmlib.NewScFunc(ctx, HScName, HFuncCallOnChain)} - f.Func.SetPtrs(&f.Params.id, &f.Results.id) + f.Params.proxy = wasmlib.NewCallParamsProxy(&f.Func.ScView) + wasmlib.NewCallResultsProxy(&f.Func.ScView, &f.Results.proxy) return f } func (sc Funcs) CheckContextFromFullEP(ctx wasmlib.ScFuncCallContext) *CheckContextFromFullEPCall { f := &CheckContextFromFullEPCall{Func: wasmlib.NewScFunc(ctx, HScName, HFuncCheckContextFromFullEP)} - f.Func.SetPtrs(&f.Params.id, nil) + f.Params.proxy = wasmlib.NewCallParamsProxy(&f.Func.ScView) return f } @@ -184,7 +185,7 @@ func (sc Funcs) DoNothing(ctx wasmlib.ScFuncCallContext) *DoNothingCall { func (sc Funcs) GetMintedSupply(ctx wasmlib.ScFuncCallContext) *GetMintedSupplyCall { f := &GetMintedSupplyCall{Func: wasmlib.NewScFunc(ctx, HScName, HFuncGetMintedSupply)} - f.Func.SetPtrs(nil, &f.Results.id) + wasmlib.NewCallResultsProxy(&f.Func.ScView, &f.Results.proxy) return f } @@ -193,38 +194,39 @@ func (sc Funcs) IncCounter(ctx wasmlib.ScFuncCallContext) *IncCounterCall { } func (sc Funcs) Init(ctx wasmlib.ScFuncCallContext) *InitCall { - f := &InitCall{Func: wasmlib.NewScInitFunc(ctx, HScName, HFuncInit, keyMap[:], idxMap[:])} - f.Func.SetPtrs(&f.Params.id, nil) + f := &InitCall{Func: wasmlib.NewScInitFunc(ctx, HScName, HFuncInit)} + f.Params.proxy = wasmlib.NewCallParamsProxy(&f.Func.ScView) return f } func (sc Funcs) PassTypesFull(ctx wasmlib.ScFuncCallContext) *PassTypesFullCall { f := &PassTypesFullCall{Func: wasmlib.NewScFunc(ctx, HScName, HFuncPassTypesFull)} - f.Func.SetPtrs(&f.Params.id, nil) + f.Params.proxy = wasmlib.NewCallParamsProxy(&f.Func.ScView) return f } func (sc Funcs) RunRecursion(ctx wasmlib.ScFuncCallContext) *RunRecursionCall { f := &RunRecursionCall{Func: wasmlib.NewScFunc(ctx, HScName, HFuncRunRecursion)} - f.Func.SetPtrs(&f.Params.id, &f.Results.id) + f.Params.proxy = wasmlib.NewCallParamsProxy(&f.Func.ScView) + wasmlib.NewCallResultsProxy(&f.Func.ScView, &f.Results.proxy) return f } func (sc Funcs) SendToAddress(ctx wasmlib.ScFuncCallContext) *SendToAddressCall { f := &SendToAddressCall{Func: wasmlib.NewScFunc(ctx, HScName, HFuncSendToAddress)} - f.Func.SetPtrs(&f.Params.id, nil) + f.Params.proxy = wasmlib.NewCallParamsProxy(&f.Func.ScView) return f } func (sc Funcs) SetInt(ctx wasmlib.ScFuncCallContext) *SetIntCall { f := &SetIntCall{Func: wasmlib.NewScFunc(ctx, HScName, HFuncSetInt)} - f.Func.SetPtrs(&f.Params.id, nil) + f.Params.proxy = wasmlib.NewCallParamsProxy(&f.Func.ScView) return f } func (sc Funcs) Spawn(ctx wasmlib.ScFuncCallContext) *SpawnCall { f := &SpawnCall{Func: wasmlib.NewScFunc(ctx, HScName, HFuncSpawn)} - f.Func.SetPtrs(&f.Params.id, nil) + f.Params.proxy = wasmlib.NewCallParamsProxy(&f.Func.ScView) return f } @@ -246,7 +248,7 @@ func (sc Funcs) TestCallPanicViewEPFromFull(ctx wasmlib.ScFuncCallContext) *Test func (sc Funcs) TestChainOwnerIDFull(ctx wasmlib.ScFuncCallContext) *TestChainOwnerIDFullCall { f := &TestChainOwnerIDFullCall{Func: wasmlib.NewScFunc(ctx, HScName, HFuncTestChainOwnerIDFull)} - f.Func.SetPtrs(nil, &f.Results.id) + wasmlib.NewCallResultsProxy(&f.Func.ScView, &f.Results.proxy) return f } @@ -260,7 +262,7 @@ func (sc Funcs) TestEventLogEventData(ctx wasmlib.ScFuncCallContext) *TestEventL func (sc Funcs) TestEventLogGenericData(ctx wasmlib.ScFuncCallContext) *TestEventLogGenericDataCall { f := &TestEventLogGenericDataCall{Func: wasmlib.NewScFunc(ctx, HScName, HFuncTestEventLogGenericData)} - f.Func.SetPtrs(&f.Params.id, nil) + f.Params.proxy = wasmlib.NewCallParamsProxy(&f.Func.ScView) return f } @@ -270,37 +272,40 @@ func (sc Funcs) TestPanicFullEP(ctx wasmlib.ScFuncCallContext) *TestPanicFullEPC func (sc Funcs) WithdrawToChain(ctx wasmlib.ScFuncCallContext) *WithdrawToChainCall { f := &WithdrawToChainCall{Func: wasmlib.NewScFunc(ctx, HScName, HFuncWithdrawToChain)} - f.Func.SetPtrs(&f.Params.id, nil) + f.Params.proxy = wasmlib.NewCallParamsProxy(&f.Func.ScView) return f } func (sc Funcs) CheckContextFromViewEP(ctx wasmlib.ScViewCallContext) *CheckContextFromViewEPCall { f := &CheckContextFromViewEPCall{Func: wasmlib.NewScView(ctx, HScName, HViewCheckContextFromViewEP)} - f.Func.SetPtrs(&f.Params.id, nil) + f.Params.proxy = wasmlib.NewCallParamsProxy(f.Func) return f } func (sc Funcs) Fibonacci(ctx wasmlib.ScViewCallContext) *FibonacciCall { f := &FibonacciCall{Func: wasmlib.NewScView(ctx, HScName, HViewFibonacci)} - f.Func.SetPtrs(&f.Params.id, &f.Results.id) + f.Params.proxy = wasmlib.NewCallParamsProxy(f.Func) + wasmlib.NewCallResultsProxy(f.Func, &f.Results.proxy) return f } func (sc Funcs) GetCounter(ctx wasmlib.ScViewCallContext) *GetCounterCall { f := &GetCounterCall{Func: wasmlib.NewScView(ctx, HScName, HViewGetCounter)} - f.Func.SetPtrs(nil, &f.Results.id) + wasmlib.NewCallResultsProxy(f.Func, &f.Results.proxy) return f } func (sc Funcs) GetInt(ctx wasmlib.ScViewCallContext) *GetIntCall { f := &GetIntCall{Func: wasmlib.NewScView(ctx, HScName, HViewGetInt)} - f.Func.SetPtrs(&f.Params.id, &f.Results.id) + f.Params.proxy = wasmlib.NewCallParamsProxy(f.Func) + wasmlib.NewCallResultsProxy(f.Func, &f.Results.proxy) return f } func (sc Funcs) GetStringValue(ctx wasmlib.ScViewCallContext) *GetStringValueCall { f := &GetStringValueCall{Func: wasmlib.NewScView(ctx, HScName, HViewGetStringValue)} - f.Func.SetPtrs(&f.Params.id, &f.Results.id) + f.Params.proxy = wasmlib.NewCallParamsProxy(f.Func) + wasmlib.NewCallResultsProxy(f.Func, &f.Results.proxy) return f } @@ -310,7 +315,7 @@ func (sc Funcs) JustView(ctx wasmlib.ScViewCallContext) *JustViewCall { func (sc Funcs) PassTypesView(ctx wasmlib.ScViewCallContext) *PassTypesViewCall { f := &PassTypesViewCall{Func: wasmlib.NewScView(ctx, HScName, HViewPassTypesView)} - f.Func.SetPtrs(&f.Params.id, nil) + f.Params.proxy = wasmlib.NewCallParamsProxy(f.Func) return f } @@ -320,7 +325,7 @@ func (sc Funcs) TestCallPanicViewEPFromView(ctx wasmlib.ScViewCallContext) *Test func (sc Funcs) TestChainOwnerIDView(ctx wasmlib.ScViewCallContext) *TestChainOwnerIDViewCall { f := &TestChainOwnerIDViewCall{Func: wasmlib.NewScView(ctx, HScName, HViewTestChainOwnerIDView)} - f.Func.SetPtrs(nil, &f.Results.id) + wasmlib.NewCallResultsProxy(f.Func, &f.Results.proxy) return f } @@ -330,6 +335,6 @@ func (sc Funcs) TestPanicViewEP(ctx wasmlib.ScViewCallContext) *TestPanicViewEPC func (sc Funcs) TestSandboxCall(ctx wasmlib.ScViewCallContext) *TestSandboxCallCall { f := &TestSandboxCallCall{Func: wasmlib.NewScView(ctx, HScName, HViewTestSandboxCall)} - f.Func.SetPtrs(nil, &f.Results.id) + wasmlib.NewCallResultsProxy(f.Func, &f.Results.proxy) return f } diff --git a/contracts/wasm/testcore/go/testcore/keys.go b/contracts/wasm/testcore/go/testcore/keys.go index bf75b33824..09ac529c6f 100644 --- a/contracts/wasm/testcore/go/testcore/keys.go +++ b/contracts/wasm/testcore/go/testcore/keys.go @@ -6,87 +6,3 @@ // Change the json schema instead package testcore - -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" - -const ( - IdxParamAddress = 0 - IdxParamAgentID = 1 - IdxParamCaller = 2 - IdxParamChainID = 3 - IdxParamChainOwnerID = 4 - IdxParamContractCreator = 5 - IdxParamContractID = 6 - IdxParamCounter = 7 - IdxParamFail = 8 - IdxParamHash = 9 - IdxParamHname = 10 - IdxParamHnameContract = 11 - IdxParamHnameEP = 12 - IdxParamHnameZero = 13 - IdxParamInt64 = 14 - IdxParamInt64Zero = 15 - IdxParamIntValue = 16 - IdxParamName = 17 - IdxParamProgHash = 18 - IdxParamString = 19 - IdxParamStringZero = 20 - IdxParamVarName = 21 - - IdxResultChainOwnerID = 22 - IdxResultCounter = 23 - IdxResultIntValue = 24 - IdxResultMintedColor = 25 - IdxResultMintedSupply = 26 - IdxResultSandboxCall = 27 - IdxResultValues = 28 - IdxResultVars = 29 - - IdxStateCounter = 30 - IdxStateHnameEP = 31 - IdxStateInts = 32 - IdxStateMintedColor = 33 - IdxStateMintedSupply = 34 -) - -const keyMapLen = 35 - -var keyMap = [keyMapLen]wasmlib.Key{ - ParamAddress, - ParamAgentID, - ParamCaller, - ParamChainID, - ParamChainOwnerID, - ParamContractCreator, - ParamContractID, - ParamCounter, - ParamFail, - ParamHash, - ParamHname, - ParamHnameContract, - ParamHnameEP, - ParamHnameZero, - ParamInt64, - ParamInt64Zero, - ParamIntValue, - ParamName, - ParamProgHash, - ParamString, - ParamStringZero, - ParamVarName, - ResultChainOwnerID, - ResultCounter, - ResultIntValue, - ResultMintedColor, - ResultMintedSupply, - ResultSandboxCall, - ResultValues, - ResultVars, - StateCounter, - StateHnameEP, - StateInts, - StateMintedColor, - StateMintedSupply, -} - -var idxMap [keyMapLen]wasmlib.Key32 diff --git a/contracts/wasm/testcore/go/testcore/lib.go b/contracts/wasm/testcore/go/testcore/lib.go index d24d89a3b2..a6c9b21adc 100644 --- a/contracts/wasm/testcore/go/testcore/lib.go +++ b/contracts/wasm/testcore/go/testcore/lib.go @@ -44,10 +44,6 @@ func OnLoad() { exports.AddView(ViewTestChainOwnerIDView, viewTestChainOwnerIDViewThunk) exports.AddView(ViewTestPanicViewEP, viewTestPanicViewEPThunk) exports.AddView(ViewTestSandboxCall, viewTestSandboxCallThunk) - - for i, key := range keyMap { - idxMap[i] = key.KeyID() - } } type CallOnChainContext struct { @@ -60,13 +56,13 @@ func funcCallOnChainThunk(ctx wasmlib.ScFuncContext) { ctx.Log("testcore.funcCallOnChain") f := &CallOnChainContext{ Params: ImmutableCallOnChainParams{ - id: wasmlib.OBJ_ID_PARAMS, + proxy: wasmlib.NewParamsProxy(), }, Results: MutableCallOnChainResults{ - id: wasmlib.OBJ_ID_RESULTS, + proxy: wasmlib.NewResultsProxy(), }, State: MutableTestCoreState{ - id: wasmlib.OBJ_ID_STATE, + proxy: wasmlib.NewStateProxy(), }, } ctx.Require(f.Params.IntValue().Exists(), "missing mandatory intValue") @@ -83,10 +79,10 @@ func funcCheckContextFromFullEPThunk(ctx wasmlib.ScFuncContext) { ctx.Log("testcore.funcCheckContextFromFullEP") f := &CheckContextFromFullEPContext{ Params: ImmutableCheckContextFromFullEPParams{ - id: wasmlib.OBJ_ID_PARAMS, + proxy: wasmlib.NewParamsProxy(), }, State: MutableTestCoreState{ - id: wasmlib.OBJ_ID_STATE, + proxy: wasmlib.NewStateProxy(), }, } ctx.Require(f.Params.AgentID().Exists(), "missing mandatory agentID") @@ -106,7 +102,7 @@ func funcDoNothingThunk(ctx wasmlib.ScFuncContext) { ctx.Log("testcore.funcDoNothing") f := &DoNothingContext{ State: MutableTestCoreState{ - id: wasmlib.OBJ_ID_STATE, + proxy: wasmlib.NewStateProxy(), }, } funcDoNothing(ctx, f) @@ -122,10 +118,10 @@ func funcGetMintedSupplyThunk(ctx wasmlib.ScFuncContext) { ctx.Log("testcore.funcGetMintedSupply") f := &GetMintedSupplyContext{ Results: MutableGetMintedSupplyResults{ - id: wasmlib.OBJ_ID_RESULTS, + proxy: wasmlib.NewResultsProxy(), }, State: MutableTestCoreState{ - id: wasmlib.OBJ_ID_STATE, + proxy: wasmlib.NewStateProxy(), }, } funcGetMintedSupply(ctx, f) @@ -140,7 +136,7 @@ func funcIncCounterThunk(ctx wasmlib.ScFuncContext) { ctx.Log("testcore.funcIncCounter") f := &IncCounterContext{ State: MutableTestCoreState{ - id: wasmlib.OBJ_ID_STATE, + proxy: wasmlib.NewStateProxy(), }, } funcIncCounter(ctx, f) @@ -156,10 +152,10 @@ func funcInitThunk(ctx wasmlib.ScFuncContext) { ctx.Log("testcore.funcInit") f := &InitContext{ Params: ImmutableInitParams{ - id: wasmlib.OBJ_ID_PARAMS, + proxy: wasmlib.NewParamsProxy(), }, State: MutableTestCoreState{ - id: wasmlib.OBJ_ID_STATE, + proxy: wasmlib.NewStateProxy(), }, } funcInit(ctx, f) @@ -175,10 +171,10 @@ func funcPassTypesFullThunk(ctx wasmlib.ScFuncContext) { ctx.Log("testcore.funcPassTypesFull") f := &PassTypesFullContext{ Params: ImmutablePassTypesFullParams{ - id: wasmlib.OBJ_ID_PARAMS, + proxy: wasmlib.NewParamsProxy(), }, State: MutableTestCoreState{ - id: wasmlib.OBJ_ID_STATE, + proxy: wasmlib.NewStateProxy(), }, } ctx.Require(f.Params.Address().Exists(), "missing mandatory address") @@ -206,13 +202,13 @@ func funcRunRecursionThunk(ctx wasmlib.ScFuncContext) { ctx.Log("testcore.funcRunRecursion") f := &RunRecursionContext{ Params: ImmutableRunRecursionParams{ - id: wasmlib.OBJ_ID_PARAMS, + proxy: wasmlib.NewParamsProxy(), }, Results: MutableRunRecursionResults{ - id: wasmlib.OBJ_ID_RESULTS, + proxy: wasmlib.NewResultsProxy(), }, State: MutableTestCoreState{ - id: wasmlib.OBJ_ID_STATE, + proxy: wasmlib.NewStateProxy(), }, } ctx.Require(f.Params.IntValue().Exists(), "missing mandatory intValue") @@ -227,16 +223,16 @@ type SendToAddressContext struct { func funcSendToAddressThunk(ctx wasmlib.ScFuncContext) { ctx.Log("testcore.funcSendToAddress") - ctx.Require(ctx.Caller() == ctx.ContractCreator(), "no permission") - f := &SendToAddressContext{ Params: ImmutableSendToAddressParams{ - id: wasmlib.OBJ_ID_PARAMS, + proxy: wasmlib.NewParamsProxy(), }, State: MutableTestCoreState{ - id: wasmlib.OBJ_ID_STATE, + proxy: wasmlib.NewStateProxy(), }, } + ctx.Require(ctx.Caller() == ctx.ContractCreator(), "no permission") + ctx.Require(f.Params.Address().Exists(), "missing mandatory address") funcSendToAddress(ctx, f) ctx.Log("testcore.funcSendToAddress ok") @@ -251,10 +247,10 @@ func funcSetIntThunk(ctx wasmlib.ScFuncContext) { ctx.Log("testcore.funcSetInt") f := &SetIntContext{ Params: ImmutableSetIntParams{ - id: wasmlib.OBJ_ID_PARAMS, + proxy: wasmlib.NewParamsProxy(), }, State: MutableTestCoreState{ - id: wasmlib.OBJ_ID_STATE, + proxy: wasmlib.NewStateProxy(), }, } ctx.Require(f.Params.IntValue().Exists(), "missing mandatory intValue") @@ -272,10 +268,10 @@ func funcSpawnThunk(ctx wasmlib.ScFuncContext) { ctx.Log("testcore.funcSpawn") f := &SpawnContext{ Params: ImmutableSpawnParams{ - id: wasmlib.OBJ_ID_PARAMS, + proxy: wasmlib.NewParamsProxy(), }, State: MutableTestCoreState{ - id: wasmlib.OBJ_ID_STATE, + proxy: wasmlib.NewStateProxy(), }, } ctx.Require(f.Params.ProgHash().Exists(), "missing mandatory progHash") @@ -291,7 +287,7 @@ func funcTestBlockContext1Thunk(ctx wasmlib.ScFuncContext) { ctx.Log("testcore.funcTestBlockContext1") f := &TestBlockContext1Context{ State: MutableTestCoreState{ - id: wasmlib.OBJ_ID_STATE, + proxy: wasmlib.NewStateProxy(), }, } funcTestBlockContext1(ctx, f) @@ -306,7 +302,7 @@ func funcTestBlockContext2Thunk(ctx wasmlib.ScFuncContext) { ctx.Log("testcore.funcTestBlockContext2") f := &TestBlockContext2Context{ State: MutableTestCoreState{ - id: wasmlib.OBJ_ID_STATE, + proxy: wasmlib.NewStateProxy(), }, } funcTestBlockContext2(ctx, f) @@ -321,7 +317,7 @@ func funcTestCallPanicFullEPThunk(ctx wasmlib.ScFuncContext) { ctx.Log("testcore.funcTestCallPanicFullEP") f := &TestCallPanicFullEPContext{ State: MutableTestCoreState{ - id: wasmlib.OBJ_ID_STATE, + proxy: wasmlib.NewStateProxy(), }, } funcTestCallPanicFullEP(ctx, f) @@ -336,7 +332,7 @@ func funcTestCallPanicViewEPFromFullThunk(ctx wasmlib.ScFuncContext) { ctx.Log("testcore.funcTestCallPanicViewEPFromFull") f := &TestCallPanicViewEPFromFullContext{ State: MutableTestCoreState{ - id: wasmlib.OBJ_ID_STATE, + proxy: wasmlib.NewStateProxy(), }, } funcTestCallPanicViewEPFromFull(ctx, f) @@ -352,10 +348,10 @@ func funcTestChainOwnerIDFullThunk(ctx wasmlib.ScFuncContext) { ctx.Log("testcore.funcTestChainOwnerIDFull") f := &TestChainOwnerIDFullContext{ Results: MutableTestChainOwnerIDFullResults{ - id: wasmlib.OBJ_ID_RESULTS, + proxy: wasmlib.NewResultsProxy(), }, State: MutableTestCoreState{ - id: wasmlib.OBJ_ID_STATE, + proxy: wasmlib.NewStateProxy(), }, } funcTestChainOwnerIDFull(ctx, f) @@ -370,7 +366,7 @@ func funcTestEventLogDeployThunk(ctx wasmlib.ScFuncContext) { ctx.Log("testcore.funcTestEventLogDeploy") f := &TestEventLogDeployContext{ State: MutableTestCoreState{ - id: wasmlib.OBJ_ID_STATE, + proxy: wasmlib.NewStateProxy(), }, } funcTestEventLogDeploy(ctx, f) @@ -385,7 +381,7 @@ func funcTestEventLogEventDataThunk(ctx wasmlib.ScFuncContext) { ctx.Log("testcore.funcTestEventLogEventData") f := &TestEventLogEventDataContext{ State: MutableTestCoreState{ - id: wasmlib.OBJ_ID_STATE, + proxy: wasmlib.NewStateProxy(), }, } funcTestEventLogEventData(ctx, f) @@ -401,10 +397,10 @@ func funcTestEventLogGenericDataThunk(ctx wasmlib.ScFuncContext) { ctx.Log("testcore.funcTestEventLogGenericData") f := &TestEventLogGenericDataContext{ Params: ImmutableTestEventLogGenericDataParams{ - id: wasmlib.OBJ_ID_PARAMS, + proxy: wasmlib.NewParamsProxy(), }, State: MutableTestCoreState{ - id: wasmlib.OBJ_ID_STATE, + proxy: wasmlib.NewStateProxy(), }, } ctx.Require(f.Params.Counter().Exists(), "missing mandatory counter") @@ -420,7 +416,7 @@ func funcTestPanicFullEPThunk(ctx wasmlib.ScFuncContext) { ctx.Log("testcore.funcTestPanicFullEP") f := &TestPanicFullEPContext{ State: MutableTestCoreState{ - id: wasmlib.OBJ_ID_STATE, + proxy: wasmlib.NewStateProxy(), }, } funcTestPanicFullEP(ctx, f) @@ -436,10 +432,10 @@ func funcWithdrawToChainThunk(ctx wasmlib.ScFuncContext) { ctx.Log("testcore.funcWithdrawToChain") f := &WithdrawToChainContext{ Params: ImmutableWithdrawToChainParams{ - id: wasmlib.OBJ_ID_PARAMS, + proxy: wasmlib.NewParamsProxy(), }, State: MutableTestCoreState{ - id: wasmlib.OBJ_ID_STATE, + proxy: wasmlib.NewStateProxy(), }, } ctx.Require(f.Params.ChainID().Exists(), "missing mandatory chainID") @@ -456,10 +452,10 @@ func viewCheckContextFromViewEPThunk(ctx wasmlib.ScViewContext) { ctx.Log("testcore.viewCheckContextFromViewEP") f := &CheckContextFromViewEPContext{ Params: ImmutableCheckContextFromViewEPParams{ - id: wasmlib.OBJ_ID_PARAMS, + proxy: wasmlib.NewParamsProxy(), }, State: ImmutableTestCoreState{ - id: wasmlib.OBJ_ID_STATE, + proxy: wasmlib.NewStateProxy(), }, } ctx.Require(f.Params.AgentID().Exists(), "missing mandatory agentID") @@ -480,13 +476,13 @@ func viewFibonacciThunk(ctx wasmlib.ScViewContext) { ctx.Log("testcore.viewFibonacci") f := &FibonacciContext{ Params: ImmutableFibonacciParams{ - id: wasmlib.OBJ_ID_PARAMS, + proxy: wasmlib.NewParamsProxy(), }, Results: MutableFibonacciResults{ - id: wasmlib.OBJ_ID_RESULTS, + proxy: wasmlib.NewResultsProxy(), }, State: ImmutableTestCoreState{ - id: wasmlib.OBJ_ID_STATE, + proxy: wasmlib.NewStateProxy(), }, } ctx.Require(f.Params.IntValue().Exists(), "missing mandatory intValue") @@ -503,10 +499,10 @@ func viewGetCounterThunk(ctx wasmlib.ScViewContext) { ctx.Log("testcore.viewGetCounter") f := &GetCounterContext{ Results: MutableGetCounterResults{ - id: wasmlib.OBJ_ID_RESULTS, + proxy: wasmlib.NewResultsProxy(), }, State: ImmutableTestCoreState{ - id: wasmlib.OBJ_ID_STATE, + proxy: wasmlib.NewStateProxy(), }, } viewGetCounter(ctx, f) @@ -523,13 +519,13 @@ func viewGetIntThunk(ctx wasmlib.ScViewContext) { ctx.Log("testcore.viewGetInt") f := &GetIntContext{ Params: ImmutableGetIntParams{ - id: wasmlib.OBJ_ID_PARAMS, + proxy: wasmlib.NewParamsProxy(), }, Results: MutableGetIntResults{ - id: wasmlib.OBJ_ID_RESULTS, + proxy: wasmlib.NewResultsProxy(), }, State: ImmutableTestCoreState{ - id: wasmlib.OBJ_ID_STATE, + proxy: wasmlib.NewStateProxy(), }, } ctx.Require(f.Params.Name().Exists(), "missing mandatory name") @@ -547,13 +543,13 @@ func viewGetStringValueThunk(ctx wasmlib.ScViewContext) { ctx.Log("testcore.viewGetStringValue") f := &GetStringValueContext{ Params: ImmutableGetStringValueParams{ - id: wasmlib.OBJ_ID_PARAMS, + proxy: wasmlib.NewParamsProxy(), }, Results: MutableGetStringValueResults{ - id: wasmlib.OBJ_ID_RESULTS, + proxy: wasmlib.NewResultsProxy(), }, State: ImmutableTestCoreState{ - id: wasmlib.OBJ_ID_STATE, + proxy: wasmlib.NewStateProxy(), }, } ctx.Require(f.Params.VarName().Exists(), "missing mandatory varName") @@ -569,7 +565,7 @@ func viewJustViewThunk(ctx wasmlib.ScViewContext) { ctx.Log("testcore.viewJustView") f := &JustViewContext{ State: ImmutableTestCoreState{ - id: wasmlib.OBJ_ID_STATE, + proxy: wasmlib.NewStateProxy(), }, } viewJustView(ctx, f) @@ -585,10 +581,10 @@ func viewPassTypesViewThunk(ctx wasmlib.ScViewContext) { ctx.Log("testcore.viewPassTypesView") f := &PassTypesViewContext{ Params: ImmutablePassTypesViewParams{ - id: wasmlib.OBJ_ID_PARAMS, + proxy: wasmlib.NewParamsProxy(), }, State: ImmutableTestCoreState{ - id: wasmlib.OBJ_ID_STATE, + proxy: wasmlib.NewStateProxy(), }, } ctx.Require(f.Params.Address().Exists(), "missing mandatory address") @@ -614,7 +610,7 @@ func viewTestCallPanicViewEPFromViewThunk(ctx wasmlib.ScViewContext) { ctx.Log("testcore.viewTestCallPanicViewEPFromView") f := &TestCallPanicViewEPFromViewContext{ State: ImmutableTestCoreState{ - id: wasmlib.OBJ_ID_STATE, + proxy: wasmlib.NewStateProxy(), }, } viewTestCallPanicViewEPFromView(ctx, f) @@ -630,10 +626,10 @@ func viewTestChainOwnerIDViewThunk(ctx wasmlib.ScViewContext) { ctx.Log("testcore.viewTestChainOwnerIDView") f := &TestChainOwnerIDViewContext{ Results: MutableTestChainOwnerIDViewResults{ - id: wasmlib.OBJ_ID_RESULTS, + proxy: wasmlib.NewResultsProxy(), }, State: ImmutableTestCoreState{ - id: wasmlib.OBJ_ID_STATE, + proxy: wasmlib.NewStateProxy(), }, } viewTestChainOwnerIDView(ctx, f) @@ -648,7 +644,7 @@ func viewTestPanicViewEPThunk(ctx wasmlib.ScViewContext) { ctx.Log("testcore.viewTestPanicViewEP") f := &TestPanicViewEPContext{ State: ImmutableTestCoreState{ - id: wasmlib.OBJ_ID_STATE, + proxy: wasmlib.NewStateProxy(), }, } viewTestPanicViewEP(ctx, f) @@ -664,10 +660,10 @@ func viewTestSandboxCallThunk(ctx wasmlib.ScViewContext) { ctx.Log("testcore.viewTestSandboxCall") f := &TestSandboxCallContext{ Results: MutableTestSandboxCallResults{ - id: wasmlib.OBJ_ID_RESULTS, + proxy: wasmlib.NewResultsProxy(), }, State: ImmutableTestCoreState{ - id: wasmlib.OBJ_ID_STATE, + proxy: wasmlib.NewStateProxy(), }, } viewTestSandboxCall(ctx, f) diff --git a/contracts/wasm/testcore/go/testcore/params.go b/contracts/wasm/testcore/go/testcore/params.go index d72858d871..865ad90bcc 100644 --- a/contracts/wasm/testcore/go/testcore/params.go +++ b/contracts/wasm/testcore/go/testcore/params.go @@ -7,484 +7,484 @@ package testcore -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" +import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" type ImmutableCallOnChainParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableCallOnChainParams) HnameContract() wasmlib.ScImmutableHname { - return wasmlib.NewScImmutableHname(s.id, wasmlib.KeyID(ParamHnameContract)) +func (s ImmutableCallOnChainParams) HnameContract() wasmtypes.ScImmutableHname { + return wasmtypes.NewScImmutableHname(s.proxy.Root(ParamHnameContract)) } -func (s ImmutableCallOnChainParams) HnameEP() wasmlib.ScImmutableHname { - return wasmlib.NewScImmutableHname(s.id, wasmlib.KeyID(ParamHnameEP)) +func (s ImmutableCallOnChainParams) HnameEP() wasmtypes.ScImmutableHname { + return wasmtypes.NewScImmutableHname(s.proxy.Root(ParamHnameEP)) } -func (s ImmutableCallOnChainParams) IntValue() wasmlib.ScImmutableInt64 { - return wasmlib.NewScImmutableInt64(s.id, wasmlib.KeyID(ParamIntValue)) +func (s ImmutableCallOnChainParams) IntValue() wasmtypes.ScImmutableInt64 { + return wasmtypes.NewScImmutableInt64(s.proxy.Root(ParamIntValue)) } type MutableCallOnChainParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableCallOnChainParams) HnameContract() wasmlib.ScMutableHname { - return wasmlib.NewScMutableHname(s.id, wasmlib.KeyID(ParamHnameContract)) +func (s MutableCallOnChainParams) HnameContract() wasmtypes.ScMutableHname { + return wasmtypes.NewScMutableHname(s.proxy.Root(ParamHnameContract)) } -func (s MutableCallOnChainParams) HnameEP() wasmlib.ScMutableHname { - return wasmlib.NewScMutableHname(s.id, wasmlib.KeyID(ParamHnameEP)) +func (s MutableCallOnChainParams) HnameEP() wasmtypes.ScMutableHname { + return wasmtypes.NewScMutableHname(s.proxy.Root(ParamHnameEP)) } -func (s MutableCallOnChainParams) IntValue() wasmlib.ScMutableInt64 { - return wasmlib.NewScMutableInt64(s.id, wasmlib.KeyID(ParamIntValue)) +func (s MutableCallOnChainParams) IntValue() wasmtypes.ScMutableInt64 { + return wasmtypes.NewScMutableInt64(s.proxy.Root(ParamIntValue)) } type ImmutableCheckContextFromFullEPParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableCheckContextFromFullEPParams) AgentID() wasmlib.ScImmutableAgentID { - return wasmlib.NewScImmutableAgentID(s.id, wasmlib.KeyID(ParamAgentID)) +func (s ImmutableCheckContextFromFullEPParams) AgentID() wasmtypes.ScImmutableAgentID { + return wasmtypes.NewScImmutableAgentID(s.proxy.Root(ParamAgentID)) } -func (s ImmutableCheckContextFromFullEPParams) Caller() wasmlib.ScImmutableAgentID { - return wasmlib.NewScImmutableAgentID(s.id, wasmlib.KeyID(ParamCaller)) +func (s ImmutableCheckContextFromFullEPParams) Caller() wasmtypes.ScImmutableAgentID { + return wasmtypes.NewScImmutableAgentID(s.proxy.Root(ParamCaller)) } -func (s ImmutableCheckContextFromFullEPParams) ChainID() wasmlib.ScImmutableChainID { - return wasmlib.NewScImmutableChainID(s.id, wasmlib.KeyID(ParamChainID)) +func (s ImmutableCheckContextFromFullEPParams) ChainID() wasmtypes.ScImmutableChainID { + return wasmtypes.NewScImmutableChainID(s.proxy.Root(ParamChainID)) } -func (s ImmutableCheckContextFromFullEPParams) ChainOwnerID() wasmlib.ScImmutableAgentID { - return wasmlib.NewScImmutableAgentID(s.id, wasmlib.KeyID(ParamChainOwnerID)) +func (s ImmutableCheckContextFromFullEPParams) ChainOwnerID() wasmtypes.ScImmutableAgentID { + return wasmtypes.NewScImmutableAgentID(s.proxy.Root(ParamChainOwnerID)) } -func (s ImmutableCheckContextFromFullEPParams) ContractCreator() wasmlib.ScImmutableAgentID { - return wasmlib.NewScImmutableAgentID(s.id, wasmlib.KeyID(ParamContractCreator)) +func (s ImmutableCheckContextFromFullEPParams) ContractCreator() wasmtypes.ScImmutableAgentID { + return wasmtypes.NewScImmutableAgentID(s.proxy.Root(ParamContractCreator)) } type MutableCheckContextFromFullEPParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableCheckContextFromFullEPParams) AgentID() wasmlib.ScMutableAgentID { - return wasmlib.NewScMutableAgentID(s.id, wasmlib.KeyID(ParamAgentID)) +func (s MutableCheckContextFromFullEPParams) AgentID() wasmtypes.ScMutableAgentID { + return wasmtypes.NewScMutableAgentID(s.proxy.Root(ParamAgentID)) } -func (s MutableCheckContextFromFullEPParams) Caller() wasmlib.ScMutableAgentID { - return wasmlib.NewScMutableAgentID(s.id, wasmlib.KeyID(ParamCaller)) +func (s MutableCheckContextFromFullEPParams) Caller() wasmtypes.ScMutableAgentID { + return wasmtypes.NewScMutableAgentID(s.proxy.Root(ParamCaller)) } -func (s MutableCheckContextFromFullEPParams) ChainID() wasmlib.ScMutableChainID { - return wasmlib.NewScMutableChainID(s.id, wasmlib.KeyID(ParamChainID)) +func (s MutableCheckContextFromFullEPParams) ChainID() wasmtypes.ScMutableChainID { + return wasmtypes.NewScMutableChainID(s.proxy.Root(ParamChainID)) } -func (s MutableCheckContextFromFullEPParams) ChainOwnerID() wasmlib.ScMutableAgentID { - return wasmlib.NewScMutableAgentID(s.id, wasmlib.KeyID(ParamChainOwnerID)) +func (s MutableCheckContextFromFullEPParams) ChainOwnerID() wasmtypes.ScMutableAgentID { + return wasmtypes.NewScMutableAgentID(s.proxy.Root(ParamChainOwnerID)) } -func (s MutableCheckContextFromFullEPParams) ContractCreator() wasmlib.ScMutableAgentID { - return wasmlib.NewScMutableAgentID(s.id, wasmlib.KeyID(ParamContractCreator)) +func (s MutableCheckContextFromFullEPParams) ContractCreator() wasmtypes.ScMutableAgentID { + return wasmtypes.NewScMutableAgentID(s.proxy.Root(ParamContractCreator)) } type ImmutableInitParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableInitParams) Fail() wasmlib.ScImmutableInt64 { - return wasmlib.NewScImmutableInt64(s.id, idxMap[IdxParamFail]) +func (s ImmutableInitParams) Fail() wasmtypes.ScImmutableInt64 { + return wasmtypes.NewScImmutableInt64(s.proxy.Root(ParamFail)) } type MutableInitParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableInitParams) Fail() wasmlib.ScMutableInt64 { - return wasmlib.NewScMutableInt64(s.id, idxMap[IdxParamFail]) +func (s MutableInitParams) Fail() wasmtypes.ScMutableInt64 { + return wasmtypes.NewScMutableInt64(s.proxy.Root(ParamFail)) } type ImmutablePassTypesFullParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutablePassTypesFullParams) Address() wasmlib.ScImmutableAddress { - return wasmlib.NewScImmutableAddress(s.id, wasmlib.KeyID(ParamAddress)) +func (s ImmutablePassTypesFullParams) Address() wasmtypes.ScImmutableAddress { + return wasmtypes.NewScImmutableAddress(s.proxy.Root(ParamAddress)) } -func (s ImmutablePassTypesFullParams) AgentID() wasmlib.ScImmutableAgentID { - return wasmlib.NewScImmutableAgentID(s.id, wasmlib.KeyID(ParamAgentID)) +func (s ImmutablePassTypesFullParams) AgentID() wasmtypes.ScImmutableAgentID { + return wasmtypes.NewScImmutableAgentID(s.proxy.Root(ParamAgentID)) } -func (s ImmutablePassTypesFullParams) ChainID() wasmlib.ScImmutableChainID { - return wasmlib.NewScImmutableChainID(s.id, wasmlib.KeyID(ParamChainID)) +func (s ImmutablePassTypesFullParams) ChainID() wasmtypes.ScImmutableChainID { + return wasmtypes.NewScImmutableChainID(s.proxy.Root(ParamChainID)) } -func (s ImmutablePassTypesFullParams) ContractID() wasmlib.ScImmutableAgentID { - return wasmlib.NewScImmutableAgentID(s.id, wasmlib.KeyID(ParamContractID)) +func (s ImmutablePassTypesFullParams) ContractID() wasmtypes.ScImmutableAgentID { + return wasmtypes.NewScImmutableAgentID(s.proxy.Root(ParamContractID)) } -func (s ImmutablePassTypesFullParams) Hash() wasmlib.ScImmutableHash { - return wasmlib.NewScImmutableHash(s.id, wasmlib.KeyID(ParamHash)) +func (s ImmutablePassTypesFullParams) Hash() wasmtypes.ScImmutableHash { + return wasmtypes.NewScImmutableHash(s.proxy.Root(ParamHash)) } -func (s ImmutablePassTypesFullParams) Hname() wasmlib.ScImmutableHname { - return wasmlib.NewScImmutableHname(s.id, wasmlib.KeyID(ParamHname)) +func (s ImmutablePassTypesFullParams) Hname() wasmtypes.ScImmutableHname { + return wasmtypes.NewScImmutableHname(s.proxy.Root(ParamHname)) } -func (s ImmutablePassTypesFullParams) HnameZero() wasmlib.ScImmutableHname { - return wasmlib.NewScImmutableHname(s.id, wasmlib.KeyID(ParamHnameZero)) +func (s ImmutablePassTypesFullParams) HnameZero() wasmtypes.ScImmutableHname { + return wasmtypes.NewScImmutableHname(s.proxy.Root(ParamHnameZero)) } -func (s ImmutablePassTypesFullParams) Int64() wasmlib.ScImmutableInt64 { - return wasmlib.NewScImmutableInt64(s.id, wasmlib.KeyID(ParamInt64)) +func (s ImmutablePassTypesFullParams) Int64() wasmtypes.ScImmutableInt64 { + return wasmtypes.NewScImmutableInt64(s.proxy.Root(ParamInt64)) } -func (s ImmutablePassTypesFullParams) Int64Zero() wasmlib.ScImmutableInt64 { - return wasmlib.NewScImmutableInt64(s.id, wasmlib.KeyID(ParamInt64Zero)) +func (s ImmutablePassTypesFullParams) Int64Zero() wasmtypes.ScImmutableInt64 { + return wasmtypes.NewScImmutableInt64(s.proxy.Root(ParamInt64Zero)) } -func (s ImmutablePassTypesFullParams) String() wasmlib.ScImmutableString { - return wasmlib.NewScImmutableString(s.id, wasmlib.KeyID(ParamString)) +func (s ImmutablePassTypesFullParams) String() wasmtypes.ScImmutableString { + return wasmtypes.NewScImmutableString(s.proxy.Root(ParamString)) } -func (s ImmutablePassTypesFullParams) StringZero() wasmlib.ScImmutableString { - return wasmlib.NewScImmutableString(s.id, wasmlib.KeyID(ParamStringZero)) +func (s ImmutablePassTypesFullParams) StringZero() wasmtypes.ScImmutableString { + return wasmtypes.NewScImmutableString(s.proxy.Root(ParamStringZero)) } type MutablePassTypesFullParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutablePassTypesFullParams) Address() wasmlib.ScMutableAddress { - return wasmlib.NewScMutableAddress(s.id, wasmlib.KeyID(ParamAddress)) +func (s MutablePassTypesFullParams) Address() wasmtypes.ScMutableAddress { + return wasmtypes.NewScMutableAddress(s.proxy.Root(ParamAddress)) } -func (s MutablePassTypesFullParams) AgentID() wasmlib.ScMutableAgentID { - return wasmlib.NewScMutableAgentID(s.id, wasmlib.KeyID(ParamAgentID)) +func (s MutablePassTypesFullParams) AgentID() wasmtypes.ScMutableAgentID { + return wasmtypes.NewScMutableAgentID(s.proxy.Root(ParamAgentID)) } -func (s MutablePassTypesFullParams) ChainID() wasmlib.ScMutableChainID { - return wasmlib.NewScMutableChainID(s.id, wasmlib.KeyID(ParamChainID)) +func (s MutablePassTypesFullParams) ChainID() wasmtypes.ScMutableChainID { + return wasmtypes.NewScMutableChainID(s.proxy.Root(ParamChainID)) } -func (s MutablePassTypesFullParams) ContractID() wasmlib.ScMutableAgentID { - return wasmlib.NewScMutableAgentID(s.id, wasmlib.KeyID(ParamContractID)) +func (s MutablePassTypesFullParams) ContractID() wasmtypes.ScMutableAgentID { + return wasmtypes.NewScMutableAgentID(s.proxy.Root(ParamContractID)) } -func (s MutablePassTypesFullParams) Hash() wasmlib.ScMutableHash { - return wasmlib.NewScMutableHash(s.id, wasmlib.KeyID(ParamHash)) +func (s MutablePassTypesFullParams) Hash() wasmtypes.ScMutableHash { + return wasmtypes.NewScMutableHash(s.proxy.Root(ParamHash)) } -func (s MutablePassTypesFullParams) Hname() wasmlib.ScMutableHname { - return wasmlib.NewScMutableHname(s.id, wasmlib.KeyID(ParamHname)) +func (s MutablePassTypesFullParams) Hname() wasmtypes.ScMutableHname { + return wasmtypes.NewScMutableHname(s.proxy.Root(ParamHname)) } -func (s MutablePassTypesFullParams) HnameZero() wasmlib.ScMutableHname { - return wasmlib.NewScMutableHname(s.id, wasmlib.KeyID(ParamHnameZero)) +func (s MutablePassTypesFullParams) HnameZero() wasmtypes.ScMutableHname { + return wasmtypes.NewScMutableHname(s.proxy.Root(ParamHnameZero)) } -func (s MutablePassTypesFullParams) Int64() wasmlib.ScMutableInt64 { - return wasmlib.NewScMutableInt64(s.id, wasmlib.KeyID(ParamInt64)) +func (s MutablePassTypesFullParams) Int64() wasmtypes.ScMutableInt64 { + return wasmtypes.NewScMutableInt64(s.proxy.Root(ParamInt64)) } -func (s MutablePassTypesFullParams) Int64Zero() wasmlib.ScMutableInt64 { - return wasmlib.NewScMutableInt64(s.id, wasmlib.KeyID(ParamInt64Zero)) +func (s MutablePassTypesFullParams) Int64Zero() wasmtypes.ScMutableInt64 { + return wasmtypes.NewScMutableInt64(s.proxy.Root(ParamInt64Zero)) } -func (s MutablePassTypesFullParams) String() wasmlib.ScMutableString { - return wasmlib.NewScMutableString(s.id, wasmlib.KeyID(ParamString)) +func (s MutablePassTypesFullParams) String() wasmtypes.ScMutableString { + return wasmtypes.NewScMutableString(s.proxy.Root(ParamString)) } -func (s MutablePassTypesFullParams) StringZero() wasmlib.ScMutableString { - return wasmlib.NewScMutableString(s.id, wasmlib.KeyID(ParamStringZero)) +func (s MutablePassTypesFullParams) StringZero() wasmtypes.ScMutableString { + return wasmtypes.NewScMutableString(s.proxy.Root(ParamStringZero)) } type ImmutableRunRecursionParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableRunRecursionParams) IntValue() wasmlib.ScImmutableInt64 { - return wasmlib.NewScImmutableInt64(s.id, wasmlib.KeyID(ParamIntValue)) +func (s ImmutableRunRecursionParams) IntValue() wasmtypes.ScImmutableInt64 { + return wasmtypes.NewScImmutableInt64(s.proxy.Root(ParamIntValue)) } type MutableRunRecursionParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableRunRecursionParams) IntValue() wasmlib.ScMutableInt64 { - return wasmlib.NewScMutableInt64(s.id, wasmlib.KeyID(ParamIntValue)) +func (s MutableRunRecursionParams) IntValue() wasmtypes.ScMutableInt64 { + return wasmtypes.NewScMutableInt64(s.proxy.Root(ParamIntValue)) } type ImmutableSendToAddressParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableSendToAddressParams) Address() wasmlib.ScImmutableAddress { - return wasmlib.NewScImmutableAddress(s.id, wasmlib.KeyID(ParamAddress)) +func (s ImmutableSendToAddressParams) Address() wasmtypes.ScImmutableAddress { + return wasmtypes.NewScImmutableAddress(s.proxy.Root(ParamAddress)) } type MutableSendToAddressParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableSendToAddressParams) Address() wasmlib.ScMutableAddress { - return wasmlib.NewScMutableAddress(s.id, wasmlib.KeyID(ParamAddress)) +func (s MutableSendToAddressParams) Address() wasmtypes.ScMutableAddress { + return wasmtypes.NewScMutableAddress(s.proxy.Root(ParamAddress)) } type ImmutableSetIntParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableSetIntParams) IntValue() wasmlib.ScImmutableInt64 { - return wasmlib.NewScImmutableInt64(s.id, wasmlib.KeyID(ParamIntValue)) +func (s ImmutableSetIntParams) IntValue() wasmtypes.ScImmutableInt64 { + return wasmtypes.NewScImmutableInt64(s.proxy.Root(ParamIntValue)) } -func (s ImmutableSetIntParams) Name() wasmlib.ScImmutableString { - return wasmlib.NewScImmutableString(s.id, wasmlib.KeyID(ParamName)) +func (s ImmutableSetIntParams) Name() wasmtypes.ScImmutableString { + return wasmtypes.NewScImmutableString(s.proxy.Root(ParamName)) } type MutableSetIntParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableSetIntParams) IntValue() wasmlib.ScMutableInt64 { - return wasmlib.NewScMutableInt64(s.id, wasmlib.KeyID(ParamIntValue)) +func (s MutableSetIntParams) IntValue() wasmtypes.ScMutableInt64 { + return wasmtypes.NewScMutableInt64(s.proxy.Root(ParamIntValue)) } -func (s MutableSetIntParams) Name() wasmlib.ScMutableString { - return wasmlib.NewScMutableString(s.id, wasmlib.KeyID(ParamName)) +func (s MutableSetIntParams) Name() wasmtypes.ScMutableString { + return wasmtypes.NewScMutableString(s.proxy.Root(ParamName)) } type ImmutableSpawnParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableSpawnParams) ProgHash() wasmlib.ScImmutableHash { - return wasmlib.NewScImmutableHash(s.id, wasmlib.KeyID(ParamProgHash)) +func (s ImmutableSpawnParams) ProgHash() wasmtypes.ScImmutableHash { + return wasmtypes.NewScImmutableHash(s.proxy.Root(ParamProgHash)) } type MutableSpawnParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableSpawnParams) ProgHash() wasmlib.ScMutableHash { - return wasmlib.NewScMutableHash(s.id, wasmlib.KeyID(ParamProgHash)) +func (s MutableSpawnParams) ProgHash() wasmtypes.ScMutableHash { + return wasmtypes.NewScMutableHash(s.proxy.Root(ParamProgHash)) } type ImmutableTestEventLogGenericDataParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableTestEventLogGenericDataParams) Counter() wasmlib.ScImmutableInt64 { - return wasmlib.NewScImmutableInt64(s.id, wasmlib.KeyID(ParamCounter)) +func (s ImmutableTestEventLogGenericDataParams) Counter() wasmtypes.ScImmutableInt64 { + return wasmtypes.NewScImmutableInt64(s.proxy.Root(ParamCounter)) } type MutableTestEventLogGenericDataParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableTestEventLogGenericDataParams) Counter() wasmlib.ScMutableInt64 { - return wasmlib.NewScMutableInt64(s.id, wasmlib.KeyID(ParamCounter)) +func (s MutableTestEventLogGenericDataParams) Counter() wasmtypes.ScMutableInt64 { + return wasmtypes.NewScMutableInt64(s.proxy.Root(ParamCounter)) } type ImmutableWithdrawToChainParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableWithdrawToChainParams) ChainID() wasmlib.ScImmutableChainID { - return wasmlib.NewScImmutableChainID(s.id, wasmlib.KeyID(ParamChainID)) +func (s ImmutableWithdrawToChainParams) ChainID() wasmtypes.ScImmutableChainID { + return wasmtypes.NewScImmutableChainID(s.proxy.Root(ParamChainID)) } type MutableWithdrawToChainParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableWithdrawToChainParams) ChainID() wasmlib.ScMutableChainID { - return wasmlib.NewScMutableChainID(s.id, wasmlib.KeyID(ParamChainID)) +func (s MutableWithdrawToChainParams) ChainID() wasmtypes.ScMutableChainID { + return wasmtypes.NewScMutableChainID(s.proxy.Root(ParamChainID)) } type ImmutableCheckContextFromViewEPParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableCheckContextFromViewEPParams) AgentID() wasmlib.ScImmutableAgentID { - return wasmlib.NewScImmutableAgentID(s.id, wasmlib.KeyID(ParamAgentID)) +func (s ImmutableCheckContextFromViewEPParams) AgentID() wasmtypes.ScImmutableAgentID { + return wasmtypes.NewScImmutableAgentID(s.proxy.Root(ParamAgentID)) } -func (s ImmutableCheckContextFromViewEPParams) ChainID() wasmlib.ScImmutableChainID { - return wasmlib.NewScImmutableChainID(s.id, wasmlib.KeyID(ParamChainID)) +func (s ImmutableCheckContextFromViewEPParams) ChainID() wasmtypes.ScImmutableChainID { + return wasmtypes.NewScImmutableChainID(s.proxy.Root(ParamChainID)) } -func (s ImmutableCheckContextFromViewEPParams) ChainOwnerID() wasmlib.ScImmutableAgentID { - return wasmlib.NewScImmutableAgentID(s.id, wasmlib.KeyID(ParamChainOwnerID)) +func (s ImmutableCheckContextFromViewEPParams) ChainOwnerID() wasmtypes.ScImmutableAgentID { + return wasmtypes.NewScImmutableAgentID(s.proxy.Root(ParamChainOwnerID)) } -func (s ImmutableCheckContextFromViewEPParams) ContractCreator() wasmlib.ScImmutableAgentID { - return wasmlib.NewScImmutableAgentID(s.id, wasmlib.KeyID(ParamContractCreator)) +func (s ImmutableCheckContextFromViewEPParams) ContractCreator() wasmtypes.ScImmutableAgentID { + return wasmtypes.NewScImmutableAgentID(s.proxy.Root(ParamContractCreator)) } type MutableCheckContextFromViewEPParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableCheckContextFromViewEPParams) AgentID() wasmlib.ScMutableAgentID { - return wasmlib.NewScMutableAgentID(s.id, wasmlib.KeyID(ParamAgentID)) +func (s MutableCheckContextFromViewEPParams) AgentID() wasmtypes.ScMutableAgentID { + return wasmtypes.NewScMutableAgentID(s.proxy.Root(ParamAgentID)) } -func (s MutableCheckContextFromViewEPParams) ChainID() wasmlib.ScMutableChainID { - return wasmlib.NewScMutableChainID(s.id, wasmlib.KeyID(ParamChainID)) +func (s MutableCheckContextFromViewEPParams) ChainID() wasmtypes.ScMutableChainID { + return wasmtypes.NewScMutableChainID(s.proxy.Root(ParamChainID)) } -func (s MutableCheckContextFromViewEPParams) ChainOwnerID() wasmlib.ScMutableAgentID { - return wasmlib.NewScMutableAgentID(s.id, wasmlib.KeyID(ParamChainOwnerID)) +func (s MutableCheckContextFromViewEPParams) ChainOwnerID() wasmtypes.ScMutableAgentID { + return wasmtypes.NewScMutableAgentID(s.proxy.Root(ParamChainOwnerID)) } -func (s MutableCheckContextFromViewEPParams) ContractCreator() wasmlib.ScMutableAgentID { - return wasmlib.NewScMutableAgentID(s.id, wasmlib.KeyID(ParamContractCreator)) +func (s MutableCheckContextFromViewEPParams) ContractCreator() wasmtypes.ScMutableAgentID { + return wasmtypes.NewScMutableAgentID(s.proxy.Root(ParamContractCreator)) } type ImmutableFibonacciParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableFibonacciParams) IntValue() wasmlib.ScImmutableInt64 { - return wasmlib.NewScImmutableInt64(s.id, wasmlib.KeyID(ParamIntValue)) +func (s ImmutableFibonacciParams) IntValue() wasmtypes.ScImmutableInt64 { + return wasmtypes.NewScImmutableInt64(s.proxy.Root(ParamIntValue)) } type MutableFibonacciParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableFibonacciParams) IntValue() wasmlib.ScMutableInt64 { - return wasmlib.NewScMutableInt64(s.id, wasmlib.KeyID(ParamIntValue)) +func (s MutableFibonacciParams) IntValue() wasmtypes.ScMutableInt64 { + return wasmtypes.NewScMutableInt64(s.proxy.Root(ParamIntValue)) } type ImmutableGetIntParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableGetIntParams) Name() wasmlib.ScImmutableString { - return wasmlib.NewScImmutableString(s.id, wasmlib.KeyID(ParamName)) +func (s ImmutableGetIntParams) Name() wasmtypes.ScImmutableString { + return wasmtypes.NewScImmutableString(s.proxy.Root(ParamName)) } type MutableGetIntParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableGetIntParams) Name() wasmlib.ScMutableString { - return wasmlib.NewScMutableString(s.id, wasmlib.KeyID(ParamName)) +func (s MutableGetIntParams) Name() wasmtypes.ScMutableString { + return wasmtypes.NewScMutableString(s.proxy.Root(ParamName)) } type ImmutableGetStringValueParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableGetStringValueParams) VarName() wasmlib.ScImmutableString { - return wasmlib.NewScImmutableString(s.id, wasmlib.KeyID(ParamVarName)) +func (s ImmutableGetStringValueParams) VarName() wasmtypes.ScImmutableString { + return wasmtypes.NewScImmutableString(s.proxy.Root(ParamVarName)) } type MutableGetStringValueParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableGetStringValueParams) VarName() wasmlib.ScMutableString { - return wasmlib.NewScMutableString(s.id, wasmlib.KeyID(ParamVarName)) +func (s MutableGetStringValueParams) VarName() wasmtypes.ScMutableString { + return wasmtypes.NewScMutableString(s.proxy.Root(ParamVarName)) } type ImmutablePassTypesViewParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutablePassTypesViewParams) Address() wasmlib.ScImmutableAddress { - return wasmlib.NewScImmutableAddress(s.id, wasmlib.KeyID(ParamAddress)) +func (s ImmutablePassTypesViewParams) Address() wasmtypes.ScImmutableAddress { + return wasmtypes.NewScImmutableAddress(s.proxy.Root(ParamAddress)) } -func (s ImmutablePassTypesViewParams) AgentID() wasmlib.ScImmutableAgentID { - return wasmlib.NewScImmutableAgentID(s.id, wasmlib.KeyID(ParamAgentID)) +func (s ImmutablePassTypesViewParams) AgentID() wasmtypes.ScImmutableAgentID { + return wasmtypes.NewScImmutableAgentID(s.proxy.Root(ParamAgentID)) } -func (s ImmutablePassTypesViewParams) ChainID() wasmlib.ScImmutableChainID { - return wasmlib.NewScImmutableChainID(s.id, wasmlib.KeyID(ParamChainID)) +func (s ImmutablePassTypesViewParams) ChainID() wasmtypes.ScImmutableChainID { + return wasmtypes.NewScImmutableChainID(s.proxy.Root(ParamChainID)) } -func (s ImmutablePassTypesViewParams) ContractID() wasmlib.ScImmutableAgentID { - return wasmlib.NewScImmutableAgentID(s.id, wasmlib.KeyID(ParamContractID)) +func (s ImmutablePassTypesViewParams) ContractID() wasmtypes.ScImmutableAgentID { + return wasmtypes.NewScImmutableAgentID(s.proxy.Root(ParamContractID)) } -func (s ImmutablePassTypesViewParams) Hash() wasmlib.ScImmutableHash { - return wasmlib.NewScImmutableHash(s.id, wasmlib.KeyID(ParamHash)) +func (s ImmutablePassTypesViewParams) Hash() wasmtypes.ScImmutableHash { + return wasmtypes.NewScImmutableHash(s.proxy.Root(ParamHash)) } -func (s ImmutablePassTypesViewParams) Hname() wasmlib.ScImmutableHname { - return wasmlib.NewScImmutableHname(s.id, wasmlib.KeyID(ParamHname)) +func (s ImmutablePassTypesViewParams) Hname() wasmtypes.ScImmutableHname { + return wasmtypes.NewScImmutableHname(s.proxy.Root(ParamHname)) } -func (s ImmutablePassTypesViewParams) HnameZero() wasmlib.ScImmutableHname { - return wasmlib.NewScImmutableHname(s.id, wasmlib.KeyID(ParamHnameZero)) +func (s ImmutablePassTypesViewParams) HnameZero() wasmtypes.ScImmutableHname { + return wasmtypes.NewScImmutableHname(s.proxy.Root(ParamHnameZero)) } -func (s ImmutablePassTypesViewParams) Int64() wasmlib.ScImmutableInt64 { - return wasmlib.NewScImmutableInt64(s.id, wasmlib.KeyID(ParamInt64)) +func (s ImmutablePassTypesViewParams) Int64() wasmtypes.ScImmutableInt64 { + return wasmtypes.NewScImmutableInt64(s.proxy.Root(ParamInt64)) } -func (s ImmutablePassTypesViewParams) Int64Zero() wasmlib.ScImmutableInt64 { - return wasmlib.NewScImmutableInt64(s.id, wasmlib.KeyID(ParamInt64Zero)) +func (s ImmutablePassTypesViewParams) Int64Zero() wasmtypes.ScImmutableInt64 { + return wasmtypes.NewScImmutableInt64(s.proxy.Root(ParamInt64Zero)) } -func (s ImmutablePassTypesViewParams) String() wasmlib.ScImmutableString { - return wasmlib.NewScImmutableString(s.id, wasmlib.KeyID(ParamString)) +func (s ImmutablePassTypesViewParams) String() wasmtypes.ScImmutableString { + return wasmtypes.NewScImmutableString(s.proxy.Root(ParamString)) } -func (s ImmutablePassTypesViewParams) StringZero() wasmlib.ScImmutableString { - return wasmlib.NewScImmutableString(s.id, wasmlib.KeyID(ParamStringZero)) +func (s ImmutablePassTypesViewParams) StringZero() wasmtypes.ScImmutableString { + return wasmtypes.NewScImmutableString(s.proxy.Root(ParamStringZero)) } type MutablePassTypesViewParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutablePassTypesViewParams) Address() wasmlib.ScMutableAddress { - return wasmlib.NewScMutableAddress(s.id, wasmlib.KeyID(ParamAddress)) +func (s MutablePassTypesViewParams) Address() wasmtypes.ScMutableAddress { + return wasmtypes.NewScMutableAddress(s.proxy.Root(ParamAddress)) } -func (s MutablePassTypesViewParams) AgentID() wasmlib.ScMutableAgentID { - return wasmlib.NewScMutableAgentID(s.id, wasmlib.KeyID(ParamAgentID)) +func (s MutablePassTypesViewParams) AgentID() wasmtypes.ScMutableAgentID { + return wasmtypes.NewScMutableAgentID(s.proxy.Root(ParamAgentID)) } -func (s MutablePassTypesViewParams) ChainID() wasmlib.ScMutableChainID { - return wasmlib.NewScMutableChainID(s.id, wasmlib.KeyID(ParamChainID)) +func (s MutablePassTypesViewParams) ChainID() wasmtypes.ScMutableChainID { + return wasmtypes.NewScMutableChainID(s.proxy.Root(ParamChainID)) } -func (s MutablePassTypesViewParams) ContractID() wasmlib.ScMutableAgentID { - return wasmlib.NewScMutableAgentID(s.id, wasmlib.KeyID(ParamContractID)) +func (s MutablePassTypesViewParams) ContractID() wasmtypes.ScMutableAgentID { + return wasmtypes.NewScMutableAgentID(s.proxy.Root(ParamContractID)) } -func (s MutablePassTypesViewParams) Hash() wasmlib.ScMutableHash { - return wasmlib.NewScMutableHash(s.id, wasmlib.KeyID(ParamHash)) +func (s MutablePassTypesViewParams) Hash() wasmtypes.ScMutableHash { + return wasmtypes.NewScMutableHash(s.proxy.Root(ParamHash)) } -func (s MutablePassTypesViewParams) Hname() wasmlib.ScMutableHname { - return wasmlib.NewScMutableHname(s.id, wasmlib.KeyID(ParamHname)) +func (s MutablePassTypesViewParams) Hname() wasmtypes.ScMutableHname { + return wasmtypes.NewScMutableHname(s.proxy.Root(ParamHname)) } -func (s MutablePassTypesViewParams) HnameZero() wasmlib.ScMutableHname { - return wasmlib.NewScMutableHname(s.id, wasmlib.KeyID(ParamHnameZero)) +func (s MutablePassTypesViewParams) HnameZero() wasmtypes.ScMutableHname { + return wasmtypes.NewScMutableHname(s.proxy.Root(ParamHnameZero)) } -func (s MutablePassTypesViewParams) Int64() wasmlib.ScMutableInt64 { - return wasmlib.NewScMutableInt64(s.id, wasmlib.KeyID(ParamInt64)) +func (s MutablePassTypesViewParams) Int64() wasmtypes.ScMutableInt64 { + return wasmtypes.NewScMutableInt64(s.proxy.Root(ParamInt64)) } -func (s MutablePassTypesViewParams) Int64Zero() wasmlib.ScMutableInt64 { - return wasmlib.NewScMutableInt64(s.id, wasmlib.KeyID(ParamInt64Zero)) +func (s MutablePassTypesViewParams) Int64Zero() wasmtypes.ScMutableInt64 { + return wasmtypes.NewScMutableInt64(s.proxy.Root(ParamInt64Zero)) } -func (s MutablePassTypesViewParams) String() wasmlib.ScMutableString { - return wasmlib.NewScMutableString(s.id, wasmlib.KeyID(ParamString)) +func (s MutablePassTypesViewParams) String() wasmtypes.ScMutableString { + return wasmtypes.NewScMutableString(s.proxy.Root(ParamString)) } -func (s MutablePassTypesViewParams) StringZero() wasmlib.ScMutableString { - return wasmlib.NewScMutableString(s.id, wasmlib.KeyID(ParamStringZero)) +func (s MutablePassTypesViewParams) StringZero() wasmtypes.ScMutableString { + return wasmtypes.NewScMutableString(s.proxy.Root(ParamStringZero)) } diff --git a/contracts/wasm/testcore/go/testcore/results.go b/contracts/wasm/testcore/go/testcore/results.go index 2d11e8178c..3a172984fd 100644 --- a/contracts/wasm/testcore/go/testcore/results.go +++ b/contracts/wasm/testcore/go/testcore/results.go @@ -7,212 +7,216 @@ package testcore -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" +import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" type ImmutableCallOnChainResults struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableCallOnChainResults) IntValue() wasmlib.ScImmutableInt64 { - return wasmlib.NewScImmutableInt64(s.id, wasmlib.KeyID(ResultIntValue)) +func (s ImmutableCallOnChainResults) IntValue() wasmtypes.ScImmutableInt64 { + return wasmtypes.NewScImmutableInt64(s.proxy.Root(ResultIntValue)) } type MutableCallOnChainResults struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableCallOnChainResults) IntValue() wasmlib.ScMutableInt64 { - return wasmlib.NewScMutableInt64(s.id, wasmlib.KeyID(ResultIntValue)) +func (s MutableCallOnChainResults) IntValue() wasmtypes.ScMutableInt64 { + return wasmtypes.NewScMutableInt64(s.proxy.Root(ResultIntValue)) } type ImmutableGetMintedSupplyResults struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableGetMintedSupplyResults) MintedColor() wasmlib.ScImmutableColor { - return wasmlib.NewScImmutableColor(s.id, wasmlib.KeyID(ResultMintedColor)) +func (s ImmutableGetMintedSupplyResults) MintedColor() wasmtypes.ScImmutableColor { + return wasmtypes.NewScImmutableColor(s.proxy.Root(ResultMintedColor)) } -func (s ImmutableGetMintedSupplyResults) MintedSupply() wasmlib.ScImmutableInt64 { - return wasmlib.NewScImmutableInt64(s.id, wasmlib.KeyID(ResultMintedSupply)) +func (s ImmutableGetMintedSupplyResults) MintedSupply() wasmtypes.ScImmutableUint64 { + return wasmtypes.NewScImmutableUint64(s.proxy.Root(ResultMintedSupply)) } type MutableGetMintedSupplyResults struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableGetMintedSupplyResults) MintedColor() wasmlib.ScMutableColor { - return wasmlib.NewScMutableColor(s.id, wasmlib.KeyID(ResultMintedColor)) +func (s MutableGetMintedSupplyResults) MintedColor() wasmtypes.ScMutableColor { + return wasmtypes.NewScMutableColor(s.proxy.Root(ResultMintedColor)) } -func (s MutableGetMintedSupplyResults) MintedSupply() wasmlib.ScMutableInt64 { - return wasmlib.NewScMutableInt64(s.id, wasmlib.KeyID(ResultMintedSupply)) +func (s MutableGetMintedSupplyResults) MintedSupply() wasmtypes.ScMutableUint64 { + return wasmtypes.NewScMutableUint64(s.proxy.Root(ResultMintedSupply)) } type ImmutableRunRecursionResults struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableRunRecursionResults) IntValue() wasmlib.ScImmutableInt64 { - return wasmlib.NewScImmutableInt64(s.id, wasmlib.KeyID(ResultIntValue)) +func (s ImmutableRunRecursionResults) IntValue() wasmtypes.ScImmutableInt64 { + return wasmtypes.NewScImmutableInt64(s.proxy.Root(ResultIntValue)) } type MutableRunRecursionResults struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableRunRecursionResults) IntValue() wasmlib.ScMutableInt64 { - return wasmlib.NewScMutableInt64(s.id, wasmlib.KeyID(ResultIntValue)) +func (s MutableRunRecursionResults) IntValue() wasmtypes.ScMutableInt64 { + return wasmtypes.NewScMutableInt64(s.proxy.Root(ResultIntValue)) } type ImmutableTestChainOwnerIDFullResults struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableTestChainOwnerIDFullResults) ChainOwnerID() wasmlib.ScImmutableAgentID { - return wasmlib.NewScImmutableAgentID(s.id, wasmlib.KeyID(ResultChainOwnerID)) +func (s ImmutableTestChainOwnerIDFullResults) ChainOwnerID() wasmtypes.ScImmutableAgentID { + return wasmtypes.NewScImmutableAgentID(s.proxy.Root(ResultChainOwnerID)) } type MutableTestChainOwnerIDFullResults struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableTestChainOwnerIDFullResults) ChainOwnerID() wasmlib.ScMutableAgentID { - return wasmlib.NewScMutableAgentID(s.id, wasmlib.KeyID(ResultChainOwnerID)) +func (s MutableTestChainOwnerIDFullResults) ChainOwnerID() wasmtypes.ScMutableAgentID { + return wasmtypes.NewScMutableAgentID(s.proxy.Root(ResultChainOwnerID)) } type ImmutableFibonacciResults struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableFibonacciResults) IntValue() wasmlib.ScImmutableInt64 { - return wasmlib.NewScImmutableInt64(s.id, wasmlib.KeyID(ResultIntValue)) +func (s ImmutableFibonacciResults) IntValue() wasmtypes.ScImmutableInt64 { + return wasmtypes.NewScImmutableInt64(s.proxy.Root(ResultIntValue)) } type MutableFibonacciResults struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableFibonacciResults) IntValue() wasmlib.ScMutableInt64 { - return wasmlib.NewScMutableInt64(s.id, wasmlib.KeyID(ResultIntValue)) +func (s MutableFibonacciResults) IntValue() wasmtypes.ScMutableInt64 { + return wasmtypes.NewScMutableInt64(s.proxy.Root(ResultIntValue)) } type ImmutableGetCounterResults struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableGetCounterResults) Counter() wasmlib.ScImmutableInt64 { - return wasmlib.NewScImmutableInt64(s.id, wasmlib.KeyID(ResultCounter)) +func (s ImmutableGetCounterResults) Counter() wasmtypes.ScImmutableInt64 { + return wasmtypes.NewScImmutableInt64(s.proxy.Root(ResultCounter)) } type MutableGetCounterResults struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableGetCounterResults) Counter() wasmlib.ScMutableInt64 { - return wasmlib.NewScMutableInt64(s.id, wasmlib.KeyID(ResultCounter)) +func (s MutableGetCounterResults) Counter() wasmtypes.ScMutableInt64 { + return wasmtypes.NewScMutableInt64(s.proxy.Root(ResultCounter)) } type MapStringToImmutableInt64 struct { - objID int32 + proxy wasmtypes.Proxy } -func (m MapStringToImmutableInt64) GetInt64(key string) wasmlib.ScImmutableInt64 { - return wasmlib.NewScImmutableInt64(m.objID, wasmlib.Key(key).KeyID()) +func (m MapStringToImmutableInt64) GetInt64(key string) wasmtypes.ScImmutableInt64 { + return wasmtypes.NewScImmutableInt64(m.proxy.Key(wasmtypes.BytesFromString(key))) } type ImmutableGetIntResults struct { - id int32 + proxy wasmtypes.Proxy } func (s ImmutableGetIntResults) Values() MapStringToImmutableInt64 { - return MapStringToImmutableInt64{objID: s.id} + //nolint:gosimple + return MapStringToImmutableInt64{proxy: s.proxy} } type MapStringToMutableInt64 struct { - objID int32 + proxy wasmtypes.Proxy } func (m MapStringToMutableInt64) Clear() { - wasmlib.Clear(m.objID) + m.proxy.ClearMap() } -func (m MapStringToMutableInt64) GetInt64(key string) wasmlib.ScMutableInt64 { - return wasmlib.NewScMutableInt64(m.objID, wasmlib.Key(key).KeyID()) +func (m MapStringToMutableInt64) GetInt64(key string) wasmtypes.ScMutableInt64 { + return wasmtypes.NewScMutableInt64(m.proxy.Key(wasmtypes.BytesFromString(key))) } type MutableGetIntResults struct { - id int32 + proxy wasmtypes.Proxy } func (s MutableGetIntResults) Values() MapStringToMutableInt64 { - return MapStringToMutableInt64{objID: s.id} + //nolint:gosimple + return MapStringToMutableInt64{proxy: s.proxy} } type MapStringToImmutableString struct { - objID int32 + proxy wasmtypes.Proxy } -func (m MapStringToImmutableString) GetString(key string) wasmlib.ScImmutableString { - return wasmlib.NewScImmutableString(m.objID, wasmlib.Key(key).KeyID()) +func (m MapStringToImmutableString) GetString(key string) wasmtypes.ScImmutableString { + return wasmtypes.NewScImmutableString(m.proxy.Key(wasmtypes.BytesFromString(key))) } type ImmutableGetStringValueResults struct { - id int32 + proxy wasmtypes.Proxy } func (s ImmutableGetStringValueResults) Vars() MapStringToImmutableString { - return MapStringToImmutableString{objID: s.id} + //nolint:gosimple + return MapStringToImmutableString{proxy: s.proxy} } type MapStringToMutableString struct { - objID int32 + proxy wasmtypes.Proxy } func (m MapStringToMutableString) Clear() { - wasmlib.Clear(m.objID) + m.proxy.ClearMap() } -func (m MapStringToMutableString) GetString(key string) wasmlib.ScMutableString { - return wasmlib.NewScMutableString(m.objID, wasmlib.Key(key).KeyID()) +func (m MapStringToMutableString) GetString(key string) wasmtypes.ScMutableString { + return wasmtypes.NewScMutableString(m.proxy.Key(wasmtypes.BytesFromString(key))) } type MutableGetStringValueResults struct { - id int32 + proxy wasmtypes.Proxy } func (s MutableGetStringValueResults) Vars() MapStringToMutableString { - return MapStringToMutableString{objID: s.id} + //nolint:gosimple + return MapStringToMutableString{proxy: s.proxy} } type ImmutableTestChainOwnerIDViewResults struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableTestChainOwnerIDViewResults) ChainOwnerID() wasmlib.ScImmutableAgentID { - return wasmlib.NewScImmutableAgentID(s.id, wasmlib.KeyID(ResultChainOwnerID)) +func (s ImmutableTestChainOwnerIDViewResults) ChainOwnerID() wasmtypes.ScImmutableAgentID { + return wasmtypes.NewScImmutableAgentID(s.proxy.Root(ResultChainOwnerID)) } type MutableTestChainOwnerIDViewResults struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableTestChainOwnerIDViewResults) ChainOwnerID() wasmlib.ScMutableAgentID { - return wasmlib.NewScMutableAgentID(s.id, wasmlib.KeyID(ResultChainOwnerID)) +func (s MutableTestChainOwnerIDViewResults) ChainOwnerID() wasmtypes.ScMutableAgentID { + return wasmtypes.NewScMutableAgentID(s.proxy.Root(ResultChainOwnerID)) } type ImmutableTestSandboxCallResults struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableTestSandboxCallResults) SandboxCall() wasmlib.ScImmutableString { - return wasmlib.NewScImmutableString(s.id, wasmlib.KeyID(ResultSandboxCall)) +func (s ImmutableTestSandboxCallResults) SandboxCall() wasmtypes.ScImmutableString { + return wasmtypes.NewScImmutableString(s.proxy.Root(ResultSandboxCall)) } type MutableTestSandboxCallResults struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableTestSandboxCallResults) SandboxCall() wasmlib.ScMutableString { - return wasmlib.NewScMutableString(s.id, wasmlib.KeyID(ResultSandboxCall)) +func (s MutableTestSandboxCallResults) SandboxCall() wasmtypes.ScMutableString { + return wasmtypes.NewScMutableString(s.proxy.Root(ResultSandboxCall)) } diff --git a/contracts/wasm/testcore/go/testcore/state.go b/contracts/wasm/testcore/go/testcore/state.go index cb134bf3b5..173253e65d 100644 --- a/contracts/wasm/testcore/go/testcore/state.go +++ b/contracts/wasm/testcore/go/testcore/state.go @@ -7,58 +7,56 @@ package testcore -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" +import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" type ImmutableTestCoreState struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableTestCoreState) Counter() wasmlib.ScImmutableInt64 { - return wasmlib.NewScImmutableInt64(s.id, wasmlib.KeyID(StateCounter)) +func (s ImmutableTestCoreState) Counter() wasmtypes.ScImmutableInt64 { + return wasmtypes.NewScImmutableInt64(s.proxy.Root(StateCounter)) } -func (s ImmutableTestCoreState) HnameEP() wasmlib.ScImmutableHname { - return wasmlib.NewScImmutableHname(s.id, wasmlib.KeyID(StateHnameEP)) +func (s ImmutableTestCoreState) HnameEP() wasmtypes.ScImmutableHname { + return wasmtypes.NewScImmutableHname(s.proxy.Root(StateHnameEP)) } func (s ImmutableTestCoreState) Ints() MapStringToImmutableInt64 { - mapID := wasmlib.GetObjectID(s.id, wasmlib.KeyID(StateInts), wasmlib.TYPE_MAP) - return MapStringToImmutableInt64{objID: mapID} + return MapStringToImmutableInt64{proxy: s.proxy.Root(StateInts)} } -func (s ImmutableTestCoreState) MintedColor() wasmlib.ScImmutableColor { - return wasmlib.NewScImmutableColor(s.id, wasmlib.KeyID(StateMintedColor)) +func (s ImmutableTestCoreState) MintedColor() wasmtypes.ScImmutableColor { + return wasmtypes.NewScImmutableColor(s.proxy.Root(StateMintedColor)) } -func (s ImmutableTestCoreState) MintedSupply() wasmlib.ScImmutableInt64 { - return wasmlib.NewScImmutableInt64(s.id, wasmlib.KeyID(StateMintedSupply)) +func (s ImmutableTestCoreState) MintedSupply() wasmtypes.ScImmutableUint64 { + return wasmtypes.NewScImmutableUint64(s.proxy.Root(StateMintedSupply)) } type MutableTestCoreState struct { - id int32 + proxy wasmtypes.Proxy } func (s MutableTestCoreState) AsImmutable() ImmutableTestCoreState { return ImmutableTestCoreState(s) } -func (s MutableTestCoreState) Counter() wasmlib.ScMutableInt64 { - return wasmlib.NewScMutableInt64(s.id, wasmlib.KeyID(StateCounter)) +func (s MutableTestCoreState) Counter() wasmtypes.ScMutableInt64 { + return wasmtypes.NewScMutableInt64(s.proxy.Root(StateCounter)) } -func (s MutableTestCoreState) HnameEP() wasmlib.ScMutableHname { - return wasmlib.NewScMutableHname(s.id, wasmlib.KeyID(StateHnameEP)) +func (s MutableTestCoreState) HnameEP() wasmtypes.ScMutableHname { + return wasmtypes.NewScMutableHname(s.proxy.Root(StateHnameEP)) } func (s MutableTestCoreState) Ints() MapStringToMutableInt64 { - mapID := wasmlib.GetObjectID(s.id, wasmlib.KeyID(StateInts), wasmlib.TYPE_MAP) - return MapStringToMutableInt64{objID: mapID} + return MapStringToMutableInt64{proxy: s.proxy.Root(StateInts)} } -func (s MutableTestCoreState) MintedColor() wasmlib.ScMutableColor { - return wasmlib.NewScMutableColor(s.id, wasmlib.KeyID(StateMintedColor)) +func (s MutableTestCoreState) MintedColor() wasmtypes.ScMutableColor { + return wasmtypes.NewScMutableColor(s.proxy.Root(StateMintedColor)) } -func (s MutableTestCoreState) MintedSupply() wasmlib.ScMutableInt64 { - return wasmlib.NewScMutableInt64(s.id, wasmlib.KeyID(StateMintedSupply)) +func (s MutableTestCoreState) MintedSupply() wasmtypes.ScMutableUint64 { + return wasmtypes.NewScMutableUint64(s.proxy.Root(StateMintedSupply)) } diff --git a/contracts/wasm/testcore/go/testcore/testcore.go b/contracts/wasm/testcore/go/testcore/testcore.go index 9537c6374a..51f7b4c0fe 100644 --- a/contracts/wasm/testcore/go/testcore/testcore.go +++ b/contracts/wasm/testcore/go/testcore/testcore.go @@ -8,6 +8,7 @@ import ( "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/coreaccounts" "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/coregovernance" + "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmcodec" ) const ( @@ -39,10 +40,10 @@ func funcCallOnChain(ctx wasmlib.ScFuncContext, f *CallOnChainContext) { counter.SetValue(counter.Value() + 1) - params := wasmlib.NewScMutableMap() - params.GetInt64(wasmlib.Key(ParamIntValue)).SetValue(paramIn) + params := wasmlib.NewScDict() + params.Set([]byte(ParamIntValue), wasmcodec.AppendInt64(nil, paramIn)) ret := ctx.Call(hnameContract, hnameEP, params, nil) - retVal := ret.GetInt64(wasmlib.Key(ResultIntValue)).Value() + retVal, _ := wasmcodec.ExtractInt64(ret.Get([]byte(ParamIntValue))) f.Results.IntValue().SetValue(retVal) } @@ -62,8 +63,8 @@ func funcDoNothing(ctx wasmlib.ScFuncContext, f *DoNothingContext) { func funcGetMintedSupply(ctx wasmlib.ScFuncContext, f *GetMintedSupplyContext) { minted := ctx.Minted() mintedColors := minted.Colors() - ctx.Require(mintedColors.Length() == 1, "test only supports one minted color") - color := mintedColors.GetColor(0).Value() + ctx.Require(len(mintedColors) == 1, "test only supports one minted color") + color := mintedColors[0] amount := minted.Balance(color) f.Results.MintedColor().SetValue(color) f.Results.MintedSupply().SetValue(amount) @@ -87,8 +88,8 @@ func funcPassTypesFull(ctx wasmlib.ScFuncContext, f *PassTypesFullContext) { ctx.Require(f.Params.Int64Zero().Value() == 0, "int64-0 wrong") ctx.Require(f.Params.String().Value() == string(ParamString), "string wrong") ctx.Require(f.Params.StringZero().Value() == "", "string-0 wrong") - ctx.Require(f.Params.Hname().Value() == wasmlib.NewScHname(string(ParamHname)), "Hname wrong") - ctx.Require(f.Params.HnameZero().Value() == wasmlib.ScHname(0), "Hname-0 wrong") + ctx.Require(f.Params.Hname().Value() == ctx.Utility().Hname(ParamHname), "Hname wrong") + ctx.Require(f.Params.HnameZero().Value() == 0, "Hname-0 wrong") } func funcRunRecursion(ctx wasmlib.ScFuncContext, f *RunRecursionContext) { @@ -132,7 +133,7 @@ func funcTestChainOwnerIDFull(ctx wasmlib.ScFuncContext, f *TestChainOwnerIDFull func funcTestEventLogDeploy(ctx wasmlib.ScFuncContext, f *TestEventLogDeployContext) { // deploy the same contract with another name programHash := ctx.Utility().HashBlake2b([]byte("testcore")) - ctx.Deploy(programHash, ContractNameDeployed, "test contract deploy log", nil) + ctx.DeployContract(programHash, ContractNameDeployed, "test contract deploy log", nil) } //nolint:unparam @@ -203,8 +204,8 @@ func viewPassTypesView(ctx wasmlib.ScViewContext, f *PassTypesViewContext) { ctx.Require(f.Params.Int64Zero().Value() == 0, "int64-0 wrong") ctx.Require(f.Params.String().Value() == string(ParamString), "string wrong") ctx.Require(f.Params.StringZero().Value() == "", "string-0 wrong") - ctx.Require(f.Params.Hname().Value() == wasmlib.NewScHname(string(ParamHname)), "Hname wrong") - ctx.Require(f.Params.HnameZero().Value() == wasmlib.ScHname(0), "Hname-0 wrong") + ctx.Require(f.Params.Hname().Value() == ctx.Utility().Hname(ParamHname), "Hname wrong") + ctx.Require(f.Params.HnameZero().Value() == 0, "Hname-0 wrong") } //nolint:unparam @@ -245,9 +246,9 @@ func viewGetStringValue(ctx wasmlib.ScViewContext, f *GetStringValueContext) { func funcSpawn(ctx wasmlib.ScFuncContext, f *SpawnContext) { spawnName := ScName + "_spawned" spawnDescr := "spawned contract description" - ctx.Deploy(f.Params.ProgHash().Value(), spawnName, spawnDescr, nil) + ctx.DeployContract(f.Params.ProgHash().Value(), spawnName, spawnDescr, nil) - spawnHname := wasmlib.NewScHname(spawnName) + spawnHname := ctx.Utility().Hname(spawnName) for i := 0; i < 5; i++ { ctx.Call(spawnHname, HFuncIncCounter, nil, nil) } diff --git a/contracts/wasm/testcore/schema.yaml b/contracts/wasm/testcore/schema.yaml index 722daf8c8b..f5ffc71215 100644 --- a/contracts/wasm/testcore/schema.yaml +++ b/contracts/wasm/testcore/schema.yaml @@ -7,7 +7,7 @@ state: hnameEP: Hname ints: map[String]Int64 mintedColor: Color - mintedSupply: Int64 + mintedSupply: Uint64 funcs: callOnChain: params: @@ -27,7 +27,7 @@ funcs: getMintedSupply: results: mintedColor: Color - mintedSupply: Int64 + mintedSupply: Uint64 incCounter: {} init: params: diff --git a/contracts/wasm/testcore/src/results.rs b/contracts/wasm/testcore/src/results.rs index a0380fbbfa..bcc9dc8ea4 100644 --- a/contracts/wasm/testcore/src/results.rs +++ b/contracts/wasm/testcore/src/results.rs @@ -46,8 +46,8 @@ impl ImmutableGetMintedSupplyResults { ScImmutableColor::new(self.id, RESULT_MINTED_COLOR.get_key_id()) } - pub fn minted_supply(&self) -> ScImmutableInt64 { - ScImmutableInt64::new(self.id, RESULT_MINTED_SUPPLY.get_key_id()) + pub fn minted_supply(&self) -> ScImmutableUint64 { + ScImmutableUint64::new(self.id, RESULT_MINTED_SUPPLY.get_key_id()) } } @@ -61,8 +61,8 @@ impl MutableGetMintedSupplyResults { ScMutableColor::new(self.id, RESULT_MINTED_COLOR.get_key_id()) } - pub fn minted_supply(&self) -> ScMutableInt64 { - ScMutableInt64::new(self.id, RESULT_MINTED_SUPPLY.get_key_id()) + pub fn minted_supply(&self) -> ScMutableUint64 { + ScMutableUint64::new(self.id, RESULT_MINTED_SUPPLY.get_key_id()) } } diff --git a/contracts/wasm/testcore/src/state.rs b/contracts/wasm/testcore/src/state.rs index 464c4e0aa9..3aab615757 100644 --- a/contracts/wasm/testcore/src/state.rs +++ b/contracts/wasm/testcore/src/state.rs @@ -37,8 +37,8 @@ impl ImmutableTestCoreState { ScImmutableColor::new(self.id, STATE_MINTED_COLOR.get_key_id()) } - pub fn minted_supply(&self) -> ScImmutableInt64 { - ScImmutableInt64::new(self.id, STATE_MINTED_SUPPLY.get_key_id()) + pub fn minted_supply(&self) -> ScImmutableUint64 { + ScImmutableUint64::new(self.id, STATE_MINTED_SUPPLY.get_key_id()) } } @@ -69,7 +69,7 @@ impl MutableTestCoreState { ScMutableColor::new(self.id, STATE_MINTED_COLOR.get_key_id()) } - pub fn minted_supply(&self) -> ScMutableInt64 { - ScMutableInt64::new(self.id, STATE_MINTED_SUPPLY.get_key_id()) + pub fn minted_supply(&self) -> ScMutableUint64 { + ScMutableUint64::new(self.id, STATE_MINTED_SUPPLY.get_key_id()) } } diff --git a/contracts/wasm/testcore/test/testcore_bg.wasm b/contracts/wasm/testcore/test/testcore_bg.wasm index 926ca33bd093df86570cabdece8d7f0a3bb136aa..76c1881f70e60ea277e9cae13931323a61b8daa8 100644 GIT binary patch delta 17442 zcm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=aBM zVJ6)>v_QyPXW^>==L2#bVa47EkH$Q_+|CZ2={a5{4D!nop&Up6Y5hdm1v@dw#u=qX z-Pcpxt`^*vJ9a4z1YuanPkGSd@atj182U-x%XC2qQi&ZtB@9tkcX*L1MJ&JGfY@QqSIh zTKY_e`b@cuQT|rdYW*n)62sQtkpG%@=48o!u2q=nvox}hi`BmM*Nc~H$2`#2SG##b z&=<9=Q7MjNlfog>oLsmME8a?W<6xqy8XDKgvf?rl73# z;B_cD{!Xua!)t$sbB2uxt+4!|MihodgECw)QSyl#Rs+ho;pj|%W~ED=T518 z`{}W^8u{!T`B>9cRx2eZ{9&vj(+o+*AeMaMb~999=$+m&_4vADZ#bLN^{$Lf!H zZ^B<5{?@2Vw=d1SD$lXnqV~10tad1`Qkl=cDqQu+^Ht(GHTZ>o_Wpb|_l03%qWbWK zo-HO|`^o?ARQWrGw5&tTMXkO-P1;eB=`S?Z695Y1&#$)c7%pbjX1{WNX)Y&-}wH(wcP*PUvt(T%L zgeC9ZR%eAyRO5GMt1ET})Kxq27<8LjxU*P{Q%~&dnR!Q%k;xjA#Gjyk+u1pPH)sSgv>s$IutUV&OMYE(tC?TXq@c12Sn oM>{y&6Iny>$1+y`Grmc{(GIm!-+0>Bk{L=!_<3A>>f1B^A2JvYxBvhE diff --git a/contracts/wasm/testcore/test/testcore_test.go b/contracts/wasm/testcore/test/testcore_test.go index 9ca6847fbd..a69abae03c 100644 --- a/contracts/wasm/testcore/test/testcore_test.go +++ b/contracts/wasm/testcore/test/testcore_test.go @@ -130,7 +130,7 @@ func originatorBalanceReducedBy(ctx *wasmsolo.SoloContext, w bool, minus uint64) ctx.Chain.Env.AssertAddressIotas(ctx.Chain.OriginatorAddress, solo.Saldo-solo.ChainDustThreshold-minus) } -func deposit(t *testing.T, ctx *wasmsolo.SoloContext, user, target *wasmsolo.SoloAgent, amount int64) { +func deposit(t *testing.T, ctx *wasmsolo.SoloContext, user, target *wasmsolo.SoloAgent, amount uint64) { ctxAcc := ctx.SoloContextForCore(t, coreaccounts.ScName, coreaccounts.OnLoad) f := coreaccounts.ScFuncs.Deposit(ctxAcc.Sign(user)) if target != nil { diff --git a/contracts/wasm/testcore/test/types_test.go b/contracts/wasm/testcore/test/types_test.go index 1ba4b9f23c..a6da6a6fd1 100644 --- a/contracts/wasm/testcore/test/types_test.go +++ b/contracts/wasm/testcore/test/types_test.go @@ -5,7 +5,7 @@ import ( "github.com/iotaledger/wasp/contracts/wasm/testcore/go/testcore" "github.com/iotaledger/wasp/packages/hashing" - "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" + "github.com/iotaledger/wasp/packages/iscp" "github.com/stretchr/testify/require" ) @@ -19,8 +19,8 @@ func TestTypesFull(t *testing.T) { f.Params.ChainID().SetValue(ctx.ChainID()) f.Params.ContractID().SetValue(ctx.AccountID()) f.Params.Hash().SetValue(ctx.Convertor.ScHash(hashing.HashStrings("Hash"))) - f.Params.Hname().SetValue(wasmlib.NewScHname("Hname")) - f.Params.HnameZero().SetValue(wasmlib.ScHname(0)) + f.Params.Hname().SetValue(ctx.Convertor.ScHname(iscp.Hn("Hname"))) + f.Params.HnameZero().SetValue(0) f.Params.Int64().SetValue(42) f.Params.Int64Zero().SetValue(0) f.Params.String().SetValue("string") @@ -40,8 +40,8 @@ func TestTypesView(t *testing.T) { v.Params.ChainID().SetValue(ctx.ChainID()) v.Params.ContractID().SetValue(ctx.AccountID()) v.Params.Hash().SetValue(ctx.Convertor.ScHash(hashing.HashStrings("Hash"))) - v.Params.Hname().SetValue(wasmlib.NewScHname("Hname")) - v.Params.HnameZero().SetValue(wasmlib.ScHname(0)) + v.Params.Hname().SetValue(ctx.Convertor.ScHname(iscp.Hn("Hname"))) + v.Params.HnameZero().SetValue(0) v.Params.Int64().SetValue(42) v.Params.Int64Zero().SetValue(0) v.Params.String().SetValue("string") diff --git a/contracts/wasm/testcore/ts/testcore/results.ts b/contracts/wasm/testcore/ts/testcore/results.ts index 1a4abc5abf..15d59ab40c 100644 --- a/contracts/wasm/testcore/ts/testcore/results.ts +++ b/contracts/wasm/testcore/ts/testcore/results.ts @@ -25,8 +25,8 @@ export class ImmutableGetMintedSupplyResults extends wasmlib.ScMapID { return new wasmlib.ScImmutableColor(this.mapID, wasmlib.Key32.fromString(sc.ResultMintedColor)); } - mintedSupply(): wasmlib.ScImmutableInt64 { - return new wasmlib.ScImmutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ResultMintedSupply)); + mintedSupply(): wasmlib.ScImmutableUint64 { + return new wasmlib.ScImmutableUint64(this.mapID, wasmlib.Key32.fromString(sc.ResultMintedSupply)); } } @@ -35,8 +35,8 @@ export class MutableGetMintedSupplyResults extends wasmlib.ScMapID { return new wasmlib.ScMutableColor(this.mapID, wasmlib.Key32.fromString(sc.ResultMintedColor)); } - mintedSupply(): wasmlib.ScMutableInt64 { - return new wasmlib.ScMutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ResultMintedSupply)); + mintedSupply(): wasmlib.ScMutableUint64 { + return new wasmlib.ScMutableUint64(this.mapID, wasmlib.Key32.fromString(sc.ResultMintedSupply)); } } diff --git a/contracts/wasm/testcore/ts/testcore/state.ts b/contracts/wasm/testcore/ts/testcore/state.ts index 549c82f010..2b27ba7e40 100644 --- a/contracts/wasm/testcore/ts/testcore/state.ts +++ b/contracts/wasm/testcore/ts/testcore/state.ts @@ -26,8 +26,8 @@ export class ImmutableTestCoreState extends wasmlib.ScMapID { return new wasmlib.ScImmutableColor(this.mapID, wasmlib.Key32.fromString(sc.StateMintedColor)); } - mintedSupply(): wasmlib.ScImmutableInt64 { - return new wasmlib.ScImmutableInt64(this.mapID, wasmlib.Key32.fromString(sc.StateMintedSupply)); + mintedSupply(): wasmlib.ScImmutableUint64 { + return new wasmlib.ScImmutableUint64(this.mapID, wasmlib.Key32.fromString(sc.StateMintedSupply)); } } @@ -55,7 +55,7 @@ export class MutableTestCoreState extends wasmlib.ScMapID { return new wasmlib.ScMutableColor(this.mapID, wasmlib.Key32.fromString(sc.StateMintedColor)); } - mintedSupply(): wasmlib.ScMutableInt64 { - return new wasmlib.ScMutableInt64(this.mapID, wasmlib.Key32.fromString(sc.StateMintedSupply)); + mintedSupply(): wasmlib.ScMutableUint64 { + return new wasmlib.ScMutableUint64(this.mapID, wasmlib.Key32.fromString(sc.StateMintedSupply)); } } diff --git a/contracts/wasm/testwasmlib/go/testwasmlib/consts.go b/contracts/wasm/testwasmlib/go/testwasmlib/consts.go index 7b8cefa6f3..7b7791f441 100644 --- a/contracts/wasm/testwasmlib/go/testwasmlib/consts.go +++ b/contracts/wasm/testwasmlib/go/testwasmlib/consts.go @@ -7,12 +7,12 @@ package testwasmlib -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" +import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" const ( ScName = "testwasmlib" ScDescription = "Exercise several aspects of WasmLib" - HScName = wasmlib.ScHname(0x89703a45) + HScName = wasmtypes.ScHname(0x89703a45) ) const ( @@ -59,11 +59,10 @@ const ( ) const ( + FuncArrayAppend = "arrayAppend" FuncArrayClear = "arrayClear" - FuncArrayCreate = "arrayCreate" FuncArraySet = "arraySet" FuncMapClear = "mapClear" - FuncMapCreate = "mapCreate" FuncMapSet = "mapSet" FuncParamTypes = "paramTypes" FuncRandom = "random" @@ -78,20 +77,19 @@ const ( ) const ( - HFuncArrayClear = wasmlib.ScHname(0x88021821) - HFuncArrayCreate = wasmlib.ScHname(0x1ed5b23b) - HFuncArraySet = wasmlib.ScHname(0x2c4150b3) - HFuncMapClear = wasmlib.ScHname(0x027f215a) - HFuncMapCreate = wasmlib.ScHname(0x6295d599) - HFuncMapSet = wasmlib.ScHname(0xf2260404) - HFuncParamTypes = wasmlib.ScHname(0x6921c4cd) - HFuncRandom = wasmlib.ScHname(0xe86c97ca) - HFuncTriggerEvent = wasmlib.ScHname(0xd5438ac6) - HViewArrayLength = wasmlib.ScHname(0x3a831021) - HViewArrayValue = wasmlib.ScHname(0x662dbd81) - HViewBlockRecord = wasmlib.ScHname(0xad13b2f8) - HViewBlockRecords = wasmlib.ScHname(0x16e249ea) - HViewGetRandom = wasmlib.ScHname(0x46263045) - HViewIotaBalance = wasmlib.ScHname(0x9d3920bd) - HViewMapValue = wasmlib.ScHname(0x23149bef) + HFuncArrayAppend = wasmtypes.ScHname(0x612f835f) + HFuncArrayClear = wasmtypes.ScHname(0x88021821) + HFuncArraySet = wasmtypes.ScHname(0x2c4150b3) + HFuncMapClear = wasmtypes.ScHname(0x027f215a) + HFuncMapSet = wasmtypes.ScHname(0xf2260404) + HFuncParamTypes = wasmtypes.ScHname(0x6921c4cd) + HFuncRandom = wasmtypes.ScHname(0xe86c97ca) + HFuncTriggerEvent = wasmtypes.ScHname(0xd5438ac6) + HViewArrayLength = wasmtypes.ScHname(0x3a831021) + HViewArrayValue = wasmtypes.ScHname(0x662dbd81) + HViewBlockRecord = wasmtypes.ScHname(0xad13b2f8) + HViewBlockRecords = wasmtypes.ScHname(0x16e249ea) + HViewGetRandom = wasmtypes.ScHname(0x46263045) + HViewIotaBalance = wasmtypes.ScHname(0x9d3920bd) + HViewMapValue = wasmtypes.ScHname(0x23149bef) ) diff --git a/contracts/wasm/testwasmlib/go/testwasmlib/contract.go b/contracts/wasm/testwasmlib/go/testwasmlib/contract.go index 87309712b0..c3aec44cfb 100644 --- a/contracts/wasm/testwasmlib/go/testwasmlib/contract.go +++ b/contracts/wasm/testwasmlib/go/testwasmlib/contract.go @@ -9,14 +9,14 @@ package testwasmlib import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" -type ArrayClearCall struct { +type ArrayAppendCall struct { Func *wasmlib.ScFunc - Params MutableArrayClearParams + Params MutableArrayAppendParams } -type ArrayCreateCall struct { +type ArrayClearCall struct { Func *wasmlib.ScFunc - Params MutableArrayCreateParams + Params MutableArrayClearParams } type ArraySetCall struct { @@ -29,11 +29,6 @@ type MapClearCall struct { Params MutableMapClearParams } -type MapCreateCall struct { - Func *wasmlib.ScFunc - Params MutableMapCreateParams -} - type MapSetCall struct { Func *wasmlib.ScFunc Params MutableMapSetParams @@ -97,45 +92,39 @@ type Funcs struct{} var ScFuncs Funcs -func (sc Funcs) ArrayClear(ctx wasmlib.ScFuncCallContext) *ArrayClearCall { - f := &ArrayClearCall{Func: wasmlib.NewScFunc(ctx, HScName, HFuncArrayClear)} - f.Func.SetPtrs(&f.Params.id, nil) +func (sc Funcs) ArrayAppend(ctx wasmlib.ScFuncCallContext) *ArrayAppendCall { + f := &ArrayAppendCall{Func: wasmlib.NewScFunc(ctx, HScName, HFuncArrayAppend)} + f.Params.proxy = wasmlib.NewCallParamsProxy(&f.Func.ScView) return f } -func (sc Funcs) ArrayCreate(ctx wasmlib.ScFuncCallContext) *ArrayCreateCall { - f := &ArrayCreateCall{Func: wasmlib.NewScFunc(ctx, HScName, HFuncArrayCreate)} - f.Func.SetPtrs(&f.Params.id, nil) +func (sc Funcs) ArrayClear(ctx wasmlib.ScFuncCallContext) *ArrayClearCall { + f := &ArrayClearCall{Func: wasmlib.NewScFunc(ctx, HScName, HFuncArrayClear)} + f.Params.proxy = wasmlib.NewCallParamsProxy(&f.Func.ScView) return f } func (sc Funcs) ArraySet(ctx wasmlib.ScFuncCallContext) *ArraySetCall { f := &ArraySetCall{Func: wasmlib.NewScFunc(ctx, HScName, HFuncArraySet)} - f.Func.SetPtrs(&f.Params.id, nil) + f.Params.proxy = wasmlib.NewCallParamsProxy(&f.Func.ScView) return f } func (sc Funcs) MapClear(ctx wasmlib.ScFuncCallContext) *MapClearCall { f := &MapClearCall{Func: wasmlib.NewScFunc(ctx, HScName, HFuncMapClear)} - f.Func.SetPtrs(&f.Params.id, nil) - return f -} - -func (sc Funcs) MapCreate(ctx wasmlib.ScFuncCallContext) *MapCreateCall { - f := &MapCreateCall{Func: wasmlib.NewScFunc(ctx, HScName, HFuncMapCreate)} - f.Func.SetPtrs(&f.Params.id, nil) + f.Params.proxy = wasmlib.NewCallParamsProxy(&f.Func.ScView) return f } func (sc Funcs) MapSet(ctx wasmlib.ScFuncCallContext) *MapSetCall { f := &MapSetCall{Func: wasmlib.NewScFunc(ctx, HScName, HFuncMapSet)} - f.Func.SetPtrs(&f.Params.id, nil) + f.Params.proxy = wasmlib.NewCallParamsProxy(&f.Func.ScView) return f } func (sc Funcs) ParamTypes(ctx wasmlib.ScFuncCallContext) *ParamTypesCall { f := &ParamTypesCall{Func: wasmlib.NewScFunc(ctx, HScName, HFuncParamTypes)} - f.Func.SetPtrs(&f.Params.id, nil) + f.Params.proxy = wasmlib.NewCallParamsProxy(&f.Func.ScView) return f } @@ -145,48 +134,53 @@ func (sc Funcs) Random(ctx wasmlib.ScFuncCallContext) *RandomCall { func (sc Funcs) TriggerEvent(ctx wasmlib.ScFuncCallContext) *TriggerEventCall { f := &TriggerEventCall{Func: wasmlib.NewScFunc(ctx, HScName, HFuncTriggerEvent)} - f.Func.SetPtrs(&f.Params.id, nil) + f.Params.proxy = wasmlib.NewCallParamsProxy(&f.Func.ScView) return f } func (sc Funcs) ArrayLength(ctx wasmlib.ScViewCallContext) *ArrayLengthCall { f := &ArrayLengthCall{Func: wasmlib.NewScView(ctx, HScName, HViewArrayLength)} - f.Func.SetPtrs(&f.Params.id, &f.Results.id) + f.Params.proxy = wasmlib.NewCallParamsProxy(f.Func) + wasmlib.NewCallResultsProxy(f.Func, &f.Results.proxy) return f } func (sc Funcs) ArrayValue(ctx wasmlib.ScViewCallContext) *ArrayValueCall { f := &ArrayValueCall{Func: wasmlib.NewScView(ctx, HScName, HViewArrayValue)} - f.Func.SetPtrs(&f.Params.id, &f.Results.id) + f.Params.proxy = wasmlib.NewCallParamsProxy(f.Func) + wasmlib.NewCallResultsProxy(f.Func, &f.Results.proxy) return f } func (sc Funcs) BlockRecord(ctx wasmlib.ScViewCallContext) *BlockRecordCall { f := &BlockRecordCall{Func: wasmlib.NewScView(ctx, HScName, HViewBlockRecord)} - f.Func.SetPtrs(&f.Params.id, &f.Results.id) + f.Params.proxy = wasmlib.NewCallParamsProxy(f.Func) + wasmlib.NewCallResultsProxy(f.Func, &f.Results.proxy) return f } func (sc Funcs) BlockRecords(ctx wasmlib.ScViewCallContext) *BlockRecordsCall { f := &BlockRecordsCall{Func: wasmlib.NewScView(ctx, HScName, HViewBlockRecords)} - f.Func.SetPtrs(&f.Params.id, &f.Results.id) + f.Params.proxy = wasmlib.NewCallParamsProxy(f.Func) + wasmlib.NewCallResultsProxy(f.Func, &f.Results.proxy) return f } func (sc Funcs) GetRandom(ctx wasmlib.ScViewCallContext) *GetRandomCall { f := &GetRandomCall{Func: wasmlib.NewScView(ctx, HScName, HViewGetRandom)} - f.Func.SetPtrs(nil, &f.Results.id) + wasmlib.NewCallResultsProxy(f.Func, &f.Results.proxy) return f } func (sc Funcs) IotaBalance(ctx wasmlib.ScViewCallContext) *IotaBalanceCall { f := &IotaBalanceCall{Func: wasmlib.NewScView(ctx, HScName, HViewIotaBalance)} - f.Func.SetPtrs(nil, &f.Results.id) + wasmlib.NewCallResultsProxy(f.Func, &f.Results.proxy) return f } func (sc Funcs) MapValue(ctx wasmlib.ScViewCallContext) *MapValueCall { f := &MapValueCall{Func: wasmlib.NewScView(ctx, HScName, HViewMapValue)} - f.Func.SetPtrs(&f.Params.id, &f.Results.id) + f.Params.proxy = wasmlib.NewCallParamsProxy(f.Func) + wasmlib.NewCallResultsProxy(f.Func, &f.Results.proxy) return f } diff --git a/contracts/wasm/testwasmlib/go/testwasmlib/events.go b/contracts/wasm/testwasmlib/go/testwasmlib/events.go index eb9574346e..49514ce382 100644 --- a/contracts/wasm/testwasmlib/go/testwasmlib/events.go +++ b/contracts/wasm/testwasmlib/go/testwasmlib/events.go @@ -7,11 +7,14 @@ package testwasmlib -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" +import ( + "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" + "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" +) type TestWasmLibEvents struct{} -func (e TestWasmLibEvents) Test(address wasmlib.ScAddress, name string) { +func (e TestWasmLibEvents) Test(address wasmtypes.ScAddress, name string) { wasmlib.NewEventEncoder("testwasmlib.test"). Address(address). String(name). diff --git a/contracts/wasm/testwasmlib/go/testwasmlib/keys.go b/contracts/wasm/testwasmlib/go/testwasmlib/keys.go index 9b5e7ac61f..9a54ee6328 100644 --- a/contracts/wasm/testwasmlib/go/testwasmlib/keys.go +++ b/contracts/wasm/testwasmlib/go/testwasmlib/keys.go @@ -6,85 +6,3 @@ // Change the json schema instead package testwasmlib - -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" - -const ( - IdxParamAddress = 0 - IdxParamAgentID = 1 - IdxParamBlockIndex = 2 - IdxParamBool = 3 - IdxParamBytes = 4 - IdxParamChainID = 5 - IdxParamColor = 6 - IdxParamHash = 7 - IdxParamHname = 8 - IdxParamIndex = 9 - IdxParamInt16 = 10 - IdxParamInt32 = 11 - IdxParamInt64 = 12 - IdxParamInt8 = 13 - IdxParamKey = 14 - IdxParamName = 15 - IdxParamParam = 16 - IdxParamRecordIndex = 17 - IdxParamRequestID = 18 - IdxParamString = 19 - IdxParamUint16 = 20 - IdxParamUint32 = 21 - IdxParamUint64 = 22 - IdxParamUint8 = 23 - IdxParamValue = 24 - - IdxResultCount = 25 - IdxResultIotas = 26 - IdxResultLength = 27 - IdxResultRandom = 28 - IdxResultRecord = 29 - IdxResultValue = 30 - - IdxStateArrays = 31 - IdxStateMaps = 32 - IdxStateRandom = 33 -) - -const keyMapLen = 34 - -var keyMap = [keyMapLen]wasmlib.Key{ - ParamAddress, - ParamAgentID, - ParamBlockIndex, - ParamBool, - ParamBytes, - ParamChainID, - ParamColor, - ParamHash, - ParamHname, - ParamIndex, - ParamInt16, - ParamInt32, - ParamInt64, - ParamInt8, - ParamKey, - ParamName, - ParamParam, - ParamRecordIndex, - ParamRequestID, - ParamString, - ParamUint16, - ParamUint32, - ParamUint64, - ParamUint8, - ParamValue, - ResultCount, - ResultIotas, - ResultLength, - ResultRandom, - ResultRecord, - ResultValue, - StateArrays, - StateMaps, - StateRandom, -} - -var idxMap [keyMapLen]wasmlib.Key32 diff --git a/contracts/wasm/testwasmlib/go/testwasmlib/lib.go b/contracts/wasm/testwasmlib/go/testwasmlib/lib.go index 1356e5135a..78a8f60bc5 100644 --- a/contracts/wasm/testwasmlib/go/testwasmlib/lib.go +++ b/contracts/wasm/testwasmlib/go/testwasmlib/lib.go @@ -11,11 +11,10 @@ import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" func OnLoad() { exports := wasmlib.NewScExports() + exports.AddFunc(FuncArrayAppend, funcArrayAppendThunk) exports.AddFunc(FuncArrayClear, funcArrayClearThunk) - exports.AddFunc(FuncArrayCreate, funcArrayCreateThunk) exports.AddFunc(FuncArraySet, funcArraySetThunk) exports.AddFunc(FuncMapClear, funcMapClearThunk) - exports.AddFunc(FuncMapCreate, funcMapCreateThunk) exports.AddFunc(FuncMapSet, funcMapSetThunk) exports.AddFunc(FuncParamTypes, funcParamTypesThunk) exports.AddFunc(FuncRandom, funcRandomThunk) @@ -27,52 +26,49 @@ func OnLoad() { exports.AddView(ViewGetRandom, viewGetRandomThunk) exports.AddView(ViewIotaBalance, viewIotaBalanceThunk) exports.AddView(ViewMapValue, viewMapValueThunk) - - for i, key := range keyMap { - idxMap[i] = key.KeyID() - } } -type ArrayClearContext struct { +type ArrayAppendContext struct { Events TestWasmLibEvents - Params ImmutableArrayClearParams + Params ImmutableArrayAppendParams State MutableTestWasmLibState } -func funcArrayClearThunk(ctx wasmlib.ScFuncContext) { - ctx.Log("testwasmlib.funcArrayClear") - f := &ArrayClearContext{ - Params: ImmutableArrayClearParams{ - id: wasmlib.OBJ_ID_PARAMS, +func funcArrayAppendThunk(ctx wasmlib.ScFuncContext) { + ctx.Log("testwasmlib.funcArrayAppend") + f := &ArrayAppendContext{ + Params: ImmutableArrayAppendParams{ + proxy: wasmlib.NewParamsProxy(), }, State: MutableTestWasmLibState{ - id: wasmlib.OBJ_ID_STATE, + proxy: wasmlib.NewStateProxy(), }, } ctx.Require(f.Params.Name().Exists(), "missing mandatory name") - funcArrayClear(ctx, f) - ctx.Log("testwasmlib.funcArrayClear ok") + ctx.Require(f.Params.Value().Exists(), "missing mandatory value") + funcArrayAppend(ctx, f) + ctx.Log("testwasmlib.funcArrayAppend ok") } -type ArrayCreateContext struct { +type ArrayClearContext struct { Events TestWasmLibEvents - Params ImmutableArrayCreateParams + Params ImmutableArrayClearParams State MutableTestWasmLibState } -func funcArrayCreateThunk(ctx wasmlib.ScFuncContext) { - ctx.Log("testwasmlib.funcArrayCreate") - f := &ArrayCreateContext{ - Params: ImmutableArrayCreateParams{ - id: wasmlib.OBJ_ID_PARAMS, +func funcArrayClearThunk(ctx wasmlib.ScFuncContext) { + ctx.Log("testwasmlib.funcArrayClear") + f := &ArrayClearContext{ + Params: ImmutableArrayClearParams{ + proxy: wasmlib.NewParamsProxy(), }, State: MutableTestWasmLibState{ - id: wasmlib.OBJ_ID_STATE, + proxy: wasmlib.NewStateProxy(), }, } ctx.Require(f.Params.Name().Exists(), "missing mandatory name") - funcArrayCreate(ctx, f) - ctx.Log("testwasmlib.funcArrayCreate ok") + funcArrayClear(ctx, f) + ctx.Log("testwasmlib.funcArrayClear ok") } type ArraySetContext struct { @@ -85,10 +81,10 @@ func funcArraySetThunk(ctx wasmlib.ScFuncContext) { ctx.Log("testwasmlib.funcArraySet") f := &ArraySetContext{ Params: ImmutableArraySetParams{ - id: wasmlib.OBJ_ID_PARAMS, + proxy: wasmlib.NewParamsProxy(), }, State: MutableTestWasmLibState{ - id: wasmlib.OBJ_ID_STATE, + proxy: wasmlib.NewStateProxy(), }, } ctx.Require(f.Params.Index().Exists(), "missing mandatory index") @@ -108,10 +104,10 @@ func funcMapClearThunk(ctx wasmlib.ScFuncContext) { ctx.Log("testwasmlib.funcMapClear") f := &MapClearContext{ Params: ImmutableMapClearParams{ - id: wasmlib.OBJ_ID_PARAMS, + proxy: wasmlib.NewParamsProxy(), }, State: MutableTestWasmLibState{ - id: wasmlib.OBJ_ID_STATE, + proxy: wasmlib.NewStateProxy(), }, } ctx.Require(f.Params.Name().Exists(), "missing mandatory name") @@ -119,27 +115,6 @@ func funcMapClearThunk(ctx wasmlib.ScFuncContext) { ctx.Log("testwasmlib.funcMapClear ok") } -type MapCreateContext struct { - Events TestWasmLibEvents - Params ImmutableMapCreateParams - State MutableTestWasmLibState -} - -func funcMapCreateThunk(ctx wasmlib.ScFuncContext) { - ctx.Log("testwasmlib.funcMapCreate") - f := &MapCreateContext{ - Params: ImmutableMapCreateParams{ - id: wasmlib.OBJ_ID_PARAMS, - }, - State: MutableTestWasmLibState{ - id: wasmlib.OBJ_ID_STATE, - }, - } - ctx.Require(f.Params.Name().Exists(), "missing mandatory name") - funcMapCreate(ctx, f) - ctx.Log("testwasmlib.funcMapCreate ok") -} - type MapSetContext struct { Events TestWasmLibEvents Params ImmutableMapSetParams @@ -150,10 +125,10 @@ func funcMapSetThunk(ctx wasmlib.ScFuncContext) { ctx.Log("testwasmlib.funcMapSet") f := &MapSetContext{ Params: ImmutableMapSetParams{ - id: wasmlib.OBJ_ID_PARAMS, + proxy: wasmlib.NewParamsProxy(), }, State: MutableTestWasmLibState{ - id: wasmlib.OBJ_ID_STATE, + proxy: wasmlib.NewStateProxy(), }, } ctx.Require(f.Params.Key().Exists(), "missing mandatory key") @@ -173,10 +148,10 @@ func funcParamTypesThunk(ctx wasmlib.ScFuncContext) { ctx.Log("testwasmlib.funcParamTypes") f := &ParamTypesContext{ Params: ImmutableParamTypesParams{ - id: wasmlib.OBJ_ID_PARAMS, + proxy: wasmlib.NewParamsProxy(), }, State: MutableTestWasmLibState{ - id: wasmlib.OBJ_ID_STATE, + proxy: wasmlib.NewStateProxy(), }, } funcParamTypes(ctx, f) @@ -192,7 +167,7 @@ func funcRandomThunk(ctx wasmlib.ScFuncContext) { ctx.Log("testwasmlib.funcRandom") f := &RandomContext{ State: MutableTestWasmLibState{ - id: wasmlib.OBJ_ID_STATE, + proxy: wasmlib.NewStateProxy(), }, } funcRandom(ctx, f) @@ -209,10 +184,10 @@ func funcTriggerEventThunk(ctx wasmlib.ScFuncContext) { ctx.Log("testwasmlib.funcTriggerEvent") f := &TriggerEventContext{ Params: ImmutableTriggerEventParams{ - id: wasmlib.OBJ_ID_PARAMS, + proxy: wasmlib.NewParamsProxy(), }, State: MutableTestWasmLibState{ - id: wasmlib.OBJ_ID_STATE, + proxy: wasmlib.NewStateProxy(), }, } ctx.Require(f.Params.Address().Exists(), "missing mandatory address") @@ -231,13 +206,13 @@ func viewArrayLengthThunk(ctx wasmlib.ScViewContext) { ctx.Log("testwasmlib.viewArrayLength") f := &ArrayLengthContext{ Params: ImmutableArrayLengthParams{ - id: wasmlib.OBJ_ID_PARAMS, + proxy: wasmlib.NewParamsProxy(), }, Results: MutableArrayLengthResults{ - id: wasmlib.OBJ_ID_RESULTS, + proxy: wasmlib.NewResultsProxy(), }, State: ImmutableTestWasmLibState{ - id: wasmlib.OBJ_ID_STATE, + proxy: wasmlib.NewStateProxy(), }, } ctx.Require(f.Params.Name().Exists(), "missing mandatory name") @@ -255,13 +230,13 @@ func viewArrayValueThunk(ctx wasmlib.ScViewContext) { ctx.Log("testwasmlib.viewArrayValue") f := &ArrayValueContext{ Params: ImmutableArrayValueParams{ - id: wasmlib.OBJ_ID_PARAMS, + proxy: wasmlib.NewParamsProxy(), }, Results: MutableArrayValueResults{ - id: wasmlib.OBJ_ID_RESULTS, + proxy: wasmlib.NewResultsProxy(), }, State: ImmutableTestWasmLibState{ - id: wasmlib.OBJ_ID_STATE, + proxy: wasmlib.NewStateProxy(), }, } ctx.Require(f.Params.Index().Exists(), "missing mandatory index") @@ -280,13 +255,13 @@ func viewBlockRecordThunk(ctx wasmlib.ScViewContext) { ctx.Log("testwasmlib.viewBlockRecord") f := &BlockRecordContext{ Params: ImmutableBlockRecordParams{ - id: wasmlib.OBJ_ID_PARAMS, + proxy: wasmlib.NewParamsProxy(), }, Results: MutableBlockRecordResults{ - id: wasmlib.OBJ_ID_RESULTS, + proxy: wasmlib.NewResultsProxy(), }, State: ImmutableTestWasmLibState{ - id: wasmlib.OBJ_ID_STATE, + proxy: wasmlib.NewStateProxy(), }, } ctx.Require(f.Params.BlockIndex().Exists(), "missing mandatory blockIndex") @@ -305,13 +280,13 @@ func viewBlockRecordsThunk(ctx wasmlib.ScViewContext) { ctx.Log("testwasmlib.viewBlockRecords") f := &BlockRecordsContext{ Params: ImmutableBlockRecordsParams{ - id: wasmlib.OBJ_ID_PARAMS, + proxy: wasmlib.NewParamsProxy(), }, Results: MutableBlockRecordsResults{ - id: wasmlib.OBJ_ID_RESULTS, + proxy: wasmlib.NewResultsProxy(), }, State: ImmutableTestWasmLibState{ - id: wasmlib.OBJ_ID_STATE, + proxy: wasmlib.NewStateProxy(), }, } ctx.Require(f.Params.BlockIndex().Exists(), "missing mandatory blockIndex") @@ -328,10 +303,10 @@ func viewGetRandomThunk(ctx wasmlib.ScViewContext) { ctx.Log("testwasmlib.viewGetRandom") f := &GetRandomContext{ Results: MutableGetRandomResults{ - id: wasmlib.OBJ_ID_RESULTS, + proxy: wasmlib.NewResultsProxy(), }, State: ImmutableTestWasmLibState{ - id: wasmlib.OBJ_ID_STATE, + proxy: wasmlib.NewStateProxy(), }, } viewGetRandom(ctx, f) @@ -347,10 +322,10 @@ func viewIotaBalanceThunk(ctx wasmlib.ScViewContext) { ctx.Log("testwasmlib.viewIotaBalance") f := &IotaBalanceContext{ Results: MutableIotaBalanceResults{ - id: wasmlib.OBJ_ID_RESULTS, + proxy: wasmlib.NewResultsProxy(), }, State: ImmutableTestWasmLibState{ - id: wasmlib.OBJ_ID_STATE, + proxy: wasmlib.NewStateProxy(), }, } viewIotaBalance(ctx, f) @@ -367,13 +342,13 @@ func viewMapValueThunk(ctx wasmlib.ScViewContext) { ctx.Log("testwasmlib.viewMapValue") f := &MapValueContext{ Params: ImmutableMapValueParams{ - id: wasmlib.OBJ_ID_PARAMS, + proxy: wasmlib.NewParamsProxy(), }, Results: MutableMapValueResults{ - id: wasmlib.OBJ_ID_RESULTS, + proxy: wasmlib.NewResultsProxy(), }, State: ImmutableTestWasmLibState{ - id: wasmlib.OBJ_ID_STATE, + proxy: wasmlib.NewStateProxy(), }, } ctx.Require(f.Params.Key().Exists(), "missing mandatory key") diff --git a/contracts/wasm/testwasmlib/go/testwasmlib/params.go b/contracts/wasm/testwasmlib/go/testwasmlib/params.go index dd89b42103..cefc6d0937 100644 --- a/contracts/wasm/testwasmlib/go/testwasmlib/params.go +++ b/contracts/wasm/testwasmlib/go/testwasmlib/params.go @@ -7,440 +7,434 @@ package testwasmlib -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" +import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" -type ImmutableArrayClearParams struct { - id int32 -} - -func (s ImmutableArrayClearParams) Name() wasmlib.ScImmutableString { - return wasmlib.NewScImmutableString(s.id, wasmlib.KeyID(ParamName)) -} - -type MutableArrayClearParams struct { - id int32 +type ImmutableArrayAppendParams struct { + proxy wasmtypes.Proxy } -func (s MutableArrayClearParams) Name() wasmlib.ScMutableString { - return wasmlib.NewScMutableString(s.id, wasmlib.KeyID(ParamName)) +func (s ImmutableArrayAppendParams) Name() wasmtypes.ScImmutableString { + return wasmtypes.NewScImmutableString(s.proxy.Root(ParamName)) } -type ImmutableArrayCreateParams struct { - id int32 +func (s ImmutableArrayAppendParams) Value() wasmtypes.ScImmutableString { + return wasmtypes.NewScImmutableString(s.proxy.Root(ParamValue)) } -func (s ImmutableArrayCreateParams) Name() wasmlib.ScImmutableString { - return wasmlib.NewScImmutableString(s.id, wasmlib.KeyID(ParamName)) +type MutableArrayAppendParams struct { + proxy wasmtypes.Proxy } -type MutableArrayCreateParams struct { - id int32 +func (s MutableArrayAppendParams) Name() wasmtypes.ScMutableString { + return wasmtypes.NewScMutableString(s.proxy.Root(ParamName)) } -func (s MutableArrayCreateParams) Name() wasmlib.ScMutableString { - return wasmlib.NewScMutableString(s.id, wasmlib.KeyID(ParamName)) +func (s MutableArrayAppendParams) Value() wasmtypes.ScMutableString { + return wasmtypes.NewScMutableString(s.proxy.Root(ParamValue)) } -type ImmutableArraySetParams struct { - id int32 +type ImmutableArrayClearParams struct { + proxy wasmtypes.Proxy } -func (s ImmutableArraySetParams) Index() wasmlib.ScImmutableInt32 { - return wasmlib.NewScImmutableInt32(s.id, wasmlib.KeyID(ParamIndex)) +func (s ImmutableArrayClearParams) Name() wasmtypes.ScImmutableString { + return wasmtypes.NewScImmutableString(s.proxy.Root(ParamName)) } -func (s ImmutableArraySetParams) Name() wasmlib.ScImmutableString { - return wasmlib.NewScImmutableString(s.id, wasmlib.KeyID(ParamName)) +type MutableArrayClearParams struct { + proxy wasmtypes.Proxy } -func (s ImmutableArraySetParams) Value() wasmlib.ScImmutableString { - return wasmlib.NewScImmutableString(s.id, wasmlib.KeyID(ParamValue)) +func (s MutableArrayClearParams) Name() wasmtypes.ScMutableString { + return wasmtypes.NewScMutableString(s.proxy.Root(ParamName)) } -type MutableArraySetParams struct { - id int32 +type ImmutableArraySetParams struct { + proxy wasmtypes.Proxy } -func (s MutableArraySetParams) Index() wasmlib.ScMutableInt32 { - return wasmlib.NewScMutableInt32(s.id, wasmlib.KeyID(ParamIndex)) +func (s ImmutableArraySetParams) Index() wasmtypes.ScImmutableUint32 { + return wasmtypes.NewScImmutableUint32(s.proxy.Root(ParamIndex)) } -func (s MutableArraySetParams) Name() wasmlib.ScMutableString { - return wasmlib.NewScMutableString(s.id, wasmlib.KeyID(ParamName)) +func (s ImmutableArraySetParams) Name() wasmtypes.ScImmutableString { + return wasmtypes.NewScImmutableString(s.proxy.Root(ParamName)) } -func (s MutableArraySetParams) Value() wasmlib.ScMutableString { - return wasmlib.NewScMutableString(s.id, wasmlib.KeyID(ParamValue)) +func (s ImmutableArraySetParams) Value() wasmtypes.ScImmutableString { + return wasmtypes.NewScImmutableString(s.proxy.Root(ParamValue)) } -type ImmutableMapClearParams struct { - id int32 +type MutableArraySetParams struct { + proxy wasmtypes.Proxy } -func (s ImmutableMapClearParams) Name() wasmlib.ScImmutableString { - return wasmlib.NewScImmutableString(s.id, wasmlib.KeyID(ParamName)) +func (s MutableArraySetParams) Index() wasmtypes.ScMutableUint32 { + return wasmtypes.NewScMutableUint32(s.proxy.Root(ParamIndex)) } -type MutableMapClearParams struct { - id int32 +func (s MutableArraySetParams) Name() wasmtypes.ScMutableString { + return wasmtypes.NewScMutableString(s.proxy.Root(ParamName)) } -func (s MutableMapClearParams) Name() wasmlib.ScMutableString { - return wasmlib.NewScMutableString(s.id, wasmlib.KeyID(ParamName)) +func (s MutableArraySetParams) Value() wasmtypes.ScMutableString { + return wasmtypes.NewScMutableString(s.proxy.Root(ParamValue)) } -type ImmutableMapCreateParams struct { - id int32 +type ImmutableMapClearParams struct { + proxy wasmtypes.Proxy } -func (s ImmutableMapCreateParams) Name() wasmlib.ScImmutableString { - return wasmlib.NewScImmutableString(s.id, wasmlib.KeyID(ParamName)) +func (s ImmutableMapClearParams) Name() wasmtypes.ScImmutableString { + return wasmtypes.NewScImmutableString(s.proxy.Root(ParamName)) } -type MutableMapCreateParams struct { - id int32 +type MutableMapClearParams struct { + proxy wasmtypes.Proxy } -func (s MutableMapCreateParams) Name() wasmlib.ScMutableString { - return wasmlib.NewScMutableString(s.id, wasmlib.KeyID(ParamName)) +func (s MutableMapClearParams) Name() wasmtypes.ScMutableString { + return wasmtypes.NewScMutableString(s.proxy.Root(ParamName)) } type ImmutableMapSetParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableMapSetParams) Key() wasmlib.ScImmutableString { - return wasmlib.NewScImmutableString(s.id, wasmlib.KeyID(ParamKey)) +func (s ImmutableMapSetParams) Key() wasmtypes.ScImmutableString { + return wasmtypes.NewScImmutableString(s.proxy.Root(ParamKey)) } -func (s ImmutableMapSetParams) Name() wasmlib.ScImmutableString { - return wasmlib.NewScImmutableString(s.id, wasmlib.KeyID(ParamName)) +func (s ImmutableMapSetParams) Name() wasmtypes.ScImmutableString { + return wasmtypes.NewScImmutableString(s.proxy.Root(ParamName)) } -func (s ImmutableMapSetParams) Value() wasmlib.ScImmutableString { - return wasmlib.NewScImmutableString(s.id, wasmlib.KeyID(ParamValue)) +func (s ImmutableMapSetParams) Value() wasmtypes.ScImmutableString { + return wasmtypes.NewScImmutableString(s.proxy.Root(ParamValue)) } type MutableMapSetParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableMapSetParams) Key() wasmlib.ScMutableString { - return wasmlib.NewScMutableString(s.id, wasmlib.KeyID(ParamKey)) +func (s MutableMapSetParams) Key() wasmtypes.ScMutableString { + return wasmtypes.NewScMutableString(s.proxy.Root(ParamKey)) } -func (s MutableMapSetParams) Name() wasmlib.ScMutableString { - return wasmlib.NewScMutableString(s.id, wasmlib.KeyID(ParamName)) +func (s MutableMapSetParams) Name() wasmtypes.ScMutableString { + return wasmtypes.NewScMutableString(s.proxy.Root(ParamName)) } -func (s MutableMapSetParams) Value() wasmlib.ScMutableString { - return wasmlib.NewScMutableString(s.id, wasmlib.KeyID(ParamValue)) +func (s MutableMapSetParams) Value() wasmtypes.ScMutableString { + return wasmtypes.NewScMutableString(s.proxy.Root(ParamValue)) } type MapStringToImmutableBytes struct { - objID int32 + proxy wasmtypes.Proxy } -func (m MapStringToImmutableBytes) GetBytes(key string) wasmlib.ScImmutableBytes { - return wasmlib.NewScImmutableBytes(m.objID, wasmlib.Key(key).KeyID()) +func (m MapStringToImmutableBytes) GetBytes(key string) wasmtypes.ScImmutableBytes { + return wasmtypes.NewScImmutableBytes(m.proxy.Key(wasmtypes.BytesFromString(key))) } type ImmutableParamTypesParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableParamTypesParams) Address() wasmlib.ScImmutableAddress { - return wasmlib.NewScImmutableAddress(s.id, wasmlib.KeyID(ParamAddress)) +func (s ImmutableParamTypesParams) Address() wasmtypes.ScImmutableAddress { + return wasmtypes.NewScImmutableAddress(s.proxy.Root(ParamAddress)) } -func (s ImmutableParamTypesParams) AgentID() wasmlib.ScImmutableAgentID { - return wasmlib.NewScImmutableAgentID(s.id, wasmlib.KeyID(ParamAgentID)) +func (s ImmutableParamTypesParams) AgentID() wasmtypes.ScImmutableAgentID { + return wasmtypes.NewScImmutableAgentID(s.proxy.Root(ParamAgentID)) } -func (s ImmutableParamTypesParams) Bool() wasmlib.ScImmutableBool { - return wasmlib.NewScImmutableBool(s.id, wasmlib.KeyID(ParamBool)) +func (s ImmutableParamTypesParams) Bool() wasmtypes.ScImmutableBool { + return wasmtypes.NewScImmutableBool(s.proxy.Root(ParamBool)) } -func (s ImmutableParamTypesParams) Bytes() wasmlib.ScImmutableBytes { - return wasmlib.NewScImmutableBytes(s.id, wasmlib.KeyID(ParamBytes)) +func (s ImmutableParamTypesParams) Bytes() wasmtypes.ScImmutableBytes { + return wasmtypes.NewScImmutableBytes(s.proxy.Root(ParamBytes)) } -func (s ImmutableParamTypesParams) ChainID() wasmlib.ScImmutableChainID { - return wasmlib.NewScImmutableChainID(s.id, wasmlib.KeyID(ParamChainID)) +func (s ImmutableParamTypesParams) ChainID() wasmtypes.ScImmutableChainID { + return wasmtypes.NewScImmutableChainID(s.proxy.Root(ParamChainID)) } -func (s ImmutableParamTypesParams) Color() wasmlib.ScImmutableColor { - return wasmlib.NewScImmutableColor(s.id, wasmlib.KeyID(ParamColor)) +func (s ImmutableParamTypesParams) Color() wasmtypes.ScImmutableColor { + return wasmtypes.NewScImmutableColor(s.proxy.Root(ParamColor)) } -func (s ImmutableParamTypesParams) Hash() wasmlib.ScImmutableHash { - return wasmlib.NewScImmutableHash(s.id, wasmlib.KeyID(ParamHash)) +func (s ImmutableParamTypesParams) Hash() wasmtypes.ScImmutableHash { + return wasmtypes.NewScImmutableHash(s.proxy.Root(ParamHash)) } -func (s ImmutableParamTypesParams) Hname() wasmlib.ScImmutableHname { - return wasmlib.NewScImmutableHname(s.id, wasmlib.KeyID(ParamHname)) +func (s ImmutableParamTypesParams) Hname() wasmtypes.ScImmutableHname { + return wasmtypes.NewScImmutableHname(s.proxy.Root(ParamHname)) } -func (s ImmutableParamTypesParams) Int16() wasmlib.ScImmutableInt16 { - return wasmlib.NewScImmutableInt16(s.id, wasmlib.KeyID(ParamInt16)) +func (s ImmutableParamTypesParams) Int16() wasmtypes.ScImmutableInt16 { + return wasmtypes.NewScImmutableInt16(s.proxy.Root(ParamInt16)) } -func (s ImmutableParamTypesParams) Int32() wasmlib.ScImmutableInt32 { - return wasmlib.NewScImmutableInt32(s.id, wasmlib.KeyID(ParamInt32)) +func (s ImmutableParamTypesParams) Int32() wasmtypes.ScImmutableInt32 { + return wasmtypes.NewScImmutableInt32(s.proxy.Root(ParamInt32)) } -func (s ImmutableParamTypesParams) Int64() wasmlib.ScImmutableInt64 { - return wasmlib.NewScImmutableInt64(s.id, wasmlib.KeyID(ParamInt64)) +func (s ImmutableParamTypesParams) Int64() wasmtypes.ScImmutableInt64 { + return wasmtypes.NewScImmutableInt64(s.proxy.Root(ParamInt64)) } -func (s ImmutableParamTypesParams) Int8() wasmlib.ScImmutableInt8 { - return wasmlib.NewScImmutableInt8(s.id, wasmlib.KeyID(ParamInt8)) +func (s ImmutableParamTypesParams) Int8() wasmtypes.ScImmutableInt8 { + return wasmtypes.NewScImmutableInt8(s.proxy.Root(ParamInt8)) } func (s ImmutableParamTypesParams) Param() MapStringToImmutableBytes { - return MapStringToImmutableBytes{objID: s.id} + //nolint:gosimple + return MapStringToImmutableBytes{proxy: s.proxy} } -func (s ImmutableParamTypesParams) RequestID() wasmlib.ScImmutableRequestID { - return wasmlib.NewScImmutableRequestID(s.id, wasmlib.KeyID(ParamRequestID)) +func (s ImmutableParamTypesParams) RequestID() wasmtypes.ScImmutableRequestID { + return wasmtypes.NewScImmutableRequestID(s.proxy.Root(ParamRequestID)) } -func (s ImmutableParamTypesParams) String() wasmlib.ScImmutableString { - return wasmlib.NewScImmutableString(s.id, wasmlib.KeyID(ParamString)) +func (s ImmutableParamTypesParams) String() wasmtypes.ScImmutableString { + return wasmtypes.NewScImmutableString(s.proxy.Root(ParamString)) } -func (s ImmutableParamTypesParams) Uint16() wasmlib.ScImmutableUint16 { - return wasmlib.NewScImmutableUint16(s.id, wasmlib.KeyID(ParamUint16)) +func (s ImmutableParamTypesParams) Uint16() wasmtypes.ScImmutableUint16 { + return wasmtypes.NewScImmutableUint16(s.proxy.Root(ParamUint16)) } -func (s ImmutableParamTypesParams) Uint32() wasmlib.ScImmutableUint32 { - return wasmlib.NewScImmutableUint32(s.id, wasmlib.KeyID(ParamUint32)) +func (s ImmutableParamTypesParams) Uint32() wasmtypes.ScImmutableUint32 { + return wasmtypes.NewScImmutableUint32(s.proxy.Root(ParamUint32)) } -func (s ImmutableParamTypesParams) Uint64() wasmlib.ScImmutableUint64 { - return wasmlib.NewScImmutableUint64(s.id, wasmlib.KeyID(ParamUint64)) +func (s ImmutableParamTypesParams) Uint64() wasmtypes.ScImmutableUint64 { + return wasmtypes.NewScImmutableUint64(s.proxy.Root(ParamUint64)) } -func (s ImmutableParamTypesParams) Uint8() wasmlib.ScImmutableUint8 { - return wasmlib.NewScImmutableUint8(s.id, wasmlib.KeyID(ParamUint8)) +func (s ImmutableParamTypesParams) Uint8() wasmtypes.ScImmutableUint8 { + return wasmtypes.NewScImmutableUint8(s.proxy.Root(ParamUint8)) } type MapStringToMutableBytes struct { - objID int32 + proxy wasmtypes.Proxy } func (m MapStringToMutableBytes) Clear() { - wasmlib.Clear(m.objID) + m.proxy.ClearMap() } -func (m MapStringToMutableBytes) GetBytes(key string) wasmlib.ScMutableBytes { - return wasmlib.NewScMutableBytes(m.objID, wasmlib.Key(key).KeyID()) +func (m MapStringToMutableBytes) GetBytes(key string) wasmtypes.ScMutableBytes { + return wasmtypes.NewScMutableBytes(m.proxy.Key(wasmtypes.BytesFromString(key))) } type MutableParamTypesParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableParamTypesParams) Address() wasmlib.ScMutableAddress { - return wasmlib.NewScMutableAddress(s.id, wasmlib.KeyID(ParamAddress)) +func (s MutableParamTypesParams) Address() wasmtypes.ScMutableAddress { + return wasmtypes.NewScMutableAddress(s.proxy.Root(ParamAddress)) } -func (s MutableParamTypesParams) AgentID() wasmlib.ScMutableAgentID { - return wasmlib.NewScMutableAgentID(s.id, wasmlib.KeyID(ParamAgentID)) +func (s MutableParamTypesParams) AgentID() wasmtypes.ScMutableAgentID { + return wasmtypes.NewScMutableAgentID(s.proxy.Root(ParamAgentID)) } -func (s MutableParamTypesParams) Bool() wasmlib.ScMutableBool { - return wasmlib.NewScMutableBool(s.id, wasmlib.KeyID(ParamBool)) +func (s MutableParamTypesParams) Bool() wasmtypes.ScMutableBool { + return wasmtypes.NewScMutableBool(s.proxy.Root(ParamBool)) } -func (s MutableParamTypesParams) Bytes() wasmlib.ScMutableBytes { - return wasmlib.NewScMutableBytes(s.id, wasmlib.KeyID(ParamBytes)) +func (s MutableParamTypesParams) Bytes() wasmtypes.ScMutableBytes { + return wasmtypes.NewScMutableBytes(s.proxy.Root(ParamBytes)) } -func (s MutableParamTypesParams) ChainID() wasmlib.ScMutableChainID { - return wasmlib.NewScMutableChainID(s.id, wasmlib.KeyID(ParamChainID)) +func (s MutableParamTypesParams) ChainID() wasmtypes.ScMutableChainID { + return wasmtypes.NewScMutableChainID(s.proxy.Root(ParamChainID)) } -func (s MutableParamTypesParams) Color() wasmlib.ScMutableColor { - return wasmlib.NewScMutableColor(s.id, wasmlib.KeyID(ParamColor)) +func (s MutableParamTypesParams) Color() wasmtypes.ScMutableColor { + return wasmtypes.NewScMutableColor(s.proxy.Root(ParamColor)) } -func (s MutableParamTypesParams) Hash() wasmlib.ScMutableHash { - return wasmlib.NewScMutableHash(s.id, wasmlib.KeyID(ParamHash)) +func (s MutableParamTypesParams) Hash() wasmtypes.ScMutableHash { + return wasmtypes.NewScMutableHash(s.proxy.Root(ParamHash)) } -func (s MutableParamTypesParams) Hname() wasmlib.ScMutableHname { - return wasmlib.NewScMutableHname(s.id, wasmlib.KeyID(ParamHname)) +func (s MutableParamTypesParams) Hname() wasmtypes.ScMutableHname { + return wasmtypes.NewScMutableHname(s.proxy.Root(ParamHname)) } -func (s MutableParamTypesParams) Int16() wasmlib.ScMutableInt16 { - return wasmlib.NewScMutableInt16(s.id, wasmlib.KeyID(ParamInt16)) +func (s MutableParamTypesParams) Int16() wasmtypes.ScMutableInt16 { + return wasmtypes.NewScMutableInt16(s.proxy.Root(ParamInt16)) } -func (s MutableParamTypesParams) Int32() wasmlib.ScMutableInt32 { - return wasmlib.NewScMutableInt32(s.id, wasmlib.KeyID(ParamInt32)) +func (s MutableParamTypesParams) Int32() wasmtypes.ScMutableInt32 { + return wasmtypes.NewScMutableInt32(s.proxy.Root(ParamInt32)) } -func (s MutableParamTypesParams) Int64() wasmlib.ScMutableInt64 { - return wasmlib.NewScMutableInt64(s.id, wasmlib.KeyID(ParamInt64)) +func (s MutableParamTypesParams) Int64() wasmtypes.ScMutableInt64 { + return wasmtypes.NewScMutableInt64(s.proxy.Root(ParamInt64)) } -func (s MutableParamTypesParams) Int8() wasmlib.ScMutableInt8 { - return wasmlib.NewScMutableInt8(s.id, wasmlib.KeyID(ParamInt8)) +func (s MutableParamTypesParams) Int8() wasmtypes.ScMutableInt8 { + return wasmtypes.NewScMutableInt8(s.proxy.Root(ParamInt8)) } func (s MutableParamTypesParams) Param() MapStringToMutableBytes { - return MapStringToMutableBytes{objID: s.id} + //nolint:gosimple + return MapStringToMutableBytes{proxy: s.proxy} } -func (s MutableParamTypesParams) RequestID() wasmlib.ScMutableRequestID { - return wasmlib.NewScMutableRequestID(s.id, wasmlib.KeyID(ParamRequestID)) +func (s MutableParamTypesParams) RequestID() wasmtypes.ScMutableRequestID { + return wasmtypes.NewScMutableRequestID(s.proxy.Root(ParamRequestID)) } -func (s MutableParamTypesParams) String() wasmlib.ScMutableString { - return wasmlib.NewScMutableString(s.id, wasmlib.KeyID(ParamString)) +func (s MutableParamTypesParams) String() wasmtypes.ScMutableString { + return wasmtypes.NewScMutableString(s.proxy.Root(ParamString)) } -func (s MutableParamTypesParams) Uint16() wasmlib.ScMutableUint16 { - return wasmlib.NewScMutableUint16(s.id, wasmlib.KeyID(ParamUint16)) +func (s MutableParamTypesParams) Uint16() wasmtypes.ScMutableUint16 { + return wasmtypes.NewScMutableUint16(s.proxy.Root(ParamUint16)) } -func (s MutableParamTypesParams) Uint32() wasmlib.ScMutableUint32 { - return wasmlib.NewScMutableUint32(s.id, wasmlib.KeyID(ParamUint32)) +func (s MutableParamTypesParams) Uint32() wasmtypes.ScMutableUint32 { + return wasmtypes.NewScMutableUint32(s.proxy.Root(ParamUint32)) } -func (s MutableParamTypesParams) Uint64() wasmlib.ScMutableUint64 { - return wasmlib.NewScMutableUint64(s.id, wasmlib.KeyID(ParamUint64)) +func (s MutableParamTypesParams) Uint64() wasmtypes.ScMutableUint64 { + return wasmtypes.NewScMutableUint64(s.proxy.Root(ParamUint64)) } -func (s MutableParamTypesParams) Uint8() wasmlib.ScMutableUint8 { - return wasmlib.NewScMutableUint8(s.id, wasmlib.KeyID(ParamUint8)) +func (s MutableParamTypesParams) Uint8() wasmtypes.ScMutableUint8 { + return wasmtypes.NewScMutableUint8(s.proxy.Root(ParamUint8)) } type ImmutableTriggerEventParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableTriggerEventParams) Address() wasmlib.ScImmutableAddress { - return wasmlib.NewScImmutableAddress(s.id, wasmlib.KeyID(ParamAddress)) +func (s ImmutableTriggerEventParams) Address() wasmtypes.ScImmutableAddress { + return wasmtypes.NewScImmutableAddress(s.proxy.Root(ParamAddress)) } -func (s ImmutableTriggerEventParams) Name() wasmlib.ScImmutableString { - return wasmlib.NewScImmutableString(s.id, wasmlib.KeyID(ParamName)) +func (s ImmutableTriggerEventParams) Name() wasmtypes.ScImmutableString { + return wasmtypes.NewScImmutableString(s.proxy.Root(ParamName)) } type MutableTriggerEventParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableTriggerEventParams) Address() wasmlib.ScMutableAddress { - return wasmlib.NewScMutableAddress(s.id, wasmlib.KeyID(ParamAddress)) +func (s MutableTriggerEventParams) Address() wasmtypes.ScMutableAddress { + return wasmtypes.NewScMutableAddress(s.proxy.Root(ParamAddress)) } -func (s MutableTriggerEventParams) Name() wasmlib.ScMutableString { - return wasmlib.NewScMutableString(s.id, wasmlib.KeyID(ParamName)) +func (s MutableTriggerEventParams) Name() wasmtypes.ScMutableString { + return wasmtypes.NewScMutableString(s.proxy.Root(ParamName)) } type ImmutableArrayLengthParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableArrayLengthParams) Name() wasmlib.ScImmutableString { - return wasmlib.NewScImmutableString(s.id, wasmlib.KeyID(ParamName)) +func (s ImmutableArrayLengthParams) Name() wasmtypes.ScImmutableString { + return wasmtypes.NewScImmutableString(s.proxy.Root(ParamName)) } type MutableArrayLengthParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableArrayLengthParams) Name() wasmlib.ScMutableString { - return wasmlib.NewScMutableString(s.id, wasmlib.KeyID(ParamName)) +func (s MutableArrayLengthParams) Name() wasmtypes.ScMutableString { + return wasmtypes.NewScMutableString(s.proxy.Root(ParamName)) } type ImmutableArrayValueParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableArrayValueParams) Index() wasmlib.ScImmutableInt32 { - return wasmlib.NewScImmutableInt32(s.id, wasmlib.KeyID(ParamIndex)) +func (s ImmutableArrayValueParams) Index() wasmtypes.ScImmutableUint32 { + return wasmtypes.NewScImmutableUint32(s.proxy.Root(ParamIndex)) } -func (s ImmutableArrayValueParams) Name() wasmlib.ScImmutableString { - return wasmlib.NewScImmutableString(s.id, wasmlib.KeyID(ParamName)) +func (s ImmutableArrayValueParams) Name() wasmtypes.ScImmutableString { + return wasmtypes.NewScImmutableString(s.proxy.Root(ParamName)) } type MutableArrayValueParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableArrayValueParams) Index() wasmlib.ScMutableInt32 { - return wasmlib.NewScMutableInt32(s.id, wasmlib.KeyID(ParamIndex)) +func (s MutableArrayValueParams) Index() wasmtypes.ScMutableUint32 { + return wasmtypes.NewScMutableUint32(s.proxy.Root(ParamIndex)) } -func (s MutableArrayValueParams) Name() wasmlib.ScMutableString { - return wasmlib.NewScMutableString(s.id, wasmlib.KeyID(ParamName)) +func (s MutableArrayValueParams) Name() wasmtypes.ScMutableString { + return wasmtypes.NewScMutableString(s.proxy.Root(ParamName)) } type ImmutableBlockRecordParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableBlockRecordParams) BlockIndex() wasmlib.ScImmutableInt32 { - return wasmlib.NewScImmutableInt32(s.id, wasmlib.KeyID(ParamBlockIndex)) +func (s ImmutableBlockRecordParams) BlockIndex() wasmtypes.ScImmutableUint32 { + return wasmtypes.NewScImmutableUint32(s.proxy.Root(ParamBlockIndex)) } -func (s ImmutableBlockRecordParams) RecordIndex() wasmlib.ScImmutableInt32 { - return wasmlib.NewScImmutableInt32(s.id, wasmlib.KeyID(ParamRecordIndex)) +func (s ImmutableBlockRecordParams) RecordIndex() wasmtypes.ScImmutableUint32 { + return wasmtypes.NewScImmutableUint32(s.proxy.Root(ParamRecordIndex)) } type MutableBlockRecordParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableBlockRecordParams) BlockIndex() wasmlib.ScMutableInt32 { - return wasmlib.NewScMutableInt32(s.id, wasmlib.KeyID(ParamBlockIndex)) +func (s MutableBlockRecordParams) BlockIndex() wasmtypes.ScMutableUint32 { + return wasmtypes.NewScMutableUint32(s.proxy.Root(ParamBlockIndex)) } -func (s MutableBlockRecordParams) RecordIndex() wasmlib.ScMutableInt32 { - return wasmlib.NewScMutableInt32(s.id, wasmlib.KeyID(ParamRecordIndex)) +func (s MutableBlockRecordParams) RecordIndex() wasmtypes.ScMutableUint32 { + return wasmtypes.NewScMutableUint32(s.proxy.Root(ParamRecordIndex)) } type ImmutableBlockRecordsParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableBlockRecordsParams) BlockIndex() wasmlib.ScImmutableInt32 { - return wasmlib.NewScImmutableInt32(s.id, wasmlib.KeyID(ParamBlockIndex)) +func (s ImmutableBlockRecordsParams) BlockIndex() wasmtypes.ScImmutableUint32 { + return wasmtypes.NewScImmutableUint32(s.proxy.Root(ParamBlockIndex)) } type MutableBlockRecordsParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableBlockRecordsParams) BlockIndex() wasmlib.ScMutableInt32 { - return wasmlib.NewScMutableInt32(s.id, wasmlib.KeyID(ParamBlockIndex)) +func (s MutableBlockRecordsParams) BlockIndex() wasmtypes.ScMutableUint32 { + return wasmtypes.NewScMutableUint32(s.proxy.Root(ParamBlockIndex)) } type ImmutableMapValueParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableMapValueParams) Key() wasmlib.ScImmutableString { - return wasmlib.NewScImmutableString(s.id, wasmlib.KeyID(ParamKey)) +func (s ImmutableMapValueParams) Key() wasmtypes.ScImmutableString { + return wasmtypes.NewScImmutableString(s.proxy.Root(ParamKey)) } -func (s ImmutableMapValueParams) Name() wasmlib.ScImmutableString { - return wasmlib.NewScImmutableString(s.id, wasmlib.KeyID(ParamName)) +func (s ImmutableMapValueParams) Name() wasmtypes.ScImmutableString { + return wasmtypes.NewScImmutableString(s.proxy.Root(ParamName)) } type MutableMapValueParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableMapValueParams) Key() wasmlib.ScMutableString { - return wasmlib.NewScMutableString(s.id, wasmlib.KeyID(ParamKey)) +func (s MutableMapValueParams) Key() wasmtypes.ScMutableString { + return wasmtypes.NewScMutableString(s.proxy.Root(ParamKey)) } -func (s MutableMapValueParams) Name() wasmlib.ScMutableString { - return wasmlib.NewScMutableString(s.id, wasmlib.KeyID(ParamName)) +func (s MutableMapValueParams) Name() wasmtypes.ScMutableString { + return wasmtypes.NewScMutableString(s.proxy.Root(ParamName)) } diff --git a/contracts/wasm/testwasmlib/go/testwasmlib/results.go b/contracts/wasm/testwasmlib/go/testwasmlib/results.go index 4426bd9cea..7c05a07dbd 100644 --- a/contracts/wasm/testwasmlib/go/testwasmlib/results.go +++ b/contracts/wasm/testwasmlib/go/testwasmlib/results.go @@ -7,116 +7,116 @@ package testwasmlib -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" +import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" type ImmutableArrayLengthResults struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableArrayLengthResults) Length() wasmlib.ScImmutableInt32 { - return wasmlib.NewScImmutableInt32(s.id, wasmlib.KeyID(ResultLength)) +func (s ImmutableArrayLengthResults) Length() wasmtypes.ScImmutableUint32 { + return wasmtypes.NewScImmutableUint32(s.proxy.Root(ResultLength)) } type MutableArrayLengthResults struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableArrayLengthResults) Length() wasmlib.ScMutableInt32 { - return wasmlib.NewScMutableInt32(s.id, wasmlib.KeyID(ResultLength)) +func (s MutableArrayLengthResults) Length() wasmtypes.ScMutableUint32 { + return wasmtypes.NewScMutableUint32(s.proxy.Root(ResultLength)) } type ImmutableArrayValueResults struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableArrayValueResults) Value() wasmlib.ScImmutableString { - return wasmlib.NewScImmutableString(s.id, wasmlib.KeyID(ResultValue)) +func (s ImmutableArrayValueResults) Value() wasmtypes.ScImmutableString { + return wasmtypes.NewScImmutableString(s.proxy.Root(ResultValue)) } type MutableArrayValueResults struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableArrayValueResults) Value() wasmlib.ScMutableString { - return wasmlib.NewScMutableString(s.id, wasmlib.KeyID(ResultValue)) +func (s MutableArrayValueResults) Value() wasmtypes.ScMutableString { + return wasmtypes.NewScMutableString(s.proxy.Root(ResultValue)) } type ImmutableBlockRecordResults struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableBlockRecordResults) Record() wasmlib.ScImmutableBytes { - return wasmlib.NewScImmutableBytes(s.id, wasmlib.KeyID(ResultRecord)) +func (s ImmutableBlockRecordResults) Record() wasmtypes.ScImmutableBytes { + return wasmtypes.NewScImmutableBytes(s.proxy.Root(ResultRecord)) } type MutableBlockRecordResults struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableBlockRecordResults) Record() wasmlib.ScMutableBytes { - return wasmlib.NewScMutableBytes(s.id, wasmlib.KeyID(ResultRecord)) +func (s MutableBlockRecordResults) Record() wasmtypes.ScMutableBytes { + return wasmtypes.NewScMutableBytes(s.proxy.Root(ResultRecord)) } type ImmutableBlockRecordsResults struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableBlockRecordsResults) Count() wasmlib.ScImmutableInt32 { - return wasmlib.NewScImmutableInt32(s.id, wasmlib.KeyID(ResultCount)) +func (s ImmutableBlockRecordsResults) Count() wasmtypes.ScImmutableUint32 { + return wasmtypes.NewScImmutableUint32(s.proxy.Root(ResultCount)) } type MutableBlockRecordsResults struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableBlockRecordsResults) Count() wasmlib.ScMutableInt32 { - return wasmlib.NewScMutableInt32(s.id, wasmlib.KeyID(ResultCount)) +func (s MutableBlockRecordsResults) Count() wasmtypes.ScMutableUint32 { + return wasmtypes.NewScMutableUint32(s.proxy.Root(ResultCount)) } type ImmutableGetRandomResults struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableGetRandomResults) Random() wasmlib.ScImmutableInt64 { - return wasmlib.NewScImmutableInt64(s.id, wasmlib.KeyID(ResultRandom)) +func (s ImmutableGetRandomResults) Random() wasmtypes.ScImmutableUint64 { + return wasmtypes.NewScImmutableUint64(s.proxy.Root(ResultRandom)) } type MutableGetRandomResults struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableGetRandomResults) Random() wasmlib.ScMutableInt64 { - return wasmlib.NewScMutableInt64(s.id, wasmlib.KeyID(ResultRandom)) +func (s MutableGetRandomResults) Random() wasmtypes.ScMutableUint64 { + return wasmtypes.NewScMutableUint64(s.proxy.Root(ResultRandom)) } type ImmutableIotaBalanceResults struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableIotaBalanceResults) Iotas() wasmlib.ScImmutableInt64 { - return wasmlib.NewScImmutableInt64(s.id, wasmlib.KeyID(ResultIotas)) +func (s ImmutableIotaBalanceResults) Iotas() wasmtypes.ScImmutableUint64 { + return wasmtypes.NewScImmutableUint64(s.proxy.Root(ResultIotas)) } type MutableIotaBalanceResults struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableIotaBalanceResults) Iotas() wasmlib.ScMutableInt64 { - return wasmlib.NewScMutableInt64(s.id, wasmlib.KeyID(ResultIotas)) +func (s MutableIotaBalanceResults) Iotas() wasmtypes.ScMutableUint64 { + return wasmtypes.NewScMutableUint64(s.proxy.Root(ResultIotas)) } type ImmutableMapValueResults struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableMapValueResults) Value() wasmlib.ScImmutableString { - return wasmlib.NewScImmutableString(s.id, wasmlib.KeyID(ResultValue)) +func (s ImmutableMapValueResults) Value() wasmtypes.ScImmutableString { + return wasmtypes.NewScImmutableString(s.proxy.Root(ResultValue)) } type MutableMapValueResults struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableMapValueResults) Value() wasmlib.ScMutableString { - return wasmlib.NewScMutableString(s.id, wasmlib.KeyID(ResultValue)) +func (s MutableMapValueResults) Value() wasmtypes.ScMutableString { + return wasmtypes.NewScMutableString(s.proxy.Root(ResultValue)) } diff --git a/contracts/wasm/testwasmlib/go/testwasmlib/state.go b/contracts/wasm/testwasmlib/go/testwasmlib/state.go index 47bd6093a9..5e1f3ccf87 100644 --- a/contracts/wasm/testwasmlib/go/testwasmlib/state.go +++ b/contracts/wasm/testwasmlib/go/testwasmlib/state.go @@ -7,72 +7,66 @@ package testwasmlib -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" +import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" type MapStringToImmutableStringArray struct { - objID int32 + proxy wasmtypes.Proxy } func (m MapStringToImmutableStringArray) GetStringArray(key string) ImmutableStringArray { - subID := wasmlib.GetObjectID(m.objID, wasmlib.Key(key).KeyID(), wasmlib.TYPE_ARRAY|wasmlib.TYPE_STRING) - return ImmutableStringArray{objID: subID} + return ImmutableStringArray{proxy: m.proxy.Key(wasmtypes.BytesFromString(key))} } type MapStringToImmutableStringMap struct { - objID int32 + proxy wasmtypes.Proxy } func (m MapStringToImmutableStringMap) GetStringMap(key string) ImmutableStringMap { - subID := wasmlib.GetObjectID(m.objID, wasmlib.Key(key).KeyID(), wasmlib.TYPE_MAP) - return ImmutableStringMap{objID: subID} + return ImmutableStringMap{proxy: m.proxy.Key(wasmtypes.BytesFromString(key))} } type ImmutableTestWasmLibState struct { - id int32 + proxy wasmtypes.Proxy } func (s ImmutableTestWasmLibState) Arrays() MapStringToImmutableStringArray { - mapID := wasmlib.GetObjectID(s.id, wasmlib.KeyID(StateArrays), wasmlib.TYPE_MAP) - return MapStringToImmutableStringArray{objID: mapID} + return MapStringToImmutableStringArray{proxy: s.proxy.Root(StateArrays)} } func (s ImmutableTestWasmLibState) Maps() MapStringToImmutableStringMap { - mapID := wasmlib.GetObjectID(s.id, wasmlib.KeyID(StateMaps), wasmlib.TYPE_MAP) - return MapStringToImmutableStringMap{objID: mapID} + return MapStringToImmutableStringMap{proxy: s.proxy.Root(StateMaps)} } -func (s ImmutableTestWasmLibState) Random() wasmlib.ScImmutableInt64 { - return wasmlib.NewScImmutableInt64(s.id, wasmlib.KeyID(StateRandom)) +func (s ImmutableTestWasmLibState) Random() wasmtypes.ScImmutableUint64 { + return wasmtypes.NewScImmutableUint64(s.proxy.Root(StateRandom)) } type MapStringToMutableStringArray struct { - objID int32 + proxy wasmtypes.Proxy } func (m MapStringToMutableStringArray) Clear() { - wasmlib.Clear(m.objID) + m.proxy.ClearMap() } func (m MapStringToMutableStringArray) GetStringArray(key string) MutableStringArray { - subID := wasmlib.GetObjectID(m.objID, wasmlib.Key(key).KeyID(), wasmlib.TYPE_ARRAY|wasmlib.TYPE_STRING) - return MutableStringArray{objID: subID} + return MutableStringArray{proxy: m.proxy.Key(wasmtypes.BytesFromString(key))} } type MapStringToMutableStringMap struct { - objID int32 + proxy wasmtypes.Proxy } func (m MapStringToMutableStringMap) Clear() { - wasmlib.Clear(m.objID) + m.proxy.ClearMap() } func (m MapStringToMutableStringMap) GetStringMap(key string) MutableStringMap { - subID := wasmlib.GetObjectID(m.objID, wasmlib.Key(key).KeyID(), wasmlib.TYPE_MAP) - return MutableStringMap{objID: subID} + return MutableStringMap{proxy: m.proxy.Key(wasmtypes.BytesFromString(key))} } type MutableTestWasmLibState struct { - id int32 + proxy wasmtypes.Proxy } func (s MutableTestWasmLibState) AsImmutable() ImmutableTestWasmLibState { @@ -80,15 +74,13 @@ func (s MutableTestWasmLibState) AsImmutable() ImmutableTestWasmLibState { } func (s MutableTestWasmLibState) Arrays() MapStringToMutableStringArray { - mapID := wasmlib.GetObjectID(s.id, wasmlib.KeyID(StateArrays), wasmlib.TYPE_MAP) - return MapStringToMutableStringArray{objID: mapID} + return MapStringToMutableStringArray{proxy: s.proxy.Root(StateArrays)} } func (s MutableTestWasmLibState) Maps() MapStringToMutableStringMap { - mapID := wasmlib.GetObjectID(s.id, wasmlib.KeyID(StateMaps), wasmlib.TYPE_MAP) - return MapStringToMutableStringMap{objID: mapID} + return MapStringToMutableStringMap{proxy: s.proxy.Root(StateMaps)} } -func (s MutableTestWasmLibState) Random() wasmlib.ScMutableInt64 { - return wasmlib.NewScMutableInt64(s.id, wasmlib.KeyID(StateRandom)) +func (s MutableTestWasmLibState) Random() wasmtypes.ScMutableUint64 { + return wasmtypes.NewScMutableUint64(s.proxy.Root(StateRandom)) } diff --git a/contracts/wasm/testwasmlib/go/testwasmlib/structs.go b/contracts/wasm/testwasmlib/go/testwasmlib/structs.go index f57de29a9d..bdfd327928 100644 --- a/contracts/wasm/testwasmlib/go/testwasmlib/structs.go +++ b/contracts/wasm/testwasmlib/go/testwasmlib/structs.go @@ -7,59 +7,243 @@ package testwasmlib -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" +import ( + "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmcodec" + "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" +) -type Location struct { - X int32 - Y int32 +type CallRequest struct { + Contract wasmtypes.ScHname + Function wasmtypes.ScHname + Params []byte + Transfer []byte } -func NewLocationFromBytes(bytes []byte) *Location { - decode := wasmlib.NewBytesDecoder(bytes) - data := &Location{} - data.X = decode.Int32() - data.Y = decode.Int32() - decode.Close() +func NewCallRequestFromBytes(buf []byte) *CallRequest { + dec := wasmcodec.NewWasmDecoder(buf) + data := &CallRequest{} + data.Contract = wasmtypes.DecodeHname(dec) + data.Function = wasmtypes.DecodeHname(dec) + data.Params = wasmtypes.DecodeBytes(dec) + data.Transfer = wasmtypes.DecodeBytes(dec) + dec.Close() return data } -func (o *Location) Bytes() []byte { - return wasmlib.NewBytesEncoder(). - Int32(o.X). - Int32(o.Y). - Data() +func (o *CallRequest) Bytes() []byte { + enc := wasmcodec.NewWasmEncoder() + wasmtypes.EncodeHname(enc, o.Contract) + wasmtypes.EncodeHname(enc, o.Function) + wasmtypes.EncodeBytes(enc, o.Params) + wasmtypes.EncodeBytes(enc, o.Transfer) + return enc.Buf() } -type ImmutableLocation struct { - objID int32 - keyID wasmlib.Key32 +type ImmutableCallRequest struct { + proxy wasmtypes.Proxy } -func (o ImmutableLocation) Exists() bool { - return wasmlib.Exists(o.objID, o.keyID, wasmlib.TYPE_BYTES) +func (o ImmutableCallRequest) Exists() bool { + return o.proxy.Exists() } -func (o ImmutableLocation) Value() *Location { - return NewLocationFromBytes(wasmlib.GetBytes(o.objID, o.keyID, wasmlib.TYPE_BYTES)) +func (o ImmutableCallRequest) Value() *CallRequest { + return NewCallRequestFromBytes(o.proxy.Get()) } -type MutableLocation struct { - objID int32 - keyID wasmlib.Key32 +type MutableCallRequest struct { + proxy wasmtypes.Proxy } -func (o MutableLocation) Delete() { - wasmlib.DelKey(o.objID, o.keyID, wasmlib.TYPE_BYTES) +func (o MutableCallRequest) Delete() { + o.proxy.Delete() } -func (o MutableLocation) Exists() bool { - return wasmlib.Exists(o.objID, o.keyID, wasmlib.TYPE_BYTES) +func (o MutableCallRequest) Exists() bool { + return o.proxy.Exists() } -func (o MutableLocation) SetValue(value *Location) { - wasmlib.SetBytes(o.objID, o.keyID, wasmlib.TYPE_BYTES, value.Bytes()) +func (o MutableCallRequest) SetValue(value *CallRequest) { + o.proxy.Set(value.Bytes()) } -func (o MutableLocation) Value() *Location { - return NewLocationFromBytes(wasmlib.GetBytes(o.objID, o.keyID, wasmlib.TYPE_BYTES)) +func (o MutableCallRequest) Value() *CallRequest { + return NewCallRequestFromBytes(o.proxy.Get()) +} + +type DeployRequest struct { + Description string + Name string + Params []byte + ProgHash wasmtypes.ScHash +} + +func NewDeployRequestFromBytes(buf []byte) *DeployRequest { + dec := wasmcodec.NewWasmDecoder(buf) + data := &DeployRequest{} + data.Description = wasmtypes.DecodeString(dec) + data.Name = wasmtypes.DecodeString(dec) + data.Params = wasmtypes.DecodeBytes(dec) + data.ProgHash = wasmtypes.DecodeHash(dec) + dec.Close() + return data +} + +func (o *DeployRequest) Bytes() []byte { + enc := wasmcodec.NewWasmEncoder() + wasmtypes.EncodeString(enc, o.Description) + wasmtypes.EncodeString(enc, o.Name) + wasmtypes.EncodeBytes(enc, o.Params) + wasmtypes.EncodeHash(enc, o.ProgHash) + return enc.Buf() +} + +type ImmutableDeployRequest struct { + proxy wasmtypes.Proxy +} + +func (o ImmutableDeployRequest) Exists() bool { + return o.proxy.Exists() +} + +func (o ImmutableDeployRequest) Value() *DeployRequest { + return NewDeployRequestFromBytes(o.proxy.Get()) +} + +type MutableDeployRequest struct { + proxy wasmtypes.Proxy +} + +func (o MutableDeployRequest) Delete() { + o.proxy.Delete() +} + +func (o MutableDeployRequest) Exists() bool { + return o.proxy.Exists() +} + +func (o MutableDeployRequest) SetValue(value *DeployRequest) { + o.proxy.Set(value.Bytes()) +} + +func (o MutableDeployRequest) Value() *DeployRequest { + return NewDeployRequestFromBytes(o.proxy.Get()) +} + +type PostRequest struct { + ChainID wasmtypes.ScChainID + Contract wasmtypes.ScHname + Delay uint32 + Function wasmtypes.ScHname + Params []byte + Transfer []byte +} + +func NewPostRequestFromBytes(buf []byte) *PostRequest { + dec := wasmcodec.NewWasmDecoder(buf) + data := &PostRequest{} + data.ChainID = wasmtypes.DecodeChainID(dec) + data.Contract = wasmtypes.DecodeHname(dec) + data.Delay = wasmtypes.DecodeUint32(dec) + data.Function = wasmtypes.DecodeHname(dec) + data.Params = wasmtypes.DecodeBytes(dec) + data.Transfer = wasmtypes.DecodeBytes(dec) + dec.Close() + return data +} + +func (o *PostRequest) Bytes() []byte { + enc := wasmcodec.NewWasmEncoder() + wasmtypes.EncodeChainID(enc, o.ChainID) + wasmtypes.EncodeHname(enc, o.Contract) + wasmtypes.EncodeUint32(enc, o.Delay) + wasmtypes.EncodeHname(enc, o.Function) + wasmtypes.EncodeBytes(enc, o.Params) + wasmtypes.EncodeBytes(enc, o.Transfer) + return enc.Buf() +} + +type ImmutablePostRequest struct { + proxy wasmtypes.Proxy +} + +func (o ImmutablePostRequest) Exists() bool { + return o.proxy.Exists() +} + +func (o ImmutablePostRequest) Value() *PostRequest { + return NewPostRequestFromBytes(o.proxy.Get()) +} + +type MutablePostRequest struct { + proxy wasmtypes.Proxy +} + +func (o MutablePostRequest) Delete() { + o.proxy.Delete() +} + +func (o MutablePostRequest) Exists() bool { + return o.proxy.Exists() +} + +func (o MutablePostRequest) SetValue(value *PostRequest) { + o.proxy.Set(value.Bytes()) +} + +func (o MutablePostRequest) Value() *PostRequest { + return NewPostRequestFromBytes(o.proxy.Get()) +} + +type SendRequest struct { + Address wasmtypes.ScAddress + Transfer []byte +} + +func NewSendRequestFromBytes(buf []byte) *SendRequest { + dec := wasmcodec.NewWasmDecoder(buf) + data := &SendRequest{} + data.Address = wasmtypes.DecodeAddress(dec) + data.Transfer = wasmtypes.DecodeBytes(dec) + dec.Close() + return data +} + +func (o *SendRequest) Bytes() []byte { + enc := wasmcodec.NewWasmEncoder() + wasmtypes.EncodeAddress(enc, o.Address) + wasmtypes.EncodeBytes(enc, o.Transfer) + return enc.Buf() +} + +type ImmutableSendRequest struct { + proxy wasmtypes.Proxy +} + +func (o ImmutableSendRequest) Exists() bool { + return o.proxy.Exists() +} + +func (o ImmutableSendRequest) Value() *SendRequest { + return NewSendRequestFromBytes(o.proxy.Get()) +} + +type MutableSendRequest struct { + proxy wasmtypes.Proxy +} + +func (o MutableSendRequest) Delete() { + o.proxy.Delete() +} + +func (o MutableSendRequest) Exists() bool { + return o.proxy.Exists() +} + +func (o MutableSendRequest) SetValue(value *SendRequest) { + o.proxy.Set(value.Bytes()) +} + +func (o MutableSendRequest) Value() *SendRequest { + return NewSendRequestFromBytes(o.proxy.Get()) } diff --git a/contracts/wasm/testwasmlib/go/testwasmlib/testwasmlib.go b/contracts/wasm/testwasmlib/go/testwasmlib/testwasmlib.go index 8efb37d99e..afda26d9d5 100644 --- a/contracts/wasm/testwasmlib/go/testwasmlib/testwasmlib.go +++ b/contracts/wasm/testwasmlib/go/testwasmlib/testwasmlib.go @@ -8,8 +8,44 @@ import ( "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/coreblocklog" + "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" ) +func funcArrayAppend(ctx wasmlib.ScFuncContext, f *ArrayAppendContext) { + name := f.Params.Name().Value() + array := f.State.Arrays().GetStringArray(name) + value := f.Params.Value().Value() + array.AppendString().SetValue(value) +} + +func funcArrayClear(ctx wasmlib.ScFuncContext, f *ArrayClearContext) { + name := f.Params.Name().Value() + array := f.State.Arrays().GetStringArray(name) + array.Clear() +} + +func funcArraySet(ctx wasmlib.ScFuncContext, f *ArraySetContext) { + name := f.Params.Name().Value() + array := f.State.Arrays().GetStringArray(name) + index := f.Params.Index().Value() + value := f.Params.Value().Value() + array.GetString(index).SetValue(value) +} + +func funcMapClear(ctx wasmlib.ScFuncContext, f *MapClearContext) { + name := f.Params.Name().Value() + myMap := f.State.Maps().GetStringMap(name) + myMap.Clear() +} + +func funcMapSet(ctx wasmlib.ScFuncContext, f *MapSetContext) { + name := f.Params.Name().Value() + myMap := f.State.Maps().GetStringMap(name) + key := f.Params.Key().Value() + value := f.Params.Value().Value() + myMap.GetString(key).SetValue(value) +} + func funcParamTypes(ctx wasmlib.ScFuncContext, f *ParamTypesContext) { if f.Params.Address().Exists() { ctx.Require(f.Params.Address().Value() == ctx.AccountID().Address(), "mismatch: Address") @@ -28,11 +64,11 @@ func funcParamTypes(ctx wasmlib.ScFuncContext, f *ParamTypesContext) { ctx.Require(f.Params.ChainID().Value() == ctx.ChainID(), "mismatch: ChainID") } if f.Params.Color().Exists() { - color := wasmlib.NewScColorFromBytes([]byte("RedGreenBlueYellowCyanBlackWhite")) + color := wasmtypes.ColorFromBytes([]byte("RedGreenBlueYellowCyanBlackWhite")) ctx.Require(f.Params.Color().Value() == color, "mismatch: Color") } if f.Params.Hash().Exists() { - hash := wasmlib.NewScHashFromBytes([]byte("0123456789abcdeffedcba9876543210")) + hash := wasmtypes.HashFromBytes([]byte("0123456789abcdeffedcba9876543210")) ctx.Require(f.Params.Hash().Value() == hash, "mismatch: Hash") } if f.Params.Hname().Exists() { @@ -51,7 +87,7 @@ func funcParamTypes(ctx wasmlib.ScFuncContext, f *ParamTypesContext) { ctx.Require(f.Params.Int64().Value() == -1234567890123456789, "mismatch: Int64") } if f.Params.RequestID().Exists() { - requestID := wasmlib.NewScRequestIDFromBytes([]byte("abcdefghijklmnopqrstuvwxyz123456\x00\x00")) + requestID := wasmtypes.RequestIDFromBytes([]byte("abcdefghijklmnopqrstuvwxyz123456\x00\x00")) ctx.Require(f.Params.RequestID().Value() == requestID, "mismatch: RequestID") } if f.Params.String().Exists() { @@ -71,40 +107,20 @@ func funcParamTypes(ctx wasmlib.ScFuncContext, f *ParamTypesContext) { } } -func viewBlockRecord(ctx wasmlib.ScViewContext, f *BlockRecordContext) { - records := coreblocklog.ScFuncs.GetRequestReceiptsForBlock(ctx) - records.Params.BlockIndex().SetValue(f.Params.BlockIndex().Value()) - records.Func.Call() - recordIndex := f.Params.RecordIndex().Value() - ctx.Require(recordIndex < records.Results.RequestRecord().Length(), "invalid recordIndex") - f.Results.Record().SetValue(records.Results.RequestRecord().GetBytes(recordIndex).Value()) -} - -func viewBlockRecords(ctx wasmlib.ScViewContext, f *BlockRecordsContext) { - records := coreblocklog.ScFuncs.GetRequestReceiptsForBlock(ctx) - records.Params.BlockIndex().SetValue(f.Params.BlockIndex().Value()) - records.Func.Call() - f.Results.Count().SetValue(records.Results.RequestRecord().Length()) -} - -func funcArrayClear(ctx wasmlib.ScFuncContext, f *ArrayClearContext) { - name := f.Params.Name().Value() - array := f.State.Arrays().GetStringArray(name) - array.Clear() +func funcRandom(ctx wasmlib.ScFuncContext, f *RandomContext) { + f.State.Random().SetValue(ctx.Random(1000)) } -func funcArrayCreate(ctx wasmlib.ScFuncContext, f *ArrayCreateContext) { - name := f.Params.Name().Value() - array := f.State.Arrays().GetStringArray(name) - array.Clear() +func funcTriggerEvent(ctx wasmlib.ScFuncContext, f *TriggerEventContext) { + f.Events.Test(f.Params.Address().Value(), f.Params.Name().Value()) } -func funcArraySet(ctx wasmlib.ScFuncContext, f *ArraySetContext) { +func viewArrayValue(ctx wasmlib.ScViewContext, f *ArrayValueContext) { name := f.Params.Name().Value() array := f.State.Arrays().GetStringArray(name) index := f.Params.Index().Value() - value := f.Params.Value().Value() - array.GetString(index).SetValue(value) + value := array.GetString(index).Value() + f.Results.Value().SetValue(value) } func viewArrayLength(ctx wasmlib.ScViewContext, f *ArrayLengthContext) { @@ -114,48 +130,28 @@ func viewArrayLength(ctx wasmlib.ScViewContext, f *ArrayLengthContext) { f.Results.Length().SetValue(length) } -func viewArrayValue(ctx wasmlib.ScViewContext, f *ArrayValueContext) { - name := f.Params.Name().Value() - array := f.State.Arrays().GetStringArray(name) - index := f.Params.Index().Value() - value := array.GetString(index).Value() - f.Results.Value().SetValue(value) -} - -func viewIotaBalance(ctx wasmlib.ScViewContext, f *IotaBalanceContext) { - f.Results.Iotas().SetValue(ctx.Balances().Balance(wasmlib.IOTA)) +func viewBlockRecord(ctx wasmlib.ScViewContext, f *BlockRecordContext) { + records := coreblocklog.ScFuncs.GetRequestReceiptsForBlock(ctx) + records.Params.BlockIndex().SetValue(f.Params.BlockIndex().Value()) + records.Func.Call() + recordIndex := f.Params.RecordIndex().Value() + ctx.Require(recordIndex < records.Results.RequestRecord().Length(), "invalid recordIndex") + f.Results.Record().SetValue(records.Results.RequestRecord().GetBytes(recordIndex).Value()) } -func funcRandom(ctx wasmlib.ScFuncContext, f *RandomContext) { - f.State.Random().SetValue(ctx.Random(1000)) +func viewBlockRecords(ctx wasmlib.ScViewContext, f *BlockRecordsContext) { + records := coreblocklog.ScFuncs.GetRequestReceiptsForBlock(ctx) + records.Params.BlockIndex().SetValue(f.Params.BlockIndex().Value()) + records.Func.Call() + f.Results.Count().SetValue(records.Results.RequestRecord().Length()) } func viewGetRandom(ctx wasmlib.ScViewContext, f *GetRandomContext) { f.Results.Random().SetValue(f.State.Random().Value()) } -func funcTriggerEvent(ctx wasmlib.ScFuncContext, f *TriggerEventContext) { - f.Events.Test(f.Params.Address().Value(), f.Params.Name().Value()) -} - -func funcMapClear(ctx wasmlib.ScFuncContext, f *MapClearContext) { - name := f.Params.Name().Value() - myMap := f.State.Maps().GetStringMap(name) - myMap.Clear() -} - -func funcMapCreate(ctx wasmlib.ScFuncContext, f *MapCreateContext) { - name := f.Params.Name().Value() - myMap := f.State.Maps().GetStringMap(name) - myMap.Clear() -} - -func funcMapSet(ctx wasmlib.ScFuncContext, f *MapSetContext) { - name := f.Params.Name().Value() - myMap := f.State.Maps().GetStringMap(name) - key := f.Params.Key().Value() - value := f.Params.Value().Value() - myMap.GetString(key).SetValue(value) +func viewIotaBalance(ctx wasmlib.ScViewContext, f *IotaBalanceContext) { + f.Results.Iotas().SetValue(ctx.Balances().Balance(wasmtypes.IOTA)) } func viewMapValue(ctx wasmlib.ScViewContext, f *MapValueContext) { diff --git a/contracts/wasm/testwasmlib/go/testwasmlib/typedefs.go b/contracts/wasm/testwasmlib/go/testwasmlib/typedefs.go index 97090d3d58..e722b8184d 100644 --- a/contracts/wasm/testwasmlib/go/testwasmlib/typedefs.go +++ b/contracts/wasm/testwasmlib/go/testwasmlib/typedefs.go @@ -7,60 +7,64 @@ package testwasmlib -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" +import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" type ArrayOfImmutableString struct { - objID int32 + proxy wasmtypes.Proxy } -func (a ArrayOfImmutableString) Length() int32 { - return wasmlib.GetLength(a.objID) +func (a ArrayOfImmutableString) Length() uint32 { + return a.proxy.Length() } -func (a ArrayOfImmutableString) GetString(index int32) wasmlib.ScImmutableString { - return wasmlib.NewScImmutableString(a.objID, wasmlib.Key32(index)) +func (a ArrayOfImmutableString) GetString(index uint32) wasmtypes.ScImmutableString { + return wasmtypes.NewScImmutableString(a.proxy.Index(index)) } type ImmutableStringArray = ArrayOfImmutableString type ArrayOfMutableString struct { - objID int32 + proxy wasmtypes.Proxy +} + +func (a ArrayOfMutableString) AppendString() wasmtypes.ScMutableString { + return wasmtypes.NewScMutableString(a.proxy.Append()) } func (a ArrayOfMutableString) Clear() { - wasmlib.Clear(a.objID) + a.proxy.ClearArray() } -func (a ArrayOfMutableString) Length() int32 { - return wasmlib.GetLength(a.objID) +func (a ArrayOfMutableString) Length() uint32 { + return a.proxy.Length() } -func (a ArrayOfMutableString) GetString(index int32) wasmlib.ScMutableString { - return wasmlib.NewScMutableString(a.objID, wasmlib.Key32(index)) +func (a ArrayOfMutableString) GetString(index uint32) wasmtypes.ScMutableString { + return wasmtypes.NewScMutableString(a.proxy.Index(index)) } type MutableStringArray = ArrayOfMutableString type MapStringToImmutableString struct { - objID int32 + proxy wasmtypes.Proxy } -func (m MapStringToImmutableString) GetString(key string) wasmlib.ScImmutableString { - return wasmlib.NewScImmutableString(m.objID, wasmlib.Key(key).KeyID()) +func (m MapStringToImmutableString) GetString(key string) wasmtypes.ScImmutableString { + return wasmtypes.NewScImmutableString(m.proxy.Key(wasmtypes.BytesFromString(key))) } type ImmutableStringMap = MapStringToImmutableString type MapStringToMutableString struct { - objID int32 + proxy wasmtypes.Proxy } func (m MapStringToMutableString) Clear() { - wasmlib.Clear(m.objID) + m.proxy.ClearMap() } -func (m MapStringToMutableString) GetString(key string) wasmlib.ScMutableString { - return wasmlib.NewScMutableString(m.objID, wasmlib.Key(key).KeyID()) +func (m MapStringToMutableString) GetString(key string) wasmtypes.ScMutableString { + return wasmtypes.NewScMutableString(m.proxy.Key(wasmtypes.BytesFromString(key))) } type MutableStringMap = MapStringToMutableString diff --git a/contracts/wasm/testwasmlib/go/testwasmlibclient/service.go b/contracts/wasm/testwasmlib/go/testwasmlibclient/service.go index c770434319..0d5c0f2df8 100644 --- a/contracts/wasm/testwasmlib/go/testwasmlibclient/service.go +++ b/contracts/wasm/testwasmlib/go/testwasmlibclient/service.go @@ -44,36 +44,41 @@ const ( ResValue = "value" ) -///////////////////////////// arrayClear ///////////////////////////// +///////////////////////////// arrayAppend ///////////////////////////// -type ArrayClearFunc struct { +type ArrayAppendFunc struct { wasmclient.ClientFunc args wasmclient.Arguments } -func (f *ArrayClearFunc) Name(v string) { +func (f *ArrayAppendFunc) Name(v string) { f.args.Set(ArgName, f.args.FromString(v)) } -func (f *ArrayClearFunc) Post() wasmclient.Request { +func (f *ArrayAppendFunc) Value(v string) { + f.args.Set(ArgValue, f.args.FromString(v)) +} + +func (f *ArrayAppendFunc) Post() wasmclient.Request { f.args.Mandatory(ArgName) - return f.ClientFunc.Post(0x88021821, &f.args) + f.args.Mandatory(ArgValue) + return f.ClientFunc.Post(0x612f835f, &f.args) } -///////////////////////////// arrayCreate ///////////////////////////// +///////////////////////////// arrayClear ///////////////////////////// -type ArrayCreateFunc struct { +type ArrayClearFunc struct { wasmclient.ClientFunc args wasmclient.Arguments } -func (f *ArrayCreateFunc) Name(v string) { +func (f *ArrayClearFunc) Name(v string) { f.args.Set(ArgName, f.args.FromString(v)) } -func (f *ArrayCreateFunc) Post() wasmclient.Request { +func (f *ArrayClearFunc) Post() wasmclient.Request { f.args.Mandatory(ArgName) - return f.ClientFunc.Post(0x1ed5b23b, &f.args) + return f.ClientFunc.Post(0x88021821, &f.args) } ///////////////////////////// arraySet ///////////////////////////// @@ -83,8 +88,8 @@ type ArraySetFunc struct { args wasmclient.Arguments } -func (f *ArraySetFunc) Index(v int32) { - f.args.Set(ArgIndex, f.args.FromInt32(v)) +func (f *ArraySetFunc) Index(v uint32) { + f.args.Set(ArgIndex, f.args.FromUint32(v)) } func (f *ArraySetFunc) Name(v string) { @@ -118,22 +123,6 @@ func (f *MapClearFunc) Post() wasmclient.Request { return f.ClientFunc.Post(0x027f215a, &f.args) } -///////////////////////////// mapCreate ///////////////////////////// - -type MapCreateFunc struct { - wasmclient.ClientFunc - args wasmclient.Arguments -} - -func (f *MapCreateFunc) Name(v string) { - f.args.Set(ArgName, f.args.FromString(v)) -} - -func (f *MapCreateFunc) Post() wasmclient.Request { - f.args.Mandatory(ArgName) - return f.ClientFunc.Post(0x6295d599, &f.args) -} - ///////////////////////////// mapSet ///////////////////////////// type MapSetFunc struct { @@ -299,8 +288,8 @@ type ArrayLengthResults struct { res wasmclient.Results } -func (r *ArrayLengthResults) Length() int32 { - return r.res.ToInt32(r.res.Get(ResLength)) +func (r *ArrayLengthResults) Length() uint32 { + return r.res.ToUint32(r.res.Get(ResLength)) } ///////////////////////////// arrayValue ///////////////////////////// @@ -310,8 +299,8 @@ type ArrayValueView struct { args wasmclient.Arguments } -func (f *ArrayValueView) Index(v int32) { - f.args.Set(ArgIndex, f.args.FromInt32(v)) +func (f *ArrayValueView) Index(v uint32) { + f.args.Set(ArgIndex, f.args.FromUint32(v)) } func (f *ArrayValueView) Name(v string) { @@ -340,12 +329,12 @@ type BlockRecordView struct { args wasmclient.Arguments } -func (f *BlockRecordView) BlockIndex(v int32) { - f.args.Set(ArgBlockIndex, f.args.FromInt32(v)) +func (f *BlockRecordView) BlockIndex(v uint32) { + f.args.Set(ArgBlockIndex, f.args.FromUint32(v)) } -func (f *BlockRecordView) RecordIndex(v int32) { - f.args.Set(ArgRecordIndex, f.args.FromInt32(v)) +func (f *BlockRecordView) RecordIndex(v uint32) { + f.args.Set(ArgRecordIndex, f.args.FromUint32(v)) } func (f *BlockRecordView) Call() BlockRecordResults { @@ -370,8 +359,8 @@ type BlockRecordsView struct { args wasmclient.Arguments } -func (f *BlockRecordsView) BlockIndex(v int32) { - f.args.Set(ArgBlockIndex, f.args.FromInt32(v)) +func (f *BlockRecordsView) BlockIndex(v uint32) { + f.args.Set(ArgBlockIndex, f.args.FromUint32(v)) } func (f *BlockRecordsView) Call() BlockRecordsResults { @@ -384,8 +373,8 @@ type BlockRecordsResults struct { res wasmclient.Results } -func (r *BlockRecordsResults) Count() int32 { - return r.res.ToInt32(r.res.Get(ResCount)) +func (r *BlockRecordsResults) Count() uint32 { + return r.res.ToUint32(r.res.Get(ResCount)) } ///////////////////////////// getRandom ///////////////////////////// @@ -403,8 +392,8 @@ type GetRandomResults struct { res wasmclient.Results } -func (r *GetRandomResults) Random() int64 { - return r.res.ToInt64(r.res.Get(ResRandom)) +func (r *GetRandomResults) Random() uint64 { + return r.res.ToUint64(r.res.Get(ResRandom)) } ///////////////////////////// iotaBalance ///////////////////////////// @@ -422,8 +411,8 @@ type IotaBalanceResults struct { res wasmclient.Results } -func (r *IotaBalanceResults) Iotas() int64 { - return r.res.ToInt64(r.res.Get(ResIotas)) +func (r *IotaBalanceResults) Iotas() uint64 { + return r.res.ToUint64(r.res.Get(ResIotas)) } ///////////////////////////// mapValue ///////////////////////////// @@ -472,12 +461,12 @@ func (s *TestWasmLibService) NewEventHandler() *TestWasmLibEvents { return &TestWasmLibEvents{} } -func (s *TestWasmLibService) ArrayClear() ArrayClearFunc { - return ArrayClearFunc{ClientFunc: s.AsClientFunc()} +func (s *TestWasmLibService) ArrayAppend() ArrayAppendFunc { + return ArrayAppendFunc{ClientFunc: s.AsClientFunc()} } -func (s *TestWasmLibService) ArrayCreate() ArrayCreateFunc { - return ArrayCreateFunc{ClientFunc: s.AsClientFunc()} +func (s *TestWasmLibService) ArrayClear() ArrayClearFunc { + return ArrayClearFunc{ClientFunc: s.AsClientFunc()} } func (s *TestWasmLibService) ArraySet() ArraySetFunc { @@ -488,10 +477,6 @@ func (s *TestWasmLibService) MapClear() MapClearFunc { return MapClearFunc{ClientFunc: s.AsClientFunc()} } -func (s *TestWasmLibService) MapCreate() MapCreateFunc { - return MapCreateFunc{ClientFunc: s.AsClientFunc()} -} - func (s *TestWasmLibService) MapSet() MapSetFunc { return MapSetFunc{ClientFunc: s.AsClientFunc()} } diff --git a/contracts/wasm/testwasmlib/schema.yaml b/contracts/wasm/testwasmlib/schema.yaml index 7b1358e733..822e7b77d9 100644 --- a/contracts/wasm/testwasmlib/schema.yaml +++ b/contracts/wasm/testwasmlib/schema.yaml @@ -27,23 +27,24 @@ state: # ################################## arrays: map[String]StringArray maps: map[String]StringMap - random: Int64 + random: Uint64 # latLong: map[Int32]Longitude # ################################## funcs: # ################################## - arrayClear: + arrayAppend: params: name: String + value: String - arrayCreate: + arrayClear: params: name: String arraySet: params: - index: Int32 + index: Uint32 name: String value: String @@ -51,10 +52,6 @@ funcs: params: name: String - mapCreate: - params: - name: String - mapSet: params: name: String @@ -97,31 +94,31 @@ views: params: name: String results: - length: Int32 + length: Uint32 arrayValue: params: - index: Int32 + index: Uint32 name: String results: value: String blockRecord: params: - blockIndex: Int32 - recordIndex: Int32 + blockIndex: Uint32 + recordIndex: Uint32 results: record: Bytes blockRecords: params: - blockIndex: Int32 + blockIndex: Uint32 results: - count: Int32 + count: Uint32 iotaBalance: results: - iotas: Int64 + iotas: Uint64 mapValue: params: @@ -132,4 +129,4 @@ views: getRandom: results: - random: Int64 + random: Uint64 diff --git a/contracts/wasm/testwasmlib/src/consts.rs b/contracts/wasm/testwasmlib/src/consts.rs index 8842bfad04..27e099be87 100644 --- a/contracts/wasm/testwasmlib/src/consts.rs +++ b/contracts/wasm/testwasmlib/src/consts.rs @@ -50,11 +50,10 @@ pub const STATE_ARRAYS : &str = "arrays"; pub const STATE_MAPS : &str = "maps"; pub const STATE_RANDOM : &str = "random"; +pub const FUNC_ARRAY_APPEND : &str = "arrayAppend"; pub const FUNC_ARRAY_CLEAR : &str = "arrayClear"; -pub const FUNC_ARRAY_CREATE : &str = "arrayCreate"; pub const FUNC_ARRAY_SET : &str = "arraySet"; pub const FUNC_MAP_CLEAR : &str = "mapClear"; -pub const FUNC_MAP_CREATE : &str = "mapCreate"; pub const FUNC_MAP_SET : &str = "mapSet"; pub const FUNC_PARAM_TYPES : &str = "paramTypes"; pub const FUNC_RANDOM : &str = "random"; @@ -67,11 +66,10 @@ pub const VIEW_GET_RANDOM : &str = "getRandom"; pub const VIEW_IOTA_BALANCE : &str = "iotaBalance"; pub const VIEW_MAP_VALUE : &str = "mapValue"; +pub const HFUNC_ARRAY_APPEND : ScHname = ScHname(0x612f835f); pub const HFUNC_ARRAY_CLEAR : ScHname = ScHname(0x88021821); -pub const HFUNC_ARRAY_CREATE : ScHname = ScHname(0x1ed5b23b); pub const HFUNC_ARRAY_SET : ScHname = ScHname(0x2c4150b3); pub const HFUNC_MAP_CLEAR : ScHname = ScHname(0x027f215a); -pub const HFUNC_MAP_CREATE : ScHname = ScHname(0x6295d599); pub const HFUNC_MAP_SET : ScHname = ScHname(0xf2260404); pub const HFUNC_PARAM_TYPES : ScHname = ScHname(0x6921c4cd); pub const HFUNC_RANDOM : ScHname = ScHname(0xe86c97ca); diff --git a/contracts/wasm/testwasmlib/src/contract.rs b/contracts/wasm/testwasmlib/src/contract.rs index 8de723d684..b08cd1741d 100644 --- a/contracts/wasm/testwasmlib/src/contract.rs +++ b/contracts/wasm/testwasmlib/src/contract.rs @@ -15,14 +15,14 @@ use crate::consts::*; use crate::params::*; use crate::results::*; -pub struct ArrayClearCall { +pub struct ArrayAppendCall { pub func: ScFunc, - pub params: MutableArrayClearParams, + pub params: MutableArrayAppendParams, } -pub struct ArrayCreateCall { +pub struct ArrayClearCall { pub func: ScFunc, - pub params: MutableArrayCreateParams, + pub params: MutableArrayClearParams, } pub struct ArraySetCall { @@ -35,11 +35,6 @@ pub struct MapClearCall { pub params: MutableMapClearParams, } -pub struct MapCreateCall { - pub func: ScFunc, - pub params: MutableMapCreateParams, -} - pub struct MapSetCall { pub func: ScFunc, pub params: MutableMapSetParams, @@ -103,19 +98,19 @@ pub struct ScFuncs { } impl ScFuncs { - pub fn array_clear(_ctx: & dyn ScFuncCallContext) -> ArrayClearCall { - let mut f = ArrayClearCall { - func: ScFunc::new(HSC_NAME, HFUNC_ARRAY_CLEAR), - params: MutableArrayClearParams { id: 0 }, + pub fn array_append(_ctx: & dyn ScFuncCallContext) -> ArrayAppendCall { + let mut f = ArrayAppendCall { + func: ScFunc::new(HSC_NAME, HFUNC_ARRAY_APPEND), + params: MutableArrayAppendParams { id: 0 }, }; f.func.set_ptrs(&mut f.params.id, ptr::null_mut()); f } - pub fn array_create(_ctx: & dyn ScFuncCallContext) -> ArrayCreateCall { - let mut f = ArrayCreateCall { - func: ScFunc::new(HSC_NAME, HFUNC_ARRAY_CREATE), - params: MutableArrayCreateParams { id: 0 }, + pub fn array_clear(_ctx: & dyn ScFuncCallContext) -> ArrayClearCall { + let mut f = ArrayClearCall { + func: ScFunc::new(HSC_NAME, HFUNC_ARRAY_CLEAR), + params: MutableArrayClearParams { id: 0 }, }; f.func.set_ptrs(&mut f.params.id, ptr::null_mut()); f @@ -139,15 +134,6 @@ impl ScFuncs { f } - pub fn map_create(_ctx: & dyn ScFuncCallContext) -> MapCreateCall { - let mut f = MapCreateCall { - func: ScFunc::new(HSC_NAME, HFUNC_MAP_CREATE), - params: MutableMapCreateParams { id: 0 }, - }; - f.func.set_ptrs(&mut f.params.id, ptr::null_mut()); - f - } - pub fn map_set(_ctx: & dyn ScFuncCallContext) -> MapSetCall { let mut f = MapSetCall { func: ScFunc::new(HSC_NAME, HFUNC_MAP_SET), diff --git a/contracts/wasm/testwasmlib/src/lib.rs b/contracts/wasm/testwasmlib/src/lib.rs index b5f7cade6a..9b9fb445ba 100644 --- a/contracts/wasm/testwasmlib/src/lib.rs +++ b/contracts/wasm/testwasmlib/src/lib.rs @@ -32,11 +32,10 @@ mod testwasmlib; #[no_mangle] fn on_load() { let exports = ScExports::new(); + exports.add_func(FUNC_ARRAY_APPEND, func_array_append_thunk); exports.add_func(FUNC_ARRAY_CLEAR, func_array_clear_thunk); - exports.add_func(FUNC_ARRAY_CREATE, func_array_create_thunk); exports.add_func(FUNC_ARRAY_SET, func_array_set_thunk); exports.add_func(FUNC_MAP_CLEAR, func_map_clear_thunk); - exports.add_func(FUNC_MAP_CREATE, func_map_create_thunk); exports.add_func(FUNC_MAP_SET, func_map_set_thunk); exports.add_func(FUNC_PARAM_TYPES, func_param_types_thunk); exports.add_func(FUNC_RANDOM, func_random_thunk); @@ -56,17 +55,17 @@ fn on_load() { } } -pub struct ArrayClearContext { +pub struct ArrayAppendContext { events: TestWasmLibEvents, - params: ImmutableArrayClearParams, + params: ImmutableArrayAppendParams, state: MutableTestWasmLibState, } -fn func_array_clear_thunk(ctx: &ScFuncContext) { - ctx.log("testwasmlib.funcArrayClear"); - let f = ArrayClearContext { +fn func_array_append_thunk(ctx: &ScFuncContext) { + ctx.log("testwasmlib.funcArrayAppend"); + let f = ArrayAppendContext { events: TestWasmLibEvents {}, - params: ImmutableArrayClearParams { + params: ImmutableArrayAppendParams { id: OBJ_ID_PARAMS, }, state: MutableTestWasmLibState { @@ -74,21 +73,22 @@ fn func_array_clear_thunk(ctx: &ScFuncContext) { }, }; ctx.require(f.params.name().exists(), "missing mandatory name"); - func_array_clear(ctx, &f); - ctx.log("testwasmlib.funcArrayClear ok"); + ctx.require(f.params.value().exists(), "missing mandatory value"); + func_array_append(ctx, &f); + ctx.log("testwasmlib.funcArrayAppend ok"); } -pub struct ArrayCreateContext { +pub struct ArrayClearContext { events: TestWasmLibEvents, - params: ImmutableArrayCreateParams, + params: ImmutableArrayClearParams, state: MutableTestWasmLibState, } -fn func_array_create_thunk(ctx: &ScFuncContext) { - ctx.log("testwasmlib.funcArrayCreate"); - let f = ArrayCreateContext { +fn func_array_clear_thunk(ctx: &ScFuncContext) { + ctx.log("testwasmlib.funcArrayClear"); + let f = ArrayClearContext { events: TestWasmLibEvents {}, - params: ImmutableArrayCreateParams { + params: ImmutableArrayClearParams { id: OBJ_ID_PARAMS, }, state: MutableTestWasmLibState { @@ -96,8 +96,8 @@ fn func_array_create_thunk(ctx: &ScFuncContext) { }, }; ctx.require(f.params.name().exists(), "missing mandatory name"); - func_array_create(ctx, &f); - ctx.log("testwasmlib.funcArrayCreate ok"); + func_array_clear(ctx, &f); + ctx.log("testwasmlib.funcArrayClear ok"); } pub struct ArraySetContext { @@ -146,28 +146,6 @@ fn func_map_clear_thunk(ctx: &ScFuncContext) { ctx.log("testwasmlib.funcMapClear ok"); } -pub struct MapCreateContext { - events: TestWasmLibEvents, - params: ImmutableMapCreateParams, - state: MutableTestWasmLibState, -} - -fn func_map_create_thunk(ctx: &ScFuncContext) { - ctx.log("testwasmlib.funcMapCreate"); - let f = MapCreateContext { - events: TestWasmLibEvents {}, - params: ImmutableMapCreateParams { - id: OBJ_ID_PARAMS, - }, - state: MutableTestWasmLibState { - id: OBJ_ID_STATE, - }, - }; - ctx.require(f.params.name().exists(), "missing mandatory name"); - func_map_create(ctx, &f); - ctx.log("testwasmlib.funcMapCreate ok"); -} - pub struct MapSetContext { events: TestWasmLibEvents, params: ImmutableMapSetParams, diff --git a/contracts/wasm/testwasmlib/src/params.rs b/contracts/wasm/testwasmlib/src/params.rs index 1d9f4e9d87..855e99b35f 100644 --- a/contracts/wasm/testwasmlib/src/params.rs +++ b/contracts/wasm/testwasmlib/src/params.rs @@ -16,44 +16,52 @@ use crate::keys::*; use crate::typedefs::*; #[derive(Clone, Copy)] -pub struct ImmutableArrayClearParams { +pub struct ImmutableArrayAppendParams { pub(crate) id: i32, } -impl ImmutableArrayClearParams { +impl ImmutableArrayAppendParams { pub fn name(&self) -> ScImmutableString { ScImmutableString::new(self.id, PARAM_NAME.get_key_id()) } + + pub fn value(&self) -> ScImmutableString { + ScImmutableString::new(self.id, PARAM_VALUE.get_key_id()) + } } #[derive(Clone, Copy)] -pub struct MutableArrayClearParams { +pub struct MutableArrayAppendParams { pub(crate) id: i32, } -impl MutableArrayClearParams { +impl MutableArrayAppendParams { pub fn name(&self) -> ScMutableString { ScMutableString::new(self.id, PARAM_NAME.get_key_id()) } + + pub fn value(&self) -> ScMutableString { + ScMutableString::new(self.id, PARAM_VALUE.get_key_id()) + } } #[derive(Clone, Copy)] -pub struct ImmutableArrayCreateParams { +pub struct ImmutableArrayClearParams { pub(crate) id: i32, } -impl ImmutableArrayCreateParams { +impl ImmutableArrayClearParams { pub fn name(&self) -> ScImmutableString { ScImmutableString::new(self.id, PARAM_NAME.get_key_id()) } } #[derive(Clone, Copy)] -pub struct MutableArrayCreateParams { +pub struct MutableArrayClearParams { pub(crate) id: i32, } -impl MutableArrayCreateParams { +impl MutableArrayClearParams { pub fn name(&self) -> ScMutableString { ScMutableString::new(self.id, PARAM_NAME.get_key_id()) } @@ -65,8 +73,8 @@ pub struct ImmutableArraySetParams { } impl ImmutableArraySetParams { - pub fn index(&self) -> ScImmutableInt32 { - ScImmutableInt32::new(self.id, PARAM_INDEX.get_key_id()) + pub fn index(&self) -> ScImmutableUint32 { + ScImmutableUint32::new(self.id, PARAM_INDEX.get_key_id()) } pub fn name(&self) -> ScImmutableString { @@ -84,8 +92,8 @@ pub struct MutableArraySetParams { } impl MutableArraySetParams { - pub fn index(&self) -> ScMutableInt32 { - ScMutableInt32::new(self.id, PARAM_INDEX.get_key_id()) + pub fn index(&self) -> ScMutableUint32 { + ScMutableUint32::new(self.id, PARAM_INDEX.get_key_id()) } pub fn name(&self) -> ScMutableString { @@ -119,28 +127,6 @@ impl MutableMapClearParams { } } -#[derive(Clone, Copy)] -pub struct ImmutableMapCreateParams { - pub(crate) id: i32, -} - -impl ImmutableMapCreateParams { - pub fn name(&self) -> ScImmutableString { - ScImmutableString::new(self.id, PARAM_NAME.get_key_id()) - } -} - -#[derive(Clone, Copy)] -pub struct MutableMapCreateParams { - pub(crate) id: i32, -} - -impl MutableMapCreateParams { - pub fn name(&self) -> ScMutableString { - ScMutableString::new(self.id, PARAM_NAME.get_key_id()) - } -} - #[derive(Clone, Copy)] pub struct ImmutableMapSetParams { pub(crate) id: i32, @@ -429,8 +415,8 @@ pub struct ImmutableArrayValueParams { } impl ImmutableArrayValueParams { - pub fn index(&self) -> ScImmutableInt32 { - ScImmutableInt32::new(self.id, PARAM_INDEX.get_key_id()) + pub fn index(&self) -> ScImmutableUint32 { + ScImmutableUint32::new(self.id, PARAM_INDEX.get_key_id()) } pub fn name(&self) -> ScImmutableString { @@ -444,8 +430,8 @@ pub struct MutableArrayValueParams { } impl MutableArrayValueParams { - pub fn index(&self) -> ScMutableInt32 { - ScMutableInt32::new(self.id, PARAM_INDEX.get_key_id()) + pub fn index(&self) -> ScMutableUint32 { + ScMutableUint32::new(self.id, PARAM_INDEX.get_key_id()) } pub fn name(&self) -> ScMutableString { @@ -459,12 +445,12 @@ pub struct ImmutableBlockRecordParams { } impl ImmutableBlockRecordParams { - pub fn block_index(&self) -> ScImmutableInt32 { - ScImmutableInt32::new(self.id, PARAM_BLOCK_INDEX.get_key_id()) + pub fn block_index(&self) -> ScImmutableUint32 { + ScImmutableUint32::new(self.id, PARAM_BLOCK_INDEX.get_key_id()) } - pub fn record_index(&self) -> ScImmutableInt32 { - ScImmutableInt32::new(self.id, PARAM_RECORD_INDEX.get_key_id()) + pub fn record_index(&self) -> ScImmutableUint32 { + ScImmutableUint32::new(self.id, PARAM_RECORD_INDEX.get_key_id()) } } @@ -474,12 +460,12 @@ pub struct MutableBlockRecordParams { } impl MutableBlockRecordParams { - pub fn block_index(&self) -> ScMutableInt32 { - ScMutableInt32::new(self.id, PARAM_BLOCK_INDEX.get_key_id()) + pub fn block_index(&self) -> ScMutableUint32 { + ScMutableUint32::new(self.id, PARAM_BLOCK_INDEX.get_key_id()) } - pub fn record_index(&self) -> ScMutableInt32 { - ScMutableInt32::new(self.id, PARAM_RECORD_INDEX.get_key_id()) + pub fn record_index(&self) -> ScMutableUint32 { + ScMutableUint32::new(self.id, PARAM_RECORD_INDEX.get_key_id()) } } @@ -489,8 +475,8 @@ pub struct ImmutableBlockRecordsParams { } impl ImmutableBlockRecordsParams { - pub fn block_index(&self) -> ScImmutableInt32 { - ScImmutableInt32::new(self.id, PARAM_BLOCK_INDEX.get_key_id()) + pub fn block_index(&self) -> ScImmutableUint32 { + ScImmutableUint32::new(self.id, PARAM_BLOCK_INDEX.get_key_id()) } } @@ -500,8 +486,8 @@ pub struct MutableBlockRecordsParams { } impl MutableBlockRecordsParams { - pub fn block_index(&self) -> ScMutableInt32 { - ScMutableInt32::new(self.id, PARAM_BLOCK_INDEX.get_key_id()) + pub fn block_index(&self) -> ScMutableUint32 { + ScMutableUint32::new(self.id, PARAM_BLOCK_INDEX.get_key_id()) } } diff --git a/contracts/wasm/testwasmlib/src/results.rs b/contracts/wasm/testwasmlib/src/results.rs index e46d27f60b..977c05598d 100644 --- a/contracts/wasm/testwasmlib/src/results.rs +++ b/contracts/wasm/testwasmlib/src/results.rs @@ -21,8 +21,8 @@ pub struct ImmutableArrayLengthResults { } impl ImmutableArrayLengthResults { - pub fn length(&self) -> ScImmutableInt32 { - ScImmutableInt32::new(self.id, RESULT_LENGTH.get_key_id()) + pub fn length(&self) -> ScImmutableUint32 { + ScImmutableUint32::new(self.id, RESULT_LENGTH.get_key_id()) } } @@ -32,8 +32,8 @@ pub struct MutableArrayLengthResults { } impl MutableArrayLengthResults { - pub fn length(&self) -> ScMutableInt32 { - ScMutableInt32::new(self.id, RESULT_LENGTH.get_key_id()) + pub fn length(&self) -> ScMutableUint32 { + ScMutableUint32::new(self.id, RESULT_LENGTH.get_key_id()) } } @@ -87,8 +87,8 @@ pub struct ImmutableBlockRecordsResults { } impl ImmutableBlockRecordsResults { - pub fn count(&self) -> ScImmutableInt32 { - ScImmutableInt32::new(self.id, RESULT_COUNT.get_key_id()) + pub fn count(&self) -> ScImmutableUint32 { + ScImmutableUint32::new(self.id, RESULT_COUNT.get_key_id()) } } @@ -98,8 +98,8 @@ pub struct MutableBlockRecordsResults { } impl MutableBlockRecordsResults { - pub fn count(&self) -> ScMutableInt32 { - ScMutableInt32::new(self.id, RESULT_COUNT.get_key_id()) + pub fn count(&self) -> ScMutableUint32 { + ScMutableUint32::new(self.id, RESULT_COUNT.get_key_id()) } } @@ -109,8 +109,8 @@ pub struct ImmutableGetRandomResults { } impl ImmutableGetRandomResults { - pub fn random(&self) -> ScImmutableInt64 { - ScImmutableInt64::new(self.id, RESULT_RANDOM.get_key_id()) + pub fn random(&self) -> ScImmutableUint64 { + ScImmutableUint64::new(self.id, RESULT_RANDOM.get_key_id()) } } @@ -120,8 +120,8 @@ pub struct MutableGetRandomResults { } impl MutableGetRandomResults { - pub fn random(&self) -> ScMutableInt64 { - ScMutableInt64::new(self.id, RESULT_RANDOM.get_key_id()) + pub fn random(&self) -> ScMutableUint64 { + ScMutableUint64::new(self.id, RESULT_RANDOM.get_key_id()) } } @@ -131,8 +131,8 @@ pub struct ImmutableIotaBalanceResults { } impl ImmutableIotaBalanceResults { - pub fn iotas(&self) -> ScImmutableInt64 { - ScImmutableInt64::new(self.id, RESULT_IOTAS.get_key_id()) + pub fn iotas(&self) -> ScImmutableUint64 { + ScImmutableUint64::new(self.id, RESULT_IOTAS.get_key_id()) } } @@ -142,8 +142,8 @@ pub struct MutableIotaBalanceResults { } impl MutableIotaBalanceResults { - pub fn iotas(&self) -> ScMutableInt64 { - ScMutableInt64::new(self.id, RESULT_IOTAS.get_key_id()) + pub fn iotas(&self) -> ScMutableUint64 { + ScMutableUint64::new(self.id, RESULT_IOTAS.get_key_id()) } } diff --git a/contracts/wasm/testwasmlib/src/state.rs b/contracts/wasm/testwasmlib/src/state.rs index 01ceb24c3b..720601ef25 100644 --- a/contracts/wasm/testwasmlib/src/state.rs +++ b/contracts/wasm/testwasmlib/src/state.rs @@ -55,8 +55,8 @@ impl ImmutableTestWasmLibState { MapStringToImmutableStringMap { obj_id: map_id } } - pub fn random(&self) -> ScImmutableInt64 { - ScImmutableInt64::new(self.id, STATE_RANDOM.get_key_id()) + pub fn random(&self) -> ScImmutableUint64 { + ScImmutableUint64::new(self.id, STATE_RANDOM.get_key_id()) } } @@ -112,7 +112,7 @@ impl MutableTestWasmLibState { MapStringToMutableStringMap { obj_id: map_id } } - pub fn random(&self) -> ScMutableInt64 { - ScMutableInt64::new(self.id, STATE_RANDOM.get_key_id()) + pub fn random(&self) -> ScMutableUint64 { + ScMutableUint64::new(self.id, STATE_RANDOM.get_key_id()) } } diff --git a/contracts/wasm/testwasmlib/src/structs.rs b/contracts/wasm/testwasmlib/src/structs.rs index 9d670e8dee..0166c45640 100644 --- a/contracts/wasm/testwasmlib/src/structs.rs +++ b/contracts/wasm/testwasmlib/src/structs.rs @@ -12,49 +12,58 @@ use wasmlib::*; use wasmlib::host::*; use crate::typedefs::*; -pub struct Location { - pub x : i32, - pub y : i32, +#[derive(Clone)] +pub struct CallRequest { + pub contract : ScHname, + pub function : ScHname, + pub params : , + pub transfer : , } -impl Location { - pub fn from_bytes(bytes: &[u8]) -> Location { +impl CallRequest { + pub fn from_bytes(bytes: &[u8]) -> CallRequest { let mut decode = BytesDecoder::new(bytes); - Location { - x : decode.int32(), - y : decode.int32(), + CallRequest { + contract : decode.hname(), + function : decode.hname(), + params : decode.bytes(), + transfer : decode.bytes(), } } pub fn to_bytes(&self) -> Vec { let mut encode = BytesEncoder::new(); - encode.int32(self.x); - encode.int32(self.y); + encode.hname(self.contract); + encode.hname(self.function); + encode.bytes(self.params); + encode.bytes(self.transfer); return encode.data(); } } -pub struct ImmutableLocation { +#[derive(Clone, Copy)] +pub struct ImmutableCallRequest { pub(crate) obj_id: i32, pub(crate) key_id: Key32, } -impl ImmutableLocation { +impl ImmutableCallRequest { pub fn exists(&self) -> bool { exists(self.obj_id, self.key_id, TYPE_BYTES) } - pub fn value(&self) -> Location { - Location::from_bytes(&get_bytes(self.obj_id, self.key_id, TYPE_BYTES)) + pub fn value(&self) -> CallRequest { + CallRequest::from_bytes(&get_bytes(self.obj_id, self.key_id, TYPE_BYTES)) } } -pub struct MutableLocation { +#[derive(Clone, Copy)] +pub struct MutableCallRequest { pub(crate) obj_id: i32, pub(crate) key_id: Key32, } -impl MutableLocation { +impl MutableCallRequest { pub fn delete(&self) { del_key(self.obj_id, self.key_id, TYPE_BYTES); } @@ -63,11 +72,218 @@ impl MutableLocation { exists(self.obj_id, self.key_id, TYPE_BYTES) } - pub fn set_value(&self, value: &Location) { + pub fn set_value(&self, value: &CallRequest) { set_bytes(self.obj_id, self.key_id, TYPE_BYTES, &value.to_bytes()); } - pub fn value(&self) -> Location { - Location::from_bytes(&get_bytes(self.obj_id, self.key_id, TYPE_BYTES)) + pub fn value(&self) -> CallRequest { + CallRequest::from_bytes(&get_bytes(self.obj_id, self.key_id, TYPE_BYTES)) + } +} + +#[derive(Clone)] +pub struct DeployRequest { + pub description : String, + pub name : String, + pub params : , + pub prog_hash : ScHash, +} + +impl DeployRequest { + pub fn from_bytes(bytes: &[u8]) -> DeployRequest { + let mut decode = BytesDecoder::new(bytes); + DeployRequest { + description : decode.string(), + name : decode.string(), + params : decode.bytes(), + prog_hash : decode.hash(), + } + } + + pub fn to_bytes(&self) -> Vec { + let mut encode = BytesEncoder::new(); + encode.string(&self.description); + encode.string(&self.name); + encode.bytes(self.params); + encode.hash(&self.prog_hash); + return encode.data(); + } +} + +#[derive(Clone, Copy)] +pub struct ImmutableDeployRequest { + pub(crate) obj_id: i32, + pub(crate) key_id: Key32, +} + +impl ImmutableDeployRequest { + pub fn exists(&self) -> bool { + exists(self.obj_id, self.key_id, TYPE_BYTES) + } + + pub fn value(&self) -> DeployRequest { + DeployRequest::from_bytes(&get_bytes(self.obj_id, self.key_id, TYPE_BYTES)) + } +} + +#[derive(Clone, Copy)] +pub struct MutableDeployRequest { + pub(crate) obj_id: i32, + pub(crate) key_id: Key32, +} + +impl MutableDeployRequest { + pub fn delete(&self) { + del_key(self.obj_id, self.key_id, TYPE_BYTES); + } + + pub fn exists(&self) -> bool { + exists(self.obj_id, self.key_id, TYPE_BYTES) + } + + pub fn set_value(&self, value: &DeployRequest) { + set_bytes(self.obj_id, self.key_id, TYPE_BYTES, &value.to_bytes()); + } + + pub fn value(&self) -> DeployRequest { + DeployRequest::from_bytes(&get_bytes(self.obj_id, self.key_id, TYPE_BYTES)) + } +} + +#[derive(Clone)] +pub struct PostRequest { + pub chain_id : ScChainID, + pub contract : ScHname, + pub delay : u32, + pub function : ScHname, + pub params : , + pub transfer : , +} + +impl PostRequest { + pub fn from_bytes(bytes: &[u8]) -> PostRequest { + let mut decode = BytesDecoder::new(bytes); + PostRequest { + chain_id : decode.chain_id(), + contract : decode.hname(), + delay : decode.uint32(), + function : decode.hname(), + params : decode.bytes(), + transfer : decode.bytes(), + } + } + + pub fn to_bytes(&self) -> Vec { + let mut encode = BytesEncoder::new(); + encode.chain_id(&self.chain_id); + encode.hname(self.contract); + encode.uint32(self.delay); + encode.hname(self.function); + encode.bytes(self.params); + encode.bytes(self.transfer); + return encode.data(); + } +} + +#[derive(Clone, Copy)] +pub struct ImmutablePostRequest { + pub(crate) obj_id: i32, + pub(crate) key_id: Key32, +} + +impl ImmutablePostRequest { + pub fn exists(&self) -> bool { + exists(self.obj_id, self.key_id, TYPE_BYTES) + } + + pub fn value(&self) -> PostRequest { + PostRequest::from_bytes(&get_bytes(self.obj_id, self.key_id, TYPE_BYTES)) + } +} + +#[derive(Clone, Copy)] +pub struct MutablePostRequest { + pub(crate) obj_id: i32, + pub(crate) key_id: Key32, +} + +impl MutablePostRequest { + pub fn delete(&self) { + del_key(self.obj_id, self.key_id, TYPE_BYTES); + } + + pub fn exists(&self) -> bool { + exists(self.obj_id, self.key_id, TYPE_BYTES) + } + + pub fn set_value(&self, value: &PostRequest) { + set_bytes(self.obj_id, self.key_id, TYPE_BYTES, &value.to_bytes()); + } + + pub fn value(&self) -> PostRequest { + PostRequest::from_bytes(&get_bytes(self.obj_id, self.key_id, TYPE_BYTES)) + } +} + +#[derive(Clone)] +pub struct SendRequest { + pub address : ScAddress, + pub transfer : , +} + +impl SendRequest { + pub fn from_bytes(bytes: &[u8]) -> SendRequest { + let mut decode = BytesDecoder::new(bytes); + SendRequest { + address : decode.address(), + transfer : decode.bytes(), + } + } + + pub fn to_bytes(&self) -> Vec { + let mut encode = BytesEncoder::new(); + encode.address(&self.address); + encode.bytes(self.transfer); + return encode.data(); + } +} + +#[derive(Clone, Copy)] +pub struct ImmutableSendRequest { + pub(crate) obj_id: i32, + pub(crate) key_id: Key32, +} + +impl ImmutableSendRequest { + pub fn exists(&self) -> bool { + exists(self.obj_id, self.key_id, TYPE_BYTES) + } + + pub fn value(&self) -> SendRequest { + SendRequest::from_bytes(&get_bytes(self.obj_id, self.key_id, TYPE_BYTES)) + } +} + +#[derive(Clone, Copy)] +pub struct MutableSendRequest { + pub(crate) obj_id: i32, + pub(crate) key_id: Key32, +} + +impl MutableSendRequest { + pub fn delete(&self) { + del_key(self.obj_id, self.key_id, TYPE_BYTES); + } + + pub fn exists(&self) -> bool { + exists(self.obj_id, self.key_id, TYPE_BYTES) + } + + pub fn set_value(&self, value: &SendRequest) { + set_bytes(self.obj_id, self.key_id, TYPE_BYTES, &value.to_bytes()); + } + + pub fn value(&self) -> SendRequest { + SendRequest::from_bytes(&get_bytes(self.obj_id, self.key_id, TYPE_BYTES)) } } diff --git a/contracts/wasm/testwasmlib/src/testwasmlib.rs b/contracts/wasm/testwasmlib/src/testwasmlib.rs index 31db1e8ab6..825d7ba5b4 100644 --- a/contracts/wasm/testwasmlib/src/testwasmlib.rs +++ b/contracts/wasm/testwasmlib/src/testwasmlib.rs @@ -5,13 +5,10 @@ use wasmlib::*; use crate::*; -pub fn func_array_clear(_ctx: &ScFuncContext, f: &ArrayClearContext) { - let name = f.params.name().value(); - let array = f.state.arrays().get_string_array(&name); - array.clear(); +pub fn func_array_append(_ctx: &ScFuncContext, _f: &ArrayAppendContext) { } -pub fn func_array_create(_ctx: &ScFuncContext, f: &ArrayCreateContext) { +pub fn func_array_clear(_ctx: &ScFuncContext, f: &ArrayClearContext) { let name = f.params.name().value(); let array = f.state.arrays().get_string_array(&name); array.clear(); @@ -25,6 +22,12 @@ pub fn func_array_set(_ctx: &ScFuncContext, f: &ArraySetContext) { array.get_string(index).set_value(&value); } +pub fn func_map_clear(_ctx: &ScFuncContext, _f: &MapClearContext) { +} + +pub fn func_map_set(_ctx: &ScFuncContext, _f: &MapSetContext) { +} + pub fn func_param_types(ctx: &ScFuncContext, f: &ParamTypesContext) { if f.params.address().exists() { ctx.require(f.params.address().value() == ctx.account_id().address(), "mismatch: Address"); @@ -86,6 +89,14 @@ pub fn func_param_types(ctx: &ScFuncContext, f: &ParamTypesContext) { } } +pub fn func_random(ctx: &ScFuncContext, f: &RandomContext) { + f.state.random().set_value(ctx.random(1000)); +} + +pub fn func_trigger_event(_ctx: &ScFuncContext, f: &TriggerEventContext) { + f.events.test(&f.params.address().value(), &f.params.name().value()); +} + pub fn view_array_length(_ctx: &ScViewContext, f: &ArrayLengthContext) { let name = f.params.name().value(); let array = f.state.arrays().get_string_array(&name); @@ -117,29 +128,12 @@ pub fn view_block_records(ctx: &ScViewContext, f: &BlockRecordsContext) { f.results.count().set_value(records.results.request_record().length()); } -pub fn view_iota_balance(ctx: &ScViewContext, f: &IotaBalanceContext) { - f.results.iotas().set_value(ctx.balances().balance(&ScColor::IOTA)); -} - -pub fn func_random(ctx: &ScFuncContext, f: &RandomContext) { - f.state.random().set_value(ctx.random(1000)); -} - pub fn view_get_random(_ctx: &ScViewContext, f: &GetRandomContext) { f.results.random().set_value(f.state.random().value()); } -pub fn func_trigger_event(_ctx: &ScFuncContext, f: &TriggerEventContext) { - f.events.test(&f.params.address().value(), &f.params.name().value()); -} - -pub fn func_map_clear(_ctx: &ScFuncContext, _f: &MapClearContext) { -} - -pub fn func_map_create(_ctx: &ScFuncContext, _f: &MapCreateContext) { -} - -pub fn func_map_set(_ctx: &ScFuncContext, _f: &MapSetContext) { +pub fn view_iota_balance(ctx: &ScViewContext, f: &IotaBalanceContext) { + f.results.iotas().set_value(ctx.balances().balance(&ScColor::IOTA)); } pub fn view_map_value(_ctx: &ScViewContext, _f: &MapValueContext) { diff --git a/contracts/wasm/testwasmlib/src/typedefs.rs b/contracts/wasm/testwasmlib/src/typedefs.rs index 7f96eb2368..0e75ea6cbc 100644 --- a/contracts/wasm/testwasmlib/src/typedefs.rs +++ b/contracts/wasm/testwasmlib/src/typedefs.rs @@ -16,12 +16,12 @@ pub struct ArrayOfImmutableString { } impl ArrayOfImmutableString { - pub fn length(&self) -> i32 { + pub fn length(&self) -> u32 { get_length(self.obj_id) } - pub fn get_string(&self, index: i32) -> ScImmutableString { - ScImmutableString::new(self.obj_id, Key32(index)) + pub fn get_string(&self, index: u32) -> ScImmutableString { + ScImmutableString::new(self.obj_id, Key32(index as i32)) } } @@ -37,12 +37,12 @@ impl ArrayOfMutableString { clear(self.obj_id); } - pub fn length(&self) -> i32 { + pub fn length(&self) -> u32 { get_length(self.obj_id) } - pub fn get_string(&self, index: i32) -> ScMutableString { - ScMutableString::new(self.obj_id, Key32(index)) + pub fn get_string(&self, index: u32) -> ScMutableString { + ScMutableString::new(self.obj_id, Key32(index as i32)) } } diff --git a/contracts/wasm/testwasmlib/test/testwasmlib_bg.wasm b/contracts/wasm/testwasmlib/test/testwasmlib_bg.wasm index be70aa0f7862e4e1f77152c8c6e7da516dea01f2..ef646af1cbd708a26453a266709788fcfe0a8626 100644 GIT binary patch delta 15236 zcmbVT3w%_?xj%Ex?&h)Ca1uhEkeuBlkN^n*fq)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mxRVS znAV0S{q;d^8>YpWC|e4_N#ayvnO%+%2ff#$?2S@v+1a=Jmb(@$xoyFUl_e`y(h7Iu z$*5Q0;dmVUt<`G@$snG!V(HGw?2qE5ou~WKI+sP2s87Ljxp->VVD_~*vTI6WX}a34 zQlvebnYaoq!n9J1c(y2UD_SJbd&Poh2eYGM^Rs1X|ARiVApX8;tWA9UY*BVOS|q$x zC~3DVQ4*Xsk=-;t=&o6dUOK*AD2cIqQIgeY6L&QYPdkYg9dr^N68e)ZuQf%y6Bp*% s@~o@TMQ84|uS1=XbKA2~pM)o#;HfQjd*@k66gCBzhdu{<`qKLU1v|@$QUCw| diff --git a/contracts/wasm/testwasmlib/test/testwasmlib_test.go b/contracts/wasm/testwasmlib/test/testwasmlib_test.go index 1fb5acb218..2cb58fb960 100644 --- a/contracts/wasm/testwasmlib/test/testwasmlib_test.go +++ b/contracts/wasm/testwasmlib/test/testwasmlib_test.go @@ -9,7 +9,7 @@ import ( "github.com/iotaledger/goshimmer/packages/ledgerstate" "github.com/iotaledger/wasp/contracts/wasm/testwasmlib/go/testwasmlib" "github.com/iotaledger/wasp/packages/solo" - "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" + "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" "github.com/iotaledger/wasp/packages/vm/wasmsolo" "github.com/stretchr/testify/require" ) @@ -34,7 +34,7 @@ var ( testwasmlib.ParamUint64, } allLengths = []int{33, 37, 1, 33, 32, 32, 4, 1, 2, 4, 8, 34, 1, 2, 4, 8} - invalidValues = map[wasmlib.Key][][]byte{ + invalidValues = map[string][][]byte{ testwasmlib.ParamAddress: { append([]byte{3}, zeroHash...), append([]byte{4}, zeroHash...), @@ -88,14 +88,14 @@ func testValidParams(t *testing.T) *wasmsolo.SoloContext { pt.Params.Bool().SetValue(true) pt.Params.Bytes().SetValue([]byte("these are bytes")) pt.Params.ChainID().SetValue(ctx.ChainID()) - pt.Params.Color().SetValue(wasmlib.NewScColorFromBytes([]byte("RedGreenBlueYellowCyanBlackWhite"))) - pt.Params.Hash().SetValue(wasmlib.NewScHashFromBytes([]byte("0123456789abcdeffedcba9876543210"))) + pt.Params.Color().SetValue(wasmtypes.ColorFromBytes([]byte("RedGreenBlueYellowCyanBlackWhite"))) + pt.Params.Hash().SetValue(wasmtypes.HashFromBytes([]byte("0123456789abcdeffedcba9876543210"))) pt.Params.Hname().SetValue(testwasmlib.HScName) pt.Params.Int8().SetValue(-123) pt.Params.Int16().SetValue(-12345) pt.Params.Int32().SetValue(-1234567890) pt.Params.Int64().SetValue(-1234567890123456789) - pt.Params.RequestID().SetValue(wasmlib.NewScRequestIDFromBytes([]byte("abcdefghijklmnopqrstuvwxyz123456\x00\x00"))) + pt.Params.RequestID().SetValue(wasmtypes.RequestIDFromBytes([]byte("abcdefghijklmnopqrstuvwxyz123456\x00\x00"))) pt.Params.String().SetValue("this is a string") pt.Params.Uint8().SetValue(123) pt.Params.Uint16().SetValue(12345) @@ -127,23 +127,24 @@ func TestInvalidSizeParams(t *testing.T) { ctx := setupTest(t) for index, param := range allParams { t.Run("InvalidSize "+param, func(t *testing.T) { + invalidLength := fmt.Sprintf("invalid %s%s length", strings.ToUpper(param[:1]), param[1:]) pt := testwasmlib.ScFuncs.ParamTypes(ctx) pt.Params.Param().GetBytes(param).SetValue(make([]byte, 0)) pt.Func.TransferIotas(1).Post() require.Error(t, ctx.Err) - require.True(t, strings.HasSuffix(ctx.Err.Error(), "invalid type size")) + require.Contains(t, ctx.Err.Error(), invalidLength) pt = testwasmlib.ScFuncs.ParamTypes(ctx) pt.Params.Param().GetBytes(param).SetValue(make([]byte, allLengths[index]-1)) pt.Func.TransferIotas(1).Post() require.Error(t, ctx.Err) - require.True(t, strings.HasSuffix(ctx.Err.Error(), "invalid type size")) + require.Contains(t, ctx.Err.Error(), invalidLength) pt = testwasmlib.ScFuncs.ParamTypes(ctx) pt.Params.Param().GetBytes(param).SetValue(make([]byte, allLengths[index]+1)) pt.Func.TransferIotas(1).Post() require.Error(t, ctx.Err) - require.Contains(t, ctx.Err.Error(), "invalid type size") + require.Contains(t, ctx.Err.Error(), invalidLength) }) } } @@ -152,9 +153,9 @@ func TestInvalidTypeParams(t *testing.T) { ctx := setupTest(t) for param, values := range invalidValues { for index, value := range values { - t.Run("InvalidType "+string(param)+" "+strconv.Itoa(index), func(t *testing.T) { + t.Run("InvalidType "+param+" "+strconv.Itoa(index), func(t *testing.T) { req := solo.NewCallParams(testwasmlib.ScName, testwasmlib.FuncParamTypes, - string(param), value, + param, value, ).WithIotas(1) _, err := ctx.Chain.PostRequestSync(req, nil) require.Error(t, err) @@ -282,7 +283,7 @@ func TestClearMap(t *testing.T) { require.True(t, value.Exists()) require.EqualValues(t, "Calling Elvis", value.Value()) - ac := testwasmlib.ScFuncs.ArrayClear(ctx) + ac := testwasmlib.ScFuncs.MapClear(ctx) ac.Params.Name().SetValue("bands") ac.Func.TransferIotas(1).Post() require.NoError(t, ctx.Err) @@ -331,14 +332,14 @@ func TestRandom(t *testing.T) { v.Func.Call() require.NoError(t, ctx.Err) random := v.Results.Random().Value() - require.True(t, random >= 0 && random < 1000) + require.True(t, random < 1000) fmt.Printf("Random value: %d\n", random) } func TestMultiRandom(t *testing.T) { ctx := setupTest(t) - numbers := make([]int64, 0) + numbers := make([]uint64, 0) for i := 0; i < 10; i++ { f := testwasmlib.ScFuncs.Random(ctx) f.Func.TransferIotas(1).Post() @@ -348,7 +349,7 @@ func TestMultiRandom(t *testing.T) { v.Func.Call() require.NoError(t, ctx.Err) random := v.Results.Random().Value() - require.True(t, random >= 0 && random < 1000) + require.True(t, random < 1000) numbers = append(numbers, random) } diff --git a/contracts/wasm/testwasmlib/ts/testwasmlib/consts.ts b/contracts/wasm/testwasmlib/ts/testwasmlib/consts.ts index fbce884289..b39471a981 100644 --- a/contracts/wasm/testwasmlib/ts/testwasmlib/consts.ts +++ b/contracts/wasm/testwasmlib/ts/testwasmlib/consts.ts @@ -48,11 +48,10 @@ export const StateArrays = "arrays"; export const StateMaps = "maps"; export const StateRandom = "random"; +export const FuncArrayAppend = "arrayAppend"; export const FuncArrayClear = "arrayClear"; -export const FuncArrayCreate = "arrayCreate"; export const FuncArraySet = "arraySet"; export const FuncMapClear = "mapClear"; -export const FuncMapCreate = "mapCreate"; export const FuncMapSet = "mapSet"; export const FuncParamTypes = "paramTypes"; export const FuncRandom = "random"; @@ -65,11 +64,10 @@ export const ViewGetRandom = "getRandom"; export const ViewIotaBalance = "iotaBalance"; export const ViewMapValue = "mapValue"; +export const HFuncArrayAppend = new wasmlib.ScHname(0x612f835f); export const HFuncArrayClear = new wasmlib.ScHname(0x88021821); -export const HFuncArrayCreate = new wasmlib.ScHname(0x1ed5b23b); export const HFuncArraySet = new wasmlib.ScHname(0x2c4150b3); export const HFuncMapClear = new wasmlib.ScHname(0x027f215a); -export const HFuncMapCreate = new wasmlib.ScHname(0x6295d599); export const HFuncMapSet = new wasmlib.ScHname(0xf2260404); export const HFuncParamTypes = new wasmlib.ScHname(0x6921c4cd); export const HFuncRandom = new wasmlib.ScHname(0xe86c97ca); diff --git a/contracts/wasm/testwasmlib/ts/testwasmlib/contract.ts b/contracts/wasm/testwasmlib/ts/testwasmlib/contract.ts index 0b3ecd8c70..091d1253b0 100644 --- a/contracts/wasm/testwasmlib/ts/testwasmlib/contract.ts +++ b/contracts/wasm/testwasmlib/ts/testwasmlib/contract.ts @@ -8,25 +8,25 @@ import * as wasmlib from "wasmlib"; import * as sc from "./index"; -export class ArrayClearCall { - func: wasmlib.ScFunc = new wasmlib.ScFunc(sc.HScName, sc.HFuncArrayClear); - params: sc.MutableArrayClearParams = new sc.MutableArrayClearParams(); +export class ArrayAppendCall { + func: wasmlib.ScFunc = new wasmlib.ScFunc(sc.HScName, sc.HFuncArrayAppend); + params: sc.MutableArrayAppendParams = new sc.MutableArrayAppendParams(); } -export class ArrayClearContext { +export class ArrayAppendContext { events: sc.TestWasmLibEvents = new sc.TestWasmLibEvents(); - params: sc.ImmutableArrayClearParams = new sc.ImmutableArrayClearParams(); + params: sc.ImmutableArrayAppendParams = new sc.ImmutableArrayAppendParams(); state: sc.MutableTestWasmLibState = new sc.MutableTestWasmLibState(); } -export class ArrayCreateCall { - func: wasmlib.ScFunc = new wasmlib.ScFunc(sc.HScName, sc.HFuncArrayCreate); - params: sc.MutableArrayCreateParams = new sc.MutableArrayCreateParams(); +export class ArrayClearCall { + func: wasmlib.ScFunc = new wasmlib.ScFunc(sc.HScName, sc.HFuncArrayClear); + params: sc.MutableArrayClearParams = new sc.MutableArrayClearParams(); } -export class ArrayCreateContext { +export class ArrayClearContext { events: sc.TestWasmLibEvents = new sc.TestWasmLibEvents(); - params: sc.ImmutableArrayCreateParams = new sc.ImmutableArrayCreateParams(); + params: sc.ImmutableArrayClearParams = new sc.ImmutableArrayClearParams(); state: sc.MutableTestWasmLibState = new sc.MutableTestWasmLibState(); } @@ -52,17 +52,6 @@ export class MapClearContext { state: sc.MutableTestWasmLibState = new sc.MutableTestWasmLibState(); } -export class MapCreateCall { - func: wasmlib.ScFunc = new wasmlib.ScFunc(sc.HScName, sc.HFuncMapCreate); - params: sc.MutableMapCreateParams = new sc.MutableMapCreateParams(); -} - -export class MapCreateContext { - events: sc.TestWasmLibEvents = new sc.TestWasmLibEvents(); - params: sc.ImmutableMapCreateParams = new sc.ImmutableMapCreateParams(); - state: sc.MutableTestWasmLibState = new sc.MutableTestWasmLibState(); -} - export class MapSetCall { func: wasmlib.ScFunc = new wasmlib.ScFunc(sc.HScName, sc.HFuncMapSet); params: sc.MutableMapSetParams = new sc.MutableMapSetParams(); @@ -186,14 +175,14 @@ export class MapValueContext { } export class ScFuncs { - static arrayClear(ctx: wasmlib.ScFuncCallContext): ArrayClearCall { - let f = new ArrayClearCall(); + static arrayAppend(ctx: wasmlib.ScFuncCallContext): ArrayAppendCall { + let f = new ArrayAppendCall(); f.func.setPtrs(f.params, null); return f; } - static arrayCreate(ctx: wasmlib.ScFuncCallContext): ArrayCreateCall { - let f = new ArrayCreateCall(); + static arrayClear(ctx: wasmlib.ScFuncCallContext): ArrayClearCall { + let f = new ArrayClearCall(); f.func.setPtrs(f.params, null); return f; } @@ -210,12 +199,6 @@ export class ScFuncs { return f; } - static mapCreate(ctx: wasmlib.ScFuncCallContext): MapCreateCall { - let f = new MapCreateCall(); - f.func.setPtrs(f.params, null); - return f; - } - static mapSet(ctx: wasmlib.ScFuncCallContext): MapSetCall { let f = new MapSetCall(); f.func.setPtrs(f.params, null); diff --git a/contracts/wasm/testwasmlib/ts/testwasmlib/lib.ts b/contracts/wasm/testwasmlib/ts/testwasmlib/lib.ts index 10066f63d0..dd8f65b877 100644 --- a/contracts/wasm/testwasmlib/ts/testwasmlib/lib.ts +++ b/contracts/wasm/testwasmlib/ts/testwasmlib/lib.ts @@ -14,11 +14,10 @@ export function on_call(index: i32): void { export function on_load(): void { let exports = new wasmlib.ScExports(); + exports.addFunc(sc.FuncArrayAppend, funcArrayAppendThunk); exports.addFunc(sc.FuncArrayClear, funcArrayClearThunk); - exports.addFunc(sc.FuncArrayCreate, funcArrayCreateThunk); exports.addFunc(sc.FuncArraySet, funcArraySetThunk); exports.addFunc(sc.FuncMapClear, funcMapClearThunk); - exports.addFunc(sc.FuncMapCreate, funcMapCreateThunk); exports.addFunc(sc.FuncMapSet, funcMapSetThunk); exports.addFunc(sc.FuncParamTypes, funcParamTypesThunk); exports.addFunc(sc.FuncRandom, funcRandomThunk); @@ -36,24 +35,25 @@ export function on_load(): void { } } -function funcArrayClearThunk(ctx: wasmlib.ScFuncContext): void { - ctx.log("testwasmlib.funcArrayClear"); - let f = new sc.ArrayClearContext(); +function funcArrayAppendThunk(ctx: wasmlib.ScFuncContext): void { + ctx.log("testwasmlib.funcArrayAppend"); + let f = new sc.ArrayAppendContext(); f.params.mapID = wasmlib.OBJ_ID_PARAMS; f.state.mapID = wasmlib.OBJ_ID_STATE; ctx.require(f.params.name().exists(), "missing mandatory name"); - sc.funcArrayClear(ctx, f); - ctx.log("testwasmlib.funcArrayClear ok"); + ctx.require(f.params.value().exists(), "missing mandatory value"); + sc.funcArrayAppend(ctx, f); + ctx.log("testwasmlib.funcArrayAppend ok"); } -function funcArrayCreateThunk(ctx: wasmlib.ScFuncContext): void { - ctx.log("testwasmlib.funcArrayCreate"); - let f = new sc.ArrayCreateContext(); +function funcArrayClearThunk(ctx: wasmlib.ScFuncContext): void { + ctx.log("testwasmlib.funcArrayClear"); + let f = new sc.ArrayClearContext(); f.params.mapID = wasmlib.OBJ_ID_PARAMS; f.state.mapID = wasmlib.OBJ_ID_STATE; ctx.require(f.params.name().exists(), "missing mandatory name"); - sc.funcArrayCreate(ctx, f); - ctx.log("testwasmlib.funcArrayCreate ok"); + sc.funcArrayClear(ctx, f); + ctx.log("testwasmlib.funcArrayClear ok"); } function funcArraySetThunk(ctx: wasmlib.ScFuncContext): void { @@ -78,16 +78,6 @@ function funcMapClearThunk(ctx: wasmlib.ScFuncContext): void { ctx.log("testwasmlib.funcMapClear ok"); } -function funcMapCreateThunk(ctx: wasmlib.ScFuncContext): void { - ctx.log("testwasmlib.funcMapCreate"); - let f = new sc.MapCreateContext(); - f.params.mapID = wasmlib.OBJ_ID_PARAMS; - f.state.mapID = wasmlib.OBJ_ID_STATE; - ctx.require(f.params.name().exists(), "missing mandatory name"); - sc.funcMapCreate(ctx, f); - ctx.log("testwasmlib.funcMapCreate ok"); -} - function funcMapSetThunk(ctx: wasmlib.ScFuncContext): void { ctx.log("testwasmlib.funcMapSet"); let f = new sc.MapSetContext(); diff --git a/contracts/wasm/testwasmlib/ts/testwasmlib/params.ts b/contracts/wasm/testwasmlib/ts/testwasmlib/params.ts index cacc72ca4d..7a86530e48 100644 --- a/contracts/wasm/testwasmlib/ts/testwasmlib/params.ts +++ b/contracts/wasm/testwasmlib/ts/testwasmlib/params.ts @@ -8,33 +8,41 @@ import * as wasmlib from "wasmlib"; import * as sc from "./index"; -export class ImmutableArrayClearParams extends wasmlib.ScMapID { +export class ImmutableArrayAppendParams extends wasmlib.ScMapID { name(): wasmlib.ScImmutableString { return new wasmlib.ScImmutableString(this.mapID, wasmlib.Key32.fromString(sc.ParamName)); } + + value(): wasmlib.ScImmutableString { + return new wasmlib.ScImmutableString(this.mapID, wasmlib.Key32.fromString(sc.ParamValue)); + } } -export class MutableArrayClearParams extends wasmlib.ScMapID { +export class MutableArrayAppendParams extends wasmlib.ScMapID { name(): wasmlib.ScMutableString { return new wasmlib.ScMutableString(this.mapID, wasmlib.Key32.fromString(sc.ParamName)); } + + value(): wasmlib.ScMutableString { + return new wasmlib.ScMutableString(this.mapID, wasmlib.Key32.fromString(sc.ParamValue)); + } } -export class ImmutableArrayCreateParams extends wasmlib.ScMapID { +export class ImmutableArrayClearParams extends wasmlib.ScMapID { name(): wasmlib.ScImmutableString { return new wasmlib.ScImmutableString(this.mapID, wasmlib.Key32.fromString(sc.ParamName)); } } -export class MutableArrayCreateParams extends wasmlib.ScMapID { +export class MutableArrayClearParams extends wasmlib.ScMapID { name(): wasmlib.ScMutableString { return new wasmlib.ScMutableString(this.mapID, wasmlib.Key32.fromString(sc.ParamName)); } } export class ImmutableArraySetParams extends wasmlib.ScMapID { - index(): wasmlib.ScImmutableInt32 { - return new wasmlib.ScImmutableInt32(this.mapID, wasmlib.Key32.fromString(sc.ParamIndex)); + index(): wasmlib.ScImmutableUint32 { + return new wasmlib.ScImmutableUint32(this.mapID, wasmlib.Key32.fromString(sc.ParamIndex)); } name(): wasmlib.ScImmutableString { @@ -47,8 +55,8 @@ export class ImmutableArraySetParams extends wasmlib.ScMapID { } export class MutableArraySetParams extends wasmlib.ScMapID { - index(): wasmlib.ScMutableInt32 { - return new wasmlib.ScMutableInt32(this.mapID, wasmlib.Key32.fromString(sc.ParamIndex)); + index(): wasmlib.ScMutableUint32 { + return new wasmlib.ScMutableUint32(this.mapID, wasmlib.Key32.fromString(sc.ParamIndex)); } name(): wasmlib.ScMutableString { @@ -72,18 +80,6 @@ export class MutableMapClearParams extends wasmlib.ScMapID { } } -export class ImmutableMapCreateParams extends wasmlib.ScMapID { - name(): wasmlib.ScImmutableString { - return new wasmlib.ScImmutableString(this.mapID, wasmlib.Key32.fromString(sc.ParamName)); - } -} - -export class MutableMapCreateParams extends wasmlib.ScMapID { - name(): wasmlib.ScMutableString { - return new wasmlib.ScMutableString(this.mapID, wasmlib.Key32.fromString(sc.ParamName)); - } -} - export class ImmutableMapSetParams extends wasmlib.ScMapID { key(): wasmlib.ScImmutableString { return new wasmlib.ScImmutableString(this.mapID, wasmlib.Key32.fromString(sc.ParamKey)); @@ -329,8 +325,8 @@ export class MutableArrayLengthParams extends wasmlib.ScMapID { } export class ImmutableArrayValueParams extends wasmlib.ScMapID { - index(): wasmlib.ScImmutableInt32 { - return new wasmlib.ScImmutableInt32(this.mapID, wasmlib.Key32.fromString(sc.ParamIndex)); + index(): wasmlib.ScImmutableUint32 { + return new wasmlib.ScImmutableUint32(this.mapID, wasmlib.Key32.fromString(sc.ParamIndex)); } name(): wasmlib.ScImmutableString { @@ -339,8 +335,8 @@ export class ImmutableArrayValueParams extends wasmlib.ScMapID { } export class MutableArrayValueParams extends wasmlib.ScMapID { - index(): wasmlib.ScMutableInt32 { - return new wasmlib.ScMutableInt32(this.mapID, wasmlib.Key32.fromString(sc.ParamIndex)); + index(): wasmlib.ScMutableUint32 { + return new wasmlib.ScMutableUint32(this.mapID, wasmlib.Key32.fromString(sc.ParamIndex)); } name(): wasmlib.ScMutableString { @@ -349,34 +345,34 @@ export class MutableArrayValueParams extends wasmlib.ScMapID { } export class ImmutableBlockRecordParams extends wasmlib.ScMapID { - blockIndex(): wasmlib.ScImmutableInt32 { - return new wasmlib.ScImmutableInt32(this.mapID, wasmlib.Key32.fromString(sc.ParamBlockIndex)); + blockIndex(): wasmlib.ScImmutableUint32 { + return new wasmlib.ScImmutableUint32(this.mapID, wasmlib.Key32.fromString(sc.ParamBlockIndex)); } - recordIndex(): wasmlib.ScImmutableInt32 { - return new wasmlib.ScImmutableInt32(this.mapID, wasmlib.Key32.fromString(sc.ParamRecordIndex)); + recordIndex(): wasmlib.ScImmutableUint32 { + return new wasmlib.ScImmutableUint32(this.mapID, wasmlib.Key32.fromString(sc.ParamRecordIndex)); } } export class MutableBlockRecordParams extends wasmlib.ScMapID { - blockIndex(): wasmlib.ScMutableInt32 { - return new wasmlib.ScMutableInt32(this.mapID, wasmlib.Key32.fromString(sc.ParamBlockIndex)); + blockIndex(): wasmlib.ScMutableUint32 { + return new wasmlib.ScMutableUint32(this.mapID, wasmlib.Key32.fromString(sc.ParamBlockIndex)); } - recordIndex(): wasmlib.ScMutableInt32 { - return new wasmlib.ScMutableInt32(this.mapID, wasmlib.Key32.fromString(sc.ParamRecordIndex)); + recordIndex(): wasmlib.ScMutableUint32 { + return new wasmlib.ScMutableUint32(this.mapID, wasmlib.Key32.fromString(sc.ParamRecordIndex)); } } export class ImmutableBlockRecordsParams extends wasmlib.ScMapID { - blockIndex(): wasmlib.ScImmutableInt32 { - return new wasmlib.ScImmutableInt32(this.mapID, wasmlib.Key32.fromString(sc.ParamBlockIndex)); + blockIndex(): wasmlib.ScImmutableUint32 { + return new wasmlib.ScImmutableUint32(this.mapID, wasmlib.Key32.fromString(sc.ParamBlockIndex)); } } export class MutableBlockRecordsParams extends wasmlib.ScMapID { - blockIndex(): wasmlib.ScMutableInt32 { - return new wasmlib.ScMutableInt32(this.mapID, wasmlib.Key32.fromString(sc.ParamBlockIndex)); + blockIndex(): wasmlib.ScMutableUint32 { + return new wasmlib.ScMutableUint32(this.mapID, wasmlib.Key32.fromString(sc.ParamBlockIndex)); } } diff --git a/contracts/wasm/testwasmlib/ts/testwasmlib/results.ts b/contracts/wasm/testwasmlib/ts/testwasmlib/results.ts index 476649ffcd..05cd88628a 100644 --- a/contracts/wasm/testwasmlib/ts/testwasmlib/results.ts +++ b/contracts/wasm/testwasmlib/ts/testwasmlib/results.ts @@ -9,14 +9,14 @@ import * as wasmlib from "wasmlib"; import * as sc from "./index"; export class ImmutableArrayLengthResults extends wasmlib.ScMapID { - length(): wasmlib.ScImmutableInt32 { - return new wasmlib.ScImmutableInt32(this.mapID, wasmlib.Key32.fromString(sc.ResultLength)); + length(): wasmlib.ScImmutableUint32 { + return new wasmlib.ScImmutableUint32(this.mapID, wasmlib.Key32.fromString(sc.ResultLength)); } } export class MutableArrayLengthResults extends wasmlib.ScMapID { - length(): wasmlib.ScMutableInt32 { - return new wasmlib.ScMutableInt32(this.mapID, wasmlib.Key32.fromString(sc.ResultLength)); + length(): wasmlib.ScMutableUint32 { + return new wasmlib.ScMutableUint32(this.mapID, wasmlib.Key32.fromString(sc.ResultLength)); } } @@ -45,38 +45,38 @@ export class MutableBlockRecordResults extends wasmlib.ScMapID { } export class ImmutableBlockRecordsResults extends wasmlib.ScMapID { - count(): wasmlib.ScImmutableInt32 { - return new wasmlib.ScImmutableInt32(this.mapID, wasmlib.Key32.fromString(sc.ResultCount)); + count(): wasmlib.ScImmutableUint32 { + return new wasmlib.ScImmutableUint32(this.mapID, wasmlib.Key32.fromString(sc.ResultCount)); } } export class MutableBlockRecordsResults extends wasmlib.ScMapID { - count(): wasmlib.ScMutableInt32 { - return new wasmlib.ScMutableInt32(this.mapID, wasmlib.Key32.fromString(sc.ResultCount)); + count(): wasmlib.ScMutableUint32 { + return new wasmlib.ScMutableUint32(this.mapID, wasmlib.Key32.fromString(sc.ResultCount)); } } export class ImmutableGetRandomResults extends wasmlib.ScMapID { - random(): wasmlib.ScImmutableInt64 { - return new wasmlib.ScImmutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ResultRandom)); + random(): wasmlib.ScImmutableUint64 { + return new wasmlib.ScImmutableUint64(this.mapID, wasmlib.Key32.fromString(sc.ResultRandom)); } } export class MutableGetRandomResults extends wasmlib.ScMapID { - random(): wasmlib.ScMutableInt64 { - return new wasmlib.ScMutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ResultRandom)); + random(): wasmlib.ScMutableUint64 { + return new wasmlib.ScMutableUint64(this.mapID, wasmlib.Key32.fromString(sc.ResultRandom)); } } export class ImmutableIotaBalanceResults extends wasmlib.ScMapID { - iotas(): wasmlib.ScImmutableInt64 { - return new wasmlib.ScImmutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ResultIotas)); + iotas(): wasmlib.ScImmutableUint64 { + return new wasmlib.ScImmutableUint64(this.mapID, wasmlib.Key32.fromString(sc.ResultIotas)); } } export class MutableIotaBalanceResults extends wasmlib.ScMapID { - iotas(): wasmlib.ScMutableInt64 { - return new wasmlib.ScMutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ResultIotas)); + iotas(): wasmlib.ScMutableUint64 { + return new wasmlib.ScMutableUint64(this.mapID, wasmlib.Key32.fromString(sc.ResultIotas)); } } diff --git a/contracts/wasm/testwasmlib/ts/testwasmlib/state.ts b/contracts/wasm/testwasmlib/ts/testwasmlib/state.ts index bdc4b782a3..07351efdc4 100644 --- a/contracts/wasm/testwasmlib/ts/testwasmlib/state.ts +++ b/contracts/wasm/testwasmlib/ts/testwasmlib/state.ts @@ -45,8 +45,8 @@ export class ImmutableTestWasmLibState extends wasmlib.ScMapID { return new sc.MapStringToImmutableStringMap(mapID); } - random(): wasmlib.ScImmutableInt64 { - return new wasmlib.ScImmutableInt64(this.mapID, wasmlib.Key32.fromString(sc.StateRandom)); + random(): wasmlib.ScImmutableUint64 { + return new wasmlib.ScImmutableUint64(this.mapID, wasmlib.Key32.fromString(sc.StateRandom)); } } @@ -101,7 +101,7 @@ export class MutableTestWasmLibState extends wasmlib.ScMapID { return new sc.MapStringToMutableStringMap(mapID); } - random(): wasmlib.ScMutableInt64 { - return new wasmlib.ScMutableInt64(this.mapID, wasmlib.Key32.fromString(sc.StateRandom)); + random(): wasmlib.ScMutableUint64 { + return new wasmlib.ScMutableUint64(this.mapID, wasmlib.Key32.fromString(sc.StateRandom)); } } diff --git a/contracts/wasm/testwasmlib/ts/testwasmlib/structs.ts b/contracts/wasm/testwasmlib/ts/testwasmlib/structs.ts index 943ee88121..dde968d18d 100644 --- a/contracts/wasm/testwasmlib/ts/testwasmlib/structs.ts +++ b/contracts/wasm/testwasmlib/ts/testwasmlib/structs.ts @@ -7,28 +7,34 @@ import * as wasmlib from "wasmlib"; -export class Location { - x : i32 = 0; - y : i32 = 0; +export class CallRequest { + contract : wasmlib.ScHname = new wasmlib.ScHname(0); + function : wasmlib.ScHname = new wasmlib.ScHname(0); + params : = ; + transfer : = ; - static fromBytes(bytes: u8[]): Location { + static fromBytes(bytes: u8[]): CallRequest { let decode = new wasmlib.BytesDecoder(bytes); - let data = new Location(); - data.x = decode.int32(); - data.y = decode.int32(); + let data = new CallRequest(); + data.contract = decode.hname(); + data.function = decode.hname(); + data.params = decode.bytes(); + data.transfer = decode.bytes(); decode.close(); return data; } bytes(): u8[] { return new wasmlib.BytesEncoder(). - int32(this.x). - int32(this.y). + hname(this.contract). + hname(this.function). + bytes(this.params). + bytes(this.transfer). data(); } } -export class ImmutableLocation { +export class ImmutableCallRequest { objID: i32; keyID: wasmlib.Key32; @@ -41,12 +47,12 @@ export class ImmutableLocation { return wasmlib.exists(this.objID, this.keyID, wasmlib.TYPE_BYTES); } - value(): Location { - return Location.fromBytes(wasmlib.getBytes(this.objID, this.keyID, wasmlib.TYPE_BYTES)); + value(): CallRequest { + return CallRequest.fromBytes(wasmlib.getBytes(this.objID, this.keyID, wasmlib.TYPE_BYTES)); } } -export class MutableLocation { +export class MutableCallRequest { objID: i32; keyID: wasmlib.Key32; @@ -63,11 +69,224 @@ export class MutableLocation { return wasmlib.exists(this.objID, this.keyID, wasmlib.TYPE_BYTES); } - setValue(value: Location): void { + setValue(value: CallRequest): void { wasmlib.setBytes(this.objID, this.keyID, wasmlib.TYPE_BYTES, value.bytes()); } - value(): Location { - return Location.fromBytes(wasmlib.getBytes(this.objID, this.keyID, wasmlib.TYPE_BYTES)); + value(): CallRequest { + return CallRequest.fromBytes(wasmlib.getBytes(this.objID, this.keyID, wasmlib.TYPE_BYTES)); + } +} + +export class DeployRequest { + description : string = ""; + name : string = ""; + params : = ; + progHash : wasmlib.ScHash = new wasmlib.ScHash(); + + static fromBytes(bytes: u8[]): DeployRequest { + let decode = new wasmlib.BytesDecoder(bytes); + let data = new DeployRequest(); + data.description = decode.string(); + data.name = decode.string(); + data.params = decode.bytes(); + data.progHash = decode.hash(); + decode.close(); + return data; + } + + bytes(): u8[] { + return new wasmlib.BytesEncoder(). + string(this.description). + string(this.name). + bytes(this.params). + hash(this.progHash). + data(); + } +} + +export class ImmutableDeployRequest { + objID: i32; + keyID: wasmlib.Key32; + + constructor(objID: i32, keyID: wasmlib.Key32) { + this.objID = objID; + this.keyID = keyID; + } + + exists(): boolean { + return wasmlib.exists(this.objID, this.keyID, wasmlib.TYPE_BYTES); + } + + value(): DeployRequest { + return DeployRequest.fromBytes(wasmlib.getBytes(this.objID, this.keyID, wasmlib.TYPE_BYTES)); + } +} + +export class MutableDeployRequest { + objID: i32; + keyID: wasmlib.Key32; + + constructor(objID: i32, keyID: wasmlib.Key32) { + this.objID = objID; + this.keyID = keyID; + } + + delete(): void { + wasmlib.delKey(this.objID, this.keyID, wasmlib.TYPE_BYTES); + } + + exists(): boolean { + return wasmlib.exists(this.objID, this.keyID, wasmlib.TYPE_BYTES); + } + + setValue(value: DeployRequest): void { + wasmlib.setBytes(this.objID, this.keyID, wasmlib.TYPE_BYTES, value.bytes()); + } + + value(): DeployRequest { + return DeployRequest.fromBytes(wasmlib.getBytes(this.objID, this.keyID, wasmlib.TYPE_BYTES)); + } +} + +export class PostRequest { + chainID : wasmlib.ScChainID = new wasmlib.ScChainID(); + contract : wasmlib.ScHname = new wasmlib.ScHname(0); + delay : u32 = 0; + function : wasmlib.ScHname = new wasmlib.ScHname(0); + params : = ; + transfer : = ; + + static fromBytes(bytes: u8[]): PostRequest { + let decode = new wasmlib.BytesDecoder(bytes); + let data = new PostRequest(); + data.chainID = decode.chainID(); + data.contract = decode.hname(); + data.delay = decode.uint32(); + data.function = decode.hname(); + data.params = decode.bytes(); + data.transfer = decode.bytes(); + decode.close(); + return data; + } + + bytes(): u8[] { + return new wasmlib.BytesEncoder(). + chainID(this.chainID). + hname(this.contract). + uint32(this.delay). + hname(this.function). + bytes(this.params). + bytes(this.transfer). + data(); + } +} + +export class ImmutablePostRequest { + objID: i32; + keyID: wasmlib.Key32; + + constructor(objID: i32, keyID: wasmlib.Key32) { + this.objID = objID; + this.keyID = keyID; + } + + exists(): boolean { + return wasmlib.exists(this.objID, this.keyID, wasmlib.TYPE_BYTES); + } + + value(): PostRequest { + return PostRequest.fromBytes(wasmlib.getBytes(this.objID, this.keyID, wasmlib.TYPE_BYTES)); + } +} + +export class MutablePostRequest { + objID: i32; + keyID: wasmlib.Key32; + + constructor(objID: i32, keyID: wasmlib.Key32) { + this.objID = objID; + this.keyID = keyID; + } + + delete(): void { + wasmlib.delKey(this.objID, this.keyID, wasmlib.TYPE_BYTES); + } + + exists(): boolean { + return wasmlib.exists(this.objID, this.keyID, wasmlib.TYPE_BYTES); + } + + setValue(value: PostRequest): void { + wasmlib.setBytes(this.objID, this.keyID, wasmlib.TYPE_BYTES, value.bytes()); + } + + value(): PostRequest { + return PostRequest.fromBytes(wasmlib.getBytes(this.objID, this.keyID, wasmlib.TYPE_BYTES)); + } +} + +export class SendRequest { + address : wasmlib.ScAddress = new wasmlib.ScAddress(); + transfer : = ; + + static fromBytes(bytes: u8[]): SendRequest { + let decode = new wasmlib.BytesDecoder(bytes); + let data = new SendRequest(); + data.address = decode.address(); + data.transfer = decode.bytes(); + decode.close(); + return data; + } + + bytes(): u8[] { + return new wasmlib.BytesEncoder(). + address(this.address). + bytes(this.transfer). + data(); + } +} + +export class ImmutableSendRequest { + objID: i32; + keyID: wasmlib.Key32; + + constructor(objID: i32, keyID: wasmlib.Key32) { + this.objID = objID; + this.keyID = keyID; + } + + exists(): boolean { + return wasmlib.exists(this.objID, this.keyID, wasmlib.TYPE_BYTES); + } + + value(): SendRequest { + return SendRequest.fromBytes(wasmlib.getBytes(this.objID, this.keyID, wasmlib.TYPE_BYTES)); + } +} + +export class MutableSendRequest { + objID: i32; + keyID: wasmlib.Key32; + + constructor(objID: i32, keyID: wasmlib.Key32) { + this.objID = objID; + this.keyID = keyID; + } + + delete(): void { + wasmlib.delKey(this.objID, this.keyID, wasmlib.TYPE_BYTES); + } + + exists(): boolean { + return wasmlib.exists(this.objID, this.keyID, wasmlib.TYPE_BYTES); + } + + setValue(value: SendRequest): void { + wasmlib.setBytes(this.objID, this.keyID, wasmlib.TYPE_BYTES, value.bytes()); + } + + value(): SendRequest { + return SendRequest.fromBytes(wasmlib.getBytes(this.objID, this.keyID, wasmlib.TYPE_BYTES)); } } diff --git a/contracts/wasm/testwasmlib/ts/testwasmlib/testwasmlib.ts b/contracts/wasm/testwasmlib/ts/testwasmlib/testwasmlib.ts index c92f97dba5..fd9aebacce 100644 --- a/contracts/wasm/testwasmlib/ts/testwasmlib/testwasmlib.ts +++ b/contracts/wasm/testwasmlib/ts/testwasmlib/testwasmlib.ts @@ -5,13 +5,10 @@ import * as wasmlib from "wasmlib" import * as coreblocklog from "wasmlib/coreblocklog" import * as sc from "./index"; -export function funcArrayClear(ctx: wasmlib.ScFuncContext, f: sc.ArrayClearContext): void { - let name = f.params.name().value(); - let array = f.state.arrays().getStringArray(name); - array.clear(); +export function funcArrayAppend(ctx: wasmlib.ScFuncContext, f: sc.ArrayAppendContext): void { } -export function funcArrayCreate(ctx: wasmlib.ScFuncContext, f: sc.ArrayCreateContext): void { +export function funcArrayClear(ctx: wasmlib.ScFuncContext, f: sc.ArrayClearContext): void { let name = f.params.name().value(); let array = f.state.arrays().getStringArray(name); array.clear(); @@ -25,6 +22,12 @@ export function funcArraySet(ctx: wasmlib.ScFuncContext, f: sc.ArraySetContext): array.getString(index).setValue(value); } +export function funcMapClear(ctx: wasmlib.ScFuncContext, f: sc.MapClearContext): void { +} + +export function funcMapSet(ctx: wasmlib.ScFuncContext, f: sc.MapSetContext): void { +} + export function funcParamTypes(ctx: wasmlib.ScFuncContext, f: sc.ParamTypesContext): void { if (f.params.address().exists()) { ctx.require(f.params.address().value().equals(ctx.accountID().address()), "mismatch: Address"); @@ -86,6 +89,14 @@ export function funcParamTypes(ctx: wasmlib.ScFuncContext, f: sc.ParamTypesConte } } +export function funcRandom(ctx: wasmlib.ScFuncContext, f: sc.RandomContext): void { + f.state.random().setValue(ctx.random(1000)); +} + +export function funcTriggerEvent(ctx: wasmlib.ScFuncContext, f: sc.TriggerEventContext): void { + f.events.test(f.params.address().value(), f.params.name().value()); +} + export function viewArrayLength(ctx: wasmlib.ScViewContext, f: sc.ArrayLengthContext): void { let name = f.params.name().value(); let array = f.state.arrays().getStringArray(name); @@ -117,29 +128,12 @@ export function viewBlockRecords(ctx: wasmlib.ScViewContext, f: sc.BlockRecordsC f.results.count().setValue(records.results.requestRecord().length()); } -export function viewIotaBalance(ctx: wasmlib.ScViewContext, f: sc.IotaBalanceContext): void { - f.results.iotas().setValue(ctx.balances().balance(wasmlib.ScColor.IOTA)); -} - -export function funcRandom(ctx: wasmlib.ScFuncContext, f: sc.RandomContext): void { - f.state.random().setValue(ctx.random(1000)); -} - export function viewGetRandom(ctx: wasmlib.ScViewContext, f: sc.GetRandomContext): void { f.results.random().setValue(f.state.random().value()); } -export function funcTriggerEvent(ctx: wasmlib.ScFuncContext, f: sc.TriggerEventContext): void { - f.events.test(f.params.address().value(), f.params.name().value()); -} - -export function funcMapClear(ctx: wasmlib.ScFuncContext, f: sc.MapClearContext): void { -} - -export function funcMapCreate(ctx: wasmlib.ScFuncContext, f: sc.MapCreateContext): void { -} - -export function funcMapSet(ctx: wasmlib.ScFuncContext, f: sc.MapSetContext): void { +export function viewIotaBalance(ctx: wasmlib.ScViewContext, f: sc.IotaBalanceContext): void { + f.results.iotas().setValue(ctx.balances().balance(wasmlib.ScColor.IOTA)); } export function viewMapValue(ctx: wasmlib.ScViewContext, f: sc.MapValueContext): void { diff --git a/contracts/wasm/testwasmlib/ts/testwasmlib/typedefs.ts b/contracts/wasm/testwasmlib/ts/testwasmlib/typedefs.ts index a38bec20bd..14c0baab9a 100644 --- a/contracts/wasm/testwasmlib/ts/testwasmlib/typedefs.ts +++ b/contracts/wasm/testwasmlib/ts/testwasmlib/typedefs.ts @@ -15,12 +15,12 @@ export class ArrayOfImmutableString { this.objID = objID; } - length(): i32 { + length(): u32 { return wasmlib.getLength(this.objID); } - getString(index: i32): wasmlib.ScImmutableString { - return new wasmlib.ScImmutableString(this.objID, new wasmlib.Key32(index)); + getString(index: u32): wasmlib.ScImmutableString { + return new wasmlib.ScImmutableString(this.objID, new wasmlib.Key32(index as i32)); } } @@ -38,12 +38,12 @@ export class ArrayOfMutableString { wasmlib.clear(this.objID); } - length(): i32 { + length(): u32 { return wasmlib.getLength(this.objID); } - getString(index: i32): wasmlib.ScMutableString { - return new wasmlib.ScMutableString(this.objID, new wasmlib.Key32(index)); + getString(index: u32): wasmlib.ScMutableString { + return new wasmlib.ScMutableString(this.objID, new wasmlib.Key32(index as i32)); } } diff --git a/contracts/wasm/testwasmlib/ts/testwasmlibclient/events.ts b/contracts/wasm/testwasmlib/ts/testwasmlibclient/events.ts index e08edc7a31..1fce46bcb8 100644 --- a/contracts/wasm/testwasmlib/ts/testwasmlibclient/events.ts +++ b/contracts/wasm/testwasmlib/ts/testwasmlibclient/events.ts @@ -12,16 +12,18 @@ const testWasmLibHandlers = new Map void = () => {}; +/* eslint-disable @typescript-eslint/no-empty-function */ + test: (evt: EventTest) => void = () => {}; +/* eslint-enable @typescript-eslint/no-empty-function */ public callHandler(topic: string, params: string[]): void { const handler = testWasmLibHandlers.get(topic); - if (handler !== undefined) { + if (handler) { handler(this, params); } } - public onTestWasmLibTest(handler: (EventTest) => void): void { + public onTestWasmLibTest(handler: (evt: EventTest) => void): void { this.test = handler; } } @@ -31,7 +33,7 @@ export class EventTest extends wasmclient.Event { public readonly name: wasmclient.String; public constructor(msg: string[]) { - super(msg) + super(msg); this.address = this.nextAddress(); this.name = this.nextString(); } diff --git a/contracts/wasm/testwasmlib/ts/testwasmlibclient/index.ts b/contracts/wasm/testwasmlib/ts/testwasmlibclient/index.ts index f3eff69c33..1c2d312bca 100644 --- a/contracts/wasm/testwasmlib/ts/testwasmlibclient/index.ts +++ b/contracts/wasm/testwasmlib/ts/testwasmlibclient/index.ts @@ -5,6 +5,5 @@ // >>>> DO NOT CHANGE THIS FILE! <<<< // Change the json schema instead -export * from "./testwasmlib"; export * from "./events"; export * from "./service"; diff --git a/contracts/wasm/testwasmlib/ts/testwasmlibclient/service.ts b/contracts/wasm/testwasmlib/ts/testwasmlibclient/service.ts index 58e3f5982b..fab9b3e3f0 100644 --- a/contracts/wasm/testwasmlib/ts/testwasmlibclient/service.ts +++ b/contracts/wasm/testwasmlib/ts/testwasmlibclient/service.ts @@ -41,24 +41,29 @@ const ResRandom = "random"; const ResRecord = "record"; const ResValue = "value"; -///////////////////////////// arrayClear ///////////////////////////// +///////////////////////////// arrayAppend ///////////////////////////// -export class ArrayClearFunc extends wasmclient.ClientFunc { +export class ArrayAppendFunc extends wasmclient.ClientFunc { private args: wasmclient.Arguments = new wasmclient.Arguments(); public name(v: string): void { this.args.set(ArgName, this.args.fromString(v)); } + public value(v: string): void { + this.args.set(ArgValue, this.args.fromString(v)); + } + public async post(): Promise { this.args.mandatory(ArgName); - return await super.post(0x88021821, this.args); + this.args.mandatory(ArgValue); + return await super.post(0x612f835f, this.args); } } -///////////////////////////// arrayCreate ///////////////////////////// +///////////////////////////// arrayClear ///////////////////////////// -export class ArrayCreateFunc extends wasmclient.ClientFunc { +export class ArrayClearFunc extends wasmclient.ClientFunc { private args: wasmclient.Arguments = new wasmclient.Arguments(); public name(v: string): void { @@ -67,7 +72,7 @@ export class ArrayCreateFunc extends wasmclient.ClientFunc { public async post(): Promise { this.args.mandatory(ArgName); - return await super.post(0x1ed5b23b, this.args); + return await super.post(0x88021821, this.args); } } @@ -76,8 +81,8 @@ export class ArrayCreateFunc extends wasmclient.ClientFunc { export class ArraySetFunc extends wasmclient.ClientFunc { private args: wasmclient.Arguments = new wasmclient.Arguments(); - public index(v: wasmclient.Int32): void { - this.args.set(ArgIndex, this.args.fromInt32(v)); + public index(v: wasmclient.Uint32): void { + this.args.set(ArgIndex, this.args.fromUint32(v)); } public name(v: string): void { @@ -111,21 +116,6 @@ export class MapClearFunc extends wasmclient.ClientFunc { } } -///////////////////////////// mapCreate ///////////////////////////// - -export class MapCreateFunc extends wasmclient.ClientFunc { - private args: wasmclient.Arguments = new wasmclient.Arguments(); - - public name(v: string): void { - this.args.set(ArgName, this.args.fromString(v)); - } - - public async post(): Promise { - this.args.mandatory(ArgName); - return await super.post(0x6295d599, this.args); - } -} - ///////////////////////////// mapSet ///////////////////////////// export class MapSetFunc extends wasmclient.ClientFunc { @@ -285,8 +275,8 @@ export class ArrayLengthView extends wasmclient.ClientView { export class ArrayLengthResults extends wasmclient.Results { - length(): wasmclient.Int32 { - return this.toInt32(this.get(ResLength)); + length(): wasmclient.Uint32 { + return this.toUint32(this.get(ResLength)); } } @@ -295,8 +285,8 @@ export class ArrayLengthResults extends wasmclient.Results { export class ArrayValueView extends wasmclient.ClientView { private args: wasmclient.Arguments = new wasmclient.Arguments(); - public index(v: wasmclient.Int32): void { - this.args.set(ArgIndex, this.args.fromInt32(v)); + public index(v: wasmclient.Uint32): void { + this.args.set(ArgIndex, this.args.fromUint32(v)); } public name(v: string): void { @@ -324,12 +314,12 @@ export class ArrayValueResults extends wasmclient.Results { export class BlockRecordView extends wasmclient.ClientView { private args: wasmclient.Arguments = new wasmclient.Arguments(); - public blockIndex(v: wasmclient.Int32): void { - this.args.set(ArgBlockIndex, this.args.fromInt32(v)); + public blockIndex(v: wasmclient.Uint32): void { + this.args.set(ArgBlockIndex, this.args.fromUint32(v)); } - public recordIndex(v: wasmclient.Int32): void { - this.args.set(ArgRecordIndex, this.args.fromInt32(v)); + public recordIndex(v: wasmclient.Uint32): void { + this.args.set(ArgRecordIndex, this.args.fromUint32(v)); } public async call(): Promise { @@ -353,8 +343,8 @@ export class BlockRecordResults extends wasmclient.Results { export class BlockRecordsView extends wasmclient.ClientView { private args: wasmclient.Arguments = new wasmclient.Arguments(); - public blockIndex(v: wasmclient.Int32): void { - this.args.set(ArgBlockIndex, this.args.fromInt32(v)); + public blockIndex(v: wasmclient.Uint32): void { + this.args.set(ArgBlockIndex, this.args.fromUint32(v)); } public async call(): Promise { @@ -367,8 +357,8 @@ export class BlockRecordsView extends wasmclient.ClientView { export class BlockRecordsResults extends wasmclient.Results { - count(): wasmclient.Int32 { - return this.toInt32(this.get(ResCount)); + count(): wasmclient.Uint32 { + return this.toUint32(this.get(ResCount)); } } @@ -385,8 +375,8 @@ export class GetRandomView extends wasmclient.ClientView { export class GetRandomResults extends wasmclient.Results { - random(): wasmclient.Int64 { - return this.toInt64(this.get(ResRandom)); + random(): wasmclient.Uint64 { + return this.toUint64(this.get(ResRandom)); } } @@ -403,8 +393,8 @@ export class IotaBalanceView extends wasmclient.ClientView { export class IotaBalanceResults extends wasmclient.Results { - iotas(): wasmclient.Int64 { - return this.toInt64(this.get(ResIotas)); + iotas(): wasmclient.Uint64 { + return this.toUint64(this.get(ResIotas)); } } @@ -449,12 +439,12 @@ export class TestWasmLibService extends wasmclient.Service { return new events.TestWasmLibEvents(); } - public arrayClear(): ArrayClearFunc { - return new ArrayClearFunc(this); + public arrayAppend(): ArrayAppendFunc { + return new ArrayAppendFunc(this); } - public arrayCreate(): ArrayCreateFunc { - return new ArrayCreateFunc(this); + public arrayClear(): ArrayClearFunc { + return new ArrayClearFunc(this); } public arraySet(): ArraySetFunc { @@ -465,10 +455,6 @@ export class TestWasmLibService extends wasmclient.Service { return new MapClearFunc(this); } - public mapCreate(): MapCreateFunc { - return new MapCreateFunc(this); - } - public mapSet(): MapSetFunc { return new MapSetFunc(this); } diff --git a/contracts/wasm/timestamp/go/timestamp/consts.go b/contracts/wasm/timestamp/go/timestamp/consts.go index 7e2f5135f8..99c6f616bf 100644 --- a/contracts/wasm/timestamp/go/timestamp/consts.go +++ b/contracts/wasm/timestamp/go/timestamp/consts.go @@ -7,12 +7,12 @@ package timestamp -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" +import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" const ( ScName = "timestamp" ScDescription = "Extremely simple timestamp server" - HScName = wasmlib.ScHname(0x3988002e) + HScName = wasmtypes.ScHname(0x3988002e) ) const ( @@ -29,6 +29,6 @@ const ( ) const ( - HFuncNow = wasmlib.ScHname(0xd73b7fc9) - HViewGetTimestamp = wasmlib.ScHname(0x40c6376a) + HFuncNow = wasmtypes.ScHname(0xd73b7fc9) + HViewGetTimestamp = wasmtypes.ScHname(0x40c6376a) ) diff --git a/contracts/wasm/timestamp/go/timestamp/contract.go b/contracts/wasm/timestamp/go/timestamp/contract.go index e58a562fbd..c74dfd3c4f 100644 --- a/contracts/wasm/timestamp/go/timestamp/contract.go +++ b/contracts/wasm/timestamp/go/timestamp/contract.go @@ -28,6 +28,6 @@ func (sc Funcs) Now(ctx wasmlib.ScFuncCallContext) *NowCall { func (sc Funcs) GetTimestamp(ctx wasmlib.ScViewCallContext) *GetTimestampCall { f := &GetTimestampCall{Func: wasmlib.NewScView(ctx, HScName, HViewGetTimestamp)} - f.Func.SetPtrs(nil, &f.Results.id) + wasmlib.NewCallResultsProxy(f.Func, &f.Results.proxy) return f } diff --git a/contracts/wasm/timestamp/go/timestamp/keys.go b/contracts/wasm/timestamp/go/timestamp/keys.go index 9b658897b1..ddfdc850c0 100644 --- a/contracts/wasm/timestamp/go/timestamp/keys.go +++ b/contracts/wasm/timestamp/go/timestamp/keys.go @@ -6,20 +6,3 @@ // Change the json schema instead package timestamp - -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" - -const ( - IdxResultTimestamp = 0 - - IdxStateTimestamp = 1 -) - -const keyMapLen = 2 - -var keyMap = [keyMapLen]wasmlib.Key{ - ResultTimestamp, - StateTimestamp, -} - -var idxMap [keyMapLen]wasmlib.Key32 diff --git a/contracts/wasm/timestamp/go/timestamp/lib.go b/contracts/wasm/timestamp/go/timestamp/lib.go index bc42403aa1..0bc59d0fc7 100644 --- a/contracts/wasm/timestamp/go/timestamp/lib.go +++ b/contracts/wasm/timestamp/go/timestamp/lib.go @@ -13,10 +13,6 @@ func OnLoad() { exports := wasmlib.NewScExports() exports.AddFunc(FuncNow, funcNowThunk) exports.AddView(ViewGetTimestamp, viewGetTimestampThunk) - - for i, key := range keyMap { - idxMap[i] = key.KeyID() - } } type NowContext struct { @@ -27,7 +23,7 @@ func funcNowThunk(ctx wasmlib.ScFuncContext) { ctx.Log("timestamp.funcNow") f := &NowContext{ State: MutabletimestampState{ - id: wasmlib.OBJ_ID_STATE, + proxy: wasmlib.NewStateProxy(), }, } funcNow(ctx, f) @@ -43,10 +39,10 @@ func viewGetTimestampThunk(ctx wasmlib.ScViewContext) { ctx.Log("timestamp.viewGetTimestamp") f := &GetTimestampContext{ Results: MutableGetTimestampResults{ - id: wasmlib.OBJ_ID_RESULTS, + proxy: wasmlib.NewResultsProxy(), }, State: ImmutabletimestampState{ - id: wasmlib.OBJ_ID_STATE, + proxy: wasmlib.NewStateProxy(), }, } viewGetTimestamp(ctx, f) diff --git a/contracts/wasm/timestamp/go/timestamp/results.go b/contracts/wasm/timestamp/go/timestamp/results.go index ca6aaac36a..56994cd2d2 100644 --- a/contracts/wasm/timestamp/go/timestamp/results.go +++ b/contracts/wasm/timestamp/go/timestamp/results.go @@ -7,20 +7,20 @@ package timestamp -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" +import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" type ImmutableGetTimestampResults struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableGetTimestampResults) Timestamp() wasmlib.ScImmutableInt64 { - return wasmlib.NewScImmutableInt64(s.id, wasmlib.KeyID(ResultTimestamp)) +func (s ImmutableGetTimestampResults) Timestamp() wasmtypes.ScImmutableUint64 { + return wasmtypes.NewScImmutableUint64(s.proxy.Root(ResultTimestamp)) } type MutableGetTimestampResults struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableGetTimestampResults) Timestamp() wasmlib.ScMutableInt64 { - return wasmlib.NewScMutableInt64(s.id, wasmlib.KeyID(ResultTimestamp)) +func (s MutableGetTimestampResults) Timestamp() wasmtypes.ScMutableUint64 { + return wasmtypes.NewScMutableUint64(s.proxy.Root(ResultTimestamp)) } diff --git a/contracts/wasm/timestamp/go/timestamp/state.go b/contracts/wasm/timestamp/go/timestamp/state.go index 8d1efbe83e..bc4b2f9934 100644 --- a/contracts/wasm/timestamp/go/timestamp/state.go +++ b/contracts/wasm/timestamp/go/timestamp/state.go @@ -7,24 +7,24 @@ package timestamp -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" +import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" type ImmutabletimestampState struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutabletimestampState) Timestamp() wasmlib.ScImmutableInt64 { - return wasmlib.NewScImmutableInt64(s.id, wasmlib.KeyID(StateTimestamp)) +func (s ImmutabletimestampState) Timestamp() wasmtypes.ScImmutableUint64 { + return wasmtypes.NewScImmutableUint64(s.proxy.Root(StateTimestamp)) } type MutabletimestampState struct { - id int32 + proxy wasmtypes.Proxy } func (s MutabletimestampState) AsImmutable() ImmutabletimestampState { return ImmutabletimestampState(s) } -func (s MutabletimestampState) Timestamp() wasmlib.ScMutableInt64 { - return wasmlib.NewScMutableInt64(s.id, wasmlib.KeyID(StateTimestamp)) +func (s MutabletimestampState) Timestamp() wasmtypes.ScMutableUint64 { + return wasmtypes.NewScMutableUint64(s.proxy.Root(StateTimestamp)) } diff --git a/contracts/wasm/timestamp/schema.yaml b/contracts/wasm/timestamp/schema.yaml index aaad197bea..f273364817 100644 --- a/contracts/wasm/timestamp/schema.yaml +++ b/contracts/wasm/timestamp/schema.yaml @@ -3,10 +3,10 @@ description: Extremely simple timestamp server structs: {} typedefs: {} state: - timestamp: Int64 // last official timestamp generated + timestamp: Uint64 // last official timestamp generated funcs: now: views: getTimestamp: results: - timestamp: Int64 // last official timestamp generated + timestamp: Uint64 // last official timestamp generated diff --git a/contracts/wasm/timestamp/src/results.rs b/contracts/wasm/timestamp/src/results.rs index b0de1e3b73..bfe1f7008f 100644 --- a/contracts/wasm/timestamp/src/results.rs +++ b/contracts/wasm/timestamp/src/results.rs @@ -20,8 +20,8 @@ pub struct ImmutableGetTimestampResults { } impl ImmutableGetTimestampResults { - pub fn timestamp(&self) -> ScImmutableInt64 { - ScImmutableInt64::new(self.id, RESULT_TIMESTAMP.get_key_id()) + pub fn timestamp(&self) -> ScImmutableUint64 { + ScImmutableUint64::new(self.id, RESULT_TIMESTAMP.get_key_id()) } } @@ -31,7 +31,7 @@ pub struct MutableGetTimestampResults { } impl MutableGetTimestampResults { - pub fn timestamp(&self) -> ScMutableInt64 { - ScMutableInt64::new(self.id, RESULT_TIMESTAMP.get_key_id()) + pub fn timestamp(&self) -> ScMutableUint64 { + ScMutableUint64::new(self.id, RESULT_TIMESTAMP.get_key_id()) } } diff --git a/contracts/wasm/timestamp/src/state.rs b/contracts/wasm/timestamp/src/state.rs index 3b05d63230..003e40975d 100644 --- a/contracts/wasm/timestamp/src/state.rs +++ b/contracts/wasm/timestamp/src/state.rs @@ -20,8 +20,8 @@ pub struct ImmutabletimestampState { } impl ImmutabletimestampState { - pub fn timestamp(&self) -> ScImmutableInt64 { - ScImmutableInt64::new(self.id, STATE_TIMESTAMP.get_key_id()) + pub fn timestamp(&self) -> ScImmutableUint64 { + ScImmutableUint64::new(self.id, STATE_TIMESTAMP.get_key_id()) } } @@ -35,7 +35,7 @@ impl MutabletimestampState { ImmutabletimestampState { id: self.id } } - pub fn timestamp(&self) -> ScMutableInt64 { - ScMutableInt64::new(self.id, STATE_TIMESTAMP.get_key_id()) + pub fn timestamp(&self) -> ScMutableUint64 { + ScMutableUint64::new(self.id, STATE_TIMESTAMP.get_key_id()) } } diff --git a/contracts/wasm/timestamp/test/timestamp_bg.wasm b/contracts/wasm/timestamp/test/timestamp_bg.wasm index 3407019dba8db5bfa905e4c2a02c4064fe7008cb..932fe7b91e6c1452c35a8962202d231f5ebe44ed 100644 GIT binary patch delta 155 zcmZ2*hjG>&#tkbN8Cy25WSry1Xua9Z<0uQG@Ma$02sXy}$yb844IB?N9bnL4Vo+pI zV07Hl2xglx$tW-?Fqkn(0L28dfP_SrfR=z0kfAU+A-H(6WylI9Myt(_!dTeEN;Az& u6mnAY(n~TJt}qBNcrY+9EMVUJCx(Mjq!cdofl+|L3n+7qX|qHehX4Su*ebjL delta 146 zcmbPrhjGCj#tkbN8M`*GWSry1XtmkR<0uQG&}JUr2)4;bg7X4{T9B6`a7!(*47&Vz0%$X;z4Hn;Q9I}Fm(R%ZpFcvnkOfwUOoYcJZk_-lh lD+~e*9t;c&PZ>9Vi{W4tLCAez6kzZI%2YFM7K-B#006QPDGUGr diff --git a/contracts/wasm/timestamp/ts/timestamp/results.ts b/contracts/wasm/timestamp/ts/timestamp/results.ts index 5644226dec..bb6a357a74 100644 --- a/contracts/wasm/timestamp/ts/timestamp/results.ts +++ b/contracts/wasm/timestamp/ts/timestamp/results.ts @@ -9,13 +9,13 @@ import * as wasmlib from "wasmlib"; import * as sc from "./index"; export class ImmutableGetTimestampResults extends wasmlib.ScMapID { - timestamp(): wasmlib.ScImmutableInt64 { - return new wasmlib.ScImmutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ResultTimestamp)); + timestamp(): wasmlib.ScImmutableUint64 { + return new wasmlib.ScImmutableUint64(this.mapID, wasmlib.Key32.fromString(sc.ResultTimestamp)); } } export class MutableGetTimestampResults extends wasmlib.ScMapID { - timestamp(): wasmlib.ScMutableInt64 { - return new wasmlib.ScMutableInt64(this.mapID, wasmlib.Key32.fromString(sc.ResultTimestamp)); + timestamp(): wasmlib.ScMutableUint64 { + return new wasmlib.ScMutableUint64(this.mapID, wasmlib.Key32.fromString(sc.ResultTimestamp)); } } diff --git a/contracts/wasm/timestamp/ts/timestamp/state.ts b/contracts/wasm/timestamp/ts/timestamp/state.ts index 43c2fce463..3e70cc6e39 100644 --- a/contracts/wasm/timestamp/ts/timestamp/state.ts +++ b/contracts/wasm/timestamp/ts/timestamp/state.ts @@ -9,8 +9,8 @@ import * as wasmlib from "wasmlib"; import * as sc from "./index"; export class ImmutabletimestampState extends wasmlib.ScMapID { - timestamp(): wasmlib.ScImmutableInt64 { - return new wasmlib.ScImmutableInt64(this.mapID, wasmlib.Key32.fromString(sc.StateTimestamp)); + timestamp(): wasmlib.ScImmutableUint64 { + return new wasmlib.ScImmutableUint64(this.mapID, wasmlib.Key32.fromString(sc.StateTimestamp)); } } @@ -21,7 +21,7 @@ export class MutabletimestampState extends wasmlib.ScMapID { return imm; } - timestamp(): wasmlib.ScMutableInt64 { - return new wasmlib.ScMutableInt64(this.mapID, wasmlib.Key32.fromString(sc.StateTimestamp)); + timestamp(): wasmlib.ScMutableUint64 { + return new wasmlib.ScMutableUint64(this.mapID, wasmlib.Key32.fromString(sc.StateTimestamp)); } } diff --git a/contracts/wasm/tokenregistry/go/tokenregistry/consts.go b/contracts/wasm/tokenregistry/go/tokenregistry/consts.go index 03f53793bd..c8473c7899 100644 --- a/contracts/wasm/tokenregistry/go/tokenregistry/consts.go +++ b/contracts/wasm/tokenregistry/go/tokenregistry/consts.go @@ -7,12 +7,12 @@ package tokenregistry -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" +import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" const ( ScName = "tokenregistry" ScDescription = "" - HScName = wasmlib.ScHname(0xe1ba0c78) + HScName = wasmtypes.ScHname(0xe1ba0c78) ) const ( @@ -34,8 +34,8 @@ const ( ) const ( - HFuncMintSupply = wasmlib.ScHname(0x564349a7) - HFuncTransferOwnership = wasmlib.ScHname(0xbb9eb5af) - HFuncUpdateMetadata = wasmlib.ScHname(0xa26b23b6) - HViewGetInfo = wasmlib.ScHname(0xcfedba5f) + HFuncMintSupply = wasmtypes.ScHname(0x564349a7) + HFuncTransferOwnership = wasmtypes.ScHname(0xbb9eb5af) + HFuncUpdateMetadata = wasmtypes.ScHname(0xa26b23b6) + HViewGetInfo = wasmtypes.ScHname(0xcfedba5f) ) diff --git a/contracts/wasm/tokenregistry/go/tokenregistry/contract.go b/contracts/wasm/tokenregistry/go/tokenregistry/contract.go index c254b5d29d..100714067b 100644 --- a/contracts/wasm/tokenregistry/go/tokenregistry/contract.go +++ b/contracts/wasm/tokenregistry/go/tokenregistry/contract.go @@ -35,24 +35,24 @@ var ScFuncs Funcs func (sc Funcs) MintSupply(ctx wasmlib.ScFuncCallContext) *MintSupplyCall { f := &MintSupplyCall{Func: wasmlib.NewScFunc(ctx, HScName, HFuncMintSupply)} - f.Func.SetPtrs(&f.Params.id, nil) + f.Params.proxy = wasmlib.NewCallParamsProxy(&f.Func.ScView) return f } func (sc Funcs) TransferOwnership(ctx wasmlib.ScFuncCallContext) *TransferOwnershipCall { f := &TransferOwnershipCall{Func: wasmlib.NewScFunc(ctx, HScName, HFuncTransferOwnership)} - f.Func.SetPtrs(&f.Params.id, nil) + f.Params.proxy = wasmlib.NewCallParamsProxy(&f.Func.ScView) return f } func (sc Funcs) UpdateMetadata(ctx wasmlib.ScFuncCallContext) *UpdateMetadataCall { f := &UpdateMetadataCall{Func: wasmlib.NewScFunc(ctx, HScName, HFuncUpdateMetadata)} - f.Func.SetPtrs(&f.Params.id, nil) + f.Params.proxy = wasmlib.NewCallParamsProxy(&f.Func.ScView) return f } func (sc Funcs) GetInfo(ctx wasmlib.ScViewCallContext) *GetInfoCall { f := &GetInfoCall{Func: wasmlib.NewScView(ctx, HScName, HViewGetInfo)} - f.Func.SetPtrs(&f.Params.id, nil) + f.Params.proxy = wasmlib.NewCallParamsProxy(f.Func) return f } diff --git a/contracts/wasm/tokenregistry/go/tokenregistry/keys.go b/contracts/wasm/tokenregistry/go/tokenregistry/keys.go index ec80cb792f..8b3b04d0c9 100644 --- a/contracts/wasm/tokenregistry/go/tokenregistry/keys.go +++ b/contracts/wasm/tokenregistry/go/tokenregistry/keys.go @@ -6,26 +6,3 @@ // Change the json schema instead package tokenregistry - -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" - -const ( - IdxParamColor = 0 - IdxParamDescription = 1 - IdxParamUserDefined = 2 - - IdxStateColorList = 3 - IdxStateRegistry = 4 -) - -const keyMapLen = 5 - -var keyMap = [keyMapLen]wasmlib.Key{ - ParamColor, - ParamDescription, - ParamUserDefined, - StateColorList, - StateRegistry, -} - -var idxMap [keyMapLen]wasmlib.Key32 diff --git a/contracts/wasm/tokenregistry/go/tokenregistry/lib.go b/contracts/wasm/tokenregistry/go/tokenregistry/lib.go index 1d16acbac7..a6282cd504 100644 --- a/contracts/wasm/tokenregistry/go/tokenregistry/lib.go +++ b/contracts/wasm/tokenregistry/go/tokenregistry/lib.go @@ -15,10 +15,6 @@ func OnLoad() { exports.AddFunc(FuncTransferOwnership, funcTransferOwnershipThunk) exports.AddFunc(FuncUpdateMetadata, funcUpdateMetadataThunk) exports.AddView(ViewGetInfo, viewGetInfoThunk) - - for i, key := range keyMap { - idxMap[i] = key.KeyID() - } } type MintSupplyContext struct { @@ -30,10 +26,10 @@ func funcMintSupplyThunk(ctx wasmlib.ScFuncContext) { ctx.Log("tokenregistry.funcMintSupply") f := &MintSupplyContext{ Params: ImmutableMintSupplyParams{ - id: wasmlib.OBJ_ID_PARAMS, + proxy: wasmlib.NewParamsProxy(), }, State: MutableTokenRegistryState{ - id: wasmlib.OBJ_ID_STATE, + proxy: wasmlib.NewStateProxy(), }, } funcMintSupply(ctx, f) @@ -47,18 +43,18 @@ type TransferOwnershipContext struct { func funcTransferOwnershipThunk(ctx wasmlib.ScFuncContext) { ctx.Log("tokenregistry.funcTransferOwnership") - - // TODO the one who can transfer token ownership - ctx.Require(ctx.Caller() == ctx.ContractCreator(), "no permission") - f := &TransferOwnershipContext{ Params: ImmutableTransferOwnershipParams{ - id: wasmlib.OBJ_ID_PARAMS, + proxy: wasmlib.NewParamsProxy(), }, State: MutableTokenRegistryState{ - id: wasmlib.OBJ_ID_STATE, + proxy: wasmlib.NewStateProxy(), }, } + + // TODO the one who can transfer token ownership + ctx.Require(ctx.Caller() == ctx.ContractCreator(), "no permission") + ctx.Require(f.Params.Color().Exists(), "missing mandatory color") funcTransferOwnership(ctx, f) ctx.Log("tokenregistry.funcTransferOwnership ok") @@ -71,18 +67,18 @@ type UpdateMetadataContext struct { func funcUpdateMetadataThunk(ctx wasmlib.ScFuncContext) { ctx.Log("tokenregistry.funcUpdateMetadata") - - // TODO the one who can change the token info - ctx.Require(ctx.Caller() == ctx.ContractCreator(), "no permission") - f := &UpdateMetadataContext{ Params: ImmutableUpdateMetadataParams{ - id: wasmlib.OBJ_ID_PARAMS, + proxy: wasmlib.NewParamsProxy(), }, State: MutableTokenRegistryState{ - id: wasmlib.OBJ_ID_STATE, + proxy: wasmlib.NewStateProxy(), }, } + + // TODO the one who can change the token info + ctx.Require(ctx.Caller() == ctx.ContractCreator(), "no permission") + ctx.Require(f.Params.Color().Exists(), "missing mandatory color") funcUpdateMetadata(ctx, f) ctx.Log("tokenregistry.funcUpdateMetadata ok") @@ -97,10 +93,10 @@ func viewGetInfoThunk(ctx wasmlib.ScViewContext) { ctx.Log("tokenregistry.viewGetInfo") f := &GetInfoContext{ Params: ImmutableGetInfoParams{ - id: wasmlib.OBJ_ID_PARAMS, + proxy: wasmlib.NewParamsProxy(), }, State: ImmutableTokenRegistryState{ - id: wasmlib.OBJ_ID_STATE, + proxy: wasmlib.NewStateProxy(), }, } ctx.Require(f.Params.Color().Exists(), "missing mandatory color") diff --git a/contracts/wasm/tokenregistry/go/tokenregistry/params.go b/contracts/wasm/tokenregistry/go/tokenregistry/params.go index 4a71631851..36c4cd55a1 100644 --- a/contracts/wasm/tokenregistry/go/tokenregistry/params.go +++ b/contracts/wasm/tokenregistry/go/tokenregistry/params.go @@ -7,76 +7,76 @@ package tokenregistry -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" +import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" type ImmutableMintSupplyParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableMintSupplyParams) Description() wasmlib.ScImmutableString { - return wasmlib.NewScImmutableString(s.id, wasmlib.KeyID(ParamDescription)) +func (s ImmutableMintSupplyParams) Description() wasmtypes.ScImmutableString { + return wasmtypes.NewScImmutableString(s.proxy.Root(ParamDescription)) } -func (s ImmutableMintSupplyParams) UserDefined() wasmlib.ScImmutableString { - return wasmlib.NewScImmutableString(s.id, wasmlib.KeyID(ParamUserDefined)) +func (s ImmutableMintSupplyParams) UserDefined() wasmtypes.ScImmutableString { + return wasmtypes.NewScImmutableString(s.proxy.Root(ParamUserDefined)) } type MutableMintSupplyParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableMintSupplyParams) Description() wasmlib.ScMutableString { - return wasmlib.NewScMutableString(s.id, wasmlib.KeyID(ParamDescription)) +func (s MutableMintSupplyParams) Description() wasmtypes.ScMutableString { + return wasmtypes.NewScMutableString(s.proxy.Root(ParamDescription)) } -func (s MutableMintSupplyParams) UserDefined() wasmlib.ScMutableString { - return wasmlib.NewScMutableString(s.id, wasmlib.KeyID(ParamUserDefined)) +func (s MutableMintSupplyParams) UserDefined() wasmtypes.ScMutableString { + return wasmtypes.NewScMutableString(s.proxy.Root(ParamUserDefined)) } type ImmutableTransferOwnershipParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableTransferOwnershipParams) Color() wasmlib.ScImmutableColor { - return wasmlib.NewScImmutableColor(s.id, wasmlib.KeyID(ParamColor)) +func (s ImmutableTransferOwnershipParams) Color() wasmtypes.ScImmutableColor { + return wasmtypes.NewScImmutableColor(s.proxy.Root(ParamColor)) } type MutableTransferOwnershipParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableTransferOwnershipParams) Color() wasmlib.ScMutableColor { - return wasmlib.NewScMutableColor(s.id, wasmlib.KeyID(ParamColor)) +func (s MutableTransferOwnershipParams) Color() wasmtypes.ScMutableColor { + return wasmtypes.NewScMutableColor(s.proxy.Root(ParamColor)) } type ImmutableUpdateMetadataParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableUpdateMetadataParams) Color() wasmlib.ScImmutableColor { - return wasmlib.NewScImmutableColor(s.id, wasmlib.KeyID(ParamColor)) +func (s ImmutableUpdateMetadataParams) Color() wasmtypes.ScImmutableColor { + return wasmtypes.NewScImmutableColor(s.proxy.Root(ParamColor)) } type MutableUpdateMetadataParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableUpdateMetadataParams) Color() wasmlib.ScMutableColor { - return wasmlib.NewScMutableColor(s.id, wasmlib.KeyID(ParamColor)) +func (s MutableUpdateMetadataParams) Color() wasmtypes.ScMutableColor { + return wasmtypes.NewScMutableColor(s.proxy.Root(ParamColor)) } type ImmutableGetInfoParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableGetInfoParams) Color() wasmlib.ScImmutableColor { - return wasmlib.NewScImmutableColor(s.id, wasmlib.KeyID(ParamColor)) +func (s ImmutableGetInfoParams) Color() wasmtypes.ScImmutableColor { + return wasmtypes.NewScImmutableColor(s.proxy.Root(ParamColor)) } type MutableGetInfoParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableGetInfoParams) Color() wasmlib.ScMutableColor { - return wasmlib.NewScMutableColor(s.id, wasmlib.KeyID(ParamColor)) +func (s MutableGetInfoParams) Color() wasmtypes.ScMutableColor { + return wasmtypes.NewScMutableColor(s.proxy.Root(ParamColor)) } diff --git a/contracts/wasm/tokenregistry/go/tokenregistry/state.go b/contracts/wasm/tokenregistry/go/tokenregistry/state.go index ffd7d313f9..e8e7277a38 100644 --- a/contracts/wasm/tokenregistry/go/tokenregistry/state.go +++ b/contracts/wasm/tokenregistry/go/tokenregistry/state.go @@ -7,72 +7,74 @@ package tokenregistry -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" +import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" type ArrayOfImmutableColor struct { - objID int32 + proxy wasmtypes.Proxy } -func (a ArrayOfImmutableColor) Length() int32 { - return wasmlib.GetLength(a.objID) +func (a ArrayOfImmutableColor) Length() uint32 { + return a.proxy.Length() } -func (a ArrayOfImmutableColor) GetColor(index int32) wasmlib.ScImmutableColor { - return wasmlib.NewScImmutableColor(a.objID, wasmlib.Key32(index)) +func (a ArrayOfImmutableColor) GetColor(index uint32) wasmtypes.ScImmutableColor { + return wasmtypes.NewScImmutableColor(a.proxy.Index(index)) } type MapColorToImmutableToken struct { - objID int32 + proxy wasmtypes.Proxy } -func (m MapColorToImmutableToken) GetToken(key wasmlib.ScColor) ImmutableToken { - return ImmutableToken{objID: m.objID, keyID: key.KeyID()} +func (m MapColorToImmutableToken) GetToken(key wasmtypes.ScColor) ImmutableToken { + return ImmutableToken{proxy: m.proxy.Key(key.Bytes())} } type ImmutableTokenRegistryState struct { - id int32 + proxy wasmtypes.Proxy } func (s ImmutableTokenRegistryState) ColorList() ArrayOfImmutableColor { - arrID := wasmlib.GetObjectID(s.id, wasmlib.KeyID(StateColorList), wasmlib.TYPE_ARRAY|wasmlib.TYPE_COLOR) - return ArrayOfImmutableColor{objID: arrID} + return ArrayOfImmutableColor{proxy: s.proxy.Root(StateColorList)} } func (s ImmutableTokenRegistryState) Registry() MapColorToImmutableToken { - mapID := wasmlib.GetObjectID(s.id, wasmlib.KeyID(StateRegistry), wasmlib.TYPE_MAP) - return MapColorToImmutableToken{objID: mapID} + return MapColorToImmutableToken{proxy: s.proxy.Root(StateRegistry)} } type ArrayOfMutableColor struct { - objID int32 + proxy wasmtypes.Proxy +} + +func (a ArrayOfMutableColor) AppendColor() wasmtypes.ScMutableColor { + return wasmtypes.NewScMutableColor(a.proxy.Append()) } func (a ArrayOfMutableColor) Clear() { - wasmlib.Clear(a.objID) + a.proxy.ClearArray() } -func (a ArrayOfMutableColor) Length() int32 { - return wasmlib.GetLength(a.objID) +func (a ArrayOfMutableColor) Length() uint32 { + return a.proxy.Length() } -func (a ArrayOfMutableColor) GetColor(index int32) wasmlib.ScMutableColor { - return wasmlib.NewScMutableColor(a.objID, wasmlib.Key32(index)) +func (a ArrayOfMutableColor) GetColor(index uint32) wasmtypes.ScMutableColor { + return wasmtypes.NewScMutableColor(a.proxy.Index(index)) } type MapColorToMutableToken struct { - objID int32 + proxy wasmtypes.Proxy } func (m MapColorToMutableToken) Clear() { - wasmlib.Clear(m.objID) + m.proxy.ClearMap() } -func (m MapColorToMutableToken) GetToken(key wasmlib.ScColor) MutableToken { - return MutableToken{objID: m.objID, keyID: key.KeyID()} +func (m MapColorToMutableToken) GetToken(key wasmtypes.ScColor) MutableToken { + return MutableToken{proxy: m.proxy.Key(key.Bytes())} } type MutableTokenRegistryState struct { - id int32 + proxy wasmtypes.Proxy } func (s MutableTokenRegistryState) AsImmutable() ImmutableTokenRegistryState { @@ -80,11 +82,9 @@ func (s MutableTokenRegistryState) AsImmutable() ImmutableTokenRegistryState { } func (s MutableTokenRegistryState) ColorList() ArrayOfMutableColor { - arrID := wasmlib.GetObjectID(s.id, wasmlib.KeyID(StateColorList), wasmlib.TYPE_ARRAY|wasmlib.TYPE_COLOR) - return ArrayOfMutableColor{objID: arrID} + return ArrayOfMutableColor{proxy: s.proxy.Root(StateColorList)} } func (s MutableTokenRegistryState) Registry() MapColorToMutableToken { - mapID := wasmlib.GetObjectID(s.id, wasmlib.KeyID(StateRegistry), wasmlib.TYPE_MAP) - return MapColorToMutableToken{objID: mapID} + return MapColorToMutableToken{proxy: s.proxy.Root(StateRegistry)} } diff --git a/contracts/wasm/tokenregistry/go/tokenregistry/structs.go b/contracts/wasm/tokenregistry/go/tokenregistry/structs.go index 7dbf217c6f..3234c8de19 100644 --- a/contracts/wasm/tokenregistry/go/tokenregistry/structs.go +++ b/contracts/wasm/tokenregistry/go/tokenregistry/structs.go @@ -7,74 +7,75 @@ package tokenregistry -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" +import ( + "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmcodec" + "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" +) type Token struct { - Created int64 // creation timestamp - Description string // description what minted token represents - MintedBy wasmlib.ScAgentID // original minter - Owner wasmlib.ScAgentID // current owner - Supply int64 // amount of tokens originally minted - Updated int64 // last update timestamp - UserDefined string // any user defined text + Created uint64 // creation timestamp + Description string // description what minted token represents + MintedBy wasmtypes.ScAgentID // original minter + Owner wasmtypes.ScAgentID // current owner + Supply uint64 // amount of tokens originally minted + Updated uint64 // last update timestamp + UserDefined string // any user defined text } -func NewTokenFromBytes(bytes []byte) *Token { - decode := wasmlib.NewBytesDecoder(bytes) +func NewTokenFromBytes(buf []byte) *Token { + dec := wasmcodec.NewWasmDecoder(buf) data := &Token{} - data.Created = decode.Int64() - data.Description = decode.String() - data.MintedBy = decode.AgentID() - data.Owner = decode.AgentID() - data.Supply = decode.Int64() - data.Updated = decode.Int64() - data.UserDefined = decode.String() - decode.Close() + data.Created = wasmtypes.DecodeUint64(dec) + data.Description = wasmtypes.DecodeString(dec) + data.MintedBy = wasmtypes.DecodeAgentID(dec) + data.Owner = wasmtypes.DecodeAgentID(dec) + data.Supply = wasmtypes.DecodeUint64(dec) + data.Updated = wasmtypes.DecodeUint64(dec) + data.UserDefined = wasmtypes.DecodeString(dec) + dec.Close() return data } func (o *Token) Bytes() []byte { - return wasmlib.NewBytesEncoder(). - Int64(o.Created). - String(o.Description). - AgentID(o.MintedBy). - AgentID(o.Owner). - Int64(o.Supply). - Int64(o.Updated). - String(o.UserDefined). - Data() + enc := wasmcodec.NewWasmEncoder() + wasmtypes.EncodeUint64(enc, o.Created) + wasmtypes.EncodeString(enc, o.Description) + wasmtypes.EncodeAgentID(enc, o.MintedBy) + wasmtypes.EncodeAgentID(enc, o.Owner) + wasmtypes.EncodeUint64(enc, o.Supply) + wasmtypes.EncodeUint64(enc, o.Updated) + wasmtypes.EncodeString(enc, o.UserDefined) + return enc.Buf() } type ImmutableToken struct { - objID int32 - keyID wasmlib.Key32 + proxy wasmtypes.Proxy } func (o ImmutableToken) Exists() bool { - return wasmlib.Exists(o.objID, o.keyID, wasmlib.TYPE_BYTES) + return o.proxy.Exists() } func (o ImmutableToken) Value() *Token { - return NewTokenFromBytes(wasmlib.GetBytes(o.objID, o.keyID, wasmlib.TYPE_BYTES)) + return NewTokenFromBytes(o.proxy.Get()) } type MutableToken struct { - objID int32 - keyID wasmlib.Key32 + proxy wasmtypes.Proxy } func (o MutableToken) Delete() { - wasmlib.DelKey(o.objID, o.keyID, wasmlib.TYPE_BYTES) + o.proxy.Delete() } func (o MutableToken) Exists() bool { - return wasmlib.Exists(o.objID, o.keyID, wasmlib.TYPE_BYTES) + return o.proxy.Exists() } func (o MutableToken) SetValue(value *Token) { - wasmlib.SetBytes(o.objID, o.keyID, wasmlib.TYPE_BYTES, value.Bytes()) + o.proxy.Set(value.Bytes()) } func (o MutableToken) Value() *Token { - return NewTokenFromBytes(wasmlib.GetBytes(o.objID, o.keyID, wasmlib.TYPE_BYTES)) + return NewTokenFromBytes(o.proxy.Get()) } diff --git a/contracts/wasm/tokenregistry/go/tokenregistry/tokenregistry.go b/contracts/wasm/tokenregistry/go/tokenregistry/tokenregistry.go index cc6d7d48dc..7258ec6229 100644 --- a/contracts/wasm/tokenregistry/go/tokenregistry/tokenregistry.go +++ b/contracts/wasm/tokenregistry/go/tokenregistry/tokenregistry.go @@ -10,8 +10,8 @@ import ( func funcMintSupply(ctx wasmlib.ScFuncContext, f *MintSupplyContext) { minted := ctx.Minted() mintedColors := minted.Colors() - ctx.Require(mintedColors.Length() == 1, "need single minted color") - mintedColor := mintedColors.GetColor(0).Value() + ctx.Require(len(mintedColors) == 1, "need single minted color") + mintedColor := mintedColors[0] currentToken := f.State.Registry().GetToken(mintedColor) if currentToken.Exists() { // should never happen, because transaction id is unique @@ -31,7 +31,7 @@ func funcMintSupply(ctx wasmlib.ScFuncContext, f *MintSupplyContext) { } currentToken.SetValue(token) colorList := f.State.ColorList() - colorList.GetColor(colorList.Length()).SetValue(mintedColor) + colorList.AppendColor().SetValue(mintedColor) } func funcTransferOwnership(ctx wasmlib.ScFuncContext, f *TransferOwnershipContext) { diff --git a/contracts/wasm/tokenregistry/schema.yaml b/contracts/wasm/tokenregistry/schema.yaml index 3048afcc3e..b980690567 100644 --- a/contracts/wasm/tokenregistry/schema.yaml +++ b/contracts/wasm/tokenregistry/schema.yaml @@ -2,12 +2,12 @@ name: TokenRegistry description: "" structs: Token: - created: Int64 // creation timestamp + created: Uint64 // creation timestamp description: String // description what minted token represents mintedBy: AgentID // original minter owner: AgentID // current owner - supply: Int64 // amount of tokens originally minted - updated: Int64 // last update timestamp + supply: Uint64 // amount of tokens originally minted + updated: Uint64 // last update timestamp userDefined: String // any user defined text typedefs: {} state: diff --git a/contracts/wasm/tokenregistry/src/state.rs b/contracts/wasm/tokenregistry/src/state.rs index 786e448ff1..dac3d17a47 100644 --- a/contracts/wasm/tokenregistry/src/state.rs +++ b/contracts/wasm/tokenregistry/src/state.rs @@ -21,12 +21,12 @@ pub struct ArrayOfImmutableColor { } impl ArrayOfImmutableColor { - pub fn length(&self) -> i32 { + pub fn length(&self) -> u32 { get_length(self.obj_id) } - pub fn get_color(&self, index: i32) -> ScImmutableColor { - ScImmutableColor::new(self.obj_id, Key32(index)) + pub fn get_color(&self, index: u32) -> ScImmutableColor { + ScImmutableColor::new(self.obj_id, Key32(index as i32)) } } @@ -68,12 +68,12 @@ impl ArrayOfMutableColor { clear(self.obj_id); } - pub fn length(&self) -> i32 { + pub fn length(&self) -> u32 { get_length(self.obj_id) } - pub fn get_color(&self, index: i32) -> ScMutableColor { - ScMutableColor::new(self.obj_id, Key32(index)) + pub fn get_color(&self, index: u32) -> ScMutableColor { + ScMutableColor::new(self.obj_id, Key32(index as i32)) } } diff --git a/contracts/wasm/tokenregistry/src/structs.rs b/contracts/wasm/tokenregistry/src/structs.rs index 3fce40d7f1..34b5bf68be 100644 --- a/contracts/wasm/tokenregistry/src/structs.rs +++ b/contracts/wasm/tokenregistry/src/structs.rs @@ -13,12 +13,12 @@ use wasmlib::host::*; #[derive(Clone)] pub struct Token { - pub created : i64, // creation timestamp + pub created : u64, // creation timestamp pub description : String, // description what minted token represents pub minted_by : ScAgentID, // original minter pub owner : ScAgentID, // current owner - pub supply : i64, // amount of tokens originally minted - pub updated : i64, // last update timestamp + pub supply : u64, // amount of tokens originally minted + pub updated : u64, // last update timestamp pub user_defined : String, // any user defined text } @@ -26,24 +26,24 @@ impl Token { pub fn from_bytes(bytes: &[u8]) -> Token { let mut decode = BytesDecoder::new(bytes); Token { - created : decode.int64(), + created : decode.uint64(), description : decode.string(), minted_by : decode.agent_id(), owner : decode.agent_id(), - supply : decode.int64(), - updated : decode.int64(), + supply : decode.uint64(), + updated : decode.uint64(), user_defined : decode.string(), } } pub fn to_bytes(&self) -> Vec { let mut encode = BytesEncoder::new(); - encode.int64(self.created); + encode.uint64(self.created); encode.string(&self.description); encode.agent_id(&self.minted_by); encode.agent_id(&self.owner); - encode.int64(self.supply); - encode.int64(self.updated); + encode.uint64(self.supply); + encode.uint64(self.updated); encode.string(&self.user_defined); return encode.data(); } diff --git a/contracts/wasm/tokenregistry/test/tokenregistry_bg.wasm b/contracts/wasm/tokenregistry/test/tokenregistry_bg.wasm index fea472d1b88d7292ec79112959b061139390739e..d047c482ebfd87d1514070e3dbda6ee0094d3020 100644 GIT binary patch delta 4700 zcmcInYj9Q76+Ub4b06W}n`|nDkRUnt8bSgg0n}U(BiUepB)o#LJPd{aA>mv^FyWy> zZje_YJhO#5Q#*s&RvkK)&h1#Mc8Yb{qVj_}ZS{wp*3r)RgJ~V6Gez5(_FMbh2;!@M zI+>ia_d08@z4rRn`qsXG{ue#{3B{bw-uuaM99peT#F|g6+%e@O8FHhN3fvfx6prIM zB3u|3juaswLXIOwgfIz*op2~IM5(eONs`4-aD|XkI-!VgrR$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(ooUIuAB}&Vy3l@F#*f_Il4Q@dD@n?AiFQcI^w#zQ*kXAu(-B%4obfwq%^yx@=6| zQx8CV0}g`je2%-%%Mhrk=HimdE2~WV(h-RNzNJ46WYl1`Et?9-Q_GIh3Nv}RxjI?r zmM2F5&cGy~Ac98e=dr^?R@{yCi51h$^D8D|^uda4nfd9JJbz>5f^a|^CV$oP%rL!c z)l5R-!)waTZ=N42!gG_ILUEoSc;mo}JhuBoJz=Iu4N&}{SBnyq+xYyar(bi{S3 z6OJgi&@H2Q17x+EZR-kYr#ZH+xfI_J4J1pZ0eLuJ{<-cL-D-}m zuPEdjpZ{rPG1z}NfZ&bS0}mm5&E}o;BWbz0xW1_o7_7U$udff+ohZT#qX~WS0M-`! zAW#gFiEztT#ihw#2BY;sduvw>!cEMg%E$D^v7P5 UhF^KN&r)JO-t47xtUEvVUur|(82|tP diff --git a/contracts/wasm/tokenregistry/ts/tokenregistry/state.ts b/contracts/wasm/tokenregistry/ts/tokenregistry/state.ts index 99141b917a..c9b96c3358 100644 --- a/contracts/wasm/tokenregistry/ts/tokenregistry/state.ts +++ b/contracts/wasm/tokenregistry/ts/tokenregistry/state.ts @@ -15,12 +15,12 @@ export class ArrayOfImmutableColor { this.objID = objID; } - length(): i32 { + length(): u32 { return wasmlib.getLength(this.objID); } - getColor(index: i32): wasmlib.ScImmutableColor { - return new wasmlib.ScImmutableColor(this.objID, new wasmlib.Key32(index)); + getColor(index: u32): wasmlib.ScImmutableColor { + return new wasmlib.ScImmutableColor(this.objID, new wasmlib.Key32(index as i32)); } } @@ -59,12 +59,12 @@ export class ArrayOfMutableColor { wasmlib.clear(this.objID); } - length(): i32 { + length(): u32 { return wasmlib.getLength(this.objID); } - getColor(index: i32): wasmlib.ScMutableColor { - return new wasmlib.ScMutableColor(this.objID, new wasmlib.Key32(index)); + getColor(index: u32): wasmlib.ScMutableColor { + return new wasmlib.ScMutableColor(this.objID, new wasmlib.Key32(index as i32)); } } diff --git a/contracts/wasm/tokenregistry/ts/tokenregistry/structs.ts b/contracts/wasm/tokenregistry/ts/tokenregistry/structs.ts index e7617740b3..ad32fbf939 100644 --- a/contracts/wasm/tokenregistry/ts/tokenregistry/structs.ts +++ b/contracts/wasm/tokenregistry/ts/tokenregistry/structs.ts @@ -8,23 +8,23 @@ import * as wasmlib from "wasmlib"; export class Token { - created : i64 = 0; // creation timestamp + created : u64 = 0; // creation timestamp description : string = ""; // description what minted token represents mintedBy : wasmlib.ScAgentID = new wasmlib.ScAgentID(); // original minter owner : wasmlib.ScAgentID = new wasmlib.ScAgentID(); // current owner - supply : i64 = 0; // amount of tokens originally minted - updated : i64 = 0; // last update timestamp + supply : u64 = 0; // amount of tokens originally minted + updated : u64 = 0; // last update timestamp userDefined : string = ""; // any user defined text static fromBytes(bytes: u8[]): Token { let decode = new wasmlib.BytesDecoder(bytes); let data = new Token(); - data.created = decode.int64(); + data.created = decode.uint64(); data.description = decode.string(); data.mintedBy = decode.agentID(); data.owner = decode.agentID(); - data.supply = decode.int64(); - data.updated = decode.int64(); + data.supply = decode.uint64(); + data.updated = decode.uint64(); data.userDefined = decode.string(); decode.close(); return data; @@ -32,12 +32,12 @@ export class Token { bytes(): u8[] { return new wasmlib.BytesEncoder(). - int64(this.created). + uint64(this.created). string(this.description). agentID(this.mintedBy). agentID(this.owner). - int64(this.supply). - int64(this.updated). + uint64(this.supply). + uint64(this.updated). string(this.userDefined). data(); } diff --git a/documentation/tutorial-examples/test/example_tutorial_bg.wasm b/documentation/tutorial-examples/test/example_tutorial_bg.wasm index 55f6570a7a5a6592c2a846291122ce3f90eec7e8..f0223e484d8665fa65f2cb8a4232b5a2d680e65a 100644 GIT binary patch delta 30 mcmZ40%($|daYH2|n8xhH7`d6*aG3xA!UYRI diff --git a/packages/solo/solo.go b/packages/solo/solo.go index b6607b1840..93ef6096c1 100644 --- a/packages/solo/solo.go +++ b/packages/solo/solo.go @@ -33,7 +33,7 @@ import ( "github.com/iotaledger/wasp/packages/vm/runvm" _ "github.com/iotaledger/wasp/packages/vm/sandbox" "github.com/iotaledger/wasp/packages/vm/vmtypes" - "github.com/iotaledger/wasp/packages/vm/wasmproc" + "github.com/iotaledger/wasp/packages/vm/wasmhost" "github.com/stretchr/testify/require" "go.uber.org/atomic" "go.uber.org/zap/zapcore" @@ -151,7 +151,7 @@ func NewWithLogger(t TestContext, log *logger.Logger, seedOpt ...*ed25519.Seed) processorConfig := processors.NewConfig() err := processorConfig.RegisterVMType(vmtypes.WasmTime, func(binary []byte) (iscp.VMProcessor, error) { - return wasmproc.GetProcessor(binary, log) + return wasmhost.GetProcessor(binary, log) }) require.NoError(t, err) diff --git a/packages/vm/core/testcore/sbtests/sbtestsc/testcore_bg.wasm b/packages/vm/core/testcore/sbtests/sbtestsc/testcore_bg.wasm index 926ca33bd093df86570cabdece8d7f0a3bb136aa..76c1881f70e60ea277e9cae13931323a61b8daa8 100644 GIT binary patch delta 17442 zcmbtb349bq*6-?`nGBgEbRc&i>6rwQfPshzs0b-E97YZm!2=LML??)%S;TV!gb)xV zP+TIopor+AqCw+<5)c6e75q>Uvf6>eZ`v z)vHd!25a{tR^7+ed~@ECrtTJFhDc(0qJ;ezTEXUZr{W1=vBFf{i&M0$?T16EqjYS$WE{y*m?}!hu=f^RhvKHIo}*G z-|X`Pn>pW{&0a*8`Q{;3SW%0H_gLBuHRjW-;LLm3XKV|b7s40>^P%Wv8tc6Xk^?TUae-!MzfQpeywvXQP* zZrF3o0CO1k+6P$$Ptm2V%af<>2=ZHJ@VkNmlLG<3frE^jl@%CdI&4_BV+>C;fzB0_ zL;NmYeMpp9qq@|+*JuO_O(S5qN*$NuwqIvFcSfZ@jvIbvNgC{*#EaIfUWXaRG#cnT zBVd#zT8?2KW!GU6-i!lap9QiVhSs0NHLigDDhn8ihR3 za<$SpzDhOw-9+p(Pp>oThy}Dk9`2PTZKLcRFou9@vg%NwFFtP~7MgwRi-TZFHymdw& z6FX|Dbx~1e27nj{!Ki>4y-X4-gI0-08>^H%3&i5#IJvvqZH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R!Q%k;xjA#Gjyk+u1pPH)sSgv>s$IutUV&OMYE(tC?TXq@c12Sn oM>{y&6Iny>$1+y`Grmc{(GIm!-+0>Bk{L=!_<3A>>f1B^A2JvYxBvhE diff --git a/packages/vm/wasmhost/kvstorehost.go b/packages/vm/wasmhost/kvstorehost.go deleted file mode 100644 index b9f57f36c3..0000000000 --- a/packages/vm/wasmhost/kvstorehost.go +++ /dev/null @@ -1,341 +0,0 @@ -// Copyright 2020 IOTA Stiftung -// SPDX-License-Identifier: Apache-2.0 - -package wasmhost - -import ( - "encoding/binary" - "fmt" - - "github.com/iotaledger/goshimmer/packages/ledgerstate" - "github.com/iotaledger/wasp/packages/kv/codec" - "github.com/mr-tron/base58" -) - -// all type id values should exactly match their counterpart values on the client! - -//nolint:revive -const ( - OBJTYPE_ARRAY int32 = 0x20 - OBJTYPE_ARRAY16 int32 = 0x60 - OBJTYPE_CALL int32 = 0x80 - OBJTYPE_TYPEMASK int32 = 0x1f - - OBJTYPE_ADDRESS int32 = 1 - OBJTYPE_AGENT_ID int32 = 2 - OBJTYPE_BOOL int32 = 3 - OBJTYPE_BYTES int32 = 4 - OBJTYPE_CHAIN_ID int32 = 5 - OBJTYPE_COLOR int32 = 6 - OBJTYPE_HASH int32 = 7 - OBJTYPE_HNAME int32 = 8 - OBJTYPE_INT8 int32 = 9 - OBJTYPE_INT16 int32 = 10 - OBJTYPE_INT32 int32 = 11 - OBJTYPE_INT64 int32 = 12 - OBJTYPE_MAP int32 = 13 - OBJTYPE_REQUEST_ID int32 = 14 - OBJTYPE_STRING int32 = 15 - - OBJID_NULL int32 = 0 - OBJID_ROOT int32 = 1 - OBJID_STATE int32 = 2 - OBJID_PARAMS int32 = 3 - OBJID_RESULTS int32 = 4 -) - -// flag to indicate that this key id originally comes from a bytes key -// this allows us to display better readable tracing information -const KeyFromBytes int32 = 0x4000 - -var TypeSizes = [...]int{0, 33, 37, 1, 0, 33, 32, 32, 4, 1, 2, 4, 8, 0, 34, 0} - -type HostObject interface { - CallFunc(keyID int32, params []byte) []byte - DelKey(keyID, typeID int32) - Exists(keyID, typeID int32) bool - GetBytes(keyID, typeID int32) []byte - GetObjectID(keyID, typeID int32) int32 - GetTypeID(keyID int32) int32 - SetBytes(keyID, typeID int32, bytes []byte) -} - -// KvStoreHost implements WaspLib.client.ScHost interface -// it allows WasmGoVM to bypass Wasm and access the sandbox directly -// so that it is possible to debug into SC code that was written in Go -type KvStoreHost struct { - scKeys *KvStoreHost - keyIDToKey [][]byte - keyToKeyID map[string]int32 - objIDToObj []HostObject -} - -func (h *KvStoreHost) Init(scKeys *KvStoreHost) { - h.scKeys = scKeys - h.keyIDToKey = [][]byte{[]byte("")} - h.keyToKeyID = make(map[string]int32) - h.objIDToObj = make([]HostObject, 0, 16) -} - -func (h *KvStoreHost) CallFunc(objID, keyID int32, params []byte) []byte { - return h.FindObject(objID).CallFunc(keyID, params) -} - -func (h *KvStoreHost) DelKey(objID, keyID, typeID int32) { - h.FindObject(objID).DelKey(keyID, typeID) -} - -func (h *KvStoreHost) Exists(objID, keyID, typeID int32) bool { - return h.FindObject(objID).Exists(keyID, typeID) -} - -func (h *KvStoreHost) FindObject(objID int32) HostObject { - if objID < 0 || objID >= int32(len(h.objIDToObj)) { - h.Panicf("FindObject: invalid objID") - } - return h.objIDToObj[objID] -} - -func (h *KvStoreHost) GetBytes(objID, keyID, typeID int32) []byte { - obj := h.FindObject(objID) - if !obj.Exists(keyID, typeID) { - h.Tracef("GetBytes o%d k%d missing key", objID, keyID) - return nil - } - bytes := obj.GetBytes(keyID, typeID) - switch typeID { - case OBJTYPE_INT8: - val8, err := codec.DecodeInt8(bytes, 0) - if err != nil { - h.Panicf("GetBytes: invalid int8") - } - h.Tracef("GetBytes o%d k%d = %db", objID, keyID, val8) - case OBJTYPE_INT16: - val16, err := codec.DecodeInt16(bytes, 0) - if err != nil { - h.Panicf("GetBytes: invalid int16") - } - h.Tracef("GetBytes o%d k%d = %ds", objID, keyID, val16) - case OBJTYPE_INT32: - val32, err := codec.DecodeInt32(bytes, 0) - if err != nil { - h.Panicf("GetBytes: invalid int32") - } - h.Tracef("GetBytes o%d k%d = %di", objID, keyID, val32) - case OBJTYPE_INT64: - val64, err := codec.DecodeInt64(bytes, 0) - if err != nil { - h.Panicf("GetBytes: invalid int64") - } - h.Tracef("GetBytes o%d k%d = %dl", objID, keyID, val64) - case OBJTYPE_STRING: - h.Tracef("GetBytes o%d k%d = '%s'", objID, keyID, string(bytes)) - default: - h.Tracef("GetBytes o%d k%d = '%s'", objID, keyID, base58.Encode(bytes)) - } - return bytes -} - -func (h *KvStoreHost) getKeyFromID(keyID int32) []byte { - if keyID < 0 { - return predefinedKeys[-keyID] - } - - // find user-defined key - keyID &= ^KeyFromBytes - if h.scKeys != nil { - // get common SC user-defined keys count (skip null) - scKeysLen := int32(len(h.scKeys.keyIDToKey)) - 1 - - // find common SC user-defined key - if keyID <= scKeysLen { - return h.scKeys.keyIDToKey[keyID] - } - - // correct for SC keys count - keyID -= scKeysLen - } - - // user-defined key must be local - return h.keyIDToKey[keyID] -} - -func (h *KvStoreHost) GetKeyFromID(keyID int32) []byte { - h.TraceAllf("GetKeyFromID(k%d)", keyID) - key := h.getKeyFromID(keyID) - if (keyID & (KeyFromBytes | -0x80000000)) == KeyFromBytes { - // originally a byte slice key - h.Tracef("GetKeyFromID k%d='%s'", keyID, base58.Encode(key)) - return key - } - // originally a string key - h.Tracef("GetKeyFromID k%d='%s'", keyID, string(key)) - return key -} - -func (h *KvStoreHost) getKeyID(key []byte, fromBytes bool) int32 { - // cannot use []byte as key in maps - // so we will convert to (non-utf8) string - // most will have started out as string anyway - keyString := string(key) - - var scKeysLen int32 - if h.scKeys != nil { - // check common SC user-defined keys - keyID, ok := h.scKeys.keyToKeyID[keyString] - if ok { - return keyID - } - - // get common SC user-defined keys count (skip null) - scKeysLen = int32(len(h.scKeys.keyIDToKey)) - 1 - } - - // check local user-defined keys - keyID, ok := h.keyToKeyID[keyString] - if ok { - return keyID - } - - // unknown key, add it to local user-defined keys - keyID = int32(len(h.keyIDToKey)) + scKeysLen - if fromBytes { - keyID |= KeyFromBytes - } - h.keyToKeyID[keyString] = keyID - h.keyIDToKey = append(h.keyIDToKey, key) - return keyID -} - -func (h *KvStoreHost) GetKeyIDFromBytes(bytes []byte) int32 { - keyID := h.getKeyID(bytes, true) - h.Tracef("GetKeyIDFromBytes '%s'=k%d", base58.Encode(bytes), keyID) - return keyID -} - -func (h *KvStoreHost) GetKeyIDFromString(key string) int32 { - keyID := h.getKeyID([]byte(key), false) - h.Tracef("GetKeyIDFromString '%s'=k%d", key, keyID) - return keyID -} - -func (h *KvStoreHost) GetKeyStringFromID(keyID int32) string { - return string(h.GetKeyFromID(keyID)) -} - -func (h *KvStoreHost) GetObjectID(objID, keyID, typeID int32) int32 { - h.TraceAllf("GetObjectID(o%d,k%d,t%d)", objID, keyID, typeID) - subID := h.FindObject(objID).GetObjectID(keyID, typeID) - h.Tracef("GetObjectID o%d k%d t%d = o%d", objID, keyID, typeID, subID) - return subID -} - -func (h *KvStoreHost) Panicf(format string, args ...interface{}) { - err := fmt.Errorf(format, args...) - h.Tracef(err.Error()) - panic(err) -} - -func (h *KvStoreHost) SetBytes(objID, keyID, typeID int32, bytes []byte) { - h.FindObject(objID).SetBytes(keyID, typeID, bytes) - switch typeID { - case OBJTYPE_INT8: - val8, err := codec.DecodeInt8(bytes, 0) - if err != nil { - h.Panicf("SetBytes: invalid int8") - } - h.Tracef("SetBytes o%d k%d v=%db", objID, keyID, val8) - case OBJTYPE_INT16: - val16, err := codec.DecodeInt16(bytes, 0) - if err != nil { - h.Panicf("SetBytes: invalid int16") - } - h.Tracef("SetBytes o%d k%d v=%ds", objID, keyID, val16) - case OBJTYPE_INT32: - val32, err := codec.DecodeInt32(bytes, 0) - if err != nil { - h.Panicf("SetBytes: invalid int32") - } - h.Tracef("SetBytes o%d k%d v=%di", objID, keyID, val32) - case OBJTYPE_INT64: - val64, err := codec.DecodeInt64(bytes, 0) - if err != nil { - h.Panicf("SetBytes: invalid int64") - } - h.Tracef("SetBytes o%d k%d v=%dl", objID, keyID, val64) - case OBJTYPE_STRING: - if keyID != KeyTrace { - h.Tracef("SetBytes o%d k%d v='%s'", objID, keyID, string(bytes)) - } - default: - h.Tracef("SetBytes o%d k%d v='%s'", objID, keyID, base58.Encode(bytes)) - } -} - -func (h *KvStoreHost) Tracef(format string, a ...interface{}) { - if HostTracing { - text := fmt.Sprintf(format, a...) - h.SetBytes(OBJID_ROOT, KeyTrace, OBJTYPE_STRING, []byte(text)) - } -} - -func (h *KvStoreHost) TraceAllf(format string, a ...interface{}) { - if HostTracingAll { - h.Tracef(format, a...) - } -} - -func (h *KvStoreHost) TrackObject(obj HostObject) int32 { - objID := int32(len(h.objIDToObj)) - h.objIDToObj = append(h.objIDToObj, obj) - return objID -} - -func (h *KvStoreHost) TypeCheck(typeID int32, bytes []byte) { - typeSize := TypeSizes[typeID] - if typeSize != 0 && typeSize != len(bytes) { - h.Panicf("TypeCheck: invalid type size") - } - switch typeID { - case OBJTYPE_ADDRESS: - // address bytes must start with valid address type - if ledgerstate.AddressType(bytes[0]) > ledgerstate.AliasAddressType { - h.Panicf("TypeCheck: invalid address type") - } - case OBJTYPE_AGENT_ID: - // address bytes in agent id must start with valid address type - if ledgerstate.AddressType(bytes[0]) > ledgerstate.AliasAddressType { - h.Panicf("TypeCheck: invalid agent id address type") - } - case OBJTYPE_CHAIN_ID: - // chain id must be alias address - if ledgerstate.AddressType(bytes[0]) != ledgerstate.AliasAddressType { - h.Panicf("TypeCheck: invalid chain id address type") - } - case OBJTYPE_REQUEST_ID: - outputIndex := binary.LittleEndian.Uint16(bytes[ledgerstate.TransactionIDLength:]) - if outputIndex > ledgerstate.MaxOutputCount { - h.Panicf("TypeCheck: invalid request id output index") - } - } -} - -func (h *KvStoreHost) Sandbox(funcNr int32, params []byte) []byte { - panic("implement me") -} - -func (h *KvStoreHost) StateDelete(key []byte) { - panic("implement me") -} - -func (h *KvStoreHost) StateExists(key []byte) bool { - panic("implement me") -} - -func (h *KvStoreHost) StateGet(key []byte) []byte { - panic("implement me") -} - -func (h *KvStoreHost) StateSet(key, value []byte) { - panic("implement me") -} diff --git a/packages/vm/wasmproc/wasmcontext.go b/packages/vm/wasmhost/wasmcontext.go similarity index 50% rename from packages/vm/wasmproc/wasmcontext.go rename to packages/vm/wasmhost/wasmcontext.go index f11d4bf5b1..a3007156ed 100644 --- a/packages/vm/wasmproc/wasmcontext.go +++ b/packages/vm/wasmhost/wasmcontext.go @@ -1,10 +1,9 @@ -package wasmproc +package wasmhost import ( "github.com/iotaledger/wasp/packages/iscp" "github.com/iotaledger/wasp/packages/kv" "github.com/iotaledger/wasp/packages/kv/dict" - "github.com/iotaledger/wasp/packages/vm/wasmhost" "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" ) @@ -12,15 +11,18 @@ const ( FuncDefault = "_default" ) +type ISandbox interface { + Call(funcNr int32, params []byte) []byte +} + type WasmContext struct { - wasmhost.KvStoreHost - common iscp.SandboxBase - ctx iscp.Sandbox - ctxView iscp.SandboxView function string id int32 - host *wasmhost.WasmHost + host *WasmHost + mini ISandbox proc *WasmProcessor + sandbox *WasmToSandbox + results dict.Dict } var ( @@ -29,23 +31,12 @@ var ( ) func NewWasmContext(function string, proc *WasmProcessor) *WasmContext { - wc := &WasmContext{function: function, proc: proc} - - if proc == nil { - wc.host = &wasmhost.WasmHost{} - wc.host.Init() - return wc - } - wc.host = &proc.WasmHost - - var scKeys *wasmhost.KvStoreHost - if proc.scContext != nil { - scKeys = &proc.scContext.KvStoreHost - } + return &WasmContext{function: function, proc: proc, host: &proc.WasmHost} +} - wc.Init(scKeys) - wc.TrackObject(NewNullObject(&wc.KvStoreHost)) - wc.TrackObject(NewScContext(wc, &wc.KvStoreHost)) +func NewWasmMiniContext(function string, mini ISandbox) *WasmContext { + wc := &WasmContext{function: function, mini: mini, host: &WasmHost{}} + wc.host.Init() return wc } @@ -62,26 +53,16 @@ func (wc *WasmContext) Call(ctx interface{}) (dict.Dict, error) { panic("Context id is zero") } - wcSaved := wasmhost.Connect(wc) + wc.sandbox = NewWasmToSandbox(wc, ctx) + wc.mini = wc.sandbox + + wcSaved := Connect(wc) defer func() { - wasmhost.Connect(wcSaved) + Connect(wcSaved) // clean up context after use wc.proc.KillContext(wc.id) }() - switch tctx := ctx.(type) { - case iscp.Sandbox: - wc.common = tctx - wc.ctx = tctx - wc.ctxView = nil - case iscp.SandboxView: - wc.common = tctx - wc.ctx = nil - wc.ctxView = tctx - default: - panic(iscp.ErrWrongTypeEntryPoint) - } - if wc.function == "" { // init function was missing, do nothing return nil, nil @@ -92,15 +73,14 @@ func (wc *WasmContext) Call(ctx interface{}) (dict.Dict, error) { return nil, nil } - wc.Tracef("Calling " + wc.function) + wc.log().Debugf("Calling " + wc.function) + wc.results = nil err := wc.callFunction() if err != nil { wc.log().Infof("VM call %s(): error %v", wc.function, err) return nil, err } - resultsID := wc.GetObjectID(wasmhost.OBJID_ROOT, wasmhost.KeyResults, wasmhost.OBJTYPE_MAP) - results := wc.FindObject(resultsID).(*ScDict).kvStore.(dict.Dict) - return results, nil + return wc.results, nil } func (wc *WasmContext) callFunction() error { @@ -114,28 +94,75 @@ func (wc *WasmContext) callFunction() error { return err } +func (wc *WasmContext) ExportName(index int32, name string) { + wc.host.SetExport(index, name) +} + +func (wc *WasmContext) ExportWasmTag() { + if wc.proc != nil { + wc.proc.log.Infof("WASM::GO::DEBUG") + } +} + func (wc *WasmContext) FunctionFromCode(code uint32) string { return wc.host.FunctionFromCode(code) } +func (wc *WasmContext) Host() *WasmHost { + return wc.host +} + func (wc *WasmContext) IsView() bool { return wc.host.IsView(wc.function) } func (wc *WasmContext) log() iscp.LogInterface { - if wc.common != nil { - return wc.common.Log() + if wc.sandbox.common != nil { + return wc.sandbox.common.Log() } return wc.proc.log } -func (wc *WasmContext) params() dict.Dict { - return wc.common.Params() +func (wc *WasmContext) Sandbox(funcNr int32, params []byte) []byte { + return wc.mini.Call(funcNr, params) +} + +func (wc *WasmContext) state() kv.KVStoreReader { + ctx := wc.sandbox.ctx + if ctx != nil { + return ctx.State() + } + ctxView := wc.sandbox.ctxView + if ctxView != nil { + return ctxView.State() + } + panic("cannot access state") +} + +func (wc *WasmContext) StateDelete(key []byte) { + ctx := wc.sandbox.ctx + if ctx == nil { + panic("StateDelete: readonly state") + } + ctx.State().Del(kv.Key(key)) +} + +func (wc *WasmContext) StateExists(key []byte) bool { + // TODO check err? + exists, _ := wc.state().Has(kv.Key(key)) + return exists +} + +func (wc *WasmContext) StateGet(key []byte) []byte { + // TODO check err? + res, _ := wc.state().Get(kv.Key(key)) + return res } -func (wc *WasmContext) state() kv.KVStore { - if wc.ctx != nil { - return wc.ctx.State() +func (wc *WasmContext) StateSet(key, value []byte) { + ctx := wc.sandbox.ctx + if ctx == nil { + panic("StateSet: readonly state") } - return NewScViewState(wc.ctxView) + ctx.State().Set(kv.Key(key), value) } diff --git a/packages/vm/wasmhost/wasmhost.go b/packages/vm/wasmhost/wasmhost.go index 7e5145eacb..fcf27ade21 100644 --- a/packages/vm/wasmhost/wasmhost.go +++ b/packages/vm/wasmhost/wasmhost.go @@ -11,7 +11,7 @@ import ( ) type WasmStore interface { - GetKvStore(id int32) *KvStoreHost + GetContext(id int32) *WasmContext } type WasmHost struct { @@ -38,10 +38,6 @@ func (host *WasmHost) AddView(v wasmlib.ScViewContextFunction) []wasmlib.ScViewC return host.views } -func (host *WasmHost) getKvStore(id int32) *KvStoreHost { - return host.store.GetKvStore(id) -} - func (host *WasmHost) InitVM(vm WasmVM, store WasmStore) error { host.store = store return vm.LinkHost(vm, host) @@ -86,28 +82,21 @@ func (host *WasmHost) RunScFunction(functionName string) (err error) { } func (host *WasmHost) SetExport(index int32, functionName string) { - if index < 0 { - // double check that predefined keys are in sync - if index == KeyZzzzzzz { - return - } - panic("SetExport: predefined key value mismatch") - } - funcIndex, ok := host.funcToIndex[functionName] if ok { + // TODO remove this check? if funcIndex != index { panic("SetExport: duplicate function name") } return } - hn := iscp.Hn(functionName) - hashedName := uint32(hn) + hashedName := uint32(iscp.Hn(functionName)) _, ok = host.codeToFunc[hashedName] if ok { panic("SetExport: duplicate hashed name") } + host.codeToFunc[hashedName] = functionName host.funcToCode[functionName] = hashedName host.funcToIndex[functionName] = index diff --git a/packages/vm/wasmhost/wasmkeys.go b/packages/vm/wasmhost/wasmkeys.go deleted file mode 100644 index c925cdb123..0000000000 --- a/packages/vm/wasmhost/wasmkeys.go +++ /dev/null @@ -1,108 +0,0 @@ -package wasmhost - -// all predefined key id values should exactly match their counterpart values on the client! -// note that predefined key ids are negative values to distinguish them from indexes -// this allows us to use them to initiate special functionality -// for example array[KeyLength] returns the array length - -const ( - KeyAccountID = int32(-1) - KeyAddress = int32(-2) - KeyBalances = int32(-3) - KeyBase58Decode = int32(-4) - KeyBase58Encode = int32(-5) - KeyBlsAddress = int32(-6) - KeyBlsAggregate = int32(-7) - KeyBlsValid = int32(-8) - KeyCall = int32(-9) - KeyCaller = int32(-10) - KeyChainID = int32(-11) - KeyChainOwnerID = int32(-12) - KeyColor = int32(-13) - KeyContract = int32(-14) - KeyContractCreator = int32(-15) - KeyDeploy = int32(-16) - KeyEd25519Address = int32(-17) - KeyEd25519Valid = int32(-18) - KeyEvent = int32(-19) - KeyExports = int32(-20) - KeyHashBlake2b = int32(-21) - KeyHashSha3 = int32(-22) - KeyHname = int32(-23) - KeyIncoming = int32(-24) - KeyLength = int32(-25) - KeyLog = int32(-26) - KeyMaps = int32(-27) - KeyMinted = int32(-28) - KeyPanic = int32(-29) - KeyParams = int32(-30) - KeyPost = int32(-31) - KeyRandom = int32(-32) - KeyRequestID = int32(-33) - KeyResults = int32(-34) - KeyReturn = int32(-35) - KeyState = int32(-36) - KeyTimestamp = int32(-37) - KeyTrace = int32(-38) - KeyTransfers = int32(-39) - KeyUtility = int32(-40) - - // KeyZzzzzzz is treated like a version number. - // When anything changes to the keys give this one a different value - // and make sure that the client side is updated accordingly - KeyZzzzzzz = int32(-41) -) - -// associate names with predefined key ids -var predefinedKeyMap = map[string]int32{ - "$accountID": KeyAccountID, - "$address": KeyAddress, - "$balances": KeyBalances, - "$base58Bytes": KeyBase58Decode, - "$base58String": KeyBase58Encode, - "$blsAddress": KeyBlsAddress, - "$blsAggregate": KeyBlsAggregate, - "$blsValid": KeyBlsValid, - "$call": KeyCall, - "$caller": KeyCaller, - "$chainID": KeyChainID, - "$chainOwnerID": KeyChainOwnerID, - "$color": KeyColor, - "$contract": KeyContract, - "$contractCreator": KeyContractCreator, - "$deploy": KeyDeploy, - "$ed25519Address": KeyEd25519Address, - "$ed25519Valid": KeyEd25519Valid, - "$event": KeyEvent, - "$exports": KeyExports, - "$hashBlake2b": KeyHashBlake2b, - "$hashSha3": KeyHashSha3, - "$hname": KeyHname, - "$incoming": KeyIncoming, - "$length": KeyLength, - "$log": KeyLog, - "$maps": KeyMaps, - "$minted": KeyMinted, - "$panic": KeyPanic, - "$params": KeyParams, - "$post": KeyPost, - "$random": KeyRandom, - "$requestID": KeyRequestID, - "$results": KeyResults, - "$return": KeyReturn, - "$state": KeyState, - "$timestamp": KeyTimestamp, - "$trace": KeyTrace, - "$transfers": KeyTransfers, - "$utility": KeyUtility, -} - -var predefinedKeys = initKeyMap() - -func initKeyMap() [][]byte { - keys := make([][]byte, len(predefinedKeyMap)+1) - for k, v := range predefinedKeyMap { - keys[-v] = []byte(k) - } - return keys -} diff --git a/packages/vm/wasmproc/wasmprocessor.go b/packages/vm/wasmhost/wasmprocessor.go similarity index 83% rename from packages/vm/wasmproc/wasmprocessor.go rename to packages/vm/wasmhost/wasmprocessor.go index d06e8db726..233e408cd9 100644 --- a/packages/vm/wasmproc/wasmprocessor.go +++ b/packages/vm/wasmhost/wasmprocessor.go @@ -1,18 +1,17 @@ // Copyright 2020 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 -package wasmproc +package wasmhost import ( "sync" "github.com/iotaledger/hive.go/logger" "github.com/iotaledger/wasp/packages/iscp" - "github.com/iotaledger/wasp/packages/vm/wasmhost" ) type WasmProcessor struct { - wasmhost.WasmHost + WasmHost contextLock sync.Mutex contexts map[int32]*WasmContext currentContextID int32 @@ -21,19 +20,19 @@ type WasmProcessor struct { mainProcessor *WasmProcessor nextContextID int32 scContext *WasmContext - wasmVM func() wasmhost.WasmVM + wasmVM func() WasmVM } var _ iscp.VMProcessor = &WasmProcessor{} -var GoWasmVM func() wasmhost.WasmVM +var GoWasmVM func() WasmVM // GetProcessor creates a new Wasm VM processor. func GetProcessor(wasmBytes []byte, log *logger.Logger) (iscp.VMProcessor, error) { - proc := &WasmProcessor{log: log, contexts: make(map[int32]*WasmContext), wasmVM: wasmhost.NewWasmTimeVM} + proc := &WasmProcessor{log: log, contexts: make(map[int32]*WasmContext), wasmVM: NewWasmTimeVM} proc.Init() - // By default we will use WasmTimeVM, but this can be overruled by setting GoWasmVm + // By default, we will use WasmTimeVM, but this can be overruled by setting GoWasmVm // This setting will also be propagated to all the sub-processors of this processor if GoWasmVM != nil { proc.wasmVM = GoWasmVM @@ -47,7 +46,7 @@ func GetProcessor(wasmBytes []byte, log *logger.Logger) (iscp.VMProcessor, error } proc.scContext = NewWasmContext("", proc) - wasmhost.Connect(proc.scContext) + Connect(proc.scContext) err = proc.LoadWasm(wasmBytes) if err != nil { return nil, err @@ -75,13 +74,13 @@ func (proc *WasmProcessor) GetDefaultEntryPoint() iscp.VMProcessorEntryPoint { return proc.wasmContext(FuncDefault) } -func (proc *WasmProcessor) GetKvStore(id int32) *wasmhost.KvStoreHost { +func (proc *WasmProcessor) GetContext(id int32) *WasmContext { if id == 0 { id = proc.currentContextID } if id == 0 { - return &proc.scContext.KvStoreHost + return proc.scContext } mainProcessor := proc @@ -91,7 +90,7 @@ func (proc *WasmProcessor) GetKvStore(id int32) *wasmhost.KvStoreHost { mainProcessor.contextLock.Lock() defer mainProcessor.contextLock.Unlock() - return &mainProcessor.contexts[id].KvStoreHost + return mainProcessor.contexts[id] } func (proc *WasmProcessor) KillContext(id int32) { @@ -117,7 +116,7 @@ func (proc *WasmProcessor) wasmContext(function string) *WasmContext { return wc } -func (proc *WasmProcessor) getSubProcessor(vmInstance wasmhost.WasmVM) *WasmProcessor { +func (proc *WasmProcessor) getSubProcessor(vmInstance WasmVM) *WasmProcessor { processor := &WasmProcessor{log: proc.log, mainProcessor: proc, wasmVM: proc.wasmVM} processor.Init() err := processor.InitVM(vmInstance, processor) @@ -126,7 +125,7 @@ func (proc *WasmProcessor) getSubProcessor(vmInstance wasmhost.WasmVM) *WasmProc } processor.scContext = NewWasmContext("", processor) - wasmhost.Connect(processor.scContext) + Connect(processor.scContext) err = processor.Instantiate() if err != nil { panic("Cannot instantiate: " + err.Error()) diff --git a/packages/vm/wasmhost/wasmtosandbox.go b/packages/vm/wasmhost/wasmtosandbox.go new file mode 100644 index 0000000000..b0b6edf2cf --- /dev/null +++ b/packages/vm/wasmhost/wasmtosandbox.go @@ -0,0 +1,291 @@ +// Copyright 2020 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +package wasmhost + +import ( + "time" + + "github.com/iotaledger/goshimmer/packages/ledgerstate" + "github.com/iotaledger/wasp/packages/hashing" + "github.com/iotaledger/wasp/packages/iscp" + "github.com/iotaledger/wasp/packages/iscp/colored" + "github.com/iotaledger/wasp/packages/kv/codec" + "github.com/iotaledger/wasp/packages/kv/dict" + "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmrequests" +) + +// NOTE: These functions correspond to the Sandbox fnXxx constants in WasmLib +var sandboxFunctions = []func(*WasmToSandbox, []byte) []byte{ + nil, + (*WasmToSandbox).fnAccountID, + (*WasmToSandbox).fnBalance, + (*WasmToSandbox).fnBalances, + (*WasmToSandbox).fnBlockContext, + (*WasmToSandbox).fnCall, + (*WasmToSandbox).fnCaller, + (*WasmToSandbox).fnChainID, + (*WasmToSandbox).fnChainOwnerID, + (*WasmToSandbox).fnContract, + (*WasmToSandbox).fnContractCreator, + (*WasmToSandbox).fnDeployContract, + (*WasmToSandbox).fnEntropy, + (*WasmToSandbox).fnEvent, + (*WasmToSandbox).fnIncomingTransfer, + (*WasmToSandbox).fnLog, + (*WasmToSandbox).fnMinted, + (*WasmToSandbox).fnPanic, + (*WasmToSandbox).fnParams, + (*WasmToSandbox).fnPost, + (*WasmToSandbox).fnRequest, + (*WasmToSandbox).fnRequestID, + (*WasmToSandbox).fnSend, + (*WasmToSandbox).fnStateAnchor, + (*WasmToSandbox).fnTimestamp, + (*WasmToSandbox).fnTrace, + (*WasmToSandbox).fnUtilsBase58Decode, + (*WasmToSandbox).fnUtilsBase58Encode, + (*WasmToSandbox).fnUtilsBlsAddress, + (*WasmToSandbox).fnUtilsBlsAggregate, + (*WasmToSandbox).fnUtilsBlsValid, + (*WasmToSandbox).fnUtilsEd25519Address, + (*WasmToSandbox).fnUtilsEd25519Valid, + (*WasmToSandbox).fnUtilsHashBlake2b, + (*WasmToSandbox).fnUtilsHashName, + (*WasmToSandbox).fnUtilsHashSha3, +} + +type WasmToSandbox struct { + common iscp.SandboxBase + ctx iscp.Sandbox + ctxView iscp.SandboxView + wc *WasmContext +} + +var _ ISandbox = new(WasmToSandbox) + +func NewWasmToSandbox(wc *WasmContext, ctx interface{}) *WasmToSandbox { + s := new(WasmToSandbox) + s.wc = wc + switch tctx := ctx.(type) { + case iscp.Sandbox: + s.common = tctx + s.ctx = tctx + case iscp.SandboxView: + s.common = tctx + s.ctxView = tctx + default: + panic(iscp.ErrWrongTypeEntryPoint) + } + return s +} + +func (s *WasmToSandbox) Call(funcNr int32, params []byte) []byte { + return sandboxFunctions[-funcNr](s, params) +} + +func (s *WasmToSandbox) checkErr(err error) { + if err != nil { + s.Panicf(err.Error()) + } +} + +func (s *WasmToSandbox) Panicf(format string, args ...interface{}) { + s.common.Log().Panicf(format, args...) +} + +func (s *WasmToSandbox) Tracef(format string, args ...interface{}) { + s.common.Log().Debugf(format, args...) +} + +//////////////////// sandbox functions \\\\\\\\\\\\\\\\\\\\ + +func (s *WasmToSandbox) fnAccountID(args []byte) []byte { + return s.common.AccountID().Bytes() +} + +func (s *WasmToSandbox) fnBalance(args []byte) []byte { + color, err := colored.ColorFromBytes(args) + s.checkErr(err) + return codec.EncodeUint64(s.ctx.Balance(color)) +} + +func (s *WasmToSandbox) fnBalances(args []byte) []byte { + return s.common.Balances().Bytes() +} + +func (s *WasmToSandbox) fnBlockContext(args []byte) []byte { + panic("implement me") +} + +func (s *WasmToSandbox) fnCall(args []byte) []byte { + req := wasmrequests.NewCallRequestFromBytes(args) + contract, err := iscp.HnameFromBytes(req.Contract.Bytes()) + s.checkErr(err) + function, err := iscp.HnameFromBytes(req.Function.Bytes()) + s.checkErr(err) + params, err := dict.FromBytes(req.Params) + s.checkErr(err) + transfer, err := colored.BalancesFromBytes(req.Transfer) + s.checkErr(err) + s.Tracef("CALL hContract '%s, hFunction %s", contract.String(), function.String()) + results, err := s.callUnlocked(contract, function, params, transfer) + s.checkErr(err) + return results.Bytes() +} + +func (s *WasmToSandbox) callUnlocked(contract, function iscp.Hname, params dict.Dict, transfer colored.Balances) (dict.Dict, error) { + s.wc.proc.instanceLock.Unlock() + defer s.wc.proc.instanceLock.Lock() + + if s.ctx != nil { + return s.ctx.Call(contract, function, params, transfer) + } + return s.ctxView.Call(contract, function, params) +} + +func (s *WasmToSandbox) fnCaller(args []byte) []byte { + return s.ctx.Caller().Bytes() +} + +func (s *WasmToSandbox) fnChainID(args []byte) []byte { + return s.common.ChainID().Bytes() +} + +func (s *WasmToSandbox) fnChainOwnerID(args []byte) []byte { + return s.common.ChainOwnerID().Bytes() +} + +func (s *WasmToSandbox) fnContract(args []byte) []byte { + return s.common.Contract().Bytes() +} + +func (s *WasmToSandbox) fnContractCreator(args []byte) []byte { + return s.common.ContractCreator().Bytes() +} + +func (s *WasmToSandbox) fnDeployContract(args []byte) []byte { + req := wasmrequests.NewDeployRequestFromBytes(args) + programHash, err := hashing.HashValueFromBytes(req.ProgHash.Bytes()) + s.checkErr(err) + initParams, err := dict.FromBytes(req.Params) + s.checkErr(err) + s.Tracef("DEPLOY %s: %s", req.Name, req.Description) + err = s.deployUnlocked(programHash, req.Name, req.Description, initParams) + s.checkErr(err) + return nil +} + +func (s *WasmToSandbox) deployUnlocked(programHash hashing.HashValue, name, description string, params dict.Dict) error { + s.wc.proc.instanceLock.Unlock() + defer s.wc.proc.instanceLock.Lock() + + return s.ctx.DeployContract(programHash, name, description, params) +} + +func (s *WasmToSandbox) fnEntropy(args []byte) []byte { + return s.ctx.GetEntropy().Bytes() +} + +func (s *WasmToSandbox) fnEvent(args []byte) []byte { + s.ctx.Event(string(args)) + return nil +} + +func (s *WasmToSandbox) fnIncomingTransfer(args []byte) []byte { + return s.ctx.IncomingTransfer().Bytes() +} + +func (s *WasmToSandbox) fnLog(args []byte) []byte { + s.common.Log().Infof(string(args)) + return nil +} + +func (s *WasmToSandbox) fnMinted(args []byte) []byte { + return s.ctx.Minted().Bytes() +} + +func (s *WasmToSandbox) fnPanic(args []byte) []byte { + s.common.Log().Panicf(string(args)) + return nil +} + +func (s *WasmToSandbox) fnParams(args []byte) []byte { + return s.common.Params().Bytes() +} + +func (s *WasmToSandbox) fnPost(args []byte) []byte { + req := wasmrequests.NewPostRequestFromBytes(args) + chainID, err := iscp.ChainIDFromBytes(req.ChainID.Bytes()) + s.checkErr(err) + contract, err := iscp.HnameFromBytes(req.Contract.Bytes()) + s.checkErr(err) + function, err := iscp.HnameFromBytes(req.Function.Bytes()) + s.checkErr(err) + params, err := dict.FromBytes(req.Params) + s.checkErr(err) + transfer, err := colored.BalancesFromBytes(req.Transfer) + s.checkErr(err) + if len(transfer) == 0 { + s.Panicf("transfer is required for post") + } + + s.Tracef("POST hContract '%s, hFunction %s, chain ", contract.String(), function.String(), chainID.String()) + metadata := &iscp.SendMetadata{ + TargetContract: contract, + EntryPoint: function, + Args: params, + } + if req.Delay == 0 { + if !s.ctx.Send(chainID.AsAddress(), transfer, metadata) { + s.Panicf("failed to send to %s", chainID.AsAddress().String()) + } + return nil + } + + timeLock := time.Unix(0, s.ctx.GetTimestamp()) + timeLock = timeLock.Add(time.Duration(req.Delay) * time.Second) + options := iscp.SendOptions{ + TimeLock: uint32(timeLock.Unix()), + } + if !s.ctx.Send(chainID.AsAddress(), transfer, metadata, options) { + s.Panicf("failed to send to %s", chainID.AsAddress().String()) + } + return nil +} + +func (s *WasmToSandbox) fnRequest(args []byte) []byte { + return s.ctx.Request().Bytes() +} + +func (s *WasmToSandbox) fnRequestID(args []byte) []byte { + return s.ctx.Request().ID().Bytes() +} + +// transfer tokens to address +func (s *WasmToSandbox) fnSend(args []byte) []byte { + req := wasmrequests.NewSendRequestFromBytes(args) + address, _, err := ledgerstate.AddressFromBytes(req.Address.Bytes()) + s.checkErr(err) + transfer, err := colored.BalancesFromBytes(req.Transfer) + s.checkErr(err) + if len(transfer) != 0 { + if !s.ctx.Send(address, transfer, nil) { + s.Panicf("failed to send to %s", address.String()) + } + } + return nil +} + +func (s *WasmToSandbox) fnStateAnchor(args []byte) []byte { + panic("implement me") +} + +func (s *WasmToSandbox) fnTimestamp(args []byte) []byte { + return codec.EncodeInt64(s.common.GetTimestamp()) +} + +func (s *WasmToSandbox) fnTrace(args []byte) []byte { + s.common.Log().Debugf(string(args)) + return nil +} diff --git a/packages/vm/wasmhost/wasmtosandboxutils.go b/packages/vm/wasmhost/wasmtosandboxutils.go new file mode 100644 index 0000000000..e5be77ebc1 --- /dev/null +++ b/packages/vm/wasmhost/wasmtosandboxutils.go @@ -0,0 +1,79 @@ +// Copyright 2020 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +package wasmhost + +import ( + "github.com/iotaledger/wasp/packages/kv/codec" + "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmcodec" + "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" +) + +func (s WasmToSandbox) fnUtilsBase58Decode(args []byte) []byte { + bytes, err := s.common.Utils().Base58().Decode(string(args)) + s.checkErr(err) + return bytes +} + +func (s WasmToSandbox) fnUtilsBase58Encode(args []byte) []byte { + return []byte(s.common.Utils().Base58().Encode(args)) +} + +func (s WasmToSandbox) fnUtilsBlsAddress(args []byte) []byte { + address, err := s.common.Utils().BLS().AddressFromPublicKey(args) + s.checkErr(err) + return address.Bytes() +} + +func (s WasmToSandbox) fnUtilsBlsAggregate(args []byte) []byte { + dec := wasmcodec.NewWasmDecoder(args) + count := wasmtypes.DecodeUint32(dec) + pubKeysBin := make([][]byte, count) + for i := uint32(0); i < count; i++ { + pubKeysBin[i] = dec.Bytes() + } + count = wasmtypes.DecodeUint32(dec) + sigsBin := make([][]byte, count) + for i := uint32(0); i < count; i++ { + sigsBin[i] = dec.Bytes() + } + pubKeyBin, sigBin, err := s.common.Utils().BLS().AggregateBLSSignatures(pubKeysBin, sigsBin) + s.checkErr(err) + return wasmcodec.NewWasmEncoder().Bytes(pubKeyBin).Bytes(sigBin).Buf() +} + +func (s WasmToSandbox) fnUtilsBlsValid(args []byte) []byte { + dec := wasmcodec.NewWasmDecoder(args) + data := dec.Bytes() + pubKey := dec.Bytes() + signature := dec.Bytes() + valid := s.common.Utils().BLS().ValidSignature(data, pubKey, signature) + return codec.EncodeBool(valid) +} + +func (s WasmToSandbox) fnUtilsEd25519Address(args []byte) []byte { + address, err := s.common.Utils().ED25519().AddressFromPublicKey(args) + s.checkErr(err) + return address.Bytes() +} + +func (s WasmToSandbox) fnUtilsEd25519Valid(args []byte) []byte { + dec := wasmcodec.NewWasmDecoder(args) + data := dec.Bytes() + pubKey := dec.Bytes() + signature := dec.Bytes() + valid := s.common.Utils().ED25519().ValidSignature(data, pubKey, signature) + return codec.EncodeBool(valid) +} + +func (s WasmToSandbox) fnUtilsHashBlake2b(args []byte) []byte { + return s.common.Utils().Hashing().Blake2b(args).Bytes() +} + +func (s WasmToSandbox) fnUtilsHashName(args []byte) []byte { + return codec.EncodeHname(s.common.Utils().Hashing().Hname(string(args))) +} + +func (s WasmToSandbox) fnUtilsHashSha3(args []byte) []byte { + return s.common.Utils().Hashing().Sha3(args).Bytes() +} diff --git a/packages/vm/wasmhost/wasmvm.go b/packages/vm/wasmhost/wasmvm.go index 487f895a2f..331195d80c 100644 --- a/packages/vm/wasmhost/wasmvm.go +++ b/packages/vm/wasmhost/wasmvm.go @@ -54,22 +54,11 @@ type WasmVM interface { VMSetBytes(offset int32, size int32, bytes []byte) int32 } -// TODO implement this in WasmContext? -type SandboxContext interface { - CallSandbox(funcNr int32, params []byte) []byte - StateDelete(key []byte) - StateExists(key []byte) bool - StateGet(key []byte) []byte - StateSet(key []byte, value []byte) -} - type WasmVMBase struct { impl WasmVM host *WasmHost - ctx SandboxContext panicErr error result []byte - resultKeyID int32 timeoutStarted bool } @@ -95,9 +84,8 @@ func (vm *WasmVMBase) catchPanicMessage() { panic(panicMsg) } -//nolint:unparam -func (vm *WasmVMBase) getKvStore(id int32) *KvStoreHost { - return vm.host.getKvStore(id) +func (vm *WasmVMBase) getContext(id int32) *WasmContext { + return vm.host.store.GetContext(id) } func (vm *WasmVMBase) HostAbort(errMsg, fileName, line, col int32) { @@ -127,8 +115,9 @@ func (vm *WasmVMBase) HostAbort(errMsg, fileName, line, col int32) { func (vm *WasmVMBase) HostFdWrite(_fd, iovs, _size, written int32) int32 { defer vm.catchPanicMessage() - host := vm.getKvStore(0) - host.TraceAllf("HostFdWrite(...)") + ctx := vm.getContext(0) + ctx.log().Debugf("HostFdWrite(...)") + // very basic implementation that expects fd to be stdout and iovs to be only one element ptr := vm.impl.VMGetBytes(iovs, 8) text := int32(binary.LittleEndian.Uint32(ptr[0:4])) @@ -143,102 +132,34 @@ func (vm *WasmVMBase) HostFdWrite(_fd, iovs, _size, written int32) int32 { func (vm *WasmVMBase) HostGetBytes(objID, keyID, typeID, stringRef, size int32) int32 { defer vm.catchPanicMessage() - - host := vm.getKvStore(0) - host.TraceAllf("HostGetBytes(o%d,k%d,t%d,r%d,s%d)", objID, keyID, typeID, stringRef, size) - - // only check for existence ? - if size < 0 { - if host.Exists(objID, keyID, typeID) { - return 0 - } - // missing key is indicated by -1 - return -1 - } - - // actual GetBytes request ? - if (typeID & OBJTYPE_CALL) == 0 { - bytes := host.GetBytes(objID, keyID, typeID) - if bytes == nil { - return -1 - } - return vm.impl.VMSetBytes(stringRef, size, bytes) - } - - // func call request - switch typeID { - case OBJTYPE_CALL: - // func call with params, returns result length - vm.resultKeyID = keyID - params := vm.impl.VMGetBytes(stringRef, size) - vm.result = host.CallFunc(objID, keyID, params) - return int32(len(vm.result)) - - case OBJTYPE_CALL + 1: - // retrieve previous func call result - if vm.resultKeyID == keyID { - result := vm.result - vm.result = nil - vm.resultKeyID = 0 - if result == nil { - return -1 - } - return vm.impl.VMSetBytes(stringRef, int32(len(result)), result) - } - } - panic("HostGetBytes: Invalid func call state") + panic("deprecated: HostGetBytes") } func (vm *WasmVMBase) HostGetKeyID(keyRef, size int32) int32 { defer vm.catchPanicMessage() - - host := vm.getKvStore(0) - host.TraceAllf("HostGetKeyID(r%d,s%d)", keyRef, size) - // non-negative size means original key was a string - if size >= 0 { - bytes := vm.impl.VMGetBytes(keyRef, size) - return host.GetKeyIDFromString(string(bytes)) - } - - // negative size means original key was a byte slice - bytes := vm.impl.VMGetBytes(keyRef, -size-1) - return host.GetKeyIDFromBytes(bytes) + panic("deprecated: HostGetKeyID") } func (vm *WasmVMBase) HostGetObjectID(objID, keyID, typeID int32) int32 { defer vm.catchPanicMessage() - - host := vm.getKvStore(0) - host.TraceAllf("HostGetObjectID(o%d,k%d,t%d)", objID, keyID, typeID) - return host.GetObjectID(objID, keyID, typeID) + panic("deprecated: HostGetObjectID") } func (vm *WasmVMBase) HostSetBytes(objID, keyID, typeID, stringRef, size int32) { defer vm.catchPanicMessage() - - host := vm.getKvStore(0) - host.TraceAllf("HostSetBytes(o%d,k%d,t%d,r%d,s%d)", objID, keyID, typeID, stringRef, size) - - // delete key ? - if size < 0 { - host.DelKey(objID, keyID, typeID) - return - } - - bytes := vm.impl.VMGetBytes(stringRef, size) - host.SetBytes(objID, keyID, typeID, bytes) + panic("deprecated: HostSetBytes") } func (vm *WasmVMBase) HostStateGet(keyRef, keyLen, valRef, valLen int32) int32 { defer vm.catchPanicMessage() - host := vm.getKvStore(0) - host.TraceAllf("HostStateGet(k(%d,%d),v(%d,s%d))", keyRef, keyLen, valRef, valLen) + ctx := vm.getContext(0) + ctx.log().Debugf("HostStateGet(k(%d,%d),v(%d,s%d))", keyRef, keyLen, valRef, valLen) // only check for existence ? if valLen < 0 { key := vm.impl.VMGetBytes(keyRef, keyLen) - if vm.ctx.StateExists(key) { + if ctx.StateExists(key) { return 0 } // missing key is indicated by -1 @@ -250,7 +171,7 @@ func (vm *WasmVMBase) HostStateGet(keyRef, keyLen, valRef, valLen int32) int32 { if keyLen > 0 { // retrieve value associated with key key := vm.impl.VMGetBytes(keyRef, keyLen) - vm.result = vm.ctx.StateGet(key) + vm.result = ctx.StateGet(key) } if vm.result == nil { return -1 @@ -260,26 +181,26 @@ func (vm *WasmVMBase) HostStateGet(keyRef, keyLen, valRef, valLen int32) int32 { // sandbox func call request, keyLen is func nr params := vm.impl.VMGetBytes(valRef, valLen) - vm.result = vm.ctx.CallSandbox(keyLen, params) + vm.result = ctx.Sandbox(keyLen, params) return int32(len(vm.result)) } func (vm *WasmVMBase) HostStateSet(keyRef, keyLen, valRef, valLen int32) { defer vm.catchPanicMessage() - host := vm.getKvStore(0) - host.TraceAllf("HostStateSet(k(%d,%d),v(%d,s%d))", keyRef, keyLen, valRef, valLen) + ctx := vm.getContext(0) + ctx.log().Debugf("HostStateSet(k(%d,%d),v(%d,s%d))", keyRef, keyLen, valRef, valLen) key := vm.impl.VMGetBytes(keyRef, keyLen) // delete key ? if valLen < 0 { - vm.ctx.StateDelete(key) + ctx.StateDelete(key) return } value := vm.impl.VMGetBytes(valRef, valLen) - vm.ctx.StateSet(key, value) + ctx.StateSet(key, value) } func (vm *WasmVMBase) Instantiate() error { diff --git a/packages/vm/wasmlib/go/wasmclient/coreblocklog/service.go b/packages/vm/wasmlib/go/wasmclient/coreblocklog/service.go index 99fce49453..3a1c3a423a 100644 --- a/packages/vm/wasmlib/go/wasmclient/coreblocklog/service.go +++ b/packages/vm/wasmlib/go/wasmclient/coreblocklog/service.go @@ -42,8 +42,8 @@ type ControlAddressesResults struct { res wasmclient.Results } -func (r *ControlAddressesResults) BlockIndex() int32 { - return r.res.ToInt32(r.res.Get(ResBlockIndex)) +func (r *ControlAddressesResults) BlockIndex() uint32 { + return r.res.ToUint32(r.res.Get(ResBlockIndex)) } func (r *ControlAddressesResults) GoverningAddress() wasmclient.Address { @@ -61,8 +61,8 @@ type GetBlockInfoView struct { args wasmclient.Arguments } -func (f *GetBlockInfoView) BlockIndex(v int32) { - f.args.Set(ArgBlockIndex, f.args.FromInt32(v)) +func (f *GetBlockInfoView) BlockIndex(v uint32) { + f.args.Set(ArgBlockIndex, f.args.FromUint32(v)) } func (f *GetBlockInfoView) Call() GetBlockInfoResults { @@ -86,8 +86,8 @@ type GetEventsForBlockView struct { args wasmclient.Arguments } -func (f *GetEventsForBlockView) BlockIndex(v int32) { - f.args.Set(ArgBlockIndex, f.args.FromInt32(v)) +func (f *GetEventsForBlockView) BlockIndex(v uint32) { + f.args.Set(ArgBlockIndex, f.args.FromUint32(v)) } func (f *GetEventsForBlockView) Call() GetEventsForBlockResults { @@ -115,12 +115,12 @@ func (f *GetEventsForContractView) ContractHname(v wasmclient.Hname) { f.args.Set(ArgContractHname, f.args.FromHname(v)) } -func (f *GetEventsForContractView) FromBlock(v int32) { - f.args.Set(ArgFromBlock, f.args.FromInt32(v)) +func (f *GetEventsForContractView) FromBlock(v uint32) { + f.args.Set(ArgFromBlock, f.args.FromUint32(v)) } -func (f *GetEventsForContractView) ToBlock(v int32) { - f.args.Set(ArgToBlock, f.args.FromInt32(v)) +func (f *GetEventsForContractView) ToBlock(v uint32) { + f.args.Set(ArgToBlock, f.args.FromUint32(v)) } func (f *GetEventsForContractView) Call() GetEventsForContractResults { @@ -177,8 +177,8 @@ type GetLatestBlockInfoResults struct { res wasmclient.Results } -func (r *GetLatestBlockInfoResults) BlockIndex() int32 { - return r.res.ToInt32(r.res.Get(ResBlockIndex)) +func (r *GetLatestBlockInfoResults) BlockIndex() uint32 { + return r.res.ToUint32(r.res.Get(ResBlockIndex)) } func (r *GetLatestBlockInfoResults) BlockInfo() []byte { @@ -192,8 +192,8 @@ type GetRequestIDsForBlockView struct { args wasmclient.Arguments } -func (f *GetRequestIDsForBlockView) BlockIndex(v int32) { - f.args.Set(ArgBlockIndex, f.args.FromInt32(v)) +func (f *GetRequestIDsForBlockView) BlockIndex(v uint32) { + f.args.Set(ArgBlockIndex, f.args.FromUint32(v)) } func (f *GetRequestIDsForBlockView) Call() GetRequestIDsForBlockResults { @@ -231,12 +231,12 @@ type GetRequestReceiptResults struct { res wasmclient.Results } -func (r *GetRequestReceiptResults) BlockIndex() int32 { - return r.res.ToInt32(r.res.Get(ResBlockIndex)) +func (r *GetRequestReceiptResults) BlockIndex() uint32 { + return r.res.ToUint32(r.res.Get(ResBlockIndex)) } -func (r *GetRequestReceiptResults) RequestIndex() int16 { - return r.res.ToInt16(r.res.Get(ResRequestIndex)) +func (r *GetRequestReceiptResults) RequestIndex() uint16 { + return r.res.ToUint16(r.res.Get(ResRequestIndex)) } func (r *GetRequestReceiptResults) RequestRecord() []byte { @@ -250,8 +250,8 @@ type GetRequestReceiptsForBlockView struct { args wasmclient.Arguments } -func (f *GetRequestReceiptsForBlockView) BlockIndex(v int32) { - f.args.Set(ArgBlockIndex, f.args.FromInt32(v)) +func (f *GetRequestReceiptsForBlockView) BlockIndex(v uint32) { + f.args.Set(ArgBlockIndex, f.args.FromUint32(v)) } func (f *GetRequestReceiptsForBlockView) Call() GetRequestReceiptsForBlockResults { diff --git a/packages/vm/wasmlib/go/wasmclient/wasmrequests/service.go b/packages/vm/wasmlib/go/wasmclient/wasmrequests/service.go new file mode 100644 index 0000000000..5553665021 --- /dev/null +++ b/packages/vm/wasmlib/go/wasmclient/wasmrequests/service.go @@ -0,0 +1,8 @@ +// Copyright 2020 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +// (Re-)generated by schema tool +// >>>> DO NOT CHANGE THIS FILE! <<<< +// Change the json schema instead + +package wasmrequestsclient diff --git a/packages/vm/wasmlib/go/wasmlib/assets.go b/packages/vm/wasmlib/go/wasmlib/assets.go new file mode 100644 index 0000000000..6c32cd692f --- /dev/null +++ b/packages/vm/wasmlib/go/wasmlib/assets.go @@ -0,0 +1,95 @@ +// Copyright 2020 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +package wasmlib + +import ( + "sort" + + "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmcodec" + "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" +) + +type ScAssets map[wasmtypes.ScColor]uint64 + +func NewScAssetsFromBytes(buf []byte) ScAssets { + dict := make(ScAssets) + size, buf := wasmcodec.ExtractUint32(buf) + var k []byte + var v uint64 + for i := uint32(0); i < size; i++ { + k, buf = wasmcodec.ExtractBytes(buf, 32) + v, buf = wasmcodec.ExtractUint64(buf) + dict[wasmtypes.ColorFromBytes(k)] = v + } + return dict +} + +func (a ScAssets) Bytes() []byte { + keys := make([]wasmtypes.ScColor, 0, len(a)) + for key := range a { + keys = append(keys, key) + } + sort.Slice(keys, func(i, j int) bool { + return string(keys[i].Bytes()) < string(keys[j].Bytes()) + }) + buf := wasmcodec.AppendUint32(nil, uint32(len(keys))) + for _, k := range keys { + v := a[k] + buf = wasmcodec.AppendBytes(buf, k.Bytes()) + buf = wasmcodec.AppendUint64(buf, v) + } + return buf +} + +func (a ScAssets) Balances() ScBalances { + return ScBalances{assets: a} +} + +type ScBalances struct { + assets ScAssets +} + +func (b ScBalances) Balance(color wasmtypes.ScColor) uint64 { + return b.assets[color] +} + +func (b ScBalances) Colors() []wasmtypes.ScColor { + res := make([]wasmtypes.ScColor, 0, len(b.assets)) + for color := range b.assets { + res = append(res, color) + } + return res +} + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +type ScTransfers ScAssets + +// create a new transfers object ready to add token transfers +func NewScTransfers() ScTransfers { + return make(ScTransfers) +} + +// create a new transfers object from a balances object +func NewScTransfersFromBalances(balances ScBalances) ScTransfers { + return ScTransfers(balances.assets) +} + +// create a new transfers object and initialize it with the specified amount of iotas +func NewScTransferIotas(amount uint64) ScTransfers { + return NewScTransfer(wasmtypes.IOTA, amount) +} + +// create a new transfers object and initialize it with the specified token transfer +func NewScTransfer(color wasmtypes.ScColor, amount uint64) ScTransfers { + transfer := make(ScTransfers) + transfer[color] = amount + return transfer +} + +// set the specified colored token transfer in the transfers object +// note that this will overwrite any previous amount for the specified color +func (t ScTransfers) Set(color wasmtypes.ScColor, amount uint64) { + t[color] = amount +} diff --git a/packages/vm/wasmlib/go/wasmlib/bytes.go b/packages/vm/wasmlib/go/wasmlib/bytes.go deleted file mode 100644 index 9a81cf7139..0000000000 --- a/packages/vm/wasmlib/go/wasmlib/bytes.go +++ /dev/null @@ -1,303 +0,0 @@ -// Copyright 2020 IOTA Stiftung -// SPDX-License-Identifier: Apache-2.0 - -package wasmlib - -type BytesDecoder struct { - data []byte -} - -func NewBytesDecoder(data []byte) *BytesDecoder { - if len(data) == 0 { - panic("cannot decode empty byte array, use exist()") - } - return &BytesDecoder{data: data} -} - -func (d *BytesDecoder) Address() ScAddress { - return NewScAddressFromBytes(d.FixedBytes(uint32(TypeSizes[TYPE_ADDRESS]))) -} - -func (d *BytesDecoder) AgentID() ScAgentID { - return NewScAgentIDFromBytes(d.FixedBytes(uint32(TypeSizes[TYPE_AGENT_ID]))) -} - -func (d *BytesDecoder) Bool() bool { - return d.Uint8() != 0 -} - -func (d *BytesDecoder) Bytes() []byte { - length := d.Uint32() - return d.FixedBytes(length) -} - -func (d *BytesDecoder) ChainID() ScChainID { - return NewScChainIDFromBytes(d.FixedBytes(uint32(TypeSizes[TYPE_CHAIN_ID]))) -} - -func (d *BytesDecoder) Close() { - if len(d.data) != 0 { - panic("extra bytes") - } -} - -func (d *BytesDecoder) Color() ScColor { - return NewScColorFromBytes(d.FixedBytes(uint32(TypeSizes[TYPE_COLOR]))) -} - -func (d *BytesDecoder) FixedBytes(size uint32) []byte { - if uint32(len(d.data)) < size { - panic("insufficient bytes") - } - value := d.data[:size] - d.data = d.data[size:] - return value -} - -func (d *BytesDecoder) Hash() ScHash { - return NewScHashFromBytes(d.FixedBytes(uint32(TypeSizes[TYPE_HASH]))) -} - -func (d *BytesDecoder) Hname() ScHname { - return NewScHnameFromBytes(d.FixedBytes(uint32(TypeSizes[TYPE_HNAME]))) -} - -func (d *BytesDecoder) Int8() int8 { - return int8(d.Uint8()) -} - -func (d *BytesDecoder) Int16() int16 { - return int16(d.vliDecode(16)) -} - -func (d *BytesDecoder) Int32() int32 { - return int32(d.vliDecode(32)) -} - -func (d *BytesDecoder) Int64() int64 { - return d.vliDecode(64) -} - -func (d *BytesDecoder) RequestID() ScRequestID { - return NewScRequestIDFromBytes(d.FixedBytes(uint32(TypeSizes[TYPE_REQUEST_ID]))) -} - -func (d *BytesDecoder) String() string { - return string(d.Bytes()) -} - -func (d *BytesDecoder) Uint8() uint8 { - if len(d.data) == 0 { - panic("insufficient bytes") - } - value := d.data[0] - d.data = d.data[1:] - return value -} - -func (d *BytesDecoder) Uint16() uint16 { - return uint16(d.vluDecode(16)) -} - -func (d *BytesDecoder) Uint32() uint32 { - return uint32(d.vluDecode(32)) -} - -func (d *BytesDecoder) Uint64() uint64 { - return d.vluDecode(64) -} - -// vli (variable length integer) decoder -func (d *BytesDecoder) vliDecode(bits int) (value int64) { - b := d.Uint8() - sign := b & 0x40 - - // first group of 6 bits - value = int64(b & 0x3f) - s := 6 - - // while continuation bit is set - for (b & 0x80) != 0 { - if s >= bits { - panic("integer representation too long") - } - - // next group of 7 bits - b = d.Uint8() - value |= int64(b&0x7f) << s - s += 7 - } - - if sign == 0 { - // positive, sign bits are already zero - return value - } - - // negative, extend sign bits - return value | (int64(-1) << s) -} - -// vlu (variable length unsigned) decoder -func (d *BytesDecoder) vluDecode(bits int) uint64 { - // first group of 7 bits - b := d.Uint8() - value := uint64(b & 0x7f) - s := 7 - - // while continuation bit is set - for (b & 0x80) != 0 { - if s >= bits { - panic("integer representation too long") - } - - // next group of 7 bits - b = d.Uint8() - value |= uint64(b&0x7f) << s - s += 7 - } - return value -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -type BytesEncoder struct { - data []byte -} - -func NewBytesEncoder() *BytesEncoder { - return &BytesEncoder{data: make([]byte, 0, 128)} -} - -func (e *BytesEncoder) Address(value ScAddress) *BytesEncoder { - return e.FixedBytes(value.Bytes(), uint32(TypeSizes[TYPE_ADDRESS])) -} - -func (e *BytesEncoder) AgentID(value ScAgentID) *BytesEncoder { - return e.FixedBytes(value.Bytes(), uint32(TypeSizes[TYPE_AGENT_ID])) -} - -func (e *BytesEncoder) Bool(value bool) *BytesEncoder { - if value { - return e.Uint8(1) - } - return e.Uint8(0) -} - -func (e *BytesEncoder) Bytes(value []byte) *BytesEncoder { - length := uint32(len(value)) - e.Uint32(length) - e.FixedBytes(value, length) - return e -} - -func (e *BytesEncoder) ChainID(value ScChainID) *BytesEncoder { - return e.FixedBytes(value.Bytes(), uint32(TypeSizes[TYPE_CHAIN_ID])) -} - -func (e *BytesEncoder) Color(value ScColor) *BytesEncoder { - return e.FixedBytes(value.Bytes(), uint32(TypeSizes[TYPE_COLOR])) -} - -func (e *BytesEncoder) Data() []byte { - return e.data -} - -func (e *BytesEncoder) FixedBytes(value []byte, length uint32) *BytesEncoder { - if len(value) != int(length) { - panic("invalid fixed bytes length") - } - e.data = append(e.data, value...) - return e -} - -func (e *BytesEncoder) Hash(value ScHash) *BytesEncoder { - return e.FixedBytes(value.Bytes(), uint32(TypeSizes[TYPE_HASH])) -} - -func (e *BytesEncoder) Hname(value ScHname) *BytesEncoder { - return e.FixedBytes(value.Bytes(), uint32(TypeSizes[TYPE_HNAME])) -} - -func (e *BytesEncoder) Int8(value int8) *BytesEncoder { - return e.Uint8(uint8(value)) -} - -func (e *BytesEncoder) Int16(value int16) *BytesEncoder { - return e.Int64(int64(value)) -} - -func (e *BytesEncoder) Int32(value int32) *BytesEncoder { - return e.Int64(int64(value)) -} - -// vli (variable length integer) encoder -func (e *BytesEncoder) Int64(value int64) *BytesEncoder { - // first group of 6 bits - // 1st byte encodes 0 as positive in bit 6 - b := byte(value) & 0x3f - value >>= 6 - - finalValue := int64(0) - if value < 0 { - // encode negative value - // 1st byte encodes 1 as negative in bit 6 - b |= 0x40 - finalValue = -1 - } - - // keep shifting until all bits are done - for value != finalValue { - // emit with continuation bit - e.data = append(e.data, b|0x80) - - // next group of 7 bits - b = byte(value) & 0x7f - value >>= 7 - } - - // emit without continuation bit - e.data = append(e.data, b) - return e -} - -func (e *BytesEncoder) RequestID(value ScRequestID) *BytesEncoder { - return e.FixedBytes(value.Bytes(), uint32(TypeSizes[TYPE_REQUEST_ID])) -} - -func (e *BytesEncoder) String(value string) *BytesEncoder { - return e.Bytes([]byte(value)) -} - -func (e *BytesEncoder) Uint8(value uint8) *BytesEncoder { - e.data = append(e.data, value) - return e -} - -func (e *BytesEncoder) Uint16(value uint16) *BytesEncoder { - return e.Uint64(uint64(value)) -} - -func (e *BytesEncoder) Uint32(value uint32) *BytesEncoder { - return e.Uint64(uint64(value)) -} - -// vlu (variable length unsigned) encoder -func (e *BytesEncoder) Uint64(value uint64) *BytesEncoder { - // first group of 7 bits - b := byte(value) - value >>= 7 - - // keep shifting until all bits are done - for value != 0 { - // emit with continuation bit - e.data = append(e.data, b|0x80) - - // next group of 7 bits - b = byte(value) - value >>= 7 - } - - // emit without continuation bit - e.data = append(e.data, b) - return e -} diff --git a/packages/vm/wasmlib/go/wasmlib/context.go b/packages/vm/wasmlib/go/wasmlib/context.go index e3fd8571ad..f0afc48c23 100644 --- a/packages/vm/wasmlib/go/wasmlib/context.go +++ b/packages/vm/wasmlib/go/wasmlib/context.go @@ -6,375 +6,52 @@ package wasmlib import ( - "encoding/binary" - "strconv" + "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" ) -// used to retrieve any information that is related to colored token balances -type ScBalances struct { - balances ScImmutableMap -} - -// retrieve the balance for the specified token color -func (ctx ScBalances) Balance(color ScColor) int64 { - return ctx.balances.GetInt64(color).Value() -} - -// retrieve a list of all token colors that have a non-zero balance -func (ctx ScBalances) Colors() ScImmutableColorArray { - return ctx.balances.GetColorArray(KeyColor) -} - // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -type ScTransfers struct { - transfers ScMutableMap -} - -// create a new transfers object ready to add token transfers -func NewScTransfers() ScTransfers { - return ScTransfers{transfers: *NewScMutableMap()} -} - -// create a new transfers object from a balances object -func NewScTransfersFromBalances(balances ScBalances) ScTransfers { - transfers := NewScTransfers() - colors := balances.Colors() - length := colors.Length() - for i := int32(0); i < length; i++ { - color := colors.GetColor(i).Value() - transfers.Set(color, balances.Balance(color)) - } - return transfers -} - -// create a new transfers object and initialize it with the specified amount of iotas -func NewScTransferIotas(amount int64) ScTransfers { - return NewScTransfer(IOTA, amount) -} - -// create a new transfers object and initialize it with the specified token transfer -func NewScTransfer(color ScColor, amount int64) ScTransfers { - transfer := NewScTransfers() - transfer.Set(color, amount) - return transfer -} - -// set the specified colored token transfer in the transfers object -// note that this will overwrite any previous amount for the specified color -func (ctx ScTransfers) Set(color ScColor, amount int64) { - ctx.transfers.GetInt64(color).SetValue(amount) -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -type ScUtility struct { - utility ScMutableMap -} - -// decodes the specified base58-encoded string value to its original bytes -func (ctx ScUtility) Base58Decode(value string) []byte { - return ctx.utility.CallFunc(KeyBase58Decode, []byte(value)) -} - -// encodes the specified bytes to a base-58-encoded string -func (ctx ScUtility) Base58Encode(value []byte) string { - return string(ctx.utility.CallFunc(KeyBase58Encode, value)) -} - -func (ctx ScUtility) BlsAddressFromPubKey(pubKey []byte) ScAddress { - result := ctx.utility.CallFunc(KeyBlsAddress, pubKey) - return NewScAddressFromBytes(result) -} - -func (ctx ScUtility) BlsAggregateSignatures(pubKeys, sigs [][]byte) ([]byte, []byte) { - encode := NewBytesEncoder() - encode.Int32(int32(len(pubKeys))) - for _, pubKey := range pubKeys { - encode.Bytes(pubKey) - } - encode.Int32(int32(len(sigs))) - for _, sig := range sigs { - encode.Bytes(sig) - } - result := ctx.utility.CallFunc(KeyBlsAggregate, encode.Data()) - decode := NewBytesDecoder(result) - return decode.Bytes(), decode.Bytes() -} - -func (ctx ScUtility) BlsValidSignature(data, pubKey, signature []byte) bool { - encode := NewBytesEncoder().Bytes(data).Bytes(pubKey).Bytes(signature) - result := ctx.utility.CallFunc(KeyBlsValid, encode.Data()) - return len(result) != 0 -} - -func (ctx ScUtility) Ed25519AddressFromPubKey(pubKey []byte) ScAddress { - result := ctx.utility.CallFunc(KeyEd25519Address, pubKey) - return NewScAddressFromBytes(result) -} - -func (ctx ScUtility) Ed25519ValidSignature(data, pubKey, signature []byte) bool { - encode := NewBytesEncoder().Bytes(data).Bytes(pubKey).Bytes(signature) - result := ctx.utility.CallFunc(KeyEd25519Valid, encode.Data()) - return len(result) != 0 -} - -// hashes the specified value bytes using blake2b hashing and returns the resulting 32-byte hash -func (ctx ScUtility) HashBlake2b(value []byte) ScHash { - result := ctx.utility.CallFunc(KeyHashBlake2b, value) - return NewScHashFromBytes(result) -} - -// hashes the specified value bytes using sha3 hashing and returns the resulting 32-byte hash -func (ctx ScUtility) HashSha3(value []byte) ScHash { - result := ctx.utility.CallFunc(KeyHashSha3, value) - return NewScHashFromBytes(result) -} - -// hashes the specified value bytes using blake2b hashing and returns the resulting 32-byte hash -func (ctx ScUtility) Hname(value string) ScHname { - result := ctx.utility.CallFunc(KeyHname, []byte(value)) - return NewScHnameFromBytes(result) -} - -// converts an integer to its string representation -func (ctx ScUtility) String(value int64) string { - return strconv.FormatInt(value, 10) -} - // wrapper for simplified use by hashtypes func base58Encode(bytes []byte) string { - return ScFuncContext{}.Utility().Base58Encode(bytes) -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -// shared interface part of ScFuncContext and ScViewContext -type ScBaseContext struct{} - -// retrieve the agent id of this contract account -func (ctx ScBaseContext) AccountID() ScAgentID { - return Root.GetAgentID(KeyAccountID).Value() -} - -// access the current balances for all token colors -func (ctx ScBaseContext) Balances() ScBalances { - return ScBalances{Root.GetMap(KeyBalances).Immutable()} -} - -// retrieve the chain id of the chain this contract lives on -func (ctx ScBaseContext) ChainID() ScChainID { - return Root.GetChainID(KeyChainID).Value() -} - -// retrieve the agent id of the owner of the chain this contract lives on -func (ctx ScBaseContext) ChainOwnerID() ScAgentID { - return Root.GetAgentID(KeyChainOwnerID).Value() -} - -// retrieve the hname of this contract -func (ctx ScBaseContext) Contract() ScHname { - return Root.GetHname(KeyContract).Value() -} - -// retrieve the agent id of the creator of this contract -func (ctx ScBaseContext) ContractCreator() ScAgentID { - return Root.GetAgentID(KeyContractCreator).Value() -} - -// logs informational text message -func (ctx ScBaseContext) Log(text string) { - Log(text) -} - -// logs error text message and then panics -func (ctx ScBaseContext) Panic(text string) { - Panic(text) -} - -// retrieve parameters passed to the smart contract function that was called -func (ctx ScBaseContext) Params() ScImmutableMap { - return Root.GetMap(KeyParams).Immutable() -} - -// panics if condition is not satisfied -func (ctx ScBaseContext) Require(cond bool, msg string) { - if !cond { - Panic(msg) - } -} - -// any results returned by the smart contract function call are returned here -func (ctx ScBaseContext) Results() ScMutableMap { - return Root.GetMap(KeyResults) -} - -// deterministic time stamp fixed at the moment of calling the smart contract -func (ctx ScBaseContext) Timestamp() int64 { - return Root.GetInt64(KeyTimestamp).Value() -} - -// logs debugging trace text message -func (ctx ScBaseContext) Trace(text string) { - Trace(text) -} - -// access diverse utility functions -func (ctx ScBaseContext) Utility() ScUtility { - return ScUtility{Root.GetMap(KeyUtility)} + return ScSandboxUtils{}.Base58Encode(bytes) } // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -// smart contract interface with mutable access to state +// smart contract func sandbox interface type ScFuncContext struct { - ScBaseContext + ScSandboxFunc } var _ ScFuncCallContext = &ScFuncContext{} -// calls a smart contract function -func (ctx ScFuncContext) Call(hContract, hFunction ScHname, params *ScMutableMap, transfer *ScTransfers) ScImmutableMap { - encode := NewBytesEncoder() - encode.Hname(hContract) - encode.Hname(hFunction) - if params != nil { - encode.Int32(params.objID) - } else { - encode.Int32(0) - } - if transfer != nil { - encode.Int32(transfer.transfers.objID) - } else { - encode.Int32(0) - } - Root.GetBytes(KeyCall).SetValue(encode.Data()) - return Root.GetMap(KeyReturn).Immutable() -} - -// retrieve the agent id of the caller of the smart contract -func (ctx ScFuncContext) Caller() ScAgentID { - return Root.GetAgentID(KeyCaller).Value() -} - -// deploys a smart contract -func (ctx ScFuncContext) Deploy(programHash ScHash, name, description string, params *ScMutableMap) { - encode := NewBytesEncoder() - encode.Hash(programHash) - encode.String(name) - encode.String(description) - if params != nil { - encode.Int32(params.objID) - } else { - encode.Int32(0) - } - Root.GetBytes(KeyDeploy).SetValue(encode.Data()) -} - -// signals an event on the node that external entities can subscribe to -func (ctx ScFuncContext) Event(text string) { - Root.GetString(KeyEvent).SetValue(text) -} - func (ctx ScFuncContext) Host() ScHost { return nil } -// access the incoming balances for all token colors -func (ctx ScFuncContext) Incoming() ScBalances { - return ScBalances{Root.GetMap(KeyIncoming).Immutable()} -} - func (ctx ScFuncContext) InitFuncCallContext() { } func (ctx ScFuncContext) InitViewCallContext() { } -// retrieve the tokens that were minted in this transaction -func (ctx ScFuncContext) Minted() ScBalances { - return ScBalances{Root.GetMap(KeyMinted).Immutable()} -} - -// (delayed) posts a smart contract function -func (ctx ScFuncContext) Post(chainID ScChainID, hContract, hFunction ScHname, params *ScMutableMap, transfer ScTransfers, delay int32) { - encode := NewBytesEncoder() - encode.ChainID(chainID) - encode.Hname(hContract) - encode.Hname(hFunction) - if params != nil { - encode.Int32(params.objID) - } else { - encode.Int32(0) - } - encode.Int32(transfer.transfers.objID) - encode.Int32(delay) - Root.GetBytes(KeyPost).SetValue(encode.Data()) -} - -// TODO expose Entropy function - -// generates a random value from 0 to max (exclusive max) using a deterministic RNG -func (ctx ScFuncContext) Random(max int64) int64 { - if max == 0 { - ctx.Panic("random: max parameter should be non-zero") - } - state := ScMutableMap{objID: OBJ_ID_STATE} - rnd := state.GetBytes(KeyRandom) - seed := rnd.Value() - if len(seed) == 0 { - seed = Root.GetBytes(KeyRandom).Value() - } - rnd.SetValue(ctx.Utility().HashSha3(seed).Bytes()) - return int64(binary.LittleEndian.Uint64(seed[:8]) % uint64(max)) -} - -// retrieve the request id of this transaction -func (ctx ScFuncContext) RequestID() ScRequestID { - return Root.GetRequestID(KeyRequestID).Value() -} - -// access to mutable state storage -func (ctx ScFuncContext) State() ScMutableMap { - return Root.GetMap(KeyState) +// TODO deprecated +func (ctx ScFuncContext) Incoming() ScBalances { + return ctx.IncomingTransfer() } -// transfer colored token amounts to the specified Tangle ledger address -func (ctx ScFuncContext) TransferToAddress(address ScAddress, transfer ScTransfers) { - transfers := Root.GetMapArray(KeyTransfers) - tx := transfers.GetMap(transfers.Length()) - tx.GetAddress(KeyAddress).SetValue(address) - tx.GetInt32(KeyBalances).SetValue(transfer.transfers.objID) +func (ctx ScFuncContext) TransferToAddress(address wasmtypes.ScAddress, transfer ScTransfers) { + ctx.Send(address, transfer) } // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -// smart contract interface with immutable access to state +// smart contract view sandbox interface type ScViewContext struct { - ScBaseContext + ScSandbox } var _ ScViewCallContext = &ScViewContext{} -// calls a smart contract function -func (ctx ScViewContext) Call(contract, function ScHname, params *ScMutableMap) ScImmutableMap { - encode := NewBytesEncoder() - encode.Hname(contract) - encode.Hname(function) - if params != nil { - encode.Int32(params.objID) - } else { - encode.Int32(0) - } - encode.Int32(0) - Root.GetBytes(KeyCall).SetValue(encode.Data()) - return Root.GetMap(KeyReturn).Immutable() -} - func (ctx ScViewContext) InitViewCallContext() { } - -// access to immutable state storage -func (ctx ScViewContext) State() ScImmutableMap { - return Root.GetMap(KeyState).Immutable() -} diff --git a/packages/vm/wasmlib/go/wasmlib/contract.go b/packages/vm/wasmlib/go/wasmlib/contract.go index 5fcb4a8637..cf90303977 100644 --- a/packages/vm/wasmlib/go/wasmlib/contract.go +++ b/packages/vm/wasmlib/go/wasmlib/contract.go @@ -1,6 +1,15 @@ +// Copyright 2020 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + package wasmlib +import ( + "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmrequests" + "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" +) + type ScFuncCallContext interface { + ChainID() wasmtypes.ScChainID InitFuncCallContext() } @@ -11,67 +20,65 @@ type ScViewCallContext interface { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ type ScView struct { - hContract ScHname - hFunction ScHname - paramsID *int32 - resultsID *int32 + hContract wasmtypes.ScHname + hFunction wasmtypes.ScHname + params ScDict + resultsProxy *wasmtypes.Proxy } -func NewScView(ctx ScViewCallContext, hContract, hFunction ScHname) *ScView { +func NewScView(ctx ScViewCallContext, hContract, hFunction wasmtypes.ScHname) *ScView { ctx.InitViewCallContext() - return &ScView{hContract, hFunction, nil, nil} + v := new(ScView) + v.initView(hContract, hFunction) + return v } -func (v *ScView) SetPtrs(paramsID, resultsID *int32) { - v.paramsID = paramsID - v.resultsID = resultsID - if paramsID != nil { - *paramsID = NewScMutableMap().MapID() - } +func NewCallParamsProxy(v *ScView) wasmtypes.Proxy { + v.params = NewScDict() + return wasmtypes.NewProxy(v.params) +} + +func NewCallResultsProxy(v *ScView, resultsProxy *wasmtypes.Proxy) { + v.resultsProxy = resultsProxy } func (v *ScView) Call() { - v.call(0) -} - -func (v *ScView) call(transferID int32) { - encode := NewBytesEncoder() - encode.Hname(v.hContract) - encode.Hname(v.hFunction) - encode.Int32(paramsID(v.paramsID)) - encode.Int32(transferID) - Root.GetBytes(KeyCall).SetValue(encode.Data()) - if v.resultsID != nil { - *v.resultsID = GetObjectID(OBJ_ID_ROOT, KeyReturn, TYPE_MAP) + v.call(nil) +} + +func (v *ScView) call(transfer ScAssets) { + req := wasmrequests.CallRequest{ + Contract: v.hContract, + Function: v.hFunction, + Params: v.params.Bytes(), + Transfer: transfer.Bytes(), + } + res := Sandbox(FnCall, req.Bytes()) + if v.resultsProxy != nil { + *v.resultsProxy = wasmtypes.NewProxy(NewScDictFromBytes(res)) } } -func (v *ScView) OfContract(hContract ScHname) *ScView { +func (v *ScView) initView(hContract, hFunction wasmtypes.ScHname) { v.hContract = hContract - return v + v.hFunction = hFunction } -func paramsID(id *int32) int32 { - if id == nil { - return 0 - } - return *id +func (v *ScView) OfContract(hContract wasmtypes.ScHname) *ScView { + v.hContract = hContract + return v } // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ type ScInitFunc struct { ScView - keys []Key - indexes []Key32 - oldIndexes []Key32 - host ScHost + host ScHost } -func NewScInitFunc(ctx ScFuncCallContext, hContract, hFunction ScHname, keys []Key, indexes []Key32) *ScInitFunc { - f := &ScInitFunc{} - f.hContract = hContract - f.hFunction = hFunction +func NewScInitFunc(ctx ScFuncCallContext, hContract, hFunction wasmtypes.ScHname) *ScInitFunc { + f := new(ScInitFunc) + f.initView(hContract, hFunction) if ctx != nil { ctx.InitFuncCallContext() return f @@ -85,12 +92,6 @@ func NewScInitFunc(ctx ScFuncCallContext, hContract, hFunction ScHname, keys []K // just enough to gather the parameter data and pass it correctly to // solo's contract deployment function, which in turn passes it to the // contract's init() function - f.keys = keys - f.oldIndexes = append(f.oldIndexes, indexes...) - f.indexes = indexes - for i := 0; i < len(indexes); i++ { - indexes[i] = Key32(i) - } f.host = ConnectHost(NewInitHost()) return f } @@ -99,22 +100,17 @@ func (f *ScInitFunc) Call() { Panic("cannot call init") } -func (f *ScInitFunc) OfContract(hContract ScHname) *ScInitFunc { +func (f *ScInitFunc) OfContract(hContract wasmtypes.ScHname) *ScInitFunc { f.hContract = hContract return f } func (f *ScInitFunc) Params() []interface{} { - if f.keys == nil { - Panic("cannot call params") - } - var params []interface{} - for k, v := range host.(*InitHost).params { - params = append(params, string(f.keys[k])) + for k, v := range f.params { + params = append(params, k) params = append(params, v) } - copy(f.indexes, f.oldIndexes) ConnectHost(f.host) return params } @@ -123,55 +119,62 @@ func (f *ScInitFunc) Params() []interface{} { type ScFunc struct { ScView - delay int32 - transferID int32 + ctx ScFuncCallContext + delay uint32 + transfer ScAssets } -func NewScFunc(ctx ScFuncCallContext, hContract, hFunction ScHname) *ScFunc { +func NewScFunc(ctx ScFuncCallContext, hContract, hFunction wasmtypes.ScHname) *ScFunc { ctx.InitFuncCallContext() - return &ScFunc{ScView{hContract, hFunction, nil, nil}, 0, 0} + f := new(ScFunc) + f.ctx = ctx + f.initView(hContract, hFunction) + return f } func (f *ScFunc) Call() { if f.delay != 0 { Panic("cannot delay a call") } - f.call(f.transferID) + f.call(f.transfer) } -func (f *ScFunc) Delay(seconds int32) *ScFunc { +func (f *ScFunc) Delay(seconds uint32) *ScFunc { f.delay = seconds return f } -func (f *ScFunc) OfContract(hContract ScHname) *ScFunc { +func (f *ScFunc) OfContract(hContract wasmtypes.ScHname) *ScFunc { f.hContract = hContract return f } func (f *ScFunc) Post() { - f.PostToChain(Root.GetChainID(KeyChainID).Value()) -} - -func (f *ScFunc) PostToChain(chainID ScChainID) { - encode := NewBytesEncoder() - encode.ChainID(chainID) - encode.Hname(f.hContract) - encode.Hname(f.hFunction) - encode.Int32(paramsID(f.paramsID)) - encode.Int32(f.transferID) - encode.Int32(f.delay) - Root.GetBytes(KeyPost).SetValue(encode.Data()) - if f.resultsID != nil { - *f.resultsID = GetObjectID(OBJ_ID_ROOT, KeyReturn, TYPE_MAP) + f.PostToChain(f.ctx.ChainID()) +} + +func (f *ScFunc) PostToChain(chainID wasmtypes.ScChainID) { + req := wasmrequests.PostRequest{ + ChainID: chainID, + Contract: f.hContract, + Function: f.hFunction, + Params: f.params.Bytes(), + Transfer: f.transfer.Bytes(), + Delay: f.delay, + } + res := Sandbox(FnPost, req.Bytes()) + if f.resultsProxy != nil { + *f.resultsProxy = wasmtypes.NewProxy(NewScDictFromBytes(res)) } } func (f *ScFunc) Transfer(transfer ScTransfers) *ScFunc { - f.transferID = transfer.transfers.MapID() + f.transfer = ScAssets(transfer) return f } -func (f *ScFunc) TransferIotas(amount int64) *ScFunc { - return f.Transfer(NewScTransferIotas(amount)) +func (f *ScFunc) TransferIotas(amount uint64) *ScFunc { + f.transfer = make(ScAssets) + f.transfer[wasmtypes.IOTA] = amount + return f } diff --git a/packages/vm/wasmlib/go/wasmlib/coreaccounts/consts.go b/packages/vm/wasmlib/go/wasmlib/coreaccounts/consts.go index 08325d7f74..2e98e2cbb3 100644 --- a/packages/vm/wasmlib/go/wasmlib/coreaccounts/consts.go +++ b/packages/vm/wasmlib/go/wasmlib/coreaccounts/consts.go @@ -7,12 +7,12 @@ package coreaccounts -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" +import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" const ( ScName = "accounts" ScDescription = "Core chain account ledger contract" - HScName = wasmlib.ScHname(0x3c4b5e02) + HScName = wasmtypes.ScHname(0x3c4b5e02) ) const ( @@ -38,11 +38,11 @@ const ( ) const ( - HFuncDeposit = wasmlib.ScHname(0xbdc9102d) - HFuncHarvest = wasmlib.ScHname(0x7b40efbd) - HFuncWithdraw = wasmlib.ScHname(0x9dcc0f41) - HViewAccounts = wasmlib.ScHname(0x3c4b5e02) - HViewBalance = wasmlib.ScHname(0x84168cb4) - HViewGetAccountNonce = wasmlib.ScHname(0x529d7df9) - HViewTotalAssets = wasmlib.ScHname(0xfab0f8d2) + HFuncDeposit = wasmtypes.ScHname(0xbdc9102d) + HFuncHarvest = wasmtypes.ScHname(0x7b40efbd) + HFuncWithdraw = wasmtypes.ScHname(0x9dcc0f41) + HViewAccounts = wasmtypes.ScHname(0x3c4b5e02) + HViewBalance = wasmtypes.ScHname(0x84168cb4) + HViewGetAccountNonce = wasmtypes.ScHname(0x529d7df9) + HViewTotalAssets = wasmtypes.ScHname(0xfab0f8d2) ) diff --git a/packages/vm/wasmlib/go/wasmlib/coreaccounts/contract.go b/packages/vm/wasmlib/go/wasmlib/coreaccounts/contract.go index 849636826b..fdb8764ea8 100644 --- a/packages/vm/wasmlib/go/wasmlib/coreaccounts/contract.go +++ b/packages/vm/wasmlib/go/wasmlib/coreaccounts/contract.go @@ -51,13 +51,13 @@ var ScFuncs Funcs func (sc Funcs) Deposit(ctx wasmlib.ScFuncCallContext) *DepositCall { f := &DepositCall{Func: wasmlib.NewScFunc(ctx, HScName, HFuncDeposit)} - f.Func.SetPtrs(&f.Params.id, nil) + f.Params.proxy = wasmlib.NewCallParamsProxy(&f.Func.ScView) return f } func (sc Funcs) Harvest(ctx wasmlib.ScFuncCallContext) *HarvestCall { f := &HarvestCall{Func: wasmlib.NewScFunc(ctx, HScName, HFuncHarvest)} - f.Func.SetPtrs(&f.Params.id, nil) + f.Params.proxy = wasmlib.NewCallParamsProxy(&f.Func.ScView) return f } @@ -67,25 +67,27 @@ func (sc Funcs) Withdraw(ctx wasmlib.ScFuncCallContext) *WithdrawCall { func (sc Funcs) Accounts(ctx wasmlib.ScViewCallContext) *AccountsCall { f := &AccountsCall{Func: wasmlib.NewScView(ctx, HScName, HViewAccounts)} - f.Func.SetPtrs(nil, &f.Results.id) + wasmlib.NewCallResultsProxy(f.Func, &f.Results.proxy) return f } func (sc Funcs) Balance(ctx wasmlib.ScViewCallContext) *BalanceCall { f := &BalanceCall{Func: wasmlib.NewScView(ctx, HScName, HViewBalance)} - f.Func.SetPtrs(&f.Params.id, &f.Results.id) + f.Params.proxy = wasmlib.NewCallParamsProxy(f.Func) + wasmlib.NewCallResultsProxy(f.Func, &f.Results.proxy) return f } func (sc Funcs) GetAccountNonce(ctx wasmlib.ScViewCallContext) *GetAccountNonceCall { f := &GetAccountNonceCall{Func: wasmlib.NewScView(ctx, HScName, HViewGetAccountNonce)} - f.Func.SetPtrs(&f.Params.id, &f.Results.id) + f.Params.proxy = wasmlib.NewCallParamsProxy(f.Func) + wasmlib.NewCallResultsProxy(f.Func, &f.Results.proxy) return f } func (sc Funcs) TotalAssets(ctx wasmlib.ScViewCallContext) *TotalAssetsCall { f := &TotalAssetsCall{Func: wasmlib.NewScView(ctx, HScName, HViewTotalAssets)} - f.Func.SetPtrs(nil, &f.Results.id) + wasmlib.NewCallResultsProxy(f.Func, &f.Results.proxy) return f } diff --git a/packages/vm/wasmlib/go/wasmlib/coreaccounts/params.go b/packages/vm/wasmlib/go/wasmlib/coreaccounts/params.go index 9c17692cec..afe5b847fb 100644 --- a/packages/vm/wasmlib/go/wasmlib/coreaccounts/params.go +++ b/packages/vm/wasmlib/go/wasmlib/coreaccounts/params.go @@ -7,76 +7,76 @@ package coreaccounts -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" +import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" type ImmutableDepositParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableDepositParams) AgentID() wasmlib.ScImmutableAgentID { - return wasmlib.NewScImmutableAgentID(s.id, wasmlib.KeyID(ParamAgentID)) +func (s ImmutableDepositParams) AgentID() wasmtypes.ScImmutableAgentID { + return wasmtypes.NewScImmutableAgentID(s.proxy.Root(ParamAgentID)) } type MutableDepositParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableDepositParams) AgentID() wasmlib.ScMutableAgentID { - return wasmlib.NewScMutableAgentID(s.id, wasmlib.KeyID(ParamAgentID)) +func (s MutableDepositParams) AgentID() wasmtypes.ScMutableAgentID { + return wasmtypes.NewScMutableAgentID(s.proxy.Root(ParamAgentID)) } type ImmutableHarvestParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableHarvestParams) WithdrawAmount() wasmlib.ScImmutableInt64 { - return wasmlib.NewScImmutableInt64(s.id, wasmlib.KeyID(ParamWithdrawAmount)) +func (s ImmutableHarvestParams) WithdrawAmount() wasmtypes.ScImmutableInt64 { + return wasmtypes.NewScImmutableInt64(s.proxy.Root(ParamWithdrawAmount)) } -func (s ImmutableHarvestParams) WithdrawColor() wasmlib.ScImmutableColor { - return wasmlib.NewScImmutableColor(s.id, wasmlib.KeyID(ParamWithdrawColor)) +func (s ImmutableHarvestParams) WithdrawColor() wasmtypes.ScImmutableColor { + return wasmtypes.NewScImmutableColor(s.proxy.Root(ParamWithdrawColor)) } type MutableHarvestParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableHarvestParams) WithdrawAmount() wasmlib.ScMutableInt64 { - return wasmlib.NewScMutableInt64(s.id, wasmlib.KeyID(ParamWithdrawAmount)) +func (s MutableHarvestParams) WithdrawAmount() wasmtypes.ScMutableInt64 { + return wasmtypes.NewScMutableInt64(s.proxy.Root(ParamWithdrawAmount)) } -func (s MutableHarvestParams) WithdrawColor() wasmlib.ScMutableColor { - return wasmlib.NewScMutableColor(s.id, wasmlib.KeyID(ParamWithdrawColor)) +func (s MutableHarvestParams) WithdrawColor() wasmtypes.ScMutableColor { + return wasmtypes.NewScMutableColor(s.proxy.Root(ParamWithdrawColor)) } type ImmutableBalanceParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableBalanceParams) AgentID() wasmlib.ScImmutableAgentID { - return wasmlib.NewScImmutableAgentID(s.id, wasmlib.KeyID(ParamAgentID)) +func (s ImmutableBalanceParams) AgentID() wasmtypes.ScImmutableAgentID { + return wasmtypes.NewScImmutableAgentID(s.proxy.Root(ParamAgentID)) } type MutableBalanceParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableBalanceParams) AgentID() wasmlib.ScMutableAgentID { - return wasmlib.NewScMutableAgentID(s.id, wasmlib.KeyID(ParamAgentID)) +func (s MutableBalanceParams) AgentID() wasmtypes.ScMutableAgentID { + return wasmtypes.NewScMutableAgentID(s.proxy.Root(ParamAgentID)) } type ImmutableGetAccountNonceParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableGetAccountNonceParams) AgentID() wasmlib.ScImmutableAgentID { - return wasmlib.NewScImmutableAgentID(s.id, wasmlib.KeyID(ParamAgentID)) +func (s ImmutableGetAccountNonceParams) AgentID() wasmtypes.ScImmutableAgentID { + return wasmtypes.NewScImmutableAgentID(s.proxy.Root(ParamAgentID)) } type MutableGetAccountNonceParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableGetAccountNonceParams) AgentID() wasmlib.ScMutableAgentID { - return wasmlib.NewScMutableAgentID(s.id, wasmlib.KeyID(ParamAgentID)) +func (s MutableGetAccountNonceParams) AgentID() wasmtypes.ScMutableAgentID { + return wasmtypes.NewScMutableAgentID(s.proxy.Root(ParamAgentID)) } diff --git a/packages/vm/wasmlib/go/wasmlib/coreaccounts/results.go b/packages/vm/wasmlib/go/wasmlib/coreaccounts/results.go index 2dd3a316ec..64f6eb93df 100644 --- a/packages/vm/wasmlib/go/wasmlib/coreaccounts/results.go +++ b/packages/vm/wasmlib/go/wasmlib/coreaccounts/results.go @@ -7,108 +7,114 @@ package coreaccounts -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" +import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" type MapAgentIDToImmutableBytes struct { - objID int32 + proxy wasmtypes.Proxy } -func (m MapAgentIDToImmutableBytes) GetBytes(key wasmlib.ScAgentID) wasmlib.ScImmutableBytes { - return wasmlib.NewScImmutableBytes(m.objID, key.KeyID()) +func (m MapAgentIDToImmutableBytes) GetBytes(key wasmtypes.ScAgentID) wasmtypes.ScImmutableBytes { + return wasmtypes.NewScImmutableBytes(m.proxy.Key(key.Bytes())) } type ImmutableAccountsResults struct { - id int32 + proxy wasmtypes.Proxy } func (s ImmutableAccountsResults) Agents() MapAgentIDToImmutableBytes { - return MapAgentIDToImmutableBytes{objID: s.id} + //nolint:gosimple + return MapAgentIDToImmutableBytes{proxy: s.proxy} } type MapAgentIDToMutableBytes struct { - objID int32 + proxy wasmtypes.Proxy } func (m MapAgentIDToMutableBytes) Clear() { - wasmlib.Clear(m.objID) + m.proxy.ClearMap() } -func (m MapAgentIDToMutableBytes) GetBytes(key wasmlib.ScAgentID) wasmlib.ScMutableBytes { - return wasmlib.NewScMutableBytes(m.objID, key.KeyID()) +func (m MapAgentIDToMutableBytes) GetBytes(key wasmtypes.ScAgentID) wasmtypes.ScMutableBytes { + return wasmtypes.NewScMutableBytes(m.proxy.Key(key.Bytes())) } type MutableAccountsResults struct { - id int32 + proxy wasmtypes.Proxy } func (s MutableAccountsResults) Agents() MapAgentIDToMutableBytes { - return MapAgentIDToMutableBytes{objID: s.id} + //nolint:gosimple + return MapAgentIDToMutableBytes{proxy: s.proxy} } type MapColorToImmutableInt64 struct { - objID int32 + proxy wasmtypes.Proxy } -func (m MapColorToImmutableInt64) GetInt64(key wasmlib.ScColor) wasmlib.ScImmutableInt64 { - return wasmlib.NewScImmutableInt64(m.objID, key.KeyID()) +func (m MapColorToImmutableInt64) GetInt64(key wasmtypes.ScColor) wasmtypes.ScImmutableInt64 { + return wasmtypes.NewScImmutableInt64(m.proxy.Key(key.Bytes())) } type ImmutableBalanceResults struct { - id int32 + proxy wasmtypes.Proxy } func (s ImmutableBalanceResults) Balances() MapColorToImmutableInt64 { - return MapColorToImmutableInt64{objID: s.id} + //nolint:gosimple + return MapColorToImmutableInt64{proxy: s.proxy} } type MapColorToMutableInt64 struct { - objID int32 + proxy wasmtypes.Proxy } func (m MapColorToMutableInt64) Clear() { - wasmlib.Clear(m.objID) + m.proxy.ClearMap() } -func (m MapColorToMutableInt64) GetInt64(key wasmlib.ScColor) wasmlib.ScMutableInt64 { - return wasmlib.NewScMutableInt64(m.objID, key.KeyID()) +func (m MapColorToMutableInt64) GetInt64(key wasmtypes.ScColor) wasmtypes.ScMutableInt64 { + return wasmtypes.NewScMutableInt64(m.proxy.Key(key.Bytes())) } type MutableBalanceResults struct { - id int32 + proxy wasmtypes.Proxy } func (s MutableBalanceResults) Balances() MapColorToMutableInt64 { - return MapColorToMutableInt64{objID: s.id} + //nolint:gosimple + return MapColorToMutableInt64{proxy: s.proxy} } type ImmutableGetAccountNonceResults struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableGetAccountNonceResults) AccountNonce() wasmlib.ScImmutableInt64 { - return wasmlib.NewScImmutableInt64(s.id, wasmlib.KeyID(ResultAccountNonce)) +func (s ImmutableGetAccountNonceResults) AccountNonce() wasmtypes.ScImmutableInt64 { + return wasmtypes.NewScImmutableInt64(s.proxy.Root(ResultAccountNonce)) } type MutableGetAccountNonceResults struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableGetAccountNonceResults) AccountNonce() wasmlib.ScMutableInt64 { - return wasmlib.NewScMutableInt64(s.id, wasmlib.KeyID(ResultAccountNonce)) +func (s MutableGetAccountNonceResults) AccountNonce() wasmtypes.ScMutableInt64 { + return wasmtypes.NewScMutableInt64(s.proxy.Root(ResultAccountNonce)) } type ImmutableTotalAssetsResults struct { - id int32 + proxy wasmtypes.Proxy } func (s ImmutableTotalAssetsResults) Balances() MapColorToImmutableInt64 { - return MapColorToImmutableInt64{objID: s.id} + //nolint:gosimple + return MapColorToImmutableInt64{proxy: s.proxy} } type MutableTotalAssetsResults struct { - id int32 + proxy wasmtypes.Proxy } func (s MutableTotalAssetsResults) Balances() MapColorToMutableInt64 { - return MapColorToMutableInt64{objID: s.id} + //nolint:gosimple + return MapColorToMutableInt64{proxy: s.proxy} } diff --git a/packages/vm/wasmlib/go/wasmlib/coreblob/consts.go b/packages/vm/wasmlib/go/wasmlib/coreblob/consts.go index 34e266cf68..2378a1b724 100644 --- a/packages/vm/wasmlib/go/wasmlib/coreblob/consts.go +++ b/packages/vm/wasmlib/go/wasmlib/coreblob/consts.go @@ -7,12 +7,12 @@ package coreblob -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" +import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" const ( ScName = "blob" ScDescription = "Core blob contract" - HScName = wasmlib.ScHname(0xfd91bc63) + HScName = wasmtypes.ScHname(0xfd91bc63) ) const ( @@ -35,8 +35,8 @@ const ( ) const ( - HFuncStoreBlob = wasmlib.ScHname(0xddd4c281) - HViewGetBlobField = wasmlib.ScHname(0x1f448130) - HViewGetBlobInfo = wasmlib.ScHname(0xfde4ab46) - HViewListBlobs = wasmlib.ScHname(0x62ca7990) + HFuncStoreBlob = wasmtypes.ScHname(0xddd4c281) + HViewGetBlobField = wasmtypes.ScHname(0x1f448130) + HViewGetBlobInfo = wasmtypes.ScHname(0xfde4ab46) + HViewListBlobs = wasmtypes.ScHname(0x62ca7990) ) diff --git a/packages/vm/wasmlib/go/wasmlib/coreblob/contract.go b/packages/vm/wasmlib/go/wasmlib/coreblob/contract.go index 57b72f9f2e..8f21673915 100644 --- a/packages/vm/wasmlib/go/wasmlib/coreblob/contract.go +++ b/packages/vm/wasmlib/go/wasmlib/coreblob/contract.go @@ -38,25 +38,28 @@ var ScFuncs Funcs func (sc Funcs) StoreBlob(ctx wasmlib.ScFuncCallContext) *StoreBlobCall { f := &StoreBlobCall{Func: wasmlib.NewScFunc(ctx, HScName, HFuncStoreBlob)} - f.Func.SetPtrs(&f.Params.id, &f.Results.id) + f.Params.proxy = wasmlib.NewCallParamsProxy(&f.Func.ScView) + wasmlib.NewCallResultsProxy(&f.Func.ScView, &f.Results.proxy) return f } func (sc Funcs) GetBlobField(ctx wasmlib.ScViewCallContext) *GetBlobFieldCall { f := &GetBlobFieldCall{Func: wasmlib.NewScView(ctx, HScName, HViewGetBlobField)} - f.Func.SetPtrs(&f.Params.id, &f.Results.id) + f.Params.proxy = wasmlib.NewCallParamsProxy(f.Func) + wasmlib.NewCallResultsProxy(f.Func, &f.Results.proxy) return f } func (sc Funcs) GetBlobInfo(ctx wasmlib.ScViewCallContext) *GetBlobInfoCall { f := &GetBlobInfoCall{Func: wasmlib.NewScView(ctx, HScName, HViewGetBlobInfo)} - f.Func.SetPtrs(&f.Params.id, &f.Results.id) + f.Params.proxy = wasmlib.NewCallParamsProxy(f.Func) + wasmlib.NewCallResultsProxy(f.Func, &f.Results.proxy) return f } func (sc Funcs) ListBlobs(ctx wasmlib.ScViewCallContext) *ListBlobsCall { f := &ListBlobsCall{Func: wasmlib.NewScView(ctx, HScName, HViewListBlobs)} - f.Func.SetPtrs(nil, &f.Results.id) + wasmlib.NewCallResultsProxy(f.Func, &f.Results.proxy) return f } diff --git a/packages/vm/wasmlib/go/wasmlib/coreblob/params.go b/packages/vm/wasmlib/go/wasmlib/coreblob/params.go index 4a93f14cdb..33c126a634 100644 --- a/packages/vm/wasmlib/go/wasmlib/coreblob/params.go +++ b/packages/vm/wasmlib/go/wasmlib/coreblob/params.go @@ -7,80 +7,82 @@ package coreblob -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" +import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" type MapStringToImmutableBytes struct { - objID int32 + proxy wasmtypes.Proxy } -func (m MapStringToImmutableBytes) GetBytes(key string) wasmlib.ScImmutableBytes { - return wasmlib.NewScImmutableBytes(m.objID, wasmlib.Key(key).KeyID()) +func (m MapStringToImmutableBytes) GetBytes(key string) wasmtypes.ScImmutableBytes { + return wasmtypes.NewScImmutableBytes(m.proxy.Key(wasmtypes.BytesFromString(key))) } type ImmutableStoreBlobParams struct { - id int32 + proxy wasmtypes.Proxy } func (s ImmutableStoreBlobParams) Blobs() MapStringToImmutableBytes { - return MapStringToImmutableBytes{objID: s.id} + //nolint:gosimple + return MapStringToImmutableBytes{proxy: s.proxy} } type MapStringToMutableBytes struct { - objID int32 + proxy wasmtypes.Proxy } func (m MapStringToMutableBytes) Clear() { - wasmlib.Clear(m.objID) + m.proxy.ClearMap() } -func (m MapStringToMutableBytes) GetBytes(key string) wasmlib.ScMutableBytes { - return wasmlib.NewScMutableBytes(m.objID, wasmlib.Key(key).KeyID()) +func (m MapStringToMutableBytes) GetBytes(key string) wasmtypes.ScMutableBytes { + return wasmtypes.NewScMutableBytes(m.proxy.Key(wasmtypes.BytesFromString(key))) } type MutableStoreBlobParams struct { - id int32 + proxy wasmtypes.Proxy } func (s MutableStoreBlobParams) Blobs() MapStringToMutableBytes { - return MapStringToMutableBytes{objID: s.id} + //nolint:gosimple + return MapStringToMutableBytes{proxy: s.proxy} } type ImmutableGetBlobFieldParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableGetBlobFieldParams) Field() wasmlib.ScImmutableString { - return wasmlib.NewScImmutableString(s.id, wasmlib.KeyID(ParamField)) +func (s ImmutableGetBlobFieldParams) Field() wasmtypes.ScImmutableString { + return wasmtypes.NewScImmutableString(s.proxy.Root(ParamField)) } -func (s ImmutableGetBlobFieldParams) Hash() wasmlib.ScImmutableHash { - return wasmlib.NewScImmutableHash(s.id, wasmlib.KeyID(ParamHash)) +func (s ImmutableGetBlobFieldParams) Hash() wasmtypes.ScImmutableHash { + return wasmtypes.NewScImmutableHash(s.proxy.Root(ParamHash)) } type MutableGetBlobFieldParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableGetBlobFieldParams) Field() wasmlib.ScMutableString { - return wasmlib.NewScMutableString(s.id, wasmlib.KeyID(ParamField)) +func (s MutableGetBlobFieldParams) Field() wasmtypes.ScMutableString { + return wasmtypes.NewScMutableString(s.proxy.Root(ParamField)) } -func (s MutableGetBlobFieldParams) Hash() wasmlib.ScMutableHash { - return wasmlib.NewScMutableHash(s.id, wasmlib.KeyID(ParamHash)) +func (s MutableGetBlobFieldParams) Hash() wasmtypes.ScMutableHash { + return wasmtypes.NewScMutableHash(s.proxy.Root(ParamHash)) } type ImmutableGetBlobInfoParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableGetBlobInfoParams) Hash() wasmlib.ScImmutableHash { - return wasmlib.NewScImmutableHash(s.id, wasmlib.KeyID(ParamHash)) +func (s ImmutableGetBlobInfoParams) Hash() wasmtypes.ScImmutableHash { + return wasmtypes.NewScImmutableHash(s.proxy.Root(ParamHash)) } type MutableGetBlobInfoParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableGetBlobInfoParams) Hash() wasmlib.ScMutableHash { - return wasmlib.NewScMutableHash(s.id, wasmlib.KeyID(ParamHash)) +func (s MutableGetBlobInfoParams) Hash() wasmtypes.ScMutableHash { + return wasmtypes.NewScMutableHash(s.proxy.Root(ParamHash)) } diff --git a/packages/vm/wasmlib/go/wasmlib/coreblob/results.go b/packages/vm/wasmlib/go/wasmlib/coreblob/results.go index 8a24de4245..1868827ad7 100644 --- a/packages/vm/wasmlib/go/wasmlib/coreblob/results.go +++ b/packages/vm/wasmlib/go/wasmlib/coreblob/results.go @@ -7,108 +7,112 @@ package coreblob -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" +import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" type ImmutableStoreBlobResults struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableStoreBlobResults) Hash() wasmlib.ScImmutableHash { - return wasmlib.NewScImmutableHash(s.id, wasmlib.KeyID(ResultHash)) +func (s ImmutableStoreBlobResults) Hash() wasmtypes.ScImmutableHash { + return wasmtypes.NewScImmutableHash(s.proxy.Root(ResultHash)) } type MutableStoreBlobResults struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableStoreBlobResults) Hash() wasmlib.ScMutableHash { - return wasmlib.NewScMutableHash(s.id, wasmlib.KeyID(ResultHash)) +func (s MutableStoreBlobResults) Hash() wasmtypes.ScMutableHash { + return wasmtypes.NewScMutableHash(s.proxy.Root(ResultHash)) } type ImmutableGetBlobFieldResults struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableGetBlobFieldResults) Bytes() wasmlib.ScImmutableBytes { - return wasmlib.NewScImmutableBytes(s.id, wasmlib.KeyID(ResultBytes)) +func (s ImmutableGetBlobFieldResults) Bytes() wasmtypes.ScImmutableBytes { + return wasmtypes.NewScImmutableBytes(s.proxy.Root(ResultBytes)) } type MutableGetBlobFieldResults struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableGetBlobFieldResults) Bytes() wasmlib.ScMutableBytes { - return wasmlib.NewScMutableBytes(s.id, wasmlib.KeyID(ResultBytes)) +func (s MutableGetBlobFieldResults) Bytes() wasmtypes.ScMutableBytes { + return wasmtypes.NewScMutableBytes(s.proxy.Root(ResultBytes)) } type MapStringToImmutableInt32 struct { - objID int32 + proxy wasmtypes.Proxy } -func (m MapStringToImmutableInt32) GetInt32(key string) wasmlib.ScImmutableInt32 { - return wasmlib.NewScImmutableInt32(m.objID, wasmlib.Key(key).KeyID()) +func (m MapStringToImmutableInt32) GetInt32(key string) wasmtypes.ScImmutableInt32 { + return wasmtypes.NewScImmutableInt32(m.proxy.Key(wasmtypes.BytesFromString(key))) } type ImmutableGetBlobInfoResults struct { - id int32 + proxy wasmtypes.Proxy } func (s ImmutableGetBlobInfoResults) BlobSizes() MapStringToImmutableInt32 { - return MapStringToImmutableInt32{objID: s.id} + //nolint:gosimple + return MapStringToImmutableInt32{proxy: s.proxy} } type MapStringToMutableInt32 struct { - objID int32 + proxy wasmtypes.Proxy } func (m MapStringToMutableInt32) Clear() { - wasmlib.Clear(m.objID) + m.proxy.ClearMap() } -func (m MapStringToMutableInt32) GetInt32(key string) wasmlib.ScMutableInt32 { - return wasmlib.NewScMutableInt32(m.objID, wasmlib.Key(key).KeyID()) +func (m MapStringToMutableInt32) GetInt32(key string) wasmtypes.ScMutableInt32 { + return wasmtypes.NewScMutableInt32(m.proxy.Key(wasmtypes.BytesFromString(key))) } type MutableGetBlobInfoResults struct { - id int32 + proxy wasmtypes.Proxy } func (s MutableGetBlobInfoResults) BlobSizes() MapStringToMutableInt32 { - return MapStringToMutableInt32{objID: s.id} + //nolint:gosimple + return MapStringToMutableInt32{proxy: s.proxy} } type MapHashToImmutableInt32 struct { - objID int32 + proxy wasmtypes.Proxy } -func (m MapHashToImmutableInt32) GetInt32(key wasmlib.ScHash) wasmlib.ScImmutableInt32 { - return wasmlib.NewScImmutableInt32(m.objID, key.KeyID()) +func (m MapHashToImmutableInt32) GetInt32(key wasmtypes.ScHash) wasmtypes.ScImmutableInt32 { + return wasmtypes.NewScImmutableInt32(m.proxy.Key(key.Bytes())) } type ImmutableListBlobsResults struct { - id int32 + proxy wasmtypes.Proxy } func (s ImmutableListBlobsResults) BlobSizes() MapHashToImmutableInt32 { - return MapHashToImmutableInt32{objID: s.id} + //nolint:gosimple + return MapHashToImmutableInt32{proxy: s.proxy} } type MapHashToMutableInt32 struct { - objID int32 + proxy wasmtypes.Proxy } func (m MapHashToMutableInt32) Clear() { - wasmlib.Clear(m.objID) + m.proxy.ClearMap() } -func (m MapHashToMutableInt32) GetInt32(key wasmlib.ScHash) wasmlib.ScMutableInt32 { - return wasmlib.NewScMutableInt32(m.objID, key.KeyID()) +func (m MapHashToMutableInt32) GetInt32(key wasmtypes.ScHash) wasmtypes.ScMutableInt32 { + return wasmtypes.NewScMutableInt32(m.proxy.Key(key.Bytes())) } type MutableListBlobsResults struct { - id int32 + proxy wasmtypes.Proxy } func (s MutableListBlobsResults) BlobSizes() MapHashToMutableInt32 { - return MapHashToMutableInt32{objID: s.id} + //nolint:gosimple + return MapHashToMutableInt32{proxy: s.proxy} } diff --git a/packages/vm/wasmlib/go/wasmlib/coreblocklog/consts.go b/packages/vm/wasmlib/go/wasmlib/coreblocklog/consts.go index 9b38d5f02d..7879542162 100644 --- a/packages/vm/wasmlib/go/wasmlib/coreblocklog/consts.go +++ b/packages/vm/wasmlib/go/wasmlib/coreblocklog/consts.go @@ -7,12 +7,12 @@ package coreblocklog -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" +import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" const ( ScName = "blocklog" ScDescription = "Core block log contract" - HScName = wasmlib.ScHname(0xf538ef2b) + HScName = wasmtypes.ScHname(0xf538ef2b) ) const ( @@ -49,14 +49,14 @@ const ( ) const ( - HViewControlAddresses = wasmlib.ScHname(0x796bd223) - HViewGetBlockInfo = wasmlib.ScHname(0xbe89f9b3) - HViewGetEventsForBlock = wasmlib.ScHname(0x36232798) - HViewGetEventsForContract = wasmlib.ScHname(0x682a1922) - HViewGetEventsForRequest = wasmlib.ScHname(0x4f8d68e4) - HViewGetLatestBlockInfo = wasmlib.ScHname(0x084a1760) - HViewGetRequestIDsForBlock = wasmlib.ScHname(0x5a20327a) - HViewGetRequestReceipt = wasmlib.ScHname(0xb7f9534f) - HViewGetRequestReceiptsForBlock = wasmlib.ScHname(0x77e3beef) - HViewIsRequestProcessed = wasmlib.ScHname(0xd57d50a9) + HViewControlAddresses = wasmtypes.ScHname(0x796bd223) + HViewGetBlockInfo = wasmtypes.ScHname(0xbe89f9b3) + HViewGetEventsForBlock = wasmtypes.ScHname(0x36232798) + HViewGetEventsForContract = wasmtypes.ScHname(0x682a1922) + HViewGetEventsForRequest = wasmtypes.ScHname(0x4f8d68e4) + HViewGetLatestBlockInfo = wasmtypes.ScHname(0x084a1760) + HViewGetRequestIDsForBlock = wasmtypes.ScHname(0x5a20327a) + HViewGetRequestReceipt = wasmtypes.ScHname(0xb7f9534f) + HViewGetRequestReceiptsForBlock = wasmtypes.ScHname(0x77e3beef) + HViewIsRequestProcessed = wasmtypes.ScHname(0xd57d50a9) ) diff --git a/packages/vm/wasmlib/go/wasmlib/coreblocklog/contract.go b/packages/vm/wasmlib/go/wasmlib/coreblocklog/contract.go index 19da3392e3..17386d86ed 100644 --- a/packages/vm/wasmlib/go/wasmlib/coreblocklog/contract.go +++ b/packages/vm/wasmlib/go/wasmlib/coreblocklog/contract.go @@ -73,61 +73,69 @@ var ScFuncs Funcs func (sc Funcs) ControlAddresses(ctx wasmlib.ScViewCallContext) *ControlAddressesCall { f := &ControlAddressesCall{Func: wasmlib.NewScView(ctx, HScName, HViewControlAddresses)} - f.Func.SetPtrs(nil, &f.Results.id) + wasmlib.NewCallResultsProxy(f.Func, &f.Results.proxy) return f } func (sc Funcs) GetBlockInfo(ctx wasmlib.ScViewCallContext) *GetBlockInfoCall { f := &GetBlockInfoCall{Func: wasmlib.NewScView(ctx, HScName, HViewGetBlockInfo)} - f.Func.SetPtrs(&f.Params.id, &f.Results.id) + f.Params.proxy = wasmlib.NewCallParamsProxy(f.Func) + wasmlib.NewCallResultsProxy(f.Func, &f.Results.proxy) return f } func (sc Funcs) GetEventsForBlock(ctx wasmlib.ScViewCallContext) *GetEventsForBlockCall { f := &GetEventsForBlockCall{Func: wasmlib.NewScView(ctx, HScName, HViewGetEventsForBlock)} - f.Func.SetPtrs(&f.Params.id, &f.Results.id) + f.Params.proxy = wasmlib.NewCallParamsProxy(f.Func) + wasmlib.NewCallResultsProxy(f.Func, &f.Results.proxy) return f } func (sc Funcs) GetEventsForContract(ctx wasmlib.ScViewCallContext) *GetEventsForContractCall { f := &GetEventsForContractCall{Func: wasmlib.NewScView(ctx, HScName, HViewGetEventsForContract)} - f.Func.SetPtrs(&f.Params.id, &f.Results.id) + f.Params.proxy = wasmlib.NewCallParamsProxy(f.Func) + wasmlib.NewCallResultsProxy(f.Func, &f.Results.proxy) return f } func (sc Funcs) GetEventsForRequest(ctx wasmlib.ScViewCallContext) *GetEventsForRequestCall { f := &GetEventsForRequestCall{Func: wasmlib.NewScView(ctx, HScName, HViewGetEventsForRequest)} - f.Func.SetPtrs(&f.Params.id, &f.Results.id) + f.Params.proxy = wasmlib.NewCallParamsProxy(f.Func) + wasmlib.NewCallResultsProxy(f.Func, &f.Results.proxy) return f } func (sc Funcs) GetLatestBlockInfo(ctx wasmlib.ScViewCallContext) *GetLatestBlockInfoCall { f := &GetLatestBlockInfoCall{Func: wasmlib.NewScView(ctx, HScName, HViewGetLatestBlockInfo)} - f.Func.SetPtrs(nil, &f.Results.id) + wasmlib.NewCallResultsProxy(f.Func, &f.Results.proxy) return f } func (sc Funcs) GetRequestIDsForBlock(ctx wasmlib.ScViewCallContext) *GetRequestIDsForBlockCall { f := &GetRequestIDsForBlockCall{Func: wasmlib.NewScView(ctx, HScName, HViewGetRequestIDsForBlock)} - f.Func.SetPtrs(&f.Params.id, &f.Results.id) + f.Params.proxy = wasmlib.NewCallParamsProxy(f.Func) + wasmlib.NewCallResultsProxy(f.Func, &f.Results.proxy) return f } func (sc Funcs) GetRequestReceipt(ctx wasmlib.ScViewCallContext) *GetRequestReceiptCall { f := &GetRequestReceiptCall{Func: wasmlib.NewScView(ctx, HScName, HViewGetRequestReceipt)} - f.Func.SetPtrs(&f.Params.id, &f.Results.id) + f.Params.proxy = wasmlib.NewCallParamsProxy(f.Func) + wasmlib.NewCallResultsProxy(f.Func, &f.Results.proxy) return f } func (sc Funcs) GetRequestReceiptsForBlock(ctx wasmlib.ScViewCallContext) *GetRequestReceiptsForBlockCall { f := &GetRequestReceiptsForBlockCall{Func: wasmlib.NewScView(ctx, HScName, HViewGetRequestReceiptsForBlock)} - f.Func.SetPtrs(&f.Params.id, &f.Results.id) + f.Params.proxy = wasmlib.NewCallParamsProxy(f.Func) + wasmlib.NewCallResultsProxy(f.Func, &f.Results.proxy) return f } func (sc Funcs) IsRequestProcessed(ctx wasmlib.ScViewCallContext) *IsRequestProcessedCall { f := &IsRequestProcessedCall{Func: wasmlib.NewScView(ctx, HScName, HViewIsRequestProcessed)} - f.Func.SetPtrs(&f.Params.id, &f.Results.id) + f.Params.proxy = wasmlib.NewCallParamsProxy(f.Func) + wasmlib.NewCallResultsProxy(f.Func, &f.Results.proxy) return f } diff --git a/packages/vm/wasmlib/go/wasmlib/coreblocklog/params.go b/packages/vm/wasmlib/go/wasmlib/coreblocklog/params.go index b67570e3b1..c36be0377e 100644 --- a/packages/vm/wasmlib/go/wasmlib/coreblocklog/params.go +++ b/packages/vm/wasmlib/go/wasmlib/coreblocklog/params.go @@ -7,148 +7,148 @@ package coreblocklog -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" +import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" type ImmutableGetBlockInfoParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableGetBlockInfoParams) BlockIndex() wasmlib.ScImmutableInt32 { - return wasmlib.NewScImmutableInt32(s.id, wasmlib.KeyID(ParamBlockIndex)) +func (s ImmutableGetBlockInfoParams) BlockIndex() wasmtypes.ScImmutableUint32 { + return wasmtypes.NewScImmutableUint32(s.proxy.Root(ParamBlockIndex)) } type MutableGetBlockInfoParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableGetBlockInfoParams) BlockIndex() wasmlib.ScMutableInt32 { - return wasmlib.NewScMutableInt32(s.id, wasmlib.KeyID(ParamBlockIndex)) +func (s MutableGetBlockInfoParams) BlockIndex() wasmtypes.ScMutableUint32 { + return wasmtypes.NewScMutableUint32(s.proxy.Root(ParamBlockIndex)) } type ImmutableGetEventsForBlockParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableGetEventsForBlockParams) BlockIndex() wasmlib.ScImmutableInt32 { - return wasmlib.NewScImmutableInt32(s.id, wasmlib.KeyID(ParamBlockIndex)) +func (s ImmutableGetEventsForBlockParams) BlockIndex() wasmtypes.ScImmutableUint32 { + return wasmtypes.NewScImmutableUint32(s.proxy.Root(ParamBlockIndex)) } type MutableGetEventsForBlockParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableGetEventsForBlockParams) BlockIndex() wasmlib.ScMutableInt32 { - return wasmlib.NewScMutableInt32(s.id, wasmlib.KeyID(ParamBlockIndex)) +func (s MutableGetEventsForBlockParams) BlockIndex() wasmtypes.ScMutableUint32 { + return wasmtypes.NewScMutableUint32(s.proxy.Root(ParamBlockIndex)) } type ImmutableGetEventsForContractParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableGetEventsForContractParams) ContractHname() wasmlib.ScImmutableHname { - return wasmlib.NewScImmutableHname(s.id, wasmlib.KeyID(ParamContractHname)) +func (s ImmutableGetEventsForContractParams) ContractHname() wasmtypes.ScImmutableHname { + return wasmtypes.NewScImmutableHname(s.proxy.Root(ParamContractHname)) } -func (s ImmutableGetEventsForContractParams) FromBlock() wasmlib.ScImmutableInt32 { - return wasmlib.NewScImmutableInt32(s.id, wasmlib.KeyID(ParamFromBlock)) +func (s ImmutableGetEventsForContractParams) FromBlock() wasmtypes.ScImmutableUint32 { + return wasmtypes.NewScImmutableUint32(s.proxy.Root(ParamFromBlock)) } -func (s ImmutableGetEventsForContractParams) ToBlock() wasmlib.ScImmutableInt32 { - return wasmlib.NewScImmutableInt32(s.id, wasmlib.KeyID(ParamToBlock)) +func (s ImmutableGetEventsForContractParams) ToBlock() wasmtypes.ScImmutableUint32 { + return wasmtypes.NewScImmutableUint32(s.proxy.Root(ParamToBlock)) } type MutableGetEventsForContractParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableGetEventsForContractParams) ContractHname() wasmlib.ScMutableHname { - return wasmlib.NewScMutableHname(s.id, wasmlib.KeyID(ParamContractHname)) +func (s MutableGetEventsForContractParams) ContractHname() wasmtypes.ScMutableHname { + return wasmtypes.NewScMutableHname(s.proxy.Root(ParamContractHname)) } -func (s MutableGetEventsForContractParams) FromBlock() wasmlib.ScMutableInt32 { - return wasmlib.NewScMutableInt32(s.id, wasmlib.KeyID(ParamFromBlock)) +func (s MutableGetEventsForContractParams) FromBlock() wasmtypes.ScMutableUint32 { + return wasmtypes.NewScMutableUint32(s.proxy.Root(ParamFromBlock)) } -func (s MutableGetEventsForContractParams) ToBlock() wasmlib.ScMutableInt32 { - return wasmlib.NewScMutableInt32(s.id, wasmlib.KeyID(ParamToBlock)) +func (s MutableGetEventsForContractParams) ToBlock() wasmtypes.ScMutableUint32 { + return wasmtypes.NewScMutableUint32(s.proxy.Root(ParamToBlock)) } type ImmutableGetEventsForRequestParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableGetEventsForRequestParams) RequestID() wasmlib.ScImmutableRequestID { - return wasmlib.NewScImmutableRequestID(s.id, wasmlib.KeyID(ParamRequestID)) +func (s ImmutableGetEventsForRequestParams) RequestID() wasmtypes.ScImmutableRequestID { + return wasmtypes.NewScImmutableRequestID(s.proxy.Root(ParamRequestID)) } type MutableGetEventsForRequestParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableGetEventsForRequestParams) RequestID() wasmlib.ScMutableRequestID { - return wasmlib.NewScMutableRequestID(s.id, wasmlib.KeyID(ParamRequestID)) +func (s MutableGetEventsForRequestParams) RequestID() wasmtypes.ScMutableRequestID { + return wasmtypes.NewScMutableRequestID(s.proxy.Root(ParamRequestID)) } type ImmutableGetRequestIDsForBlockParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableGetRequestIDsForBlockParams) BlockIndex() wasmlib.ScImmutableInt32 { - return wasmlib.NewScImmutableInt32(s.id, wasmlib.KeyID(ParamBlockIndex)) +func (s ImmutableGetRequestIDsForBlockParams) BlockIndex() wasmtypes.ScImmutableUint32 { + return wasmtypes.NewScImmutableUint32(s.proxy.Root(ParamBlockIndex)) } type MutableGetRequestIDsForBlockParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableGetRequestIDsForBlockParams) BlockIndex() wasmlib.ScMutableInt32 { - return wasmlib.NewScMutableInt32(s.id, wasmlib.KeyID(ParamBlockIndex)) +func (s MutableGetRequestIDsForBlockParams) BlockIndex() wasmtypes.ScMutableUint32 { + return wasmtypes.NewScMutableUint32(s.proxy.Root(ParamBlockIndex)) } type ImmutableGetRequestReceiptParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableGetRequestReceiptParams) RequestID() wasmlib.ScImmutableRequestID { - return wasmlib.NewScImmutableRequestID(s.id, wasmlib.KeyID(ParamRequestID)) +func (s ImmutableGetRequestReceiptParams) RequestID() wasmtypes.ScImmutableRequestID { + return wasmtypes.NewScImmutableRequestID(s.proxy.Root(ParamRequestID)) } type MutableGetRequestReceiptParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableGetRequestReceiptParams) RequestID() wasmlib.ScMutableRequestID { - return wasmlib.NewScMutableRequestID(s.id, wasmlib.KeyID(ParamRequestID)) +func (s MutableGetRequestReceiptParams) RequestID() wasmtypes.ScMutableRequestID { + return wasmtypes.NewScMutableRequestID(s.proxy.Root(ParamRequestID)) } type ImmutableGetRequestReceiptsForBlockParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableGetRequestReceiptsForBlockParams) BlockIndex() wasmlib.ScImmutableInt32 { - return wasmlib.NewScImmutableInt32(s.id, wasmlib.KeyID(ParamBlockIndex)) +func (s ImmutableGetRequestReceiptsForBlockParams) BlockIndex() wasmtypes.ScImmutableUint32 { + return wasmtypes.NewScImmutableUint32(s.proxy.Root(ParamBlockIndex)) } type MutableGetRequestReceiptsForBlockParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableGetRequestReceiptsForBlockParams) BlockIndex() wasmlib.ScMutableInt32 { - return wasmlib.NewScMutableInt32(s.id, wasmlib.KeyID(ParamBlockIndex)) +func (s MutableGetRequestReceiptsForBlockParams) BlockIndex() wasmtypes.ScMutableUint32 { + return wasmtypes.NewScMutableUint32(s.proxy.Root(ParamBlockIndex)) } type ImmutableIsRequestProcessedParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableIsRequestProcessedParams) RequestID() wasmlib.ScImmutableRequestID { - return wasmlib.NewScImmutableRequestID(s.id, wasmlib.KeyID(ParamRequestID)) +func (s ImmutableIsRequestProcessedParams) RequestID() wasmtypes.ScImmutableRequestID { + return wasmtypes.NewScImmutableRequestID(s.proxy.Root(ParamRequestID)) } type MutableIsRequestProcessedParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableIsRequestProcessedParams) RequestID() wasmlib.ScMutableRequestID { - return wasmlib.NewScMutableRequestID(s.id, wasmlib.KeyID(ParamRequestID)) +func (s MutableIsRequestProcessedParams) RequestID() wasmtypes.ScMutableRequestID { + return wasmtypes.NewScMutableRequestID(s.proxy.Root(ParamRequestID)) } diff --git a/packages/vm/wasmlib/go/wasmlib/coreblocklog/results.go b/packages/vm/wasmlib/go/wasmlib/coreblocklog/results.go index 6fee94382e..0b9bce761d 100644 --- a/packages/vm/wasmlib/go/wasmlib/coreblocklog/results.go +++ b/packages/vm/wasmlib/go/wasmlib/coreblocklog/results.go @@ -7,270 +7,268 @@ package coreblocklog -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" +import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" type ImmutableControlAddressesResults struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableControlAddressesResults) BlockIndex() wasmlib.ScImmutableInt32 { - return wasmlib.NewScImmutableInt32(s.id, wasmlib.KeyID(ResultBlockIndex)) +func (s ImmutableControlAddressesResults) BlockIndex() wasmtypes.ScImmutableUint32 { + return wasmtypes.NewScImmutableUint32(s.proxy.Root(ResultBlockIndex)) } -func (s ImmutableControlAddressesResults) GoverningAddress() wasmlib.ScImmutableAddress { - return wasmlib.NewScImmutableAddress(s.id, wasmlib.KeyID(ResultGoverningAddress)) +func (s ImmutableControlAddressesResults) GoverningAddress() wasmtypes.ScImmutableAddress { + return wasmtypes.NewScImmutableAddress(s.proxy.Root(ResultGoverningAddress)) } -func (s ImmutableControlAddressesResults) StateControllerAddress() wasmlib.ScImmutableAddress { - return wasmlib.NewScImmutableAddress(s.id, wasmlib.KeyID(ResultStateControllerAddress)) +func (s ImmutableControlAddressesResults) StateControllerAddress() wasmtypes.ScImmutableAddress { + return wasmtypes.NewScImmutableAddress(s.proxy.Root(ResultStateControllerAddress)) } type MutableControlAddressesResults struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableControlAddressesResults) BlockIndex() wasmlib.ScMutableInt32 { - return wasmlib.NewScMutableInt32(s.id, wasmlib.KeyID(ResultBlockIndex)) +func (s MutableControlAddressesResults) BlockIndex() wasmtypes.ScMutableUint32 { + return wasmtypes.NewScMutableUint32(s.proxy.Root(ResultBlockIndex)) } -func (s MutableControlAddressesResults) GoverningAddress() wasmlib.ScMutableAddress { - return wasmlib.NewScMutableAddress(s.id, wasmlib.KeyID(ResultGoverningAddress)) +func (s MutableControlAddressesResults) GoverningAddress() wasmtypes.ScMutableAddress { + return wasmtypes.NewScMutableAddress(s.proxy.Root(ResultGoverningAddress)) } -func (s MutableControlAddressesResults) StateControllerAddress() wasmlib.ScMutableAddress { - return wasmlib.NewScMutableAddress(s.id, wasmlib.KeyID(ResultStateControllerAddress)) +func (s MutableControlAddressesResults) StateControllerAddress() wasmtypes.ScMutableAddress { + return wasmtypes.NewScMutableAddress(s.proxy.Root(ResultStateControllerAddress)) } type ImmutableGetBlockInfoResults struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableGetBlockInfoResults) BlockInfo() wasmlib.ScImmutableBytes { - return wasmlib.NewScImmutableBytes(s.id, wasmlib.KeyID(ResultBlockInfo)) +func (s ImmutableGetBlockInfoResults) BlockInfo() wasmtypes.ScImmutableBytes { + return wasmtypes.NewScImmutableBytes(s.proxy.Root(ResultBlockInfo)) } type MutableGetBlockInfoResults struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableGetBlockInfoResults) BlockInfo() wasmlib.ScMutableBytes { - return wasmlib.NewScMutableBytes(s.id, wasmlib.KeyID(ResultBlockInfo)) +func (s MutableGetBlockInfoResults) BlockInfo() wasmtypes.ScMutableBytes { + return wasmtypes.NewScMutableBytes(s.proxy.Root(ResultBlockInfo)) } type ArrayOfImmutableBytes struct { - objID int32 + proxy wasmtypes.Proxy } -func (a ArrayOfImmutableBytes) Length() int32 { - return wasmlib.GetLength(a.objID) +func (a ArrayOfImmutableBytes) Length() uint32 { + return a.proxy.Length() } -func (a ArrayOfImmutableBytes) GetBytes(index int32) wasmlib.ScImmutableBytes { - return wasmlib.NewScImmutableBytes(a.objID, wasmlib.Key32(index)) +func (a ArrayOfImmutableBytes) GetBytes(index uint32) wasmtypes.ScImmutableBytes { + return wasmtypes.NewScImmutableBytes(a.proxy.Index(index)) } type ImmutableGetEventsForBlockResults struct { - id int32 + proxy wasmtypes.Proxy } func (s ImmutableGetEventsForBlockResults) Event() ArrayOfImmutableBytes { - arrID := wasmlib.GetObjectID(s.id, wasmlib.KeyID(ResultEvent), wasmlib.TYPE_ARRAY16|wasmlib.TYPE_BYTES) - return ArrayOfImmutableBytes{objID: arrID} + return ArrayOfImmutableBytes{proxy: s.proxy.Root(ResultEvent)} } type ArrayOfMutableBytes struct { - objID int32 + proxy wasmtypes.Proxy +} + +func (a ArrayOfMutableBytes) AppendBytes() wasmtypes.ScMutableBytes { + return wasmtypes.NewScMutableBytes(a.proxy.Append()) } func (a ArrayOfMutableBytes) Clear() { - wasmlib.Clear(a.objID) + a.proxy.ClearArray() } -func (a ArrayOfMutableBytes) Length() int32 { - return wasmlib.GetLength(a.objID) +func (a ArrayOfMutableBytes) Length() uint32 { + return a.proxy.Length() } -func (a ArrayOfMutableBytes) GetBytes(index int32) wasmlib.ScMutableBytes { - return wasmlib.NewScMutableBytes(a.objID, wasmlib.Key32(index)) +func (a ArrayOfMutableBytes) GetBytes(index uint32) wasmtypes.ScMutableBytes { + return wasmtypes.NewScMutableBytes(a.proxy.Index(index)) } type MutableGetEventsForBlockResults struct { - id int32 + proxy wasmtypes.Proxy } func (s MutableGetEventsForBlockResults) Event() ArrayOfMutableBytes { - arrID := wasmlib.GetObjectID(s.id, wasmlib.KeyID(ResultEvent), wasmlib.TYPE_ARRAY16|wasmlib.TYPE_BYTES) - return ArrayOfMutableBytes{objID: arrID} + return ArrayOfMutableBytes{proxy: s.proxy.Root(ResultEvent)} } type ImmutableGetEventsForContractResults struct { - id int32 + proxy wasmtypes.Proxy } func (s ImmutableGetEventsForContractResults) Event() ArrayOfImmutableBytes { - arrID := wasmlib.GetObjectID(s.id, wasmlib.KeyID(ResultEvent), wasmlib.TYPE_ARRAY16|wasmlib.TYPE_BYTES) - return ArrayOfImmutableBytes{objID: arrID} + return ArrayOfImmutableBytes{proxy: s.proxy.Root(ResultEvent)} } type MutableGetEventsForContractResults struct { - id int32 + proxy wasmtypes.Proxy } func (s MutableGetEventsForContractResults) Event() ArrayOfMutableBytes { - arrID := wasmlib.GetObjectID(s.id, wasmlib.KeyID(ResultEvent), wasmlib.TYPE_ARRAY16|wasmlib.TYPE_BYTES) - return ArrayOfMutableBytes{objID: arrID} + return ArrayOfMutableBytes{proxy: s.proxy.Root(ResultEvent)} } type ImmutableGetEventsForRequestResults struct { - id int32 + proxy wasmtypes.Proxy } func (s ImmutableGetEventsForRequestResults) Event() ArrayOfImmutableBytes { - arrID := wasmlib.GetObjectID(s.id, wasmlib.KeyID(ResultEvent), wasmlib.TYPE_ARRAY16|wasmlib.TYPE_BYTES) - return ArrayOfImmutableBytes{objID: arrID} + return ArrayOfImmutableBytes{proxy: s.proxy.Root(ResultEvent)} } type MutableGetEventsForRequestResults struct { - id int32 + proxy wasmtypes.Proxy } func (s MutableGetEventsForRequestResults) Event() ArrayOfMutableBytes { - arrID := wasmlib.GetObjectID(s.id, wasmlib.KeyID(ResultEvent), wasmlib.TYPE_ARRAY16|wasmlib.TYPE_BYTES) - return ArrayOfMutableBytes{objID: arrID} + return ArrayOfMutableBytes{proxy: s.proxy.Root(ResultEvent)} } type ImmutableGetLatestBlockInfoResults struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableGetLatestBlockInfoResults) BlockIndex() wasmlib.ScImmutableInt32 { - return wasmlib.NewScImmutableInt32(s.id, wasmlib.KeyID(ResultBlockIndex)) +func (s ImmutableGetLatestBlockInfoResults) BlockIndex() wasmtypes.ScImmutableUint32 { + return wasmtypes.NewScImmutableUint32(s.proxy.Root(ResultBlockIndex)) } -func (s ImmutableGetLatestBlockInfoResults) BlockInfo() wasmlib.ScImmutableBytes { - return wasmlib.NewScImmutableBytes(s.id, wasmlib.KeyID(ResultBlockInfo)) +func (s ImmutableGetLatestBlockInfoResults) BlockInfo() wasmtypes.ScImmutableBytes { + return wasmtypes.NewScImmutableBytes(s.proxy.Root(ResultBlockInfo)) } type MutableGetLatestBlockInfoResults struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableGetLatestBlockInfoResults) BlockIndex() wasmlib.ScMutableInt32 { - return wasmlib.NewScMutableInt32(s.id, wasmlib.KeyID(ResultBlockIndex)) +func (s MutableGetLatestBlockInfoResults) BlockIndex() wasmtypes.ScMutableUint32 { + return wasmtypes.NewScMutableUint32(s.proxy.Root(ResultBlockIndex)) } -func (s MutableGetLatestBlockInfoResults) BlockInfo() wasmlib.ScMutableBytes { - return wasmlib.NewScMutableBytes(s.id, wasmlib.KeyID(ResultBlockInfo)) +func (s MutableGetLatestBlockInfoResults) BlockInfo() wasmtypes.ScMutableBytes { + return wasmtypes.NewScMutableBytes(s.proxy.Root(ResultBlockInfo)) } type ArrayOfImmutableRequestID struct { - objID int32 + proxy wasmtypes.Proxy } -func (a ArrayOfImmutableRequestID) Length() int32 { - return wasmlib.GetLength(a.objID) +func (a ArrayOfImmutableRequestID) Length() uint32 { + return a.proxy.Length() } -func (a ArrayOfImmutableRequestID) GetRequestID(index int32) wasmlib.ScImmutableRequestID { - return wasmlib.NewScImmutableRequestID(a.objID, wasmlib.Key32(index)) +func (a ArrayOfImmutableRequestID) GetRequestID(index uint32) wasmtypes.ScImmutableRequestID { + return wasmtypes.NewScImmutableRequestID(a.proxy.Index(index)) } type ImmutableGetRequestIDsForBlockResults struct { - id int32 + proxy wasmtypes.Proxy } func (s ImmutableGetRequestIDsForBlockResults) RequestID() ArrayOfImmutableRequestID { - arrID := wasmlib.GetObjectID(s.id, wasmlib.KeyID(ResultRequestID), wasmlib.TYPE_ARRAY16|wasmlib.TYPE_REQUEST_ID) - return ArrayOfImmutableRequestID{objID: arrID} + return ArrayOfImmutableRequestID{proxy: s.proxy.Root(ResultRequestID)} } type ArrayOfMutableRequestID struct { - objID int32 + proxy wasmtypes.Proxy +} + +func (a ArrayOfMutableRequestID) AppendRequestID() wasmtypes.ScMutableRequestID { + return wasmtypes.NewScMutableRequestID(a.proxy.Append()) } func (a ArrayOfMutableRequestID) Clear() { - wasmlib.Clear(a.objID) + a.proxy.ClearArray() } -func (a ArrayOfMutableRequestID) Length() int32 { - return wasmlib.GetLength(a.objID) +func (a ArrayOfMutableRequestID) Length() uint32 { + return a.proxy.Length() } -func (a ArrayOfMutableRequestID) GetRequestID(index int32) wasmlib.ScMutableRequestID { - return wasmlib.NewScMutableRequestID(a.objID, wasmlib.Key32(index)) +func (a ArrayOfMutableRequestID) GetRequestID(index uint32) wasmtypes.ScMutableRequestID { + return wasmtypes.NewScMutableRequestID(a.proxy.Index(index)) } type MutableGetRequestIDsForBlockResults struct { - id int32 + proxy wasmtypes.Proxy } func (s MutableGetRequestIDsForBlockResults) RequestID() ArrayOfMutableRequestID { - arrID := wasmlib.GetObjectID(s.id, wasmlib.KeyID(ResultRequestID), wasmlib.TYPE_ARRAY16|wasmlib.TYPE_REQUEST_ID) - return ArrayOfMutableRequestID{objID: arrID} + return ArrayOfMutableRequestID{proxy: s.proxy.Root(ResultRequestID)} } type ImmutableGetRequestReceiptResults struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableGetRequestReceiptResults) BlockIndex() wasmlib.ScImmutableInt32 { - return wasmlib.NewScImmutableInt32(s.id, wasmlib.KeyID(ResultBlockIndex)) +func (s ImmutableGetRequestReceiptResults) BlockIndex() wasmtypes.ScImmutableUint32 { + return wasmtypes.NewScImmutableUint32(s.proxy.Root(ResultBlockIndex)) } -func (s ImmutableGetRequestReceiptResults) RequestIndex() wasmlib.ScImmutableInt16 { - return wasmlib.NewScImmutableInt16(s.id, wasmlib.KeyID(ResultRequestIndex)) +func (s ImmutableGetRequestReceiptResults) RequestIndex() wasmtypes.ScImmutableUint16 { + return wasmtypes.NewScImmutableUint16(s.proxy.Root(ResultRequestIndex)) } -func (s ImmutableGetRequestReceiptResults) RequestRecord() wasmlib.ScImmutableBytes { - return wasmlib.NewScImmutableBytes(s.id, wasmlib.KeyID(ResultRequestRecord)) +func (s ImmutableGetRequestReceiptResults) RequestRecord() wasmtypes.ScImmutableBytes { + return wasmtypes.NewScImmutableBytes(s.proxy.Root(ResultRequestRecord)) } type MutableGetRequestReceiptResults struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableGetRequestReceiptResults) BlockIndex() wasmlib.ScMutableInt32 { - return wasmlib.NewScMutableInt32(s.id, wasmlib.KeyID(ResultBlockIndex)) +func (s MutableGetRequestReceiptResults) BlockIndex() wasmtypes.ScMutableUint32 { + return wasmtypes.NewScMutableUint32(s.proxy.Root(ResultBlockIndex)) } -func (s MutableGetRequestReceiptResults) RequestIndex() wasmlib.ScMutableInt16 { - return wasmlib.NewScMutableInt16(s.id, wasmlib.KeyID(ResultRequestIndex)) +func (s MutableGetRequestReceiptResults) RequestIndex() wasmtypes.ScMutableUint16 { + return wasmtypes.NewScMutableUint16(s.proxy.Root(ResultRequestIndex)) } -func (s MutableGetRequestReceiptResults) RequestRecord() wasmlib.ScMutableBytes { - return wasmlib.NewScMutableBytes(s.id, wasmlib.KeyID(ResultRequestRecord)) +func (s MutableGetRequestReceiptResults) RequestRecord() wasmtypes.ScMutableBytes { + return wasmtypes.NewScMutableBytes(s.proxy.Root(ResultRequestRecord)) } type ImmutableGetRequestReceiptsForBlockResults struct { - id int32 + proxy wasmtypes.Proxy } func (s ImmutableGetRequestReceiptsForBlockResults) RequestRecord() ArrayOfImmutableBytes { - arrID := wasmlib.GetObjectID(s.id, wasmlib.KeyID(ResultRequestRecord), wasmlib.TYPE_ARRAY16|wasmlib.TYPE_BYTES) - return ArrayOfImmutableBytes{objID: arrID} + return ArrayOfImmutableBytes{proxy: s.proxy.Root(ResultRequestRecord)} } type MutableGetRequestReceiptsForBlockResults struct { - id int32 + proxy wasmtypes.Proxy } func (s MutableGetRequestReceiptsForBlockResults) RequestRecord() ArrayOfMutableBytes { - arrID := wasmlib.GetObjectID(s.id, wasmlib.KeyID(ResultRequestRecord), wasmlib.TYPE_ARRAY16|wasmlib.TYPE_BYTES) - return ArrayOfMutableBytes{objID: arrID} + return ArrayOfMutableBytes{proxy: s.proxy.Root(ResultRequestRecord)} } type ImmutableIsRequestProcessedResults struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableIsRequestProcessedResults) RequestProcessed() wasmlib.ScImmutableString { - return wasmlib.NewScImmutableString(s.id, wasmlib.KeyID(ResultRequestProcessed)) +func (s ImmutableIsRequestProcessedResults) RequestProcessed() wasmtypes.ScImmutableString { + return wasmtypes.NewScImmutableString(s.proxy.Root(ResultRequestProcessed)) } type MutableIsRequestProcessedResults struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableIsRequestProcessedResults) RequestProcessed() wasmlib.ScMutableString { - return wasmlib.NewScMutableString(s.id, wasmlib.KeyID(ResultRequestProcessed)) +func (s MutableIsRequestProcessedResults) RequestProcessed() wasmtypes.ScMutableString { + return wasmtypes.NewScMutableString(s.proxy.Root(ResultRequestProcessed)) } diff --git a/packages/vm/wasmlib/go/wasmlib/coregovernance/consts.go b/packages/vm/wasmlib/go/wasmlib/coregovernance/consts.go index 98cb3accc7..5e1e2221fd 100644 --- a/packages/vm/wasmlib/go/wasmlib/coregovernance/consts.go +++ b/packages/vm/wasmlib/go/wasmlib/coregovernance/consts.go @@ -7,12 +7,12 @@ package coregovernance -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" +import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" const ( ScName = "governance" ScDescription = "Core governance contract" - HScName = wasmlib.ScHname(0x17cf909f) + HScName = wasmtypes.ScHname(0x17cf909f) ) const ( @@ -58,16 +58,16 @@ const ( ) const ( - HFuncAddAllowedStateControllerAddress = wasmlib.ScHname(0x9469d567) - HFuncClaimChainOwnership = wasmlib.ScHname(0x03ff0fc0) - HFuncDelegateChainOwnership = wasmlib.ScHname(0x93ecb6ad) - HFuncRemoveAllowedStateControllerAddress = wasmlib.ScHname(0x31f69447) - HFuncRotateStateController = wasmlib.ScHname(0x244d1038) - HFuncSetChainInfo = wasmlib.ScHname(0x702f5d2b) - HFuncSetContractFee = wasmlib.ScHname(0x8421a42b) - HFuncSetDefaultFee = wasmlib.ScHname(0x3310ecd0) - HViewGetAllowedStateControllerAddresses = wasmlib.ScHname(0xf3505183) - HViewGetChainInfo = wasmlib.ScHname(0x434477e2) - HViewGetFeeInfo = wasmlib.ScHname(0x9fe54b48) - HViewGetMaxBlobSize = wasmlib.ScHname(0xe1db3d28) + HFuncAddAllowedStateControllerAddress = wasmtypes.ScHname(0x9469d567) + HFuncClaimChainOwnership = wasmtypes.ScHname(0x03ff0fc0) + HFuncDelegateChainOwnership = wasmtypes.ScHname(0x93ecb6ad) + HFuncRemoveAllowedStateControllerAddress = wasmtypes.ScHname(0x31f69447) + HFuncRotateStateController = wasmtypes.ScHname(0x244d1038) + HFuncSetChainInfo = wasmtypes.ScHname(0x702f5d2b) + HFuncSetContractFee = wasmtypes.ScHname(0x8421a42b) + HFuncSetDefaultFee = wasmtypes.ScHname(0x3310ecd0) + HViewGetAllowedStateControllerAddresses = wasmtypes.ScHname(0xf3505183) + HViewGetChainInfo = wasmtypes.ScHname(0x434477e2) + HViewGetFeeInfo = wasmtypes.ScHname(0x9fe54b48) + HViewGetMaxBlobSize = wasmtypes.ScHname(0xe1db3d28) ) diff --git a/packages/vm/wasmlib/go/wasmlib/coregovernance/contract.go b/packages/vm/wasmlib/go/wasmlib/coregovernance/contract.go index 1a6fd89a82..8ea58578ab 100644 --- a/packages/vm/wasmlib/go/wasmlib/coregovernance/contract.go +++ b/packages/vm/wasmlib/go/wasmlib/coregovernance/contract.go @@ -75,7 +75,7 @@ var ScFuncs Funcs func (sc Funcs) AddAllowedStateControllerAddress(ctx wasmlib.ScFuncCallContext) *AddAllowedStateControllerAddressCall { f := &AddAllowedStateControllerAddressCall{Func: wasmlib.NewScFunc(ctx, HScName, HFuncAddAllowedStateControllerAddress)} - f.Func.SetPtrs(&f.Params.id, nil) + f.Params.proxy = wasmlib.NewCallParamsProxy(&f.Func.ScView) return f } @@ -85,61 +85,62 @@ func (sc Funcs) ClaimChainOwnership(ctx wasmlib.ScFuncCallContext) *ClaimChainOw func (sc Funcs) DelegateChainOwnership(ctx wasmlib.ScFuncCallContext) *DelegateChainOwnershipCall { f := &DelegateChainOwnershipCall{Func: wasmlib.NewScFunc(ctx, HScName, HFuncDelegateChainOwnership)} - f.Func.SetPtrs(&f.Params.id, nil) + f.Params.proxy = wasmlib.NewCallParamsProxy(&f.Func.ScView) return f } func (sc Funcs) RemoveAllowedStateControllerAddress(ctx wasmlib.ScFuncCallContext) *RemoveAllowedStateControllerAddressCall { f := &RemoveAllowedStateControllerAddressCall{Func: wasmlib.NewScFunc(ctx, HScName, HFuncRemoveAllowedStateControllerAddress)} - f.Func.SetPtrs(&f.Params.id, nil) + f.Params.proxy = wasmlib.NewCallParamsProxy(&f.Func.ScView) return f } func (sc Funcs) RotateStateController(ctx wasmlib.ScFuncCallContext) *RotateStateControllerCall { f := &RotateStateControllerCall{Func: wasmlib.NewScFunc(ctx, HScName, HFuncRotateStateController)} - f.Func.SetPtrs(&f.Params.id, nil) + f.Params.proxy = wasmlib.NewCallParamsProxy(&f.Func.ScView) return f } func (sc Funcs) SetChainInfo(ctx wasmlib.ScFuncCallContext) *SetChainInfoCall { f := &SetChainInfoCall{Func: wasmlib.NewScFunc(ctx, HScName, HFuncSetChainInfo)} - f.Func.SetPtrs(&f.Params.id, nil) + f.Params.proxy = wasmlib.NewCallParamsProxy(&f.Func.ScView) return f } func (sc Funcs) SetContractFee(ctx wasmlib.ScFuncCallContext) *SetContractFeeCall { f := &SetContractFeeCall{Func: wasmlib.NewScFunc(ctx, HScName, HFuncSetContractFee)} - f.Func.SetPtrs(&f.Params.id, nil) + f.Params.proxy = wasmlib.NewCallParamsProxy(&f.Func.ScView) return f } func (sc Funcs) SetDefaultFee(ctx wasmlib.ScFuncCallContext) *SetDefaultFeeCall { f := &SetDefaultFeeCall{Func: wasmlib.NewScFunc(ctx, HScName, HFuncSetDefaultFee)} - f.Func.SetPtrs(&f.Params.id, nil) + f.Params.proxy = wasmlib.NewCallParamsProxy(&f.Func.ScView) return f } func (sc Funcs) GetAllowedStateControllerAddresses(ctx wasmlib.ScViewCallContext) *GetAllowedStateControllerAddressesCall { f := &GetAllowedStateControllerAddressesCall{Func: wasmlib.NewScView(ctx, HScName, HViewGetAllowedStateControllerAddresses)} - f.Func.SetPtrs(nil, &f.Results.id) + wasmlib.NewCallResultsProxy(f.Func, &f.Results.proxy) return f } func (sc Funcs) GetChainInfo(ctx wasmlib.ScViewCallContext) *GetChainInfoCall { f := &GetChainInfoCall{Func: wasmlib.NewScView(ctx, HScName, HViewGetChainInfo)} - f.Func.SetPtrs(nil, &f.Results.id) + wasmlib.NewCallResultsProxy(f.Func, &f.Results.proxy) return f } func (sc Funcs) GetFeeInfo(ctx wasmlib.ScViewCallContext) *GetFeeInfoCall { f := &GetFeeInfoCall{Func: wasmlib.NewScView(ctx, HScName, HViewGetFeeInfo)} - f.Func.SetPtrs(&f.Params.id, &f.Results.id) + f.Params.proxy = wasmlib.NewCallParamsProxy(f.Func) + wasmlib.NewCallResultsProxy(f.Func, &f.Results.proxy) return f } func (sc Funcs) GetMaxBlobSize(ctx wasmlib.ScViewCallContext) *GetMaxBlobSizeCall { f := &GetMaxBlobSizeCall{Func: wasmlib.NewScView(ctx, HScName, HViewGetMaxBlobSize)} - f.Func.SetPtrs(nil, &f.Results.id) + wasmlib.NewCallResultsProxy(f.Func, &f.Results.proxy) return f } diff --git a/packages/vm/wasmlib/go/wasmlib/coregovernance/params.go b/packages/vm/wasmlib/go/wasmlib/coregovernance/params.go index 41e3e62ea2..d4798d9484 100644 --- a/packages/vm/wasmlib/go/wasmlib/coregovernance/params.go +++ b/packages/vm/wasmlib/go/wasmlib/coregovernance/params.go @@ -7,204 +7,204 @@ package coregovernance -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" +import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" type ImmutableAddAllowedStateControllerAddressParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableAddAllowedStateControllerAddressParams) ChainOwner() wasmlib.ScImmutableAgentID { - return wasmlib.NewScImmutableAgentID(s.id, wasmlib.KeyID(ParamChainOwner)) +func (s ImmutableAddAllowedStateControllerAddressParams) ChainOwner() wasmtypes.ScImmutableAgentID { + return wasmtypes.NewScImmutableAgentID(s.proxy.Root(ParamChainOwner)) } -func (s ImmutableAddAllowedStateControllerAddressParams) FeeColor() wasmlib.ScImmutableColor { - return wasmlib.NewScImmutableColor(s.id, wasmlib.KeyID(ParamFeeColor)) +func (s ImmutableAddAllowedStateControllerAddressParams) FeeColor() wasmtypes.ScImmutableColor { + return wasmtypes.NewScImmutableColor(s.proxy.Root(ParamFeeColor)) } -func (s ImmutableAddAllowedStateControllerAddressParams) StateControllerAddress() wasmlib.ScImmutableAddress { - return wasmlib.NewScImmutableAddress(s.id, wasmlib.KeyID(ParamStateControllerAddress)) +func (s ImmutableAddAllowedStateControllerAddressParams) StateControllerAddress() wasmtypes.ScImmutableAddress { + return wasmtypes.NewScImmutableAddress(s.proxy.Root(ParamStateControllerAddress)) } type MutableAddAllowedStateControllerAddressParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableAddAllowedStateControllerAddressParams) ChainOwner() wasmlib.ScMutableAgentID { - return wasmlib.NewScMutableAgentID(s.id, wasmlib.KeyID(ParamChainOwner)) +func (s MutableAddAllowedStateControllerAddressParams) ChainOwner() wasmtypes.ScMutableAgentID { + return wasmtypes.NewScMutableAgentID(s.proxy.Root(ParamChainOwner)) } -func (s MutableAddAllowedStateControllerAddressParams) FeeColor() wasmlib.ScMutableColor { - return wasmlib.NewScMutableColor(s.id, wasmlib.KeyID(ParamFeeColor)) +func (s MutableAddAllowedStateControllerAddressParams) FeeColor() wasmtypes.ScMutableColor { + return wasmtypes.NewScMutableColor(s.proxy.Root(ParamFeeColor)) } -func (s MutableAddAllowedStateControllerAddressParams) StateControllerAddress() wasmlib.ScMutableAddress { - return wasmlib.NewScMutableAddress(s.id, wasmlib.KeyID(ParamStateControllerAddress)) +func (s MutableAddAllowedStateControllerAddressParams) StateControllerAddress() wasmtypes.ScMutableAddress { + return wasmtypes.NewScMutableAddress(s.proxy.Root(ParamStateControllerAddress)) } type ImmutableDelegateChainOwnershipParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableDelegateChainOwnershipParams) ChainOwner() wasmlib.ScImmutableAgentID { - return wasmlib.NewScImmutableAgentID(s.id, wasmlib.KeyID(ParamChainOwner)) +func (s ImmutableDelegateChainOwnershipParams) ChainOwner() wasmtypes.ScImmutableAgentID { + return wasmtypes.NewScImmutableAgentID(s.proxy.Root(ParamChainOwner)) } type MutableDelegateChainOwnershipParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableDelegateChainOwnershipParams) ChainOwner() wasmlib.ScMutableAgentID { - return wasmlib.NewScMutableAgentID(s.id, wasmlib.KeyID(ParamChainOwner)) +func (s MutableDelegateChainOwnershipParams) ChainOwner() wasmtypes.ScMutableAgentID { + return wasmtypes.NewScMutableAgentID(s.proxy.Root(ParamChainOwner)) } type ImmutableRemoveAllowedStateControllerAddressParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableRemoveAllowedStateControllerAddressParams) StateControllerAddress() wasmlib.ScImmutableAddress { - return wasmlib.NewScImmutableAddress(s.id, wasmlib.KeyID(ParamStateControllerAddress)) +func (s ImmutableRemoveAllowedStateControllerAddressParams) StateControllerAddress() wasmtypes.ScImmutableAddress { + return wasmtypes.NewScImmutableAddress(s.proxy.Root(ParamStateControllerAddress)) } type MutableRemoveAllowedStateControllerAddressParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableRemoveAllowedStateControllerAddressParams) StateControllerAddress() wasmlib.ScMutableAddress { - return wasmlib.NewScMutableAddress(s.id, wasmlib.KeyID(ParamStateControllerAddress)) +func (s MutableRemoveAllowedStateControllerAddressParams) StateControllerAddress() wasmtypes.ScMutableAddress { + return wasmtypes.NewScMutableAddress(s.proxy.Root(ParamStateControllerAddress)) } type ImmutableRotateStateControllerParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableRotateStateControllerParams) StateControllerAddress() wasmlib.ScImmutableAddress { - return wasmlib.NewScImmutableAddress(s.id, wasmlib.KeyID(ParamStateControllerAddress)) +func (s ImmutableRotateStateControllerParams) StateControllerAddress() wasmtypes.ScImmutableAddress { + return wasmtypes.NewScImmutableAddress(s.proxy.Root(ParamStateControllerAddress)) } type MutableRotateStateControllerParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableRotateStateControllerParams) StateControllerAddress() wasmlib.ScMutableAddress { - return wasmlib.NewScMutableAddress(s.id, wasmlib.KeyID(ParamStateControllerAddress)) +func (s MutableRotateStateControllerParams) StateControllerAddress() wasmtypes.ScMutableAddress { + return wasmtypes.NewScMutableAddress(s.proxy.Root(ParamStateControllerAddress)) } type ImmutableSetChainInfoParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableSetChainInfoParams) MaxBlobSize() wasmlib.ScImmutableInt32 { - return wasmlib.NewScImmutableInt32(s.id, wasmlib.KeyID(ParamMaxBlobSize)) +func (s ImmutableSetChainInfoParams) MaxBlobSize() wasmtypes.ScImmutableInt32 { + return wasmtypes.NewScImmutableInt32(s.proxy.Root(ParamMaxBlobSize)) } -func (s ImmutableSetChainInfoParams) MaxEventSize() wasmlib.ScImmutableInt16 { - return wasmlib.NewScImmutableInt16(s.id, wasmlib.KeyID(ParamMaxEventSize)) +func (s ImmutableSetChainInfoParams) MaxEventSize() wasmtypes.ScImmutableInt16 { + return wasmtypes.NewScImmutableInt16(s.proxy.Root(ParamMaxEventSize)) } -func (s ImmutableSetChainInfoParams) MaxEventsPerReq() wasmlib.ScImmutableInt16 { - return wasmlib.NewScImmutableInt16(s.id, wasmlib.KeyID(ParamMaxEventsPerReq)) +func (s ImmutableSetChainInfoParams) MaxEventsPerReq() wasmtypes.ScImmutableInt16 { + return wasmtypes.NewScImmutableInt16(s.proxy.Root(ParamMaxEventsPerReq)) } -func (s ImmutableSetChainInfoParams) OwnerFee() wasmlib.ScImmutableInt64 { - return wasmlib.NewScImmutableInt64(s.id, wasmlib.KeyID(ParamOwnerFee)) +func (s ImmutableSetChainInfoParams) OwnerFee() wasmtypes.ScImmutableInt64 { + return wasmtypes.NewScImmutableInt64(s.proxy.Root(ParamOwnerFee)) } -func (s ImmutableSetChainInfoParams) ValidatorFee() wasmlib.ScImmutableInt64 { - return wasmlib.NewScImmutableInt64(s.id, wasmlib.KeyID(ParamValidatorFee)) +func (s ImmutableSetChainInfoParams) ValidatorFee() wasmtypes.ScImmutableInt64 { + return wasmtypes.NewScImmutableInt64(s.proxy.Root(ParamValidatorFee)) } type MutableSetChainInfoParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableSetChainInfoParams) MaxBlobSize() wasmlib.ScMutableInt32 { - return wasmlib.NewScMutableInt32(s.id, wasmlib.KeyID(ParamMaxBlobSize)) +func (s MutableSetChainInfoParams) MaxBlobSize() wasmtypes.ScMutableInt32 { + return wasmtypes.NewScMutableInt32(s.proxy.Root(ParamMaxBlobSize)) } -func (s MutableSetChainInfoParams) MaxEventSize() wasmlib.ScMutableInt16 { - return wasmlib.NewScMutableInt16(s.id, wasmlib.KeyID(ParamMaxEventSize)) +func (s MutableSetChainInfoParams) MaxEventSize() wasmtypes.ScMutableInt16 { + return wasmtypes.NewScMutableInt16(s.proxy.Root(ParamMaxEventSize)) } -func (s MutableSetChainInfoParams) MaxEventsPerReq() wasmlib.ScMutableInt16 { - return wasmlib.NewScMutableInt16(s.id, wasmlib.KeyID(ParamMaxEventsPerReq)) +func (s MutableSetChainInfoParams) MaxEventsPerReq() wasmtypes.ScMutableInt16 { + return wasmtypes.NewScMutableInt16(s.proxy.Root(ParamMaxEventsPerReq)) } -func (s MutableSetChainInfoParams) OwnerFee() wasmlib.ScMutableInt64 { - return wasmlib.NewScMutableInt64(s.id, wasmlib.KeyID(ParamOwnerFee)) +func (s MutableSetChainInfoParams) OwnerFee() wasmtypes.ScMutableInt64 { + return wasmtypes.NewScMutableInt64(s.proxy.Root(ParamOwnerFee)) } -func (s MutableSetChainInfoParams) ValidatorFee() wasmlib.ScMutableInt64 { - return wasmlib.NewScMutableInt64(s.id, wasmlib.KeyID(ParamValidatorFee)) +func (s MutableSetChainInfoParams) ValidatorFee() wasmtypes.ScMutableInt64 { + return wasmtypes.NewScMutableInt64(s.proxy.Root(ParamValidatorFee)) } type ImmutableSetContractFeeParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableSetContractFeeParams) Hname() wasmlib.ScImmutableHname { - return wasmlib.NewScImmutableHname(s.id, wasmlib.KeyID(ParamHname)) +func (s ImmutableSetContractFeeParams) Hname() wasmtypes.ScImmutableHname { + return wasmtypes.NewScImmutableHname(s.proxy.Root(ParamHname)) } -func (s ImmutableSetContractFeeParams) OwnerFee() wasmlib.ScImmutableInt64 { - return wasmlib.NewScImmutableInt64(s.id, wasmlib.KeyID(ParamOwnerFee)) +func (s ImmutableSetContractFeeParams) OwnerFee() wasmtypes.ScImmutableInt64 { + return wasmtypes.NewScImmutableInt64(s.proxy.Root(ParamOwnerFee)) } -func (s ImmutableSetContractFeeParams) ValidatorFee() wasmlib.ScImmutableInt64 { - return wasmlib.NewScImmutableInt64(s.id, wasmlib.KeyID(ParamValidatorFee)) +func (s ImmutableSetContractFeeParams) ValidatorFee() wasmtypes.ScImmutableInt64 { + return wasmtypes.NewScImmutableInt64(s.proxy.Root(ParamValidatorFee)) } type MutableSetContractFeeParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableSetContractFeeParams) Hname() wasmlib.ScMutableHname { - return wasmlib.NewScMutableHname(s.id, wasmlib.KeyID(ParamHname)) +func (s MutableSetContractFeeParams) Hname() wasmtypes.ScMutableHname { + return wasmtypes.NewScMutableHname(s.proxy.Root(ParamHname)) } -func (s MutableSetContractFeeParams) OwnerFee() wasmlib.ScMutableInt64 { - return wasmlib.NewScMutableInt64(s.id, wasmlib.KeyID(ParamOwnerFee)) +func (s MutableSetContractFeeParams) OwnerFee() wasmtypes.ScMutableInt64 { + return wasmtypes.NewScMutableInt64(s.proxy.Root(ParamOwnerFee)) } -func (s MutableSetContractFeeParams) ValidatorFee() wasmlib.ScMutableInt64 { - return wasmlib.NewScMutableInt64(s.id, wasmlib.KeyID(ParamValidatorFee)) +func (s MutableSetContractFeeParams) ValidatorFee() wasmtypes.ScMutableInt64 { + return wasmtypes.NewScMutableInt64(s.proxy.Root(ParamValidatorFee)) } type ImmutableSetDefaultFeeParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableSetDefaultFeeParams) OwnerFee() wasmlib.ScImmutableInt64 { - return wasmlib.NewScImmutableInt64(s.id, wasmlib.KeyID(ParamOwnerFee)) +func (s ImmutableSetDefaultFeeParams) OwnerFee() wasmtypes.ScImmutableInt64 { + return wasmtypes.NewScImmutableInt64(s.proxy.Root(ParamOwnerFee)) } -func (s ImmutableSetDefaultFeeParams) ValidatorFee() wasmlib.ScImmutableInt64 { - return wasmlib.NewScImmutableInt64(s.id, wasmlib.KeyID(ParamValidatorFee)) +func (s ImmutableSetDefaultFeeParams) ValidatorFee() wasmtypes.ScImmutableInt64 { + return wasmtypes.NewScImmutableInt64(s.proxy.Root(ParamValidatorFee)) } type MutableSetDefaultFeeParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableSetDefaultFeeParams) OwnerFee() wasmlib.ScMutableInt64 { - return wasmlib.NewScMutableInt64(s.id, wasmlib.KeyID(ParamOwnerFee)) +func (s MutableSetDefaultFeeParams) OwnerFee() wasmtypes.ScMutableInt64 { + return wasmtypes.NewScMutableInt64(s.proxy.Root(ParamOwnerFee)) } -func (s MutableSetDefaultFeeParams) ValidatorFee() wasmlib.ScMutableInt64 { - return wasmlib.NewScMutableInt64(s.id, wasmlib.KeyID(ParamValidatorFee)) +func (s MutableSetDefaultFeeParams) ValidatorFee() wasmtypes.ScMutableInt64 { + return wasmtypes.NewScMutableInt64(s.proxy.Root(ParamValidatorFee)) } type ImmutableGetFeeInfoParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableGetFeeInfoParams) Hname() wasmlib.ScImmutableHname { - return wasmlib.NewScImmutableHname(s.id, wasmlib.KeyID(ParamHname)) +func (s ImmutableGetFeeInfoParams) Hname() wasmtypes.ScImmutableHname { + return wasmtypes.NewScImmutableHname(s.proxy.Root(ParamHname)) } type MutableGetFeeInfoParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableGetFeeInfoParams) Hname() wasmlib.ScMutableHname { - return wasmlib.NewScMutableHname(s.id, wasmlib.KeyID(ParamHname)) +func (s MutableGetFeeInfoParams) Hname() wasmtypes.ScMutableHname { + return wasmtypes.NewScMutableHname(s.proxy.Root(ParamHname)) } diff --git a/packages/vm/wasmlib/go/wasmlib/coregovernance/results.go b/packages/vm/wasmlib/go/wasmlib/coregovernance/results.go index c322210258..e482d8df9b 100644 --- a/packages/vm/wasmlib/go/wasmlib/coregovernance/results.go +++ b/packages/vm/wasmlib/go/wasmlib/coregovernance/results.go @@ -7,178 +7,180 @@ package coregovernance -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" +import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" type ArrayOfImmutableBytes struct { - objID int32 + proxy wasmtypes.Proxy } -func (a ArrayOfImmutableBytes) Length() int32 { - return wasmlib.GetLength(a.objID) +func (a ArrayOfImmutableBytes) Length() uint32 { + return a.proxy.Length() } -func (a ArrayOfImmutableBytes) GetBytes(index int32) wasmlib.ScImmutableBytes { - return wasmlib.NewScImmutableBytes(a.objID, wasmlib.Key32(index)) +func (a ArrayOfImmutableBytes) GetBytes(index uint32) wasmtypes.ScImmutableBytes { + return wasmtypes.NewScImmutableBytes(a.proxy.Index(index)) } type ImmutableGetAllowedStateControllerAddressesResults struct { - id int32 + proxy wasmtypes.Proxy } func (s ImmutableGetAllowedStateControllerAddressesResults) AllowedStateControllerAddresses() ArrayOfImmutableBytes { - arrID := wasmlib.GetObjectID(s.id, wasmlib.KeyID(ResultAllowedStateControllerAddresses), wasmlib.TYPE_ARRAY16|wasmlib.TYPE_BYTES) - return ArrayOfImmutableBytes{objID: arrID} + return ArrayOfImmutableBytes{proxy: s.proxy.Root(ResultAllowedStateControllerAddresses)} } type ArrayOfMutableBytes struct { - objID int32 + proxy wasmtypes.Proxy +} + +func (a ArrayOfMutableBytes) AppendBytes() wasmtypes.ScMutableBytes { + return wasmtypes.NewScMutableBytes(a.proxy.Append()) } func (a ArrayOfMutableBytes) Clear() { - wasmlib.Clear(a.objID) + a.proxy.ClearArray() } -func (a ArrayOfMutableBytes) Length() int32 { - return wasmlib.GetLength(a.objID) +func (a ArrayOfMutableBytes) Length() uint32 { + return a.proxy.Length() } -func (a ArrayOfMutableBytes) GetBytes(index int32) wasmlib.ScMutableBytes { - return wasmlib.NewScMutableBytes(a.objID, wasmlib.Key32(index)) +func (a ArrayOfMutableBytes) GetBytes(index uint32) wasmtypes.ScMutableBytes { + return wasmtypes.NewScMutableBytes(a.proxy.Index(index)) } type MutableGetAllowedStateControllerAddressesResults struct { - id int32 + proxy wasmtypes.Proxy } func (s MutableGetAllowedStateControllerAddressesResults) AllowedStateControllerAddresses() ArrayOfMutableBytes { - arrID := wasmlib.GetObjectID(s.id, wasmlib.KeyID(ResultAllowedStateControllerAddresses), wasmlib.TYPE_ARRAY16|wasmlib.TYPE_BYTES) - return ArrayOfMutableBytes{objID: arrID} + return ArrayOfMutableBytes{proxy: s.proxy.Root(ResultAllowedStateControllerAddresses)} } type ImmutableGetChainInfoResults struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableGetChainInfoResults) ChainID() wasmlib.ScImmutableChainID { - return wasmlib.NewScImmutableChainID(s.id, wasmlib.KeyID(ResultChainID)) +func (s ImmutableGetChainInfoResults) ChainID() wasmtypes.ScImmutableChainID { + return wasmtypes.NewScImmutableChainID(s.proxy.Root(ResultChainID)) } -func (s ImmutableGetChainInfoResults) ChainOwnerID() wasmlib.ScImmutableAgentID { - return wasmlib.NewScImmutableAgentID(s.id, wasmlib.KeyID(ResultChainOwnerID)) +func (s ImmutableGetChainInfoResults) ChainOwnerID() wasmtypes.ScImmutableAgentID { + return wasmtypes.NewScImmutableAgentID(s.proxy.Root(ResultChainOwnerID)) } -func (s ImmutableGetChainInfoResults) DefaultOwnerFee() wasmlib.ScImmutableInt64 { - return wasmlib.NewScImmutableInt64(s.id, wasmlib.KeyID(ResultDefaultOwnerFee)) +func (s ImmutableGetChainInfoResults) DefaultOwnerFee() wasmtypes.ScImmutableInt64 { + return wasmtypes.NewScImmutableInt64(s.proxy.Root(ResultDefaultOwnerFee)) } -func (s ImmutableGetChainInfoResults) DefaultValidatorFee() wasmlib.ScImmutableInt64 { - return wasmlib.NewScImmutableInt64(s.id, wasmlib.KeyID(ResultDefaultValidatorFee)) +func (s ImmutableGetChainInfoResults) DefaultValidatorFee() wasmtypes.ScImmutableInt64 { + return wasmtypes.NewScImmutableInt64(s.proxy.Root(ResultDefaultValidatorFee)) } -func (s ImmutableGetChainInfoResults) Description() wasmlib.ScImmutableString { - return wasmlib.NewScImmutableString(s.id, wasmlib.KeyID(ResultDescription)) +func (s ImmutableGetChainInfoResults) Description() wasmtypes.ScImmutableString { + return wasmtypes.NewScImmutableString(s.proxy.Root(ResultDescription)) } -func (s ImmutableGetChainInfoResults) FeeColor() wasmlib.ScImmutableColor { - return wasmlib.NewScImmutableColor(s.id, wasmlib.KeyID(ResultFeeColor)) +func (s ImmutableGetChainInfoResults) FeeColor() wasmtypes.ScImmutableColor { + return wasmtypes.NewScImmutableColor(s.proxy.Root(ResultFeeColor)) } -func (s ImmutableGetChainInfoResults) MaxBlobSize() wasmlib.ScImmutableInt32 { - return wasmlib.NewScImmutableInt32(s.id, wasmlib.KeyID(ResultMaxBlobSize)) +func (s ImmutableGetChainInfoResults) MaxBlobSize() wasmtypes.ScImmutableInt32 { + return wasmtypes.NewScImmutableInt32(s.proxy.Root(ResultMaxBlobSize)) } -func (s ImmutableGetChainInfoResults) MaxEventSize() wasmlib.ScImmutableInt16 { - return wasmlib.NewScImmutableInt16(s.id, wasmlib.KeyID(ResultMaxEventSize)) +func (s ImmutableGetChainInfoResults) MaxEventSize() wasmtypes.ScImmutableInt16 { + return wasmtypes.NewScImmutableInt16(s.proxy.Root(ResultMaxEventSize)) } -func (s ImmutableGetChainInfoResults) MaxEventsPerReq() wasmlib.ScImmutableInt16 { - return wasmlib.NewScImmutableInt16(s.id, wasmlib.KeyID(ResultMaxEventsPerReq)) +func (s ImmutableGetChainInfoResults) MaxEventsPerReq() wasmtypes.ScImmutableInt16 { + return wasmtypes.NewScImmutableInt16(s.proxy.Root(ResultMaxEventsPerReq)) } type MutableGetChainInfoResults struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableGetChainInfoResults) ChainID() wasmlib.ScMutableChainID { - return wasmlib.NewScMutableChainID(s.id, wasmlib.KeyID(ResultChainID)) +func (s MutableGetChainInfoResults) ChainID() wasmtypes.ScMutableChainID { + return wasmtypes.NewScMutableChainID(s.proxy.Root(ResultChainID)) } -func (s MutableGetChainInfoResults) ChainOwnerID() wasmlib.ScMutableAgentID { - return wasmlib.NewScMutableAgentID(s.id, wasmlib.KeyID(ResultChainOwnerID)) +func (s MutableGetChainInfoResults) ChainOwnerID() wasmtypes.ScMutableAgentID { + return wasmtypes.NewScMutableAgentID(s.proxy.Root(ResultChainOwnerID)) } -func (s MutableGetChainInfoResults) DefaultOwnerFee() wasmlib.ScMutableInt64 { - return wasmlib.NewScMutableInt64(s.id, wasmlib.KeyID(ResultDefaultOwnerFee)) +func (s MutableGetChainInfoResults) DefaultOwnerFee() wasmtypes.ScMutableInt64 { + return wasmtypes.NewScMutableInt64(s.proxy.Root(ResultDefaultOwnerFee)) } -func (s MutableGetChainInfoResults) DefaultValidatorFee() wasmlib.ScMutableInt64 { - return wasmlib.NewScMutableInt64(s.id, wasmlib.KeyID(ResultDefaultValidatorFee)) +func (s MutableGetChainInfoResults) DefaultValidatorFee() wasmtypes.ScMutableInt64 { + return wasmtypes.NewScMutableInt64(s.proxy.Root(ResultDefaultValidatorFee)) } -func (s MutableGetChainInfoResults) Description() wasmlib.ScMutableString { - return wasmlib.NewScMutableString(s.id, wasmlib.KeyID(ResultDescription)) +func (s MutableGetChainInfoResults) Description() wasmtypes.ScMutableString { + return wasmtypes.NewScMutableString(s.proxy.Root(ResultDescription)) } -func (s MutableGetChainInfoResults) FeeColor() wasmlib.ScMutableColor { - return wasmlib.NewScMutableColor(s.id, wasmlib.KeyID(ResultFeeColor)) +func (s MutableGetChainInfoResults) FeeColor() wasmtypes.ScMutableColor { + return wasmtypes.NewScMutableColor(s.proxy.Root(ResultFeeColor)) } -func (s MutableGetChainInfoResults) MaxBlobSize() wasmlib.ScMutableInt32 { - return wasmlib.NewScMutableInt32(s.id, wasmlib.KeyID(ResultMaxBlobSize)) +func (s MutableGetChainInfoResults) MaxBlobSize() wasmtypes.ScMutableInt32 { + return wasmtypes.NewScMutableInt32(s.proxy.Root(ResultMaxBlobSize)) } -func (s MutableGetChainInfoResults) MaxEventSize() wasmlib.ScMutableInt16 { - return wasmlib.NewScMutableInt16(s.id, wasmlib.KeyID(ResultMaxEventSize)) +func (s MutableGetChainInfoResults) MaxEventSize() wasmtypes.ScMutableInt16 { + return wasmtypes.NewScMutableInt16(s.proxy.Root(ResultMaxEventSize)) } -func (s MutableGetChainInfoResults) MaxEventsPerReq() wasmlib.ScMutableInt16 { - return wasmlib.NewScMutableInt16(s.id, wasmlib.KeyID(ResultMaxEventsPerReq)) +func (s MutableGetChainInfoResults) MaxEventsPerReq() wasmtypes.ScMutableInt16 { + return wasmtypes.NewScMutableInt16(s.proxy.Root(ResultMaxEventsPerReq)) } type ImmutableGetFeeInfoResults struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableGetFeeInfoResults) FeeColor() wasmlib.ScImmutableColor { - return wasmlib.NewScImmutableColor(s.id, wasmlib.KeyID(ResultFeeColor)) +func (s ImmutableGetFeeInfoResults) FeeColor() wasmtypes.ScImmutableColor { + return wasmtypes.NewScImmutableColor(s.proxy.Root(ResultFeeColor)) } -func (s ImmutableGetFeeInfoResults) OwnerFee() wasmlib.ScImmutableInt64 { - return wasmlib.NewScImmutableInt64(s.id, wasmlib.KeyID(ResultOwnerFee)) +func (s ImmutableGetFeeInfoResults) OwnerFee() wasmtypes.ScImmutableInt64 { + return wasmtypes.NewScImmutableInt64(s.proxy.Root(ResultOwnerFee)) } -func (s ImmutableGetFeeInfoResults) ValidatorFee() wasmlib.ScImmutableInt64 { - return wasmlib.NewScImmutableInt64(s.id, wasmlib.KeyID(ResultValidatorFee)) +func (s ImmutableGetFeeInfoResults) ValidatorFee() wasmtypes.ScImmutableInt64 { + return wasmtypes.NewScImmutableInt64(s.proxy.Root(ResultValidatorFee)) } type MutableGetFeeInfoResults struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableGetFeeInfoResults) FeeColor() wasmlib.ScMutableColor { - return wasmlib.NewScMutableColor(s.id, wasmlib.KeyID(ResultFeeColor)) +func (s MutableGetFeeInfoResults) FeeColor() wasmtypes.ScMutableColor { + return wasmtypes.NewScMutableColor(s.proxy.Root(ResultFeeColor)) } -func (s MutableGetFeeInfoResults) OwnerFee() wasmlib.ScMutableInt64 { - return wasmlib.NewScMutableInt64(s.id, wasmlib.KeyID(ResultOwnerFee)) +func (s MutableGetFeeInfoResults) OwnerFee() wasmtypes.ScMutableInt64 { + return wasmtypes.NewScMutableInt64(s.proxy.Root(ResultOwnerFee)) } -func (s MutableGetFeeInfoResults) ValidatorFee() wasmlib.ScMutableInt64 { - return wasmlib.NewScMutableInt64(s.id, wasmlib.KeyID(ResultValidatorFee)) +func (s MutableGetFeeInfoResults) ValidatorFee() wasmtypes.ScMutableInt64 { + return wasmtypes.NewScMutableInt64(s.proxy.Root(ResultValidatorFee)) } type ImmutableGetMaxBlobSizeResults struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableGetMaxBlobSizeResults) MaxBlobSize() wasmlib.ScImmutableInt32 { - return wasmlib.NewScImmutableInt32(s.id, wasmlib.KeyID(ResultMaxBlobSize)) +func (s ImmutableGetMaxBlobSizeResults) MaxBlobSize() wasmtypes.ScImmutableInt32 { + return wasmtypes.NewScImmutableInt32(s.proxy.Root(ResultMaxBlobSize)) } type MutableGetMaxBlobSizeResults struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableGetMaxBlobSizeResults) MaxBlobSize() wasmlib.ScMutableInt32 { - return wasmlib.NewScMutableInt32(s.id, wasmlib.KeyID(ResultMaxBlobSize)) +func (s MutableGetMaxBlobSizeResults) MaxBlobSize() wasmtypes.ScMutableInt32 { + return wasmtypes.NewScMutableInt32(s.proxy.Root(ResultMaxBlobSize)) } diff --git a/packages/vm/wasmlib/go/wasmlib/coreroot/consts.go b/packages/vm/wasmlib/go/wasmlib/coreroot/consts.go index b791ab59f4..56bd94dba6 100644 --- a/packages/vm/wasmlib/go/wasmlib/coreroot/consts.go +++ b/packages/vm/wasmlib/go/wasmlib/coreroot/consts.go @@ -7,12 +7,12 @@ package coreroot -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" +import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" const ( ScName = "root" ScDescription = "Core root contract" - HScName = wasmlib.ScHname(0xcebf5908) + HScName = wasmtypes.ScHname(0xcebf5908) ) const ( @@ -38,9 +38,9 @@ const ( ) const ( - HFuncDeployContract = wasmlib.ScHname(0x28232c27) - HFuncGrantDeployPermission = wasmlib.ScHname(0xf440263a) - HFuncRevokeDeployPermission = wasmlib.ScHname(0x850744f1) - HViewFindContract = wasmlib.ScHname(0xc145ca00) - HViewGetContractRecords = wasmlib.ScHname(0x078b3ef3) + HFuncDeployContract = wasmtypes.ScHname(0x28232c27) + HFuncGrantDeployPermission = wasmtypes.ScHname(0xf440263a) + HFuncRevokeDeployPermission = wasmtypes.ScHname(0x850744f1) + HViewFindContract = wasmtypes.ScHname(0xc145ca00) + HViewGetContractRecords = wasmtypes.ScHname(0x078b3ef3) ) diff --git a/packages/vm/wasmlib/go/wasmlib/coreroot/contract.go b/packages/vm/wasmlib/go/wasmlib/coreroot/contract.go index 400eb1237e..a857945095 100644 --- a/packages/vm/wasmlib/go/wasmlib/coreroot/contract.go +++ b/packages/vm/wasmlib/go/wasmlib/coreroot/contract.go @@ -41,31 +41,32 @@ var ScFuncs Funcs func (sc Funcs) DeployContract(ctx wasmlib.ScFuncCallContext) *DeployContractCall { f := &DeployContractCall{Func: wasmlib.NewScFunc(ctx, HScName, HFuncDeployContract)} - f.Func.SetPtrs(&f.Params.id, nil) + f.Params.proxy = wasmlib.NewCallParamsProxy(&f.Func.ScView) return f } func (sc Funcs) GrantDeployPermission(ctx wasmlib.ScFuncCallContext) *GrantDeployPermissionCall { f := &GrantDeployPermissionCall{Func: wasmlib.NewScFunc(ctx, HScName, HFuncGrantDeployPermission)} - f.Func.SetPtrs(&f.Params.id, nil) + f.Params.proxy = wasmlib.NewCallParamsProxy(&f.Func.ScView) return f } func (sc Funcs) RevokeDeployPermission(ctx wasmlib.ScFuncCallContext) *RevokeDeployPermissionCall { f := &RevokeDeployPermissionCall{Func: wasmlib.NewScFunc(ctx, HScName, HFuncRevokeDeployPermission)} - f.Func.SetPtrs(&f.Params.id, nil) + f.Params.proxy = wasmlib.NewCallParamsProxy(&f.Func.ScView) return f } func (sc Funcs) FindContract(ctx wasmlib.ScViewCallContext) *FindContractCall { f := &FindContractCall{Func: wasmlib.NewScView(ctx, HScName, HViewFindContract)} - f.Func.SetPtrs(&f.Params.id, &f.Results.id) + f.Params.proxy = wasmlib.NewCallParamsProxy(f.Func) + wasmlib.NewCallResultsProxy(f.Func, &f.Results.proxy) return f } func (sc Funcs) GetContractRecords(ctx wasmlib.ScViewCallContext) *GetContractRecordsCall { f := &GetContractRecordsCall{Func: wasmlib.NewScView(ctx, HScName, HViewGetContractRecords)} - f.Func.SetPtrs(nil, &f.Results.id) + wasmlib.NewCallResultsProxy(f.Func, &f.Results.proxy) return f } diff --git a/packages/vm/wasmlib/go/wasmlib/coreroot/params.go b/packages/vm/wasmlib/go/wasmlib/coreroot/params.go index f302c05d5c..db4108ff75 100644 --- a/packages/vm/wasmlib/go/wasmlib/coreroot/params.go +++ b/packages/vm/wasmlib/go/wasmlib/coreroot/params.go @@ -7,84 +7,84 @@ package coreroot -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" +import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" type ImmutableDeployContractParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableDeployContractParams) Description() wasmlib.ScImmutableString { - return wasmlib.NewScImmutableString(s.id, wasmlib.KeyID(ParamDescription)) +func (s ImmutableDeployContractParams) Description() wasmtypes.ScImmutableString { + return wasmtypes.NewScImmutableString(s.proxy.Root(ParamDescription)) } -func (s ImmutableDeployContractParams) Name() wasmlib.ScImmutableString { - return wasmlib.NewScImmutableString(s.id, wasmlib.KeyID(ParamName)) +func (s ImmutableDeployContractParams) Name() wasmtypes.ScImmutableString { + return wasmtypes.NewScImmutableString(s.proxy.Root(ParamName)) } -func (s ImmutableDeployContractParams) ProgramHash() wasmlib.ScImmutableHash { - return wasmlib.NewScImmutableHash(s.id, wasmlib.KeyID(ParamProgramHash)) +func (s ImmutableDeployContractParams) ProgramHash() wasmtypes.ScImmutableHash { + return wasmtypes.NewScImmutableHash(s.proxy.Root(ParamProgramHash)) } type MutableDeployContractParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableDeployContractParams) Description() wasmlib.ScMutableString { - return wasmlib.NewScMutableString(s.id, wasmlib.KeyID(ParamDescription)) +func (s MutableDeployContractParams) Description() wasmtypes.ScMutableString { + return wasmtypes.NewScMutableString(s.proxy.Root(ParamDescription)) } -func (s MutableDeployContractParams) Name() wasmlib.ScMutableString { - return wasmlib.NewScMutableString(s.id, wasmlib.KeyID(ParamName)) +func (s MutableDeployContractParams) Name() wasmtypes.ScMutableString { + return wasmtypes.NewScMutableString(s.proxy.Root(ParamName)) } -func (s MutableDeployContractParams) ProgramHash() wasmlib.ScMutableHash { - return wasmlib.NewScMutableHash(s.id, wasmlib.KeyID(ParamProgramHash)) +func (s MutableDeployContractParams) ProgramHash() wasmtypes.ScMutableHash { + return wasmtypes.NewScMutableHash(s.proxy.Root(ParamProgramHash)) } type ImmutableGrantDeployPermissionParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableGrantDeployPermissionParams) Deployer() wasmlib.ScImmutableAgentID { - return wasmlib.NewScImmutableAgentID(s.id, wasmlib.KeyID(ParamDeployer)) +func (s ImmutableGrantDeployPermissionParams) Deployer() wasmtypes.ScImmutableAgentID { + return wasmtypes.NewScImmutableAgentID(s.proxy.Root(ParamDeployer)) } type MutableGrantDeployPermissionParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableGrantDeployPermissionParams) Deployer() wasmlib.ScMutableAgentID { - return wasmlib.NewScMutableAgentID(s.id, wasmlib.KeyID(ParamDeployer)) +func (s MutableGrantDeployPermissionParams) Deployer() wasmtypes.ScMutableAgentID { + return wasmtypes.NewScMutableAgentID(s.proxy.Root(ParamDeployer)) } type ImmutableRevokeDeployPermissionParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableRevokeDeployPermissionParams) Deployer() wasmlib.ScImmutableAgentID { - return wasmlib.NewScImmutableAgentID(s.id, wasmlib.KeyID(ParamDeployer)) +func (s ImmutableRevokeDeployPermissionParams) Deployer() wasmtypes.ScImmutableAgentID { + return wasmtypes.NewScImmutableAgentID(s.proxy.Root(ParamDeployer)) } type MutableRevokeDeployPermissionParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableRevokeDeployPermissionParams) Deployer() wasmlib.ScMutableAgentID { - return wasmlib.NewScMutableAgentID(s.id, wasmlib.KeyID(ParamDeployer)) +func (s MutableRevokeDeployPermissionParams) Deployer() wasmtypes.ScMutableAgentID { + return wasmtypes.NewScMutableAgentID(s.proxy.Root(ParamDeployer)) } type ImmutableFindContractParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableFindContractParams) Hname() wasmlib.ScImmutableHname { - return wasmlib.NewScImmutableHname(s.id, wasmlib.KeyID(ParamHname)) +func (s ImmutableFindContractParams) Hname() wasmtypes.ScImmutableHname { + return wasmtypes.NewScImmutableHname(s.proxy.Root(ParamHname)) } type MutableFindContractParams struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableFindContractParams) Hname() wasmlib.ScMutableHname { - return wasmlib.NewScMutableHname(s.id, wasmlib.KeyID(ParamHname)) +func (s MutableFindContractParams) Hname() wasmtypes.ScMutableHname { + return wasmtypes.NewScMutableHname(s.proxy.Root(ParamHname)) } diff --git a/packages/vm/wasmlib/go/wasmlib/coreroot/results.go b/packages/vm/wasmlib/go/wasmlib/coreroot/results.go index 7108487a19..f422fa2825 100644 --- a/packages/vm/wasmlib/go/wasmlib/coreroot/results.go +++ b/packages/vm/wasmlib/go/wasmlib/coreroot/results.go @@ -7,66 +7,64 @@ package coreroot -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" +import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" type ImmutableFindContractResults struct { - id int32 + proxy wasmtypes.Proxy } -func (s ImmutableFindContractResults) ContractFound() wasmlib.ScImmutableBytes { - return wasmlib.NewScImmutableBytes(s.id, wasmlib.KeyID(ResultContractFound)) +func (s ImmutableFindContractResults) ContractFound() wasmtypes.ScImmutableBytes { + return wasmtypes.NewScImmutableBytes(s.proxy.Root(ResultContractFound)) } -func (s ImmutableFindContractResults) ContractRecData() wasmlib.ScImmutableBytes { - return wasmlib.NewScImmutableBytes(s.id, wasmlib.KeyID(ResultContractRecData)) +func (s ImmutableFindContractResults) ContractRecData() wasmtypes.ScImmutableBytes { + return wasmtypes.NewScImmutableBytes(s.proxy.Root(ResultContractRecData)) } type MutableFindContractResults struct { - id int32 + proxy wasmtypes.Proxy } -func (s MutableFindContractResults) ContractFound() wasmlib.ScMutableBytes { - return wasmlib.NewScMutableBytes(s.id, wasmlib.KeyID(ResultContractFound)) +func (s MutableFindContractResults) ContractFound() wasmtypes.ScMutableBytes { + return wasmtypes.NewScMutableBytes(s.proxy.Root(ResultContractFound)) } -func (s MutableFindContractResults) ContractRecData() wasmlib.ScMutableBytes { - return wasmlib.NewScMutableBytes(s.id, wasmlib.KeyID(ResultContractRecData)) +func (s MutableFindContractResults) ContractRecData() wasmtypes.ScMutableBytes { + return wasmtypes.NewScMutableBytes(s.proxy.Root(ResultContractRecData)) } type MapHnameToImmutableBytes struct { - objID int32 + proxy wasmtypes.Proxy } -func (m MapHnameToImmutableBytes) GetBytes(key wasmlib.ScHname) wasmlib.ScImmutableBytes { - return wasmlib.NewScImmutableBytes(m.objID, key.KeyID()) +func (m MapHnameToImmutableBytes) GetBytes(key wasmtypes.ScHname) wasmtypes.ScImmutableBytes { + return wasmtypes.NewScImmutableBytes(m.proxy.Key(key.Bytes())) } type ImmutableGetContractRecordsResults struct { - id int32 + proxy wasmtypes.Proxy } func (s ImmutableGetContractRecordsResults) ContractRegistry() MapHnameToImmutableBytes { - mapID := wasmlib.GetObjectID(s.id, wasmlib.KeyID(ResultContractRegistry), wasmlib.TYPE_MAP) - return MapHnameToImmutableBytes{objID: mapID} + return MapHnameToImmutableBytes{proxy: s.proxy.Root(ResultContractRegistry)} } type MapHnameToMutableBytes struct { - objID int32 + proxy wasmtypes.Proxy } func (m MapHnameToMutableBytes) Clear() { - wasmlib.Clear(m.objID) + m.proxy.ClearMap() } -func (m MapHnameToMutableBytes) GetBytes(key wasmlib.ScHname) wasmlib.ScMutableBytes { - return wasmlib.NewScMutableBytes(m.objID, key.KeyID()) +func (m MapHnameToMutableBytes) GetBytes(key wasmtypes.ScHname) wasmtypes.ScMutableBytes { + return wasmtypes.NewScMutableBytes(m.proxy.Key(key.Bytes())) } type MutableGetContractRecordsResults struct { - id int32 + proxy wasmtypes.Proxy } func (s MutableGetContractRecordsResults) ContractRegistry() MapHnameToMutableBytes { - mapID := wasmlib.GetObjectID(s.id, wasmlib.KeyID(ResultContractRegistry), wasmlib.TYPE_MAP) - return MapHnameToMutableBytes{objID: mapID} + return MapHnameToMutableBytes{proxy: s.proxy.Root(ResultContractRegistry)} } diff --git a/packages/vm/wasmlib/go/wasmlib/dict.go b/packages/vm/wasmlib/go/wasmlib/dict.go new file mode 100644 index 0000000000..ad9a9febbe --- /dev/null +++ b/packages/vm/wasmlib/go/wasmlib/dict.go @@ -0,0 +1,95 @@ +// Copyright 2020 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +package wasmlib + +import ( + "sort" + + "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmcodec" + "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" +) + +type ScDict map[string][]byte + +var _ wasmtypes.IKvStore = ScDict{} + +func NewDictProxy() wasmtypes.Proxy { + return wasmtypes.NewProxy(NewScDict()) +} + +func NewResultsProxy() wasmtypes.Proxy { + return wasmtypes.NewProxy(NewScDict()) +} + +func NewScDict() ScDict { + return make(ScDict) +} + +func NewScDictFromBytes(buf []byte) ScDict { + size, buf := wasmcodec.ExtractUint32(buf) + dict := make(ScDict, size) + var k uint16 + var v uint32 + var key []byte + var val []byte + for i := uint32(0); i < size; i++ { + k, buf = wasmcodec.ExtractUint16(buf) + key, buf = wasmcodec.ExtractBytes(buf, int(k)) + v, buf = wasmcodec.ExtractUint32(buf) + val, buf = wasmcodec.ExtractBytes(buf, int(v)) + dict.Set(key, val) + } + return dict +} + +func (d ScDict) Bytes() []byte { + keys := make([]string, 0, len(d)) + for key := range d { + keys = append(keys, key) + } + sort.Slice(keys, func(i, j int) bool { + return keys[i] < keys[j] + }) + buf := wasmcodec.AppendUint32(nil, uint32(len(keys))) + for _, k := range keys { + v := d[k] + buf = wasmcodec.AppendUint16(buf, uint16(len(k))) + buf = wasmcodec.AppendBytes(buf, []byte(k)) + buf = wasmcodec.AppendUint32(buf, uint32(len(v))) + buf = wasmcodec.AppendBytes(buf, v) + } + return buf +} + +func (d ScDict) Delete(key []byte) { + delete(d, string(key)) +} + +func (d ScDict) Exists(key []byte) bool { + return d[string(key)] != nil +} + +func (d ScDict) Get(key []byte) []byte { + return d[string(key)] +} + +func (d ScDict) Set(key, value []byte) { + d[string(key)] = value +} + +func (d ScDict) Immutable() ScImmutableDict { + return ScImmutableDict{d: d} +} + +type ScImmutableDict struct { + d ScDict +} + +func (d ScImmutableDict) Exists(key []byte) bool { + return d.d.Exists(key) +} + +func (d ScImmutableDict) Get(key []byte) []byte { + return d.d.Get(key) +} diff --git a/packages/vm/wasmlib/go/wasmlib/events.go b/packages/vm/wasmlib/go/wasmlib/events.go index feabb505c5..f48e2541f7 100644 --- a/packages/vm/wasmlib/go/wasmlib/events.go +++ b/packages/vm/wasmlib/go/wasmlib/events.go @@ -5,6 +5,8 @@ package wasmlib import ( "strconv" + + "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" ) // encodes separate entities into a byte buffer @@ -14,16 +16,16 @@ type EventEncoder struct { func NewEventEncoder(eventName string) *EventEncoder { e := &EventEncoder{event: eventName} - timestamp := Root.GetInt64(KeyTimestamp).Value() + timestamp := ScSandbox{}.Timestamp() // convert nanoseconds to seconds - return e.Int64(timestamp / 1_000_000_000) + return e.Uint64(timestamp / 1_000_000_000) } -func (e *EventEncoder) Address(value ScAddress) *EventEncoder { +func (e *EventEncoder) Address(value wasmtypes.ScAddress) *EventEncoder { return e.String(value.String()) } -func (e *EventEncoder) AgentID(value ScAgentID) *EventEncoder { +func (e *EventEncoder) AgentID(value wasmtypes.ScAgentID) *EventEncoder { return e.String(value.String()) } @@ -38,23 +40,23 @@ func (e *EventEncoder) Bytes(value []byte) *EventEncoder { return e.String(base58Encode(value)) } -func (e *EventEncoder) ChainID(value ScChainID) *EventEncoder { +func (e *EventEncoder) ChainID(value wasmtypes.ScChainID) *EventEncoder { return e.String(value.String()) } -func (e *EventEncoder) Color(value ScColor) *EventEncoder { +func (e *EventEncoder) Color(value wasmtypes.ScColor) *EventEncoder { return e.String(value.String()) } func (e *EventEncoder) Emit() { - Root.GetString(KeyEvent).SetValue(e.event) + ScSandboxFunc{}.Event(e.event) } -func (e *EventEncoder) Hash(value ScHash) *EventEncoder { +func (e *EventEncoder) Hash(value wasmtypes.ScHash) *EventEncoder { return e.String(value.String()) } -func (e *EventEncoder) Hname(value ScHname) *EventEncoder { +func (e *EventEncoder) Hname(value wasmtypes.ScHname) *EventEncoder { return e.String(value.String()) } @@ -74,7 +76,7 @@ func (e *EventEncoder) Int64(value int64) *EventEncoder { return e.String(strconv.FormatInt(value, 10)) } -func (e *EventEncoder) RequestID(value ScRequestID) *EventEncoder { +func (e *EventEncoder) RequestID(value wasmtypes.ScRequestID) *EventEncoder { return e.String(value.String()) } diff --git a/packages/vm/wasmlib/go/wasmlib/exports.go b/packages/vm/wasmlib/go/wasmlib/exports.go index 5787959311..575c2ea59d 100644 --- a/packages/vm/wasmlib/go/wasmlib/exports.go +++ b/packages/vm/wasmlib/go/wasmlib/exports.go @@ -5,13 +5,8 @@ package wasmlib //export on_call func OnCall(index int32) { - ctx := ScFuncContext{} - ctx.Require(GetObjectID(OBJ_ID_ROOT, KeyState, TYPE_MAP) == OBJ_ID_STATE, "object id mismatch") - ctx.Require(GetObjectID(OBJ_ID_ROOT, KeyParams, TYPE_MAP) == OBJ_ID_PARAMS, "object id mismatch") - ctx.Require(GetObjectID(OBJ_ID_ROOT, KeyResults, TYPE_MAP) == OBJ_ID_RESULTS, "object id mismatch") - if (index & 0x8000) == 0 { - AddFunc(nil)[index](ctx) + AddFunc(nil)[index](ScFuncContext{}) return } @@ -28,24 +23,19 @@ func ViewError(ctx ScViewContext) { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -type ScExports struct { - exports ScMutableStringArray -} +type ScExports struct{} func NewScExports() ScExports { - exports := Root.GetStringArray(KeyExports) - // tell host what our highest predefined key is - // this helps detect missing or extra keys - exports.GetString(int32(KeyZzzzzzz)).SetValue("Go:KEY_ZZZZZZZ") - return ScExports{exports: exports} + ExportWasmTag() + return ScExports{} } func (ctx ScExports) AddFunc(name string, f ScFuncContextFunction) { index := int32(len(AddFunc(f))) - 1 - ctx.exports.GetString(index).SetValue(name) + ExportName(index, name) } func (ctx ScExports) AddView(name string, v ScViewContextFunction) { index := int32(len(AddView(v))) - 1 - ctx.exports.GetString(index | 0x8000).SetValue(name) + ExportName(index|0x8000, name) } diff --git a/packages/vm/wasmlib/go/wasmlib/hashtypes.go b/packages/vm/wasmlib/go/wasmlib/hashtypes.go deleted file mode 100644 index 70b0904930..0000000000 --- a/packages/vm/wasmlib/go/wasmlib/hashtypes.go +++ /dev/null @@ -1,254 +0,0 @@ -// Copyright 2020 IOTA Stiftung -// SPDX-License-Identifier: Apache-2.0 - -package wasmlib - -import ( - "encoding/binary" -) - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -type ScAddress struct { - id [33]byte -} - -func NewScAddressFromBytes(bytes []byte) ScAddress { - o := ScAddress{} - if len(bytes) != len(o.id) { - Panic("invalid address id length") - } - copy(o.id[:], bytes) - return o -} - -func (o ScAddress) AsAgentID() ScAgentID { - a := ScAgentID{} - // agent id is address padded with zeroes - copy(a.id[:], o.id[:]) - return a -} - -func (o ScAddress) Bytes() []byte { - return o.id[:] -} - -func (o ScAddress) KeyID() Key32 { - return GetKeyIDFromBytes(o.id[:]) -} - -func (o ScAddress) String() string { - return base58Encode(o.id[:]) -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -type ScAgentID struct { - id [37]byte -} - -func NewScAgentID(address ScAddress, hContract ScHname) ScAgentID { - o := ScAgentID{} - copy(o.id[:], address.Bytes()) - copy(o.id[33:], hContract.Bytes()) - return o -} - -func NewScAgentIDFromBytes(bytes []byte) ScAgentID { - o := ScAgentID{} - if len(bytes) != len(o.id) { - Panic("invalid agent id length") - } - copy(o.id[:], bytes) - return o -} - -func (o ScAgentID) Address() ScAddress { - a := ScAddress{} - copy(a.id[:], o.id[:]) - return a -} - -func (o ScAgentID) Bytes() []byte { - return o.id[:] -} - -func (o ScAgentID) Hname() ScHname { - return NewScHnameFromBytes(o.id[33:]) -} - -func (o ScAgentID) KeyID() Key32 { - return GetKeyIDFromBytes(o.id[:]) -} - -func (o ScAgentID) IsAddress() bool { - return o.Hname() == ScHname(0) -} - -func (o ScAgentID) String() string { - return base58Encode(o.id[:]) -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -type ScChainID struct { - id [33]byte -} - -func NewScChainIDFromBytes(bytes []byte) ScChainID { - o := ScChainID{} - if len(bytes) != len(o.id) { - Panic("invalid chain id length") - } - copy(o.id[:], bytes) - return o -} - -func (o ScChainID) Address() ScAddress { - a := ScAddress{} - copy(a.id[:], o.id[:]) - return a -} - -func (o ScChainID) Bytes() []byte { - return o.id[:] -} - -func (o ScChainID) KeyID() Key32 { - return GetKeyIDFromBytes(o.id[:]) -} - -func (o ScChainID) String() string { - return base58Encode(o.id[:]) -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -type ScColor struct { - id [32]byte -} - -var ( - IOTA = ScColor{} - MINT = ScColor{} -) - -func init() { - for i := range MINT.id { - MINT.id[i] = 0xff - } -} - -func NewScColorFromBytes(bytes []byte) ScColor { - o := ScColor{} - if len(bytes) != len(o.id) { - Panic("invalid color id length") - } - copy(o.id[:], bytes) - return o -} - -func NewScColorFromRequestID(requestID ScRequestID) ScColor { - o := ScColor{} - copy(o.id[:], requestID.Bytes()) - return o -} - -func (o ScColor) Bytes() []byte { - return o.id[:] -} - -func (o ScColor) KeyID() Key32 { - return GetKeyIDFromBytes(o.id[:]) -} - -func (o ScColor) String() string { - return base58Encode(o.id[:]) -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -type ScHash struct { - id [32]byte -} - -func NewScHashFromBytes(bytes []byte) ScHash { - o := ScHash{} - if len(bytes) != len(o.id) { - Panic("invalid hash id length") - } - copy(o.id[:], bytes) - return o -} - -func (o ScHash) Bytes() []byte { - return o.id[:] -} - -func (o ScHash) KeyID() Key32 { - return GetKeyIDFromBytes(o.id[:]) -} - -func (o ScHash) String() string { - return base58Encode(o.id[:]) -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -type ScHname uint32 - -func NewScHname(name string) ScHname { - return ScFuncContext{}.Utility().Hname(name) -} - -func NewScHnameFromBytes(bytes []byte) ScHname { - return ScHname(binary.LittleEndian.Uint32(bytes)) -} - -func (hn ScHname) Bytes() []byte { - bytes := make([]byte, 4) - binary.LittleEndian.PutUint32(bytes, uint32(hn)) - return bytes -} - -func (hn ScHname) KeyID() Key32 { - return GetKeyIDFromBytes(hn.Bytes()) -} - -func (hn ScHname) String() string { - const hex = "0123456789abcdef" - res := make([]byte, 8) - val := hn - for i := 0; i < 8; i++ { - res[7-i] = hex[val&0x0f] - val >>= 4 - } - return string(res) -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -type ScRequestID struct { - id [34]byte -} - -func NewScRequestIDFromBytes(bytes []byte) ScRequestID { - o := ScRequestID{} - if len(bytes) != len(o.id) { - Panic("invalid request id length") - } - copy(o.id[:], bytes) - return o -} - -func (o ScRequestID) Bytes() []byte { - return o.id[:] -} - -func (o ScRequestID) KeyID() Key32 { - return GetKeyIDFromBytes(o.id[:]) -} - -func (o ScRequestID) String() string { - return base58Encode(o.id[:]) -} diff --git a/packages/vm/wasmlib/go/wasmlib/host.go b/packages/vm/wasmlib/go/wasmlib/host.go index 8927bd0919..b28e972c8e 100644 --- a/packages/vm/wasmlib/go/wasmlib/host.go +++ b/packages/vm/wasmlib/go/wasmlib/host.go @@ -3,41 +3,6 @@ package wasmlib -import "encoding/binary" - -//nolint:revive -const ( - // all TYPE_* values should exactly match the counterpart OBJTYPE_* values on the host! - TYPE_ARRAY int32 = 0x20 - TYPE_ARRAY16 int32 = 0x60 - TYPE_CALL int32 = 0x80 - TYPE_MASK int32 = 0x1f - - TYPE_ADDRESS int32 = 1 - TYPE_AGENT_ID int32 = 2 - TYPE_BOOL int32 = 3 - TYPE_BYTES int32 = 4 - TYPE_CHAIN_ID int32 = 5 - TYPE_COLOR int32 = 6 - TYPE_HASH int32 = 7 - TYPE_HNAME int32 = 8 - TYPE_INT8 int32 = 9 - TYPE_INT16 int32 = 10 - TYPE_INT32 int32 = 11 - TYPE_INT64 int32 = 12 - TYPE_MAP int32 = 13 - TYPE_REQUEST_ID int32 = 14 - TYPE_STRING int32 = 15 - - OBJ_ID_NULL int32 = 0 - OBJ_ID_ROOT int32 = 1 - OBJ_ID_STATE int32 = 2 - OBJ_ID_PARAMS int32 = 3 - OBJ_ID_RESULTS int32 = 4 -) - -var TypeSizes = [...]uint8{0, 33, 37, 1, 0, 33, 32, 32, 4, 1, 2, 4, 8, 0, 34, 0} - type ( ScFuncContextFunction func(ScFuncContext) ScViewContextFunction func(ScViewContext) @@ -45,14 +10,8 @@ type ( ScHost interface { AddFunc(f ScFuncContextFunction) []ScFuncContextFunction AddView(v ScViewContextFunction) []ScViewContextFunction - CallFunc(objID, keyID int32, params []byte) []byte - DelKey(objID, keyID, typeID int32) - Exists(objID, keyID, typeID int32) bool - GetBytes(objID, keyID, typeID int32) []byte - GetKeyIDFromBytes(bytes []byte) int32 - GetKeyIDFromString(key string) int32 - GetObjectID(objID, keyID, typeID int32) int32 - SetBytes(objID, keyID, typeID int32, value []byte) + ExportName(index int32, name string) + ExportWasmTag() Sandbox(funcNr int32, params []byte) []byte StateDelete(key []byte) StateExists(key []byte) bool @@ -78,68 +37,20 @@ func ConnectHost(h ScHost) ScHost { return oldHost } -func CallFunc(objID int32, keyID Key32, params []byte) []byte { - return host.CallFunc(objID, int32(keyID), params) -} - -func Clear(objID int32) { - var zero [4]byte - SetBytes(objID, KeyLength, TYPE_INT32, zero[:]) -} - -func DelKey(objID int32, keyID Key32, typeID int32) { - host.DelKey(objID, int32(keyID), typeID) -} - -func Exists(objID int32, keyID Key32, typeID int32) bool { - return host.Exists(objID, int32(keyID), typeID) -} - -func GetBytes(objID int32, keyID Key32, typeID int32) []byte { - bytes := host.GetBytes(objID, int32(keyID), typeID) - if len(bytes) == 0 { - return make([]byte, TypeSizes[typeID]) - } - return bytes -} - -func GetKeyIDFromBytes(bytes []byte) Key32 { - return Key32(host.GetKeyIDFromBytes(bytes)) -} - -func GetKeyIDFromString(key string) Key32 { - return Key32(host.GetKeyIDFromString(key)) -} - -func GetKeyIDFromUint64(value uint64, nrOfBytes int) Key32 { - bytes := make([]byte, 8) - binary.LittleEndian.PutUint64(bytes, value) - return GetKeyIDFromBytes(bytes[:nrOfBytes]) -} - -func GetLength(objID int32) int32 { - bytes := GetBytes(objID, KeyLength, TYPE_INT32) - return int32(binary.LittleEndian.Uint32(bytes)) -} - -func GetObjectID(objID int32, keyID Key32, typeID int32) int32 { - return host.GetObjectID(objID, int32(keyID), typeID) -} - func Log(text string) { - SetBytes(1, KeyLog, TYPE_STRING, []byte(text)) + host.Sandbox(FnLog, []byte(text)) } func Panic(text string) { - SetBytes(1, KeyPanic, TYPE_STRING, []byte(text)) + host.Sandbox(FnPanic, []byte(text)) } -func SetBytes(objID int32, keyID Key32, typeID int32, value []byte) { - host.SetBytes(objID, int32(keyID), typeID, value) +func ExportName(index int32, name string) { + host.ExportName(index, name) } -func Trace(text string) { - SetBytes(1, KeyTrace, TYPE_STRING, []byte(text)) +func ExportWasmTag() { + host.ExportWasmTag() } func Sandbox(funcNr int32, params []byte) []byte { diff --git a/packages/vm/wasmlib/go/wasmlib/immutable.go b/packages/vm/wasmlib/go/wasmlib/immutable.go deleted file mode 100644 index c8290ed720..0000000000 --- a/packages/vm/wasmlib/go/wasmlib/immutable.go +++ /dev/null @@ -1,586 +0,0 @@ -// Copyright 2020 IOTA Stiftung -// SPDX-License-Identifier: Apache-2.0 - -package wasmlib - -import ( - "encoding/binary" - "strconv" -) - -type ScImmutableAddress struct { - objID int32 - keyID Key32 -} - -func NewScImmutableAddress(objID int32, keyID Key32) ScImmutableAddress { - return ScImmutableAddress{objID: objID, keyID: keyID} -} - -func (o ScImmutableAddress) Exists() bool { - return Exists(o.objID, o.keyID, TYPE_ADDRESS) -} - -func (o ScImmutableAddress) String() string { - return o.Value().String() -} - -func (o ScImmutableAddress) Value() ScAddress { - return NewScAddressFromBytes(GetBytes(o.objID, o.keyID, TYPE_ADDRESS)) -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -type ScImmutableAgentID struct { - objID int32 - keyID Key32 -} - -func NewScImmutableAgentID(objID int32, keyID Key32) ScImmutableAgentID { - return ScImmutableAgentID{objID: objID, keyID: keyID} -} - -func (o ScImmutableAgentID) Exists() bool { - return Exists(o.objID, o.keyID, TYPE_AGENT_ID) -} - -func (o ScImmutableAgentID) String() string { - return o.Value().String() -} - -func (o ScImmutableAgentID) Value() ScAgentID { - return NewScAgentIDFromBytes(GetBytes(o.objID, o.keyID, TYPE_AGENT_ID)) -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -type ScImmutableBool struct { - objID int32 - keyID Key32 -} - -func NewScImmutableBool(objID int32, keyID Key32) ScImmutableBool { - return ScImmutableBool{objID: objID, keyID: keyID} -} - -func (o ScImmutableBool) Exists() bool { - return Exists(o.objID, o.keyID, TYPE_BOOL) -} - -func (o ScImmutableBool) String() string { - if o.Value() { - return "1" - } - return "0" -} - -func (o ScImmutableBool) Value() bool { - bytes := GetBytes(o.objID, o.keyID, TYPE_BOOL) - return bytes[0] != 0 -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -type ScImmutableBytes struct { - objID int32 - keyID Key32 -} - -func NewScImmutableBytes(objID int32, keyID Key32) ScImmutableBytes { - return ScImmutableBytes{objID: objID, keyID: keyID} -} - -func (o ScImmutableBytes) Exists() bool { - return Exists(o.objID, o.keyID, TYPE_BYTES) -} - -func (o ScImmutableBytes) String() string { - return base58Encode(o.Value()) -} - -func (o ScImmutableBytes) Value() []byte { - return GetBytes(o.objID, o.keyID, TYPE_BYTES) -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -type ScImmutableChainID struct { - objID int32 - keyID Key32 -} - -func NewScImmutableChainID(objID int32, keyID Key32) ScImmutableChainID { - return ScImmutableChainID{objID: objID, keyID: keyID} -} - -func (o ScImmutableChainID) Exists() bool { - return Exists(o.objID, o.keyID, TYPE_CHAIN_ID) -} - -func (o ScImmutableChainID) String() string { - return o.Value().String() -} - -func (o ScImmutableChainID) Value() ScChainID { - return NewScChainIDFromBytes(GetBytes(o.objID, o.keyID, TYPE_CHAIN_ID)) -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -type ScImmutableColor struct { - objID int32 - keyID Key32 -} - -func NewScImmutableColor(objID int32, keyID Key32) ScImmutableColor { - return ScImmutableColor{objID: objID, keyID: keyID} -} - -func (o ScImmutableColor) Exists() bool { - return Exists(o.objID, o.keyID, TYPE_COLOR) -} - -func (o ScImmutableColor) String() string { - return o.Value().String() -} - -func (o ScImmutableColor) Value() ScColor { - return NewScColorFromBytes(GetBytes(o.objID, o.keyID, TYPE_COLOR)) -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -type ScImmutableColorArray struct { - objID int32 -} - -func (o ScImmutableColorArray) GetColor(index int32) ScImmutableColor { - return ScImmutableColor{objID: o.objID, keyID: Key32(index)} -} - -func (o ScImmutableColorArray) Length() int32 { - return GetLength(o.objID) -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -type ScImmutableHash struct { - objID int32 - keyID Key32 -} - -func NewScImmutableHash(objID int32, keyID Key32) ScImmutableHash { - return ScImmutableHash{objID: objID, keyID: keyID} -} - -func (o ScImmutableHash) Exists() bool { - return Exists(o.objID, o.keyID, TYPE_HASH) -} - -func (o ScImmutableHash) String() string { - return o.Value().String() -} - -func (o ScImmutableHash) Value() ScHash { - return NewScHashFromBytes(GetBytes(o.objID, o.keyID, TYPE_HASH)) -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -type ScImmutableHname struct { - objID int32 - keyID Key32 -} - -func NewScImmutableHname(objID int32, keyID Key32) ScImmutableHname { - return ScImmutableHname{objID: objID, keyID: keyID} -} - -func (o ScImmutableHname) Exists() bool { - return Exists(o.objID, o.keyID, TYPE_HNAME) -} - -func (o ScImmutableHname) String() string { - return o.Value().String() -} - -func (o ScImmutableHname) Value() ScHname { - return NewScHnameFromBytes(GetBytes(o.objID, o.keyID, TYPE_HNAME)) -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -type ScImmutableInt8 struct { - objID int32 - keyID Key32 -} - -func NewScImmutableInt8(objID int32, keyID Key32) ScImmutableInt8 { - return ScImmutableInt8{objID: objID, keyID: keyID} -} - -func (o ScImmutableInt8) Exists() bool { - return Exists(o.objID, o.keyID, TYPE_INT8) -} - -func (o ScImmutableInt8) String() string { - return strconv.FormatInt(int64(o.Value()), 10) -} - -func (o ScImmutableInt8) Value() int8 { - bytes := GetBytes(o.objID, o.keyID, TYPE_INT8) - return int8(bytes[0]) -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -type ScImmutableInt16 struct { - objID int32 - keyID Key32 -} - -func NewScImmutableInt16(objID int32, keyID Key32) ScImmutableInt16 { - return ScImmutableInt16{objID: objID, keyID: keyID} -} - -func (o ScImmutableInt16) Exists() bool { - return Exists(o.objID, o.keyID, TYPE_INT16) -} - -func (o ScImmutableInt16) String() string { - return strconv.FormatInt(int64(o.Value()), 10) -} - -func (o ScImmutableInt16) Value() int16 { - bytes := GetBytes(o.objID, o.keyID, TYPE_INT16) - return int16(binary.LittleEndian.Uint16(bytes)) -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -type ScImmutableInt32 struct { - objID int32 - keyID Key32 -} - -func NewScImmutableInt32(objID int32, keyID Key32) ScImmutableInt32 { - return ScImmutableInt32{objID: objID, keyID: keyID} -} - -func (o ScImmutableInt32) Exists() bool { - return Exists(o.objID, o.keyID, TYPE_INT32) -} - -func (o ScImmutableInt32) String() string { - return strconv.FormatInt(int64(o.Value()), 10) -} - -func (o ScImmutableInt32) Value() int32 { - bytes := GetBytes(o.objID, o.keyID, TYPE_INT32) - return int32(binary.LittleEndian.Uint32(bytes)) -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -type ScImmutableInt64 struct { - objID int32 - keyID Key32 -} - -func NewScImmutableInt64(objID int32, keyID Key32) ScImmutableInt64 { - return ScImmutableInt64{objID: objID, keyID: keyID} -} - -func (o ScImmutableInt64) Exists() bool { - return Exists(o.objID, o.keyID, TYPE_INT64) -} - -func (o ScImmutableInt64) String() string { - return strconv.FormatInt(o.Value(), 10) -} - -func (o ScImmutableInt64) Value() int64 { - bytes := GetBytes(o.objID, o.keyID, TYPE_INT64) - return int64(binary.LittleEndian.Uint64(bytes)) -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -type ScImmutableMap struct { - objID int32 -} - -func (o ScImmutableMap) CallFunc(keyID Key32, params []byte) []byte { - return CallFunc(o.objID, keyID, params) -} - -func (o ScImmutableMap) GetAddress(key MapKey) ScImmutableAddress { - return ScImmutableAddress{objID: o.objID, keyID: key.KeyID()} -} - -func (o ScImmutableMap) GetAgentID(key MapKey) ScImmutableAgentID { - return ScImmutableAgentID{objID: o.objID, keyID: key.KeyID()} -} - -func (o ScImmutableMap) GetBool(key MapKey) ScImmutableBool { - return ScImmutableBool{objID: o.objID, keyID: key.KeyID()} -} - -func (o ScImmutableMap) GetBytes(key MapKey) ScImmutableBytes { - return ScImmutableBytes{objID: o.objID, keyID: key.KeyID()} -} - -func (o ScImmutableMap) GetChainID(key MapKey) ScImmutableChainID { - return ScImmutableChainID{objID: o.objID, keyID: key.KeyID()} -} - -func (o ScImmutableMap) GetColor(key MapKey) ScImmutableColor { - return ScImmutableColor{objID: o.objID, keyID: key.KeyID()} -} - -func (o ScImmutableMap) GetColorArray(key MapKey) ScImmutableColorArray { - arrID := GetObjectID(o.objID, key.KeyID(), TYPE_COLOR|TYPE_ARRAY) - return ScImmutableColorArray{objID: arrID} -} - -func (o ScImmutableMap) GetHash(key MapKey) ScImmutableHash { - return ScImmutableHash{objID: o.objID, keyID: key.KeyID()} -} - -func (o ScImmutableMap) GetHname(key MapKey) ScImmutableHname { - return ScImmutableHname{objID: o.objID, keyID: key.KeyID()} -} - -func (o ScImmutableMap) GetInt8(key MapKey) ScImmutableInt8 { - return ScImmutableInt8{objID: o.objID, keyID: key.KeyID()} -} - -func (o ScImmutableMap) GetInt16(key MapKey) ScImmutableInt16 { - return ScImmutableInt16{objID: o.objID, keyID: key.KeyID()} -} - -func (o ScImmutableMap) GetInt32(key MapKey) ScImmutableInt32 { - return ScImmutableInt32{objID: o.objID, keyID: key.KeyID()} -} - -func (o ScImmutableMap) GetInt64(key MapKey) ScImmutableInt64 { - return ScImmutableInt64{objID: o.objID, keyID: key.KeyID()} -} - -func (o ScImmutableMap) GetMap(key MapKey) ScImmutableMap { - mapID := GetObjectID(o.objID, key.KeyID(), TYPE_MAP) - return ScImmutableMap{objID: mapID} -} - -func (o ScImmutableMap) GetMapArray(key MapKey) ScImmutableMapArray { - arrID := GetObjectID(o.objID, key.KeyID(), TYPE_MAP|TYPE_ARRAY) - return ScImmutableMapArray{objID: arrID} -} - -func (o ScImmutableMap) GetRequestID(key MapKey) ScImmutableRequestID { - return ScImmutableRequestID{objID: o.objID, keyID: key.KeyID()} -} - -func (o ScImmutableMap) GetString(key MapKey) ScImmutableString { - return ScImmutableString{objID: o.objID, keyID: key.KeyID()} -} - -func (o ScImmutableMap) GetStringArray(key MapKey) ScImmutableStringArray { - arrID := GetObjectID(o.objID, key.KeyID(), TYPE_STRING|TYPE_ARRAY) - return ScImmutableStringArray{objID: arrID} -} - -func (o ScImmutableMap) GetUint8(key MapKey) ScImmutableUint8 { - return ScImmutableUint8{objID: o.objID, keyID: key.KeyID()} -} - -func (o ScImmutableMap) GetUint16(key MapKey) ScImmutableUint16 { - return ScImmutableUint16{objID: o.objID, keyID: key.KeyID()} -} - -func (o ScImmutableMap) GetUint32(key MapKey) ScImmutableUint32 { - return ScImmutableUint32{objID: o.objID, keyID: key.KeyID()} -} - -func (o ScImmutableMap) GetUint64(key MapKey) ScImmutableUint64 { - return ScImmutableUint64{objID: o.objID, keyID: key.KeyID()} -} - -func (o ScImmutableMap) MapID() int32 { - return o.objID -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -type ScImmutableMapArray struct { - objID int32 -} - -func (o ScImmutableMapArray) GetMap(index int32) ScImmutableMap { - mapID := GetObjectID(o.objID, Key32(index), TYPE_MAP) - return ScImmutableMap{objID: mapID} -} - -func (o ScImmutableMapArray) Length() int32 { - return GetLength(o.objID) -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -type ScImmutableRequestID struct { - objID int32 - keyID Key32 -} - -func NewScImmutableRequestID(objID int32, keyID Key32) ScImmutableRequestID { - return ScImmutableRequestID{objID: objID, keyID: keyID} -} - -func (o ScImmutableRequestID) Exists() bool { - return Exists(o.objID, o.keyID, TYPE_REQUEST_ID) -} - -func (o ScImmutableRequestID) String() string { - return o.Value().String() -} - -func (o ScImmutableRequestID) Value() ScRequestID { - return NewScRequestIDFromBytes(GetBytes(o.objID, o.keyID, TYPE_REQUEST_ID)) -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -type ScImmutableString struct { - objID int32 - keyID Key32 -} - -func NewScImmutableString(objID int32, keyID Key32) ScImmutableString { - return ScImmutableString{objID: objID, keyID: keyID} -} - -func (o ScImmutableString) Exists() bool { - return Exists(o.objID, o.keyID, TYPE_STRING) -} - -func (o ScImmutableString) String() string { - return o.Value() -} - -func (o ScImmutableString) Value() string { - bytes := GetBytes(o.objID, o.keyID, TYPE_STRING) - if bytes == nil { - return "" - } - return string(bytes) -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -type ScImmutableStringArray struct { - objID int32 -} - -func (o ScImmutableStringArray) GetString(index int32) ScImmutableString { - return ScImmutableString{objID: o.objID, keyID: Key32(index)} -} - -func (o ScImmutableStringArray) Length() int32 { - return GetLength(o.objID) -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -type ScImmutableUint8 struct { - objID int32 - keyID Key32 -} - -func NewScImmutableUint8(objID int32, keyID Key32) ScImmutableUint8 { - return ScImmutableUint8{objID: objID, keyID: keyID} -} - -func (o ScImmutableUint8) Exists() bool { - return Exists(o.objID, o.keyID, TYPE_INT8) -} - -func (o ScImmutableUint8) String() string { - return strconv.FormatUint(uint64(o.Value()), 10) -} - -func (o ScImmutableUint8) Value() uint8 { - bytes := GetBytes(o.objID, o.keyID, TYPE_INT8) - return bytes[0] -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -type ScImmutableUint16 struct { - objID int32 - keyID Key32 -} - -func NewScImmutableUint16(objID int32, keyID Key32) ScImmutableUint16 { - return ScImmutableUint16{objID: objID, keyID: keyID} -} - -func (o ScImmutableUint16) Exists() bool { - return Exists(o.objID, o.keyID, TYPE_INT16) -} - -func (o ScImmutableUint16) String() string { - return strconv.FormatUint(uint64(o.Value()), 10) -} - -func (o ScImmutableUint16) Value() uint16 { - bytes := GetBytes(o.objID, o.keyID, TYPE_INT16) - return binary.LittleEndian.Uint16(bytes) -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -type ScImmutableUint32 struct { - objID int32 - keyID Key32 -} - -func NewScImmutableUint32(objID int32, keyID Key32) ScImmutableUint32 { - return ScImmutableUint32{objID: objID, keyID: keyID} -} - -func (o ScImmutableUint32) Exists() bool { - return Exists(o.objID, o.keyID, TYPE_INT32) -} - -func (o ScImmutableUint32) String() string { - return strconv.FormatUint(uint64(o.Value()), 10) -} - -func (o ScImmutableUint32) Value() uint32 { - bytes := GetBytes(o.objID, o.keyID, TYPE_INT32) - return binary.LittleEndian.Uint32(bytes) -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -type ScImmutableUint64 struct { - objID int32 - keyID Key32 -} - -func NewScImmutableUint64(objID int32, keyID Key32) ScImmutableUint64 { - return ScImmutableUint64{objID: objID, keyID: keyID} -} - -func (o ScImmutableUint64) Exists() bool { - return Exists(o.objID, o.keyID, TYPE_INT64) -} - -func (o ScImmutableUint64) String() string { - return strconv.FormatUint(o.Value(), 10) -} - -func (o ScImmutableUint64) Value() uint64 { - bytes := GetBytes(o.objID, o.keyID, TYPE_INT64) - return binary.LittleEndian.Uint64(bytes) -} diff --git a/packages/vm/wasmlib/go/wasmlib/inithost.go b/packages/vm/wasmlib/go/wasmlib/inithost.go index 764cb92561..85a9fc4e4b 100644 --- a/packages/vm/wasmlib/go/wasmlib/inithost.go +++ b/packages/vm/wasmlib/go/wasmlib/inithost.go @@ -4,15 +4,14 @@ package wasmlib type InitHost struct { - funcs []ScFuncContextFunction - views []ScViewContextFunction - params map[int32][]byte + funcs []ScFuncContextFunction + views []ScViewContextFunction } var _ ScHost = &InitHost{} func NewInitHost() *InitHost { - return &InitHost{params: make(map[int32][]byte)} + return &InitHost{} } func (h InitHost) AddFunc(f ScFuncContextFunction) []ScFuncContextFunction { @@ -29,65 +28,12 @@ func (h InitHost) AddView(v ScViewContextFunction) []ScViewContextFunction { return h.views } -func (h InitHost) CallFunc(objID, keyID int32, params []byte) []byte { - Panic("InitHost::CallFunc") - return nil -} - -func (h InitHost) DelKey(objID, keyID, typeID int32) { - Panic("InitHost::DelKey") -} - -func (h InitHost) Exists(objID, keyID, typeID int32) bool { - if objID == int32(KeyParams) { - _, exists := h.params[keyID] - return exists - } - Panic("InitHost::Exists") - return false -} - -func (h InitHost) GetBytes(objID, keyID, typeID int32) []byte { - if objID == int32(KeyMaps) && keyID == int32(KeyLength) { - return nil - } - if objID == int32(KeyParams) { - return h.params[keyID] - } - Panic("InitHost::GetBytes") - return nil -} - -func (h InitHost) GetKeyIDFromBytes(bytes []byte) int32 { - Panic("InitHost::GetKeyIDFromBytes") - return 0 -} - -func (h InitHost) GetKeyIDFromString(key string) int32 { - Panic("InitHost::GetKeyIDFromString") - return 0 -} - -func (h InitHost) GetObjectID(objID, keyID, typeID int32) int32 { - if objID == 1 && keyID == int32(KeyMaps) { - return keyID - } - if objID == int32(KeyMaps) && keyID == 0 { - return int32(KeyParams) - } - Panic("InitHost::GetObjectID") - return 0 +func (h InitHost) ExportName(index int32, name string) { + panic("implement me") } -func (h InitHost) SetBytes(objID, keyID, typeID int32, value []byte) { - if objID == 1 && keyID == int32(KeyPanic) { - panic(string(value)) - } - if objID == int32(KeyParams) { - h.params[keyID] = value - return - } - Panic("InitHost::SetBytes") +func (h InitHost) ExportWasmTag() { + h.ExportName(-1, "WASM::GO::SOLO") } func (h InitHost) Sandbox(funcNr int32, params []byte) []byte { diff --git a/packages/vm/wasmlib/go/wasmlib/keys.go b/packages/vm/wasmlib/go/wasmlib/keys.go deleted file mode 100644 index 62c5ccbba0..0000000000 --- a/packages/vm/wasmlib/go/wasmlib/keys.go +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright 2020 IOTA Stiftung -// SPDX-License-Identifier: Apache-2.0 - -package wasmlib - -type MapKey interface { - KeyID() Key32 -} - -type Key string - -func (key Key) KeyID() Key32 { - return GetKeyIDFromString(string(key)) -} - -func KeyID(key string) Key32 { - return Key(key).KeyID() -} - -type Key32 int32 - -func (key Key32) KeyID() Key32 { - return key -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -const ( - KeyAccountID = Key32(-1) - KeyAddress = Key32(-2) - KeyBalances = Key32(-3) - KeyBase58Decode = Key32(-4) - KeyBase58Encode = Key32(-5) - KeyBlsAddress = Key32(-6) - KeyBlsAggregate = Key32(-7) - KeyBlsValid = Key32(-8) - KeyCall = Key32(-9) - KeyCaller = Key32(-10) - KeyChainID = Key32(-11) - KeyChainOwnerID = Key32(-12) - KeyColor = Key32(-13) - KeyContract = Key32(-14) - KeyContractCreator = Key32(-15) - KeyDeploy = Key32(-16) - KeyEd25519Address = Key32(-17) - KeyEd25519Valid = Key32(-18) - KeyEvent = Key32(-19) - KeyExports = Key32(-20) - KeyHashBlake2b = Key32(-21) - KeyHashSha3 = Key32(-22) - KeyHname = Key32(-23) - KeyIncoming = Key32(-24) - KeyLength = Key32(-25) - KeyLog = Key32(-26) - KeyMaps = Key32(-27) - KeyMinted = Key32(-28) - KeyPanic = Key32(-29) - KeyParams = Key32(-30) - KeyPost = Key32(-31) - KeyRandom = Key32(-32) - KeyRequestID = Key32(-33) - KeyResults = Key32(-34) - KeyReturn = Key32(-35) - KeyState = Key32(-36) - KeyTimestamp = Key32(-37) - KeyTrace = Key32(-38) - KeyTransfers = Key32(-39) - KeyUtility = Key32(-40) - KeyZzzzzzz = Key32(-41) -) diff --git a/packages/vm/wasmlib/go/wasmlib/mutable.go b/packages/vm/wasmlib/go/wasmlib/mutable.go deleted file mode 100644 index e45d459b83..0000000000 --- a/packages/vm/wasmlib/go/wasmlib/mutable.go +++ /dev/null @@ -1,764 +0,0 @@ -// Copyright 2020 IOTA Stiftung -// SPDX-License-Identifier: Apache-2.0 - -package wasmlib - -import ( - "encoding/binary" - "strconv" -) - -var Root = ScMutableMap{objID: OBJ_ID_ROOT} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -type ScMutableAddress struct { - objID int32 - keyID Key32 -} - -func NewScMutableAddress(objID int32, keyID Key32) ScMutableAddress { - return ScMutableAddress{objID: objID, keyID: keyID} -} - -func (o ScMutableAddress) Delete() { - DelKey(o.objID, o.keyID, TYPE_ADDRESS) -} - -func (o ScMutableAddress) Exists() bool { - return Exists(o.objID, o.keyID, TYPE_ADDRESS) -} - -func (o ScMutableAddress) SetValue(value ScAddress) { - SetBytes(o.objID, o.keyID, TYPE_ADDRESS, value.Bytes()) -} - -func (o ScMutableAddress) String() string { - return o.Value().String() -} - -func (o ScMutableAddress) Value() ScAddress { - return NewScAddressFromBytes(GetBytes(o.objID, o.keyID, TYPE_ADDRESS)) -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -type ScMutableAgentID struct { - objID int32 - keyID Key32 -} - -func NewScMutableAgentID(objID int32, keyID Key32) ScMutableAgentID { - return ScMutableAgentID{objID: objID, keyID: keyID} -} - -func (o ScMutableAgentID) Delete() { - DelKey(o.objID, o.keyID, TYPE_AGENT_ID) -} - -func (o ScMutableAgentID) Exists() bool { - return Exists(o.objID, o.keyID, TYPE_AGENT_ID) -} - -func (o ScMutableAgentID) SetValue(value ScAgentID) { - SetBytes(o.objID, o.keyID, TYPE_AGENT_ID, value.Bytes()) -} - -func (o ScMutableAgentID) String() string { - return o.Value().String() -} - -func (o ScMutableAgentID) Value() ScAgentID { - return NewScAgentIDFromBytes(GetBytes(o.objID, o.keyID, TYPE_AGENT_ID)) -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -type ScMutableBool struct { - objID int32 - keyID Key32 -} - -func NewScMutableBool(objID int32, keyID Key32) ScMutableBool { - return ScMutableBool{objID: objID, keyID: keyID} -} - -func (o ScMutableBool) Delete() { - DelKey(o.objID, o.keyID, TYPE_BOOL) -} - -func (o ScMutableBool) Exists() bool { - return Exists(o.objID, o.keyID, TYPE_BOOL) -} - -func (o ScMutableBool) SetValue(value bool) { - bytes := make([]byte, 1) - if value { - bytes[0] = 1 - } - SetBytes(o.objID, o.keyID, TYPE_BOOL, bytes) -} - -func (o ScMutableBool) String() string { - if o.Value() { - return "1" - } - return "0" -} - -func (o ScMutableBool) Value() bool { - bytes := GetBytes(o.objID, o.keyID, TYPE_BOOL) - return bytes[0] != 0 -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -type ScMutableBytes struct { - objID int32 - keyID Key32 -} - -func NewScMutableBytes(objID int32, keyID Key32) ScMutableBytes { - return ScMutableBytes{objID: objID, keyID: keyID} -} - -func (o ScMutableBytes) Delete() { - DelKey(o.objID, o.keyID, TYPE_BYTES) -} - -func (o ScMutableBytes) Exists() bool { - return Exists(o.objID, o.keyID, TYPE_BYTES) -} - -func (o ScMutableBytes) SetValue(value []byte) { - SetBytes(o.objID, o.keyID, TYPE_BYTES, value) -} - -func (o ScMutableBytes) String() string { - return base58Encode(o.Value()) -} - -func (o ScMutableBytes) Value() []byte { - return GetBytes(o.objID, o.keyID, TYPE_BYTES) -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -type ScMutableChainID struct { - objID int32 - keyID Key32 -} - -func NewScMutableChainID(objID int32, keyID Key32) ScMutableChainID { - return ScMutableChainID{objID: objID, keyID: keyID} -} - -func (o ScMutableChainID) Delete() { - DelKey(o.objID, o.keyID, TYPE_CHAIN_ID) -} - -func (o ScMutableChainID) Exists() bool { - return Exists(o.objID, o.keyID, TYPE_CHAIN_ID) -} - -func (o ScMutableChainID) SetValue(value ScChainID) { - SetBytes(o.objID, o.keyID, TYPE_CHAIN_ID, value.Bytes()) -} - -func (o ScMutableChainID) String() string { - return o.Value().String() -} - -func (o ScMutableChainID) Value() ScChainID { - return NewScChainIDFromBytes(GetBytes(o.objID, o.keyID, TYPE_CHAIN_ID)) -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -type ScMutableColor struct { - objID int32 - keyID Key32 -} - -func NewScMutableColor(objID int32, keyID Key32) ScMutableColor { - return ScMutableColor{objID: objID, keyID: keyID} -} - -func (o ScMutableColor) Delete() { - DelKey(o.objID, o.keyID, TYPE_COLOR) -} - -func (o ScMutableColor) Exists() bool { - return Exists(o.objID, o.keyID, TYPE_COLOR) -} - -func (o ScMutableColor) SetValue(value ScColor) { - SetBytes(o.objID, o.keyID, TYPE_COLOR, value.Bytes()) -} - -func (o ScMutableColor) String() string { - return o.Value().String() -} - -func (o ScMutableColor) Value() ScColor { - return NewScColorFromBytes(GetBytes(o.objID, o.keyID, TYPE_COLOR)) -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -type ScMutableHash struct { - objID int32 - keyID Key32 -} - -func NewScMutableHash(objID int32, keyID Key32) ScMutableHash { - return ScMutableHash{objID: objID, keyID: keyID} -} - -func (o ScMutableHash) Delete() { - DelKey(o.objID, o.keyID, TYPE_HASH) -} - -func (o ScMutableHash) Exists() bool { - return Exists(o.objID, o.keyID, TYPE_HASH) -} - -func (o ScMutableHash) SetValue(value ScHash) { - SetBytes(o.objID, o.keyID, TYPE_HASH, value.Bytes()) -} - -func (o ScMutableHash) String() string { - return o.Value().String() -} - -func (o ScMutableHash) Value() ScHash { - return NewScHashFromBytes(GetBytes(o.objID, o.keyID, TYPE_HASH)) -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -type ScMutableHname struct { - objID int32 - keyID Key32 -} - -func NewScMutableHname(objID int32, keyID Key32) ScMutableHname { - return ScMutableHname{objID: objID, keyID: keyID} -} - -func (o ScMutableHname) Delete() { - DelKey(o.objID, o.keyID, TYPE_HNAME) -} - -func (o ScMutableHname) Exists() bool { - return Exists(o.objID, o.keyID, TYPE_HNAME) -} - -func (o ScMutableHname) SetValue(value ScHname) { - SetBytes(o.objID, o.keyID, TYPE_HNAME, value.Bytes()) -} - -func (o ScMutableHname) String() string { - return o.Value().String() -} - -func (o ScMutableHname) Value() ScHname { - return NewScHnameFromBytes(GetBytes(o.objID, o.keyID, TYPE_HNAME)) -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -type ScMutableInt8 struct { - objID int32 - keyID Key32 -} - -func NewScMutableInt8(objID int32, keyID Key32) ScMutableInt8 { - return ScMutableInt8{objID: objID, keyID: keyID} -} - -func (o ScMutableInt8) Delete() { - DelKey(o.objID, o.keyID, TYPE_INT8) -} - -func (o ScMutableInt8) Exists() bool { - return Exists(o.objID, o.keyID, TYPE_INT8) -} - -func (o ScMutableInt8) SetValue(value int8) { - bytes := make([]byte, 1) - bytes[0] = byte(value) - SetBytes(o.objID, o.keyID, TYPE_INT8, bytes) -} - -func (o ScMutableInt8) String() string { - return strconv.FormatInt(int64(o.Value()), 10) -} - -func (o ScMutableInt8) Value() int8 { - bytes := GetBytes(o.objID, o.keyID, TYPE_INT8) - return int8(bytes[0]) -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -type ScMutableInt16 struct { - objID int32 - keyID Key32 -} - -func NewScMutableInt16(objID int32, keyID Key32) ScMutableInt16 { - return ScMutableInt16{objID: objID, keyID: keyID} -} - -func (o ScMutableInt16) Delete() { - DelKey(o.objID, o.keyID, TYPE_INT16) -} - -func (o ScMutableInt16) Exists() bool { - return Exists(o.objID, o.keyID, TYPE_INT16) -} - -func (o ScMutableInt16) SetValue(value int16) { - bytes := make([]byte, 2) - binary.LittleEndian.PutUint16(bytes, uint16(value)) - SetBytes(o.objID, o.keyID, TYPE_INT16, bytes) -} - -func (o ScMutableInt16) String() string { - return strconv.FormatInt(int64(o.Value()), 10) -} - -func (o ScMutableInt16) Value() int16 { - bytes := GetBytes(o.objID, o.keyID, TYPE_INT16) - return int16(binary.LittleEndian.Uint16(bytes)) -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -type ScMutableInt32 struct { - objID int32 - keyID Key32 -} - -func NewScMutableInt32(objID int32, keyID Key32) ScMutableInt32 { - return ScMutableInt32{objID: objID, keyID: keyID} -} - -func (o ScMutableInt32) Delete() { - DelKey(o.objID, o.keyID, TYPE_INT32) -} - -func (o ScMutableInt32) Exists() bool { - return Exists(o.objID, o.keyID, TYPE_INT32) -} - -func (o ScMutableInt32) SetValue(value int32) { - bytes := make([]byte, 4) - binary.LittleEndian.PutUint32(bytes, uint32(value)) - SetBytes(o.objID, o.keyID, TYPE_INT32, bytes) -} - -func (o ScMutableInt32) String() string { - return strconv.FormatInt(int64(o.Value()), 10) -} - -func (o ScMutableInt32) Value() int32 { - bytes := GetBytes(o.objID, o.keyID, TYPE_INT32) - return int32(binary.LittleEndian.Uint32(bytes)) -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -type ScMutableInt64 struct { - objID int32 - keyID Key32 -} - -func NewScMutableInt64(objID int32, keyID Key32) ScMutableInt64 { - return ScMutableInt64{objID: objID, keyID: keyID} -} - -func (o ScMutableInt64) Delete() { - DelKey(o.objID, o.keyID, TYPE_INT64) -} - -func (o ScMutableInt64) Exists() bool { - return Exists(o.objID, o.keyID, TYPE_INT64) -} - -func (o ScMutableInt64) SetValue(value int64) { - bytes := make([]byte, 8) - binary.LittleEndian.PutUint64(bytes, uint64(value)) - SetBytes(o.objID, o.keyID, TYPE_INT64, bytes) -} - -func (o ScMutableInt64) String() string { - return strconv.FormatInt(o.Value(), 10) -} - -func (o ScMutableInt64) Value() int64 { - bytes := GetBytes(o.objID, o.keyID, TYPE_INT64) - return int64(binary.LittleEndian.Uint64(bytes)) -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -type ScMutableMap struct { - objID int32 -} - -func NewScMutableMap() *ScMutableMap { - maps := Root.GetMapArray(KeyMaps) - return &ScMutableMap{objID: maps.GetMap(maps.Length()).objID} -} - -func (o ScMutableMap) CallFunc(keyID Key32, params []byte) []byte { - return CallFunc(o.objID, keyID, params) -} - -func (o ScMutableMap) Clear() { - Clear(o.objID) -} - -func (o ScMutableMap) GetAddress(key MapKey) ScMutableAddress { - return ScMutableAddress{objID: o.objID, keyID: key.KeyID()} -} - -func (o ScMutableMap) GetAgentID(key MapKey) ScMutableAgentID { - return ScMutableAgentID{objID: o.objID, keyID: key.KeyID()} -} - -func (o ScMutableMap) GetBool(key MapKey) ScMutableBool { - return ScMutableBool{objID: o.objID, keyID: key.KeyID()} -} - -func (o ScMutableMap) GetBytes(key MapKey) ScMutableBytes { - return ScMutableBytes{objID: o.objID, keyID: key.KeyID()} -} - -func (o ScMutableMap) GetChainID(key MapKey) ScMutableChainID { - return ScMutableChainID{objID: o.objID, keyID: key.KeyID()} -} - -func (o ScMutableMap) GetColor(key MapKey) ScMutableColor { - return ScMutableColor{objID: o.objID, keyID: key.KeyID()} -} - -func (o ScMutableMap) GetHash(key MapKey) ScMutableHash { - return ScMutableHash{objID: o.objID, keyID: key.KeyID()} -} - -func (o ScMutableMap) GetHname(key MapKey) ScMutableHname { - return ScMutableHname{objID: o.objID, keyID: key.KeyID()} -} - -func (o ScMutableMap) GetInt8(key MapKey) ScMutableInt8 { - return ScMutableInt8{objID: o.objID, keyID: key.KeyID()} -} - -func (o ScMutableMap) GetInt16(key MapKey) ScMutableInt16 { - return ScMutableInt16{objID: o.objID, keyID: key.KeyID()} -} - -func (o ScMutableMap) GetInt32(key MapKey) ScMutableInt32 { - return ScMutableInt32{objID: o.objID, keyID: key.KeyID()} -} - -func (o ScMutableMap) GetInt64(key MapKey) ScMutableInt64 { - return ScMutableInt64{objID: o.objID, keyID: key.KeyID()} -} - -func (o ScMutableMap) GetMap(key MapKey) ScMutableMap { - mapID := GetObjectID(o.objID, key.KeyID(), TYPE_MAP) - return ScMutableMap{objID: mapID} -} - -func (o ScMutableMap) GetMapArray(key MapKey) ScMutableMapArray { - arrID := GetObjectID(o.objID, key.KeyID(), TYPE_MAP|TYPE_ARRAY) - return ScMutableMapArray{objID: arrID} -} - -func (o ScMutableMap) GetRequestID(key MapKey) ScMutableRequestID { - return ScMutableRequestID{objID: o.objID, keyID: key.KeyID()} -} - -func (o ScMutableMap) GetString(key MapKey) ScMutableString { - return ScMutableString{objID: o.objID, keyID: key.KeyID()} -} - -func (o ScMutableMap) GetStringArray(key MapKey) ScMutableStringArray { - arrID := GetObjectID(o.objID, key.KeyID(), TYPE_STRING|TYPE_ARRAY) - return ScMutableStringArray{objID: arrID} -} - -func (o ScMutableMap) GetUint8(key MapKey) ScMutableUint8 { - return ScMutableUint8{objID: o.objID, keyID: key.KeyID()} -} - -func (o ScMutableMap) GetUint16(key MapKey) ScMutableUint16 { - return ScMutableUint16{objID: o.objID, keyID: key.KeyID()} -} - -func (o ScMutableMap) GetUint32(key MapKey) ScMutableUint32 { - return ScMutableUint32{objID: o.objID, keyID: key.KeyID()} -} - -func (o ScMutableMap) GetUint64(key MapKey) ScMutableUint64 { - return ScMutableUint64{objID: o.objID, keyID: key.KeyID()} -} - -func (o ScMutableMap) Immutable() ScImmutableMap { - return ScImmutableMap(o) -} - -func (o ScMutableMap) MapID() int32 { - return o.objID -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -type ScMutableMapArray struct { - objID int32 -} - -func (o ScMutableMapArray) Clear() { - Clear(o.objID) -} - -func (o ScMutableMapArray) GetMap(index int32) ScMutableMap { - mapID := GetObjectID(o.objID, Key32(index), TYPE_MAP) - return ScMutableMap{objID: mapID} -} - -func (o ScMutableMapArray) Immutable() ScImmutableMapArray { - return ScImmutableMapArray(o) -} - -func (o ScMutableMapArray) Length() int32 { - return GetLength(o.objID) -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -type ScMutableRequestID struct { - objID int32 - keyID Key32 -} - -func NewScMutableRequestID(objID int32, keyID Key32) ScMutableRequestID { - return ScMutableRequestID{objID: objID, keyID: keyID} -} - -func (o ScMutableRequestID) Delete() { - DelKey(o.objID, o.keyID, TYPE_REQUEST_ID) -} - -func (o ScMutableRequestID) Exists() bool { - return Exists(o.objID, o.keyID, TYPE_REQUEST_ID) -} - -func (o ScMutableRequestID) SetValue(value ScRequestID) { - SetBytes(o.objID, o.keyID, TYPE_REQUEST_ID, value.Bytes()) -} - -func (o ScMutableRequestID) String() string { - return o.Value().String() -} - -func (o ScMutableRequestID) Value() ScRequestID { - return NewScRequestIDFromBytes(GetBytes(o.objID, o.keyID, TYPE_REQUEST_ID)) -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -type ScMutableString struct { - objID int32 - keyID Key32 -} - -func NewScMutableString(objID int32, keyID Key32) ScMutableString { - return ScMutableString{objID: objID, keyID: keyID} -} - -func (o ScMutableString) Delete() { - DelKey(o.objID, o.keyID, TYPE_STRING) -} - -func (o ScMutableString) Exists() bool { - return Exists(o.objID, o.keyID, TYPE_STRING) -} - -func (o ScMutableString) SetValue(value string) { - SetBytes(o.objID, o.keyID, TYPE_STRING, []byte(value)) -} - -func (o ScMutableString) String() string { - return o.Value() -} - -func (o ScMutableString) Value() string { - bytes := GetBytes(o.objID, o.keyID, TYPE_STRING) - if bytes == nil { - return "" - } - return string(bytes) -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -type ScMutableStringArray struct { - objID int32 -} - -func (o ScMutableStringArray) Clear() { - Clear(o.objID) -} - -func (o ScMutableStringArray) GetString(index int32) ScMutableString { - return ScMutableString{objID: o.objID, keyID: Key32(index)} -} - -func (o ScMutableStringArray) Immutable() ScImmutableStringArray { - return ScImmutableStringArray(o) -} - -func (o ScMutableStringArray) Length() int32 { - return GetLength(o.objID) -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -type ScMutableUint8 struct { - objID int32 - keyID Key32 -} - -func NewScMutableUint8(objID int32, keyID Key32) ScMutableUint8 { - return ScMutableUint8{objID: objID, keyID: keyID} -} - -func (o ScMutableUint8) Delete() { - DelKey(o.objID, o.keyID, TYPE_INT8) -} - -func (o ScMutableUint8) Exists() bool { - return Exists(o.objID, o.keyID, TYPE_INT8) -} - -func (o ScMutableUint8) SetValue(value uint8) { - bytes := make([]byte, 1) - bytes[0] = value - SetBytes(o.objID, o.keyID, TYPE_INT8, bytes) -} - -func (o ScMutableUint8) String() string { - return strconv.FormatUint(uint64(o.Value()), 10) -} - -func (o ScMutableUint8) Value() uint8 { - bytes := GetBytes(o.objID, o.keyID, TYPE_INT8) - return bytes[0] -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -type ScMutableUint16 struct { - objID int32 - keyID Key32 -} - -func NewScMutableUint16(objID int32, keyID Key32) ScMutableUint16 { - return ScMutableUint16{objID: objID, keyID: keyID} -} - -func (o ScMutableUint16) Delete() { - DelKey(o.objID, o.keyID, TYPE_INT16) -} - -func (o ScMutableUint16) Exists() bool { - return Exists(o.objID, o.keyID, TYPE_INT16) -} - -func (o ScMutableUint16) SetValue(value uint16) { - bytes := make([]byte, 2) - binary.LittleEndian.PutUint16(bytes, value) - SetBytes(o.objID, o.keyID, TYPE_INT16, bytes) -} - -func (o ScMutableUint16) String() string { - return strconv.FormatUint(uint64(o.Value()), 10) -} - -func (o ScMutableUint16) Value() uint16 { - bytes := GetBytes(o.objID, o.keyID, TYPE_INT16) - return binary.LittleEndian.Uint16(bytes) -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -type ScMutableUint32 struct { - objID int32 - keyID Key32 -} - -func NewScMutableUint32(objID int32, keyID Key32) ScMutableUint32 { - return ScMutableUint32{objID: objID, keyID: keyID} -} - -func (o ScMutableUint32) Delete() { - DelKey(o.objID, o.keyID, TYPE_INT32) -} - -func (o ScMutableUint32) Exists() bool { - return Exists(o.objID, o.keyID, TYPE_INT32) -} - -func (o ScMutableUint32) SetValue(value uint32) { - bytes := make([]byte, 4) - binary.LittleEndian.PutUint32(bytes, value) - SetBytes(o.objID, o.keyID, TYPE_INT32, bytes) -} - -func (o ScMutableUint32) String() string { - return strconv.FormatUint(uint64(o.Value()), 10) -} - -func (o ScMutableUint32) Value() uint32 { - bytes := GetBytes(o.objID, o.keyID, TYPE_INT32) - return binary.LittleEndian.Uint32(bytes) -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -type ScMutableUint64 struct { - objID int32 - keyID Key32 -} - -func NewScMutableUint64(objID int32, keyID Key32) ScMutableUint64 { - return ScMutableUint64{objID: objID, keyID: keyID} -} - -func (o ScMutableUint64) Delete() { - DelKey(o.objID, o.keyID, TYPE_INT64) -} - -func (o ScMutableUint64) Exists() bool { - return Exists(o.objID, o.keyID, TYPE_INT64) -} - -func (o ScMutableUint64) SetValue(value uint64) { - bytes := make([]byte, 8) - binary.LittleEndian.PutUint64(bytes, value) - SetBytes(o.objID, o.keyID, TYPE_INT64, bytes) -} - -func (o ScMutableUint64) String() string { - return strconv.FormatUint(o.Value(), 10) -} - -func (o ScMutableUint64) Value() uint64 { - bytes := GetBytes(o.objID, o.keyID, TYPE_INT64) - return binary.LittleEndian.Uint64(bytes) -} diff --git a/packages/vm/wasmlib/go/wasmlib/proxy.go b/packages/vm/wasmlib/go/wasmlib/proxy.go deleted file mode 100644 index 23fee722f8..0000000000 --- a/packages/vm/wasmlib/go/wasmlib/proxy.go +++ /dev/null @@ -1,71 +0,0 @@ -package wasmlib - -type Proxy struct { - key []byte - kvStore IKvStore -} - -func makeKey(key []byte, sep byte, subKey []byte) []byte { - if len(key) == 0 { - return subKey - } - return append(append(key, sep), subKey...) -} - -func subProxy(proxy Proxy, sep byte, subKey []byte) Proxy { - return Proxy{key: makeKey(proxy.key, sep, subKey), kvStore: proxy.kvStore} -} - -func (p Proxy) Buf() *BytesDecoder { - return NewBytesDecoder(p.Get()) -} - -func (p Proxy) Delete() { - p.kvStore.Delete(p.key) -} - -func (p Proxy) Exists() bool { - return p.kvStore.Exists(p.key) -} - -func (p Proxy) Get() []byte { - return p.kvStore.Get(p.key) -} - -func (p Proxy) Set(value []byte) { - p.kvStore.Set(p.key, value) -} - -type ArrayProxy struct { - proxy Proxy -} - -func (a ArrayProxy) NewProxy(index uint32) Proxy { - subKey := NewBytesEncoder().Uint32(index).Data() - return subProxy(a.proxy, '#', subKey) -} - -func (a ArrayProxy) Clear() { - a.proxy.Set([]byte{0}) -} - -func (a ArrayProxy) Length() uint32 { - return a.proxy.Buf().Uint32() -} - -type MapProxy struct { - proxy Proxy -} - -func (m MapProxy) NewProxy(subKey []byte) Proxy { - return subProxy(m.proxy, '.', subKey) -} - -//TODO hidden array of keys? -//func (m MapProxy) Clear() { -// m.proxy.Set([]byte{0}) -//} - -//func (m MapProxy) Length() uint32 { -// return m.proxy.Buf().Uint32() -//} diff --git a/packages/vm/wasmlib/go/wasmlib/sandbox.go b/packages/vm/wasmlib/go/wasmlib/sandbox.go index ead5274dab..96ee894e58 100644 --- a/packages/vm/wasmlib/go/wasmlib/sandbox.go +++ b/packages/vm/wasmlib/go/wasmlib/sandbox.go @@ -3,6 +3,14 @@ package wasmlib +import ( + "encoding/binary" + + "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmcodec" + "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmrequests" + "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" +) + const ( FnAccountID = int32(-1) FnBalance = int32(-2) @@ -39,129 +47,235 @@ const ( FnUtilsHashBlake2b = int32(-33) FnUtilsHashName = int32(-34) FnUtilsHashSha3 = int32(-35) - FnZzzLastItem = int32(-36) ) type ScSandbox struct{} -func (s ScSandbox) AccountID() ScAgentID { - return NewScAgentIDFromBytes(Sandbox(FnAccountID, nil)) +// TODO go over core contract schemas to set correct unsigned types + +func NewParamsProxy() wasmtypes.Proxy { + return wasmtypes.NewProxy(NewScDictFromBytes(Sandbox(FnParams, nil))) } -func (s ScSandbox) Balance(color ScColor) uint64 { - bal, _ := ExtractUint64(Sandbox(FnBalance, color.Bytes())) - return bal +// retrieve the agent id of this contract account +func (s ScSandbox) AccountID() wasmtypes.ScAgentID { + return wasmtypes.AgentIDFromBytes(Sandbox(FnAccountID, nil)) } -func (s ScSandbox) Balances() ScAssets { - return NewScAssetsFromBytes(Sandbox(FnBalances, nil)) +func (s ScSandbox) Balance(color wasmtypes.ScColor) uint64 { + bal, _ := wasmcodec.ExtractUint64(Sandbox(FnBalance, color.Bytes())) + return bal } -func (s ScSandbox) BlockContext(construct func(sandbox ScSandbox) interface{}, onClose func(interface{})) interface{} { - panic("implement me") +// access the current balances for all assets +func (s ScSandbox) Balances() ScBalances { + return NewScAssetsFromBytes(Sandbox(FnBalances, nil)).Balances() } -func (s ScSandbox) Call(contract, function ScHname, params ScDict, transfer ScAssets) ScDict { - enc := NewBytesEncoder() - enc.Hname(contract) - enc.Hname(function) - enc.Bytes(params.Bytes()) - enc.Bytes(transfer.Bytes()) - return NewScDictFromBytes(Sandbox(FnCall, enc.Data())) +// calls a smart contract view +func (s ScSandbox) Call(hContract, hFunction wasmtypes.ScHname, params ScDict) ScImmutableDict { + return s.call(hContract, hFunction, params, nil) } -func (s ScSandbox) Caller() ScAgentID { - return NewScAgentIDFromBytes(Sandbox(FnCaller, nil)) +// calls a smart contract function +func (s ScSandbox) call(hContract, hFunction wasmtypes.ScHname, params ScDict, transfer ScTransfers) ScImmutableDict { + req := &wasmrequests.CallRequest{ + Contract: hContract, + Function: hFunction, + Params: params.Bytes(), + Transfer: ScAssets(transfer).Bytes(), + } + res := Sandbox(FnCall, req.Bytes()) + return NewScDictFromBytes(res).Immutable() } -func (s ScSandbox) ChainID() ScChainID { - return NewScChainIDFromBytes(Sandbox(FnChainID, nil)) +// retrieve the chain id of the chain this contract lives on +func (s ScSandbox) ChainID() wasmtypes.ScChainID { + return wasmtypes.ChainIDFromBytes(Sandbox(FnChainID, nil)) } -func (s ScSandbox) ChainOwnerID() ScAgentID { - return NewScAgentIDFromBytes(Sandbox(FnChainOwnerID, nil)) +// retrieve the agent id of the owner of the chain this contract lives on +func (s ScSandbox) ChainOwnerID() wasmtypes.ScAgentID { + return wasmtypes.AgentIDFromBytes(Sandbox(FnChainOwnerID, nil)) } -func (s ScSandbox) Contract() ScHname { - return NewScHnameFromBytes(Sandbox(FnContract, nil)) +// retrieve the hname of this contract +func (s ScSandbox) Contract() wasmtypes.ScHname { + return wasmtypes.HnameFromBytes(Sandbox(FnContract, nil)) } -func (s ScSandbox) ContractCreator() ScAgentID { - return NewScAgentIDFromBytes(Sandbox(FnContractCreator, nil)) +// retrieve the agent id of the creator of this contract +func (s ScSandbox) ContractCreator() wasmtypes.ScAgentID { + return wasmtypes.AgentIDFromBytes(Sandbox(FnContractCreator, nil)) } -func (s ScSandbox) DeployContract(programHash ScHash, name, description string, initParams ScDict) { - enc := NewBytesEncoder() - enc.Hash(programHash) - enc.String(name) - enc.String(description) - enc.Bytes(initParams.Bytes()) - Sandbox(FnDeployContract, enc.Data()) +// logs informational text message +func (s ScSandbox) Log(text string) { + Sandbox(FnLog, []byte(text)) } -func (s ScSandbox) Entropy() ScHash { - return NewScHashFromBytes(Sandbox(FnEntropy, nil)) +// logs error text message and then panics +func (s ScSandbox) Panic(text string) { + Sandbox(FnPanic, []byte(text)) } -func (s ScSandbox) Event(msg string) { - Sandbox(FnEvent, []byte(msg)) +// retrieve parameters passed to the smart contract function that was called +func (s ScSandbox) Params() ScImmutableDict { + return NewScDictFromBytes(Sandbox(FnParams, nil)).Immutable() } -func (s ScSandbox) IncomingTransfer() ScAssets { - return NewScAssetsFromBytes(Sandbox(FnIncomingTransfer, nil)) +func (s ScSandbox) RawState() ScImmutableState { + return ScImmutableState{} } -func (s ScSandbox) Log(text string) { - Sandbox(FnLog, []byte(text)) +// panics if condition is not satisfied +func (s ScSandbox) Require(cond bool, msg string) { + if !cond { + s.Panic(msg) + } } -func (s ScSandbox) Minted() ScAssets { - return NewScAssetsFromBytes(Sandbox(FnMinted, nil)) +// deterministic time stamp fixed at the moment of calling the smart contract +func (s ScSandbox) Timestamp() uint64 { + ts, _ := wasmcodec.ExtractUint64(Sandbox(FnTimestamp, nil)) + return ts } -func (s ScSandbox) Panic(text string) { - Sandbox(FnPanic, []byte(text)) +// logs debugging trace text message +func (s ScSandbox) Trace(text string) { + Sandbox(FnTrace, []byte(text)) } -func (s ScSandbox) Params() ScDict { - return NewScDictFromBytes(Sandbox(FnParams, nil)) +// access diverse utility functions +func (s ScSandbox) Utility() ScSandboxUtils { + return ScSandboxUtils{} } -func (s ScSandbox) Post(chainID ScChainID, contract, function ScHname, params ScDict, transfer ScAssets, delay uint32) { - enc := NewBytesEncoder() - enc.ChainID(chainID) - enc.Hname(contract) - enc.Hname(function) - enc.Bytes(params.Bytes()) - enc.Bytes(transfer.Bytes()) - enc.Uint32(delay) - Sandbox(FnSend, enc.Data()) +type ScSandboxFunc struct { + ScSandbox } -//func (s ScSandbox) Request() ScRequest { +//func (s ScSandbox) BlockContext(construct func(sandbox ScSandbox) interface{}, onClose func(interface{})) interface{} { // panic("implement me") //} -func (s ScSandbox) RequestID() ScRequestID { - return NewScRequestIDFromBytes(Sandbox(FnRequestID, nil)) +// calls a smart contract function +func (s ScSandboxFunc) Call(hContract, hFunction wasmtypes.ScHname, params ScDict, transfer ScTransfers) ScImmutableDict { + return s.call(hContract, hFunction, params, transfer) } -func (s ScSandbox) Send(target ScAddress, tokens ScAssets) { - enc := NewBytesEncoder() - enc.Address(target) - enc.Bytes(tokens.Bytes()) - Sandbox(FnSend, enc.Data()) +// retrieve the agent id of the caller of the smart contract +func (s ScSandboxFunc) Caller() wasmtypes.ScAgentID { + return wasmtypes.AgentIDFromBytes(Sandbox(FnCaller, nil)) } -func (s ScSandbox) StateAnchor() interface{} { - panic("implement me") +// deploys a smart contract +func (s ScSandboxFunc) DeployContract(programHash wasmtypes.ScHash, name, description string, initParams ScDict) { + req := &wasmrequests.DeployRequest{ + ProgHash: programHash, + Name: name, + Description: description, + Params: initParams.Bytes(), + } + Sandbox(FnDeployContract, req.Bytes()) } -func (s ScSandbox) Timestamp() int64 { - ts, _ := ExtractInt64(Sandbox(FnTimestamp, nil)) - return ts +// returns random entropy data for current request. +func (s ScSandboxFunc) Entropy() wasmtypes.ScHash { + return wasmtypes.HashFromBytes(Sandbox(FnEntropy, nil)) } -func (s ScSandbox) Trace(text string) { - Sandbox(FnTrace, []byte(text)) +// signals an event on the node that external entities can subscribe to +func (s ScSandboxFunc) Event(msg string) { + Sandbox(FnEvent, []byte(msg)) +} + +// access the incoming balances for all assets +func (s ScSandboxFunc) IncomingTransfer() ScBalances { + buf := Sandbox(FnIncomingTransfer, nil) + return NewScAssetsFromBytes(buf).Balances() +} + +// retrieve the assets that were minted in this transaction +func (s ScSandboxFunc) Minted() ScBalances { + return NewScAssetsFromBytes(Sandbox(FnMinted, nil)).Balances() +} + +// (delayed) posts a smart contract function request +func (s ScSandboxFunc) Post(chainID wasmtypes.ScChainID, hContract, hFunction wasmtypes.ScHname, params ScDict, transfer ScTransfers, delay uint32) { + if len(transfer) == 0 { + s.Panic("missing transfer") + } + req := &wasmrequests.PostRequest{ + ChainID: chainID, + Contract: hContract, + Function: hFunction, + Params: params.Bytes(), + Transfer: ScAssets(transfer).Bytes(), + Delay: delay, + } + Sandbox(FnPost, req.Bytes()) +} + +var ( + entropy []byte + offset = 0 +) + +// generates a random value from 0 to max (exclusive max) using a deterministic RNG +func (s ScSandboxFunc) Random(max uint64) (rnd uint64) { + if max == 0 { + s.Panic("random: max parameter should be non-zero") + } + + // note that entropy gets reset for every request + if len(entropy) == 0 { + // first time in this request, initialize with current request entropy + entropy = s.Entropy().Bytes() + offset = 0 + } + if offset == 32 { + // ran out of entropy data, hash entropy for next pseudo-random entropy + entropy = s.Utility().HashBlake2b(entropy).Bytes() + offset = 0 + } + rnd = binary.LittleEndian.Uint64(entropy[offset:offset+8]) % max + offset += 8 + return +} + +func (s ScSandboxFunc) RawState() ScState { + return ScState{} } + +//func (s ScSandboxFunc) Request() ScRequest { +// panic("implement me") +//} + +// retrieve the request id of this transaction +func (s ScSandboxFunc) RequestID() wasmtypes.ScRequestID { + return wasmtypes.RequestIDFromBytes(Sandbox(FnRequestID, nil)) +} + +// transfer assetss to the specified Tangle ledger address +func (s ScSandboxFunc) Send(address wasmtypes.ScAddress, transfer ScTransfers) { + // we need some assets to send + assets := uint64(0) + for _, amount := range transfer { + assets += amount + } + if assets == 0 { + // only try to send when non-zero assets + return + } + + req := wasmrequests.SendRequest{ + Address: address, + Transfer: ScAssets(transfer).Bytes(), + } + Sandbox(FnSend, req.Bytes()) +} + +//func (s ScSandboxFunc) StateAnchor() interface{} { +// panic("implement me") +//} diff --git a/packages/vm/wasmlib/go/wasmlib/sandboxtypes.go b/packages/vm/wasmlib/go/wasmlib/sandboxtypes.go deleted file mode 100644 index 33d9270e7b..0000000000 --- a/packages/vm/wasmlib/go/wasmlib/sandboxtypes.go +++ /dev/null @@ -1,223 +0,0 @@ -// Copyright 2020 IOTA Stiftung -// SPDX-License-Identifier: Apache-2.0 - -package wasmlib - -import ( - "encoding/binary" - "sort" -) - -type IKvStore interface { - Delete(key []byte) - Exists(key []byte) bool - Get(key []byte) []byte - Set(key, value []byte) -} - -type ScAssets map[ScColor]uint64 - -func NewScAssetsFromBytes(buf []byte) ScAssets { - dict := make(ScAssets) - size, buf := ExtractUint32(buf) - var k []byte - var v uint64 - for i := uint32(0); i < size; i++ { - k, buf = ExtractBytes(buf, 32) - v, buf = ExtractUint64(buf) - dict[NewScColorFromBytes(k)] = v - } - return dict -} - -func (a ScAssets) Bytes() []byte { - keys := make([]ScColor, 0, len(a)) - for key := range a { - keys = append(keys, key) - } - sort.Slice(keys, func(i, j int) bool { - return string(keys[i].id[:]) < string(keys[j].id[:]) - }) - buf := AppendUint32(nil, uint32(len(keys))) - for _, k := range keys { - v := a[k] - buf = AppendBytes(buf, k.Bytes()) - buf = AppendUint64(buf, v) - } - return buf -} - -type ScDict map[string][]byte - -var _ IKvStore = new(ScDict) - -func NewScDict() ScDict { - return make(ScDict) -} - -func NewScDictFromBytes(buf []byte) ScDict { - size, buf := ExtractUint32(buf) - dict := make(ScDict, size) - var k uint16 - var v uint32 - var key []byte - var val []byte - for i := uint32(0); i < size; i++ { - k, buf = ExtractUint16(buf) - key, buf = ExtractBytes(buf, int(k)) - v, buf = ExtractUint32(buf) - val, buf = ExtractBytes(buf, int(v)) - dict.Set(key, val) - } - return dict -} - -func (d ScDict) Bytes() []byte { - keys := make([]string, 0, len(d)) - for key := range d { - keys = append(keys, key) - } - sort.Slice(keys, func(i, j int) bool { - return keys[i] < keys[j] - }) - buf := AppendUint32(nil, uint32(len(keys))) - for _, k := range keys { - v := d[k] - buf = AppendUint16(buf, uint16(len(k))) - buf = AppendBytes(buf, []byte(k)) - buf = AppendUint32(buf, uint32(len(v))) - buf = AppendBytes(buf, v) - } - return buf -} - -func (d ScDict) Delete(key []byte) { - delete(d, string(key)) -} - -func (d ScDict) Exists(key []byte) bool { - return d[string(key)] != nil -} - -func (d ScDict) Get(key []byte) []byte { - return d[string(key)] -} - -func (d ScDict) Set(key, value []byte) { - d[string(key)] = value -} - -///////////////////////////////////////////////// - -type ScState struct{} - -var _ IKvStore = new(ScState) - -func (d ScState) Delete(key []byte) { - StateDelete(key) -} - -func (d ScState) Exists(key []byte) bool { - return StateExists(key) -} - -func (d ScState) Get(key []byte) []byte { - return StateGet(key) -} - -func (d ScState) Set(key, value []byte) { - StateSet(key, value) -} - -///////////////////////////////////////////////// - -func ExtractBool(buf []byte) (bool, []byte) { - return buf[0] != 0, buf[1:] -} - -func ExtractBytes(buf []byte, n int) ([]byte, []byte) { - return buf[:n], buf[n:] -} - -func ExtractInt8(buf []byte) (int8, []byte) { - return int8(buf[0]), buf[1:] -} - -func ExtractInt16(buf []byte) (int16, []byte) { - return int16(binary.LittleEndian.Uint16(buf)), buf[2:] -} - -func ExtractInt32(buf []byte) (int32, []byte) { - return int32(binary.LittleEndian.Uint32(buf)), buf[4:] -} - -func ExtractInt64(buf []byte) (int64, []byte) { - return int64(binary.LittleEndian.Uint64(buf)), buf[8:] -} - -func ExtractUint8(buf []byte) (uint8, []byte) { - return buf[0], buf[1:] -} - -func ExtractUint16(buf []byte) (uint16, []byte) { - return binary.LittleEndian.Uint16(buf), buf[2:] -} - -func ExtractUint32(buf []byte) (uint32, []byte) { - return binary.LittleEndian.Uint32(buf), buf[4:] -} - -func ExtractUint64(buf []byte) (uint64, []byte) { - return binary.LittleEndian.Uint64(buf), buf[8:] -} - -//////////////////////////////////// - -func AppendBool(buf []byte, value bool) []byte { - if value { - return AppendUint8(buf, 1) - } - return AppendUint8(buf, 0) -} - -func AppendBytes(buf, value []byte) []byte { - return append(buf, value...) -} - -func AppendInt8(buf []byte, value int8) []byte { - return AppendUint8(buf, uint8(value)) -} - -func AppendInt16(buf []byte, value int16) []byte { - return AppendUint16(buf, uint16(value)) -} - -func AppendInt32(buf []byte, value int32) []byte { - return AppendUint32(buf, uint32(value)) -} - -func AppendInt64(buf []byte, value int64) []byte { - return AppendUint64(buf, uint64(value)) -} - -func AppendUint8(buf []byte, value uint8) []byte { - return append(buf, value) -} - -func AppendUint16(buf []byte, value uint16) []byte { - tmp := make([]byte, 2) - binary.LittleEndian.PutUint16(tmp, value) - return append(buf, tmp...) -} - -func AppendUint32(buf []byte, value uint32) []byte { - tmp := make([]byte, 4) - binary.LittleEndian.PutUint32(tmp, value) - return append(buf, tmp...) -} - -func AppendUint64(buf []byte, value uint64) []byte { - tmp := make([]byte, 8) - binary.LittleEndian.PutUint64(tmp, value) - return append(buf, tmp...) -} diff --git a/packages/vm/wasmlib/go/wasmlib/sandboxutils.go b/packages/vm/wasmlib/go/wasmlib/sandboxutils.go index 82582e4683..bb5d18e703 100644 --- a/packages/vm/wasmlib/go/wasmlib/sandboxutils.go +++ b/packages/vm/wasmlib/go/wasmlib/sandboxutils.go @@ -3,59 +3,74 @@ package wasmlib +import ( + "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmcodec" + "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" +) + type ScSandboxUtils struct{} +// decodes the specified base58-encoded string value to its original bytes func (u ScSandboxUtils) Base58Decode(value string) []byte { return Sandbox(FnUtilsBase58Decode, []byte(value)) } +// encodes the specified bytes to a base-58-encoded string func (u ScSandboxUtils) Base58Encode(bytes []byte) string { return string(Sandbox(FnUtilsBase58Encode, bytes)) } -func (u ScSandboxUtils) BlsAddress(pubKey []byte) ScAddress { - return NewScAddressFromBytes(Sandbox(FnUtilsBlsAddress, pubKey)) +func (u ScSandboxUtils) BlsAddressFromPubKey(pubKey []byte) wasmtypes.ScAddress { + return wasmtypes.AddressFromBytes(Sandbox(FnUtilsBlsAddress, pubKey)) } -func (u ScSandboxUtils) BlsAggregate(pubKeys, sigs [][]byte) ([]byte, []byte) { - encode := NewBytesEncoder() - encode.Int32(int32(len(pubKeys))) +func (u ScSandboxUtils) BlsAggregateSignatures(pubKeys, sigs [][]byte) ([]byte, []byte) { + enc := wasmcodec.NewWasmEncoder() + wasmtypes.EncodeUint32(enc, uint32(len(pubKeys))) for _, pubKey := range pubKeys { - encode.Bytes(pubKey) + enc.Bytes(pubKey) } - encode.Int32(int32(len(sigs))) + wasmtypes.EncodeUint32(enc, uint32(len(sigs))) for _, sig := range sigs { - encode.Bytes(sig) + enc.Bytes(sig) } - result := Sandbox(FnUtilsBlsAggregate, encode.Data()) - decode := NewBytesDecoder(result) + result := Sandbox(FnUtilsBlsAggregate, enc.Buf()) + decode := wasmcodec.NewWasmDecoder(result) return decode.Bytes(), decode.Bytes() } -func (u ScSandboxUtils) BlsValid(data, pubKey, signature []byte) bool { - encode := NewBytesEncoder().Bytes(data).Bytes(pubKey).Bytes(signature) - valid, _ := ExtractBool(Sandbox(FnUtilsBlsValid, encode.Data())) +func (u ScSandboxUtils) BlsValidSignature(data, pubKey, signature []byte) bool { + enc := wasmcodec.NewWasmEncoder().Bytes(data).Bytes(pubKey).Bytes(signature) + valid, _ := wasmcodec.ExtractBool(Sandbox(FnUtilsBlsValid, enc.Buf())) return valid } -func (u ScSandboxUtils) Ed25519Address(pubKey []byte) ScAddress { - return NewScAddressFromBytes(Sandbox(FnUtilsEd25519Address, pubKey)) +func (u ScSandboxUtils) Ed25519AddressFromPubKey(pubKey []byte) wasmtypes.ScAddress { + return wasmtypes.AddressFromBytes(Sandbox(FnUtilsEd25519Address, pubKey)) } -func (u ScSandboxUtils) Ed25519Valid(data, pubKey, signature []byte) bool { - encode := NewBytesEncoder().Bytes(data).Bytes(pubKey).Bytes(signature) - valid, _ := ExtractBool(Sandbox(FnUtilsEd25519Valid, encode.Data())) +func (u ScSandboxUtils) Ed25519ValidSignature(data, pubKey, signature []byte) bool { + enc := wasmcodec.NewWasmEncoder().Bytes(data).Bytes(pubKey).Bytes(signature) + valid, _ := wasmcodec.ExtractBool(Sandbox(FnUtilsEd25519Valid, enc.Buf())) return valid } -func (u ScSandboxUtils) HashBlake2b(value []byte) ScHash { - return NewScHashFromBytes(Sandbox(FnUtilsHashBlake2b, value)) +// hashes the specified value bytes using blake2b hashing and returns the resulting 32-byte hash +func (u ScSandboxUtils) HashBlake2b(value []byte) wasmtypes.ScHash { + return wasmtypes.HashFromBytes(Sandbox(FnUtilsHashBlake2b, value)) +} + +// hashes the specified value bytes using sha3 hashing and returns the resulting 32-byte hash +func (u ScSandboxUtils) HashSha3(value []byte) wasmtypes.ScHash { + return wasmtypes.HashFromBytes(Sandbox(FnUtilsHashSha3, value)) } -func (u ScSandboxUtils) HashName(value string) ScHname { - return NewScHnameFromBytes(Sandbox(FnUtilsHashName, []byte(value))) +// hashes the specified value bytes using blake2b hashing and returns the resulting 32-byte hash +func (u ScSandboxUtils) Hname(value string) wasmtypes.ScHname { + return wasmtypes.HnameFromBytes(Sandbox(FnUtilsHashName, []byte(value))) } -func (u ScSandboxUtils) HashSha3(value []byte) ScHash { - return NewScHashFromBytes(Sandbox(FnUtilsHashSha3, value)) +// converts an integer to its string representation +func (u ScSandboxUtils) String(value int64) string { + return wasmtypes.StringFromInt64(value) } diff --git a/packages/vm/wasmlib/go/wasmlib/state.go b/packages/vm/wasmlib/go/wasmlib/state.go new file mode 100644 index 0000000000..07cbc78b90 --- /dev/null +++ b/packages/vm/wasmlib/go/wasmlib/state.go @@ -0,0 +1,40 @@ +// Copyright 2020 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +package wasmlib + +import ( + "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" +) + +type ScImmutableState struct{} + +func (d ScImmutableState) Exists(key []byte) bool { + return StateExists(key) +} + +func (d ScImmutableState) Get(key []byte) []byte { + return StateGet(key) +} + +type ScState struct { + ScImmutableState +} + +var _ wasmtypes.IKvStore = ScState{} + +func (d ScState) Delete(key []byte) { + StateDelete(key) +} + +func (d ScState) Immutable() ScImmutableState { + return ScImmutableState{} +} + +func (d ScState) Set(key, value []byte) { + StateSet(key, value) +} + +func NewStateProxy() wasmtypes.Proxy { + return wasmtypes.NewProxy(new(ScState)) +} diff --git a/packages/vm/wasmlib/go/wasmlib/wasmcodec/buffer.go b/packages/vm/wasmlib/go/wasmlib/wasmcodec/buffer.go new file mode 100644 index 0000000000..c042515c8c --- /dev/null +++ b/packages/vm/wasmlib/go/wasmlib/wasmcodec/buffer.go @@ -0,0 +1,99 @@ +// Copyright 2020 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +package wasmcodec + +import ( + "encoding/binary" +) + +func ExtractBool(buf []byte) (bool, []byte) { + return buf[0] != 0, buf[1:] +} + +func ExtractBytes(buf []byte, n int) ([]byte, []byte) { + return buf[:n], buf[n:] +} + +func ExtractInt8(buf []byte) (int8, []byte) { + return int8(buf[0]), buf[1:] +} + +func ExtractInt16(buf []byte) (int16, []byte) { + return int16(binary.LittleEndian.Uint16(buf)), buf[2:] +} + +func ExtractInt32(buf []byte) (int32, []byte) { + return int32(binary.LittleEndian.Uint32(buf)), buf[4:] +} + +func ExtractInt64(buf []byte) (int64, []byte) { + return int64(binary.LittleEndian.Uint64(buf)), buf[8:] +} + +func ExtractUint8(buf []byte) (uint8, []byte) { + return buf[0], buf[1:] +} + +func ExtractUint16(buf []byte) (uint16, []byte) { + return binary.LittleEndian.Uint16(buf), buf[2:] +} + +func ExtractUint32(buf []byte) (uint32, []byte) { + return binary.LittleEndian.Uint32(buf), buf[4:] +} + +func ExtractUint64(buf []byte) (uint64, []byte) { + return binary.LittleEndian.Uint64(buf), buf[8:] +} + +//////////////////////////////////// + +func AppendBool(buf []byte, value bool) []byte { + if value { + return AppendUint8(buf, 1) + } + return AppendUint8(buf, 0) +} + +func AppendBytes(buf, value []byte) []byte { + return append(buf, value...) +} + +func AppendInt8(buf []byte, value int8) []byte { + return AppendUint8(buf, uint8(value)) +} + +func AppendInt16(buf []byte, value int16) []byte { + return AppendUint16(buf, uint16(value)) +} + +func AppendInt32(buf []byte, value int32) []byte { + return AppendUint32(buf, uint32(value)) +} + +func AppendInt64(buf []byte, value int64) []byte { + return AppendUint64(buf, uint64(value)) +} + +func AppendUint8(buf []byte, value uint8) []byte { + return append(buf, value) +} + +func AppendUint16(buf []byte, value uint16) []byte { + tmp := make([]byte, 2) + binary.LittleEndian.PutUint16(tmp, value) + return append(buf, tmp...) +} + +func AppendUint32(buf []byte, value uint32) []byte { + tmp := make([]byte, 4) + binary.LittleEndian.PutUint32(tmp, value) + return append(buf, tmp...) +} + +func AppendUint64(buf []byte, value uint64) []byte { + tmp := make([]byte, 8) + binary.LittleEndian.PutUint64(tmp, value) + return append(buf, tmp...) +} diff --git a/packages/vm/wasmlib/go/wasmlib/wasmcodec/codec.go b/packages/vm/wasmlib/go/wasmlib/wasmcodec/codec.go new file mode 100644 index 0000000000..0d3b939b31 --- /dev/null +++ b/packages/vm/wasmlib/go/wasmlib/wasmcodec/codec.go @@ -0,0 +1,183 @@ +// Copyright 2020 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +package wasmcodec + +type WasmDecoder struct { + buf []byte +} + +func NewWasmDecoder(buf []byte) *WasmDecoder { + return &WasmDecoder{buf: buf} +} + +func (d *WasmDecoder) abort(msg string) { + // make sure deferred Close() will not trigger another panic + d.buf = nil + panic(msg) +} + +func (d *WasmDecoder) Byte() byte { + if len(d.buf) == 0 { + d.abort("insufficient bytes") + } + value := d.buf[0] + d.buf = d.buf[1:] + return value +} + +func (d *WasmDecoder) Bytes() []byte { + length := uint32(d.VluDecode(32)) + return d.FixedBytes(length) +} + +func (d *WasmDecoder) Close() { + if len(d.buf) != 0 { + d.abort("extra bytes") + } +} + +func (d *WasmDecoder) FixedBytes(size uint32) []byte { + if uint32(len(d.buf)) < size { + d.abort("insufficient bytes") + } + value := d.buf[:size] + d.buf = d.buf[size:] + return value +} + +// VliDecode: Variable Length Integer decoder +func (d *WasmDecoder) VliDecode(bits int) (value int64) { + b := d.Byte() + sign := b & 0x40 + + // first group of 6 bits + value = int64(b & 0x3f) + s := 6 + + // while continuation bit is set + for (b & 0x80) != 0 { + if s >= bits { + d.abort("integer representation too long") + } + + // next group of 7 bits + b = d.Byte() + value |= int64(b&0x7f) << s + s += 7 + } + + if sign == 0 { + // positive, sign bits are already zero + return value + } + + // negative, extend sign bits + return value | (int64(-1) << s) +} + +// VluDecode: Variable Length Unsigned decoder +func (d *WasmDecoder) VluDecode(bits int) uint64 { + // first group of 7 bits + b := d.Byte() + value := uint64(b & 0x7f) + s := 7 + + // while continuation bit is set + for (b & 0x80) != 0 { + if s >= bits { + d.abort("integer representation too long") + } + + // next group of 7 bits + b = d.Byte() + value |= uint64(b&0x7f) << s + s += 7 + } + return value +} + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +type WasmEncoder struct { + buf []byte +} + +func NewWasmEncoder() *WasmEncoder { + return &WasmEncoder{buf: make([]byte, 0, 128)} +} + +func (e *WasmEncoder) Buf() []byte { + return e.buf +} + +func (e *WasmEncoder) Byte(value uint8) *WasmEncoder { + e.buf = append(e.buf, value) + return e +} + +func (e *WasmEncoder) Bytes(value []byte) *WasmEncoder { + length := len(value) + e.VluEncode(uint64(length)) + e.FixedBytes(value, uint32(length)) + return e +} + +func (e *WasmEncoder) FixedBytes(value []byte, length uint32) *WasmEncoder { + if len(value) != int(length) { + panic("invalid fixed bytes length") + } + e.buf = append(e.buf, value...) + return e +} + +// vli (variable length integer) encoder +func (e *WasmEncoder) VliEncode(value int64) *WasmEncoder { + // first group of 6 bits + // 1st byte encodes 0 as positive in bit 6 + b := byte(value) & 0x3f + value >>= 6 + + finalValue := int64(0) + if value < 0 { + // encode negative value + // 1st byte encodes 1 as negative in bit 6 + b |= 0x40 + finalValue = -1 + } + + // keep shifting until all bits are done + for value != finalValue { + // emit with continuation bit + e.buf = append(e.buf, b|0x80) + + // next group of 7 bits + b = byte(value) & 0x7f + value >>= 7 + } + + // emit without continuation bit + e.buf = append(e.buf, b) + return e +} + +// vlu (variable length unsigned) encoder +func (e *WasmEncoder) VluEncode(value uint64) *WasmEncoder { + // first group of 7 bits + b := byte(value) + value >>= 7 + + // keep shifting until all bits are done + for value != 0 { + // emit with continuation bit + e.buf = append(e.buf, b|0x80) + + // next group of 7 bits + b = byte(value) + value >>= 7 + } + + // emit without continuation bit + e.buf = append(e.buf, b) + return e +} diff --git a/packages/vm/wasmlib/go/wasmlib/wasmrequests/consts.go b/packages/vm/wasmlib/go/wasmlib/wasmrequests/consts.go new file mode 100644 index 0000000000..ec615e944a --- /dev/null +++ b/packages/vm/wasmlib/go/wasmlib/wasmrequests/consts.go @@ -0,0 +1,16 @@ +// Copyright 2020 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +// (Re-)generated by schema tool +// >>>> DO NOT CHANGE THIS FILE! <<<< +// Change the json schema instead + +package wasmrequests + +import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" + +const ( + ScName = "requests" + ScDescription = "WasmLib request structures" + HScName = wasmtypes.ScHname(0x98e19453) +) diff --git a/packages/vm/wasmlib/go/wasmlib/wasmrequests/contract.go b/packages/vm/wasmlib/go/wasmlib/wasmrequests/contract.go new file mode 100644 index 0000000000..26d5cdd63a --- /dev/null +++ b/packages/vm/wasmlib/go/wasmlib/wasmrequests/contract.go @@ -0,0 +1,8 @@ +// Copyright 2020 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +// (Re-)generated by schema tool +// >>>> DO NOT CHANGE THIS FILE! <<<< +// Change the json schema instead + +package wasmrequests diff --git a/packages/vm/wasmlib/go/wasmlib/wasmrequests/structs.go b/packages/vm/wasmlib/go/wasmlib/wasmrequests/structs.go new file mode 100644 index 0000000000..f23953fdaa --- /dev/null +++ b/packages/vm/wasmlib/go/wasmlib/wasmrequests/structs.go @@ -0,0 +1,249 @@ +// Copyright 2020 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +// (Re-)generated by schema tool +// >>>> DO NOT CHANGE THIS FILE! <<<< +// Change the json schema instead + +package wasmrequests + +import ( + "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmcodec" + "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" +) + +type CallRequest struct { + Contract wasmtypes.ScHname + Function wasmtypes.ScHname + Params []byte + Transfer []byte +} + +func NewCallRequestFromBytes(buf []byte) *CallRequest { + dec := wasmcodec.NewWasmDecoder(buf) + data := &CallRequest{} + data.Contract = wasmtypes.DecodeHname(dec) + data.Function = wasmtypes.DecodeHname(dec) + data.Params = wasmtypes.DecodeBytes(dec) + data.Transfer = wasmtypes.DecodeBytes(dec) + dec.Close() + return data +} + +func (o *CallRequest) Bytes() []byte { + enc := wasmcodec.NewWasmEncoder() + wasmtypes.EncodeHname(enc, o.Contract) + wasmtypes.EncodeHname(enc, o.Function) + wasmtypes.EncodeBytes(enc, o.Params) + wasmtypes.EncodeBytes(enc, o.Transfer) + return enc.Buf() +} + +type ImmutableCallRequest struct { + proxy wasmtypes.Proxy +} + +func (o ImmutableCallRequest) Exists() bool { + return o.proxy.Exists() +} + +func (o ImmutableCallRequest) Value() *CallRequest { + return NewCallRequestFromBytes(o.proxy.Get()) +} + +type MutableCallRequest struct { + proxy wasmtypes.Proxy +} + +func (o MutableCallRequest) Delete() { + o.proxy.Delete() +} + +func (o MutableCallRequest) Exists() bool { + return o.proxy.Exists() +} + +func (o MutableCallRequest) SetValue(value *CallRequest) { + o.proxy.Set(value.Bytes()) +} + +func (o MutableCallRequest) Value() *CallRequest { + return NewCallRequestFromBytes(o.proxy.Get()) +} + +type DeployRequest struct { + Description string + Name string + Params []byte + ProgHash wasmtypes.ScHash +} + +func NewDeployRequestFromBytes(buf []byte) *DeployRequest { + dec := wasmcodec.NewWasmDecoder(buf) + data := &DeployRequest{} + data.Description = wasmtypes.DecodeString(dec) + data.Name = wasmtypes.DecodeString(dec) + data.Params = wasmtypes.DecodeBytes(dec) + data.ProgHash = wasmtypes.DecodeHash(dec) + dec.Close() + return data +} + +func (o *DeployRequest) Bytes() []byte { + enc := wasmcodec.NewWasmEncoder() + wasmtypes.EncodeString(enc, o.Description) + wasmtypes.EncodeString(enc, o.Name) + wasmtypes.EncodeBytes(enc, o.Params) + wasmtypes.EncodeHash(enc, o.ProgHash) + return enc.Buf() +} + +type ImmutableDeployRequest struct { + proxy wasmtypes.Proxy +} + +func (o ImmutableDeployRequest) Exists() bool { + return o.proxy.Exists() +} + +func (o ImmutableDeployRequest) Value() *DeployRequest { + return NewDeployRequestFromBytes(o.proxy.Get()) +} + +type MutableDeployRequest struct { + proxy wasmtypes.Proxy +} + +func (o MutableDeployRequest) Delete() { + o.proxy.Delete() +} + +func (o MutableDeployRequest) Exists() bool { + return o.proxy.Exists() +} + +func (o MutableDeployRequest) SetValue(value *DeployRequest) { + o.proxy.Set(value.Bytes()) +} + +func (o MutableDeployRequest) Value() *DeployRequest { + return NewDeployRequestFromBytes(o.proxy.Get()) +} + +type PostRequest struct { + ChainID wasmtypes.ScChainID + Contract wasmtypes.ScHname + Delay uint32 + Function wasmtypes.ScHname + Params []byte + Transfer []byte +} + +func NewPostRequestFromBytes(buf []byte) *PostRequest { + dec := wasmcodec.NewWasmDecoder(buf) + data := &PostRequest{} + data.ChainID = wasmtypes.DecodeChainID(dec) + data.Contract = wasmtypes.DecodeHname(dec) + data.Delay = wasmtypes.DecodeUint32(dec) + data.Function = wasmtypes.DecodeHname(dec) + data.Params = wasmtypes.DecodeBytes(dec) + data.Transfer = wasmtypes.DecodeBytes(dec) + dec.Close() + return data +} + +func (o *PostRequest) Bytes() []byte { + enc := wasmcodec.NewWasmEncoder() + wasmtypes.EncodeChainID(enc, o.ChainID) + wasmtypes.EncodeHname(enc, o.Contract) + wasmtypes.EncodeUint32(enc, o.Delay) + wasmtypes.EncodeHname(enc, o.Function) + wasmtypes.EncodeBytes(enc, o.Params) + wasmtypes.EncodeBytes(enc, o.Transfer) + return enc.Buf() +} + +type ImmutablePostRequest struct { + proxy wasmtypes.Proxy +} + +func (o ImmutablePostRequest) Exists() bool { + return o.proxy.Exists() +} + +func (o ImmutablePostRequest) Value() *PostRequest { + return NewPostRequestFromBytes(o.proxy.Get()) +} + +type MutablePostRequest struct { + proxy wasmtypes.Proxy +} + +func (o MutablePostRequest) Delete() { + o.proxy.Delete() +} + +func (o MutablePostRequest) Exists() bool { + return o.proxy.Exists() +} + +func (o MutablePostRequest) SetValue(value *PostRequest) { + o.proxy.Set(value.Bytes()) +} + +func (o MutablePostRequest) Value() *PostRequest { + return NewPostRequestFromBytes(o.proxy.Get()) +} + +type SendRequest struct { + Address wasmtypes.ScAddress + Transfer []byte +} + +func NewSendRequestFromBytes(buf []byte) *SendRequest { + dec := wasmcodec.NewWasmDecoder(buf) + data := &SendRequest{} + data.Address = wasmtypes.DecodeAddress(dec) + data.Transfer = wasmtypes.DecodeBytes(dec) + dec.Close() + return data +} + +func (o *SendRequest) Bytes() []byte { + enc := wasmcodec.NewWasmEncoder() + wasmtypes.EncodeAddress(enc, o.Address) + wasmtypes.EncodeBytes(enc, o.Transfer) + return enc.Buf() +} + +type ImmutableSendRequest struct { + proxy wasmtypes.Proxy +} + +func (o ImmutableSendRequest) Exists() bool { + return o.proxy.Exists() +} + +func (o ImmutableSendRequest) Value() *SendRequest { + return NewSendRequestFromBytes(o.proxy.Get()) +} + +type MutableSendRequest struct { + proxy wasmtypes.Proxy +} + +func (o MutableSendRequest) Delete() { + o.proxy.Delete() +} + +func (o MutableSendRequest) Exists() bool { + return o.proxy.Exists() +} + +func (o MutableSendRequest) SetValue(value *SendRequest) { + o.proxy.Set(value.Bytes()) +} + +func (o MutableSendRequest) Value() *SendRequest { + return NewSendRequestFromBytes(o.proxy.Get()) +} diff --git a/packages/vm/wasmlib/go/wasmlib/wasmtypes/address.go b/packages/vm/wasmlib/go/wasmlib/wasmtypes/address.go new file mode 100644 index 0000000000..f4151fc865 --- /dev/null +++ b/packages/vm/wasmlib/go/wasmlib/wasmtypes/address.go @@ -0,0 +1,91 @@ +// Copyright 2020 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +package wasmtypes + +import ( + "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmcodec" +) + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +const ScAddressLength = 33 + +type ScAddress struct { + id [ScAddressLength]byte +} + +func DecodeAddress(dec *wasmcodec.WasmDecoder) ScAddress { + return newAddressFromBytes(dec.FixedBytes(ScAddressLength)) +} + +func EncodeAddress(enc *wasmcodec.WasmEncoder, value ScAddress) { + enc.FixedBytes(value.Bytes(), ScAddressLength) +} + +func AddressFromBytes(buf []byte) ScAddress { + if len(buf) != ScAddressLength { + Panic("invalid Address length") + } + return newAddressFromBytes(buf) +} + +func newAddressFromBytes(buf []byte) ScAddress { + o := ScAddress{} + copy(o.id[:], buf) + return o +} + +func (o ScAddress) AsAgentID() ScAgentID { + // agentID for address has Hname zero + return NewScAgentID(o, 0) +} + +func (o ScAddress) Bytes() []byte { + return o.id[:] +} + +func (o ScAddress) String() string { + // TODO standardize human readable string + return base58Encode(o.id[:]) +} + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +type ScImmutableAddress struct { + proxy Proxy +} + +func NewScImmutableAddress(proxy Proxy) ScImmutableAddress { + return ScImmutableAddress{proxy: proxy} +} + +func (o ScImmutableAddress) Exists() bool { + return o.proxy.Exists() +} + +func (o ScImmutableAddress) String() string { + return o.Value().String() +} + +func (o ScImmutableAddress) Value() ScAddress { + return AddressFromBytes(o.proxy.Get()) +} + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +type ScMutableAddress struct { + ScImmutableAddress +} + +func NewScMutableAddress(proxy Proxy) ScMutableAddress { + return ScMutableAddress{ScImmutableAddress{proxy: proxy}} +} + +func (o ScMutableAddress) Delete() { + o.proxy.Delete() +} + +func (o ScMutableAddress) SetValue(value ScAddress) { + o.proxy.Set(value.Bytes()) +} diff --git a/packages/vm/wasmlib/go/wasmlib/wasmtypes/agentid.go b/packages/vm/wasmlib/go/wasmlib/wasmtypes/agentid.go new file mode 100644 index 0000000000..128f702311 --- /dev/null +++ b/packages/vm/wasmlib/go/wasmlib/wasmtypes/agentid.go @@ -0,0 +1,107 @@ +// Copyright 2020 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +package wasmtypes + +import ( + "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmcodec" +) + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +const ScAgentIDLength = ScAddressLength + ScHnameLength + +type ScAgentID struct { + address ScAddress + hname ScHname +} + +func DecodeAgentID(dec *wasmcodec.WasmDecoder) ScAgentID { + return newAgentIDFromBytes(dec.FixedBytes(ScAgentIDLength)) +} + +func EncodeAgentID(enc *wasmcodec.WasmEncoder, value ScAgentID) { + EncodeAddress(enc, value.address) + EncodeHname(enc, value.hname) +} + +func AgentIDFromBytes(buf []byte) ScAgentID { + if len(buf) != ScAgentIDLength { + Panic("invalid AgentID length") + } + return newAgentIDFromBytes(buf) +} + +func newAgentIDFromBytes(buf []byte) ScAgentID { + return ScAgentID{ + address: AddressFromBytes(buf[:ScAddressLength]), + hname: HnameFromBytes(buf[ScAddressLength:]), + } +} + +func NewScAgentID(address ScAddress, hname ScHname) ScAgentID { + return ScAgentID{address: address, hname: hname} +} + +func (o ScAgentID) Address() ScAddress { + return o.address +} + +func (o ScAgentID) Bytes() []byte { + enc := wasmcodec.NewWasmEncoder() + EncodeAgentID(enc, o) + return enc.Buf() +} + +func (o ScAgentID) Hname() ScHname { + return o.hname +} + +func (o ScAgentID) IsAddress() bool { + return o.hname == 0 +} + +func (o ScAgentID) String() string { + // TODO standardize human readable string + return o.address.String() + "::" + o.hname.String() +} + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +type ScImmutableAgentID struct { + proxy Proxy +} + +func NewScImmutableAgentID(proxy Proxy) ScImmutableAgentID { + return ScImmutableAgentID{proxy: proxy} +} + +func (o ScImmutableAgentID) Exists() bool { + return o.proxy.Exists() +} + +func (o ScImmutableAgentID) String() string { + return o.Value().String() +} + +func (o ScImmutableAgentID) Value() ScAgentID { + return AgentIDFromBytes(o.proxy.Get()) +} + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +type ScMutableAgentID struct { + ScImmutableAgentID +} + +func NewScMutableAgentID(proxy Proxy) ScMutableAgentID { + return ScMutableAgentID{ScImmutableAgentID{proxy: proxy}} +} + +func (o ScMutableAgentID) Delete() { + o.proxy.Delete() +} + +func (o ScMutableAgentID) SetValue(value ScAgentID) { + o.proxy.Set(value.Bytes()) +} diff --git a/packages/vm/wasmlib/go/wasmlib/wasmtypes/bool.go b/packages/vm/wasmlib/go/wasmlib/wasmtypes/bool.go new file mode 100644 index 0000000000..edb35a1f04 --- /dev/null +++ b/packages/vm/wasmlib/go/wasmlib/wasmtypes/bool.go @@ -0,0 +1,83 @@ +// Copyright 2020 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +package wasmtypes + +import ( + "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmcodec" +) + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +func DecodeBool(dec *wasmcodec.WasmDecoder) bool { + return dec.Byte() != 0 +} + +func EncodeBool(enc *wasmcodec.WasmEncoder, value bool) { + if value { + enc.Byte(1) + return + } + enc.Byte(0) +} + +func BoolFromBytes(buf []byte) bool { + if len(buf) != 1 { + Panic("invalid Bool length") + } + return buf[0] != 0 +} + +func BytesFromBool(value bool) []byte { + if value { + return []byte{1} + } + return []byte{0} +} + +func StringFromBool(value bool) string { + if value { + return "1" + } + return "0" +} + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +type ScImmutableBool struct { + proxy Proxy +} + +func NewScImmutableBool(proxy Proxy) ScImmutableBool { + return ScImmutableBool{proxy: proxy} +} + +func (o ScImmutableBool) Exists() bool { + return o.proxy.Exists() +} + +func (o ScImmutableBool) String() string { + return StringFromBool(o.Value()) +} + +func (o ScImmutableBool) Value() bool { + return BoolFromBytes(o.proxy.Get()) +} + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +type ScMutableBool struct { + ScImmutableBool +} + +func NewScMutableBool(proxy Proxy) ScMutableBool { + return ScMutableBool{ScImmutableBool{proxy: proxy}} +} + +func (o ScMutableBool) Delete() { + o.proxy.Delete() +} + +func (o ScMutableBool) SetValue(value bool) { + o.proxy.Set(BytesFromBool(value)) +} diff --git a/packages/vm/wasmlib/go/wasmlib/wasmtypes/bytes.go b/packages/vm/wasmlib/go/wasmlib/wasmtypes/bytes.go new file mode 100644 index 0000000000..52ebc3d43e --- /dev/null +++ b/packages/vm/wasmlib/go/wasmlib/wasmtypes/bytes.go @@ -0,0 +1,62 @@ +// Copyright 2020 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +package wasmtypes + +import ( + "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmcodec" +) + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +func DecodeBytes(dec *wasmcodec.WasmDecoder) []byte { + return dec.Bytes() +} + +func EncodeBytes(enc *wasmcodec.WasmEncoder, value []byte) { + enc.Bytes(value) +} + +func BytesFromBytes(buf []byte) []byte { + return buf +} + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +type ScImmutableBytes struct { + proxy Proxy +} + +func NewScImmutableBytes(proxy Proxy) ScImmutableBytes { + return ScImmutableBytes{proxy: proxy} +} + +func (o ScImmutableBytes) Exists() bool { + return o.proxy.Exists() +} + +func (o ScImmutableBytes) String() string { + return StringFromBytes(o.Value()) +} + +func (o ScImmutableBytes) Value() []byte { + return BytesFromBytes(o.proxy.Get()) +} + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +type ScMutableBytes struct { + ScImmutableBytes +} + +func NewScMutableBytes(proxy Proxy) ScMutableBytes { + return ScMutableBytes{ScImmutableBytes{proxy: proxy}} +} + +func (o ScMutableBytes) Delete() { + o.proxy.Delete() +} + +func (o ScMutableBytes) SetValue(value []byte) { + o.proxy.Set(BytesFromBytes(value)) +} diff --git a/packages/vm/wasmlib/go/wasmlib/wasmtypes/chainid.go b/packages/vm/wasmlib/go/wasmlib/wasmtypes/chainid.go new file mode 100644 index 0000000000..847381b914 --- /dev/null +++ b/packages/vm/wasmlib/go/wasmlib/wasmtypes/chainid.go @@ -0,0 +1,90 @@ +// Copyright 2020 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +package wasmtypes + +import ( + "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmcodec" +) + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +const ScChainIDLength = 33 + +type ScChainID struct { + id [ScChainIDLength]byte +} + +func DecodeChainID(dec *wasmcodec.WasmDecoder) ScChainID { + return newChainIDFromBytes(dec.FixedBytes(ScChainIDLength)) +} + +func EncodeChainID(enc *wasmcodec.WasmEncoder, value ScChainID) { + enc.FixedBytes(value.Bytes(), ScChainIDLength) +} + +func ChainIDFromBytes(buf []byte) ScChainID { + if len(buf) != ScChainIDLength { + Panic("invalid ChainID length") + } + return newChainIDFromBytes(buf) +} + +func newChainIDFromBytes(buf []byte) ScChainID { + o := ScChainID{} + copy(o.id[:], buf) + return o +} + +func (o ScChainID) Address() ScAddress { + return AddressFromBytes(o.id[:]) +} + +func (o ScChainID) Bytes() []byte { + return o.id[:] +} + +func (o ScChainID) String() string { + // TODO standardize human readable string + return base58Encode(o.id[:]) +} + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +type ScImmutableChainID struct { + proxy Proxy +} + +func NewScImmutableChainID(proxy Proxy) ScImmutableChainID { + return ScImmutableChainID{proxy: proxy} +} + +func (o ScImmutableChainID) Exists() bool { + return o.proxy.Exists() +} + +func (o ScImmutableChainID) String() string { + return o.Value().String() +} + +func (o ScImmutableChainID) Value() ScChainID { + return ChainIDFromBytes(o.proxy.Get()) +} + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +type ScMutableChainID struct { + ScImmutableChainID +} + +func NewScMutableChainID(proxy Proxy) ScMutableChainID { + return ScMutableChainID{ScImmutableChainID{proxy: proxy}} +} + +func (o ScMutableChainID) Delete() { + o.proxy.Delete() +} + +func (o ScMutableChainID) SetValue(value ScChainID) { + o.proxy.Set(value.Bytes()) +} diff --git a/packages/vm/wasmlib/go/wasmlib/wasmtypes/color.go b/packages/vm/wasmlib/go/wasmlib/wasmtypes/color.go new file mode 100644 index 0000000000..414d760c9c --- /dev/null +++ b/packages/vm/wasmlib/go/wasmlib/wasmtypes/color.go @@ -0,0 +1,97 @@ +// Copyright 2020 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +package wasmtypes + +import ( + "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmcodec" +) + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +const ScColorLength = 32 + +type ScColor struct { + id [ScColorLength]byte +} + +var ( + IOTA = ScColor{} + MINT = ScColor{} +) + +func init() { + for i := range MINT.id { + MINT.id[i] = 0xff + } +} + +func DecodeColor(dec *wasmcodec.WasmDecoder) ScColor { + return newColorFromBytes(dec.FixedBytes(ScColorLength)) +} + +func EncodeColor(enc *wasmcodec.WasmEncoder, value ScColor) { + enc.FixedBytes(value.Bytes(), ScColorLength) +} + +func ColorFromBytes(buf []byte) ScColor { + if len(buf) != ScColorLength { + Panic("invalid Color length") + } + return newColorFromBytes(buf) +} + +func newColorFromBytes(buf []byte) ScColor { + o := ScColor{} + copy(o.id[:], buf) + return o +} + +func (o ScColor) Bytes() []byte { + return o.id[:] +} + +func (o ScColor) String() string { + // TODO standardize human readable string + return base58Encode(o.id[:]) +} + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +type ScImmutableColor struct { + proxy Proxy +} + +func NewScImmutableColor(proxy Proxy) ScImmutableColor { + return ScImmutableColor{proxy: proxy} +} + +func (o ScImmutableColor) Exists() bool { + return o.proxy.Exists() +} + +func (o ScImmutableColor) String() string { + return o.Value().String() +} + +func (o ScImmutableColor) Value() ScColor { + return ColorFromBytes(o.proxy.Get()) +} + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +type ScMutableColor struct { + ScImmutableColor +} + +func NewScMutableColor(proxy Proxy) ScMutableColor { + return ScMutableColor{ScImmutableColor{proxy: proxy}} +} + +func (o ScMutableColor) Delete() { + o.proxy.Delete() +} + +func (o ScMutableColor) SetValue(value ScColor) { + o.proxy.Set(value.Bytes()) +} diff --git a/packages/vm/wasmlib/go/wasmlib/wasmtypes/hash.go b/packages/vm/wasmlib/go/wasmlib/wasmtypes/hash.go new file mode 100644 index 0000000000..9e855b4c81 --- /dev/null +++ b/packages/vm/wasmlib/go/wasmlib/wasmtypes/hash.go @@ -0,0 +1,87 @@ +// Copyright 2020 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +//nolint:dupl +package wasmtypes + +import ( + "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmcodec" +) + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +const ScHashLength = 32 + +type ScHash struct { + id [ScHashLength]byte +} + +func DecodeHash(dec *wasmcodec.WasmDecoder) ScHash { + return newHashFromBytes(dec.FixedBytes(ScHashLength)) +} + +func EncodeHash(enc *wasmcodec.WasmEncoder, value ScHash) { + enc.FixedBytes(value.Bytes(), ScHashLength) +} + +func HashFromBytes(buf []byte) ScHash { + if len(buf) != ScHashLength { + Panic("invalid Hash length") + } + return newHashFromBytes(buf) +} + +func newHashFromBytes(buf []byte) ScHash { + o := ScHash{} + copy(o.id[:], buf) + return o +} + +func (o ScHash) Bytes() []byte { + return o.id[:] +} + +func (o ScHash) String() string { + // TODO standardize human readable string + return base58Encode(o.id[:]) +} + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +type ScImmutableHash struct { + proxy Proxy +} + +func NewScImmutableHash(proxy Proxy) ScImmutableHash { + return ScImmutableHash{proxy: proxy} +} + +func (o ScImmutableHash) Exists() bool { + return o.proxy.Exists() +} + +func (o ScImmutableHash) String() string { + return o.Value().String() +} + +func (o ScImmutableHash) Value() ScHash { + return HashFromBytes(o.proxy.Get()) +} + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +type ScMutableHash struct { + ScImmutableHash +} + +func NewScMutableHash(proxy Proxy) ScMutableHash { + return ScMutableHash{ScImmutableHash{proxy: proxy}} +} + +func (o ScMutableHash) Delete() { + o.proxy.Delete() +} + +func (o ScMutableHash) SetValue(value ScHash) { + o.proxy.Set(value.Bytes()) +} diff --git a/packages/vm/wasmlib/go/wasmlib/wasmtypes/hname.go b/packages/vm/wasmlib/go/wasmlib/wasmtypes/hname.go new file mode 100644 index 0000000000..daa11ab441 --- /dev/null +++ b/packages/vm/wasmlib/go/wasmlib/wasmtypes/hname.go @@ -0,0 +1,90 @@ +// Copyright 2020 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +package wasmtypes + +import ( + "encoding/binary" + + "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmcodec" +) + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +const ScHnameLength = 4 + +type ScHname uint32 + +func DecodeHname(dec *wasmcodec.WasmDecoder) ScHname { + return newHnameFromBytes(dec.FixedBytes(ScHnameLength)) +} + +func EncodeHname(enc *wasmcodec.WasmEncoder, value ScHname) { + enc.FixedBytes(value.Bytes(), ScHnameLength) +} + +func HnameFromBytes(buf []byte) ScHname { + if len(buf) != ScHnameLength { + Panic("invalid Hname length") + } + return newHnameFromBytes(buf) +} + +func newHnameFromBytes(buf []byte) ScHname { + return ScHname(binary.LittleEndian.Uint32(buf)) +} + +//func HnameFromString(name string) ScHname { +// return HnameFromBytes(wasmlib.Sandbox(wasmstore.FnUtilsHashName, []byte(name))) +//} + +func (o ScHname) Bytes() []byte { + buf := make([]byte, 4) + binary.LittleEndian.PutUint32(buf, uint32(o)) + return buf +} + +func (o ScHname) String() string { + // TODO standardize human readable string + return hex(o.Bytes()) +} + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +type ScImmutableHname struct { + proxy Proxy +} + +func NewScImmutableHname(proxy Proxy) ScImmutableHname { + return ScImmutableHname{proxy: proxy} +} + +func (o ScImmutableHname) Exists() bool { + return o.proxy.Exists() +} + +func (o ScImmutableHname) String() string { + return o.Value().String() +} + +func (o ScImmutableHname) Value() ScHname { + return HnameFromBytes(o.proxy.Get()) +} + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +type ScMutableHname struct { + ScImmutableHname +} + +func NewScMutableHname(proxy Proxy) ScMutableHname { + return ScMutableHname{ScImmutableHname{proxy: proxy}} +} + +func (o ScMutableHname) Delete() { + o.proxy.Delete() +} + +func (o ScMutableHname) SetValue(value ScHname) { + o.proxy.Set(value.Bytes()) +} diff --git a/packages/vm/wasmlib/go/wasmlib/wasmtypes/int16.go b/packages/vm/wasmlib/go/wasmlib/wasmtypes/int16.go new file mode 100644 index 0000000000..8f182628ed --- /dev/null +++ b/packages/vm/wasmlib/go/wasmlib/wasmtypes/int16.go @@ -0,0 +1,79 @@ +// Copyright 2020 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +//nolint:dupl +package wasmtypes + +import ( + "encoding/binary" + "strconv" + + "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmcodec" +) + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +func DecodeInt16(dec *wasmcodec.WasmDecoder) int16 { + return int16(dec.VliDecode(16)) +} + +func EncodeInt16(enc *wasmcodec.WasmEncoder, value int16) { + enc.VliEncode(int64(value)) +} + +func Int16FromBytes(buf []byte) int16 { + if len(buf) != 2 { + Panic("invalid Int16 length") + } + return int16(binary.LittleEndian.Uint16(buf)) +} + +func BytesFromInt16(value int16) []byte { + tmp := make([]byte, 2) + binary.LittleEndian.PutUint16(tmp, uint16(value)) + return tmp +} + +func StringFromInt16(value int16) string { + return strconv.FormatInt(int64(value), 10) +} + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +type ScImmutableInt16 struct { + proxy Proxy +} + +func NewScImmutableInt16(proxy Proxy) ScImmutableInt16 { + return ScImmutableInt16{proxy: proxy} +} + +func (o ScImmutableInt16) Exists() bool { + return o.proxy.Exists() +} + +func (o ScImmutableInt16) String() string { + return StringFromInt16(o.Value()) +} + +func (o ScImmutableInt16) Value() int16 { + return Int16FromBytes(o.proxy.Get()) +} + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +type ScMutableInt16 struct { + ScImmutableInt16 +} + +func NewScMutableInt16(proxy Proxy) ScMutableInt16 { + return ScMutableInt16{ScImmutableInt16{proxy: proxy}} +} + +func (o ScMutableInt16) Delete() { + o.proxy.Delete() +} + +func (o ScMutableInt16) SetValue(value int16) { + o.proxy.Set(BytesFromInt16(value)) +} diff --git a/packages/vm/wasmlib/go/wasmlib/wasmtypes/int32.go b/packages/vm/wasmlib/go/wasmlib/wasmtypes/int32.go new file mode 100644 index 0000000000..f0e4417aaf --- /dev/null +++ b/packages/vm/wasmlib/go/wasmlib/wasmtypes/int32.go @@ -0,0 +1,79 @@ +// Copyright 2020 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +//nolint:dupl +package wasmtypes + +import ( + "encoding/binary" + "strconv" + + "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmcodec" +) + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +func DecodeInt32(dec *wasmcodec.WasmDecoder) int32 { + return int32(dec.VliDecode(32)) +} + +func EncodeInt32(enc *wasmcodec.WasmEncoder, value int32) { + enc.VliEncode(int64(value)) +} + +func Int32FromBytes(buf []byte) int32 { + if len(buf) != 4 { + Panic("invalid Int32 length") + } + return int32(binary.LittleEndian.Uint32(buf)) +} + +func BytesFromInt32(value int32) []byte { + tmp := make([]byte, 4) + binary.LittleEndian.PutUint32(tmp, uint32(value)) + return tmp +} + +func StringFromInt32(value int32) string { + return strconv.FormatInt(int64(value), 10) +} + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +type ScImmutableInt32 struct { + proxy Proxy +} + +func NewScImmutableInt32(proxy Proxy) ScImmutableInt32 { + return ScImmutableInt32{proxy: proxy} +} + +func (o ScImmutableInt32) Exists() bool { + return o.proxy.Exists() +} + +func (o ScImmutableInt32) String() string { + return StringFromInt32(o.Value()) +} + +func (o ScImmutableInt32) Value() int32 { + return Int32FromBytes(o.proxy.Get()) +} + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +type ScMutableInt32 struct { + ScImmutableInt32 +} + +func NewScMutableInt32(proxy Proxy) ScMutableInt32 { + return ScMutableInt32{ScImmutableInt32{proxy: proxy}} +} + +func (o ScMutableInt32) Delete() { + o.proxy.Delete() +} + +func (o ScMutableInt32) SetValue(value int32) { + o.proxy.Set(BytesFromInt32(value)) +} diff --git a/packages/vm/wasmlib/go/wasmlib/wasmtypes/int64.go b/packages/vm/wasmlib/go/wasmlib/wasmtypes/int64.go new file mode 100644 index 0000000000..457cdae295 --- /dev/null +++ b/packages/vm/wasmlib/go/wasmlib/wasmtypes/int64.go @@ -0,0 +1,78 @@ +// Copyright 2020 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +package wasmtypes + +import ( + "encoding/binary" + "strconv" + + "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmcodec" +) + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +func DecodeInt64(dec *wasmcodec.WasmDecoder) int64 { + return dec.VliDecode(64) +} + +func EncodeInt64(enc *wasmcodec.WasmEncoder, value int64) { + enc.VliEncode(value) +} + +func Int64FromBytes(buf []byte) int64 { + if len(buf) != 8 { + Panic("invalid Int64 length") + } + return int64(binary.LittleEndian.Uint64(buf)) +} + +func BytesFromInt64(value int64) []byte { + tmp := make([]byte, 8) + binary.LittleEndian.PutUint64(tmp, uint64(value)) + return tmp +} + +func StringFromInt64(value int64) string { + return strconv.FormatInt(value, 10) +} + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +type ScImmutableInt64 struct { + proxy Proxy +} + +func NewScImmutableInt64(proxy Proxy) ScImmutableInt64 { + return ScImmutableInt64{proxy: proxy} +} + +func (o ScImmutableInt64) Exists() bool { + return o.proxy.Exists() +} + +func (o ScImmutableInt64) String() string { + return StringFromInt64(o.Value()) +} + +func (o ScImmutableInt64) Value() int64 { + return Int64FromBytes(o.proxy.Get()) +} + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +type ScMutableInt64 struct { + ScImmutableInt64 +} + +func NewScMutableInt64(proxy Proxy) ScMutableInt64 { + return ScMutableInt64{ScImmutableInt64{proxy: proxy}} +} + +func (o ScMutableInt64) Delete() { + o.proxy.Delete() +} + +func (o ScMutableInt64) SetValue(value int64) { + o.proxy.Set(BytesFromInt64(value)) +} diff --git a/packages/vm/wasmlib/go/wasmlib/wasmtypes/int8.go b/packages/vm/wasmlib/go/wasmlib/wasmtypes/int8.go new file mode 100644 index 0000000000..2a707a8e4d --- /dev/null +++ b/packages/vm/wasmlib/go/wasmlib/wasmtypes/int8.go @@ -0,0 +1,75 @@ +// Copyright 2020 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +package wasmtypes + +import ( + "strconv" + + "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmcodec" +) + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +func DecodeInt8(dec *wasmcodec.WasmDecoder) int8 { + return int8(dec.Byte()) +} + +func EncodeInt8(enc *wasmcodec.WasmEncoder, value int8) { + enc.Byte(byte(value)) +} + +func Int8FromBytes(buf []byte) int8 { + if len(buf) != 1 { + Panic("invalid Int8 length") + } + return int8(buf[0]) +} + +func BytesFromInt8(value int8) []byte { + return []byte{byte(value)} +} + +func StringFromInt8(value int8) string { + return strconv.FormatInt(int64(value), 10) +} + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +type ScImmutableInt8 struct { + proxy Proxy +} + +func NewScImmutableInt8(proxy Proxy) ScImmutableInt8 { + return ScImmutableInt8{proxy: proxy} +} + +func (o ScImmutableInt8) Exists() bool { + return o.proxy.Exists() +} + +func (o ScImmutableInt8) String() string { + return StringFromInt8(o.Value()) +} + +func (o ScImmutableInt8) Value() int8 { + return Int8FromBytes(o.proxy.Get()) +} + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +type ScMutableInt8 struct { + ScImmutableInt8 +} + +func NewScMutableInt8(proxy Proxy) ScMutableInt8 { + return ScMutableInt8{ScImmutableInt8{proxy: proxy}} +} + +func (o ScMutableInt8) Delete() { + o.proxy.Delete() +} + +func (o ScMutableInt8) SetValue(value int8) { + o.proxy.Set(BytesFromInt8(value)) +} diff --git a/packages/vm/wasmlib/go/wasmlib/wasmtypes/proxy.go b/packages/vm/wasmlib/go/wasmlib/wasmtypes/proxy.go new file mode 100644 index 0000000000..e5555cec58 --- /dev/null +++ b/packages/vm/wasmlib/go/wasmlib/wasmtypes/proxy.go @@ -0,0 +1,134 @@ +// Copyright 2020 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +package wasmtypes + +import ( + "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmcodec" +) + +type IKvStore interface { + Delete(key []byte) + Exists(key []byte) bool + Get(key []byte) []byte + Set(key, value []byte) +} + +type Proxy struct { + key []byte + kvStore IKvStore +} + +func NewProxy(kvStore IKvStore) Proxy { + return Proxy{kvStore: kvStore} +} + +// Append returns a Proxy for a newly appended null element +// Note that this will essentially return the element at Length() +func (p Proxy) Append() Proxy { + length := p.Length() + p.Expand(length + 1) + return p.element(length) +} + +// ClearArray clears an array by deleting all elements +// TODO Note that this does not delete recursive container elements +func (p Proxy) ClearArray() { + for length := p.Length(); length != 0; length-- { + p.element(length - 1).Delete() + } + + // clear the length counter + p.Delete() +} + +// ClearMap clears a map by deleting all elements +// TODO Note that this does not delete recursive container elements +func (p Proxy) ClearMap() { + // TODO clearPrefix + + // clear the length counter + p.Delete() +} + +func (p Proxy) Decoder() *wasmcodec.WasmDecoder { + return p.decoder(p.Get()) +} + +func (p Proxy) decoder(buf []byte) *wasmcodec.WasmDecoder { + return wasmcodec.NewWasmDecoder(buf) +} + +func (p Proxy) Delete() { + p.kvStore.Delete(p.key) +} + +func (p Proxy) element(index uint32) Proxy { + enc := p.Encoder() + EncodeUint32(enc, index) + return p.sub('#', enc.Buf()) +} + +func (p Proxy) Encoder() *wasmcodec.WasmEncoder { + return wasmcodec.NewWasmEncoder() +} + +func (p Proxy) Exists() bool { + return p.kvStore.Exists(p.key) +} + +func (p Proxy) Expand(length uint32) { + // update the length counter + enc := p.Encoder() + EncodeUint32(enc, length) + p.Set(enc.Buf()) +} + +func (p Proxy) Get() []byte { + return p.kvStore.Get(p.key) +} + +// Index gets a Proxy for an element of an Array by its index +func (p Proxy) Index(index uint32) Proxy { + if index >= p.Length() { + panic("invalid index") + } + return p.element(index) +} + +// Key gets a Proxy for an element of a Map by its key +func (p Proxy) Key(key []byte) Proxy { + return p.sub('.', key) +} + +// Length returns the number of elements in an Array +// Never try to access an index >= Length() +func (p Proxy) Length() uint32 { + // get the length counter + buf := p.Get() + if buf == nil { + return 0 + } + return DecodeUint32(p.decoder(buf)) +} + +// Root returns a Proxy for an element of a root container (Params/Results/State). +// The key is always a string. +func (p Proxy) Root(key string) Proxy { + return Proxy{kvStore: p.kvStore, key: []byte(key)} +} + +func (p Proxy) Set(value []byte) { + p.kvStore.Set(p.key, value) +} + +// sub returns a proxy for an element of a container. +// The separator is significant, it prevents potential clashes with other elements. +// Different separators can be used to indicate different subcontainers +func (p Proxy) sub(sep byte, key []byte) Proxy { + if p.key == nil { + // this must be a root proxy + return Proxy{kvStore: p.kvStore, key: key} + } + return Proxy{kvStore: p.kvStore, key: append(append(p.key, sep), key...)} +} diff --git a/packages/vm/wasmlib/go/wasmlib/wasmtypes/requestid.go b/packages/vm/wasmlib/go/wasmlib/wasmtypes/requestid.go new file mode 100644 index 0000000000..85c0ac4468 --- /dev/null +++ b/packages/vm/wasmlib/go/wasmlib/wasmtypes/requestid.go @@ -0,0 +1,87 @@ +// Copyright 2020 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +//nolint:dupl +package wasmtypes + +import ( + "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmcodec" +) + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +const ScRequestIDLength = 34 + +type ScRequestID struct { + id [ScRequestIDLength]byte +} + +func DecodeRequestID(dec *wasmcodec.WasmDecoder) ScRequestID { + return newRequestIDFromBytes(dec.FixedBytes(ScRequestIDLength)) +} + +func EncodeRequestID(enc *wasmcodec.WasmEncoder, value ScRequestID) { + enc.FixedBytes(value.Bytes(), ScRequestIDLength) +} + +func RequestIDFromBytes(buf []byte) ScRequestID { + if len(buf) != ScRequestIDLength { + Panic("invalid RequestID length") + } + return newRequestIDFromBytes(buf) +} + +func newRequestIDFromBytes(buf []byte) ScRequestID { + o := ScRequestID{} + copy(o.id[:], buf) + return o +} + +func (o ScRequestID) Bytes() []byte { + return o.id[:] +} + +func (o ScRequestID) String() string { + // TODO standardize human readable string + return base58Encode(o.id[:]) +} + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +type ScImmutableRequestID struct { + proxy Proxy +} + +func NewScImmutableRequestID(proxy Proxy) ScImmutableRequestID { + return ScImmutableRequestID{proxy: proxy} +} + +func (o ScImmutableRequestID) Exists() bool { + return o.proxy.Exists() +} + +func (o ScImmutableRequestID) String() string { + return o.Value().String() +} + +func (o ScImmutableRequestID) Value() ScRequestID { + return RequestIDFromBytes(o.proxy.Get()) +} + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +type ScMutableRequestID struct { + ScImmutableRequestID +} + +func NewScMutableRequestID(proxy Proxy) ScMutableRequestID { + return ScMutableRequestID{ScImmutableRequestID{proxy: proxy}} +} + +func (o ScMutableRequestID) Delete() { + o.proxy.Delete() +} + +func (o ScMutableRequestID) SetValue(value ScRequestID) { + o.proxy.Set(value.Bytes()) +} diff --git a/packages/vm/wasmlib/go/wasmlib/wasmtypes/string.go b/packages/vm/wasmlib/go/wasmlib/wasmtypes/string.go new file mode 100644 index 0000000000..61655affe4 --- /dev/null +++ b/packages/vm/wasmlib/go/wasmlib/wasmtypes/string.go @@ -0,0 +1,70 @@ +// Copyright 2020 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +package wasmtypes + +import ( + "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmcodec" +) + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +func DecodeString(dec *wasmcodec.WasmDecoder) string { + return string(dec.Bytes()) +} + +func EncodeString(enc *wasmcodec.WasmEncoder, value string) { + enc.Bytes([]byte(value)) +} + +func StringFromBytes(buf []byte) string { + return string(buf) +} + +func BytesFromString(value string) []byte { + return []byte(value) +} + +func StringFromString(value string) string { + return value +} + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +type ScImmutableString struct { + proxy Proxy +} + +func NewScImmutableString(proxy Proxy) ScImmutableString { + return ScImmutableString{proxy: proxy} +} + +func (o ScImmutableString) Exists() bool { + return o.proxy.Exists() +} + +func (o ScImmutableString) String() string { + return StringFromString(o.Value()) +} + +func (o ScImmutableString) Value() string { + return StringFromBytes(o.proxy.Get()) +} + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +type ScMutableString struct { + ScImmutableString +} + +func NewScMutableString(proxy Proxy) ScMutableString { + return ScMutableString{ScImmutableString{proxy: proxy}} +} + +func (o ScMutableString) Delete() { + o.proxy.Delete() +} + +func (o ScMutableString) SetValue(value string) { + o.proxy.Set(BytesFromString(value)) +} diff --git a/packages/vm/wasmlib/go/wasmlib/wasmtypes/uint16.go b/packages/vm/wasmlib/go/wasmlib/wasmtypes/uint16.go new file mode 100644 index 0000000000..2235c58d2e --- /dev/null +++ b/packages/vm/wasmlib/go/wasmlib/wasmtypes/uint16.go @@ -0,0 +1,79 @@ +// Copyright 2020 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +//nolint:dupl +package wasmtypes + +import ( + "encoding/binary" + "strconv" + + "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmcodec" +) + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +func DecodeUint16(dec *wasmcodec.WasmDecoder) uint16 { + return uint16(dec.VluDecode(16)) +} + +func EncodeUint16(enc *wasmcodec.WasmEncoder, value uint16) { + enc.VluEncode(uint64(value)) +} + +func Uint16FromBytes(buf []byte) uint16 { + if len(buf) != 2 { + Panic("invalid Uint16 length") + } + return binary.LittleEndian.Uint16(buf) +} + +func BytesFromUint16(value uint16) []byte { + tmp := make([]byte, 2) + binary.LittleEndian.PutUint16(tmp, value) + return tmp +} + +func StringFromUint16(value uint16) string { + return strconv.FormatUint(uint64(value), 10) +} + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +type ScImmutableUint16 struct { + proxy Proxy +} + +func NewScImmutableUint16(proxy Proxy) ScImmutableUint16 { + return ScImmutableUint16{proxy: proxy} +} + +func (o ScImmutableUint16) Exists() bool { + return o.proxy.Exists() +} + +func (o ScImmutableUint16) String() string { + return StringFromUint16(o.Value()) +} + +func (o ScImmutableUint16) Value() uint16 { + return Uint16FromBytes(o.proxy.Get()) +} + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +type ScMutableUint16 struct { + ScImmutableUint16 +} + +func NewScMutableUint16(proxy Proxy) ScMutableUint16 { + return ScMutableUint16{ScImmutableUint16{proxy: proxy}} +} + +func (o ScMutableUint16) Delete() { + o.proxy.Delete() +} + +func (o ScMutableUint16) SetValue(value uint16) { + o.proxy.Set(BytesFromUint16(value)) +} diff --git a/packages/vm/wasmlib/go/wasmlib/wasmtypes/uint32.go b/packages/vm/wasmlib/go/wasmlib/wasmtypes/uint32.go new file mode 100644 index 0000000000..6e0be58dde --- /dev/null +++ b/packages/vm/wasmlib/go/wasmlib/wasmtypes/uint32.go @@ -0,0 +1,79 @@ +// Copyright 2020 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +//nolint:dupl +package wasmtypes + +import ( + "encoding/binary" + "strconv" + + "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmcodec" +) + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +func DecodeUint32(dec *wasmcodec.WasmDecoder) uint32 { + return uint32(dec.VluDecode(32)) +} + +func EncodeUint32(enc *wasmcodec.WasmEncoder, value uint32) { + enc.VluEncode(uint64(value)) +} + +func Uint32FromBytes(buf []byte) uint32 { + if len(buf) != 4 { + Panic("invalid Uint32 length") + } + return binary.LittleEndian.Uint32(buf) +} + +func BytesFromUint32(value uint32) []byte { + tmp := make([]byte, 4) + binary.LittleEndian.PutUint32(tmp, value) + return tmp +} + +func StringFromUint32(value uint32) string { + return strconv.FormatUint(uint64(value), 10) +} + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +type ScImmutableUint32 struct { + proxy Proxy +} + +func NewScImmutableUint32(proxy Proxy) ScImmutableUint32 { + return ScImmutableUint32{proxy: proxy} +} + +func (o ScImmutableUint32) Exists() bool { + return o.proxy.Exists() +} + +func (o ScImmutableUint32) String() string { + return StringFromUint32(o.Value()) +} + +func (o ScImmutableUint32) Value() uint32 { + return Uint32FromBytes(o.proxy.Get()) +} + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +type ScMutableUint32 struct { + ScImmutableUint32 +} + +func NewScMutableUint32(proxy Proxy) ScMutableUint32 { + return ScMutableUint32{ScImmutableUint32{proxy: proxy}} +} + +func (o ScMutableUint32) Delete() { + o.proxy.Delete() +} + +func (o ScMutableUint32) SetValue(value uint32) { + o.proxy.Set(BytesFromUint32(value)) +} diff --git a/packages/vm/wasmlib/go/wasmlib/wasmtypes/uint64.go b/packages/vm/wasmlib/go/wasmlib/wasmtypes/uint64.go new file mode 100644 index 0000000000..65d9e31d49 --- /dev/null +++ b/packages/vm/wasmlib/go/wasmlib/wasmtypes/uint64.go @@ -0,0 +1,78 @@ +// Copyright 2020 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +package wasmtypes + +import ( + "encoding/binary" + "strconv" + + "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmcodec" +) + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +func DecodeUint64(dec *wasmcodec.WasmDecoder) uint64 { + return dec.VluDecode(64) +} + +func EncodeUint64(enc *wasmcodec.WasmEncoder, value uint64) { + enc.VluEncode(value) +} + +func Uint64FromBytes(buf []byte) uint64 { + if len(buf) != 8 { + Panic("invalid Uint64 length") + } + return binary.LittleEndian.Uint64(buf) +} + +func BytesFromUint64(value uint64) []byte { + tmp := make([]byte, 8) + binary.LittleEndian.PutUint64(tmp, value) + return tmp +} + +func StringFromUint64(value uint64) string { + return strconv.FormatUint(value, 10) +} + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +type ScImmutableUint64 struct { + proxy Proxy +} + +func NewScImmutableUint64(proxy Proxy) ScImmutableUint64 { + return ScImmutableUint64{proxy: proxy} +} + +func (o ScImmutableUint64) Exists() bool { + return o.proxy.Exists() +} + +func (o ScImmutableUint64) String() string { + return StringFromUint64(o.Value()) +} + +func (o ScImmutableUint64) Value() uint64 { + return Uint64FromBytes(o.proxy.Get()) +} + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +type ScMutableUint64 struct { + ScImmutableUint64 +} + +func NewScMutableUint64(proxy Proxy) ScMutableUint64 { + return ScMutableUint64{ScImmutableUint64{proxy: proxy}} +} + +func (o ScMutableUint64) Delete() { + o.proxy.Delete() +} + +func (o ScMutableUint64) SetValue(value uint64) { + o.proxy.Set(BytesFromUint64(value)) +} diff --git a/packages/vm/wasmlib/go/wasmlib/wasmtypes/uint8.go b/packages/vm/wasmlib/go/wasmlib/wasmtypes/uint8.go new file mode 100644 index 0000000000..3c6bde78f7 --- /dev/null +++ b/packages/vm/wasmlib/go/wasmlib/wasmtypes/uint8.go @@ -0,0 +1,75 @@ +// Copyright 2020 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +package wasmtypes + +import ( + "strconv" + + "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmcodec" +) + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +func DecodeUint8(dec *wasmcodec.WasmDecoder) uint8 { + return dec.Byte() +} + +func EncodeUint8(enc *wasmcodec.WasmEncoder, value uint8) { + enc.Byte(value) +} + +func Uint8FromBytes(buf []byte) uint8 { + if len(buf) != 1 { + Panic("invalid Uint8 length") + } + return buf[0] +} + +func BytesFromUint8(value uint8) []byte { + return []byte{value} +} + +func StringFromUint8(value uint8) string { + return strconv.FormatUint(uint64(value), 10) +} + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +type ScImmutableUint8 struct { + proxy Proxy +} + +func NewScImmutableUint8(proxy Proxy) ScImmutableUint8 { + return ScImmutableUint8{proxy: proxy} +} + +func (o ScImmutableUint8) Exists() bool { + return o.proxy.Exists() +} + +func (o ScImmutableUint8) String() string { + return StringFromUint8(o.Value()) +} + +func (o ScImmutableUint8) Value() uint8 { + return Uint8FromBytes(o.proxy.Get()) +} + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +type ScMutableUint8 struct { + ScImmutableUint8 +} + +func NewScMutableUint8(proxy Proxy) ScMutableUint8 { + return ScMutableUint8{ScImmutableUint8{proxy: proxy}} +} + +func (o ScMutableUint8) Delete() { + o.proxy.Delete() +} + +func (o ScMutableUint8) SetValue(value uint8) { + o.proxy.Set(BytesFromUint8(value)) +} diff --git a/packages/vm/wasmlib/go/wasmlib/wasmtypes/utils.go b/packages/vm/wasmlib/go/wasmlib/wasmtypes/utils.go new file mode 100644 index 0000000000..6de694531f --- /dev/null +++ b/packages/vm/wasmlib/go/wasmlib/wasmtypes/utils.go @@ -0,0 +1,28 @@ +// Copyright 2020 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +package wasmtypes + +// wrapper for simplified use by hashtypes +func base58Encode(buf []byte) string { + // TODO + // return string(wasmlib.Sandbox(wasmstore.FnUtilsBase58Encode, buf)) + return hex(buf) +} + +func hex(buf []byte) string { + const hexa = "0123456789abcdef" + digits := len(buf) * 2 + res := make([]byte, digits) + for _, b := range buf { + digits-- + res[digits] = hexa[b&0x0f] + digits-- + res[digits] = hexa[b>>4] + } + return string(res) +} + +func Panic(msg string) { + panic(msg) +} diff --git a/packages/vm/wasmlib/interfaces/coreblocklog.yaml b/packages/vm/wasmlib/interfaces/coreblocklog.yaml index 9c07e01aba..ecdab5b531 100644 --- a/packages/vm/wasmlib/interfaces/coreblocklog.yaml +++ b/packages/vm/wasmlib/interfaces/coreblocklog.yaml @@ -7,24 +7,24 @@ funcs: {} views: controlAddresses: results: - blockIndex=n: Int32 + blockIndex=n: Uint32 governingAddress=g: Address stateControllerAddress=s: Address getBlockInfo: params: - blockIndex=n: Int32 + blockIndex=n: Uint32 results: blockInfo=i: Bytes getEventsForBlock: params: - blockIndex=n: Int32 + blockIndex=n: Uint32 results: event=e: Bytes[] // native contract, so this is an Array16 getEventsForContract: params: contractHname=h: Hname - fromBlock=f: Int32? - toBlock=t: Int32? + fromBlock=f: Uint32? + toBlock=t: Uint32? results: event=e: Bytes[] // native contract, so this is an Array16 getEventsForRequest: @@ -34,23 +34,23 @@ views: event=e: Bytes[] // native contract, so this is an Array16 getLatestBlockInfo: results: - blockIndex=n: Int32 + blockIndex=n: Uint32 blockInfo=i: Bytes getRequestIDsForBlock: params: - blockIndex=n: Int32 + blockIndex=n: Uint32 results: requestID=u: RequestID[] // native contract, so this is an Array16 getRequestReceipt: params: requestID=u: RequestID results: - blockIndex=n: Int32 - requestIndex=r: Int16 + blockIndex=n: Uint32 + requestIndex=r: Uint16 requestRecord=d: Bytes getRequestReceiptsForBlock: params: - blockIndex=n: Int32 + blockIndex=n: Uint32 results: requestRecord=d: Bytes[] // native contract, so this is an Array16 isRequestProcessed: diff --git a/packages/vm/wasmlib/interfaces/wasmrequests.yaml b/packages/vm/wasmlib/interfaces/wasmrequests.yaml new file mode 100644 index 0000000000..afbd41a39a --- /dev/null +++ b/packages/vm/wasmlib/interfaces/wasmrequests.yaml @@ -0,0 +1,32 @@ +name: WasmRequests +description: WasmLib request structures +events: {} +structs: + CallRequest: + contract: Hname + function: Hname + params: Bytes + transfer: Bytes + + DeployRequest: + progHash: Hash + name: String + description: String + params: Bytes + + PostRequest: + chainID: ChainID + contract: Hname + function: Hname + params: Bytes + transfer: Bytes + delay: Uint32 + + SendRequest: + address: Address + transfer: Bytes + +typedefs: {} +state: {} +funcs: {} +views: {} diff --git a/packages/vm/wasmlib/src/context.rs b/packages/vm/wasmlib/src/context.rs index eadcb87483..42e49fad7a 100644 --- a/packages/vm/wasmlib/src/context.rs +++ b/packages/vm/wasmlib/src/context.rs @@ -25,8 +25,8 @@ pub struct ScBalances { impl ScBalances { // retrieve the balance for the specified token color - pub fn balance(&self, color: &ScColor) -> i64 { - self.balances.get_int64(color).value() + pub fn balance(&self, color: &ScColor) -> u64 { + self.balances.get_uint64(color).value() } // retrieve an array of all token colors that have a non-zero balance @@ -61,12 +61,12 @@ impl ScTransfers { } // create a new transfers object and initialize it with the specified amount of iotas - pub fn iotas(amount: i64) -> ScTransfers { + pub fn iotas(amount: u64) -> ScTransfers { ScTransfers::transfer(&ScColor::IOTA, amount) } // create a new transfers object and initialize it with the specified token transfer - pub fn transfer(color: &ScColor, amount: i64) -> ScTransfers { + pub fn transfer(color: &ScColor, amount: u64) -> ScTransfers { let transfer = ScTransfers::new(); transfer.set(color, amount); transfer @@ -74,8 +74,8 @@ impl ScTransfers { // set the specified colored token transfer in the transfers object // note that this will overwrite any previous amount for the specified color - pub fn set(&self, color: &ScColor, amount: i64) { - self.transfers.get_int64(color).set_value(amount); + pub fn set(&self, color: &ScColor, amount: u64) { + self.transfers.get_uint64(color).set_value(amount); } } @@ -232,8 +232,8 @@ pub trait ScBaseContext { } // deterministic time stamp fixed at the moment of calling the smart contract - fn timestamp(&self) -> i64 { - ROOT.get_int64(&KEY_TIMESTAMP).value() + fn timestamp(&self) -> u64 { + ROOT.get_uint64(&KEY_TIMESTAMP).value() } // logs debugging trace text message in the log on the host @@ -328,7 +328,7 @@ impl ScFuncContext { // asynchronously calls the specified smart contract function, // passing the provided parameters and token transfers to it // it is possible to schedule the call for a later execution by specifying a delay - pub fn post(&self, chain_id: &ScChainID, hcontract: ScHname, hfunction: ScHname, params: Option, transfer: ScTransfers, delay: i32) { + pub fn post(&self, chain_id: &ScChainID, hcontract: ScHname, hfunction: ScHname, params: Option, transfer: ScTransfers, delay: u32) { let mut encode = BytesEncoder::new(); encode.chain_id(chain_id); encode.hname(hcontract); @@ -339,12 +339,12 @@ impl ScFuncContext { encode.int32(0); } encode.int32(transfer.transfers.map_id()); - encode.int32(delay); + encode.uint32(delay); ROOT.get_bytes(&KEY_POST).set_value(&encode.data()); } // generates a random value from 0 to max (exclusive max) using a deterministic RNG - pub fn random(&self, max: i64) -> i64 { + pub fn random(&self, max: u64) -> u64 { if max == 0 { self.panic("random: max parameter should be non-zero"); } @@ -356,8 +356,8 @@ impl ScFuncContext { seed = ROOT.get_bytes(&KEY_RANDOM).value(); } rnd.set_value(&self.utility().hash_sha3(&seed).to_bytes()); - let rnd = i64::from_le_bytes(seed[0..8].try_into().expect("invalid i64 length")); - (rnd as u64 % max as u64) as i64 + let rnd = u64::from_le_bytes(seed[0..8].try_into().expect("invalid u64 length")); + rnd % max } // retrieve the request id of this transaction diff --git a/packages/vm/wasmlib/src/contract.rs b/packages/vm/wasmlib/src/contract.rs index 66b349ffa4..b1e9a8a49b 100644 --- a/packages/vm/wasmlib/src/contract.rs +++ b/packages/vm/wasmlib/src/contract.rs @@ -120,7 +120,7 @@ impl ScInitFunc { #[derive(Clone, Copy)] pub struct ScFunc { view: ScView, - delay: i32, + delay: u32, transfer_id: i32, } @@ -144,7 +144,7 @@ impl ScFunc { self.view.call_with_transfer(self.transfer_id); } - pub fn delay(&self, seconds: i32) -> ScFunc { + pub fn delay(&self, seconds: u32) -> ScFunc { let mut ret = self.clone(); ret.delay = seconds; ret @@ -167,7 +167,7 @@ impl ScFunc { encode.hname(self.view.h_function); encode.int32(self.view.id(self.view.params_id)); encode.int32(self.transfer_id); - encode.int32(self.delay); + encode.uint32(self.delay); ROOT.get_bytes(&KEY_POST).set_value(&encode.data()); } @@ -177,7 +177,7 @@ impl ScFunc { ret } - pub fn transfer_iotas(&self, amount: i64) -> ScFunc { + pub fn transfer_iotas(&self, amount: u64) -> ScFunc { self.transfer(ScTransfers::iotas(amount)) } } diff --git a/packages/vm/wasmlib/src/coreblocklog/params.rs b/packages/vm/wasmlib/src/coreblocklog/params.rs index 01b87611c2..e6af86d16c 100644 --- a/packages/vm/wasmlib/src/coreblocklog/params.rs +++ b/packages/vm/wasmlib/src/coreblocklog/params.rs @@ -18,8 +18,8 @@ pub struct ImmutableGetBlockInfoParams { } impl ImmutableGetBlockInfoParams { - pub fn block_index(&self) -> ScImmutableInt32 { - ScImmutableInt32::new(self.id, PARAM_BLOCK_INDEX.get_key_id()) + pub fn block_index(&self) -> ScImmutableUint32 { + ScImmutableUint32::new(self.id, PARAM_BLOCK_INDEX.get_key_id()) } } @@ -29,8 +29,8 @@ pub struct MutableGetBlockInfoParams { } impl MutableGetBlockInfoParams { - pub fn block_index(&self) -> ScMutableInt32 { - ScMutableInt32::new(self.id, PARAM_BLOCK_INDEX.get_key_id()) + pub fn block_index(&self) -> ScMutableUint32 { + ScMutableUint32::new(self.id, PARAM_BLOCK_INDEX.get_key_id()) } } @@ -40,8 +40,8 @@ pub struct ImmutableGetEventsForBlockParams { } impl ImmutableGetEventsForBlockParams { - pub fn block_index(&self) -> ScImmutableInt32 { - ScImmutableInt32::new(self.id, PARAM_BLOCK_INDEX.get_key_id()) + pub fn block_index(&self) -> ScImmutableUint32 { + ScImmutableUint32::new(self.id, PARAM_BLOCK_INDEX.get_key_id()) } } @@ -51,8 +51,8 @@ pub struct MutableGetEventsForBlockParams { } impl MutableGetEventsForBlockParams { - pub fn block_index(&self) -> ScMutableInt32 { - ScMutableInt32::new(self.id, PARAM_BLOCK_INDEX.get_key_id()) + pub fn block_index(&self) -> ScMutableUint32 { + ScMutableUint32::new(self.id, PARAM_BLOCK_INDEX.get_key_id()) } } @@ -66,12 +66,12 @@ impl ImmutableGetEventsForContractParams { ScImmutableHname::new(self.id, PARAM_CONTRACT_HNAME.get_key_id()) } - pub fn from_block(&self) -> ScImmutableInt32 { - ScImmutableInt32::new(self.id, PARAM_FROM_BLOCK.get_key_id()) + pub fn from_block(&self) -> ScImmutableUint32 { + ScImmutableUint32::new(self.id, PARAM_FROM_BLOCK.get_key_id()) } - pub fn to_block(&self) -> ScImmutableInt32 { - ScImmutableInt32::new(self.id, PARAM_TO_BLOCK.get_key_id()) + pub fn to_block(&self) -> ScImmutableUint32 { + ScImmutableUint32::new(self.id, PARAM_TO_BLOCK.get_key_id()) } } @@ -85,12 +85,12 @@ impl MutableGetEventsForContractParams { ScMutableHname::new(self.id, PARAM_CONTRACT_HNAME.get_key_id()) } - pub fn from_block(&self) -> ScMutableInt32 { - ScMutableInt32::new(self.id, PARAM_FROM_BLOCK.get_key_id()) + pub fn from_block(&self) -> ScMutableUint32 { + ScMutableUint32::new(self.id, PARAM_FROM_BLOCK.get_key_id()) } - pub fn to_block(&self) -> ScMutableInt32 { - ScMutableInt32::new(self.id, PARAM_TO_BLOCK.get_key_id()) + pub fn to_block(&self) -> ScMutableUint32 { + ScMutableUint32::new(self.id, PARAM_TO_BLOCK.get_key_id()) } } @@ -122,8 +122,8 @@ pub struct ImmutableGetRequestIDsForBlockParams { } impl ImmutableGetRequestIDsForBlockParams { - pub fn block_index(&self) -> ScImmutableInt32 { - ScImmutableInt32::new(self.id, PARAM_BLOCK_INDEX.get_key_id()) + pub fn block_index(&self) -> ScImmutableUint32 { + ScImmutableUint32::new(self.id, PARAM_BLOCK_INDEX.get_key_id()) } } @@ -133,8 +133,8 @@ pub struct MutableGetRequestIDsForBlockParams { } impl MutableGetRequestIDsForBlockParams { - pub fn block_index(&self) -> ScMutableInt32 { - ScMutableInt32::new(self.id, PARAM_BLOCK_INDEX.get_key_id()) + pub fn block_index(&self) -> ScMutableUint32 { + ScMutableUint32::new(self.id, PARAM_BLOCK_INDEX.get_key_id()) } } @@ -166,8 +166,8 @@ pub struct ImmutableGetRequestReceiptsForBlockParams { } impl ImmutableGetRequestReceiptsForBlockParams { - pub fn block_index(&self) -> ScImmutableInt32 { - ScImmutableInt32::new(self.id, PARAM_BLOCK_INDEX.get_key_id()) + pub fn block_index(&self) -> ScImmutableUint32 { + ScImmutableUint32::new(self.id, PARAM_BLOCK_INDEX.get_key_id()) } } @@ -177,8 +177,8 @@ pub struct MutableGetRequestReceiptsForBlockParams { } impl MutableGetRequestReceiptsForBlockParams { - pub fn block_index(&self) -> ScMutableInt32 { - ScMutableInt32::new(self.id, PARAM_BLOCK_INDEX.get_key_id()) + pub fn block_index(&self) -> ScMutableUint32 { + ScMutableUint32::new(self.id, PARAM_BLOCK_INDEX.get_key_id()) } } diff --git a/packages/vm/wasmlib/src/coreblocklog/results.rs b/packages/vm/wasmlib/src/coreblocklog/results.rs index 98d0efaf24..fb13f646eb 100644 --- a/packages/vm/wasmlib/src/coreblocklog/results.rs +++ b/packages/vm/wasmlib/src/coreblocklog/results.rs @@ -18,8 +18,8 @@ pub struct ImmutableControlAddressesResults { } impl ImmutableControlAddressesResults { - pub fn block_index(&self) -> ScImmutableInt32 { - ScImmutableInt32::new(self.id, RESULT_BLOCK_INDEX.get_key_id()) + pub fn block_index(&self) -> ScImmutableUint32 { + ScImmutableUint32::new(self.id, RESULT_BLOCK_INDEX.get_key_id()) } pub fn governing_address(&self) -> ScImmutableAddress { @@ -37,8 +37,8 @@ pub struct MutableControlAddressesResults { } impl MutableControlAddressesResults { - pub fn block_index(&self) -> ScMutableInt32 { - ScMutableInt32::new(self.id, RESULT_BLOCK_INDEX.get_key_id()) + pub fn block_index(&self) -> ScMutableUint32 { + ScMutableUint32::new(self.id, RESULT_BLOCK_INDEX.get_key_id()) } pub fn governing_address(&self) -> ScMutableAddress { @@ -78,12 +78,12 @@ pub struct ArrayOfImmutableBytes { } impl ArrayOfImmutableBytes { - pub fn length(&self) -> i32 { + pub fn length(&self) -> u32 { get_length(self.obj_id) } - pub fn get_bytes(&self, index: i32) -> ScImmutableBytes { - ScImmutableBytes::new(self.obj_id, Key32(index)) + pub fn get_bytes(&self, index: u32) -> ScImmutableBytes { + ScImmutableBytes::new(self.obj_id, Key32(index as i32)) } } @@ -109,12 +109,12 @@ impl ArrayOfMutableBytes { clear(self.obj_id); } - pub fn length(&self) -> i32 { + pub fn length(&self) -> u32 { get_length(self.obj_id) } - pub fn get_bytes(&self, index: i32) -> ScMutableBytes { - ScMutableBytes::new(self.obj_id, Key32(index)) + pub fn get_bytes(&self, index: u32) -> ScMutableBytes { + ScMutableBytes::new(self.obj_id, Key32(index as i32)) } } @@ -184,8 +184,8 @@ pub struct ImmutableGetLatestBlockInfoResults { } impl ImmutableGetLatestBlockInfoResults { - pub fn block_index(&self) -> ScImmutableInt32 { - ScImmutableInt32::new(self.id, RESULT_BLOCK_INDEX.get_key_id()) + pub fn block_index(&self) -> ScImmutableUint32 { + ScImmutableUint32::new(self.id, RESULT_BLOCK_INDEX.get_key_id()) } pub fn block_info(&self) -> ScImmutableBytes { @@ -199,8 +199,8 @@ pub struct MutableGetLatestBlockInfoResults { } impl MutableGetLatestBlockInfoResults { - pub fn block_index(&self) -> ScMutableInt32 { - ScMutableInt32::new(self.id, RESULT_BLOCK_INDEX.get_key_id()) + pub fn block_index(&self) -> ScMutableUint32 { + ScMutableUint32::new(self.id, RESULT_BLOCK_INDEX.get_key_id()) } pub fn block_info(&self) -> ScMutableBytes { @@ -214,12 +214,12 @@ pub struct ArrayOfImmutableRequestID { } impl ArrayOfImmutableRequestID { - pub fn length(&self) -> i32 { + pub fn length(&self) -> u32 { get_length(self.obj_id) } - pub fn get_request_id(&self, index: i32) -> ScImmutableRequestID { - ScImmutableRequestID::new(self.obj_id, Key32(index)) + pub fn get_request_id(&self, index: u32) -> ScImmutableRequestID { + ScImmutableRequestID::new(self.obj_id, Key32(index as i32)) } } @@ -245,12 +245,12 @@ impl ArrayOfMutableRequestID { clear(self.obj_id); } - pub fn length(&self) -> i32 { + pub fn length(&self) -> u32 { get_length(self.obj_id) } - pub fn get_request_id(&self, index: i32) -> ScMutableRequestID { - ScMutableRequestID::new(self.obj_id, Key32(index)) + pub fn get_request_id(&self, index: u32) -> ScMutableRequestID { + ScMutableRequestID::new(self.obj_id, Key32(index as i32)) } } @@ -272,12 +272,12 @@ pub struct ImmutableGetRequestReceiptResults { } impl ImmutableGetRequestReceiptResults { - pub fn block_index(&self) -> ScImmutableInt32 { - ScImmutableInt32::new(self.id, RESULT_BLOCK_INDEX.get_key_id()) + pub fn block_index(&self) -> ScImmutableUint32 { + ScImmutableUint32::new(self.id, RESULT_BLOCK_INDEX.get_key_id()) } - pub fn request_index(&self) -> ScImmutableInt16 { - ScImmutableInt16::new(self.id, RESULT_REQUEST_INDEX.get_key_id()) + pub fn request_index(&self) -> ScImmutableUint16 { + ScImmutableUint16::new(self.id, RESULT_REQUEST_INDEX.get_key_id()) } pub fn request_record(&self) -> ScImmutableBytes { @@ -291,12 +291,12 @@ pub struct MutableGetRequestReceiptResults { } impl MutableGetRequestReceiptResults { - pub fn block_index(&self) -> ScMutableInt32 { - ScMutableInt32::new(self.id, RESULT_BLOCK_INDEX.get_key_id()) + pub fn block_index(&self) -> ScMutableUint32 { + ScMutableUint32::new(self.id, RESULT_BLOCK_INDEX.get_key_id()) } - pub fn request_index(&self) -> ScMutableInt16 { - ScMutableInt16::new(self.id, RESULT_REQUEST_INDEX.get_key_id()) + pub fn request_index(&self) -> ScMutableUint16 { + ScMutableUint16::new(self.id, RESULT_REQUEST_INDEX.get_key_id()) } pub fn request_record(&self) -> ScMutableBytes { diff --git a/packages/vm/wasmlib/src/coregovernance/results.rs b/packages/vm/wasmlib/src/coregovernance/results.rs index d834e234b7..b4ff21b487 100644 --- a/packages/vm/wasmlib/src/coregovernance/results.rs +++ b/packages/vm/wasmlib/src/coregovernance/results.rs @@ -18,12 +18,12 @@ pub struct ArrayOfImmutableBytes { } impl ArrayOfImmutableBytes { - pub fn length(&self) -> i32 { + pub fn length(&self) -> u32 { get_length(self.obj_id) } - pub fn get_bytes(&self, index: i32) -> ScImmutableBytes { - ScImmutableBytes::new(self.obj_id, Key32(index)) + pub fn get_bytes(&self, index: u32) -> ScImmutableBytes { + ScImmutableBytes::new(self.obj_id, Key32(index as i32)) } } @@ -49,12 +49,12 @@ impl ArrayOfMutableBytes { clear(self.obj_id); } - pub fn length(&self) -> i32 { + pub fn length(&self) -> u32 { get_length(self.obj_id) } - pub fn get_bytes(&self, index: i32) -> ScMutableBytes { - ScMutableBytes::new(self.obj_id, Key32(index)) + pub fn get_bytes(&self, index: u32) -> ScMutableBytes { + ScMutableBytes::new(self.obj_id, Key32(index as i32)) } } diff --git a/packages/vm/wasmlib/src/exports.rs b/packages/vm/wasmlib/src/exports.rs index 128bf7bf1c..ee57906745 100644 --- a/packages/vm/wasmlib/src/exports.rs +++ b/packages/vm/wasmlib/src/exports.rs @@ -57,7 +57,7 @@ impl ScExports { // tell host what value our special predefined key is // this helps detect versioning problems between host // and client versions of WasmLib - exports.get_string(KEY_ZZZZZZZ.0).set_value("Rust:KEY_ZZZZZZZ"); + exports.get_string(KEY_ZZZZZZZ.0 as u32).set_value("Rust:KEY_ZZZZZZZ"); ScExports { exports: exports } } @@ -65,7 +65,7 @@ impl ScExports { // and the entry point function associated with it pub fn add_func(&self, name: &str, f: fn(&ScFuncContext)) { unsafe { - let index = FUNCS.len() as i32; + let index = FUNCS.len() as u32; FUNCS.push(f); self.exports.get_string(index).set_value(name); } @@ -75,7 +75,7 @@ impl ScExports { // and the entry point function associated with it pub fn add_view(&self, name: &str, v: fn(&ScViewContext)) { unsafe { - let index = VIEWS.len() as i32; + let index = VIEWS.len() as u32; VIEWS.push(v); self.exports.get_string(index | 0x8000).set_value(name); } diff --git a/packages/vm/wasmlib/src/host.rs b/packages/vm/wasmlib/src/host.rs index a63b769d8b..29c320fb2c 100644 --- a/packages/vm/wasmlib/src/host.rs +++ b/packages/vm/wasmlib/src/host.rs @@ -166,10 +166,10 @@ pub fn get_key_id_from_uint64(key: u64, nr_of_bytes: usize) -> Key32 { } // Retrieve the length of an array container object on the host -pub fn get_length(obj_id: i32) -> i32 { +pub fn get_length(obj_id: i32) -> u32 { // special integer key "length" is used let bytes = get_bytes(obj_id, KEY_LENGTH, TYPE_INT32); - i32::from_le_bytes(bytes.try_into().unwrap()) + u32::from_le_bytes(bytes.try_into().unwrap()) } // Retrieve the id of the specified container sub-object diff --git a/packages/vm/wasmlib/src/immutable.rs b/packages/vm/wasmlib/src/immutable.rs index 1a6cbba717..643df4e34c 100644 --- a/packages/vm/wasmlib/src/immutable.rs +++ b/packages/vm/wasmlib/src/immutable.rs @@ -192,12 +192,12 @@ pub struct ScImmutableColorArray { impl ScImmutableColorArray { // get value proxy for item at index, index can be 0..length()-1 - pub fn get_color(&self, index: i32) -> ScImmutableColor { - ScImmutableColor { obj_id: self.obj_id, key_id: Key32(index) } + pub fn get_color(&self, index: u32) -> ScImmutableColor { + ScImmutableColor { obj_id: self.obj_id, key_id: Key32(index as i32) } } // number of items in array - pub fn length(&self) -> i32 { + pub fn length(&self) -> u32 { get_length(self.obj_id) } } @@ -520,13 +520,13 @@ pub struct ScImmutableMapArray { impl ScImmutableMapArray { // get value proxy for item at index, index can be 0..length()-1 - pub fn get_map(&self, index: i32) -> ScImmutableMap { - let map_id = get_object_id(self.obj_id, Key32(index), TYPE_MAP); + pub fn get_map(&self, index: u32) -> ScImmutableMap { + let map_id = get_object_id(self.obj_id, Key32(index as i32), TYPE_MAP); ScImmutableMap { obj_id: map_id } } // number of items in array - pub fn length(&self) -> i32 { + pub fn length(&self) -> u32 { get_length(self.obj_id) } } @@ -597,12 +597,12 @@ pub struct ScImmutableStringArray { impl ScImmutableStringArray { // get value proxy for item at index, index can be 0..length()-1 - pub fn get_string(&self, index: i32) -> ScImmutableString { - ScImmutableString { obj_id: self.obj_id, key_id: Key32(index) } + pub fn get_string(&self, index: u32) -> ScImmutableString { + ScImmutableString { obj_id: self.obj_id, key_id: Key32(index as i32) } } // number of items in array - pub fn length(&self) -> i32 { + pub fn length(&self) -> u32 { get_length(self.obj_id) } } diff --git a/packages/vm/wasmlib/src/mutable.rs b/packages/vm/wasmlib/src/mutable.rs index 29b95286db..8e78cf6719 100644 --- a/packages/vm/wasmlib/src/mutable.rs +++ b/packages/vm/wasmlib/src/mutable.rs @@ -643,8 +643,8 @@ impl ScMutableMapArray { // get value proxy for item at index, index can be 0..length() // when index equals length() a new item is appended - pub fn get_map(&self, index: i32) -> ScMutableMap { - let map_id = get_object_id(self.obj_id, Key32(index), TYPE_MAP); + pub fn get_map(&self, index: u32) -> ScMutableMap { + let map_id = get_object_id(self.obj_id, Key32(index as i32), TYPE_MAP); ScMutableMap { obj_id: map_id } } @@ -654,7 +654,7 @@ impl ScMutableMapArray { } // number of items in array - pub fn length(&self) -> i32 { + pub fn length(&self) -> u32 { get_length(self.obj_id) } } @@ -753,8 +753,8 @@ impl ScMutableStringArray { // get value proxy for item at index, index can be 0..length() // when index equals length() a new item is appended - pub fn get_string(&self, index: i32) -> ScMutableString { - ScMutableString { obj_id: self.obj_id, key_id: Key32(index) } + pub fn get_string(&self, index: u32) -> ScMutableString { + ScMutableString { obj_id: self.obj_id, key_id: Key32(index as i32) } } // get immutable version of array proxy @@ -763,7 +763,7 @@ impl ScMutableStringArray { } // number of items in array - pub fn length(&self) -> i32 { + pub fn length(&self) -> u32 { get_length(self.obj_id) } } diff --git a/packages/vm/wasmlib/src/wasmrequests/consts.rs b/packages/vm/wasmlib/src/wasmrequests/consts.rs new file mode 100644 index 0000000000..23352c9ef5 --- /dev/null +++ b/packages/vm/wasmlib/src/wasmrequests/consts.rs @@ -0,0 +1,16 @@ +// Copyright 2020 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +// (Re-)generated by schema tool +// >>>> DO NOT CHANGE THIS FILE! <<<< +// Change the json schema instead + +#![allow(dead_code)] + +use crate::*; + +pub const SC_NAME : &str = "requests"; +pub const SC_DESCRIPTION : &str = "WasmLib request structures"; +pub const HSC_NAME : ScHname = ScHname(0x98e19453); + + diff --git a/packages/vm/wasmlib/src/wasmrequests/contract.rs b/packages/vm/wasmlib/src/wasmrequests/contract.rs new file mode 100644 index 0000000000..95592dc87f --- /dev/null +++ b/packages/vm/wasmlib/src/wasmrequests/contract.rs @@ -0,0 +1,19 @@ +// Copyright 2020 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +// (Re-)generated by schema tool +// >>>> DO NOT CHANGE THIS FILE! <<<< +// Change the json schema instead + +#![allow(dead_code)] + +use std::ptr; + +use crate::*; +use crate::wasmrequests::*; + +pub struct ScFuncs { +} + +impl ScFuncs { +} diff --git a/packages/vm/wasmlib/src/wasmrequests/mod.rs b/packages/vm/wasmlib/src/wasmrequests/mod.rs new file mode 100644 index 0000000000..8218c37b11 --- /dev/null +++ b/packages/vm/wasmlib/src/wasmrequests/mod.rs @@ -0,0 +1,18 @@ +// Copyright 2020 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +// (Re-)generated by schema tool +// >>>> DO NOT CHANGE THIS FILE! <<<< +// Change the json schema instead + +#![allow(unused_imports)] + +pub use consts::*; +pub use contract::*; +pub use params::*; +pub use results::*; + +pub mod consts; +pub mod contract; +pub mod params; +pub mod results; diff --git a/packages/vm/wasmlib/src/wasmrequests/structs.rs b/packages/vm/wasmlib/src/wasmrequests/structs.rs new file mode 100644 index 0000000000..d46ee5f8dc --- /dev/null +++ b/packages/vm/wasmlib/src/wasmrequests/structs.rs @@ -0,0 +1,288 @@ +// Copyright 2020 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +// (Re-)generated by schema tool +// >>>> DO NOT CHANGE THIS FILE! <<<< +// Change the json schema instead + +#![allow(dead_code)] +#![allow(unused_imports)] + +use wasmlib::*; +use wasmlib::host::*; + +#[derive(Clone)] +pub struct CallRequest { + pub contract : ScHname, + pub function : ScHname, + pub params : , + pub transfer : , +} + +impl CallRequest { + pub fn from_bytes(bytes: &[u8]) -> CallRequest { + let mut decode = BytesDecoder::new(bytes); + CallRequest { + contract : decode.hname(), + function : decode.hname(), + params : decode.bytes(), + transfer : decode.bytes(), + } + } + + pub fn to_bytes(&self) -> Vec { + let mut encode = BytesEncoder::new(); + encode.hname(self.contract); + encode.hname(self.function); + encode.bytes(self.params); + encode.bytes(self.transfer); + return encode.data(); + } +} + +#[derive(Clone, Copy)] +pub struct ImmutableCallRequest { + pub(crate) obj_id: i32, + pub(crate) key_id: Key32, +} + +impl ImmutableCallRequest { + pub fn exists(&self) -> bool { + exists(self.obj_id, self.key_id, TYPE_BYTES) + } + + pub fn value(&self) -> CallRequest { + CallRequest::from_bytes(&get_bytes(self.obj_id, self.key_id, TYPE_BYTES)) + } +} + +#[derive(Clone, Copy)] +pub struct MutableCallRequest { + pub(crate) obj_id: i32, + pub(crate) key_id: Key32, +} + +impl MutableCallRequest { + pub fn delete(&self) { + del_key(self.obj_id, self.key_id, TYPE_BYTES); + } + + pub fn exists(&self) -> bool { + exists(self.obj_id, self.key_id, TYPE_BYTES) + } + + pub fn set_value(&self, value: &CallRequest) { + set_bytes(self.obj_id, self.key_id, TYPE_BYTES, &value.to_bytes()); + } + + pub fn value(&self) -> CallRequest { + CallRequest::from_bytes(&get_bytes(self.obj_id, self.key_id, TYPE_BYTES)) + } +} + +#[derive(Clone)] +pub struct DeployRequest { + pub description : String, + pub name : String, + pub params : , + pub prog_hash : ScHash, +} + +impl DeployRequest { + pub fn from_bytes(bytes: &[u8]) -> DeployRequest { + let mut decode = BytesDecoder::new(bytes); + DeployRequest { + description : decode.string(), + name : decode.string(), + params : decode.bytes(), + prog_hash : decode.hash(), + } + } + + pub fn to_bytes(&self) -> Vec { + let mut encode = BytesEncoder::new(); + encode.string(&self.description); + encode.string(&self.name); + encode.bytes(self.params); + encode.hash(&self.prog_hash); + return encode.data(); + } +} + +#[derive(Clone, Copy)] +pub struct ImmutableDeployRequest { + pub(crate) obj_id: i32, + pub(crate) key_id: Key32, +} + +impl ImmutableDeployRequest { + pub fn exists(&self) -> bool { + exists(self.obj_id, self.key_id, TYPE_BYTES) + } + + pub fn value(&self) -> DeployRequest { + DeployRequest::from_bytes(&get_bytes(self.obj_id, self.key_id, TYPE_BYTES)) + } +} + +#[derive(Clone, Copy)] +pub struct MutableDeployRequest { + pub(crate) obj_id: i32, + pub(crate) key_id: Key32, +} + +impl MutableDeployRequest { + pub fn delete(&self) { + del_key(self.obj_id, self.key_id, TYPE_BYTES); + } + + pub fn exists(&self) -> bool { + exists(self.obj_id, self.key_id, TYPE_BYTES) + } + + pub fn set_value(&self, value: &DeployRequest) { + set_bytes(self.obj_id, self.key_id, TYPE_BYTES, &value.to_bytes()); + } + + pub fn value(&self) -> DeployRequest { + DeployRequest::from_bytes(&get_bytes(self.obj_id, self.key_id, TYPE_BYTES)) + } +} + +#[derive(Clone)] +pub struct PostRequest { + pub chain_id : ScChainID, + pub contract : ScHname, + pub delay : u32, + pub function : ScHname, + pub params : , + pub transfer : , +} + +impl PostRequest { + pub fn from_bytes(bytes: &[u8]) -> PostRequest { + let mut decode = BytesDecoder::new(bytes); + PostRequest { + chain_id : decode.chain_id(), + contract : decode.hname(), + delay : decode.uint32(), + function : decode.hname(), + params : decode.bytes(), + transfer : decode.bytes(), + } + } + + pub fn to_bytes(&self) -> Vec { + let mut encode = BytesEncoder::new(); + encode.chain_id(&self.chain_id); + encode.hname(self.contract); + encode.uint32(self.delay); + encode.hname(self.function); + encode.bytes(self.params); + encode.bytes(self.transfer); + return encode.data(); + } +} + +#[derive(Clone, Copy)] +pub struct ImmutablePostRequest { + pub(crate) obj_id: i32, + pub(crate) key_id: Key32, +} + +impl ImmutablePostRequest { + pub fn exists(&self) -> bool { + exists(self.obj_id, self.key_id, TYPE_BYTES) + } + + pub fn value(&self) -> PostRequest { + PostRequest::from_bytes(&get_bytes(self.obj_id, self.key_id, TYPE_BYTES)) + } +} + +#[derive(Clone, Copy)] +pub struct MutablePostRequest { + pub(crate) obj_id: i32, + pub(crate) key_id: Key32, +} + +impl MutablePostRequest { + pub fn delete(&self) { + del_key(self.obj_id, self.key_id, TYPE_BYTES); + } + + pub fn exists(&self) -> bool { + exists(self.obj_id, self.key_id, TYPE_BYTES) + } + + pub fn set_value(&self, value: &PostRequest) { + set_bytes(self.obj_id, self.key_id, TYPE_BYTES, &value.to_bytes()); + } + + pub fn value(&self) -> PostRequest { + PostRequest::from_bytes(&get_bytes(self.obj_id, self.key_id, TYPE_BYTES)) + } +} + +#[derive(Clone)] +pub struct SendRequest { + pub address : ScAddress, + pub transfer : , +} + +impl SendRequest { + pub fn from_bytes(bytes: &[u8]) -> SendRequest { + let mut decode = BytesDecoder::new(bytes); + SendRequest { + address : decode.address(), + transfer : decode.bytes(), + } + } + + pub fn to_bytes(&self) -> Vec { + let mut encode = BytesEncoder::new(); + encode.address(&self.address); + encode.bytes(self.transfer); + return encode.data(); + } +} + +#[derive(Clone, Copy)] +pub struct ImmutableSendRequest { + pub(crate) obj_id: i32, + pub(crate) key_id: Key32, +} + +impl ImmutableSendRequest { + pub fn exists(&self) -> bool { + exists(self.obj_id, self.key_id, TYPE_BYTES) + } + + pub fn value(&self) -> SendRequest { + SendRequest::from_bytes(&get_bytes(self.obj_id, self.key_id, TYPE_BYTES)) + } +} + +#[derive(Clone, Copy)] +pub struct MutableSendRequest { + pub(crate) obj_id: i32, + pub(crate) key_id: Key32, +} + +impl MutableSendRequest { + pub fn delete(&self) { + del_key(self.obj_id, self.key_id, TYPE_BYTES); + } + + pub fn exists(&self) -> bool { + exists(self.obj_id, self.key_id, TYPE_BYTES) + } + + pub fn set_value(&self, value: &SendRequest) { + set_bytes(self.obj_id, self.key_id, TYPE_BYTES, &value.to_bytes()); + } + + pub fn value(&self) -> SendRequest { + SendRequest::from_bytes(&get_bytes(self.obj_id, self.key_id, TYPE_BYTES)) + } +} diff --git a/packages/vm/wasmlib/ts/wasmclient/clientfunc.ts b/packages/vm/wasmlib/ts/wasmclient/clientfunc.ts index 06bb352dd9..b3ef97b507 100644 --- a/packages/vm/wasmlib/ts/wasmclient/clientfunc.ts +++ b/packages/vm/wasmlib/ts/wasmclient/clientfunc.ts @@ -20,6 +20,8 @@ export class ClientFunc { this.onLedger = onLedger; } + //TODO rename to protected postRequest to prevent need for override and hide it + // Sends a request to the smart contract service // You can wait for the request to complete by using the returned RequestID // as parameter to Service.waitRequest() diff --git a/packages/vm/wasmlib/ts/wasmclient/coreblocklog/service.ts b/packages/vm/wasmlib/ts/wasmclient/coreblocklog/service.ts index 71dd2c889c..d0a3985e67 100644 --- a/packages/vm/wasmlib/ts/wasmclient/coreblocklog/service.ts +++ b/packages/vm/wasmlib/ts/wasmclient/coreblocklog/service.ts @@ -36,8 +36,8 @@ export class ControlAddressesView extends wasmclient.ClientView { export class ControlAddressesResults extends wasmclient.Results { - blockIndex(): wasmclient.Int32 { - return this.toInt32(this.get(ResBlockIndex)); + blockIndex(): wasmclient.Uint32 { + return this.toUint32(this.get(ResBlockIndex)); } governingAddress(): wasmclient.Address { @@ -54,8 +54,8 @@ export class ControlAddressesResults extends wasmclient.Results { export class GetBlockInfoView extends wasmclient.ClientView { private args: wasmclient.Arguments = new wasmclient.Arguments(); - public blockIndex(v: wasmclient.Int32): void { - this.args.set(ArgBlockIndex, this.args.fromInt32(v)); + public blockIndex(v: wasmclient.Uint32): void { + this.args.set(ArgBlockIndex, this.args.fromUint32(v)); } public async call(): Promise { @@ -78,8 +78,8 @@ export class GetBlockInfoResults extends wasmclient.Results { export class GetEventsForBlockView extends wasmclient.ClientView { private args: wasmclient.Arguments = new wasmclient.Arguments(); - public blockIndex(v: wasmclient.Int32): void { - this.args.set(ArgBlockIndex, this.args.fromInt32(v)); + public blockIndex(v: wasmclient.Uint32): void { + this.args.set(ArgBlockIndex, this.args.fromUint32(v)); } public async call(): Promise { @@ -106,12 +106,12 @@ export class GetEventsForContractView extends wasmclient.ClientView { this.args.set(ArgContractHname, this.args.fromHname(v)); } - public fromBlock(v: wasmclient.Int32): void { - this.args.set(ArgFromBlock, this.args.fromInt32(v)); + public fromBlock(v: wasmclient.Uint32): void { + this.args.set(ArgFromBlock, this.args.fromUint32(v)); } - public toBlock(v: wasmclient.Int32): void { - this.args.set(ArgToBlock, this.args.fromInt32(v)); + public toBlock(v: wasmclient.Uint32): void { + this.args.set(ArgToBlock, this.args.fromUint32(v)); } public async call(): Promise { @@ -166,8 +166,8 @@ export class GetLatestBlockInfoView extends wasmclient.ClientView { export class GetLatestBlockInfoResults extends wasmclient.Results { - blockIndex(): wasmclient.Int32 { - return this.toInt32(this.get(ResBlockIndex)); + blockIndex(): wasmclient.Uint32 { + return this.toUint32(this.get(ResBlockIndex)); } blockInfo(): wasmclient.Bytes { @@ -180,8 +180,8 @@ export class GetLatestBlockInfoResults extends wasmclient.Results { export class GetRequestIDsForBlockView extends wasmclient.ClientView { private args: wasmclient.Arguments = new wasmclient.Arguments(); - public blockIndex(v: wasmclient.Int32): void { - this.args.set(ArgBlockIndex, this.args.fromInt32(v)); + public blockIndex(v: wasmclient.Uint32): void { + this.args.set(ArgBlockIndex, this.args.fromUint32(v)); } public async call(): Promise { @@ -218,12 +218,12 @@ export class GetRequestReceiptView extends wasmclient.ClientView { export class GetRequestReceiptResults extends wasmclient.Results { - blockIndex(): wasmclient.Int32 { - return this.toInt32(this.get(ResBlockIndex)); + blockIndex(): wasmclient.Uint32 { + return this.toUint32(this.get(ResBlockIndex)); } - requestIndex(): wasmclient.Int16 { - return this.toInt16(this.get(ResRequestIndex)); + requestIndex(): wasmclient.Uint16 { + return this.toUint16(this.get(ResRequestIndex)); } requestRecord(): wasmclient.Bytes { @@ -236,8 +236,8 @@ export class GetRequestReceiptResults extends wasmclient.Results { export class GetRequestReceiptsForBlockView extends wasmclient.ClientView { private args: wasmclient.Arguments = new wasmclient.Arguments(); - public blockIndex(v: wasmclient.Int32): void { - this.args.set(ArgBlockIndex, this.args.fromInt32(v)); + public blockIndex(v: wasmclient.Uint32): void { + this.args.set(ArgBlockIndex, this.args.fromUint32(v)); } public async call(): Promise { diff --git a/packages/vm/wasmlib/ts/wasmclient/wasmrequests/service.ts b/packages/vm/wasmlib/ts/wasmclient/wasmrequests/service.ts new file mode 100644 index 0000000000..5d33ce1c64 --- /dev/null +++ b/packages/vm/wasmlib/ts/wasmclient/wasmrequests/service.ts @@ -0,0 +1,19 @@ +// Copyright 2020 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +// (Re-)generated by schema tool +// >>>> DO NOT CHANGE THIS FILE! <<<< +// Change the json schema instead + +import * as wasmclient from "wasmclient" + + + +///////////////////////////// WasmRequestsService ///////////////////////////// + +export class WasmRequestsService extends wasmclient.Service { + + public constructor(cl: wasmclient.ServiceClient) { + super(cl, 0x98e19453); + } +} diff --git a/packages/vm/wasmlib/ts/wasmlib/context.ts b/packages/vm/wasmlib/ts/wasmlib/context.ts index 72bcd296b6..20ba943aa9 100644 --- a/packages/vm/wasmlib/ts/wasmlib/context.ts +++ b/packages/vm/wasmlib/ts/wasmlib/context.ts @@ -26,8 +26,8 @@ export class ScBalances { } // retrieve the balance for the specified token color - balance(color: ScColor): i64 { - return this.balances.getInt64(color).value(); + balance(color: ScColor): u64 { + return this.balances.getUint64(color).value(); } // retrieve an array of all token colors that have a non-zero balance @@ -51,7 +51,7 @@ export class ScTransfers { static fromBalances(balances: ScBalances): ScTransfers { let transfers = new ScTransfers(); let colors = balances.colors(); - for (let i = 0; i < colors.length(); i++) { + for (let i:u32 = 0; i < colors.length(); i++) { let color = colors.getColor(i).value(); transfers.set(color, balances.balance(color)); } @@ -59,12 +59,12 @@ export class ScTransfers { } // create a new transfers object and initialize it with the specified amount of iotas - static iotas(amount: i64): ScTransfers { + static iotas(amount: u64): ScTransfers { return ScTransfers.transfer(ScColor.IOTA, amount); } // create a new transfers object and initialize it with the specified token transfer - static transfer(color: ScColor, amount: i64): ScTransfers { + static transfer(color: ScColor, amount: u64): ScTransfers { let transfer = new ScTransfers(); transfer.set(color, amount); return transfer; @@ -72,8 +72,8 @@ export class ScTransfers { // set the specified colored token transfer in the transfers object // note that this will overwrite any previous amount for the specified color - set(color: ScColor, amount: i64): void { - this.transfers.getInt64(color).setValue(amount); + set(color: ScColor, amount: u64): void { + this.transfers.getUint64(color).setValue(amount); } } @@ -306,19 +306,19 @@ export class ScFuncContext extends ScBaseContext implements ScViewCallContext, S // asynchronously calls the specified smart contract function, // passing the provided parameters and token transfers to it // it is possible to schedule the call for a later execution by specifying a delay - post(chainID: ScChainID, hcontract: ScHname, hfunction: ScHname, params: ScMutableMap | null, transfer: ScTransfers, delay: i32): void { + post(chainID: ScChainID, hcontract: ScHname, hfunction: ScHname, params: ScMutableMap | null, transfer: ScTransfers, delay: u32): void { let encode = new BytesEncoder(); encode.chainID(chainID); encode.hname(hcontract); encode.hname(hfunction); encode.int32((params === null) ? 0 : params.mapID()); encode.int32(transfer.transfers.mapID()); - encode.int32(delay); + encode.uint32(delay); ROOT.getBytes(keys.KEY_POST).setValue(encode.data()); } // generates a random value from 0 to max (exclusive max) using a deterministic RNG - random(max: i64): i64 { + random(max: u64): u64 { if (max == 0) { this.panic("random: max parameter should be non-zero"); } @@ -329,7 +329,7 @@ export class ScFuncContext extends ScBaseContext implements ScViewCallContext, S seed = ROOT.getBytes(keys.KEY_RANDOM).value(); } rnd.setValue(this.utility().hashSha3(seed).toBytes()); - return (Convert.toI64(seed.slice(0, 8)) as u64 % max as u64) as i64; + return Convert.toI64(seed.slice(0, 8)) as u64 % max } // retrieve the request id of this transaction diff --git a/packages/vm/wasmlib/ts/wasmlib/contract.ts b/packages/vm/wasmlib/ts/wasmlib/contract.ts index b7cbfc1d11..606b6c849d 100644 --- a/packages/vm/wasmlib/ts/wasmlib/contract.ts +++ b/packages/vm/wasmlib/ts/wasmlib/contract.ts @@ -123,7 +123,7 @@ export class ScInitFunc { export class ScFunc { view: ScView; - delaySeconds: i32 = 0; + delaySeconds: u32 = 0; transferID: i32 = 0; constructor(hContract: ScHname, hFunction: ScHname) { @@ -149,7 +149,7 @@ export class ScFunc { return o; } - delay(seconds: i32): ScFunc { + delay(seconds: u32): ScFunc { let ret = this.clone(); ret.delaySeconds = seconds; return ret; @@ -172,7 +172,7 @@ export class ScFunc { encode.hname(this.view.hFunction); encode.int32(this.view.id(this.view.paramsID)); encode.int32(this.transferID); - encode.int32(this.delaySeconds); + encode.uint32(this.delaySeconds); ROOT.getBytes(keys.KEY_POST).setValue(encode.data()); } diff --git a/packages/vm/wasmlib/ts/wasmlib/coreblocklog/params.ts b/packages/vm/wasmlib/ts/wasmlib/coreblocklog/params.ts index 0343cbf2e7..ef0d9d3587 100644 --- a/packages/vm/wasmlib/ts/wasmlib/coreblocklog/params.ts +++ b/packages/vm/wasmlib/ts/wasmlib/coreblocklog/params.ts @@ -9,26 +9,26 @@ import * as wasmlib from "wasmlib"; import * as sc from "./index"; export class ImmutableGetBlockInfoParams extends wasmlib.ScMapID { - blockIndex(): wasmlib.ScImmutableInt32 { - return new wasmlib.ScImmutableInt32(this.mapID, wasmlib.Key32.fromString(sc.ParamBlockIndex)); + blockIndex(): wasmlib.ScImmutableUint32 { + return new wasmlib.ScImmutableUint32(this.mapID, wasmlib.Key32.fromString(sc.ParamBlockIndex)); } } export class MutableGetBlockInfoParams extends wasmlib.ScMapID { - blockIndex(): wasmlib.ScMutableInt32 { - return new wasmlib.ScMutableInt32(this.mapID, wasmlib.Key32.fromString(sc.ParamBlockIndex)); + blockIndex(): wasmlib.ScMutableUint32 { + return new wasmlib.ScMutableUint32(this.mapID, wasmlib.Key32.fromString(sc.ParamBlockIndex)); } } export class ImmutableGetEventsForBlockParams extends wasmlib.ScMapID { - blockIndex(): wasmlib.ScImmutableInt32 { - return new wasmlib.ScImmutableInt32(this.mapID, wasmlib.Key32.fromString(sc.ParamBlockIndex)); + blockIndex(): wasmlib.ScImmutableUint32 { + return new wasmlib.ScImmutableUint32(this.mapID, wasmlib.Key32.fromString(sc.ParamBlockIndex)); } } export class MutableGetEventsForBlockParams extends wasmlib.ScMapID { - blockIndex(): wasmlib.ScMutableInt32 { - return new wasmlib.ScMutableInt32(this.mapID, wasmlib.Key32.fromString(sc.ParamBlockIndex)); + blockIndex(): wasmlib.ScMutableUint32 { + return new wasmlib.ScMutableUint32(this.mapID, wasmlib.Key32.fromString(sc.ParamBlockIndex)); } } @@ -37,12 +37,12 @@ export class ImmutableGetEventsForContractParams extends wasmlib.ScMapID { return new wasmlib.ScImmutableHname(this.mapID, wasmlib.Key32.fromString(sc.ParamContractHname)); } - fromBlock(): wasmlib.ScImmutableInt32 { - return new wasmlib.ScImmutableInt32(this.mapID, wasmlib.Key32.fromString(sc.ParamFromBlock)); + fromBlock(): wasmlib.ScImmutableUint32 { + return new wasmlib.ScImmutableUint32(this.mapID, wasmlib.Key32.fromString(sc.ParamFromBlock)); } - toBlock(): wasmlib.ScImmutableInt32 { - return new wasmlib.ScImmutableInt32(this.mapID, wasmlib.Key32.fromString(sc.ParamToBlock)); + toBlock(): wasmlib.ScImmutableUint32 { + return new wasmlib.ScImmutableUint32(this.mapID, wasmlib.Key32.fromString(sc.ParamToBlock)); } } @@ -51,12 +51,12 @@ export class MutableGetEventsForContractParams extends wasmlib.ScMapID { return new wasmlib.ScMutableHname(this.mapID, wasmlib.Key32.fromString(sc.ParamContractHname)); } - fromBlock(): wasmlib.ScMutableInt32 { - return new wasmlib.ScMutableInt32(this.mapID, wasmlib.Key32.fromString(sc.ParamFromBlock)); + fromBlock(): wasmlib.ScMutableUint32 { + return new wasmlib.ScMutableUint32(this.mapID, wasmlib.Key32.fromString(sc.ParamFromBlock)); } - toBlock(): wasmlib.ScMutableInt32 { - return new wasmlib.ScMutableInt32(this.mapID, wasmlib.Key32.fromString(sc.ParamToBlock)); + toBlock(): wasmlib.ScMutableUint32 { + return new wasmlib.ScMutableUint32(this.mapID, wasmlib.Key32.fromString(sc.ParamToBlock)); } } @@ -73,14 +73,14 @@ export class MutableGetEventsForRequestParams extends wasmlib.ScMapID { } export class ImmutableGetRequestIDsForBlockParams extends wasmlib.ScMapID { - blockIndex(): wasmlib.ScImmutableInt32 { - return new wasmlib.ScImmutableInt32(this.mapID, wasmlib.Key32.fromString(sc.ParamBlockIndex)); + blockIndex(): wasmlib.ScImmutableUint32 { + return new wasmlib.ScImmutableUint32(this.mapID, wasmlib.Key32.fromString(sc.ParamBlockIndex)); } } export class MutableGetRequestIDsForBlockParams extends wasmlib.ScMapID { - blockIndex(): wasmlib.ScMutableInt32 { - return new wasmlib.ScMutableInt32(this.mapID, wasmlib.Key32.fromString(sc.ParamBlockIndex)); + blockIndex(): wasmlib.ScMutableUint32 { + return new wasmlib.ScMutableUint32(this.mapID, wasmlib.Key32.fromString(sc.ParamBlockIndex)); } } @@ -97,14 +97,14 @@ export class MutableGetRequestReceiptParams extends wasmlib.ScMapID { } export class ImmutableGetRequestReceiptsForBlockParams extends wasmlib.ScMapID { - blockIndex(): wasmlib.ScImmutableInt32 { - return new wasmlib.ScImmutableInt32(this.mapID, wasmlib.Key32.fromString(sc.ParamBlockIndex)); + blockIndex(): wasmlib.ScImmutableUint32 { + return new wasmlib.ScImmutableUint32(this.mapID, wasmlib.Key32.fromString(sc.ParamBlockIndex)); } } export class MutableGetRequestReceiptsForBlockParams extends wasmlib.ScMapID { - blockIndex(): wasmlib.ScMutableInt32 { - return new wasmlib.ScMutableInt32(this.mapID, wasmlib.Key32.fromString(sc.ParamBlockIndex)); + blockIndex(): wasmlib.ScMutableUint32 { + return new wasmlib.ScMutableUint32(this.mapID, wasmlib.Key32.fromString(sc.ParamBlockIndex)); } } diff --git a/packages/vm/wasmlib/ts/wasmlib/coreblocklog/results.ts b/packages/vm/wasmlib/ts/wasmlib/coreblocklog/results.ts index 0cdeab00e9..9330387092 100644 --- a/packages/vm/wasmlib/ts/wasmlib/coreblocklog/results.ts +++ b/packages/vm/wasmlib/ts/wasmlib/coreblocklog/results.ts @@ -9,8 +9,8 @@ import * as wasmlib from "wasmlib"; import * as sc from "./index"; export class ImmutableControlAddressesResults extends wasmlib.ScMapID { - blockIndex(): wasmlib.ScImmutableInt32 { - return new wasmlib.ScImmutableInt32(this.mapID, wasmlib.Key32.fromString(sc.ResultBlockIndex)); + blockIndex(): wasmlib.ScImmutableUint32 { + return new wasmlib.ScImmutableUint32(this.mapID, wasmlib.Key32.fromString(sc.ResultBlockIndex)); } governingAddress(): wasmlib.ScImmutableAddress { @@ -23,8 +23,8 @@ export class ImmutableControlAddressesResults extends wasmlib.ScMapID { } export class MutableControlAddressesResults extends wasmlib.ScMapID { - blockIndex(): wasmlib.ScMutableInt32 { - return new wasmlib.ScMutableInt32(this.mapID, wasmlib.Key32.fromString(sc.ResultBlockIndex)); + blockIndex(): wasmlib.ScMutableUint32 { + return new wasmlib.ScMutableUint32(this.mapID, wasmlib.Key32.fromString(sc.ResultBlockIndex)); } governingAddress(): wasmlib.ScMutableAddress { @@ -55,12 +55,12 @@ export class ArrayOfImmutableBytes { this.objID = objID; } - length(): i32 { + length(): u32 { return wasmlib.getLength(this.objID); } - getBytes(index: i32): wasmlib.ScImmutableBytes { - return new wasmlib.ScImmutableBytes(this.objID, new wasmlib.Key32(index)); + getBytes(index: u32): wasmlib.ScImmutableBytes { + return new wasmlib.ScImmutableBytes(this.objID, new wasmlib.Key32(index as i32)); } } @@ -82,12 +82,12 @@ export class ArrayOfMutableBytes { wasmlib.clear(this.objID); } - length(): i32 { + length(): u32 { return wasmlib.getLength(this.objID); } - getBytes(index: i32): wasmlib.ScMutableBytes { - return new wasmlib.ScMutableBytes(this.objID, new wasmlib.Key32(index)); + getBytes(index: u32): wasmlib.ScMutableBytes { + return new wasmlib.ScMutableBytes(this.objID, new wasmlib.Key32(index as i32)); } } @@ -127,8 +127,8 @@ export class MutableGetEventsForRequestResults extends wasmlib.ScMapID { } export class ImmutableGetLatestBlockInfoResults extends wasmlib.ScMapID { - blockIndex(): wasmlib.ScImmutableInt32 { - return new wasmlib.ScImmutableInt32(this.mapID, wasmlib.Key32.fromString(sc.ResultBlockIndex)); + blockIndex(): wasmlib.ScImmutableUint32 { + return new wasmlib.ScImmutableUint32(this.mapID, wasmlib.Key32.fromString(sc.ResultBlockIndex)); } blockInfo(): wasmlib.ScImmutableBytes { @@ -137,8 +137,8 @@ export class ImmutableGetLatestBlockInfoResults extends wasmlib.ScMapID { } export class MutableGetLatestBlockInfoResults extends wasmlib.ScMapID { - blockIndex(): wasmlib.ScMutableInt32 { - return new wasmlib.ScMutableInt32(this.mapID, wasmlib.Key32.fromString(sc.ResultBlockIndex)); + blockIndex(): wasmlib.ScMutableUint32 { + return new wasmlib.ScMutableUint32(this.mapID, wasmlib.Key32.fromString(sc.ResultBlockIndex)); } blockInfo(): wasmlib.ScMutableBytes { @@ -153,12 +153,12 @@ export class ArrayOfImmutableRequestID { this.objID = objID; } - length(): i32 { + length(): u32 { return wasmlib.getLength(this.objID); } - getRequestID(index: i32): wasmlib.ScImmutableRequestID { - return new wasmlib.ScImmutableRequestID(this.objID, new wasmlib.Key32(index)); + getRequestID(index: u32): wasmlib.ScImmutableRequestID { + return new wasmlib.ScImmutableRequestID(this.objID, new wasmlib.Key32(index as i32)); } } @@ -180,12 +180,12 @@ export class ArrayOfMutableRequestID { wasmlib.clear(this.objID); } - length(): i32 { + length(): u32 { return wasmlib.getLength(this.objID); } - getRequestID(index: i32): wasmlib.ScMutableRequestID { - return new wasmlib.ScMutableRequestID(this.objID, new wasmlib.Key32(index)); + getRequestID(index: u32): wasmlib.ScMutableRequestID { + return new wasmlib.ScMutableRequestID(this.objID, new wasmlib.Key32(index as i32)); } } @@ -197,12 +197,12 @@ export class MutableGetRequestIDsForBlockResults extends wasmlib.ScMapID { } export class ImmutableGetRequestReceiptResults extends wasmlib.ScMapID { - blockIndex(): wasmlib.ScImmutableInt32 { - return new wasmlib.ScImmutableInt32(this.mapID, wasmlib.Key32.fromString(sc.ResultBlockIndex)); + blockIndex(): wasmlib.ScImmutableUint32 { + return new wasmlib.ScImmutableUint32(this.mapID, wasmlib.Key32.fromString(sc.ResultBlockIndex)); } - requestIndex(): wasmlib.ScImmutableInt16 { - return new wasmlib.ScImmutableInt16(this.mapID, wasmlib.Key32.fromString(sc.ResultRequestIndex)); + requestIndex(): wasmlib.ScImmutableUint16 { + return new wasmlib.ScImmutableUint16(this.mapID, wasmlib.Key32.fromString(sc.ResultRequestIndex)); } requestRecord(): wasmlib.ScImmutableBytes { @@ -211,12 +211,12 @@ export class ImmutableGetRequestReceiptResults extends wasmlib.ScMapID { } export class MutableGetRequestReceiptResults extends wasmlib.ScMapID { - blockIndex(): wasmlib.ScMutableInt32 { - return new wasmlib.ScMutableInt32(this.mapID, wasmlib.Key32.fromString(sc.ResultBlockIndex)); + blockIndex(): wasmlib.ScMutableUint32 { + return new wasmlib.ScMutableUint32(this.mapID, wasmlib.Key32.fromString(sc.ResultBlockIndex)); } - requestIndex(): wasmlib.ScMutableInt16 { - return new wasmlib.ScMutableInt16(this.mapID, wasmlib.Key32.fromString(sc.ResultRequestIndex)); + requestIndex(): wasmlib.ScMutableUint16 { + return new wasmlib.ScMutableUint16(this.mapID, wasmlib.Key32.fromString(sc.ResultRequestIndex)); } requestRecord(): wasmlib.ScMutableBytes { diff --git a/packages/vm/wasmlib/ts/wasmlib/coregovernance/results.ts b/packages/vm/wasmlib/ts/wasmlib/coregovernance/results.ts index 96b3881322..ba0a89c508 100644 --- a/packages/vm/wasmlib/ts/wasmlib/coregovernance/results.ts +++ b/packages/vm/wasmlib/ts/wasmlib/coregovernance/results.ts @@ -15,12 +15,12 @@ export class ArrayOfImmutableBytes { this.objID = objID; } - length(): i32 { + length(): u32 { return wasmlib.getLength(this.objID); } - getBytes(index: i32): wasmlib.ScImmutableBytes { - return new wasmlib.ScImmutableBytes(this.objID, new wasmlib.Key32(index)); + getBytes(index: u32): wasmlib.ScImmutableBytes { + return new wasmlib.ScImmutableBytes(this.objID, new wasmlib.Key32(index as i32)); } } @@ -42,12 +42,12 @@ export class ArrayOfMutableBytes { wasmlib.clear(this.objID); } - length(): i32 { + length(): u32 { return wasmlib.getLength(this.objID); } - getBytes(index: i32): wasmlib.ScMutableBytes { - return new wasmlib.ScMutableBytes(this.objID, new wasmlib.Key32(index)); + getBytes(index: u32): wasmlib.ScMutableBytes { + return new wasmlib.ScMutableBytes(this.objID, new wasmlib.Key32(index as i32)); } } diff --git a/packages/vm/wasmlib/ts/wasmlib/host.ts b/packages/vm/wasmlib/ts/wasmlib/host.ts index f8373e909f..b5588d3475 100644 --- a/packages/vm/wasmlib/ts/wasmlib/host.ts +++ b/packages/vm/wasmlib/ts/wasmlib/host.ts @@ -161,10 +161,10 @@ export function getKeyIDFromUint64(key: u64, nrOfBytes: usize): Key32 { } // Retrieve the length of an array container object on the host -export function getLength(objID: i32): i32 { +export function getLength(objID: i32): u32 { // special integer key "length" is used let bytes = getBytes(objID, keys.KEY_LENGTH, TYPE_INT32); - return Convert.toI32(bytes); + return Convert.toI32(bytes) as u32; } // Retrieve the id of the specified container sub-object diff --git a/packages/vm/wasmlib/ts/wasmlib/immutable.ts b/packages/vm/wasmlib/ts/wasmlib/immutable.ts index b6617fed89..abcb56e410 100644 --- a/packages/vm/wasmlib/ts/wasmlib/immutable.ts +++ b/packages/vm/wasmlib/ts/wasmlib/immutable.ts @@ -187,12 +187,12 @@ export class ScImmutableColorArray { } // get value proxy for item at index, index can be 0..length()-1 - getColor(index: i32): ScImmutableColor { - return new ScImmutableColor(this.objID, new Key32(index)); + getColor(index: u32): ScImmutableColor { + return new ScImmutableColor(this.objID, new Key32(index as i32)); } // number of items in array - length(): i32 { + length(): u32 { return host.getLength(this.objID); } } @@ -513,13 +513,13 @@ export class ScImmutableMapArray { } // get value proxy for item at index, index can be 0..length()-1 - getMap(index: i32): ScImmutableMap { - let mapID = host.getObjectID(this.objID, new Key32(index), host.TYPE_MAP); + getMap(index: u32): ScImmutableMap { + let mapID = host.getObjectID(this.objID, new Key32(index as i32), host.TYPE_MAP); return new ScImmutableMap(mapID); } // number of items in array - length(): i32 { + length(): u32 { return host.getLength(this.objID); } } @@ -590,12 +590,12 @@ export class ScImmutableStringArray { } // get value proxy for item at index, index can be 0..length()-1 - getString(index: i32): ScImmutableString { - return new ScImmutableString(this.objID, new Key32(index)); + getString(index: u32): ScImmutableString { + return new ScImmutableString(this.objID, new Key32(index as i32)); } // number of items in array - length(): i32 { + length(): u2 { return host.getLength(this.objID); } } diff --git a/packages/vm/wasmlib/ts/wasmlib/mutable.ts b/packages/vm/wasmlib/ts/wasmlib/mutable.ts index 12e33406f2..2d91d17fb3 100644 --- a/packages/vm/wasmlib/ts/wasmlib/mutable.ts +++ b/packages/vm/wasmlib/ts/wasmlib/mutable.ts @@ -634,8 +634,8 @@ export class ScMutableMapArray { // get value proxy for item at index, index can be 0..length() // when index equals length() a new item is appended - getMap(index: i32): ScMutableMap { - let mapID = host.getObjectID(this.objID, new Key32(index), host.TYPE_MAP); + getMap(index: u32): ScMutableMap { + let mapID = host.getObjectID(this.objID, new Key32(index as i32), host.TYPE_MAP); return new ScMutableMap(mapID); } @@ -645,7 +645,7 @@ export class ScMutableMapArray { } // number of items in array - length(): i32 { + length(): u32 { return host.getLength(this.objID); } } @@ -744,8 +744,8 @@ export class ScMutableStringArray { // get value proxy for item at index, index can be 0..length() // when index equals length() a new item is appended - getString(index: i32): ScMutableString { - return new ScMutableString(this.objID, new Key32(index)); + getString(index: u32): ScMutableString { + return new ScMutableString(this.objID, new Key32(index as i32)); } // get immutable version of array proxy @@ -754,7 +754,7 @@ export class ScMutableStringArray { } // number of items in array - length(): i32 { + length(): u32 { return host.getLength(this.objID); } } diff --git a/packages/vm/wasmlib/ts/wasmlib/wasmrequests/consts.ts b/packages/vm/wasmlib/ts/wasmlib/wasmrequests/consts.ts new file mode 100644 index 0000000000..cb0890609e --- /dev/null +++ b/packages/vm/wasmlib/ts/wasmlib/wasmrequests/consts.ts @@ -0,0 +1,14 @@ +// Copyright 2020 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +// (Re-)generated by schema tool +// >>>> DO NOT CHANGE THIS FILE! <<<< +// Change the json schema instead + +import * as wasmlib from "wasmlib"; + +export const ScName = "requests"; +export const ScDescription = "WasmLib request structures"; +export const HScName = new wasmlib.ScHname(0x98e19453); + + diff --git a/packages/vm/wasmlib/ts/wasmlib/wasmrequests/contract.ts b/packages/vm/wasmlib/ts/wasmlib/wasmrequests/contract.ts new file mode 100644 index 0000000000..227f20d89d --- /dev/null +++ b/packages/vm/wasmlib/ts/wasmlib/wasmrequests/contract.ts @@ -0,0 +1,12 @@ +// Copyright 2020 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +// (Re-)generated by schema tool +// >>>> DO NOT CHANGE THIS FILE! <<<< +// Change the json schema instead + +import * as wasmlib from "wasmlib"; +import * as sc from "./index"; + +export class ScFuncs { +} diff --git a/packages/vm/wasmlib/ts/wasmlib/wasmrequests/index.ts b/packages/vm/wasmlib/ts/wasmlib/wasmrequests/index.ts new file mode 100644 index 0000000000..34b1120be4 --- /dev/null +++ b/packages/vm/wasmlib/ts/wasmlib/wasmrequests/index.ts @@ -0,0 +1,9 @@ +// Copyright 2020 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +// (Re-)generated by schema tool +// >>>> DO NOT CHANGE THIS FILE! <<<< +// Change the json schema instead + +export * from "./consts"; +export * from "./contract"; diff --git a/packages/vm/wasmlib/ts/wasmlib/wasmrequests/structs.ts b/packages/vm/wasmlib/ts/wasmlib/wasmrequests/structs.ts new file mode 100644 index 0000000000..dde968d18d --- /dev/null +++ b/packages/vm/wasmlib/ts/wasmlib/wasmrequests/structs.ts @@ -0,0 +1,292 @@ +// Copyright 2020 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +// (Re-)generated by schema tool +// >>>> DO NOT CHANGE THIS FILE! <<<< +// Change the json schema instead + +import * as wasmlib from "wasmlib"; + +export class CallRequest { + contract : wasmlib.ScHname = new wasmlib.ScHname(0); + function : wasmlib.ScHname = new wasmlib.ScHname(0); + params : = ; + transfer : = ; + + static fromBytes(bytes: u8[]): CallRequest { + let decode = new wasmlib.BytesDecoder(bytes); + let data = new CallRequest(); + data.contract = decode.hname(); + data.function = decode.hname(); + data.params = decode.bytes(); + data.transfer = decode.bytes(); + decode.close(); + return data; + } + + bytes(): u8[] { + return new wasmlib.BytesEncoder(). + hname(this.contract). + hname(this.function). + bytes(this.params). + bytes(this.transfer). + data(); + } +} + +export class ImmutableCallRequest { + objID: i32; + keyID: wasmlib.Key32; + + constructor(objID: i32, keyID: wasmlib.Key32) { + this.objID = objID; + this.keyID = keyID; + } + + exists(): boolean { + return wasmlib.exists(this.objID, this.keyID, wasmlib.TYPE_BYTES); + } + + value(): CallRequest { + return CallRequest.fromBytes(wasmlib.getBytes(this.objID, this.keyID, wasmlib.TYPE_BYTES)); + } +} + +export class MutableCallRequest { + objID: i32; + keyID: wasmlib.Key32; + + constructor(objID: i32, keyID: wasmlib.Key32) { + this.objID = objID; + this.keyID = keyID; + } + + delete(): void { + wasmlib.delKey(this.objID, this.keyID, wasmlib.TYPE_BYTES); + } + + exists(): boolean { + return wasmlib.exists(this.objID, this.keyID, wasmlib.TYPE_BYTES); + } + + setValue(value: CallRequest): void { + wasmlib.setBytes(this.objID, this.keyID, wasmlib.TYPE_BYTES, value.bytes()); + } + + value(): CallRequest { + return CallRequest.fromBytes(wasmlib.getBytes(this.objID, this.keyID, wasmlib.TYPE_BYTES)); + } +} + +export class DeployRequest { + description : string = ""; + name : string = ""; + params : = ; + progHash : wasmlib.ScHash = new wasmlib.ScHash(); + + static fromBytes(bytes: u8[]): DeployRequest { + let decode = new wasmlib.BytesDecoder(bytes); + let data = new DeployRequest(); + data.description = decode.string(); + data.name = decode.string(); + data.params = decode.bytes(); + data.progHash = decode.hash(); + decode.close(); + return data; + } + + bytes(): u8[] { + return new wasmlib.BytesEncoder(). + string(this.description). + string(this.name). + bytes(this.params). + hash(this.progHash). + data(); + } +} + +export class ImmutableDeployRequest { + objID: i32; + keyID: wasmlib.Key32; + + constructor(objID: i32, keyID: wasmlib.Key32) { + this.objID = objID; + this.keyID = keyID; + } + + exists(): boolean { + return wasmlib.exists(this.objID, this.keyID, wasmlib.TYPE_BYTES); + } + + value(): DeployRequest { + return DeployRequest.fromBytes(wasmlib.getBytes(this.objID, this.keyID, wasmlib.TYPE_BYTES)); + } +} + +export class MutableDeployRequest { + objID: i32; + keyID: wasmlib.Key32; + + constructor(objID: i32, keyID: wasmlib.Key32) { + this.objID = objID; + this.keyID = keyID; + } + + delete(): void { + wasmlib.delKey(this.objID, this.keyID, wasmlib.TYPE_BYTES); + } + + exists(): boolean { + return wasmlib.exists(this.objID, this.keyID, wasmlib.TYPE_BYTES); + } + + setValue(value: DeployRequest): void { + wasmlib.setBytes(this.objID, this.keyID, wasmlib.TYPE_BYTES, value.bytes()); + } + + value(): DeployRequest { + return DeployRequest.fromBytes(wasmlib.getBytes(this.objID, this.keyID, wasmlib.TYPE_BYTES)); + } +} + +export class PostRequest { + chainID : wasmlib.ScChainID = new wasmlib.ScChainID(); + contract : wasmlib.ScHname = new wasmlib.ScHname(0); + delay : u32 = 0; + function : wasmlib.ScHname = new wasmlib.ScHname(0); + params : = ; + transfer : = ; + + static fromBytes(bytes: u8[]): PostRequest { + let decode = new wasmlib.BytesDecoder(bytes); + let data = new PostRequest(); + data.chainID = decode.chainID(); + data.contract = decode.hname(); + data.delay = decode.uint32(); + data.function = decode.hname(); + data.params = decode.bytes(); + data.transfer = decode.bytes(); + decode.close(); + return data; + } + + bytes(): u8[] { + return new wasmlib.BytesEncoder(). + chainID(this.chainID). + hname(this.contract). + uint32(this.delay). + hname(this.function). + bytes(this.params). + bytes(this.transfer). + data(); + } +} + +export class ImmutablePostRequest { + objID: i32; + keyID: wasmlib.Key32; + + constructor(objID: i32, keyID: wasmlib.Key32) { + this.objID = objID; + this.keyID = keyID; + } + + exists(): boolean { + return wasmlib.exists(this.objID, this.keyID, wasmlib.TYPE_BYTES); + } + + value(): PostRequest { + return PostRequest.fromBytes(wasmlib.getBytes(this.objID, this.keyID, wasmlib.TYPE_BYTES)); + } +} + +export class MutablePostRequest { + objID: i32; + keyID: wasmlib.Key32; + + constructor(objID: i32, keyID: wasmlib.Key32) { + this.objID = objID; + this.keyID = keyID; + } + + delete(): void { + wasmlib.delKey(this.objID, this.keyID, wasmlib.TYPE_BYTES); + } + + exists(): boolean { + return wasmlib.exists(this.objID, this.keyID, wasmlib.TYPE_BYTES); + } + + setValue(value: PostRequest): void { + wasmlib.setBytes(this.objID, this.keyID, wasmlib.TYPE_BYTES, value.bytes()); + } + + value(): PostRequest { + return PostRequest.fromBytes(wasmlib.getBytes(this.objID, this.keyID, wasmlib.TYPE_BYTES)); + } +} + +export class SendRequest { + address : wasmlib.ScAddress = new wasmlib.ScAddress(); + transfer : = ; + + static fromBytes(bytes: u8[]): SendRequest { + let decode = new wasmlib.BytesDecoder(bytes); + let data = new SendRequest(); + data.address = decode.address(); + data.transfer = decode.bytes(); + decode.close(); + return data; + } + + bytes(): u8[] { + return new wasmlib.BytesEncoder(). + address(this.address). + bytes(this.transfer). + data(); + } +} + +export class ImmutableSendRequest { + objID: i32; + keyID: wasmlib.Key32; + + constructor(objID: i32, keyID: wasmlib.Key32) { + this.objID = objID; + this.keyID = keyID; + } + + exists(): boolean { + return wasmlib.exists(this.objID, this.keyID, wasmlib.TYPE_BYTES); + } + + value(): SendRequest { + return SendRequest.fromBytes(wasmlib.getBytes(this.objID, this.keyID, wasmlib.TYPE_BYTES)); + } +} + +export class MutableSendRequest { + objID: i32; + keyID: wasmlib.Key32; + + constructor(objID: i32, keyID: wasmlib.Key32) { + this.objID = objID; + this.keyID = keyID; + } + + delete(): void { + wasmlib.delKey(this.objID, this.keyID, wasmlib.TYPE_BYTES); + } + + exists(): boolean { + return wasmlib.exists(this.objID, this.keyID, wasmlib.TYPE_BYTES); + } + + setValue(value: SendRequest): void { + wasmlib.setBytes(this.objID, this.keyID, wasmlib.TYPE_BYTES, value.bytes()); + } + + value(): SendRequest { + return SendRequest.fromBytes(wasmlib.getBytes(this.objID, this.keyID, wasmlib.TYPE_BYTES)); + } +} diff --git a/packages/vm/wasmlib/ts/wasmlib/wasmrequests/tsconfig.json b/packages/vm/wasmlib/ts/wasmlib/wasmrequests/tsconfig.json new file mode 100644 index 0000000000..6fb4265c72 --- /dev/null +++ b/packages/vm/wasmlib/ts/wasmlib/wasmrequests/tsconfig.json @@ -0,0 +1,4 @@ +{ + "extends": "assemblyscript/std/assembly.json", + "include": ["./*.ts"] +} diff --git a/packages/vm/wasmproc/scbalances.go b/packages/vm/wasmproc/scbalances.go deleted file mode 100644 index ee02afb615..0000000000 --- a/packages/vm/wasmproc/scbalances.go +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright 2020 IOTA Stiftung -// SPDX-License-Identifier: Apache-2.0 - -package wasmproc - -import ( - "strconv" - - "github.com/iotaledger/wasp/packages/iscp/colored" - "github.com/iotaledger/wasp/packages/kv" - "github.com/iotaledger/wasp/packages/kv/codec" - "github.com/iotaledger/wasp/packages/kv/dict" - "github.com/iotaledger/wasp/packages/vm/wasmhost" -) - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -func NewScBalances(wc *WasmContext, keyID int32) *ScDict { - o := NewScDict(&wc.KvStoreHost, dict.New()) - switch keyID { - case wasmhost.KeyIncoming: - if wc.ctx == nil { - o.Panicf("no incoming() on views") - } - return loadBalances(o, wc.ctx.IncomingTransfer()) - case wasmhost.KeyMinted: - if wc.ctx == nil { - o.Panicf("no minted() on views") - } - return loadBalances(o, wc.ctx.Minted()) - - case wasmhost.KeyBalances: - if wc.ctx != nil { - return loadBalances(o, wc.ctx.Balances()) - } - return loadBalances(o, wc.ctxView.Balances()) - } - o.Panicf("unknown balances: %s", wc.GetKeyStringFromID(keyID)) - return nil -} - -func loadBalances(o *ScDict, balances colored.Balances) *ScDict { - index := 0 - key := o.host.GetKeyStringFromID(wasmhost.KeyColor) - balances.ForEachRandomly(func(color colored.Color, balance uint64) bool { - o.kvStore.Set(kv.Key(color[:]), codec.EncodeUint64(balance)) - o.kvStore.Set(kv.Key(key+"."+strconv.Itoa(index)), color[:]) - index++ - return true - }) - // save KeyLength - o.kvStore.Set(kv.Key(key), codec.EncodeInt32(int32(index))) - return o -} diff --git a/packages/vm/wasmproc/sccontext.go b/packages/vm/wasmproc/sccontext.go deleted file mode 100644 index 176c8f93ec..0000000000 --- a/packages/vm/wasmproc/sccontext.go +++ /dev/null @@ -1,285 +0,0 @@ -// Copyright 2020 IOTA Stiftung -// SPDX-License-Identifier: Apache-2.0 - -package wasmproc - -import ( - "time" - - "github.com/iotaledger/wasp/packages/iscp/colored" - "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" - - "github.com/iotaledger/wasp/packages/hashing" - "github.com/iotaledger/wasp/packages/iscp" - "github.com/iotaledger/wasp/packages/kv" - "github.com/iotaledger/wasp/packages/kv/codec" - "github.com/iotaledger/wasp/packages/kv/dict" - "github.com/iotaledger/wasp/packages/vm/wasmhost" -) - -var typeIds = map[int32]int32{ - wasmhost.KeyAccountID: wasmhost.OBJTYPE_AGENT_ID, - wasmhost.KeyBalances: wasmhost.OBJTYPE_MAP, - wasmhost.KeyCall: wasmhost.OBJTYPE_BYTES, - wasmhost.KeyCaller: wasmhost.OBJTYPE_AGENT_ID, - wasmhost.KeyChainID: wasmhost.OBJTYPE_CHAIN_ID, - wasmhost.KeyChainOwnerID: wasmhost.OBJTYPE_AGENT_ID, - wasmhost.KeyContract: wasmhost.OBJTYPE_HNAME, - wasmhost.KeyContractCreator: wasmhost.OBJTYPE_AGENT_ID, - wasmhost.KeyDeploy: wasmhost.OBJTYPE_BYTES, - wasmhost.KeyEvent: wasmhost.OBJTYPE_STRING, - wasmhost.KeyExports: wasmhost.OBJTYPE_STRING | wasmhost.OBJTYPE_ARRAY, - wasmhost.KeyIncoming: wasmhost.OBJTYPE_MAP, - wasmhost.KeyLog: wasmhost.OBJTYPE_STRING, - wasmhost.KeyMaps: wasmhost.OBJTYPE_MAP | wasmhost.OBJTYPE_ARRAY, - wasmhost.KeyMinted: wasmhost.OBJTYPE_MAP, - wasmhost.KeyPanic: wasmhost.OBJTYPE_STRING, - wasmhost.KeyParams: wasmhost.OBJTYPE_MAP, - wasmhost.KeyPost: wasmhost.OBJTYPE_BYTES, - wasmhost.KeyRandom: wasmhost.OBJTYPE_BYTES, - wasmhost.KeyRequestID: wasmhost.OBJTYPE_REQUEST_ID, - wasmhost.KeyResults: wasmhost.OBJTYPE_MAP, - wasmhost.KeyReturn: wasmhost.OBJTYPE_MAP, - wasmhost.KeyState: wasmhost.OBJTYPE_MAP, - wasmhost.KeyTimestamp: wasmhost.OBJTYPE_INT64, - wasmhost.KeyTrace: wasmhost.OBJTYPE_STRING, - wasmhost.KeyTransfers: wasmhost.OBJTYPE_MAP | wasmhost.OBJTYPE_ARRAY, - wasmhost.KeyUtility: wasmhost.OBJTYPE_MAP, -} - -type ScContext struct { - ScSandboxObject - wc *WasmContext -} - -func NewScContext(wc *WasmContext, host *wasmhost.KvStoreHost) *ScContext { - o := &ScContext{} - o.wc = wc - o.host = host - o.name = "root" - o.id = 1 - o.isRoot = true - o.objects = make(map[int32]int32) - return o -} - -func (o *ScContext) Exists(keyID, typeID int32) bool { - if keyID == wasmhost.KeyExports { - return o.wc.ctx == nil && o.wc.ctxView == nil - } - return o.GetTypeID(keyID) > 0 -} - -func (o *ScContext) GetBytes(keyID, typeID int32) []byte { - if o.wc == nil { - o.Panicf("missing context") - } - switch keyID { - // common functionality - case wasmhost.KeyAccountID: - return o.wc.common.AccountID().Bytes() - case wasmhost.KeyChainID: - return o.wc.common.ChainID().Bytes() - case wasmhost.KeyChainOwnerID: - return o.wc.common.ChainOwnerID().Bytes() - case wasmhost.KeyContract: - return o.wc.common.Contract().Bytes() - case wasmhost.KeyContractCreator: - return o.wc.common.ContractCreator().Bytes() - case wasmhost.KeyTimestamp: - return codec.EncodeInt64(o.wc.common.GetTimestamp()) - // ctx-only functionality - case wasmhost.KeyCaller: - return o.wc.ctx.Caller().Bytes() - case wasmhost.KeyRandom: - return o.wc.ctx.GetEntropy().Bytes() - case wasmhost.KeyRequestID: - return o.wc.ctx.Request().ID().Bytes() - } - o.InvalidKey(keyID) - return nil -} - -func (o *ScContext) GetObjectID(keyID, typeID int32) int32 { - if keyID == wasmhost.KeyExports && (o.wc.ctx != nil || o.wc.ctxView != nil) { - // once map has entries (after on_load) this cannot be called any longer - o.InvalidKey(keyID) - return 0 - } - - return GetMapObjectID(o, keyID, typeID, ObjFactories{ - wasmhost.KeyBalances: func() WaspObject { return NewScBalances(o.wc, keyID) }, - wasmhost.KeyExports: func() WaspObject { return NewScExports(o.wc) }, - wasmhost.KeyIncoming: func() WaspObject { return NewScBalances(o.wc, keyID) }, - wasmhost.KeyMaps: func() WaspObject { return NewScMaps(o.host) }, - wasmhost.KeyMinted: func() WaspObject { return NewScBalances(o.wc, keyID) }, - wasmhost.KeyParams: func() WaspObject { return NewScDict(o.host, o.wc.params()) }, - wasmhost.KeyResults: func() WaspObject { return NewScDict(o.host, dict.New()) }, - wasmhost.KeyReturn: func() WaspObject { return NewScDict(o.host, dict.New()) }, - wasmhost.KeyState: func() WaspObject { return NewScDict(o.host, o.wc.state()) }, - wasmhost.KeyTransfers: func() WaspObject { return NewScTransfers(o.wc) }, - wasmhost.KeyUtility: func() WaspObject { return NewScUtility(o.wc, nil) }, - }) -} - -func (o *ScContext) GetTypeID(keyID int32) int32 { - return typeIds[keyID] -} - -func (o *ScContext) SetBytes(keyID, typeID int32, bytes []byte) { - switch keyID { - case wasmhost.KeyCall: - o.processCall(bytes) - case wasmhost.KeyDeploy: - o.processDeploy(bytes) - case wasmhost.KeyEvent: - o.wc.ctx.Event(string(bytes)) - case wasmhost.KeyLog: - o.wc.log().Infof(string(bytes)) - case wasmhost.KeyTrace: - o.wc.log().Debugf(string(bytes)) - case wasmhost.KeyPanic: - o.wc.log().Panicf(string(bytes)) - case wasmhost.KeyPost: - o.processPost(bytes) - default: - o.InvalidKey(keyID) - } -} - -func (o *ScContext) processCall(bytes []byte) { - decode := wasmlib.NewBytesDecoder(bytes) - contract, err := iscp.HnameFromBytes(decode.Hname().Bytes()) - if err != nil { - o.Panicf(err.Error()) - } - function, err := iscp.HnameFromBytes(decode.Hname().Bytes()) - if err != nil { - o.Panicf(err.Error()) - } - params := o.getParams(decode.Int32()) - transfer := o.getTransfer(decode.Int32()) - - o.Tracef("CALL c'%s' f'%s'", contract.String(), function.String()) - results, err := o.processCallUnlocked(contract, function, params, transfer) - if err != nil { - o.Panicf("failed to invoke call: %v", err) - } - resultsID := o.GetObjectID(wasmhost.KeyReturn, wasmhost.OBJTYPE_MAP) - o.host.FindObject(resultsID).(*ScDict).kvStore = results -} - -func (o *ScContext) processCallUnlocked(contract, function iscp.Hname, params dict.Dict, transfer colored.Balances) (dict.Dict, error) { - o.wc.proc.instanceLock.Unlock() - defer o.wc.proc.instanceLock.Lock() - - if o.wc.ctx != nil { - return o.wc.ctx.Call(contract, function, params, transfer) - } - return o.wc.ctxView.Call(contract, function, params) -} - -func (o *ScContext) processDeploy(bytes []byte) { - decode := wasmlib.NewBytesDecoder(bytes) - programHash, err := hashing.HashValueFromBytes(decode.Hash().Bytes()) - if err != nil { - o.Panicf(err.Error()) - } - name := string(decode.Bytes()) - description := string(decode.Bytes()) - params := o.getParams(decode.Int32()) - o.Tracef("DEPLOY c'%s' f'%s'", name, description) - err = o.processDeployUnlocked(programHash, name, description, params) - if err != nil { - o.Panicf("failed to deploy: %v", err) - } -} - -func (o *ScContext) processDeployUnlocked(programHash hashing.HashValue, name, description string, params dict.Dict) error { - o.wc.proc.instanceLock.Unlock() - defer o.wc.proc.instanceLock.Lock() - - return o.wc.ctx.DeployContract(programHash, name, description, params) -} - -func (o *ScContext) processPost(bytes []byte) { - decode := wasmlib.NewBytesDecoder(bytes) - chainID, err := iscp.ChainIDFromBytes(decode.ChainID().Bytes()) - if err != nil { - o.Panicf(err.Error()) - } - contract, err := iscp.HnameFromBytes(decode.Hname().Bytes()) - if err != nil { - o.Panicf(err.Error()) - } - function, err := iscp.HnameFromBytes(decode.Hname().Bytes()) - if err != nil { - o.Panicf(err.Error()) - } - o.Tracef("POST c'%s' f'%s'", contract.String(), function.String()) - params := o.getParams(decode.Int32()) - transferID := decode.Int32() - if transferID == 0 { - o.Panicf("transfer is required for post") - } - transfer := o.getTransfer(transferID) - metadata := &iscp.SendMetadata{ - TargetContract: contract, - EntryPoint: function, - Args: params, - } - delay := decode.Int32() - if delay == 0 { - if !o.wc.ctx.Send(chainID.AsAddress(), transfer, metadata) { - o.Panicf("failed to send to %s", chainID.AsAddress().String()) - } - return - } - - if delay < 0 { - o.Panicf("invalid delay: %d", delay) - } - - timeLock := time.Unix(0, o.wc.ctx.GetTimestamp()) - timeLock = timeLock.Add(time.Duration(delay) * time.Second) - options := iscp.SendOptions{ - TimeLock: uint32(timeLock.Unix()), - } - if !o.wc.ctx.Send(chainID.AsAddress(), transfer, metadata, options) { - o.Panicf("failed to send to %s", chainID.AsAddress().String()) - } -} - -func (o *ScContext) getParams(paramsID int32) dict.Dict { - if paramsID == 0 { - return dict.New() - } - params := o.host.FindObject(paramsID).(*ScDict).kvStore.(dict.Dict) - params.MustIterate("", func(key kv.Key, value []byte) bool { - o.Tracef(" PARAM '%s'", key) - return true - }) - return params -} - -func (o *ScContext) getTransfer(transferID int32) colored.Balances { - if transferID == 0 { - return colored.NewBalances() - } - transfer := colored.NewBalances() - transferDict := o.host.FindObject(transferID).(*ScDict).kvStore - transferDict.MustIterate("", func(key kv.Key, value []byte) bool { - col, err := codec.DecodeColor([]byte(key)) - if err != nil { - o.Panicf(err.Error()) - } - amount, err := codec.DecodeUint64(value) - if err != nil { - o.Panicf(err.Error()) - } - o.Tracef(" XFER %d '%s'", amount, col.String()) - transfer.Set(col, amount) - return true - }) - return transfer -} diff --git a/packages/vm/wasmproc/scdict.go b/packages/vm/wasmproc/scdict.go deleted file mode 100644 index 1ddd454dd1..0000000000 --- a/packages/vm/wasmproc/scdict.go +++ /dev/null @@ -1,330 +0,0 @@ -// Copyright 2020 IOTA Stiftung -// SPDX-License-Identifier: Apache-2.0 - -package wasmproc - -import ( - "encoding/binary" - "fmt" - "strings" - - "github.com/iotaledger/wasp/packages/kv" - "github.com/iotaledger/wasp/packages/kv/codec" - "github.com/iotaledger/wasp/packages/vm/wasmhost" -) - -type ( - ObjFactory func() WaspObject - ObjFactories map[int32]ObjFactory -) - -type WaspObject interface { - wasmhost.HostObject - InitObj(id int32, keyID int32, owner *ScDict) - Panicf(format string, args ...interface{}) - FindOrMakeObjectID(keyID int32, factory ObjFactory) int32 - NestedKey() string - Suffix(keyID int32) string -} - -func GetArrayObjectID(arrayObj WaspObject, index, typeID int32, factory ObjFactory) int32 { - if !arrayObj.Exists(index, typeID) { - arrayObj.Panicf("GetArrayObjectID: invalid index") - } - if typeID != arrayObj.GetTypeID(index) { - arrayObj.Panicf("GetArrayObjectID: invalid type") - } - return arrayObj.FindOrMakeObjectID(index, factory) -} - -func GetMapObjectID(mapObj WaspObject, keyID, typeID int32, factories ObjFactories) int32 { - factory, ok := factories[keyID] - if !ok { - mapObj.Panicf("GetMapObjectID: invalid key") - } - if typeID != mapObj.GetTypeID(keyID) { - mapObj.Panicf("GetMapObjectID: invalid type") - } - return mapObj.FindOrMakeObjectID(keyID, factory) -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -type ScDict struct { - host *wasmhost.KvStoreHost - id int32 - isRoot bool - keyID int32 - kvStore kv.KVStore - length int32 - name string - objects map[int32]int32 - ownerID int32 - typeID int32 - types map[int32]int32 -} - -// TODO iterate over maps - -var _ WaspObject = &ScDict{} - -func NewScDict(host *wasmhost.KvStoreHost, kvStore kv.KVStore) *ScDict { - return &ScDict{host: host, kvStore: kvStore} -} - -func NewNullObject(host *wasmhost.KvStoreHost) WaspObject { - o := &ScSandboxObject{} - o.host = host - o.name = "null" - o.isRoot = true - return o -} - -func (o *ScDict) InitObj(id, keyID int32, owner *ScDict) { - o.id = id - o.keyID = keyID - o.ownerID = owner.id - o.host = owner.host - o.isRoot = o.kvStore != nil - if !o.isRoot { - o.kvStore = owner.kvStore - } - ownerObj := o.Owner() - o.typeID = ownerObj.GetTypeID(keyID) - o.name = owner.name + ownerObj.Suffix(keyID) - if o.ownerID == 1 { - // strip off "root." prefix - o.name = strings.TrimPrefix(o.name, "root.") - // strip off "." prefix - o.name = strings.TrimPrefix(o.name, ".") - } - if (o.typeID&wasmhost.OBJTYPE_ARRAY) != 0 && o.kvStore != nil { - err := o.getArrayLength() - if err != nil { - o.Panicf("InitObj: %v", err) - } - } - o.Tracef("InitObj %s", o.name) - o.objects = make(map[int32]int32) - o.types = make(map[int32]int32) -} - -func (o *ScDict) CallFunc(keyID int32, params []byte) []byte { - o.Panicf("CallFunc: invalid call") - return nil -} - -func (o *ScDict) DelKey(keyID, typeID int32) { - if (typeID & wasmhost.OBJTYPE_ARRAY) != 0 { - o.Panicf("DelKey: cannot delete array") - } - if typeID == wasmhost.OBJTYPE_MAP { - o.Panicf("DelKey: cannot delete map") - } - o.kvStore.Del(o.key(keyID, typeID)) -} - -func (o *ScDict) Exists(keyID, typeID int32) bool { - if keyID == wasmhost.KeyLength && (o.typeID&wasmhost.OBJTYPE_ARRAY) != 0 { - return true - } - if o.typeID == (wasmhost.OBJTYPE_ARRAY | wasmhost.OBJTYPE_MAP) { - return uint32(keyID) <= uint32(len(o.objects)) - } - ret, _ := o.kvStore.Has(o.key(keyID, typeID)) - return ret -} - -func (o *ScDict) FindOrMakeObjectID(keyID int32, factory ObjFactory) int32 { - objID, ok := o.objects[keyID] - if ok { - return objID - } - newObject := factory() - objID = o.host.TrackObject(newObject) - newObject.InitObj(objID, keyID, o) - o.objects[keyID] = objID - if (o.typeID & wasmhost.OBJTYPE_ARRAY) != 0 { - o.length++ - if o.kvStore != nil { - key := o.NestedKey()[1:] - o.kvStore.Set(kv.Key(key), codec.EncodeInt32(o.length)) - } - } - return objID -} - -func (o *ScDict) getArrayLength() (err error) { - key := o.NestedKey()[1:] - bytes := o.kvStore.MustGet(kv.Key(key)) - if (o.typeID & wasmhost.OBJTYPE_ARRAY16) != wasmhost.OBJTYPE_ARRAY16 { - o.length, err = codec.DecodeInt32(bytes, 0) - return err - } - - var length uint16 - length, err = codec.DecodeUint16(bytes, 0) - o.length = int32(length) - return err -} - -func (o *ScDict) GetBytes(keyID, typeID int32) []byte { - if keyID == wasmhost.KeyLength && (o.typeID&wasmhost.OBJTYPE_ARRAY) != 0 { - return codec.EncodeInt32(o.length) - } - bytes := o.kvStore.MustGet(o.key(keyID, typeID)) - o.host.TypeCheck(typeID, bytes) - return bytes -} - -func (o *ScDict) GetObjectID(keyID, typeID int32) int32 { - o.validate(keyID, typeID) - if (typeID&wasmhost.OBJTYPE_ARRAY) == 0 && typeID != wasmhost.OBJTYPE_MAP { - o.Panicf("GetObjectID: invalid type") - } - return GetMapObjectID(o, keyID, typeID, ObjFactories{ - keyID: func() WaspObject { return &ScDict{} }, - }) -} - -func (o *ScDict) GetTypeID(keyID int32) int32 { - if (o.typeID & wasmhost.OBJTYPE_ARRAY) != 0 { - return o.typeID & wasmhost.OBJTYPE_TYPEMASK - } - // TODO incomplete, currently only contains used field types - typeID, ok := o.types[keyID] - if ok { - return typeID - } - return 0 -} - -func (o *ScDict) InvalidKey(keyID int32) { - o.Panicf("invalid key: %d", keyID) -} - -func (o *ScDict) key(keyID, typeID int32) kv.Key { - o.validate(keyID, typeID) - suffix := o.Suffix(keyID) - key := o.NestedKey() + suffix - o.Tracef("fld: %s%s", o.name, suffix) - o.Tracef("key: %s", key[1:]) - return kv.Key(key[1:]) -} - -func (o *ScDict) KvStore() kv.KVStore { - return o.kvStore -} - -func (o *ScDict) NestedKey() string { - if o.isRoot { - return "" - } - ownerObj := o.Owner() - return ownerObj.NestedKey() + ownerObj.Suffix(o.keyID) -} - -func (o *ScDict) Owner() WaspObject { - return o.host.FindObject(o.ownerID).(WaspObject) -} - -func (o *ScDict) Panicf(format string, args ...interface{}) { - o.host.Panicf(o.name+"."+format, args...) -} - -func (o *ScDict) SetBytes(keyID, typeID int32, bytes []byte) { - if keyID == wasmhost.KeyLength { - if o.kvStore != nil { - // TODO this goes wrong for state, should clear map tree instead - // o.kvStore = dict.New() - if (o.typeID & wasmhost.OBJTYPE_ARRAY) != 0 { - key := o.NestedKey()[1:] - o.kvStore.Set(kv.Key(key), codec.EncodeInt32(0)) - } - } - o.objects = make(map[int32]int32) - o.length = 0 - return - } - - key := o.key(keyID, typeID) - o.host.TypeCheck(typeID, bytes) - o.kvStore.Set(key, bytes) -} - -func (o *ScDict) Suffix(keyID int32) string { - if (o.typeID & wasmhost.OBJTYPE_ARRAY16) != 0 { - if (o.typeID & wasmhost.OBJTYPE_ARRAY16) != wasmhost.OBJTYPE_ARRAY16 { - return fmt.Sprintf(".%d", keyID) - } - - buf := make([]byte, 3) - buf[0] = '#' - binary.LittleEndian.PutUint16(buf[1:], uint16(keyID)) - return string(buf) - } - - key := o.host.GetKeyFromID(keyID) - return "." + string(key) -} - -func (o *ScDict) Tracef(format string, a ...interface{}) { - o.host.Tracef(format, a...) -} - -func (o *ScDict) validate(keyID, typeID int32) { - if o.kvStore == nil { - o.Panicf("validate: Missing kvstore") - } - if typeID == -1 { - return - } - if (o.typeID & wasmhost.OBJTYPE_ARRAY) != 0 { - // actually array - arrayTypeID := o.typeID & wasmhost.OBJTYPE_TYPEMASK - if typeID == wasmhost.OBJTYPE_BYTES { - switch arrayTypeID { - case wasmhost.OBJTYPE_ADDRESS: - case wasmhost.OBJTYPE_AGENT_ID: - case wasmhost.OBJTYPE_BYTES: - case wasmhost.OBJTYPE_COLOR: - case wasmhost.OBJTYPE_HASH: - default: - o.Panicf("validate: Invalid byte type") - } - } else if arrayTypeID != typeID { - o.Panicf("validate: Invalid type") - } - if keyID == o.length { - switch o.kvStore.(type) { - case *ScViewState: - break - default: - o.length++ - key := o.NestedKey()[1:] - o.kvStore.Set(kv.Key(key), codec.EncodeInt32(o.length)) - return - } - } - if keyID < 0 || keyID >= o.length { - o.Panicf("validate: Invalid index") - } - return - } - fieldType, ok := o.types[keyID] - if !ok { - // first encounter of this key id, register type to make - // sure that future usages are all using that same type - o.types[keyID] = typeID - return - } - if fieldType != typeID { - o.Panicf("validate: Invalid access") - } -} - -func (o *ScDict) SetKvStore(res kv.KVStore) { - o.kvStore = res - o.objects = make(map[int32]int32) - o.types = make(map[int32]int32) -} diff --git a/packages/vm/wasmproc/scexports.go b/packages/vm/wasmproc/scexports.go deleted file mode 100644 index d078a337f2..0000000000 --- a/packages/vm/wasmproc/scexports.go +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2020 IOTA Stiftung -// SPDX-License-Identifier: Apache-2.0 - -package wasmproc - -type ScExports struct { - ScSandboxObject - wc *WasmContext -} - -func NewScExports(wc *WasmContext) *ScExports { - return &ScExports{wc: wc} -} - -func (o *ScExports) SetBytes(keyID, typeID int32, bytes []byte) { - o.wc.host.SetExport(keyID, string(bytes)) -} diff --git a/packages/vm/wasmproc/scmaps.go b/packages/vm/wasmproc/scmaps.go deleted file mode 100644 index 58c9406b31..0000000000 --- a/packages/vm/wasmproc/scmaps.go +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2020 IOTA Stiftung -// SPDX-License-Identifier: Apache-2.0 - -package wasmproc - -import ( - "github.com/iotaledger/wasp/packages/kv/dict" - "github.com/iotaledger/wasp/packages/vm/wasmhost" -) - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -type ScMaps struct { - ScSandboxObject -} - -func NewScMaps(host *wasmhost.KvStoreHost) *ScMaps { - a := &ScMaps{} - a.host = host - return a -} - -func (a *ScMaps) GetObjectID(keyID, typeID int32) int32 { - return GetArrayObjectID(a, keyID, typeID, func() WaspObject { - return NewScDict(a.host, dict.New()) - }) -} diff --git a/packages/vm/wasmproc/scsandbox.go b/packages/vm/wasmproc/scsandbox.go deleted file mode 100644 index d0b7311e5a..0000000000 --- a/packages/vm/wasmproc/scsandbox.go +++ /dev/null @@ -1,30 +0,0 @@ -package wasmproc - -import ( - "github.com/iotaledger/wasp/packages/vm/wasmhost" -) - -type ScSandboxObject struct { - ScDict -} - -func (o *ScSandboxObject) DelKey(keyID, typeID int32) { - o.Panicf("DelKey: cannot delete predefined key") -} - -func (o *ScSandboxObject) GetBytes(keyID, typeID int32) []byte { - if keyID == wasmhost.KeyLength && (o.typeID&wasmhost.OBJTYPE_ARRAY) != 0 { - return o.ScDict.GetBytes(keyID, typeID) - } - o.InvalidKey(keyID) - return nil -} - -func (o *ScSandboxObject) GetObjectID(keyID, typeID int32) int32 { - o.InvalidKey(keyID) - return 0 -} - -func (o *ScSandboxObject) SetBytes(keyID, typeID int32, bytes []byte) { - o.InvalidKey(keyID) -} diff --git a/packages/vm/wasmproc/sctransfer.go b/packages/vm/wasmproc/sctransfer.go deleted file mode 100644 index 980ba13d10..0000000000 --- a/packages/vm/wasmproc/sctransfer.go +++ /dev/null @@ -1,87 +0,0 @@ -// Copyright 2020 IOTA Stiftung -// SPDX-License-Identifier: Apache-2.0 - -package wasmproc - -import ( - "github.com/iotaledger/goshimmer/packages/ledgerstate" - "github.com/iotaledger/wasp/packages/iscp/colored" - "github.com/iotaledger/wasp/packages/kv" - "github.com/iotaledger/wasp/packages/kv/codec" - "github.com/iotaledger/wasp/packages/vm/wasmhost" -) - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -type ScTransfers struct { - ScSandboxObject - wc *WasmContext -} - -func NewScTransfers(wc *WasmContext) *ScTransfers { - return &ScTransfers{wc: wc} -} - -func (a *ScTransfers) GetObjectID(keyID, typeID int32) int32 { - return GetArrayObjectID(a, keyID, typeID, func() WaspObject { - return NewScTransferInfo(a.wc) - }) -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - -type ScTransferInfo struct { - ScSandboxObject - address ledgerstate.Address - wc *WasmContext -} - -func NewScTransferInfo(wc *WasmContext) *ScTransferInfo { - return &ScTransferInfo{wc: wc} -} - -// TODO refactor -func (o *ScTransferInfo) Invoke(balances int32) { - transfer := colored.NewBalances() - balancesObj := o.host.FindObject(balances).(*ScDict) - balancesObj.kvStore.MustIterate("", func(key kv.Key, value []byte) bool { - if len(key) != ledgerstate.ColorLength { - return true - } - col, err := codec.DecodeColor([]byte(key)) - if err != nil { - o.Panicf(err.Error()) - } - amount, err := codec.DecodeUint64(value) - if err != nil { - o.Panicf(err.Error()) - } - o.Tracef("TRANSFER #%d c'%s' a'%s'", value, col.String(), o.address.Base58()) - transfer.Set(col, amount) - return true - }) - if len(transfer) != 0 { - if !o.wc.ctx.Send(o.address, transfer, nil) { - o.Panicf("failed to send to %s", o.address.Base58()) - } - } -} - -func (o *ScTransferInfo) SetBytes(keyID, typeID int32, bytes []byte) { - switch keyID { - case wasmhost.KeyAddress: - var err error - o.address, _, err = ledgerstate.AddressFromBytes(bytes) - if err != nil { - o.Panicf("SetBytes: invalid address: " + err.Error()) - } - case wasmhost.KeyBalances: - balanceMapID, err := codec.DecodeInt32(bytes, 0) - if err != nil { - o.Panicf("SetBytes: invalid balance map id: " + err.Error()) - } - o.Invoke(balanceMapID) - default: - o.InvalidKey(keyID) - } -} diff --git a/packages/vm/wasmproc/scutility.go b/packages/vm/wasmproc/scutility.go deleted file mode 100644 index 8f31e78581..0000000000 --- a/packages/vm/wasmproc/scutility.go +++ /dev/null @@ -1,121 +0,0 @@ -// Copyright 2020 IOTA Stiftung -// SPDX-License-Identifier: Apache-2.0 - -package wasmproc - -import ( - "github.com/iotaledger/wasp/packages/iscp" - "github.com/iotaledger/wasp/packages/kv/codec" - "github.com/iotaledger/wasp/packages/vm/sandbox/sandbox_utils" - "github.com/iotaledger/wasp/packages/vm/wasmhost" - "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" -) - -type ScUtility struct { - ScSandboxObject - utils iscp.Utils - wc *WasmContext -} - -func NewScUtility(wc *WasmContext, gasProcessor interface{}) *ScUtility { - //if gasProcessor == nil { - // if wc.ctx != nil { - // gasProcessor = wc.ctx.Gas() - // } else { - // gasProcessor = wc.ctxView.Gas() - // } - //} - //return &ScUtility{utils: sandbox.NewUtils(gasProcessor), wc: wc} - return &ScUtility{utils: sandbox_utils.NewUtils(), wc: wc} -} - -func (o *ScUtility) CallFunc(keyID int32, bytes []byte) []byte { - utils := o.utils - switch keyID { - case wasmhost.KeyBase58Decode: - base58Decoded, err := utils.Base58().Decode(string(bytes)) - if err != nil { - o.Panicf(err.Error()) - } - return base58Decoded - case wasmhost.KeyBase58Encode: - return []byte(utils.Base58().Encode(bytes)) - case wasmhost.KeyBlsAddress: - address, err := utils.BLS().AddressFromPublicKey(bytes) - if err != nil { - o.Panicf(err.Error()) - } - return address.Bytes() - case wasmhost.KeyBlsAggregate: - return o.aggregateBLSSignatures(bytes) - case wasmhost.KeyBlsValid: - if o.validBLSSignature(bytes) { - var flag [1]byte - return flag[:] - } - return nil - case wasmhost.KeyEd25519Address: - address, err := utils.ED25519().AddressFromPublicKey(bytes) - if err != nil { - o.Panicf(err.Error()) - } - return address.Bytes() - case wasmhost.KeyEd25519Valid: - if o.validED25519Signature(bytes) { - var flag [1]byte - return flag[:] - } - return nil - case wasmhost.KeyHashBlake2b: - return utils.Hashing().Blake2b(bytes).Bytes() - case wasmhost.KeyHashSha3: - return utils.Hashing().Sha3(bytes).Bytes() - case wasmhost.KeyHname: - return codec.EncodeHname(utils.Hashing().Hname(string(bytes))) - } - o.InvalidKey(keyID) - return nil -} - -func (o *ScUtility) Exists(keyID, typeID int32) bool { - return o.GetTypeID(keyID) > 0 -} - -func (o *ScUtility) GetTypeID(keyID int32) int32 { - return wasmhost.OBJTYPE_BYTES -} - -func (o *ScUtility) aggregateBLSSignatures(bytes []byte) []byte { - decode := wasmlib.NewBytesDecoder(bytes) - count := int(decode.Int32()) - pubKeysBin := make([][]byte, count) - for i := 0; i < count; i++ { - pubKeysBin[i] = decode.Bytes() - } - count = int(decode.Int32()) - sigsBin := make([][]byte, count) - for i := 0; i < count; i++ { - sigsBin[i] = decode.Bytes() - } - pubKeyBin, sigBin, err := o.utils.BLS().AggregateBLSSignatures(pubKeysBin, sigsBin) - if err != nil { - o.Panicf(err.Error()) - } - return wasmlib.NewBytesEncoder().Bytes(pubKeyBin).Bytes(sigBin).Data() -} - -func (o *ScUtility) validBLSSignature(bytes []byte) bool { - decode := wasmlib.NewBytesDecoder(bytes) - data := decode.Bytes() - pubKey := decode.Bytes() - signature := decode.Bytes() - return o.utils.BLS().ValidSignature(data, pubKey, signature) -} - -func (o *ScUtility) validED25519Signature(bytes []byte) bool { - decode := wasmlib.NewBytesDecoder(bytes) - data := decode.Bytes() - pubKey := decode.Bytes() - signature := decode.Bytes() - return o.utils.ED25519().ValidSignature(data, pubKey, signature) -} diff --git a/packages/vm/wasmproc/scviewstate.go b/packages/vm/wasmproc/scviewstate.go deleted file mode 100644 index bd6c0f6abe..0000000000 --- a/packages/vm/wasmproc/scviewstate.go +++ /dev/null @@ -1,76 +0,0 @@ -package wasmproc - -import ( - "github.com/iotaledger/wasp/packages/iscp" - "github.com/iotaledger/wasp/packages/kv" -) - -// ScViewState wraps immutable view state into a mutable KVStore -// with the KVWriter functions implemented as panics -// WaspLib already takes care of the immutability aspect, -// so these panics should never trigger, and we can avoid -// a much more drastic refactoring for now -type ScViewState struct { - ctxView iscp.SandboxView - viewState kv.KVStoreReader -} - -func NewScViewState(ctxView iscp.SandboxView) kv.KVStore { - return &ScViewState{ctxView: ctxView, viewState: ctxView.State()} -} - -func (s ScViewState) Set(key kv.Key, value []byte) { - s.ctxView.Log().Panicf("ScViewState.Set") -} - -func (s ScViewState) Del(key kv.Key) { - s.ctxView.Log().Panicf("ScViewState.Del") -} - -func (s ScViewState) Get(key kv.Key) ([]byte, error) { - return s.viewState.Get(key) -} - -func (s ScViewState) Has(key kv.Key) (bool, error) { - return s.viewState.Has(key) -} - -func (s ScViewState) Iterate(prefix kv.Key, f func(key kv.Key, value []byte) bool) error { - return s.viewState.Iterate(prefix, f) -} - -func (s ScViewState) IterateKeys(prefix kv.Key, f func(key kv.Key) bool) error { - return s.viewState.IterateKeys(prefix, f) -} - -func (s ScViewState) IterateSorted(prefix kv.Key, f func(key kv.Key, value []byte) bool) error { - return s.viewState.IterateSorted(prefix, f) -} - -func (s ScViewState) IterateKeysSorted(prefix kv.Key, f func(key kv.Key) bool) error { - return s.viewState.IterateKeysSorted(prefix, f) -} - -func (s ScViewState) MustGet(key kv.Key) []byte { - return s.viewState.MustGet(key) -} - -func (s ScViewState) MustHas(key kv.Key) bool { - return s.viewState.MustHas(key) -} - -func (s ScViewState) MustIterate(prefix kv.Key, f func(key kv.Key, value []byte) bool) { - s.viewState.MustIterate(prefix, f) -} - -func (s ScViewState) MustIterateKeys(prefix kv.Key, f func(key kv.Key) bool) { - s.viewState.MustIterateKeys(prefix, f) -} - -func (s ScViewState) MustIterateSorted(prefix kv.Key, f func(key kv.Key, value []byte) bool) { - s.viewState.MustIterateSorted(prefix, f) -} - -func (s ScViewState) MustIterateKeysSorted(prefix kv.Key, f func(key kv.Key) bool) { - s.viewState.MustIterateKeysSorted(prefix, f) -} diff --git a/packages/vm/wasmproc/wasmtosandbox.go b/packages/vm/wasmproc/wasmtosandbox.go deleted file mode 100644 index 7ff3d1572e..0000000000 --- a/packages/vm/wasmproc/wasmtosandbox.go +++ /dev/null @@ -1,313 +0,0 @@ -// Copyright 2020 IOTA Stiftung -// SPDX-License-Identifier: Apache-2.0 - -package wasmproc - -import ( - "time" - - "github.com/iotaledger/goshimmer/packages/ledgerstate" - "github.com/iotaledger/wasp/packages/hashing" - "github.com/iotaledger/wasp/packages/iscp" - "github.com/iotaledger/wasp/packages/iscp/colored" - "github.com/iotaledger/wasp/packages/kv/codec" - "github.com/iotaledger/wasp/packages/kv/dict" - "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" -) - -const ( - FnAccountID = int32(-1) - FnBalance = int32(-2) - FnBalances = int32(-3) - FnBlockContext = int32(-4) - FnCall = int32(-5) - FnCaller = int32(-6) - FnChainID = int32(-7) - FnChainOwnerID = int32(-8) - FnContract = int32(-9) - FnContractCreator = int32(-10) - FnDeployContract = int32(-11) - FnEntropy = int32(-12) - FnEvent = int32(-13) - FnIncomingTransfer = int32(-14) - FnLog = int32(-15) - FnMinted = int32(-16) - FnPanic = int32(-17) - FnParams = int32(-18) - FnPost = int32(-19) - FnRequest = int32(-20) - FnRequestID = int32(-21) - FnSend = int32(-22) - FnStateAnchor = int32(-23) - FnTimestamp = int32(-24) - FnTrace = int32(-25) - FnUtilsBase58Decode = int32(-26) - FnUtilsBase58Encode = int32(-27) - FnUtilsBlsAddress = int32(-28) - FnUtilsBlsAggregate = int32(-29) - FnUtilsBlsValid = int32(-30) - FnUtilsEd25519Address = int32(-31) - FnUtilsEd25519Valid = int32(-32) - FnUtilsHashBlake2b = int32(-33) - FnUtilsHashName = int32(-34) - FnUtilsHashSha3 = int32(-35) - FnZzzLastItem = int32(-36) -) - -var sandboxFunctions = [-FnZzzLastItem]func(*WasmToSandbox, []byte) []byte{ - nil, - (*WasmToSandbox).fnAccountID, - (*WasmToSandbox).fnBalance, - (*WasmToSandbox).fnBalances, - (*WasmToSandbox).fnBlockContext, - (*WasmToSandbox).fnCall, - (*WasmToSandbox).fnCaller, - (*WasmToSandbox).fnChainID, - (*WasmToSandbox).fnChainOwnerID, - (*WasmToSandbox).fnContract, - (*WasmToSandbox).fnContractCreator, - (*WasmToSandbox).fnDeployContract, - (*WasmToSandbox).fnEntropy, - (*WasmToSandbox).fnEvent, - (*WasmToSandbox).fnIncomingTransfer, - (*WasmToSandbox).fnLog, - (*WasmToSandbox).fnMinted, - (*WasmToSandbox).fnPanic, - (*WasmToSandbox).fnParams, - (*WasmToSandbox).fnPost, - (*WasmToSandbox).fnRequest, - (*WasmToSandbox).fnRequestID, - (*WasmToSandbox).fnSend, - (*WasmToSandbox).fnStateAnchor, - (*WasmToSandbox).fnTimestamp, - (*WasmToSandbox).fnTrace, - (*WasmToSandbox).fnUtilsBase58Decode, - (*WasmToSandbox).fnUtilsBase58Encode, - (*WasmToSandbox).fnUtilsBlsAddress, - (*WasmToSandbox).fnUtilsBlsAggregate, - (*WasmToSandbox).fnUtilsBlsValid, - (*WasmToSandbox).fnUtilsEd25519Address, - (*WasmToSandbox).fnUtilsEd25519Valid, - (*WasmToSandbox).fnUtilsHashBlake2b, - (*WasmToSandbox).fnUtilsHashName, - (*WasmToSandbox).fnUtilsHashSha3, -} - -type WasmToSandbox struct { - common iscp.SandboxBase - ctx iscp.Sandbox - ctxView iscp.SandboxView - wc WasmContext -} - -func (f *WasmToSandbox) Call(funcNr int32, args []byte) []byte { - return sandboxFunctions[-funcNr](f, args) -} - -func (f *WasmToSandbox) checkErr(err error) { - if err != nil { - f.Panicf(err.Error()) - } -} - -func (f *WasmToSandbox) Panicf(format string, args ...interface{}) { - f.common.Log().Panicf(format, args...) -} - -func (f *WasmToSandbox) Tracef(format string, args ...interface{}) { - f.common.Log().Debugf(format, args...) -} - -//////////////////// sandbox functions \\\\\\\\\\\\\\\\\\\\ - -func (f *WasmToSandbox) fnAccountID(args []byte) []byte { - return f.common.AccountID().Bytes() -} - -func (f *WasmToSandbox) fnBalance(args []byte) []byte { - color, err := colored.ColorFromBytes(args) - f.checkErr(err) - return codec.EncodeUint64(f.ctx.Balance(color)) -} - -func (f *WasmToSandbox) fnBalances(args []byte) []byte { - return f.common.Balances().Bytes() -} - -func (f *WasmToSandbox) fnBlockContext(args []byte) []byte { - panic("implement me") -} - -func (f *WasmToSandbox) fnCall(args []byte) []byte { - decode := wasmlib.NewBytesDecoder(args) - contract, err := iscp.HnameFromBytes(decode.Hname().Bytes()) - f.checkErr(err) - function, err := iscp.HnameFromBytes(decode.Hname().Bytes()) - f.checkErr(err) - params, err := dict.FromBytes(decode.Bytes()) - f.checkErr(err) - transfer, err := colored.BalancesFromBytes(decode.Bytes()) - f.checkErr(err) - f.Tracef("CALL c'%s' f'%s'", contract.String(), function.String()) - results, err := f.callUnlocked(contract, function, params, transfer) - f.checkErr(err) - return results.Bytes() -} - -func (f *WasmToSandbox) callUnlocked(contract, function iscp.Hname, params dict.Dict, transfer colored.Balances) (dict.Dict, error) { - f.wc.proc.instanceLock.Unlock() - defer f.wc.proc.instanceLock.Lock() - - if f.ctx != nil { - return f.ctx.Call(contract, function, params, transfer) - } - return f.ctxView.Call(contract, function, params) -} - -func (f *WasmToSandbox) fnCaller(args []byte) []byte { - return f.ctx.Caller().Bytes() -} - -func (f *WasmToSandbox) fnChainID(args []byte) []byte { - return f.common.ChainID().Bytes() -} - -func (f *WasmToSandbox) fnChainOwnerID(args []byte) []byte { - return f.common.ChainOwnerID().Bytes() -} - -func (f *WasmToSandbox) fnContract(args []byte) []byte { - return f.common.Contract().Bytes() -} - -func (f *WasmToSandbox) fnContractCreator(args []byte) []byte { - return f.common.ContractCreator().Bytes() -} - -func (f *WasmToSandbox) fnDeployContract(args []byte) []byte { - decode := wasmlib.NewBytesDecoder(args) - programHash, err := hashing.HashValueFromBytes(decode.Hash().Bytes()) - f.checkErr(err) - name := string(decode.Bytes()) - description := string(decode.Bytes()) - initParams, err := dict.FromBytes(decode.Bytes()) - f.checkErr(err) - f.Tracef("DEPLOY c'%s' f'%s'", name, description) - err = f.deployUnlocked(programHash, name, description, initParams) - f.checkErr(err) - return nil -} - -func (f *WasmToSandbox) deployUnlocked(programHash hashing.HashValue, name, description string, params dict.Dict) error { - f.wc.proc.instanceLock.Unlock() - defer f.wc.proc.instanceLock.Lock() - - return f.ctx.DeployContract(programHash, name, description, params) -} - -func (f *WasmToSandbox) fnEntropy(args []byte) []byte { - return f.ctx.GetEntropy().Bytes() -} - -func (f *WasmToSandbox) fnEvent(args []byte) []byte { - f.ctx.Event(string(args)) - return nil -} - -func (f *WasmToSandbox) fnIncomingTransfer(args []byte) []byte { - return f.ctx.IncomingTransfer().Bytes() -} - -func (f *WasmToSandbox) fnLog(args []byte) []byte { - f.common.Log().Infof(string(args)) - return nil -} - -func (f *WasmToSandbox) fnMinted(args []byte) []byte { - return f.ctx.Minted().Bytes() -} - -func (f *WasmToSandbox) fnPanic(args []byte) []byte { - f.common.Log().Panicf(string(args)) - return nil -} - -func (f *WasmToSandbox) fnParams(args []byte) []byte { - return f.common.Params().Bytes() -} - -func (f *WasmToSandbox) fnPost(args []byte) []byte { - decode := wasmlib.NewBytesDecoder(args) - chainID, err := iscp.ChainIDFromBytes(decode.ChainID().Bytes()) - f.checkErr(err) - contract, err := iscp.HnameFromBytes(decode.Hname().Bytes()) - f.checkErr(err) - function, err := iscp.HnameFromBytes(decode.Hname().Bytes()) - f.checkErr(err) - f.Tracef("POST c'%s' f'%s'", contract.String(), function.String()) - params, err := dict.FromBytes(decode.Bytes()) - f.checkErr(err) - transfer, err := colored.BalancesFromBytes(decode.Bytes()) - f.checkErr(err) - if len(transfer) == 0 { - f.Panicf("transfer is required for post") - } - metadata := &iscp.SendMetadata{ - TargetContract: contract, - EntryPoint: function, - Args: params, - } - delay := decode.Uint32() - if delay == 0 { - if !f.ctx.Send(chainID.AsAddress(), transfer, metadata) { - f.Panicf("failed to send to %s", chainID.AsAddress().String()) - } - return nil - } - - timeLock := time.Unix(0, f.ctx.GetTimestamp()) - timeLock = timeLock.Add(time.Duration(delay) * time.Second) - options := iscp.SendOptions{ - TimeLock: uint32(timeLock.Unix()), - } - if !f.ctx.Send(chainID.AsAddress(), transfer, metadata, options) { - f.Panicf("failed to send to %s", chainID.AsAddress().String()) - } - return nil -} - -func (f *WasmToSandbox) fnRequest(args []byte) []byte { - return f.ctx.Request().Bytes() -} - -func (f *WasmToSandbox) fnRequestID(args []byte) []byte { - return f.ctx.Request().ID().Bytes() -} - -// transfer tokens to address -func (f *WasmToSandbox) fnSend(args []byte) []byte { - decode := wasmlib.NewBytesDecoder(args) - address, _, err := ledgerstate.AddressFromBytes(decode.Address().Bytes()) - f.checkErr(err) - transfer, err := colored.BalancesFromBytes(decode.Bytes()) - f.checkErr(err) - if len(transfer) != 0 { - if !f.ctx.Send(address, transfer, nil) { - f.Panicf("failed to send to %s", address.String()) - } - } - return nil -} - -func (f *WasmToSandbox) fnStateAnchor(args []byte) []byte { - return nil -} - -func (f *WasmToSandbox) fnTimestamp(args []byte) []byte { - return codec.EncodeInt64(f.common.GetTimestamp()) -} - -func (f *WasmToSandbox) fnTrace(args []byte) []byte { - f.common.Log().Debugf(string(args)) - return nil -} diff --git a/packages/vm/wasmproc/wasmtosandboxutils.go b/packages/vm/wasmproc/wasmtosandboxutils.go deleted file mode 100644 index 1968fbd9d6..0000000000 --- a/packages/vm/wasmproc/wasmtosandboxutils.go +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright 2020 IOTA Stiftung -// SPDX-License-Identifier: Apache-2.0 - -package wasmproc - -import ( - "github.com/iotaledger/wasp/packages/kv/codec" - "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" -) - -func (f WasmToSandbox) fnUtilsBase58Decode(args []byte) []byte { - bytes, err := f.common.Utils().Base58().Decode(string(args)) - f.checkErr(err) - return bytes -} - -func (f WasmToSandbox) fnUtilsBase58Encode(args []byte) []byte { - return []byte(f.common.Utils().Base58().Encode(args)) -} - -func (f WasmToSandbox) fnUtilsBlsAddress(args []byte) []byte { - address, err := f.common.Utils().BLS().AddressFromPublicKey(args) - f.checkErr(err) - return address.Bytes() -} - -func (f WasmToSandbox) fnUtilsBlsAggregate(args []byte) []byte { - decode := wasmlib.NewBytesDecoder(args) - count := int(decode.Int32()) - pubKeysBin := make([][]byte, count) - for i := 0; i < count; i++ { - pubKeysBin[i] = decode.Bytes() - } - count = int(decode.Int32()) - sigsBin := make([][]byte, count) - for i := 0; i < count; i++ { - sigsBin[i] = decode.Bytes() - } - pubKeyBin, sigBin, err := f.common.Utils().BLS().AggregateBLSSignatures(pubKeysBin, sigsBin) - f.checkErr(err) - return wasmlib.NewBytesEncoder().Bytes(pubKeyBin).Bytes(sigBin).Data() -} - -func (f WasmToSandbox) fnUtilsBlsValid(args []byte) []byte { - decode := wasmlib.NewBytesDecoder(args) - data := decode.Bytes() - pubKey := decode.Bytes() - signature := decode.Bytes() - valid := f.common.Utils().BLS().ValidSignature(data, pubKey, signature) - return codec.EncodeBool(valid) -} - -func (f WasmToSandbox) fnUtilsEd25519Address(args []byte) []byte { - address, err := f.common.Utils().ED25519().AddressFromPublicKey(args) - f.checkErr(err) - return address.Bytes() -} - -func (f WasmToSandbox) fnUtilsEd25519Valid(args []byte) []byte { - decode := wasmlib.NewBytesDecoder(args) - data := decode.Bytes() - pubKey := decode.Bytes() - signature := decode.Bytes() - valid := f.common.Utils().ED25519().ValidSignature(data, pubKey, signature) - return codec.EncodeBool(valid) -} - -func (f WasmToSandbox) fnUtilsHashBlake2b(args []byte) []byte { - return f.common.Utils().Hashing().Blake2b(args).Bytes() -} - -func (f WasmToSandbox) fnUtilsHashName(args []byte) []byte { - return codec.EncodeHname(f.common.Utils().Hashing().Hname(string(args))) -} - -func (f WasmToSandbox) fnUtilsHashSha3(args []byte) []byte { - return f.common.Utils().Hashing().Sha3(args).Bytes() -} diff --git a/packages/vm/wasmsolo/soloagent.go b/packages/vm/wasmsolo/soloagent.go index a535009f3e..f3ecd28431 100644 --- a/packages/vm/wasmsolo/soloagent.go +++ b/packages/vm/wasmsolo/soloagent.go @@ -9,7 +9,7 @@ import ( "github.com/iotaledger/wasp/packages/iscp" "github.com/iotaledger/wasp/packages/iscp/colored" "github.com/iotaledger/wasp/packages/solo" - "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" + "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" "github.com/stretchr/testify/require" ) @@ -26,15 +26,15 @@ func NewSoloAgent(env *solo.Solo) *SoloAgent { return agent } -func (a *SoloAgent) ScAddress() wasmlib.ScAddress { - return wasmlib.NewScAddressFromBytes(a.address.Bytes()) +func (a *SoloAgent) ScAddress() wasmtypes.ScAddress { + return wasmtypes.AddressFromBytes(a.address.Bytes()) } -func (a *SoloAgent) ScAgentID() wasmlib.ScAgentID { - return wasmlib.NewScAgentID(a.ScAddress(), wasmlib.ScHname(a.hname)) +func (a *SoloAgent) ScAgentID() wasmtypes.ScAgentID { + return wasmtypes.NewScAgentID(a.ScAddress(), wasmtypes.ScHname(a.hname)) } -func (a *SoloAgent) Balance(color ...wasmlib.ScColor) int64 { +func (a *SoloAgent) Balance(color ...wasmtypes.ScColor) int64 { switch len(color) { case 0: return int64(a.Env.GetAddressBalance(a.address, colored.IOTA)) @@ -48,7 +48,7 @@ func (a *SoloAgent) Balance(color ...wasmlib.ScColor) int64 { } } -func (a *SoloAgent) Mint(amount int64) (wasmlib.ScColor, error) { +func (a *SoloAgent) Mint(amount int64) (wasmtypes.ScColor, error) { color, err := a.Env.MintTokens(a.Pair, uint64(amount)) - return wasmlib.NewScColorFromBytes(color.Bytes()), err + return wasmtypes.ColorFromBytes(color.Bytes()), err } diff --git a/packages/vm/wasmsolo/solocontext.go b/packages/vm/wasmsolo/solocontext.go index 479ce39b22..68819031b2 100644 --- a/packages/vm/wasmsolo/solocontext.go +++ b/packages/vm/wasmsolo/solocontext.go @@ -19,18 +19,18 @@ import ( "github.com/iotaledger/wasp/packages/util" "github.com/iotaledger/wasp/packages/vm/wasmhost" "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" - "github.com/iotaledger/wasp/packages/vm/wasmproc" + "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" "github.com/stretchr/testify/require" ) const ( - SoloDebug = false - SoloHostTracing = false - SoloStackTracing = false + SoloDebug = true + SoloHostTracing = true + SoloStackTracing = true ) -var ( - GoDebug = flag.Bool("godebug", false, "debug go smart contract code") +var ( // TODO set back to false + GoDebug = flag.Bool("godebug", true, "debug go smart contract code") GoWasm = flag.Bool("gowasm", false, "prefer go wasm smart contract code") GoWasmEdge = flag.Bool("gowasmedge", false, "use WasmEdge instead of WasmTime") TsWasm = flag.Bool("tswasm", false, "prefer typescript wasm smart contract code") @@ -48,7 +48,7 @@ type SoloContext struct { offLedger bool scName string Tx *ledgerstate.Transaction - wc *wasmproc.WasmContext + wc *wasmhost.WasmContext wasmHostOld wasmlib.ScHost } @@ -111,7 +111,7 @@ func NewSoloContextForChain(t *testing.T, chain *solo.Chain, creator *SoloAgent, params = init[0].Params() } if *GoDebug { - wasmproc.GoWasmVM = func() wasmhost.WasmVM { + wasmhost.GoWasmVM = func() wasmhost.WasmVM { return wasmhost.NewWasmGoVM(ctx.scName, onLoad) } } @@ -121,7 +121,7 @@ func NewSoloContextForChain(t *testing.T, chain *solo.Chain, creator *SoloAgent, ctx.Err = ctx.Chain.DeployContract(keyPair, ctx.scName, ctx.Hprog, params...) if *GoDebug { // just in case deploy failed we don't want to leave this around - wasmproc.GoWasmVM = nil + wasmhost.GoWasmVM = nil } if ctx.Err != nil { return ctx @@ -197,7 +197,7 @@ func (ctx *SoloContext) Account() *SoloAgent { } } -func (ctx *SoloContext) AccountID() wasmlib.ScAgentID { +func (ctx *SoloContext) AccountID() wasmtypes.ScAgentID { return ctx.Account().ScAgentID() } @@ -209,31 +209,31 @@ func (ctx *SoloContext) AdvanceClockBy(step time.Duration) { // Balance returns the account balance of the specified agent on the chain associated with ctx. // The optional color parameter can be used to retrieve the balance for the specific color. // When color is omitted, wasmlib.IOTA is assumed. -func (ctx *SoloContext) Balance(agent *SoloAgent, color ...wasmlib.ScColor) int64 { +func (ctx *SoloContext) Balance(agent *SoloAgent, color ...wasmtypes.ScColor) uint64 { account := iscp.NewAgentID(agent.address, agent.hname) balances := ctx.Chain.GetAccountBalance(account) switch len(color) { case 0: - return int64(balances.Get(colored.IOTA)) + return balances.Get(colored.IOTA) case 1: col, err := colored.ColorFromBytes(color[0].Bytes()) require.NoError(ctx.Chain.Env.T, err) - return int64(balances.Get(col)) + return balances.Get(col) default: require.Fail(ctx.Chain.Env.T, "too many color arguments") return 0 } } -func (ctx *SoloContext) ChainID() wasmlib.ScChainID { +func (ctx *SoloContext) ChainID() wasmtypes.ScChainID { return ctx.Convertor.ScChainID(ctx.Chain.ChainID) } -func (ctx *SoloContext) ChainOwnerID() wasmlib.ScAgentID { +func (ctx *SoloContext) ChainOwnerID() wasmtypes.ScAgentID { return ctx.Convertor.ScAgentID(ctx.Chain.OriginatorAgentID) } -func (ctx *SoloContext) ContractCreator() wasmlib.ScAgentID { +func (ctx *SoloContext) ContractCreator() wasmtypes.ScAgentID { return ctx.Creator().ScAgentID() } @@ -261,10 +261,7 @@ func (ctx *SoloContext) Host() wasmlib.ScHost { // init further initializes the SoloContext. func (ctx *SoloContext) init(onLoad func()) *SoloContext { - ctx.wc = wasmproc.NewWasmContext("-solo", nil) - ctx.wc.Init(nil) - ctx.wc.TrackObject(wasmproc.NewNullObject(&ctx.wc.KvStoreHost)) - ctx.wc.TrackObject(NewSoloScContext(ctx)) + ctx.wc = wasmhost.NewWasmMiniContext("-solo-", NewSoloSandbox(ctx)) ctx.wasmHostOld = wasmhost.Connect(ctx.wc) onLoad() return ctx @@ -281,12 +278,12 @@ func (ctx *SoloContext) InitViewCallContext() { } // Minted returns the color and amount of newly minted tokens -func (ctx *SoloContext) Minted() (wasmlib.ScColor, uint64) { +func (ctx *SoloContext) Minted() (wasmtypes.ScColor, uint64) { t := ctx.Chain.Env.T t.Logf("minting request tx: %s", ctx.Tx.ID().Base58()) mintedAmounts := colored.BalancesFromL1Map(utxoutil.GetMintedAmounts(ctx.Tx)) require.Len(t, mintedAmounts, 1) - var mintedColor wasmlib.ScColor + var mintedColor wasmtypes.ScColor var mintedAmount uint64 for c := range mintedAmounts { mintedColor = ctx.Convertor.ScColor(c) diff --git a/packages/vm/wasmsolo/soloconvertor.go b/packages/vm/wasmsolo/soloconvertor.go index 2225226751..f7cfbc9432 100644 --- a/packages/vm/wasmsolo/soloconvertor.go +++ b/packages/vm/wasmsolo/soloconvertor.go @@ -5,36 +5,36 @@ import ( "github.com/iotaledger/wasp/packages/hashing" "github.com/iotaledger/wasp/packages/iscp" "github.com/iotaledger/wasp/packages/iscp/colored" - "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" + "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" ) // SoloConvertor converts ISCP data types to WasmLib data types type SoloConvertor struct{} -func (cvt SoloConvertor) ScAddress(address ledgerstate.Address) wasmlib.ScAddress { - return wasmlib.NewScAddressFromBytes(address.Bytes()) +func (cvt SoloConvertor) ScAddress(address ledgerstate.Address) wasmtypes.ScAddress { + return wasmtypes.AddressFromBytes(address.Bytes()) } -func (cvt SoloConvertor) ScAgentID(agentID *iscp.AgentID) wasmlib.ScAgentID { - return wasmlib.NewScAgentIDFromBytes(agentID.Bytes()) +func (cvt SoloConvertor) ScAgentID(agentID *iscp.AgentID) wasmtypes.ScAgentID { + return wasmtypes.AgentIDFromBytes(agentID.Bytes()) } -func (cvt SoloConvertor) ScChainID(chainID *iscp.ChainID) wasmlib.ScChainID { - return wasmlib.NewScChainIDFromBytes(chainID.Bytes()) +func (cvt SoloConvertor) ScChainID(chainID *iscp.ChainID) wasmtypes.ScChainID { + return wasmtypes.ChainIDFromBytes(chainID.Bytes()) } -func (cvt SoloConvertor) ScColor(color colored.Color) wasmlib.ScColor { - return wasmlib.NewScColorFromBytes(color.Bytes()) +func (cvt SoloConvertor) ScColor(color colored.Color) wasmtypes.ScColor { + return wasmtypes.ColorFromBytes(color.Bytes()) } -func (cvt SoloConvertor) ScHash(hash hashing.HashValue) wasmlib.ScHash { - return wasmlib.NewScHashFromBytes(hash.Bytes()) +func (cvt SoloConvertor) ScHash(hash hashing.HashValue) wasmtypes.ScHash { + return wasmtypes.HashFromBytes(hash.Bytes()) } -func (cvt SoloConvertor) ScHname(hname iscp.Hname) wasmlib.ScHname { - return wasmlib.NewScHnameFromBytes(hname.Bytes()) +func (cvt SoloConvertor) ScHname(hname iscp.Hname) wasmtypes.ScHname { + return wasmtypes.HnameFromBytes(hname.Bytes()) } -func (cvt SoloConvertor) ScRequestID(requestID iscp.RequestID) wasmlib.ScRequestID { - return wasmlib.NewScRequestIDFromBytes(requestID.Bytes()) +func (cvt SoloConvertor) ScRequestID(requestID iscp.RequestID) wasmtypes.ScRequestID { + return wasmtypes.RequestIDFromBytes(requestID.Bytes()) } diff --git a/packages/vm/wasmsolo/solosandbox.go b/packages/vm/wasmsolo/solosandbox.go new file mode 100644 index 0000000000..44121be46a --- /dev/null +++ b/packages/vm/wasmsolo/solosandbox.go @@ -0,0 +1,274 @@ +package wasmsolo + +import ( + "bytes" + "time" + + "github.com/iotaledger/wasp/packages/iscp" + "github.com/iotaledger/wasp/packages/iscp/colored" + "github.com/iotaledger/wasp/packages/kv/codec" + "github.com/iotaledger/wasp/packages/kv/dict" + "github.com/iotaledger/wasp/packages/solo" + "github.com/iotaledger/wasp/packages/vm/sandbox/sandbox_utils" + "github.com/iotaledger/wasp/packages/vm/wasmhost" + "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmrequests" + "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" +) + +// NOTE: These functions correspond to the Sandbox fnXxx constants in WasmLib +var sandboxFunctions = []func(*SoloSandbox, []byte) []byte{ + nil, + (*SoloSandbox).fnAccountID, + (*SoloSandbox).fnBalance, + (*SoloSandbox).fnBalances, + (*SoloSandbox).fnBlockContext, + (*SoloSandbox).fnCall, + (*SoloSandbox).fnCaller, + (*SoloSandbox).fnChainID, + (*SoloSandbox).fnChainOwnerID, + (*SoloSandbox).fnContract, + (*SoloSandbox).fnContractCreator, + (*SoloSandbox).fnDeployContract, + (*SoloSandbox).fnEntropy, + (*SoloSandbox).fnEvent, + (*SoloSandbox).fnIncomingTransfer, + (*SoloSandbox).fnLog, + (*SoloSandbox).fnMinted, + (*SoloSandbox).fnPanic, + (*SoloSandbox).fnParams, + (*SoloSandbox).fnPost, + (*SoloSandbox).fnRequest, + (*SoloSandbox).fnRequestID, + (*SoloSandbox).fnSend, + (*SoloSandbox).fnStateAnchor, + (*SoloSandbox).fnTimestamp, + (*SoloSandbox).fnTrace, + (*SoloSandbox).fnUtilsBase58Decode, + (*SoloSandbox).fnUtilsBase58Encode, + (*SoloSandbox).fnUtilsBlsAddress, + (*SoloSandbox).fnUtilsBlsAggregate, + (*SoloSandbox).fnUtilsBlsValid, + (*SoloSandbox).fnUtilsEd25519Address, + (*SoloSandbox).fnUtilsEd25519Valid, + (*SoloSandbox).fnUtilsHashBlake2b, + (*SoloSandbox).fnUtilsHashName, + (*SoloSandbox).fnUtilsHashSha3, +} + +type SoloSandbox struct { + ctx *SoloContext + utils iscp.Utils +} + +var _ wasmhost.ISandbox = new(SoloSandbox) + +func NewSoloSandbox(ctx *SoloContext) *SoloSandbox { + return &SoloSandbox{ctx: ctx, utils: sandbox_utils.NewUtils()} +} + +func (s *SoloSandbox) Call(funcNr int32, params []byte) []byte { + return sandboxFunctions[-funcNr](s, params) +} + +func (s *SoloSandbox) checkErr(err error) { + if err != nil { + panic(err.Error()) + } +} + +func (s *SoloSandbox) Panicf(format string, args ...interface{}) { + s.ctx.Chain.Log.Panicf(format, args...) +} + +func (s *SoloSandbox) Tracef(format string, args ...interface{}) { + s.ctx.Chain.Log.Debugf(format, args...) +} + +func (s *SoloSandbox) postSync(contract, function string, params dict.Dict, transfer colored.Balances) []byte { + req := solo.NewCallParamsFromDic(contract, function, params) + req.WithTransfers(transfer) + ctx := s.ctx + _ = wasmhost.Connect(ctx.wasmHostOld) + var res dict.Dict + if ctx.offLedger { + ctx.offLedger = false + res, ctx.Err = ctx.Chain.PostRequestOffLedger(req, ctx.keyPair) + } else if !ctx.isRequest { + ctx.Tx, res, ctx.Err = ctx.Chain.PostRequestSyncTx(req, ctx.keyPair) + } else { + ctx.isRequest = false + ctx.Tx, _, ctx.Err = ctx.Chain.RequestFromParamsToLedger(req, nil) + if ctx.Err == nil { + ctx.Chain.Env.EnqueueRequests(ctx.Tx) + } + } + _ = wasmhost.Connect(ctx.wc) + if ctx.Err != nil { + return nil + } + return res.Bytes() +} + +//////////////////// sandbox functions \\\\\\\\\\\\\\\\\\\\ + +func (s *SoloSandbox) fnAccountID(args []byte) []byte { + return s.ctx.AccountID().Bytes() +} + +func (s *SoloSandbox) fnBalance(args []byte) []byte { + color := wasmtypes.ColorFromBytes(args) + return codec.EncodeUint64(s.ctx.Balance(s.ctx.Account(), color)) +} + +func (s *SoloSandbox) fnBalances(args []byte) []byte { + agent := s.ctx.Account() + account := iscp.NewAgentID(agent.address, agent.hname) + balances := s.ctx.Chain.GetAccountBalance(account) + return balances.Bytes() +} + +func (s *SoloSandbox) fnBlockContext(args []byte) []byte { + panic("implement me") +} + +func (s *SoloSandbox) fnCall(args []byte) []byte { + req := wasmrequests.NewCallRequestFromBytes(args) + contract, err := iscp.HnameFromBytes(req.Contract.Bytes()) + s.checkErr(err) + if contract != iscp.Hn(s.ctx.scName) { + s.Panicf("unknown contract: %s", contract.String()) + } + function, err := iscp.HnameFromBytes(req.Function.Bytes()) + s.checkErr(err) + funcName := s.ctx.wc.Host().FunctionFromCode(uint32(function)) + if funcName == "" { + s.Panicf("unknown function: %s", function.String()) + } + s.Tracef("CALL c'%s' f'%s'", s.ctx.scName, funcName) + params, err := dict.FromBytes(req.Params) + s.checkErr(err) + transfer, err := colored.BalancesFromBytes(req.Transfer) + s.checkErr(err) + + if len(transfer) != 0 { + return s.postSync(s.ctx.scName, funcName, params, transfer) + } + + res, err := s.ctx.Chain.CallView(s.ctx.scName, funcName, params) + if err != nil { + s.Panicf(err.Error()) + } + return res.Bytes() +} + +func (s *SoloSandbox) fnCaller(args []byte) []byte { + return s.ctx.Chain.OriginatorAgentID.Bytes() +} + +func (s *SoloSandbox) fnChainID(args []byte) []byte { + return s.ctx.ChainID().Bytes() +} + +func (s *SoloSandbox) fnChainOwnerID(args []byte) []byte { + return s.ctx.ChainOwnerID().Bytes() +} + +func (s *SoloSandbox) fnContract(args []byte) []byte { + return s.ctx.Account().hname.Bytes() +} + +func (s *SoloSandbox) fnContractCreator(args []byte) []byte { + return s.ctx.ContractCreator().Bytes() +} + +func (s *SoloSandbox) fnDeployContract(args []byte) []byte { + panic("implement me") +} + +func (s *SoloSandbox) fnEntropy(args []byte) []byte { + return s.ctx.Chain.ChainID.Bytes()[1:] +} + +func (s *SoloSandbox) fnEvent(args []byte) []byte { + s.Panicf("solo cannot send events") + return nil +} + +func (s *SoloSandbox) fnIncomingTransfer(args []byte) []byte { + // zero incoming balance + return colored.NewBalances().Bytes() +} + +func (s *SoloSandbox) fnLog(args []byte) []byte { + s.ctx.Chain.Log.Infof(string(args)) + return nil +} + +func (s *SoloSandbox) fnMinted(args []byte) []byte { + panic("implement me") +} + +func (s *SoloSandbox) fnPanic(args []byte) []byte { + s.ctx.Chain.Log.Panicf(string(args)) + return nil +} + +func (s *SoloSandbox) fnParams(args []byte) []byte { + return make(dict.Dict).Bytes() +} + +func (s *SoloSandbox) fnPost(args []byte) []byte { + req := wasmrequests.NewPostRequestFromBytes(args) + if !bytes.Equal(req.ChainID.Bytes(), s.fnChainID(nil)) { + s.Panicf("unknown chain id: %s", req.ChainID.String()) + } + contract, err := iscp.HnameFromBytes(req.Contract.Bytes()) + s.checkErr(err) + if contract != iscp.Hn(s.ctx.scName) { + s.Panicf("unknown contract: %s", contract.String()) + } + function, err := iscp.HnameFromBytes(req.Function.Bytes()) + s.checkErr(err) + funcName := s.ctx.wc.Host().FunctionFromCode(uint32(function)) + if funcName == "" { + s.Panicf("unknown function: %s", function.String()) + } + s.Tracef("POST c'%s' f'%s'", s.ctx.scName, funcName) + params, err := dict.FromBytes(req.Params) + s.checkErr(err) + transfer, err := colored.BalancesFromBytes(req.Transfer) + s.checkErr(err) + if len(transfer) == 0 { + s.Panicf("transfer is required for post") + } + if req.Delay != 0 { + s.Panicf("cannot delay solo post") + } + return s.postSync(s.ctx.scName, funcName, params, transfer) +} + +func (s *SoloSandbox) fnRequest(args []byte) []byte { + panic("implement me") +} + +func (s *SoloSandbox) fnRequestID(args []byte) []byte { + return append(s.ctx.Chain.ChainID.Bytes()[1:], 0, 0) +} + +// transfer tokens to address +func (s *SoloSandbox) fnSend(args []byte) []byte { + panic("implement me") +} + +func (s *SoloSandbox) fnStateAnchor(args []byte) []byte { + panic("implement me") +} + +func (s *SoloSandbox) fnTimestamp(args []byte) []byte { + return codec.EncodeInt64(time.Now().UnixNano()) +} + +func (s *SoloSandbox) fnTrace(args []byte) []byte { + s.ctx.Chain.Log.Debugf(string(args)) + return nil +} diff --git a/packages/vm/wasmsolo/solosandboxutils.go b/packages/vm/wasmsolo/solosandboxutils.go new file mode 100644 index 0000000000..3d0492d7a0 --- /dev/null +++ b/packages/vm/wasmsolo/solosandboxutils.go @@ -0,0 +1,79 @@ +// Copyright 2020 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +package wasmsolo + +import ( + "github.com/iotaledger/wasp/packages/kv/codec" + "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmcodec" + "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" +) + +func (s *SoloSandbox) fnUtilsBase58Decode(args []byte) []byte { + bytes, err := s.utils.Base58().Decode(string(args)) + s.checkErr(err) + return bytes +} + +func (s *SoloSandbox) fnUtilsBase58Encode(args []byte) []byte { + return []byte(s.utils.Base58().Encode(args)) +} + +func (s *SoloSandbox) fnUtilsBlsAddress(args []byte) []byte { + address, err := s.utils.BLS().AddressFromPublicKey(args) + s.checkErr(err) + return address.Bytes() +} + +func (s *SoloSandbox) fnUtilsBlsAggregate(args []byte) []byte { + dec := wasmcodec.NewWasmDecoder(args) + count := int(wasmtypes.DecodeUint32(dec)) + pubKeysBin := make([][]byte, count) + for i := 0; i < count; i++ { + pubKeysBin[i] = dec.Bytes() + } + count = int(wasmtypes.DecodeUint32(dec)) + sigsBin := make([][]byte, count) + for i := 0; i < count; i++ { + sigsBin[i] = dec.Bytes() + } + pubKeyBin, sigBin, err := s.utils.BLS().AggregateBLSSignatures(pubKeysBin, sigsBin) + s.checkErr(err) + return wasmcodec.NewWasmEncoder().Bytes(pubKeyBin).Bytes(sigBin).Buf() +} + +func (s *SoloSandbox) fnUtilsBlsValid(args []byte) []byte { + dec := wasmcodec.NewWasmDecoder(args) + data := dec.Bytes() + pubKey := dec.Bytes() + signature := dec.Bytes() + valid := s.utils.BLS().ValidSignature(data, pubKey, signature) + return codec.EncodeBool(valid) +} + +func (s *SoloSandbox) fnUtilsEd25519Address(args []byte) []byte { + address, err := s.utils.ED25519().AddressFromPublicKey(args) + s.checkErr(err) + return address.Bytes() +} + +func (s *SoloSandbox) fnUtilsEd25519Valid(args []byte) []byte { + dec := wasmcodec.NewWasmDecoder(args) + data := dec.Bytes() + pubKey := dec.Bytes() + signature := dec.Bytes() + valid := s.utils.ED25519().ValidSignature(data, pubKey, signature) + return codec.EncodeBool(valid) +} + +func (s *SoloSandbox) fnUtilsHashBlake2b(args []byte) []byte { + return s.utils.Hashing().Blake2b(args).Bytes() +} + +func (s *SoloSandbox) fnUtilsHashName(args []byte) []byte { + return codec.EncodeHname(s.utils.Hashing().Hname(string(args))) +} + +func (s *SoloSandbox) fnUtilsHashSha3(args []byte) []byte { + return s.utils.Hashing().Sha3(args).Bytes() +} diff --git a/packages/vm/wasmsolo/solosccontext.go b/packages/vm/wasmsolo/solosccontext.go deleted file mode 100644 index b976ad334d..0000000000 --- a/packages/vm/wasmsolo/solosccontext.go +++ /dev/null @@ -1,235 +0,0 @@ -// Copyright 2020 IOTA Stiftung -// SPDX-License-Identifier: Apache-2.0 - -package wasmsolo - -import ( - "github.com/iotaledger/goshimmer/packages/ledgerstate" - "github.com/iotaledger/wasp/packages/iscp" - "github.com/iotaledger/wasp/packages/iscp/colored" - "github.com/iotaledger/wasp/packages/kv" - "github.com/iotaledger/wasp/packages/kv/codec" - "github.com/iotaledger/wasp/packages/kv/dict" - "github.com/iotaledger/wasp/packages/solo" - "github.com/iotaledger/wasp/packages/vm/wasmhost" - "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" - "github.com/iotaledger/wasp/packages/vm/wasmproc" -) - -type SoloScContext struct { - wasmproc.ScContext - ctx *SoloContext -} - -func NewSoloScContext(ctx *SoloContext) *SoloScContext { - return &SoloScContext{ScContext: *wasmproc.NewScContext(nil, &ctx.wc.KvStoreHost), ctx: ctx} -} - -func (o *SoloScContext) Exists(keyID, typeID int32) bool { - return o.GetTypeID(keyID) > 0 -} - -func (o *SoloScContext) GetBytes(keyID, typeID int32) []byte { - switch keyID { - case wasmhost.KeyChainID: - return o.ctx.Chain.ChainID.Bytes() - default: - o.InvalidKey(keyID) - return nil - } -} - -func (o *SoloScContext) GetObjectID(keyID, typeID int32) int32 { - host := o.ctx.wc - return wasmproc.GetMapObjectID(o, keyID, typeID, wasmproc.ObjFactories{ - // wasmhost.KeyBalances: func() wasmproc.WaspObject { return wasmproc.NewScBalances(o.vm, keyID) }, - wasmhost.KeyExports: func() wasmproc.WaspObject { return wasmproc.NewScExports(host) }, - // wasmhost.KeyIncoming: func() wasmproc.WaspObject { return wasmproc.NewScBalances(o.vm, keyID) }, - wasmhost.KeyMaps: func() wasmproc.WaspObject { return wasmproc.NewScMaps(&host.KvStoreHost) }, - // wasmhost.KeyMinted: func() wasmproc.WaspObject { return wasmproc.NewScBalances(o.vm, keyID) }, - // wasmhost.KeyParams: func() wasmproc.WaspObject { return wasmproc.NewScDict(o.host, o.vm.params()) }, - wasmhost.KeyResults: func() wasmproc.WaspObject { return wasmproc.NewScDict(&host.KvStoreHost, dict.New()) }, - wasmhost.KeyReturn: func() wasmproc.WaspObject { return wasmproc.NewScDict(&host.KvStoreHost, dict.New()) }, - // wasmhost.KeyState: func() wasmproc.WaspObject { return wasmproc.NewScDict(o.host, o.vm.state()) }, - // wasmhost.KeyTransfers: func() wasmproc.WaspObject { return wasmproc.NewScTransfers(o.vm) }, - wasmhost.KeyUtility: func() wasmproc.WaspObject { return wasmproc.NewScUtility(nil, o.ctx) }, - }) -} - -func (o *SoloScContext) SetBytes(keyID, typeID int32, bytes []byte) { - switch keyID { - case wasmhost.KeyCall: - o.processCall(bytes) - case wasmhost.KeyPost: - o.processPost(bytes) - case wasmhost.KeyLog: - o.ctx.Chain.Log.Infof(string(bytes)) - case wasmhost.KeyTrace: - o.ctx.Chain.Log.Debugf(string(bytes)) - default: - o.ScContext.SetBytes(keyID, typeID, bytes) - } -} - -func (o *SoloScContext) processCall(bytes []byte) { - decode := wasmlib.NewBytesDecoder(bytes) - contract, err := iscp.HnameFromBytes(decode.Hname().Bytes()) - if err != nil { - o.Panicf(err.Error()) - } - function, err := iscp.HnameFromBytes(decode.Hname().Bytes()) - if err != nil { - o.Panicf(err.Error()) - } - paramsID := decode.Int32() - transferID := decode.Int32() - if transferID != 0 { - o.postSync(contract, function, paramsID, transferID, 0) - return - } - - ctx := o.ctx - funcName := ctx.wc.FunctionFromCode(uint32(function)) - if funcName == "" { - o.Panicf("unknown function") - } - o.Tracef("CALL %s.%s", ctx.scName, funcName) - params := o.getParams(paramsID) - _ = wasmhost.Connect(ctx.wasmHostOld) - res, err := ctx.Chain.CallView(ctx.scName, funcName, params) - _ = wasmhost.Connect(ctx.wc) - ctx.Err = err - if err != nil { - // o.Panicf("failed to invoke call: " + err.Error()) - return - } - returnID := o.GetObjectID(wasmhost.KeyReturn, wasmhost.OBJTYPE_MAP) - ctx.wc.FindObject(returnID).(*wasmproc.ScDict).SetKvStore(res) -} - -func (o *SoloScContext) processPost(bytes []byte) { - decode := wasmlib.NewBytesDecoder(bytes) - chainID, err := iscp.ChainIDFromBytes(decode.ChainID().Bytes()) - if err != nil { - o.Panicf(err.Error()) - } - if !chainID.Equals(o.ctx.Chain.ChainID) { - o.Panicf("invalid chainID") - } - contract, err := iscp.HnameFromBytes(decode.Hname().Bytes()) - if err != nil { - o.Panicf(err.Error()) - } - function, err := iscp.HnameFromBytes(decode.Hname().Bytes()) - if err != nil { - o.Panicf(err.Error()) - } - paramsID := decode.Int32() - transferID := decode.Int32() - delay := decode.Int32() - o.postSync(contract, function, paramsID, transferID, delay) - //metadata := &iscp.SendMetadata{ - // TargetContract: contract, - // EntryPoint: function, - // Args: params, - //} - //delay := decode.Int32() - //if delay == 0 { - // if !o.vm.ctx.Send(chainID.AsAddress(), transfer, metadata) { - // o.Panicf("failed to send to %s", chainID.AsAddress().String()) - // } - // return - //} - // - //if delay < -1 { - // o.Panicf("invalid delay: %d", delay) - //} - // - //timeLock := time.Unix(0, o.vm.ctx.GetTimestamp()) - //timeLock = timeLock.Add(time.Duration(delay) * time.Second) - //options := iscp.SendOptions{ - // TimeLock: uint32(timeLock.Unix()), - //} - //if !o.vm.ctx.Send(chainID.AsAddress(), transfer, metadata, options) { - // o.Panicf("failed to send to %s", chainID.AsAddress().String()) - //} -} - -func (o *SoloScContext) getParams(paramsID int32) dict.Dict { - if paramsID == 0 { - return dict.New() - } - params := o.ctx.wc.FindObject(paramsID).(*wasmproc.ScDict).KvStore().(dict.Dict) - params.MustIterate("", func(key kv.Key, value []byte) bool { - o.Tracef(" PARAM '%s'", key) - return true - }) - return params -} - -func (o *SoloScContext) getTransfer(transferID int32) colored.Balances { - if transferID == 0 { - return colored.NewBalances() - } - transfer := colored.NewBalances() - transferDict := o.ctx.wc.FindObject(transferID).(*wasmproc.ScDict).KvStore() - transferDict.MustIterate("", func(key kv.Key, value []byte) bool { - color, err := codec.DecodeColor([]byte(key)) - if err != nil { - o.Panicf(err.Error()) - } - amount, err := codec.DecodeUint64(value) - if err != nil { - o.Panicf(err.Error()) - } - o.Tracef(" XFER %d '%s'", amount, color.String()) - transfer[color] = amount - return true - }) - return transfer -} - -func (o *SoloScContext) postSync(contract, function iscp.Hname, paramsID, transferID, delay int32) { - if delay != 0 { - o.Panicf("unsupported nonzero delay for SoloContext") - } - ctx := o.ctx - if contract != iscp.Hn(ctx.scName) { - o.Panicf("invalid contract") - } - funcName := ctx.wc.FunctionFromCode(uint32(function)) - if funcName == "" { - o.Panicf("unknown function") - } - o.Tracef("POST %s.%s", ctx.scName, funcName) - params := o.getParams(paramsID) - req := solo.NewCallParamsFromDic(ctx.scName, funcName, params) - if transferID != 0 { - transfer := o.getTransfer(transferID) - req.WithTransfers(transfer) - } - if ctx.mint > 0 { - mintAddress := ledgerstate.NewED25519Address(ctx.keyPair.PublicKey) - req.WithMint(mintAddress, ctx.mint) - } - _ = wasmhost.Connect(ctx.wasmHostOld) - var res dict.Dict - if ctx.offLedger { - ctx.offLedger = false - res, ctx.Err = ctx.Chain.PostRequestOffLedger(req, ctx.keyPair) - } else if !ctx.isRequest { - ctx.Tx, res, ctx.Err = ctx.Chain.PostRequestSyncTx(req, ctx.keyPair) - } else { - ctx.isRequest = false - ctx.Tx, _, ctx.Err = ctx.Chain.RequestFromParamsToLedger(req, nil) - if ctx.Err == nil { - ctx.Chain.Env.EnqueueRequests(ctx.Tx) - } - } - _ = wasmhost.Connect(ctx.wc) - if ctx.Err != nil { - return - } - returnID := o.GetObjectID(wasmhost.KeyReturn, wasmhost.OBJTYPE_MAP) - ctx.wc.FindObject(returnID).(*wasmproc.ScDict).SetKvStore(res) -} diff --git a/packages/vm/wasmvmhost/host.go b/packages/vm/wasmvmhost/host.go index d0be1e756d..1dfb72764b 100644 --- a/packages/vm/wasmvmhost/host.go +++ b/packages/vm/wasmvmhost/host.go @@ -1,29 +1,13 @@ // Copyright 2020 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 -//go:build wasm +// go:build wasm // +build wasm package wasmvmhost import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" -//go:wasm-module WasmLib -//export hostGetBytes -func hostGetBytes(objID, keyID, typeID int32, value *byte, size int32) int32 - -//go:wasm-module WasmLib -//export hostGetKeyID -func hostGetKeyID(key *byte, size int32) int32 - -//go:wasm-module WasmLib -//export hostGetObjectID -func hostGetObjectID(objID, keyID, typeID int32) int32 - -//go:wasm-module WasmLib -//export hostSetBytes -func hostSetBytes(objID, keyID, typeID int32, value *byte, size int32) - // new Wasm VM //go:wasm-module WasmLib @@ -73,88 +57,13 @@ func (w *WasmVMHost) ConnectWasmHost() { wasmlib.ConnectHost(w) } -func (w *WasmVMHost) CallFunc(objID, keyID int32, params []byte) []byte { - // pass params and query expected length of result - size := hostGetBytes(objID, keyID, wasmlib.TYPE_CALL, ptr(params), int32(len(params))) - - // -1 means non-existent, so return default value for type - if size <= 0 { - return []byte(nil) - } - - // allocate a sufficient length byte array in Wasm memory - // and let the host copy the actual result into this Wasm byte array - result := make([]byte, size) - hostGetBytes(objID, keyID, wasmlib.TYPE_CALL+1, &result[0], size) - return result -} - -func (w *WasmVMHost) DelKey(objID, keyID, typeID int32) { - // size -1 means delete - // this removes the need for a separate hostDelete function - hostSetBytes(objID, keyID, typeID, nil, -1) -} - -func (w *WasmVMHost) Exists(objID, keyID, typeID int32) bool { - // size -1 means only test for existence - // returned size -1 indicates keyID not found (or error) - // this removes the need for a separate hostExists function - return hostGetBytes(objID, keyID, typeID, nil, -1) >= 0 -} - -func (w *WasmVMHost) GetBytes(objID, keyID, typeID int32) []byte { - size := int32(wasmlib.TypeSizes[typeID]) - if size == 0 { - // variable-sized type, first query expected length of bytes array - // (pass zero-length buffer) - size = hostGetBytes(objID, keyID, typeID, nil, 0) - - // -1 means non-existent, so return default value for type - if size <= 0 { - return []byte(nil) - } - } - - // allocate a sufficient length byte array in Wasm memory - // and let the host copy the actual data bytes into this Wasm byte array - result := make([]byte, size) - hostGetBytes(objID, keyID, typeID, &result[0], size) - return result +func (w *WasmVMHost) ExportName(index int32, name string) { + value := []byte(name) + hostStateSet(nil, index, ptr(value), int32(len(value))) } -func (w *WasmVMHost) GetKeyIDFromBytes(bytes []byte) int32 { - size := int32(len(bytes)) - // &bytes[0] will panic on zero length slice, so use nil instead - // negative size indicates this was from bytes - if size == 0 { - return hostGetKeyID(nil, -1) - } - return hostGetKeyID(&bytes[0], -size-1) -} - -func (w *WasmVMHost) GetKeyIDFromString(key string) int32 { - bytes := []byte(key) - size := int32(len(bytes)) - // &bytes[0] will panic on zero length slice, so use nil instead - // non-negative size indicates this was from string - if size == 0 { - return hostGetKeyID(nil, 0) - } - return hostGetKeyID(&bytes[0], size) -} - -func (w *WasmVMHost) GetObjectID(objID, keyID, typeID int32) int32 { - return hostGetObjectID(objID, keyID, typeID) -} - -func (w *WasmVMHost) SetBytes(objID, keyID, typeID int32, value []byte) { - // &bytes[0] will panic on zero length slice, so use nil instead - size := int32(len(value)) - if size == 0 { - hostSetBytes(objID, keyID, typeID, nil, size) - return - } - hostSetBytes(objID, keyID, typeID, &value[0], size) +func (w *WasmVMHost) ExportWasmTag() { + w.ExportName(-1, "WASM::GO") } func (w *WasmVMHost) Sandbox(funcNr int32, params []byte) []byte { @@ -218,6 +127,6 @@ func (w *WasmVMHost) StateGet(key []byte) []byte { return value } -func (w *WasmVMHost) StateSet(key []byte, value []byte) { +func (w *WasmVMHost) StateSet(key, value []byte) { hostStateSet(&key[0], int32(len(key)), ptr(value), int32(len(value))) } diff --git a/plugins/wasmtimevm/plugin.go b/plugins/wasmtimevm/plugin.go index 20fb213f41..d4a943952e 100644 --- a/plugins/wasmtimevm/plugin.go +++ b/plugins/wasmtimevm/plugin.go @@ -10,7 +10,7 @@ import ( "github.com/iotaledger/hive.go/node" "github.com/iotaledger/wasp/packages/iscp" "github.com/iotaledger/wasp/packages/vm/vmtypes" - "github.com/iotaledger/wasp/packages/vm/wasmproc" + "github.com/iotaledger/wasp/packages/vm/wasmhost" "github.com/iotaledger/wasp/plugins/processors" ) @@ -30,7 +30,7 @@ func configure(_ *node.Plugin) { err := processors.Config.RegisterVMType(vmtypes.WasmTime, func(binary []byte) (iscp.VMProcessor, error) { // TODO (via config?) pass non-default timeout for WasmTime processor like this: // WasmTimeout = 3 * time.Second - return wasmproc.GetProcessor(binary, log) + return wasmhost.GetProcessor(binary, log) }) if err != nil { log.Panicf("%v: %v", pluginName, err) diff --git a/tools/cluster/tests/wasm/inccounter_bg.wasm b/tools/cluster/tests/wasm/inccounter_bg.wasm index ae1937db526f66951a7f2aa742ed3e65e10f983c..e9884aa9c0a08667b433fcb83befa5867674d40f 100644 GIT binary patch delta 206 zcmbPwl4<5irU{WUjP(gj^>qvhj6lp<4+20DHZY@pVyPvgz{K?qjDizC$TRXz7GM-- zA) zOg8hSXfrV`nrxM}fJuR2^R2W%=EDN)XGw2P$^N8fZf2s8lbV-alA*yV pz~IHez);P|z@Q7HGxN$4b23vDN{x-6Di|1GYIZPf?w!OT1ONopJcIxM delta 182 zcmbPvl4gy(!S~BuaT<^drF!6&tqu^u#MsY^I$r_9*jJ%V58UHiR z-0aJAQIxTDvb;pt5&ATObNiwdQ?5VHGXtH^sQI;XA36p?;-e!RmZ6?MAlWo!# zY`&Kk$UNCMTY9rs7Bk~y{VeIt8QGuI%#Do{a#HisOENS#1sJ>-7#Lz185nedbY@;z ZVoqj?LZ+DsR0RVAOieZ8=82Oyga9mvH4Oj& diff --git a/tools/schema/generator/emitter.go b/tools/schema/generator/emitter.go index 85310d21e5..c0a98ae562 100644 --- a/tools/schema/generator/emitter.go +++ b/tools/schema/generator/emitter.go @@ -20,6 +20,7 @@ const ( KeyEvents = "events" KeyExist = "exist" KeyFunc = "func" + KeyFuncs = "funcs" KeyInit = "init" KeyMandatory = "mandatory" KeyMap = "map" @@ -209,7 +210,7 @@ func (g *GenBase) emitEachMandatoryField(template string) { mandatoryFields := make([]*model.Field, 0) for _, g.currentField = range g.currentFunc.Params { fld := g.currentField - if !fld.Optional && fld.TypeID != 0 && !fld.Array && fld.MapKey == "" { + if !fld.Optional && fld.BaseType && !fld.Array && fld.MapKey == "" { mandatoryFields = append(mandatoryFields, g.currentField) } } @@ -267,7 +268,7 @@ func (g *GenBase) emitIf(line string) { case KeyArray: condition = g.currentField.Array case KeyBaseType: - condition = g.currentField.TypeID != 0 + condition = g.currentField.BaseType case KeyCore: condition = g.s.CoreContracts case KeyEvent: @@ -278,6 +279,8 @@ func (g *GenBase) emitIf(line string) { condition = g.newTypes[g.keys[KeyProxy]] case KeyFunc: condition = g.keys["kind"] == KeyFunc + case KeyFuncs: + condition = len(g.s.Funcs) != 0 case KeyInit: condition = g.currentFunc.Name == KeyInit case KeyMandatory: @@ -403,6 +406,13 @@ func (g *GenBase) setFieldKeys(pad bool, maxCamelLength, maxSnakeLength int) { g.setMultiKeyValues("fldName", g.currentField.Name) g.setMultiKeyValues("fldType", g.currentField.Type) + isArray := "" + if g.currentField.Array { + isArray = "true" + } + g.keys["fldIsArray"] = isArray + g.keys["fldIsMap"] = g.currentField.MapKey + g.keys["fldAlias"] = g.currentField.Alias g.keys["fldComment"] = g.currentField.Comment g.keys["fldMapKey"] = g.currentField.MapKey @@ -446,7 +456,7 @@ func (g *GenBase) setFuncKeys(pad bool, maxCamelLength, maxSnakeLength int) { comment = grant[index:] grant = strings.TrimSpace(grant[:index]) } - g.keys["funcAccess"] = grant + g.setMultiKeyValues("funcAccess", grant) g.keys["funcAccessComment"] = comment if pad { diff --git a/tools/schema/generator/goclienttemplates/service.go b/tools/schema/generator/goclienttemplates/service.go index 50ce6ba1db..8a62f1cd80 100644 --- a/tools/schema/generator/goclienttemplates/service.go +++ b/tools/schema/generator/goclienttemplates/service.go @@ -3,7 +3,13 @@ package goclienttemplates var serviceGo = map[string]string{ // ******************************* "service.go": ` -$#emit clientHeader +package $package$+client +$#if funcs emitContract +`, + // ******************************* + "emitContract": ` + +import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmclient" const ( $#each params constArg diff --git a/tools/schema/generator/gotemplates/alltemplates.go b/tools/schema/generator/gotemplates/alltemplates.go index 3fe42a9552..e7ad765ca8 100644 --- a/tools/schema/generator/gotemplates/alltemplates.go +++ b/tools/schema/generator/gotemplates/alltemplates.go @@ -29,96 +29,69 @@ var Templates = []map[string]string{ var TypeDependent = model.StringMapMap{ "fldLangType": { - "Address": "wasmlib.ScAddress", - "AgentID": "wasmlib.ScAgentID", + "Address": "wasmtypes.ScAddress", + "AgentID": "wasmtypes.ScAgentID", "Bool": "bool", - "ChainID": "wasmlib.ScChainID", - "Color": "wasmlib.ScColor", - "Hash": "wasmlib.ScHash", - "Hname": "wasmlib.ScHname", + "Bytes": "[]byte", + "ChainID": "wasmtypes.ScChainID", + "Color": "wasmtypes.ScColor", + "Hash": "wasmtypes.ScHash", + "Hname": "wasmtypes.ScHname", "Int8": "int8", "Int16": "int16", "Int32": "int32", "Int64": "int64", - "RequestID": "wasmlib.ScRequestID", + "RequestID": "wasmtypes.ScRequestID", "String": "string", "Uint8": "uint8", "Uint16": "uint16", "Uint32": "uint32", "Uint64": "uint64", }, - "fldTypeID": { - "Address": "wasmlib.TYPE_ADDRESS", - "AgentID": "wasmlib.TYPE_AGENT_ID", - "Bool": "wasmlib.TYPE_BOOL", - "ChainID": "wasmlib.TYPE_CHAIN_ID", - "Color": "wasmlib.TYPE_COLOR", - "Hash": "wasmlib.TYPE_HASH", - "Hname": "wasmlib.TYPE_HNAME", - "Int8": "wasmlib.TYPE_INT8", - "Int16": "wasmlib.TYPE_INT16", - "Int32": "wasmlib.TYPE_INT32", - "Int64": "wasmlib.TYPE_INT64", - "RequestID": "wasmlib.TYPE_REQUEST_ID", - "String": "wasmlib.TYPE_STRING", - "Uint8": "wasmlib.TYPE_INT8", - "Uint16": "wasmlib.TYPE_INT16", - "Uint32": "wasmlib.TYPE_INT32", - "Uint64": "wasmlib.TYPE_INT64", - "": "wasmlib.TYPE_BYTES", - }, - "fldToKey32": { - "Address": "key.KeyID()", - "AgentID": "key.KeyID()", - "Bool": "???cannot use Bool as map key", - "ChainID": "key.KeyID()", - "Color": "key.KeyID()", - "Hash": "key.KeyID()", - "Hname": "key.KeyID()", - "Int8": "wasmlib.GetKeyIDFromUint64(uint64(key), 1)", - "Int16": "wasmlib.GetKeyIDFromUint64(uint64(key), 2)", - "Int32": "wasmlib.GetKeyIDFromUint64(uint64(key), 4)", - "Int64": "wasmlib.GetKeyIDFromUint64(uint64(key), 8)", - "RequestID": "key.KeyID()", - "String": "wasmlib.Key(key).KeyID()", - "Uint8": "wasmlib.GetKeyIDFromUint64(uint64(key), 1)", - "Uint16": "wasmlib.GetKeyIDFromUint64(uint64(key), 2)", - "Uint32": "wasmlib.GetKeyIDFromUint64(uint64(key), 4)", - "Uint64": "wasmlib.GetKeyIDFromUint64(key, 8)", + "fldToBytes": { + "Address": "key.Bytes()", + "AgentID": "key.Bytes()", + "Bool": "wasmtypes.BytesFromBool(key)", + "Bytes": "wasmtypes.BytesFromBytes(key)", + "ChainID": "key.Bytes()", + "Color": "key.Bytes()", + "Hash": "key.Bytes()", + "Hname": "key.Bytes()", + "Int8": "wasmtypes.BytesFromInt8(key)", + "Int16": "wasmtypes.BytesFromInt16(key)", + "Int32": "wasmtypes.BytesFromInt32(key)", + "Int64": "wasmtypes.BytesFromInt64(key)", + "RequestID": "key.Bytes()", + "String": "wasmtypes.BytesFromString(key)", + "Uint8": "wasmtypes.BytesFromUint8(key)", + "Uint16": "wasmtypes.BytesFromUint16(key)", + "Uint32": "wasmtypes.BytesFromUint32(key)", + "Uint64": "wasmtypes.BytesFromUint64(key)", + "": "key.Bytes()", }, } var common = map[string]string{ - // ******************************* - "initGlobals": ` -$#set arrayTypeID wasmlib.TYPE_ARRAY -$#if core setArrayTypeID -`, - // ******************************* - "setArrayTypeID": ` -$#set arrayTypeID wasmlib.TYPE_ARRAY16 -`, // ******************************* "goPackage": ` package $package +`, + // ******************************* + "importWasmCodec": ` +import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmcodec" `, // ******************************* "importWasmLib": ` - import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" +`, + // ******************************* + "importWasmTypes": ` +import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" `, // ******************************* "goHeader": ` $#emit goPackage + $#emit importWasmLib -`, - // ******************************* - "setVarType": ` -$#set varType wasmlib.TYPE_MAP -$#if array setVarTypeArray -`, - // ******************************* - "setVarTypeArray": ` -$#set varType $arrayTypeID|$fldTypeID `, } diff --git a/tools/schema/generator/gotemplates/consts.go b/tools/schema/generator/gotemplates/consts.go index 81474d2c23..8a092299bd 100644 --- a/tools/schema/generator/gotemplates/consts.go +++ b/tools/schema/generator/gotemplates/consts.go @@ -3,24 +3,19 @@ package gotemplates var constsGo = map[string]string{ // ******************************* "consts.go": ` -$#emit goHeader +$#emit goPackage + +$#emit importWasmTypes const ( ScName = "$scName" ScDescription = "$scDesc" - HScName = wasmlib.ScHname(0x$hscName) + HScName = wasmtypes.ScHname(0x$hscName) ) $#if params constParams $#if results constResults $#if state constState - -const ( -$#each func constFunc -) - -const ( -$#each func constHFunc -) +$#if funcs constFuncs `, // ******************************* "constParams": ` @@ -45,6 +40,17 @@ const ( $#set constPrefix State $#each state constField ) +`, + // ******************************* + "constFuncs": ` + +const ( +$#each func constFunc +) + +const ( +$#each func constHFunc +) `, // ******************************* "constField": ` @@ -56,6 +62,6 @@ $#each state constField `, // ******************************* "constHFunc": ` - H$Kind$FuncName$funcPad = wasmlib.ScHname(0x$hFuncName) + H$Kind$FuncName$funcPad = wasmtypes.ScHname(0x$hFuncName) `, } diff --git a/tools/schema/generator/gotemplates/contract.go b/tools/schema/generator/gotemplates/contract.go index 773be9aeec..52acde3741 100644 --- a/tools/schema/generator/gotemplates/contract.go +++ b/tools/schema/generator/gotemplates/contract.go @@ -3,7 +3,13 @@ package gotemplates var contractGo = map[string]string{ // ******************************* "contract.go": ` -$#emit goHeader +$#emit goPackage +$#if funcs emitContract +`, + // ******************************* + "emitContract": ` + +$#emit importWasmLib $#each func FuncNameCall type Funcs struct{} @@ -35,12 +41,21 @@ $#if result ImmutableFuncNameResults $#emit setupInitFunc func (sc Funcs) $FuncName(ctx wasmlib.Sc$Kind$+CallContext) *$FuncName$+Call { -$#set paramsID nil -$#set resultsID nil -$#if param setParamsID -$#if result setResultsID -$#if ptrs setPtrs noPtrs +$#set thisView f.Func +$#if func setThisView +$#set complex $false +$#if param setComplex +$#if result setComplex +$#if complex initComplex initSimple } +`, + // ******************************* + "setThisView": ` +$#set thisView &f.Func.ScView +`, + // ******************************* + "setComplex": ` +$#set complex $true `, // ******************************* "coreOnload": ` @@ -55,21 +70,22 @@ $#each func coreExportFunc exports.Add$Kind($Kind$FuncName, wasmlib.$Kind$+Error) `, // ******************************* - "setPtrs": ` - f := &$FuncName$+Call{Func: wasmlib.NewSc$initFunc$Kind(ctx, HScName, H$Kind$FuncName$initMap)} - f.Func.SetPtrs($paramsID, $resultsID) + "initComplex": ` + f := &$FuncName$+Call{Func: wasmlib.NewSc$initFunc$Kind(ctx, HScName, H$Kind$FuncName)} +$#if param initParams +$#if result initResults return f `, // ******************************* - "setParamsID": ` -$#set paramsID &f.Params.id + "initParams": ` + f.Params.proxy = wasmlib.NewCallParamsProxy($thisView) `, // ******************************* - "setResultsID": ` -$#set resultsID &f.Results.id + "initResults": ` + wasmlib.NewCallResultsProxy($thisView, &f.Results.proxy) `, // ******************************* - "noPtrs": ` - return &$FuncName$+Call{Func: wasmlib.NewSc$initFunc$Kind(ctx, HScName, H$Kind$FuncName$initMap)} + "initSimple": ` + return &$FuncName$+Call{Func: wasmlib.NewSc$initFunc$Kind(ctx, HScName, H$Kind$FuncName)} `, } diff --git a/tools/schema/generator/gotemplates/events.go b/tools/schema/generator/gotemplates/events.go index a52a60fb7b..64aade2a71 100644 --- a/tools/schema/generator/gotemplates/events.go +++ b/tools/schema/generator/gotemplates/events.go @@ -5,6 +5,7 @@ var eventsGo = map[string]string{ "events.go": ` //nolint:gocritic $#emit goHeader +$#emit importWasmTypes $#set TypeName $Package$+Events type $TypeName struct { diff --git a/tools/schema/generator/gotemplates/keys.go b/tools/schema/generator/gotemplates/keys.go index e8528d83bc..efde033401 100644 --- a/tools/schema/generator/gotemplates/keys.go +++ b/tools/schema/generator/gotemplates/keys.go @@ -3,38 +3,6 @@ package gotemplates var keysGo = map[string]string{ // ******************************* "keys.go": ` -$#emit goHeader - -const ( -$#set constPrefix Param -$#each params constFieldIdx - -$#set constPrefix Result -$#each results constFieldIdx - -$#set constPrefix State -$#each state constFieldIdx -) - -const keyMapLen = $maxIndex - -var keyMap = [keyMapLen]wasmlib.Key{ -$#set constPrefix Param -$#each params constFieldKey -$#set constPrefix Result -$#each results constFieldKey -$#set constPrefix State -$#each state constFieldKey -} - -var idxMap [keyMapLen]wasmlib.Key32 -`, - // ******************************* - "constFieldIdx": ` - Idx$constPrefix$FldName$fldPad = $fldIndex -`, - // ******************************* - "constFieldKey": ` - $constPrefix$FldName, +$#emit goPackage `, } diff --git a/tools/schema/generator/gotemplates/lib.go b/tools/schema/generator/gotemplates/lib.go index ec5822463c..537e1c3545 100644 --- a/tools/schema/generator/gotemplates/lib.go +++ b/tools/schema/generator/gotemplates/lib.go @@ -9,10 +9,6 @@ $#emit goHeader func OnLoad() { exports := wasmlib.NewScExports() $#each func libExportFunc - - for i, key := range keyMap { - idxMap[i] = key.KeyID() - } } $#each func libThunk `, @@ -33,13 +29,13 @@ $#if view ImmutablePackageState func $kind$FuncName$+Thunk(ctx wasmlib.Sc$Kind$+Context) { ctx.Log("$package.$kind$FuncName") -$#emit accessCheck f := &$FuncName$+Context{ $#if param ImmutableFuncNameParamsInit $#if result MutableFuncNameResultsInit $#if func MutablePackageStateInit $#if view ImmutablePackageStateInit } +$#emit accessCheck $#each mandatory requireMandatory $kind$FuncName(ctx, f) ctx.Log("$package.$kind$FuncName ok") @@ -60,7 +56,7 @@ $#if events PackageEventsExist // ******************************* "ImmutableFuncNameParamsInit": ` Params: Immutable$FuncName$+Params{ - id: wasmlib.OBJ_ID_PARAMS, + proxy: wasmlib.NewParamsProxy(), }, `, // ******************************* @@ -70,7 +66,7 @@ $#if events PackageEventsExist // ******************************* "MutableFuncNameResultsInit": ` Results: Mutable$FuncName$+Results{ - id: wasmlib.OBJ_ID_RESULTS, + proxy: wasmlib.NewResultsProxy(), }, `, // ******************************* @@ -80,7 +76,7 @@ $#if events PackageEventsExist // ******************************* "MutablePackageStateInit": ` State: Mutable$Package$+State{ - id: wasmlib.OBJ_ID_STATE, + proxy: wasmlib.NewStateProxy(), }, `, // ******************************* @@ -90,7 +86,7 @@ $#if events PackageEventsExist // ******************************* "ImmutablePackageStateInit": ` State: Immutable$Package$+State{ - id: wasmlib.OBJ_ID_STATE, + proxy: wasmlib.NewStateProxy(), }, `, // ******************************* @@ -132,7 +128,7 @@ $#set accessFinalize accessDone // ******************************* "accessOther": ` $#if funcAccessComment accessComment - access := ctx.State().GetAgentID(wasmlib.Key("$funcAccess")) + access := f.State.$FuncAccess() ctx.Require(access.Exists(), "access not set: $funcAccess") ctx.Require(ctx.Caller() == access.Value(), "no permission") diff --git a/tools/schema/generator/gotemplates/params.go b/tools/schema/generator/gotemplates/params.go index 447ee0580f..f23157565f 100644 --- a/tools/schema/generator/gotemplates/params.go +++ b/tools/schema/generator/gotemplates/params.go @@ -3,7 +3,9 @@ package gotemplates var paramsGo = map[string]string{ // ******************************* "params.go": ` -$#emit goHeader +$#emit goPackage + +$#emit importWasmTypes $#each func paramsFunc `, // ******************************* @@ -24,7 +26,7 @@ $#set TypeName $mut$FuncName$+Params $#each param proxyContainers type $TypeName struct { - id int32 + proxy wasmtypes.Proxy } $#each param proxyMethods `, diff --git a/tools/schema/generator/gotemplates/proxy.go b/tools/schema/generator/gotemplates/proxy.go index 4e4725c4fb..6ac0c7d4a2 100644 --- a/tools/schema/generator/gotemplates/proxy.go +++ b/tools/schema/generator/gotemplates/proxy.go @@ -8,14 +8,7 @@ $#if map typedefProxyMap `, // ******************************* "proxyMethods": ` -$#set varID wasmlib.KeyID($Kind$FldName) -$#if init setInitVarID -$#if core setCoreVarID $#if array proxyArray proxyMethods2 -`, - // ******************************* - "setInitVarID": ` -$#set varID idxMap[Idx$Kind$FldName] `, // ******************************* "proxyMethods2": ` @@ -23,22 +16,18 @@ $#if map proxyMap proxyMethods3 `, // ******************************* "proxyMethods3": ` -$#if basetype proxyBaseType proxyMethods4 +$#if basetype proxyBaseType proxyOtherType `, // ******************************* - "proxyMethods4": ` + // TODO when will this be called, and if so, fix it + "proxyOtherType": ` $#if typedef proxyTypeDef proxyStruct -`, - // ******************************* - "setCoreVarID": ` -$#set varID wasmlib.KeyID($Kind$FldName) `, // ******************************* "proxyArray": ` func (s $TypeName) $FldName() ArrayOf$mut$FldType { - arrID := wasmlib.GetObjectID(s.id, $varID, $arrayTypeID|$fldTypeID) - return ArrayOf$mut$FldType{objID: arrID} + return ArrayOf$mut$FldType{proxy: s.proxy.Root($Kind$FldName)} } `, // ******************************* @@ -49,27 +38,27 @@ $#if this proxyMapThis proxyMapOther "proxyMapThis": ` func (s $TypeName) $FldName() Map$fldMapKey$+To$mut$FldType { - return Map$fldMapKey$+To$mut$FldType{objID: s.id} + //nolint:gosimple + return Map$fldMapKey$+To$mut$FldType{proxy: s.proxy} } `, // ******************************* "proxyMapOther": ` func (s $TypeName) $FldName() Map$fldMapKey$+To$mut$FldType { - mapID := wasmlib.GetObjectID(s.id, $varID, wasmlib.TYPE_MAP) - return Map$fldMapKey$+To$mut$FldType{objID: mapID} + return Map$fldMapKey$+To$mut$FldType{proxy: s.proxy.Root($Kind$FldName)} } `, // ******************************* "proxyBaseType": ` -func (s $TypeName) $FldName() wasmlib.Sc$mut$FldType { - return wasmlib.NewSc$mut$FldType(s.id, $varID) +func (s $TypeName) $FldName() wasmtypes.Sc$mut$FldType { + return wasmtypes.NewSc$mut$FldType(s.proxy.Root($Kind$FldName)) } `, // ******************************* + // TODO when will this be called, and if so, fix it "proxyTypeDef": ` -$#emit setVarType func (s $TypeName) $OldName() $mut$OldType { subID := wasmlib.GetObjectID(s.id, $varID, $varType) @@ -77,6 +66,7 @@ func (s $TypeName) $OldName() $mut$OldType { } `, // ******************************* + // TODO when will this be called, and if so, fix it "proxyStruct": ` func (s $TypeName) $FldName() $mut$FldType { diff --git a/tools/schema/generator/gotemplates/results.go b/tools/schema/generator/gotemplates/results.go index 1b46ecd872..345b454bf9 100644 --- a/tools/schema/generator/gotemplates/results.go +++ b/tools/schema/generator/gotemplates/results.go @@ -3,7 +3,9 @@ package gotemplates var resultsGo = map[string]string{ // ******************************* "results.go": ` -$#emit goHeader +$#emit goPackage + +$#emit importWasmTypes $#each func resultsFunc `, // ******************************* @@ -24,7 +26,7 @@ $#set TypeName $mut$FuncName$+Results $#each result proxyContainers type $TypeName struct { - id int32 + proxy wasmtypes.Proxy } $#each result proxyMethods `, diff --git a/tools/schema/generator/gotemplates/state.go b/tools/schema/generator/gotemplates/state.go index 5cd4a0bd9a..faca5700d0 100644 --- a/tools/schema/generator/gotemplates/state.go +++ b/tools/schema/generator/gotemplates/state.go @@ -4,7 +4,8 @@ var stateGo = map[string]string{ // ******************************* "state.go": ` $#emit goPackage -$#if state importWasmLib + +$#emit importWasmTypes $#set Kind State $#set mut Immutable $#emit stateProxyStruct @@ -17,7 +18,7 @@ $#set TypeName $mut$Package$+State $#each state proxyContainers type $TypeName struct { - id int32 + proxy wasmtypes.Proxy } $#if mut stateProxyImmutableFunc $#each state proxyMethods diff --git a/tools/schema/generator/gotemplates/structs.go b/tools/schema/generator/gotemplates/structs.go index af2a356a87..03568b5abd 100644 --- a/tools/schema/generator/gotemplates/structs.go +++ b/tools/schema/generator/gotemplates/structs.go @@ -3,7 +3,10 @@ package gotemplates var structsGo = map[string]string{ // ******************************* "structs.go": ` -$#emit goHeader +$#emit goPackage + +$#emit importWasmCodec +$#emit importWasmTypes $#each structs structType `, // ******************************* @@ -13,18 +16,18 @@ type $StrName struct { $#each struct structField } -func New$StrName$+FromBytes(bytes []byte) *$StrName { - decode := wasmlib.NewBytesDecoder(bytes) +func New$StrName$+FromBytes(buf []byte) *$StrName { + dec := wasmcodec.NewWasmDecoder(buf) data := &$StrName$+{} $#each struct structDecode - decode.Close() + dec.Close() return data } func (o *$StrName) Bytes() []byte { - return wasmlib.NewBytesEncoder(). + enc := wasmcodec.NewWasmEncoder() $#each struct structEncode - Data() + return enc.Buf() } $#set mut Immutable $#emit structMethods @@ -37,42 +40,41 @@ $#emit structMethods `, // ******************************* "structDecode": ` - data.$FldName$fldPad = decode.$FldType() + data.$FldName$fldPad = wasmtypes.Decode$FldType(dec) `, // ******************************* "structEncode": ` - $FldType(o.$FldName). + wasmtypes.Encode$FldType(enc, o.$FldName) `, // ******************************* "structMethods": ` type $mut$StrName struct { - objID int32 - keyID wasmlib.Key32 + proxy wasmtypes.Proxy } $#if mut structMethodDelete func (o $mut$StrName) Exists() bool { - return wasmlib.Exists(o.objID, o.keyID, wasmlib.TYPE_BYTES) + return o.proxy.Exists() } $#if mut structMethodSetValue func (o $mut$StrName) Value() *$StrName { - return New$StrName$+FromBytes(wasmlib.GetBytes(o.objID, o.keyID, wasmlib.TYPE_BYTES)) + return New$StrName$+FromBytes(o.proxy.Get()) } `, // ******************************* "structMethodDelete": ` func (o $mut$StrName) Delete() { - wasmlib.DelKey(o.objID, o.keyID, wasmlib.TYPE_BYTES) + o.proxy.Delete() } `, // ******************************* "structMethodSetValue": ` func (o $mut$StrName) SetValue(value *$StrName) { - wasmlib.SetBytes(o.objID, o.keyID, wasmlib.TYPE_BYTES, value.Bytes()) + o.proxy.Set(value.Bytes()) } `, } diff --git a/tools/schema/generator/gotemplates/typedefs.go b/tools/schema/generator/gotemplates/typedefs.go index ed5fcb42e9..1d976dafe2 100644 --- a/tools/schema/generator/gotemplates/typedefs.go +++ b/tools/schema/generator/gotemplates/typedefs.go @@ -3,7 +3,9 @@ package gotemplates var typedefsGo = map[string]string{ // ******************************* "typedefs.go": ` -$#emit goHeader +$#emit goPackage + +$#emit importWasmTypes $#each typedef typedefProxy `, // ******************************* @@ -33,48 +35,50 @@ $#if exist else typedefProxyArrayNew "typedefProxyArrayNew": ` type $proxy struct { - objID int32 + proxy wasmtypes.Proxy } -$#if mut typedefProxyArrayClear +$#if mut typedefProxyArrayMut -func (a $proxy) Length() int32 { - return wasmlib.GetLength(a.objID) +func (a $proxy) Length() uint32 { + return a.proxy.Length() } $#if basetype typedefProxyArrayNewBaseType typedefProxyArrayNewOtherType $#set exist $proxy `, // ******************************* - "typedefProxyArrayClear": ` + "typedefProxyArrayMut": ` +$#if basetype typedefProxyArrayAppendBaseType typedefProxyArrayAppendOtherType func (a $proxy) Clear() { - wasmlib.Clear(a.objID) + a.proxy.ClearArray() } `, // ******************************* - "typedefProxyArrayNewBaseType": ` + "typedefProxyArrayAppendBaseType": ` -func (a $proxy) Get$FldType(index int32) wasmlib.Sc$mut$FldType { - return wasmlib.NewSc$mut$FldType(a.objID, wasmlib.Key32(index)) +func (a $proxy) Append$FldType() wasmtypes.Sc$mut$FldType { + return wasmtypes.NewSc$mut$FldType(a.proxy.Append()) } `, // ******************************* - "typedefProxyArrayNewOtherType": ` -$#if typedef typedefProxyArrayNewOtherTypeTypeDef typedefProxyArrayNewOtherTypeStruct + "typedefProxyArrayAppendOtherType": ` + +func (a $proxy) Append$FldType() $mut$FldType { + return $mut$FldType{proxy: a.proxy.Append()} +} `, // ******************************* - "typedefProxyArrayNewOtherTypeTypeDef": ` -$#emit setVarType + "typedefProxyArrayNewBaseType": ` -func (a $proxy) Get$OldType(index int32) $mut$OldType { - subID := wasmlib.GetObjectID(a.objID, wasmlib.Key32(index), $varType) - return $mut$OldType{objID: subID} +func (a $proxy) Get$FldType(index uint32) wasmtypes.Sc$mut$FldType { + return wasmtypes.NewSc$mut$FldType(a.proxy.Index(index)) } `, // ******************************* - "typedefProxyArrayNewOtherTypeStruct": ` + "typedefProxyArrayNewOtherType": ` -func (a $proxy) Get$FldType(index int32) $mut$FldType { - return $mut$FldType{objID: a.objID, keyID: wasmlib.Key32(index)} +func (a $proxy) Get$FldType(index uint32) $mut$FldType { + return $mut$FldType{proxy: a.proxy.Index(index)} } `, // ******************************* @@ -86,44 +90,31 @@ $#if exist else typedefProxyMapNew "typedefProxyMapNew": ` type $proxy struct { - objID int32 + proxy wasmtypes.Proxy } -$#if mut typedefProxyMapClear +$#if mut typedefProxyMapMut $#if basetype typedefProxyMapNewBaseType typedefProxyMapNewOtherType $#set exist $proxy `, // ******************************* - "typedefProxyMapClear": ` + "typedefProxyMapMut": ` func (m $proxy) Clear() { - wasmlib.Clear(m.objID) + m.proxy.ClearMap() } `, // ******************************* "typedefProxyMapNewBaseType": ` -func (m $proxy) Get$FldType(key $fldKeyLangType) wasmlib.Sc$mut$FldType { - return wasmlib.NewSc$mut$FldType(m.objID, $fldKeyToKey32) +func (m $proxy) Get$FldType(key $fldKeyLangType) wasmtypes.Sc$mut$FldType { + return wasmtypes.NewSc$mut$FldType(m.proxy.Key($fldKeyToBytes)) } `, // ******************************* "typedefProxyMapNewOtherType": ` -$#if typedef typedefProxyMapNewOtherTypeTypeDef typedefProxyMapNewOtherTypeStruct -`, - // ******************************* - "typedefProxyMapNewOtherTypeTypeDef": ` -$#emit setVarType - -func (m $proxy) Get$OldType(key $oldKeyLangType) $mut$OldType { - subID := wasmlib.GetObjectID(m.objID, $oldKeyToKey32, $varType) - return $mut$OldType{objID: subID} -} -`, - // ******************************* - "typedefProxyMapNewOtherTypeStruct": ` func (m $proxy) Get$FldType(key $fldKeyLangType) $mut$FldType { - return $mut$FldType{objID: m.objID, keyID: $fldKeyToKey32} + return $mut$FldType{proxy: m.proxy.Key($fldKeyToBytes)} } `, } diff --git a/tools/schema/generator/rstemplates/typedefs.go b/tools/schema/generator/rstemplates/typedefs.go index 06a3e60021..c47174c021 100644 --- a/tools/schema/generator/rstemplates/typedefs.go +++ b/tools/schema/generator/rstemplates/typedefs.go @@ -43,7 +43,7 @@ pub struct $proxy { impl $proxy { $#if mut typedefProxyArrayClear - pub fn length(&self) -> i32 { + pub fn length(&self) -> u32 { get_length(self.obj_id) } @@ -60,8 +60,8 @@ $#set exist $proxy `, // ******************************* "typedefProxyArrayNewBaseType": ` - pub fn get_$fld_type(&self, index: i32) -> Sc$mut$FldType { - Sc$mut$FldType::new(self.obj_id, Key32(index)) + pub fn get_$fld_type(&self, index: u32) -> Sc$mut$FldType { + Sc$mut$FldType::new(self.obj_id, Key32(index as i32)) } `, // ******************************* @@ -71,15 +71,15 @@ $#if typedef typedefProxyArrayNewOtherTypeTypeDef typedefProxyArrayNewOtherTypeS // ******************************* "typedefProxyArrayNewOtherTypeTypeDef": ` $#emit setVarType - pub fn get_$old_type(&self, index: i32) -> $mut$OldType { - let sub_id = get_object_id(self.obj_id, Key32(index), $varType); + pub fn get_$old_type(&self, index: u32) -> $mut$OldType { + let sub_id = get_object_id(self.obj_id, Key32(index as i32), $varType); $mut$OldType { obj_id: sub_id } } `, // ******************************* "typedefProxyArrayNewOtherTypeStruct": ` - pub fn get_$fld_type(&self, index: i32) -> $mut$FldType { - $mut$FldType { obj_id: self.obj_id, key_id: Key32(index) } + pub fn get_$fld_type(&self, index: u32) -> $mut$FldType { + $mut$FldType { obj_id: self.obj_id, key_id: Key32(index as i32) } } `, // ******************************* diff --git a/tools/schema/generator/templates.go b/tools/schema/generator/templates.go index b4652457dd..6302094177 100644 --- a/tools/schema/generator/templates.go +++ b/tools/schema/generator/templates.go @@ -48,12 +48,10 @@ func TestDeploy(t *testing.T) { // ******************************* "setupInitFunc": ` $#set initFunc -$#set initMap $#if init setInitFunc `, // ******************************* "setInitFunc": ` $#set initFunc Init -$#set initMap , keyMap[:], idxMap[:] `, } diff --git a/tools/schema/generator/tstemplates/typedefs.go b/tools/schema/generator/tstemplates/typedefs.go index 21ae67839b..5ca4fc2303 100644 --- a/tools/schema/generator/tstemplates/typedefs.go +++ b/tools/schema/generator/tstemplates/typedefs.go @@ -41,7 +41,7 @@ export class $proxy { } $#if mut typedefProxyArrayClear - length(): i32 { + length(): u32 { return wasmlib.getLength(this.objID); } $#if basetype typedefProxyArrayNewBaseType typedefProxyArrayNewOtherType @@ -58,8 +58,8 @@ $#set exist $proxy // ******************************* "typedefProxyArrayNewBaseType": ` - get$FldType(index: i32): wasmlib.Sc$mut$FldType { - return new wasmlib.Sc$mut$FldType(this.objID, new wasmlib.Key32(index)); + get$FldType(index: u32): wasmlib.Sc$mut$FldType { + return new wasmlib.Sc$mut$FldType(this.objID, new wasmlib.Key32(index as i32)); } `, // ******************************* @@ -70,16 +70,16 @@ $#if typedef typedefProxyArrayNewOtherTypeTypeDef typedefProxyArrayNewOtherTypeS "typedefProxyArrayNewOtherTypeTypeDef": ` $#emit setVarType - get$OldType(index: i32): sc.$mut$OldType { - let subID = wasmlib.getObjectID(this.objID, new wasmlib.Key32(index), $varType); + get$OldType(index: u32): sc.$mut$OldType { + let subID = wasmlib.getObjectID(this.objID, new wasmlib.Key32(index as i32), $varType); return new sc.$mut$OldType(subID); } `, // ******************************* "typedefProxyArrayNewOtherTypeStruct": ` - get$FldType(index: i32): sc.$mut$FldType { - return new sc.$mut$FldType(this.objID, new wasmlib.Key32(index)); + get$FldType(index: u32): sc.$mut$FldType { + return new sc.$mut$FldType(this.objID, new wasmlib.Key32(index as i32)); } `, // ******************************* diff --git a/tools/schema/generator/utils.go b/tools/schema/generator/utils.go index ae12a5aec8..90b548d326 100644 --- a/tools/schema/generator/utils.go +++ b/tools/schema/generator/utils.go @@ -18,6 +18,9 @@ var ( // capitalize first letter func capitalize(name string) string { + if name == "" { + return "" + } return upper(name[:1]) + name[1:] } @@ -92,6 +95,9 @@ func snake(name string) string { // uncapitalize first letter func uncapitalize(name string) string { + if name == "" { + return "" + } return lower(name[:1]) + name[1:] } diff --git a/tools/schema/model/field.go b/tools/schema/model/field.go index 38232a01df..360f99c805 100644 --- a/tools/schema/model/field.go +++ b/tools/schema/model/field.go @@ -7,8 +7,6 @@ import ( "fmt" "regexp" "strings" - - "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" ) var ( @@ -17,25 +15,25 @@ var ( fldTypeRegexp = regexp.MustCompile(`^[A-Z][a-zA-Z0-9]+$`) ) -var FieldTypes = map[string]int32{ - "Address": wasmlib.TYPE_ADDRESS, - "AgentID": wasmlib.TYPE_AGENT_ID, - "Bool": wasmlib.TYPE_BOOL, - "Bytes": wasmlib.TYPE_BYTES, - "ChainID": wasmlib.TYPE_CHAIN_ID, - "Color": wasmlib.TYPE_COLOR, - "Hash": wasmlib.TYPE_HASH, - "Hname": wasmlib.TYPE_HNAME, - "Int8": wasmlib.TYPE_INT8, - "Int16": wasmlib.TYPE_INT16, - "Int32": wasmlib.TYPE_INT32, - "Int64": wasmlib.TYPE_INT64, - "RequestID": wasmlib.TYPE_REQUEST_ID, - "String": wasmlib.TYPE_STRING, - "Uint8": wasmlib.TYPE_INT8, - "Uint16": wasmlib.TYPE_INT16, - "Uint32": wasmlib.TYPE_INT32, - "Uint64": wasmlib.TYPE_INT64, +var FieldTypes = map[string]bool{ + "Address": true, + "AgentID": true, + "Bool": true, + "Bytes": true, + "ChainID": true, + "Color": true, + "Hash": true, + "Hname": true, + "Int8": true, + "Int16": true, + "Int32": true, + "Int64": true, + "RequestID": true, + "String": true, + "Uint8": true, + "Uint16": true, + "Uint32": true, + "Uint64": true, } type Field struct { @@ -47,7 +45,7 @@ type Field struct { MapKey string Optional bool Type string - TypeID int32 + BaseType bool } func (f *Field) Compile(s *Schema, fldName, fldType string) error { @@ -102,9 +100,8 @@ func (f *Field) Compile(s *Schema, fldName, fldType string) error { if !fldTypeRegexp.MatchString(f.Type) { return fmt.Errorf("invalid field type: %s", f.Type) } - typeID, ok := FieldTypes[f.Type] - if ok { - f.TypeID = typeID + f.BaseType = FieldTypes[f.Type] + if f.BaseType { return nil } for _, typeDef := range s.Structs { From dd8de3112ab99741dd466b9abbfd9ba73b533566 Mon Sep 17 00:00:00 2001 From: Eric Hop Date: Mon, 24 Jan 2022 19:52:12 -0800 Subject: [PATCH 040/111] Fixed test --- .../wasm/testwasmlib/test/testwasmlib_test.go | 15 +++++++-------- .../vm/wasmlib/go/wasmlib/wasmtypes/address.go | 4 ++++ .../vm/wasmlib/go/wasmlib/wasmtypes/agentid.go | 4 ++++ .../vm/wasmlib/go/wasmlib/wasmtypes/chainid.go | 4 ++++ packages/vm/wasmlib/go/wasmlib/wasmtypes/hash.go | 1 - .../vm/wasmlib/go/wasmlib/wasmtypes/requestid.go | 5 ++++- .../vm/wasmlib/ts/wasmlib/wasmrequests/structs.ts | 12 ++++++------ .../schema/generator/tstemplates/alltemplates.go | 2 ++ 8 files changed, 31 insertions(+), 16 deletions(-) diff --git a/contracts/wasm/testwasmlib/test/testwasmlib_test.go b/contracts/wasm/testwasmlib/test/testwasmlib_test.go index 2cb58fb960..6c0772e07d 100644 --- a/contracts/wasm/testwasmlib/test/testwasmlib_test.go +++ b/contracts/wasm/testwasmlib/test/testwasmlib_test.go @@ -110,6 +110,7 @@ func TestValidSizeParams(t *testing.T) { ctx := setupTest(t) for index, param := range allParams { t.Run("ValidSize "+param, func(t *testing.T) { + paramMismatch := fmt.Sprintf("mismatch: %s%s", strings.ToUpper(param[:1]), param[1:]) pt := testwasmlib.ScFuncs.ParamTypes(ctx) bytes := make([]byte, allLengths[index]) if param == testwasmlib.ParamChainID { @@ -118,7 +119,7 @@ func TestValidSizeParams(t *testing.T) { pt.Params.Param().GetBytes(param).SetValue(bytes) pt.Func.TransferIotas(1).Post() require.Error(t, ctx.Err) - require.Contains(t, ctx.Err.Error(), "mismatch: ") + require.Contains(t, ctx.Err.Error(), paramMismatch) }) } } @@ -154,12 +155,13 @@ func TestInvalidTypeParams(t *testing.T) { for param, values := range invalidValues { for index, value := range values { t.Run("InvalidType "+param+" "+strconv.Itoa(index), func(t *testing.T) { + invalidParam := fmt.Sprintf("invalid %s%s:", strings.ToUpper(param[:1]), param[1:]) req := solo.NewCallParams(testwasmlib.ScName, testwasmlib.FuncParamTypes, param, value, ).WithIotas(1) _, err := ctx.Chain.PostRequestSync(req, nil) require.Error(t, err) - require.Contains(t, err.Error(), "invalid ") + require.Contains(t, err.Error(), invalidParam) }) } } @@ -188,23 +190,20 @@ func TestViewBlockRecords(t *testing.T) { func TestClearArray(t *testing.T) { ctx := setupTest(t) - as := testwasmlib.ScFuncs.ArraySet(ctx) + as := testwasmlib.ScFuncs.ArrayAppend(ctx) as.Params.Name().SetValue("bands") - as.Params.Index().SetValue(0) as.Params.Value().SetValue("Simple Minds") as.Func.TransferIotas(1).Post() require.NoError(t, ctx.Err) - as = testwasmlib.ScFuncs.ArraySet(ctx) + as = testwasmlib.ScFuncs.ArrayAppend(ctx) as.Params.Name().SetValue("bands") - as.Params.Index().SetValue(1) as.Params.Value().SetValue("Dire Straits") as.Func.TransferIotas(1).Post() require.NoError(t, ctx.Err) - as = testwasmlib.ScFuncs.ArraySet(ctx) + as = testwasmlib.ScFuncs.ArrayAppend(ctx) as.Params.Name().SetValue("bands") - as.Params.Index().SetValue(2) as.Params.Value().SetValue("ELO") as.Func.TransferIotas(1).Post() require.NoError(t, ctx.Err) diff --git a/packages/vm/wasmlib/go/wasmlib/wasmtypes/address.go b/packages/vm/wasmlib/go/wasmlib/wasmtypes/address.go index f4151fc865..1254eb58a7 100644 --- a/packages/vm/wasmlib/go/wasmlib/wasmtypes/address.go +++ b/packages/vm/wasmlib/go/wasmlib/wasmtypes/address.go @@ -27,6 +27,10 @@ func AddressFromBytes(buf []byte) ScAddress { if len(buf) != ScAddressLength { Panic("invalid Address length") } + // max ledgerstate.AliasAddressType + if buf[0] > 2 { + Panic("invalid Address: address type > 2") + } return newAddressFromBytes(buf) } diff --git a/packages/vm/wasmlib/go/wasmlib/wasmtypes/agentid.go b/packages/vm/wasmlib/go/wasmlib/wasmtypes/agentid.go index 128f702311..16731318e7 100644 --- a/packages/vm/wasmlib/go/wasmlib/wasmtypes/agentid.go +++ b/packages/vm/wasmlib/go/wasmlib/wasmtypes/agentid.go @@ -29,6 +29,10 @@ func AgentIDFromBytes(buf []byte) ScAgentID { if len(buf) != ScAgentIDLength { Panic("invalid AgentID length") } + // max ledgerstate.AliasAddressType + if buf[0] > 2 { + Panic("invalid AgentID: address type > 2") + } return newAgentIDFromBytes(buf) } diff --git a/packages/vm/wasmlib/go/wasmlib/wasmtypes/chainid.go b/packages/vm/wasmlib/go/wasmlib/wasmtypes/chainid.go index 847381b914..2152c646a0 100644 --- a/packages/vm/wasmlib/go/wasmlib/wasmtypes/chainid.go +++ b/packages/vm/wasmlib/go/wasmlib/wasmtypes/chainid.go @@ -27,6 +27,10 @@ func ChainIDFromBytes(buf []byte) ScChainID { if len(buf) != ScChainIDLength { Panic("invalid ChainID length") } + // must be ledgerstate.AliasAddressType + if buf[0] != 2 { + Panic("invalid ChainID: not an alias address") + } return newChainIDFromBytes(buf) } diff --git a/packages/vm/wasmlib/go/wasmlib/wasmtypes/hash.go b/packages/vm/wasmlib/go/wasmlib/wasmtypes/hash.go index 9e855b4c81..a79836b39a 100644 --- a/packages/vm/wasmlib/go/wasmlib/wasmtypes/hash.go +++ b/packages/vm/wasmlib/go/wasmlib/wasmtypes/hash.go @@ -1,7 +1,6 @@ // Copyright 2020 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 -//nolint:dupl package wasmtypes import ( diff --git a/packages/vm/wasmlib/go/wasmlib/wasmtypes/requestid.go b/packages/vm/wasmlib/go/wasmlib/wasmtypes/requestid.go index 85c0ac4468..b3a8ea73ff 100644 --- a/packages/vm/wasmlib/go/wasmlib/wasmtypes/requestid.go +++ b/packages/vm/wasmlib/go/wasmlib/wasmtypes/requestid.go @@ -1,7 +1,6 @@ // Copyright 2020 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 -//nolint:dupl package wasmtypes import ( @@ -28,6 +27,10 @@ func RequestIDFromBytes(buf []byte) ScRequestID { if len(buf) != ScRequestIDLength { Panic("invalid RequestID length") } + // final uint16 output index must be > ledgerstate.MaxOutputCount + if buf[ScHashLength] > 127 || buf[ScHashLength+1] != 0 { + Panic("invalid RequestID: output index > 127") + } return newRequestIDFromBytes(buf) } diff --git a/packages/vm/wasmlib/ts/wasmlib/wasmrequests/structs.ts b/packages/vm/wasmlib/ts/wasmlib/wasmrequests/structs.ts index dde968d18d..cea6528926 100644 --- a/packages/vm/wasmlib/ts/wasmlib/wasmrequests/structs.ts +++ b/packages/vm/wasmlib/ts/wasmlib/wasmrequests/structs.ts @@ -10,8 +10,8 @@ import * as wasmlib from "wasmlib"; export class CallRequest { contract : wasmlib.ScHname = new wasmlib.ScHname(0); function : wasmlib.ScHname = new wasmlib.ScHname(0); - params : = ; - transfer : = ; + params : u8[] = []; + transfer : u8[] = []; static fromBytes(bytes: u8[]): CallRequest { let decode = new wasmlib.BytesDecoder(bytes); @@ -81,7 +81,7 @@ export class MutableCallRequest { export class DeployRequest { description : string = ""; name : string = ""; - params : = ; + params : u8[] = []; progHash : wasmlib.ScHash = new wasmlib.ScHash(); static fromBytes(bytes: u8[]): DeployRequest { @@ -154,8 +154,8 @@ export class PostRequest { contract : wasmlib.ScHname = new wasmlib.ScHname(0); delay : u32 = 0; function : wasmlib.ScHname = new wasmlib.ScHname(0); - params : = ; - transfer : = ; + params : u8[] = []; + transfer : u8[] = []; static fromBytes(bytes: u8[]): PostRequest { let decode = new wasmlib.BytesDecoder(bytes); @@ -228,7 +228,7 @@ export class MutablePostRequest { export class SendRequest { address : wasmlib.ScAddress = new wasmlib.ScAddress(); - transfer : = ; + transfer : u8[] = []; static fromBytes(bytes: u8[]): SendRequest { let decode = new wasmlib.BytesDecoder(bytes); diff --git a/tools/schema/generator/tstemplates/alltemplates.go b/tools/schema/generator/tstemplates/alltemplates.go index 9fa0a18071..f30640fe55 100644 --- a/tools/schema/generator/tstemplates/alltemplates.go +++ b/tools/schema/generator/tstemplates/alltemplates.go @@ -32,6 +32,7 @@ var TypeDependent = model.StringMapMap{ "Address": "wasmlib.ScAddress", "AgentID": "wasmlib.ScAgentID", "Bool": "bool", + "Bytes": "u8[]", "ChainID": "wasmlib.ScChainID", "Color": "wasmlib.ScColor", "Hash": "wasmlib.ScHash", @@ -90,6 +91,7 @@ var TypeDependent = model.StringMapMap{ "Address": "new wasmlib.ScAddress()", "AgentID": "new wasmlib.ScAgentID()", "Bool": "false", + "Bytes": "[]", "ChainID": "new wasmlib.ScChainID()", "Color": "new wasmlib.ScColor(0)", "Hash": "new wasmlib.ScHash()", From 2e2599b52ea633393bdff85acf0d6d81b90f902a Mon Sep 17 00:00:00 2001 From: Eric Hop Date: Mon, 24 Jan 2022 19:54:26 -0800 Subject: [PATCH 041/111] Fixed Bytes type generation in TS structs --- tools/schema/generator/tstemplates/alltemplates.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/schema/generator/tstemplates/alltemplates.go b/tools/schema/generator/tstemplates/alltemplates.go index 9fa0a18071..fc46ee0eac 100644 --- a/tools/schema/generator/tstemplates/alltemplates.go +++ b/tools/schema/generator/tstemplates/alltemplates.go @@ -32,6 +32,7 @@ var TypeDependent = model.StringMapMap{ "Address": "wasmlib.ScAddress", "AgentID": "wasmlib.ScAgentID", "Bool": "bool", + "Bytes": "u8[]", "ChainID": "wasmlib.ScChainID", "Color": "wasmlib.ScColor", "Hash": "wasmlib.ScHash", @@ -90,6 +91,7 @@ var TypeDependent = model.StringMapMap{ "Address": "new wasmlib.ScAddress()", "AgentID": "new wasmlib.ScAgentID()", "Bool": "false", + "Bytes": "[]]", "ChainID": "new wasmlib.ScChainID()", "Color": "new wasmlib.ScColor(0)", "Hash": "new wasmlib.ScHash()", From 5c8d2c4595970480f7f5c954f6f486d95de425ad Mon Sep 17 00:00:00 2001 From: Eric Hop Date: Mon, 24 Jan 2022 19:56:48 -0800 Subject: [PATCH 042/111] Oopsie fix --- tools/schema/generator/tstemplates/alltemplates.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/schema/generator/tstemplates/alltemplates.go b/tools/schema/generator/tstemplates/alltemplates.go index fc46ee0eac..f30640fe55 100644 --- a/tools/schema/generator/tstemplates/alltemplates.go +++ b/tools/schema/generator/tstemplates/alltemplates.go @@ -91,7 +91,7 @@ var TypeDependent = model.StringMapMap{ "Address": "new wasmlib.ScAddress()", "AgentID": "new wasmlib.ScAgentID()", "Bool": "false", - "Bytes": "[]]", + "Bytes": "[]", "ChainID": "new wasmlib.ScChainID()", "Color": "new wasmlib.ScColor(0)", "Hash": "new wasmlib.ScHash()", From d3066be0550532f0c893c2ced51860a41964c4fa Mon Sep 17 00:00:00 2001 From: Eric Hop Date: Mon, 24 Jan 2022 20:00:17 -0800 Subject: [PATCH 043/111] Same fix for Go version --- tools/schema/generator/gotemplates/alltemplates.go | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/schema/generator/gotemplates/alltemplates.go b/tools/schema/generator/gotemplates/alltemplates.go index 3fe42a9552..bb0acb0a01 100644 --- a/tools/schema/generator/gotemplates/alltemplates.go +++ b/tools/schema/generator/gotemplates/alltemplates.go @@ -32,6 +32,7 @@ var TypeDependent = model.StringMapMap{ "Address": "wasmlib.ScAddress", "AgentID": "wasmlib.ScAgentID", "Bool": "bool", + "Bytes": "[]byte", "ChainID": "wasmlib.ScChainID", "Color": "wasmlib.ScColor", "Hash": "wasmlib.ScHash", From 0517a12fafb6ed53e04f8542c2d4f92b3f2b3aa8 Mon Sep 17 00:00:00 2001 From: Eric Hop Date: Tue, 25 Jan 2022 11:30:11 -0800 Subject: [PATCH 044/111] Fixed loads of tests --- contracts/wasm/dividend/go/dividend/lib.go | 8 +- .../go/donatewithfeedback/lib.go | 8 +- contracts/wasm/erc20/go/erc20/lib.go | 12 ++- contracts/wasm/erc721/go/erc721/lib.go | 28 +++++-- .../wasm/fairauction/go/fairauction/lib.go | 4 +- .../wasm/fairauction/test/fairauction_test.go | 2 +- .../wasm/fairroulette/go/fairroulette/lib.go | 16 +++- .../wasm/helloworld/go/helloworld/lib.go | 4 +- .../wasm/inccounter/go/inccounter/lib.go | 12 ++- contracts/wasm/testcore/go/testcore/lib.go | 40 +++++++--- contracts/wasm/testcore/test/testcore_test.go | 55 +++++++------- .../wasm/testwasmlib/go/testwasmlib/lib.go | 28 +++++-- contracts/wasm/timestamp/go/timestamp/lib.go | 4 +- packages/vm/wasmhost/wasmgovm.go | 17 ++++- packages/vm/wasmhost/wasmprocessor.go | 73 ++++++++++--------- packages/vm/wasmhost/wasmtosandbox.go | 10 +++ packages/vm/wasmlib/go/wasmlib/dict.go | 15 ++-- packages/vm/wasmlib/go/wasmlib/sandbox.go | 33 +++++---- .../vm/wasmlib/go/wasmlib/wasmtypes/bool.go | 3 + .../vm/wasmlib/go/wasmlib/wasmtypes/int16.go | 3 + .../vm/wasmlib/go/wasmlib/wasmtypes/int32.go | 3 + .../vm/wasmlib/go/wasmlib/wasmtypes/int64.go | 3 + .../vm/wasmlib/go/wasmlib/wasmtypes/int8.go | 3 + .../vm/wasmlib/go/wasmlib/wasmtypes/uint16.go | 3 + .../vm/wasmlib/go/wasmlib/wasmtypes/uint32.go | 3 + .../vm/wasmlib/go/wasmlib/wasmtypes/uint64.go | 3 + .../vm/wasmlib/go/wasmlib/wasmtypes/uint8.go | 3 + packages/vm/wasmsolo/solosandbox.go | 10 ++- tools/schema/generator/gotemplates/lib.go | 12 ++- 29 files changed, 287 insertions(+), 131 deletions(-) diff --git a/contracts/wasm/dividend/go/dividend/lib.go b/contracts/wasm/dividend/go/dividend/lib.go index 470be11717..3cc4d82751 100644 --- a/contracts/wasm/dividend/go/dividend/lib.go +++ b/contracts/wasm/dividend/go/dividend/lib.go @@ -114,12 +114,13 @@ type GetFactorContext struct { func viewGetFactorThunk(ctx wasmlib.ScViewContext) { ctx.Log("dividend.viewGetFactor") + results := wasmlib.NewScDict() f := &GetFactorContext{ Params: ImmutableGetFactorParams{ proxy: wasmlib.NewParamsProxy(), }, Results: MutableGetFactorResults{ - proxy: wasmlib.NewResultsProxy(), + proxy: results.AsProxy(), }, State: ImmutableDividendState{ proxy: wasmlib.NewStateProxy(), @@ -128,6 +129,7 @@ func viewGetFactorThunk(ctx wasmlib.ScViewContext) { ctx.Require(f.Params.Address().Exists(), "missing mandatory address") viewGetFactor(ctx, f) ctx.Log("dividend.viewGetFactor ok") + ctx.Results(results) } type GetOwnerContext struct { @@ -137,9 +139,10 @@ type GetOwnerContext struct { func viewGetOwnerThunk(ctx wasmlib.ScViewContext) { ctx.Log("dividend.viewGetOwner") + results := wasmlib.NewScDict() f := &GetOwnerContext{ Results: MutableGetOwnerResults{ - proxy: wasmlib.NewResultsProxy(), + proxy: results.AsProxy(), }, State: ImmutableDividendState{ proxy: wasmlib.NewStateProxy(), @@ -147,4 +150,5 @@ func viewGetOwnerThunk(ctx wasmlib.ScViewContext) { } viewGetOwner(ctx, f) ctx.Log("dividend.viewGetOwner ok") + ctx.Results(results) } diff --git a/contracts/wasm/donatewithfeedback/go/donatewithfeedback/lib.go b/contracts/wasm/donatewithfeedback/go/donatewithfeedback/lib.go index bbf65a3b33..9243c086c6 100644 --- a/contracts/wasm/donatewithfeedback/go/donatewithfeedback/lib.go +++ b/contracts/wasm/donatewithfeedback/go/donatewithfeedback/lib.go @@ -67,12 +67,13 @@ type DonationContext struct { func viewDonationThunk(ctx wasmlib.ScViewContext) { ctx.Log("donatewithfeedback.viewDonation") + results := wasmlib.NewScDict() f := &DonationContext{ Params: ImmutableDonationParams{ proxy: wasmlib.NewParamsProxy(), }, Results: MutableDonationResults{ - proxy: wasmlib.NewResultsProxy(), + proxy: results.AsProxy(), }, State: ImmutableDonateWithFeedbackState{ proxy: wasmlib.NewStateProxy(), @@ -81,6 +82,7 @@ func viewDonationThunk(ctx wasmlib.ScViewContext) { ctx.Require(f.Params.Nr().Exists(), "missing mandatory nr") viewDonation(ctx, f) ctx.Log("donatewithfeedback.viewDonation ok") + ctx.Results(results) } type DonationInfoContext struct { @@ -90,9 +92,10 @@ type DonationInfoContext struct { func viewDonationInfoThunk(ctx wasmlib.ScViewContext) { ctx.Log("donatewithfeedback.viewDonationInfo") + results := wasmlib.NewScDict() f := &DonationInfoContext{ Results: MutableDonationInfoResults{ - proxy: wasmlib.NewResultsProxy(), + proxy: results.AsProxy(), }, State: ImmutableDonateWithFeedbackState{ proxy: wasmlib.NewStateProxy(), @@ -100,4 +103,5 @@ func viewDonationInfoThunk(ctx wasmlib.ScViewContext) { } viewDonationInfo(ctx, f) ctx.Log("donatewithfeedback.viewDonationInfo ok") + ctx.Results(results) } diff --git a/contracts/wasm/erc20/go/erc20/lib.go b/contracts/wasm/erc20/go/erc20/lib.go index bf42f90b78..596d41f4de 100644 --- a/contracts/wasm/erc20/go/erc20/lib.go +++ b/contracts/wasm/erc20/go/erc20/lib.go @@ -117,12 +117,13 @@ type AllowanceContext struct { func viewAllowanceThunk(ctx wasmlib.ScViewContext) { ctx.Log("erc20.viewAllowance") + results := wasmlib.NewScDict() f := &AllowanceContext{ Params: ImmutableAllowanceParams{ proxy: wasmlib.NewParamsProxy(), }, Results: MutableAllowanceResults{ - proxy: wasmlib.NewResultsProxy(), + proxy: results.AsProxy(), }, State: ImmutableErc20State{ proxy: wasmlib.NewStateProxy(), @@ -132,6 +133,7 @@ func viewAllowanceThunk(ctx wasmlib.ScViewContext) { ctx.Require(f.Params.Delegation().Exists(), "missing mandatory delegation") viewAllowance(ctx, f) ctx.Log("erc20.viewAllowance ok") + ctx.Results(results) } type BalanceOfContext struct { @@ -142,12 +144,13 @@ type BalanceOfContext struct { func viewBalanceOfThunk(ctx wasmlib.ScViewContext) { ctx.Log("erc20.viewBalanceOf") + results := wasmlib.NewScDict() f := &BalanceOfContext{ Params: ImmutableBalanceOfParams{ proxy: wasmlib.NewParamsProxy(), }, Results: MutableBalanceOfResults{ - proxy: wasmlib.NewResultsProxy(), + proxy: results.AsProxy(), }, State: ImmutableErc20State{ proxy: wasmlib.NewStateProxy(), @@ -156,6 +159,7 @@ func viewBalanceOfThunk(ctx wasmlib.ScViewContext) { ctx.Require(f.Params.Account().Exists(), "missing mandatory account") viewBalanceOf(ctx, f) ctx.Log("erc20.viewBalanceOf ok") + ctx.Results(results) } type TotalSupplyContext struct { @@ -165,9 +169,10 @@ type TotalSupplyContext struct { func viewTotalSupplyThunk(ctx wasmlib.ScViewContext) { ctx.Log("erc20.viewTotalSupply") + results := wasmlib.NewScDict() f := &TotalSupplyContext{ Results: MutableTotalSupplyResults{ - proxy: wasmlib.NewResultsProxy(), + proxy: results.AsProxy(), }, State: ImmutableErc20State{ proxy: wasmlib.NewStateProxy(), @@ -175,4 +180,5 @@ func viewTotalSupplyThunk(ctx wasmlib.ScViewContext) { } viewTotalSupply(ctx, f) ctx.Log("erc20.viewTotalSupply ok") + ctx.Results(results) } diff --git a/contracts/wasm/erc721/go/erc721/lib.go b/contracts/wasm/erc721/go/erc721/lib.go index 44e48b89d0..1906f5c190 100644 --- a/contracts/wasm/erc721/go/erc721/lib.go +++ b/contracts/wasm/erc721/go/erc721/lib.go @@ -188,12 +188,13 @@ type BalanceOfContext struct { func viewBalanceOfThunk(ctx wasmlib.ScViewContext) { ctx.Log("erc721.viewBalanceOf") + results := wasmlib.NewScDict() f := &BalanceOfContext{ Params: ImmutableBalanceOfParams{ proxy: wasmlib.NewParamsProxy(), }, Results: MutableBalanceOfResults{ - proxy: wasmlib.NewResultsProxy(), + proxy: results.AsProxy(), }, State: ImmutableErc721State{ proxy: wasmlib.NewStateProxy(), @@ -202,6 +203,7 @@ func viewBalanceOfThunk(ctx wasmlib.ScViewContext) { ctx.Require(f.Params.Owner().Exists(), "missing mandatory owner") viewBalanceOf(ctx, f) ctx.Log("erc721.viewBalanceOf ok") + ctx.Results(results) } type GetApprovedContext struct { @@ -212,12 +214,13 @@ type GetApprovedContext struct { func viewGetApprovedThunk(ctx wasmlib.ScViewContext) { ctx.Log("erc721.viewGetApproved") + results := wasmlib.NewScDict() f := &GetApprovedContext{ Params: ImmutableGetApprovedParams{ proxy: wasmlib.NewParamsProxy(), }, Results: MutableGetApprovedResults{ - proxy: wasmlib.NewResultsProxy(), + proxy: results.AsProxy(), }, State: ImmutableErc721State{ proxy: wasmlib.NewStateProxy(), @@ -226,6 +229,7 @@ func viewGetApprovedThunk(ctx wasmlib.ScViewContext) { ctx.Require(f.Params.TokenID().Exists(), "missing mandatory tokenID") viewGetApproved(ctx, f) ctx.Log("erc721.viewGetApproved ok") + ctx.Results(results) } type IsApprovedForAllContext struct { @@ -236,12 +240,13 @@ type IsApprovedForAllContext struct { func viewIsApprovedForAllThunk(ctx wasmlib.ScViewContext) { ctx.Log("erc721.viewIsApprovedForAll") + results := wasmlib.NewScDict() f := &IsApprovedForAllContext{ Params: ImmutableIsApprovedForAllParams{ proxy: wasmlib.NewParamsProxy(), }, Results: MutableIsApprovedForAllResults{ - proxy: wasmlib.NewResultsProxy(), + proxy: results.AsProxy(), }, State: ImmutableErc721State{ proxy: wasmlib.NewStateProxy(), @@ -251,6 +256,7 @@ func viewIsApprovedForAllThunk(ctx wasmlib.ScViewContext) { ctx.Require(f.Params.Owner().Exists(), "missing mandatory owner") viewIsApprovedForAll(ctx, f) ctx.Log("erc721.viewIsApprovedForAll ok") + ctx.Results(results) } type NameContext struct { @@ -260,9 +266,10 @@ type NameContext struct { func viewNameThunk(ctx wasmlib.ScViewContext) { ctx.Log("erc721.viewName") + results := wasmlib.NewScDict() f := &NameContext{ Results: MutableNameResults{ - proxy: wasmlib.NewResultsProxy(), + proxy: results.AsProxy(), }, State: ImmutableErc721State{ proxy: wasmlib.NewStateProxy(), @@ -270,6 +277,7 @@ func viewNameThunk(ctx wasmlib.ScViewContext) { } viewName(ctx, f) ctx.Log("erc721.viewName ok") + ctx.Results(results) } type OwnerOfContext struct { @@ -280,12 +288,13 @@ type OwnerOfContext struct { func viewOwnerOfThunk(ctx wasmlib.ScViewContext) { ctx.Log("erc721.viewOwnerOf") + results := wasmlib.NewScDict() f := &OwnerOfContext{ Params: ImmutableOwnerOfParams{ proxy: wasmlib.NewParamsProxy(), }, Results: MutableOwnerOfResults{ - proxy: wasmlib.NewResultsProxy(), + proxy: results.AsProxy(), }, State: ImmutableErc721State{ proxy: wasmlib.NewStateProxy(), @@ -294,6 +303,7 @@ func viewOwnerOfThunk(ctx wasmlib.ScViewContext) { ctx.Require(f.Params.TokenID().Exists(), "missing mandatory tokenID") viewOwnerOf(ctx, f) ctx.Log("erc721.viewOwnerOf ok") + ctx.Results(results) } type SymbolContext struct { @@ -303,9 +313,10 @@ type SymbolContext struct { func viewSymbolThunk(ctx wasmlib.ScViewContext) { ctx.Log("erc721.viewSymbol") + results := wasmlib.NewScDict() f := &SymbolContext{ Results: MutableSymbolResults{ - proxy: wasmlib.NewResultsProxy(), + proxy: results.AsProxy(), }, State: ImmutableErc721State{ proxy: wasmlib.NewStateProxy(), @@ -313,6 +324,7 @@ func viewSymbolThunk(ctx wasmlib.ScViewContext) { } viewSymbol(ctx, f) ctx.Log("erc721.viewSymbol ok") + ctx.Results(results) } type TokenURIContext struct { @@ -323,12 +335,13 @@ type TokenURIContext struct { func viewTokenURIThunk(ctx wasmlib.ScViewContext) { ctx.Log("erc721.viewTokenURI") + results := wasmlib.NewScDict() f := &TokenURIContext{ Params: ImmutableTokenURIParams{ proxy: wasmlib.NewParamsProxy(), }, Results: MutableTokenURIResults{ - proxy: wasmlib.NewResultsProxy(), + proxy: results.AsProxy(), }, State: ImmutableErc721State{ proxy: wasmlib.NewStateProxy(), @@ -337,4 +350,5 @@ func viewTokenURIThunk(ctx wasmlib.ScViewContext) { ctx.Require(f.Params.TokenID().Exists(), "missing mandatory tokenID") viewTokenURI(ctx, f) ctx.Log("erc721.viewTokenURI ok") + ctx.Results(results) } diff --git a/contracts/wasm/fairauction/go/fairauction/lib.go b/contracts/wasm/fairauction/go/fairauction/lib.go index 4c25061f29..d9b2220171 100644 --- a/contracts/wasm/fairauction/go/fairauction/lib.go +++ b/contracts/wasm/fairauction/go/fairauction/lib.go @@ -115,12 +115,13 @@ type GetInfoContext struct { func viewGetInfoThunk(ctx wasmlib.ScViewContext) { ctx.Log("fairauction.viewGetInfo") + results := wasmlib.NewScDict() f := &GetInfoContext{ Params: ImmutableGetInfoParams{ proxy: wasmlib.NewParamsProxy(), }, Results: MutableGetInfoResults{ - proxy: wasmlib.NewResultsProxy(), + proxy: results.AsProxy(), }, State: ImmutableFairAuctionState{ proxy: wasmlib.NewStateProxy(), @@ -129,4 +130,5 @@ func viewGetInfoThunk(ctx wasmlib.ScViewContext) { ctx.Require(f.Params.Color().Exists(), "missing mandatory color") viewGetInfo(ctx, f) ctx.Log("fairauction.viewGetInfo ok") + ctx.Results(results) } diff --git a/contracts/wasm/fairauction/test/fairauction_test.go b/contracts/wasm/fairauction/test/fairauction_test.go index c8e5ca8022..b2bef5d2fa 100644 --- a/contracts/wasm/fairauction/test/fairauction_test.go +++ b/contracts/wasm/fairauction/test/fairauction_test.go @@ -115,7 +115,7 @@ func TestFaOneBidTooLow(t *testing.T) { require.NoError(t, ctx.Err) require.EqualValues(t, 0, getInfo.Results.Bidders().Value()) - require.EqualValues(t, -1, getInfo.Results.HighestBid().Value()) + require.EqualValues(t, 0, getInfo.Results.HighestBid().Value()) } func TestFaOneBid(t *testing.T) { diff --git a/contracts/wasm/fairroulette/go/fairroulette/lib.go b/contracts/wasm/fairroulette/go/fairroulette/lib.go index cee12a9e9d..3478e30260 100644 --- a/contracts/wasm/fairroulette/go/fairroulette/lib.go +++ b/contracts/wasm/fairroulette/go/fairroulette/lib.go @@ -135,9 +135,10 @@ type LastWinningNumberContext struct { func viewLastWinningNumberThunk(ctx wasmlib.ScViewContext) { ctx.Log("fairroulette.viewLastWinningNumber") + results := wasmlib.NewScDict() f := &LastWinningNumberContext{ Results: MutableLastWinningNumberResults{ - proxy: wasmlib.NewResultsProxy(), + proxy: results.AsProxy(), }, State: ImmutableFairRouletteState{ proxy: wasmlib.NewStateProxy(), @@ -145,6 +146,7 @@ func viewLastWinningNumberThunk(ctx wasmlib.ScViewContext) { } viewLastWinningNumber(ctx, f) ctx.Log("fairroulette.viewLastWinningNumber ok") + ctx.Results(results) } type RoundNumberContext struct { @@ -154,9 +156,10 @@ type RoundNumberContext struct { func viewRoundNumberThunk(ctx wasmlib.ScViewContext) { ctx.Log("fairroulette.viewRoundNumber") + results := wasmlib.NewScDict() f := &RoundNumberContext{ Results: MutableRoundNumberResults{ - proxy: wasmlib.NewResultsProxy(), + proxy: results.AsProxy(), }, State: ImmutableFairRouletteState{ proxy: wasmlib.NewStateProxy(), @@ -164,6 +167,7 @@ func viewRoundNumberThunk(ctx wasmlib.ScViewContext) { } viewRoundNumber(ctx, f) ctx.Log("fairroulette.viewRoundNumber ok") + ctx.Results(results) } type RoundStartedAtContext struct { @@ -173,9 +177,10 @@ type RoundStartedAtContext struct { func viewRoundStartedAtThunk(ctx wasmlib.ScViewContext) { ctx.Log("fairroulette.viewRoundStartedAt") + results := wasmlib.NewScDict() f := &RoundStartedAtContext{ Results: MutableRoundStartedAtResults{ - proxy: wasmlib.NewResultsProxy(), + proxy: results.AsProxy(), }, State: ImmutableFairRouletteState{ proxy: wasmlib.NewStateProxy(), @@ -183,6 +188,7 @@ func viewRoundStartedAtThunk(ctx wasmlib.ScViewContext) { } viewRoundStartedAt(ctx, f) ctx.Log("fairroulette.viewRoundStartedAt ok") + ctx.Results(results) } type RoundStatusContext struct { @@ -192,9 +198,10 @@ type RoundStatusContext struct { func viewRoundStatusThunk(ctx wasmlib.ScViewContext) { ctx.Log("fairroulette.viewRoundStatus") + results := wasmlib.NewScDict() f := &RoundStatusContext{ Results: MutableRoundStatusResults{ - proxy: wasmlib.NewResultsProxy(), + proxy: results.AsProxy(), }, State: ImmutableFairRouletteState{ proxy: wasmlib.NewStateProxy(), @@ -202,4 +209,5 @@ func viewRoundStatusThunk(ctx wasmlib.ScViewContext) { } viewRoundStatus(ctx, f) ctx.Log("fairroulette.viewRoundStatus ok") + ctx.Results(results) } diff --git a/contracts/wasm/helloworld/go/helloworld/lib.go b/contracts/wasm/helloworld/go/helloworld/lib.go index b797aa785d..a8909c358b 100644 --- a/contracts/wasm/helloworld/go/helloworld/lib.go +++ b/contracts/wasm/helloworld/go/helloworld/lib.go @@ -37,9 +37,10 @@ type GetHelloWorldContext struct { func viewGetHelloWorldThunk(ctx wasmlib.ScViewContext) { ctx.Log("helloworld.viewGetHelloWorld") + results := wasmlib.NewScDict() f := &GetHelloWorldContext{ Results: MutableGetHelloWorldResults{ - proxy: wasmlib.NewResultsProxy(), + proxy: results.AsProxy(), }, State: ImmutableHelloWorldState{ proxy: wasmlib.NewStateProxy(), @@ -47,4 +48,5 @@ func viewGetHelloWorldThunk(ctx wasmlib.ScViewContext) { } viewGetHelloWorld(ctx, f) ctx.Log("helloworld.viewGetHelloWorld ok") + ctx.Results(results) } diff --git a/contracts/wasm/inccounter/go/inccounter/lib.go b/contracts/wasm/inccounter/go/inccounter/lib.go index d1e105a0ab..1efabe8993 100644 --- a/contracts/wasm/inccounter/go/inccounter/lib.go +++ b/contracts/wasm/inccounter/go/inccounter/lib.go @@ -264,9 +264,10 @@ type GetCounterContext struct { func viewGetCounterThunk(ctx wasmlib.ScViewContext) { ctx.Log("inccounter.viewGetCounter") + results := wasmlib.NewScDict() f := &GetCounterContext{ Results: MutableGetCounterResults{ - proxy: wasmlib.NewResultsProxy(), + proxy: results.AsProxy(), }, State: ImmutableIncCounterState{ proxy: wasmlib.NewStateProxy(), @@ -274,6 +275,7 @@ func viewGetCounterThunk(ctx wasmlib.ScViewContext) { } viewGetCounter(ctx, f) ctx.Log("inccounter.viewGetCounter ok") + ctx.Results(results) } type GetVliContext struct { @@ -284,12 +286,13 @@ type GetVliContext struct { func viewGetVliThunk(ctx wasmlib.ScViewContext) { ctx.Log("inccounter.viewGetVli") + results := wasmlib.NewScDict() f := &GetVliContext{ Params: ImmutableGetVliParams{ proxy: wasmlib.NewParamsProxy(), }, Results: MutableGetVliResults{ - proxy: wasmlib.NewResultsProxy(), + proxy: results.AsProxy(), }, State: ImmutableIncCounterState{ proxy: wasmlib.NewStateProxy(), @@ -298,6 +301,7 @@ func viewGetVliThunk(ctx wasmlib.ScViewContext) { ctx.Require(f.Params.Ni64().Exists(), "missing mandatory ni64") viewGetVli(ctx, f) ctx.Log("inccounter.viewGetVli ok") + ctx.Results(results) } type GetVluContext struct { @@ -308,12 +312,13 @@ type GetVluContext struct { func viewGetVluThunk(ctx wasmlib.ScViewContext) { ctx.Log("inccounter.viewGetVlu") + results := wasmlib.NewScDict() f := &GetVluContext{ Params: ImmutableGetVluParams{ proxy: wasmlib.NewParamsProxy(), }, Results: MutableGetVluResults{ - proxy: wasmlib.NewResultsProxy(), + proxy: results.AsProxy(), }, State: ImmutableIncCounterState{ proxy: wasmlib.NewStateProxy(), @@ -322,4 +327,5 @@ func viewGetVluThunk(ctx wasmlib.ScViewContext) { ctx.Require(f.Params.Nu64().Exists(), "missing mandatory nu64") viewGetVlu(ctx, f) ctx.Log("inccounter.viewGetVlu ok") + ctx.Results(results) } diff --git a/contracts/wasm/testcore/go/testcore/lib.go b/contracts/wasm/testcore/go/testcore/lib.go index a6c9b21adc..eceeccdbed 100644 --- a/contracts/wasm/testcore/go/testcore/lib.go +++ b/contracts/wasm/testcore/go/testcore/lib.go @@ -54,12 +54,13 @@ type CallOnChainContext struct { func funcCallOnChainThunk(ctx wasmlib.ScFuncContext) { ctx.Log("testcore.funcCallOnChain") + results := wasmlib.NewScDict() f := &CallOnChainContext{ Params: ImmutableCallOnChainParams{ proxy: wasmlib.NewParamsProxy(), }, Results: MutableCallOnChainResults{ - proxy: wasmlib.NewResultsProxy(), + proxy: results.AsProxy(), }, State: MutableTestCoreState{ proxy: wasmlib.NewStateProxy(), @@ -68,6 +69,7 @@ func funcCallOnChainThunk(ctx wasmlib.ScFuncContext) { ctx.Require(f.Params.IntValue().Exists(), "missing mandatory intValue") funcCallOnChain(ctx, f) ctx.Log("testcore.funcCallOnChain ok") + ctx.Results(results) } type CheckContextFromFullEPContext struct { @@ -116,9 +118,10 @@ type GetMintedSupplyContext struct { func funcGetMintedSupplyThunk(ctx wasmlib.ScFuncContext) { ctx.Log("testcore.funcGetMintedSupply") + results := wasmlib.NewScDict() f := &GetMintedSupplyContext{ Results: MutableGetMintedSupplyResults{ - proxy: wasmlib.NewResultsProxy(), + proxy: results.AsProxy(), }, State: MutableTestCoreState{ proxy: wasmlib.NewStateProxy(), @@ -126,6 +129,7 @@ func funcGetMintedSupplyThunk(ctx wasmlib.ScFuncContext) { } funcGetMintedSupply(ctx, f) ctx.Log("testcore.funcGetMintedSupply ok") + ctx.Results(results) } type IncCounterContext struct { @@ -200,12 +204,13 @@ type RunRecursionContext struct { func funcRunRecursionThunk(ctx wasmlib.ScFuncContext) { ctx.Log("testcore.funcRunRecursion") + results := wasmlib.NewScDict() f := &RunRecursionContext{ Params: ImmutableRunRecursionParams{ proxy: wasmlib.NewParamsProxy(), }, Results: MutableRunRecursionResults{ - proxy: wasmlib.NewResultsProxy(), + proxy: results.AsProxy(), }, State: MutableTestCoreState{ proxy: wasmlib.NewStateProxy(), @@ -214,6 +219,7 @@ func funcRunRecursionThunk(ctx wasmlib.ScFuncContext) { ctx.Require(f.Params.IntValue().Exists(), "missing mandatory intValue") funcRunRecursion(ctx, f) ctx.Log("testcore.funcRunRecursion ok") + ctx.Results(results) } type SendToAddressContext struct { @@ -346,9 +352,10 @@ type TestChainOwnerIDFullContext struct { func funcTestChainOwnerIDFullThunk(ctx wasmlib.ScFuncContext) { ctx.Log("testcore.funcTestChainOwnerIDFull") + results := wasmlib.NewScDict() f := &TestChainOwnerIDFullContext{ Results: MutableTestChainOwnerIDFullResults{ - proxy: wasmlib.NewResultsProxy(), + proxy: results.AsProxy(), }, State: MutableTestCoreState{ proxy: wasmlib.NewStateProxy(), @@ -356,6 +363,7 @@ func funcTestChainOwnerIDFullThunk(ctx wasmlib.ScFuncContext) { } funcTestChainOwnerIDFull(ctx, f) ctx.Log("testcore.funcTestChainOwnerIDFull ok") + ctx.Results(results) } type TestEventLogDeployContext struct { @@ -474,12 +482,13 @@ type FibonacciContext struct { func viewFibonacciThunk(ctx wasmlib.ScViewContext) { ctx.Log("testcore.viewFibonacci") + results := wasmlib.NewScDict() f := &FibonacciContext{ Params: ImmutableFibonacciParams{ proxy: wasmlib.NewParamsProxy(), }, Results: MutableFibonacciResults{ - proxy: wasmlib.NewResultsProxy(), + proxy: results.AsProxy(), }, State: ImmutableTestCoreState{ proxy: wasmlib.NewStateProxy(), @@ -488,6 +497,7 @@ func viewFibonacciThunk(ctx wasmlib.ScViewContext) { ctx.Require(f.Params.IntValue().Exists(), "missing mandatory intValue") viewFibonacci(ctx, f) ctx.Log("testcore.viewFibonacci ok") + ctx.Results(results) } type GetCounterContext struct { @@ -497,9 +507,10 @@ type GetCounterContext struct { func viewGetCounterThunk(ctx wasmlib.ScViewContext) { ctx.Log("testcore.viewGetCounter") + results := wasmlib.NewScDict() f := &GetCounterContext{ Results: MutableGetCounterResults{ - proxy: wasmlib.NewResultsProxy(), + proxy: results.AsProxy(), }, State: ImmutableTestCoreState{ proxy: wasmlib.NewStateProxy(), @@ -507,6 +518,7 @@ func viewGetCounterThunk(ctx wasmlib.ScViewContext) { } viewGetCounter(ctx, f) ctx.Log("testcore.viewGetCounter ok") + ctx.Results(results) } type GetIntContext struct { @@ -517,12 +529,13 @@ type GetIntContext struct { func viewGetIntThunk(ctx wasmlib.ScViewContext) { ctx.Log("testcore.viewGetInt") + results := wasmlib.NewScDict() f := &GetIntContext{ Params: ImmutableGetIntParams{ proxy: wasmlib.NewParamsProxy(), }, Results: MutableGetIntResults{ - proxy: wasmlib.NewResultsProxy(), + proxy: results.AsProxy(), }, State: ImmutableTestCoreState{ proxy: wasmlib.NewStateProxy(), @@ -531,6 +544,7 @@ func viewGetIntThunk(ctx wasmlib.ScViewContext) { ctx.Require(f.Params.Name().Exists(), "missing mandatory name") viewGetInt(ctx, f) ctx.Log("testcore.viewGetInt ok") + ctx.Results(results) } type GetStringValueContext struct { @@ -541,12 +555,13 @@ type GetStringValueContext struct { func viewGetStringValueThunk(ctx wasmlib.ScViewContext) { ctx.Log("testcore.viewGetStringValue") + results := wasmlib.NewScDict() f := &GetStringValueContext{ Params: ImmutableGetStringValueParams{ proxy: wasmlib.NewParamsProxy(), }, Results: MutableGetStringValueResults{ - proxy: wasmlib.NewResultsProxy(), + proxy: results.AsProxy(), }, State: ImmutableTestCoreState{ proxy: wasmlib.NewStateProxy(), @@ -555,6 +570,7 @@ func viewGetStringValueThunk(ctx wasmlib.ScViewContext) { ctx.Require(f.Params.VarName().Exists(), "missing mandatory varName") viewGetStringValue(ctx, f) ctx.Log("testcore.viewGetStringValue ok") + ctx.Results(results) } type JustViewContext struct { @@ -624,9 +640,10 @@ type TestChainOwnerIDViewContext struct { func viewTestChainOwnerIDViewThunk(ctx wasmlib.ScViewContext) { ctx.Log("testcore.viewTestChainOwnerIDView") + results := wasmlib.NewScDict() f := &TestChainOwnerIDViewContext{ Results: MutableTestChainOwnerIDViewResults{ - proxy: wasmlib.NewResultsProxy(), + proxy: results.AsProxy(), }, State: ImmutableTestCoreState{ proxy: wasmlib.NewStateProxy(), @@ -634,6 +651,7 @@ func viewTestChainOwnerIDViewThunk(ctx wasmlib.ScViewContext) { } viewTestChainOwnerIDView(ctx, f) ctx.Log("testcore.viewTestChainOwnerIDView ok") + ctx.Results(results) } type TestPanicViewEPContext struct { @@ -658,9 +676,10 @@ type TestSandboxCallContext struct { func viewTestSandboxCallThunk(ctx wasmlib.ScViewContext) { ctx.Log("testcore.viewTestSandboxCall") + results := wasmlib.NewScDict() f := &TestSandboxCallContext{ Results: MutableTestSandboxCallResults{ - proxy: wasmlib.NewResultsProxy(), + proxy: results.AsProxy(), }, State: ImmutableTestCoreState{ proxy: wasmlib.NewStateProxy(), @@ -668,4 +687,5 @@ func viewTestSandboxCallThunk(ctx wasmlib.ScViewContext) { } viewTestSandboxCall(ctx, f) ctx.Log("testcore.viewTestSandboxCall ok") + ctx.Results(results) } diff --git a/contracts/wasm/testcore/test/testcore_test.go b/contracts/wasm/testcore/test/testcore_test.go index a69abae03c..517b92e374 100644 --- a/contracts/wasm/testcore/test/testcore_test.go +++ b/contracts/wasm/testcore/test/testcore_test.go @@ -6,7 +6,6 @@ import ( "github.com/iotaledger/wasp/contracts/wasm/testcore/go/testcore" "github.com/iotaledger/wasp/packages/solo" - "github.com/iotaledger/wasp/packages/util" "github.com/iotaledger/wasp/packages/vm/core/testcore/sbtests/sbtestsc" "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/coreaccounts" @@ -55,33 +54,33 @@ func run2(t *testing.T, test func(*testing.T, bool), skipWasm ...bool) { *wasmsolo.GoWasm = false *wasmsolo.TsWasm = false - exists, _ := util.ExistsFilePath("../pkg/testcore_bg.wasm") - if exists { - wasmlib.ConnectHost(nil) - t.Run(fmt.Sprintf("run RUST version of %s", t.Name()), func(t *testing.T) { - test(t, true) - }) - } - - exists, _ = util.ExistsFilePath("../go/pkg/testcore_go.wasm") - if exists { - *wasmsolo.GoWasm = true - wasmlib.ConnectHost(nil) - t.Run(fmt.Sprintf("run GO version of %s", t.Name()), func(t *testing.T) { - test(t, true) - }) - *wasmsolo.GoWasm = false - } - - exists, _ = util.ExistsFilePath("../ts/pkg/testcore_ts.wasm") - if exists { - *wasmsolo.TsWasm = true - wasmlib.ConnectHost(nil) - t.Run(fmt.Sprintf("run TS version of %s", t.Name()), func(t *testing.T) { - test(t, true) - }) - *wasmsolo.TsWasm = false - } + //exists, _ := util.ExistsFilePath("../pkg/testcore_bg.wasm") + //if exists { + // wasmlib.ConnectHost(nil) + // t.Run(fmt.Sprintf("run RUST version of %s", t.Name()), func(t *testing.T) { + // test(t, true) + // }) + //} + // + //exists, _ = util.ExistsFilePath("../go/pkg/testcore_go.wasm") + //if exists { + // *wasmsolo.GoWasm = true + // wasmlib.ConnectHost(nil) + // t.Run(fmt.Sprintf("run GO version of %s", t.Name()), func(t *testing.T) { + // test(t, true) + // }) + // *wasmsolo.GoWasm = false + //} + // + //exists, _ = util.ExistsFilePath("../ts/pkg/testcore_ts.wasm") + //if exists { + // *wasmsolo.TsWasm = true + // wasmlib.ConnectHost(nil) + // t.Run(fmt.Sprintf("run TS version of %s", t.Name()), func(t *testing.T) { + // test(t, true) + // }) + // *wasmsolo.TsWasm = false + //} *wasmsolo.GoDebug = true wasmlib.ConnectHost(nil) diff --git a/contracts/wasm/testwasmlib/go/testwasmlib/lib.go b/contracts/wasm/testwasmlib/go/testwasmlib/lib.go index 78a8f60bc5..889af2998e 100644 --- a/contracts/wasm/testwasmlib/go/testwasmlib/lib.go +++ b/contracts/wasm/testwasmlib/go/testwasmlib/lib.go @@ -204,12 +204,13 @@ type ArrayLengthContext struct { func viewArrayLengthThunk(ctx wasmlib.ScViewContext) { ctx.Log("testwasmlib.viewArrayLength") + results := wasmlib.NewScDict() f := &ArrayLengthContext{ Params: ImmutableArrayLengthParams{ proxy: wasmlib.NewParamsProxy(), }, Results: MutableArrayLengthResults{ - proxy: wasmlib.NewResultsProxy(), + proxy: results.AsProxy(), }, State: ImmutableTestWasmLibState{ proxy: wasmlib.NewStateProxy(), @@ -218,6 +219,7 @@ func viewArrayLengthThunk(ctx wasmlib.ScViewContext) { ctx.Require(f.Params.Name().Exists(), "missing mandatory name") viewArrayLength(ctx, f) ctx.Log("testwasmlib.viewArrayLength ok") + ctx.Results(results) } type ArrayValueContext struct { @@ -228,12 +230,13 @@ type ArrayValueContext struct { func viewArrayValueThunk(ctx wasmlib.ScViewContext) { ctx.Log("testwasmlib.viewArrayValue") + results := wasmlib.NewScDict() f := &ArrayValueContext{ Params: ImmutableArrayValueParams{ proxy: wasmlib.NewParamsProxy(), }, Results: MutableArrayValueResults{ - proxy: wasmlib.NewResultsProxy(), + proxy: results.AsProxy(), }, State: ImmutableTestWasmLibState{ proxy: wasmlib.NewStateProxy(), @@ -243,6 +246,7 @@ func viewArrayValueThunk(ctx wasmlib.ScViewContext) { ctx.Require(f.Params.Name().Exists(), "missing mandatory name") viewArrayValue(ctx, f) ctx.Log("testwasmlib.viewArrayValue ok") + ctx.Results(results) } type BlockRecordContext struct { @@ -253,12 +257,13 @@ type BlockRecordContext struct { func viewBlockRecordThunk(ctx wasmlib.ScViewContext) { ctx.Log("testwasmlib.viewBlockRecord") + results := wasmlib.NewScDict() f := &BlockRecordContext{ Params: ImmutableBlockRecordParams{ proxy: wasmlib.NewParamsProxy(), }, Results: MutableBlockRecordResults{ - proxy: wasmlib.NewResultsProxy(), + proxy: results.AsProxy(), }, State: ImmutableTestWasmLibState{ proxy: wasmlib.NewStateProxy(), @@ -268,6 +273,7 @@ func viewBlockRecordThunk(ctx wasmlib.ScViewContext) { ctx.Require(f.Params.RecordIndex().Exists(), "missing mandatory recordIndex") viewBlockRecord(ctx, f) ctx.Log("testwasmlib.viewBlockRecord ok") + ctx.Results(results) } type BlockRecordsContext struct { @@ -278,12 +284,13 @@ type BlockRecordsContext struct { func viewBlockRecordsThunk(ctx wasmlib.ScViewContext) { ctx.Log("testwasmlib.viewBlockRecords") + results := wasmlib.NewScDict() f := &BlockRecordsContext{ Params: ImmutableBlockRecordsParams{ proxy: wasmlib.NewParamsProxy(), }, Results: MutableBlockRecordsResults{ - proxy: wasmlib.NewResultsProxy(), + proxy: results.AsProxy(), }, State: ImmutableTestWasmLibState{ proxy: wasmlib.NewStateProxy(), @@ -292,6 +299,7 @@ func viewBlockRecordsThunk(ctx wasmlib.ScViewContext) { ctx.Require(f.Params.BlockIndex().Exists(), "missing mandatory blockIndex") viewBlockRecords(ctx, f) ctx.Log("testwasmlib.viewBlockRecords ok") + ctx.Results(results) } type GetRandomContext struct { @@ -301,9 +309,10 @@ type GetRandomContext struct { func viewGetRandomThunk(ctx wasmlib.ScViewContext) { ctx.Log("testwasmlib.viewGetRandom") + results := wasmlib.NewScDict() f := &GetRandomContext{ Results: MutableGetRandomResults{ - proxy: wasmlib.NewResultsProxy(), + proxy: results.AsProxy(), }, State: ImmutableTestWasmLibState{ proxy: wasmlib.NewStateProxy(), @@ -311,6 +320,7 @@ func viewGetRandomThunk(ctx wasmlib.ScViewContext) { } viewGetRandom(ctx, f) ctx.Log("testwasmlib.viewGetRandom ok") + ctx.Results(results) } type IotaBalanceContext struct { @@ -320,9 +330,10 @@ type IotaBalanceContext struct { func viewIotaBalanceThunk(ctx wasmlib.ScViewContext) { ctx.Log("testwasmlib.viewIotaBalance") + results := wasmlib.NewScDict() f := &IotaBalanceContext{ Results: MutableIotaBalanceResults{ - proxy: wasmlib.NewResultsProxy(), + proxy: results.AsProxy(), }, State: ImmutableTestWasmLibState{ proxy: wasmlib.NewStateProxy(), @@ -330,6 +341,7 @@ func viewIotaBalanceThunk(ctx wasmlib.ScViewContext) { } viewIotaBalance(ctx, f) ctx.Log("testwasmlib.viewIotaBalance ok") + ctx.Results(results) } type MapValueContext struct { @@ -340,12 +352,13 @@ type MapValueContext struct { func viewMapValueThunk(ctx wasmlib.ScViewContext) { ctx.Log("testwasmlib.viewMapValue") + results := wasmlib.NewScDict() f := &MapValueContext{ Params: ImmutableMapValueParams{ proxy: wasmlib.NewParamsProxy(), }, Results: MutableMapValueResults{ - proxy: wasmlib.NewResultsProxy(), + proxy: results.AsProxy(), }, State: ImmutableTestWasmLibState{ proxy: wasmlib.NewStateProxy(), @@ -355,4 +368,5 @@ func viewMapValueThunk(ctx wasmlib.ScViewContext) { ctx.Require(f.Params.Name().Exists(), "missing mandatory name") viewMapValue(ctx, f) ctx.Log("testwasmlib.viewMapValue ok") + ctx.Results(results) } diff --git a/contracts/wasm/timestamp/go/timestamp/lib.go b/contracts/wasm/timestamp/go/timestamp/lib.go index 0bc59d0fc7..d136a17f28 100644 --- a/contracts/wasm/timestamp/go/timestamp/lib.go +++ b/contracts/wasm/timestamp/go/timestamp/lib.go @@ -37,9 +37,10 @@ type GetTimestampContext struct { func viewGetTimestampThunk(ctx wasmlib.ScViewContext) { ctx.Log("timestamp.viewGetTimestamp") + results := wasmlib.NewScDict() f := &GetTimestampContext{ Results: MutableGetTimestampResults{ - proxy: wasmlib.NewResultsProxy(), + proxy: results.AsProxy(), }, State: ImmutabletimestampState{ proxy: wasmlib.NewStateProxy(), @@ -47,4 +48,5 @@ func viewGetTimestampThunk(ctx wasmlib.ScViewContext) { } viewGetTimestamp(ctx, f) ctx.Log("timestamp.viewGetTimestamp ok") + ctx.Results(results) } diff --git a/packages/vm/wasmhost/wasmgovm.go b/packages/vm/wasmhost/wasmgovm.go index 6e0a7e64ab..f72b4ea646 100644 --- a/packages/vm/wasmhost/wasmgovm.go +++ b/packages/vm/wasmhost/wasmgovm.go @@ -8,6 +8,7 @@ import ( "strings" "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" + "golang.org/x/xerrors" ) // provide implementation for Wasm-only function @@ -57,7 +58,21 @@ func (vm *WasmGoVM) RunFunction(functionName string, args ...interface{}) error return errors.New("WasmGoVM: cannot run function: " + functionName) } -func (vm *WasmGoVM) RunScFunction(index int32) error { +func (vm *WasmGoVM) RunScFunction(index int32) (err error) { + defer func() { + r := recover() + if r == nil { + return + } + switch errType := r.(type) { + case error: + err = errType + case string: + err = errors.New(errType) + default: + err = xerrors.Errorf("RunScFunction: %v", errType) + } + }() return vm.Run(func() error { wasmlib.OnCall(index) return nil diff --git a/packages/vm/wasmhost/wasmprocessor.go b/packages/vm/wasmhost/wasmprocessor.go index 233e408cd9..99ef92495e 100644 --- a/packages/vm/wasmhost/wasmprocessor.go +++ b/packages/vm/wasmhost/wasmprocessor.go @@ -23,7 +23,10 @@ type WasmProcessor struct { wasmVM func() WasmVM } -var _ iscp.VMProcessor = &WasmProcessor{} +var ( + _ iscp.VMProcessor = new(WasmProcessor) + _ WasmStore = new(WasmProcessor) +) var GoWasmVM func() WasmVM @@ -58,22 +61,6 @@ func GetProcessor(wasmBytes []byte, log *logger.Logger) (iscp.VMProcessor, error return proc, nil } -func (proc *WasmProcessor) GetDescription() string { - return "Wasm VM smart contract processor" -} - -func (proc *WasmProcessor) GetEntryPoint(code iscp.Hname) (iscp.VMProcessorEntryPoint, bool) { - function := proc.FunctionFromCode(uint32(code)) - if function == "" && code != iscp.EntryPointInit { - return nil, false - } - return proc.wasmContext(function), true -} - -func (proc *WasmProcessor) GetDefaultEntryPoint() iscp.VMProcessorEntryPoint { - return proc.wasmContext(FuncDefault) -} - func (proc *WasmProcessor) GetContext(id int32) *WasmContext { if id == 0 { id = proc.currentContextID @@ -93,27 +80,20 @@ func (proc *WasmProcessor) GetContext(id int32) *WasmContext { return mainProcessor.contexts[id] } -func (proc *WasmProcessor) KillContext(id int32) { - proc.contextLock.Lock() - defer proc.contextLock.Unlock() - delete(proc.contexts, id) +func (proc *WasmProcessor) GetDefaultEntryPoint() iscp.VMProcessorEntryPoint { + return proc.wasmContext(FuncDefault) } -func (proc *WasmProcessor) wasmContext(function string) *WasmContext { - processor := proc - vmInstance := proc.NewInstance() - if vmInstance != nil { - processor = proc.getSubProcessor(vmInstance) - } - wc := NewWasmContext(function, processor) - - proc.contextLock.Lock() - defer proc.contextLock.Unlock() +func (proc *WasmProcessor) GetDescription() string { + return "Wasm VM smart contract processor" +} - proc.nextContextID++ - wc.id = proc.nextContextID - proc.contexts[wc.id] = wc - return wc +func (proc *WasmProcessor) GetEntryPoint(code iscp.Hname) (iscp.VMProcessorEntryPoint, bool) { + function := proc.FunctionFromCode(uint32(code)) + if function == "" && code != iscp.EntryPointInit { + return nil, false + } + return proc.wasmContext(function), true } func (proc *WasmProcessor) getSubProcessor(vmInstance WasmVM) *WasmProcessor { @@ -138,3 +118,26 @@ func (proc *WasmProcessor) getSubProcessor(vmInstance WasmVM) *WasmProcessor { } return processor } + +func (proc *WasmProcessor) KillContext(id int32) { + proc.contextLock.Lock() + defer proc.contextLock.Unlock() + delete(proc.contexts, id) +} + +func (proc *WasmProcessor) wasmContext(function string) *WasmContext { + processor := proc + vmInstance := proc.NewInstance() + if vmInstance != nil { + processor = proc.getSubProcessor(vmInstance) + } + wc := NewWasmContext(function, processor) + + proc.contextLock.Lock() + defer proc.contextLock.Unlock() + + proc.nextContextID++ + wc.id = proc.nextContextID + proc.contexts[wc.id] = wc + return wc +} diff --git a/packages/vm/wasmhost/wasmtosandbox.go b/packages/vm/wasmhost/wasmtosandbox.go index b0b6edf2cf..2ea5f3feb2 100644 --- a/packages/vm/wasmhost/wasmtosandbox.go +++ b/packages/vm/wasmhost/wasmtosandbox.go @@ -39,6 +39,7 @@ var sandboxFunctions = []func(*WasmToSandbox, []byte) []byte{ (*WasmToSandbox).fnPost, (*WasmToSandbox).fnRequest, (*WasmToSandbox).fnRequestID, + (*WasmToSandbox).fnResults, (*WasmToSandbox).fnSend, (*WasmToSandbox).fnStateAnchor, (*WasmToSandbox).fnTimestamp, @@ -262,6 +263,15 @@ func (s *WasmToSandbox) fnRequestID(args []byte) []byte { return s.ctx.Request().ID().Bytes() } +func (s *WasmToSandbox) fnResults(args []byte) []byte { + results, err := dict.FromBytes(args) + if err != nil { + s.Panicf("call results: %s", err.Error()) + } + s.wc.results = results + return nil +} + // transfer tokens to address func (s *WasmToSandbox) fnSend(args []byte) []byte { req := wasmrequests.NewSendRequestFromBytes(args) diff --git a/packages/vm/wasmlib/go/wasmlib/dict.go b/packages/vm/wasmlib/go/wasmlib/dict.go index ad9a9febbe..c573866277 100644 --- a/packages/vm/wasmlib/go/wasmlib/dict.go +++ b/packages/vm/wasmlib/go/wasmlib/dict.go @@ -14,19 +14,14 @@ type ScDict map[string][]byte var _ wasmtypes.IKvStore = ScDict{} -func NewDictProxy() wasmtypes.Proxy { - return wasmtypes.NewProxy(NewScDict()) -} - -func NewResultsProxy() wasmtypes.Proxy { - return wasmtypes.NewProxy(NewScDict()) -} - func NewScDict() ScDict { return make(ScDict) } func NewScDictFromBytes(buf []byte) ScDict { + if len(buf) == 0 { + return make(ScDict) + } size, buf := wasmcodec.ExtractUint32(buf) dict := make(ScDict, size) var k uint16 @@ -43,6 +38,10 @@ func NewScDictFromBytes(buf []byte) ScDict { return dict } +func (d ScDict) AsProxy() wasmtypes.Proxy { + return wasmtypes.NewProxy(d) +} + func (d ScDict) Bytes() []byte { keys := make([]string, 0, len(d)) for key := range d { diff --git a/packages/vm/wasmlib/go/wasmlib/sandbox.go b/packages/vm/wasmlib/go/wasmlib/sandbox.go index 96ee894e58..0fbcd3c0a2 100644 --- a/packages/vm/wasmlib/go/wasmlib/sandbox.go +++ b/packages/vm/wasmlib/go/wasmlib/sandbox.go @@ -33,20 +33,21 @@ const ( FnPost = int32(-19) FnRequest = int32(-20) FnRequestID = int32(-21) - FnSend = int32(-22) - FnStateAnchor = int32(-23) - FnTimestamp = int32(-24) - FnTrace = int32(-25) - FnUtilsBase58Decode = int32(-26) - FnUtilsBase58Encode = int32(-27) - FnUtilsBlsAddress = int32(-28) - FnUtilsBlsAggregate = int32(-29) - FnUtilsBlsValid = int32(-30) - FnUtilsEd25519Address = int32(-31) - FnUtilsEd25519Valid = int32(-32) - FnUtilsHashBlake2b = int32(-33) - FnUtilsHashName = int32(-34) - FnUtilsHashSha3 = int32(-35) + FnResults = int32(-22) + FnSend = int32(-23) + FnStateAnchor = int32(-24) + FnTimestamp = int32(-25) + FnTrace = int32(-26) + FnUtilsBase58Decode = int32(-27) + FnUtilsBase58Encode = int32(-28) + FnUtilsBlsAddress = int32(-29) + FnUtilsBlsAggregate = int32(-30) + FnUtilsBlsValid = int32(-31) + FnUtilsEd25519Address = int32(-32) + FnUtilsEd25519Valid = int32(-33) + FnUtilsHashBlake2b = int32(-34) + FnUtilsHashName = int32(-35) + FnUtilsHashSha3 = int32(-36) ) type ScSandbox struct{} @@ -135,6 +136,10 @@ func (s ScSandbox) Require(cond bool, msg string) { } } +func (s ScSandbox) Results(results ScDict) { + Sandbox(FnResults, results.Bytes()) +} + // deterministic time stamp fixed at the moment of calling the smart contract func (s ScSandbox) Timestamp() uint64 { ts, _ := wasmcodec.ExtractUint64(Sandbox(FnTimestamp, nil)) diff --git a/packages/vm/wasmlib/go/wasmlib/wasmtypes/bool.go b/packages/vm/wasmlib/go/wasmlib/wasmtypes/bool.go index edb35a1f04..00d9e85bf2 100644 --- a/packages/vm/wasmlib/go/wasmlib/wasmtypes/bool.go +++ b/packages/vm/wasmlib/go/wasmlib/wasmtypes/bool.go @@ -22,6 +22,9 @@ func EncodeBool(enc *wasmcodec.WasmEncoder, value bool) { } func BoolFromBytes(buf []byte) bool { + if buf == nil { + return false + } if len(buf) != 1 { Panic("invalid Bool length") } diff --git a/packages/vm/wasmlib/go/wasmlib/wasmtypes/int16.go b/packages/vm/wasmlib/go/wasmlib/wasmtypes/int16.go index 8f182628ed..bec0706fc9 100644 --- a/packages/vm/wasmlib/go/wasmlib/wasmtypes/int16.go +++ b/packages/vm/wasmlib/go/wasmlib/wasmtypes/int16.go @@ -22,6 +22,9 @@ func EncodeInt16(enc *wasmcodec.WasmEncoder, value int16) { } func Int16FromBytes(buf []byte) int16 { + if buf == nil { + return 0 + } if len(buf) != 2 { Panic("invalid Int16 length") } diff --git a/packages/vm/wasmlib/go/wasmlib/wasmtypes/int32.go b/packages/vm/wasmlib/go/wasmlib/wasmtypes/int32.go index f0e4417aaf..bc506de308 100644 --- a/packages/vm/wasmlib/go/wasmlib/wasmtypes/int32.go +++ b/packages/vm/wasmlib/go/wasmlib/wasmtypes/int32.go @@ -22,6 +22,9 @@ func EncodeInt32(enc *wasmcodec.WasmEncoder, value int32) { } func Int32FromBytes(buf []byte) int32 { + if buf == nil { + return 0 + } if len(buf) != 4 { Panic("invalid Int32 length") } diff --git a/packages/vm/wasmlib/go/wasmlib/wasmtypes/int64.go b/packages/vm/wasmlib/go/wasmlib/wasmtypes/int64.go index 457cdae295..c92c6cef8a 100644 --- a/packages/vm/wasmlib/go/wasmlib/wasmtypes/int64.go +++ b/packages/vm/wasmlib/go/wasmlib/wasmtypes/int64.go @@ -21,6 +21,9 @@ func EncodeInt64(enc *wasmcodec.WasmEncoder, value int64) { } func Int64FromBytes(buf []byte) int64 { + if buf == nil { + return 0 + } if len(buf) != 8 { Panic("invalid Int64 length") } diff --git a/packages/vm/wasmlib/go/wasmlib/wasmtypes/int8.go b/packages/vm/wasmlib/go/wasmlib/wasmtypes/int8.go index 2a707a8e4d..e1ccfea9a6 100644 --- a/packages/vm/wasmlib/go/wasmlib/wasmtypes/int8.go +++ b/packages/vm/wasmlib/go/wasmlib/wasmtypes/int8.go @@ -20,6 +20,9 @@ func EncodeInt8(enc *wasmcodec.WasmEncoder, value int8) { } func Int8FromBytes(buf []byte) int8 { + if buf == nil { + return 0 + } if len(buf) != 1 { Panic("invalid Int8 length") } diff --git a/packages/vm/wasmlib/go/wasmlib/wasmtypes/uint16.go b/packages/vm/wasmlib/go/wasmlib/wasmtypes/uint16.go index 2235c58d2e..202c7c0fbd 100644 --- a/packages/vm/wasmlib/go/wasmlib/wasmtypes/uint16.go +++ b/packages/vm/wasmlib/go/wasmlib/wasmtypes/uint16.go @@ -22,6 +22,9 @@ func EncodeUint16(enc *wasmcodec.WasmEncoder, value uint16) { } func Uint16FromBytes(buf []byte) uint16 { + if buf == nil { + return 0 + } if len(buf) != 2 { Panic("invalid Uint16 length") } diff --git a/packages/vm/wasmlib/go/wasmlib/wasmtypes/uint32.go b/packages/vm/wasmlib/go/wasmlib/wasmtypes/uint32.go index 6e0be58dde..e867881b8c 100644 --- a/packages/vm/wasmlib/go/wasmlib/wasmtypes/uint32.go +++ b/packages/vm/wasmlib/go/wasmlib/wasmtypes/uint32.go @@ -22,6 +22,9 @@ func EncodeUint32(enc *wasmcodec.WasmEncoder, value uint32) { } func Uint32FromBytes(buf []byte) uint32 { + if buf == nil { + return 0 + } if len(buf) != 4 { Panic("invalid Uint32 length") } diff --git a/packages/vm/wasmlib/go/wasmlib/wasmtypes/uint64.go b/packages/vm/wasmlib/go/wasmlib/wasmtypes/uint64.go index 65d9e31d49..c2fe939c04 100644 --- a/packages/vm/wasmlib/go/wasmlib/wasmtypes/uint64.go +++ b/packages/vm/wasmlib/go/wasmlib/wasmtypes/uint64.go @@ -21,6 +21,9 @@ func EncodeUint64(enc *wasmcodec.WasmEncoder, value uint64) { } func Uint64FromBytes(buf []byte) uint64 { + if buf == nil { + return 0 + } if len(buf) != 8 { Panic("invalid Uint64 length") } diff --git a/packages/vm/wasmlib/go/wasmlib/wasmtypes/uint8.go b/packages/vm/wasmlib/go/wasmlib/wasmtypes/uint8.go index 3c6bde78f7..70ff00c472 100644 --- a/packages/vm/wasmlib/go/wasmlib/wasmtypes/uint8.go +++ b/packages/vm/wasmlib/go/wasmlib/wasmtypes/uint8.go @@ -20,6 +20,9 @@ func EncodeUint8(enc *wasmcodec.WasmEncoder, value uint8) { } func Uint8FromBytes(buf []byte) uint8 { + if buf == nil { + return 0 + } if len(buf) != 1 { Panic("invalid Uint8 length") } diff --git a/packages/vm/wasmsolo/solosandbox.go b/packages/vm/wasmsolo/solosandbox.go index 44121be46a..d16319261a 100644 --- a/packages/vm/wasmsolo/solosandbox.go +++ b/packages/vm/wasmsolo/solosandbox.go @@ -39,6 +39,7 @@ var sandboxFunctions = []func(*SoloSandbox, []byte) []byte{ (*SoloSandbox).fnPost, (*SoloSandbox).fnRequest, (*SoloSandbox).fnRequestID, + (*SoloSandbox).fnResults, (*SoloSandbox).fnSend, (*SoloSandbox).fnStateAnchor, (*SoloSandbox).fnTimestamp, @@ -155,8 +156,9 @@ func (s *SoloSandbox) fnCall(args []byte) []byte { } res, err := s.ctx.Chain.CallView(s.ctx.scName, funcName, params) + s.ctx.Err = err if err != nil { - s.Panicf(err.Error()) + return nil } return res.Bytes() } @@ -238,7 +240,7 @@ func (s *SoloSandbox) fnPost(args []byte) []byte { s.checkErr(err) transfer, err := colored.BalancesFromBytes(req.Transfer) s.checkErr(err) - if len(transfer) == 0 { + if len(transfer) == 0 && !s.ctx.offLedger { s.Panicf("transfer is required for post") } if req.Delay != 0 { @@ -255,6 +257,10 @@ func (s *SoloSandbox) fnRequestID(args []byte) []byte { return append(s.ctx.Chain.ChainID.Bytes()[1:], 0, 0) } +func (s *SoloSandbox) fnResults(args []byte) []byte { + panic("implement me") +} + // transfer tokens to address func (s *SoloSandbox) fnSend(args []byte) []byte { panic("implement me") diff --git a/tools/schema/generator/gotemplates/lib.go b/tools/schema/generator/gotemplates/lib.go index 537e1c3545..6203505b5e 100644 --- a/tools/schema/generator/gotemplates/lib.go +++ b/tools/schema/generator/gotemplates/lib.go @@ -29,6 +29,7 @@ $#if view ImmutablePackageState func $kind$FuncName$+Thunk(ctx wasmlib.Sc$Kind$+Context) { ctx.Log("$package.$kind$FuncName") +$#if result initResultDict f := &$FuncName$+Context{ $#if param ImmutableFuncNameParamsInit $#if result MutableFuncNameResultsInit @@ -39,7 +40,16 @@ $#emit accessCheck $#each mandatory requireMandatory $kind$FuncName(ctx, f) ctx.Log("$package.$kind$FuncName ok") +$#if result returnResultDict } +`, + // ******************************* + "initResultDict": ` + results := wasmlib.NewScDict() +`, + // ******************************* + "returnResultDict": ` + ctx.Results(results) `, // ******************************* "PackageEvents": ` @@ -66,7 +76,7 @@ $#if events PackageEventsExist // ******************************* "MutableFuncNameResultsInit": ` Results: Mutable$FuncName$+Results{ - proxy: wasmlib.NewResultsProxy(), + proxy: results.AsProxy(), }, `, // ******************************* From 37a6074d8e6bdc5316be733afcfdd46ae2f8b997 Mon Sep 17 00:00:00 2001 From: Eric Hop Date: Tue, 25 Jan 2022 11:54:35 -0800 Subject: [PATCH 045/111] Implemented default values for hash types --- packages/vm/wasmlib/go/wasmlib/wasmtypes/address.go | 3 +++ packages/vm/wasmlib/go/wasmlib/wasmtypes/agentid.go | 3 +++ packages/vm/wasmlib/go/wasmlib/wasmtypes/chainid.go | 3 +++ packages/vm/wasmlib/go/wasmlib/wasmtypes/color.go | 3 +++ packages/vm/wasmlib/go/wasmlib/wasmtypes/hash.go | 3 +++ packages/vm/wasmlib/go/wasmlib/wasmtypes/hname.go | 3 +++ packages/vm/wasmlib/go/wasmlib/wasmtypes/requestid.go | 3 +++ packages/vm/wasmsolo/solosandbox.go | 5 +++++ 8 files changed, 26 insertions(+) diff --git a/packages/vm/wasmlib/go/wasmlib/wasmtypes/address.go b/packages/vm/wasmlib/go/wasmlib/wasmtypes/address.go index 1254eb58a7..dcafc361ce 100644 --- a/packages/vm/wasmlib/go/wasmlib/wasmtypes/address.go +++ b/packages/vm/wasmlib/go/wasmlib/wasmtypes/address.go @@ -24,6 +24,9 @@ func EncodeAddress(enc *wasmcodec.WasmEncoder, value ScAddress) { } func AddressFromBytes(buf []byte) ScAddress { + if buf == nil { + return ScAddress{} + } if len(buf) != ScAddressLength { Panic("invalid Address length") } diff --git a/packages/vm/wasmlib/go/wasmlib/wasmtypes/agentid.go b/packages/vm/wasmlib/go/wasmlib/wasmtypes/agentid.go index 16731318e7..19b1686daa 100644 --- a/packages/vm/wasmlib/go/wasmlib/wasmtypes/agentid.go +++ b/packages/vm/wasmlib/go/wasmlib/wasmtypes/agentid.go @@ -26,6 +26,9 @@ func EncodeAgentID(enc *wasmcodec.WasmEncoder, value ScAgentID) { } func AgentIDFromBytes(buf []byte) ScAgentID { + if buf == nil { + return ScAgentID{} + } if len(buf) != ScAgentIDLength { Panic("invalid AgentID length") } diff --git a/packages/vm/wasmlib/go/wasmlib/wasmtypes/chainid.go b/packages/vm/wasmlib/go/wasmlib/wasmtypes/chainid.go index 2152c646a0..f2dda1d03e 100644 --- a/packages/vm/wasmlib/go/wasmlib/wasmtypes/chainid.go +++ b/packages/vm/wasmlib/go/wasmlib/wasmtypes/chainid.go @@ -24,6 +24,9 @@ func EncodeChainID(enc *wasmcodec.WasmEncoder, value ScChainID) { } func ChainIDFromBytes(buf []byte) ScChainID { + if buf == nil { + return ScChainID{id: [ScChainIDLength]byte{2}} + } if len(buf) != ScChainIDLength { Panic("invalid ChainID length") } diff --git a/packages/vm/wasmlib/go/wasmlib/wasmtypes/color.go b/packages/vm/wasmlib/go/wasmlib/wasmtypes/color.go index 414d760c9c..5b826c6c43 100644 --- a/packages/vm/wasmlib/go/wasmlib/wasmtypes/color.go +++ b/packages/vm/wasmlib/go/wasmlib/wasmtypes/color.go @@ -35,6 +35,9 @@ func EncodeColor(enc *wasmcodec.WasmEncoder, value ScColor) { } func ColorFromBytes(buf []byte) ScColor { + if buf == nil { + return ScColor{} + } if len(buf) != ScColorLength { Panic("invalid Color length") } diff --git a/packages/vm/wasmlib/go/wasmlib/wasmtypes/hash.go b/packages/vm/wasmlib/go/wasmlib/wasmtypes/hash.go index a79836b39a..6b44f2390e 100644 --- a/packages/vm/wasmlib/go/wasmlib/wasmtypes/hash.go +++ b/packages/vm/wasmlib/go/wasmlib/wasmtypes/hash.go @@ -24,6 +24,9 @@ func EncodeHash(enc *wasmcodec.WasmEncoder, value ScHash) { } func HashFromBytes(buf []byte) ScHash { + if buf == nil { + return ScHash{} + } if len(buf) != ScHashLength { Panic("invalid Hash length") } diff --git a/packages/vm/wasmlib/go/wasmlib/wasmtypes/hname.go b/packages/vm/wasmlib/go/wasmlib/wasmtypes/hname.go index daa11ab441..18ba9f7433 100644 --- a/packages/vm/wasmlib/go/wasmlib/wasmtypes/hname.go +++ b/packages/vm/wasmlib/go/wasmlib/wasmtypes/hname.go @@ -24,6 +24,9 @@ func EncodeHname(enc *wasmcodec.WasmEncoder, value ScHname) { } func HnameFromBytes(buf []byte) ScHname { + if buf == nil { + return 0 + } if len(buf) != ScHnameLength { Panic("invalid Hname length") } diff --git a/packages/vm/wasmlib/go/wasmlib/wasmtypes/requestid.go b/packages/vm/wasmlib/go/wasmlib/wasmtypes/requestid.go index b3a8ea73ff..4feea99e87 100644 --- a/packages/vm/wasmlib/go/wasmlib/wasmtypes/requestid.go +++ b/packages/vm/wasmlib/go/wasmlib/wasmtypes/requestid.go @@ -24,6 +24,9 @@ func EncodeRequestID(enc *wasmcodec.WasmEncoder, value ScRequestID) { } func RequestIDFromBytes(buf []byte) ScRequestID { + if buf == nil { + return ScRequestID{} + } if len(buf) != ScRequestIDLength { Panic("invalid RequestID length") } diff --git a/packages/vm/wasmsolo/solosandbox.go b/packages/vm/wasmsolo/solosandbox.go index d16319261a..7ae23ea0e9 100644 --- a/packages/vm/wasmsolo/solosandbox.go +++ b/packages/vm/wasmsolo/solosandbox.go @@ -4,6 +4,7 @@ import ( "bytes" "time" + "github.com/iotaledger/goshimmer/packages/ledgerstate" "github.com/iotaledger/wasp/packages/iscp" "github.com/iotaledger/wasp/packages/iscp/colored" "github.com/iotaledger/wasp/packages/kv/codec" @@ -89,6 +90,10 @@ func (s *SoloSandbox) postSync(contract, function string, params dict.Dict, tran req := solo.NewCallParamsFromDic(contract, function, params) req.WithTransfers(transfer) ctx := s.ctx + if ctx.mint > 0 { + mintAddress := ledgerstate.NewED25519Address(ctx.keyPair.PublicKey) + req.WithMint(mintAddress, ctx.mint) + } _ = wasmhost.Connect(ctx.wasmHostOld) var res dict.Dict if ctx.offLedger { From eeb77dc3e2b456d4d9c5c2177ec2bb21d3271f76 Mon Sep 17 00:00:00 2001 From: Eric Hop Date: Wed, 26 Jan 2022 08:27:55 -0800 Subject: [PATCH 046/111] GoDebug and GoWasm pass all wasm tests --- .../wasm/testcore/go/testcore/testcore.go | 6 +- contracts/wasm/testcore/test/spawn_test.go | 3 +- contracts/wasm/testcore/test/testcore_test.go | 23 ++--- packages/kv/collections/array16.go | 54 ++++++---- packages/kv/collections/array32.go | 57 +++++++---- packages/vm/wasmhost/wasmcontext.go | 2 +- packages/vm/wasmhost/wasmgovm.go | 29 +++--- packages/vm/wasmhost/wasmvm.go | 46 ++++++--- packages/vm/wasmlib/go/wasmlib/assets.go | 27 ++--- packages/vm/wasmlib/go/wasmlib/context.go | 6 +- packages/vm/wasmlib/go/wasmlib/contract.go | 7 +- packages/vm/wasmlib/go/wasmlib/dict.go | 31 +++--- packages/vm/wasmlib/go/wasmlib/sandbox.go | 7 +- .../vm/wasmlib/go/wasmlib/sandboxutils.go | 6 +- .../vm/wasmlib/go/wasmlib/wasmcodec/buffer.go | 99 ------------------- .../vm/wasmlib/go/wasmlib/wasmcodec/codec.go | 6 +- .../vm/wasmlib/go/wasmlib/wasmtypes/bool.go | 12 ++- .../vm/wasmlib/go/wasmlib/wasmtypes/uint16.go | 12 +-- .../vm/wasmlib/go/wasmlib/wasmtypes/uint32.go | 7 +- .../vm/wasmlib/go/wasmlib/wasmtypes/uint64.go | 6 +- .../vm/wasmlib/go/wasmlib/wasmtypes/uint8.go | 4 +- packages/vm/wasmsolo/solocontext.go | 3 +- packages/vm/wasmsolo/solosandbox.go | 23 ++++- packages/vm/wasmvmhost/host.go | 3 + 24 files changed, 237 insertions(+), 242 deletions(-) delete mode 100644 packages/vm/wasmlib/go/wasmlib/wasmcodec/buffer.go diff --git a/contracts/wasm/testcore/go/testcore/testcore.go b/contracts/wasm/testcore/go/testcore/testcore.go index 51f7b4c0fe..1bb58c5470 100644 --- a/contracts/wasm/testcore/go/testcore/testcore.go +++ b/contracts/wasm/testcore/go/testcore/testcore.go @@ -8,7 +8,7 @@ import ( "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/coreaccounts" "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/coregovernance" - "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmcodec" + "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" ) const ( @@ -41,9 +41,9 @@ func funcCallOnChain(ctx wasmlib.ScFuncContext, f *CallOnChainContext) { counter.SetValue(counter.Value() + 1) params := wasmlib.NewScDict() - params.Set([]byte(ParamIntValue), wasmcodec.AppendInt64(nil, paramIn)) + params.Set([]byte(ParamIntValue), wasmtypes.BytesFromInt64(paramIn)) ret := ctx.Call(hnameContract, hnameEP, params, nil) - retVal, _ := wasmcodec.ExtractInt64(ret.Get([]byte(ParamIntValue))) + retVal := wasmtypes.Int64FromBytes(ret.Get([]byte(ParamIntValue))) f.Results.IntValue().SetValue(retVal) } diff --git a/contracts/wasm/testcore/test/spawn_test.go b/contracts/wasm/testcore/test/spawn_test.go index 7be97ab57e..b0e9f22061 100644 --- a/contracts/wasm/testcore/test/spawn_test.go +++ b/contracts/wasm/testcore/test/spawn_test.go @@ -17,7 +17,8 @@ func TestSpawn(t *testing.T) { f.Func.TransferIotas(1).Post() require.NoError(t, ctx.Err) - ctxSpawn := ctx.SoloContextForCore(t, testcore.ScName+"_spawned", testcore.OnLoad) + spawnedName := testcore.ScName + "_spawned" + ctxSpawn := ctx.SoloContextForCore(t, spawnedName, testcore.OnLoad) require.NoError(t, ctxSpawn.Err) v := testcore.ScFuncs.GetCounter(ctxSpawn) v.Func.Call() diff --git a/contracts/wasm/testcore/test/testcore_test.go b/contracts/wasm/testcore/test/testcore_test.go index 517b92e374..eb6ad5f7ff 100644 --- a/contracts/wasm/testcore/test/testcore_test.go +++ b/contracts/wasm/testcore/test/testcore_test.go @@ -6,6 +6,7 @@ import ( "github.com/iotaledger/wasp/contracts/wasm/testcore/go/testcore" "github.com/iotaledger/wasp/packages/solo" + "github.com/iotaledger/wasp/packages/util" "github.com/iotaledger/wasp/packages/vm/core/testcore/sbtests/sbtestsc" "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/coreaccounts" @@ -61,17 +62,17 @@ func run2(t *testing.T, test func(*testing.T, bool), skipWasm ...bool) { // test(t, true) // }) //} - // - //exists, _ = util.ExistsFilePath("../go/pkg/testcore_go.wasm") - //if exists { - // *wasmsolo.GoWasm = true - // wasmlib.ConnectHost(nil) - // t.Run(fmt.Sprintf("run GO version of %s", t.Name()), func(t *testing.T) { - // test(t, true) - // }) - // *wasmsolo.GoWasm = false - //} - // + + exists, _ := util.ExistsFilePath("../go/pkg/testcore_go.wasm") + if exists { + *wasmsolo.GoWasm = true + wasmlib.ConnectHost(nil) + t.Run(fmt.Sprintf("run GO version of %s", t.Name()), func(t *testing.T) { + test(t, true) + }) + *wasmsolo.GoWasm = false + } + //exists, _ = util.ExistsFilePath("../ts/pkg/testcore_ts.wasm") //if exists { // *wasmsolo.TsWasm = true diff --git a/packages/kv/collections/array16.go b/packages/kv/collections/array16.go index 2c19c8ecba..cdd5a8681f 100644 --- a/packages/kv/collections/array16.go +++ b/packages/kv/collections/array16.go @@ -1,4 +1,3 @@ -//nolint:dupl package collections import ( @@ -6,7 +5,6 @@ import ( "fmt" "github.com/iotaledger/wasp/packages/kv" - "github.com/iotaledger/wasp/packages/util" ) // Array16 represents a dynamic array stored in a kv.KVStore @@ -37,27 +35,15 @@ func NewArray16ReadOnly(kvReader kv.KVStoreReader, name string) *ImmutableArray1 const array16ElemKeyCode = byte('#') -func (a *Array16) Immutable() *ImmutableArray16 { - return a.ImmutableArray16 -} - -func (a *ImmutableArray16) getSizeKey() kv.Key { - return array16SizeKey(a.name) -} - func array16SizeKey(name string) kv.Key { return kv.Key(name) } -func (a *ImmutableArray16) getArray16ElemKey(idx uint16) kv.Key { - return array16ElemKey(a.name, idx) -} - func array16ElemKey(name string, idx uint16) kv.Key { var buf bytes.Buffer buf.Write([]byte(name)) buf.WriteByte(array16ElemKeyCode) - _ = util.WriteUint16(&buf, idx) + buf.Write(uint16ToBytes(idx)) return kv.Key(buf.Bytes()) } @@ -73,11 +59,45 @@ func Array16RangeKeys(name string, length, from, to uint16) []kv.Key { return keys } +// use ULEB128 decoding so that WasmLib can use it as well +func bytesToUint16(buf []byte) uint16 { + if (buf[0] & 0x80) == 0 { + return uint16(buf[0]) + } + if (buf[1] & 0x80) == 0 { + return (uint16(buf[1]) << 7) | uint16(buf[0]&0x7f) + } + return (uint16(buf[2]) << 14) | (uint16(buf[1]&0x7f) << 7) | uint16(buf[0]&0x7f) +} + +// use ULEB128 encoding so that WasmLib can decode it as well +func uint16ToBytes(value uint16) []byte { + if value < 128 { + return []byte{byte(value)} + } + if value < 16384 { + return []byte{byte(value | 0x80), byte(value >> 7)} + } + return []byte{byte(value | 0x80), byte((value >> 7) | 0x80), byte(value >> 14)} +} + +func (a *Array16) Immutable() *ImmutableArray16 { + return a.ImmutableArray16 +} + +func (a *ImmutableArray16) getSizeKey() kv.Key { + return array16SizeKey(a.name) +} + +func (a *ImmutableArray16) getArray16ElemKey(idx uint16) kv.Key { + return array16ElemKey(a.name, idx) +} + func (a *Array16) setSize(n uint16) { if n == 0 { a.kvw.Del(a.getSizeKey()) } else { - a.kvw.Set(a.getSizeKey(), util.Uint16To2Bytes(n)) + a.kvw.Set(a.getSizeKey(), uint16ToBytes(n)) } } @@ -99,7 +119,7 @@ func (a *ImmutableArray16) Len() (uint16, error) { if v == nil { return 0, nil } - return util.MustUint16From2Bytes(v), nil + return bytesToUint16(v), nil } func (a *ImmutableArray16) MustLen() uint16 { diff --git a/packages/kv/collections/array32.go b/packages/kv/collections/array32.go index 436f947817..685822061a 100644 --- a/packages/kv/collections/array32.go +++ b/packages/kv/collections/array32.go @@ -1,4 +1,3 @@ -//nolint:dupl package collections import ( @@ -6,7 +5,6 @@ import ( "fmt" "github.com/iotaledger/wasp/packages/kv" - "github.com/iotaledger/wasp/packages/util" ) // Array32 represents a dynamic array stored in a kv.KVStore @@ -37,27 +35,15 @@ func NewArray32ReadOnly(kvReader kv.KVStoreReader, name string) *ImmutableArray3 const array32ElemKeyCode = byte('#') -func (a *Array32) Immutable() *ImmutableArray32 { - return a.ImmutableArray32 -} - -func (a *ImmutableArray32) getSizeKey() kv.Key { - return array32SizeKey(a.name) -} - func array32SizeKey(name string) kv.Key { return kv.Key(name) } -func (a *ImmutableArray32) getArray32ElemKey(idx uint32) kv.Key { - return array32ElemKey(a.name, idx) -} - func array32ElemKey(name string, idx uint32) kv.Key { var buf bytes.Buffer buf.Write([]byte(name)) buf.WriteByte(array32ElemKeyCode) - _ = util.WriteUint32(&buf, idx) + buf.Write(uint32ToBytes(idx)) return kv.Key(buf.Bytes()) } @@ -73,11 +59,48 @@ func Array32RangeKeys(name string, length, from, to uint32) []kv.Key { return keys } +// use ULEB128 decoding so that WasmLib can use it as well +func bytesToUint32(buf []byte) uint32 { + value := uint32(buf[0] & 0x7f) + i := 0 + for s := 7; (buf[i] & 0x80) != 0; s += 7 { + i++ + value |= uint32(buf[i]&0x7f) << s + } + return value +} + +// use ULEB128 encoding so that WasmLib can decode it as well +func uint32ToBytes(value uint32) []byte { + buf := make([]byte, 0, 5) + b := byte(value) + value >>= 7 + for value != 0 { + buf = append(buf, b|0x80) + b = byte(value) + value >>= 7 + } + buf = append(buf, b) + return buf +} + +func (a *Array32) Immutable() *ImmutableArray32 { + return a.ImmutableArray32 +} + +func (a *ImmutableArray32) getSizeKey() kv.Key { + return array32SizeKey(a.name) +} + +func (a *ImmutableArray32) getArray32ElemKey(idx uint32) kv.Key { + return array32ElemKey(a.name, idx) +} + func (a *Array32) setSize(n uint32) { if n == 0 { a.kvw.Del(a.getSizeKey()) } else { - a.kvw.Set(a.getSizeKey(), util.Uint32To4Bytes(n)) + a.kvw.Set(a.getSizeKey(), uint32ToBytes(n)) } } @@ -99,7 +122,7 @@ func (a *ImmutableArray32) Len() (uint32, error) { if v == nil { return 0, nil } - return util.MustUint32From4Bytes(v), nil + return bytesToUint32(v), nil } func (a *ImmutableArray32) MustLen() uint32 { diff --git a/packages/vm/wasmhost/wasmcontext.go b/packages/vm/wasmhost/wasmcontext.go index a3007156ed..8a855aae09 100644 --- a/packages/vm/wasmhost/wasmcontext.go +++ b/packages/vm/wasmhost/wasmcontext.go @@ -117,7 +117,7 @@ func (wc *WasmContext) IsView() bool { } func (wc *WasmContext) log() iscp.LogInterface { - if wc.sandbox.common != nil { + if wc.sandbox != nil && wc.sandbox.common != nil { return wc.sandbox.common.Log() } return wc.proc.log diff --git a/packages/vm/wasmhost/wasmgovm.go b/packages/vm/wasmhost/wasmgovm.go index f72b4ea646..cc50f58595 100644 --- a/packages/vm/wasmhost/wasmgovm.go +++ b/packages/vm/wasmhost/wasmgovm.go @@ -8,7 +8,6 @@ import ( "strings" "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" - "golang.org/x/xerrors" ) // provide implementation for Wasm-only function @@ -59,20 +58,20 @@ func (vm *WasmGoVM) RunFunction(functionName string, args ...interface{}) error } func (vm *WasmGoVM) RunScFunction(index int32) (err error) { - defer func() { - r := recover() - if r == nil { - return - } - switch errType := r.(type) { - case error: - err = errType - case string: - err = errors.New(errType) - default: - err = xerrors.Errorf("RunScFunction: %v", errType) - } - }() + //defer func() { + // r := recover() + // if r == nil { + // return + // } + // switch errType := r.(type) { + // case error: + // err = errType + // case string: + // err = errors.New(errType) + // default: + // err = xerrors.Errorf("RunScFunction: %v", errType) + // } + //}() return vm.Run(func() error { wasmlib.OnCall(index) return nil diff --git a/packages/vm/wasmhost/wasmvm.go b/packages/vm/wasmhost/wasmvm.go index 331195d80c..bce71eb4f6 100644 --- a/packages/vm/wasmhost/wasmvm.go +++ b/packages/vm/wasmhost/wasmvm.go @@ -8,6 +8,8 @@ import ( "errors" "fmt" "time" + + "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" ) const ( @@ -122,11 +124,14 @@ func (vm *WasmVMBase) HostFdWrite(_fd, iovs, _size, written int32) int32 { ptr := vm.impl.VMGetBytes(iovs, 8) text := int32(binary.LittleEndian.Uint32(ptr[0:4])) size := int32(binary.LittleEndian.Uint32(ptr[4:8])) - msg := vm.impl.VMGetBytes(text, size) - fmt.Print(string(msg)) + // msg := vm.impl.VMGetBytes(text, size) + // fmt.Print(string(msg)) ptr = make([]byte, 4) binary.LittleEndian.PutUint32(ptr, uint32(size)) vm.impl.VMSetBytes(written, size, ptr) + + // strip off "panic: " prefix and call sandbox panic function + vm.HostStateGet(0, wasmlib.FnPanic, text+7, size) return size } @@ -191,6 +196,18 @@ func (vm *WasmVMBase) HostStateSet(keyRef, keyLen, valRef, valLen int32) { ctx := vm.getContext(0) ctx.log().Debugf("HostStateSet(k(%d,%d),v(%d,s%d))", keyRef, keyLen, valRef, valLen) + // export name? + if keyRef == 0 { + name := string(vm.impl.VMGetBytes(valRef, valLen)) + if keyLen < 0 { + // ExportWasmTag, log the wasm tag name + ctx.proc.log.Infof(name) + return + } + ctx.ExportName(keyLen, name) + return + } + key := vm.impl.VMGetBytes(keyRef, keyLen) // delete key ? @@ -199,6 +216,7 @@ func (vm *WasmVMBase) HostStateSet(keyRef, keyLen, valRef, valLen int32) { return } + // set key value := vm.impl.VMGetBytes(valRef, valLen) ctx.StateSet(key, value) } @@ -219,18 +237,18 @@ func (vm *WasmVMBase) LinkHost(impl WasmVM, host *WasmHost) error { } func (vm *WasmVMBase) Run(runner func() error) (err error) { - defer func() { - r := recover() - if r == nil { - return - } - // could be the wrong panic message due to a WasmTime bug, so we always - // rethrow our intercepted first panic instead of WasmTime's last panic - if vm.panicErr != nil { - panic(vm.panicErr) - } - panic(r) - }() + //defer func() { + // r := recover() + // if r == nil { + // return + // } + // // could be the wrong panic message due to a WasmTime bug, so we always + // // rethrow our intercepted first panic instead of WasmTime's last panic + // if vm.panicErr != nil { + // panic(vm.panicErr) + // } + // panic(r) + //}() if vm.timeoutStarted { // no need to wrap nested calls in timeout code diff --git a/packages/vm/wasmlib/go/wasmlib/assets.go b/packages/vm/wasmlib/go/wasmlib/assets.go index 6c32cd692f..cb5cc02ad0 100644 --- a/packages/vm/wasmlib/go/wasmlib/assets.go +++ b/packages/vm/wasmlib/go/wasmlib/assets.go @@ -13,14 +13,15 @@ import ( type ScAssets map[wasmtypes.ScColor]uint64 func NewScAssetsFromBytes(buf []byte) ScAssets { - dict := make(ScAssets) - size, buf := wasmcodec.ExtractUint32(buf) - var k []byte - var v uint64 + if len(buf) == 0 { + return make(ScAssets) + } + dec := wasmcodec.NewWasmDecoder(buf) + size := wasmtypes.Uint32FromBytes(dec.FixedBytes(wasmtypes.ScUint32Length)) + dict := make(ScAssets, size) for i := uint32(0); i < size; i++ { - k, buf = wasmcodec.ExtractBytes(buf, 32) - v, buf = wasmcodec.ExtractUint64(buf) - dict[wasmtypes.ColorFromBytes(k)] = v + color := wasmtypes.ColorFromBytes(dec.FixedBytes(wasmtypes.ScColorLength)) + dict[color] = wasmtypes.Uint64FromBytes(dec.FixedBytes(wasmtypes.ScUint64Length)) } return dict } @@ -33,13 +34,13 @@ func (a ScAssets) Bytes() []byte { sort.Slice(keys, func(i, j int) bool { return string(keys[i].Bytes()) < string(keys[j].Bytes()) }) - buf := wasmcodec.AppendUint32(nil, uint32(len(keys))) - for _, k := range keys { - v := a[k] - buf = wasmcodec.AppendBytes(buf, k.Bytes()) - buf = wasmcodec.AppendUint64(buf, v) + enc := wasmcodec.NewWasmEncoder() + enc.FixedBytes(wasmtypes.BytesFromUint32(uint32(len(keys))), wasmtypes.ScUint32Length) + for _, color := range keys { + enc.FixedBytes(color.Bytes(), wasmtypes.ScColorLength) + enc.FixedBytes(wasmtypes.BytesFromUint64(a[color]), wasmtypes.ScUint64Length) } - return buf + return enc.Buf() } func (a ScAssets) Balances() ScBalances { diff --git a/packages/vm/wasmlib/go/wasmlib/context.go b/packages/vm/wasmlib/go/wasmlib/context.go index f0afc48c23..c1386a7adf 100644 --- a/packages/vm/wasmlib/go/wasmlib/context.go +++ b/packages/vm/wasmlib/go/wasmlib/context.go @@ -32,7 +32,8 @@ func (ctx ScFuncContext) Host() ScHost { func (ctx ScFuncContext) InitFuncCallContext() { } -func (ctx ScFuncContext) InitViewCallContext() { +func (ctx ScFuncContext) InitViewCallContext(hContract wasmtypes.ScHname) wasmtypes.ScHname { + return hContract } // TODO deprecated @@ -53,5 +54,6 @@ type ScViewContext struct { var _ ScViewCallContext = &ScViewContext{} -func (ctx ScViewContext) InitViewCallContext() { +func (ctx ScViewContext) InitViewCallContext(hContract wasmtypes.ScHname) wasmtypes.ScHname { + return hContract } diff --git a/packages/vm/wasmlib/go/wasmlib/contract.go b/packages/vm/wasmlib/go/wasmlib/contract.go index cf90303977..f5e9c132ff 100644 --- a/packages/vm/wasmlib/go/wasmlib/contract.go +++ b/packages/vm/wasmlib/go/wasmlib/contract.go @@ -14,7 +14,7 @@ type ScFuncCallContext interface { } type ScViewCallContext interface { - InitViewCallContext() + InitViewCallContext(hContract wasmtypes.ScHname) wasmtypes.ScHname } // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ @@ -27,7 +27,8 @@ type ScView struct { } func NewScView(ctx ScViewCallContext, hContract, hFunction wasmtypes.ScHname) *ScView { - ctx.InitViewCallContext() + // allow context to override default hContract + hContract = ctx.InitViewCallContext(hContract) v := new(ScView) v.initView(hContract, hFunction) return v @@ -84,6 +85,8 @@ func NewScInitFunc(ctx ScFuncCallContext, hContract, hFunction wasmtypes.ScHname return f } + // TODO: is this still necessary? + // Special initialization for SoloContext usage // Note that we do not have a contract context that can talk to the host // until *after* deployment of the contract, so we cannot use the normal diff --git a/packages/vm/wasmlib/go/wasmlib/dict.go b/packages/vm/wasmlib/go/wasmlib/dict.go index c573866277..c51ccd61a5 100644 --- a/packages/vm/wasmlib/go/wasmlib/dict.go +++ b/packages/vm/wasmlib/go/wasmlib/dict.go @@ -22,17 +22,14 @@ func NewScDictFromBytes(buf []byte) ScDict { if len(buf) == 0 { return make(ScDict) } - size, buf := wasmcodec.ExtractUint32(buf) + dec := wasmcodec.NewWasmDecoder(buf) + size := wasmtypes.Uint32FromBytes(dec.FixedBytes(wasmtypes.ScUint32Length)) dict := make(ScDict, size) - var k uint16 - var v uint32 - var key []byte - var val []byte for i := uint32(0); i < size; i++ { - k, buf = wasmcodec.ExtractUint16(buf) - key, buf = wasmcodec.ExtractBytes(buf, int(k)) - v, buf = wasmcodec.ExtractUint32(buf) - val, buf = wasmcodec.ExtractBytes(buf, int(v)) + keyLen := wasmtypes.Uint16FromBytes(dec.FixedBytes(wasmtypes.ScUint16Length)) + key := dec.FixedBytes(uint32(keyLen)) + valLen := wasmtypes.Uint32FromBytes(dec.FixedBytes(wasmtypes.ScUint32Length)) + val := dec.FixedBytes(valLen) dict.Set(key, val) } return dict @@ -50,15 +47,17 @@ func (d ScDict) Bytes() []byte { sort.Slice(keys, func(i, j int) bool { return keys[i] < keys[j] }) - buf := wasmcodec.AppendUint32(nil, uint32(len(keys))) + enc := wasmcodec.NewWasmEncoder() + enc.FixedBytes(wasmtypes.BytesFromUint32(uint32(len(keys))), wasmtypes.ScUint32Length) for _, k := range keys { - v := d[k] - buf = wasmcodec.AppendUint16(buf, uint16(len(k))) - buf = wasmcodec.AppendBytes(buf, []byte(k)) - buf = wasmcodec.AppendUint32(buf, uint32(len(v))) - buf = wasmcodec.AppendBytes(buf, v) + key := []byte(k) + val := d[k] + enc.FixedBytes(wasmtypes.BytesFromUint16(uint16(len(key))), wasmtypes.ScUint16Length) + enc.FixedBytes(key, uint32(len(key))) + enc.FixedBytes(wasmtypes.BytesFromUint32(uint32(len(val))), wasmtypes.ScUint32Length) + enc.FixedBytes(val, uint32(len(val))) } - return buf + return enc.Buf() } func (d ScDict) Delete(key []byte) { diff --git a/packages/vm/wasmlib/go/wasmlib/sandbox.go b/packages/vm/wasmlib/go/wasmlib/sandbox.go index 0fbcd3c0a2..05bc8c7fe1 100644 --- a/packages/vm/wasmlib/go/wasmlib/sandbox.go +++ b/packages/vm/wasmlib/go/wasmlib/sandbox.go @@ -6,7 +6,6 @@ package wasmlib import ( "encoding/binary" - "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmcodec" "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmrequests" "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" ) @@ -64,8 +63,7 @@ func (s ScSandbox) AccountID() wasmtypes.ScAgentID { } func (s ScSandbox) Balance(color wasmtypes.ScColor) uint64 { - bal, _ := wasmcodec.ExtractUint64(Sandbox(FnBalance, color.Bytes())) - return bal + return wasmtypes.Uint64FromBytes(Sandbox(FnBalance, color.Bytes())) } // access the current balances for all assets @@ -142,8 +140,7 @@ func (s ScSandbox) Results(results ScDict) { // deterministic time stamp fixed at the moment of calling the smart contract func (s ScSandbox) Timestamp() uint64 { - ts, _ := wasmcodec.ExtractUint64(Sandbox(FnTimestamp, nil)) - return ts + return wasmtypes.Uint64FromBytes(Sandbox(FnTimestamp, nil)) } // logs debugging trace text message diff --git a/packages/vm/wasmlib/go/wasmlib/sandboxutils.go b/packages/vm/wasmlib/go/wasmlib/sandboxutils.go index bb5d18e703..e71fecfa75 100644 --- a/packages/vm/wasmlib/go/wasmlib/sandboxutils.go +++ b/packages/vm/wasmlib/go/wasmlib/sandboxutils.go @@ -41,8 +41,7 @@ func (u ScSandboxUtils) BlsAggregateSignatures(pubKeys, sigs [][]byte) ([]byte, func (u ScSandboxUtils) BlsValidSignature(data, pubKey, signature []byte) bool { enc := wasmcodec.NewWasmEncoder().Bytes(data).Bytes(pubKey).Bytes(signature) - valid, _ := wasmcodec.ExtractBool(Sandbox(FnUtilsBlsValid, enc.Buf())) - return valid + return wasmtypes.BoolFromBytes(Sandbox(FnUtilsBlsValid, enc.Buf())) } func (u ScSandboxUtils) Ed25519AddressFromPubKey(pubKey []byte) wasmtypes.ScAddress { @@ -51,8 +50,7 @@ func (u ScSandboxUtils) Ed25519AddressFromPubKey(pubKey []byte) wasmtypes.ScAddr func (u ScSandboxUtils) Ed25519ValidSignature(data, pubKey, signature []byte) bool { enc := wasmcodec.NewWasmEncoder().Bytes(data).Bytes(pubKey).Bytes(signature) - valid, _ := wasmcodec.ExtractBool(Sandbox(FnUtilsEd25519Valid, enc.Buf())) - return valid + return wasmtypes.BoolFromBytes(Sandbox(FnUtilsEd25519Valid, enc.Buf())) } // hashes the specified value bytes using blake2b hashing and returns the resulting 32-byte hash diff --git a/packages/vm/wasmlib/go/wasmlib/wasmcodec/buffer.go b/packages/vm/wasmlib/go/wasmlib/wasmcodec/buffer.go deleted file mode 100644 index c042515c8c..0000000000 --- a/packages/vm/wasmlib/go/wasmlib/wasmcodec/buffer.go +++ /dev/null @@ -1,99 +0,0 @@ -// Copyright 2020 IOTA Stiftung -// SPDX-License-Identifier: Apache-2.0 - -package wasmcodec - -import ( - "encoding/binary" -) - -func ExtractBool(buf []byte) (bool, []byte) { - return buf[0] != 0, buf[1:] -} - -func ExtractBytes(buf []byte, n int) ([]byte, []byte) { - return buf[:n], buf[n:] -} - -func ExtractInt8(buf []byte) (int8, []byte) { - return int8(buf[0]), buf[1:] -} - -func ExtractInt16(buf []byte) (int16, []byte) { - return int16(binary.LittleEndian.Uint16(buf)), buf[2:] -} - -func ExtractInt32(buf []byte) (int32, []byte) { - return int32(binary.LittleEndian.Uint32(buf)), buf[4:] -} - -func ExtractInt64(buf []byte) (int64, []byte) { - return int64(binary.LittleEndian.Uint64(buf)), buf[8:] -} - -func ExtractUint8(buf []byte) (uint8, []byte) { - return buf[0], buf[1:] -} - -func ExtractUint16(buf []byte) (uint16, []byte) { - return binary.LittleEndian.Uint16(buf), buf[2:] -} - -func ExtractUint32(buf []byte) (uint32, []byte) { - return binary.LittleEndian.Uint32(buf), buf[4:] -} - -func ExtractUint64(buf []byte) (uint64, []byte) { - return binary.LittleEndian.Uint64(buf), buf[8:] -} - -//////////////////////////////////// - -func AppendBool(buf []byte, value bool) []byte { - if value { - return AppendUint8(buf, 1) - } - return AppendUint8(buf, 0) -} - -func AppendBytes(buf, value []byte) []byte { - return append(buf, value...) -} - -func AppendInt8(buf []byte, value int8) []byte { - return AppendUint8(buf, uint8(value)) -} - -func AppendInt16(buf []byte, value int16) []byte { - return AppendUint16(buf, uint16(value)) -} - -func AppendInt32(buf []byte, value int32) []byte { - return AppendUint32(buf, uint32(value)) -} - -func AppendInt64(buf []byte, value int64) []byte { - return AppendUint64(buf, uint64(value)) -} - -func AppendUint8(buf []byte, value uint8) []byte { - return append(buf, value) -} - -func AppendUint16(buf []byte, value uint16) []byte { - tmp := make([]byte, 2) - binary.LittleEndian.PutUint16(tmp, value) - return append(buf, tmp...) -} - -func AppendUint32(buf []byte, value uint32) []byte { - tmp := make([]byte, 4) - binary.LittleEndian.PutUint32(tmp, value) - return append(buf, tmp...) -} - -func AppendUint64(buf []byte, value uint64) []byte { - tmp := make([]byte, 8) - binary.LittleEndian.PutUint64(tmp, value) - return append(buf, tmp...) -} diff --git a/packages/vm/wasmlib/go/wasmlib/wasmcodec/codec.go b/packages/vm/wasmlib/go/wasmlib/wasmcodec/codec.go index 0d3b939b31..9ed2bf89cc 100644 --- a/packages/vm/wasmlib/go/wasmlib/wasmcodec/codec.go +++ b/packages/vm/wasmlib/go/wasmlib/wasmcodec/codec.go @@ -56,7 +56,7 @@ func (d *WasmDecoder) VliDecode(bits int) (value int64) { s := 6 // while continuation bit is set - for (b & 0x80) != 0 { + for ; (b & 0x80) != 0; s += 7 { if s >= bits { d.abort("integer representation too long") } @@ -64,7 +64,6 @@ func (d *WasmDecoder) VliDecode(bits int) (value int64) { // next group of 7 bits b = d.Byte() value |= int64(b&0x7f) << s - s += 7 } if sign == 0 { @@ -84,7 +83,7 @@ func (d *WasmDecoder) VluDecode(bits int) uint64 { s := 7 // while continuation bit is set - for (b & 0x80) != 0 { + for ; (b & 0x80) != 0; s += 7 { if s >= bits { d.abort("integer representation too long") } @@ -92,7 +91,6 @@ func (d *WasmDecoder) VluDecode(bits int) uint64 { // next group of 7 bits b = d.Byte() value |= uint64(b&0x7f) << s - s += 7 } return value } diff --git a/packages/vm/wasmlib/go/wasmlib/wasmtypes/bool.go b/packages/vm/wasmlib/go/wasmlib/wasmtypes/bool.go index 00d9e85bf2..6c1ee8866a 100644 --- a/packages/vm/wasmlib/go/wasmlib/wasmtypes/bool.go +++ b/packages/vm/wasmlib/go/wasmlib/wasmtypes/bool.go @@ -28,14 +28,20 @@ func BoolFromBytes(buf []byte) bool { if len(buf) != 1 { Panic("invalid Bool length") } - return buf[0] != 0 + if buf[0] == 0x00 { + return false + } + if buf[0] != 0xff { + Panic("invalid Bool value") + } + return true } func BytesFromBool(value bool) []byte { if value { - return []byte{1} + return []byte{0xff} } - return []byte{0} + return []byte{0x00} } func StringFromBool(value bool) string { diff --git a/packages/vm/wasmlib/go/wasmlib/wasmtypes/uint16.go b/packages/vm/wasmlib/go/wasmlib/wasmtypes/uint16.go index 202c7c0fbd..3d7f44242d 100644 --- a/packages/vm/wasmlib/go/wasmlib/wasmtypes/uint16.go +++ b/packages/vm/wasmlib/go/wasmlib/wasmtypes/uint16.go @@ -1,11 +1,9 @@ // Copyright 2020 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 -//nolint:dupl package wasmtypes import ( - "encoding/binary" "strconv" "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmcodec" @@ -13,6 +11,8 @@ import ( // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ +const ScUint16Length = 2 + func DecodeUint16(dec *wasmcodec.WasmDecoder) uint16 { return uint16(dec.VluDecode(16)) } @@ -25,16 +25,14 @@ func Uint16FromBytes(buf []byte) uint16 { if buf == nil { return 0 } - if len(buf) != 2 { + if len(buf) != ScUint16Length { Panic("invalid Uint16 length") } - return binary.LittleEndian.Uint16(buf) + return uint16(buf[0]) | uint16(buf[1])<<8 } func BytesFromUint16(value uint16) []byte { - tmp := make([]byte, 2) - binary.LittleEndian.PutUint16(tmp, value) - return tmp + return []byte{byte(value), byte(value >> 8)} } func StringFromUint16(value uint16) string { diff --git a/packages/vm/wasmlib/go/wasmlib/wasmtypes/uint32.go b/packages/vm/wasmlib/go/wasmlib/wasmtypes/uint32.go index e867881b8c..a1ed8d3070 100644 --- a/packages/vm/wasmlib/go/wasmlib/wasmtypes/uint32.go +++ b/packages/vm/wasmlib/go/wasmlib/wasmtypes/uint32.go @@ -1,7 +1,6 @@ // Copyright 2020 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 -//nolint:dupl package wasmtypes import ( @@ -13,6 +12,8 @@ import ( // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ +const ScUint32Length = 4 + func DecodeUint32(dec *wasmcodec.WasmDecoder) uint32 { return uint32(dec.VluDecode(32)) } @@ -25,14 +26,14 @@ func Uint32FromBytes(buf []byte) uint32 { if buf == nil { return 0 } - if len(buf) != 4 { + if len(buf) != ScUint32Length { Panic("invalid Uint32 length") } return binary.LittleEndian.Uint32(buf) } func BytesFromUint32(value uint32) []byte { - tmp := make([]byte, 4) + tmp := make([]byte, ScUint32Length) binary.LittleEndian.PutUint32(tmp, value) return tmp } diff --git a/packages/vm/wasmlib/go/wasmlib/wasmtypes/uint64.go b/packages/vm/wasmlib/go/wasmlib/wasmtypes/uint64.go index c2fe939c04..a5df22c60a 100644 --- a/packages/vm/wasmlib/go/wasmlib/wasmtypes/uint64.go +++ b/packages/vm/wasmlib/go/wasmlib/wasmtypes/uint64.go @@ -12,6 +12,8 @@ import ( // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ +const ScUint64Length = 8 + func DecodeUint64(dec *wasmcodec.WasmDecoder) uint64 { return dec.VluDecode(64) } @@ -24,14 +26,14 @@ func Uint64FromBytes(buf []byte) uint64 { if buf == nil { return 0 } - if len(buf) != 8 { + if len(buf) != ScUint64Length { Panic("invalid Uint64 length") } return binary.LittleEndian.Uint64(buf) } func BytesFromUint64(value uint64) []byte { - tmp := make([]byte, 8) + tmp := make([]byte, ScUint64Length) binary.LittleEndian.PutUint64(tmp, value) return tmp } diff --git a/packages/vm/wasmlib/go/wasmlib/wasmtypes/uint8.go b/packages/vm/wasmlib/go/wasmlib/wasmtypes/uint8.go index 70ff00c472..1320cd4127 100644 --- a/packages/vm/wasmlib/go/wasmlib/wasmtypes/uint8.go +++ b/packages/vm/wasmlib/go/wasmlib/wasmtypes/uint8.go @@ -11,6 +11,8 @@ import ( // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ +const ScUint8Length = 1 + func DecodeUint8(dec *wasmcodec.WasmDecoder) uint8 { return dec.Byte() } @@ -23,7 +25,7 @@ func Uint8FromBytes(buf []byte) uint8 { if buf == nil { return 0 } - if len(buf) != 1 { + if len(buf) != ScUint8Length { Panic("invalid Uint8 length") } return buf[0] diff --git a/packages/vm/wasmsolo/solocontext.go b/packages/vm/wasmsolo/solocontext.go index 68819031b2..06cfe7f3ae 100644 --- a/packages/vm/wasmsolo/solocontext.go +++ b/packages/vm/wasmsolo/solocontext.go @@ -273,8 +273,9 @@ func (ctx *SoloContext) InitFuncCallContext() { } // InitViewCallContext is a function that is required to use SoloContext as an ScViewCallContext -func (ctx *SoloContext) InitViewCallContext() { +func (ctx *SoloContext) InitViewCallContext(hContract wasmtypes.ScHname) wasmtypes.ScHname { _ = wasmhost.Connect(ctx.wc) + return ctx.Convertor.ScHname(iscp.Hn(ctx.scName)) } // Minted returns the color and amount of newly minted tokens diff --git a/packages/vm/wasmsolo/solosandbox.go b/packages/vm/wasmsolo/solosandbox.go index 7ae23ea0e9..6abbcdb0a1 100644 --- a/packages/vm/wasmsolo/solosandbox.go +++ b/packages/vm/wasmsolo/solosandbox.go @@ -2,6 +2,7 @@ package wasmsolo import ( "bytes" + "errors" "time" "github.com/iotaledger/goshimmer/packages/ledgerstate" @@ -14,6 +15,7 @@ import ( "github.com/iotaledger/wasp/packages/vm/wasmhost" "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmrequests" "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" + "golang.org/x/xerrors" ) // NOTE: These functions correspond to the Sandbox fnXxx constants in WasmLib @@ -69,6 +71,25 @@ func NewSoloSandbox(ctx *SoloContext) *SoloSandbox { } func (s *SoloSandbox) Call(funcNr int32, params []byte) []byte { + s.ctx.Err = nil + defer func() { + r := recover() + if r == nil { + return + } + if s.ctx.Err != nil { + s.ctx.Chain.Log.Infof("stacked error: %s", s.ctx.Err.Error()) + } + switch errType := r.(type) { + case error: + s.ctx.Err = errType + case string: + s.ctx.Err = errors.New(errType) + default: + s.ctx.Err = xerrors.Errorf("RunScFunction: %v", errType) + } + s.ctx.Chain.Log.Infof("stolor error:: %s", s.ctx.Err.Error()) + }() return sandboxFunctions[-funcNr](s, params) } @@ -142,7 +163,7 @@ func (s *SoloSandbox) fnCall(args []byte) []byte { contract, err := iscp.HnameFromBytes(req.Contract.Bytes()) s.checkErr(err) if contract != iscp.Hn(s.ctx.scName) { - s.Panicf("unknown contract: %s", contract.String()) + s.Panicf("unknown contract: %s vs. %s", contract.String(), s.ctx.scName) } function, err := iscp.HnameFromBytes(req.Function.Bytes()) s.checkErr(err) diff --git a/packages/vm/wasmvmhost/host.go b/packages/vm/wasmvmhost/host.go index 1dfb72764b..492c661e14 100644 --- a/packages/vm/wasmvmhost/host.go +++ b/packages/vm/wasmvmhost/host.go @@ -58,11 +58,14 @@ func (w *WasmVMHost) ConnectWasmHost() { } func (w *WasmVMHost) ExportName(index int32, name string) { + // nil key indicates export name, with keyLen indicating index + // this removes the need for a separate hostExportName function value := []byte(name) hostStateSet(nil, index, ptr(value), int32(len(value))) } func (w *WasmVMHost) ExportWasmTag() { + // special index -1 indicates this is not an export name but the wasm tag w.ExportName(-1, "WASM::GO") } From 7adc81c64aa20637ed7bc780828a19aa55e22626 Mon Sep 17 00:00:00 2001 From: Eric Hop Date: Wed, 26 Jan 2022 12:26:27 -0800 Subject: [PATCH 047/111] Cleanup and consistency --- contracts/wasm/dividend/go/dividend/state.go | 4 +- .../go/donatewithfeedback/structs.go | 9 +-- contracts/wasm/erc20/go/erc20/events.go | 20 +++--- contracts/wasm/erc20/go/erc20/state.go | 4 +- contracts/wasm/erc20/go/erc20/typedefs.go | 4 +- contracts/wasm/erc721/go/erc721/events.go | 48 ++++++------- contracts/wasm/erc721/go/erc721/state.go | 16 ++--- contracts/wasm/erc721/go/erc721/typedefs.go | 4 +- .../wasm/fairauction/go/fairauction/state.go | 12 ++-- .../fairauction/go/fairauction/structs.go | 13 ++-- .../fairauction/go/fairauction/typedefs.go | 4 +- .../fairroulette/go/fairroulette/events.go | 38 +++++----- .../fairroulette/go/fairroulette/structs.go | 9 +-- .../inccounter/go/inccounter/inccounter.go | 17 +++-- .../wasm/testwasmlib/go/testwasmlib/events.go | 8 +-- .../testwasmlib/go/testwasmlib/structs.go | 17 +++-- .../tokenregistry/go/tokenregistry/state.go | 4 +- .../tokenregistry/go/tokenregistry/structs.go | 9 +-- packages/vm/wasmhost/wasmtosandboxutils.go | 9 ++- packages/vm/wasmlib/go/wasmlib/assets.go | 5 +- .../go/wasmlib/coreaccounts/results.go | 8 +-- .../vm/wasmlib/go/wasmlib/coreblob/results.go | 4 +- .../vm/wasmlib/go/wasmlib/coreroot/results.go | 4 +- packages/vm/wasmlib/go/wasmlib/dict.go | 5 +- packages/vm/wasmlib/go/wasmlib/events.go | 8 ++- .../vm/wasmlib/go/wasmlib/sandboxutils.go | 11 ++- .../go/wasmlib/wasmrequests/structs.go | 21 +++--- .../wasmlib/go/wasmlib/wasmtypes/address.go | 60 ++++++++-------- .../wasmlib/go/wasmlib/wasmtypes/agentid.go | 70 ++++++++++--------- .../vm/wasmlib/go/wasmlib/wasmtypes/bool.go | 16 ++--- .../vm/wasmlib/go/wasmlib/wasmtypes/bytes.go | 14 ++-- .../wasmlib/go/wasmlib/wasmtypes/chainid.go | 58 ++++++++------- .../wasmlib/{wasmcodec => wasmtypes}/codec.go | 28 +++++++- .../vm/wasmlib/go/wasmlib/wasmtypes/color.go | 44 ++++++------ .../vm/wasmlib/go/wasmlib/wasmtypes/hash.go | 44 ++++++------ .../vm/wasmlib/go/wasmlib/wasmtypes/hname.go | 52 ++++++++------ .../vm/wasmlib/go/wasmlib/wasmtypes/int16.go | 12 ++-- .../vm/wasmlib/go/wasmlib/wasmtypes/int32.go | 12 ++-- .../vm/wasmlib/go/wasmlib/wasmtypes/int64.go | 12 ++-- .../vm/wasmlib/go/wasmlib/wasmtypes/int8.go | 12 ++-- .../vm/wasmlib/go/wasmlib/wasmtypes/proxy.go | 16 ++--- .../wasmlib/go/wasmlib/wasmtypes/requestid.go | 50 +++++++------ .../vm/wasmlib/go/wasmlib/wasmtypes/string.go | 12 ++-- .../vm/wasmlib/go/wasmlib/wasmtypes/uint16.go | 12 ++-- .../vm/wasmlib/go/wasmlib/wasmtypes/uint32.go | 12 ++-- .../vm/wasmlib/go/wasmlib/wasmtypes/uint64.go | 12 ++-- .../vm/wasmlib/go/wasmlib/wasmtypes/uint8.go | 12 ++-- .../vm/wasmlib/go/wasmlib/wasmtypes/utils.go | 28 -------- packages/vm/wasmsolo/solosandboxutils.go | 9 ++- .../generator/gotemplates/alltemplates.go | 25 ------- tools/schema/generator/gotemplates/events.go | 6 +- tools/schema/generator/gotemplates/structs.go | 5 +- .../schema/generator/gotemplates/typedefs.go | 4 +- 53 files changed, 454 insertions(+), 498 deletions(-) rename packages/vm/wasmlib/go/wasmlib/{wasmcodec => wasmtypes}/codec.go (84%) delete mode 100644 packages/vm/wasmlib/go/wasmlib/wasmtypes/utils.go diff --git a/contracts/wasm/dividend/go/dividend/state.go b/contracts/wasm/dividend/go/dividend/state.go index a136855912..ade138803a 100644 --- a/contracts/wasm/dividend/go/dividend/state.go +++ b/contracts/wasm/dividend/go/dividend/state.go @@ -26,7 +26,7 @@ type MapAddressToImmutableUint64 struct { } func (m MapAddressToImmutableUint64) GetUint64(key wasmtypes.ScAddress) wasmtypes.ScImmutableUint64 { - return wasmtypes.NewScImmutableUint64(m.proxy.Key(key.Bytes())) + return wasmtypes.NewScImmutableUint64(m.proxy.Key(wasmtypes.BytesFromAddress(key))) } type ImmutableDividendState struct { @@ -78,7 +78,7 @@ func (m MapAddressToMutableUint64) Clear() { } func (m MapAddressToMutableUint64) GetUint64(key wasmtypes.ScAddress) wasmtypes.ScMutableUint64 { - return wasmtypes.NewScMutableUint64(m.proxy.Key(key.Bytes())) + return wasmtypes.NewScMutableUint64(m.proxy.Key(wasmtypes.BytesFromAddress(key))) } type MutableDividendState struct { diff --git a/contracts/wasm/donatewithfeedback/go/donatewithfeedback/structs.go b/contracts/wasm/donatewithfeedback/go/donatewithfeedback/structs.go index c52180a38f..1d252e2fa0 100644 --- a/contracts/wasm/donatewithfeedback/go/donatewithfeedback/structs.go +++ b/contracts/wasm/donatewithfeedback/go/donatewithfeedback/structs.go @@ -7,10 +7,7 @@ package donatewithfeedback -import ( - "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmcodec" - "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" -) +import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" type Donation struct { Amount uint64 // amount donated @@ -21,7 +18,7 @@ type Donation struct { } func NewDonationFromBytes(buf []byte) *Donation { - dec := wasmcodec.NewWasmDecoder(buf) + dec := wasmtypes.NewWasmDecoder(buf) data := &Donation{} data.Amount = wasmtypes.DecodeUint64(dec) data.Donator = wasmtypes.DecodeAgentID(dec) @@ -33,7 +30,7 @@ func NewDonationFromBytes(buf []byte) *Donation { } func (o *Donation) Bytes() []byte { - enc := wasmcodec.NewWasmEncoder() + enc := wasmtypes.NewWasmEncoder() wasmtypes.EncodeUint64(enc, o.Amount) wasmtypes.EncodeAgentID(enc, o.Donator) wasmtypes.EncodeString(enc, o.Error) diff --git a/contracts/wasm/erc20/go/erc20/events.go b/contracts/wasm/erc20/go/erc20/events.go index 341776b4aa..2edf5859ce 100644 --- a/contracts/wasm/erc20/go/erc20/events.go +++ b/contracts/wasm/erc20/go/erc20/events.go @@ -16,17 +16,17 @@ import ( type Erc20Events struct{} func (e Erc20Events) Approval(amount uint64, owner wasmtypes.ScAgentID, spender wasmtypes.ScAgentID) { - wasmlib.NewEventEncoder("erc20.approval"). - Uint64(amount). - AgentID(owner). - AgentID(spender). - Emit() + evt := wasmlib.NewEventEncoder("erc20.approval") + evt.Encode(wasmtypes.Uint64ToString(amount)) + evt.Encode(wasmtypes.AgentIDToString(owner)) + evt.Encode(wasmtypes.AgentIDToString(spender)) + evt.Emit() } func (e Erc20Events) Transfer(amount uint64, from wasmtypes.ScAgentID, to wasmtypes.ScAgentID) { - wasmlib.NewEventEncoder("erc20.transfer"). - Uint64(amount). - AgentID(from). - AgentID(to). - Emit() + evt := wasmlib.NewEventEncoder("erc20.transfer") + evt.Encode(wasmtypes.Uint64ToString(amount)) + evt.Encode(wasmtypes.AgentIDToString(from)) + evt.Encode(wasmtypes.AgentIDToString(to)) + evt.Emit() } diff --git a/contracts/wasm/erc20/go/erc20/state.go b/contracts/wasm/erc20/go/erc20/state.go index cd70d0c367..8695ee6ac3 100644 --- a/contracts/wasm/erc20/go/erc20/state.go +++ b/contracts/wasm/erc20/go/erc20/state.go @@ -14,7 +14,7 @@ type MapAgentIDToImmutableAllowancesForAgent struct { } func (m MapAgentIDToImmutableAllowancesForAgent) GetAllowancesForAgent(key wasmtypes.ScAgentID) ImmutableAllowancesForAgent { - return ImmutableAllowancesForAgent{proxy: m.proxy.Key(key.Bytes())} + return ImmutableAllowancesForAgent{proxy: m.proxy.Key(wasmtypes.BytesFromAgentID(key))} } type ImmutableErc20State struct { @@ -42,7 +42,7 @@ func (m MapAgentIDToMutableAllowancesForAgent) Clear() { } func (m MapAgentIDToMutableAllowancesForAgent) GetAllowancesForAgent(key wasmtypes.ScAgentID) MutableAllowancesForAgent { - return MutableAllowancesForAgent{proxy: m.proxy.Key(key.Bytes())} + return MutableAllowancesForAgent{proxy: m.proxy.Key(wasmtypes.BytesFromAgentID(key))} } type MutableErc20State struct { diff --git a/contracts/wasm/erc20/go/erc20/typedefs.go b/contracts/wasm/erc20/go/erc20/typedefs.go index 6d0bc76dd8..8a8eb520c3 100644 --- a/contracts/wasm/erc20/go/erc20/typedefs.go +++ b/contracts/wasm/erc20/go/erc20/typedefs.go @@ -14,7 +14,7 @@ type MapAgentIDToImmutableUint64 struct { } func (m MapAgentIDToImmutableUint64) GetUint64(key wasmtypes.ScAgentID) wasmtypes.ScImmutableUint64 { - return wasmtypes.NewScImmutableUint64(m.proxy.Key(key.Bytes())) + return wasmtypes.NewScImmutableUint64(m.proxy.Key(wasmtypes.BytesFromAgentID(key))) } type ImmutableAllowancesForAgent = MapAgentIDToImmutableUint64 @@ -28,7 +28,7 @@ func (m MapAgentIDToMutableUint64) Clear() { } func (m MapAgentIDToMutableUint64) GetUint64(key wasmtypes.ScAgentID) wasmtypes.ScMutableUint64 { - return wasmtypes.NewScMutableUint64(m.proxy.Key(key.Bytes())) + return wasmtypes.NewScMutableUint64(m.proxy.Key(wasmtypes.BytesFromAgentID(key))) } type MutableAllowancesForAgent = MapAgentIDToMutableUint64 diff --git a/contracts/wasm/erc721/go/erc721/events.go b/contracts/wasm/erc721/go/erc721/events.go index 1c14a5b748..aaf14ff9bc 100644 --- a/contracts/wasm/erc721/go/erc721/events.go +++ b/contracts/wasm/erc721/go/erc721/events.go @@ -16,40 +16,40 @@ import ( type Erc721Events struct{} func (e Erc721Events) Approval(approved wasmtypes.ScAgentID, owner wasmtypes.ScAgentID, tokenID wasmtypes.ScHash) { - wasmlib.NewEventEncoder("erc721.approval"). - AgentID(approved). - AgentID(owner). - Hash(tokenID). - Emit() + evt := wasmlib.NewEventEncoder("erc721.approval") + evt.Encode(wasmtypes.AgentIDToString(approved)) + evt.Encode(wasmtypes.AgentIDToString(owner)) + evt.Encode(wasmtypes.HashToString(tokenID)) + evt.Emit() } func (e Erc721Events) ApprovalForAll(approval bool, operator wasmtypes.ScAgentID, owner wasmtypes.ScAgentID) { - wasmlib.NewEventEncoder("erc721.approvalForAll"). - Bool(approval). - AgentID(operator). - AgentID(owner). - Emit() + evt := wasmlib.NewEventEncoder("erc721.approvalForAll") + evt.Encode(wasmtypes.BoolToString(approval)) + evt.Encode(wasmtypes.AgentIDToString(operator)) + evt.Encode(wasmtypes.AgentIDToString(owner)) + evt.Emit() } func (e Erc721Events) Init(name string, symbol string) { - wasmlib.NewEventEncoder("erc721.init"). - String(name). - String(symbol). - Emit() + evt := wasmlib.NewEventEncoder("erc721.init") + evt.Encode(wasmtypes.StringToString(name)) + evt.Encode(wasmtypes.StringToString(symbol)) + evt.Emit() } func (e Erc721Events) Mint(balance uint64, owner wasmtypes.ScAgentID, tokenID wasmtypes.ScHash) { - wasmlib.NewEventEncoder("erc721.mint"). - Uint64(balance). - AgentID(owner). - Hash(tokenID). - Emit() + evt := wasmlib.NewEventEncoder("erc721.mint") + evt.Encode(wasmtypes.Uint64ToString(balance)) + evt.Encode(wasmtypes.AgentIDToString(owner)) + evt.Encode(wasmtypes.HashToString(tokenID)) + evt.Emit() } func (e Erc721Events) Transfer(from wasmtypes.ScAgentID, to wasmtypes.ScAgentID, tokenID wasmtypes.ScHash) { - wasmlib.NewEventEncoder("erc721.transfer"). - AgentID(from). - AgentID(to). - Hash(tokenID). - Emit() + evt := wasmlib.NewEventEncoder("erc721.transfer") + evt.Encode(wasmtypes.AgentIDToString(from)) + evt.Encode(wasmtypes.AgentIDToString(to)) + evt.Encode(wasmtypes.HashToString(tokenID)) + evt.Emit() } diff --git a/contracts/wasm/erc721/go/erc721/state.go b/contracts/wasm/erc721/go/erc721/state.go index f282488665..79d9f83951 100644 --- a/contracts/wasm/erc721/go/erc721/state.go +++ b/contracts/wasm/erc721/go/erc721/state.go @@ -14,7 +14,7 @@ type MapHashToImmutableAgentID struct { } func (m MapHashToImmutableAgentID) GetAgentID(key wasmtypes.ScHash) wasmtypes.ScImmutableAgentID { - return wasmtypes.NewScImmutableAgentID(m.proxy.Key(key.Bytes())) + return wasmtypes.NewScImmutableAgentID(m.proxy.Key(wasmtypes.BytesFromHash(key))) } type MapAgentIDToImmutableOperators struct { @@ -22,7 +22,7 @@ type MapAgentIDToImmutableOperators struct { } func (m MapAgentIDToImmutableOperators) GetOperators(key wasmtypes.ScAgentID) ImmutableOperators { - return ImmutableOperators{proxy: m.proxy.Key(key.Bytes())} + return ImmutableOperators{proxy: m.proxy.Key(wasmtypes.BytesFromAgentID(key))} } type MapAgentIDToImmutableUint64 struct { @@ -30,7 +30,7 @@ type MapAgentIDToImmutableUint64 struct { } func (m MapAgentIDToImmutableUint64) GetUint64(key wasmtypes.ScAgentID) wasmtypes.ScImmutableUint64 { - return wasmtypes.NewScImmutableUint64(m.proxy.Key(key.Bytes())) + return wasmtypes.NewScImmutableUint64(m.proxy.Key(wasmtypes.BytesFromAgentID(key))) } type MapHashToImmutableString struct { @@ -38,7 +38,7 @@ type MapHashToImmutableString struct { } func (m MapHashToImmutableString) GetString(key wasmtypes.ScHash) wasmtypes.ScImmutableString { - return wasmtypes.NewScImmutableString(m.proxy.Key(key.Bytes())) + return wasmtypes.NewScImmutableString(m.proxy.Key(wasmtypes.BytesFromHash(key))) } type ImmutableErc721State struct { @@ -82,7 +82,7 @@ func (m MapHashToMutableAgentID) Clear() { } func (m MapHashToMutableAgentID) GetAgentID(key wasmtypes.ScHash) wasmtypes.ScMutableAgentID { - return wasmtypes.NewScMutableAgentID(m.proxy.Key(key.Bytes())) + return wasmtypes.NewScMutableAgentID(m.proxy.Key(wasmtypes.BytesFromHash(key))) } type MapAgentIDToMutableOperators struct { @@ -94,7 +94,7 @@ func (m MapAgentIDToMutableOperators) Clear() { } func (m MapAgentIDToMutableOperators) GetOperators(key wasmtypes.ScAgentID) MutableOperators { - return MutableOperators{proxy: m.proxy.Key(key.Bytes())} + return MutableOperators{proxy: m.proxy.Key(wasmtypes.BytesFromAgentID(key))} } type MapAgentIDToMutableUint64 struct { @@ -106,7 +106,7 @@ func (m MapAgentIDToMutableUint64) Clear() { } func (m MapAgentIDToMutableUint64) GetUint64(key wasmtypes.ScAgentID) wasmtypes.ScMutableUint64 { - return wasmtypes.NewScMutableUint64(m.proxy.Key(key.Bytes())) + return wasmtypes.NewScMutableUint64(m.proxy.Key(wasmtypes.BytesFromAgentID(key))) } type MapHashToMutableString struct { @@ -118,7 +118,7 @@ func (m MapHashToMutableString) Clear() { } func (m MapHashToMutableString) GetString(key wasmtypes.ScHash) wasmtypes.ScMutableString { - return wasmtypes.NewScMutableString(m.proxy.Key(key.Bytes())) + return wasmtypes.NewScMutableString(m.proxy.Key(wasmtypes.BytesFromHash(key))) } type MutableErc721State struct { diff --git a/contracts/wasm/erc721/go/erc721/typedefs.go b/contracts/wasm/erc721/go/erc721/typedefs.go index c115aa21fc..85616b91bc 100644 --- a/contracts/wasm/erc721/go/erc721/typedefs.go +++ b/contracts/wasm/erc721/go/erc721/typedefs.go @@ -14,7 +14,7 @@ type MapAgentIDToImmutableBool struct { } func (m MapAgentIDToImmutableBool) GetBool(key wasmtypes.ScAgentID) wasmtypes.ScImmutableBool { - return wasmtypes.NewScImmutableBool(m.proxy.Key(key.Bytes())) + return wasmtypes.NewScImmutableBool(m.proxy.Key(wasmtypes.BytesFromAgentID(key))) } type ImmutableOperators = MapAgentIDToImmutableBool @@ -28,7 +28,7 @@ func (m MapAgentIDToMutableBool) Clear() { } func (m MapAgentIDToMutableBool) GetBool(key wasmtypes.ScAgentID) wasmtypes.ScMutableBool { - return wasmtypes.NewScMutableBool(m.proxy.Key(key.Bytes())) + return wasmtypes.NewScMutableBool(m.proxy.Key(wasmtypes.BytesFromAgentID(key))) } type MutableOperators = MapAgentIDToMutableBool diff --git a/contracts/wasm/fairauction/go/fairauction/state.go b/contracts/wasm/fairauction/go/fairauction/state.go index ef75841723..07c752484f 100644 --- a/contracts/wasm/fairauction/go/fairauction/state.go +++ b/contracts/wasm/fairauction/go/fairauction/state.go @@ -14,7 +14,7 @@ type MapColorToImmutableAuction struct { } func (m MapColorToImmutableAuction) GetAuction(key wasmtypes.ScColor) ImmutableAuction { - return ImmutableAuction{proxy: m.proxy.Key(key.Bytes())} + return ImmutableAuction{proxy: m.proxy.Key(wasmtypes.BytesFromColor(key))} } type MapColorToImmutableBidderList struct { @@ -22,7 +22,7 @@ type MapColorToImmutableBidderList struct { } func (m MapColorToImmutableBidderList) GetBidderList(key wasmtypes.ScColor) ImmutableBidderList { - return ImmutableBidderList{proxy: m.proxy.Key(key.Bytes())} + return ImmutableBidderList{proxy: m.proxy.Key(wasmtypes.BytesFromColor(key))} } type MapColorToImmutableBids struct { @@ -30,7 +30,7 @@ type MapColorToImmutableBids struct { } func (m MapColorToImmutableBids) GetBids(key wasmtypes.ScColor) ImmutableBids { - return ImmutableBids{proxy: m.proxy.Key(key.Bytes())} + return ImmutableBids{proxy: m.proxy.Key(wasmtypes.BytesFromColor(key))} } type ImmutableFairAuctionState struct { @@ -62,7 +62,7 @@ func (m MapColorToMutableAuction) Clear() { } func (m MapColorToMutableAuction) GetAuction(key wasmtypes.ScColor) MutableAuction { - return MutableAuction{proxy: m.proxy.Key(key.Bytes())} + return MutableAuction{proxy: m.proxy.Key(wasmtypes.BytesFromColor(key))} } type MapColorToMutableBidderList struct { @@ -74,7 +74,7 @@ func (m MapColorToMutableBidderList) Clear() { } func (m MapColorToMutableBidderList) GetBidderList(key wasmtypes.ScColor) MutableBidderList { - return MutableBidderList{proxy: m.proxy.Key(key.Bytes())} + return MutableBidderList{proxy: m.proxy.Key(wasmtypes.BytesFromColor(key))} } type MapColorToMutableBids struct { @@ -86,7 +86,7 @@ func (m MapColorToMutableBids) Clear() { } func (m MapColorToMutableBids) GetBids(key wasmtypes.ScColor) MutableBids { - return MutableBids{proxy: m.proxy.Key(key.Bytes())} + return MutableBids{proxy: m.proxy.Key(wasmtypes.BytesFromColor(key))} } type MutableFairAuctionState struct { diff --git a/contracts/wasm/fairauction/go/fairauction/structs.go b/contracts/wasm/fairauction/go/fairauction/structs.go index 2baa66e008..1d36eb8c26 100644 --- a/contracts/wasm/fairauction/go/fairauction/structs.go +++ b/contracts/wasm/fairauction/go/fairauction/structs.go @@ -7,10 +7,7 @@ package fairauction -import ( - "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmcodec" - "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" -) +import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" type Auction struct { Color wasmtypes.ScColor // color of tokens for sale @@ -27,7 +24,7 @@ type Auction struct { } func NewAuctionFromBytes(buf []byte) *Auction { - dec := wasmcodec.NewWasmDecoder(buf) + dec := wasmtypes.NewWasmDecoder(buf) data := &Auction{} data.Color = wasmtypes.DecodeColor(dec) data.Creator = wasmtypes.DecodeAgentID(dec) @@ -45,7 +42,7 @@ func NewAuctionFromBytes(buf []byte) *Auction { } func (o *Auction) Bytes() []byte { - enc := wasmcodec.NewWasmEncoder() + enc := wasmtypes.NewWasmEncoder() wasmtypes.EncodeColor(enc, o.Color) wasmtypes.EncodeAgentID(enc, o.Creator) wasmtypes.EncodeUint64(enc, o.Deposit) @@ -99,7 +96,7 @@ type Bid struct { } func NewBidFromBytes(buf []byte) *Bid { - dec := wasmcodec.NewWasmDecoder(buf) + dec := wasmtypes.NewWasmDecoder(buf) data := &Bid{} data.Amount = wasmtypes.DecodeUint64(dec) data.Index = wasmtypes.DecodeUint32(dec) @@ -109,7 +106,7 @@ func NewBidFromBytes(buf []byte) *Bid { } func (o *Bid) Bytes() []byte { - enc := wasmcodec.NewWasmEncoder() + enc := wasmtypes.NewWasmEncoder() wasmtypes.EncodeUint64(enc, o.Amount) wasmtypes.EncodeUint32(enc, o.Index) wasmtypes.EncodeUint64(enc, o.Timestamp) diff --git a/contracts/wasm/fairauction/go/fairauction/typedefs.go b/contracts/wasm/fairauction/go/fairauction/typedefs.go index 4defcbafbb..e399e4cdf4 100644 --- a/contracts/wasm/fairauction/go/fairauction/typedefs.go +++ b/contracts/wasm/fairauction/go/fairauction/typedefs.go @@ -50,7 +50,7 @@ type MapAgentIDToImmutableBid struct { } func (m MapAgentIDToImmutableBid) GetBid(key wasmtypes.ScAgentID) ImmutableBid { - return ImmutableBid{proxy: m.proxy.Key(key.Bytes())} + return ImmutableBid{proxy: m.proxy.Key(wasmtypes.BytesFromAgentID(key))} } type ImmutableBids = MapAgentIDToImmutableBid @@ -64,7 +64,7 @@ func (m MapAgentIDToMutableBid) Clear() { } func (m MapAgentIDToMutableBid) GetBid(key wasmtypes.ScAgentID) MutableBid { - return MutableBid{proxy: m.proxy.Key(key.Bytes())} + return MutableBid{proxy: m.proxy.Key(wasmtypes.BytesFromAgentID(key))} } type MutableBids = MapAgentIDToMutableBid diff --git a/contracts/wasm/fairroulette/go/fairroulette/events.go b/contracts/wasm/fairroulette/go/fairroulette/events.go index 0159e09921..6f05c31d77 100644 --- a/contracts/wasm/fairroulette/go/fairroulette/events.go +++ b/contracts/wasm/fairroulette/go/fairroulette/events.go @@ -15,38 +15,38 @@ import ( type FairRouletteEvents struct{} func (e FairRouletteEvents) Bet(address wasmtypes.ScAddress, amount uint64, number uint16) { - wasmlib.NewEventEncoder("fairroulette.bet"). - Address(address). - Uint64(amount). - Uint16(number). - Emit() + evt := wasmlib.NewEventEncoder("fairroulette.bet") + evt.Encode(wasmtypes.AddressToString(address)) + evt.Encode(wasmtypes.Uint64ToString(amount)) + evt.Encode(wasmtypes.Uint16ToString(number)) + evt.Emit() } func (e FairRouletteEvents) Payout(address wasmtypes.ScAddress, amount uint64) { - wasmlib.NewEventEncoder("fairroulette.payout"). - Address(address). - Uint64(amount). - Emit() + evt := wasmlib.NewEventEncoder("fairroulette.payout") + evt.Encode(wasmtypes.AddressToString(address)) + evt.Encode(wasmtypes.Uint64ToString(amount)) + evt.Emit() } func (e FairRouletteEvents) Round(number uint32) { - wasmlib.NewEventEncoder("fairroulette.round"). - Uint32(number). - Emit() + evt := wasmlib.NewEventEncoder("fairroulette.round") + evt.Encode(wasmtypes.Uint32ToString(number)) + evt.Emit() } func (e FairRouletteEvents) Start() { - wasmlib.NewEventEncoder("fairroulette.start"). - Emit() + evt := wasmlib.NewEventEncoder("fairroulette.start") + evt.Emit() } func (e FairRouletteEvents) Stop() { - wasmlib.NewEventEncoder("fairroulette.stop"). - Emit() + evt := wasmlib.NewEventEncoder("fairroulette.stop") + evt.Emit() } func (e FairRouletteEvents) Winner(number uint16) { - wasmlib.NewEventEncoder("fairroulette.winner"). - Uint16(number). - Emit() + evt := wasmlib.NewEventEncoder("fairroulette.winner") + evt.Encode(wasmtypes.Uint16ToString(number)) + evt.Emit() } diff --git a/contracts/wasm/fairroulette/go/fairroulette/structs.go b/contracts/wasm/fairroulette/go/fairroulette/structs.go index f96f3ac96f..d130221353 100644 --- a/contracts/wasm/fairroulette/go/fairroulette/structs.go +++ b/contracts/wasm/fairroulette/go/fairroulette/structs.go @@ -7,10 +7,7 @@ package fairroulette -import ( - "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmcodec" - "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" -) +import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" type Bet struct { Amount uint64 @@ -19,7 +16,7 @@ type Bet struct { } func NewBetFromBytes(buf []byte) *Bet { - dec := wasmcodec.NewWasmDecoder(buf) + dec := wasmtypes.NewWasmDecoder(buf) data := &Bet{} data.Amount = wasmtypes.DecodeUint64(dec) data.Better = wasmtypes.DecodeAgentID(dec) @@ -29,7 +26,7 @@ func NewBetFromBytes(buf []byte) *Bet { } func (o *Bet) Bytes() []byte { - enc := wasmcodec.NewWasmEncoder() + enc := wasmtypes.NewWasmEncoder() wasmtypes.EncodeUint64(enc, o.Amount) wasmtypes.EncodeAgentID(enc, o.Better) wasmtypes.EncodeUint16(enc, o.Number) diff --git a/contracts/wasm/inccounter/go/inccounter/inccounter.go b/contracts/wasm/inccounter/go/inccounter/inccounter.go index fdf2031b67..88e97dc386 100644 --- a/contracts/wasm/inccounter/go/inccounter/inccounter.go +++ b/contracts/wasm/inccounter/go/inccounter/inccounter.go @@ -7,7 +7,6 @@ import ( "strconv" "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" - "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmcodec" "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" ) @@ -169,10 +168,10 @@ func viewGetCounter(ctx wasmlib.ScViewContext, f *GetCounterContext) { //nolint:dupl func viewGetVli(ctx wasmlib.ScViewContext, f *GetVliContext) { - enc := wasmcodec.NewWasmEncoder() + enc := wasmtypes.NewWasmEncoder() n := f.Params.Ni64().Value() buf := enc.VliEncode(n).Buf() - dec := wasmcodec.NewWasmDecoder(buf) + dec := wasmtypes.NewWasmDecoder(buf) x := wasmtypes.DecodeInt64(dec) str := strconv.FormatInt(n, 10) + " -" @@ -190,10 +189,10 @@ func viewGetVli(ctx wasmlib.ScViewContext, f *GetVliContext) { //nolint:dupl func viewGetVlu(ctx wasmlib.ScViewContext, f *GetVluContext) { - enc := wasmcodec.NewWasmEncoder() + enc := wasmtypes.NewWasmEncoder() n := f.Params.Nu64().Value() buf := enc.VluEncode(n).Buf() - dec := wasmcodec.NewWasmDecoder(buf) + dec := wasmtypes.NewWasmDecoder(buf) x := wasmtypes.DecodeUint64(dec) str := strconv.FormatUint(n, 10) + " -" @@ -219,12 +218,12 @@ func localStatePost(ctx wasmlib.ScFuncContext, nr int64) { } func vliSave(ctx wasmlib.ScFuncContext, name string, value int64) { - enc := wasmcodec.NewWasmEncoder() + enc := wasmtypes.NewWasmEncoder() state := wasmlib.ScState{} state.Set([]byte(name), enc.VliEncode(value).Buf()) buf := state.Get([]byte(name)) - dec := wasmcodec.NewWasmDecoder(buf) + dec := wasmtypes.NewWasmDecoder(buf) retrieved := wasmtypes.DecodeInt64(dec) if retrieved != value { ctx.Log(name + " in : " + ctx.Utility().String(value)) @@ -233,12 +232,12 @@ func vliSave(ctx wasmlib.ScFuncContext, name string, value int64) { } func vluSave(ctx wasmlib.ScFuncContext, name string, value uint64) { - enc := wasmcodec.NewWasmEncoder() + enc := wasmtypes.NewWasmEncoder() state := wasmlib.ScState{} state.Set([]byte(name), enc.VluEncode(value).Buf()) buf := state.Get([]byte(name)) - dec := wasmcodec.NewWasmDecoder(buf) + dec := wasmtypes.NewWasmDecoder(buf) retrieved := wasmtypes.DecodeUint64(dec) if retrieved != value { ctx.Log(name + " in : " + ctx.Utility().String(int64(value))) diff --git a/contracts/wasm/testwasmlib/go/testwasmlib/events.go b/contracts/wasm/testwasmlib/go/testwasmlib/events.go index 49514ce382..72a21499f1 100644 --- a/contracts/wasm/testwasmlib/go/testwasmlib/events.go +++ b/contracts/wasm/testwasmlib/go/testwasmlib/events.go @@ -15,8 +15,8 @@ import ( type TestWasmLibEvents struct{} func (e TestWasmLibEvents) Test(address wasmtypes.ScAddress, name string) { - wasmlib.NewEventEncoder("testwasmlib.test"). - Address(address). - String(name). - Emit() + evt := wasmlib.NewEventEncoder("testwasmlib.test") + evt.Encode(wasmtypes.AddressToString(address)) + evt.Encode(wasmtypes.StringToString(name)) + evt.Emit() } diff --git a/contracts/wasm/testwasmlib/go/testwasmlib/structs.go b/contracts/wasm/testwasmlib/go/testwasmlib/structs.go index bdfd327928..ac02c3738d 100644 --- a/contracts/wasm/testwasmlib/go/testwasmlib/structs.go +++ b/contracts/wasm/testwasmlib/go/testwasmlib/structs.go @@ -8,7 +8,6 @@ package testwasmlib import ( - "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmcodec" "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" ) @@ -20,7 +19,7 @@ type CallRequest struct { } func NewCallRequestFromBytes(buf []byte) *CallRequest { - dec := wasmcodec.NewWasmDecoder(buf) + dec := wasmtypes.NewWasmDecoder(buf) data := &CallRequest{} data.Contract = wasmtypes.DecodeHname(dec) data.Function = wasmtypes.DecodeHname(dec) @@ -31,7 +30,7 @@ func NewCallRequestFromBytes(buf []byte) *CallRequest { } func (o *CallRequest) Bytes() []byte { - enc := wasmcodec.NewWasmEncoder() + enc := wasmtypes.NewWasmEncoder() wasmtypes.EncodeHname(enc, o.Contract) wasmtypes.EncodeHname(enc, o.Function) wasmtypes.EncodeBytes(enc, o.Params) @@ -79,7 +78,7 @@ type DeployRequest struct { } func NewDeployRequestFromBytes(buf []byte) *DeployRequest { - dec := wasmcodec.NewWasmDecoder(buf) + dec := wasmtypes.NewWasmDecoder(buf) data := &DeployRequest{} data.Description = wasmtypes.DecodeString(dec) data.Name = wasmtypes.DecodeString(dec) @@ -90,7 +89,7 @@ func NewDeployRequestFromBytes(buf []byte) *DeployRequest { } func (o *DeployRequest) Bytes() []byte { - enc := wasmcodec.NewWasmEncoder() + enc := wasmtypes.NewWasmEncoder() wasmtypes.EncodeString(enc, o.Description) wasmtypes.EncodeString(enc, o.Name) wasmtypes.EncodeBytes(enc, o.Params) @@ -140,7 +139,7 @@ type PostRequest struct { } func NewPostRequestFromBytes(buf []byte) *PostRequest { - dec := wasmcodec.NewWasmDecoder(buf) + dec := wasmtypes.NewWasmDecoder(buf) data := &PostRequest{} data.ChainID = wasmtypes.DecodeChainID(dec) data.Contract = wasmtypes.DecodeHname(dec) @@ -153,7 +152,7 @@ func NewPostRequestFromBytes(buf []byte) *PostRequest { } func (o *PostRequest) Bytes() []byte { - enc := wasmcodec.NewWasmEncoder() + enc := wasmtypes.NewWasmEncoder() wasmtypes.EncodeChainID(enc, o.ChainID) wasmtypes.EncodeHname(enc, o.Contract) wasmtypes.EncodeUint32(enc, o.Delay) @@ -201,7 +200,7 @@ type SendRequest struct { } func NewSendRequestFromBytes(buf []byte) *SendRequest { - dec := wasmcodec.NewWasmDecoder(buf) + dec := wasmtypes.NewWasmDecoder(buf) data := &SendRequest{} data.Address = wasmtypes.DecodeAddress(dec) data.Transfer = wasmtypes.DecodeBytes(dec) @@ -210,7 +209,7 @@ func NewSendRequestFromBytes(buf []byte) *SendRequest { } func (o *SendRequest) Bytes() []byte { - enc := wasmcodec.NewWasmEncoder() + enc := wasmtypes.NewWasmEncoder() wasmtypes.EncodeAddress(enc, o.Address) wasmtypes.EncodeBytes(enc, o.Transfer) return enc.Buf() diff --git a/contracts/wasm/tokenregistry/go/tokenregistry/state.go b/contracts/wasm/tokenregistry/go/tokenregistry/state.go index e8e7277a38..6d7f964ed4 100644 --- a/contracts/wasm/tokenregistry/go/tokenregistry/state.go +++ b/contracts/wasm/tokenregistry/go/tokenregistry/state.go @@ -26,7 +26,7 @@ type MapColorToImmutableToken struct { } func (m MapColorToImmutableToken) GetToken(key wasmtypes.ScColor) ImmutableToken { - return ImmutableToken{proxy: m.proxy.Key(key.Bytes())} + return ImmutableToken{proxy: m.proxy.Key(wasmtypes.BytesFromColor(key))} } type ImmutableTokenRegistryState struct { @@ -70,7 +70,7 @@ func (m MapColorToMutableToken) Clear() { } func (m MapColorToMutableToken) GetToken(key wasmtypes.ScColor) MutableToken { - return MutableToken{proxy: m.proxy.Key(key.Bytes())} + return MutableToken{proxy: m.proxy.Key(wasmtypes.BytesFromColor(key))} } type MutableTokenRegistryState struct { diff --git a/contracts/wasm/tokenregistry/go/tokenregistry/structs.go b/contracts/wasm/tokenregistry/go/tokenregistry/structs.go index 3234c8de19..2c531a8486 100644 --- a/contracts/wasm/tokenregistry/go/tokenregistry/structs.go +++ b/contracts/wasm/tokenregistry/go/tokenregistry/structs.go @@ -7,10 +7,7 @@ package tokenregistry -import ( - "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmcodec" - "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" -) +import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" type Token struct { Created uint64 // creation timestamp @@ -23,7 +20,7 @@ type Token struct { } func NewTokenFromBytes(buf []byte) *Token { - dec := wasmcodec.NewWasmDecoder(buf) + dec := wasmtypes.NewWasmDecoder(buf) data := &Token{} data.Created = wasmtypes.DecodeUint64(dec) data.Description = wasmtypes.DecodeString(dec) @@ -37,7 +34,7 @@ func NewTokenFromBytes(buf []byte) *Token { } func (o *Token) Bytes() []byte { - enc := wasmcodec.NewWasmEncoder() + enc := wasmtypes.NewWasmEncoder() wasmtypes.EncodeUint64(enc, o.Created) wasmtypes.EncodeString(enc, o.Description) wasmtypes.EncodeAgentID(enc, o.MintedBy) diff --git a/packages/vm/wasmhost/wasmtosandboxutils.go b/packages/vm/wasmhost/wasmtosandboxutils.go index e5be77ebc1..cd9108fd37 100644 --- a/packages/vm/wasmhost/wasmtosandboxutils.go +++ b/packages/vm/wasmhost/wasmtosandboxutils.go @@ -5,7 +5,6 @@ package wasmhost import ( "github.com/iotaledger/wasp/packages/kv/codec" - "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmcodec" "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" ) @@ -26,7 +25,7 @@ func (s WasmToSandbox) fnUtilsBlsAddress(args []byte) []byte { } func (s WasmToSandbox) fnUtilsBlsAggregate(args []byte) []byte { - dec := wasmcodec.NewWasmDecoder(args) + dec := wasmtypes.NewWasmDecoder(args) count := wasmtypes.DecodeUint32(dec) pubKeysBin := make([][]byte, count) for i := uint32(0); i < count; i++ { @@ -39,11 +38,11 @@ func (s WasmToSandbox) fnUtilsBlsAggregate(args []byte) []byte { } pubKeyBin, sigBin, err := s.common.Utils().BLS().AggregateBLSSignatures(pubKeysBin, sigsBin) s.checkErr(err) - return wasmcodec.NewWasmEncoder().Bytes(pubKeyBin).Bytes(sigBin).Buf() + return wasmtypes.NewWasmEncoder().Bytes(pubKeyBin).Bytes(sigBin).Buf() } func (s WasmToSandbox) fnUtilsBlsValid(args []byte) []byte { - dec := wasmcodec.NewWasmDecoder(args) + dec := wasmtypes.NewWasmDecoder(args) data := dec.Bytes() pubKey := dec.Bytes() signature := dec.Bytes() @@ -58,7 +57,7 @@ func (s WasmToSandbox) fnUtilsEd25519Address(args []byte) []byte { } func (s WasmToSandbox) fnUtilsEd25519Valid(args []byte) []byte { - dec := wasmcodec.NewWasmDecoder(args) + dec := wasmtypes.NewWasmDecoder(args) data := dec.Bytes() pubKey := dec.Bytes() signature := dec.Bytes() diff --git a/packages/vm/wasmlib/go/wasmlib/assets.go b/packages/vm/wasmlib/go/wasmlib/assets.go index cb5cc02ad0..ea9151ee33 100644 --- a/packages/vm/wasmlib/go/wasmlib/assets.go +++ b/packages/vm/wasmlib/go/wasmlib/assets.go @@ -6,7 +6,6 @@ package wasmlib import ( "sort" - "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmcodec" "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" ) @@ -16,7 +15,7 @@ func NewScAssetsFromBytes(buf []byte) ScAssets { if len(buf) == 0 { return make(ScAssets) } - dec := wasmcodec.NewWasmDecoder(buf) + dec := wasmtypes.NewWasmDecoder(buf) size := wasmtypes.Uint32FromBytes(dec.FixedBytes(wasmtypes.ScUint32Length)) dict := make(ScAssets, size) for i := uint32(0); i < size; i++ { @@ -34,7 +33,7 @@ func (a ScAssets) Bytes() []byte { sort.Slice(keys, func(i, j int) bool { return string(keys[i].Bytes()) < string(keys[j].Bytes()) }) - enc := wasmcodec.NewWasmEncoder() + enc := wasmtypes.NewWasmEncoder() enc.FixedBytes(wasmtypes.BytesFromUint32(uint32(len(keys))), wasmtypes.ScUint32Length) for _, color := range keys { enc.FixedBytes(color.Bytes(), wasmtypes.ScColorLength) diff --git a/packages/vm/wasmlib/go/wasmlib/coreaccounts/results.go b/packages/vm/wasmlib/go/wasmlib/coreaccounts/results.go index 64f6eb93df..eaf9429363 100644 --- a/packages/vm/wasmlib/go/wasmlib/coreaccounts/results.go +++ b/packages/vm/wasmlib/go/wasmlib/coreaccounts/results.go @@ -14,7 +14,7 @@ type MapAgentIDToImmutableBytes struct { } func (m MapAgentIDToImmutableBytes) GetBytes(key wasmtypes.ScAgentID) wasmtypes.ScImmutableBytes { - return wasmtypes.NewScImmutableBytes(m.proxy.Key(key.Bytes())) + return wasmtypes.NewScImmutableBytes(m.proxy.Key(wasmtypes.BytesFromAgentID(key))) } type ImmutableAccountsResults struct { @@ -35,7 +35,7 @@ func (m MapAgentIDToMutableBytes) Clear() { } func (m MapAgentIDToMutableBytes) GetBytes(key wasmtypes.ScAgentID) wasmtypes.ScMutableBytes { - return wasmtypes.NewScMutableBytes(m.proxy.Key(key.Bytes())) + return wasmtypes.NewScMutableBytes(m.proxy.Key(wasmtypes.BytesFromAgentID(key))) } type MutableAccountsResults struct { @@ -52,7 +52,7 @@ type MapColorToImmutableInt64 struct { } func (m MapColorToImmutableInt64) GetInt64(key wasmtypes.ScColor) wasmtypes.ScImmutableInt64 { - return wasmtypes.NewScImmutableInt64(m.proxy.Key(key.Bytes())) + return wasmtypes.NewScImmutableInt64(m.proxy.Key(wasmtypes.BytesFromColor(key))) } type ImmutableBalanceResults struct { @@ -73,7 +73,7 @@ func (m MapColorToMutableInt64) Clear() { } func (m MapColorToMutableInt64) GetInt64(key wasmtypes.ScColor) wasmtypes.ScMutableInt64 { - return wasmtypes.NewScMutableInt64(m.proxy.Key(key.Bytes())) + return wasmtypes.NewScMutableInt64(m.proxy.Key(wasmtypes.BytesFromColor(key))) } type MutableBalanceResults struct { diff --git a/packages/vm/wasmlib/go/wasmlib/coreblob/results.go b/packages/vm/wasmlib/go/wasmlib/coreblob/results.go index 1868827ad7..a55b75cdc4 100644 --- a/packages/vm/wasmlib/go/wasmlib/coreblob/results.go +++ b/packages/vm/wasmlib/go/wasmlib/coreblob/results.go @@ -84,7 +84,7 @@ type MapHashToImmutableInt32 struct { } func (m MapHashToImmutableInt32) GetInt32(key wasmtypes.ScHash) wasmtypes.ScImmutableInt32 { - return wasmtypes.NewScImmutableInt32(m.proxy.Key(key.Bytes())) + return wasmtypes.NewScImmutableInt32(m.proxy.Key(wasmtypes.BytesFromHash(key))) } type ImmutableListBlobsResults struct { @@ -105,7 +105,7 @@ func (m MapHashToMutableInt32) Clear() { } func (m MapHashToMutableInt32) GetInt32(key wasmtypes.ScHash) wasmtypes.ScMutableInt32 { - return wasmtypes.NewScMutableInt32(m.proxy.Key(key.Bytes())) + return wasmtypes.NewScMutableInt32(m.proxy.Key(wasmtypes.BytesFromHash(key))) } type MutableListBlobsResults struct { diff --git a/packages/vm/wasmlib/go/wasmlib/coreroot/results.go b/packages/vm/wasmlib/go/wasmlib/coreroot/results.go index f422fa2825..869af58b69 100644 --- a/packages/vm/wasmlib/go/wasmlib/coreroot/results.go +++ b/packages/vm/wasmlib/go/wasmlib/coreroot/results.go @@ -38,7 +38,7 @@ type MapHnameToImmutableBytes struct { } func (m MapHnameToImmutableBytes) GetBytes(key wasmtypes.ScHname) wasmtypes.ScImmutableBytes { - return wasmtypes.NewScImmutableBytes(m.proxy.Key(key.Bytes())) + return wasmtypes.NewScImmutableBytes(m.proxy.Key(wasmtypes.BytesFromHname(key))) } type ImmutableGetContractRecordsResults struct { @@ -58,7 +58,7 @@ func (m MapHnameToMutableBytes) Clear() { } func (m MapHnameToMutableBytes) GetBytes(key wasmtypes.ScHname) wasmtypes.ScMutableBytes { - return wasmtypes.NewScMutableBytes(m.proxy.Key(key.Bytes())) + return wasmtypes.NewScMutableBytes(m.proxy.Key(wasmtypes.BytesFromHname(key))) } type MutableGetContractRecordsResults struct { diff --git a/packages/vm/wasmlib/go/wasmlib/dict.go b/packages/vm/wasmlib/go/wasmlib/dict.go index c51ccd61a5..2e63a5445b 100644 --- a/packages/vm/wasmlib/go/wasmlib/dict.go +++ b/packages/vm/wasmlib/go/wasmlib/dict.go @@ -6,7 +6,6 @@ package wasmlib import ( "sort" - "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmcodec" "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" ) @@ -22,7 +21,7 @@ func NewScDictFromBytes(buf []byte) ScDict { if len(buf) == 0 { return make(ScDict) } - dec := wasmcodec.NewWasmDecoder(buf) + dec := wasmtypes.NewWasmDecoder(buf) size := wasmtypes.Uint32FromBytes(dec.FixedBytes(wasmtypes.ScUint32Length)) dict := make(ScDict, size) for i := uint32(0); i < size; i++ { @@ -47,7 +46,7 @@ func (d ScDict) Bytes() []byte { sort.Slice(keys, func(i, j int) bool { return keys[i] < keys[j] }) - enc := wasmcodec.NewWasmEncoder() + enc := wasmtypes.NewWasmEncoder() enc.FixedBytes(wasmtypes.BytesFromUint32(uint32(len(keys))), wasmtypes.ScUint32Length) for _, k := range keys { key := []byte(k) diff --git a/packages/vm/wasmlib/go/wasmlib/events.go b/packages/vm/wasmlib/go/wasmlib/events.go index f48e2541f7..1717f3a550 100644 --- a/packages/vm/wasmlib/go/wasmlib/events.go +++ b/packages/vm/wasmlib/go/wasmlib/events.go @@ -18,7 +18,8 @@ func NewEventEncoder(eventName string) *EventEncoder { e := &EventEncoder{event: eventName} timestamp := ScSandbox{}.Timestamp() // convert nanoseconds to seconds - return e.Uint64(timestamp / 1_000_000_000) + e.Encode(wasmtypes.Uint64ToString(timestamp / 1_000_000_000)) + return e } func (e *EventEncoder) Address(value wasmtypes.ScAddress) *EventEncoder { @@ -52,6 +53,11 @@ func (e *EventEncoder) Emit() { ScSandboxFunc{}.Event(e.event) } +func (e *EventEncoder) Encode(value string) { + // TODO encode potential vertical bars that are present in the value string + e.event += "|" + value +} + func (e *EventEncoder) Hash(value wasmtypes.ScHash) *EventEncoder { return e.String(value.String()) } diff --git a/packages/vm/wasmlib/go/wasmlib/sandboxutils.go b/packages/vm/wasmlib/go/wasmlib/sandboxutils.go index e71fecfa75..8d4769dd6d 100644 --- a/packages/vm/wasmlib/go/wasmlib/sandboxutils.go +++ b/packages/vm/wasmlib/go/wasmlib/sandboxutils.go @@ -4,7 +4,6 @@ package wasmlib import ( - "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmcodec" "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" ) @@ -25,7 +24,7 @@ func (u ScSandboxUtils) BlsAddressFromPubKey(pubKey []byte) wasmtypes.ScAddress } func (u ScSandboxUtils) BlsAggregateSignatures(pubKeys, sigs [][]byte) ([]byte, []byte) { - enc := wasmcodec.NewWasmEncoder() + enc := wasmtypes.NewWasmEncoder() wasmtypes.EncodeUint32(enc, uint32(len(pubKeys))) for _, pubKey := range pubKeys { enc.Bytes(pubKey) @@ -35,12 +34,12 @@ func (u ScSandboxUtils) BlsAggregateSignatures(pubKeys, sigs [][]byte) ([]byte, enc.Bytes(sig) } result := Sandbox(FnUtilsBlsAggregate, enc.Buf()) - decode := wasmcodec.NewWasmDecoder(result) + decode := wasmtypes.NewWasmDecoder(result) return decode.Bytes(), decode.Bytes() } func (u ScSandboxUtils) BlsValidSignature(data, pubKey, signature []byte) bool { - enc := wasmcodec.NewWasmEncoder().Bytes(data).Bytes(pubKey).Bytes(signature) + enc := wasmtypes.NewWasmEncoder().Bytes(data).Bytes(pubKey).Bytes(signature) return wasmtypes.BoolFromBytes(Sandbox(FnUtilsBlsValid, enc.Buf())) } @@ -49,7 +48,7 @@ func (u ScSandboxUtils) Ed25519AddressFromPubKey(pubKey []byte) wasmtypes.ScAddr } func (u ScSandboxUtils) Ed25519ValidSignature(data, pubKey, signature []byte) bool { - enc := wasmcodec.NewWasmEncoder().Bytes(data).Bytes(pubKey).Bytes(signature) + enc := wasmtypes.NewWasmEncoder().Bytes(data).Bytes(pubKey).Bytes(signature) return wasmtypes.BoolFromBytes(Sandbox(FnUtilsEd25519Valid, enc.Buf())) } @@ -70,5 +69,5 @@ func (u ScSandboxUtils) Hname(value string) wasmtypes.ScHname { // converts an integer to its string representation func (u ScSandboxUtils) String(value int64) string { - return wasmtypes.StringFromInt64(value) + return wasmtypes.Int64ToString(value) } diff --git a/packages/vm/wasmlib/go/wasmlib/wasmrequests/structs.go b/packages/vm/wasmlib/go/wasmlib/wasmrequests/structs.go index f23953fdaa..6bb15070d6 100644 --- a/packages/vm/wasmlib/go/wasmlib/wasmrequests/structs.go +++ b/packages/vm/wasmlib/go/wasmlib/wasmrequests/structs.go @@ -7,10 +7,7 @@ package wasmrequests -import ( - "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmcodec" - "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" -) +import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" type CallRequest struct { Contract wasmtypes.ScHname @@ -20,7 +17,7 @@ type CallRequest struct { } func NewCallRequestFromBytes(buf []byte) *CallRequest { - dec := wasmcodec.NewWasmDecoder(buf) + dec := wasmtypes.NewWasmDecoder(buf) data := &CallRequest{} data.Contract = wasmtypes.DecodeHname(dec) data.Function = wasmtypes.DecodeHname(dec) @@ -31,7 +28,7 @@ func NewCallRequestFromBytes(buf []byte) *CallRequest { } func (o *CallRequest) Bytes() []byte { - enc := wasmcodec.NewWasmEncoder() + enc := wasmtypes.NewWasmEncoder() wasmtypes.EncodeHname(enc, o.Contract) wasmtypes.EncodeHname(enc, o.Function) wasmtypes.EncodeBytes(enc, o.Params) @@ -79,7 +76,7 @@ type DeployRequest struct { } func NewDeployRequestFromBytes(buf []byte) *DeployRequest { - dec := wasmcodec.NewWasmDecoder(buf) + dec := wasmtypes.NewWasmDecoder(buf) data := &DeployRequest{} data.Description = wasmtypes.DecodeString(dec) data.Name = wasmtypes.DecodeString(dec) @@ -90,7 +87,7 @@ func NewDeployRequestFromBytes(buf []byte) *DeployRequest { } func (o *DeployRequest) Bytes() []byte { - enc := wasmcodec.NewWasmEncoder() + enc := wasmtypes.NewWasmEncoder() wasmtypes.EncodeString(enc, o.Description) wasmtypes.EncodeString(enc, o.Name) wasmtypes.EncodeBytes(enc, o.Params) @@ -140,7 +137,7 @@ type PostRequest struct { } func NewPostRequestFromBytes(buf []byte) *PostRequest { - dec := wasmcodec.NewWasmDecoder(buf) + dec := wasmtypes.NewWasmDecoder(buf) data := &PostRequest{} data.ChainID = wasmtypes.DecodeChainID(dec) data.Contract = wasmtypes.DecodeHname(dec) @@ -153,7 +150,7 @@ func NewPostRequestFromBytes(buf []byte) *PostRequest { } func (o *PostRequest) Bytes() []byte { - enc := wasmcodec.NewWasmEncoder() + enc := wasmtypes.NewWasmEncoder() wasmtypes.EncodeChainID(enc, o.ChainID) wasmtypes.EncodeHname(enc, o.Contract) wasmtypes.EncodeUint32(enc, o.Delay) @@ -201,7 +198,7 @@ type SendRequest struct { } func NewSendRequestFromBytes(buf []byte) *SendRequest { - dec := wasmcodec.NewWasmDecoder(buf) + dec := wasmtypes.NewWasmDecoder(buf) data := &SendRequest{} data.Address = wasmtypes.DecodeAddress(dec) data.Transfer = wasmtypes.DecodeBytes(dec) @@ -210,7 +207,7 @@ func NewSendRequestFromBytes(buf []byte) *SendRequest { } func (o *SendRequest) Bytes() []byte { - enc := wasmcodec.NewWasmEncoder() + enc := wasmtypes.NewWasmEncoder() wasmtypes.EncodeAddress(enc, o.Address) wasmtypes.EncodeBytes(enc, o.Transfer) return enc.Buf() diff --git a/packages/vm/wasmlib/go/wasmlib/wasmtypes/address.go b/packages/vm/wasmlib/go/wasmlib/wasmtypes/address.go index dcafc361ce..c5a80e9fd0 100644 --- a/packages/vm/wasmlib/go/wasmlib/wasmtypes/address.go +++ b/packages/vm/wasmlib/go/wasmlib/wasmtypes/address.go @@ -3,23 +3,39 @@ package wasmtypes -import ( - "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmcodec" -) - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - const ScAddressLength = 33 type ScAddress struct { id [ScAddressLength]byte } -func DecodeAddress(dec *wasmcodec.WasmDecoder) ScAddress { - return newAddressFromBytes(dec.FixedBytes(ScAddressLength)) +func addressFromBytes(buf []byte) ScAddress { + o := ScAddress{} + copy(o.id[:], buf) + return o +} + +func (o ScAddress) AsAgentID() ScAgentID { + // agentID for address has Hname zero + return NewScAgentID(o, 0) +} + +func (o ScAddress) Bytes() []byte { + return o.id[:] +} + +func (o ScAddress) String() string { + // TODO standardize human readable string + return base58Encode(o.id[:]) } -func EncodeAddress(enc *wasmcodec.WasmEncoder, value ScAddress) { +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +func DecodeAddress(dec *WasmDecoder) ScAddress { + return addressFromBytes(dec.FixedBytes(ScAddressLength)) +} + +func EncodeAddress(enc *WasmEncoder, value ScAddress) { enc.FixedBytes(value.Bytes(), ScAddressLength) } @@ -28,33 +44,21 @@ func AddressFromBytes(buf []byte) ScAddress { return ScAddress{} } if len(buf) != ScAddressLength { - Panic("invalid Address length") + panic("invalid Address length") } // max ledgerstate.AliasAddressType if buf[0] > 2 { - Panic("invalid Address: address type > 2") + panic("invalid Address: address type > 2") } - return newAddressFromBytes(buf) + return addressFromBytes(buf) } -func newAddressFromBytes(buf []byte) ScAddress { - o := ScAddress{} - copy(o.id[:], buf) - return o +func BytesFromAddress(value ScAddress) []byte { + return value.Bytes() } -func (o ScAddress) AsAgentID() ScAgentID { - // agentID for address has Hname zero - return NewScAgentID(o, 0) -} - -func (o ScAddress) Bytes() []byte { - return o.id[:] -} - -func (o ScAddress) String() string { - // TODO standardize human readable string - return base58Encode(o.id[:]) +func AddressToString(value ScAddress) string { + return value.String() } // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ diff --git a/packages/vm/wasmlib/go/wasmlib/wasmtypes/agentid.go b/packages/vm/wasmlib/go/wasmlib/wasmtypes/agentid.go index 19b1686daa..cf0eea2f65 100644 --- a/packages/vm/wasmlib/go/wasmlib/wasmtypes/agentid.go +++ b/packages/vm/wasmlib/go/wasmlib/wasmtypes/agentid.go @@ -3,12 +3,6 @@ package wasmtypes -import ( - "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmcodec" -) - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - const ScAgentIDLength = ScAddressLength + ScHnameLength type ScAgentID struct { @@ -16,46 +10,23 @@ type ScAgentID struct { hname ScHname } -func DecodeAgentID(dec *wasmcodec.WasmDecoder) ScAgentID { - return newAgentIDFromBytes(dec.FixedBytes(ScAgentIDLength)) -} - -func EncodeAgentID(enc *wasmcodec.WasmEncoder, value ScAgentID) { - EncodeAddress(enc, value.address) - EncodeHname(enc, value.hname) -} - -func AgentIDFromBytes(buf []byte) ScAgentID { - if buf == nil { - return ScAgentID{} - } - if len(buf) != ScAgentIDLength { - Panic("invalid AgentID length") - } - // max ledgerstate.AliasAddressType - if buf[0] > 2 { - Panic("invalid AgentID: address type > 2") - } - return newAgentIDFromBytes(buf) +func NewScAgentID(address ScAddress, hname ScHname) ScAgentID { + return ScAgentID{address: address, hname: hname} } -func newAgentIDFromBytes(buf []byte) ScAgentID { +func agentIDFromBytes(buf []byte) ScAgentID { return ScAgentID{ address: AddressFromBytes(buf[:ScAddressLength]), hname: HnameFromBytes(buf[ScAddressLength:]), } } -func NewScAgentID(address ScAddress, hname ScHname) ScAgentID { - return ScAgentID{address: address, hname: hname} -} - func (o ScAgentID) Address() ScAddress { return o.address } func (o ScAgentID) Bytes() []byte { - enc := wasmcodec.NewWasmEncoder() + enc := NewWasmEncoder() EncodeAgentID(enc, o) return enc.Buf() } @@ -75,6 +46,39 @@ func (o ScAgentID) String() string { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ +func DecodeAgentID(dec *WasmDecoder) ScAgentID { + return agentIDFromBytes(dec.FixedBytes(ScAgentIDLength)) +} + +func EncodeAgentID(enc *WasmEncoder, value ScAgentID) { + EncodeAddress(enc, value.address) + EncodeHname(enc, value.hname) +} + +func AgentIDFromBytes(buf []byte) ScAgentID { + if buf == nil { + return ScAgentID{} + } + if len(buf) != ScAgentIDLength { + panic("invalid AgentID length") + } + // max ledgerstate.AliasAddressType + if buf[0] > 2 { + panic("invalid AgentID: address type > 2") + } + return agentIDFromBytes(buf) +} + +func BytesFromAgentID(value ScAgentID) []byte { + return value.Bytes() +} + +func AgentIDToString(value ScAgentID) string { + return value.String() +} + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + type ScImmutableAgentID struct { proxy Proxy } diff --git a/packages/vm/wasmlib/go/wasmlib/wasmtypes/bool.go b/packages/vm/wasmlib/go/wasmlib/wasmtypes/bool.go index 6c1ee8866a..401c196fab 100644 --- a/packages/vm/wasmlib/go/wasmlib/wasmtypes/bool.go +++ b/packages/vm/wasmlib/go/wasmlib/wasmtypes/bool.go @@ -3,17 +3,13 @@ package wasmtypes -import ( - "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmcodec" -) - // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -func DecodeBool(dec *wasmcodec.WasmDecoder) bool { +func DecodeBool(dec *WasmDecoder) bool { return dec.Byte() != 0 } -func EncodeBool(enc *wasmcodec.WasmEncoder, value bool) { +func EncodeBool(enc *WasmEncoder, value bool) { if value { enc.Byte(1) return @@ -26,13 +22,13 @@ func BoolFromBytes(buf []byte) bool { return false } if len(buf) != 1 { - Panic("invalid Bool length") + panic("invalid Bool length") } if buf[0] == 0x00 { return false } if buf[0] != 0xff { - Panic("invalid Bool value") + panic("invalid Bool value") } return true } @@ -44,7 +40,7 @@ func BytesFromBool(value bool) []byte { return []byte{0x00} } -func StringFromBool(value bool) string { +func BoolToString(value bool) string { if value { return "1" } @@ -66,7 +62,7 @@ func (o ScImmutableBool) Exists() bool { } func (o ScImmutableBool) String() string { - return StringFromBool(o.Value()) + return BoolToString(o.Value()) } func (o ScImmutableBool) Value() bool { diff --git a/packages/vm/wasmlib/go/wasmlib/wasmtypes/bytes.go b/packages/vm/wasmlib/go/wasmlib/wasmtypes/bytes.go index 52ebc3d43e..002cf1834c 100644 --- a/packages/vm/wasmlib/go/wasmlib/wasmtypes/bytes.go +++ b/packages/vm/wasmlib/go/wasmlib/wasmtypes/bytes.go @@ -3,17 +3,13 @@ package wasmtypes -import ( - "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmcodec" -) - // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -func DecodeBytes(dec *wasmcodec.WasmDecoder) []byte { +func DecodeBytes(dec *WasmDecoder) []byte { return dec.Bytes() } -func EncodeBytes(enc *wasmcodec.WasmEncoder, value []byte) { +func EncodeBytes(enc *WasmEncoder, value []byte) { enc.Bytes(value) } @@ -21,6 +17,10 @@ func BytesFromBytes(buf []byte) []byte { return buf } +func BytesToString(buf []byte) string { + return base58Encode(buf) +} + // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ type ScImmutableBytes struct { @@ -36,7 +36,7 @@ func (o ScImmutableBytes) Exists() bool { } func (o ScImmutableBytes) String() string { - return StringFromBytes(o.Value()) + return BytesToString(o.Value()) } func (o ScImmutableBytes) Value() []byte { diff --git a/packages/vm/wasmlib/go/wasmlib/wasmtypes/chainid.go b/packages/vm/wasmlib/go/wasmlib/wasmtypes/chainid.go index f2dda1d03e..2c5a18c0eb 100644 --- a/packages/vm/wasmlib/go/wasmlib/wasmtypes/chainid.go +++ b/packages/vm/wasmlib/go/wasmlib/wasmtypes/chainid.go @@ -3,23 +3,38 @@ package wasmtypes -import ( - "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmcodec" -) - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - const ScChainIDLength = 33 type ScChainID struct { id [ScChainIDLength]byte } -func DecodeChainID(dec *wasmcodec.WasmDecoder) ScChainID { - return newChainIDFromBytes(dec.FixedBytes(ScChainIDLength)) +func chainIDFromBytes(buf []byte) ScChainID { + o := ScChainID{} + copy(o.id[:], buf) + return o +} + +func (o ScChainID) Address() ScAddress { + return AddressFromBytes(o.id[:]) +} + +func (o ScChainID) Bytes() []byte { + return o.id[:] +} + +func (o ScChainID) String() string { + // TODO standardize human readable string + return base58Encode(o.id[:]) } -func EncodeChainID(enc *wasmcodec.WasmEncoder, value ScChainID) { +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +func DecodeChainID(dec *WasmDecoder) ScChainID { + return chainIDFromBytes(dec.FixedBytes(ScChainIDLength)) +} + +func EncodeChainID(enc *WasmEncoder, value ScChainID) { enc.FixedBytes(value.Bytes(), ScChainIDLength) } @@ -28,32 +43,21 @@ func ChainIDFromBytes(buf []byte) ScChainID { return ScChainID{id: [ScChainIDLength]byte{2}} } if len(buf) != ScChainIDLength { - Panic("invalid ChainID length") + panic("invalid ChainID length") } // must be ledgerstate.AliasAddressType if buf[0] != 2 { - Panic("invalid ChainID: not an alias address") + panic("invalid ChainID: not an alias address") } - return newChainIDFromBytes(buf) -} - -func newChainIDFromBytes(buf []byte) ScChainID { - o := ScChainID{} - copy(o.id[:], buf) - return o + return chainIDFromBytes(buf) } -func (o ScChainID) Address() ScAddress { - return AddressFromBytes(o.id[:]) +func BytesFromChainID(value ScChainID) []byte { + return value.Bytes() } -func (o ScChainID) Bytes() []byte { - return o.id[:] -} - -func (o ScChainID) String() string { - // TODO standardize human readable string - return base58Encode(o.id[:]) +func ChainIDToString(value ScChainID) string { + return value.String() } // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ diff --git a/packages/vm/wasmlib/go/wasmlib/wasmcodec/codec.go b/packages/vm/wasmlib/go/wasmlib/wasmtypes/codec.go similarity index 84% rename from packages/vm/wasmlib/go/wasmlib/wasmcodec/codec.go rename to packages/vm/wasmlib/go/wasmlib/wasmtypes/codec.go index 9ed2bf89cc..d11a5efa47 100644 --- a/packages/vm/wasmlib/go/wasmlib/wasmcodec/codec.go +++ b/packages/vm/wasmlib/go/wasmlib/wasmtypes/codec.go @@ -1,7 +1,9 @@ // Copyright 2020 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 -package wasmcodec +package wasmtypes + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ type WasmDecoder struct { buf []byte @@ -85,7 +87,7 @@ func (d *WasmDecoder) VluDecode(bits int) uint64 { // while continuation bit is set for ; (b & 0x80) != 0; s += 7 { if s >= bits { - d.abort("integer representation too long") + d.abort("unsigned representation too long") } // next group of 7 bits @@ -179,3 +181,25 @@ func (e *WasmEncoder) VluEncode(value uint64) *WasmEncoder { e.buf = append(e.buf, b) return e } + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +// wrapper for simplified use by hashtypes +func base58Encode(buf []byte) string { + // TODO + // return string(wasmlib.Sandbox(wasmstore.FnUtilsBase58Encode, buf)) + return hex(buf) +} + +func hex(buf []byte) string { + const hexa = "0123456789abcdef" + digits := len(buf) * 2 + res := make([]byte, digits) + for _, b := range buf { + digits-- + res[digits] = hexa[b&0x0f] + digits-- + res[digits] = hexa[b>>4] + } + return string(res) +} diff --git a/packages/vm/wasmlib/go/wasmlib/wasmtypes/color.go b/packages/vm/wasmlib/go/wasmlib/wasmtypes/color.go index 5b826c6c43..875d7a73bd 100644 --- a/packages/vm/wasmlib/go/wasmlib/wasmtypes/color.go +++ b/packages/vm/wasmlib/go/wasmlib/wasmtypes/color.go @@ -3,12 +3,6 @@ package wasmtypes -import ( - "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmcodec" -) - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - const ScColorLength = 32 type ScColor struct { @@ -26,11 +20,28 @@ func init() { } } -func DecodeColor(dec *wasmcodec.WasmDecoder) ScColor { +func newColorFromBytes(buf []byte) ScColor { + o := ScColor{} + copy(o.id[:], buf) + return o +} + +func (o ScColor) Bytes() []byte { + return o.id[:] +} + +func (o ScColor) String() string { + // TODO standardize human readable string + return base58Encode(o.id[:]) +} + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +func DecodeColor(dec *WasmDecoder) ScColor { return newColorFromBytes(dec.FixedBytes(ScColorLength)) } -func EncodeColor(enc *wasmcodec.WasmEncoder, value ScColor) { +func EncodeColor(enc *WasmEncoder, value ScColor) { enc.FixedBytes(value.Bytes(), ScColorLength) } @@ -39,24 +50,17 @@ func ColorFromBytes(buf []byte) ScColor { return ScColor{} } if len(buf) != ScColorLength { - Panic("invalid Color length") + panic("invalid Color length") } return newColorFromBytes(buf) } -func newColorFromBytes(buf []byte) ScColor { - o := ScColor{} - copy(o.id[:], buf) - return o -} - -func (o ScColor) Bytes() []byte { - return o.id[:] +func BytesFromColor(value ScColor) []byte { + return value.Bytes() } -func (o ScColor) String() string { - // TODO standardize human readable string - return base58Encode(o.id[:]) +func ColorToString(value ScColor) string { + return value.String() } // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ diff --git a/packages/vm/wasmlib/go/wasmlib/wasmtypes/hash.go b/packages/vm/wasmlib/go/wasmlib/wasmtypes/hash.go index 6b44f2390e..e613b75bda 100644 --- a/packages/vm/wasmlib/go/wasmlib/wasmtypes/hash.go +++ b/packages/vm/wasmlib/go/wasmlib/wasmtypes/hash.go @@ -3,23 +3,34 @@ package wasmtypes -import ( - "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmcodec" -) - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - const ScHashLength = 32 type ScHash struct { id [ScHashLength]byte } -func DecodeHash(dec *wasmcodec.WasmDecoder) ScHash { +func newHashFromBytes(buf []byte) ScHash { + o := ScHash{} + copy(o.id[:], buf) + return o +} + +func (o ScHash) Bytes() []byte { + return o.id[:] +} + +func (o ScHash) String() string { + // TODO standardize human readable string + return base58Encode(o.id[:]) +} + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +func DecodeHash(dec *WasmDecoder) ScHash { return newHashFromBytes(dec.FixedBytes(ScHashLength)) } -func EncodeHash(enc *wasmcodec.WasmEncoder, value ScHash) { +func EncodeHash(enc *WasmEncoder, value ScHash) { enc.FixedBytes(value.Bytes(), ScHashLength) } @@ -28,24 +39,17 @@ func HashFromBytes(buf []byte) ScHash { return ScHash{} } if len(buf) != ScHashLength { - Panic("invalid Hash length") + panic("invalid Hash length") } return newHashFromBytes(buf) } -func newHashFromBytes(buf []byte) ScHash { - o := ScHash{} - copy(o.id[:], buf) - return o +func BytesFromHash(value ScHash) []byte { + return value.Bytes() } -func (o ScHash) Bytes() []byte { - return o.id[:] -} - -func (o ScHash) String() string { - // TODO standardize human readable string - return base58Encode(o.id[:]) +func HashToString(value ScHash) string { + return value.String() } // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ diff --git a/packages/vm/wasmlib/go/wasmlib/wasmtypes/hname.go b/packages/vm/wasmlib/go/wasmlib/wasmtypes/hname.go index 18ba9f7433..3382278677 100644 --- a/packages/vm/wasmlib/go/wasmlib/wasmtypes/hname.go +++ b/packages/vm/wasmlib/go/wasmlib/wasmtypes/hname.go @@ -5,35 +5,13 @@ package wasmtypes import ( "encoding/binary" - - "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmcodec" ) -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - const ScHnameLength = 4 type ScHname uint32 -func DecodeHname(dec *wasmcodec.WasmDecoder) ScHname { - return newHnameFromBytes(dec.FixedBytes(ScHnameLength)) -} - -func EncodeHname(enc *wasmcodec.WasmEncoder, value ScHname) { - enc.FixedBytes(value.Bytes(), ScHnameLength) -} - -func HnameFromBytes(buf []byte) ScHname { - if buf == nil { - return 0 - } - if len(buf) != ScHnameLength { - Panic("invalid Hname length") - } - return newHnameFromBytes(buf) -} - -func newHnameFromBytes(buf []byte) ScHname { +func hnameFromBytes(buf []byte) ScHname { return ScHname(binary.LittleEndian.Uint32(buf)) } @@ -54,6 +32,34 @@ func (o ScHname) String() string { // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ +func DecodeHname(dec *WasmDecoder) ScHname { + return hnameFromBytes(dec.FixedBytes(ScHnameLength)) +} + +func EncodeHname(enc *WasmEncoder, value ScHname) { + enc.FixedBytes(value.Bytes(), ScHnameLength) +} + +func HnameFromBytes(buf []byte) ScHname { + if buf == nil { + return 0 + } + if len(buf) != ScHnameLength { + panic("invalid Hname length") + } + return hnameFromBytes(buf) +} + +func BytesFromHname(value ScHname) []byte { + return value.Bytes() +} + +func HnameToString(value ScHname) string { + return value.String() +} + +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + type ScImmutableHname struct { proxy Proxy } diff --git a/packages/vm/wasmlib/go/wasmlib/wasmtypes/int16.go b/packages/vm/wasmlib/go/wasmlib/wasmtypes/int16.go index bec0706fc9..467ab41f44 100644 --- a/packages/vm/wasmlib/go/wasmlib/wasmtypes/int16.go +++ b/packages/vm/wasmlib/go/wasmlib/wasmtypes/int16.go @@ -7,17 +7,15 @@ package wasmtypes import ( "encoding/binary" "strconv" - - "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmcodec" ) // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -func DecodeInt16(dec *wasmcodec.WasmDecoder) int16 { +func DecodeInt16(dec *WasmDecoder) int16 { return int16(dec.VliDecode(16)) } -func EncodeInt16(enc *wasmcodec.WasmEncoder, value int16) { +func EncodeInt16(enc *WasmEncoder, value int16) { enc.VliEncode(int64(value)) } @@ -26,7 +24,7 @@ func Int16FromBytes(buf []byte) int16 { return 0 } if len(buf) != 2 { - Panic("invalid Int16 length") + panic("invalid Int16 length") } return int16(binary.LittleEndian.Uint16(buf)) } @@ -37,7 +35,7 @@ func BytesFromInt16(value int16) []byte { return tmp } -func StringFromInt16(value int16) string { +func Int16ToString(value int16) string { return strconv.FormatInt(int64(value), 10) } @@ -56,7 +54,7 @@ func (o ScImmutableInt16) Exists() bool { } func (o ScImmutableInt16) String() string { - return StringFromInt16(o.Value()) + return Int16ToString(o.Value()) } func (o ScImmutableInt16) Value() int16 { diff --git a/packages/vm/wasmlib/go/wasmlib/wasmtypes/int32.go b/packages/vm/wasmlib/go/wasmlib/wasmtypes/int32.go index bc506de308..afe677af4d 100644 --- a/packages/vm/wasmlib/go/wasmlib/wasmtypes/int32.go +++ b/packages/vm/wasmlib/go/wasmlib/wasmtypes/int32.go @@ -7,17 +7,15 @@ package wasmtypes import ( "encoding/binary" "strconv" - - "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmcodec" ) // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -func DecodeInt32(dec *wasmcodec.WasmDecoder) int32 { +func DecodeInt32(dec *WasmDecoder) int32 { return int32(dec.VliDecode(32)) } -func EncodeInt32(enc *wasmcodec.WasmEncoder, value int32) { +func EncodeInt32(enc *WasmEncoder, value int32) { enc.VliEncode(int64(value)) } @@ -26,7 +24,7 @@ func Int32FromBytes(buf []byte) int32 { return 0 } if len(buf) != 4 { - Panic("invalid Int32 length") + panic("invalid Int32 length") } return int32(binary.LittleEndian.Uint32(buf)) } @@ -37,7 +35,7 @@ func BytesFromInt32(value int32) []byte { return tmp } -func StringFromInt32(value int32) string { +func Int32ToString(value int32) string { return strconv.FormatInt(int64(value), 10) } @@ -56,7 +54,7 @@ func (o ScImmutableInt32) Exists() bool { } func (o ScImmutableInt32) String() string { - return StringFromInt32(o.Value()) + return Int32ToString(o.Value()) } func (o ScImmutableInt32) Value() int32 { diff --git a/packages/vm/wasmlib/go/wasmlib/wasmtypes/int64.go b/packages/vm/wasmlib/go/wasmlib/wasmtypes/int64.go index c92c6cef8a..98d17cd9b3 100644 --- a/packages/vm/wasmlib/go/wasmlib/wasmtypes/int64.go +++ b/packages/vm/wasmlib/go/wasmlib/wasmtypes/int64.go @@ -6,17 +6,15 @@ package wasmtypes import ( "encoding/binary" "strconv" - - "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmcodec" ) // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -func DecodeInt64(dec *wasmcodec.WasmDecoder) int64 { +func DecodeInt64(dec *WasmDecoder) int64 { return dec.VliDecode(64) } -func EncodeInt64(enc *wasmcodec.WasmEncoder, value int64) { +func EncodeInt64(enc *WasmEncoder, value int64) { enc.VliEncode(value) } @@ -25,7 +23,7 @@ func Int64FromBytes(buf []byte) int64 { return 0 } if len(buf) != 8 { - Panic("invalid Int64 length") + panic("invalid Int64 length") } return int64(binary.LittleEndian.Uint64(buf)) } @@ -36,7 +34,7 @@ func BytesFromInt64(value int64) []byte { return tmp } -func StringFromInt64(value int64) string { +func Int64ToString(value int64) string { return strconv.FormatInt(value, 10) } @@ -55,7 +53,7 @@ func (o ScImmutableInt64) Exists() bool { } func (o ScImmutableInt64) String() string { - return StringFromInt64(o.Value()) + return Int64ToString(o.Value()) } func (o ScImmutableInt64) Value() int64 { diff --git a/packages/vm/wasmlib/go/wasmlib/wasmtypes/int8.go b/packages/vm/wasmlib/go/wasmlib/wasmtypes/int8.go index e1ccfea9a6..1f03df5a9b 100644 --- a/packages/vm/wasmlib/go/wasmlib/wasmtypes/int8.go +++ b/packages/vm/wasmlib/go/wasmlib/wasmtypes/int8.go @@ -5,17 +5,15 @@ package wasmtypes import ( "strconv" - - "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmcodec" ) // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -func DecodeInt8(dec *wasmcodec.WasmDecoder) int8 { +func DecodeInt8(dec *WasmDecoder) int8 { return int8(dec.Byte()) } -func EncodeInt8(enc *wasmcodec.WasmEncoder, value int8) { +func EncodeInt8(enc *WasmEncoder, value int8) { enc.Byte(byte(value)) } @@ -24,7 +22,7 @@ func Int8FromBytes(buf []byte) int8 { return 0 } if len(buf) != 1 { - Panic("invalid Int8 length") + panic("invalid Int8 length") } return int8(buf[0]) } @@ -33,7 +31,7 @@ func BytesFromInt8(value int8) []byte { return []byte{byte(value)} } -func StringFromInt8(value int8) string { +func Int8ToString(value int8) string { return strconv.FormatInt(int64(value), 10) } @@ -52,7 +50,7 @@ func (o ScImmutableInt8) Exists() bool { } func (o ScImmutableInt8) String() string { - return StringFromInt8(o.Value()) + return Int8ToString(o.Value()) } func (o ScImmutableInt8) Value() int8 { diff --git a/packages/vm/wasmlib/go/wasmlib/wasmtypes/proxy.go b/packages/vm/wasmlib/go/wasmlib/wasmtypes/proxy.go index e5555cec58..55bbac4317 100644 --- a/packages/vm/wasmlib/go/wasmlib/wasmtypes/proxy.go +++ b/packages/vm/wasmlib/go/wasmlib/wasmtypes/proxy.go @@ -3,10 +3,6 @@ package wasmtypes -import ( - "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmcodec" -) - type IKvStore interface { Delete(key []byte) Exists(key []byte) bool @@ -51,12 +47,12 @@ func (p Proxy) ClearMap() { p.Delete() } -func (p Proxy) Decoder() *wasmcodec.WasmDecoder { +func (p Proxy) Decoder() *WasmDecoder { return p.decoder(p.Get()) } -func (p Proxy) decoder(buf []byte) *wasmcodec.WasmDecoder { - return wasmcodec.NewWasmDecoder(buf) +func (p Proxy) decoder(buf []byte) *WasmDecoder { + return NewWasmDecoder(buf) } func (p Proxy) Delete() { @@ -69,8 +65,8 @@ func (p Proxy) element(index uint32) Proxy { return p.sub('#', enc.Buf()) } -func (p Proxy) Encoder() *wasmcodec.WasmEncoder { - return wasmcodec.NewWasmEncoder() +func (p Proxy) Encoder() *WasmEncoder { + return NewWasmEncoder() } func (p Proxy) Exists() bool { @@ -124,7 +120,7 @@ func (p Proxy) Set(value []byte) { // sub returns a proxy for an element of a container. // The separator is significant, it prevents potential clashes with other elements. -// Different separators can be used to indicate different subcontainers +// Different separators can be used to indicate different sub-containers func (p Proxy) sub(sep byte, key []byte) Proxy { if p.key == nil { // this must be a root proxy diff --git a/packages/vm/wasmlib/go/wasmlib/wasmtypes/requestid.go b/packages/vm/wasmlib/go/wasmlib/wasmtypes/requestid.go index 4feea99e87..cdcdb3e2e5 100644 --- a/packages/vm/wasmlib/go/wasmlib/wasmtypes/requestid.go +++ b/packages/vm/wasmlib/go/wasmlib/wasmtypes/requestid.go @@ -3,23 +3,34 @@ package wasmtypes -import ( - "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmcodec" -) - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - const ScRequestIDLength = 34 type ScRequestID struct { id [ScRequestIDLength]byte } -func DecodeRequestID(dec *wasmcodec.WasmDecoder) ScRequestID { - return newRequestIDFromBytes(dec.FixedBytes(ScRequestIDLength)) +func requestIDFromBytes(buf []byte) ScRequestID { + o := ScRequestID{} + copy(o.id[:], buf) + return o +} + +func (o ScRequestID) Bytes() []byte { + return o.id[:] +} + +func (o ScRequestID) String() string { + // TODO standardize human readable string + return base58Encode(o.id[:]) } -func EncodeRequestID(enc *wasmcodec.WasmEncoder, value ScRequestID) { +// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ + +func DecodeRequestID(dec *WasmDecoder) ScRequestID { + return requestIDFromBytes(dec.FixedBytes(ScRequestIDLength)) +} + +func EncodeRequestID(enc *WasmEncoder, value ScRequestID) { enc.FixedBytes(value.Bytes(), ScRequestIDLength) } @@ -28,28 +39,21 @@ func RequestIDFromBytes(buf []byte) ScRequestID { return ScRequestID{} } if len(buf) != ScRequestIDLength { - Panic("invalid RequestID length") + panic("invalid RequestID length") } // final uint16 output index must be > ledgerstate.MaxOutputCount if buf[ScHashLength] > 127 || buf[ScHashLength+1] != 0 { - Panic("invalid RequestID: output index > 127") + panic("invalid RequestID: output index > 127") } - return newRequestIDFromBytes(buf) -} - -func newRequestIDFromBytes(buf []byte) ScRequestID { - o := ScRequestID{} - copy(o.id[:], buf) - return o + return requestIDFromBytes(buf) } -func (o ScRequestID) Bytes() []byte { - return o.id[:] +func BytesFromRequestID(value ScRequestID) []byte { + return value.Bytes() } -func (o ScRequestID) String() string { - // TODO standardize human readable string - return base58Encode(o.id[:]) +func RequestIDToString(value ScRequestID) string { + return value.String() } // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ diff --git a/packages/vm/wasmlib/go/wasmlib/wasmtypes/string.go b/packages/vm/wasmlib/go/wasmlib/wasmtypes/string.go index 61655affe4..be17af5cd4 100644 --- a/packages/vm/wasmlib/go/wasmlib/wasmtypes/string.go +++ b/packages/vm/wasmlib/go/wasmlib/wasmtypes/string.go @@ -3,17 +3,13 @@ package wasmtypes -import ( - "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmcodec" -) - // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -func DecodeString(dec *wasmcodec.WasmDecoder) string { +func DecodeString(dec *WasmDecoder) string { return string(dec.Bytes()) } -func EncodeString(enc *wasmcodec.WasmEncoder, value string) { +func EncodeString(enc *WasmEncoder, value string) { enc.Bytes([]byte(value)) } @@ -25,7 +21,7 @@ func BytesFromString(value string) []byte { return []byte(value) } -func StringFromString(value string) string { +func StringToString(value string) string { return value } @@ -44,7 +40,7 @@ func (o ScImmutableString) Exists() bool { } func (o ScImmutableString) String() string { - return StringFromString(o.Value()) + return StringToString(o.Value()) } func (o ScImmutableString) Value() string { diff --git a/packages/vm/wasmlib/go/wasmlib/wasmtypes/uint16.go b/packages/vm/wasmlib/go/wasmlib/wasmtypes/uint16.go index 3d7f44242d..88c42b0e61 100644 --- a/packages/vm/wasmlib/go/wasmlib/wasmtypes/uint16.go +++ b/packages/vm/wasmlib/go/wasmlib/wasmtypes/uint16.go @@ -5,19 +5,17 @@ package wasmtypes import ( "strconv" - - "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmcodec" ) // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ const ScUint16Length = 2 -func DecodeUint16(dec *wasmcodec.WasmDecoder) uint16 { +func DecodeUint16(dec *WasmDecoder) uint16 { return uint16(dec.VluDecode(16)) } -func EncodeUint16(enc *wasmcodec.WasmEncoder, value uint16) { +func EncodeUint16(enc *WasmEncoder, value uint16) { enc.VluEncode(uint64(value)) } @@ -26,7 +24,7 @@ func Uint16FromBytes(buf []byte) uint16 { return 0 } if len(buf) != ScUint16Length { - Panic("invalid Uint16 length") + panic("invalid Uint16 length") } return uint16(buf[0]) | uint16(buf[1])<<8 } @@ -35,7 +33,7 @@ func BytesFromUint16(value uint16) []byte { return []byte{byte(value), byte(value >> 8)} } -func StringFromUint16(value uint16) string { +func Uint16ToString(value uint16) string { return strconv.FormatUint(uint64(value), 10) } @@ -54,7 +52,7 @@ func (o ScImmutableUint16) Exists() bool { } func (o ScImmutableUint16) String() string { - return StringFromUint16(o.Value()) + return Uint16ToString(o.Value()) } func (o ScImmutableUint16) Value() uint16 { diff --git a/packages/vm/wasmlib/go/wasmlib/wasmtypes/uint32.go b/packages/vm/wasmlib/go/wasmlib/wasmtypes/uint32.go index a1ed8d3070..d71d4c20a6 100644 --- a/packages/vm/wasmlib/go/wasmlib/wasmtypes/uint32.go +++ b/packages/vm/wasmlib/go/wasmlib/wasmtypes/uint32.go @@ -6,19 +6,17 @@ package wasmtypes import ( "encoding/binary" "strconv" - - "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmcodec" ) // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ const ScUint32Length = 4 -func DecodeUint32(dec *wasmcodec.WasmDecoder) uint32 { +func DecodeUint32(dec *WasmDecoder) uint32 { return uint32(dec.VluDecode(32)) } -func EncodeUint32(enc *wasmcodec.WasmEncoder, value uint32) { +func EncodeUint32(enc *WasmEncoder, value uint32) { enc.VluEncode(uint64(value)) } @@ -27,7 +25,7 @@ func Uint32FromBytes(buf []byte) uint32 { return 0 } if len(buf) != ScUint32Length { - Panic("invalid Uint32 length") + panic("invalid Uint32 length") } return binary.LittleEndian.Uint32(buf) } @@ -38,7 +36,7 @@ func BytesFromUint32(value uint32) []byte { return tmp } -func StringFromUint32(value uint32) string { +func Uint32ToString(value uint32) string { return strconv.FormatUint(uint64(value), 10) } @@ -57,7 +55,7 @@ func (o ScImmutableUint32) Exists() bool { } func (o ScImmutableUint32) String() string { - return StringFromUint32(o.Value()) + return Uint32ToString(o.Value()) } func (o ScImmutableUint32) Value() uint32 { diff --git a/packages/vm/wasmlib/go/wasmlib/wasmtypes/uint64.go b/packages/vm/wasmlib/go/wasmlib/wasmtypes/uint64.go index a5df22c60a..97956b491c 100644 --- a/packages/vm/wasmlib/go/wasmlib/wasmtypes/uint64.go +++ b/packages/vm/wasmlib/go/wasmlib/wasmtypes/uint64.go @@ -6,19 +6,17 @@ package wasmtypes import ( "encoding/binary" "strconv" - - "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmcodec" ) // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ const ScUint64Length = 8 -func DecodeUint64(dec *wasmcodec.WasmDecoder) uint64 { +func DecodeUint64(dec *WasmDecoder) uint64 { return dec.VluDecode(64) } -func EncodeUint64(enc *wasmcodec.WasmEncoder, value uint64) { +func EncodeUint64(enc *WasmEncoder, value uint64) { enc.VluEncode(value) } @@ -27,7 +25,7 @@ func Uint64FromBytes(buf []byte) uint64 { return 0 } if len(buf) != ScUint64Length { - Panic("invalid Uint64 length") + panic("invalid Uint64 length") } return binary.LittleEndian.Uint64(buf) } @@ -38,7 +36,7 @@ func BytesFromUint64(value uint64) []byte { return tmp } -func StringFromUint64(value uint64) string { +func Uint64ToString(value uint64) string { return strconv.FormatUint(value, 10) } @@ -57,7 +55,7 @@ func (o ScImmutableUint64) Exists() bool { } func (o ScImmutableUint64) String() string { - return StringFromUint64(o.Value()) + return Uint64ToString(o.Value()) } func (o ScImmutableUint64) Value() uint64 { diff --git a/packages/vm/wasmlib/go/wasmlib/wasmtypes/uint8.go b/packages/vm/wasmlib/go/wasmlib/wasmtypes/uint8.go index 1320cd4127..26ce34f394 100644 --- a/packages/vm/wasmlib/go/wasmlib/wasmtypes/uint8.go +++ b/packages/vm/wasmlib/go/wasmlib/wasmtypes/uint8.go @@ -5,19 +5,17 @@ package wasmtypes import ( "strconv" - - "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmcodec" ) // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ const ScUint8Length = 1 -func DecodeUint8(dec *wasmcodec.WasmDecoder) uint8 { +func DecodeUint8(dec *WasmDecoder) uint8 { return dec.Byte() } -func EncodeUint8(enc *wasmcodec.WasmEncoder, value uint8) { +func EncodeUint8(enc *WasmEncoder, value uint8) { enc.Byte(value) } @@ -26,7 +24,7 @@ func Uint8FromBytes(buf []byte) uint8 { return 0 } if len(buf) != ScUint8Length { - Panic("invalid Uint8 length") + panic("invalid Uint8 length") } return buf[0] } @@ -35,7 +33,7 @@ func BytesFromUint8(value uint8) []byte { return []byte{value} } -func StringFromUint8(value uint8) string { +func Uint8ToString(value uint8) string { return strconv.FormatUint(uint64(value), 10) } @@ -54,7 +52,7 @@ func (o ScImmutableUint8) Exists() bool { } func (o ScImmutableUint8) String() string { - return StringFromUint8(o.Value()) + return Uint8ToString(o.Value()) } func (o ScImmutableUint8) Value() uint8 { diff --git a/packages/vm/wasmlib/go/wasmlib/wasmtypes/utils.go b/packages/vm/wasmlib/go/wasmlib/wasmtypes/utils.go deleted file mode 100644 index 6de694531f..0000000000 --- a/packages/vm/wasmlib/go/wasmlib/wasmtypes/utils.go +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2020 IOTA Stiftung -// SPDX-License-Identifier: Apache-2.0 - -package wasmtypes - -// wrapper for simplified use by hashtypes -func base58Encode(buf []byte) string { - // TODO - // return string(wasmlib.Sandbox(wasmstore.FnUtilsBase58Encode, buf)) - return hex(buf) -} - -func hex(buf []byte) string { - const hexa = "0123456789abcdef" - digits := len(buf) * 2 - res := make([]byte, digits) - for _, b := range buf { - digits-- - res[digits] = hexa[b&0x0f] - digits-- - res[digits] = hexa[b>>4] - } - return string(res) -} - -func Panic(msg string) { - panic(msg) -} diff --git a/packages/vm/wasmsolo/solosandboxutils.go b/packages/vm/wasmsolo/solosandboxutils.go index 3d0492d7a0..aabdcbcec2 100644 --- a/packages/vm/wasmsolo/solosandboxutils.go +++ b/packages/vm/wasmsolo/solosandboxutils.go @@ -5,7 +5,6 @@ package wasmsolo import ( "github.com/iotaledger/wasp/packages/kv/codec" - "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmcodec" "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" ) @@ -26,7 +25,7 @@ func (s *SoloSandbox) fnUtilsBlsAddress(args []byte) []byte { } func (s *SoloSandbox) fnUtilsBlsAggregate(args []byte) []byte { - dec := wasmcodec.NewWasmDecoder(args) + dec := wasmtypes.NewWasmDecoder(args) count := int(wasmtypes.DecodeUint32(dec)) pubKeysBin := make([][]byte, count) for i := 0; i < count; i++ { @@ -39,11 +38,11 @@ func (s *SoloSandbox) fnUtilsBlsAggregate(args []byte) []byte { } pubKeyBin, sigBin, err := s.utils.BLS().AggregateBLSSignatures(pubKeysBin, sigsBin) s.checkErr(err) - return wasmcodec.NewWasmEncoder().Bytes(pubKeyBin).Bytes(sigBin).Buf() + return wasmtypes.NewWasmEncoder().Bytes(pubKeyBin).Bytes(sigBin).Buf() } func (s *SoloSandbox) fnUtilsBlsValid(args []byte) []byte { - dec := wasmcodec.NewWasmDecoder(args) + dec := wasmtypes.NewWasmDecoder(args) data := dec.Bytes() pubKey := dec.Bytes() signature := dec.Bytes() @@ -58,7 +57,7 @@ func (s *SoloSandbox) fnUtilsEd25519Address(args []byte) []byte { } func (s *SoloSandbox) fnUtilsEd25519Valid(args []byte) []byte { - dec := wasmcodec.NewWasmDecoder(args) + dec := wasmtypes.NewWasmDecoder(args) data := dec.Bytes() pubKey := dec.Bytes() signature := dec.Bytes() diff --git a/tools/schema/generator/gotemplates/alltemplates.go b/tools/schema/generator/gotemplates/alltemplates.go index e7ad765ca8..f096867187 100644 --- a/tools/schema/generator/gotemplates/alltemplates.go +++ b/tools/schema/generator/gotemplates/alltemplates.go @@ -48,37 +48,12 @@ var TypeDependent = model.StringMapMap{ "Uint32": "uint32", "Uint64": "uint64", }, - "fldToBytes": { - "Address": "key.Bytes()", - "AgentID": "key.Bytes()", - "Bool": "wasmtypes.BytesFromBool(key)", - "Bytes": "wasmtypes.BytesFromBytes(key)", - "ChainID": "key.Bytes()", - "Color": "key.Bytes()", - "Hash": "key.Bytes()", - "Hname": "key.Bytes()", - "Int8": "wasmtypes.BytesFromInt8(key)", - "Int16": "wasmtypes.BytesFromInt16(key)", - "Int32": "wasmtypes.BytesFromInt32(key)", - "Int64": "wasmtypes.BytesFromInt64(key)", - "RequestID": "key.Bytes()", - "String": "wasmtypes.BytesFromString(key)", - "Uint8": "wasmtypes.BytesFromUint8(key)", - "Uint16": "wasmtypes.BytesFromUint16(key)", - "Uint32": "wasmtypes.BytesFromUint32(key)", - "Uint64": "wasmtypes.BytesFromUint64(key)", - "": "key.Bytes()", - }, } var common = map[string]string{ // ******************************* "goPackage": ` package $package -`, - // ******************************* - "importWasmCodec": ` -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmcodec" `, // ******************************* "importWasmLib": ` diff --git a/tools/schema/generator/gotemplates/events.go b/tools/schema/generator/gotemplates/events.go index 64aade2a71..fc92002364 100644 --- a/tools/schema/generator/gotemplates/events.go +++ b/tools/schema/generator/gotemplates/events.go @@ -19,9 +19,9 @@ $#set separator $#each event eventParam func (e $TypeName) $EvtName($params) { - wasmlib.NewEventEncoder("$package.$evtName"). + evt := wasmlib.NewEventEncoder("$package.$evtName") $#each event eventEmit - Emit() + evt.Emit() } `, // ******************************* @@ -31,6 +31,6 @@ $#set separator , `, // ******************************* "eventEmit": ` - $FldType($fldName). + evt.Encode(wasmtypes.$FldType$+ToString($fldName)) `, } diff --git a/tools/schema/generator/gotemplates/structs.go b/tools/schema/generator/gotemplates/structs.go index 03568b5abd..6718afa4d6 100644 --- a/tools/schema/generator/gotemplates/structs.go +++ b/tools/schema/generator/gotemplates/structs.go @@ -5,7 +5,6 @@ var structsGo = map[string]string{ "structs.go": ` $#emit goPackage -$#emit importWasmCodec $#emit importWasmTypes $#each structs structType `, @@ -17,7 +16,7 @@ $#each struct structField } func New$StrName$+FromBytes(buf []byte) *$StrName { - dec := wasmcodec.NewWasmDecoder(buf) + dec := wasmtypes.NewWasmDecoder(buf) data := &$StrName$+{} $#each struct structDecode dec.Close() @@ -25,7 +24,7 @@ $#each struct structDecode } func (o *$StrName) Bytes() []byte { - enc := wasmcodec.NewWasmEncoder() + enc := wasmtypes.NewWasmEncoder() $#each struct structEncode return enc.Buf() } diff --git a/tools/schema/generator/gotemplates/typedefs.go b/tools/schema/generator/gotemplates/typedefs.go index 1d976dafe2..ad0f48f043 100644 --- a/tools/schema/generator/gotemplates/typedefs.go +++ b/tools/schema/generator/gotemplates/typedefs.go @@ -107,14 +107,14 @@ func (m $proxy) Clear() { "typedefProxyMapNewBaseType": ` func (m $proxy) Get$FldType(key $fldKeyLangType) wasmtypes.Sc$mut$FldType { - return wasmtypes.NewSc$mut$FldType(m.proxy.Key($fldKeyToBytes)) + return wasmtypes.NewSc$mut$FldType(m.proxy.Key(wasmtypes.BytesFrom$fldMapKey(key))) } `, // ******************************* "typedefProxyMapNewOtherType": ` func (m $proxy) Get$FldType(key $fldKeyLangType) $mut$FldType { - return $mut$FldType{proxy: m.proxy.Key($fldKeyToBytes)} + return $mut$FldType{proxy: m.proxy.Key(wasmtypes.BytesFrom$fldMapKey(key))} } `, } From b916cab4fa02116e18bed64b1f2dcc374c6aed98 Mon Sep 17 00:00:00 2001 From: Eric Hop Date: Wed, 26 Jan 2022 12:43:43 -0800 Subject: [PATCH 048/111] Yay! Even more cleanup! --- packages/vm/wasmlib/go/wasmlib/context.go | 7 -- packages/vm/wasmlib/go/wasmlib/events.go | 80 ----------------------- 2 files changed, 87 deletions(-) diff --git a/packages/vm/wasmlib/go/wasmlib/context.go b/packages/vm/wasmlib/go/wasmlib/context.go index c1386a7adf..7a0301d7f9 100644 --- a/packages/vm/wasmlib/go/wasmlib/context.go +++ b/packages/vm/wasmlib/go/wasmlib/context.go @@ -11,13 +11,6 @@ import ( // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ -// wrapper for simplified use by hashtypes -func base58Encode(bytes []byte) string { - return ScSandboxUtils{}.Base58Encode(bytes) -} - -// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ - // smart contract func sandbox interface type ScFuncContext struct { ScSandboxFunc diff --git a/packages/vm/wasmlib/go/wasmlib/events.go b/packages/vm/wasmlib/go/wasmlib/events.go index 1717f3a550..38ad2db8e0 100644 --- a/packages/vm/wasmlib/go/wasmlib/events.go +++ b/packages/vm/wasmlib/go/wasmlib/events.go @@ -4,12 +4,9 @@ package wasmlib import ( - "strconv" - "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" ) -// encodes separate entities into a byte buffer type EventEncoder struct { event string } @@ -22,33 +19,6 @@ func NewEventEncoder(eventName string) *EventEncoder { return e } -func (e *EventEncoder) Address(value wasmtypes.ScAddress) *EventEncoder { - return e.String(value.String()) -} - -func (e *EventEncoder) AgentID(value wasmtypes.ScAgentID) *EventEncoder { - return e.String(value.String()) -} - -func (e *EventEncoder) Bool(value bool) *EventEncoder { - if value { - return e.Uint8(1) - } - return e.Uint8(0) -} - -func (e *EventEncoder) Bytes(value []byte) *EventEncoder { - return e.String(base58Encode(value)) -} - -func (e *EventEncoder) ChainID(value wasmtypes.ScChainID) *EventEncoder { - return e.String(value.String()) -} - -func (e *EventEncoder) Color(value wasmtypes.ScColor) *EventEncoder { - return e.String(value.String()) -} - func (e *EventEncoder) Emit() { ScSandboxFunc{}.Event(e.event) } @@ -57,53 +27,3 @@ func (e *EventEncoder) Encode(value string) { // TODO encode potential vertical bars that are present in the value string e.event += "|" + value } - -func (e *EventEncoder) Hash(value wasmtypes.ScHash) *EventEncoder { - return e.String(value.String()) -} - -func (e *EventEncoder) Hname(value wasmtypes.ScHname) *EventEncoder { - return e.String(value.String()) -} - -func (e *EventEncoder) Int8(value int8) *EventEncoder { - return e.Int64(int64(value)) -} - -func (e *EventEncoder) Int16(value int16) *EventEncoder { - return e.Int64(int64(value)) -} - -func (e *EventEncoder) Int32(value int32) *EventEncoder { - return e.Int64(int64(value)) -} - -func (e *EventEncoder) Int64(value int64) *EventEncoder { - return e.String(strconv.FormatInt(value, 10)) -} - -func (e *EventEncoder) RequestID(value wasmtypes.ScRequestID) *EventEncoder { - return e.String(value.String()) -} - -func (e *EventEncoder) String(value string) *EventEncoder { - // TODO encode potential vertical bars that are present in the value string - e.event += "|" + value - return e -} - -func (e *EventEncoder) Uint8(value uint8) *EventEncoder { - return e.Uint64(uint64(value)) -} - -func (e *EventEncoder) Uint16(value uint16) *EventEncoder { - return e.Uint64(uint64(value)) -} - -func (e *EventEncoder) Uint32(value uint32) *EventEncoder { - return e.Uint64(uint64(value)) -} - -func (e *EventEncoder) Uint64(value uint64) *EventEncoder { - return e.String(strconv.FormatUint(value, 10)) -} From 4d74809de480732306b1c25492d60ab39b56c2e9 Mon Sep 17 00:00:00 2001 From: Eric Hop Date: Wed, 26 Jan 2022 13:38:44 -0800 Subject: [PATCH 049/111] Reorganize wasm VM folders into packages/wasmvm --- contracts/wasm/dividend/Cargo.toml | 2 +- contracts/wasm/dividend/go/dividend/consts.go | 2 +- .../wasm/dividend/go/dividend/contract.go | 2 +- .../wasm/dividend/go/dividend/dividend.go | 4 +- contracts/wasm/dividend/go/dividend/lib.go | 2 +- contracts/wasm/dividend/go/dividend/params.go | 2 +- .../wasm/dividend/go/dividend/results.go | 2 +- contracts/wasm/dividend/go/dividend/state.go | 2 +- contracts/wasm/dividend/test/dividend_test.go | 24 ++-- contracts/wasm/donatewithfeedback/Cargo.toml | 2 +- .../go/donatewithfeedback/consts.go | 2 +- .../go/donatewithfeedback/contract.go | 2 +- .../donatewithfeedback/donatewithfeedback.go | 4 +- .../go/donatewithfeedback/lib.go | 2 +- .../go/donatewithfeedback/params.go | 2 +- .../go/donatewithfeedback/results.go | 2 +- .../go/donatewithfeedback/state.go | 2 +- .../go/donatewithfeedback/structs.go | 2 +- .../test/donatewithfeedback_test.go | 2 +- contracts/wasm/erc20/Cargo.toml | 2 +- contracts/wasm/erc20/go/erc20/consts.go | 2 +- contracts/wasm/erc20/go/erc20/contract.go | 2 +- contracts/wasm/erc20/go/erc20/erc20.go | 2 +- contracts/wasm/erc20/go/erc20/events.go | 4 +- contracts/wasm/erc20/go/erc20/lib.go | 2 +- contracts/wasm/erc20/go/erc20/params.go | 2 +- contracts/wasm/erc20/go/erc20/results.go | 2 +- contracts/wasm/erc20/go/erc20/state.go | 2 +- contracts/wasm/erc20/go/erc20/typedefs.go | 2 +- contracts/wasm/erc20/test/erc20_test.go | 22 +-- contracts/wasm/erc20/test/init_test.go | 2 +- contracts/wasm/erc721/Cargo.toml | 2 +- contracts/wasm/erc721/go/erc721/consts.go | 2 +- contracts/wasm/erc721/go/erc721/contract.go | 2 +- contracts/wasm/erc721/go/erc721/erc721.go | 4 +- contracts/wasm/erc721/go/erc721/events.go | 4 +- contracts/wasm/erc721/go/erc721/lib.go | 2 +- contracts/wasm/erc721/go/erc721/params.go | 2 +- contracts/wasm/erc721/go/erc721/results.go | 2 +- contracts/wasm/erc721/go/erc721/state.go | 2 +- contracts/wasm/erc721/go/erc721/typedefs.go | 2 +- .../wasm/erc721/go/erc721client/events.go | 34 ++--- .../wasm/erc721/go/erc721client/service.go | 126 +++++++++--------- contracts/wasm/erc721/test/erc721_test.go | 22 +-- contracts/wasm/fairauction/Cargo.toml | 2 +- .../wasm/fairauction/go/fairauction/consts.go | 2 +- .../fairauction/go/fairauction/contract.go | 2 +- .../fairauction/go/fairauction/fairauction.go | 4 +- .../wasm/fairauction/go/fairauction/lib.go | 2 +- .../wasm/fairauction/go/fairauction/params.go | 2 +- .../fairauction/go/fairauction/results.go | 2 +- .../wasm/fairauction/go/fairauction/state.go | 2 +- .../fairauction/go/fairauction/structs.go | 2 +- .../fairauction/go/fairauction/typedefs.go | 2 +- .../wasm/fairauction/test/fairauction_test.go | 12 +- contracts/wasm/fairroulette/Cargo.toml | 2 +- .../fairroulette/go/fairroulette/consts.go | 2 +- .../fairroulette/go/fairroulette/contract.go | 2 +- .../fairroulette/go/fairroulette/events.go | 4 +- .../go/fairroulette/fairroulette.go | 4 +- .../wasm/fairroulette/go/fairroulette/lib.go | 2 +- .../fairroulette/go/fairroulette/params.go | 2 +- .../fairroulette/go/fairroulette/results.go | 2 +- .../fairroulette/go/fairroulette/state.go | 2 +- .../fairroulette/go/fairroulette/structs.go | 2 +- .../fairroulette/test/fairroulette_test.go | 8 +- contracts/wasm/helloworld/Cargo.toml | 2 +- .../wasm/helloworld/go/helloworld/consts.go | 2 +- .../wasm/helloworld/go/helloworld/contract.go | 2 +- .../helloworld/go/helloworld/helloworld.go | 2 +- .../wasm/helloworld/go/helloworld/lib.go | 2 +- .../wasm/helloworld/go/helloworld/results.go | 2 +- .../wasm/helloworld/go/helloworld/state.go | 2 +- .../wasm/helloworld/test/helloworld_test.go | 2 +- contracts/wasm/inccounter/Cargo.toml | 2 +- .../wasm/inccounter/go/inccounter/consts.go | 2 +- .../wasm/inccounter/go/inccounter/contract.go | 2 +- .../inccounter/go/inccounter/inccounter.go | 4 +- .../wasm/inccounter/go/inccounter/lib.go | 2 +- .../wasm/inccounter/go/inccounter/params.go | 2 +- .../wasm/inccounter/go/inccounter/results.go | 2 +- .../wasm/inccounter/go/inccounter/state.go | 2 +- .../wasm/inccounter/test/inccounter_test.go | 2 +- contracts/wasm/testcore/Cargo.toml | 2 +- contracts/wasm/testcore/go/testcore/consts.go | 2 +- .../wasm/testcore/go/testcore/contract.go | 2 +- contracts/wasm/testcore/go/testcore/lib.go | 2 +- contracts/wasm/testcore/go/testcore/params.go | 2 +- .../wasm/testcore/go/testcore/results.go | 2 +- contracts/wasm/testcore/go/testcore/state.go | 2 +- .../wasm/testcore/go/testcore/testcore.go | 8 +- contracts/wasm/testcore/test/2chains_test.go | 8 +- .../wasm/testcore/test/concurrency_test.go | 14 +- .../wasm/testcore/test/init_fail_test.go | 2 +- .../wasm/testcore/test/sandbox_panic_test.go | 2 +- contracts/wasm/testcore/test/testcore_test.go | 62 ++++----- contracts/wasm/testwasmlib/Cargo.toml | 2 +- .../wasm/testwasmlib/go/testwasmlib/consts.go | 2 +- .../testwasmlib/go/testwasmlib/contract.go | 2 +- .../wasm/testwasmlib/go/testwasmlib/events.go | 4 +- .../wasm/testwasmlib/go/testwasmlib/lib.go | 2 +- .../wasm/testwasmlib/go/testwasmlib/params.go | 2 +- .../testwasmlib/go/testwasmlib/results.go | 2 +- .../wasm/testwasmlib/go/testwasmlib/state.go | 2 +- .../testwasmlib/go/testwasmlib/structs.go | 2 +- .../testwasmlib/go/testwasmlib/testwasmlib.go | 6 +- .../testwasmlib/go/testwasmlib/typedefs.go | 2 +- .../go/testwasmlibclient/events.go | 8 +- .../go/testwasmlibclient/service.go | 108 +++++++-------- .../test/testwasmlib_client_test.go | 22 +-- .../wasm/testwasmlib/test/testwasmlib_test.go | 4 +- contracts/wasm/timestamp/Cargo.toml | 2 +- .../wasm/timestamp/go/timestamp/consts.go | 2 +- .../wasm/timestamp/go/timestamp/contract.go | 2 +- contracts/wasm/timestamp/go/timestamp/lib.go | 2 +- .../wasm/timestamp/go/timestamp/results.go | 2 +- .../wasm/timestamp/go/timestamp/state.go | 2 +- .../wasm/timestamp/go/timestamp/timestamp.go | 2 +- .../wasm/timestamp/test/timestamp_test.go | 2 +- contracts/wasm/tokenregistry/Cargo.toml | 2 +- .../tokenregistry/go/tokenregistry/consts.go | 2 +- .../go/tokenregistry/contract.go | 2 +- .../tokenregistry/go/tokenregistry/lib.go | 2 +- .../tokenregistry/go/tokenregistry/params.go | 2 +- .../tokenregistry/go/tokenregistry/state.go | 2 +- .../tokenregistry/go/tokenregistry/structs.go | 2 +- .../go/tokenregistry/tokenregistry.go | 2 +- .../tokenregistry/test/tokenregistry_test.go | 2 +- documentation/docs/guide/schema/events.mdx | 2 +- documentation/docs/guide/schema/funcdesc.mdx | 2 +- documentation/docs/guide/schema/init.mdx | 2 +- documentation/docs/guide/schema/structs.mdx | 4 +- documentation/docs/guide/schema/typedefs.mdx | 4 +- documentation/docs/guide/schema/usage.mdx | 2 +- documentation/tutorial-examples/Cargo.toml | 2 +- .../{vm => wasmvm}/wasmhost/wasmcontext.go | 2 +- .../{vm => wasmvm}/wasmhost/wasmedgevm.go | 0 packages/{vm => wasmvm}/wasmhost/wasmervm.go | 0 packages/{vm => wasmvm}/wasmhost/wasmgovm.go | 2 +- packages/{vm => wasmvm}/wasmhost/wasmhost.go | 2 +- .../{vm => wasmvm}/wasmhost/wasmprocessor.go | 0 .../{vm => wasmvm}/wasmhost/wasmtimevm.go | 0 .../{vm => wasmvm}/wasmhost/wasmtosandbox.go | 2 +- .../wasmhost/wasmtosandboxutils.go | 2 +- packages/{vm => wasmvm}/wasmhost/wasmvm.go | 2 +- packages/{vm => wasmvm}/wasmlib/Cargo.toml | 0 packages/{vm => wasmvm}/wasmlib/LICENSE | 0 packages/{vm => wasmvm}/wasmlib/README.md | 0 .../wasmlib/go/wasmclient/arguments.go | 0 .../wasmlib/go/wasmclient/clientfunc.go | 0 .../wasmlib/go/wasmclient/clientview.go | 0 .../go/wasmclient/coreaccounts/service.go | 64 ++++----- .../wasmlib/go/wasmclient/coreblob/service.go | 38 +++--- .../go/wasmclient/coreblocklog/service.go | 78 +++++------ .../go/wasmclient/coregovernance/service.go | 96 ++++++------- .../wasmlib/go/wasmclient/coreroot/service.go | 48 +++---- .../wasmlib/go/wasmclient/decoder.go | 0 .../wasmlib/go/wasmclient/encoder.go | 0 .../wasmlib/go/wasmclient/event.go | 0 .../wasmlib/go/wasmclient/request.go | 0 .../wasmlib/go/wasmclient/results.go | 0 .../wasmlib/go/wasmclient/seed.go | 0 .../wasmlib/go/wasmclient/service.go | 0 .../wasmlib/go/wasmclient/serviceclient.go | 0 .../wasmlib/go/wasmclient/transfer.go | 0 .../wasmlib/go/wasmclient/types.go | 0 .../go/wasmclient/wasmrequests/service.go | 0 .../wasmlib/go/wasmlib/assets.go | 2 +- .../wasmlib/go/wasmlib/context.go | 2 +- .../wasmlib/go/wasmlib/contract.go | 4 +- .../wasmlib/go/wasmlib/coreaccounts/consts.go | 2 +- .../go/wasmlib/coreaccounts/contract.go | 2 +- .../wasmlib/go/wasmlib/coreaccounts/params.go | 2 +- .../go/wasmlib/coreaccounts/results.go | 2 +- .../wasmlib/go/wasmlib/coreblob/consts.go | 2 +- .../wasmlib/go/wasmlib/coreblob/contract.go | 2 +- .../wasmlib/go/wasmlib/coreblob/params.go | 2 +- .../wasmlib/go/wasmlib/coreblob/results.go | 2 +- .../wasmlib/go/wasmlib/coreblocklog/consts.go | 2 +- .../go/wasmlib/coreblocklog/contract.go | 2 +- .../wasmlib/go/wasmlib/coreblocklog/params.go | 2 +- .../go/wasmlib/coreblocklog/results.go | 2 +- .../go/wasmlib/coregovernance/consts.go | 2 +- .../go/wasmlib/coregovernance/contract.go | 2 +- .../go/wasmlib/coregovernance/params.go | 2 +- .../go/wasmlib/coregovernance/results.go | 2 +- .../wasmlib/go/wasmlib/coreroot/consts.go | 2 +- .../wasmlib/go/wasmlib/coreroot/contract.go | 2 +- .../wasmlib/go/wasmlib/coreroot/params.go | 2 +- .../wasmlib/go/wasmlib/coreroot/results.go | 2 +- .../{vm => wasmvm}/wasmlib/go/wasmlib/dict.go | 2 +- .../wasmlib/go/wasmlib/events.go | 2 +- .../wasmlib/go/wasmlib/exports.go | 0 .../{vm => wasmvm}/wasmlib/go/wasmlib/host.go | 0 .../wasmlib/go/wasmlib/inithost.go | 0 .../wasmlib/go/wasmlib/sandbox.go | 4 +- .../wasmlib/go/wasmlib/sandboxutils.go | 2 +- .../wasmlib/go/wasmlib/state.go | 2 +- .../wasmlib/go/wasmlib/wasmrequests/consts.go | 2 +- .../go/wasmlib/wasmrequests/contract.go | 0 .../go/wasmlib/wasmrequests/structs.go | 2 +- .../wasmlib/go/wasmlib/wasmtypes/address.go | 0 .../wasmlib/go/wasmlib/wasmtypes/agentid.go | 0 .../wasmlib/go/wasmlib/wasmtypes/bool.go | 0 .../wasmlib/go/wasmlib/wasmtypes/bytes.go | 0 .../wasmlib/go/wasmlib/wasmtypes/chainid.go | 0 .../wasmlib/go/wasmlib/wasmtypes/codec.go | 0 .../wasmlib/go/wasmlib/wasmtypes/color.go | 0 .../wasmlib/go/wasmlib/wasmtypes/hash.go | 0 .../wasmlib/go/wasmlib/wasmtypes/hname.go | 0 .../wasmlib/go/wasmlib/wasmtypes/int16.go | 0 .../wasmlib/go/wasmlib/wasmtypes/int32.go | 0 .../wasmlib/go/wasmlib/wasmtypes/int64.go | 0 .../wasmlib/go/wasmlib/wasmtypes/int8.go | 0 .../wasmlib/go/wasmlib/wasmtypes/proxy.go | 0 .../wasmlib/go/wasmlib/wasmtypes/requestid.go | 0 .../wasmlib/go/wasmlib/wasmtypes/string.go | 0 .../wasmlib/go/wasmlib/wasmtypes/uint16.go | 0 .../wasmlib/go/wasmlib/wasmtypes/uint32.go | 0 .../wasmlib/go/wasmlib/wasmtypes/uint64.go | 0 .../wasmlib/go/wasmlib/wasmtypes/uint8.go | 0 .../wasmlib/interfaces/coreaccounts.yaml | 0 .../wasmlib/interfaces/coreblob.yaml | 0 .../wasmlib/interfaces/coreblocklog.yaml | 0 .../wasmlib/interfaces/coregovernance.yaml | 0 .../wasmlib/interfaces/coreroot.yaml | 0 .../wasmlib/interfaces/wasmrequests.yaml | 0 packages/{vm => wasmvm}/wasmlib/src/bytes.rs | 0 .../{vm => wasmvm}/wasmlib/src/context.rs | 0 .../{vm => wasmvm}/wasmlib/src/contract.rs | 0 .../wasmlib/src/coreaccounts/consts.rs | 0 .../wasmlib/src/coreaccounts/contract.rs | 0 .../wasmlib/src/coreaccounts/mod.rs | 0 .../wasmlib/src/coreaccounts/params.rs | 0 .../wasmlib/src/coreaccounts/results.rs | 0 .../wasmlib/src/coreblob/consts.rs | 0 .../wasmlib/src/coreblob/contract.rs | 0 .../wasmlib/src/coreblob/mod.rs | 0 .../wasmlib/src/coreblob/params.rs | 0 .../wasmlib/src/coreblob/results.rs | 0 .../wasmlib/src/coreblocklog/consts.rs | 0 .../wasmlib/src/coreblocklog/contract.rs | 0 .../wasmlib/src/coreblocklog/mod.rs | 0 .../wasmlib/src/coreblocklog/params.rs | 0 .../wasmlib/src/coreblocklog/results.rs | 0 .../wasmlib/src/coregovernance/consts.rs | 0 .../wasmlib/src/coregovernance/contract.rs | 0 .../wasmlib/src/coregovernance/mod.rs | 0 .../wasmlib/src/coregovernance/params.rs | 0 .../wasmlib/src/coregovernance/results.rs | 0 .../wasmlib/src/coreroot/consts.rs | 0 .../wasmlib/src/coreroot/contract.rs | 0 .../wasmlib/src/coreroot/mod.rs | 0 .../wasmlib/src/coreroot/params.rs | 0 .../wasmlib/src/coreroot/results.rs | 0 packages/{vm => wasmvm}/wasmlib/src/events.rs | 0 .../{vm => wasmvm}/wasmlib/src/exports.rs | 0 .../{vm => wasmvm}/wasmlib/src/hashtypes.rs | 0 packages/{vm => wasmvm}/wasmlib/src/host.rs | 0 .../{vm => wasmvm}/wasmlib/src/immutable.rs | 0 packages/{vm => wasmvm}/wasmlib/src/keys.rs | 0 packages/{vm => wasmvm}/wasmlib/src/lib.rs | 0 .../{vm => wasmvm}/wasmlib/src/mutable.rs | 0 .../wasmlib/src/wasmrequests/consts.rs | 0 .../wasmlib/src/wasmrequests/contract.rs | 0 .../wasmlib/src/wasmrequests/mod.rs | 0 .../wasmlib/src/wasmrequests/structs.rs | 0 .../wasmclient/api_common/request_sender.ts | 0 .../wasmclient/api_common/response_models.ts | 0 .../wasmlib/ts/wasmclient/arguments.ts | 0 .../wasmlib/ts/wasmclient/buffer/index.d.ts | 0 .../wasmlib/ts/wasmclient/buffer/index.js | 0 .../wasmlib/ts/wasmclient/buffer/readme.md | 0 .../wasmlib/ts/wasmclient/clientfunc.ts | 0 .../wasmlib/ts/wasmclient/clientview.ts | 0 .../wasmlib/ts/wasmclient/colors.ts | 0 .../wasmlib/ts/wasmclient/configuration.ts | 0 .../ts/wasmclient/coreaccounts/service.ts | 0 .../wasmlib/ts/wasmclient/coreblob/service.ts | 0 .../ts/wasmclient/coreblocklog/service.ts | 0 .../ts/wasmclient/coregovernance/service.ts | 0 .../wasmlib/ts/wasmclient/coreroot/service.ts | 0 .../wasmlib/ts/wasmclient/crypto/base58.ts | 0 .../wasmlib/ts/wasmclient/crypto/ed25519.ts | 0 .../wasmlib/ts/wasmclient/crypto/hash.ts | 0 .../wasmlib/ts/wasmclient/crypto/index.ts | 0 .../wasmlib/ts/wasmclient/crypto/seed.ts | 0 .../wasmlib/ts/wasmclient/decoder.ts | 0 .../wasmlib/ts/wasmclient/encoder.ts | 0 .../wasmlib/ts/wasmclient/event.ts | 0 .../goshimmer/faucet/faucet_helper.ts | 0 .../goshimmer/faucet/faucet_models.ts | 0 .../wasmclient/goshimmer/goshimmerclient.ts | 0 .../ts/wasmclient/goshimmer/models/mana.ts | 0 .../wasmclient/goshimmer/models/on_ledger.ts | 0 .../goshimmer/models/transaction.ts | 0 .../goshimmer/models/unspent_outputs.ts | 0 .../goshimmer/pow_web_worker/pow.worker.ts | 0 .../pow_web_worker/pow_worker_manager.ts | 0 .../goshimmer/pow_web_worker/proof_of_work.ts | 0 .../pow_web_worker/worker-loader.d.ts | 0 .../goshimmer/utils/simple_buffer_cursor.ts | 0 .../ts/wasmclient/goshimmer/wallet/wallet.ts | 0 .../goshimmer/wallet/wallet_models.ts | 0 .../wasmlib/ts/wasmclient/index.ts | 0 .../wasmlib/ts/wasmclient/package-lock.json | 0 .../wasmlib/ts/wasmclient/package.json | 0 .../wasmlib/ts/wasmclient/results.ts | 0 .../wasmlib/ts/wasmclient/service.ts | 0 .../wasmlib/ts/wasmclient/serviceclient.ts | 0 .../wasmlib/ts/wasmclient/transfer.ts | 0 .../wasmlib/ts/wasmclient/tsconfig.json | 0 .../wasmlib/ts/wasmclient/types.ts | 0 .../ts/wasmclient/wasmrequests/service.ts | 0 .../wasmlib/ts/wasmclient/waspclient.ts | 0 .../wasmlib/ts/wasmlib/bytes.ts | 0 .../wasmlib/ts/wasmlib/context.ts | 0 .../wasmlib/ts/wasmlib/contract.ts | 0 .../wasmlib/ts/wasmlib/convert.ts | 0 .../wasmlib/ts/wasmlib/coreaccounts/consts.ts | 0 .../ts/wasmlib/coreaccounts/contract.ts | 0 .../wasmlib/ts/wasmlib/coreaccounts/index.ts | 0 .../wasmlib/ts/wasmlib/coreaccounts/params.ts | 0 .../ts/wasmlib/coreaccounts/results.ts | 0 .../ts/wasmlib/coreaccounts/tsconfig.json | 0 .../wasmlib/ts/wasmlib/coreblob/consts.ts | 0 .../wasmlib/ts/wasmlib/coreblob/contract.ts | 0 .../wasmlib/ts/wasmlib/coreblob/index.ts | 0 .../wasmlib/ts/wasmlib/coreblob/params.ts | 0 .../wasmlib/ts/wasmlib/coreblob/results.ts | 0 .../wasmlib/ts/wasmlib/coreblob/tsconfig.json | 0 .../wasmlib/ts/wasmlib/coreblocklog/consts.ts | 0 .../ts/wasmlib/coreblocklog/contract.ts | 0 .../wasmlib/ts/wasmlib/coreblocklog/index.ts | 0 .../wasmlib/ts/wasmlib/coreblocklog/params.ts | 0 .../ts/wasmlib/coreblocklog/results.ts | 0 .../ts/wasmlib/coreblocklog/tsconfig.json | 0 .../ts/wasmlib/coregovernance/consts.ts | 0 .../ts/wasmlib/coregovernance/contract.ts | 0 .../ts/wasmlib/coregovernance/index.ts | 0 .../ts/wasmlib/coregovernance/params.ts | 0 .../ts/wasmlib/coregovernance/results.ts | 0 .../ts/wasmlib/coregovernance/tsconfig.json | 0 .../wasmlib/ts/wasmlib/coreroot/consts.ts | 0 .../wasmlib/ts/wasmlib/coreroot/contract.ts | 0 .../wasmlib/ts/wasmlib/coreroot/index.ts | 0 .../wasmlib/ts/wasmlib/coreroot/params.ts | 0 .../wasmlib/ts/wasmlib/coreroot/results.ts | 0 .../wasmlib/ts/wasmlib/coreroot/tsconfig.json | 0 .../wasmlib/ts/wasmlib/events.ts | 0 .../wasmlib/ts/wasmlib/exports.ts | 0 .../wasmlib/ts/wasmlib/hashtypes.ts | 0 .../{vm => wasmvm}/wasmlib/ts/wasmlib/host.ts | 0 .../wasmlib/ts/wasmlib/immutable.ts | 0 .../wasmlib/ts/wasmlib/index.ts | 0 .../{vm => wasmvm}/wasmlib/ts/wasmlib/keys.ts | 0 .../wasmlib/ts/wasmlib/mutable.ts | 0 .../wasmlib/ts/wasmlib/package-lock.json | 0 .../wasmlib/ts/wasmlib/package.json | 0 .../wasmlib/ts/wasmlib/tsconfig.json | 0 .../wasmlib/ts/wasmlib/wasmrequests/consts.ts | 0 .../ts/wasmlib/wasmrequests/contract.ts | 0 .../wasmlib/ts/wasmlib/wasmrequests/index.ts | 0 .../ts/wasmlib/wasmrequests/structs.ts | 0 .../ts/wasmlib/wasmrequests/tsconfig.json | 0 packages/{vm => wasmvm}/wasmsolo/soloagent.go | 2 +- .../{vm => wasmvm}/wasmsolo/solocontext.go | 12 +- .../{vm => wasmvm}/wasmsolo/soloconvertor.go | 2 +- .../{vm => wasmvm}/wasmsolo/solosandbox.go | 4 +- .../wasmsolo/solosandboxutils.go | 2 +- packages/{vm => wasmvm}/wasmvmhost/host.go | 2 +- .../goclienttemplates/alltemplates.go | 2 +- .../generator/goclienttemplates/service.go | 2 +- .../generator/gotemplates/alltemplates.go | 4 +- 374 files changed, 600 insertions(+), 582 deletions(-) rename packages/{vm => wasmvm}/wasmhost/wasmcontext.go (98%) rename packages/{vm => wasmvm}/wasmhost/wasmedgevm.go (100%) rename packages/{vm => wasmvm}/wasmhost/wasmervm.go (100%) rename packages/{vm => wasmvm}/wasmhost/wasmgovm.go (96%) rename packages/{vm => wasmvm}/wasmhost/wasmhost.go (97%) rename packages/{vm => wasmvm}/wasmhost/wasmprocessor.go (100%) rename packages/{vm => wasmvm}/wasmhost/wasmtimevm.go (100%) rename packages/{vm => wasmvm}/wasmhost/wasmtosandbox.go (99%) rename packages/{vm => wasmvm}/wasmhost/wasmtosandboxutils.go (97%) rename packages/{vm => wasmvm}/wasmhost/wasmvm.go (99%) rename packages/{vm => wasmvm}/wasmlib/Cargo.toml (100%) rename packages/{vm => wasmvm}/wasmlib/LICENSE (100%) rename packages/{vm => wasmvm}/wasmlib/README.md (100%) rename packages/{vm => wasmvm}/wasmlib/go/wasmclient/arguments.go (100%) rename packages/{vm => wasmvm}/wasmlib/go/wasmclient/clientfunc.go (100%) rename packages/{vm => wasmvm}/wasmlib/go/wasmclient/clientview.go (100%) rename packages/{vm => wasmvm}/wasmlib/go/wasmclient/coreaccounts/service.go (73%) rename packages/{vm => wasmvm}/wasmlib/go/wasmclient/coreblob/service.go (78%) rename packages/{vm => wasmvm}/wasmlib/go/wasmclient/coreblocklog/service.go (85%) rename packages/{vm => wasmvm}/wasmlib/go/wasmclient/coregovernance/service.go (83%) rename packages/{vm => wasmvm}/wasmlib/go/wasmclient/coreroot/service.go (77%) rename packages/{vm => wasmvm}/wasmlib/go/wasmclient/decoder.go (100%) rename packages/{vm => wasmvm}/wasmlib/go/wasmclient/encoder.go (100%) rename packages/{vm => wasmvm}/wasmlib/go/wasmclient/event.go (100%) rename packages/{vm => wasmvm}/wasmlib/go/wasmclient/request.go (100%) rename packages/{vm => wasmvm}/wasmlib/go/wasmclient/results.go (100%) rename packages/{vm => wasmvm}/wasmlib/go/wasmclient/seed.go (100%) rename packages/{vm => wasmvm}/wasmlib/go/wasmclient/service.go (100%) rename packages/{vm => wasmvm}/wasmlib/go/wasmclient/serviceclient.go (100%) rename packages/{vm => wasmvm}/wasmlib/go/wasmclient/transfer.go (100%) rename packages/{vm => wasmvm}/wasmlib/go/wasmclient/types.go (100%) rename packages/{vm => wasmvm}/wasmlib/go/wasmclient/wasmrequests/service.go (100%) rename packages/{vm => wasmvm}/wasmlib/go/wasmlib/assets.go (97%) rename packages/{vm => wasmvm}/wasmlib/go/wasmlib/context.go (94%) rename packages/{vm => wasmvm}/wasmlib/go/wasmlib/contract.go (96%) rename packages/{vm => wasmvm}/wasmlib/go/wasmlib/coreaccounts/consts.go (93%) rename packages/{vm => wasmvm}/wasmlib/go/wasmlib/coreaccounts/contract.go (97%) rename packages/{vm => wasmvm}/wasmlib/go/wasmlib/coreaccounts/params.go (96%) rename packages/{vm => wasmvm}/wasmlib/go/wasmlib/coreaccounts/results.go (97%) rename packages/{vm => wasmvm}/wasmlib/go/wasmlib/coreblob/consts.go (91%) rename packages/{vm => wasmvm}/wasmlib/go/wasmlib/coreblob/contract.go (96%) rename packages/{vm => wasmvm}/wasmlib/go/wasmlib/coreblob/params.go (96%) rename packages/{vm => wasmvm}/wasmlib/go/wasmlib/coreblob/results.go (97%) rename packages/{vm => wasmvm}/wasmlib/go/wasmlib/coreblocklog/consts.go (96%) rename packages/{vm => wasmvm}/wasmlib/go/wasmlib/coreblocklog/contract.go (98%) rename packages/{vm => wasmvm}/wasmlib/go/wasmlib/coreblocklog/params.go (98%) rename packages/{vm => wasmvm}/wasmlib/go/wasmlib/coreblocklog/results.go (99%) rename packages/{vm => wasmvm}/wasmlib/go/wasmlib/coregovernance/consts.go (97%) rename packages/{vm => wasmvm}/wasmlib/go/wasmlib/coregovernance/contract.go (98%) rename packages/{vm => wasmvm}/wasmlib/go/wasmlib/coregovernance/params.go (98%) rename packages/{vm => wasmvm}/wasmlib/go/wasmlib/coregovernance/results.go (98%) rename packages/{vm => wasmvm}/wasmlib/go/wasmlib/coreroot/consts.go (93%) rename packages/{vm => wasmvm}/wasmlib/go/wasmlib/coreroot/contract.go (97%) rename packages/{vm => wasmvm}/wasmlib/go/wasmlib/coreroot/params.go (97%) rename packages/{vm => wasmvm}/wasmlib/go/wasmlib/coreroot/results.go (96%) rename packages/{vm => wasmvm}/wasmlib/go/wasmlib/dict.go (96%) rename packages/{vm => wasmvm}/wasmlib/go/wasmlib/events.go (89%) rename packages/{vm => wasmvm}/wasmlib/go/wasmlib/exports.go (100%) rename packages/{vm => wasmvm}/wasmlib/go/wasmlib/host.go (100%) rename packages/{vm => wasmvm}/wasmlib/go/wasmlib/inithost.go (100%) rename packages/{vm => wasmvm}/wasmlib/go/wasmlib/sandbox.go (98%) rename packages/{vm => wasmvm}/wasmlib/go/wasmlib/sandboxutils.go (97%) rename packages/{vm => wasmvm}/wasmlib/go/wasmlib/state.go (90%) rename packages/{vm => wasmvm}/wasmlib/go/wasmlib/wasmrequests/consts.go (81%) rename packages/{vm => wasmvm}/wasmlib/go/wasmlib/wasmrequests/contract.go (100%) rename packages/{vm => wasmvm}/wasmlib/go/wasmlib/wasmrequests/structs.go (98%) rename packages/{vm => wasmvm}/wasmlib/go/wasmlib/wasmtypes/address.go (100%) rename packages/{vm => wasmvm}/wasmlib/go/wasmlib/wasmtypes/agentid.go (100%) rename packages/{vm => wasmvm}/wasmlib/go/wasmlib/wasmtypes/bool.go (100%) rename packages/{vm => wasmvm}/wasmlib/go/wasmlib/wasmtypes/bytes.go (100%) rename packages/{vm => wasmvm}/wasmlib/go/wasmlib/wasmtypes/chainid.go (100%) rename packages/{vm => wasmvm}/wasmlib/go/wasmlib/wasmtypes/codec.go (100%) rename packages/{vm => wasmvm}/wasmlib/go/wasmlib/wasmtypes/color.go (100%) rename packages/{vm => wasmvm}/wasmlib/go/wasmlib/wasmtypes/hash.go (100%) rename packages/{vm => wasmvm}/wasmlib/go/wasmlib/wasmtypes/hname.go (100%) rename packages/{vm => wasmvm}/wasmlib/go/wasmlib/wasmtypes/int16.go (100%) rename packages/{vm => wasmvm}/wasmlib/go/wasmlib/wasmtypes/int32.go (100%) rename packages/{vm => wasmvm}/wasmlib/go/wasmlib/wasmtypes/int64.go (100%) rename packages/{vm => wasmvm}/wasmlib/go/wasmlib/wasmtypes/int8.go (100%) rename packages/{vm => wasmvm}/wasmlib/go/wasmlib/wasmtypes/proxy.go (100%) rename packages/{vm => wasmvm}/wasmlib/go/wasmlib/wasmtypes/requestid.go (100%) rename packages/{vm => wasmvm}/wasmlib/go/wasmlib/wasmtypes/string.go (100%) rename packages/{vm => wasmvm}/wasmlib/go/wasmlib/wasmtypes/uint16.go (100%) rename packages/{vm => wasmvm}/wasmlib/go/wasmlib/wasmtypes/uint32.go (100%) rename packages/{vm => wasmvm}/wasmlib/go/wasmlib/wasmtypes/uint64.go (100%) rename packages/{vm => wasmvm}/wasmlib/go/wasmlib/wasmtypes/uint8.go (100%) rename packages/{vm => wasmvm}/wasmlib/interfaces/coreaccounts.yaml (100%) rename packages/{vm => wasmvm}/wasmlib/interfaces/coreblob.yaml (100%) rename packages/{vm => wasmvm}/wasmlib/interfaces/coreblocklog.yaml (100%) rename packages/{vm => wasmvm}/wasmlib/interfaces/coregovernance.yaml (100%) rename packages/{vm => wasmvm}/wasmlib/interfaces/coreroot.yaml (100%) rename packages/{vm => wasmvm}/wasmlib/interfaces/wasmrequests.yaml (100%) rename packages/{vm => wasmvm}/wasmlib/src/bytes.rs (100%) rename packages/{vm => wasmvm}/wasmlib/src/context.rs (100%) rename packages/{vm => wasmvm}/wasmlib/src/contract.rs (100%) rename packages/{vm => wasmvm}/wasmlib/src/coreaccounts/consts.rs (100%) rename packages/{vm => wasmvm}/wasmlib/src/coreaccounts/contract.rs (100%) rename packages/{vm => wasmvm}/wasmlib/src/coreaccounts/mod.rs (100%) rename packages/{vm => wasmvm}/wasmlib/src/coreaccounts/params.rs (100%) rename packages/{vm => wasmvm}/wasmlib/src/coreaccounts/results.rs (100%) rename packages/{vm => wasmvm}/wasmlib/src/coreblob/consts.rs (100%) rename packages/{vm => wasmvm}/wasmlib/src/coreblob/contract.rs (100%) rename packages/{vm => wasmvm}/wasmlib/src/coreblob/mod.rs (100%) rename packages/{vm => wasmvm}/wasmlib/src/coreblob/params.rs (100%) rename packages/{vm => wasmvm}/wasmlib/src/coreblob/results.rs (100%) rename packages/{vm => wasmvm}/wasmlib/src/coreblocklog/consts.rs (100%) rename packages/{vm => wasmvm}/wasmlib/src/coreblocklog/contract.rs (100%) rename packages/{vm => wasmvm}/wasmlib/src/coreblocklog/mod.rs (100%) rename packages/{vm => wasmvm}/wasmlib/src/coreblocklog/params.rs (100%) rename packages/{vm => wasmvm}/wasmlib/src/coreblocklog/results.rs (100%) rename packages/{vm => wasmvm}/wasmlib/src/coregovernance/consts.rs (100%) rename packages/{vm => wasmvm}/wasmlib/src/coregovernance/contract.rs (100%) rename packages/{vm => wasmvm}/wasmlib/src/coregovernance/mod.rs (100%) rename packages/{vm => wasmvm}/wasmlib/src/coregovernance/params.rs (100%) rename packages/{vm => wasmvm}/wasmlib/src/coregovernance/results.rs (100%) rename packages/{vm => wasmvm}/wasmlib/src/coreroot/consts.rs (100%) rename packages/{vm => wasmvm}/wasmlib/src/coreroot/contract.rs (100%) rename packages/{vm => wasmvm}/wasmlib/src/coreroot/mod.rs (100%) rename packages/{vm => wasmvm}/wasmlib/src/coreroot/params.rs (100%) rename packages/{vm => wasmvm}/wasmlib/src/coreroot/results.rs (100%) rename packages/{vm => wasmvm}/wasmlib/src/events.rs (100%) rename packages/{vm => wasmvm}/wasmlib/src/exports.rs (100%) rename packages/{vm => wasmvm}/wasmlib/src/hashtypes.rs (100%) rename packages/{vm => wasmvm}/wasmlib/src/host.rs (100%) rename packages/{vm => wasmvm}/wasmlib/src/immutable.rs (100%) rename packages/{vm => wasmvm}/wasmlib/src/keys.rs (100%) rename packages/{vm => wasmvm}/wasmlib/src/lib.rs (100%) rename packages/{vm => wasmvm}/wasmlib/src/mutable.rs (100%) rename packages/{vm => wasmvm}/wasmlib/src/wasmrequests/consts.rs (100%) rename packages/{vm => wasmvm}/wasmlib/src/wasmrequests/contract.rs (100%) rename packages/{vm => wasmvm}/wasmlib/src/wasmrequests/mod.rs (100%) rename packages/{vm => wasmvm}/wasmlib/src/wasmrequests/structs.rs (100%) rename packages/{vm => wasmvm}/wasmlib/ts/wasmclient/api_common/request_sender.ts (100%) rename packages/{vm => wasmvm}/wasmlib/ts/wasmclient/api_common/response_models.ts (100%) rename packages/{vm => wasmvm}/wasmlib/ts/wasmclient/arguments.ts (100%) rename packages/{vm => wasmvm}/wasmlib/ts/wasmclient/buffer/index.d.ts (100%) rename packages/{vm => wasmvm}/wasmlib/ts/wasmclient/buffer/index.js (100%) rename packages/{vm => wasmvm}/wasmlib/ts/wasmclient/buffer/readme.md (100%) rename packages/{vm => wasmvm}/wasmlib/ts/wasmclient/clientfunc.ts (100%) rename packages/{vm => wasmvm}/wasmlib/ts/wasmclient/clientview.ts (100%) rename packages/{vm => wasmvm}/wasmlib/ts/wasmclient/colors.ts (100%) rename packages/{vm => wasmvm}/wasmlib/ts/wasmclient/configuration.ts (100%) rename packages/{vm => wasmvm}/wasmlib/ts/wasmclient/coreaccounts/service.ts (100%) rename packages/{vm => wasmvm}/wasmlib/ts/wasmclient/coreblob/service.ts (100%) rename packages/{vm => wasmvm}/wasmlib/ts/wasmclient/coreblocklog/service.ts (100%) rename packages/{vm => wasmvm}/wasmlib/ts/wasmclient/coregovernance/service.ts (100%) rename packages/{vm => wasmvm}/wasmlib/ts/wasmclient/coreroot/service.ts (100%) rename packages/{vm => wasmvm}/wasmlib/ts/wasmclient/crypto/base58.ts (100%) rename packages/{vm => wasmvm}/wasmlib/ts/wasmclient/crypto/ed25519.ts (100%) rename packages/{vm => wasmvm}/wasmlib/ts/wasmclient/crypto/hash.ts (100%) rename packages/{vm => wasmvm}/wasmlib/ts/wasmclient/crypto/index.ts (100%) rename packages/{vm => wasmvm}/wasmlib/ts/wasmclient/crypto/seed.ts (100%) rename packages/{vm => wasmvm}/wasmlib/ts/wasmclient/decoder.ts (100%) rename packages/{vm => wasmvm}/wasmlib/ts/wasmclient/encoder.ts (100%) rename packages/{vm => wasmvm}/wasmlib/ts/wasmclient/event.ts (100%) rename packages/{vm => wasmvm}/wasmlib/ts/wasmclient/goshimmer/faucet/faucet_helper.ts (100%) rename packages/{vm => wasmvm}/wasmlib/ts/wasmclient/goshimmer/faucet/faucet_models.ts (100%) rename packages/{vm => wasmvm}/wasmlib/ts/wasmclient/goshimmer/goshimmerclient.ts (100%) rename packages/{vm => wasmvm}/wasmlib/ts/wasmclient/goshimmer/models/mana.ts (100%) rename packages/{vm => wasmvm}/wasmlib/ts/wasmclient/goshimmer/models/on_ledger.ts (100%) rename packages/{vm => wasmvm}/wasmlib/ts/wasmclient/goshimmer/models/transaction.ts (100%) rename packages/{vm => wasmvm}/wasmlib/ts/wasmclient/goshimmer/models/unspent_outputs.ts (100%) rename packages/{vm => wasmvm}/wasmlib/ts/wasmclient/goshimmer/pow_web_worker/pow.worker.ts (100%) rename packages/{vm => wasmvm}/wasmlib/ts/wasmclient/goshimmer/pow_web_worker/pow_worker_manager.ts (100%) rename packages/{vm => wasmvm}/wasmlib/ts/wasmclient/goshimmer/pow_web_worker/proof_of_work.ts (100%) rename packages/{vm => wasmvm}/wasmlib/ts/wasmclient/goshimmer/pow_web_worker/worker-loader.d.ts (100%) rename packages/{vm => wasmvm}/wasmlib/ts/wasmclient/goshimmer/utils/simple_buffer_cursor.ts (100%) rename packages/{vm => wasmvm}/wasmlib/ts/wasmclient/goshimmer/wallet/wallet.ts (100%) rename packages/{vm => wasmvm}/wasmlib/ts/wasmclient/goshimmer/wallet/wallet_models.ts (100%) rename packages/{vm => wasmvm}/wasmlib/ts/wasmclient/index.ts (100%) rename packages/{vm => wasmvm}/wasmlib/ts/wasmclient/package-lock.json (100%) rename packages/{vm => wasmvm}/wasmlib/ts/wasmclient/package.json (100%) rename packages/{vm => wasmvm}/wasmlib/ts/wasmclient/results.ts (100%) rename packages/{vm => wasmvm}/wasmlib/ts/wasmclient/service.ts (100%) rename packages/{vm => wasmvm}/wasmlib/ts/wasmclient/serviceclient.ts (100%) rename packages/{vm => wasmvm}/wasmlib/ts/wasmclient/transfer.ts (100%) rename packages/{vm => wasmvm}/wasmlib/ts/wasmclient/tsconfig.json (100%) rename packages/{vm => wasmvm}/wasmlib/ts/wasmclient/types.ts (100%) rename packages/{vm => wasmvm}/wasmlib/ts/wasmclient/wasmrequests/service.ts (100%) rename packages/{vm => wasmvm}/wasmlib/ts/wasmclient/waspclient.ts (100%) rename packages/{vm => wasmvm}/wasmlib/ts/wasmlib/bytes.ts (100%) rename packages/{vm => wasmvm}/wasmlib/ts/wasmlib/context.ts (100%) rename packages/{vm => wasmvm}/wasmlib/ts/wasmlib/contract.ts (100%) rename packages/{vm => wasmvm}/wasmlib/ts/wasmlib/convert.ts (100%) rename packages/{vm => wasmvm}/wasmlib/ts/wasmlib/coreaccounts/consts.ts (100%) rename packages/{vm => wasmvm}/wasmlib/ts/wasmlib/coreaccounts/contract.ts (100%) rename packages/{vm => wasmvm}/wasmlib/ts/wasmlib/coreaccounts/index.ts (100%) rename packages/{vm => wasmvm}/wasmlib/ts/wasmlib/coreaccounts/params.ts (100%) rename packages/{vm => wasmvm}/wasmlib/ts/wasmlib/coreaccounts/results.ts (100%) rename packages/{vm => wasmvm}/wasmlib/ts/wasmlib/coreaccounts/tsconfig.json (100%) rename packages/{vm => wasmvm}/wasmlib/ts/wasmlib/coreblob/consts.ts (100%) rename packages/{vm => wasmvm}/wasmlib/ts/wasmlib/coreblob/contract.ts (100%) rename packages/{vm => wasmvm}/wasmlib/ts/wasmlib/coreblob/index.ts (100%) rename packages/{vm => wasmvm}/wasmlib/ts/wasmlib/coreblob/params.ts (100%) rename packages/{vm => wasmvm}/wasmlib/ts/wasmlib/coreblob/results.ts (100%) rename packages/{vm => wasmvm}/wasmlib/ts/wasmlib/coreblob/tsconfig.json (100%) rename packages/{vm => wasmvm}/wasmlib/ts/wasmlib/coreblocklog/consts.ts (100%) rename packages/{vm => wasmvm}/wasmlib/ts/wasmlib/coreblocklog/contract.ts (100%) rename packages/{vm => wasmvm}/wasmlib/ts/wasmlib/coreblocklog/index.ts (100%) rename packages/{vm => wasmvm}/wasmlib/ts/wasmlib/coreblocklog/params.ts (100%) rename packages/{vm => wasmvm}/wasmlib/ts/wasmlib/coreblocklog/results.ts (100%) rename packages/{vm => wasmvm}/wasmlib/ts/wasmlib/coreblocklog/tsconfig.json (100%) rename packages/{vm => wasmvm}/wasmlib/ts/wasmlib/coregovernance/consts.ts (100%) rename packages/{vm => wasmvm}/wasmlib/ts/wasmlib/coregovernance/contract.ts (100%) rename packages/{vm => wasmvm}/wasmlib/ts/wasmlib/coregovernance/index.ts (100%) rename packages/{vm => wasmvm}/wasmlib/ts/wasmlib/coregovernance/params.ts (100%) rename packages/{vm => wasmvm}/wasmlib/ts/wasmlib/coregovernance/results.ts (100%) rename packages/{vm => wasmvm}/wasmlib/ts/wasmlib/coregovernance/tsconfig.json (100%) rename packages/{vm => wasmvm}/wasmlib/ts/wasmlib/coreroot/consts.ts (100%) rename packages/{vm => wasmvm}/wasmlib/ts/wasmlib/coreroot/contract.ts (100%) rename packages/{vm => wasmvm}/wasmlib/ts/wasmlib/coreroot/index.ts (100%) rename packages/{vm => wasmvm}/wasmlib/ts/wasmlib/coreroot/params.ts (100%) rename packages/{vm => wasmvm}/wasmlib/ts/wasmlib/coreroot/results.ts (100%) rename packages/{vm => wasmvm}/wasmlib/ts/wasmlib/coreroot/tsconfig.json (100%) rename packages/{vm => wasmvm}/wasmlib/ts/wasmlib/events.ts (100%) rename packages/{vm => wasmvm}/wasmlib/ts/wasmlib/exports.ts (100%) rename packages/{vm => wasmvm}/wasmlib/ts/wasmlib/hashtypes.ts (100%) rename packages/{vm => wasmvm}/wasmlib/ts/wasmlib/host.ts (100%) rename packages/{vm => wasmvm}/wasmlib/ts/wasmlib/immutable.ts (100%) rename packages/{vm => wasmvm}/wasmlib/ts/wasmlib/index.ts (100%) rename packages/{vm => wasmvm}/wasmlib/ts/wasmlib/keys.ts (100%) rename packages/{vm => wasmvm}/wasmlib/ts/wasmlib/mutable.ts (100%) rename packages/{vm => wasmvm}/wasmlib/ts/wasmlib/package-lock.json (100%) rename packages/{vm => wasmvm}/wasmlib/ts/wasmlib/package.json (100%) rename packages/{vm => wasmvm}/wasmlib/ts/wasmlib/tsconfig.json (100%) rename packages/{vm => wasmvm}/wasmlib/ts/wasmlib/wasmrequests/consts.ts (100%) rename packages/{vm => wasmvm}/wasmlib/ts/wasmlib/wasmrequests/contract.ts (100%) rename packages/{vm => wasmvm}/wasmlib/ts/wasmlib/wasmrequests/index.ts (100%) rename packages/{vm => wasmvm}/wasmlib/ts/wasmlib/wasmrequests/structs.ts (100%) rename packages/{vm => wasmvm}/wasmlib/ts/wasmlib/wasmrequests/tsconfig.json (100%) rename packages/{vm => wasmvm}/wasmsolo/soloagent.go (95%) rename packages/{vm => wasmvm}/wasmsolo/solocontext.go (98%) rename packages/{vm => wasmvm}/wasmsolo/soloconvertor.go (94%) rename packages/{vm => wasmvm}/wasmsolo/solosandbox.go (98%) rename packages/{vm => wasmvm}/wasmsolo/solosandboxutils.go (96%) rename packages/{vm => wasmvm}/wasmvmhost/host.go (98%) diff --git a/contracts/wasm/dividend/Cargo.toml b/contracts/wasm/dividend/Cargo.toml index 5a603fb952..64ca57d31b 100644 --- a/contracts/wasm/dividend/Cargo.toml +++ b/contracts/wasm/dividend/Cargo.toml @@ -17,7 +17,7 @@ crate-type = ["cdylib", "rlib"] default = ["console_error_panic_hook"] [dependencies] -wasmlib = { path = "../../../packages/vm/wasmlib" } +wasmlib = { path = "../../../wasmvm/wasmlib" } #wasmlib = { git = "https://github.com/iotaledger/wasp", branch = "develop" } # The `console_error_panic_hook` crate provides better debugging of panics by diff --git a/contracts/wasm/dividend/go/dividend/consts.go b/contracts/wasm/dividend/go/dividend/consts.go index 0e4eafd67f..0d3f661756 100644 --- a/contracts/wasm/dividend/go/dividend/consts.go +++ b/contracts/wasm/dividend/go/dividend/consts.go @@ -7,7 +7,7 @@ package dividend -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" +import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" const ( ScName = "dividend" diff --git a/contracts/wasm/dividend/go/dividend/contract.go b/contracts/wasm/dividend/go/dividend/contract.go index 3d15ba00c4..df3e7cf45f 100644 --- a/contracts/wasm/dividend/go/dividend/contract.go +++ b/contracts/wasm/dividend/go/dividend/contract.go @@ -7,7 +7,7 @@ package dividend -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" +import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib" type DivideCall struct { Func *wasmlib.ScFunc diff --git a/contracts/wasm/dividend/go/dividend/dividend.go b/contracts/wasm/dividend/go/dividend/dividend.go index 54ac3539c2..0786eb7f25 100644 --- a/contracts/wasm/dividend/go/dividend/dividend.go +++ b/contracts/wasm/dividend/go/dividend/dividend.go @@ -15,8 +15,8 @@ package dividend import ( - "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" - "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" + "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib" + "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" ) // 'init' is used as a way to initialize a smart contract. It is an optional diff --git a/contracts/wasm/dividend/go/dividend/lib.go b/contracts/wasm/dividend/go/dividend/lib.go index 3cc4d82751..4fd65066d1 100644 --- a/contracts/wasm/dividend/go/dividend/lib.go +++ b/contracts/wasm/dividend/go/dividend/lib.go @@ -7,7 +7,7 @@ package dividend -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" +import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib" func OnLoad() { exports := wasmlib.NewScExports() diff --git a/contracts/wasm/dividend/go/dividend/params.go b/contracts/wasm/dividend/go/dividend/params.go index 92dd61d3af..3a98c8c45b 100644 --- a/contracts/wasm/dividend/go/dividend/params.go +++ b/contracts/wasm/dividend/go/dividend/params.go @@ -7,7 +7,7 @@ package dividend -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" +import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" type ImmutableInitParams struct { proxy wasmtypes.Proxy diff --git a/contracts/wasm/dividend/go/dividend/results.go b/contracts/wasm/dividend/go/dividend/results.go index e66bbf78d2..e433eee980 100644 --- a/contracts/wasm/dividend/go/dividend/results.go +++ b/contracts/wasm/dividend/go/dividend/results.go @@ -7,7 +7,7 @@ package dividend -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" +import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" type ImmutableGetFactorResults struct { proxy wasmtypes.Proxy diff --git a/contracts/wasm/dividend/go/dividend/state.go b/contracts/wasm/dividend/go/dividend/state.go index ade138803a..ee700b52a4 100644 --- a/contracts/wasm/dividend/go/dividend/state.go +++ b/contracts/wasm/dividend/go/dividend/state.go @@ -7,7 +7,7 @@ package dividend -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" +import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" type ArrayOfImmutableAddress struct { proxy wasmtypes.Proxy diff --git a/contracts/wasm/dividend/test/dividend_test.go b/contracts/wasm/dividend/test/dividend_test.go index c6e60f1ddd..f81bbee93b 100644 --- a/contracts/wasm/dividend/test/dividend_test.go +++ b/contracts/wasm/dividend/test/dividend_test.go @@ -9,23 +9,23 @@ import ( "github.com/iotaledger/wasp/contracts/wasm/dividend/go/dividend" "github.com/iotaledger/wasp/packages/solo" - "github.com/iotaledger/wasp/packages/vm/wasmsolo" + wasmsolo2 "github.com/iotaledger/wasp/packages/wasmvm/wasmsolo" "github.com/stretchr/testify/require" ) -func dividendMember(ctx *wasmsolo.SoloContext, agent *wasmsolo.SoloAgent, factor uint64) { +func dividendMember(ctx *wasmsolo2.SoloContext, agent *wasmsolo2.SoloAgent, factor uint64) { member := dividend.ScFuncs.Member(ctx) member.Params.Address().SetValue(agent.ScAddress()) member.Params.Factor().SetValue(factor) member.Func.TransferIotas(1).Post() } -func dividendDivide(ctx *wasmsolo.SoloContext, amount uint64) { +func dividendDivide(ctx *wasmsolo2.SoloContext, amount uint64) { divide := dividend.ScFuncs.Divide(ctx) divide.Func.TransferIotas(amount).Post() } -func dividendGetFactor(ctx *wasmsolo.SoloContext, member *wasmsolo.SoloAgent) uint64 { +func dividendGetFactor(ctx *wasmsolo2.SoloContext, member *wasmsolo2.SoloAgent) uint64 { getFactor := dividend.ScFuncs.GetFactor(ctx) getFactor.Params.Address().SetValue(member.ScAddress()) getFactor.Func.Call() @@ -34,12 +34,12 @@ func dividendGetFactor(ctx *wasmsolo.SoloContext, member *wasmsolo.SoloAgent) ui } func TestDeploy(t *testing.T) { - ctx := wasmsolo.NewSoloContext(t, dividend.ScName, dividend.OnLoad) + ctx := wasmsolo2.NewSoloContext(t, dividend.ScName, dividend.OnLoad) require.NoError(t, ctx.ContractExists(dividend.ScName)) } func TestAddMemberOk(t *testing.T) { - ctx := wasmsolo.NewSoloContext(t, dividend.ScName, dividend.OnLoad) + ctx := wasmsolo2.NewSoloContext(t, dividend.ScName, dividend.OnLoad) member1 := ctx.NewSoloAgent() dividendMember(ctx, member1, 100) @@ -47,7 +47,7 @@ func TestAddMemberOk(t *testing.T) { } func TestAddMemberFailMissingAddress(t *testing.T) { - ctx := wasmsolo.NewSoloContext(t, dividend.ScName, dividend.OnLoad) + ctx := wasmsolo2.NewSoloContext(t, dividend.ScName, dividend.OnLoad) member := dividend.ScFuncs.Member(ctx) member.Params.Factor().SetValue(100) @@ -57,7 +57,7 @@ func TestAddMemberFailMissingAddress(t *testing.T) { } func TestAddMemberFailMissingFactor(t *testing.T) { - ctx := wasmsolo.NewSoloContext(t, dividend.ScName, dividend.OnLoad) + ctx := wasmsolo2.NewSoloContext(t, dividend.ScName, dividend.OnLoad) member1 := ctx.NewSoloAgent() member := dividend.ScFuncs.Member(ctx) @@ -68,7 +68,7 @@ func TestAddMemberFailMissingFactor(t *testing.T) { } func TestDivide1Member(t *testing.T) { - ctx := wasmsolo.NewSoloContext(t, dividend.ScName, dividend.OnLoad) + ctx := wasmsolo2.NewSoloContext(t, dividend.ScName, dividend.OnLoad) member1 := ctx.NewSoloAgent() dividendMember(ctx, member1, 100) @@ -85,7 +85,7 @@ func TestDivide1Member(t *testing.T) { } func TestDivide2Members(t *testing.T) { - ctx := wasmsolo.NewSoloContext(t, dividend.ScName, dividend.OnLoad) + ctx := wasmsolo2.NewSoloContext(t, dividend.ScName, dividend.OnLoad) member1 := ctx.NewSoloAgent() dividendMember(ctx, member1, 25) @@ -107,7 +107,7 @@ func TestDivide2Members(t *testing.T) { } func TestDivide3Members(t *testing.T) { - ctx := wasmsolo.NewSoloContext(t, dividend.ScName, dividend.OnLoad) + ctx := wasmsolo2.NewSoloContext(t, dividend.ScName, dividend.OnLoad) member1 := ctx.NewSoloAgent() dividendMember(ctx, member1, 25) @@ -155,7 +155,7 @@ func TestDivide3Members(t *testing.T) { } func TestGetFactor(t *testing.T) { - ctx := wasmsolo.NewSoloContext(t, dividend.ScName, dividend.OnLoad) + ctx := wasmsolo2.NewSoloContext(t, dividend.ScName, dividend.OnLoad) member1 := ctx.NewSoloAgent() dividendMember(ctx, member1, 25) diff --git a/contracts/wasm/donatewithfeedback/Cargo.toml b/contracts/wasm/donatewithfeedback/Cargo.toml index 4dc25d4110..9967571a22 100644 --- a/contracts/wasm/donatewithfeedback/Cargo.toml +++ b/contracts/wasm/donatewithfeedback/Cargo.toml @@ -17,7 +17,7 @@ crate-type = ["cdylib", "rlib"] default = ["console_error_panic_hook"] [dependencies] -wasmlib = { path = "../../../packages/vm/wasmlib" } +wasmlib = { path = "../../../wasmvm/wasmlib" } #wasmlib = { git = "https://github.com/iotaledger/wasp", branch = "develop" } # The `console_error_panic_hook` crate provides better debugging of panics by diff --git a/contracts/wasm/donatewithfeedback/go/donatewithfeedback/consts.go b/contracts/wasm/donatewithfeedback/go/donatewithfeedback/consts.go index 970c4599b3..8d2741fe26 100644 --- a/contracts/wasm/donatewithfeedback/go/donatewithfeedback/consts.go +++ b/contracts/wasm/donatewithfeedback/go/donatewithfeedback/consts.go @@ -7,7 +7,7 @@ package donatewithfeedback -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" +import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" const ( ScName = "donatewithfeedback" diff --git a/contracts/wasm/donatewithfeedback/go/donatewithfeedback/contract.go b/contracts/wasm/donatewithfeedback/go/donatewithfeedback/contract.go index 419f9f2597..17312f10a7 100644 --- a/contracts/wasm/donatewithfeedback/go/donatewithfeedback/contract.go +++ b/contracts/wasm/donatewithfeedback/go/donatewithfeedback/contract.go @@ -7,7 +7,7 @@ package donatewithfeedback -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" +import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib" type DonateCall struct { Func *wasmlib.ScFunc diff --git a/contracts/wasm/donatewithfeedback/go/donatewithfeedback/donatewithfeedback.go b/contracts/wasm/donatewithfeedback/go/donatewithfeedback/donatewithfeedback.go index 5bc7597f91..28435f292b 100644 --- a/contracts/wasm/donatewithfeedback/go/donatewithfeedback/donatewithfeedback.go +++ b/contracts/wasm/donatewithfeedback/go/donatewithfeedback/donatewithfeedback.go @@ -4,8 +4,8 @@ package donatewithfeedback import ( - "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" - "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" + "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib" + "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" ) func funcDonate(ctx wasmlib.ScFuncContext, f *DonateContext) { diff --git a/contracts/wasm/donatewithfeedback/go/donatewithfeedback/lib.go b/contracts/wasm/donatewithfeedback/go/donatewithfeedback/lib.go index 9243c086c6..f2879b3b45 100644 --- a/contracts/wasm/donatewithfeedback/go/donatewithfeedback/lib.go +++ b/contracts/wasm/donatewithfeedback/go/donatewithfeedback/lib.go @@ -7,7 +7,7 @@ package donatewithfeedback -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" +import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib" func OnLoad() { exports := wasmlib.NewScExports() diff --git a/contracts/wasm/donatewithfeedback/go/donatewithfeedback/params.go b/contracts/wasm/donatewithfeedback/go/donatewithfeedback/params.go index 1030106b63..c212da8c53 100644 --- a/contracts/wasm/donatewithfeedback/go/donatewithfeedback/params.go +++ b/contracts/wasm/donatewithfeedback/go/donatewithfeedback/params.go @@ -7,7 +7,7 @@ package donatewithfeedback -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" +import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" type ImmutableDonateParams struct { proxy wasmtypes.Proxy diff --git a/contracts/wasm/donatewithfeedback/go/donatewithfeedback/results.go b/contracts/wasm/donatewithfeedback/go/donatewithfeedback/results.go index 31ebebb2fe..5a19480d93 100644 --- a/contracts/wasm/donatewithfeedback/go/donatewithfeedback/results.go +++ b/contracts/wasm/donatewithfeedback/go/donatewithfeedback/results.go @@ -7,7 +7,7 @@ package donatewithfeedback -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" +import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" type ImmutableDonationResults struct { proxy wasmtypes.Proxy diff --git a/contracts/wasm/donatewithfeedback/go/donatewithfeedback/state.go b/contracts/wasm/donatewithfeedback/go/donatewithfeedback/state.go index 00bfaeb9e6..5ec6bfc839 100644 --- a/contracts/wasm/donatewithfeedback/go/donatewithfeedback/state.go +++ b/contracts/wasm/donatewithfeedback/go/donatewithfeedback/state.go @@ -7,7 +7,7 @@ package donatewithfeedback -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" +import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" type ArrayOfImmutableDonation struct { proxy wasmtypes.Proxy diff --git a/contracts/wasm/donatewithfeedback/go/donatewithfeedback/structs.go b/contracts/wasm/donatewithfeedback/go/donatewithfeedback/structs.go index 1d252e2fa0..07dc2df7e6 100644 --- a/contracts/wasm/donatewithfeedback/go/donatewithfeedback/structs.go +++ b/contracts/wasm/donatewithfeedback/go/donatewithfeedback/structs.go @@ -7,7 +7,7 @@ package donatewithfeedback -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" +import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" type Donation struct { Amount uint64 // amount donated diff --git a/contracts/wasm/donatewithfeedback/test/donatewithfeedback_test.go b/contracts/wasm/donatewithfeedback/test/donatewithfeedback_test.go index 8c3edbf8cc..1f4e3d8c8b 100644 --- a/contracts/wasm/donatewithfeedback/test/donatewithfeedback_test.go +++ b/contracts/wasm/donatewithfeedback/test/donatewithfeedback_test.go @@ -8,7 +8,7 @@ import ( "github.com/iotaledger/wasp/contracts/wasm/donatewithfeedback/go/donatewithfeedback" "github.com/iotaledger/wasp/packages/solo" - "github.com/iotaledger/wasp/packages/vm/wasmsolo" + "github.com/iotaledger/wasp/packages/wasmvm/wasmsolo" "github.com/stretchr/testify/require" ) diff --git a/contracts/wasm/erc20/Cargo.toml b/contracts/wasm/erc20/Cargo.toml index 41b760cbfc..6801b3463b 100644 --- a/contracts/wasm/erc20/Cargo.toml +++ b/contracts/wasm/erc20/Cargo.toml @@ -17,7 +17,7 @@ crate-type = ["cdylib", "rlib"] default = ["console_error_panic_hook"] [dependencies] -wasmlib = { path = "../../../packages/vm/wasmlib" } +wasmlib = { path = "../../../wasmvm/wasmlib" } #wasmlib = { git = "https://github.com/iotaledger/wasp", branch = "develop" } # The `console_error_panic_hook` crate provides better debugging of panics by diff --git a/contracts/wasm/erc20/go/erc20/consts.go b/contracts/wasm/erc20/go/erc20/consts.go index 6adda5ce04..6c4a93112e 100644 --- a/contracts/wasm/erc20/go/erc20/consts.go +++ b/contracts/wasm/erc20/go/erc20/consts.go @@ -7,7 +7,7 @@ package erc20 -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" +import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" const ( ScName = "erc20" diff --git a/contracts/wasm/erc20/go/erc20/contract.go b/contracts/wasm/erc20/go/erc20/contract.go index cf2cdf1a0d..6788fe772f 100644 --- a/contracts/wasm/erc20/go/erc20/contract.go +++ b/contracts/wasm/erc20/go/erc20/contract.go @@ -7,7 +7,7 @@ package erc20 -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" +import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib" type ApproveCall struct { Func *wasmlib.ScFunc diff --git a/contracts/wasm/erc20/go/erc20/erc20.go b/contracts/wasm/erc20/go/erc20/erc20.go index 4cf93a97e4..c20c6a5015 100644 --- a/contracts/wasm/erc20/go/erc20/erc20.go +++ b/contracts/wasm/erc20/go/erc20/erc20.go @@ -7,7 +7,7 @@ package erc20 import ( - "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" + "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib" ) // Sets the allowance value for delegated account diff --git a/contracts/wasm/erc20/go/erc20/events.go b/contracts/wasm/erc20/go/erc20/events.go index 2edf5859ce..8612fd8c5d 100644 --- a/contracts/wasm/erc20/go/erc20/events.go +++ b/contracts/wasm/erc20/go/erc20/events.go @@ -9,8 +9,8 @@ package erc20 import ( - "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" - "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" + "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib" + "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" ) type Erc20Events struct{} diff --git a/contracts/wasm/erc20/go/erc20/lib.go b/contracts/wasm/erc20/go/erc20/lib.go index 596d41f4de..9eab89292c 100644 --- a/contracts/wasm/erc20/go/erc20/lib.go +++ b/contracts/wasm/erc20/go/erc20/lib.go @@ -7,7 +7,7 @@ package erc20 -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" +import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib" func OnLoad() { exports := wasmlib.NewScExports() diff --git a/contracts/wasm/erc20/go/erc20/params.go b/contracts/wasm/erc20/go/erc20/params.go index 44cb25afa6..36e180055d 100644 --- a/contracts/wasm/erc20/go/erc20/params.go +++ b/contracts/wasm/erc20/go/erc20/params.go @@ -7,7 +7,7 @@ package erc20 -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" +import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" type ImmutableApproveParams struct { proxy wasmtypes.Proxy diff --git a/contracts/wasm/erc20/go/erc20/results.go b/contracts/wasm/erc20/go/erc20/results.go index 1ca736ab22..ffc782c3a8 100644 --- a/contracts/wasm/erc20/go/erc20/results.go +++ b/contracts/wasm/erc20/go/erc20/results.go @@ -7,7 +7,7 @@ package erc20 -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" +import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" type ImmutableAllowanceResults struct { proxy wasmtypes.Proxy diff --git a/contracts/wasm/erc20/go/erc20/state.go b/contracts/wasm/erc20/go/erc20/state.go index 8695ee6ac3..0e0e70dd16 100644 --- a/contracts/wasm/erc20/go/erc20/state.go +++ b/contracts/wasm/erc20/go/erc20/state.go @@ -7,7 +7,7 @@ package erc20 -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" +import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" type MapAgentIDToImmutableAllowancesForAgent struct { proxy wasmtypes.Proxy diff --git a/contracts/wasm/erc20/go/erc20/typedefs.go b/contracts/wasm/erc20/go/erc20/typedefs.go index 8a8eb520c3..de3560e533 100644 --- a/contracts/wasm/erc20/go/erc20/typedefs.go +++ b/contracts/wasm/erc20/go/erc20/typedefs.go @@ -7,7 +7,7 @@ package erc20 -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" +import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" type MapAgentIDToImmutableUint64 struct { proxy wasmtypes.Proxy diff --git a/contracts/wasm/erc20/test/erc20_test.go b/contracts/wasm/erc20/test/erc20_test.go index 523141b4de..5fd1f3de5c 100644 --- a/contracts/wasm/erc20/test/erc20_test.go +++ b/contracts/wasm/erc20/test/erc20_test.go @@ -6,26 +6,26 @@ import ( "github.com/iotaledger/wasp/contracts/wasm/erc20/go/erc20" "github.com/iotaledger/wasp/packages/solo" "github.com/iotaledger/wasp/packages/vm/core" - "github.com/iotaledger/wasp/packages/vm/wasmsolo" + wasmsolo2 "github.com/iotaledger/wasp/packages/wasmvm/wasmsolo" "github.com/stretchr/testify/require" ) var ( chain *solo.Chain - creator *wasmsolo.SoloAgent + creator *wasmsolo2.SoloAgent ) func setupTest(t *testing.T) { - chain = wasmsolo.StartChain(t, "chain1") - creator = wasmsolo.NewSoloAgent(chain.Env) + chain = wasmsolo2.StartChain(t, "chain1") + creator = wasmsolo2.NewSoloAgent(chain.Env) } -func setupErc20(t *testing.T) *wasmsolo.SoloContext { +func setupErc20(t *testing.T) *wasmsolo2.SoloContext { setupTest(t) init := erc20.ScFuncs.Init(nil) init.Params.Supply().SetValue(solo.Saldo) init.Params.Creator().SetValue(creator.ScAgentID()) - ctx := wasmsolo.NewSoloContextForChain(t, chain, nil, erc20.ScName, erc20.OnLoad, init.Func) + ctx := wasmsolo2.NewSoloContextForChain(t, chain, nil, erc20.ScName, erc20.OnLoad, init.Func) require.NoError(t, ctx.Err) _, _, rec := chain.GetInfo() require.EqualValues(t, len(core.AllCoreContractsByHash)+1, len(rec)) @@ -41,7 +41,7 @@ func setupErc20(t *testing.T) *wasmsolo.SoloContext { return ctx } -func checkErc20Balance(ctx *wasmsolo.SoloContext, account *wasmsolo.SoloAgent, amount uint64) { +func checkErc20Balance(ctx *wasmsolo2.SoloContext, account *wasmsolo2.SoloAgent, amount uint64) { t := chain.Env.T balanceOf := erc20.ScFuncs.BalanceOf(ctx) balanceOf.Params.Account().SetValue(account.ScAgentID()) @@ -52,7 +52,7 @@ func checkErc20Balance(ctx *wasmsolo.SoloContext, account *wasmsolo.SoloAgent, a require.EqualValues(t, amount, balance.Value()) } -func checkErc20Allowance(ctx *wasmsolo.SoloContext, account, delegation *wasmsolo.SoloAgent, amount uint64) { +func checkErc20Allowance(ctx *wasmsolo2.SoloContext, account, delegation *wasmsolo2.SoloAgent, amount uint64) { t := chain.Env.T allowance := erc20.ScFuncs.Allowance(ctx) allowance.Params.Account().SetValue(account.ScAgentID()) @@ -64,7 +64,7 @@ func checkErc20Allowance(ctx *wasmsolo.SoloContext, account, delegation *wasmsol require.EqualValues(t, amount, balance.Value()) } -func approve(ctx *wasmsolo.SoloContext, from, to *wasmsolo.SoloAgent, amount uint64) error { +func approve(ctx *wasmsolo2.SoloContext, from, to *wasmsolo2.SoloAgent, amount uint64) error { appr := erc20.ScFuncs.Approve(ctx.Sign(from)) appr.Params.Delegation().SetValue(to.ScAgentID()) appr.Params.Amount().SetValue(amount) @@ -72,7 +72,7 @@ func approve(ctx *wasmsolo.SoloContext, from, to *wasmsolo.SoloAgent, amount uin return ctx.Err } -func transfer(ctx *wasmsolo.SoloContext, from, to *wasmsolo.SoloAgent, amount uint64) error { +func transfer(ctx *wasmsolo2.SoloContext, from, to *wasmsolo2.SoloAgent, amount uint64) error { tx := erc20.ScFuncs.Transfer(ctx.Sign(from)) tx.Params.Account().SetValue(to.ScAgentID()) tx.Params.Amount().SetValue(amount) @@ -80,7 +80,7 @@ func transfer(ctx *wasmsolo.SoloContext, from, to *wasmsolo.SoloAgent, amount ui return ctx.Err } -func transferFrom(ctx *wasmsolo.SoloContext, delegate, from, to *wasmsolo.SoloAgent, amount uint64) error { +func transferFrom(ctx *wasmsolo2.SoloContext, delegate, from, to *wasmsolo2.SoloAgent, amount uint64) error { tx := erc20.ScFuncs.TransferFrom(ctx.Sign(delegate)) tx.Params.Account().SetValue(from.ScAgentID()) tx.Params.Recipient().SetValue(to.ScAgentID()) diff --git a/contracts/wasm/erc20/test/init_test.go b/contracts/wasm/erc20/test/init_test.go index 5bac03f74d..500b0aff50 100644 --- a/contracts/wasm/erc20/test/init_test.go +++ b/contracts/wasm/erc20/test/init_test.go @@ -6,7 +6,7 @@ import ( "github.com/iotaledger/wasp/contracts/wasm/erc20/go/erc20" "github.com/iotaledger/wasp/packages/solo" "github.com/iotaledger/wasp/packages/vm/core" - "github.com/iotaledger/wasp/packages/vm/wasmsolo" + "github.com/iotaledger/wasp/packages/wasmvm/wasmsolo" "github.com/stretchr/testify/require" ) diff --git a/contracts/wasm/erc721/Cargo.toml b/contracts/wasm/erc721/Cargo.toml index 8485099a71..456c9c79bd 100644 --- a/contracts/wasm/erc721/Cargo.toml +++ b/contracts/wasm/erc721/Cargo.toml @@ -17,7 +17,7 @@ crate-type = ["cdylib", "rlib"] default = ["console_error_panic_hook"] [dependencies] -wasmlib = { path = "../../../packages/vm/wasmlib" } +wasmlib = { path = "../../../wasmvm/wasmlib" } #wasmlib = { git = "https://github.com/iotaledger/wasp", branch = "develop" } console_error_panic_hook = { version = "0.1.6", optional = true } wee_alloc = { version = "0.4.5", optional = true } diff --git a/contracts/wasm/erc721/go/erc721/consts.go b/contracts/wasm/erc721/go/erc721/consts.go index 5c83fab6d4..b7a98b58e9 100644 --- a/contracts/wasm/erc721/go/erc721/consts.go +++ b/contracts/wasm/erc721/go/erc721/consts.go @@ -7,7 +7,7 @@ package erc721 -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" +import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" const ( ScName = "erc721" diff --git a/contracts/wasm/erc721/go/erc721/contract.go b/contracts/wasm/erc721/go/erc721/contract.go index 909e7392a5..1895c15675 100644 --- a/contracts/wasm/erc721/go/erc721/contract.go +++ b/contracts/wasm/erc721/go/erc721/contract.go @@ -7,7 +7,7 @@ package erc721 -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" +import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib" type ApproveCall struct { Func *wasmlib.ScFunc diff --git a/contracts/wasm/erc721/go/erc721/erc721.go b/contracts/wasm/erc721/go/erc721/erc721.go index 514e4d5619..472852c515 100644 --- a/contracts/wasm/erc721/go/erc721/erc721.go +++ b/contracts/wasm/erc721/go/erc721/erc721.go @@ -4,8 +4,8 @@ package erc721 import ( - "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" - "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" + "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib" + "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" ) // Follows ERC-721 standard as closely as possible diff --git a/contracts/wasm/erc721/go/erc721/events.go b/contracts/wasm/erc721/go/erc721/events.go index aaf14ff9bc..d961a72373 100644 --- a/contracts/wasm/erc721/go/erc721/events.go +++ b/contracts/wasm/erc721/go/erc721/events.go @@ -9,8 +9,8 @@ package erc721 import ( - "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" - "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" + "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib" + "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" ) type Erc721Events struct{} diff --git a/contracts/wasm/erc721/go/erc721/lib.go b/contracts/wasm/erc721/go/erc721/lib.go index 1906f5c190..ce4a03583d 100644 --- a/contracts/wasm/erc721/go/erc721/lib.go +++ b/contracts/wasm/erc721/go/erc721/lib.go @@ -7,7 +7,7 @@ package erc721 -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" +import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib" func OnLoad() { exports := wasmlib.NewScExports() diff --git a/contracts/wasm/erc721/go/erc721/params.go b/contracts/wasm/erc721/go/erc721/params.go index 5fe1bf7d3a..9f9a2d9035 100644 --- a/contracts/wasm/erc721/go/erc721/params.go +++ b/contracts/wasm/erc721/go/erc721/params.go @@ -7,7 +7,7 @@ package erc721 -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" +import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" type ImmutableApproveParams struct { proxy wasmtypes.Proxy diff --git a/contracts/wasm/erc721/go/erc721/results.go b/contracts/wasm/erc721/go/erc721/results.go index 78ed3a0797..78265bf585 100644 --- a/contracts/wasm/erc721/go/erc721/results.go +++ b/contracts/wasm/erc721/go/erc721/results.go @@ -7,7 +7,7 @@ package erc721 -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" +import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" type ImmutableBalanceOfResults struct { proxy wasmtypes.Proxy diff --git a/contracts/wasm/erc721/go/erc721/state.go b/contracts/wasm/erc721/go/erc721/state.go index 79d9f83951..a4d04e5fc8 100644 --- a/contracts/wasm/erc721/go/erc721/state.go +++ b/contracts/wasm/erc721/go/erc721/state.go @@ -7,7 +7,7 @@ package erc721 -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" +import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" type MapHashToImmutableAgentID struct { proxy wasmtypes.Proxy diff --git a/contracts/wasm/erc721/go/erc721/typedefs.go b/contracts/wasm/erc721/go/erc721/typedefs.go index 85616b91bc..d837c511db 100644 --- a/contracts/wasm/erc721/go/erc721/typedefs.go +++ b/contracts/wasm/erc721/go/erc721/typedefs.go @@ -7,7 +7,7 @@ package erc721 -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" +import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" type MapAgentIDToImmutableBool struct { proxy wasmtypes.Proxy diff --git a/contracts/wasm/erc721/go/erc721client/events.go b/contracts/wasm/erc721/go/erc721client/events.go index 9a1b3a691f..a9881f3e8b 100644 --- a/contracts/wasm/erc721/go/erc721client/events.go +++ b/contracts/wasm/erc721/go/erc721client/events.go @@ -7,7 +7,9 @@ package erc721client -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmclient" +import ( + wasmclient2 "github.com/iotaledger/wasp/packages/wasmvm/wasmlib/go/wasmclient" +) var erc721Handlers = map[string]func(*Erc721Events, []string){ "erc721.approval": func(evt *Erc721Events, msg []string) { evt.onErc721ApprovalThunk(msg) }, @@ -53,10 +55,10 @@ func (h *Erc721Events) OnErc721Transfer(handler func(e *EventTransfer)) { } type EventApproval struct { - wasmclient.Event - Approved wasmclient.AgentID - Owner wasmclient.AgentID - TokenID wasmclient.Hash + wasmclient2.Event + Approved wasmclient2.AgentID + Owner wasmclient2.AgentID + TokenID wasmclient2.Hash } func (h *Erc721Events) onErc721ApprovalThunk(message []string) { @@ -72,10 +74,10 @@ func (h *Erc721Events) onErc721ApprovalThunk(message []string) { } type EventApprovalForAll struct { - wasmclient.Event + wasmclient2.Event Approval bool - Operator wasmclient.AgentID - Owner wasmclient.AgentID + Operator wasmclient2.AgentID + Owner wasmclient2.AgentID } func (h *Erc721Events) onErc721ApprovalForAllThunk(message []string) { @@ -91,7 +93,7 @@ func (h *Erc721Events) onErc721ApprovalForAllThunk(message []string) { } type EventInit struct { - wasmclient.Event + wasmclient2.Event Name string Symbol string } @@ -108,10 +110,10 @@ func (h *Erc721Events) onErc721InitThunk(message []string) { } type EventMint struct { - wasmclient.Event + wasmclient2.Event Balance uint64 - Owner wasmclient.AgentID - TokenID wasmclient.Hash + Owner wasmclient2.AgentID + TokenID wasmclient2.Hash } func (h *Erc721Events) onErc721MintThunk(message []string) { @@ -127,10 +129,10 @@ func (h *Erc721Events) onErc721MintThunk(message []string) { } type EventTransfer struct { - wasmclient.Event - From wasmclient.AgentID - To wasmclient.AgentID - TokenID wasmclient.Hash + wasmclient2.Event + From wasmclient2.AgentID + To wasmclient2.AgentID + TokenID wasmclient2.Hash } func (h *Erc721Events) onErc721TransferThunk(message []string) { diff --git a/contracts/wasm/erc721/go/erc721client/service.go b/contracts/wasm/erc721/go/erc721client/service.go index 3e9f540bbd..9e086a7cf0 100644 --- a/contracts/wasm/erc721/go/erc721client/service.go +++ b/contracts/wasm/erc721/go/erc721client/service.go @@ -7,7 +7,9 @@ package erc721client -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmclient" +import ( + wasmclient2 "github.com/iotaledger/wasp/packages/wasmvm/wasmlib/go/wasmclient" +) const ( ArgApproval = "approval" @@ -34,19 +36,19 @@ const ( ///////////////////////////// approve ///////////////////////////// type ApproveFunc struct { - wasmclient.ClientFunc - args wasmclient.Arguments + wasmclient2.ClientFunc + args wasmclient2.Arguments } -func (f *ApproveFunc) Approved(v wasmclient.AgentID) { +func (f *ApproveFunc) Approved(v wasmclient2.AgentID) { f.args.Set(ArgApproved, f.args.FromAgentID(v)) } -func (f *ApproveFunc) TokenID(v wasmclient.Hash) { +func (f *ApproveFunc) TokenID(v wasmclient2.Hash) { f.args.Set(ArgTokenID, f.args.FromHash(v)) } -func (f *ApproveFunc) Post() wasmclient.Request { +func (f *ApproveFunc) Post() wasmclient2.Request { f.args.Mandatory(ArgTokenID) return f.ClientFunc.Post(0xa0661268, &f.args) } @@ -54,15 +56,15 @@ func (f *ApproveFunc) Post() wasmclient.Request { ///////////////////////////// burn ///////////////////////////// type BurnFunc struct { - wasmclient.ClientFunc - args wasmclient.Arguments + wasmclient2.ClientFunc + args wasmclient2.Arguments } -func (f *BurnFunc) TokenID(v wasmclient.Hash) { +func (f *BurnFunc) TokenID(v wasmclient2.Hash) { f.args.Set(ArgTokenID, f.args.FromHash(v)) } -func (f *BurnFunc) Post() wasmclient.Request { +func (f *BurnFunc) Post() wasmclient2.Request { f.args.Mandatory(ArgTokenID) return f.ClientFunc.Post(0x7bc1efb1, &f.args) } @@ -70,8 +72,8 @@ func (f *BurnFunc) Post() wasmclient.Request { ///////////////////////////// init ///////////////////////////// type InitFunc struct { - wasmclient.ClientFunc - args wasmclient.Arguments + wasmclient2.ClientFunc + args wasmclient2.Arguments } func (f *InitFunc) Name(v string) { @@ -82,7 +84,7 @@ func (f *InitFunc) Symbol(v string) { f.args.Set(ArgSymbol, f.args.FromString(v)) } -func (f *InitFunc) Post() wasmclient.Request { +func (f *InitFunc) Post() wasmclient2.Request { f.args.Mandatory(ArgName) f.args.Mandatory(ArgSymbol) return f.ClientFunc.Post(0x1f44d644, &f.args) @@ -91,11 +93,11 @@ func (f *InitFunc) Post() wasmclient.Request { ///////////////////////////// mint ///////////////////////////// type MintFunc struct { - wasmclient.ClientFunc - args wasmclient.Arguments + wasmclient2.ClientFunc + args wasmclient2.Arguments } -func (f *MintFunc) TokenID(v wasmclient.Hash) { +func (f *MintFunc) TokenID(v wasmclient2.Hash) { f.args.Set(ArgTokenID, f.args.FromHash(v)) } @@ -103,7 +105,7 @@ func (f *MintFunc) TokenURI(v string) { f.args.Set(ArgTokenURI, f.args.FromString(v)) } -func (f *MintFunc) Post() wasmclient.Request { +func (f *MintFunc) Post() wasmclient2.Request { f.args.Mandatory(ArgTokenID) return f.ClientFunc.Post(0xa29addcf, &f.args) } @@ -111,27 +113,27 @@ func (f *MintFunc) Post() wasmclient.Request { ///////////////////////////// safeTransferFrom ///////////////////////////// type SafeTransferFromFunc struct { - wasmclient.ClientFunc - args wasmclient.Arguments + wasmclient2.ClientFunc + args wasmclient2.Arguments } func (f *SafeTransferFromFunc) Data(v []byte) { f.args.Set(ArgData, f.args.FromBytes(v)) } -func (f *SafeTransferFromFunc) From(v wasmclient.AgentID) { +func (f *SafeTransferFromFunc) From(v wasmclient2.AgentID) { f.args.Set(ArgFrom, f.args.FromAgentID(v)) } -func (f *SafeTransferFromFunc) To(v wasmclient.AgentID) { +func (f *SafeTransferFromFunc) To(v wasmclient2.AgentID) { f.args.Set(ArgTo, f.args.FromAgentID(v)) } -func (f *SafeTransferFromFunc) TokenID(v wasmclient.Hash) { +func (f *SafeTransferFromFunc) TokenID(v wasmclient2.Hash) { f.args.Set(ArgTokenID, f.args.FromHash(v)) } -func (f *SafeTransferFromFunc) Post() wasmclient.Request { +func (f *SafeTransferFromFunc) Post() wasmclient2.Request { f.args.Mandatory(ArgFrom) f.args.Mandatory(ArgTo) f.args.Mandatory(ArgTokenID) @@ -141,19 +143,19 @@ func (f *SafeTransferFromFunc) Post() wasmclient.Request { ///////////////////////////// setApprovalForAll ///////////////////////////// type SetApprovalForAllFunc struct { - wasmclient.ClientFunc - args wasmclient.Arguments + wasmclient2.ClientFunc + args wasmclient2.Arguments } func (f *SetApprovalForAllFunc) Approval(v bool) { f.args.Set(ArgApproval, f.args.FromBool(v)) } -func (f *SetApprovalForAllFunc) Operator(v wasmclient.AgentID) { +func (f *SetApprovalForAllFunc) Operator(v wasmclient2.AgentID) { f.args.Set(ArgOperator, f.args.FromAgentID(v)) } -func (f *SetApprovalForAllFunc) Post() wasmclient.Request { +func (f *SetApprovalForAllFunc) Post() wasmclient2.Request { f.args.Mandatory(ArgApproval) f.args.Mandatory(ArgOperator) return f.ClientFunc.Post(0xb8d8c776, &f.args) @@ -162,23 +164,23 @@ func (f *SetApprovalForAllFunc) Post() wasmclient.Request { ///////////////////////////// transferFrom ///////////////////////////// type TransferFromFunc struct { - wasmclient.ClientFunc - args wasmclient.Arguments + wasmclient2.ClientFunc + args wasmclient2.Arguments } -func (f *TransferFromFunc) From(v wasmclient.AgentID) { +func (f *TransferFromFunc) From(v wasmclient2.AgentID) { f.args.Set(ArgFrom, f.args.FromAgentID(v)) } -func (f *TransferFromFunc) To(v wasmclient.AgentID) { +func (f *TransferFromFunc) To(v wasmclient2.AgentID) { f.args.Set(ArgTo, f.args.FromAgentID(v)) } -func (f *TransferFromFunc) TokenID(v wasmclient.Hash) { +func (f *TransferFromFunc) TokenID(v wasmclient2.Hash) { f.args.Set(ArgTokenID, f.args.FromHash(v)) } -func (f *TransferFromFunc) Post() wasmclient.Request { +func (f *TransferFromFunc) Post() wasmclient2.Request { f.args.Mandatory(ArgFrom) f.args.Mandatory(ArgTo) f.args.Mandatory(ArgTokenID) @@ -188,11 +190,11 @@ func (f *TransferFromFunc) Post() wasmclient.Request { ///////////////////////////// balanceOf ///////////////////////////// type BalanceOfView struct { - wasmclient.ClientView - args wasmclient.Arguments + wasmclient2.ClientView + args wasmclient2.Arguments } -func (f *BalanceOfView) Owner(v wasmclient.AgentID) { +func (f *BalanceOfView) Owner(v wasmclient2.AgentID) { f.args.Set(ArgOwner, f.args.FromAgentID(v)) } @@ -203,7 +205,7 @@ func (f *BalanceOfView) Call() BalanceOfResults { } type BalanceOfResults struct { - res wasmclient.Results + res wasmclient2.Results } func (r *BalanceOfResults) AmountExists() bool { @@ -217,11 +219,11 @@ func (r *BalanceOfResults) Amount() uint64 { ///////////////////////////// getApproved ///////////////////////////// type GetApprovedView struct { - wasmclient.ClientView - args wasmclient.Arguments + wasmclient2.ClientView + args wasmclient2.Arguments } -func (f *GetApprovedView) TokenID(v wasmclient.Hash) { +func (f *GetApprovedView) TokenID(v wasmclient2.Hash) { f.args.Set(ArgTokenID, f.args.FromHash(v)) } @@ -232,29 +234,29 @@ func (f *GetApprovedView) Call() GetApprovedResults { } type GetApprovedResults struct { - res wasmclient.Results + res wasmclient2.Results } func (r *GetApprovedResults) ApprovedExists() bool { return r.res.Exists(ResApproved) } -func (r *GetApprovedResults) Approved() wasmclient.AgentID { +func (r *GetApprovedResults) Approved() wasmclient2.AgentID { return r.res.ToAgentID(r.res.Get(ResApproved)) } ///////////////////////////// isApprovedForAll ///////////////////////////// type IsApprovedForAllView struct { - wasmclient.ClientView - args wasmclient.Arguments + wasmclient2.ClientView + args wasmclient2.Arguments } -func (f *IsApprovedForAllView) Operator(v wasmclient.AgentID) { +func (f *IsApprovedForAllView) Operator(v wasmclient2.AgentID) { f.args.Set(ArgOperator, f.args.FromAgentID(v)) } -func (f *IsApprovedForAllView) Owner(v wasmclient.AgentID) { +func (f *IsApprovedForAllView) Owner(v wasmclient2.AgentID) { f.args.Set(ArgOwner, f.args.FromAgentID(v)) } @@ -266,7 +268,7 @@ func (f *IsApprovedForAllView) Call() IsApprovedForAllResults { } type IsApprovedForAllResults struct { - res wasmclient.Results + res wasmclient2.Results } func (r *IsApprovedForAllResults) ApprovalExists() bool { @@ -280,7 +282,7 @@ func (r *IsApprovedForAllResults) Approval() bool { ///////////////////////////// name ///////////////////////////// type NameView struct { - wasmclient.ClientView + wasmclient2.ClientView } func (f *NameView) Call() NameResults { @@ -289,7 +291,7 @@ func (f *NameView) Call() NameResults { } type NameResults struct { - res wasmclient.Results + res wasmclient2.Results } func (r *NameResults) Name() string { @@ -299,11 +301,11 @@ func (r *NameResults) Name() string { ///////////////////////////// ownerOf ///////////////////////////// type OwnerOfView struct { - wasmclient.ClientView - args wasmclient.Arguments + wasmclient2.ClientView + args wasmclient2.Arguments } -func (f *OwnerOfView) TokenID(v wasmclient.Hash) { +func (f *OwnerOfView) TokenID(v wasmclient2.Hash) { f.args.Set(ArgTokenID, f.args.FromHash(v)) } @@ -314,21 +316,21 @@ func (f *OwnerOfView) Call() OwnerOfResults { } type OwnerOfResults struct { - res wasmclient.Results + res wasmclient2.Results } func (r *OwnerOfResults) OwnerExists() bool { return r.res.Exists(ResOwner) } -func (r *OwnerOfResults) Owner() wasmclient.AgentID { +func (r *OwnerOfResults) Owner() wasmclient2.AgentID { return r.res.ToAgentID(r.res.Get(ResOwner)) } ///////////////////////////// symbol ///////////////////////////// type SymbolView struct { - wasmclient.ClientView + wasmclient2.ClientView } func (f *SymbolView) Call() SymbolResults { @@ -337,7 +339,7 @@ func (f *SymbolView) Call() SymbolResults { } type SymbolResults struct { - res wasmclient.Results + res wasmclient2.Results } func (r *SymbolResults) Symbol() string { @@ -347,11 +349,11 @@ func (r *SymbolResults) Symbol() string { ///////////////////////////// tokenURI ///////////////////////////// type TokenURIView struct { - wasmclient.ClientView - args wasmclient.Arguments + wasmclient2.ClientView + args wasmclient2.Arguments } -func (f *TokenURIView) TokenID(v wasmclient.Hash) { +func (f *TokenURIView) TokenID(v wasmclient2.Hash) { f.args.Set(ArgTokenID, f.args.FromHash(v)) } @@ -362,7 +364,7 @@ func (f *TokenURIView) Call() TokenURIResults { } type TokenURIResults struct { - res wasmclient.Results + res wasmclient2.Results } func (r *TokenURIResults) TokenURIExists() bool { @@ -376,10 +378,10 @@ func (r *TokenURIResults) TokenURI() string { ///////////////////////////// Erc721Service ///////////////////////////// type Erc721Service struct { - wasmclient.Service + wasmclient2.Service } -func NewErc721Service(cl *wasmclient.ServiceClient, chainID string) (*Erc721Service, error) { +func NewErc721Service(cl *wasmclient2.ServiceClient, chainID string) (*Erc721Service, error) { s := &Erc721Service{} err := s.Service.Init(cl, chainID, 0xd967c216) return s, err diff --git a/contracts/wasm/erc721/test/erc721_test.go b/contracts/wasm/erc721/test/erc721_test.go index 188c5eb13a..81955c61e9 100644 --- a/contracts/wasm/erc721/test/erc721_test.go +++ b/contracts/wasm/erc721/test/erc721_test.go @@ -7,8 +7,8 @@ import ( "testing" "github.com/iotaledger/wasp/contracts/wasm/erc721/go/erc721" - "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" - "github.com/iotaledger/wasp/packages/vm/wasmsolo" + "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" + wasmsolo2 "github.com/iotaledger/wasp/packages/wasmvm/wasmsolo" "github.com/stretchr/testify/require" ) @@ -146,16 +146,16 @@ func TestTransferFrom(t *testing.T) { require.EqualValues(t, owner.ScAgentID(), currentOwner) } -func setup(t *testing.T) *wasmsolo.SoloContext { +func setup(t *testing.T) *wasmsolo2.SoloContext { init := erc721.ScFuncs.Init(nil) init.Params.Name().SetValue("My Valuable NFT") init.Params.Symbol().SetValue("MVNFT") - ctx := wasmsolo.NewSoloContext(t, erc721.ScName, erc721.OnLoad, init.Func) + ctx := wasmsolo2.NewSoloContext(t, erc721.ScName, erc721.OnLoad, init.Func) require.NoError(t, ctx.Err) return ctx } -func approve(ctx *wasmsolo.SoloContext, owner, approved *wasmsolo.SoloAgent, tokenID wasmtypes.ScHash) { +func approve(ctx *wasmsolo2.SoloContext, owner, approved *wasmsolo2.SoloAgent, tokenID wasmtypes.ScHash) { f := erc721.ScFuncs.Approve(ctx.Sign(owner)) if approved != nil { f.Params.Approved().SetValue(approved.ScAgentID()) @@ -164,7 +164,7 @@ func approve(ctx *wasmsolo.SoloContext, owner, approved *wasmsolo.SoloAgent, tok f.Func.TransferIotas(1).Post() } -func getApproved(t *testing.T, ctx *wasmsolo.SoloContext, tokenID wasmtypes.ScHash) *wasmtypes.ScAgentID { +func getApproved(t *testing.T, ctx *wasmsolo2.SoloContext, tokenID wasmtypes.ScHash) *wasmtypes.ScAgentID { v := erc721.ScFuncs.GetApproved(ctx) v.Params.TokenID().SetValue(tokenID) v.Func.Call() @@ -177,7 +177,7 @@ func getApproved(t *testing.T, ctx *wasmsolo.SoloContext, tokenID wasmtypes.ScHa return &ret } -func isApprovedForAll(t *testing.T, ctx *wasmsolo.SoloContext, owner, friend *wasmsolo.SoloAgent) bool { +func isApprovedForAll(t *testing.T, ctx *wasmsolo2.SoloContext, owner, friend *wasmsolo2.SoloAgent) bool { v := erc721.ScFuncs.IsApprovedForAll(ctx) v.Params.Owner().SetValue(owner.ScAgentID()) v.Params.Operator().SetValue(friend.ScAgentID()) @@ -186,13 +186,13 @@ func isApprovedForAll(t *testing.T, ctx *wasmsolo.SoloContext, owner, friend *wa return v.Results.Approval().Value() } -func mint(ctx *wasmsolo.SoloContext, owner *wasmsolo.SoloAgent, tokenID wasmtypes.ScHash) { +func mint(ctx *wasmsolo2.SoloContext, owner *wasmsolo2.SoloAgent, tokenID wasmtypes.ScHash) { f := erc721.ScFuncs.Mint(ctx.Sign(owner)) f.Params.TokenID().SetValue(tokenID) f.Func.TransferIotas(1).Post() } -func ownerOf(t *testing.T, ctx *wasmsolo.SoloContext, tokenID wasmtypes.ScHash) wasmtypes.ScAgentID { +func ownerOf(t *testing.T, ctx *wasmsolo2.SoloContext, tokenID wasmtypes.ScHash) wasmtypes.ScAgentID { v := erc721.ScFuncs.OwnerOf(ctx) v.Params.TokenID().SetValue(tokenID) v.Func.Call() @@ -200,14 +200,14 @@ func ownerOf(t *testing.T, ctx *wasmsolo.SoloContext, tokenID wasmtypes.ScHash) return v.Results.Owner().Value() } -func setApprovalForAll(ctx *wasmsolo.SoloContext, owner, operator *wasmsolo.SoloAgent, approval bool) { +func setApprovalForAll(ctx *wasmsolo2.SoloContext, owner, operator *wasmsolo2.SoloAgent, approval bool) { f := erc721.ScFuncs.SetApprovalForAll(ctx.Sign(owner)) f.Params.Operator().SetValue(operator.ScAgentID()) f.Params.Approval().SetValue(approval) f.Func.TransferIotas(1).Post() } -func transferFrom(ctx *wasmsolo.SoloContext, sender, from, to *wasmsolo.SoloAgent, tokenID wasmtypes.ScHash) { +func transferFrom(ctx *wasmsolo2.SoloContext, sender, from, to *wasmsolo2.SoloAgent, tokenID wasmtypes.ScHash) { f := erc721.ScFuncs.TransferFrom(ctx.Sign(sender)) f.Params.From().SetValue(from.ScAgentID()) f.Params.To().SetValue(to.ScAgentID()) diff --git a/contracts/wasm/fairauction/Cargo.toml b/contracts/wasm/fairauction/Cargo.toml index b9fd6aa045..aab5ba9388 100644 --- a/contracts/wasm/fairauction/Cargo.toml +++ b/contracts/wasm/fairauction/Cargo.toml @@ -17,7 +17,7 @@ crate-type = ["cdylib", "rlib"] default = ["console_error_panic_hook"] [dependencies] -wasmlib = { path = "../../../packages/vm/wasmlib" } +wasmlib = { path = "../../../wasmvm/wasmlib" } #wasmlib = { git = "https://github.com/iotaledger/wasp", branch = "develop" } # The `console_error_panic_hook` crate provides better debugging of panics by diff --git a/contracts/wasm/fairauction/go/fairauction/consts.go b/contracts/wasm/fairauction/go/fairauction/consts.go index 81f6323d4b..e12f2d0e46 100644 --- a/contracts/wasm/fairauction/go/fairauction/consts.go +++ b/contracts/wasm/fairauction/go/fairauction/consts.go @@ -7,7 +7,7 @@ package fairauction -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" +import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" const ( ScName = "fairauction" diff --git a/contracts/wasm/fairauction/go/fairauction/contract.go b/contracts/wasm/fairauction/go/fairauction/contract.go index 3336b197cd..b6c5708d27 100644 --- a/contracts/wasm/fairauction/go/fairauction/contract.go +++ b/contracts/wasm/fairauction/go/fairauction/contract.go @@ -7,7 +7,7 @@ package fairauction -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" +import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib" type FinalizeAuctionCall struct { Func *wasmlib.ScFunc diff --git a/contracts/wasm/fairauction/go/fairauction/fairauction.go b/contracts/wasm/fairauction/go/fairauction/fairauction.go index 26bf25fc9c..a492275215 100644 --- a/contracts/wasm/fairauction/go/fairauction/fairauction.go +++ b/contracts/wasm/fairauction/go/fairauction/fairauction.go @@ -4,8 +4,8 @@ package fairauction import ( - "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" - "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" + "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib" + "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" ) const ( diff --git a/contracts/wasm/fairauction/go/fairauction/lib.go b/contracts/wasm/fairauction/go/fairauction/lib.go index d9b2220171..62158cfe2d 100644 --- a/contracts/wasm/fairauction/go/fairauction/lib.go +++ b/contracts/wasm/fairauction/go/fairauction/lib.go @@ -7,7 +7,7 @@ package fairauction -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" +import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib" func OnLoad() { exports := wasmlib.NewScExports() diff --git a/contracts/wasm/fairauction/go/fairauction/params.go b/contracts/wasm/fairauction/go/fairauction/params.go index 269c62b4af..78a1b48b50 100644 --- a/contracts/wasm/fairauction/go/fairauction/params.go +++ b/contracts/wasm/fairauction/go/fairauction/params.go @@ -7,7 +7,7 @@ package fairauction -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" +import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" type ImmutableFinalizeAuctionParams struct { proxy wasmtypes.Proxy diff --git a/contracts/wasm/fairauction/go/fairauction/results.go b/contracts/wasm/fairauction/go/fairauction/results.go index 52d73fbc92..854c928caa 100644 --- a/contracts/wasm/fairauction/go/fairauction/results.go +++ b/contracts/wasm/fairauction/go/fairauction/results.go @@ -7,7 +7,7 @@ package fairauction -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" +import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" type ImmutableGetInfoResults struct { proxy wasmtypes.Proxy diff --git a/contracts/wasm/fairauction/go/fairauction/state.go b/contracts/wasm/fairauction/go/fairauction/state.go index 07c752484f..93d62d25ff 100644 --- a/contracts/wasm/fairauction/go/fairauction/state.go +++ b/contracts/wasm/fairauction/go/fairauction/state.go @@ -7,7 +7,7 @@ package fairauction -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" +import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" type MapColorToImmutableAuction struct { proxy wasmtypes.Proxy diff --git a/contracts/wasm/fairauction/go/fairauction/structs.go b/contracts/wasm/fairauction/go/fairauction/structs.go index 1d36eb8c26..d7ef0aa8d7 100644 --- a/contracts/wasm/fairauction/go/fairauction/structs.go +++ b/contracts/wasm/fairauction/go/fairauction/structs.go @@ -7,7 +7,7 @@ package fairauction -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" +import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" type Auction struct { Color wasmtypes.ScColor // color of tokens for sale diff --git a/contracts/wasm/fairauction/go/fairauction/typedefs.go b/contracts/wasm/fairauction/go/fairauction/typedefs.go index e399e4cdf4..35db63cd4b 100644 --- a/contracts/wasm/fairauction/go/fairauction/typedefs.go +++ b/contracts/wasm/fairauction/go/fairauction/typedefs.go @@ -7,7 +7,7 @@ package fairauction -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" +import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" type ArrayOfImmutableAgentID struct { proxy wasmtypes.Proxy diff --git a/contracts/wasm/fairauction/test/fairauction_test.go b/contracts/wasm/fairauction/test/fairauction_test.go index b2bef5d2fa..b95856dd53 100644 --- a/contracts/wasm/fairauction/test/fairauction_test.go +++ b/contracts/wasm/fairauction/test/fairauction_test.go @@ -9,18 +9,18 @@ import ( "github.com/iotaledger/wasp/contracts/wasm/fairauction/go/fairauction" "github.com/iotaledger/wasp/packages/solo" - "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" - "github.com/iotaledger/wasp/packages/vm/wasmsolo" + "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" + wasmsolo2 "github.com/iotaledger/wasp/packages/wasmvm/wasmsolo" "github.com/stretchr/testify/require" ) var ( - auctioneer *wasmsolo.SoloAgent + auctioneer *wasmsolo2.SoloAgent tokenColor wasmtypes.ScColor ) -func startAuction(t *testing.T) *wasmsolo.SoloContext { - ctx := wasmsolo.NewSoloContext(t, fairauction.ScName, fairauction.OnLoad) +func startAuction(t *testing.T) *wasmsolo2.SoloContext { + ctx := wasmsolo2.NewSoloContext(t, fairauction.ScName, fairauction.OnLoad) // set up auctioneer account and mint some tokens to auction off auctioneer = ctx.NewSoloAgent() @@ -43,7 +43,7 @@ func startAuction(t *testing.T) *wasmsolo.SoloContext { } func TestDeploy(t *testing.T) { - ctx := wasmsolo.NewSoloContext(t, fairauction.ScName, fairauction.OnLoad) + ctx := wasmsolo2.NewSoloContext(t, fairauction.ScName, fairauction.OnLoad) require.NoError(t, ctx.ContractExists(fairauction.ScName)) } diff --git a/contracts/wasm/fairroulette/Cargo.toml b/contracts/wasm/fairroulette/Cargo.toml index 101c6afcdc..bef9b6713e 100644 --- a/contracts/wasm/fairroulette/Cargo.toml +++ b/contracts/wasm/fairroulette/Cargo.toml @@ -17,7 +17,7 @@ crate-type = ["cdylib", "rlib"] default = ["console_error_panic_hook"] [dependencies] -wasmlib = { path = "../../../packages/vm/wasmlib" } +wasmlib = { path = "../../../wasmvm/wasmlib" } #wasmlib = { git = "https://github.com/iotaledger/wasp", branch = "develop" } # The `console_error_panic_hook` crate provides better debugging of panics by diff --git a/contracts/wasm/fairroulette/go/fairroulette/consts.go b/contracts/wasm/fairroulette/go/fairroulette/consts.go index 6a10f04f91..2f6e6ab67e 100644 --- a/contracts/wasm/fairroulette/go/fairroulette/consts.go +++ b/contracts/wasm/fairroulette/go/fairroulette/consts.go @@ -7,7 +7,7 @@ package fairroulette -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" +import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" const ( ScName = "fairroulette" diff --git a/contracts/wasm/fairroulette/go/fairroulette/contract.go b/contracts/wasm/fairroulette/go/fairroulette/contract.go index bcd7a7643d..2a3f301d53 100644 --- a/contracts/wasm/fairroulette/go/fairroulette/contract.go +++ b/contracts/wasm/fairroulette/go/fairroulette/contract.go @@ -7,7 +7,7 @@ package fairroulette -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" +import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib" type ForcePayoutCall struct { Func *wasmlib.ScFunc diff --git a/contracts/wasm/fairroulette/go/fairroulette/events.go b/contracts/wasm/fairroulette/go/fairroulette/events.go index 6f05c31d77..f843b9e30b 100644 --- a/contracts/wasm/fairroulette/go/fairroulette/events.go +++ b/contracts/wasm/fairroulette/go/fairroulette/events.go @@ -8,8 +8,8 @@ package fairroulette import ( - "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" - "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" + "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib" + "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" ) type FairRouletteEvents struct{} diff --git a/contracts/wasm/fairroulette/go/fairroulette/fairroulette.go b/contracts/wasm/fairroulette/go/fairroulette/fairroulette.go index 5ed3739a45..75f55366f7 100644 --- a/contracts/wasm/fairroulette/go/fairroulette/fairroulette.go +++ b/contracts/wasm/fairroulette/go/fairroulette/fairroulette.go @@ -10,8 +10,8 @@ package fairroulette import ( - "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" - "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" + "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib" + "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" ) // Define some default configuration parameters. diff --git a/contracts/wasm/fairroulette/go/fairroulette/lib.go b/contracts/wasm/fairroulette/go/fairroulette/lib.go index 3478e30260..6ff79e077a 100644 --- a/contracts/wasm/fairroulette/go/fairroulette/lib.go +++ b/contracts/wasm/fairroulette/go/fairroulette/lib.go @@ -7,7 +7,7 @@ package fairroulette -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" +import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib" func OnLoad() { exports := wasmlib.NewScExports() diff --git a/contracts/wasm/fairroulette/go/fairroulette/params.go b/contracts/wasm/fairroulette/go/fairroulette/params.go index 6fc42edd48..7437bbbfd4 100644 --- a/contracts/wasm/fairroulette/go/fairroulette/params.go +++ b/contracts/wasm/fairroulette/go/fairroulette/params.go @@ -7,7 +7,7 @@ package fairroulette -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" +import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" type ImmutablePlaceBetParams struct { proxy wasmtypes.Proxy diff --git a/contracts/wasm/fairroulette/go/fairroulette/results.go b/contracts/wasm/fairroulette/go/fairroulette/results.go index df04d86849..8eb16d8b00 100644 --- a/contracts/wasm/fairroulette/go/fairroulette/results.go +++ b/contracts/wasm/fairroulette/go/fairroulette/results.go @@ -7,7 +7,7 @@ package fairroulette -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" +import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" type ImmutableLastWinningNumberResults struct { proxy wasmtypes.Proxy diff --git a/contracts/wasm/fairroulette/go/fairroulette/state.go b/contracts/wasm/fairroulette/go/fairroulette/state.go index ec31dee948..aa2610aadc 100644 --- a/contracts/wasm/fairroulette/go/fairroulette/state.go +++ b/contracts/wasm/fairroulette/go/fairroulette/state.go @@ -7,7 +7,7 @@ package fairroulette -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" +import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" type ArrayOfImmutableBet struct { proxy wasmtypes.Proxy diff --git a/contracts/wasm/fairroulette/go/fairroulette/structs.go b/contracts/wasm/fairroulette/go/fairroulette/structs.go index d130221353..f834c412b4 100644 --- a/contracts/wasm/fairroulette/go/fairroulette/structs.go +++ b/contracts/wasm/fairroulette/go/fairroulette/structs.go @@ -7,7 +7,7 @@ package fairroulette -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" +import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" type Bet struct { Amount uint64 diff --git a/contracts/wasm/fairroulette/test/fairroulette_test.go b/contracts/wasm/fairroulette/test/fairroulette_test.go index 09b45e53d5..3c7b52d9ea 100644 --- a/contracts/wasm/fairroulette/test/fairroulette_test.go +++ b/contracts/wasm/fairroulette/test/fairroulette_test.go @@ -8,12 +8,12 @@ import ( "time" "github.com/iotaledger/wasp/contracts/wasm/fairroulette/go/fairroulette" - "github.com/iotaledger/wasp/packages/vm/wasmsolo" + wasmsolo2 "github.com/iotaledger/wasp/packages/wasmvm/wasmsolo" "github.com/stretchr/testify/require" ) -func setupTest(t *testing.T) *wasmsolo.SoloContext { - return wasmsolo.NewSoloContext(t, fairroulette.ScName, fairroulette.OnLoad) +func setupTest(t *testing.T) *wasmsolo2.SoloContext { + return wasmsolo2.NewSoloContext(t, fairroulette.ScName, fairroulette.OnLoad) } func TestDeploy(t *testing.T) { @@ -23,7 +23,7 @@ func TestDeploy(t *testing.T) { func TestBets(t *testing.T) { ctx := setupTest(t) - var better [10]*wasmsolo.SoloAgent + var better [10]*wasmsolo2.SoloAgent for i := 0; i < 10; i++ { better[i] = ctx.NewSoloAgent() placeBet := fairroulette.ScFuncs.PlaceBet(ctx.Sign(better[i])) diff --git a/contracts/wasm/helloworld/Cargo.toml b/contracts/wasm/helloworld/Cargo.toml index 5969d1d7b0..902ece4b06 100644 --- a/contracts/wasm/helloworld/Cargo.toml +++ b/contracts/wasm/helloworld/Cargo.toml @@ -17,7 +17,7 @@ crate-type = ["cdylib", "rlib"] default = ["console_error_panic_hook"] [dependencies] -wasmlib = { path = "../../../packages/vm/wasmlib" } +wasmlib = { path = "../../../wasmvm/wasmlib" } #wasmlib = { git = "https://github.com/iotaledger/wasp", branch = "develop" } # The `console_error_panic_hook` crate provides better debugging of panics by diff --git a/contracts/wasm/helloworld/go/helloworld/consts.go b/contracts/wasm/helloworld/go/helloworld/consts.go index afc4bb4101..dc6ce2fffe 100644 --- a/contracts/wasm/helloworld/go/helloworld/consts.go +++ b/contracts/wasm/helloworld/go/helloworld/consts.go @@ -7,7 +7,7 @@ package helloworld -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" +import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" const ( ScName = "helloworld" diff --git a/contracts/wasm/helloworld/go/helloworld/contract.go b/contracts/wasm/helloworld/go/helloworld/contract.go index dad20fabb0..ff7fef5cdf 100644 --- a/contracts/wasm/helloworld/go/helloworld/contract.go +++ b/contracts/wasm/helloworld/go/helloworld/contract.go @@ -7,7 +7,7 @@ package helloworld -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" +import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib" type HelloWorldCall struct { Func *wasmlib.ScFunc diff --git a/contracts/wasm/helloworld/go/helloworld/helloworld.go b/contracts/wasm/helloworld/go/helloworld/helloworld.go index 8556be3915..fd4681ad1f 100644 --- a/contracts/wasm/helloworld/go/helloworld/helloworld.go +++ b/contracts/wasm/helloworld/go/helloworld/helloworld.go @@ -4,7 +4,7 @@ package helloworld import ( - "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" + "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib" ) //nolint:unparam diff --git a/contracts/wasm/helloworld/go/helloworld/lib.go b/contracts/wasm/helloworld/go/helloworld/lib.go index a8909c358b..4a56de8f32 100644 --- a/contracts/wasm/helloworld/go/helloworld/lib.go +++ b/contracts/wasm/helloworld/go/helloworld/lib.go @@ -7,7 +7,7 @@ package helloworld -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" +import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib" func OnLoad() { exports := wasmlib.NewScExports() diff --git a/contracts/wasm/helloworld/go/helloworld/results.go b/contracts/wasm/helloworld/go/helloworld/results.go index eb63b45d11..8dd25a8eec 100644 --- a/contracts/wasm/helloworld/go/helloworld/results.go +++ b/contracts/wasm/helloworld/go/helloworld/results.go @@ -7,7 +7,7 @@ package helloworld -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" +import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" type ImmutableGetHelloWorldResults struct { proxy wasmtypes.Proxy diff --git a/contracts/wasm/helloworld/go/helloworld/state.go b/contracts/wasm/helloworld/go/helloworld/state.go index 7490209793..bed302d0a9 100644 --- a/contracts/wasm/helloworld/go/helloworld/state.go +++ b/contracts/wasm/helloworld/go/helloworld/state.go @@ -7,7 +7,7 @@ package helloworld -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" +import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" type ImmutableHelloWorldState struct { proxy wasmtypes.Proxy diff --git a/contracts/wasm/helloworld/test/helloworld_test.go b/contracts/wasm/helloworld/test/helloworld_test.go index c18c9ed42c..e385fddb4b 100644 --- a/contracts/wasm/helloworld/test/helloworld_test.go +++ b/contracts/wasm/helloworld/test/helloworld_test.go @@ -7,7 +7,7 @@ import ( "testing" "github.com/iotaledger/wasp/contracts/wasm/helloworld/go/helloworld" - "github.com/iotaledger/wasp/packages/vm/wasmsolo" + "github.com/iotaledger/wasp/packages/wasmvm/wasmsolo" "github.com/stretchr/testify/require" ) diff --git a/contracts/wasm/inccounter/Cargo.toml b/contracts/wasm/inccounter/Cargo.toml index 85cf6dbe20..acf50c84ac 100644 --- a/contracts/wasm/inccounter/Cargo.toml +++ b/contracts/wasm/inccounter/Cargo.toml @@ -17,7 +17,7 @@ crate-type = ["cdylib", "rlib"] default = ["console_error_panic_hook"] [dependencies] -wasmlib = { path = "../../../packages/vm/wasmlib" } +wasmlib = { path = "../../../wasmvm/wasmlib" } #wasmlib = { git = "https://github.com/iotaledger/wasp", branch = "develop" } # The `console_error_panic_hook` crate provides better debugging of panics by diff --git a/contracts/wasm/inccounter/go/inccounter/consts.go b/contracts/wasm/inccounter/go/inccounter/consts.go index cdf72e5dae..99609c1564 100644 --- a/contracts/wasm/inccounter/go/inccounter/consts.go +++ b/contracts/wasm/inccounter/go/inccounter/consts.go @@ -7,7 +7,7 @@ package inccounter -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" +import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" const ( ScName = "inccounter" diff --git a/contracts/wasm/inccounter/go/inccounter/contract.go b/contracts/wasm/inccounter/go/inccounter/contract.go index 29ec2b9e45..3519df24e2 100644 --- a/contracts/wasm/inccounter/go/inccounter/contract.go +++ b/contracts/wasm/inccounter/go/inccounter/contract.go @@ -7,7 +7,7 @@ package inccounter -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" +import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib" type CallIncrementCall struct { Func *wasmlib.ScFunc diff --git a/contracts/wasm/inccounter/go/inccounter/inccounter.go b/contracts/wasm/inccounter/go/inccounter/inccounter.go index 88e97dc386..b0d1e5ff93 100644 --- a/contracts/wasm/inccounter/go/inccounter/inccounter.go +++ b/contracts/wasm/inccounter/go/inccounter/inccounter.go @@ -6,8 +6,8 @@ package inccounter import ( "strconv" - "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" - "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" + "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib" + "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" ) const hex = "0123456789abcdef" diff --git a/contracts/wasm/inccounter/go/inccounter/lib.go b/contracts/wasm/inccounter/go/inccounter/lib.go index 1efabe8993..0923259dbc 100644 --- a/contracts/wasm/inccounter/go/inccounter/lib.go +++ b/contracts/wasm/inccounter/go/inccounter/lib.go @@ -7,7 +7,7 @@ package inccounter -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" +import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib" func OnLoad() { exports := wasmlib.NewScExports() diff --git a/contracts/wasm/inccounter/go/inccounter/params.go b/contracts/wasm/inccounter/go/inccounter/params.go index 42df13c5bd..38c4804e4e 100644 --- a/contracts/wasm/inccounter/go/inccounter/params.go +++ b/contracts/wasm/inccounter/go/inccounter/params.go @@ -7,7 +7,7 @@ package inccounter -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" +import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" type ImmutableIncrementWithDelayParams struct { proxy wasmtypes.Proxy diff --git a/contracts/wasm/inccounter/go/inccounter/results.go b/contracts/wasm/inccounter/go/inccounter/results.go index 5f3aaa7d2e..957a267f3d 100644 --- a/contracts/wasm/inccounter/go/inccounter/results.go +++ b/contracts/wasm/inccounter/go/inccounter/results.go @@ -7,7 +7,7 @@ package inccounter -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" +import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" type ImmutableGetCounterResults struct { proxy wasmtypes.Proxy diff --git a/contracts/wasm/inccounter/go/inccounter/state.go b/contracts/wasm/inccounter/go/inccounter/state.go index d22480973f..5bb3c642ab 100644 --- a/contracts/wasm/inccounter/go/inccounter/state.go +++ b/contracts/wasm/inccounter/go/inccounter/state.go @@ -7,7 +7,7 @@ package inccounter -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" +import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" type ImmutableIncCounterState struct { proxy wasmtypes.Proxy diff --git a/contracts/wasm/inccounter/test/inccounter_test.go b/contracts/wasm/inccounter/test/inccounter_test.go index cde0dbf0d8..e8f11c7249 100644 --- a/contracts/wasm/inccounter/test/inccounter_test.go +++ b/contracts/wasm/inccounter/test/inccounter_test.go @@ -10,7 +10,7 @@ import ( "github.com/iotaledger/wasp/contracts/wasm/inccounter/go/inccounter" "github.com/iotaledger/wasp/packages/vm/wasmhost" - "github.com/iotaledger/wasp/packages/vm/wasmsolo" + "github.com/iotaledger/wasp/packages/wasmvm/wasmsolo" "github.com/stretchr/testify/require" ) diff --git a/contracts/wasm/testcore/Cargo.toml b/contracts/wasm/testcore/Cargo.toml index 05b874a9e1..4f0ce90105 100644 --- a/contracts/wasm/testcore/Cargo.toml +++ b/contracts/wasm/testcore/Cargo.toml @@ -17,7 +17,7 @@ crate-type = ["cdylib", "rlib"] default = ["console_error_panic_hook"] [dependencies] -wasmlib = { path = "../../../packages/vm/wasmlib" } +wasmlib = { path = "../../../wasmvm/wasmlib" } #wasmlib = { git = "https://github.com/iotaledger/wasp", branch = "develop" } # The `console_error_panic_hook` crate provides better debugging of panics by diff --git a/contracts/wasm/testcore/go/testcore/consts.go b/contracts/wasm/testcore/go/testcore/consts.go index 6fd5a600de..f237534658 100644 --- a/contracts/wasm/testcore/go/testcore/consts.go +++ b/contracts/wasm/testcore/go/testcore/consts.go @@ -7,7 +7,7 @@ package testcore -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" +import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" const ( ScName = "testcore" diff --git a/contracts/wasm/testcore/go/testcore/contract.go b/contracts/wasm/testcore/go/testcore/contract.go index 57c0844acf..6b701d0e06 100644 --- a/contracts/wasm/testcore/go/testcore/contract.go +++ b/contracts/wasm/testcore/go/testcore/contract.go @@ -7,7 +7,7 @@ package testcore -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" +import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib" type CallOnChainCall struct { Func *wasmlib.ScFunc diff --git a/contracts/wasm/testcore/go/testcore/lib.go b/contracts/wasm/testcore/go/testcore/lib.go index eceeccdbed..4f481bc25c 100644 --- a/contracts/wasm/testcore/go/testcore/lib.go +++ b/contracts/wasm/testcore/go/testcore/lib.go @@ -8,7 +8,7 @@ //nolint:dupl package testcore -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" +import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib" func OnLoad() { exports := wasmlib.NewScExports() diff --git a/contracts/wasm/testcore/go/testcore/params.go b/contracts/wasm/testcore/go/testcore/params.go index 865ad90bcc..2d62400191 100644 --- a/contracts/wasm/testcore/go/testcore/params.go +++ b/contracts/wasm/testcore/go/testcore/params.go @@ -7,7 +7,7 @@ package testcore -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" +import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" type ImmutableCallOnChainParams struct { proxy wasmtypes.Proxy diff --git a/contracts/wasm/testcore/go/testcore/results.go b/contracts/wasm/testcore/go/testcore/results.go index 3a172984fd..0c16fb42a9 100644 --- a/contracts/wasm/testcore/go/testcore/results.go +++ b/contracts/wasm/testcore/go/testcore/results.go @@ -7,7 +7,7 @@ package testcore -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" +import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" type ImmutableCallOnChainResults struct { proxy wasmtypes.Proxy diff --git a/contracts/wasm/testcore/go/testcore/state.go b/contracts/wasm/testcore/go/testcore/state.go index 173253e65d..f9836737c7 100644 --- a/contracts/wasm/testcore/go/testcore/state.go +++ b/contracts/wasm/testcore/go/testcore/state.go @@ -7,7 +7,7 @@ package testcore -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" +import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" type ImmutableTestCoreState struct { proxy wasmtypes.Proxy diff --git a/contracts/wasm/testcore/go/testcore/testcore.go b/contracts/wasm/testcore/go/testcore/testcore.go index 1bb58c5470..9471f0a815 100644 --- a/contracts/wasm/testcore/go/testcore/testcore.go +++ b/contracts/wasm/testcore/go/testcore/testcore.go @@ -5,10 +5,10 @@ package testcore import ( - "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" - "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/coreaccounts" - "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/coregovernance" - "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" + "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib" + "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/coreaccounts" + "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/coregovernance" + "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" ) const ( diff --git a/contracts/wasm/testcore/test/2chains_test.go b/contracts/wasm/testcore/test/2chains_test.go index 633808182a..ec16f3eeea 100644 --- a/contracts/wasm/testcore/test/2chains_test.go +++ b/contracts/wasm/testcore/test/2chains_test.go @@ -6,7 +6,7 @@ import ( "github.com/iotaledger/wasp/contracts/wasm/testcore/go/testcore" "github.com/iotaledger/wasp/packages/solo" "github.com/iotaledger/wasp/packages/vm/core" - "github.com/iotaledger/wasp/packages/vm/wasmsolo" + wasmsolo2 "github.com/iotaledger/wasp/packages/wasmvm/wasmsolo" "github.com/stretchr/testify/require" ) @@ -14,13 +14,13 @@ func Test2Chains(t *testing.T) { run2(t, func(t *testing.T, w bool) { core.PrintWellKnownHnames() - chain1 := wasmsolo.StartChain(t, "chain1") + chain1 := wasmsolo2.StartChain(t, "chain1") chain1.CheckAccountLedger() - chain2 := wasmsolo.StartChain(t, "chain2", chain1.Env) + chain2 := wasmsolo2.StartChain(t, "chain2", chain1.Env) chain2.CheckAccountLedger() - user := wasmsolo.NewSoloAgent(chain1.Env) + user := wasmsolo2.NewSoloAgent(chain1.Env) require.EqualValues(t, solo.Saldo, user.Balance()) ctx1 := deployTestCoreOnChain(t, w, chain1, nil) diff --git a/contracts/wasm/testcore/test/concurrency_test.go b/contracts/wasm/testcore/test/concurrency_test.go index 2d410b19ab..7a7d4212f1 100644 --- a/contracts/wasm/testcore/test/concurrency_test.go +++ b/contracts/wasm/testcore/test/concurrency_test.go @@ -8,7 +8,7 @@ import ( "github.com/iotaledger/wasp/contracts/wasm/testcore/go/testcore" "github.com/iotaledger/wasp/packages/kv/codec" "github.com/iotaledger/wasp/packages/solo" - "github.com/iotaledger/wasp/packages/vm/wasmsolo" + wasmsolo2 "github.com/iotaledger/wasp/packages/wasmvm/wasmsolo" "github.com/stretchr/testify/require" ) @@ -33,7 +33,7 @@ func TestCounter(t *testing.T) { func TestSynchronous(t *testing.T) { run2(t, func(t *testing.T, w bool) { // TODO fails with 999 instead of 1000 at WaitForPendingRequests - if *wasmsolo.GoDebug || *wasmsolo.GoWasmEdge { + if *wasmsolo2.GoDebug || *wasmsolo2.GoWasmEdge { t.SkipNow() } ctx := deployTestCore(t, w) @@ -42,7 +42,7 @@ func TestSynchronous(t *testing.T) { f.Func.TransferIotas(1) repeats := []int{300, 100, 100, 100, 200, 100, 100} - if wasmsolo.SoloDebug { + if wasmsolo2.SoloDebug { for i := range repeats { repeats[i] /= 10 } @@ -89,7 +89,7 @@ func TestConcurrency(t *testing.T) { WithIotas(1) repeats := []int{300, 100, 100, 100, 200, 100, 100} - if wasmsolo.SoloDebug { + if wasmsolo2.SoloDebug { for i := range repeats { repeats[i] /= 10 } @@ -135,7 +135,7 @@ func TestConcurrency2(t *testing.T) { WithIotas(1) repeats := []int{300, 100, 100, 100, 200, 100, 100} - if wasmsolo.SoloDebug { + if wasmsolo2.SoloDebug { for i := range repeats { repeats[i] /= 10 } @@ -147,7 +147,7 @@ func TestConcurrency2(t *testing.T) { } chain := ctx.Chain - users := make([]*wasmsolo.SoloAgent, len(repeats)) + users := make([]*wasmsolo2.SoloAgent, len(repeats)) for r, n := range repeats { go func(r, n int) { users[r] = ctx.NewSoloAgent() @@ -185,7 +185,7 @@ func TestViewConcurrency(t *testing.T) { f.Func.TransferIotas(1).Post() times := 2000 - if wasmsolo.SoloDebug { + if wasmsolo2.SoloDebug { times /= 10 } diff --git a/contracts/wasm/testcore/test/init_fail_test.go b/contracts/wasm/testcore/test/init_fail_test.go index a39fdfcffa..03b543baad 100644 --- a/contracts/wasm/testcore/test/init_fail_test.go +++ b/contracts/wasm/testcore/test/init_fail_test.go @@ -5,7 +5,7 @@ import ( "github.com/iotaledger/wasp/contracts/wasm/testcore/go/testcore" "github.com/iotaledger/wasp/packages/vm/core" - "github.com/iotaledger/wasp/packages/vm/wasmsolo" + "github.com/iotaledger/wasp/packages/wasmvm/wasmsolo" "github.com/stretchr/testify/require" ) diff --git a/contracts/wasm/testcore/test/sandbox_panic_test.go b/contracts/wasm/testcore/test/sandbox_panic_test.go index 53208ffe5d..9a897ad579 100644 --- a/contracts/wasm/testcore/test/sandbox_panic_test.go +++ b/contracts/wasm/testcore/test/sandbox_panic_test.go @@ -6,7 +6,7 @@ import ( "github.com/iotaledger/wasp/contracts/wasm/testcore/go/testcore" "github.com/iotaledger/wasp/packages/vm/core/testcore/sbtests/sbtestsc" - "github.com/iotaledger/wasp/packages/vm/wasmsolo" + "github.com/iotaledger/wasp/packages/wasmvm/wasmsolo" "github.com/stretchr/testify/require" ) diff --git a/contracts/wasm/testcore/test/testcore_test.go b/contracts/wasm/testcore/test/testcore_test.go index eb6ad5f7ff..2a2cdd2145 100644 --- a/contracts/wasm/testcore/test/testcore_test.go +++ b/contracts/wasm/testcore/test/testcore_test.go @@ -8,21 +8,21 @@ import ( "github.com/iotaledger/wasp/packages/solo" "github.com/iotaledger/wasp/packages/util" "github.com/iotaledger/wasp/packages/vm/core/testcore/sbtests/sbtestsc" - "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" - "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/coreaccounts" - "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/coregovernance" - "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/coreroot" - "github.com/iotaledger/wasp/packages/vm/wasmsolo" + "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib" + "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/coreaccounts" + "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/coregovernance" + "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/coreroot" + wasmsolo2 "github.com/iotaledger/wasp/packages/wasmvm/wasmsolo" "github.com/stretchr/testify/require" ) -func deployTestCore(t *testing.T, runWasm bool, addCreator ...bool) *wasmsolo.SoloContext { - chain := wasmsolo.StartChain(t, "chain1") +func deployTestCore(t *testing.T, runWasm bool, addCreator ...bool) *wasmsolo2.SoloContext { + chain := wasmsolo2.StartChain(t, "chain1") - var creator *wasmsolo.SoloAgent + var creator *wasmsolo2.SoloAgent if len(addCreator) != 0 && addCreator[0] { - creator = wasmsolo.NewSoloAgent(chain.Env) - setDeployer(t, &wasmsolo.SoloContext{Chain: chain}, creator) + creator = wasmsolo2.NewSoloAgent(chain.Env) + setDeployer(t, &wasmsolo2.SoloContext{Chain: chain}, creator) } ctx := deployTestCoreOnChain(t, runWasm, chain, creator) @@ -30,12 +30,12 @@ func deployTestCore(t *testing.T, runWasm bool, addCreator ...bool) *wasmsolo.So return ctx } -func deployTestCoreOnChain(t *testing.T, runWasm bool, chain *solo.Chain, creator *wasmsolo.SoloAgent, init ...*wasmlib.ScInitFunc) *wasmsolo.SoloContext { +func deployTestCoreOnChain(t *testing.T, runWasm bool, chain *solo.Chain, creator *wasmsolo2.SoloAgent, init ...*wasmlib.ScInitFunc) *wasmsolo2.SoloContext { if runWasm { - return wasmsolo.NewSoloContextForChain(t, chain, creator, testcore.ScName, testcore.OnLoad, init...) + return wasmsolo2.NewSoloContextForChain(t, chain, creator, testcore.ScName, testcore.OnLoad, init...) } - return wasmsolo.NewSoloContextForNative(t, chain, creator, testcore.ScName, testcore.OnLoad, sbtestsc.Processor, init...) + return wasmsolo2.NewSoloContextForNative(t, chain, creator, testcore.ScName, testcore.OnLoad, sbtestsc.Processor, init...) } func run2(t *testing.T, test func(*testing.T, bool), skipWasm ...bool) { @@ -48,12 +48,12 @@ func run2(t *testing.T, test func(*testing.T, bool), skipWasm ...bool) { return } - saveGoDebug := *wasmsolo.GoDebug - saveGoWasm := *wasmsolo.GoWasm - saveTsWasm := *wasmsolo.TsWasm - *wasmsolo.GoDebug = false - *wasmsolo.GoWasm = false - *wasmsolo.TsWasm = false + saveGoDebug := *wasmsolo2.GoDebug + saveGoWasm := *wasmsolo2.GoWasm + saveTsWasm := *wasmsolo2.TsWasm + *wasmsolo2.GoDebug = false + *wasmsolo2.GoWasm = false + *wasmsolo2.TsWasm = false //exists, _ := util.ExistsFilePath("../pkg/testcore_bg.wasm") //if exists { @@ -65,12 +65,12 @@ func run2(t *testing.T, test func(*testing.T, bool), skipWasm ...bool) { exists, _ := util.ExistsFilePath("../go/pkg/testcore_go.wasm") if exists { - *wasmsolo.GoWasm = true + *wasmsolo2.GoWasm = true wasmlib.ConnectHost(nil) t.Run(fmt.Sprintf("run GO version of %s", t.Name()), func(t *testing.T) { test(t, true) }) - *wasmsolo.GoWasm = false + *wasmsolo2.GoWasm = false } //exists, _ = util.ExistsFilePath("../ts/pkg/testcore_ts.wasm") @@ -83,15 +83,15 @@ func run2(t *testing.T, test func(*testing.T, bool), skipWasm ...bool) { // *wasmsolo.TsWasm = false //} - *wasmsolo.GoDebug = true + *wasmsolo2.GoDebug = true wasmlib.ConnectHost(nil) t.Run(fmt.Sprintf("run GOVM version of %s", t.Name()), func(t *testing.T) { test(t, true) }) - *wasmsolo.GoDebug = saveGoDebug - *wasmsolo.GoWasm = saveGoWasm - *wasmsolo.TsWasm = saveTsWasm + *wasmsolo2.GoDebug = saveGoDebug + *wasmsolo2.GoWasm = saveGoWasm + *wasmsolo2.TsWasm = saveTsWasm } func TestDeployTestCore(t *testing.T) { @@ -110,7 +110,7 @@ func TestDeployTestCoreWithCreator(t *testing.T) { // chainAccountBalances checks the balance of the chain account and the total // balance of all accounts, taking any extra uploadWasm() into account -func chainAccountBalances(ctx *wasmsolo.SoloContext, w bool, chain, total uint64) { +func chainAccountBalances(ctx *wasmsolo2.SoloContext, w bool, chain, total uint64) { if w { // wasm setup takes 1 more iota than core setup due to uploadWasm() chain++ @@ -122,7 +122,7 @@ func chainAccountBalances(ctx *wasmsolo.SoloContext, w bool, chain, total uint64 // originatorBalanceReducedBy checks the balance of the originator address has // reduced by the given amount, taking any extra uploadWasm() into account -func originatorBalanceReducedBy(ctx *wasmsolo.SoloContext, w bool, minus uint64) { +func originatorBalanceReducedBy(ctx *wasmsolo2.SoloContext, w bool, minus uint64) { if w { // wasm setup takes 1 more iota than core setup due to uploadWasm() minus++ @@ -130,7 +130,7 @@ func originatorBalanceReducedBy(ctx *wasmsolo.SoloContext, w bool, minus uint64) ctx.Chain.Env.AssertAddressIotas(ctx.Chain.OriginatorAddress, solo.Saldo-solo.ChainDustThreshold-minus) } -func deposit(t *testing.T, ctx *wasmsolo.SoloContext, user, target *wasmsolo.SoloAgent, amount uint64) { +func deposit(t *testing.T, ctx *wasmsolo2.SoloContext, user, target *wasmsolo2.SoloAgent, amount uint64) { ctxAcc := ctx.SoloContextForCore(t, coreaccounts.ScName, coreaccounts.OnLoad) f := coreaccounts.ScFuncs.Deposit(ctxAcc.Sign(user)) if target != nil { @@ -140,7 +140,7 @@ func deposit(t *testing.T, ctx *wasmsolo.SoloContext, user, target *wasmsolo.Sol require.NoError(t, ctxAcc.Err) } -func setDeployer(t *testing.T, ctx *wasmsolo.SoloContext, deployer *wasmsolo.SoloAgent) { +func setDeployer(t *testing.T, ctx *wasmsolo2.SoloContext, deployer *wasmsolo2.SoloAgent) { ctxRoot := ctx.SoloContextForCore(t, coreroot.ScName, coreroot.OnLoad) f := coreroot.ScFuncs.GrantDeployPermission(ctxRoot) f.Params.Deployer().SetValue(deployer.ScAgentID()) @@ -148,7 +148,7 @@ func setDeployer(t *testing.T, ctx *wasmsolo.SoloContext, deployer *wasmsolo.Sol require.NoError(t, ctxRoot.Err) } -func setOwnerFee(t *testing.T, ctx *wasmsolo.SoloContext, amount int64) { +func setOwnerFee(t *testing.T, ctx *wasmsolo2.SoloContext, amount int64) { ctxGov := ctx.SoloContextForCore(t, coregovernance.ScName, coregovernance.OnLoad) f := coregovernance.ScFuncs.SetContractFee(ctxGov) f.Params.Hname().SetValue(testcore.HScName) @@ -157,7 +157,7 @@ func setOwnerFee(t *testing.T, ctx *wasmsolo.SoloContext, amount int64) { require.NoError(t, ctxGov.Err) } -func withdraw(t *testing.T, ctx *wasmsolo.SoloContext, user *wasmsolo.SoloAgent) { +func withdraw(t *testing.T, ctx *wasmsolo2.SoloContext, user *wasmsolo2.SoloAgent) { ctxAcc := ctx.SoloContextForCore(t, coreaccounts.ScName, coreaccounts.OnLoad) f := coreaccounts.ScFuncs.Withdraw(ctxAcc.Sign(user)) f.Func.TransferIotas(1).Post() diff --git a/contracts/wasm/testwasmlib/Cargo.toml b/contracts/wasm/testwasmlib/Cargo.toml index e789cadf3e..4cbe3477a5 100644 --- a/contracts/wasm/testwasmlib/Cargo.toml +++ b/contracts/wasm/testwasmlib/Cargo.toml @@ -17,7 +17,7 @@ crate-type = ["cdylib", "rlib"] default = ["console_error_panic_hook"] [dependencies] -wasmlib = { path = "../../../packages/vm/wasmlib" } +wasmlib = { path = "../../../wasmvm/wasmlib" } #wasmlib = { git = "https://github.com/iotaledger/wasp", branch = "develop" } console_error_panic_hook = { version = "0.1.6", optional = true } wee_alloc = { version = "0.4.5", optional = true } diff --git a/contracts/wasm/testwasmlib/go/testwasmlib/consts.go b/contracts/wasm/testwasmlib/go/testwasmlib/consts.go index 7b7791f441..3cf0b5ebdb 100644 --- a/contracts/wasm/testwasmlib/go/testwasmlib/consts.go +++ b/contracts/wasm/testwasmlib/go/testwasmlib/consts.go @@ -7,7 +7,7 @@ package testwasmlib -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" +import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" const ( ScName = "testwasmlib" diff --git a/contracts/wasm/testwasmlib/go/testwasmlib/contract.go b/contracts/wasm/testwasmlib/go/testwasmlib/contract.go index c3aec44cfb..d55f87ef83 100644 --- a/contracts/wasm/testwasmlib/go/testwasmlib/contract.go +++ b/contracts/wasm/testwasmlib/go/testwasmlib/contract.go @@ -7,7 +7,7 @@ package testwasmlib -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" +import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib" type ArrayAppendCall struct { Func *wasmlib.ScFunc diff --git a/contracts/wasm/testwasmlib/go/testwasmlib/events.go b/contracts/wasm/testwasmlib/go/testwasmlib/events.go index 72a21499f1..cfdd465887 100644 --- a/contracts/wasm/testwasmlib/go/testwasmlib/events.go +++ b/contracts/wasm/testwasmlib/go/testwasmlib/events.go @@ -8,8 +8,8 @@ package testwasmlib import ( - "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" - "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" + "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib" + "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" ) type TestWasmLibEvents struct{} diff --git a/contracts/wasm/testwasmlib/go/testwasmlib/lib.go b/contracts/wasm/testwasmlib/go/testwasmlib/lib.go index 889af2998e..93c3e9971f 100644 --- a/contracts/wasm/testwasmlib/go/testwasmlib/lib.go +++ b/contracts/wasm/testwasmlib/go/testwasmlib/lib.go @@ -7,7 +7,7 @@ package testwasmlib -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" +import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib" func OnLoad() { exports := wasmlib.NewScExports() diff --git a/contracts/wasm/testwasmlib/go/testwasmlib/params.go b/contracts/wasm/testwasmlib/go/testwasmlib/params.go index cefc6d0937..e2ad48c156 100644 --- a/contracts/wasm/testwasmlib/go/testwasmlib/params.go +++ b/contracts/wasm/testwasmlib/go/testwasmlib/params.go @@ -7,7 +7,7 @@ package testwasmlib -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" +import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" type ImmutableArrayAppendParams struct { proxy wasmtypes.Proxy diff --git a/contracts/wasm/testwasmlib/go/testwasmlib/results.go b/contracts/wasm/testwasmlib/go/testwasmlib/results.go index 7c05a07dbd..a7a1873708 100644 --- a/contracts/wasm/testwasmlib/go/testwasmlib/results.go +++ b/contracts/wasm/testwasmlib/go/testwasmlib/results.go @@ -7,7 +7,7 @@ package testwasmlib -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" +import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" type ImmutableArrayLengthResults struct { proxy wasmtypes.Proxy diff --git a/contracts/wasm/testwasmlib/go/testwasmlib/state.go b/contracts/wasm/testwasmlib/go/testwasmlib/state.go index 5e1f3ccf87..f34f244263 100644 --- a/contracts/wasm/testwasmlib/go/testwasmlib/state.go +++ b/contracts/wasm/testwasmlib/go/testwasmlib/state.go @@ -7,7 +7,7 @@ package testwasmlib -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" +import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" type MapStringToImmutableStringArray struct { proxy wasmtypes.Proxy diff --git a/contracts/wasm/testwasmlib/go/testwasmlib/structs.go b/contracts/wasm/testwasmlib/go/testwasmlib/structs.go index ac02c3738d..e80d181037 100644 --- a/contracts/wasm/testwasmlib/go/testwasmlib/structs.go +++ b/contracts/wasm/testwasmlib/go/testwasmlib/structs.go @@ -8,7 +8,7 @@ package testwasmlib import ( - "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" + "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" ) type CallRequest struct { diff --git a/contracts/wasm/testwasmlib/go/testwasmlib/testwasmlib.go b/contracts/wasm/testwasmlib/go/testwasmlib/testwasmlib.go index afda26d9d5..bcb79e674e 100644 --- a/contracts/wasm/testwasmlib/go/testwasmlib/testwasmlib.go +++ b/contracts/wasm/testwasmlib/go/testwasmlib/testwasmlib.go @@ -6,9 +6,9 @@ package testwasmlib import ( "bytes" - "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" - "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/coreblocklog" - "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" + "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib" + "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/coreblocklog" + "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" ) func funcArrayAppend(ctx wasmlib.ScFuncContext, f *ArrayAppendContext) { diff --git a/contracts/wasm/testwasmlib/go/testwasmlib/typedefs.go b/contracts/wasm/testwasmlib/go/testwasmlib/typedefs.go index e722b8184d..4aa38ecf2d 100644 --- a/contracts/wasm/testwasmlib/go/testwasmlib/typedefs.go +++ b/contracts/wasm/testwasmlib/go/testwasmlib/typedefs.go @@ -7,7 +7,7 @@ package testwasmlib -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" +import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" type ArrayOfImmutableString struct { proxy wasmtypes.Proxy diff --git a/contracts/wasm/testwasmlib/go/testwasmlibclient/events.go b/contracts/wasm/testwasmlib/go/testwasmlibclient/events.go index 6f7c526768..680d9171f8 100644 --- a/contracts/wasm/testwasmlib/go/testwasmlibclient/events.go +++ b/contracts/wasm/testwasmlib/go/testwasmlibclient/events.go @@ -7,7 +7,9 @@ package testwasmlibclient -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmclient" +import ( + wasmclient2 "github.com/iotaledger/wasp/packages/wasmvm/wasmlib/go/wasmclient" +) var testWasmLibHandlers = map[string]func(*TestWasmLibEvents, []string){ "testwasmlib.test": func(evt *TestWasmLibEvents, msg []string) { evt.onTestWasmLibTestThunk(msg) }, @@ -29,8 +31,8 @@ func (h *TestWasmLibEvents) OnTestWasmLibTest(handler func(e *EventTest)) { } type EventTest struct { - wasmclient.Event - Address wasmclient.Address + wasmclient2.Event + Address wasmclient2.Address Name string } diff --git a/contracts/wasm/testwasmlib/go/testwasmlibclient/service.go b/contracts/wasm/testwasmlib/go/testwasmlibclient/service.go index 0d5c0f2df8..767325e3a3 100644 --- a/contracts/wasm/testwasmlib/go/testwasmlibclient/service.go +++ b/contracts/wasm/testwasmlib/go/testwasmlibclient/service.go @@ -7,7 +7,9 @@ package testwasmlibclient -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmclient" +import ( + wasmclient2 "github.com/iotaledger/wasp/packages/wasmvm/wasmlib/go/wasmclient" +) const ( ArgAddress = "address" @@ -47,8 +49,8 @@ const ( ///////////////////////////// arrayAppend ///////////////////////////// type ArrayAppendFunc struct { - wasmclient.ClientFunc - args wasmclient.Arguments + wasmclient2.ClientFunc + args wasmclient2.Arguments } func (f *ArrayAppendFunc) Name(v string) { @@ -59,7 +61,7 @@ func (f *ArrayAppendFunc) Value(v string) { f.args.Set(ArgValue, f.args.FromString(v)) } -func (f *ArrayAppendFunc) Post() wasmclient.Request { +func (f *ArrayAppendFunc) Post() wasmclient2.Request { f.args.Mandatory(ArgName) f.args.Mandatory(ArgValue) return f.ClientFunc.Post(0x612f835f, &f.args) @@ -68,15 +70,15 @@ func (f *ArrayAppendFunc) Post() wasmclient.Request { ///////////////////////////// arrayClear ///////////////////////////// type ArrayClearFunc struct { - wasmclient.ClientFunc - args wasmclient.Arguments + wasmclient2.ClientFunc + args wasmclient2.Arguments } func (f *ArrayClearFunc) Name(v string) { f.args.Set(ArgName, f.args.FromString(v)) } -func (f *ArrayClearFunc) Post() wasmclient.Request { +func (f *ArrayClearFunc) Post() wasmclient2.Request { f.args.Mandatory(ArgName) return f.ClientFunc.Post(0x88021821, &f.args) } @@ -84,8 +86,8 @@ func (f *ArrayClearFunc) Post() wasmclient.Request { ///////////////////////////// arraySet ///////////////////////////// type ArraySetFunc struct { - wasmclient.ClientFunc - args wasmclient.Arguments + wasmclient2.ClientFunc + args wasmclient2.Arguments } func (f *ArraySetFunc) Index(v uint32) { @@ -100,7 +102,7 @@ func (f *ArraySetFunc) Value(v string) { f.args.Set(ArgValue, f.args.FromString(v)) } -func (f *ArraySetFunc) Post() wasmclient.Request { +func (f *ArraySetFunc) Post() wasmclient2.Request { f.args.Mandatory(ArgIndex) f.args.Mandatory(ArgName) f.args.Mandatory(ArgValue) @@ -110,15 +112,15 @@ func (f *ArraySetFunc) Post() wasmclient.Request { ///////////////////////////// mapClear ///////////////////////////// type MapClearFunc struct { - wasmclient.ClientFunc - args wasmclient.Arguments + wasmclient2.ClientFunc + args wasmclient2.Arguments } func (f *MapClearFunc) Name(v string) { f.args.Set(ArgName, f.args.FromString(v)) } -func (f *MapClearFunc) Post() wasmclient.Request { +func (f *MapClearFunc) Post() wasmclient2.Request { f.args.Mandatory(ArgName) return f.ClientFunc.Post(0x027f215a, &f.args) } @@ -126,8 +128,8 @@ func (f *MapClearFunc) Post() wasmclient.Request { ///////////////////////////// mapSet ///////////////////////////// type MapSetFunc struct { - wasmclient.ClientFunc - args wasmclient.Arguments + wasmclient2.ClientFunc + args wasmclient2.Arguments } func (f *MapSetFunc) Key(v string) { @@ -142,7 +144,7 @@ func (f *MapSetFunc) Value(v string) { f.args.Set(ArgValue, f.args.FromString(v)) } -func (f *MapSetFunc) Post() wasmclient.Request { +func (f *MapSetFunc) Post() wasmclient2.Request { f.args.Mandatory(ArgKey) f.args.Mandatory(ArgName) f.args.Mandatory(ArgValue) @@ -152,15 +154,15 @@ func (f *MapSetFunc) Post() wasmclient.Request { ///////////////////////////// paramTypes ///////////////////////////// type ParamTypesFunc struct { - wasmclient.ClientFunc - args wasmclient.Arguments + wasmclient2.ClientFunc + args wasmclient2.Arguments } -func (f *ParamTypesFunc) Address(v wasmclient.Address) { +func (f *ParamTypesFunc) Address(v wasmclient2.Address) { f.args.Set(ArgAddress, f.args.FromAddress(v)) } -func (f *ParamTypesFunc) AgentID(v wasmclient.AgentID) { +func (f *ParamTypesFunc) AgentID(v wasmclient2.AgentID) { f.args.Set(ArgAgentID, f.args.FromAgentID(v)) } @@ -172,19 +174,19 @@ func (f *ParamTypesFunc) Bytes(v []byte) { f.args.Set(ArgBytes, f.args.FromBytes(v)) } -func (f *ParamTypesFunc) ChainID(v wasmclient.ChainID) { +func (f *ParamTypesFunc) ChainID(v wasmclient2.ChainID) { f.args.Set(ArgChainID, f.args.FromChainID(v)) } -func (f *ParamTypesFunc) Color(v wasmclient.Color) { +func (f *ParamTypesFunc) Color(v wasmclient2.Color) { f.args.Set(ArgColor, f.args.FromColor(v)) } -func (f *ParamTypesFunc) Hash(v wasmclient.Hash) { +func (f *ParamTypesFunc) Hash(v wasmclient2.Hash) { f.args.Set(ArgHash, f.args.FromHash(v)) } -func (f *ParamTypesFunc) Hname(v wasmclient.Hname) { +func (f *ParamTypesFunc) Hname(v wasmclient2.Hname) { f.args.Set(ArgHname, f.args.FromHname(v)) } @@ -208,7 +210,7 @@ func (f *ParamTypesFunc) Param(v []byte) { f.args.Set(ArgParam, f.args.FromBytes(v)) } -func (f *ParamTypesFunc) RequestID(v wasmclient.RequestID) { +func (f *ParamTypesFunc) RequestID(v wasmclient2.RequestID) { f.args.Set(ArgRequestID, f.args.FromRequestID(v)) } @@ -232,28 +234,28 @@ func (f *ParamTypesFunc) Uint8(v uint8) { f.args.Set(ArgUint8, f.args.FromUint8(v)) } -func (f *ParamTypesFunc) Post() wasmclient.Request { +func (f *ParamTypesFunc) Post() wasmclient2.Request { return f.ClientFunc.Post(0x6921c4cd, &f.args) } ///////////////////////////// random ///////////////////////////// type RandomFunc struct { - wasmclient.ClientFunc + wasmclient2.ClientFunc } -func (f *RandomFunc) Post() wasmclient.Request { +func (f *RandomFunc) Post() wasmclient2.Request { return f.ClientFunc.Post(0xe86c97ca, nil) } ///////////////////////////// triggerEvent ///////////////////////////// type TriggerEventFunc struct { - wasmclient.ClientFunc - args wasmclient.Arguments + wasmclient2.ClientFunc + args wasmclient2.Arguments } -func (f *TriggerEventFunc) Address(v wasmclient.Address) { +func (f *TriggerEventFunc) Address(v wasmclient2.Address) { f.args.Set(ArgAddress, f.args.FromAddress(v)) } @@ -261,7 +263,7 @@ func (f *TriggerEventFunc) Name(v string) { f.args.Set(ArgName, f.args.FromString(v)) } -func (f *TriggerEventFunc) Post() wasmclient.Request { +func (f *TriggerEventFunc) Post() wasmclient2.Request { f.args.Mandatory(ArgAddress) f.args.Mandatory(ArgName) return f.ClientFunc.Post(0xd5438ac6, &f.args) @@ -270,8 +272,8 @@ func (f *TriggerEventFunc) Post() wasmclient.Request { ///////////////////////////// arrayLength ///////////////////////////// type ArrayLengthView struct { - wasmclient.ClientView - args wasmclient.Arguments + wasmclient2.ClientView + args wasmclient2.Arguments } func (f *ArrayLengthView) Name(v string) { @@ -285,7 +287,7 @@ func (f *ArrayLengthView) Call() ArrayLengthResults { } type ArrayLengthResults struct { - res wasmclient.Results + res wasmclient2.Results } func (r *ArrayLengthResults) Length() uint32 { @@ -295,8 +297,8 @@ func (r *ArrayLengthResults) Length() uint32 { ///////////////////////////// arrayValue ///////////////////////////// type ArrayValueView struct { - wasmclient.ClientView - args wasmclient.Arguments + wasmclient2.ClientView + args wasmclient2.Arguments } func (f *ArrayValueView) Index(v uint32) { @@ -315,7 +317,7 @@ func (f *ArrayValueView) Call() ArrayValueResults { } type ArrayValueResults struct { - res wasmclient.Results + res wasmclient2.Results } func (r *ArrayValueResults) Value() string { @@ -325,8 +327,8 @@ func (r *ArrayValueResults) Value() string { ///////////////////////////// blockRecord ///////////////////////////// type BlockRecordView struct { - wasmclient.ClientView - args wasmclient.Arguments + wasmclient2.ClientView + args wasmclient2.Arguments } func (f *BlockRecordView) BlockIndex(v uint32) { @@ -345,7 +347,7 @@ func (f *BlockRecordView) Call() BlockRecordResults { } type BlockRecordResults struct { - res wasmclient.Results + res wasmclient2.Results } func (r *BlockRecordResults) Record() []byte { @@ -355,8 +357,8 @@ func (r *BlockRecordResults) Record() []byte { ///////////////////////////// blockRecords ///////////////////////////// type BlockRecordsView struct { - wasmclient.ClientView - args wasmclient.Arguments + wasmclient2.ClientView + args wasmclient2.Arguments } func (f *BlockRecordsView) BlockIndex(v uint32) { @@ -370,7 +372,7 @@ func (f *BlockRecordsView) Call() BlockRecordsResults { } type BlockRecordsResults struct { - res wasmclient.Results + res wasmclient2.Results } func (r *BlockRecordsResults) Count() uint32 { @@ -380,7 +382,7 @@ func (r *BlockRecordsResults) Count() uint32 { ///////////////////////////// getRandom ///////////////////////////// type GetRandomView struct { - wasmclient.ClientView + wasmclient2.ClientView } func (f *GetRandomView) Call() GetRandomResults { @@ -389,7 +391,7 @@ func (f *GetRandomView) Call() GetRandomResults { } type GetRandomResults struct { - res wasmclient.Results + res wasmclient2.Results } func (r *GetRandomResults) Random() uint64 { @@ -399,7 +401,7 @@ func (r *GetRandomResults) Random() uint64 { ///////////////////////////// iotaBalance ///////////////////////////// type IotaBalanceView struct { - wasmclient.ClientView + wasmclient2.ClientView } func (f *IotaBalanceView) Call() IotaBalanceResults { @@ -408,7 +410,7 @@ func (f *IotaBalanceView) Call() IotaBalanceResults { } type IotaBalanceResults struct { - res wasmclient.Results + res wasmclient2.Results } func (r *IotaBalanceResults) Iotas() uint64 { @@ -418,8 +420,8 @@ func (r *IotaBalanceResults) Iotas() uint64 { ///////////////////////////// mapValue ///////////////////////////// type MapValueView struct { - wasmclient.ClientView - args wasmclient.Arguments + wasmclient2.ClientView + args wasmclient2.Arguments } func (f *MapValueView) Key(v string) { @@ -438,7 +440,7 @@ func (f *MapValueView) Call() MapValueResults { } type MapValueResults struct { - res wasmclient.Results + res wasmclient2.Results } func (r *MapValueResults) Value() string { @@ -448,10 +450,10 @@ func (r *MapValueResults) Value() string { ///////////////////////////// TestWasmLibService ///////////////////////////// type TestWasmLibService struct { - wasmclient.Service + wasmclient2.Service } -func NewTestWasmLibService(cl *wasmclient.ServiceClient, chainID string) (*TestWasmLibService, error) { +func NewTestWasmLibService(cl *wasmclient2.ServiceClient, chainID string) (*TestWasmLibService, error) { s := &TestWasmLibService{} err := s.Service.Init(cl, chainID, 0x89703a45) return s, err diff --git a/contracts/wasm/testwasmlib/test/testwasmlib_client_test.go b/contracts/wasm/testwasmlib/test/testwasmlib_client_test.go index b41677eed6..674bd2ecc9 100644 --- a/contracts/wasm/testwasmlib/test/testwasmlib_client_test.go +++ b/contracts/wasm/testwasmlib/test/testwasmlib_client_test.go @@ -5,8 +5,8 @@ import ( "testing" "github.com/iotaledger/wasp/contracts/wasm/testwasmlib/go/testwasmlibclient" - "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmclient" - coreaccountsclient "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmclient/coreaccounts" + wasmclient2 "github.com/iotaledger/wasp/packages/wasmvm/wasmlib/go/wasmclient" + "github.com/iotaledger/wasp/packages/wasmvm/wasmlib/go/wasmclient/coreaccounts" "github.com/stretchr/testify/require" ) @@ -23,18 +23,18 @@ func setupClient(t *testing.T) *testwasmlibclient.TestWasmLibService { // for now skip client tests t.SkipNow() - require.True(t, wasmclient.SeedIsValid(mySeed)) - require.True(t, wasmclient.ChainIsValid(myChainID)) + require.True(t, wasmclient2.SeedIsValid(mySeed)) + require.True(t, wasmclient2.ChainIsValid(myChainID)) // we're testing against wasp-cluster, so defaults will do - svcClient := wasmclient.DefaultServiceClient() + svcClient := wasmclient2.DefaultServiceClient() // create the service for the testwasmlib smart contract svc, err := testwasmlibclient.NewTestWasmLibService(svcClient, myChainID) require.NoError(t, err) // we'll use the first address in the seed to sign requests - svc.SignRequests(wasmclient.SeedToKeyPair(mySeed, 0)) + svc.SignRequests(wasmclient2.SeedToKeyPair(mySeed, 0)) return svc } @@ -49,7 +49,7 @@ func TestClientEvents(t *testing.T) { // get new triggerEvent interface, pass params, and post the request f := svc.TriggerEvent() f.Name("Lala") - f.Address(wasmclient.SeedToAddress(mySeed, 0)) + f.Address(wasmclient2.SeedToAddress(mySeed, 0)) req1 := f.Post() require.NoError(t, req1.Error()) @@ -59,7 +59,7 @@ func TestClientEvents(t *testing.T) { // get new triggerEvent interface, pass params, and post the request f = svc.TriggerEvent() f.Name("Trala") - f.Address(wasmclient.SeedToAddress(mySeed, 1)) + f.Address(wasmclient2.SeedToAddress(mySeed, 1)) req2 := f.Post() require.NoError(t, req2.Error()) @@ -129,17 +129,17 @@ func TestAccountBalance(t *testing.T) { t.SkipNow() // we're testing against wasp-cluster, so defaults will do - svcClient := wasmclient.DefaultServiceClient() + svcClient := wasmclient2.DefaultServiceClient() // create the service for the testwasmlib smart contract svc, err := coreaccountsclient.NewCoreAccountsService(svcClient, myChainID) require.NoError(t, err) // we'll use the first address in the seed to sign requests - svc.SignRequests(wasmclient.SeedToKeyPair(mySeed, 0)) + svc.SignRequests(wasmclient2.SeedToKeyPair(mySeed, 0)) bal := svc.Balance() - agendID := wasmclient.SeedToAgentID(mySeed, 0) + agendID := wasmclient2.SeedToAgentID(mySeed, 0) bal.AgentID(agendID) res := bal.Call() require.NoError(t, bal.Error()) diff --git a/contracts/wasm/testwasmlib/test/testwasmlib_test.go b/contracts/wasm/testwasmlib/test/testwasmlib_test.go index 6c0772e07d..5a21deddef 100644 --- a/contracts/wasm/testwasmlib/test/testwasmlib_test.go +++ b/contracts/wasm/testwasmlib/test/testwasmlib_test.go @@ -9,8 +9,8 @@ import ( "github.com/iotaledger/goshimmer/packages/ledgerstate" "github.com/iotaledger/wasp/contracts/wasm/testwasmlib/go/testwasmlib" "github.com/iotaledger/wasp/packages/solo" - "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" - "github.com/iotaledger/wasp/packages/vm/wasmsolo" + "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" + "github.com/iotaledger/wasp/packages/wasmvm/wasmsolo" "github.com/stretchr/testify/require" ) diff --git a/contracts/wasm/timestamp/Cargo.toml b/contracts/wasm/timestamp/Cargo.toml index 1484bd0a63..d9e528cb77 100644 --- a/contracts/wasm/timestamp/Cargo.toml +++ b/contracts/wasm/timestamp/Cargo.toml @@ -14,7 +14,7 @@ crate-type = ["cdylib", "rlib"] default = ["console_error_panic_hook"] [dependencies] -wasmlib = { path = "../../../packages/vm/wasmlib" } +wasmlib = { path = "../../../wasmvm/wasmlib" } #wasmlib = { git = "https://github.com/iotaledger/wasp", branch = "develop" } console_error_panic_hook = { version = "0.1.6", optional = true } wee_alloc = { version = "0.4.5", optional = true } diff --git a/contracts/wasm/timestamp/go/timestamp/consts.go b/contracts/wasm/timestamp/go/timestamp/consts.go index 99c6f616bf..620ce3115f 100644 --- a/contracts/wasm/timestamp/go/timestamp/consts.go +++ b/contracts/wasm/timestamp/go/timestamp/consts.go @@ -7,7 +7,7 @@ package timestamp -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" +import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" const ( ScName = "timestamp" diff --git a/contracts/wasm/timestamp/go/timestamp/contract.go b/contracts/wasm/timestamp/go/timestamp/contract.go index c74dfd3c4f..a5a5e483b5 100644 --- a/contracts/wasm/timestamp/go/timestamp/contract.go +++ b/contracts/wasm/timestamp/go/timestamp/contract.go @@ -7,7 +7,7 @@ package timestamp -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" +import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib" type NowCall struct { Func *wasmlib.ScFunc diff --git a/contracts/wasm/timestamp/go/timestamp/lib.go b/contracts/wasm/timestamp/go/timestamp/lib.go index d136a17f28..17961a49d5 100644 --- a/contracts/wasm/timestamp/go/timestamp/lib.go +++ b/contracts/wasm/timestamp/go/timestamp/lib.go @@ -7,7 +7,7 @@ package timestamp -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" +import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib" func OnLoad() { exports := wasmlib.NewScExports() diff --git a/contracts/wasm/timestamp/go/timestamp/results.go b/contracts/wasm/timestamp/go/timestamp/results.go index 56994cd2d2..52146d74bd 100644 --- a/contracts/wasm/timestamp/go/timestamp/results.go +++ b/contracts/wasm/timestamp/go/timestamp/results.go @@ -7,7 +7,7 @@ package timestamp -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" +import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" type ImmutableGetTimestampResults struct { proxy wasmtypes.Proxy diff --git a/contracts/wasm/timestamp/go/timestamp/state.go b/contracts/wasm/timestamp/go/timestamp/state.go index bc4b2f9934..60b58fc68b 100644 --- a/contracts/wasm/timestamp/go/timestamp/state.go +++ b/contracts/wasm/timestamp/go/timestamp/state.go @@ -7,7 +7,7 @@ package timestamp -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" +import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" type ImmutabletimestampState struct { proxy wasmtypes.Proxy diff --git a/contracts/wasm/timestamp/go/timestamp/timestamp.go b/contracts/wasm/timestamp/go/timestamp/timestamp.go index f8af6b9764..950e2ec072 100644 --- a/contracts/wasm/timestamp/go/timestamp/timestamp.go +++ b/contracts/wasm/timestamp/go/timestamp/timestamp.go @@ -3,7 +3,7 @@ package timestamp -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" +import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib" func funcNow(ctx wasmlib.ScFuncContext, f *NowContext) { f.State.Timestamp().SetValue(ctx.Timestamp()) diff --git a/contracts/wasm/timestamp/test/timestamp_test.go b/contracts/wasm/timestamp/test/timestamp_test.go index 5dbf04649e..bc353b842e 100644 --- a/contracts/wasm/timestamp/test/timestamp_test.go +++ b/contracts/wasm/timestamp/test/timestamp_test.go @@ -4,7 +4,7 @@ import ( "testing" "github.com/iotaledger/wasp/contracts/wasm/timestamp/go/timestamp" - "github.com/iotaledger/wasp/packages/vm/wasmsolo" + "github.com/iotaledger/wasp/packages/wasmvm/wasmsolo" "github.com/stretchr/testify/require" ) diff --git a/contracts/wasm/tokenregistry/Cargo.toml b/contracts/wasm/tokenregistry/Cargo.toml index 77d8171015..5dcd05a552 100644 --- a/contracts/wasm/tokenregistry/Cargo.toml +++ b/contracts/wasm/tokenregistry/Cargo.toml @@ -17,7 +17,7 @@ crate-type = ["cdylib", "rlib"] default = ["console_error_panic_hook"] [dependencies] -wasmlib = { path = "../../../packages/vm/wasmlib" } +wasmlib = { path = "../../../wasmvm/wasmlib" } #wasmlib = { git = "https://github.com/iotaledger/wasp", branch = "develop" } # The `console_error_panic_hook` crate provides better debugging of panics by diff --git a/contracts/wasm/tokenregistry/go/tokenregistry/consts.go b/contracts/wasm/tokenregistry/go/tokenregistry/consts.go index c8473c7899..a3e614caa3 100644 --- a/contracts/wasm/tokenregistry/go/tokenregistry/consts.go +++ b/contracts/wasm/tokenregistry/go/tokenregistry/consts.go @@ -7,7 +7,7 @@ package tokenregistry -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" +import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" const ( ScName = "tokenregistry" diff --git a/contracts/wasm/tokenregistry/go/tokenregistry/contract.go b/contracts/wasm/tokenregistry/go/tokenregistry/contract.go index 100714067b..3ecf964449 100644 --- a/contracts/wasm/tokenregistry/go/tokenregistry/contract.go +++ b/contracts/wasm/tokenregistry/go/tokenregistry/contract.go @@ -7,7 +7,7 @@ package tokenregistry -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" +import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib" type MintSupplyCall struct { Func *wasmlib.ScFunc diff --git a/contracts/wasm/tokenregistry/go/tokenregistry/lib.go b/contracts/wasm/tokenregistry/go/tokenregistry/lib.go index a6282cd504..d5b196db03 100644 --- a/contracts/wasm/tokenregistry/go/tokenregistry/lib.go +++ b/contracts/wasm/tokenregistry/go/tokenregistry/lib.go @@ -7,7 +7,7 @@ package tokenregistry -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" +import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib" func OnLoad() { exports := wasmlib.NewScExports() diff --git a/contracts/wasm/tokenregistry/go/tokenregistry/params.go b/contracts/wasm/tokenregistry/go/tokenregistry/params.go index 36c4cd55a1..a171f74e0e 100644 --- a/contracts/wasm/tokenregistry/go/tokenregistry/params.go +++ b/contracts/wasm/tokenregistry/go/tokenregistry/params.go @@ -7,7 +7,7 @@ package tokenregistry -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" +import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" type ImmutableMintSupplyParams struct { proxy wasmtypes.Proxy diff --git a/contracts/wasm/tokenregistry/go/tokenregistry/state.go b/contracts/wasm/tokenregistry/go/tokenregistry/state.go index 6d7f964ed4..b78d68e423 100644 --- a/contracts/wasm/tokenregistry/go/tokenregistry/state.go +++ b/contracts/wasm/tokenregistry/go/tokenregistry/state.go @@ -7,7 +7,7 @@ package tokenregistry -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" +import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" type ArrayOfImmutableColor struct { proxy wasmtypes.Proxy diff --git a/contracts/wasm/tokenregistry/go/tokenregistry/structs.go b/contracts/wasm/tokenregistry/go/tokenregistry/structs.go index 2c531a8486..36a28ce60a 100644 --- a/contracts/wasm/tokenregistry/go/tokenregistry/structs.go +++ b/contracts/wasm/tokenregistry/go/tokenregistry/structs.go @@ -7,7 +7,7 @@ package tokenregistry -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" +import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" type Token struct { Created uint64 // creation timestamp diff --git a/contracts/wasm/tokenregistry/go/tokenregistry/tokenregistry.go b/contracts/wasm/tokenregistry/go/tokenregistry/tokenregistry.go index 7258ec6229..22ce73ae8e 100644 --- a/contracts/wasm/tokenregistry/go/tokenregistry/tokenregistry.go +++ b/contracts/wasm/tokenregistry/go/tokenregistry/tokenregistry.go @@ -4,7 +4,7 @@ package tokenregistry import ( - "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" + "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib" ) func funcMintSupply(ctx wasmlib.ScFuncContext, f *MintSupplyContext) { diff --git a/contracts/wasm/tokenregistry/test/tokenregistry_test.go b/contracts/wasm/tokenregistry/test/tokenregistry_test.go index 2583c11e6d..1fe41d8298 100644 --- a/contracts/wasm/tokenregistry/test/tokenregistry_test.go +++ b/contracts/wasm/tokenregistry/test/tokenregistry_test.go @@ -7,7 +7,7 @@ import ( "testing" "github.com/iotaledger/wasp/contracts/wasm/tokenregistry/go/tokenregistry" - "github.com/iotaledger/wasp/packages/vm/wasmsolo" + "github.com/iotaledger/wasp/packages/wasmvm/wasmsolo" "github.com/stretchr/testify/require" ) diff --git a/documentation/docs/guide/schema/events.mdx b/documentation/docs/guide/schema/events.mdx index 8ea06c9848..9b90342f50 100644 --- a/documentation/docs/guide/schema/events.mdx +++ b/documentation/docs/guide/schema/events.mdx @@ -118,7 +118,7 @@ FairRouletteEvents struct: ```go package fairroulette -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" +import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib" type FairRouletteEvents struct{} diff --git a/documentation/docs/guide/schema/funcdesc.mdx b/documentation/docs/guide/schema/funcdesc.mdx index 71f56c0a7d..ca28b2ad76 100644 --- a/documentation/docs/guide/schema/funcdesc.mdx +++ b/documentation/docs/guide/schema/funcdesc.mdx @@ -37,7 +37,7 @@ in `contract.xx`: ```go package dividend -import "github.com/iotaledger/wasp/packages/vm/wasmlib" +import "github.com/iotaledger/wasp/wasmvm/wasmlib" type DivideCall struct { Func *wasmlib.ScFunc diff --git a/documentation/docs/guide/schema/init.mdx b/documentation/docs/guide/schema/init.mdx index 9d6cb2297c..2b9763ea0d 100644 --- a/documentation/docs/guide/schema/init.mdx +++ b/documentation/docs/guide/schema/init.mdx @@ -57,7 +57,7 @@ first part of the Rust code that implements it, which contains the `'`init`'` fu //nolint:revive package dividend -import "github.com/iotaledger/wasp/packages/vm/wasmlib" +import "github.com/iotaledger/wasp/wasmvm/wasmlib" // 'init' is used as a way to initialize a smart contract. It is an optional // function that will automatically be called upon contract deployment. In this diff --git a/documentation/docs/guide/schema/structs.mdx b/documentation/docs/guide/schema/structs.mdx index e1b44f52ca..d595b40b1d 100644 --- a/documentation/docs/guide/schema/structs.mdx +++ b/documentation/docs/guide/schema/structs.mdx @@ -86,7 +86,7 @@ struct: ```go package betting -import "github.com/iotaledger/wasp/packages/vm/wasmlib" +import "github.com/iotaledger/wasp/wasmvm/wasmlib" type Bet struct { Amount int64 // bet amount @@ -311,7 +311,7 @@ The generated code in `state.xx` that implements the state interface is shown he ```go package betting -import "github.com/iotaledger/wasp/packages/vm/wasmlib" +import "github.com/iotaledger/wasp/wasmvm/wasmlib" type ArrayOfImmutableBet struct { objID int32 diff --git a/documentation/docs/guide/schema/typedefs.mdx b/documentation/docs/guide/schema/typedefs.mdx index c757ea7058..ec676372b1 100644 --- a/documentation/docs/guide/schema/typedefs.mdx +++ b/documentation/docs/guide/schema/typedefs.mdx @@ -76,7 +76,7 @@ The schema tool will generate the following proxies in `typedefs.xx`: ```go package betting -import "github.com/iotaledger/wasp/packages/vm/wasmlib" +import "github.com/iotaledger/wasp/wasmvm/wasmlib" type ImmutableBettingRound = ArrayOfImmutableBet @@ -227,7 +227,7 @@ definition in `state.xx`: ```go package betting -import "github.com/iotaledger/wasp/packages/vm/wasmlib" +import "github.com/iotaledger/wasp/wasmvm/wasmlib" type ArrayOfImmutableBettingRound struct { objID int32 diff --git a/documentation/docs/guide/schema/usage.mdx b/documentation/docs/guide/schema/usage.mdx index 076bf53a9a..c211d81b32 100644 --- a/documentation/docs/guide/schema/usage.mdx +++ b/documentation/docs/guide/schema/usage.mdx @@ -252,7 +252,7 @@ looks like this before you even start modifying it: ```go package mysmartcontract -import "github.com/iotaledger/wasp/packages/vm/wasmlib" +import "github.com/iotaledger/wasp/wasmvm/wasmlib" func funcInit(ctx wasmlib.ScFuncContext, f *InitContext) { diff --git a/documentation/tutorial-examples/Cargo.toml b/documentation/tutorial-examples/Cargo.toml index f8fe8d12c8..98838db21f 100644 --- a/documentation/tutorial-examples/Cargo.toml +++ b/documentation/tutorial-examples/Cargo.toml @@ -17,7 +17,7 @@ crate-type = ["cdylib", "rlib"] default = ["console_error_panic_hook"] [dependencies] -wasmlib = { path = "../../packages/vm/wasmlib" } +wasmlib = { path = "../../wasmvm/wasmlib" } #wasmlib = { git = "https://github.com/iotaledger/wasp", branch = "develop" } # The `console_error_panic_hook` crate provides better debugging of panics by diff --git a/packages/vm/wasmhost/wasmcontext.go b/packages/wasmvm/wasmhost/wasmcontext.go similarity index 98% rename from packages/vm/wasmhost/wasmcontext.go rename to packages/wasmvm/wasmhost/wasmcontext.go index 8a855aae09..8e2c500480 100644 --- a/packages/vm/wasmhost/wasmcontext.go +++ b/packages/wasmvm/wasmhost/wasmcontext.go @@ -4,7 +4,7 @@ import ( "github.com/iotaledger/wasp/packages/iscp" "github.com/iotaledger/wasp/packages/kv" "github.com/iotaledger/wasp/packages/kv/dict" - "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" + "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib" ) const ( diff --git a/packages/vm/wasmhost/wasmedgevm.go b/packages/wasmvm/wasmhost/wasmedgevm.go similarity index 100% rename from packages/vm/wasmhost/wasmedgevm.go rename to packages/wasmvm/wasmhost/wasmedgevm.go diff --git a/packages/vm/wasmhost/wasmervm.go b/packages/wasmvm/wasmhost/wasmervm.go similarity index 100% rename from packages/vm/wasmhost/wasmervm.go rename to packages/wasmvm/wasmhost/wasmervm.go diff --git a/packages/vm/wasmhost/wasmgovm.go b/packages/wasmvm/wasmhost/wasmgovm.go similarity index 96% rename from packages/vm/wasmhost/wasmgovm.go rename to packages/wasmvm/wasmhost/wasmgovm.go index cc50f58595..ef3dcc81f6 100644 --- a/packages/vm/wasmhost/wasmgovm.go +++ b/packages/wasmvm/wasmhost/wasmgovm.go @@ -7,7 +7,7 @@ import ( "errors" "strings" - "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" + "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib" ) // provide implementation for Wasm-only function diff --git a/packages/vm/wasmhost/wasmhost.go b/packages/wasmvm/wasmhost/wasmhost.go similarity index 97% rename from packages/vm/wasmhost/wasmhost.go rename to packages/wasmvm/wasmhost/wasmhost.go index fcf27ade21..03f1bf9453 100644 --- a/packages/vm/wasmhost/wasmhost.go +++ b/packages/wasmvm/wasmhost/wasmhost.go @@ -7,7 +7,7 @@ import ( "errors" "github.com/iotaledger/wasp/packages/iscp" - "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" + "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib" ) type WasmStore interface { diff --git a/packages/vm/wasmhost/wasmprocessor.go b/packages/wasmvm/wasmhost/wasmprocessor.go similarity index 100% rename from packages/vm/wasmhost/wasmprocessor.go rename to packages/wasmvm/wasmhost/wasmprocessor.go diff --git a/packages/vm/wasmhost/wasmtimevm.go b/packages/wasmvm/wasmhost/wasmtimevm.go similarity index 100% rename from packages/vm/wasmhost/wasmtimevm.go rename to packages/wasmvm/wasmhost/wasmtimevm.go diff --git a/packages/vm/wasmhost/wasmtosandbox.go b/packages/wasmvm/wasmhost/wasmtosandbox.go similarity index 99% rename from packages/vm/wasmhost/wasmtosandbox.go rename to packages/wasmvm/wasmhost/wasmtosandbox.go index 2ea5f3feb2..92608ee5d8 100644 --- a/packages/vm/wasmhost/wasmtosandbox.go +++ b/packages/wasmvm/wasmhost/wasmtosandbox.go @@ -12,7 +12,7 @@ import ( "github.com/iotaledger/wasp/packages/iscp/colored" "github.com/iotaledger/wasp/packages/kv/codec" "github.com/iotaledger/wasp/packages/kv/dict" - "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmrequests" + "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmrequests" ) // NOTE: These functions correspond to the Sandbox fnXxx constants in WasmLib diff --git a/packages/vm/wasmhost/wasmtosandboxutils.go b/packages/wasmvm/wasmhost/wasmtosandboxutils.go similarity index 97% rename from packages/vm/wasmhost/wasmtosandboxutils.go rename to packages/wasmvm/wasmhost/wasmtosandboxutils.go index cd9108fd37..e7248a0878 100644 --- a/packages/vm/wasmhost/wasmtosandboxutils.go +++ b/packages/wasmvm/wasmhost/wasmtosandboxutils.go @@ -5,7 +5,7 @@ package wasmhost import ( "github.com/iotaledger/wasp/packages/kv/codec" - "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" + "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" ) func (s WasmToSandbox) fnUtilsBase58Decode(args []byte) []byte { diff --git a/packages/vm/wasmhost/wasmvm.go b/packages/wasmvm/wasmhost/wasmvm.go similarity index 99% rename from packages/vm/wasmhost/wasmvm.go rename to packages/wasmvm/wasmhost/wasmvm.go index bce71eb4f6..6ffb6e78b7 100644 --- a/packages/vm/wasmhost/wasmvm.go +++ b/packages/wasmvm/wasmhost/wasmvm.go @@ -9,7 +9,7 @@ import ( "fmt" "time" - "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" + "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib" ) const ( diff --git a/packages/vm/wasmlib/Cargo.toml b/packages/wasmvm/wasmlib/Cargo.toml similarity index 100% rename from packages/vm/wasmlib/Cargo.toml rename to packages/wasmvm/wasmlib/Cargo.toml diff --git a/packages/vm/wasmlib/LICENSE b/packages/wasmvm/wasmlib/LICENSE similarity index 100% rename from packages/vm/wasmlib/LICENSE rename to packages/wasmvm/wasmlib/LICENSE diff --git a/packages/vm/wasmlib/README.md b/packages/wasmvm/wasmlib/README.md similarity index 100% rename from packages/vm/wasmlib/README.md rename to packages/wasmvm/wasmlib/README.md diff --git a/packages/vm/wasmlib/go/wasmclient/arguments.go b/packages/wasmvm/wasmlib/go/wasmclient/arguments.go similarity index 100% rename from packages/vm/wasmlib/go/wasmclient/arguments.go rename to packages/wasmvm/wasmlib/go/wasmclient/arguments.go diff --git a/packages/vm/wasmlib/go/wasmclient/clientfunc.go b/packages/wasmvm/wasmlib/go/wasmclient/clientfunc.go similarity index 100% rename from packages/vm/wasmlib/go/wasmclient/clientfunc.go rename to packages/wasmvm/wasmlib/go/wasmclient/clientfunc.go diff --git a/packages/vm/wasmlib/go/wasmclient/clientview.go b/packages/wasmvm/wasmlib/go/wasmclient/clientview.go similarity index 100% rename from packages/vm/wasmlib/go/wasmclient/clientview.go rename to packages/wasmvm/wasmlib/go/wasmclient/clientview.go diff --git a/packages/vm/wasmlib/go/wasmclient/coreaccounts/service.go b/packages/wasmvm/wasmlib/go/wasmclient/coreaccounts/service.go similarity index 73% rename from packages/vm/wasmlib/go/wasmclient/coreaccounts/service.go rename to packages/wasmvm/wasmlib/go/wasmclient/coreaccounts/service.go index 9cae8217e0..570baef454 100644 --- a/packages/vm/wasmlib/go/wasmclient/coreaccounts/service.go +++ b/packages/wasmvm/wasmlib/go/wasmclient/coreaccounts/service.go @@ -7,7 +7,9 @@ package coreaccountsclient -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmclient" +import ( + wasmclient2 "github.com/iotaledger/wasp/packages/wasmvm/wasmlib/go/wasmclient" +) const ( ArgAgentID = "a" @@ -22,51 +24,51 @@ const ( ///////////////////////////// deposit ///////////////////////////// type DepositFunc struct { - wasmclient.ClientFunc - args wasmclient.Arguments + wasmclient2.ClientFunc + args wasmclient2.Arguments } -func (f *DepositFunc) AgentID(v wasmclient.AgentID) { +func (f *DepositFunc) AgentID(v wasmclient2.AgentID) { f.args.Set(ArgAgentID, f.args.FromAgentID(v)) } -func (f *DepositFunc) Post() wasmclient.Request { +func (f *DepositFunc) Post() wasmclient2.Request { return f.ClientFunc.Post(0xbdc9102d, &f.args) } ///////////////////////////// harvest ///////////////////////////// type HarvestFunc struct { - wasmclient.ClientFunc - args wasmclient.Arguments + wasmclient2.ClientFunc + args wasmclient2.Arguments } func (f *HarvestFunc) WithdrawAmount(v int64) { f.args.Set(ArgWithdrawAmount, f.args.FromInt64(v)) } -func (f *HarvestFunc) WithdrawColor(v wasmclient.Color) { +func (f *HarvestFunc) WithdrawColor(v wasmclient2.Color) { f.args.Set(ArgWithdrawColor, f.args.FromColor(v)) } -func (f *HarvestFunc) Post() wasmclient.Request { +func (f *HarvestFunc) Post() wasmclient2.Request { return f.ClientFunc.Post(0x7b40efbd, &f.args) } ///////////////////////////// withdraw ///////////////////////////// type WithdrawFunc struct { - wasmclient.ClientFunc + wasmclient2.ClientFunc } -func (f *WithdrawFunc) Post() wasmclient.Request { +func (f *WithdrawFunc) Post() wasmclient2.Request { return f.ClientFunc.Post(0x9dcc0f41, nil) } ///////////////////////////// accounts ///////////////////////////// type AccountsView struct { - wasmclient.ClientView + wasmclient2.ClientView } func (f *AccountsView) Call() AccountsResults { @@ -75,11 +77,11 @@ func (f *AccountsView) Call() AccountsResults { } type AccountsResults struct { - res wasmclient.Results + res wasmclient2.Results } -func (r *AccountsResults) Agents() map[wasmclient.AgentID][]byte { - res := make(map[wasmclient.AgentID][]byte) +func (r *AccountsResults) Agents() map[wasmclient2.AgentID][]byte { + res := make(map[wasmclient2.AgentID][]byte) r.res.ForEach(func(key []byte, val []byte) { res[r.res.ToAgentID(key)] = r.res.ToBytes(val) }) @@ -89,11 +91,11 @@ func (r *AccountsResults) Agents() map[wasmclient.AgentID][]byte { ///////////////////////////// balance ///////////////////////////// type BalanceView struct { - wasmclient.ClientView - args wasmclient.Arguments + wasmclient2.ClientView + args wasmclient2.Arguments } -func (f *BalanceView) AgentID(v wasmclient.AgentID) { +func (f *BalanceView) AgentID(v wasmclient2.AgentID) { f.args.Set(ArgAgentID, f.args.FromAgentID(v)) } @@ -104,11 +106,11 @@ func (f *BalanceView) Call() BalanceResults { } type BalanceResults struct { - res wasmclient.Results + res wasmclient2.Results } -func (r *BalanceResults) Balances() map[wasmclient.Color]int64 { - res := make(map[wasmclient.Color]int64) +func (r *BalanceResults) Balances() map[wasmclient2.Color]int64 { + res := make(map[wasmclient2.Color]int64) r.res.ForEach(func(key []byte, val []byte) { res[r.res.ToColor(key)] = r.res.ToInt64(val) }) @@ -118,11 +120,11 @@ func (r *BalanceResults) Balances() map[wasmclient.Color]int64 { ///////////////////////////// getAccountNonce ///////////////////////////// type GetAccountNonceView struct { - wasmclient.ClientView - args wasmclient.Arguments + wasmclient2.ClientView + args wasmclient2.Arguments } -func (f *GetAccountNonceView) AgentID(v wasmclient.AgentID) { +func (f *GetAccountNonceView) AgentID(v wasmclient2.AgentID) { f.args.Set(ArgAgentID, f.args.FromAgentID(v)) } @@ -133,7 +135,7 @@ func (f *GetAccountNonceView) Call() GetAccountNonceResults { } type GetAccountNonceResults struct { - res wasmclient.Results + res wasmclient2.Results } func (r *GetAccountNonceResults) AccountNonce() int64 { @@ -143,7 +145,7 @@ func (r *GetAccountNonceResults) AccountNonce() int64 { ///////////////////////////// totalAssets ///////////////////////////// type TotalAssetsView struct { - wasmclient.ClientView + wasmclient2.ClientView } func (f *TotalAssetsView) Call() TotalAssetsResults { @@ -152,11 +154,11 @@ func (f *TotalAssetsView) Call() TotalAssetsResults { } type TotalAssetsResults struct { - res wasmclient.Results + res wasmclient2.Results } -func (r *TotalAssetsResults) Balances() map[wasmclient.Color]int64 { - res := make(map[wasmclient.Color]int64) +func (r *TotalAssetsResults) Balances() map[wasmclient2.Color]int64 { + res := make(map[wasmclient2.Color]int64) r.res.ForEach(func(key []byte, val []byte) { res[r.res.ToColor(key)] = r.res.ToInt64(val) }) @@ -166,10 +168,10 @@ func (r *TotalAssetsResults) Balances() map[wasmclient.Color]int64 { ///////////////////////////// CoreAccountsService ///////////////////////////// type CoreAccountsService struct { - wasmclient.Service + wasmclient2.Service } -func NewCoreAccountsService(cl *wasmclient.ServiceClient, chainID string) (*CoreAccountsService, error) { +func NewCoreAccountsService(cl *wasmclient2.ServiceClient, chainID string) (*CoreAccountsService, error) { s := &CoreAccountsService{} err := s.Service.Init(cl, chainID, 0x3c4b5e02) return s, err diff --git a/packages/vm/wasmlib/go/wasmclient/coreblob/service.go b/packages/wasmvm/wasmlib/go/wasmclient/coreblob/service.go similarity index 78% rename from packages/vm/wasmlib/go/wasmclient/coreblob/service.go rename to packages/wasmvm/wasmlib/go/wasmclient/coreblob/service.go index 337132ad48..fa6d5552e8 100644 --- a/packages/vm/wasmlib/go/wasmclient/coreblob/service.go +++ b/packages/wasmvm/wasmlib/go/wasmclient/coreblob/service.go @@ -7,7 +7,9 @@ package coreblobclient -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmclient" +import ( + wasmclient2 "github.com/iotaledger/wasp/packages/wasmvm/wasmlib/go/wasmclient" +) const ( ArgBlobs = "this" @@ -22,30 +24,30 @@ const ( ///////////////////////////// storeBlob ///////////////////////////// type StoreBlobFunc struct { - wasmclient.ClientFunc - args wasmclient.Arguments + wasmclient2.ClientFunc + args wasmclient2.Arguments } func (f *StoreBlobFunc) Blobs(v []byte) { f.args.Set(ArgBlobs, f.args.FromBytes(v)) } -func (f *StoreBlobFunc) Post() wasmclient.Request { +func (f *StoreBlobFunc) Post() wasmclient2.Request { return f.ClientFunc.Post(0xddd4c281, &f.args) } ///////////////////////////// getBlobField ///////////////////////////// type GetBlobFieldView struct { - wasmclient.ClientView - args wasmclient.Arguments + wasmclient2.ClientView + args wasmclient2.Arguments } func (f *GetBlobFieldView) Field(v string) { f.args.Set(ArgField, f.args.FromString(v)) } -func (f *GetBlobFieldView) Hash(v wasmclient.Hash) { +func (f *GetBlobFieldView) Hash(v wasmclient2.Hash) { f.args.Set(ArgHash, f.args.FromHash(v)) } @@ -57,7 +59,7 @@ func (f *GetBlobFieldView) Call() GetBlobFieldResults { } type GetBlobFieldResults struct { - res wasmclient.Results + res wasmclient2.Results } func (r *GetBlobFieldResults) Bytes() []byte { @@ -67,11 +69,11 @@ func (r *GetBlobFieldResults) Bytes() []byte { ///////////////////////////// getBlobInfo ///////////////////////////// type GetBlobInfoView struct { - wasmclient.ClientView - args wasmclient.Arguments + wasmclient2.ClientView + args wasmclient2.Arguments } -func (f *GetBlobInfoView) Hash(v wasmclient.Hash) { +func (f *GetBlobInfoView) Hash(v wasmclient2.Hash) { f.args.Set(ArgHash, f.args.FromHash(v)) } @@ -82,7 +84,7 @@ func (f *GetBlobInfoView) Call() GetBlobInfoResults { } type GetBlobInfoResults struct { - res wasmclient.Results + res wasmclient2.Results } func (r *GetBlobInfoResults) BlobSizes() map[string]int32 { @@ -96,7 +98,7 @@ func (r *GetBlobInfoResults) BlobSizes() map[string]int32 { ///////////////////////////// listBlobs ///////////////////////////// type ListBlobsView struct { - wasmclient.ClientView + wasmclient2.ClientView } func (f *ListBlobsView) Call() ListBlobsResults { @@ -105,11 +107,11 @@ func (f *ListBlobsView) Call() ListBlobsResults { } type ListBlobsResults struct { - res wasmclient.Results + res wasmclient2.Results } -func (r *ListBlobsResults) BlobSizes() map[wasmclient.Hash]int32 { - res := make(map[wasmclient.Hash]int32) +func (r *ListBlobsResults) BlobSizes() map[wasmclient2.Hash]int32 { + res := make(map[wasmclient2.Hash]int32) r.res.ForEach(func(key []byte, val []byte) { res[r.res.ToHash(key)] = r.res.ToInt32(val) }) @@ -119,10 +121,10 @@ func (r *ListBlobsResults) BlobSizes() map[wasmclient.Hash]int32 { ///////////////////////////// CoreBlobService ///////////////////////////// type CoreBlobService struct { - wasmclient.Service + wasmclient2.Service } -func NewCoreBlobService(cl *wasmclient.ServiceClient, chainID string) (*CoreBlobService, error) { +func NewCoreBlobService(cl *wasmclient2.ServiceClient, chainID string) (*CoreBlobService, error) { s := &CoreBlobService{} err := s.Service.Init(cl, chainID, 0xfd91bc63) return s, err diff --git a/packages/vm/wasmlib/go/wasmclient/coreblocklog/service.go b/packages/wasmvm/wasmlib/go/wasmclient/coreblocklog/service.go similarity index 85% rename from packages/vm/wasmlib/go/wasmclient/coreblocklog/service.go rename to packages/wasmvm/wasmlib/go/wasmclient/coreblocklog/service.go index 3a1c3a423a..07f927d0d9 100644 --- a/packages/vm/wasmlib/go/wasmclient/coreblocklog/service.go +++ b/packages/wasmvm/wasmlib/go/wasmclient/coreblocklog/service.go @@ -7,7 +7,9 @@ package coreblocklogclient -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmclient" +import ( + wasmclient2 "github.com/iotaledger/wasp/packages/wasmvm/wasmlib/go/wasmclient" +) const ( ArgBlockIndex = "n" @@ -30,7 +32,7 @@ const ( ///////////////////////////// controlAddresses ///////////////////////////// type ControlAddressesView struct { - wasmclient.ClientView + wasmclient2.ClientView } func (f *ControlAddressesView) Call() ControlAddressesResults { @@ -39,26 +41,26 @@ func (f *ControlAddressesView) Call() ControlAddressesResults { } type ControlAddressesResults struct { - res wasmclient.Results + res wasmclient2.Results } func (r *ControlAddressesResults) BlockIndex() uint32 { return r.res.ToUint32(r.res.Get(ResBlockIndex)) } -func (r *ControlAddressesResults) GoverningAddress() wasmclient.Address { +func (r *ControlAddressesResults) GoverningAddress() wasmclient2.Address { return r.res.ToAddress(r.res.Get(ResGoverningAddress)) } -func (r *ControlAddressesResults) StateControllerAddress() wasmclient.Address { +func (r *ControlAddressesResults) StateControllerAddress() wasmclient2.Address { return r.res.ToAddress(r.res.Get(ResStateControllerAddress)) } ///////////////////////////// getBlockInfo ///////////////////////////// type GetBlockInfoView struct { - wasmclient.ClientView - args wasmclient.Arguments + wasmclient2.ClientView + args wasmclient2.Arguments } func (f *GetBlockInfoView) BlockIndex(v uint32) { @@ -72,7 +74,7 @@ func (f *GetBlockInfoView) Call() GetBlockInfoResults { } type GetBlockInfoResults struct { - res wasmclient.Results + res wasmclient2.Results } func (r *GetBlockInfoResults) BlockInfo() []byte { @@ -82,8 +84,8 @@ func (r *GetBlockInfoResults) BlockInfo() []byte { ///////////////////////////// getEventsForBlock ///////////////////////////// type GetEventsForBlockView struct { - wasmclient.ClientView - args wasmclient.Arguments + wasmclient2.ClientView + args wasmclient2.Arguments } func (f *GetEventsForBlockView) BlockIndex(v uint32) { @@ -97,7 +99,7 @@ func (f *GetEventsForBlockView) Call() GetEventsForBlockResults { } type GetEventsForBlockResults struct { - res wasmclient.Results + res wasmclient2.Results } func (r *GetEventsForBlockResults) Event() []byte { @@ -107,11 +109,11 @@ func (r *GetEventsForBlockResults) Event() []byte { ///////////////////////////// getEventsForContract ///////////////////////////// type GetEventsForContractView struct { - wasmclient.ClientView - args wasmclient.Arguments + wasmclient2.ClientView + args wasmclient2.Arguments } -func (f *GetEventsForContractView) ContractHname(v wasmclient.Hname) { +func (f *GetEventsForContractView) ContractHname(v wasmclient2.Hname) { f.args.Set(ArgContractHname, f.args.FromHname(v)) } @@ -130,7 +132,7 @@ func (f *GetEventsForContractView) Call() GetEventsForContractResults { } type GetEventsForContractResults struct { - res wasmclient.Results + res wasmclient2.Results } func (r *GetEventsForContractResults) Event() []byte { @@ -140,11 +142,11 @@ func (r *GetEventsForContractResults) Event() []byte { ///////////////////////////// getEventsForRequest ///////////////////////////// type GetEventsForRequestView struct { - wasmclient.ClientView - args wasmclient.Arguments + wasmclient2.ClientView + args wasmclient2.Arguments } -func (f *GetEventsForRequestView) RequestID(v wasmclient.RequestID) { +func (f *GetEventsForRequestView) RequestID(v wasmclient2.RequestID) { f.args.Set(ArgRequestID, f.args.FromRequestID(v)) } @@ -155,7 +157,7 @@ func (f *GetEventsForRequestView) Call() GetEventsForRequestResults { } type GetEventsForRequestResults struct { - res wasmclient.Results + res wasmclient2.Results } func (r *GetEventsForRequestResults) Event() []byte { @@ -165,7 +167,7 @@ func (r *GetEventsForRequestResults) Event() []byte { ///////////////////////////// getLatestBlockInfo ///////////////////////////// type GetLatestBlockInfoView struct { - wasmclient.ClientView + wasmclient2.ClientView } func (f *GetLatestBlockInfoView) Call() GetLatestBlockInfoResults { @@ -174,7 +176,7 @@ func (f *GetLatestBlockInfoView) Call() GetLatestBlockInfoResults { } type GetLatestBlockInfoResults struct { - res wasmclient.Results + res wasmclient2.Results } func (r *GetLatestBlockInfoResults) BlockIndex() uint32 { @@ -188,8 +190,8 @@ func (r *GetLatestBlockInfoResults) BlockInfo() []byte { ///////////////////////////// getRequestIDsForBlock ///////////////////////////// type GetRequestIDsForBlockView struct { - wasmclient.ClientView - args wasmclient.Arguments + wasmclient2.ClientView + args wasmclient2.Arguments } func (f *GetRequestIDsForBlockView) BlockIndex(v uint32) { @@ -203,21 +205,21 @@ func (f *GetRequestIDsForBlockView) Call() GetRequestIDsForBlockResults { } type GetRequestIDsForBlockResults struct { - res wasmclient.Results + res wasmclient2.Results } -func (r *GetRequestIDsForBlockResults) RequestID() wasmclient.RequestID { +func (r *GetRequestIDsForBlockResults) RequestID() wasmclient2.RequestID { return r.res.ToRequestID(r.res.Get(ResRequestID)) } ///////////////////////////// getRequestReceipt ///////////////////////////// type GetRequestReceiptView struct { - wasmclient.ClientView - args wasmclient.Arguments + wasmclient2.ClientView + args wasmclient2.Arguments } -func (f *GetRequestReceiptView) RequestID(v wasmclient.RequestID) { +func (f *GetRequestReceiptView) RequestID(v wasmclient2.RequestID) { f.args.Set(ArgRequestID, f.args.FromRequestID(v)) } @@ -228,7 +230,7 @@ func (f *GetRequestReceiptView) Call() GetRequestReceiptResults { } type GetRequestReceiptResults struct { - res wasmclient.Results + res wasmclient2.Results } func (r *GetRequestReceiptResults) BlockIndex() uint32 { @@ -246,8 +248,8 @@ func (r *GetRequestReceiptResults) RequestRecord() []byte { ///////////////////////////// getRequestReceiptsForBlock ///////////////////////////// type GetRequestReceiptsForBlockView struct { - wasmclient.ClientView - args wasmclient.Arguments + wasmclient2.ClientView + args wasmclient2.Arguments } func (f *GetRequestReceiptsForBlockView) BlockIndex(v uint32) { @@ -261,7 +263,7 @@ func (f *GetRequestReceiptsForBlockView) Call() GetRequestReceiptsForBlockResult } type GetRequestReceiptsForBlockResults struct { - res wasmclient.Results + res wasmclient2.Results } func (r *GetRequestReceiptsForBlockResults) RequestRecord() []byte { @@ -271,11 +273,11 @@ func (r *GetRequestReceiptsForBlockResults) RequestRecord() []byte { ///////////////////////////// isRequestProcessed ///////////////////////////// type IsRequestProcessedView struct { - wasmclient.ClientView - args wasmclient.Arguments + wasmclient2.ClientView + args wasmclient2.Arguments } -func (f *IsRequestProcessedView) RequestID(v wasmclient.RequestID) { +func (f *IsRequestProcessedView) RequestID(v wasmclient2.RequestID) { f.args.Set(ArgRequestID, f.args.FromRequestID(v)) } @@ -286,7 +288,7 @@ func (f *IsRequestProcessedView) Call() IsRequestProcessedResults { } type IsRequestProcessedResults struct { - res wasmclient.Results + res wasmclient2.Results } func (r *IsRequestProcessedResults) RequestProcessed() string { @@ -296,10 +298,10 @@ func (r *IsRequestProcessedResults) RequestProcessed() string { ///////////////////////////// CoreBlockLogService ///////////////////////////// type CoreBlockLogService struct { - wasmclient.Service + wasmclient2.Service } -func NewCoreBlockLogService(cl *wasmclient.ServiceClient, chainID string) (*CoreBlockLogService, error) { +func NewCoreBlockLogService(cl *wasmclient2.ServiceClient, chainID string) (*CoreBlockLogService, error) { s := &CoreBlockLogService{} err := s.Service.Init(cl, chainID, 0xf538ef2b) return s, err diff --git a/packages/vm/wasmlib/go/wasmclient/coregovernance/service.go b/packages/wasmvm/wasmlib/go/wasmclient/coregovernance/service.go similarity index 83% rename from packages/vm/wasmlib/go/wasmclient/coregovernance/service.go rename to packages/wasmvm/wasmlib/go/wasmclient/coregovernance/service.go index 921306a07b..ddf702729c 100644 --- a/packages/vm/wasmlib/go/wasmclient/coregovernance/service.go +++ b/packages/wasmvm/wasmlib/go/wasmclient/coregovernance/service.go @@ -7,7 +7,9 @@ package coregovernanceclient -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmclient" +import ( + wasmclient2 "github.com/iotaledger/wasp/packages/wasmvm/wasmlib/go/wasmclient" +) const ( ArgChainOwner = "oi" @@ -37,23 +39,23 @@ const ( ///////////////////////////// addAllowedStateControllerAddress ///////////////////////////// type AddAllowedStateControllerAddressFunc struct { - wasmclient.ClientFunc - args wasmclient.Arguments + wasmclient2.ClientFunc + args wasmclient2.Arguments } -func (f *AddAllowedStateControllerAddressFunc) ChainOwner(v wasmclient.AgentID) { +func (f *AddAllowedStateControllerAddressFunc) ChainOwner(v wasmclient2.AgentID) { f.args.Set(ArgChainOwner, f.args.FromAgentID(v)) } -func (f *AddAllowedStateControllerAddressFunc) FeeColor(v wasmclient.Color) { +func (f *AddAllowedStateControllerAddressFunc) FeeColor(v wasmclient2.Color) { f.args.Set(ArgFeeColor, f.args.FromColor(v)) } -func (f *AddAllowedStateControllerAddressFunc) StateControllerAddress(v wasmclient.Address) { +func (f *AddAllowedStateControllerAddressFunc) StateControllerAddress(v wasmclient2.Address) { f.args.Set(ArgStateControllerAddress, f.args.FromAddress(v)) } -func (f *AddAllowedStateControllerAddressFunc) Post() wasmclient.Request { +func (f *AddAllowedStateControllerAddressFunc) Post() wasmclient2.Request { f.args.Mandatory(ArgChainOwner) f.args.Mandatory(ArgStateControllerAddress) return f.ClientFunc.Post(0x9469d567, &f.args) @@ -62,25 +64,25 @@ func (f *AddAllowedStateControllerAddressFunc) Post() wasmclient.Request { ///////////////////////////// claimChainOwnership ///////////////////////////// type ClaimChainOwnershipFunc struct { - wasmclient.ClientFunc + wasmclient2.ClientFunc } -func (f *ClaimChainOwnershipFunc) Post() wasmclient.Request { +func (f *ClaimChainOwnershipFunc) Post() wasmclient2.Request { return f.ClientFunc.Post(0x03ff0fc0, nil) } ///////////////////////////// delegateChainOwnership ///////////////////////////// type DelegateChainOwnershipFunc struct { - wasmclient.ClientFunc - args wasmclient.Arguments + wasmclient2.ClientFunc + args wasmclient2.Arguments } -func (f *DelegateChainOwnershipFunc) ChainOwner(v wasmclient.AgentID) { +func (f *DelegateChainOwnershipFunc) ChainOwner(v wasmclient2.AgentID) { f.args.Set(ArgChainOwner, f.args.FromAgentID(v)) } -func (f *DelegateChainOwnershipFunc) Post() wasmclient.Request { +func (f *DelegateChainOwnershipFunc) Post() wasmclient2.Request { f.args.Mandatory(ArgChainOwner) return f.ClientFunc.Post(0x93ecb6ad, &f.args) } @@ -88,15 +90,15 @@ func (f *DelegateChainOwnershipFunc) Post() wasmclient.Request { ///////////////////////////// removeAllowedStateControllerAddress ///////////////////////////// type RemoveAllowedStateControllerAddressFunc struct { - wasmclient.ClientFunc - args wasmclient.Arguments + wasmclient2.ClientFunc + args wasmclient2.Arguments } -func (f *RemoveAllowedStateControllerAddressFunc) StateControllerAddress(v wasmclient.Address) { +func (f *RemoveAllowedStateControllerAddressFunc) StateControllerAddress(v wasmclient2.Address) { f.args.Set(ArgStateControllerAddress, f.args.FromAddress(v)) } -func (f *RemoveAllowedStateControllerAddressFunc) Post() wasmclient.Request { +func (f *RemoveAllowedStateControllerAddressFunc) Post() wasmclient2.Request { f.args.Mandatory(ArgStateControllerAddress) return f.ClientFunc.Post(0x31f69447, &f.args) } @@ -104,15 +106,15 @@ func (f *RemoveAllowedStateControllerAddressFunc) Post() wasmclient.Request { ///////////////////////////// rotateStateController ///////////////////////////// type RotateStateControllerFunc struct { - wasmclient.ClientFunc - args wasmclient.Arguments + wasmclient2.ClientFunc + args wasmclient2.Arguments } -func (f *RotateStateControllerFunc) StateControllerAddress(v wasmclient.Address) { +func (f *RotateStateControllerFunc) StateControllerAddress(v wasmclient2.Address) { f.args.Set(ArgStateControllerAddress, f.args.FromAddress(v)) } -func (f *RotateStateControllerFunc) Post() wasmclient.Request { +func (f *RotateStateControllerFunc) Post() wasmclient2.Request { f.args.Mandatory(ArgStateControllerAddress) return f.ClientFunc.Post(0x244d1038, &f.args) } @@ -120,8 +122,8 @@ func (f *RotateStateControllerFunc) Post() wasmclient.Request { ///////////////////////////// setChainInfo ///////////////////////////// type SetChainInfoFunc struct { - wasmclient.ClientFunc - args wasmclient.Arguments + wasmclient2.ClientFunc + args wasmclient2.Arguments } func (f *SetChainInfoFunc) MaxBlobSize(v int32) { @@ -144,18 +146,18 @@ func (f *SetChainInfoFunc) ValidatorFee(v int64) { f.args.Set(ArgValidatorFee, f.args.FromInt64(v)) } -func (f *SetChainInfoFunc) Post() wasmclient.Request { +func (f *SetChainInfoFunc) Post() wasmclient2.Request { return f.ClientFunc.Post(0x702f5d2b, &f.args) } ///////////////////////////// setContractFee ///////////////////////////// type SetContractFeeFunc struct { - wasmclient.ClientFunc - args wasmclient.Arguments + wasmclient2.ClientFunc + args wasmclient2.Arguments } -func (f *SetContractFeeFunc) Hname(v wasmclient.Hname) { +func (f *SetContractFeeFunc) Hname(v wasmclient2.Hname) { f.args.Set(ArgHname, f.args.FromHname(v)) } @@ -167,7 +169,7 @@ func (f *SetContractFeeFunc) ValidatorFee(v int64) { f.args.Set(ArgValidatorFee, f.args.FromInt64(v)) } -func (f *SetContractFeeFunc) Post() wasmclient.Request { +func (f *SetContractFeeFunc) Post() wasmclient2.Request { f.args.Mandatory(ArgHname) return f.ClientFunc.Post(0x8421a42b, &f.args) } @@ -175,8 +177,8 @@ func (f *SetContractFeeFunc) Post() wasmclient.Request { ///////////////////////////// setDefaultFee ///////////////////////////// type SetDefaultFeeFunc struct { - wasmclient.ClientFunc - args wasmclient.Arguments + wasmclient2.ClientFunc + args wasmclient2.Arguments } func (f *SetDefaultFeeFunc) OwnerFee(v int64) { @@ -187,14 +189,14 @@ func (f *SetDefaultFeeFunc) ValidatorFee(v int64) { f.args.Set(ArgValidatorFee, f.args.FromInt64(v)) } -func (f *SetDefaultFeeFunc) Post() wasmclient.Request { +func (f *SetDefaultFeeFunc) Post() wasmclient2.Request { return f.ClientFunc.Post(0x3310ecd0, &f.args) } ///////////////////////////// getAllowedStateControllerAddresses ///////////////////////////// type GetAllowedStateControllerAddressesView struct { - wasmclient.ClientView + wasmclient2.ClientView } func (f *GetAllowedStateControllerAddressesView) Call() GetAllowedStateControllerAddressesResults { @@ -203,7 +205,7 @@ func (f *GetAllowedStateControllerAddressesView) Call() GetAllowedStateControlle } type GetAllowedStateControllerAddressesResults struct { - res wasmclient.Results + res wasmclient2.Results } func (r *GetAllowedStateControllerAddressesResults) AllowedStateControllerAddresses() []byte { @@ -213,7 +215,7 @@ func (r *GetAllowedStateControllerAddressesResults) AllowedStateControllerAddres ///////////////////////////// getChainInfo ///////////////////////////// type GetChainInfoView struct { - wasmclient.ClientView + wasmclient2.ClientView } func (f *GetChainInfoView) Call() GetChainInfoResults { @@ -222,14 +224,14 @@ func (f *GetChainInfoView) Call() GetChainInfoResults { } type GetChainInfoResults struct { - res wasmclient.Results + res wasmclient2.Results } -func (r *GetChainInfoResults) ChainID() wasmclient.ChainID { +func (r *GetChainInfoResults) ChainID() wasmclient2.ChainID { return r.res.ToChainID(r.res.Get(ResChainID)) } -func (r *GetChainInfoResults) ChainOwnerID() wasmclient.AgentID { +func (r *GetChainInfoResults) ChainOwnerID() wasmclient2.AgentID { return r.res.ToAgentID(r.res.Get(ResChainOwnerID)) } @@ -245,7 +247,7 @@ func (r *GetChainInfoResults) Description() string { return r.res.ToString(r.res.Get(ResDescription)) } -func (r *GetChainInfoResults) FeeColor() wasmclient.Color { +func (r *GetChainInfoResults) FeeColor() wasmclient2.Color { return r.res.ToColor(r.res.Get(ResFeeColor)) } @@ -264,11 +266,11 @@ func (r *GetChainInfoResults) MaxEventsPerReq() int16 { ///////////////////////////// getFeeInfo ///////////////////////////// type GetFeeInfoView struct { - wasmclient.ClientView - args wasmclient.Arguments + wasmclient2.ClientView + args wasmclient2.Arguments } -func (f *GetFeeInfoView) Hname(v wasmclient.Hname) { +func (f *GetFeeInfoView) Hname(v wasmclient2.Hname) { f.args.Set(ArgHname, f.args.FromHname(v)) } @@ -279,10 +281,10 @@ func (f *GetFeeInfoView) Call() GetFeeInfoResults { } type GetFeeInfoResults struct { - res wasmclient.Results + res wasmclient2.Results } -func (r *GetFeeInfoResults) FeeColor() wasmclient.Color { +func (r *GetFeeInfoResults) FeeColor() wasmclient2.Color { return r.res.ToColor(r.res.Get(ResFeeColor)) } @@ -297,7 +299,7 @@ func (r *GetFeeInfoResults) ValidatorFee() int64 { ///////////////////////////// getMaxBlobSize ///////////////////////////// type GetMaxBlobSizeView struct { - wasmclient.ClientView + wasmclient2.ClientView } func (f *GetMaxBlobSizeView) Call() GetMaxBlobSizeResults { @@ -306,7 +308,7 @@ func (f *GetMaxBlobSizeView) Call() GetMaxBlobSizeResults { } type GetMaxBlobSizeResults struct { - res wasmclient.Results + res wasmclient2.Results } func (r *GetMaxBlobSizeResults) MaxBlobSize() int32 { @@ -316,10 +318,10 @@ func (r *GetMaxBlobSizeResults) MaxBlobSize() int32 { ///////////////////////////// CoreGovernanceService ///////////////////////////// type CoreGovernanceService struct { - wasmclient.Service + wasmclient2.Service } -func NewCoreGovernanceService(cl *wasmclient.ServiceClient, chainID string) (*CoreGovernanceService, error) { +func NewCoreGovernanceService(cl *wasmclient2.ServiceClient, chainID string) (*CoreGovernanceService, error) { s := &CoreGovernanceService{} err := s.Service.Init(cl, chainID, 0x17cf909f) return s, err diff --git a/packages/vm/wasmlib/go/wasmclient/coreroot/service.go b/packages/wasmvm/wasmlib/go/wasmclient/coreroot/service.go similarity index 77% rename from packages/vm/wasmlib/go/wasmclient/coreroot/service.go rename to packages/wasmvm/wasmlib/go/wasmclient/coreroot/service.go index 5b1cf896b7..353808f2fc 100644 --- a/packages/vm/wasmlib/go/wasmclient/coreroot/service.go +++ b/packages/wasmvm/wasmlib/go/wasmclient/coreroot/service.go @@ -7,7 +7,9 @@ package corerootclient -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmclient" +import ( + wasmclient2 "github.com/iotaledger/wasp/packages/wasmvm/wasmlib/go/wasmclient" +) const ( ArgDeployer = "dp" @@ -24,8 +26,8 @@ const ( ///////////////////////////// deployContract ///////////////////////////// type DeployContractFunc struct { - wasmclient.ClientFunc - args wasmclient.Arguments + wasmclient2.ClientFunc + args wasmclient2.Arguments } func (f *DeployContractFunc) Description(v string) { @@ -36,11 +38,11 @@ func (f *DeployContractFunc) Name(v string) { f.args.Set(ArgName, f.args.FromString(v)) } -func (f *DeployContractFunc) ProgramHash(v wasmclient.Hash) { +func (f *DeployContractFunc) ProgramHash(v wasmclient2.Hash) { f.args.Set(ArgProgramHash, f.args.FromHash(v)) } -func (f *DeployContractFunc) Post() wasmclient.Request { +func (f *DeployContractFunc) Post() wasmclient2.Request { f.args.Mandatory(ArgName) f.args.Mandatory(ArgProgramHash) return f.ClientFunc.Post(0x28232c27, &f.args) @@ -49,15 +51,15 @@ func (f *DeployContractFunc) Post() wasmclient.Request { ///////////////////////////// grantDeployPermission ///////////////////////////// type GrantDeployPermissionFunc struct { - wasmclient.ClientFunc - args wasmclient.Arguments + wasmclient2.ClientFunc + args wasmclient2.Arguments } -func (f *GrantDeployPermissionFunc) Deployer(v wasmclient.AgentID) { +func (f *GrantDeployPermissionFunc) Deployer(v wasmclient2.AgentID) { f.args.Set(ArgDeployer, f.args.FromAgentID(v)) } -func (f *GrantDeployPermissionFunc) Post() wasmclient.Request { +func (f *GrantDeployPermissionFunc) Post() wasmclient2.Request { f.args.Mandatory(ArgDeployer) return f.ClientFunc.Post(0xf440263a, &f.args) } @@ -65,15 +67,15 @@ func (f *GrantDeployPermissionFunc) Post() wasmclient.Request { ///////////////////////////// revokeDeployPermission ///////////////////////////// type RevokeDeployPermissionFunc struct { - wasmclient.ClientFunc - args wasmclient.Arguments + wasmclient2.ClientFunc + args wasmclient2.Arguments } -func (f *RevokeDeployPermissionFunc) Deployer(v wasmclient.AgentID) { +func (f *RevokeDeployPermissionFunc) Deployer(v wasmclient2.AgentID) { f.args.Set(ArgDeployer, f.args.FromAgentID(v)) } -func (f *RevokeDeployPermissionFunc) Post() wasmclient.Request { +func (f *RevokeDeployPermissionFunc) Post() wasmclient2.Request { f.args.Mandatory(ArgDeployer) return f.ClientFunc.Post(0x850744f1, &f.args) } @@ -81,11 +83,11 @@ func (f *RevokeDeployPermissionFunc) Post() wasmclient.Request { ///////////////////////////// findContract ///////////////////////////// type FindContractView struct { - wasmclient.ClientView - args wasmclient.Arguments + wasmclient2.ClientView + args wasmclient2.Arguments } -func (f *FindContractView) Hname(v wasmclient.Hname) { +func (f *FindContractView) Hname(v wasmclient2.Hname) { f.args.Set(ArgHname, f.args.FromHname(v)) } @@ -96,7 +98,7 @@ func (f *FindContractView) Call() FindContractResults { } type FindContractResults struct { - res wasmclient.Results + res wasmclient2.Results } func (r *FindContractResults) ContractFound() []byte { @@ -110,7 +112,7 @@ func (r *FindContractResults) ContractRecData() []byte { ///////////////////////////// getContractRecords ///////////////////////////// type GetContractRecordsView struct { - wasmclient.ClientView + wasmclient2.ClientView } func (f *GetContractRecordsView) Call() GetContractRecordsResults { @@ -119,11 +121,11 @@ func (f *GetContractRecordsView) Call() GetContractRecordsResults { } type GetContractRecordsResults struct { - res wasmclient.Results + res wasmclient2.Results } -func (r *GetContractRecordsResults) ContractRegistry() map[wasmclient.Hname][]byte { - res := make(map[wasmclient.Hname][]byte) +func (r *GetContractRecordsResults) ContractRegistry() map[wasmclient2.Hname][]byte { + res := make(map[wasmclient2.Hname][]byte) r.res.ForEach(func(key []byte, val []byte) { res[r.res.ToHname(key)] = r.res.ToBytes(val) }) @@ -133,10 +135,10 @@ func (r *GetContractRecordsResults) ContractRegistry() map[wasmclient.Hname][]by ///////////////////////////// CoreRootService ///////////////////////////// type CoreRootService struct { - wasmclient.Service + wasmclient2.Service } -func NewCoreRootService(cl *wasmclient.ServiceClient, chainID string) (*CoreRootService, error) { +func NewCoreRootService(cl *wasmclient2.ServiceClient, chainID string) (*CoreRootService, error) { s := &CoreRootService{} err := s.Service.Init(cl, chainID, 0xcebf5908) return s, err diff --git a/packages/vm/wasmlib/go/wasmclient/decoder.go b/packages/wasmvm/wasmlib/go/wasmclient/decoder.go similarity index 100% rename from packages/vm/wasmlib/go/wasmclient/decoder.go rename to packages/wasmvm/wasmlib/go/wasmclient/decoder.go diff --git a/packages/vm/wasmlib/go/wasmclient/encoder.go b/packages/wasmvm/wasmlib/go/wasmclient/encoder.go similarity index 100% rename from packages/vm/wasmlib/go/wasmclient/encoder.go rename to packages/wasmvm/wasmlib/go/wasmclient/encoder.go diff --git a/packages/vm/wasmlib/go/wasmclient/event.go b/packages/wasmvm/wasmlib/go/wasmclient/event.go similarity index 100% rename from packages/vm/wasmlib/go/wasmclient/event.go rename to packages/wasmvm/wasmlib/go/wasmclient/event.go diff --git a/packages/vm/wasmlib/go/wasmclient/request.go b/packages/wasmvm/wasmlib/go/wasmclient/request.go similarity index 100% rename from packages/vm/wasmlib/go/wasmclient/request.go rename to packages/wasmvm/wasmlib/go/wasmclient/request.go diff --git a/packages/vm/wasmlib/go/wasmclient/results.go b/packages/wasmvm/wasmlib/go/wasmclient/results.go similarity index 100% rename from packages/vm/wasmlib/go/wasmclient/results.go rename to packages/wasmvm/wasmlib/go/wasmclient/results.go diff --git a/packages/vm/wasmlib/go/wasmclient/seed.go b/packages/wasmvm/wasmlib/go/wasmclient/seed.go similarity index 100% rename from packages/vm/wasmlib/go/wasmclient/seed.go rename to packages/wasmvm/wasmlib/go/wasmclient/seed.go diff --git a/packages/vm/wasmlib/go/wasmclient/service.go b/packages/wasmvm/wasmlib/go/wasmclient/service.go similarity index 100% rename from packages/vm/wasmlib/go/wasmclient/service.go rename to packages/wasmvm/wasmlib/go/wasmclient/service.go diff --git a/packages/vm/wasmlib/go/wasmclient/serviceclient.go b/packages/wasmvm/wasmlib/go/wasmclient/serviceclient.go similarity index 100% rename from packages/vm/wasmlib/go/wasmclient/serviceclient.go rename to packages/wasmvm/wasmlib/go/wasmclient/serviceclient.go diff --git a/packages/vm/wasmlib/go/wasmclient/transfer.go b/packages/wasmvm/wasmlib/go/wasmclient/transfer.go similarity index 100% rename from packages/vm/wasmlib/go/wasmclient/transfer.go rename to packages/wasmvm/wasmlib/go/wasmclient/transfer.go diff --git a/packages/vm/wasmlib/go/wasmclient/types.go b/packages/wasmvm/wasmlib/go/wasmclient/types.go similarity index 100% rename from packages/vm/wasmlib/go/wasmclient/types.go rename to packages/wasmvm/wasmlib/go/wasmclient/types.go diff --git a/packages/vm/wasmlib/go/wasmclient/wasmrequests/service.go b/packages/wasmvm/wasmlib/go/wasmclient/wasmrequests/service.go similarity index 100% rename from packages/vm/wasmlib/go/wasmclient/wasmrequests/service.go rename to packages/wasmvm/wasmlib/go/wasmclient/wasmrequests/service.go diff --git a/packages/vm/wasmlib/go/wasmlib/assets.go b/packages/wasmvm/wasmlib/go/wasmlib/assets.go similarity index 97% rename from packages/vm/wasmlib/go/wasmlib/assets.go rename to packages/wasmvm/wasmlib/go/wasmlib/assets.go index ea9151ee33..011d312018 100644 --- a/packages/vm/wasmlib/go/wasmlib/assets.go +++ b/packages/wasmvm/wasmlib/go/wasmlib/assets.go @@ -6,7 +6,7 @@ package wasmlib import ( "sort" - "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" + "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" ) type ScAssets map[wasmtypes.ScColor]uint64 diff --git a/packages/vm/wasmlib/go/wasmlib/context.go b/packages/wasmvm/wasmlib/go/wasmlib/context.go similarity index 94% rename from packages/vm/wasmlib/go/wasmlib/context.go rename to packages/wasmvm/wasmlib/go/wasmlib/context.go index 7a0301d7f9..2d10538f00 100644 --- a/packages/vm/wasmlib/go/wasmlib/context.go +++ b/packages/wasmvm/wasmlib/go/wasmlib/context.go @@ -6,7 +6,7 @@ package wasmlib import ( - "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" + "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" ) // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ diff --git a/packages/vm/wasmlib/go/wasmlib/contract.go b/packages/wasmvm/wasmlib/go/wasmlib/contract.go similarity index 96% rename from packages/vm/wasmlib/go/wasmlib/contract.go rename to packages/wasmvm/wasmlib/go/wasmlib/contract.go index f5e9c132ff..3d4a2bb06c 100644 --- a/packages/vm/wasmlib/go/wasmlib/contract.go +++ b/packages/wasmvm/wasmlib/go/wasmlib/contract.go @@ -4,8 +4,8 @@ package wasmlib import ( - "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmrequests" - "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" + "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmrequests" + "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" ) type ScFuncCallContext interface { diff --git a/packages/vm/wasmlib/go/wasmlib/coreaccounts/consts.go b/packages/wasmvm/wasmlib/go/wasmlib/coreaccounts/consts.go similarity index 93% rename from packages/vm/wasmlib/go/wasmlib/coreaccounts/consts.go rename to packages/wasmvm/wasmlib/go/wasmlib/coreaccounts/consts.go index 2e98e2cbb3..c217eaa8f8 100644 --- a/packages/vm/wasmlib/go/wasmlib/coreaccounts/consts.go +++ b/packages/wasmvm/wasmlib/go/wasmlib/coreaccounts/consts.go @@ -7,7 +7,7 @@ package coreaccounts -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" +import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" const ( ScName = "accounts" diff --git a/packages/vm/wasmlib/go/wasmlib/coreaccounts/contract.go b/packages/wasmvm/wasmlib/go/wasmlib/coreaccounts/contract.go similarity index 97% rename from packages/vm/wasmlib/go/wasmlib/coreaccounts/contract.go rename to packages/wasmvm/wasmlib/go/wasmlib/coreaccounts/contract.go index fdb8764ea8..0565bb1ef3 100644 --- a/packages/vm/wasmlib/go/wasmlib/coreaccounts/contract.go +++ b/packages/wasmvm/wasmlib/go/wasmlib/coreaccounts/contract.go @@ -7,7 +7,7 @@ package coreaccounts -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" +import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib" type DepositCall struct { Func *wasmlib.ScFunc diff --git a/packages/vm/wasmlib/go/wasmlib/coreaccounts/params.go b/packages/wasmvm/wasmlib/go/wasmlib/coreaccounts/params.go similarity index 96% rename from packages/vm/wasmlib/go/wasmlib/coreaccounts/params.go rename to packages/wasmvm/wasmlib/go/wasmlib/coreaccounts/params.go index afe5b847fb..29bf9934d7 100644 --- a/packages/vm/wasmlib/go/wasmlib/coreaccounts/params.go +++ b/packages/wasmvm/wasmlib/go/wasmlib/coreaccounts/params.go @@ -7,7 +7,7 @@ package coreaccounts -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" +import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" type ImmutableDepositParams struct { proxy wasmtypes.Proxy diff --git a/packages/vm/wasmlib/go/wasmlib/coreaccounts/results.go b/packages/wasmvm/wasmlib/go/wasmlib/coreaccounts/results.go similarity index 97% rename from packages/vm/wasmlib/go/wasmlib/coreaccounts/results.go rename to packages/wasmvm/wasmlib/go/wasmlib/coreaccounts/results.go index eaf9429363..1dcd428609 100644 --- a/packages/vm/wasmlib/go/wasmlib/coreaccounts/results.go +++ b/packages/wasmvm/wasmlib/go/wasmlib/coreaccounts/results.go @@ -7,7 +7,7 @@ package coreaccounts -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" +import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" type MapAgentIDToImmutableBytes struct { proxy wasmtypes.Proxy diff --git a/packages/vm/wasmlib/go/wasmlib/coreblob/consts.go b/packages/wasmvm/wasmlib/go/wasmlib/coreblob/consts.go similarity index 91% rename from packages/vm/wasmlib/go/wasmlib/coreblob/consts.go rename to packages/wasmvm/wasmlib/go/wasmlib/coreblob/consts.go index 2378a1b724..30d2f077f9 100644 --- a/packages/vm/wasmlib/go/wasmlib/coreblob/consts.go +++ b/packages/wasmvm/wasmlib/go/wasmlib/coreblob/consts.go @@ -7,7 +7,7 @@ package coreblob -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" +import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" const ( ScName = "blob" diff --git a/packages/vm/wasmlib/go/wasmlib/coreblob/contract.go b/packages/wasmvm/wasmlib/go/wasmlib/coreblob/contract.go similarity index 96% rename from packages/vm/wasmlib/go/wasmlib/coreblob/contract.go rename to packages/wasmvm/wasmlib/go/wasmlib/coreblob/contract.go index 8f21673915..b7bc4ee031 100644 --- a/packages/vm/wasmlib/go/wasmlib/coreblob/contract.go +++ b/packages/wasmvm/wasmlib/go/wasmlib/coreblob/contract.go @@ -7,7 +7,7 @@ package coreblob -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" +import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib" type StoreBlobCall struct { Func *wasmlib.ScFunc diff --git a/packages/vm/wasmlib/go/wasmlib/coreblob/params.go b/packages/wasmvm/wasmlib/go/wasmlib/coreblob/params.go similarity index 96% rename from packages/vm/wasmlib/go/wasmlib/coreblob/params.go rename to packages/wasmvm/wasmlib/go/wasmlib/coreblob/params.go index 33c126a634..c085dadc86 100644 --- a/packages/vm/wasmlib/go/wasmlib/coreblob/params.go +++ b/packages/wasmvm/wasmlib/go/wasmlib/coreblob/params.go @@ -7,7 +7,7 @@ package coreblob -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" +import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" type MapStringToImmutableBytes struct { proxy wasmtypes.Proxy diff --git a/packages/vm/wasmlib/go/wasmlib/coreblob/results.go b/packages/wasmvm/wasmlib/go/wasmlib/coreblob/results.go similarity index 97% rename from packages/vm/wasmlib/go/wasmlib/coreblob/results.go rename to packages/wasmvm/wasmlib/go/wasmlib/coreblob/results.go index a55b75cdc4..70cf755651 100644 --- a/packages/vm/wasmlib/go/wasmlib/coreblob/results.go +++ b/packages/wasmvm/wasmlib/go/wasmlib/coreblob/results.go @@ -7,7 +7,7 @@ package coreblob -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" +import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" type ImmutableStoreBlobResults struct { proxy wasmtypes.Proxy diff --git a/packages/vm/wasmlib/go/wasmlib/coreblocklog/consts.go b/packages/wasmvm/wasmlib/go/wasmlib/coreblocklog/consts.go similarity index 96% rename from packages/vm/wasmlib/go/wasmlib/coreblocklog/consts.go rename to packages/wasmvm/wasmlib/go/wasmlib/coreblocklog/consts.go index 7879542162..33db5e3a36 100644 --- a/packages/vm/wasmlib/go/wasmlib/coreblocklog/consts.go +++ b/packages/wasmvm/wasmlib/go/wasmlib/coreblocklog/consts.go @@ -7,7 +7,7 @@ package coreblocklog -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" +import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" const ( ScName = "blocklog" diff --git a/packages/vm/wasmlib/go/wasmlib/coreblocklog/contract.go b/packages/wasmvm/wasmlib/go/wasmlib/coreblocklog/contract.go similarity index 98% rename from packages/vm/wasmlib/go/wasmlib/coreblocklog/contract.go rename to packages/wasmvm/wasmlib/go/wasmlib/coreblocklog/contract.go index 17386d86ed..13b594dc2d 100644 --- a/packages/vm/wasmlib/go/wasmlib/coreblocklog/contract.go +++ b/packages/wasmvm/wasmlib/go/wasmlib/coreblocklog/contract.go @@ -7,7 +7,7 @@ package coreblocklog -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" +import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib" type ControlAddressesCall struct { Func *wasmlib.ScView diff --git a/packages/vm/wasmlib/go/wasmlib/coreblocklog/params.go b/packages/wasmvm/wasmlib/go/wasmlib/coreblocklog/params.go similarity index 98% rename from packages/vm/wasmlib/go/wasmlib/coreblocklog/params.go rename to packages/wasmvm/wasmlib/go/wasmlib/coreblocklog/params.go index c36be0377e..878ff16693 100644 --- a/packages/vm/wasmlib/go/wasmlib/coreblocklog/params.go +++ b/packages/wasmvm/wasmlib/go/wasmlib/coreblocklog/params.go @@ -7,7 +7,7 @@ package coreblocklog -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" +import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" type ImmutableGetBlockInfoParams struct { proxy wasmtypes.Proxy diff --git a/packages/vm/wasmlib/go/wasmlib/coreblocklog/results.go b/packages/wasmvm/wasmlib/go/wasmlib/coreblocklog/results.go similarity index 99% rename from packages/vm/wasmlib/go/wasmlib/coreblocklog/results.go rename to packages/wasmvm/wasmlib/go/wasmlib/coreblocklog/results.go index 0b9bce761d..29fe73c167 100644 --- a/packages/vm/wasmlib/go/wasmlib/coreblocklog/results.go +++ b/packages/wasmvm/wasmlib/go/wasmlib/coreblocklog/results.go @@ -7,7 +7,7 @@ package coreblocklog -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" +import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" type ImmutableControlAddressesResults struct { proxy wasmtypes.Proxy diff --git a/packages/vm/wasmlib/go/wasmlib/coregovernance/consts.go b/packages/wasmvm/wasmlib/go/wasmlib/coregovernance/consts.go similarity index 97% rename from packages/vm/wasmlib/go/wasmlib/coregovernance/consts.go rename to packages/wasmvm/wasmlib/go/wasmlib/coregovernance/consts.go index 5e1e2221fd..f152f1b48c 100644 --- a/packages/vm/wasmlib/go/wasmlib/coregovernance/consts.go +++ b/packages/wasmvm/wasmlib/go/wasmlib/coregovernance/consts.go @@ -7,7 +7,7 @@ package coregovernance -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" +import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" const ( ScName = "governance" diff --git a/packages/vm/wasmlib/go/wasmlib/coregovernance/contract.go b/packages/wasmvm/wasmlib/go/wasmlib/coregovernance/contract.go similarity index 98% rename from packages/vm/wasmlib/go/wasmlib/coregovernance/contract.go rename to packages/wasmvm/wasmlib/go/wasmlib/coregovernance/contract.go index 8ea58578ab..4ba2946eba 100644 --- a/packages/vm/wasmlib/go/wasmlib/coregovernance/contract.go +++ b/packages/wasmvm/wasmlib/go/wasmlib/coregovernance/contract.go @@ -7,7 +7,7 @@ package coregovernance -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" +import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib" type AddAllowedStateControllerAddressCall struct { Func *wasmlib.ScFunc diff --git a/packages/vm/wasmlib/go/wasmlib/coregovernance/params.go b/packages/wasmvm/wasmlib/go/wasmlib/coregovernance/params.go similarity index 98% rename from packages/vm/wasmlib/go/wasmlib/coregovernance/params.go rename to packages/wasmvm/wasmlib/go/wasmlib/coregovernance/params.go index d4798d9484..a173796187 100644 --- a/packages/vm/wasmlib/go/wasmlib/coregovernance/params.go +++ b/packages/wasmvm/wasmlib/go/wasmlib/coregovernance/params.go @@ -7,7 +7,7 @@ package coregovernance -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" +import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" type ImmutableAddAllowedStateControllerAddressParams struct { proxy wasmtypes.Proxy diff --git a/packages/vm/wasmlib/go/wasmlib/coregovernance/results.go b/packages/wasmvm/wasmlib/go/wasmlib/coregovernance/results.go similarity index 98% rename from packages/vm/wasmlib/go/wasmlib/coregovernance/results.go rename to packages/wasmvm/wasmlib/go/wasmlib/coregovernance/results.go index e482d8df9b..e805a79711 100644 --- a/packages/vm/wasmlib/go/wasmlib/coregovernance/results.go +++ b/packages/wasmvm/wasmlib/go/wasmlib/coregovernance/results.go @@ -7,7 +7,7 @@ package coregovernance -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" +import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" type ArrayOfImmutableBytes struct { proxy wasmtypes.Proxy diff --git a/packages/vm/wasmlib/go/wasmlib/coreroot/consts.go b/packages/wasmvm/wasmlib/go/wasmlib/coreroot/consts.go similarity index 93% rename from packages/vm/wasmlib/go/wasmlib/coreroot/consts.go rename to packages/wasmvm/wasmlib/go/wasmlib/coreroot/consts.go index 56bd94dba6..ebcb63ec6b 100644 --- a/packages/vm/wasmlib/go/wasmlib/coreroot/consts.go +++ b/packages/wasmvm/wasmlib/go/wasmlib/coreroot/consts.go @@ -7,7 +7,7 @@ package coreroot -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" +import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" const ( ScName = "root" diff --git a/packages/vm/wasmlib/go/wasmlib/coreroot/contract.go b/packages/wasmvm/wasmlib/go/wasmlib/coreroot/contract.go similarity index 97% rename from packages/vm/wasmlib/go/wasmlib/coreroot/contract.go rename to packages/wasmvm/wasmlib/go/wasmlib/coreroot/contract.go index a857945095..22a89c616e 100644 --- a/packages/vm/wasmlib/go/wasmlib/coreroot/contract.go +++ b/packages/wasmvm/wasmlib/go/wasmlib/coreroot/contract.go @@ -7,7 +7,7 @@ package coreroot -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" +import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib" type DeployContractCall struct { Func *wasmlib.ScFunc diff --git a/packages/vm/wasmlib/go/wasmlib/coreroot/params.go b/packages/wasmvm/wasmlib/go/wasmlib/coreroot/params.go similarity index 97% rename from packages/vm/wasmlib/go/wasmlib/coreroot/params.go rename to packages/wasmvm/wasmlib/go/wasmlib/coreroot/params.go index db4108ff75..36bcfa9240 100644 --- a/packages/vm/wasmlib/go/wasmlib/coreroot/params.go +++ b/packages/wasmvm/wasmlib/go/wasmlib/coreroot/params.go @@ -7,7 +7,7 @@ package coreroot -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" +import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" type ImmutableDeployContractParams struct { proxy wasmtypes.Proxy diff --git a/packages/vm/wasmlib/go/wasmlib/coreroot/results.go b/packages/wasmvm/wasmlib/go/wasmlib/coreroot/results.go similarity index 96% rename from packages/vm/wasmlib/go/wasmlib/coreroot/results.go rename to packages/wasmvm/wasmlib/go/wasmlib/coreroot/results.go index 869af58b69..06db8d11cc 100644 --- a/packages/vm/wasmlib/go/wasmlib/coreroot/results.go +++ b/packages/wasmvm/wasmlib/go/wasmlib/coreroot/results.go @@ -7,7 +7,7 @@ package coreroot -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" +import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" type ImmutableFindContractResults struct { proxy wasmtypes.Proxy diff --git a/packages/vm/wasmlib/go/wasmlib/dict.go b/packages/wasmvm/wasmlib/go/wasmlib/dict.go similarity index 96% rename from packages/vm/wasmlib/go/wasmlib/dict.go rename to packages/wasmvm/wasmlib/go/wasmlib/dict.go index 2e63a5445b..a859474dab 100644 --- a/packages/vm/wasmlib/go/wasmlib/dict.go +++ b/packages/wasmvm/wasmlib/go/wasmlib/dict.go @@ -6,7 +6,7 @@ package wasmlib import ( "sort" - "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" + "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" ) type ScDict map[string][]byte diff --git a/packages/vm/wasmlib/go/wasmlib/events.go b/packages/wasmvm/wasmlib/go/wasmlib/events.go similarity index 89% rename from packages/vm/wasmlib/go/wasmlib/events.go rename to packages/wasmvm/wasmlib/go/wasmlib/events.go index 38ad2db8e0..cbae89a9e2 100644 --- a/packages/vm/wasmlib/go/wasmlib/events.go +++ b/packages/wasmvm/wasmlib/go/wasmlib/events.go @@ -4,7 +4,7 @@ package wasmlib import ( - "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" + "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" ) type EventEncoder struct { diff --git a/packages/vm/wasmlib/go/wasmlib/exports.go b/packages/wasmvm/wasmlib/go/wasmlib/exports.go similarity index 100% rename from packages/vm/wasmlib/go/wasmlib/exports.go rename to packages/wasmvm/wasmlib/go/wasmlib/exports.go diff --git a/packages/vm/wasmlib/go/wasmlib/host.go b/packages/wasmvm/wasmlib/go/wasmlib/host.go similarity index 100% rename from packages/vm/wasmlib/go/wasmlib/host.go rename to packages/wasmvm/wasmlib/go/wasmlib/host.go diff --git a/packages/vm/wasmlib/go/wasmlib/inithost.go b/packages/wasmvm/wasmlib/go/wasmlib/inithost.go similarity index 100% rename from packages/vm/wasmlib/go/wasmlib/inithost.go rename to packages/wasmvm/wasmlib/go/wasmlib/inithost.go diff --git a/packages/vm/wasmlib/go/wasmlib/sandbox.go b/packages/wasmvm/wasmlib/go/wasmlib/sandbox.go similarity index 98% rename from packages/vm/wasmlib/go/wasmlib/sandbox.go rename to packages/wasmvm/wasmlib/go/wasmlib/sandbox.go index 05bc8c7fe1..9f70a7007b 100644 --- a/packages/vm/wasmlib/go/wasmlib/sandbox.go +++ b/packages/wasmvm/wasmlib/go/wasmlib/sandbox.go @@ -6,8 +6,8 @@ package wasmlib import ( "encoding/binary" - "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmrequests" - "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" + "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmrequests" + "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" ) const ( diff --git a/packages/vm/wasmlib/go/wasmlib/sandboxutils.go b/packages/wasmvm/wasmlib/go/wasmlib/sandboxutils.go similarity index 97% rename from packages/vm/wasmlib/go/wasmlib/sandboxutils.go rename to packages/wasmvm/wasmlib/go/wasmlib/sandboxutils.go index 8d4769dd6d..31419d40dd 100644 --- a/packages/vm/wasmlib/go/wasmlib/sandboxutils.go +++ b/packages/wasmvm/wasmlib/go/wasmlib/sandboxutils.go @@ -4,7 +4,7 @@ package wasmlib import ( - "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" + "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" ) type ScSandboxUtils struct{} diff --git a/packages/vm/wasmlib/go/wasmlib/state.go b/packages/wasmvm/wasmlib/go/wasmlib/state.go similarity index 90% rename from packages/vm/wasmlib/go/wasmlib/state.go rename to packages/wasmvm/wasmlib/go/wasmlib/state.go index 07cbc78b90..67abe53b2f 100644 --- a/packages/vm/wasmlib/go/wasmlib/state.go +++ b/packages/wasmvm/wasmlib/go/wasmlib/state.go @@ -4,7 +4,7 @@ package wasmlib import ( - "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" + "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" ) type ScImmutableState struct{} diff --git a/packages/vm/wasmlib/go/wasmlib/wasmrequests/consts.go b/packages/wasmvm/wasmlib/go/wasmlib/wasmrequests/consts.go similarity index 81% rename from packages/vm/wasmlib/go/wasmlib/wasmrequests/consts.go rename to packages/wasmvm/wasmlib/go/wasmlib/wasmrequests/consts.go index ec615e944a..6d57f7d9a1 100644 --- a/packages/vm/wasmlib/go/wasmlib/wasmrequests/consts.go +++ b/packages/wasmvm/wasmlib/go/wasmlib/wasmrequests/consts.go @@ -7,7 +7,7 @@ package wasmrequests -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" +import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" const ( ScName = "requests" diff --git a/packages/vm/wasmlib/go/wasmlib/wasmrequests/contract.go b/packages/wasmvm/wasmlib/go/wasmlib/wasmrequests/contract.go similarity index 100% rename from packages/vm/wasmlib/go/wasmlib/wasmrequests/contract.go rename to packages/wasmvm/wasmlib/go/wasmlib/wasmrequests/contract.go diff --git a/packages/vm/wasmlib/go/wasmlib/wasmrequests/structs.go b/packages/wasmvm/wasmlib/go/wasmlib/wasmrequests/structs.go similarity index 98% rename from packages/vm/wasmlib/go/wasmlib/wasmrequests/structs.go rename to packages/wasmvm/wasmlib/go/wasmlib/wasmrequests/structs.go index 6bb15070d6..e456e4b023 100644 --- a/packages/vm/wasmlib/go/wasmlib/wasmrequests/structs.go +++ b/packages/wasmvm/wasmlib/go/wasmlib/wasmrequests/structs.go @@ -7,7 +7,7 @@ package wasmrequests -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" +import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" type CallRequest struct { Contract wasmtypes.ScHname diff --git a/packages/vm/wasmlib/go/wasmlib/wasmtypes/address.go b/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/address.go similarity index 100% rename from packages/vm/wasmlib/go/wasmlib/wasmtypes/address.go rename to packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/address.go diff --git a/packages/vm/wasmlib/go/wasmlib/wasmtypes/agentid.go b/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/agentid.go similarity index 100% rename from packages/vm/wasmlib/go/wasmlib/wasmtypes/agentid.go rename to packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/agentid.go diff --git a/packages/vm/wasmlib/go/wasmlib/wasmtypes/bool.go b/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/bool.go similarity index 100% rename from packages/vm/wasmlib/go/wasmlib/wasmtypes/bool.go rename to packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/bool.go diff --git a/packages/vm/wasmlib/go/wasmlib/wasmtypes/bytes.go b/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/bytes.go similarity index 100% rename from packages/vm/wasmlib/go/wasmlib/wasmtypes/bytes.go rename to packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/bytes.go diff --git a/packages/vm/wasmlib/go/wasmlib/wasmtypes/chainid.go b/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/chainid.go similarity index 100% rename from packages/vm/wasmlib/go/wasmlib/wasmtypes/chainid.go rename to packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/chainid.go diff --git a/packages/vm/wasmlib/go/wasmlib/wasmtypes/codec.go b/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/codec.go similarity index 100% rename from packages/vm/wasmlib/go/wasmlib/wasmtypes/codec.go rename to packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/codec.go diff --git a/packages/vm/wasmlib/go/wasmlib/wasmtypes/color.go b/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/color.go similarity index 100% rename from packages/vm/wasmlib/go/wasmlib/wasmtypes/color.go rename to packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/color.go diff --git a/packages/vm/wasmlib/go/wasmlib/wasmtypes/hash.go b/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/hash.go similarity index 100% rename from packages/vm/wasmlib/go/wasmlib/wasmtypes/hash.go rename to packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/hash.go diff --git a/packages/vm/wasmlib/go/wasmlib/wasmtypes/hname.go b/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/hname.go similarity index 100% rename from packages/vm/wasmlib/go/wasmlib/wasmtypes/hname.go rename to packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/hname.go diff --git a/packages/vm/wasmlib/go/wasmlib/wasmtypes/int16.go b/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/int16.go similarity index 100% rename from packages/vm/wasmlib/go/wasmlib/wasmtypes/int16.go rename to packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/int16.go diff --git a/packages/vm/wasmlib/go/wasmlib/wasmtypes/int32.go b/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/int32.go similarity index 100% rename from packages/vm/wasmlib/go/wasmlib/wasmtypes/int32.go rename to packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/int32.go diff --git a/packages/vm/wasmlib/go/wasmlib/wasmtypes/int64.go b/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/int64.go similarity index 100% rename from packages/vm/wasmlib/go/wasmlib/wasmtypes/int64.go rename to packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/int64.go diff --git a/packages/vm/wasmlib/go/wasmlib/wasmtypes/int8.go b/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/int8.go similarity index 100% rename from packages/vm/wasmlib/go/wasmlib/wasmtypes/int8.go rename to packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/int8.go diff --git a/packages/vm/wasmlib/go/wasmlib/wasmtypes/proxy.go b/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/proxy.go similarity index 100% rename from packages/vm/wasmlib/go/wasmlib/wasmtypes/proxy.go rename to packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/proxy.go diff --git a/packages/vm/wasmlib/go/wasmlib/wasmtypes/requestid.go b/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/requestid.go similarity index 100% rename from packages/vm/wasmlib/go/wasmlib/wasmtypes/requestid.go rename to packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/requestid.go diff --git a/packages/vm/wasmlib/go/wasmlib/wasmtypes/string.go b/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/string.go similarity index 100% rename from packages/vm/wasmlib/go/wasmlib/wasmtypes/string.go rename to packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/string.go diff --git a/packages/vm/wasmlib/go/wasmlib/wasmtypes/uint16.go b/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/uint16.go similarity index 100% rename from packages/vm/wasmlib/go/wasmlib/wasmtypes/uint16.go rename to packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/uint16.go diff --git a/packages/vm/wasmlib/go/wasmlib/wasmtypes/uint32.go b/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/uint32.go similarity index 100% rename from packages/vm/wasmlib/go/wasmlib/wasmtypes/uint32.go rename to packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/uint32.go diff --git a/packages/vm/wasmlib/go/wasmlib/wasmtypes/uint64.go b/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/uint64.go similarity index 100% rename from packages/vm/wasmlib/go/wasmlib/wasmtypes/uint64.go rename to packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/uint64.go diff --git a/packages/vm/wasmlib/go/wasmlib/wasmtypes/uint8.go b/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/uint8.go similarity index 100% rename from packages/vm/wasmlib/go/wasmlib/wasmtypes/uint8.go rename to packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/uint8.go diff --git a/packages/vm/wasmlib/interfaces/coreaccounts.yaml b/packages/wasmvm/wasmlib/interfaces/coreaccounts.yaml similarity index 100% rename from packages/vm/wasmlib/interfaces/coreaccounts.yaml rename to packages/wasmvm/wasmlib/interfaces/coreaccounts.yaml diff --git a/packages/vm/wasmlib/interfaces/coreblob.yaml b/packages/wasmvm/wasmlib/interfaces/coreblob.yaml similarity index 100% rename from packages/vm/wasmlib/interfaces/coreblob.yaml rename to packages/wasmvm/wasmlib/interfaces/coreblob.yaml diff --git a/packages/vm/wasmlib/interfaces/coreblocklog.yaml b/packages/wasmvm/wasmlib/interfaces/coreblocklog.yaml similarity index 100% rename from packages/vm/wasmlib/interfaces/coreblocklog.yaml rename to packages/wasmvm/wasmlib/interfaces/coreblocklog.yaml diff --git a/packages/vm/wasmlib/interfaces/coregovernance.yaml b/packages/wasmvm/wasmlib/interfaces/coregovernance.yaml similarity index 100% rename from packages/vm/wasmlib/interfaces/coregovernance.yaml rename to packages/wasmvm/wasmlib/interfaces/coregovernance.yaml diff --git a/packages/vm/wasmlib/interfaces/coreroot.yaml b/packages/wasmvm/wasmlib/interfaces/coreroot.yaml similarity index 100% rename from packages/vm/wasmlib/interfaces/coreroot.yaml rename to packages/wasmvm/wasmlib/interfaces/coreroot.yaml diff --git a/packages/vm/wasmlib/interfaces/wasmrequests.yaml b/packages/wasmvm/wasmlib/interfaces/wasmrequests.yaml similarity index 100% rename from packages/vm/wasmlib/interfaces/wasmrequests.yaml rename to packages/wasmvm/wasmlib/interfaces/wasmrequests.yaml diff --git a/packages/vm/wasmlib/src/bytes.rs b/packages/wasmvm/wasmlib/src/bytes.rs similarity index 100% rename from packages/vm/wasmlib/src/bytes.rs rename to packages/wasmvm/wasmlib/src/bytes.rs diff --git a/packages/vm/wasmlib/src/context.rs b/packages/wasmvm/wasmlib/src/context.rs similarity index 100% rename from packages/vm/wasmlib/src/context.rs rename to packages/wasmvm/wasmlib/src/context.rs diff --git a/packages/vm/wasmlib/src/contract.rs b/packages/wasmvm/wasmlib/src/contract.rs similarity index 100% rename from packages/vm/wasmlib/src/contract.rs rename to packages/wasmvm/wasmlib/src/contract.rs diff --git a/packages/vm/wasmlib/src/coreaccounts/consts.rs b/packages/wasmvm/wasmlib/src/coreaccounts/consts.rs similarity index 100% rename from packages/vm/wasmlib/src/coreaccounts/consts.rs rename to packages/wasmvm/wasmlib/src/coreaccounts/consts.rs diff --git a/packages/vm/wasmlib/src/coreaccounts/contract.rs b/packages/wasmvm/wasmlib/src/coreaccounts/contract.rs similarity index 100% rename from packages/vm/wasmlib/src/coreaccounts/contract.rs rename to packages/wasmvm/wasmlib/src/coreaccounts/contract.rs diff --git a/packages/vm/wasmlib/src/coreaccounts/mod.rs b/packages/wasmvm/wasmlib/src/coreaccounts/mod.rs similarity index 100% rename from packages/vm/wasmlib/src/coreaccounts/mod.rs rename to packages/wasmvm/wasmlib/src/coreaccounts/mod.rs diff --git a/packages/vm/wasmlib/src/coreaccounts/params.rs b/packages/wasmvm/wasmlib/src/coreaccounts/params.rs similarity index 100% rename from packages/vm/wasmlib/src/coreaccounts/params.rs rename to packages/wasmvm/wasmlib/src/coreaccounts/params.rs diff --git a/packages/vm/wasmlib/src/coreaccounts/results.rs b/packages/wasmvm/wasmlib/src/coreaccounts/results.rs similarity index 100% rename from packages/vm/wasmlib/src/coreaccounts/results.rs rename to packages/wasmvm/wasmlib/src/coreaccounts/results.rs diff --git a/packages/vm/wasmlib/src/coreblob/consts.rs b/packages/wasmvm/wasmlib/src/coreblob/consts.rs similarity index 100% rename from packages/vm/wasmlib/src/coreblob/consts.rs rename to packages/wasmvm/wasmlib/src/coreblob/consts.rs diff --git a/packages/vm/wasmlib/src/coreblob/contract.rs b/packages/wasmvm/wasmlib/src/coreblob/contract.rs similarity index 100% rename from packages/vm/wasmlib/src/coreblob/contract.rs rename to packages/wasmvm/wasmlib/src/coreblob/contract.rs diff --git a/packages/vm/wasmlib/src/coreblob/mod.rs b/packages/wasmvm/wasmlib/src/coreblob/mod.rs similarity index 100% rename from packages/vm/wasmlib/src/coreblob/mod.rs rename to packages/wasmvm/wasmlib/src/coreblob/mod.rs diff --git a/packages/vm/wasmlib/src/coreblob/params.rs b/packages/wasmvm/wasmlib/src/coreblob/params.rs similarity index 100% rename from packages/vm/wasmlib/src/coreblob/params.rs rename to packages/wasmvm/wasmlib/src/coreblob/params.rs diff --git a/packages/vm/wasmlib/src/coreblob/results.rs b/packages/wasmvm/wasmlib/src/coreblob/results.rs similarity index 100% rename from packages/vm/wasmlib/src/coreblob/results.rs rename to packages/wasmvm/wasmlib/src/coreblob/results.rs diff --git a/packages/vm/wasmlib/src/coreblocklog/consts.rs b/packages/wasmvm/wasmlib/src/coreblocklog/consts.rs similarity index 100% rename from packages/vm/wasmlib/src/coreblocklog/consts.rs rename to packages/wasmvm/wasmlib/src/coreblocklog/consts.rs diff --git a/packages/vm/wasmlib/src/coreblocklog/contract.rs b/packages/wasmvm/wasmlib/src/coreblocklog/contract.rs similarity index 100% rename from packages/vm/wasmlib/src/coreblocklog/contract.rs rename to packages/wasmvm/wasmlib/src/coreblocklog/contract.rs diff --git a/packages/vm/wasmlib/src/coreblocklog/mod.rs b/packages/wasmvm/wasmlib/src/coreblocklog/mod.rs similarity index 100% rename from packages/vm/wasmlib/src/coreblocklog/mod.rs rename to packages/wasmvm/wasmlib/src/coreblocklog/mod.rs diff --git a/packages/vm/wasmlib/src/coreblocklog/params.rs b/packages/wasmvm/wasmlib/src/coreblocklog/params.rs similarity index 100% rename from packages/vm/wasmlib/src/coreblocklog/params.rs rename to packages/wasmvm/wasmlib/src/coreblocklog/params.rs diff --git a/packages/vm/wasmlib/src/coreblocklog/results.rs b/packages/wasmvm/wasmlib/src/coreblocklog/results.rs similarity index 100% rename from packages/vm/wasmlib/src/coreblocklog/results.rs rename to packages/wasmvm/wasmlib/src/coreblocklog/results.rs diff --git a/packages/vm/wasmlib/src/coregovernance/consts.rs b/packages/wasmvm/wasmlib/src/coregovernance/consts.rs similarity index 100% rename from packages/vm/wasmlib/src/coregovernance/consts.rs rename to packages/wasmvm/wasmlib/src/coregovernance/consts.rs diff --git a/packages/vm/wasmlib/src/coregovernance/contract.rs b/packages/wasmvm/wasmlib/src/coregovernance/contract.rs similarity index 100% rename from packages/vm/wasmlib/src/coregovernance/contract.rs rename to packages/wasmvm/wasmlib/src/coregovernance/contract.rs diff --git a/packages/vm/wasmlib/src/coregovernance/mod.rs b/packages/wasmvm/wasmlib/src/coregovernance/mod.rs similarity index 100% rename from packages/vm/wasmlib/src/coregovernance/mod.rs rename to packages/wasmvm/wasmlib/src/coregovernance/mod.rs diff --git a/packages/vm/wasmlib/src/coregovernance/params.rs b/packages/wasmvm/wasmlib/src/coregovernance/params.rs similarity index 100% rename from packages/vm/wasmlib/src/coregovernance/params.rs rename to packages/wasmvm/wasmlib/src/coregovernance/params.rs diff --git a/packages/vm/wasmlib/src/coregovernance/results.rs b/packages/wasmvm/wasmlib/src/coregovernance/results.rs similarity index 100% rename from packages/vm/wasmlib/src/coregovernance/results.rs rename to packages/wasmvm/wasmlib/src/coregovernance/results.rs diff --git a/packages/vm/wasmlib/src/coreroot/consts.rs b/packages/wasmvm/wasmlib/src/coreroot/consts.rs similarity index 100% rename from packages/vm/wasmlib/src/coreroot/consts.rs rename to packages/wasmvm/wasmlib/src/coreroot/consts.rs diff --git a/packages/vm/wasmlib/src/coreroot/contract.rs b/packages/wasmvm/wasmlib/src/coreroot/contract.rs similarity index 100% rename from packages/vm/wasmlib/src/coreroot/contract.rs rename to packages/wasmvm/wasmlib/src/coreroot/contract.rs diff --git a/packages/vm/wasmlib/src/coreroot/mod.rs b/packages/wasmvm/wasmlib/src/coreroot/mod.rs similarity index 100% rename from packages/vm/wasmlib/src/coreroot/mod.rs rename to packages/wasmvm/wasmlib/src/coreroot/mod.rs diff --git a/packages/vm/wasmlib/src/coreroot/params.rs b/packages/wasmvm/wasmlib/src/coreroot/params.rs similarity index 100% rename from packages/vm/wasmlib/src/coreroot/params.rs rename to packages/wasmvm/wasmlib/src/coreroot/params.rs diff --git a/packages/vm/wasmlib/src/coreroot/results.rs b/packages/wasmvm/wasmlib/src/coreroot/results.rs similarity index 100% rename from packages/vm/wasmlib/src/coreroot/results.rs rename to packages/wasmvm/wasmlib/src/coreroot/results.rs diff --git a/packages/vm/wasmlib/src/events.rs b/packages/wasmvm/wasmlib/src/events.rs similarity index 100% rename from packages/vm/wasmlib/src/events.rs rename to packages/wasmvm/wasmlib/src/events.rs diff --git a/packages/vm/wasmlib/src/exports.rs b/packages/wasmvm/wasmlib/src/exports.rs similarity index 100% rename from packages/vm/wasmlib/src/exports.rs rename to packages/wasmvm/wasmlib/src/exports.rs diff --git a/packages/vm/wasmlib/src/hashtypes.rs b/packages/wasmvm/wasmlib/src/hashtypes.rs similarity index 100% rename from packages/vm/wasmlib/src/hashtypes.rs rename to packages/wasmvm/wasmlib/src/hashtypes.rs diff --git a/packages/vm/wasmlib/src/host.rs b/packages/wasmvm/wasmlib/src/host.rs similarity index 100% rename from packages/vm/wasmlib/src/host.rs rename to packages/wasmvm/wasmlib/src/host.rs diff --git a/packages/vm/wasmlib/src/immutable.rs b/packages/wasmvm/wasmlib/src/immutable.rs similarity index 100% rename from packages/vm/wasmlib/src/immutable.rs rename to packages/wasmvm/wasmlib/src/immutable.rs diff --git a/packages/vm/wasmlib/src/keys.rs b/packages/wasmvm/wasmlib/src/keys.rs similarity index 100% rename from packages/vm/wasmlib/src/keys.rs rename to packages/wasmvm/wasmlib/src/keys.rs diff --git a/packages/vm/wasmlib/src/lib.rs b/packages/wasmvm/wasmlib/src/lib.rs similarity index 100% rename from packages/vm/wasmlib/src/lib.rs rename to packages/wasmvm/wasmlib/src/lib.rs diff --git a/packages/vm/wasmlib/src/mutable.rs b/packages/wasmvm/wasmlib/src/mutable.rs similarity index 100% rename from packages/vm/wasmlib/src/mutable.rs rename to packages/wasmvm/wasmlib/src/mutable.rs diff --git a/packages/vm/wasmlib/src/wasmrequests/consts.rs b/packages/wasmvm/wasmlib/src/wasmrequests/consts.rs similarity index 100% rename from packages/vm/wasmlib/src/wasmrequests/consts.rs rename to packages/wasmvm/wasmlib/src/wasmrequests/consts.rs diff --git a/packages/vm/wasmlib/src/wasmrequests/contract.rs b/packages/wasmvm/wasmlib/src/wasmrequests/contract.rs similarity index 100% rename from packages/vm/wasmlib/src/wasmrequests/contract.rs rename to packages/wasmvm/wasmlib/src/wasmrequests/contract.rs diff --git a/packages/vm/wasmlib/src/wasmrequests/mod.rs b/packages/wasmvm/wasmlib/src/wasmrequests/mod.rs similarity index 100% rename from packages/vm/wasmlib/src/wasmrequests/mod.rs rename to packages/wasmvm/wasmlib/src/wasmrequests/mod.rs diff --git a/packages/vm/wasmlib/src/wasmrequests/structs.rs b/packages/wasmvm/wasmlib/src/wasmrequests/structs.rs similarity index 100% rename from packages/vm/wasmlib/src/wasmrequests/structs.rs rename to packages/wasmvm/wasmlib/src/wasmrequests/structs.rs diff --git a/packages/vm/wasmlib/ts/wasmclient/api_common/request_sender.ts b/packages/wasmvm/wasmlib/ts/wasmclient/api_common/request_sender.ts similarity index 100% rename from packages/vm/wasmlib/ts/wasmclient/api_common/request_sender.ts rename to packages/wasmvm/wasmlib/ts/wasmclient/api_common/request_sender.ts diff --git a/packages/vm/wasmlib/ts/wasmclient/api_common/response_models.ts b/packages/wasmvm/wasmlib/ts/wasmclient/api_common/response_models.ts similarity index 100% rename from packages/vm/wasmlib/ts/wasmclient/api_common/response_models.ts rename to packages/wasmvm/wasmlib/ts/wasmclient/api_common/response_models.ts diff --git a/packages/vm/wasmlib/ts/wasmclient/arguments.ts b/packages/wasmvm/wasmlib/ts/wasmclient/arguments.ts similarity index 100% rename from packages/vm/wasmlib/ts/wasmclient/arguments.ts rename to packages/wasmvm/wasmlib/ts/wasmclient/arguments.ts diff --git a/packages/vm/wasmlib/ts/wasmclient/buffer/index.d.ts b/packages/wasmvm/wasmlib/ts/wasmclient/buffer/index.d.ts similarity index 100% rename from packages/vm/wasmlib/ts/wasmclient/buffer/index.d.ts rename to packages/wasmvm/wasmlib/ts/wasmclient/buffer/index.d.ts diff --git a/packages/vm/wasmlib/ts/wasmclient/buffer/index.js b/packages/wasmvm/wasmlib/ts/wasmclient/buffer/index.js similarity index 100% rename from packages/vm/wasmlib/ts/wasmclient/buffer/index.js rename to packages/wasmvm/wasmlib/ts/wasmclient/buffer/index.js diff --git a/packages/vm/wasmlib/ts/wasmclient/buffer/readme.md b/packages/wasmvm/wasmlib/ts/wasmclient/buffer/readme.md similarity index 100% rename from packages/vm/wasmlib/ts/wasmclient/buffer/readme.md rename to packages/wasmvm/wasmlib/ts/wasmclient/buffer/readme.md diff --git a/packages/vm/wasmlib/ts/wasmclient/clientfunc.ts b/packages/wasmvm/wasmlib/ts/wasmclient/clientfunc.ts similarity index 100% rename from packages/vm/wasmlib/ts/wasmclient/clientfunc.ts rename to packages/wasmvm/wasmlib/ts/wasmclient/clientfunc.ts diff --git a/packages/vm/wasmlib/ts/wasmclient/clientview.ts b/packages/wasmvm/wasmlib/ts/wasmclient/clientview.ts similarity index 100% rename from packages/vm/wasmlib/ts/wasmclient/clientview.ts rename to packages/wasmvm/wasmlib/ts/wasmclient/clientview.ts diff --git a/packages/vm/wasmlib/ts/wasmclient/colors.ts b/packages/wasmvm/wasmlib/ts/wasmclient/colors.ts similarity index 100% rename from packages/vm/wasmlib/ts/wasmclient/colors.ts rename to packages/wasmvm/wasmlib/ts/wasmclient/colors.ts diff --git a/packages/vm/wasmlib/ts/wasmclient/configuration.ts b/packages/wasmvm/wasmlib/ts/wasmclient/configuration.ts similarity index 100% rename from packages/vm/wasmlib/ts/wasmclient/configuration.ts rename to packages/wasmvm/wasmlib/ts/wasmclient/configuration.ts diff --git a/packages/vm/wasmlib/ts/wasmclient/coreaccounts/service.ts b/packages/wasmvm/wasmlib/ts/wasmclient/coreaccounts/service.ts similarity index 100% rename from packages/vm/wasmlib/ts/wasmclient/coreaccounts/service.ts rename to packages/wasmvm/wasmlib/ts/wasmclient/coreaccounts/service.ts diff --git a/packages/vm/wasmlib/ts/wasmclient/coreblob/service.ts b/packages/wasmvm/wasmlib/ts/wasmclient/coreblob/service.ts similarity index 100% rename from packages/vm/wasmlib/ts/wasmclient/coreblob/service.ts rename to packages/wasmvm/wasmlib/ts/wasmclient/coreblob/service.ts diff --git a/packages/vm/wasmlib/ts/wasmclient/coreblocklog/service.ts b/packages/wasmvm/wasmlib/ts/wasmclient/coreblocklog/service.ts similarity index 100% rename from packages/vm/wasmlib/ts/wasmclient/coreblocklog/service.ts rename to packages/wasmvm/wasmlib/ts/wasmclient/coreblocklog/service.ts diff --git a/packages/vm/wasmlib/ts/wasmclient/coregovernance/service.ts b/packages/wasmvm/wasmlib/ts/wasmclient/coregovernance/service.ts similarity index 100% rename from packages/vm/wasmlib/ts/wasmclient/coregovernance/service.ts rename to packages/wasmvm/wasmlib/ts/wasmclient/coregovernance/service.ts diff --git a/packages/vm/wasmlib/ts/wasmclient/coreroot/service.ts b/packages/wasmvm/wasmlib/ts/wasmclient/coreroot/service.ts similarity index 100% rename from packages/vm/wasmlib/ts/wasmclient/coreroot/service.ts rename to packages/wasmvm/wasmlib/ts/wasmclient/coreroot/service.ts diff --git a/packages/vm/wasmlib/ts/wasmclient/crypto/base58.ts b/packages/wasmvm/wasmlib/ts/wasmclient/crypto/base58.ts similarity index 100% rename from packages/vm/wasmlib/ts/wasmclient/crypto/base58.ts rename to packages/wasmvm/wasmlib/ts/wasmclient/crypto/base58.ts diff --git a/packages/vm/wasmlib/ts/wasmclient/crypto/ed25519.ts b/packages/wasmvm/wasmlib/ts/wasmclient/crypto/ed25519.ts similarity index 100% rename from packages/vm/wasmlib/ts/wasmclient/crypto/ed25519.ts rename to packages/wasmvm/wasmlib/ts/wasmclient/crypto/ed25519.ts diff --git a/packages/vm/wasmlib/ts/wasmclient/crypto/hash.ts b/packages/wasmvm/wasmlib/ts/wasmclient/crypto/hash.ts similarity index 100% rename from packages/vm/wasmlib/ts/wasmclient/crypto/hash.ts rename to packages/wasmvm/wasmlib/ts/wasmclient/crypto/hash.ts diff --git a/packages/vm/wasmlib/ts/wasmclient/crypto/index.ts b/packages/wasmvm/wasmlib/ts/wasmclient/crypto/index.ts similarity index 100% rename from packages/vm/wasmlib/ts/wasmclient/crypto/index.ts rename to packages/wasmvm/wasmlib/ts/wasmclient/crypto/index.ts diff --git a/packages/vm/wasmlib/ts/wasmclient/crypto/seed.ts b/packages/wasmvm/wasmlib/ts/wasmclient/crypto/seed.ts similarity index 100% rename from packages/vm/wasmlib/ts/wasmclient/crypto/seed.ts rename to packages/wasmvm/wasmlib/ts/wasmclient/crypto/seed.ts diff --git a/packages/vm/wasmlib/ts/wasmclient/decoder.ts b/packages/wasmvm/wasmlib/ts/wasmclient/decoder.ts similarity index 100% rename from packages/vm/wasmlib/ts/wasmclient/decoder.ts rename to packages/wasmvm/wasmlib/ts/wasmclient/decoder.ts diff --git a/packages/vm/wasmlib/ts/wasmclient/encoder.ts b/packages/wasmvm/wasmlib/ts/wasmclient/encoder.ts similarity index 100% rename from packages/vm/wasmlib/ts/wasmclient/encoder.ts rename to packages/wasmvm/wasmlib/ts/wasmclient/encoder.ts diff --git a/packages/vm/wasmlib/ts/wasmclient/event.ts b/packages/wasmvm/wasmlib/ts/wasmclient/event.ts similarity index 100% rename from packages/vm/wasmlib/ts/wasmclient/event.ts rename to packages/wasmvm/wasmlib/ts/wasmclient/event.ts diff --git a/packages/vm/wasmlib/ts/wasmclient/goshimmer/faucet/faucet_helper.ts b/packages/wasmvm/wasmlib/ts/wasmclient/goshimmer/faucet/faucet_helper.ts similarity index 100% rename from packages/vm/wasmlib/ts/wasmclient/goshimmer/faucet/faucet_helper.ts rename to packages/wasmvm/wasmlib/ts/wasmclient/goshimmer/faucet/faucet_helper.ts diff --git a/packages/vm/wasmlib/ts/wasmclient/goshimmer/faucet/faucet_models.ts b/packages/wasmvm/wasmlib/ts/wasmclient/goshimmer/faucet/faucet_models.ts similarity index 100% rename from packages/vm/wasmlib/ts/wasmclient/goshimmer/faucet/faucet_models.ts rename to packages/wasmvm/wasmlib/ts/wasmclient/goshimmer/faucet/faucet_models.ts diff --git a/packages/vm/wasmlib/ts/wasmclient/goshimmer/goshimmerclient.ts b/packages/wasmvm/wasmlib/ts/wasmclient/goshimmer/goshimmerclient.ts similarity index 100% rename from packages/vm/wasmlib/ts/wasmclient/goshimmer/goshimmerclient.ts rename to packages/wasmvm/wasmlib/ts/wasmclient/goshimmer/goshimmerclient.ts diff --git a/packages/vm/wasmlib/ts/wasmclient/goshimmer/models/mana.ts b/packages/wasmvm/wasmlib/ts/wasmclient/goshimmer/models/mana.ts similarity index 100% rename from packages/vm/wasmlib/ts/wasmclient/goshimmer/models/mana.ts rename to packages/wasmvm/wasmlib/ts/wasmclient/goshimmer/models/mana.ts diff --git a/packages/vm/wasmlib/ts/wasmclient/goshimmer/models/on_ledger.ts b/packages/wasmvm/wasmlib/ts/wasmclient/goshimmer/models/on_ledger.ts similarity index 100% rename from packages/vm/wasmlib/ts/wasmclient/goshimmer/models/on_ledger.ts rename to packages/wasmvm/wasmlib/ts/wasmclient/goshimmer/models/on_ledger.ts diff --git a/packages/vm/wasmlib/ts/wasmclient/goshimmer/models/transaction.ts b/packages/wasmvm/wasmlib/ts/wasmclient/goshimmer/models/transaction.ts similarity index 100% rename from packages/vm/wasmlib/ts/wasmclient/goshimmer/models/transaction.ts rename to packages/wasmvm/wasmlib/ts/wasmclient/goshimmer/models/transaction.ts diff --git a/packages/vm/wasmlib/ts/wasmclient/goshimmer/models/unspent_outputs.ts b/packages/wasmvm/wasmlib/ts/wasmclient/goshimmer/models/unspent_outputs.ts similarity index 100% rename from packages/vm/wasmlib/ts/wasmclient/goshimmer/models/unspent_outputs.ts rename to packages/wasmvm/wasmlib/ts/wasmclient/goshimmer/models/unspent_outputs.ts diff --git a/packages/vm/wasmlib/ts/wasmclient/goshimmer/pow_web_worker/pow.worker.ts b/packages/wasmvm/wasmlib/ts/wasmclient/goshimmer/pow_web_worker/pow.worker.ts similarity index 100% rename from packages/vm/wasmlib/ts/wasmclient/goshimmer/pow_web_worker/pow.worker.ts rename to packages/wasmvm/wasmlib/ts/wasmclient/goshimmer/pow_web_worker/pow.worker.ts diff --git a/packages/vm/wasmlib/ts/wasmclient/goshimmer/pow_web_worker/pow_worker_manager.ts b/packages/wasmvm/wasmlib/ts/wasmclient/goshimmer/pow_web_worker/pow_worker_manager.ts similarity index 100% rename from packages/vm/wasmlib/ts/wasmclient/goshimmer/pow_web_worker/pow_worker_manager.ts rename to packages/wasmvm/wasmlib/ts/wasmclient/goshimmer/pow_web_worker/pow_worker_manager.ts diff --git a/packages/vm/wasmlib/ts/wasmclient/goshimmer/pow_web_worker/proof_of_work.ts b/packages/wasmvm/wasmlib/ts/wasmclient/goshimmer/pow_web_worker/proof_of_work.ts similarity index 100% rename from packages/vm/wasmlib/ts/wasmclient/goshimmer/pow_web_worker/proof_of_work.ts rename to packages/wasmvm/wasmlib/ts/wasmclient/goshimmer/pow_web_worker/proof_of_work.ts diff --git a/packages/vm/wasmlib/ts/wasmclient/goshimmer/pow_web_worker/worker-loader.d.ts b/packages/wasmvm/wasmlib/ts/wasmclient/goshimmer/pow_web_worker/worker-loader.d.ts similarity index 100% rename from packages/vm/wasmlib/ts/wasmclient/goshimmer/pow_web_worker/worker-loader.d.ts rename to packages/wasmvm/wasmlib/ts/wasmclient/goshimmer/pow_web_worker/worker-loader.d.ts diff --git a/packages/vm/wasmlib/ts/wasmclient/goshimmer/utils/simple_buffer_cursor.ts b/packages/wasmvm/wasmlib/ts/wasmclient/goshimmer/utils/simple_buffer_cursor.ts similarity index 100% rename from packages/vm/wasmlib/ts/wasmclient/goshimmer/utils/simple_buffer_cursor.ts rename to packages/wasmvm/wasmlib/ts/wasmclient/goshimmer/utils/simple_buffer_cursor.ts diff --git a/packages/vm/wasmlib/ts/wasmclient/goshimmer/wallet/wallet.ts b/packages/wasmvm/wasmlib/ts/wasmclient/goshimmer/wallet/wallet.ts similarity index 100% rename from packages/vm/wasmlib/ts/wasmclient/goshimmer/wallet/wallet.ts rename to packages/wasmvm/wasmlib/ts/wasmclient/goshimmer/wallet/wallet.ts diff --git a/packages/vm/wasmlib/ts/wasmclient/goshimmer/wallet/wallet_models.ts b/packages/wasmvm/wasmlib/ts/wasmclient/goshimmer/wallet/wallet_models.ts similarity index 100% rename from packages/vm/wasmlib/ts/wasmclient/goshimmer/wallet/wallet_models.ts rename to packages/wasmvm/wasmlib/ts/wasmclient/goshimmer/wallet/wallet_models.ts diff --git a/packages/vm/wasmlib/ts/wasmclient/index.ts b/packages/wasmvm/wasmlib/ts/wasmclient/index.ts similarity index 100% rename from packages/vm/wasmlib/ts/wasmclient/index.ts rename to packages/wasmvm/wasmlib/ts/wasmclient/index.ts diff --git a/packages/vm/wasmlib/ts/wasmclient/package-lock.json b/packages/wasmvm/wasmlib/ts/wasmclient/package-lock.json similarity index 100% rename from packages/vm/wasmlib/ts/wasmclient/package-lock.json rename to packages/wasmvm/wasmlib/ts/wasmclient/package-lock.json diff --git a/packages/vm/wasmlib/ts/wasmclient/package.json b/packages/wasmvm/wasmlib/ts/wasmclient/package.json similarity index 100% rename from packages/vm/wasmlib/ts/wasmclient/package.json rename to packages/wasmvm/wasmlib/ts/wasmclient/package.json diff --git a/packages/vm/wasmlib/ts/wasmclient/results.ts b/packages/wasmvm/wasmlib/ts/wasmclient/results.ts similarity index 100% rename from packages/vm/wasmlib/ts/wasmclient/results.ts rename to packages/wasmvm/wasmlib/ts/wasmclient/results.ts diff --git a/packages/vm/wasmlib/ts/wasmclient/service.ts b/packages/wasmvm/wasmlib/ts/wasmclient/service.ts similarity index 100% rename from packages/vm/wasmlib/ts/wasmclient/service.ts rename to packages/wasmvm/wasmlib/ts/wasmclient/service.ts diff --git a/packages/vm/wasmlib/ts/wasmclient/serviceclient.ts b/packages/wasmvm/wasmlib/ts/wasmclient/serviceclient.ts similarity index 100% rename from packages/vm/wasmlib/ts/wasmclient/serviceclient.ts rename to packages/wasmvm/wasmlib/ts/wasmclient/serviceclient.ts diff --git a/packages/vm/wasmlib/ts/wasmclient/transfer.ts b/packages/wasmvm/wasmlib/ts/wasmclient/transfer.ts similarity index 100% rename from packages/vm/wasmlib/ts/wasmclient/transfer.ts rename to packages/wasmvm/wasmlib/ts/wasmclient/transfer.ts diff --git a/packages/vm/wasmlib/ts/wasmclient/tsconfig.json b/packages/wasmvm/wasmlib/ts/wasmclient/tsconfig.json similarity index 100% rename from packages/vm/wasmlib/ts/wasmclient/tsconfig.json rename to packages/wasmvm/wasmlib/ts/wasmclient/tsconfig.json diff --git a/packages/vm/wasmlib/ts/wasmclient/types.ts b/packages/wasmvm/wasmlib/ts/wasmclient/types.ts similarity index 100% rename from packages/vm/wasmlib/ts/wasmclient/types.ts rename to packages/wasmvm/wasmlib/ts/wasmclient/types.ts diff --git a/packages/vm/wasmlib/ts/wasmclient/wasmrequests/service.ts b/packages/wasmvm/wasmlib/ts/wasmclient/wasmrequests/service.ts similarity index 100% rename from packages/vm/wasmlib/ts/wasmclient/wasmrequests/service.ts rename to packages/wasmvm/wasmlib/ts/wasmclient/wasmrequests/service.ts diff --git a/packages/vm/wasmlib/ts/wasmclient/waspclient.ts b/packages/wasmvm/wasmlib/ts/wasmclient/waspclient.ts similarity index 100% rename from packages/vm/wasmlib/ts/wasmclient/waspclient.ts rename to packages/wasmvm/wasmlib/ts/wasmclient/waspclient.ts diff --git a/packages/vm/wasmlib/ts/wasmlib/bytes.ts b/packages/wasmvm/wasmlib/ts/wasmlib/bytes.ts similarity index 100% rename from packages/vm/wasmlib/ts/wasmlib/bytes.ts rename to packages/wasmvm/wasmlib/ts/wasmlib/bytes.ts diff --git a/packages/vm/wasmlib/ts/wasmlib/context.ts b/packages/wasmvm/wasmlib/ts/wasmlib/context.ts similarity index 100% rename from packages/vm/wasmlib/ts/wasmlib/context.ts rename to packages/wasmvm/wasmlib/ts/wasmlib/context.ts diff --git a/packages/vm/wasmlib/ts/wasmlib/contract.ts b/packages/wasmvm/wasmlib/ts/wasmlib/contract.ts similarity index 100% rename from packages/vm/wasmlib/ts/wasmlib/contract.ts rename to packages/wasmvm/wasmlib/ts/wasmlib/contract.ts diff --git a/packages/vm/wasmlib/ts/wasmlib/convert.ts b/packages/wasmvm/wasmlib/ts/wasmlib/convert.ts similarity index 100% rename from packages/vm/wasmlib/ts/wasmlib/convert.ts rename to packages/wasmvm/wasmlib/ts/wasmlib/convert.ts diff --git a/packages/vm/wasmlib/ts/wasmlib/coreaccounts/consts.ts b/packages/wasmvm/wasmlib/ts/wasmlib/coreaccounts/consts.ts similarity index 100% rename from packages/vm/wasmlib/ts/wasmlib/coreaccounts/consts.ts rename to packages/wasmvm/wasmlib/ts/wasmlib/coreaccounts/consts.ts diff --git a/packages/vm/wasmlib/ts/wasmlib/coreaccounts/contract.ts b/packages/wasmvm/wasmlib/ts/wasmlib/coreaccounts/contract.ts similarity index 100% rename from packages/vm/wasmlib/ts/wasmlib/coreaccounts/contract.ts rename to packages/wasmvm/wasmlib/ts/wasmlib/coreaccounts/contract.ts diff --git a/packages/vm/wasmlib/ts/wasmlib/coreaccounts/index.ts b/packages/wasmvm/wasmlib/ts/wasmlib/coreaccounts/index.ts similarity index 100% rename from packages/vm/wasmlib/ts/wasmlib/coreaccounts/index.ts rename to packages/wasmvm/wasmlib/ts/wasmlib/coreaccounts/index.ts diff --git a/packages/vm/wasmlib/ts/wasmlib/coreaccounts/params.ts b/packages/wasmvm/wasmlib/ts/wasmlib/coreaccounts/params.ts similarity index 100% rename from packages/vm/wasmlib/ts/wasmlib/coreaccounts/params.ts rename to packages/wasmvm/wasmlib/ts/wasmlib/coreaccounts/params.ts diff --git a/packages/vm/wasmlib/ts/wasmlib/coreaccounts/results.ts b/packages/wasmvm/wasmlib/ts/wasmlib/coreaccounts/results.ts similarity index 100% rename from packages/vm/wasmlib/ts/wasmlib/coreaccounts/results.ts rename to packages/wasmvm/wasmlib/ts/wasmlib/coreaccounts/results.ts diff --git a/packages/vm/wasmlib/ts/wasmlib/coreaccounts/tsconfig.json b/packages/wasmvm/wasmlib/ts/wasmlib/coreaccounts/tsconfig.json similarity index 100% rename from packages/vm/wasmlib/ts/wasmlib/coreaccounts/tsconfig.json rename to packages/wasmvm/wasmlib/ts/wasmlib/coreaccounts/tsconfig.json diff --git a/packages/vm/wasmlib/ts/wasmlib/coreblob/consts.ts b/packages/wasmvm/wasmlib/ts/wasmlib/coreblob/consts.ts similarity index 100% rename from packages/vm/wasmlib/ts/wasmlib/coreblob/consts.ts rename to packages/wasmvm/wasmlib/ts/wasmlib/coreblob/consts.ts diff --git a/packages/vm/wasmlib/ts/wasmlib/coreblob/contract.ts b/packages/wasmvm/wasmlib/ts/wasmlib/coreblob/contract.ts similarity index 100% rename from packages/vm/wasmlib/ts/wasmlib/coreblob/contract.ts rename to packages/wasmvm/wasmlib/ts/wasmlib/coreblob/contract.ts diff --git a/packages/vm/wasmlib/ts/wasmlib/coreblob/index.ts b/packages/wasmvm/wasmlib/ts/wasmlib/coreblob/index.ts similarity index 100% rename from packages/vm/wasmlib/ts/wasmlib/coreblob/index.ts rename to packages/wasmvm/wasmlib/ts/wasmlib/coreblob/index.ts diff --git a/packages/vm/wasmlib/ts/wasmlib/coreblob/params.ts b/packages/wasmvm/wasmlib/ts/wasmlib/coreblob/params.ts similarity index 100% rename from packages/vm/wasmlib/ts/wasmlib/coreblob/params.ts rename to packages/wasmvm/wasmlib/ts/wasmlib/coreblob/params.ts diff --git a/packages/vm/wasmlib/ts/wasmlib/coreblob/results.ts b/packages/wasmvm/wasmlib/ts/wasmlib/coreblob/results.ts similarity index 100% rename from packages/vm/wasmlib/ts/wasmlib/coreblob/results.ts rename to packages/wasmvm/wasmlib/ts/wasmlib/coreblob/results.ts diff --git a/packages/vm/wasmlib/ts/wasmlib/coreblob/tsconfig.json b/packages/wasmvm/wasmlib/ts/wasmlib/coreblob/tsconfig.json similarity index 100% rename from packages/vm/wasmlib/ts/wasmlib/coreblob/tsconfig.json rename to packages/wasmvm/wasmlib/ts/wasmlib/coreblob/tsconfig.json diff --git a/packages/vm/wasmlib/ts/wasmlib/coreblocklog/consts.ts b/packages/wasmvm/wasmlib/ts/wasmlib/coreblocklog/consts.ts similarity index 100% rename from packages/vm/wasmlib/ts/wasmlib/coreblocklog/consts.ts rename to packages/wasmvm/wasmlib/ts/wasmlib/coreblocklog/consts.ts diff --git a/packages/vm/wasmlib/ts/wasmlib/coreblocklog/contract.ts b/packages/wasmvm/wasmlib/ts/wasmlib/coreblocklog/contract.ts similarity index 100% rename from packages/vm/wasmlib/ts/wasmlib/coreblocklog/contract.ts rename to packages/wasmvm/wasmlib/ts/wasmlib/coreblocklog/contract.ts diff --git a/packages/vm/wasmlib/ts/wasmlib/coreblocklog/index.ts b/packages/wasmvm/wasmlib/ts/wasmlib/coreblocklog/index.ts similarity index 100% rename from packages/vm/wasmlib/ts/wasmlib/coreblocklog/index.ts rename to packages/wasmvm/wasmlib/ts/wasmlib/coreblocklog/index.ts diff --git a/packages/vm/wasmlib/ts/wasmlib/coreblocklog/params.ts b/packages/wasmvm/wasmlib/ts/wasmlib/coreblocklog/params.ts similarity index 100% rename from packages/vm/wasmlib/ts/wasmlib/coreblocklog/params.ts rename to packages/wasmvm/wasmlib/ts/wasmlib/coreblocklog/params.ts diff --git a/packages/vm/wasmlib/ts/wasmlib/coreblocklog/results.ts b/packages/wasmvm/wasmlib/ts/wasmlib/coreblocklog/results.ts similarity index 100% rename from packages/vm/wasmlib/ts/wasmlib/coreblocklog/results.ts rename to packages/wasmvm/wasmlib/ts/wasmlib/coreblocklog/results.ts diff --git a/packages/vm/wasmlib/ts/wasmlib/coreblocklog/tsconfig.json b/packages/wasmvm/wasmlib/ts/wasmlib/coreblocklog/tsconfig.json similarity index 100% rename from packages/vm/wasmlib/ts/wasmlib/coreblocklog/tsconfig.json rename to packages/wasmvm/wasmlib/ts/wasmlib/coreblocklog/tsconfig.json diff --git a/packages/vm/wasmlib/ts/wasmlib/coregovernance/consts.ts b/packages/wasmvm/wasmlib/ts/wasmlib/coregovernance/consts.ts similarity index 100% rename from packages/vm/wasmlib/ts/wasmlib/coregovernance/consts.ts rename to packages/wasmvm/wasmlib/ts/wasmlib/coregovernance/consts.ts diff --git a/packages/vm/wasmlib/ts/wasmlib/coregovernance/contract.ts b/packages/wasmvm/wasmlib/ts/wasmlib/coregovernance/contract.ts similarity index 100% rename from packages/vm/wasmlib/ts/wasmlib/coregovernance/contract.ts rename to packages/wasmvm/wasmlib/ts/wasmlib/coregovernance/contract.ts diff --git a/packages/vm/wasmlib/ts/wasmlib/coregovernance/index.ts b/packages/wasmvm/wasmlib/ts/wasmlib/coregovernance/index.ts similarity index 100% rename from packages/vm/wasmlib/ts/wasmlib/coregovernance/index.ts rename to packages/wasmvm/wasmlib/ts/wasmlib/coregovernance/index.ts diff --git a/packages/vm/wasmlib/ts/wasmlib/coregovernance/params.ts b/packages/wasmvm/wasmlib/ts/wasmlib/coregovernance/params.ts similarity index 100% rename from packages/vm/wasmlib/ts/wasmlib/coregovernance/params.ts rename to packages/wasmvm/wasmlib/ts/wasmlib/coregovernance/params.ts diff --git a/packages/vm/wasmlib/ts/wasmlib/coregovernance/results.ts b/packages/wasmvm/wasmlib/ts/wasmlib/coregovernance/results.ts similarity index 100% rename from packages/vm/wasmlib/ts/wasmlib/coregovernance/results.ts rename to packages/wasmvm/wasmlib/ts/wasmlib/coregovernance/results.ts diff --git a/packages/vm/wasmlib/ts/wasmlib/coregovernance/tsconfig.json b/packages/wasmvm/wasmlib/ts/wasmlib/coregovernance/tsconfig.json similarity index 100% rename from packages/vm/wasmlib/ts/wasmlib/coregovernance/tsconfig.json rename to packages/wasmvm/wasmlib/ts/wasmlib/coregovernance/tsconfig.json diff --git a/packages/vm/wasmlib/ts/wasmlib/coreroot/consts.ts b/packages/wasmvm/wasmlib/ts/wasmlib/coreroot/consts.ts similarity index 100% rename from packages/vm/wasmlib/ts/wasmlib/coreroot/consts.ts rename to packages/wasmvm/wasmlib/ts/wasmlib/coreroot/consts.ts diff --git a/packages/vm/wasmlib/ts/wasmlib/coreroot/contract.ts b/packages/wasmvm/wasmlib/ts/wasmlib/coreroot/contract.ts similarity index 100% rename from packages/vm/wasmlib/ts/wasmlib/coreroot/contract.ts rename to packages/wasmvm/wasmlib/ts/wasmlib/coreroot/contract.ts diff --git a/packages/vm/wasmlib/ts/wasmlib/coreroot/index.ts b/packages/wasmvm/wasmlib/ts/wasmlib/coreroot/index.ts similarity index 100% rename from packages/vm/wasmlib/ts/wasmlib/coreroot/index.ts rename to packages/wasmvm/wasmlib/ts/wasmlib/coreroot/index.ts diff --git a/packages/vm/wasmlib/ts/wasmlib/coreroot/params.ts b/packages/wasmvm/wasmlib/ts/wasmlib/coreroot/params.ts similarity index 100% rename from packages/vm/wasmlib/ts/wasmlib/coreroot/params.ts rename to packages/wasmvm/wasmlib/ts/wasmlib/coreroot/params.ts diff --git a/packages/vm/wasmlib/ts/wasmlib/coreroot/results.ts b/packages/wasmvm/wasmlib/ts/wasmlib/coreroot/results.ts similarity index 100% rename from packages/vm/wasmlib/ts/wasmlib/coreroot/results.ts rename to packages/wasmvm/wasmlib/ts/wasmlib/coreroot/results.ts diff --git a/packages/vm/wasmlib/ts/wasmlib/coreroot/tsconfig.json b/packages/wasmvm/wasmlib/ts/wasmlib/coreroot/tsconfig.json similarity index 100% rename from packages/vm/wasmlib/ts/wasmlib/coreroot/tsconfig.json rename to packages/wasmvm/wasmlib/ts/wasmlib/coreroot/tsconfig.json diff --git a/packages/vm/wasmlib/ts/wasmlib/events.ts b/packages/wasmvm/wasmlib/ts/wasmlib/events.ts similarity index 100% rename from packages/vm/wasmlib/ts/wasmlib/events.ts rename to packages/wasmvm/wasmlib/ts/wasmlib/events.ts diff --git a/packages/vm/wasmlib/ts/wasmlib/exports.ts b/packages/wasmvm/wasmlib/ts/wasmlib/exports.ts similarity index 100% rename from packages/vm/wasmlib/ts/wasmlib/exports.ts rename to packages/wasmvm/wasmlib/ts/wasmlib/exports.ts diff --git a/packages/vm/wasmlib/ts/wasmlib/hashtypes.ts b/packages/wasmvm/wasmlib/ts/wasmlib/hashtypes.ts similarity index 100% rename from packages/vm/wasmlib/ts/wasmlib/hashtypes.ts rename to packages/wasmvm/wasmlib/ts/wasmlib/hashtypes.ts diff --git a/packages/vm/wasmlib/ts/wasmlib/host.ts b/packages/wasmvm/wasmlib/ts/wasmlib/host.ts similarity index 100% rename from packages/vm/wasmlib/ts/wasmlib/host.ts rename to packages/wasmvm/wasmlib/ts/wasmlib/host.ts diff --git a/packages/vm/wasmlib/ts/wasmlib/immutable.ts b/packages/wasmvm/wasmlib/ts/wasmlib/immutable.ts similarity index 100% rename from packages/vm/wasmlib/ts/wasmlib/immutable.ts rename to packages/wasmvm/wasmlib/ts/wasmlib/immutable.ts diff --git a/packages/vm/wasmlib/ts/wasmlib/index.ts b/packages/wasmvm/wasmlib/ts/wasmlib/index.ts similarity index 100% rename from packages/vm/wasmlib/ts/wasmlib/index.ts rename to packages/wasmvm/wasmlib/ts/wasmlib/index.ts diff --git a/packages/vm/wasmlib/ts/wasmlib/keys.ts b/packages/wasmvm/wasmlib/ts/wasmlib/keys.ts similarity index 100% rename from packages/vm/wasmlib/ts/wasmlib/keys.ts rename to packages/wasmvm/wasmlib/ts/wasmlib/keys.ts diff --git a/packages/vm/wasmlib/ts/wasmlib/mutable.ts b/packages/wasmvm/wasmlib/ts/wasmlib/mutable.ts similarity index 100% rename from packages/vm/wasmlib/ts/wasmlib/mutable.ts rename to packages/wasmvm/wasmlib/ts/wasmlib/mutable.ts diff --git a/packages/vm/wasmlib/ts/wasmlib/package-lock.json b/packages/wasmvm/wasmlib/ts/wasmlib/package-lock.json similarity index 100% rename from packages/vm/wasmlib/ts/wasmlib/package-lock.json rename to packages/wasmvm/wasmlib/ts/wasmlib/package-lock.json diff --git a/packages/vm/wasmlib/ts/wasmlib/package.json b/packages/wasmvm/wasmlib/ts/wasmlib/package.json similarity index 100% rename from packages/vm/wasmlib/ts/wasmlib/package.json rename to packages/wasmvm/wasmlib/ts/wasmlib/package.json diff --git a/packages/vm/wasmlib/ts/wasmlib/tsconfig.json b/packages/wasmvm/wasmlib/ts/wasmlib/tsconfig.json similarity index 100% rename from packages/vm/wasmlib/ts/wasmlib/tsconfig.json rename to packages/wasmvm/wasmlib/ts/wasmlib/tsconfig.json diff --git a/packages/vm/wasmlib/ts/wasmlib/wasmrequests/consts.ts b/packages/wasmvm/wasmlib/ts/wasmlib/wasmrequests/consts.ts similarity index 100% rename from packages/vm/wasmlib/ts/wasmlib/wasmrequests/consts.ts rename to packages/wasmvm/wasmlib/ts/wasmlib/wasmrequests/consts.ts diff --git a/packages/vm/wasmlib/ts/wasmlib/wasmrequests/contract.ts b/packages/wasmvm/wasmlib/ts/wasmlib/wasmrequests/contract.ts similarity index 100% rename from packages/vm/wasmlib/ts/wasmlib/wasmrequests/contract.ts rename to packages/wasmvm/wasmlib/ts/wasmlib/wasmrequests/contract.ts diff --git a/packages/vm/wasmlib/ts/wasmlib/wasmrequests/index.ts b/packages/wasmvm/wasmlib/ts/wasmlib/wasmrequests/index.ts similarity index 100% rename from packages/vm/wasmlib/ts/wasmlib/wasmrequests/index.ts rename to packages/wasmvm/wasmlib/ts/wasmlib/wasmrequests/index.ts diff --git a/packages/vm/wasmlib/ts/wasmlib/wasmrequests/structs.ts b/packages/wasmvm/wasmlib/ts/wasmlib/wasmrequests/structs.ts similarity index 100% rename from packages/vm/wasmlib/ts/wasmlib/wasmrequests/structs.ts rename to packages/wasmvm/wasmlib/ts/wasmlib/wasmrequests/structs.ts diff --git a/packages/vm/wasmlib/ts/wasmlib/wasmrequests/tsconfig.json b/packages/wasmvm/wasmlib/ts/wasmlib/wasmrequests/tsconfig.json similarity index 100% rename from packages/vm/wasmlib/ts/wasmlib/wasmrequests/tsconfig.json rename to packages/wasmvm/wasmlib/ts/wasmlib/wasmrequests/tsconfig.json diff --git a/packages/vm/wasmsolo/soloagent.go b/packages/wasmvm/wasmsolo/soloagent.go similarity index 95% rename from packages/vm/wasmsolo/soloagent.go rename to packages/wasmvm/wasmsolo/soloagent.go index f3ecd28431..00af406b22 100644 --- a/packages/vm/wasmsolo/soloagent.go +++ b/packages/wasmvm/wasmsolo/soloagent.go @@ -9,7 +9,7 @@ import ( "github.com/iotaledger/wasp/packages/iscp" "github.com/iotaledger/wasp/packages/iscp/colored" "github.com/iotaledger/wasp/packages/solo" - "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" + "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" "github.com/stretchr/testify/require" ) diff --git a/packages/vm/wasmsolo/solocontext.go b/packages/wasmvm/wasmsolo/solocontext.go similarity index 98% rename from packages/vm/wasmsolo/solocontext.go rename to packages/wasmvm/wasmsolo/solocontext.go index 06cfe7f3ae..b4a283a4a9 100644 --- a/packages/vm/wasmsolo/solocontext.go +++ b/packages/wasmvm/wasmsolo/solocontext.go @@ -18,8 +18,8 @@ import ( "github.com/iotaledger/wasp/packages/solo" "github.com/iotaledger/wasp/packages/util" "github.com/iotaledger/wasp/packages/vm/wasmhost" - "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" - "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" + "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib" + "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" "github.com/stretchr/testify/require" ) @@ -37,10 +37,10 @@ var ( // TODO set back to false ) type SoloContext struct { - Chain *solo.Chain - Convertor SoloConvertor - creator *SoloAgent - Err error + Chain *solo.Chain + Convertor SoloConvertor + creator *SoloAgent + Err error Hprog hashing.HashValue keyPair *ed25519.KeyPair isRequest bool diff --git a/packages/vm/wasmsolo/soloconvertor.go b/packages/wasmvm/wasmsolo/soloconvertor.go similarity index 94% rename from packages/vm/wasmsolo/soloconvertor.go rename to packages/wasmvm/wasmsolo/soloconvertor.go index f7cfbc9432..ba4771cf85 100644 --- a/packages/vm/wasmsolo/soloconvertor.go +++ b/packages/wasmvm/wasmsolo/soloconvertor.go @@ -5,7 +5,7 @@ import ( "github.com/iotaledger/wasp/packages/hashing" "github.com/iotaledger/wasp/packages/iscp" "github.com/iotaledger/wasp/packages/iscp/colored" - "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" + "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" ) // SoloConvertor converts ISCP data types to WasmLib data types diff --git a/packages/vm/wasmsolo/solosandbox.go b/packages/wasmvm/wasmsolo/solosandbox.go similarity index 98% rename from packages/vm/wasmsolo/solosandbox.go rename to packages/wasmvm/wasmsolo/solosandbox.go index 6abbcdb0a1..5185710fff 100644 --- a/packages/vm/wasmsolo/solosandbox.go +++ b/packages/wasmvm/wasmsolo/solosandbox.go @@ -13,8 +13,8 @@ import ( "github.com/iotaledger/wasp/packages/solo" "github.com/iotaledger/wasp/packages/vm/sandbox/sandbox_utils" "github.com/iotaledger/wasp/packages/vm/wasmhost" - "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmrequests" - "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" + "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmrequests" + "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" "golang.org/x/xerrors" ) diff --git a/packages/vm/wasmsolo/solosandboxutils.go b/packages/wasmvm/wasmsolo/solosandboxutils.go similarity index 96% rename from packages/vm/wasmsolo/solosandboxutils.go rename to packages/wasmvm/wasmsolo/solosandboxutils.go index aabdcbcec2..77a763db02 100644 --- a/packages/vm/wasmsolo/solosandboxutils.go +++ b/packages/wasmvm/wasmsolo/solosandboxutils.go @@ -5,7 +5,7 @@ package wasmsolo import ( "github.com/iotaledger/wasp/packages/kv/codec" - "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" + "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" ) func (s *SoloSandbox) fnUtilsBase58Decode(args []byte) []byte { diff --git a/packages/vm/wasmvmhost/host.go b/packages/wasmvm/wasmvmhost/host.go similarity index 98% rename from packages/vm/wasmvmhost/host.go rename to packages/wasmvm/wasmvmhost/host.go index 492c661e14..cc3cfa0d6f 100644 --- a/packages/vm/wasmvmhost/host.go +++ b/packages/wasmvm/wasmvmhost/host.go @@ -6,7 +6,7 @@ package wasmvmhost -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" +import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib" // new Wasm VM diff --git a/tools/schema/generator/goclienttemplates/alltemplates.go b/tools/schema/generator/goclienttemplates/alltemplates.go index baffd0d584..1627458c96 100644 --- a/tools/schema/generator/goclienttemplates/alltemplates.go +++ b/tools/schema/generator/goclienttemplates/alltemplates.go @@ -162,6 +162,6 @@ var common = map[string]string{ "clientHeader": ` package $package$+client -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmclient" +import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmclient" `, } diff --git a/tools/schema/generator/goclienttemplates/service.go b/tools/schema/generator/goclienttemplates/service.go index 8a62f1cd80..bb304d5aab 100644 --- a/tools/schema/generator/goclienttemplates/service.go +++ b/tools/schema/generator/goclienttemplates/service.go @@ -9,7 +9,7 @@ $#if funcs emitContract // ******************************* "emitContract": ` -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmclient" +import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmclient" const ( $#each params constArg diff --git a/tools/schema/generator/gotemplates/alltemplates.go b/tools/schema/generator/gotemplates/alltemplates.go index f096867187..796fe51513 100644 --- a/tools/schema/generator/gotemplates/alltemplates.go +++ b/tools/schema/generator/gotemplates/alltemplates.go @@ -57,11 +57,11 @@ package $package `, // ******************************* "importWasmLib": ` -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib" +import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib" `, // ******************************* "importWasmTypes": ` -import "github.com/iotaledger/wasp/packages/vm/wasmlib/go/wasmlib/wasmtypes" +import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" `, // ******************************* "goHeader": ` From 2c98ebbc2ea6cd5c15e658aff1f984a5c095ba89 Mon Sep 17 00:00:00 2001 From: Eric Hop Date: Wed, 26 Jan 2022 14:10:54 -0800 Subject: [PATCH 050/111] Finalize move to packages/wasmvm --- contracts/wasm/core_build.cmd | 6 +- contracts/wasm/dividend/Cargo.toml | 2 +- contracts/wasm/dividend/go/dividend/consts.go | 2 +- .../wasm/dividend/go/dividend/contract.go | 2 +- .../wasm/dividend/go/dividend/dividend.go | 4 +- contracts/wasm/dividend/go/dividend/lib.go | 2 +- contracts/wasm/dividend/go/dividend/params.go | 2 +- .../wasm/dividend/go/dividend/results.go | 2 +- contracts/wasm/dividend/go/dividend/state.go | 2 +- contracts/wasm/dividend/go/main.go | 2 +- contracts/wasm/dividend/test/dividend_bg.wasm | Bin 32299 -> 32319 bytes contracts/wasm/dividend/test/dividend_test.go | 24 ++-- contracts/wasm/donatewithfeedback/Cargo.toml | 2 +- .../go/donatewithfeedback/consts.go | 2 +- .../go/donatewithfeedback/contract.go | 2 +- .../donatewithfeedback/donatewithfeedback.go | 4 +- .../go/donatewithfeedback/lib.go | 2 +- .../go/donatewithfeedback/params.go | 2 +- .../go/donatewithfeedback/results.go | 2 +- .../go/donatewithfeedback/state.go | 2 +- .../go/donatewithfeedback/structs.go | 2 +- contracts/wasm/donatewithfeedback/go/main.go | 2 +- .../test/donatewithfeedback_bg.wasm | Bin 36806 -> 36830 bytes contracts/wasm/erc20/Cargo.toml | 2 +- contracts/wasm/erc20/go/erc20/consts.go | 2 +- contracts/wasm/erc20/go/erc20/contract.go | 2 +- contracts/wasm/erc20/go/erc20/erc20.go | 2 +- contracts/wasm/erc20/go/erc20/events.go | 4 +- contracts/wasm/erc20/go/erc20/lib.go | 2 +- contracts/wasm/erc20/go/erc20/params.go | 2 +- contracts/wasm/erc20/go/erc20/results.go | 2 +- contracts/wasm/erc20/go/erc20/state.go | 2 +- contracts/wasm/erc20/go/erc20/typedefs.go | 2 +- contracts/wasm/erc20/go/main.go | 2 +- contracts/wasm/erc20/test/erc20_bg.wasm | Bin 35689 -> 35709 bytes contracts/wasm/erc20/test/erc20_test.go | 22 +-- contracts/wasm/erc721/Cargo.toml | 2 +- contracts/wasm/erc721/go/erc721/consts.go | 2 +- contracts/wasm/erc721/go/erc721/contract.go | 2 +- contracts/wasm/erc721/go/erc721/erc721.go | 4 +- contracts/wasm/erc721/go/erc721/events.go | 4 +- contracts/wasm/erc721/go/erc721/lib.go | 2 +- contracts/wasm/erc721/go/erc721/params.go | 2 +- contracts/wasm/erc721/go/erc721/results.go | 2 +- contracts/wasm/erc721/go/erc721/state.go | 2 +- contracts/wasm/erc721/go/erc721/typedefs.go | 2 +- .../wasm/erc721/go/erc721client/events.go | 34 +++-- .../wasm/erc721/go/erc721client/service.go | 126 +++++++++--------- contracts/wasm/erc721/go/main.go | 2 +- contracts/wasm/erc721/test/erc721_bg.wasm | Bin 40104 -> 40124 bytes contracts/wasm/erc721/test/erc721_test.go | 22 +-- contracts/wasm/fairauction/Cargo.toml | 2 +- .../wasm/fairauction/go/fairauction/consts.go | 2 +- .../fairauction/go/fairauction/contract.go | 2 +- .../fairauction/go/fairauction/fairauction.go | 4 +- .../wasm/fairauction/go/fairauction/lib.go | 2 +- .../wasm/fairauction/go/fairauction/params.go | 2 +- .../fairauction/go/fairauction/results.go | 2 +- .../wasm/fairauction/go/fairauction/state.go | 2 +- .../fairauction/go/fairauction/structs.go | 2 +- .../fairauction/go/fairauction/typedefs.go | 2 +- contracts/wasm/fairauction/go/main.go | 2 +- .../wasm/fairauction/test/fairauction_bg.wasm | Bin 43080 -> 43101 bytes .../wasm/fairauction/test/fairauction_test.go | 12 +- contracts/wasm/fairroulette/Cargo.toml | 2 +- .../fairroulette/go/fairroulette/consts.go | 2 +- .../fairroulette/go/fairroulette/contract.go | 2 +- .../fairroulette/go/fairroulette/events.go | 4 +- .../go/fairroulette/fairroulette.go | 4 +- .../wasm/fairroulette/go/fairroulette/lib.go | 2 +- .../fairroulette/go/fairroulette/params.go | 2 +- .../fairroulette/go/fairroulette/results.go | 2 +- .../fairroulette/go/fairroulette/state.go | 2 +- .../fairroulette/go/fairroulette/structs.go | 2 +- contracts/wasm/fairroulette/go/main.go | 2 +- .../fairroulette/test/fairroulette_bg.wasm | Bin 41098 -> 41128 bytes .../fairroulette/test/fairroulette_test.go | 8 +- contracts/wasm/helloworld/Cargo.toml | 2 +- .../wasm/helloworld/go/helloworld/consts.go | 2 +- .../wasm/helloworld/go/helloworld/contract.go | 2 +- .../helloworld/go/helloworld/helloworld.go | 2 +- .../wasm/helloworld/go/helloworld/lib.go | 2 +- .../wasm/helloworld/go/helloworld/results.go | 2 +- .../wasm/helloworld/go/helloworld/state.go | 2 +- contracts/wasm/helloworld/go/main.go | 2 +- .../wasm/helloworld/test/helloworld_bg.wasm | Bin 15381 -> 15385 bytes contracts/wasm/inccounter/Cargo.toml | 2 +- .../wasm/inccounter/go/inccounter/consts.go | 2 +- .../wasm/inccounter/go/inccounter/contract.go | 2 +- .../inccounter/go/inccounter/inccounter.go | 4 +- .../wasm/inccounter/go/inccounter/lib.go | 2 +- .../wasm/inccounter/go/inccounter/params.go | 2 +- .../wasm/inccounter/go/inccounter/results.go | 2 +- .../wasm/inccounter/go/inccounter/state.go | 2 +- contracts/wasm/inccounter/go/main.go | 2 +- .../wasm/inccounter/test/inccounter_bg.wasm | Bin 42137 -> 42161 bytes .../wasm/inccounter/test/inccounter_test.go | 2 +- contracts/wasm/testcore/Cargo.toml | 2 +- contracts/wasm/testcore/go/main.go | 2 +- contracts/wasm/testcore/go/testcore/consts.go | 2 +- .../wasm/testcore/go/testcore/contract.go | 2 +- contracts/wasm/testcore/go/testcore/lib.go | 2 +- contracts/wasm/testcore/go/testcore/params.go | 2 +- .../wasm/testcore/go/testcore/results.go | 2 +- contracts/wasm/testcore/go/testcore/state.go | 2 +- .../wasm/testcore/go/testcore/testcore.go | 8 +- contracts/wasm/testcore/test/2chains_test.go | 8 +- .../wasm/testcore/test/concurrency_test.go | 14 +- contracts/wasm/testcore/test/testcore_bg.wasm | Bin 53958 -> 53986 bytes contracts/wasm/testcore/test/testcore_test.go | 62 ++++----- contracts/wasm/testwasmlib/Cargo.toml | 2 +- contracts/wasm/testwasmlib/go/main.go | 2 +- .../wasm/testwasmlib/go/testwasmlib/consts.go | 2 +- .../testwasmlib/go/testwasmlib/contract.go | 2 +- .../wasm/testwasmlib/go/testwasmlib/events.go | 4 +- .../wasm/testwasmlib/go/testwasmlib/lib.go | 2 +- .../wasm/testwasmlib/go/testwasmlib/params.go | 2 +- .../testwasmlib/go/testwasmlib/results.go | 2 +- .../wasm/testwasmlib/go/testwasmlib/state.go | 2 +- .../testwasmlib/go/testwasmlib/structs.go | 2 +- .../testwasmlib/go/testwasmlib/testwasmlib.go | 6 +- .../testwasmlib/go/testwasmlib/typedefs.go | 2 +- .../go/testwasmlibclient/events.go | 8 +- .../go/testwasmlibclient/service.go | 108 ++++++++------- .../wasm/testwasmlib/test/testwasmlib_bg.wasm | Bin 44634 -> 44657 bytes .../test/testwasmlib_client_test.go | 22 +-- .../wasm/testwasmlib/test/testwasmlib_test.go | 2 +- contracts/wasm/timestamp/Cargo.toml | 2 +- contracts/wasm/timestamp/go/main.go | 2 +- .../wasm/timestamp/go/timestamp/consts.go | 2 +- .../wasm/timestamp/go/timestamp/contract.go | 2 +- contracts/wasm/timestamp/go/timestamp/lib.go | 2 +- .../wasm/timestamp/go/timestamp/results.go | 2 +- .../wasm/timestamp/go/timestamp/state.go | 2 +- .../wasm/timestamp/go/timestamp/timestamp.go | 2 +- .../wasm/timestamp/test/timestamp_bg.wasm | Bin 28186 -> 28202 bytes contracts/wasm/tokenregistry/Cargo.toml | 2 +- contracts/wasm/tokenregistry/go/main.go | 2 +- .../tokenregistry/go/tokenregistry/consts.go | 2 +- .../go/tokenregistry/contract.go | 2 +- .../tokenregistry/go/tokenregistry/lib.go | 2 +- .../tokenregistry/go/tokenregistry/params.go | 2 +- .../tokenregistry/go/tokenregistry/state.go | 2 +- .../tokenregistry/go/tokenregistry/structs.go | 2 +- .../go/tokenregistry/tokenregistry.go | 2 +- .../tokenregistry/test/tokenregistry_bg.wasm | Bin 32035 -> 32055 bytes documentation/docs/guide/schema/events.mdx | 2 +- documentation/docs/guide/schema/funcdesc.mdx | 2 +- documentation/docs/guide/schema/init.mdx | 2 +- documentation/docs/guide/schema/structs.mdx | 4 +- documentation/docs/guide/schema/typedefs.mdx | 4 +- documentation/docs/guide/schema/usage.mdx | 2 +- documentation/tutorial-examples/Cargo.toml | 2 +- .../test/example_tutorial_bg.wasm | Bin 16809 -> 16813 bytes packages/solo/solo.go | 2 +- .../sbtests/sbtestsc/testcore_bg.wasm | Bin 53958 -> 53986 bytes packages/wasmvm/wasmhost/wasmcontext.go | 2 +- packages/wasmvm/wasmhost/wasmgovm.go | 2 +- packages/wasmvm/wasmhost/wasmhost.go | 2 +- packages/wasmvm/wasmhost/wasmtosandbox.go | 2 +- .../wasmvm/wasmhost/wasmtosandboxutils.go | 2 +- packages/wasmvm/wasmhost/wasmvm.go | 2 +- .../go/wasmclient/coreaccounts/service.go | 64 +++++---- .../wasmlib/go/wasmclient/coreblob/service.go | 38 +++--- .../go/wasmclient/coreblocklog/service.go | 78 ++++++----- .../go/wasmclient/coregovernance/service.go | 96 +++++++------ .../wasmlib/go/wasmclient/coreroot/service.go | 48 ++++--- packages/wasmvm/wasmlib/go/wasmlib/assets.go | 2 +- packages/wasmvm/wasmlib/go/wasmlib/context.go | 2 +- .../wasmvm/wasmlib/go/wasmlib/contract.go | 4 +- .../wasmlib/go/wasmlib/coreaccounts/consts.go | 2 +- .../go/wasmlib/coreaccounts/contract.go | 2 +- .../wasmlib/go/wasmlib/coreaccounts/params.go | 2 +- .../go/wasmlib/coreaccounts/results.go | 2 +- .../wasmlib/go/wasmlib/coreblob/consts.go | 2 +- .../wasmlib/go/wasmlib/coreblob/contract.go | 2 +- .../wasmlib/go/wasmlib/coreblob/params.go | 2 +- .../wasmlib/go/wasmlib/coreblob/results.go | 2 +- .../wasmlib/go/wasmlib/coreblocklog/consts.go | 2 +- .../go/wasmlib/coreblocklog/contract.go | 2 +- .../wasmlib/go/wasmlib/coreblocklog/params.go | 2 +- .../go/wasmlib/coreblocklog/results.go | 2 +- .../go/wasmlib/coregovernance/consts.go | 2 +- .../go/wasmlib/coregovernance/contract.go | 2 +- .../go/wasmlib/coregovernance/params.go | 2 +- .../go/wasmlib/coregovernance/results.go | 2 +- .../wasmlib/go/wasmlib/coreroot/consts.go | 2 +- .../wasmlib/go/wasmlib/coreroot/contract.go | 2 +- .../wasmlib/go/wasmlib/coreroot/params.go | 2 +- .../wasmlib/go/wasmlib/coreroot/results.go | 2 +- packages/wasmvm/wasmlib/go/wasmlib/dict.go | 2 +- packages/wasmvm/wasmlib/go/wasmlib/events.go | 2 +- packages/wasmvm/wasmlib/go/wasmlib/sandbox.go | 4 +- .../wasmvm/wasmlib/go/wasmlib/sandboxutils.go | 2 +- packages/wasmvm/wasmlib/go/wasmlib/state.go | 2 +- .../wasmlib/go/wasmlib/wasmrequests/consts.go | 2 +- .../go/wasmlib/wasmrequests/structs.go | 2 +- packages/wasmvm/wasmsolo/soloagent.go | 2 +- packages/wasmvm/wasmsolo/solocontext.go | 14 +- packages/wasmvm/wasmsolo/soloconvertor.go | 2 +- packages/wasmvm/wasmsolo/solosandbox.go | 6 +- packages/wasmvm/wasmsolo/solosandboxutils.go | 2 +- packages/wasmvm/wasmvmhost/host.go | 2 +- plugins/wasmtimevm/plugin.go | 2 +- tools/cluster/tests/wasm/inccounter_bg.wasm | Bin 42137 -> 42161 bytes .../goclienttemplates/alltemplates.go | 2 +- .../generator/goclienttemplates/service.go | 2 +- .../generator/gotemplates/alltemplates.go | 4 +- tools/schema/generator/gotemplates/main.go | 2 +- tools/schema/generator/templates.go | 2 +- 210 files changed, 595 insertions(+), 613 deletions(-) diff --git a/contracts/wasm/core_build.cmd b/contracts/wasm/core_build.cmd index 1ae6c16ad8..53f3f1720a 100644 --- a/contracts/wasm/core_build.cmd +++ b/contracts/wasm/core_build.cmd @@ -1,9 +1,9 @@ @echo off go install ../../tools/schema -cd ..\..\packages\vm\wasmlib +cd ..\..\packages\wasmvm\wasmlib schema -core -go -rust -ts -client -force del /s /q d:\work\node_modules\wasmlib\*.* >nul: del /s /q d:\work\node_modules\wasmclient\*.* >nul: -xcopy /s /q d:\Work\go\github.com\iotaledger\wasp\packages\vm\wasmlib\ts\wasmclient d:\work\node_modules\wasmclient -xcopy /s /q d:\Work\go\github.com\iotaledger\wasp\packages\vm\wasmlib\ts\wasmlib d:\work\node_modules\wasmlib +xcopy /s /q d:\Work\go\github.com\iotaledger\wasp\packages\wasmvm\wasmlib\ts\wasmclient d:\work\node_modules\wasmclient +xcopy /s /q d:\Work\go\github.com\iotaledger\wasp\packages\wasmvm\wasmlib\ts\wasmlib d:\work\node_modules\wasmlib cd ..\..\..\contracts\wasm diff --git a/contracts/wasm/dividend/Cargo.toml b/contracts/wasm/dividend/Cargo.toml index 64ca57d31b..2efc543b4e 100644 --- a/contracts/wasm/dividend/Cargo.toml +++ b/contracts/wasm/dividend/Cargo.toml @@ -17,7 +17,7 @@ crate-type = ["cdylib", "rlib"] default = ["console_error_panic_hook"] [dependencies] -wasmlib = { path = "../../../wasmvm/wasmlib" } +wasmlib = { path = "../../../packages/wasmvm/wasmlib" } #wasmlib = { git = "https://github.com/iotaledger/wasp", branch = "develop" } # The `console_error_panic_hook` crate provides better debugging of panics by diff --git a/contracts/wasm/dividend/go/dividend/consts.go b/contracts/wasm/dividend/go/dividend/consts.go index 0d3f661756..e5c66a5b75 100644 --- a/contracts/wasm/dividend/go/dividend/consts.go +++ b/contracts/wasm/dividend/go/dividend/consts.go @@ -7,7 +7,7 @@ package dividend -import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" +import "github.com/iotaledger/wasp/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes" const ( ScName = "dividend" diff --git a/contracts/wasm/dividend/go/dividend/contract.go b/contracts/wasm/dividend/go/dividend/contract.go index df3e7cf45f..3efc3fb14a 100644 --- a/contracts/wasm/dividend/go/dividend/contract.go +++ b/contracts/wasm/dividend/go/dividend/contract.go @@ -7,7 +7,7 @@ package dividend -import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib" +import "github.com/iotaledger/wasp/packages/wasmvm/wasmlib/go/wasmlib" type DivideCall struct { Func *wasmlib.ScFunc diff --git a/contracts/wasm/dividend/go/dividend/dividend.go b/contracts/wasm/dividend/go/dividend/dividend.go index 0786eb7f25..c397b30f97 100644 --- a/contracts/wasm/dividend/go/dividend/dividend.go +++ b/contracts/wasm/dividend/go/dividend/dividend.go @@ -15,8 +15,8 @@ package dividend import ( - "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib" - "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" + "github.com/iotaledger/wasp/packages/wasmvm/wasmlib/go/wasmlib" + "github.com/iotaledger/wasp/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes" ) // 'init' is used as a way to initialize a smart contract. It is an optional diff --git a/contracts/wasm/dividend/go/dividend/lib.go b/contracts/wasm/dividend/go/dividend/lib.go index 4fd65066d1..6196d7a900 100644 --- a/contracts/wasm/dividend/go/dividend/lib.go +++ b/contracts/wasm/dividend/go/dividend/lib.go @@ -7,7 +7,7 @@ package dividend -import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib" +import "github.com/iotaledger/wasp/packages/wasmvm/wasmlib/go/wasmlib" func OnLoad() { exports := wasmlib.NewScExports() diff --git a/contracts/wasm/dividend/go/dividend/params.go b/contracts/wasm/dividend/go/dividend/params.go index 3a98c8c45b..3e5c7c3513 100644 --- a/contracts/wasm/dividend/go/dividend/params.go +++ b/contracts/wasm/dividend/go/dividend/params.go @@ -7,7 +7,7 @@ package dividend -import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" +import "github.com/iotaledger/wasp/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes" type ImmutableInitParams struct { proxy wasmtypes.Proxy diff --git a/contracts/wasm/dividend/go/dividend/results.go b/contracts/wasm/dividend/go/dividend/results.go index e433eee980..963b7b9208 100644 --- a/contracts/wasm/dividend/go/dividend/results.go +++ b/contracts/wasm/dividend/go/dividend/results.go @@ -7,7 +7,7 @@ package dividend -import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" +import "github.com/iotaledger/wasp/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes" type ImmutableGetFactorResults struct { proxy wasmtypes.Proxy diff --git a/contracts/wasm/dividend/go/dividend/state.go b/contracts/wasm/dividend/go/dividend/state.go index ee700b52a4..9d5ad8cbb8 100644 --- a/contracts/wasm/dividend/go/dividend/state.go +++ b/contracts/wasm/dividend/go/dividend/state.go @@ -7,7 +7,7 @@ package dividend -import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" +import "github.com/iotaledger/wasp/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes" type ArrayOfImmutableAddress struct { proxy wasmtypes.Proxy diff --git a/contracts/wasm/dividend/go/main.go b/contracts/wasm/dividend/go/main.go index 2b86f655a4..5701ab931a 100644 --- a/contracts/wasm/dividend/go/main.go +++ b/contracts/wasm/dividend/go/main.go @@ -9,7 +9,7 @@ package main -import "github.com/iotaledger/wasp/packages/vm/wasmvmhost" +import "github.com/iotaledger/wasp/packages/wasmvm/wasmvmhost" import "github.com/iotaledger/wasp/contracts/wasm/dividend/go/dividend" diff --git a/contracts/wasm/dividend/test/dividend_bg.wasm b/contracts/wasm/dividend/test/dividend_bg.wasm index 21b499b830d5ecdeb77a0e66e309123da7f42460..c97fe7d5c4c428160a6ee9720ef911116bcd2592 100644 GI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?P@!jDKb((ba<=;KHR83R`t zb@IZK7@sAvy270Lb~ngqYs$yt9rWz#Vx;`1tEbY;vN%dDi$dCFm)%F_R;5Po*b9+# zOMHOGeRQg<0;!sK|E6eu66L4~hB{y5;xkHxU%T$Fj=uC1?o*f3S9+fYywMnw|apFo?n{t@okMq$`#+UT_R0IZ9O&7cK=MFB9c$ zY!E-8BO5a&SJ%|E*0!}hSiPaWskQ0h#@g0VLq+)p7vFXK=;p?<`AUnTD^_6X{ z8!9(ew{2{Hw7Iq|tF=wpW@p(48&mDpXkX*btUKkK+S*xEQI(Wu{*(z}x)P1K9Q0oFt<{YW)f%;pHO8jK zn%YNUv5+z`FpmY$g5(v=8s=b+cn z=b>jkL!`FP^#s>6gF6Y_=g~XSA41PjAEK)EsZr-ZO$5bpW}lq%A8PNgdn%%IB@JW| ee%uG?GK|@{3V+^@+ihW-DK4S$m+Q$Vw*L=WRaA%o diff --git a/contracts/wasm/dividend/test/dividend_test.go b/contracts/wasm/dividend/test/dividend_test.go index f81bbee93b..2f2943492d 100644 --- a/contracts/wasm/dividend/test/dividend_test.go +++ b/contracts/wasm/dividend/test/dividend_test.go @@ -9,23 +9,23 @@ import ( "github.com/iotaledger/wasp/contracts/wasm/dividend/go/dividend" "github.com/iotaledger/wasp/packages/solo" - wasmsolo2 "github.com/iotaledger/wasp/packages/wasmvm/wasmsolo" + "github.com/iotaledger/wasp/packages/wasmvm/wasmsolo" "github.com/stretchr/testify/require" ) -func dividendMember(ctx *wasmsolo2.SoloContext, agent *wasmsolo2.SoloAgent, factor uint64) { +func dividendMember(ctx *wasmsolo.SoloContext, agent *wasmsolo.SoloAgent, factor uint64) { member := dividend.ScFuncs.Member(ctx) member.Params.Address().SetValue(agent.ScAddress()) member.Params.Factor().SetValue(factor) member.Func.TransferIotas(1).Post() } -func dividendDivide(ctx *wasmsolo2.SoloContext, amount uint64) { +func dividendDivide(ctx *wasmsolo.SoloContext, amount uint64) { divide := dividend.ScFuncs.Divide(ctx) divide.Func.TransferIotas(amount).Post() } -func dividendGetFactor(ctx *wasmsolo2.SoloContext, member *wasmsolo2.SoloAgent) uint64 { +func dividendGetFactor(ctx *wasmsolo.SoloContext, member *wasmsolo.SoloAgent) uint64 { getFactor := dividend.ScFuncs.GetFactor(ctx) getFactor.Params.Address().SetValue(member.ScAddress()) getFactor.Func.Call() @@ -34,12 +34,12 @@ func dividendGetFactor(ctx *wasmsolo2.SoloContext, member *wasmsolo2.SoloAgent) } func TestDeploy(t *testing.T) { - ctx := wasmsolo2.NewSoloContext(t, dividend.ScName, dividend.OnLoad) + ctx := wasmsolo.NewSoloContext(t, dividend.ScName, dividend.OnLoad) require.NoError(t, ctx.ContractExists(dividend.ScName)) } func TestAddMemberOk(t *testing.T) { - ctx := wasmsolo2.NewSoloContext(t, dividend.ScName, dividend.OnLoad) + ctx := wasmsolo.NewSoloContext(t, dividend.ScName, dividend.OnLoad) member1 := ctx.NewSoloAgent() dividendMember(ctx, member1, 100) @@ -47,7 +47,7 @@ func TestAddMemberOk(t *testing.T) { } func TestAddMemberFailMissingAddress(t *testing.T) { - ctx := wasmsolo2.NewSoloContext(t, dividend.ScName, dividend.OnLoad) + ctx := wasmsolo.NewSoloContext(t, dividend.ScName, dividend.OnLoad) member := dividend.ScFuncs.Member(ctx) member.Params.Factor().SetValue(100) @@ -57,7 +57,7 @@ func TestAddMemberFailMissingAddress(t *testing.T) { } func TestAddMemberFailMissingFactor(t *testing.T) { - ctx := wasmsolo2.NewSoloContext(t, dividend.ScName, dividend.OnLoad) + ctx := wasmsolo.NewSoloContext(t, dividend.ScName, dividend.OnLoad) member1 := ctx.NewSoloAgent() member := dividend.ScFuncs.Member(ctx) @@ -68,7 +68,7 @@ func TestAddMemberFailMissingFactor(t *testing.T) { } func TestDivide1Member(t *testing.T) { - ctx := wasmsolo2.NewSoloContext(t, dividend.ScName, dividend.OnLoad) + ctx := wasmsolo.NewSoloContext(t, dividend.ScName, dividend.OnLoad) member1 := ctx.NewSoloAgent() dividendMember(ctx, member1, 100) @@ -85,7 +85,7 @@ func TestDivide1Member(t *testing.T) { } func TestDivide2Members(t *testing.T) { - ctx := wasmsolo2.NewSoloContext(t, dividend.ScName, dividend.OnLoad) + ctx := wasmsolo.NewSoloContext(t, dividend.ScName, dividend.OnLoad) member1 := ctx.NewSoloAgent() dividendMember(ctx, member1, 25) @@ -107,7 +107,7 @@ func TestDivide2Members(t *testing.T) { } func TestDivide3Members(t *testing.T) { - ctx := wasmsolo2.NewSoloContext(t, dividend.ScName, dividend.OnLoad) + ctx := wasmsolo.NewSoloContext(t, dividend.ScName, dividend.OnLoad) member1 := ctx.NewSoloAgent() dividendMember(ctx, member1, 25) @@ -155,7 +155,7 @@ func TestDivide3Members(t *testing.T) { } func TestGetFactor(t *testing.T) { - ctx := wasmsolo2.NewSoloContext(t, dividend.ScName, dividend.OnLoad) + ctx := wasmsolo.NewSoloContext(t, dividend.ScName, dividend.OnLoad) member1 := ctx.NewSoloAgent() dividendMember(ctx, member1, 25) diff --git a/contracts/wasm/donatewithfeedback/Cargo.toml b/contracts/wasm/donatewithfeedback/Cargo.toml index 9967571a22..864d2989f1 100644 --- a/contracts/wasm/donatewithfeedback/Cargo.toml +++ b/contracts/wasm/donatewithfeedback/Cargo.toml @@ -17,7 +17,7 @@ crate-type = ["cdylib", "rlib"] default = ["console_error_panic_hook"] [dependencies] -wasmlib = { path = "../../../wasmvm/wasmlib" } +wasmlib = { path = "../../../packages/wasmvm/wasmlib" } #wasmlib = { git = "https://github.com/iotaledger/wasp", branch = "develop" } # The `console_error_panic_hook` crate provides better debugging of panics by diff --git a/contracts/wasm/donatewithfeedback/go/donatewithfeedback/consts.go b/contracts/wasm/donatewithfeedback/go/donatewithfeedback/consts.go index 8d2741fe26..4c8fe93542 100644 --- a/contracts/wasm/donatewithfeedback/go/donatewithfeedback/consts.go +++ b/contracts/wasm/donatewithfeedback/go/donatewithfeedback/consts.go @@ -7,7 +7,7 @@ package donatewithfeedback -import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" +import "github.com/iotaledger/wasp/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes" const ( ScName = "donatewithfeedback" diff --git a/contracts/wasm/donatewithfeedback/go/donatewithfeedback/contract.go b/contracts/wasm/donatewithfeedback/go/donatewithfeedback/contract.go index 17312f10a7..30a896390d 100644 --- a/contracts/wasm/donatewithfeedback/go/donatewithfeedback/contract.go +++ b/contracts/wasm/donatewithfeedback/go/donatewithfeedback/contract.go @@ -7,7 +7,7 @@ package donatewithfeedback -import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib" +import "github.com/iotaledger/wasp/packages/wasmvm/wasmlib/go/wasmlib" type DonateCall struct { Func *wasmlib.ScFunc diff --git a/contracts/wasm/donatewithfeedback/go/donatewithfeedback/donatewithfeedback.go b/contracts/wasm/donatewithfeedback/go/donatewithfeedback/donatewithfeedback.go index 28435f292b..75bb332187 100644 --- a/contracts/wasm/donatewithfeedback/go/donatewithfeedback/donatewithfeedback.go +++ b/contracts/wasm/donatewithfeedback/go/donatewithfeedback/donatewithfeedback.go @@ -4,8 +4,8 @@ package donatewithfeedback import ( - "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib" - "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" + "github.com/iotaledger/wasp/packages/wasmvm/wasmlib/go/wasmlib" + "github.com/iotaledger/wasp/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes" ) func funcDonate(ctx wasmlib.ScFuncContext, f *DonateContext) { diff --git a/contracts/wasm/donatewithfeedback/go/donatewithfeedback/lib.go b/contracts/wasm/donatewithfeedback/go/donatewithfeedback/lib.go index f2879b3b45..3f9c5b8023 100644 --- a/contracts/wasm/donatewithfeedback/go/donatewithfeedback/lib.go +++ b/contracts/wasm/donatewithfeedback/go/donatewithfeedback/lib.go @@ -7,7 +7,7 @@ package donatewithfeedback -import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib" +import "github.com/iotaledger/wasp/packages/wasmvm/wasmlib/go/wasmlib" func OnLoad() { exports := wasmlib.NewScExports() diff --git a/contracts/wasm/donatewithfeedback/go/donatewithfeedback/params.go b/contracts/wasm/donatewithfeedback/go/donatewithfeedback/params.go index c212da8c53..50f50d0f2a 100644 --- a/contracts/wasm/donatewithfeedback/go/donatewithfeedback/params.go +++ b/contracts/wasm/donatewithfeedback/go/donatewithfeedback/params.go @@ -7,7 +7,7 @@ package donatewithfeedback -import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" +import "github.com/iotaledger/wasp/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes" type ImmutableDonateParams struct { proxy wasmtypes.Proxy diff --git a/contracts/wasm/donatewithfeedback/go/donatewithfeedback/results.go b/contracts/wasm/donatewithfeedback/go/donatewithfeedback/results.go index 5a19480d93..50ddf93dfe 100644 --- a/contracts/wasm/donatewithfeedback/go/donatewithfeedback/results.go +++ b/contracts/wasm/donatewithfeedback/go/donatewithfeedback/results.go @@ -7,7 +7,7 @@ package donatewithfeedback -import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" +import "github.com/iotaledger/wasp/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes" type ImmutableDonationResults struct { proxy wasmtypes.Proxy diff --git a/contracts/wasm/donatewithfeedback/go/donatewithfeedback/state.go b/contracts/wasm/donatewithfeedback/go/donatewithfeedback/state.go index 5ec6bfc839..0610963601 100644 --- a/contracts/wasm/donatewithfeedback/go/donatewithfeedback/state.go +++ b/contracts/wasm/donatewithfeedback/go/donatewithfeedback/state.go @@ -7,7 +7,7 @@ package donatewithfeedback -import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" +import "github.com/iotaledger/wasp/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes" type ArrayOfImmutableDonation struct { proxy wasmtypes.Proxy diff --git a/contracts/wasm/donatewithfeedback/go/donatewithfeedback/structs.go b/contracts/wasm/donatewithfeedback/go/donatewithfeedback/structs.go index 07dc2df7e6..84f733fc31 100644 --- a/contracts/wasm/donatewithfeedback/go/donatewithfeedback/structs.go +++ b/contracts/wasm/donatewithfeedback/go/donatewithfeedback/structs.go @@ -7,7 +7,7 @@ package donatewithfeedback -import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" +import "github.com/iotaledger/wasp/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes" type Donation struct { Amount uint64 // amount donated diff --git a/contracts/wasm/donatewithfeedback/go/main.go b/contracts/wasm/donatewithfeedback/go/main.go index a263164081..f616cdc2a9 100644 --- a/contracts/wasm/donatewithfeedback/go/main.go +++ b/contracts/wasm/donatewithfeedback/go/main.go @@ -9,7 +9,7 @@ package main -import "github.com/iotaledger/wasp/packages/vm/wasmvmhost" +import "github.com/iotaledger/wasp/packages/wasmvm/wasmvmhost" import "github.com/iotaledger/wasp/contracts/wasm/donatewithfeedback/go/donatewithfeedback" diff --git a/contracts/wasm/donatewithfeedback/test/donatewithfeedback_bg.wasm b/contracts/wasm/donatewithfeedback/test/donatewithfeedback_bg.wasm index a4f9ce75523457118aa888ab38920fa3f1cec26c..49f8eb30aa3582efdb347be57d914b9c3000ef2c 100644 GIT binary patch delta 5424 zcmai14Rln+6@K$}v)N>`$=m!A^7nQFA>CS*)Cw+oP_a#GT4SX>sVD8pvDiZuTac)zcuWzb-+k|G2xyPVd2{E^ z{h66N-@P;Y$0yW(KA|32qlz9{tKK0_(QnoL=r6S;qQAjbhW3Q*u2H>5Iu*ayp*G5s z=w+*lPnAL!^**uQUZOj)RcDlN$&*xKUn5S^^L9P!RM60?aEI#-w~#%SnNo@YMQar` zQmvP#=nEK}qPxQqh^_9^9<9Bh#qr7OBx z6k5e6VN;3+&1{yLxZVt`X(mEumuZyTfxdD=I!kx6ibf$kX&#cx6dHo4c}AyDw65 zADi|2uq;Jh0B1D3e?`Zdbul}IC1*{&QiS#*jdo^?355;e(CxK8AvNjL?&C>VBF#0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pc67t%HvaWvR#@I2VDuIA9CZe z2Op@_Yad*puYPbvZG*lB?L0yW)o#zz_5$&mUV-E&(V^{)QHb&5FCfOZ({0U(RNCyM zY0X2CW0y2%q1@3tdU?NFQ_^AnIKC8oVZ0S}ZV%%}Z^8AzJn^tTaErcnKu<|Kio82G zAEK!Rl4sdNi+ALubO6Nw{Tk8^`2i%asD}>inCJ`lvBzji7Fu&5nX_XcnZrGFZO3Tu zQlJq)(fD{jmWC$nY;^c9#A`}6;4FMB!+0L*Jb?@Gp-=a0vPE-laS1!Wg%&=u{eQ4` BRTBUJ diff --git a/contracts/wasm/erc20/Cargo.toml b/contracts/wasm/erc20/Cargo.toml index 6801b3463b..79f7479434 100644 --- a/contracts/wasm/erc20/Cargo.toml +++ b/contracts/wasm/erc20/Cargo.toml @@ -17,7 +17,7 @@ crate-type = ["cdylib", "rlib"] default = ["console_error_panic_hook"] [dependencies] -wasmlib = { path = "../../../wasmvm/wasmlib" } +wasmlib = { path = "../../../packages/wasmvm/wasmlib" } #wasmlib = { git = "https://github.com/iotaledger/wasp", branch = "develop" } # The `console_error_panic_hook` crate provides better debugging of panics by diff --git a/contracts/wasm/erc20/go/erc20/consts.go b/contracts/wasm/erc20/go/erc20/consts.go index 6c4a93112e..d6c91bcf3e 100644 --- a/contracts/wasm/erc20/go/erc20/consts.go +++ b/contracts/wasm/erc20/go/erc20/consts.go @@ -7,7 +7,7 @@ package erc20 -import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" +import "github.com/iotaledger/wasp/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes" const ( ScName = "erc20" diff --git a/contracts/wasm/erc20/go/erc20/contract.go b/contracts/wasm/erc20/go/erc20/contract.go index 6788fe772f..b86cd07093 100644 --- a/contracts/wasm/erc20/go/erc20/contract.go +++ b/contracts/wasm/erc20/go/erc20/contract.go @@ -7,7 +7,7 @@ package erc20 -import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib" +import "github.com/iotaledger/wasp/packages/wasmvm/wasmlib/go/wasmlib" type ApproveCall struct { Func *wasmlib.ScFunc diff --git a/contracts/wasm/erc20/go/erc20/erc20.go b/contracts/wasm/erc20/go/erc20/erc20.go index c20c6a5015..6a4882485c 100644 --- a/contracts/wasm/erc20/go/erc20/erc20.go +++ b/contracts/wasm/erc20/go/erc20/erc20.go @@ -7,7 +7,7 @@ package erc20 import ( - "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib" + "github.com/iotaledger/wasp/packages/wasmvm/wasmlib/go/wasmlib" ) // Sets the allowance value for delegated account diff --git a/contracts/wasm/erc20/go/erc20/events.go b/contracts/wasm/erc20/go/erc20/events.go index 8612fd8c5d..087cd28b86 100644 --- a/contracts/wasm/erc20/go/erc20/events.go +++ b/contracts/wasm/erc20/go/erc20/events.go @@ -9,8 +9,8 @@ package erc20 import ( - "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib" - "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" + "github.com/iotaledger/wasp/packages/wasmvm/wasmlib/go/wasmlib" + "github.com/iotaledger/wasp/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes" ) type Erc20Events struct{} diff --git a/contracts/wasm/erc20/go/erc20/lib.go b/contracts/wasm/erc20/go/erc20/lib.go index 9eab89292c..158396f17b 100644 --- a/contracts/wasm/erc20/go/erc20/lib.go +++ b/contracts/wasm/erc20/go/erc20/lib.go @@ -7,7 +7,7 @@ package erc20 -import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib" +import "github.com/iotaledger/wasp/packages/wasmvm/wasmlib/go/wasmlib" func OnLoad() { exports := wasmlib.NewScExports() diff --git a/contracts/wasm/erc20/go/erc20/params.go b/contracts/wasm/erc20/go/erc20/params.go index 36e180055d..ad361dd08f 100644 --- a/contracts/wasm/erc20/go/erc20/params.go +++ b/contracts/wasm/erc20/go/erc20/params.go @@ -7,7 +7,7 @@ package erc20 -import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" +import "github.com/iotaledger/wasp/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes" type ImmutableApproveParams struct { proxy wasmtypes.Proxy diff --git a/contracts/wasm/erc20/go/erc20/results.go b/contracts/wasm/erc20/go/erc20/results.go index ffc782c3a8..ce2871f763 100644 --- a/contracts/wasm/erc20/go/erc20/results.go +++ b/contracts/wasm/erc20/go/erc20/results.go @@ -7,7 +7,7 @@ package erc20 -import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" +import "github.com/iotaledger/wasp/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes" type ImmutableAllowanceResults struct { proxy wasmtypes.Proxy diff --git a/contracts/wasm/erc20/go/erc20/state.go b/contracts/wasm/erc20/go/erc20/state.go index 0e0e70dd16..8ed002ffe8 100644 --- a/contracts/wasm/erc20/go/erc20/state.go +++ b/contracts/wasm/erc20/go/erc20/state.go @@ -7,7 +7,7 @@ package erc20 -import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" +import "github.com/iotaledger/wasp/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes" type MapAgentIDToImmutableAllowancesForAgent struct { proxy wasmtypes.Proxy diff --git a/contracts/wasm/erc20/go/erc20/typedefs.go b/contracts/wasm/erc20/go/erc20/typedefs.go index de3560e533..cf93e072b5 100644 --- a/contracts/wasm/erc20/go/erc20/typedefs.go +++ b/contracts/wasm/erc20/go/erc20/typedefs.go @@ -7,7 +7,7 @@ package erc20 -import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" +import "github.com/iotaledger/wasp/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes" type MapAgentIDToImmutableUint64 struct { proxy wasmtypes.Proxy diff --git a/contracts/wasm/erc20/go/main.go b/contracts/wasm/erc20/go/main.go index ebb45b8642..9599ca1081 100644 --- a/contracts/wasm/erc20/go/main.go +++ b/contracts/wasm/erc20/go/main.go @@ -9,7 +9,7 @@ package main -import "github.com/iotaledger/wasp/packages/vm/wasmvmhost" +import "github.com/iotaledger/wasp/packages/wasmvm/wasmvmhost" import "github.com/iotaledger/wasp/contracts/wasm/erc20/go/erc20" diff --git a/contracts/wasm/erc20/test/erc20_bg.wasm b/contracts/wasm/erc20/test/erc20_bg.wasm index 54e4add5288403991f08ead39374ff41de74b0f5..7b2ec074b0a9f27b0359d5313ef8a0e4cdb10b97 100644 GIT binary patch delta 4499 zcmai14Nz3q6@K@=x68ur;w}(jMd9uPagiT23S_VdS4Hp#MJG{XXfz@w0Ui0-B#atZ zE0bU(mE>ST8`5g4k;xCDYZIK%1{>Ru8I#(Ho!U-jVlsB}=Omao8QR*=bKZN4B%xDw z-o5vnd+xdCp7Y&v51&56|MLv*Z{@u0B<$mryz>;i$DjALog7jETxrmiQnxA;&y(x{ z$%7JS52&TQ^E6yks{-vPRO`3%Rv9wIbuO7;L7g>dCBh!y4i|Ic9NekZaqP}%sou`h zhT;l$l(4&*#9gmz3AAgJtuD)&)LE%p6HKZP>(~UPxlferHrM)Xr1N>(?Y#3O{Mi^{#17-+ z@F)8WI^7rc96=Tedp=hrX&@sMp?ZGJ{Hn`tcw%8xj>`~2Gf4=7QJE2+=!(#mYbCPl zH1tKSE;&LPoB^)sF_Oj@j#?d!Rpc?Gj0Rb_2u~u|%4C}9G383pv%T;mM=I-vDu-_> z?I^7s4Ml!q?}HA%)3DRf+6}Kc#F{}_O>U5PB_dvg^lnuZ)E`6pI22TS9LMQ@5r{S7> zu3>CV|1*>?a;L-_3K=QmLcZKlV*^_1Q@ z@ub2nJf1^{UEC>?D}Jwtm5y53Z;}PLU99k8_kW<*56^n5COu|y+`M!v1UjCf!cE7- zQ%~aA_v{0J=e-2W<3DFNAunMU8wejyxWIVFbI>%kjGc$qr`|J-+=Koo!$30(vs4?T zTIS|-wdW?TANTu{iJ4iJYXqZ2#Uj}ZR~kb~N2Yse?T3j|R~hjzQI4BLpd+}M1<+=hStOp)STF)`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Jv;BZ5?@2O(!` zJ{t-z-X-#n^Hx13VA$NUI zk#Yoi972y3C6ozd4I)W@AH&Gw%i@%HuOg5VFu!Y&Z?Q$)h8#bBi=nrxg1sI--<87H z`!LeIC_m!zDv3B1@Al#kTt#Wy@X!OzqWPgFvFV|v=1wsm`Lsbi+!-wJG$1vZq_Fou zWmhr`1ScWrL%~wtACTw5x$~CHAVh)%X^O|IBp^2ddky`C7s%-=b0T6E1~_?XNEhU T>{ML@O&8Pfq@93o_x|j^YFke3 diff --git a/contracts/wasm/erc20/test/erc20_test.go b/contracts/wasm/erc20/test/erc20_test.go index 5fd1f3de5c..282d50aa0e 100644 --- a/contracts/wasm/erc20/test/erc20_test.go +++ b/contracts/wasm/erc20/test/erc20_test.go @@ -6,26 +6,26 @@ import ( "github.com/iotaledger/wasp/contracts/wasm/erc20/go/erc20" "github.com/iotaledger/wasp/packages/solo" "github.com/iotaledger/wasp/packages/vm/core" - wasmsolo2 "github.com/iotaledger/wasp/packages/wasmvm/wasmsolo" + "github.com/iotaledger/wasp/packages/wasmvm/wasmsolo" "github.com/stretchr/testify/require" ) var ( chain *solo.Chain - creator *wasmsolo2.SoloAgent + creator *wasmsolo.SoloAgent ) func setupTest(t *testing.T) { - chain = wasmsolo2.StartChain(t, "chain1") - creator = wasmsolo2.NewSoloAgent(chain.Env) + chain = wasmsolo.StartChain(t, "chain1") + creator = wasmsolo.NewSoloAgent(chain.Env) } -func setupErc20(t *testing.T) *wasmsolo2.SoloContext { +func setupErc20(t *testing.T) *wasmsolo.SoloContext { setupTest(t) init := erc20.ScFuncs.Init(nil) init.Params.Supply().SetValue(solo.Saldo) init.Params.Creator().SetValue(creator.ScAgentID()) - ctx := wasmsolo2.NewSoloContextForChain(t, chain, nil, erc20.ScName, erc20.OnLoad, init.Func) + ctx := wasmsolo.NewSoloContextForChain(t, chain, nil, erc20.ScName, erc20.OnLoad, init.Func) require.NoError(t, ctx.Err) _, _, rec := chain.GetInfo() require.EqualValues(t, len(core.AllCoreContractsByHash)+1, len(rec)) @@ -41,7 +41,7 @@ func setupErc20(t *testing.T) *wasmsolo2.SoloContext { return ctx } -func checkErc20Balance(ctx *wasmsolo2.SoloContext, account *wasmsolo2.SoloAgent, amount uint64) { +func checkErc20Balance(ctx *wasmsolo.SoloContext, account *wasmsolo.SoloAgent, amount uint64) { t := chain.Env.T balanceOf := erc20.ScFuncs.BalanceOf(ctx) balanceOf.Params.Account().SetValue(account.ScAgentID()) @@ -52,7 +52,7 @@ func checkErc20Balance(ctx *wasmsolo2.SoloContext, account *wasmsolo2.SoloAgent, require.EqualValues(t, amount, balance.Value()) } -func checkErc20Allowance(ctx *wasmsolo2.SoloContext, account, delegation *wasmsolo2.SoloAgent, amount uint64) { +func checkErc20Allowance(ctx *wasmsolo.SoloContext, account, delegation *wasmsolo.SoloAgent, amount uint64) { t := chain.Env.T allowance := erc20.ScFuncs.Allowance(ctx) allowance.Params.Account().SetValue(account.ScAgentID()) @@ -64,7 +64,7 @@ func checkErc20Allowance(ctx *wasmsolo2.SoloContext, account, delegation *wasmso require.EqualValues(t, amount, balance.Value()) } -func approve(ctx *wasmsolo2.SoloContext, from, to *wasmsolo2.SoloAgent, amount uint64) error { +func approve(ctx *wasmsolo.SoloContext, from, to *wasmsolo.SoloAgent, amount uint64) error { appr := erc20.ScFuncs.Approve(ctx.Sign(from)) appr.Params.Delegation().SetValue(to.ScAgentID()) appr.Params.Amount().SetValue(amount) @@ -72,7 +72,7 @@ func approve(ctx *wasmsolo2.SoloContext, from, to *wasmsolo2.SoloAgent, amount u return ctx.Err } -func transfer(ctx *wasmsolo2.SoloContext, from, to *wasmsolo2.SoloAgent, amount uint64) error { +func transfer(ctx *wasmsolo.SoloContext, from, to *wasmsolo.SoloAgent, amount uint64) error { tx := erc20.ScFuncs.Transfer(ctx.Sign(from)) tx.Params.Account().SetValue(to.ScAgentID()) tx.Params.Amount().SetValue(amount) @@ -80,7 +80,7 @@ func transfer(ctx *wasmsolo2.SoloContext, from, to *wasmsolo2.SoloAgent, amount return ctx.Err } -func transferFrom(ctx *wasmsolo2.SoloContext, delegate, from, to *wasmsolo2.SoloAgent, amount uint64) error { +func transferFrom(ctx *wasmsolo.SoloContext, delegate, from, to *wasmsolo.SoloAgent, amount uint64) error { tx := erc20.ScFuncs.TransferFrom(ctx.Sign(delegate)) tx.Params.Account().SetValue(from.ScAgentID()) tx.Params.Recipient().SetValue(to.ScAgentID()) diff --git a/contracts/wasm/erc721/Cargo.toml b/contracts/wasm/erc721/Cargo.toml index 456c9c79bd..883bb82695 100644 --- a/contracts/wasm/erc721/Cargo.toml +++ b/contracts/wasm/erc721/Cargo.toml @@ -17,7 +17,7 @@ crate-type = ["cdylib", "rlib"] default = ["console_error_panic_hook"] [dependencies] -wasmlib = { path = "../../../wasmvm/wasmlib" } +wasmlib = { path = "../../../packages/wasmvm/wasmlib" } #wasmlib = { git = "https://github.com/iotaledger/wasp", branch = "develop" } console_error_panic_hook = { version = "0.1.6", optional = true } wee_alloc = { version = "0.4.5", optional = true } diff --git a/contracts/wasm/erc721/go/erc721/consts.go b/contracts/wasm/erc721/go/erc721/consts.go index b7a98b58e9..b5d8b0ad3a 100644 --- a/contracts/wasm/erc721/go/erc721/consts.go +++ b/contracts/wasm/erc721/go/erc721/consts.go @@ -7,7 +7,7 @@ package erc721 -import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" +import "github.com/iotaledger/wasp/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes" const ( ScName = "erc721" diff --git a/contracts/wasm/erc721/go/erc721/contract.go b/contracts/wasm/erc721/go/erc721/contract.go index 1895c15675..903a910922 100644 --- a/contracts/wasm/erc721/go/erc721/contract.go +++ b/contracts/wasm/erc721/go/erc721/contract.go @@ -7,7 +7,7 @@ package erc721 -import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib" +import "github.com/iotaledger/wasp/packages/wasmvm/wasmlib/go/wasmlib" type ApproveCall struct { Func *wasmlib.ScFunc diff --git a/contracts/wasm/erc721/go/erc721/erc721.go b/contracts/wasm/erc721/go/erc721/erc721.go index 472852c515..97f1da0653 100644 --- a/contracts/wasm/erc721/go/erc721/erc721.go +++ b/contracts/wasm/erc721/go/erc721/erc721.go @@ -4,8 +4,8 @@ package erc721 import ( - "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib" - "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" + "github.com/iotaledger/wasp/packages/wasmvm/wasmlib/go/wasmlib" + "github.com/iotaledger/wasp/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes" ) // Follows ERC-721 standard as closely as possible diff --git a/contracts/wasm/erc721/go/erc721/events.go b/contracts/wasm/erc721/go/erc721/events.go index d961a72373..7b913defe2 100644 --- a/contracts/wasm/erc721/go/erc721/events.go +++ b/contracts/wasm/erc721/go/erc721/events.go @@ -9,8 +9,8 @@ package erc721 import ( - "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib" - "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" + "github.com/iotaledger/wasp/packages/wasmvm/wasmlib/go/wasmlib" + "github.com/iotaledger/wasp/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes" ) type Erc721Events struct{} diff --git a/contracts/wasm/erc721/go/erc721/lib.go b/contracts/wasm/erc721/go/erc721/lib.go index ce4a03583d..ec7e5d7da2 100644 --- a/contracts/wasm/erc721/go/erc721/lib.go +++ b/contracts/wasm/erc721/go/erc721/lib.go @@ -7,7 +7,7 @@ package erc721 -import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib" +import "github.com/iotaledger/wasp/packages/wasmvm/wasmlib/go/wasmlib" func OnLoad() { exports := wasmlib.NewScExports() diff --git a/contracts/wasm/erc721/go/erc721/params.go b/contracts/wasm/erc721/go/erc721/params.go index 9f9a2d9035..60ef796639 100644 --- a/contracts/wasm/erc721/go/erc721/params.go +++ b/contracts/wasm/erc721/go/erc721/params.go @@ -7,7 +7,7 @@ package erc721 -import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" +import "github.com/iotaledger/wasp/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes" type ImmutableApproveParams struct { proxy wasmtypes.Proxy diff --git a/contracts/wasm/erc721/go/erc721/results.go b/contracts/wasm/erc721/go/erc721/results.go index 78265bf585..f8864d5e54 100644 --- a/contracts/wasm/erc721/go/erc721/results.go +++ b/contracts/wasm/erc721/go/erc721/results.go @@ -7,7 +7,7 @@ package erc721 -import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" +import "github.com/iotaledger/wasp/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes" type ImmutableBalanceOfResults struct { proxy wasmtypes.Proxy diff --git a/contracts/wasm/erc721/go/erc721/state.go b/contracts/wasm/erc721/go/erc721/state.go index a4d04e5fc8..884610fa40 100644 --- a/contracts/wasm/erc721/go/erc721/state.go +++ b/contracts/wasm/erc721/go/erc721/state.go @@ -7,7 +7,7 @@ package erc721 -import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" +import "github.com/iotaledger/wasp/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes" type MapHashToImmutableAgentID struct { proxy wasmtypes.Proxy diff --git a/contracts/wasm/erc721/go/erc721/typedefs.go b/contracts/wasm/erc721/go/erc721/typedefs.go index d837c511db..25811e6af9 100644 --- a/contracts/wasm/erc721/go/erc721/typedefs.go +++ b/contracts/wasm/erc721/go/erc721/typedefs.go @@ -7,7 +7,7 @@ package erc721 -import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" +import "github.com/iotaledger/wasp/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes" type MapAgentIDToImmutableBool struct { proxy wasmtypes.Proxy diff --git a/contracts/wasm/erc721/go/erc721client/events.go b/contracts/wasm/erc721/go/erc721client/events.go index a9881f3e8b..8c27c39289 100644 --- a/contracts/wasm/erc721/go/erc721client/events.go +++ b/contracts/wasm/erc721/go/erc721client/events.go @@ -7,9 +7,7 @@ package erc721client -import ( - wasmclient2 "github.com/iotaledger/wasp/packages/wasmvm/wasmlib/go/wasmclient" -) +import "github.com/iotaledger/wasp/packages/wasmvm/wasmlib/go/wasmclient" var erc721Handlers = map[string]func(*Erc721Events, []string){ "erc721.approval": func(evt *Erc721Events, msg []string) { evt.onErc721ApprovalThunk(msg) }, @@ -55,10 +53,10 @@ func (h *Erc721Events) OnErc721Transfer(handler func(e *EventTransfer)) { } type EventApproval struct { - wasmclient2.Event - Approved wasmclient2.AgentID - Owner wasmclient2.AgentID - TokenID wasmclient2.Hash + wasmclient.Event + Approved wasmclient.AgentID + Owner wasmclient.AgentID + TokenID wasmclient.Hash } func (h *Erc721Events) onErc721ApprovalThunk(message []string) { @@ -74,10 +72,10 @@ func (h *Erc721Events) onErc721ApprovalThunk(message []string) { } type EventApprovalForAll struct { - wasmclient2.Event + wasmclient.Event Approval bool - Operator wasmclient2.AgentID - Owner wasmclient2.AgentID + Operator wasmclient.AgentID + Owner wasmclient.AgentID } func (h *Erc721Events) onErc721ApprovalForAllThunk(message []string) { @@ -93,7 +91,7 @@ func (h *Erc721Events) onErc721ApprovalForAllThunk(message []string) { } type EventInit struct { - wasmclient2.Event + wasmclient.Event Name string Symbol string } @@ -110,10 +108,10 @@ func (h *Erc721Events) onErc721InitThunk(message []string) { } type EventMint struct { - wasmclient2.Event + wasmclient.Event Balance uint64 - Owner wasmclient2.AgentID - TokenID wasmclient2.Hash + Owner wasmclient.AgentID + TokenID wasmclient.Hash } func (h *Erc721Events) onErc721MintThunk(message []string) { @@ -129,10 +127,10 @@ func (h *Erc721Events) onErc721MintThunk(message []string) { } type EventTransfer struct { - wasmclient2.Event - From wasmclient2.AgentID - To wasmclient2.AgentID - TokenID wasmclient2.Hash + wasmclient.Event + From wasmclient.AgentID + To wasmclient.AgentID + TokenID wasmclient.Hash } func (h *Erc721Events) onErc721TransferThunk(message []string) { diff --git a/contracts/wasm/erc721/go/erc721client/service.go b/contracts/wasm/erc721/go/erc721client/service.go index 9e086a7cf0..57659c39ed 100644 --- a/contracts/wasm/erc721/go/erc721client/service.go +++ b/contracts/wasm/erc721/go/erc721client/service.go @@ -7,9 +7,7 @@ package erc721client -import ( - wasmclient2 "github.com/iotaledger/wasp/packages/wasmvm/wasmlib/go/wasmclient" -) +import "github.com/iotaledger/wasp/packages/wasmvm/wasmlib/go/wasmclient" const ( ArgApproval = "approval" @@ -36,19 +34,19 @@ const ( ///////////////////////////// approve ///////////////////////////// type ApproveFunc struct { - wasmclient2.ClientFunc - args wasmclient2.Arguments + wasmclient.ClientFunc + args wasmclient.Arguments } -func (f *ApproveFunc) Approved(v wasmclient2.AgentID) { +func (f *ApproveFunc) Approved(v wasmclient.AgentID) { f.args.Set(ArgApproved, f.args.FromAgentID(v)) } -func (f *ApproveFunc) TokenID(v wasmclient2.Hash) { +func (f *ApproveFunc) TokenID(v wasmclient.Hash) { f.args.Set(ArgTokenID, f.args.FromHash(v)) } -func (f *ApproveFunc) Post() wasmclient2.Request { +func (f *ApproveFunc) Post() wasmclient.Request { f.args.Mandatory(ArgTokenID) return f.ClientFunc.Post(0xa0661268, &f.args) } @@ -56,15 +54,15 @@ func (f *ApproveFunc) Post() wasmclient2.Request { ///////////////////////////// burn ///////////////////////////// type BurnFunc struct { - wasmclient2.ClientFunc - args wasmclient2.Arguments + wasmclient.ClientFunc + args wasmclient.Arguments } -func (f *BurnFunc) TokenID(v wasmclient2.Hash) { +func (f *BurnFunc) TokenID(v wasmclient.Hash) { f.args.Set(ArgTokenID, f.args.FromHash(v)) } -func (f *BurnFunc) Post() wasmclient2.Request { +func (f *BurnFunc) Post() wasmclient.Request { f.args.Mandatory(ArgTokenID) return f.ClientFunc.Post(0x7bc1efb1, &f.args) } @@ -72,8 +70,8 @@ func (f *BurnFunc) Post() wasmclient2.Request { ///////////////////////////// init ///////////////////////////// type InitFunc struct { - wasmclient2.ClientFunc - args wasmclient2.Arguments + wasmclient.ClientFunc + args wasmclient.Arguments } func (f *InitFunc) Name(v string) { @@ -84,7 +82,7 @@ func (f *InitFunc) Symbol(v string) { f.args.Set(ArgSymbol, f.args.FromString(v)) } -func (f *InitFunc) Post() wasmclient2.Request { +func (f *InitFunc) Post() wasmclient.Request { f.args.Mandatory(ArgName) f.args.Mandatory(ArgSymbol) return f.ClientFunc.Post(0x1f44d644, &f.args) @@ -93,11 +91,11 @@ func (f *InitFunc) Post() wasmclient2.Request { ///////////////////////////// mint ///////////////////////////// type MintFunc struct { - wasmclient2.ClientFunc - args wasmclient2.Arguments + wasmclient.ClientFunc + args wasmclient.Arguments } -func (f *MintFunc) TokenID(v wasmclient2.Hash) { +func (f *MintFunc) TokenID(v wasmclient.Hash) { f.args.Set(ArgTokenID, f.args.FromHash(v)) } @@ -105,7 +103,7 @@ func (f *MintFunc) TokenURI(v string) { f.args.Set(ArgTokenURI, f.args.FromString(v)) } -func (f *MintFunc) Post() wasmclient2.Request { +func (f *MintFunc) Post() wasmclient.Request { f.args.Mandatory(ArgTokenID) return f.ClientFunc.Post(0xa29addcf, &f.args) } @@ -113,27 +111,27 @@ func (f *MintFunc) Post() wasmclient2.Request { ///////////////////////////// safeTransferFrom ///////////////////////////// type SafeTransferFromFunc struct { - wasmclient2.ClientFunc - args wasmclient2.Arguments + wasmclient.ClientFunc + args wasmclient.Arguments } func (f *SafeTransferFromFunc) Data(v []byte) { f.args.Set(ArgData, f.args.FromBytes(v)) } -func (f *SafeTransferFromFunc) From(v wasmclient2.AgentID) { +func (f *SafeTransferFromFunc) From(v wasmclient.AgentID) { f.args.Set(ArgFrom, f.args.FromAgentID(v)) } -func (f *SafeTransferFromFunc) To(v wasmclient2.AgentID) { +func (f *SafeTransferFromFunc) To(v wasmclient.AgentID) { f.args.Set(ArgTo, f.args.FromAgentID(v)) } -func (f *SafeTransferFromFunc) TokenID(v wasmclient2.Hash) { +func (f *SafeTransferFromFunc) TokenID(v wasmclient.Hash) { f.args.Set(ArgTokenID, f.args.FromHash(v)) } -func (f *SafeTransferFromFunc) Post() wasmclient2.Request { +func (f *SafeTransferFromFunc) Post() wasmclient.Request { f.args.Mandatory(ArgFrom) f.args.Mandatory(ArgTo) f.args.Mandatory(ArgTokenID) @@ -143,19 +141,19 @@ func (f *SafeTransferFromFunc) Post() wasmclient2.Request { ///////////////////////////// setApprovalForAll ///////////////////////////// type SetApprovalForAllFunc struct { - wasmclient2.ClientFunc - args wasmclient2.Arguments + wasmclient.ClientFunc + args wasmclient.Arguments } func (f *SetApprovalForAllFunc) Approval(v bool) { f.args.Set(ArgApproval, f.args.FromBool(v)) } -func (f *SetApprovalForAllFunc) Operator(v wasmclient2.AgentID) { +func (f *SetApprovalForAllFunc) Operator(v wasmclient.AgentID) { f.args.Set(ArgOperator, f.args.FromAgentID(v)) } -func (f *SetApprovalForAllFunc) Post() wasmclient2.Request { +func (f *SetApprovalForAllFunc) Post() wasmclient.Request { f.args.Mandatory(ArgApproval) f.args.Mandatory(ArgOperator) return f.ClientFunc.Post(0xb8d8c776, &f.args) @@ -164,23 +162,23 @@ func (f *SetApprovalForAllFunc) Post() wasmclient2.Request { ///////////////////////////// transferFrom ///////////////////////////// type TransferFromFunc struct { - wasmclient2.ClientFunc - args wasmclient2.Arguments + wasmclient.ClientFunc + args wasmclient.Arguments } -func (f *TransferFromFunc) From(v wasmclient2.AgentID) { +func (f *TransferFromFunc) From(v wasmclient.AgentID) { f.args.Set(ArgFrom, f.args.FromAgentID(v)) } -func (f *TransferFromFunc) To(v wasmclient2.AgentID) { +func (f *TransferFromFunc) To(v wasmclient.AgentID) { f.args.Set(ArgTo, f.args.FromAgentID(v)) } -func (f *TransferFromFunc) TokenID(v wasmclient2.Hash) { +func (f *TransferFromFunc) TokenID(v wasmclient.Hash) { f.args.Set(ArgTokenID, f.args.FromHash(v)) } -func (f *TransferFromFunc) Post() wasmclient2.Request { +func (f *TransferFromFunc) Post() wasmclient.Request { f.args.Mandatory(ArgFrom) f.args.Mandatory(ArgTo) f.args.Mandatory(ArgTokenID) @@ -190,11 +188,11 @@ func (f *TransferFromFunc) Post() wasmclient2.Request { ///////////////////////////// balanceOf ///////////////////////////// type BalanceOfView struct { - wasmclient2.ClientView - args wasmclient2.Arguments + wasmclient.ClientView + args wasmclient.Arguments } -func (f *BalanceOfView) Owner(v wasmclient2.AgentID) { +func (f *BalanceOfView) Owner(v wasmclient.AgentID) { f.args.Set(ArgOwner, f.args.FromAgentID(v)) } @@ -205,7 +203,7 @@ func (f *BalanceOfView) Call() BalanceOfResults { } type BalanceOfResults struct { - res wasmclient2.Results + res wasmclient.Results } func (r *BalanceOfResults) AmountExists() bool { @@ -219,11 +217,11 @@ func (r *BalanceOfResults) Amount() uint64 { ///////////////////////////// getApproved ///////////////////////////// type GetApprovedView struct { - wasmclient2.ClientView - args wasmclient2.Arguments + wasmclient.ClientView + args wasmclient.Arguments } -func (f *GetApprovedView) TokenID(v wasmclient2.Hash) { +func (f *GetApprovedView) TokenID(v wasmclient.Hash) { f.args.Set(ArgTokenID, f.args.FromHash(v)) } @@ -234,29 +232,29 @@ func (f *GetApprovedView) Call() GetApprovedResults { } type GetApprovedResults struct { - res wasmclient2.Results + res wasmclient.Results } func (r *GetApprovedResults) ApprovedExists() bool { return r.res.Exists(ResApproved) } -func (r *GetApprovedResults) Approved() wasmclient2.AgentID { +func (r *GetApprovedResults) Approved() wasmclient.AgentID { return r.res.ToAgentID(r.res.Get(ResApproved)) } ///////////////////////////// isApprovedForAll ///////////////////////////// type IsApprovedForAllView struct { - wasmclient2.ClientView - args wasmclient2.Arguments + wasmclient.ClientView + args wasmclient.Arguments } -func (f *IsApprovedForAllView) Operator(v wasmclient2.AgentID) { +func (f *IsApprovedForAllView) Operator(v wasmclient.AgentID) { f.args.Set(ArgOperator, f.args.FromAgentID(v)) } -func (f *IsApprovedForAllView) Owner(v wasmclient2.AgentID) { +func (f *IsApprovedForAllView) Owner(v wasmclient.AgentID) { f.args.Set(ArgOwner, f.args.FromAgentID(v)) } @@ -268,7 +266,7 @@ func (f *IsApprovedForAllView) Call() IsApprovedForAllResults { } type IsApprovedForAllResults struct { - res wasmclient2.Results + res wasmclient.Results } func (r *IsApprovedForAllResults) ApprovalExists() bool { @@ -282,7 +280,7 @@ func (r *IsApprovedForAllResults) Approval() bool { ///////////////////////////// name ///////////////////////////// type NameView struct { - wasmclient2.ClientView + wasmclient.ClientView } func (f *NameView) Call() NameResults { @@ -291,7 +289,7 @@ func (f *NameView) Call() NameResults { } type NameResults struct { - res wasmclient2.Results + res wasmclient.Results } func (r *NameResults) Name() string { @@ -301,11 +299,11 @@ func (r *NameResults) Name() string { ///////////////////////////// ownerOf ///////////////////////////// type OwnerOfView struct { - wasmclient2.ClientView - args wasmclient2.Arguments + wasmclient.ClientView + args wasmclient.Arguments } -func (f *OwnerOfView) TokenID(v wasmclient2.Hash) { +func (f *OwnerOfView) TokenID(v wasmclient.Hash) { f.args.Set(ArgTokenID, f.args.FromHash(v)) } @@ -316,21 +314,21 @@ func (f *OwnerOfView) Call() OwnerOfResults { } type OwnerOfResults struct { - res wasmclient2.Results + res wasmclient.Results } func (r *OwnerOfResults) OwnerExists() bool { return r.res.Exists(ResOwner) } -func (r *OwnerOfResults) Owner() wasmclient2.AgentID { +func (r *OwnerOfResults) Owner() wasmclient.AgentID { return r.res.ToAgentID(r.res.Get(ResOwner)) } ///////////////////////////// symbol ///////////////////////////// type SymbolView struct { - wasmclient2.ClientView + wasmclient.ClientView } func (f *SymbolView) Call() SymbolResults { @@ -339,7 +337,7 @@ func (f *SymbolView) Call() SymbolResults { } type SymbolResults struct { - res wasmclient2.Results + res wasmclient.Results } func (r *SymbolResults) Symbol() string { @@ -349,11 +347,11 @@ func (r *SymbolResults) Symbol() string { ///////////////////////////// tokenURI ///////////////////////////// type TokenURIView struct { - wasmclient2.ClientView - args wasmclient2.Arguments + wasmclient.ClientView + args wasmclient.Arguments } -func (f *TokenURIView) TokenID(v wasmclient2.Hash) { +func (f *TokenURIView) TokenID(v wasmclient.Hash) { f.args.Set(ArgTokenID, f.args.FromHash(v)) } @@ -364,7 +362,7 @@ func (f *TokenURIView) Call() TokenURIResults { } type TokenURIResults struct { - res wasmclient2.Results + res wasmclient.Results } func (r *TokenURIResults) TokenURIExists() bool { @@ -378,10 +376,10 @@ func (r *TokenURIResults) TokenURI() string { ///////////////////////////// Erc721Service ///////////////////////////// type Erc721Service struct { - wasmclient2.Service + wasmclient.Service } -func NewErc721Service(cl *wasmclient2.ServiceClient, chainID string) (*Erc721Service, error) { +func NewErc721Service(cl *wasmclient.ServiceClient, chainID string) (*Erc721Service, error) { s := &Erc721Service{} err := s.Service.Init(cl, chainID, 0xd967c216) return s, err diff --git a/contracts/wasm/erc721/go/main.go b/contracts/wasm/erc721/go/main.go index f06a3059cc..c848bb7781 100644 --- a/contracts/wasm/erc721/go/main.go +++ b/contracts/wasm/erc721/go/main.go @@ -9,7 +9,7 @@ package main -import "github.com/iotaledger/wasp/packages/vm/wasmvmhost" +import "github.com/iotaledger/wasp/packages/wasmvm/wasmvmhost" import "github.com/iotaledger/wasp/contracts/wasm/erc721/go/erc721" diff --git a/contracts/wasm/erc721/test/erc721_bg.wasm b/contracts/wasm/erc721/test/erc721_bg.wasm index e505977cbbdec59650d47e33f807039fa99a841f..ba5fba1619971af2ffef1b730de321b511722acc 100644 GIT binary patch delta 4634 zcma)9eQ;FO6@T}>-A%}5lb7#L$lFZ5cDnX$4ZN^=aiE-PDXX#4080RFFFK ziD0>{FDcjtmP)Tn)~kTc?2}5EqRuC39c8AgKt{(3H`b`$@vKDmPe;z+V5g;ax+ltX zd4vk@!ka|(-(;k7O<|bTC(1nzQz(7C4^5r2ca2hQwkEHWclgBl&`*MF4ovpBRJ7Gg zQ?t2!+C&%x(l298&6NIL%SO5$d$?Cl56g*r>c)BD)ni?jFKeQT+!hmz0uvpN zDl~eHFddT}WvYe#9`!`o5tersNQW;*@fe<|^x+7aItt2a*jbthb4)Qci&qZWeC3Et zJ3SYjGa}+-_|9}x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rU|%sw{NOJIT*iru7qiKZq5nc z?BCw}a01`Z3#HePQ$!JR5`j%)pI)4>`*tIrq@O*#Aff&C=}ywOJSKW+<(8*pu!X9& zq|(K$Uh-_6Aln9_-A9-jy0|rsum4~C=wZ~M>D%UGY}sbWubb%XwoJCk$J>k~+a}iM zN>o5kRQq;PVokOP(ZrfGv5V%{Omgk#`0!HA#=*8J2ZSE16QfQw(q}bus3BNPn}RVk z7Vx*hQ^kE5?UU-9mEDHm+kXcTRNr~Z=J4UC0G>k@!!oiupv>=PrXs(7U7IHV&_M6k zE{9&z>WY5Yvd1a}m3%!97ZfLct!uMoIC+!PyonQ=*c?9mEW~rXNd#|Vn7?c=Rkery zr7lU_@KUcNxhYozRgS;rK-`JFnP|@}x={|v$ z$yW)fF45-35%?l|u`x%8f1?Xc!|*%GUz)axe-2gcyeLEi-MedN)M>sk#^bo1yAGsw z*aZf4+|bhEHBED)9pZ!MISM}0nDxe8QT#K?InA9^x_sTbgpY&;!p#ipa}#;OUH_#rsyqYT9@B`wN~A@X*D5d6cyKN)2Q`B6TeSupH107yyg{ zTniWtxYeHD0T>B9%)i^l_uKIH^(~m^^*;mj^ph6?KFF3^%o}!Kg5leMyzxaqUU(VM z2^dzOa?$d&_CX(8w|2>6Pc2`ZzjmFbH9A87xM!!JK{SbGQ(o#1B6MvA)*W|fS{|T4 zlRznQ-;5`sGU}zwcqR|S!+QOh*~#1d2yJN2i`eASwV8CXIn#c-(7Z8k!^+1tE?Tz| z`smTyz7U$03Al$29oiw1$T&PiJVN6S7Y$nA z)-lhNO^0U!J&XrzYIAv9Xx(;koH1-*fkh<)MYo4H4pL+H_>axl#YlG#zD#c=m~WktBLTf8?0+NKxg4$7{(vMJ1ej*^w^1NM>JO*w{Y@3=KYuI F{|8pwkd*)c diff --git a/contracts/wasm/fairauction/test/fairauction_test.go b/contracts/wasm/fairauction/test/fairauction_test.go index b95856dd53..8219200521 100644 --- a/contracts/wasm/fairauction/test/fairauction_test.go +++ b/contracts/wasm/fairauction/test/fairauction_test.go @@ -9,18 +9,18 @@ import ( "github.com/iotaledger/wasp/contracts/wasm/fairauction/go/fairauction" "github.com/iotaledger/wasp/packages/solo" - "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" - wasmsolo2 "github.com/iotaledger/wasp/packages/wasmvm/wasmsolo" + "github.com/iotaledger/wasp/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes" + "github.com/iotaledger/wasp/packages/wasmvm/wasmsolo" "github.com/stretchr/testify/require" ) var ( - auctioneer *wasmsolo2.SoloAgent + auctioneer *wasmsolo.SoloAgent tokenColor wasmtypes.ScColor ) -func startAuction(t *testing.T) *wasmsolo2.SoloContext { - ctx := wasmsolo2.NewSoloContext(t, fairauction.ScName, fairauction.OnLoad) +func startAuction(t *testing.T) *wasmsolo.SoloContext { + ctx := wasmsolo.NewSoloContext(t, fairauction.ScName, fairauction.OnLoad) // set up auctioneer account and mint some tokens to auction off auctioneer = ctx.NewSoloAgent() @@ -43,7 +43,7 @@ func startAuction(t *testing.T) *wasmsolo2.SoloContext { } func TestDeploy(t *testing.T) { - ctx := wasmsolo2.NewSoloContext(t, fairauction.ScName, fairauction.OnLoad) + ctx := wasmsolo.NewSoloContext(t, fairauction.ScName, fairauction.OnLoad) require.NoError(t, ctx.ContractExists(fairauction.ScName)) } diff --git a/contracts/wasm/fairroulette/Cargo.toml b/contracts/wasm/fairroulette/Cargo.toml index bef9b6713e..0f67e54bd6 100644 --- a/contracts/wasm/fairroulette/Cargo.toml +++ b/contracts/wasm/fairroulette/Cargo.toml @@ -17,7 +17,7 @@ crate-type = ["cdylib", "rlib"] default = ["console_error_panic_hook"] [dependencies] -wasmlib = { path = "../../../wasmvm/wasmlib" } +wasmlib = { path = "../../../packages/wasmvm/wasmlib" } #wasmlib = { git = "https://github.com/iotaledger/wasp", branch = "develop" } # The `console_error_panic_hook` crate provides better debugging of panics by diff --git a/contracts/wasm/fairroulette/go/fairroulette/consts.go b/contracts/wasm/fairroulette/go/fairroulette/consts.go index 2f6e6ab67e..6ef1d12317 100644 --- a/contracts/wasm/fairroulette/go/fairroulette/consts.go +++ b/contracts/wasm/fairroulette/go/fairroulette/consts.go @@ -7,7 +7,7 @@ package fairroulette -import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" +import "github.com/iotaledger/wasp/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes" const ( ScName = "fairroulette" diff --git a/contracts/wasm/fairroulette/go/fairroulette/contract.go b/contracts/wasm/fairroulette/go/fairroulette/contract.go index 2a3f301d53..6cd760fd22 100644 --- a/contracts/wasm/fairroulette/go/fairroulette/contract.go +++ b/contracts/wasm/fairroulette/go/fairroulette/contract.go @@ -7,7 +7,7 @@ package fairroulette -import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib" +import "github.com/iotaledger/wasp/packages/wasmvm/wasmlib/go/wasmlib" type ForcePayoutCall struct { Func *wasmlib.ScFunc diff --git a/contracts/wasm/fairroulette/go/fairroulette/events.go b/contracts/wasm/fairroulette/go/fairroulette/events.go index f843b9e30b..905109b708 100644 --- a/contracts/wasm/fairroulette/go/fairroulette/events.go +++ b/contracts/wasm/fairroulette/go/fairroulette/events.go @@ -8,8 +8,8 @@ package fairroulette import ( - "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib" - "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" + "github.com/iotaledger/wasp/packages/wasmvm/wasmlib/go/wasmlib" + "github.com/iotaledger/wasp/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes" ) type FairRouletteEvents struct{} diff --git a/contracts/wasm/fairroulette/go/fairroulette/fairroulette.go b/contracts/wasm/fairroulette/go/fairroulette/fairroulette.go index 75f55366f7..67d70bba54 100644 --- a/contracts/wasm/fairroulette/go/fairroulette/fairroulette.go +++ b/contracts/wasm/fairroulette/go/fairroulette/fairroulette.go @@ -10,8 +10,8 @@ package fairroulette import ( - "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib" - "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" + "github.com/iotaledger/wasp/packages/wasmvm/wasmlib/go/wasmlib" + "github.com/iotaledger/wasp/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes" ) // Define some default configuration parameters. diff --git a/contracts/wasm/fairroulette/go/fairroulette/lib.go b/contracts/wasm/fairroulette/go/fairroulette/lib.go index 6ff79e077a..d8950efd3d 100644 --- a/contracts/wasm/fairroulette/go/fairroulette/lib.go +++ b/contracts/wasm/fairroulette/go/fairroulette/lib.go @@ -7,7 +7,7 @@ package fairroulette -import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib" +import "github.com/iotaledger/wasp/packages/wasmvm/wasmlib/go/wasmlib" func OnLoad() { exports := wasmlib.NewScExports() diff --git a/contracts/wasm/fairroulette/go/fairroulette/params.go b/contracts/wasm/fairroulette/go/fairroulette/params.go index 7437bbbfd4..37eb25c28f 100644 --- a/contracts/wasm/fairroulette/go/fairroulette/params.go +++ b/contracts/wasm/fairroulette/go/fairroulette/params.go @@ -7,7 +7,7 @@ package fairroulette -import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" +import "github.com/iotaledger/wasp/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes" type ImmutablePlaceBetParams struct { proxy wasmtypes.Proxy diff --git a/contracts/wasm/fairroulette/go/fairroulette/results.go b/contracts/wasm/fairroulette/go/fairroulette/results.go index 8eb16d8b00..988371e5a9 100644 --- a/contracts/wasm/fairroulette/go/fairroulette/results.go +++ b/contracts/wasm/fairroulette/go/fairroulette/results.go @@ -7,7 +7,7 @@ package fairroulette -import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" +import "github.com/iotaledger/wasp/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes" type ImmutableLastWinningNumberResults struct { proxy wasmtypes.Proxy diff --git a/contracts/wasm/fairroulette/go/fairroulette/state.go b/contracts/wasm/fairroulette/go/fairroulette/state.go index aa2610aadc..b481a01364 100644 --- a/contracts/wasm/fairroulette/go/fairroulette/state.go +++ b/contracts/wasm/fairroulette/go/fairroulette/state.go @@ -7,7 +7,7 @@ package fairroulette -import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" +import "github.com/iotaledger/wasp/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes" type ArrayOfImmutableBet struct { proxy wasmtypes.Proxy diff --git a/contracts/wasm/fairroulette/go/fairroulette/structs.go b/contracts/wasm/fairroulette/go/fairroulette/structs.go index f834c412b4..fa92b9f25e 100644 --- a/contracts/wasm/fairroulette/go/fairroulette/structs.go +++ b/contracts/wasm/fairroulette/go/fairroulette/structs.go @@ -7,7 +7,7 @@ package fairroulette -import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" +import "github.com/iotaledger/wasp/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes" type Bet struct { Amount uint64 diff --git a/contracts/wasm/fairroulette/go/main.go b/contracts/wasm/fairroulette/go/main.go index c4f5e312dc..d7cd1af022 100644 --- a/contracts/wasm/fairroulette/go/main.go +++ b/contracts/wasm/fairroulette/go/main.go @@ -9,7 +9,7 @@ package main -import "github.com/iotaledger/wasp/packages/vm/wasmvmhost" +import "github.com/iotaledger/wasp/packages/wasmvm/wasmvmhost" import "github.com/iotaledger/wasp/contracts/wasm/fairroulette/go/fairroulette" diff --git a/contracts/wasm/fairroulette/test/fairroulette_bg.wasm b/contracts/wasm/fairroulette/test/fairroulette_bg.wasm index f9f6095b5b2dbac1d82fdfd9178b3bae1002fe45..8a487046e577c630120c4f266620f0d80ef06705 100644 GIT binary patch delta 5220 zcma)A4OCTC7QW})`yR-95AJ&?@*{HI1C=C1MI@<44yEXTW2xkCr6~SD{vh~Qt>IbE z$q*IYXlj}|Lo-;KG>=dz9jsQ_jJcdO&Wx*}wA7XrwP-~%tQ9L~?|bh4ru9W+faV}LT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_D;VA$}N`<6;fCW=Ln%fBPq6INQZV{kI<}QEFt)a~` befz%Mbj5hF=sO--`&4h9#ePC~)KEsINsEG?-CB%nj! zs-#0pzz!`G8hB#`-{9t=gS1EoL5BzJ=+LFb`_lL`+!i2MA0GA8|Caz%P5@fi1QN}L(kw4>916*f7X+DvUV97rmN zqlRU_(u#a#s{h9{ka|@XGN9lgn$+f#R2W2eD*4r{#hGhsZVW%XwjXa{UcY&cp8H(3A66+7h|C_#T{F!#0=a zKF9w^D4HRsCUGacxJl)U4=jq!K6A|TPtQ!Z?qxT`pKFKbyC}bpa;v^Wfhj;gIQ#6- z>01}1s6@M5^4 WEYO0r`CH*+#7knL0o3B%V(l7~V489O diff --git a/contracts/wasm/inccounter/Cargo.toml b/contracts/wasm/inccounter/Cargo.toml index acf50c84ac..b8a519e68e 100644 --- a/contracts/wasm/inccounter/Cargo.toml +++ b/contracts/wasm/inccounter/Cargo.toml @@ -17,7 +17,7 @@ crate-type = ["cdylib", "rlib"] default = ["console_error_panic_hook"] [dependencies] -wasmlib = { path = "../../../wasmvm/wasmlib" } +wasmlib = { path = "../../../packages/wasmvm/wasmlib" } #wasmlib = { git = "https://github.com/iotaledger/wasp", branch = "develop" } # The `console_error_panic_hook` crate provides better debugging of panics by diff --git a/contracts/wasm/inccounter/go/inccounter/consts.go b/contracts/wasm/inccounter/go/inccounter/consts.go index 99609c1564..cfd2fabd96 100644 --- a/contracts/wasm/inccounter/go/inccounter/consts.go +++ b/contracts/wasm/inccounter/go/inccounter/consts.go @@ -7,7 +7,7 @@ package inccounter -import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" +import "github.com/iotaledger/wasp/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes" const ( ScName = "inccounter" diff --git a/contracts/wasm/inccounter/go/inccounter/contract.go b/contracts/wasm/inccounter/go/inccounter/contract.go index 3519df24e2..91e558d74f 100644 --- a/contracts/wasm/inccounter/go/inccounter/contract.go +++ b/contracts/wasm/inccounter/go/inccounter/contract.go @@ -7,7 +7,7 @@ package inccounter -import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib" +import "github.com/iotaledger/wasp/packages/wasmvm/wasmlib/go/wasmlib" type CallIncrementCall struct { Func *wasmlib.ScFunc diff --git a/contracts/wasm/inccounter/go/inccounter/inccounter.go b/contracts/wasm/inccounter/go/inccounter/inccounter.go index b0d1e5ff93..f438068188 100644 --- a/contracts/wasm/inccounter/go/inccounter/inccounter.go +++ b/contracts/wasm/inccounter/go/inccounter/inccounter.go @@ -6,8 +6,8 @@ package inccounter import ( "strconv" - "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib" - "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" + "github.com/iotaledger/wasp/packages/wasmvm/wasmlib/go/wasmlib" + "github.com/iotaledger/wasp/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes" ) const hex = "0123456789abcdef" diff --git a/contracts/wasm/inccounter/go/inccounter/lib.go b/contracts/wasm/inccounter/go/inccounter/lib.go index 0923259dbc..7679907662 100644 --- a/contracts/wasm/inccounter/go/inccounter/lib.go +++ b/contracts/wasm/inccounter/go/inccounter/lib.go @@ -7,7 +7,7 @@ package inccounter -import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib" +import "github.com/iotaledger/wasp/packages/wasmvm/wasmlib/go/wasmlib" func OnLoad() { exports := wasmlib.NewScExports() diff --git a/contracts/wasm/inccounter/go/inccounter/params.go b/contracts/wasm/inccounter/go/inccounter/params.go index 38c4804e4e..017d37be87 100644 --- a/contracts/wasm/inccounter/go/inccounter/params.go +++ b/contracts/wasm/inccounter/go/inccounter/params.go @@ -7,7 +7,7 @@ package inccounter -import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" +import "github.com/iotaledger/wasp/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes" type ImmutableIncrementWithDelayParams struct { proxy wasmtypes.Proxy diff --git a/contracts/wasm/inccounter/go/inccounter/results.go b/contracts/wasm/inccounter/go/inccounter/results.go index 957a267f3d..bc6b2da0d9 100644 --- a/contracts/wasm/inccounter/go/inccounter/results.go +++ b/contracts/wasm/inccounter/go/inccounter/results.go @@ -7,7 +7,7 @@ package inccounter -import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" +import "github.com/iotaledger/wasp/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes" type ImmutableGetCounterResults struct { proxy wasmtypes.Proxy diff --git a/contracts/wasm/inccounter/go/inccounter/state.go b/contracts/wasm/inccounter/go/inccounter/state.go index 5bb3c642ab..20cecd965f 100644 --- a/contracts/wasm/inccounter/go/inccounter/state.go +++ b/contracts/wasm/inccounter/go/inccounter/state.go @@ -7,7 +7,7 @@ package inccounter -import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" +import "github.com/iotaledger/wasp/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes" type ImmutableIncCounterState struct { proxy wasmtypes.Proxy diff --git a/contracts/wasm/inccounter/go/main.go b/contracts/wasm/inccounter/go/main.go index 47c9e2a29f..c4ad27d964 100644 --- a/contracts/wasm/inccounter/go/main.go +++ b/contracts/wasm/inccounter/go/main.go @@ -9,7 +9,7 @@ package main -import "github.com/iotaledger/wasp/packages/vm/wasmvmhost" +import "github.com/iotaledger/wasp/packages/wasmvm/wasmvmhost" import "github.com/iotaledger/wasp/contracts/wasm/inccounter/go/inccounter" diff --git a/contracts/wasm/inccounter/test/inccounter_bg.wasm b/contracts/wasm/inccounter/test/inccounter_bg.wasm index e9884aa9c0a08667b433fcb83befa5867674d40f..87a53859a0cade230719a6b6dcbea18048de448e 100644 GIT binary patch delta 4501 zcma)94^WiH75{ecyW`*v_zn@}k74fwL6O541*;*riWmeGjep{3Flx1Wh>8%RM&lVU zV&WL}VE`qBB&4;e73ev}R;D#A`D02NGId&-G6|;Gp{;G5)@jKEP2c;z?+6n!lfr!a z_U*oX`}V!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^X4B(UBjp7{#bmCPT@YN9%sTujMSTqGnPbbY@PBB56wHOC7K@)r z{@wr6Ee9Fv2FEsF&-&Z8C2~I62=6?8K6D&8483^9rSW)`ns(H%Q?P%>W^K+`6PioXS328_<2G=W-Hk|ER+fNmaoGk|2XB?l#rDgx zLv+yHQySrhaW)fu7!2H5oO`g#Gm5~)OR)QtaS37y*z~$*NUpvd{Uo1UhftNu zeG0y^r2}s#wMf>%JYQPaxFCb6*|N@m(DxT^@4#}5&v1;x02Cgc%|~0|=;3ep7p+iV zmw+ehtP@z$->v%@I{~|&dXjzOzx7ly!+m*K674c6 ziXH1YlRog(m)T!kWTq<7quAf_->!Gqz}9fLYq_E*pD;y9#@|qgbNidHqG1iRHAF`o zv#AP6=d}Y}~xBdRvvZvPy{xQI%|X2;Ro0Z%pGcc%^Zn zrQVKfz)<7UQ2tz0#BztKWZ{Yj@SBRCM#Gusz!mLOl^EoFhI@&{J{r=WKN8VqaHF`Q zSdjau*Q*Rd|MMxq11O=tDG<}NGI(jIig8kujj*d}nagKT^O57m&j(kU()hna{g&oP z#yG^ZEStSRRh4j*Wn=HbzOtzN@oi#T`BqU}zIEGPu^0KYLN?U5Bn3Ak6^T?QTyB|# z7t~Noii^3htRv5XJ;?@O?y01xrAUP$wE}xH_N%ZbI|H!m)Dm}Kjt{vrk^6J(ZP<5W zZ`HJVPt9}nBb9(u2!7;~e!t^%t;JnBMO6}!T!|m`0eU@-X#=JHj<&s~5XuQVLzr}f IxBc*c0Zo&Fw*UYD diff --git a/contracts/wasm/inccounter/test/inccounter_test.go b/contracts/wasm/inccounter/test/inccounter_test.go index e8f11c7249..12b57909f9 100644 --- a/contracts/wasm/inccounter/test/inccounter_test.go +++ b/contracts/wasm/inccounter/test/inccounter_test.go @@ -9,7 +9,7 @@ import ( "time" "github.com/iotaledger/wasp/contracts/wasm/inccounter/go/inccounter" - "github.com/iotaledger/wasp/packages/vm/wasmhost" + "github.com/iotaledger/wasp/packages/wasmvm/wasmhost" "github.com/iotaledger/wasp/packages/wasmvm/wasmsolo" "github.com/stretchr/testify/require" ) diff --git a/contracts/wasm/testcore/Cargo.toml b/contracts/wasm/testcore/Cargo.toml index 4f0ce90105..616bd7fdc8 100644 --- a/contracts/wasm/testcore/Cargo.toml +++ b/contracts/wasm/testcore/Cargo.toml @@ -17,7 +17,7 @@ crate-type = ["cdylib", "rlib"] default = ["console_error_panic_hook"] [dependencies] -wasmlib = { path = "../../../wasmvm/wasmlib" } +wasmlib = { path = "../../../packages/wasmvm/wasmlib" } #wasmlib = { git = "https://github.com/iotaledger/wasp", branch = "develop" } # The `console_error_panic_hook` crate provides better debugging of panics by diff --git a/contracts/wasm/testcore/go/main.go b/contracts/wasm/testcore/go/main.go index 9d0d44a9eb..913ea199bc 100644 --- a/contracts/wasm/testcore/go/main.go +++ b/contracts/wasm/testcore/go/main.go @@ -9,7 +9,7 @@ package main -import "github.com/iotaledger/wasp/packages/vm/wasmvmhost" +import "github.com/iotaledger/wasp/packages/wasmvm/wasmvmhost" import "github.com/iotaledger/wasp/contracts/wasm/testcore/go/testcore" diff --git a/contracts/wasm/testcore/go/testcore/consts.go b/contracts/wasm/testcore/go/testcore/consts.go index f237534658..47241b51a8 100644 --- a/contracts/wasm/testcore/go/testcore/consts.go +++ b/contracts/wasm/testcore/go/testcore/consts.go @@ -7,7 +7,7 @@ package testcore -import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" +import "github.com/iotaledger/wasp/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes" const ( ScName = "testcore" diff --git a/contracts/wasm/testcore/go/testcore/contract.go b/contracts/wasm/testcore/go/testcore/contract.go index 6b701d0e06..1ead64ad99 100644 --- a/contracts/wasm/testcore/go/testcore/contract.go +++ b/contracts/wasm/testcore/go/testcore/contract.go @@ -7,7 +7,7 @@ package testcore -import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib" +import "github.com/iotaledger/wasp/packages/wasmvm/wasmlib/go/wasmlib" type CallOnChainCall struct { Func *wasmlib.ScFunc diff --git a/contracts/wasm/testcore/go/testcore/lib.go b/contracts/wasm/testcore/go/testcore/lib.go index 4f481bc25c..9eb57c27f7 100644 --- a/contracts/wasm/testcore/go/testcore/lib.go +++ b/contracts/wasm/testcore/go/testcore/lib.go @@ -8,7 +8,7 @@ //nolint:dupl package testcore -import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib" +import "github.com/iotaledger/wasp/packages/wasmvm/wasmlib/go/wasmlib" func OnLoad() { exports := wasmlib.NewScExports() diff --git a/contracts/wasm/testcore/go/testcore/params.go b/contracts/wasm/testcore/go/testcore/params.go index 2d62400191..0e6ed33026 100644 --- a/contracts/wasm/testcore/go/testcore/params.go +++ b/contracts/wasm/testcore/go/testcore/params.go @@ -7,7 +7,7 @@ package testcore -import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" +import "github.com/iotaledger/wasp/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes" type ImmutableCallOnChainParams struct { proxy wasmtypes.Proxy diff --git a/contracts/wasm/testcore/go/testcore/results.go b/contracts/wasm/testcore/go/testcore/results.go index 0c16fb42a9..cff391e8e7 100644 --- a/contracts/wasm/testcore/go/testcore/results.go +++ b/contracts/wasm/testcore/go/testcore/results.go @@ -7,7 +7,7 @@ package testcore -import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" +import "github.com/iotaledger/wasp/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes" type ImmutableCallOnChainResults struct { proxy wasmtypes.Proxy diff --git a/contracts/wasm/testcore/go/testcore/state.go b/contracts/wasm/testcore/go/testcore/state.go index f9836737c7..5927de5346 100644 --- a/contracts/wasm/testcore/go/testcore/state.go +++ b/contracts/wasm/testcore/go/testcore/state.go @@ -7,7 +7,7 @@ package testcore -import "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" +import "github.com/iotaledger/wasp/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes" type ImmutableTestCoreState struct { proxy wasmtypes.Proxy diff --git a/contracts/wasm/testcore/go/testcore/testcore.go b/contracts/wasm/testcore/go/testcore/testcore.go index 9471f0a815..d38f648ca3 100644 --- a/contracts/wasm/testcore/go/testcore/testcore.go +++ b/contracts/wasm/testcore/go/testcore/testcore.go @@ -5,10 +5,10 @@ package testcore import ( - "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib" - "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/coreaccounts" - "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/coregovernance" - "github.com/iotaledger/wasp/wasmvm/wasmlib/go/wasmlib/wasmtypes" + "github.com/iotaledger/wasp/packages/wasmvm/wasmlib/go/wasmlib" + "github.com/iotaledger/wasp/packages/wasmvm/wasmlib/go/wasmlib/coreaccounts" + "github.com/iotaledger/wasp/packages/wasmvm/wasmlib/go/wasmlib/coregovernance" + "github.com/iotaledger/wasp/packages/wasmvm/wasmlib/go/wasmlib/wasmtypes" ) const ( diff --git a/contracts/wasm/testcore/test/2chains_test.go b/contracts/wasm/testcore/test/2chains_test.go index ec16f3eeea..40ff5d02c6 100644 --- a/contracts/wasm/testcore/test/2chains_test.go +++ b/contracts/wasm/testcore/test/2chains_test.go @@ -6,7 +6,7 @@ import ( "github.com/iotaledger/wasp/contracts/wasm/testcore/go/testcore" "github.com/iotaledger/wasp/packages/solo" "github.com/iotaledger/wasp/packages/vm/core" - wasmsolo2 "github.com/iotaledger/wasp/packages/wasmvm/wasmsolo" + "github.com/iotaledger/wasp/packages/wasmvm/wasmsolo" "github.com/stretchr/testify/require" ) @@ -14,13 +14,13 @@ func Test2Chains(t *testing.T) { run2(t, func(t *testing.T, w bool) { core.PrintWellKnownHnames() - chain1 := wasmsolo2.StartChain(t, "chain1") + chain1 := wasmsolo.StartChain(t, "chain1") chain1.CheckAccountLedger() - chain2 := wasmsolo2.StartChain(t, "chain2", chain1.Env) + chain2 := wasmsolo.StartChain(t, "chain2", chain1.Env) chain2.CheckAccountLedger() - user := wasmsolo2.NewSoloAgent(chain1.Env) + user := wasmsolo.NewSoloAgent(chain1.Env) require.EqualValues(t, solo.Saldo, user.Balance()) ctx1 := deployTestCoreOnChain(t, w, chain1, nil) diff --git a/contracts/wasm/testcore/test/concurrency_test.go b/contracts/wasm/testcore/test/concurrency_test.go index 7a7d4212f1..03b4a33b1b 100644 --- a/contracts/wasm/testcore/test/concurrency_test.go +++ b/contracts/wasm/testcore/test/concurrency_test.go @@ -8,7 +8,7 @@ import ( "github.com/iotaledger/wasp/contracts/wasm/testcore/go/testcore" "github.com/iotaledger/wasp/packages/kv/codec" "github.com/iotaledger/wasp/packages/solo" - wasmsolo2 "github.com/iotaledger/wasp/packages/wasmvm/wasmsolo" + "github.com/iotaledger/wasp/packages/wasmvm/wasmsolo" "github.com/stretchr/testify/require" ) @@ -33,7 +33,7 @@ func TestCounter(t *testing.T) { func TestSynchronous(t *testing.T) { run2(t, func(t *testing.T, w bool) { // TODO fails with 999 instead of 1000 at WaitForPendingRequests - if *wasmsolo2.GoDebug || *wasmsolo2.GoWasmEdge { + if *wasmsolo.GoDebug || *wasmsolo.GoWasmEdge { t.SkipNow() } ctx := deployTestCore(t, w) @@ -42,7 +42,7 @@ func TestSynchronous(t *testing.T) { f.Func.TransferIotas(1) repeats := []int{300, 100, 100, 100, 200, 100, 100} - if wasmsolo2.SoloDebug { + if wasmsolo.SoloDebug { for i := range repeats { repeats[i] /= 10 } @@ -89,7 +89,7 @@ func TestConcurrency(t *testing.T) { WithIotas(1) repeats := []int{300, 100, 100, 100, 200, 100, 100} - if wasmsolo2.SoloDebug { + if wasmsolo.SoloDebug { for i := range repeats { repeats[i] /= 10 } @@ -135,7 +135,7 @@ func TestConcurrency2(t *testing.T) { WithIotas(1) repeats := []int{300, 100, 100, 100, 200, 100, 100} - if wasmsolo2.SoloDebug { + if wasmsolo.SoloDebug { for i := range repeats { repeats[i] /= 10 } @@ -147,7 +147,7 @@ func TestConcurrency2(t *testing.T) { } chain := ctx.Chain - users := make([]*wasmsolo2.SoloAgent, len(repeats)) + users := make([]*wasmsolo.SoloAgent, len(repeats)) for r, n := range repeats { go func(r, n int) { users[r] = ctx.NewSoloAgent() @@ -185,7 +185,7 @@ func TestViewConcurrency(t *testing.T) { f.Func.TransferIotas(1).Post() times := 2000 - if wasmsolo2.SoloDebug { + if wasmsolo.SoloDebug { times /= 10 } diff --git a/contracts/wasm/testcore/test/testcore_bg.wasm b/contracts/wasm/testcore/test/testcore_bg.wasm index 76c1881f70e60ea277e9cae13931323a61b8daa8..3409520077719e2851c41081681f8c41eb1107d1 100644 GIT binary patch delta 7531 zcmb7I33yaRw!U?H$RXy zI(2Rz+-&>nW?RD`o2a9~wlSiC*4Um&syo%BNpvVm^44~58T z``xa3i1@uuwM5pgaHNV_N^?Ajw!)!zY&dPq9_bF#oo*p5WvnZ#t*(=fhdNuLJ~7yB z*M+pr^Pwr0rt&bk*VN>7$Xa^9*%M3GI^)ufQJ*r@K0sG>rMDWTE4tcS4UZBo$enN& zKrSXM&eujx1m#3f4(3C6Xjr%0pbZN2DQp6o-!Or9O0{7bqL%iBb<1SabZ2i>kvyN* zS9F`UK=s<9oNPu^csG|J0|OyLgTr&R&`P>}n03|BRctU_J16w;A$(prYPe5vE3PQJE963WO1Brm zy_yWyP6%F~&6ApGpQ+HxmQIPtav6IvjMz(65#CW}%yFM06+K*6Mx_qMd@PnQ65c zrXjI!m^o{WFqN&;*Y%*Nq#9T9(CYU9RH9*xb<8lrOl@0c8#9dXNPSyoH#7Bth^P*t zWaazlm!n}Rrn1yxYM80C7^WeyI%cY^5vC!rZOqhKBTPeL^=(HK1e4FkhediK{91 z(yn&5IBWS}YAI41oo!r4ugdobAnOqlF0-={W83aock7z=5Azarg1=() zXc_L8$Dtl<99s}|pg8DdBc<%gv>@SwGVl&%YhlHDLAL%wXs{e-XJ5y!sR%hKy z*zs{Hh`S)Zr>^mH#O}bx_!B}c-$%uXHzMJ^o_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