From 824c1a0b4c615d67e18f9f23aa99d00332a0ba92 Mon Sep 17 00:00:00 2001 From: Zeeshan Lakhani Date: Wed, 6 Mar 2024 10:23:04 -0500 Subject: [PATCH 01/51] chore: doc interpreter This PR contains a spec/document for the WIT<->IPLD interpreter, which converts WIT runtime values to IPLD data model values based on WIT types. Consider this a living document on the state of the interpreter. Includes: - added testing - function name handling of varying cases --- Cargo.lock | 1 + README.md | 5 +- homestar-wasm/Cargo.toml | 1 + homestar-wasm/README.md | 1045 ++++++++++++++++++++++++++- homestar-wasm/src/wasmtime/ipld.rs | 213 +++++- homestar-wasm/src/wasmtime/world.rs | 7 +- 6 files changed, 1236 insertions(+), 36 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c7594f00..901d0702 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2673,6 +2673,7 @@ dependencies = [ "libipld", "rust_decimal", "serde", + "serde_json", "stacker", "thiserror", "tokio", diff --git a/README.md b/README.md index cd3ed092..35292415 100644 --- a/README.md +++ b/README.md @@ -129,9 +129,12 @@ represents the `Homestar` runtime. We recommend diving into each package's own - [homestar-wasm](./homestar-wasm) This *wasm* library manages the [wasmtime][wasmtime] runtime, provides the - [Ipld][ipld] to/from [Wit][wit] interpreter/translation-layer, and implements + [IPLD][ipld] to/from [WIT][wit] interpreter/translation-layer, and implements the input interface for working with Ipvm's standard Wasm tasks. + You can find the spec for translating between IPLD and WIT runtime values + based on WIT types [here](./homestar-wasm/README.md##interpreting-between-ipld-and-wit). + - [homestar-workflow](./homestar-workflow) The *workflow* library implements workflow-centric [Ipvm features][ipvm-spec] diff --git a/homestar-wasm/Cargo.toml b/homestar-wasm/Cargo.toml index d6509a27..3539f06c 100644 --- a/homestar-wasm/Cargo.toml +++ b/homestar-wasm/Cargo.toml @@ -54,6 +54,7 @@ wit-component = "0.200" [dev-dependencies] criterion = "0.5" +serde_json = { workspace = true } tokio = { workspace = true } [features] diff --git a/homestar-wasm/README.md b/homestar-wasm/README.md index cdc7d9b6..c6cce511 100644 --- a/homestar-wasm/README.md +++ b/homestar-wasm/README.md @@ -3,7 +3,7 @@ Homestar logo -

Homestar

+

homestar-wasm

@@ -23,15 +23,1054 @@ ## +## Outline + +- [Description](#description) +- [Interpreting between IPLD and WIT](#interpreting-between-ipld-and-wit) + ## Description This *wasm* library manages the [wasmtime][wasmtime] runtime, provides the -[Ipld][ipld] to/from [Wit][wit] interpreter/translation-layer, and implements -the input interface for working with Ipvm's standard Wasm tasks. +[IPLD][ipld] to/from Wasm Interace Types ([WIT][wit]) +interpreter/translation-layer, and implements the input interface for working +with Ipvm's standard Wasm tasks. For more information, please go to our [Homestar Readme][homestar-readme]. +## Interpreting between IPLD and WIT + +Our recursive interpreter is able to bidirectionally translate between +the runtime [IPLD data model][ipld-data-model] and [WIT][wit] values, based on +known [WIT][wit] interface types. + +### Primitive Types + +We'll start by covering WIT [primitive types][wit-builtin]. + +#### Booleans + +This section outlines the translation process between IPLD boolean values +(`Ipld::Bool`) and [WIT `bool` runtime values][wit-val]. + +- **IPLD to WIT Translation**: + + When a WIT function expects a `bool` input, an `Ipld::Bool` value (either + `true` or `false`) is mapped to a `bool` WIT runtime + value. + + **Example**: Consider a WIT function defined as follows: + + ```wit + export fn: func(a: bool) -> bool; + ``` + + Given an JSON input for this function: + + ```json + { + "args": [true] + } + ``` + + `true` is converted into an `Ipld::Bool`, which is then translated and + passed into `fn` as a boolean argument (`bool`). + +- **WIT to IPLD Translation**: + + Conversely, when a boolean value is returned from a WIT function, it can be + translated back into an `Ipld::Bool`. + +**IPLD Schema Definition**: + +```ipldsch +type IPLDBooleanAsWit bool +``` + +#### Integers + +This section outlines the translation process between IPLD integer values +(`Ipld::Integer`) and [WIT `integer` rutime values][wit-val]). + +The [Component Model][wit] supports these [integer][wit-integer] types: + +```ebnf +ty ::= 'u8' | 'u16' | 'u32' | 'u64' + | 's8' | 's16' | 's32' | 's64' +``` + +- **IPLD to WIT Translation**: + + Typically, when a WIT function expects an integer input, an `Ipld::Integer` + value is mapped to a integer WIT runtime value. + + **Example**: Consider a WIT function defined as follows: + + ```wit + export fn: func(a: s32) -> s32; + ``` + + Given an JSON input for this function: + + ```json + { + "args": [1] + } + ``` + + `1` is converted into an `Ipld::Integer`, which is then translated and + passed into `fn` as an integer argument (`s32`). + + **Note**: However, If the input argument to the WIT interface is a `float` + type, but the incoming value is an `Ipld::Integer`, then the IPLD value will + be cast to a `float`, and remain as one for the rest of the computation. This + is to avoid weird JavaScript behavior around `1.0 === 1` for example. + +- **WIT to IPLD Translation**: + + Conversely, when an integer value (not a float) is returned from a WIT + function, it can be translated back into an `Ipld::Integer`. + +**IPLD Schema Definitions**: + +```ipldschme +type IPLDIntegerAsWit union { + | U8 int + | U16 int + | U32 int + | U64 int + | S8 int + | S16 int + | S32 int + | S64 int + | Float32In int + | Float64In int +} representation kinded + +type WitAsIpldInteger union { + | U8 int + | U16 int + | U32 int + | U64 int + | S8 int + | S16 int + | S32 int + | S64 int + | Float32Out float + | Float64Out float +} representation kinded +``` + +#### Floats + +This section outlines the translation process between IPLD float values +(`Ipld::Float`) and [WIT `float` runtime values][wit-val]. + +The [Component Model][wit] supports these Float types: + +```ebnf +ty ::= 'float32' | 'float64' +``` + +- **IPLD to WIT Translation**: + + When a WIT function expects a float input, an `Ipld::Float` value is + mapped to a float WIT runtime value. Casting is done to convert from `f32` to + `f64` if necessary. + + **Example**: Consider a WIT function defined as follows: + + ```wit + export fn: func(a: f64) -> f64; + ``` + + Given an JSON input for this function: + + ```json + { + "args": [1.0] + } + ``` + + `1.0` is converted into an `Ipld::Float`, which is then translated and + passed into `fn` as a float argument (`f64`). + +- **WIT to IPLD Translation**: + + Conversely, when a `float32` or `float64` value is returned from a WIT + function, it can be translated back into an `Ipld::Float`. + + **Note**: In converting from `float32` to `float64`, the latter of which is + the default precision for [IPLD][ipld-float], precision will be lost. + **The interpreter will use decimal precision in this conversion**. + +**IPLD Schema Definitions**: + +```ipldsch +type IPLDFloatAsWit union { + | Float32 float + | Float64 float +} representation kinded + +type WitAsIpldFloat union { + | Float32 float + | Float64 float +} representation kinded +``` + +#### Strings + +This section outlines the translation process between IPLD string values +(`Ipld::String`) and varying [WIT runtime values][wit-val]. A `Ipld::String` value can be +interpreted as one of a `string`, `char`, `list`, or an `enum` discriminant +(which has no payload). + +- `string` + + * **IPLD to WIT Translation** + + When a WIT function expects a `string` input, an `Ipld::String` value is + mapped to a `string` WIT runtime value. + + **Example**: + + ```wit + export fn: func(a: string) -> string; + ``` + + Given an JSON input for this function: + + ```json + { + "args": ["Saspirilla"] + } + ``` + + `"Saspirilla"` is converted into an `Ipld::String`, which is then translated + and passed into `fn` as a string argument (`string`). + + * **WIT to IPLD Translation**: + + Conversely, when a `string` value is returned from a WIT function, it is + translated back into an `Ipld::String`. + +- `char` + + * **IPLD to WIT Translation** + + When a WIT function expects a `char` input, an `Ipld::String` value is + mapped to a `char` WIT runtime value. + + **Example**: + + ```wit + export fn: func(a: char) -> char; + ``` + + Given an JSON input for this function: + + ```json + { + "args": ["S"] + } + ``` + + `"S"`is converted into an `Ipld::String`, which is then translated and + passed into `fn` as a char argument (`char`). + + * **WIT to IPLD Translation**: + + Conversely, when a char value is returned from a WIT function, it is + translated back into an `Ipld::String`. + +- `list` + + * **IPLD to WIT Translation** + + When a WIT function expects a `list` input, an `Ipld::String` value is + mapped to a `list` WIT runtime value. + + **Example**: + + ```wit + export fn: func(a: list) -> list; + ``` + + Given an JSON input for this function: + + ```json + { + "args": ["aGVsbDA"] + } + ``` + + `"aGVsbDA"` is converted into an `Ipld::String`, which is then translated + into bytes and passed into `fn` as a `list` argument. + + * **WIT to IPLD Translation**: + + **Here, when a `list` value is returned from a WIT function, it is + translated into an `Ipld::Bytes` value, which is the proper type**. + +- [`enum`][wit-enum]: + + An enum statement defines a new type which is semantically equivalent to a + variant where none of the cases have a payload type. + + * **IPLD to WIT Translation** + + When a WIT function expects an `enum` input, an `Ipld::String` value is + mapped to a `enum` WIT runtime value. + + **Example**: + + ```wit + enum color { + Red, + Green, + Blue + } + + export fn: func(a: color) -> string; + ``` + + Given an JSON input for this function: + + ```json + { + "args": ["Green"] + } + ``` + + `"Green"` is converted into an `Ipld::String`, which is then translated and + passed into `fn` as a enum argument (`color`). **You'll have to provide a + singular string that matches on one of the discriminants**. + + * **WIT to IPLD Translation**: + + Conversely, when an enum value is returned from a WIT function, it can be + translated back into an `Ipld::String` value. + +**IPLD Schema Definitions**: + +``` ipldsch +type Enum enum { + | Red + | Green + | Blue +} + +type IPLDStringAsWit union { + | Enum Enum + | String string + | Char string + | Listu8In string +} representation kinded + +type WitAsIpldString union { + | Enum Enum + | String string + | Char string + | Listu8Out bytes +} representation kinded +``` + +#### Bytes + +This section outlines the translation process between IPLD bytes values +(`Ipld::Bytes`) and varying [WIT runtime values][wit-val]. A `Ipld::Bytes` value +can be interpreted either as a `list` or `string`. + +- [`list`][wit-list]: + + * **IPLD to WIT Translation** + + When a WIT function expects a `list` input, an `Ipld::Bytes` value is + mapped to a `list` WIT runtime value. + + **Example**: + + ```wit + export fn: func(a: list) -> list; + ``` + + Given an JSON input for this function: + + ```json + { + "args": [{"/": {"bytes": "aGVsbDA"}}] + } + ``` + + `"aGVsbDA"` is converted into an `Ipld::Bytes`, which is then translated + into bytes and passed into `fn` as a `list` argument. + + * **WIT to IPLD Translation**: + + Conversely, when a `list` value is returned from a WIT function, it is + translated back into an `Ipld::Bytes` value if the list contains valid + `u8` values. + +- `string` + + * **IPLD to WIT Translation** + + When a WIT function expects a `string` input, an `Ipld::Bytes` value is + mapped to a `string` WIT runtime value. + + **Example**: + + ```wit + export fn: func(a: string) -> string; + ``` + + Given an JSON input for this function: + + ```json + { + "args": [{"/": {"bytes": "aGVsbDA"}}] + } + ``` + + `"aGVsbDA"` is converted into an `Ipld::Bytes`, which is then translated + into a `string` and passed into `fn` as a `string` argument. + + * **WIT to IPLD Translation**: + + **Here, when a string value is returned from a WIT function, it is + translated into an `Ipld::String` value, as we can't determine if + it's related to `bytes` once again**. + +**IPLD Schema Definitions**: + +``` ipldsch +type IPLDBytesAsWit union { + | ListU8 bytes + | StringIn bytes +} representation kinded + +type WitAsIpldBytes union { + | ListU8 bytes + | StringOut string +} representation kinded +``` + + +#### Nulls + +This section outlines the translation process between IPLD null values +(`Ipld::Null`) and varying [WIT runtime values][wit-val]. A `Ipld::Null` value +can be interpreted either as a `string` or `option`. + +**We'll cover only the `string` case here** and return to the `option` case +below. + +* **IPLD to WIT Translation** + + When a WIT function expects a `string` input, an `Ipld::Null` value is + mapped as a `"null"` `string` WIT runtime value. + + **Example**: + + ```wit + export fn: func(a: string) -> string; + ``` + + Given an JSON input for this function: + + ```json + { + "args": [null] + } + ``` + + `null` is converted into an `Ipld::Null`, which is then translated and + passed into `fn` as a `string` argument with the value of `"null"`. + +* **WIT to IPLD Translation**: + + Conversely, when a `string` value of `"null"` is returned from a WIT function, + it can be translated into an `Ipld::Null` value. + +**IPLD Schema Definitions**: + +``` ipldsch +type None unit representation null + +type IPLDNullAsWit union { + | None + | String string +} representation kinded + +type WitAsIpldNull union { + | None + | String string +} representation kinded +``` + +#### Links + +This section outlines the translation process between IPLD link values +(`Ipld::Link`) and [WIT `string` runtime values]. A `Ipld::Link` is always +interpreted as a `string` in WIT, and vice versa. + +* **IPLD to WIT Translation** + + When a WIT function expects a `string` input, an `Ipld::Link` value is + mapped to a `string` WIT runtime value, translated accordingly based + on the link being [Cidv0][cidv0] or [Cidv1][cidv1]. + + **Example**: + + ```wit + export fn: func(a: string) -> string; + ``` + + Given an JSON input for this function: + + ```json + { + "args": ["bafybeia32q3oy6u47x624rmsmgrrlpn7ulruissmz5z2ap6alv7goe7h3q"] + } + ``` + + `"bafybeia32q3oy6u47x624rmsmgrrlpn7ulruissmz5z2ap6alv7goe7h3q"` is converted + into an `Ipld::Link`, which is then translated and passed into `fn` as a + `string` argument. + +* **WIT to IPLD Translation**: + + Conversely, when a `string` value is returned from a WIT function, and if it + can be converted to a Cid, it can then be translated into an `Ipld::Link` + value. + +**IPLD Schema Definitions**: + +``` ipldsch +type IPLDLinkAsWit &String link + +type WitAsIpldLink &String link +``` + +### Non-primitive Types + +Next, we'll cover the more interesting, WIT non-primitive types. + +#### List Values + +This section outlines the translation process between IPLD list values +(`Ipld::List`) and varying [WIT runtime values][wit-val]. A `Ipld::List` +value can be interpreted as one of a `list`, `tuple`, set of `flags`, +or a `result`. + +**We'll return to the `result` case below, and cover the rest of the +possibilities here**. + +- [`list`][wit-list] + + * **IPLD to WIT Translation** + + When a WIT function expects a `list` input, an `Ipld::List` value is + mapped to a `list` WIT runtime value. + + **Example**: + + ```wit + export fn: func(a: list, b: s32) -> list; + ``` + + Given an JSON input for this function: + + ```json + { + "args": [[1, 2, 3], 44] + } + ``` + + `[1, 2, 3]` is converted into an `Ipld::List`, which is then translated + and passed into `fn` as a `list` argument. + + * **WIT to IPLD Translation**: + + Conversely, when a `list` value is returned from a WIT function, it is + translated back into an `Ipld::List` value. + +- [`tuple`][wit-tuple]: + + * **IPLD to WIT Translation** + + When a WIT function expects a `tuple` input, an `Ipld::List` value is + mapped to a `tuple` WIT runtime value. + + **Example**: + + ```wit + type ipv6-socket-address = tuple; + + export fn: func(a: ipv6-socket-address) -> tuple; + ``` + + Given an JSON input for this function: + + ```json + { + "args": [[8193, 3512, 34211, 0, 0, 35374, 880, 29492]] + } + ``` + + `[8193, 3512, 34211, 0, 0, 35374, 880, 29492]` is converted into an + `Ipld::List`, which is then translated and passed into `fn` as a + `tuple` argument. + + **If the length of list does not match not match the number of fields in the + tuple interface type, then an error will be thrown in the interpreter.** + + * **WIT to IPLD Translation**: + + Conversely, when a `tuple` value is returned from a WIT function, it is + translated back into an `Ipld::List` value. + +- [`flags`][wit-flags]: + + `flags` represent a bitset structure with a name for each bit. The type + represents a set of named booleans. In an instance of the type, each flag will + be either true or false. + + * **IPLD to WIT Translation** + + When a WIT function expects a `flags` input, an `Ipld::List` value is + mapped to a `flags` WIT runtime value. + + When used as an input, you can set the flags you want turned on/true as an + inclusive subset of strings. When used as an output, you will get a list of + strings representing the flags that are set to true. + + + **Example**: + + ```wit + flags permissions { + read, + write, + exec, + } + + export fn: func(perm: permissions) -> bool; + ``` + + Given an JSON input for this function: + + ```json + { + "args": [["read", "write"]] + } + ``` + + `[read, write]` is converted into an `Ipld::List`, which is then translated + and passed into `fn` as a `permissions` argument. + + * **WIT to IPLD Translation**: + + Conversely, when a `flags` value is returned from a WIT function, it is + translated back into an `Ipld::List` value. + + +**IPLD Schema Definitions**: + +``` ipldsch +type IPLDListAsWit union { + | List [any] + | Tuple [any] + | Flags [string] +} representation kinded + +type WitAsIpldList union { + | List [any] + | Tuple [any] + | Flags [string] +} representation kinded +``` + +#### Maps + +This section outlines the translation process between IPLD map values +(`Ipld::Map`) and varying [WIT runtime values][wit-val]. A `Ipld::Map` +value can be interpreted as one of a `record`, `variant`, or +a `list` of 2-element `tuples`. + +- [`record`][wit-record]: + + * **IPLD to WIT Translation** + + When a WIT function expects a `record` input, an `Ipld::Map` value is + mapped to a `record` WIT runtime value. + + **Example**: + + ```wit + record pair { + x: u32, + y: u32, + } + + export fn: func(a: pair) -> u32; + ``` + + Given an JSON input for this function: + + ```json + { + "args": [{"x": 1, "y": 2}] + } + ``` + + `{"x": 1, "y": 2}` is converted into an `Ipld::Map`, which is then + translated and passed into `fn` as a `pair` argument. + + **The keys in the map must match the field names in the record type**. + + * **WIT to IPLD Translation**: + + Conversely, when a `record` value is returned from a WIT function, it is + translated back into an `Ipld::Map` value. + +- [`variant`][wit-variant]: + + A variant statement defines a new type where instances of the type match + exactly one of the variants listed for the type. This is similar to a + "sum" type in algebraic datatypes (or an enum in Rust if you're familiar + with it). Variants can be thought of as tagged unions as well. + + Each case of a variant can have an optional type / payload associated with it + which is present when values have that particular case's tag. + + * **IPLD to WIT Translation** + + When a WIT function expects a `variant` input, an `Ipld::Map` value is + mapped to a `variant` WIT runtime value. + + **Example**: + + ```wit + + variant filter { + all, + none, + some(list), + } + + export fn: func(a: filter); + ``` + + Given an JSON input for this function: + + ```json + { + "args": [{"some" : ["a", "b", "c"]}] + } + ``` + + `{"some" : ["a", "b", "c"]}` is converted into an `Ipld::Map`, which is + then translated and passed into `fn` as a `filter` argument, where the key + is the variant name and the value is the payload. + + **The keys in the map must match the variant names in the variant type**. + + * **WIT to IPLD Translation**: + + Conversely, when a `variant` value is returned from a WIT function, it is + translated back into an `Ipld::Map` value where the tag is the key and + payload is the value. + +- [`list`][wit-list]: + + * **IPLD to WIT Translation** + + When a WIT function expects a nested `list` of 2-element `tuples` as input, + an `Ipld::Map` value is mapped to that specific WIT runtime value. + + **Example**: + + ```wit + export fn: func(a: list>) -> list; + ``` + + Given an JSON input for this function: + + ```json + { + "args": [{"a": 1, "b": 2}] + } + ``` + + `{"a": 1, "b": 2}` is converted into an `Ipld::Map`, which is then + translated and passed into `fn` as a `list>` argument. + + * **WIT to IPLD Translation**: + + Conversely, when a `list` of 2-element `tuples` is returned from a WIT + function, it can be translated back into an `Ipld::Map` value. + +**IPLD Schema Definitions**: + +``` ipldsch +type TupleAsMap {string:any} representation listpairs + +type IPLDMapAsWit union { + | Record {string:any} + | Variant {string:any} + | List TupleAsMap +} representation kinded + +type WitAsIpldMap union { + | Record {string:any} + | Variant {string:any} + | List TupleAsMap +} representation kinded +``` + +#### WIT Options + +This section outlines the translation process between [WIT option runtime values][wit-val] +(of type `option`) and varying IPLD values. An [`option`][wit-option] can be interpreted +as either a `Ipld::Null` or of any other IPLD value. + +* **IPLD to WIT Translation** + + When a WIT function expects an `option` as input, an `Ipld::Null` value is + mapped to the `None`/`Unit` case for a WIT option. Otherwise, any other IPLD + value will be mapped to its matching WIT runtime value directly. + + **Example**: + + ```wit + export fn: func(a: option) -> option; + ``` + + * `Some` case: + + - **Json Input**: + + ```json + { + "args": [1] + } + ``` + + * `None` case: + + - **Json Input**: + + ```json + { + "args": [null] + } + ``` + + `1` is converted into an `Ipld::Integer`, which is then translated and + passed into `fn` as an integer argument (`s32`), as the `Some` case of the + option. + + `null` is converted into an `Ipld::Null`, which is then translated and + passed into `fn` as a `None`/`Unit` case of the option (i.e. no value in WIT). + + Essentially, you can view this as `Ipld::Any` being the `Some` case and + `Ipld::Null` being the `None` case. + +* **WIT to IPLD Translation**: + + Conversely, when an `option` value is returned from a WIT function, it can be + translated back into an `Ipld::Null` value if it's the `None`/`Unit` case, or + any other IPLD value if it's the `Some` case. + +**IPLD Schema Definitions**: + +``` ipldsch +type IpldAsWitOption union { + | Some any + | None +} representation kinded + +type WitAsIpldOption union { + | Some any + | None +} representation kinded +``` + +#### WIT Results + +This section outlines the translation process between [WIT result runtime values][wit-val] +(of type `result`) and varying IPLD values. We treat result as Left/Right +[either][either] types over an `Ipld::List` of 2 elements. + +A [`result`][wit-result] can be interpreted as one of these patterns: + +- `Ok` (with a payload) + + * **IPLD to WIT Translation** + + When a WIT function expects a `result` as input, an `Ipld::List` value can + be mapped to the `Ok` case of the `result` WIT runtime value, including + a payload. + + **Example**: + + ```wit + export fn: func(a: result) -> result; + ``` + + Given an JSON input for this function: + + ```json + { + "args": [[47, null]] + } + ``` + + `[47, null]` is converted into an `Ipld::List`, which is then translated + and passed into `fn` as an `Ok` case of the `result` argument with a + payload of `47` matching the `s32` type on the left. + + * **WIT to IPLD Translation**: + + Conversely, when a `result` value is returned from a WIT function, it can + be translated back into an `Ipld::List` of this specific structure. + +- `Err` (with a payload) + + * **IPLD to WIT Translation** + + **Example**: + + ```wit + export fn: func(a: result) -> result; + ``` + + Given an JSON input for this function: + + ```json + { + "args": [[null, "error message"]] + } + ``` + + `[null, "error message"]` is converted into an `Ipld::List`, which is + then translated and passed into `fn` as an `Err` case of the `result` + argument with a payload of `"error message"` matching the `string` type + on the right. + + * **WIT to IPLD Translation**: + + Conversely, when a `result` value is returned from a WIT function, it can + be translated back into an `Ipld::List` of this specific structure. + +- `Ok` case (without a payload) + + * **IPLD to WIT Translation** + + **Example**: + + ```wit + export fn: func(a: result<_, string>) -> result<_, string>; + ``` + + Given an JSON input for this function: + + ```json + { + "args": [[47, null]] + } + ``` + + `[47, null]` is converted into an `Ipld::List`, which is then translated + and passed into `fn` as an `Ok` case of the `result` argument. The payload + is ignored as it's not needed (expressed in the type as `_` above), so + `47` is not used. + + * **WIT to IPLD Translation**: + + **Here, when this specific `Ok` case is returned from a WIT function, it can + be translated back into an `Ipld::List`, but one structured as + `[1, null]` internally, which signifies the `Ok` (not error) case, but + discards the payload. + +- `Err` case (without a payload) + + * **IPLD to WIT Translation** + + **Example**: + + ```wit + export fn: func(a: result) -> result; + ``` + + Given an JSON input for this function: + + ```json + { + "args": [[null, "error message"]] + } + ``` + + `[null, "error message"]` is converted into an `Ipld::List`, which is + then translated and passed into `fn` as an `Err` case of the `result` + argument. The payload is ignored as it's not needed (expressed in the type + as `_` above), so `"error message"` is not used. + + * **WIT to IPLD Translation**: + + **Here, when this specific `Err` case is returned from a WIT function, it + can be translated back into an `Ipld::List`, but one structured as + `[null, "error message"]` internally, which signifies the `Err` (error) + case, but discards the payload. + +**IPLD Schema Definitions**: + +``` ipldsch +type Null unit representation null + +type IpldAsWitResult union { + | Ok [any, Null] + | Err [Null, any] +} representation kinded + +type WitAsIpldResult union { + | Ok [any, Null] + | OkNone [1, Null] + | Err [Null, any] + | ErrNone [Null, 1] +} representation kinded +``` + +**Note**: `any` is used here to represent any type that's not `Null`. So, +given an input with a `result` type, the JSON value of + +```json +{ + "args": [null, null] +} +``` + +would fail to be translated into a Wit `result`runtime value, as it's ambiguous +to which case it should be mapped to. + +[cidv0]: https://github.com/multiformats/cid?tab=readme-ov-file#cidv0 +[cidv1]: https://github.com/multiformats/cid?tab=readme-ov-file#cidv1 +[either]: https://www.scala-lang.org/api/2.13.6/scala/util/Either.html [homestar-readme]: https://github.com/ipvm-wg/homestar/blob/main/README.md [ipld]: https://ipld.io/ +[ipld-data-model]: https://ipld.io/docs/data-model/ +[ipld-float]: https://ipld.io/design/tricky-choices/numeric-domain/#floating-point +[ipld-type]: https://docs.rs/libipld/latest/libipld/ipld/enum.Ipld.html [wasmtime]: https://github.com/bytecodealliance/wasmtime [wit]: https://github.com/WebAssembly/component-model/blob/main/design/mvp/WIT.md +[wit-builtin]: https://component-model.bytecodealliance.org/design/wit.html#built-in-types +[wit-enum]: https://component-model.bytecodealliance.org/design/wit.html#enums +[wit-flags]: https://component-model.bytecodealliance.org/design/wit.html#flags +[wit-integer]: https://component-model.bytecodealliance.org/design/wit.html#built-in-types +[wit-list]: https://component-model.bytecodealliance.org/design/wit.html#lists +[wit-option]: https://component-model.bytecodealliance.org/design/wit.html#options +[wit-record]: https://component-model.bytecodealliance.org/design/wit.html#records +[wit-result]: https://component-model.bytecodealliance.org/design/wit.html#results +[wit-tuple]: https://component-model.bytecodealliance.org/design/wit.html#tuples +[wit-val]: https://docs.wasmtime.dev/api/wasmtime/component/enum.Val.html +[wit-varaint]: https://component-model.bytecodealliance.org/design/wit.html#variants diff --git a/homestar-wasm/src/wasmtime/ipld.rs b/homestar-wasm/src/wasmtime/ipld.rs index d3ccafd6..7d5e636e 100644 --- a/homestar-wasm/src/wasmtime/ipld.rs +++ b/homestar-wasm/src/wasmtime/ipld.rs @@ -71,6 +71,7 @@ impl<'a> From<&'a Type> for InterfaceType<'a> { | Type::Result(_) | Type::Flags(_) | Type::Enum(_) + | Type::Char | Type::String | Type::S8 | Type::S16 @@ -244,6 +245,12 @@ impl RuntimeVal { )?; RuntimeVal::new(res_inst.new_val(Err(Some(inner_v.value())))?) } + ([_ipld, Ipld::Null], _, _) => { + RuntimeVal::new(res_inst.new_val(Ok(None))?) + } + ([Ipld::Null, _ipld], _, _) => { + RuntimeVal::new(res_inst.new_val(Err(None))?) + } _ => Err(InterpreterError::IpldToWit( "IPLD (as WIT result) has specific structure does does not match" .to_string(), @@ -307,6 +314,32 @@ impl RuntimeVal { .ok_or(InterpreterError::IpldToWit( "IPLD string not an enum discriminant".to_string(), ))?, + Some(Type::Char) => { + let mut chars = v.chars(); + let c = match chars.next() { + // Attempt to get the first character + Some(c) => { + // Check if there's no second character + if chars.next().is_none() { + Ok(c) + } else { + Err(InterpreterError::IpldToWit( + "IPLD string not a valid char".to_string(), + )) + } + } + None => Err(InterpreterError::IpldToWit( + "IPLD string is empty".to_string(), + )), + }?; + RuntimeVal::new(Val::Char(c)) + } + Some(Type::List(list_inst)) => { + let bytes = v.as_bytes(); + let val_bytes = bytes.iter().map(|elem| Val::U8(*elem)).collect(); + + RuntimeVal::new(list_inst.new_val(val_bytes)?) + } _ => RuntimeVal::new(Val::String(Box::from(v))), }, Ipld::Bytes(v) => match interface_ty.inner() { @@ -355,13 +388,15 @@ impl RuntimeVal { } Some(Type::Flags(flags_inst)) => { let flags = v.iter().try_fold(vec![], |mut acc, elem| { - if let Ipld::String(flag) = elem { - acc.push(flag.as_ref()); - Ok::<_, InterpreterError>(acc) - } else { - Err(InterpreterError::IpldToWit( - "IPLD (as flags) must contain only strings".to_string(), - )) + let mut names = flags_inst.names(); + match elem { + Ipld::String(flag) if names.any(|name| name == flag) => { + acc.push(flag.as_ref()); + Ok::<_, InterpreterError>(acc) + } + _ => Err(InterpreterError::IpldToWit( + "IPLD (as flags) must contain only strings as part of the interface type".to_string(), + )), } })?; @@ -615,10 +650,10 @@ impl TryFrom for Ipld { Ipld::List(inner) } RuntimeVal(Val::Flags(v), _) => { - let inner = v.flags().try_fold(vec![], |mut acc, flag| { + let inner = v.flags().fold(vec![], |mut acc, flag| { acc.push(Ipld::String(flag.to_string())); - Ok::<_, Self::Error>(acc) - })?; + acc + }); Ipld::List(inner) } RuntimeVal(Val::Enum(v), _) => Ipld::String(v.discriminant().to_string()), @@ -635,7 +670,12 @@ impl TryFrom for Ipld { mod test { use super::*; use crate::test_utils; - use libipld::multihash::{Code, MultihashDigest}; + use libipld::{ + json::DagJsonCodec, + multihash::{Code, MultihashDigest}, + prelude::Codec, + }; + use serde_json::json; const RAW: u64 = 0x55; @@ -821,7 +861,7 @@ mod test { } #[test] - fn try_float_type_roundtrip() { + fn try_float32_type_roundtrip() { let ipld = Ipld::Float(3883.20); let runtime_float = RuntimeVal::new(Val::Float32(3883.20)); @@ -841,6 +881,27 @@ mod test { assert_eq!(Ipld::try_from(runtime_float).unwrap(), ipld); } + #[test] + fn try_float64_type_roundtrip() { + let ipld = Ipld::Float(3883.20); + let runtime_float = RuntimeVal::new(Val::Float64(3883.20)); + + let ty = test_utils::component::setup_component_with_param( + "float64".to_string(), + &[test_utils::component::Param( + test_utils::component::Type::F64, + Some(0), + )], + ); + + assert_eq!( + RuntimeVal::try_from(ipld.clone(), &InterfaceType::Type(ty)).unwrap(), + runtime_float + ); + + assert_eq!(Ipld::try_from(runtime_float).unwrap(), ipld); + } + #[test] fn try_integer_to_float() { let ipld_in = Ipld::Integer(5); @@ -865,22 +926,28 @@ mod test { #[test] fn try_string_roundtrip() { - let ipld = Ipld::String("Hello!".into()); - let runtime = RuntimeVal::new(Val::String(Box::from("Hello!"))); + let ipld1 = Ipld::String("Hello!".into()); + let ipld2 = Ipld::String("!".into()); + let runtime1 = RuntimeVal::new(Val::String(Box::from("Hello!"))); + let runtime2 = RuntimeVal::new(Val::Char('!')); assert_eq!( - RuntimeVal::try_from(ipld.clone(), &InterfaceType::Any).unwrap(), - runtime + RuntimeVal::try_from(ipld1.clone(), &InterfaceType::Any).unwrap(), + runtime1 ); + assert_eq!(Ipld::try_from(runtime1).unwrap(), ipld1); - assert_eq!(Ipld::try_from(runtime).unwrap(), ipld); + // assert char case + assert_eq!( + RuntimeVal::try_from(ipld2.clone(), &InterfaceType::TypeRef(&Type::Char)).unwrap(), + runtime2 + ); + assert_eq!(Ipld::try_from(runtime2).unwrap(), ipld2); } #[test] - fn try_bytes_roundtrip() { - let bytes = b"hell0".to_vec(); - let ipld = Ipld::Bytes(bytes.clone()); - + fn try_string_to_listu8_to_string_roundtrip() { + let ipld_bytes_as_string = Ipld::String(String::from_utf8_lossy(b"hell0").to_string()); let ty = test_utils::component::setup_component("(list u8)".to_string(), 8); let val_list = ty .unwrap_list() @@ -892,14 +959,68 @@ mod test { Val::U8(48), ])) .unwrap(); - let runtime = RuntimeVal::new(val_list); + let runtime = RuntimeVal::new(val_list); assert_eq!( - RuntimeVal::try_from(ipld.clone(), &InterfaceType::Type(ty)).unwrap(), + RuntimeVal::try_from(ipld_bytes_as_string.clone(), &InterfaceType::Type(ty)).unwrap(), runtime ); + assert_eq!( + Ipld::try_from(runtime).unwrap(), + Ipld::Bytes(b"hell0".to_vec()) + ); + } - assert_eq!(Ipld::try_from(runtime).unwrap(), ipld); + #[test] + fn try_bytes_roundtrip() { + let bytes1 = b"hell0".to_vec(); + let bytes2 = Base::Base64.encode(b"hell0"); + + let ipld1 = Ipld::Bytes(bytes1.clone()); + let ipld2 = Ipld::String("aGVsbDA".to_string()); + let json = json!({ + "/": {"bytes": format!("{}", bytes2)} + }); + + let ipld3: Ipld = DagJsonCodec.decode(json.to_string().as_bytes()).unwrap(); + let Ipld::Bytes(_bytes) = ipld3.clone() else { + panic!("IPLD is not bytes"); + }; + + let ty1 = test_utils::component::setup_component("(list u8)".to_string(), 8); + let val_list1 = ty1 + .unwrap_list() + .new_val(Box::new([ + Val::U8(104), + Val::U8(101), + Val::U8(108), + Val::U8(108), + Val::U8(48), + ])) + .unwrap(); + let runtime1 = RuntimeVal::new(val_list1); + + let ty2 = test_utils::component::setup_component("string".to_string(), 8); + let runtime2 = RuntimeVal::new(Val::String(Box::from("aGVsbDA"))); + + assert_eq!( + RuntimeVal::try_from(ipld1.clone(), &InterfaceType::Type(ty1)).unwrap(), + runtime1 + ); + assert_eq!(Ipld::try_from(runtime1).unwrap(), ipld1); + + assert_eq!( + RuntimeVal::try_from(ipld1.clone(), &InterfaceType::Type(ty2.clone())).unwrap(), + runtime2 + ); + assert_eq!(Ipld::try_from(runtime2).unwrap(), ipld2); + + let runtime3 = RuntimeVal::new(Val::String(Box::from("aGVsbDA"))); + assert_eq!( + RuntimeVal::try_from(ipld3.clone(), &InterfaceType::Type(ty2)).unwrap(), + runtime3 + ); + assert_eq!(Ipld::try_from(runtime3).unwrap(), ipld2); } #[test] @@ -1266,6 +1387,9 @@ mod test { let ty3 = test_utils::component::setup_component("(result)".to_string(), 4); let interface_ty3 = InterfaceType::Type(ty3.clone()); + let ty4 = test_utils::component::setup_component("(result (error string))".to_string(), 12); + let interface_ty4 = InterfaceType::Type(ty4.clone()); + let val1 = ty1 .unwrap_result() .new_val(Ok(Some(Val::String(Box::from("Hello!"))))) @@ -1287,6 +1411,12 @@ mod test { let val5 = ty1.unwrap_result().new_val(Err(None)).unwrap(); let runtime5 = RuntimeVal::new(val5); + let val6 = ty4.unwrap_result().new_val(Ok(None)).unwrap(); + let runtime6 = RuntimeVal::new(val6); + + let val7 = ty1.unwrap_result().new_val(Err(None)).unwrap(); + let runtime7 = RuntimeVal::new(val7); + assert_eq!( RuntimeVal::try_from(ok_ipld.clone(), &interface_ty1).unwrap(), runtime1 @@ -1316,6 +1446,20 @@ mod test { runtime5 ); assert_eq!(Ipld::try_from(runtime5).unwrap(), err_res_ipld); + + // result with `_` any ok payload: + assert_eq!( + RuntimeVal::try_from(ok_ipld.clone(), &interface_ty4).unwrap(), + runtime6 + ); + assert_eq!(Ipld::try_from(runtime6).unwrap(), ok_res_ipld); + + // result with `_` any err payload: + assert_eq!( + RuntimeVal::try_from(err_ipld.clone(), &interface_ty1).unwrap(), + runtime7 + ); + assert_eq!(Ipld::try_from(runtime7).unwrap(), err_res_ipld); } #[test] @@ -1378,11 +1522,12 @@ mod test { #[test] fn try_flags_roundtrip() { - let ipld = Ipld::List(vec![ + let ipld1 = Ipld::List(vec![ Ipld::String("foo-bar-baz".into()), Ipld::String("B".into()), Ipld::String("C".into()), ]); + let ipld2 = Ipld::List(vec![Ipld::String("foo-bar-baz".into())]); let ty = test_utils::component::setup_component( r#"(flags "foo-bar-baz" "B" "C")"#.to_string(), @@ -1390,18 +1535,24 @@ mod test { ); let interface_ty = InterfaceType::Type(ty.clone()); - let val = ty + let val1 = ty .unwrap_flags() .new_val(&["foo-bar-baz", "B", "C"]) .unwrap(); + let val2 = ty.unwrap_flags().new_val(&["foo-bar-baz"]).unwrap(); - let runtime = RuntimeVal::new(val); + let runtime1 = RuntimeVal::new(val1); + let runtime2 = RuntimeVal::new(val2); assert_eq!( - RuntimeVal::try_from(ipld.clone(), &interface_ty).unwrap(), - runtime + RuntimeVal::try_from(ipld1.clone(), &interface_ty).unwrap(), + runtime1 ); - - assert_eq!(Ipld::try_from(runtime).unwrap(), ipld); + assert_eq!(Ipld::try_from(runtime1).unwrap(), ipld1); + assert_eq!( + RuntimeVal::try_from(ipld2.clone(), &interface_ty).unwrap(), + runtime2 + ); + assert_eq!(Ipld::try_from(runtime2).unwrap(), ipld2); } } diff --git a/homestar-wasm/src/wasmtime/world.rs b/homestar-wasm/src/wasmtime/world.rs index c30c43a2..41474d66 100644 --- a/homestar-wasm/src/wasmtime/world.rs +++ b/homestar-wasm/src/wasmtime/world.rs @@ -13,7 +13,7 @@ use crate::{ Error, }, }; -use heck::{ToKebabCase, ToSnakeCase}; +use heck::{ToKebabCase, ToLowerCamelCase, ToPascalCase, ToSnakeCase}; use homestar_invocation::{ bail, error::ResolveError, @@ -384,6 +384,11 @@ impl World { .func(fun_name) .or_else(|| __exports.func(&fun_name.to_kebab_case())) .or_else(|| __exports.func(&fun_name.to_snake_case())) + .or_else(|| __exports.func(&fun_name.to_lower_camel_case())) + .or_else(|| __exports.func(&fun_name.to_pascal_case())) + // Support identifiers + // https://github.com/WebAssembly/component-model/blob/main/design/mvp/WIT.md#identifiers + .or_else(|| __exports.func(format!("%{}", fun_name).as_str())) .ok_or_else(|| Error::WasmFunctionNotFound(fun_name.to_string()))?; Ok(World(func)) From a9263bd4c1296758992edf20ba790443da1de5be Mon Sep 17 00:00:00 2001 From: Zeeshan Lakhani Date: Thu, 7 Mar 2024 18:42:59 -0500 Subject: [PATCH 02/51] Update homestar-wasm/README.md Co-authored-by: Brian Ginsburg <7957636+bgins@users.noreply.github.com> Signed-off-by: Zeeshan Lakhani --- homestar-wasm/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homestar-wasm/README.md b/homestar-wasm/README.md index c6cce511..e0287338 100644 --- a/homestar-wasm/README.md +++ b/homestar-wasm/README.md @@ -89,7 +89,7 @@ type IPLDBooleanAsWit bool #### Integers This section outlines the translation process between IPLD integer values -(`Ipld::Integer`) and [WIT `integer` rutime values][wit-val]). +(`Ipld::Integer`) and [WIT `integer` rutime values][wit-val]. The [Component Model][wit] supports these [integer][wit-integer] types: From c7c1e4302222b83f5023ef0292c8afcef520d048 Mon Sep 17 00:00:00 2001 From: Zeeshan Lakhani Date: Thu, 7 Mar 2024 18:43:05 -0500 Subject: [PATCH 03/51] Update homestar-wasm/README.md Co-authored-by: Brian Ginsburg <7957636+bgins@users.noreply.github.com> Signed-off-by: Zeeshan Lakhani --- homestar-wasm/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homestar-wasm/README.md b/homestar-wasm/README.md index e0287338..e28fdc99 100644 --- a/homestar-wasm/README.md +++ b/homestar-wasm/README.md @@ -101,7 +101,7 @@ ty ::= 'u8' | 'u16' | 'u32' | 'u64' - **IPLD to WIT Translation**: Typically, when a WIT function expects an integer input, an `Ipld::Integer` - value is mapped to a integer WIT runtime value. + value is mapped to an integer WIT runtime value. **Example**: Consider a WIT function defined as follows: From 6aafb6a32f3c58cb8e4d9897d95a9e3512d9d1e1 Mon Sep 17 00:00:00 2001 From: Zeeshan Lakhani Date: Thu, 7 Mar 2024 18:43:15 -0500 Subject: [PATCH 04/51] Update homestar-wasm/README.md Co-authored-by: Brian Ginsburg <7957636+bgins@users.noreply.github.com> Signed-off-by: Zeeshan Lakhani --- homestar-wasm/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homestar-wasm/README.md b/homestar-wasm/README.md index e28fdc99..f5b2143d 100644 --- a/homestar-wasm/README.md +++ b/homestar-wasm/README.md @@ -120,7 +120,7 @@ ty ::= 'u8' | 'u16' | 'u32' | 'u64' `1` is converted into an `Ipld::Integer`, which is then translated and passed into `fn` as an integer argument (`s32`). - **Note**: However, If the input argument to the WIT interface is a `float` + **Note**: However, if the input argument to the WIT interface is a `float` type, but the incoming value is an `Ipld::Integer`, then the IPLD value will be cast to a `float`, and remain as one for the rest of the computation. This is to avoid weird JavaScript behavior around `1.0 === 1` for example. From 0be0b2432d4b11056e83cfde122abc8d4460fd81 Mon Sep 17 00:00:00 2001 From: Zeeshan Lakhani Date: Thu, 7 Mar 2024 18:43:25 -0500 Subject: [PATCH 05/51] Update homestar-wasm/README.md Co-authored-by: Brian Ginsburg <7957636+bgins@users.noreply.github.com> Signed-off-by: Zeeshan Lakhani --- homestar-wasm/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/homestar-wasm/README.md b/homestar-wasm/README.md index f5b2143d..412447ab 100644 --- a/homestar-wasm/README.md +++ b/homestar-wasm/README.md @@ -122,8 +122,8 @@ ty ::= 'u8' | 'u16' | 'u32' | 'u64' **Note**: However, if the input argument to the WIT interface is a `float` type, but the incoming value is an `Ipld::Integer`, then the IPLD value will - be cast to a `float`, and remain as one for the rest of the computation. This - is to avoid weird JavaScript behavior around `1.0 === 1` for example. + be cast to a `float`, and remain as one for the rest of the computation. The cast is + to provide affordances for JavaScript where, for example, the number `1.0` is converted to `1`. - **WIT to IPLD Translation**: From c23a0d2304dada0ed04652ee773235f83a4c987b Mon Sep 17 00:00:00 2001 From: Zeeshan Lakhani Date: Thu, 7 Mar 2024 18:43:32 -0500 Subject: [PATCH 06/51] Update homestar-wasm/README.md Co-authored-by: Brian Ginsburg <7957636+bgins@users.noreply.github.com> Signed-off-by: Zeeshan Lakhani --- homestar-wasm/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homestar-wasm/README.md b/homestar-wasm/README.md index 412447ab..7ddb066e 100644 --- a/homestar-wasm/README.md +++ b/homestar-wasm/README.md @@ -220,7 +220,7 @@ type WitAsIpldFloat union { #### Strings This section outlines the translation process between IPLD string values -(`Ipld::String`) and varying [WIT runtime values][wit-val]. A `Ipld::String` value can be +(`Ipld::String`) and various [WIT runtime values][wit-val]. A `Ipld::String` value can be interpreted as one of a `string`, `char`, `list`, or an `enum` discriminant (which has no payload). From 7897dd30ad5bf17cba662b5ec54a91fff026335b Mon Sep 17 00:00:00 2001 From: Zeeshan Lakhani Date: Thu, 7 Mar 2024 18:43:43 -0500 Subject: [PATCH 07/51] Update homestar-wasm/README.md Co-authored-by: Brian Ginsburg <7957636+bgins@users.noreply.github.com> Signed-off-by: Zeeshan Lakhani --- homestar-wasm/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/homestar-wasm/README.md b/homestar-wasm/README.md index 7ddb066e..c3b1ff27 100644 --- a/homestar-wasm/README.md +++ b/homestar-wasm/README.md @@ -437,8 +437,8 @@ can be interpreted either as a `list` or `string`. * **WIT to IPLD Translation**: **Here, when a string value is returned from a WIT function, it is - translated into an `Ipld::String` value, as we can't determine if - it's related to `bytes` once again**. + translated into an `Ipld::String` value, because we can't determine if it + was originally `bytes`**. **IPLD Schema Definitions**: From f6c5eabb1bd105736b71b6641948f7c1ff2cd68d Mon Sep 17 00:00:00 2001 From: Zeeshan Lakhani Date: Thu, 7 Mar 2024 18:43:53 -0500 Subject: [PATCH 08/51] Update homestar-wasm/README.md Co-authored-by: Brian Ginsburg <7957636+bgins@users.noreply.github.com> Signed-off-by: Zeeshan Lakhani --- homestar-wasm/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homestar-wasm/README.md b/homestar-wasm/README.md index c3b1ff27..c6d586d6 100644 --- a/homestar-wasm/README.md +++ b/homestar-wasm/README.md @@ -1051,7 +1051,7 @@ given an input with a `result` type, the JSON value of ``` would fail to be translated into a Wit `result`runtime value, as it's ambiguous -to which case it should be mapped to. +which case it should be mapped to. [cidv0]: https://github.com/multiformats/cid?tab=readme-ov-file#cidv0 [cidv1]: https://github.com/multiformats/cid?tab=readme-ov-file#cidv1 From 04a57904eae2d7d4057d3d18a1ac25146e05aa6c Mon Sep 17 00:00:00 2001 From: Zeeshan Lakhani Date: Thu, 7 Mar 2024 18:44:01 -0500 Subject: [PATCH 09/51] Update homestar-wasm/README.md Co-authored-by: Brian Ginsburg <7957636+bgins@users.noreply.github.com> Signed-off-by: Zeeshan Lakhani --- homestar-wasm/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/homestar-wasm/README.md b/homestar-wasm/README.md index c6d586d6..bd7aa9fb 100644 --- a/homestar-wasm/README.md +++ b/homestar-wasm/README.md @@ -1020,8 +1020,8 @@ A [`result`][wit-result] can be interpreted as one of these patterns: **Here, when this specific `Err` case is returned from a WIT function, it can be translated back into an `Ipld::List`, but one structured as - `[null, "error message"]` internally, which signifies the `Err` (error) - case, but discards the payload. + `[null, 1]` internally, which signifies the `Err` (error) case, with + the `1` payload discarded.** **IPLD Schema Definitions**: From 9555898badab65e5d09e3c7ab9b4d054c8dde5c5 Mon Sep 17 00:00:00 2001 From: Zeeshan Lakhani Date: Thu, 7 Mar 2024 18:44:26 -0500 Subject: [PATCH 10/51] Update homestar-wasm/README.md Co-authored-by: Brian Ginsburg <7957636+bgins@users.noreply.github.com> Signed-off-by: Zeeshan Lakhani --- homestar-wasm/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homestar-wasm/README.md b/homestar-wasm/README.md index bd7aa9fb..9c46ce8c 100644 --- a/homestar-wasm/README.md +++ b/homestar-wasm/README.md @@ -510,7 +510,7 @@ type WitAsIpldNull union { #### Links This section outlines the translation process between IPLD link values -(`Ipld::Link`) and [WIT `string` runtime values]. A `Ipld::Link` is always +(`Ipld::Link`) and [WIT `string` runtime values][wit-val]. A `Ipld::Link` is always interpreted as a `string` in WIT, and vice versa. * **IPLD to WIT Translation** From cd245fd454e585ed043d3c425e13f0cdbd683637 Mon Sep 17 00:00:00 2001 From: Zeeshan Lakhani Date: Thu, 7 Mar 2024 18:44:46 -0500 Subject: [PATCH 11/51] Update homestar-wasm/README.md Co-authored-by: Brian Ginsburg <7957636+bgins@users.noreply.github.com> Signed-off-by: Zeeshan Lakhani --- homestar-wasm/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/homestar-wasm/README.md b/homestar-wasm/README.md index 9c46ce8c..e97c7253 100644 --- a/homestar-wasm/README.md +++ b/homestar-wasm/README.md @@ -990,8 +990,8 @@ A [`result`][wit-result] can be interpreted as one of these patterns: **Here, when this specific `Ok` case is returned from a WIT function, it can be translated back into an `Ipld::List`, but one structured as - `[1, null]` internally, which signifies the `Ok` (not error) case, but - discards the payload. + `[1, null]` internally, which signifies the `Ok` (not error) case, with + the `1` payload discarded.** - `Err` case (without a payload) From 95fb5454b02b4193fb7a09efc758604cc4de812c Mon Sep 17 00:00:00 2001 From: Zeeshan Lakhani Date: Thu, 7 Mar 2024 18:44:55 -0500 Subject: [PATCH 12/51] Update homestar-wasm/README.md Co-authored-by: Brian Ginsburg <7957636+bgins@users.noreply.github.com> Signed-off-by: Zeeshan Lakhani --- homestar-wasm/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homestar-wasm/README.md b/homestar-wasm/README.md index e97c7253..3b18aec4 100644 --- a/homestar-wasm/README.md +++ b/homestar-wasm/README.md @@ -1073,4 +1073,4 @@ which case it should be mapped to. [wit-result]: https://component-model.bytecodealliance.org/design/wit.html#results [wit-tuple]: https://component-model.bytecodealliance.org/design/wit.html#tuples [wit-val]: https://docs.wasmtime.dev/api/wasmtime/component/enum.Val.html -[wit-varaint]: https://component-model.bytecodealliance.org/design/wit.html#variants +[wit-variant]: https://component-model.bytecodealliance.org/design/wit.html#variants From 46a1d39d3095d1556218509cb982dae07222f6a5 Mon Sep 17 00:00:00 2001 From: Zeeshan Lakhani Date: Thu, 7 Mar 2024 18:49:17 -0500 Subject: [PATCH 13/51] chore: .. --- homestar-wasm/README.md | 70 ++++++++++++++++++++--------------------- 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/homestar-wasm/README.md b/homestar-wasm/README.md index 3b18aec4..e7f414a6 100644 --- a/homestar-wasm/README.md +++ b/homestar-wasm/README.md @@ -920,15 +920,15 @@ A [`result`][wit-result] can be interpreted as one of these patterns: Given an JSON input for this function: - ```json - { - "args": [[47, null]] - } - ``` + ```json + { + "args": [[47, null]] + } + ``` - `[47, null]` is converted into an `Ipld::List`, which is then translated - and passed into `fn` as an `Ok` case of the `result` argument with a - payload of `47` matching the `s32` type on the left. + `[47, null]` is converted into an `Ipld::List`, which is then translated + and passed into `fn` as an `Ok` case of the `result` argument with a + payload of `47` matching the `s32` type on the left. * **WIT to IPLD Translation**: @@ -947,16 +947,16 @@ A [`result`][wit-result] can be interpreted as one of these patterns: Given an JSON input for this function: - ```json - { - "args": [[null, "error message"]] - } - ``` + ```json + { + "args": [[null, "error message"]] + } + ``` - `[null, "error message"]` is converted into an `Ipld::List`, which is - then translated and passed into `fn` as an `Err` case of the `result` - argument with a payload of `"error message"` matching the `string` type - on the right. + `[null, "error message"]` is converted into an `Ipld::List`, which is + then translated and passed into `fn` as an `Err` case of the `result` + argument with a payload of `"error message"` matching the `string` type + on the right. * **WIT to IPLD Translation**: @@ -975,16 +975,16 @@ A [`result`][wit-result] can be interpreted as one of these patterns: Given an JSON input for this function: - ```json - { - "args": [[47, null]] - } - ``` + ```json + { + "args": [[47, null]] + } + ``` - `[47, null]` is converted into an `Ipld::List`, which is then translated - and passed into `fn` as an `Ok` case of the `result` argument. The payload - is ignored as it's not needed (expressed in the type as `_` above), so - `47` is not used. + `[47, null]` is converted into an `Ipld::List`, which is then translated + and passed into `fn` as an `Ok` case of the `result` argument. The payload + is ignored as it's not needed (expressed in the type as `_` above), so + `47` is not used. * **WIT to IPLD Translation**: @@ -1005,16 +1005,16 @@ A [`result`][wit-result] can be interpreted as one of these patterns: Given an JSON input for this function: - ```json - { - "args": [[null, "error message"]] - } - ``` + ```json + { + "args": [[null, "error message"]] + } + ``` - `[null, "error message"]` is converted into an `Ipld::List`, which is - then translated and passed into `fn` as an `Err` case of the `result` - argument. The payload is ignored as it's not needed (expressed in the type - as `_` above), so `"error message"` is not used. + `[null, "error message"]` is converted into an `Ipld::List`, which is + then translated and passed into `fn` as an `Err` case of the `result` + argument. The payload is ignored as it's not needed (expressed in the type + as `_` above), so `"error message"` is not used. * **WIT to IPLD Translation**: From ed1449f9081c15d51276e8e92c3c948bb560772d Mon Sep 17 00:00:00 2001 From: Zeeshan Lakhani Date: Thu, 7 Mar 2024 18:50:42 -0500 Subject: [PATCH 14/51] chore: .. --- homestar-wasm/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/homestar-wasm/README.md b/homestar-wasm/README.md index e7f414a6..e8c2faed 100644 --- a/homestar-wasm/README.md +++ b/homestar-wasm/README.md @@ -926,6 +926,7 @@ A [`result`][wit-result] can be interpreted as one of these patterns: } ``` + `[47, null]` is converted into an `Ipld::List`, which is then translated and passed into `fn` as an `Ok` case of the `result` argument with a payload of `47` matching the `s32` type on the left. From a7913b632a1ec866c21e53ba328cfa798f10669d Mon Sep 17 00:00:00 2001 From: Zeeshan Lakhani Date: Thu, 7 Mar 2024 18:51:42 -0500 Subject: [PATCH 15/51] chore: .. --- homestar-wasm/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homestar-wasm/README.md b/homestar-wasm/README.md index e8c2faed..ca3b8c7b 100644 --- a/homestar-wasm/README.md +++ b/homestar-wasm/README.md @@ -918,7 +918,7 @@ A [`result`][wit-result] can be interpreted as one of these patterns: export fn: func(a: result) -> result; ``` - Given an JSON input for this function: + Given an JSON input for this function: ```json { From df39c7f27d21350db9a2c6cd5a40eb98400fbdb9 Mon Sep 17 00:00:00 2001 From: Zeeshan Lakhani Date: Thu, 7 Mar 2024 22:24:46 -0500 Subject: [PATCH 16/51] Update homestar-wasm/README.md good catch Co-authored-by: Brian Ginsburg <7957636+bgins@users.noreply.github.com> Signed-off-by: Zeeshan Lakhani --- homestar-wasm/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homestar-wasm/README.md b/homestar-wasm/README.md index ca3b8c7b..ebfce13a 100644 --- a/homestar-wasm/README.md +++ b/homestar-wasm/README.md @@ -1064,7 +1064,7 @@ which case it should be mapped to. [ipld-type]: https://docs.rs/libipld/latest/libipld/ipld/enum.Ipld.html [wasmtime]: https://github.com/bytecodealliance/wasmtime [wit]: https://github.com/WebAssembly/component-model/blob/main/design/mvp/WIT.md -[wit-builtin]: https://component-model.bytecodealliance.org/design/wit.html#built-in-types +[wit-primitive]: https://component-model.bytecodealliance.org/design/wit.html#primitive-types [wit-enum]: https://component-model.bytecodealliance.org/design/wit.html#enums [wit-flags]: https://component-model.bytecodealliance.org/design/wit.html#flags [wit-integer]: https://component-model.bytecodealliance.org/design/wit.html#built-in-types From 2375e02757ccb23b7668cec7ffde6698bac0234f Mon Sep 17 00:00:00 2001 From: Zeeshan Lakhani Date: Thu, 7 Mar 2024 22:24:56 -0500 Subject: [PATCH 17/51] Update homestar-wasm/README.md Co-authored-by: Brian Ginsburg <7957636+bgins@users.noreply.github.com> Signed-off-by: Zeeshan Lakhani --- homestar-wasm/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homestar-wasm/README.md b/homestar-wasm/README.md index ebfce13a..6c610ca2 100644 --- a/homestar-wasm/README.md +++ b/homestar-wasm/README.md @@ -45,7 +45,7 @@ known [WIT][wit] interface types. ### Primitive Types -We'll start by covering WIT [primitive types][wit-builtin]. +We'll start by covering WIT [primitive types][wit-primitive]. #### Booleans From 7a99c6b0092da862f034b28df9a6538fa8899bb8 Mon Sep 17 00:00:00 2001 From: Zeeshan Lakhani Date: Thu, 7 Mar 2024 22:25:08 -0500 Subject: [PATCH 18/51] Update homestar-wasm/README.md Co-authored-by: Brian Ginsburg <7957636+bgins@users.noreply.github.com> Signed-off-by: Zeeshan Lakhani --- homestar-wasm/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homestar-wasm/README.md b/homestar-wasm/README.md index 6c610ca2..3f3b8b5a 100644 --- a/homestar-wasm/README.md +++ b/homestar-wasm/README.md @@ -1051,7 +1051,7 @@ given an input with a `result` type, the JSON value of } ``` -would fail to be translated into a Wit `result`runtime value, as it's ambiguous +will fail to be translated into a Wit `result`runtime value, as it's ambiguous which case it should be mapped to. [cidv0]: https://github.com/multiformats/cid?tab=readme-ov-file#cidv0 From 512b41a3a294e5fabc6b783d8ac5d2713e561488 Mon Sep 17 00:00:00 2001 From: Zeeshan Lakhani Date: Thu, 7 Mar 2024 22:25:17 -0500 Subject: [PATCH 19/51] Update homestar-wasm/README.md Co-authored-by: Brian Ginsburg <7957636+bgins@users.noreply.github.com> Signed-off-by: Zeeshan Lakhani --- homestar-wasm/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homestar-wasm/README.md b/homestar-wasm/README.md index 3f3b8b5a..bef1ebc4 100644 --- a/homestar-wasm/README.md +++ b/homestar-wasm/README.md @@ -900,7 +900,7 @@ type WitAsIpldOption union { This section outlines the translation process between [WIT result runtime values][wit-val] (of type `result`) and varying IPLD values. We treat result as Left/Right -[either][either] types over an `Ipld::List` of 2 elements. +[either][either] types over an `Ipld::List` of two elements. A [`result`][wit-result] can be interpreted as one of these patterns: From 278d9a6d8bbe9952649cf1ea2336d413a5a875c1 Mon Sep 17 00:00:00 2001 From: Zeeshan Lakhani Date: Thu, 7 Mar 2024 22:25:25 -0500 Subject: [PATCH 20/51] Update homestar-wasm/README.md Co-authored-by: Brian Ginsburg <7957636+bgins@users.noreply.github.com> Signed-off-by: Zeeshan Lakhani --- homestar-wasm/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homestar-wasm/README.md b/homestar-wasm/README.md index bef1ebc4..b221d8fb 100644 --- a/homestar-wasm/README.md +++ b/homestar-wasm/README.md @@ -831,7 +831,7 @@ type WitAsIpldMap union { #### WIT Options This section outlines the translation process between [WIT option runtime values][wit-val] -(of type `option`) and varying IPLD values. An [`option`][wit-option] can be interpreted +(of type `option`) and various IPLD values. An [`option`][wit-option] can be interpreted as either a `Ipld::Null` or of any other IPLD value. * **IPLD to WIT Translation** From 0a1eaf60374c406c20a85504f2c68058ea53528a Mon Sep 17 00:00:00 2001 From: Zeeshan Lakhani Date: Thu, 7 Mar 2024 22:25:49 -0500 Subject: [PATCH 21/51] Update homestar-wasm/README.md Co-authored-by: Brian Ginsburg <7957636+bgins@users.noreply.github.com> Signed-off-by: Zeeshan Lakhani --- homestar-wasm/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homestar-wasm/README.md b/homestar-wasm/README.md index b221d8fb..518e5b22 100644 --- a/homestar-wasm/README.md +++ b/homestar-wasm/README.md @@ -343,7 +343,7 @@ interpreted as one of a `string`, `char`, `list`, or an `enum` discriminant `"Green"` is converted into an `Ipld::String`, which is then translated and passed into `fn` as a enum argument (`color`). **You'll have to provide a - singular string that matches on one of the discriminants**. + string that matches on one of the discriminants**. * **WIT to IPLD Translation**: From 01936ee340ece96a40a0bf69f0a3d63879a67164 Mon Sep 17 00:00:00 2001 From: Zeeshan Lakhani Date: Thu, 7 Mar 2024 22:26:02 -0500 Subject: [PATCH 22/51] Update homestar-wasm/README.md Co-authored-by: Brian Ginsburg <7957636+bgins@users.noreply.github.com> Signed-off-by: Zeeshan Lakhani --- homestar-wasm/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homestar-wasm/README.md b/homestar-wasm/README.md index 518e5b22..749114e2 100644 --- a/homestar-wasm/README.md +++ b/homestar-wasm/README.md @@ -899,7 +899,7 @@ type WitAsIpldOption union { #### WIT Results This section outlines the translation process between [WIT result runtime values][wit-val] -(of type `result`) and varying IPLD values. We treat result as Left/Right +(of type `result`) and various IPLD values. We treat result as Left/Right [either][either] types over an `Ipld::List` of two elements. A [`result`][wit-result] can be interpreted as one of these patterns: From 08664c7e550d5fa1f96c1b537612977099e586aa Mon Sep 17 00:00:00 2001 From: Zeeshan Lakhani Date: Thu, 7 Mar 2024 22:26:11 -0500 Subject: [PATCH 23/51] Update homestar-wasm/README.md Co-authored-by: Brian Ginsburg <7957636+bgins@users.noreply.github.com> Signed-off-by: Zeeshan Lakhani --- homestar-wasm/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homestar-wasm/README.md b/homestar-wasm/README.md index 749114e2..85567a0d 100644 --- a/homestar-wasm/README.md +++ b/homestar-wasm/README.md @@ -807,7 +807,7 @@ a `list` of 2-element `tuples`. * **WIT to IPLD Translation**: - Conversely, when a `list` of 2-element `tuples` is returned from a WIT + Conversely, when a `list` of two-element `tuples` is returned from a WIT function, it can be translated back into an `Ipld::Map` value. **IPLD Schema Definitions**: From 464685ecfeebde7400eab880e5821e15564b47f5 Mon Sep 17 00:00:00 2001 From: Zeeshan Lakhani Date: Thu, 7 Mar 2024 22:26:19 -0500 Subject: [PATCH 24/51] Update homestar-wasm/README.md Co-authored-by: Brian Ginsburg <7957636+bgins@users.noreply.github.com> Signed-off-by: Zeeshan Lakhani --- homestar-wasm/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homestar-wasm/README.md b/homestar-wasm/README.md index 85567a0d..d4c1df5f 100644 --- a/homestar-wasm/README.md +++ b/homestar-wasm/README.md @@ -657,7 +657,7 @@ possibilities here**. export fn: func(perm: permissions) -> bool; ``` - Given an JSON input for this function: + Given a JSON input for this function: ```json { From 693b59937423a4153e6214f7dcabdd7c63023929 Mon Sep 17 00:00:00 2001 From: Zeeshan Lakhani Date: Thu, 7 Mar 2024 22:26:29 -0500 Subject: [PATCH 25/51] Update homestar-wasm/README.md Co-authored-by: Brian Ginsburg <7957636+bgins@users.noreply.github.com> Signed-off-by: Zeeshan Lakhani --- homestar-wasm/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homestar-wasm/README.md b/homestar-wasm/README.md index d4c1df5f..091acc46 100644 --- a/homestar-wasm/README.md +++ b/homestar-wasm/README.md @@ -785,7 +785,7 @@ a `list` of 2-element `tuples`. * **IPLD to WIT Translation** - When a WIT function expects a nested `list` of 2-element `tuples` as input, + When a WIT function expects a nested `list` of two-element `tuples` as input, an `Ipld::Map` value is mapped to that specific WIT runtime value. **Example**: From 2ebad6f2da1209720702847e1ff3ca961f4cca5c Mon Sep 17 00:00:00 2001 From: Zeeshan Lakhani Date: Thu, 7 Mar 2024 22:26:46 -0500 Subject: [PATCH 26/51] Update homestar-wasm/README.md Co-authored-by: Brian Ginsburg <7957636+bgins@users.noreply.github.com> Signed-off-by: Zeeshan Lakhani --- homestar-wasm/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homestar-wasm/README.md b/homestar-wasm/README.md index 091acc46..8d1e53b8 100644 --- a/homestar-wasm/README.md +++ b/homestar-wasm/README.md @@ -377,7 +377,7 @@ type WitAsIpldString union { #### Bytes This section outlines the translation process between IPLD bytes values -(`Ipld::Bytes`) and varying [WIT runtime values][wit-val]. A `Ipld::Bytes` value +(`Ipld::Bytes`) and various [WIT runtime values][wit-val]. A `Ipld::Bytes` value can be interpreted either as a `list` or `string`. - [`list`][wit-list]: From 40081cef5c5decc9b257c4f387f9514d5d23d086 Mon Sep 17 00:00:00 2001 From: Zeeshan Lakhani Date: Thu, 7 Mar 2024 22:27:01 -0500 Subject: [PATCH 27/51] Update homestar-wasm/README.md Co-authored-by: Brian Ginsburg <7957636+bgins@users.noreply.github.com> Signed-off-by: Zeeshan Lakhani --- homestar-wasm/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homestar-wasm/README.md b/homestar-wasm/README.md index 8d1e53b8..3f9af3eb 100644 --- a/homestar-wasm/README.md +++ b/homestar-wasm/README.md @@ -458,7 +458,7 @@ type WitAsIpldBytes union { #### Nulls This section outlines the translation process between IPLD null values -(`Ipld::Null`) and varying [WIT runtime values][wit-val]. A `Ipld::Null` value +(`Ipld::Null`) and various [WIT runtime values][wit-val]. A `Ipld::Null` value can be interpreted either as a `string` or `option`. **We'll cover only the `string` case here** and return to the `option` case From 6810989595b37a0748beb27f4988d4891ff8003b Mon Sep 17 00:00:00 2001 From: Zeeshan Lakhani Date: Thu, 7 Mar 2024 22:27:19 -0500 Subject: [PATCH 28/51] Update homestar-wasm/README.md Co-authored-by: Brian Ginsburg <7957636+bgins@users.noreply.github.com> Signed-off-by: Zeeshan Lakhani --- homestar-wasm/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homestar-wasm/README.md b/homestar-wasm/README.md index 3f9af3eb..68a7b8dd 100644 --- a/homestar-wasm/README.md +++ b/homestar-wasm/README.md @@ -558,7 +558,7 @@ Next, we'll cover the more interesting, WIT non-primitive types. #### List Values This section outlines the translation process between IPLD list values -(`Ipld::List`) and varying [WIT runtime values][wit-val]. A `Ipld::List` +(`Ipld::List`) and various [WIT runtime values][wit-val]. A `Ipld::List` value can be interpreted as one of a `list`, `tuple`, set of `flags`, or a `result`. From 6b26667fc35ff65601285c8b9dfe8c317580db7c Mon Sep 17 00:00:00 2001 From: Zeeshan Lakhani Date: Thu, 7 Mar 2024 22:27:40 -0500 Subject: [PATCH 29/51] Update homestar-wasm/README.md Co-authored-by: Brian Ginsburg <7957636+bgins@users.noreply.github.com> Signed-off-by: Zeeshan Lakhani --- homestar-wasm/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homestar-wasm/README.md b/homestar-wasm/README.md index 68a7b8dd..9603d8a4 100644 --- a/homestar-wasm/README.md +++ b/homestar-wasm/README.md @@ -295,7 +295,7 @@ interpreted as one of a `string`, `char`, `list`, or an `enum` discriminant export fn: func(a: list) -> list; ``` - Given an JSON input for this function: + Given a JSON input for this function: ```json { From d4ee77d732094288b2ce9a88eb3d9fecfba734d5 Mon Sep 17 00:00:00 2001 From: Zeeshan Lakhani Date: Thu, 7 Mar 2024 22:27:54 -0500 Subject: [PATCH 30/51] Update homestar-wasm/README.md Co-authored-by: Brian Ginsburg <7957636+bgins@users.noreply.github.com> Signed-off-by: Zeeshan Lakhani --- homestar-wasm/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homestar-wasm/README.md b/homestar-wasm/README.md index 9603d8a4..4fa679b4 100644 --- a/homestar-wasm/README.md +++ b/homestar-wasm/README.md @@ -693,7 +693,7 @@ type WitAsIpldList union { #### Maps This section outlines the translation process between IPLD map values -(`Ipld::Map`) and varying [WIT runtime values][wit-val]. A `Ipld::Map` +(`Ipld::Map`) and various [WIT runtime values][wit-val]. A `Ipld::Map` value can be interpreted as one of a `record`, `variant`, or a `list` of 2-element `tuples`. From bb37a9a29d7ca35e765c3a1f9e817949efa97f93 Mon Sep 17 00:00:00 2001 From: Zeeshan Lakhani Date: Thu, 7 Mar 2024 22:28:06 -0500 Subject: [PATCH 31/51] Update homestar-wasm/README.md Co-authored-by: Brian Ginsburg <7957636+bgins@users.noreply.github.com> Signed-off-by: Zeeshan Lakhani --- homestar-wasm/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homestar-wasm/README.md b/homestar-wasm/README.md index 4fa679b4..6f829802 100644 --- a/homestar-wasm/README.md +++ b/homestar-wasm/README.md @@ -393,7 +393,7 @@ can be interpreted either as a `list` or `string`. export fn: func(a: list) -> list; ``` - Given an JSON input for this function: + Given a JSON input for this function: ```json { From 5471ce7a628a1c2fe43227a41af055cbfcc2bc1a Mon Sep 17 00:00:00 2001 From: Zeeshan Lakhani Date: Thu, 7 Mar 2024 22:28:27 -0500 Subject: [PATCH 32/51] Update homestar-wasm/README.md Co-authored-by: Brian Ginsburg <7957636+bgins@users.noreply.github.com> Signed-off-by: Zeeshan Lakhani --- homestar-wasm/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homestar-wasm/README.md b/homestar-wasm/README.md index 6f829802..3e64bf6c 100644 --- a/homestar-wasm/README.md +++ b/homestar-wasm/README.md @@ -632,7 +632,7 @@ possibilities here**. - [`flags`][wit-flags]: `flags` represent a bitset structure with a name for each bit. The type - represents a set of named booleans. In an instance of the type, each flag will + represents a set of named booleans. In an instance of the named type, each flag will be either true or false. * **IPLD to WIT Translation** From cca53d21c482aa6c1ab8ae2e0e2f3e6a2ebe67b3 Mon Sep 17 00:00:00 2001 From: Zeeshan Lakhani Date: Thu, 7 Mar 2024 22:28:40 -0500 Subject: [PATCH 33/51] Update homestar-wasm/README.md Co-authored-by: Brian Ginsburg <7957636+bgins@users.noreply.github.com> Signed-off-by: Zeeshan Lakhani --- homestar-wasm/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homestar-wasm/README.md b/homestar-wasm/README.md index 3e64bf6c..0335e18f 100644 --- a/homestar-wasm/README.md +++ b/homestar-wasm/README.md @@ -695,7 +695,7 @@ type WitAsIpldList union { This section outlines the translation process between IPLD map values (`Ipld::Map`) and various [WIT runtime values][wit-val]. A `Ipld::Map` value can be interpreted as one of a `record`, `variant`, or -a `list` of 2-element `tuples`. +a `list` of two-element `tuples`. - [`record`][wit-record]: From 2d0701fe123049e1ce5888acae6b5879c178e9da Mon Sep 17 00:00:00 2001 From: Zeeshan Lakhani Date: Thu, 7 Mar 2024 22:28:55 -0500 Subject: [PATCH 34/51] Update homestar-wasm/README.md Co-authored-by: Brian Ginsburg <7957636+bgins@users.noreply.github.com> Signed-off-by: Zeeshan Lakhani --- homestar-wasm/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homestar-wasm/README.md b/homestar-wasm/README.md index 0335e18f..128e8079 100644 --- a/homestar-wasm/README.md +++ b/homestar-wasm/README.md @@ -715,7 +715,7 @@ a `list` of two-element `tuples`. export fn: func(a: pair) -> u32; ``` - Given an JSON input for this function: + Given a JSON input for this function: ```json { From 815c00df2e485683f693d120c529841f31cf3663 Mon Sep 17 00:00:00 2001 From: Zeeshan Lakhani Date: Thu, 7 Mar 2024 22:29:07 -0500 Subject: [PATCH 35/51] Update homestar-wasm/README.md Co-authored-by: Brian Ginsburg <7957636+bgins@users.noreply.github.com> Signed-off-by: Zeeshan Lakhani --- homestar-wasm/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homestar-wasm/README.md b/homestar-wasm/README.md index 128e8079..b2001c43 100644 --- a/homestar-wasm/README.md +++ b/homestar-wasm/README.md @@ -761,7 +761,7 @@ a `list` of two-element `tuples`. export fn: func(a: filter); ``` - Given an JSON input for this function: + Given a JSON input for this function: ```json { From c73394929adbed91d2a3aad1af4d1e81b63f5242 Mon Sep 17 00:00:00 2001 From: Zeeshan Lakhani Date: Thu, 7 Mar 2024 22:29:31 -0500 Subject: [PATCH 36/51] Update homestar-wasm/README.md Co-authored-by: Brian Ginsburg <7957636+bgins@users.noreply.github.com> Signed-off-by: Zeeshan Lakhani --- homestar-wasm/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homestar-wasm/README.md b/homestar-wasm/README.md index b2001c43..67b4bdac 100644 --- a/homestar-wasm/README.md +++ b/homestar-wasm/README.md @@ -794,7 +794,7 @@ a `list` of two-element `tuples`. export fn: func(a: list>) -> list; ``` - Given an JSON input for this function: + Given a JSON input for this function: ```json { From c6ca76e06f96a0765b9a975f7fcd8e8d059c1b5c Mon Sep 17 00:00:00 2001 From: Zeeshan Lakhani Date: Thu, 7 Mar 2024 22:29:56 -0500 Subject: [PATCH 37/51] Update homestar-wasm/README.md Co-authored-by: Brian Ginsburg <7957636+bgins@users.noreply.github.com> Signed-off-by: Zeeshan Lakhani --- homestar-wasm/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homestar-wasm/README.md b/homestar-wasm/README.md index 67b4bdac..94bce5c3 100644 --- a/homestar-wasm/README.md +++ b/homestar-wasm/README.md @@ -918,7 +918,7 @@ A [`result`][wit-result] can be interpreted as one of these patterns: export fn: func(a: result) -> result; ``` - Given an JSON input for this function: + Given a JSON input for this function: ```json { From f716019c8fc6bb162e33e66e424df9538b68cd46 Mon Sep 17 00:00:00 2001 From: Zeeshan Lakhani Date: Thu, 7 Mar 2024 22:30:09 -0500 Subject: [PATCH 38/51] Update homestar-wasm/README.md Co-authored-by: Brian Ginsburg <7957636+bgins@users.noreply.github.com> Signed-off-by: Zeeshan Lakhani --- homestar-wasm/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homestar-wasm/README.md b/homestar-wasm/README.md index 94bce5c3..c6fd22c9 100644 --- a/homestar-wasm/README.md +++ b/homestar-wasm/README.md @@ -946,7 +946,7 @@ A [`result`][wit-result] can be interpreted as one of these patterns: export fn: func(a: result) -> result; ``` - Given an JSON input for this function: + Given a JSON input for this function: ```json { From 3740d574ae761e5a1a3246661758a3609d25ac05 Mon Sep 17 00:00:00 2001 From: Zeeshan Lakhani Date: Thu, 7 Mar 2024 22:30:21 -0500 Subject: [PATCH 39/51] Update homestar-wasm/README.md Co-authored-by: Brian Ginsburg <7957636+bgins@users.noreply.github.com> Signed-off-by: Zeeshan Lakhani --- homestar-wasm/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homestar-wasm/README.md b/homestar-wasm/README.md index c6fd22c9..94b8d367 100644 --- a/homestar-wasm/README.md +++ b/homestar-wasm/README.md @@ -974,7 +974,7 @@ A [`result`][wit-result] can be interpreted as one of these patterns: export fn: func(a: result<_, string>) -> result<_, string>; ``` - Given an JSON input for this function: + Given a JSON input for this function: ```json { From de77ad1ae992de8d898d8ba43804e15b6326ef30 Mon Sep 17 00:00:00 2001 From: Zeeshan Lakhani Date: Thu, 7 Mar 2024 22:30:32 -0500 Subject: [PATCH 40/51] Update homestar-wasm/README.md Co-authored-by: Brian Ginsburg <7957636+bgins@users.noreply.github.com> Signed-off-by: Zeeshan Lakhani --- homestar-wasm/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homestar-wasm/README.md b/homestar-wasm/README.md index 94b8d367..559b0038 100644 --- a/homestar-wasm/README.md +++ b/homestar-wasm/README.md @@ -1004,7 +1004,7 @@ A [`result`][wit-result] can be interpreted as one of these patterns: export fn: func(a: result) -> result; ``` - Given an JSON input for this function: + Given a JSON input for this function: ```json { From 5a50a960d65967350c75e629ac5480326bc82000 Mon Sep 17 00:00:00 2001 From: Zeeshan Lakhani Date: Thu, 7 Mar 2024 22:30:43 -0500 Subject: [PATCH 41/51] Update homestar-wasm/README.md Co-authored-by: Brian Ginsburg <7957636+bgins@users.noreply.github.com> Signed-off-by: Zeeshan Lakhani --- homestar-wasm/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homestar-wasm/README.md b/homestar-wasm/README.md index 559b0038..6479088e 100644 --- a/homestar-wasm/README.md +++ b/homestar-wasm/README.md @@ -64,7 +64,7 @@ This section outlines the translation process between IPLD boolean values export fn: func(a: bool) -> bool; ``` - Given an JSON input for this function: + Given a JSON input for this function: ```json { From e82a7d27ffd595c58178ed302acb4f20a6833e18 Mon Sep 17 00:00:00 2001 From: Zeeshan Lakhani Date: Thu, 7 Mar 2024 22:30:53 -0500 Subject: [PATCH 42/51] Update homestar-wasm/README.md Co-authored-by: Brian Ginsburg <7957636+bgins@users.noreply.github.com> Signed-off-by: Zeeshan Lakhani --- homestar-wasm/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homestar-wasm/README.md b/homestar-wasm/README.md index 6479088e..68bf511b 100644 --- a/homestar-wasm/README.md +++ b/homestar-wasm/README.md @@ -109,7 +109,7 @@ ty ::= 'u8' | 'u16' | 'u32' | 'u64' export fn: func(a: s32) -> s32; ``` - Given an JSON input for this function: + Given a JSON input for this function: ```json { From 2bd0556b9daffd2eb3eb468f66c3affeffa5c94f Mon Sep 17 00:00:00 2001 From: Zeeshan Lakhani Date: Thu, 7 Mar 2024 22:31:04 -0500 Subject: [PATCH 43/51] Update homestar-wasm/README.md Co-authored-by: Brian Ginsburg <7957636+bgins@users.noreply.github.com> Signed-off-by: Zeeshan Lakhani --- homestar-wasm/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homestar-wasm/README.md b/homestar-wasm/README.md index 68bf511b..97ecad63 100644 --- a/homestar-wasm/README.md +++ b/homestar-wasm/README.md @@ -183,7 +183,7 @@ ty ::= 'float32' | 'float64' export fn: func(a: f64) -> f64; ``` - Given an JSON input for this function: + Given a JSON input for this function: ```json { From 1424bb9de5513cf94298631e55c9baa2850f7141 Mon Sep 17 00:00:00 2001 From: Zeeshan Lakhani Date: Thu, 7 Mar 2024 22:31:15 -0500 Subject: [PATCH 44/51] Update homestar-wasm/README.md Co-authored-by: Brian Ginsburg <7957636+bgins@users.noreply.github.com> Signed-off-by: Zeeshan Lakhani --- homestar-wasm/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homestar-wasm/README.md b/homestar-wasm/README.md index 97ecad63..2b480e4c 100644 --- a/homestar-wasm/README.md +++ b/homestar-wasm/README.md @@ -237,7 +237,7 @@ interpreted as one of a `string`, `char`, `list`, or an `enum` discriminant export fn: func(a: string) -> string; ``` - Given an JSON input for this function: + Given a JSON input for this function: ```json { From ef9677ee0622e8fa0a23a321a622417306ad95d5 Mon Sep 17 00:00:00 2001 From: Zeeshan Lakhani Date: Thu, 7 Mar 2024 22:31:28 -0500 Subject: [PATCH 45/51] Update homestar-wasm/README.md Co-authored-by: Brian Ginsburg <7957636+bgins@users.noreply.github.com> Signed-off-by: Zeeshan Lakhani --- homestar-wasm/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homestar-wasm/README.md b/homestar-wasm/README.md index 2b480e4c..e6e3a04d 100644 --- a/homestar-wasm/README.md +++ b/homestar-wasm/README.md @@ -266,7 +266,7 @@ interpreted as one of a `string`, `char`, `list`, or an `enum` discriminant export fn: func(a: char) -> char; ``` - Given an JSON input for this function: + Given a JSON input for this function: ```json { From e802141d2c44041e2e4e258ac7f35398148a5282 Mon Sep 17 00:00:00 2001 From: Zeeshan Lakhani Date: Thu, 7 Mar 2024 22:31:41 -0500 Subject: [PATCH 46/51] Update homestar-wasm/README.md Co-authored-by: Brian Ginsburg <7957636+bgins@users.noreply.github.com> Signed-off-by: Zeeshan Lakhani --- homestar-wasm/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homestar-wasm/README.md b/homestar-wasm/README.md index e6e3a04d..6be937e5 100644 --- a/homestar-wasm/README.md +++ b/homestar-wasm/README.md @@ -333,7 +333,7 @@ interpreted as one of a `string`, `char`, `list`, or an `enum` discriminant export fn: func(a: color) -> string; ``` - Given an JSON input for this function: + Given a JSON input for this function: ```json { From 5c24abd85545207d2ffb857037fffbfddcbf93f1 Mon Sep 17 00:00:00 2001 From: Zeeshan Lakhani Date: Thu, 7 Mar 2024 22:31:52 -0500 Subject: [PATCH 47/51] Update homestar-wasm/README.md Co-authored-by: Brian Ginsburg <7957636+bgins@users.noreply.github.com> Signed-off-by: Zeeshan Lakhani --- homestar-wasm/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homestar-wasm/README.md b/homestar-wasm/README.md index 6be937e5..e4e2a928 100644 --- a/homestar-wasm/README.md +++ b/homestar-wasm/README.md @@ -423,7 +423,7 @@ can be interpreted either as a `list` or `string`. export fn: func(a: string) -> string; ``` - Given an JSON input for this function: + Given a JSON input for this function: ```json { From b45ea0d8dcff6a9a498b26539e5915238108b0f0 Mon Sep 17 00:00:00 2001 From: Zeeshan Lakhani Date: Thu, 7 Mar 2024 22:32:11 -0500 Subject: [PATCH 48/51] Update homestar-wasm/README.md Co-authored-by: Brian Ginsburg <7957636+bgins@users.noreply.github.com> Signed-off-by: Zeeshan Lakhani --- homestar-wasm/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homestar-wasm/README.md b/homestar-wasm/README.md index e4e2a928..bdcd5754 100644 --- a/homestar-wasm/README.md +++ b/homestar-wasm/README.md @@ -475,7 +475,7 @@ below. export fn: func(a: string) -> string; ``` - Given an JSON input for this function: + Given a JSON input for this function: ```json { From 822cfefed6be5a56054227dbccb9eaa4a598bb99 Mon Sep 17 00:00:00 2001 From: Zeeshan Lakhani Date: Thu, 7 Mar 2024 22:32:32 -0500 Subject: [PATCH 49/51] Update homestar-wasm/README.md Co-authored-by: Brian Ginsburg <7957636+bgins@users.noreply.github.com> Signed-off-by: Zeeshan Lakhani --- homestar-wasm/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homestar-wasm/README.md b/homestar-wasm/README.md index bdcd5754..f9a33b91 100644 --- a/homestar-wasm/README.md +++ b/homestar-wasm/README.md @@ -525,7 +525,7 @@ interpreted as a `string` in WIT, and vice versa. export fn: func(a: string) -> string; ``` - Given an JSON input for this function: + Given a JSON input for this function: ```json { From f74f5e25c748ec65576fac7626d07346f53f5d29 Mon Sep 17 00:00:00 2001 From: Zeeshan Lakhani Date: Thu, 7 Mar 2024 22:32:47 -0500 Subject: [PATCH 50/51] Update homestar-wasm/README.md Co-authored-by: Brian Ginsburg <7957636+bgins@users.noreply.github.com> Signed-off-by: Zeeshan Lakhani --- homestar-wasm/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homestar-wasm/README.md b/homestar-wasm/README.md index f9a33b91..f7cc526c 100644 --- a/homestar-wasm/README.md +++ b/homestar-wasm/README.md @@ -578,7 +578,7 @@ possibilities here**. export fn: func(a: list, b: s32) -> list; ``` - Given an JSON input for this function: + Given a JSON input for this function: ```json { From 44287b8e49640a9b7a7c7e02958b53ebe1229d3e Mon Sep 17 00:00:00 2001 From: Zeeshan Lakhani Date: Thu, 7 Mar 2024 22:33:00 -0500 Subject: [PATCH 51/51] Update homestar-wasm/README.md Co-authored-by: Brian Ginsburg <7957636+bgins@users.noreply.github.com> Signed-off-by: Zeeshan Lakhani --- homestar-wasm/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homestar-wasm/README.md b/homestar-wasm/README.md index f7cc526c..ed6c2448 100644 --- a/homestar-wasm/README.md +++ b/homestar-wasm/README.md @@ -609,7 +609,7 @@ possibilities here**. export fn: func(a: ipv6-socket-address) -> tuple; ``` - Given an JSON input for this function: + Given a JSON input for this function: ```json {