As a wrapper developer, I want to invoke all types of wrappers in the same way with isolated contexts
Motivation
We want to securely provide the ability to subinvoke any implementation wrapper of an interface without requiring special schema capability syntax like use ... for ....
import { Interface, Interface_Module } from "./wrap";
const impls = Interface.getImplementations();
const module = new Interface_Module(impls[0]);
currently, we need to import the interface and specify getImplementations capability in schema to enable calling getImplementation from a wrapper. This way of doing things isn't ideal and doesn't really help a lot for security either.
There is no way to isolate the context for a plugin for specific wrappers. We are sharing the context of plugin globally with all the wrappers.
Proposed Solution:
Since we come to a conclusion during technical council that everything is an interface so we should be able to subinvoke implementations of any kind of interface whether it's a wasm wrapper interface, wrapper interface, or plugin wrapper interface in a similar manner.
I propose adding the base class for every module that we import with methods like getImplementations and other module-related host capabilities.
Codegen
// Codegen
class Interface {
private uri: string = "interface-uri.eth"; // All wrappers are interface so can be implementation also
private callerId: string; // allows sandboxing the plugin instances depending on the callerId (Note: this will create separate namespace for all the caller sharing same callerId in which the plugins/ wrappers get executed)
constructor(_uri?: string, _callerId?: string, _env?: Interface_Env) {
if (_uri) {
Interface.checkValidUri(_uri); // calls into the client to check whether wrapper is allowed to subinvoke this specific uri if custom uri is specified
this.uri = _uri;
}
this.callerId = _callerId ? _callerId : uuid();
if (_env) { // just something experimental that we can do if we want to
Interface.checkValidEnv(_env); // will even check whether it's allowed to update env at all? Although I suppose this should happen client size or atleast some part of it should maybe by providing wrap_method
this.env = _env;
}
}
method1(args: Args_method1): Method1{
...
}
}
Wrapper Devx
// Inside Wrapper
import { Interface } from "./wrap";
// calling arbitrary uri
const module = new Interface(uri); // can do stuffs like check whether uri in implementations and client can enable or disable invoking random impl uri
// calling default uri
const module = new Interface();
What do you think of making the default URI called be the first one in the list of interface implementations in the client config?
@krisbitney default uri is the interface uri. In most cases, you'd be invoking the interface (since we assume everything is an interface: wrapper and plugin invoke are just the interface invocation) directly. We can even have a custom function passed through client for implementation selection in case of a pure interface.