Skip to content

Commit 4ae6ae0

Browse files
committed
feat: add readme for polywrap-plugin
1 parent e0afde1 commit 4ae6ae0

1 file changed

Lines changed: 36 additions & 0 deletions

File tree

packages/polywrap-plugin/README.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# polywrap-wasm
2+
3+
Python implementation of the plugin wrapper runtime.
4+
5+
## Usage
6+
7+
### Invoke Plugin Wrapper
8+
9+
```python
10+
from typing import Any, Dict, List, Union, Optional
11+
from polywrap_manifest import AnyWrapManifest
12+
from polywrap_plugin import PluginModule
13+
from polywrap_core import Invoker, Uri, InvokerOptions, UriPackageOrWrapper, Env
14+
15+
class GreetingModule(PluginModule[None]):
16+
def __init__(self, config: None):
17+
super().__init__(config)
18+
19+
def greeting(self, args: Dict[str, Any], client: Invoker[UriPackageOrWrapper], env: Optional[Env] = None):
20+
return f"Greetings from: {args['name']}"
21+
22+
manifest = cast(AnyWrapManifest, {})
23+
wrapper = PluginWrapper(greeting_module, manifest)
24+
args = {
25+
"name": "Joe"
26+
}
27+
options: InvokeOptions[UriPackageOrWrapper] = InvokeOptions(
28+
uri=Uri.from_str("ens/greeting.eth"),
29+
method="greeting",
30+
args=args
31+
)
32+
invoker: Invoker = ...
33+
34+
result = await wrapper.invoke(options, invoker)
35+
assert result, "Greetings from: Joe"
36+
```

0 commit comments

Comments
 (0)