Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve schema consistency #60

Merged
merged 1 commit into from
Jan 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions schemas/type/complex/mapping.schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ properties:
const: mapping
contains:
type: object
title: Mapping key/value types
properties:
key:
$ref: "schema:ethdebug/format/type/wrapper"
Expand Down
4 changes: 2 additions & 2 deletions schemas/type/complex/struct.schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ $defs:
**ethdebug/format/type/wrapper** with additional fields.
allOf:
- $ref: "schema:ethdebug/format/type/wrapper"
- type: object
title: Additional fields
- title: Additional fields
description:
An object with optional `name` property for identifying named struct
member fields. **Note** that this language does not specify that a
struct must be consistent in its use of naming for all fields or none
type: object
properties:
name:
type: string
36 changes: 23 additions & 13 deletions schemas/type/complex/tuple.schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,7 @@ properties:
contains:
type: array
items:
title: '{ name?, type }'
allOf:
- $ref: "schema:ethdebug/format/type/wrapper"
- properties:
name:
type: string
description:
For tuple types where positional element types are identified
by name, this field **should** include this information.

This schema makes no restriction on whether all-or-no elements
have names, and so this field may be sparse across elements of
the same tuple.
$ref: "#/$defs/Element"

required:
- kind
Expand All @@ -49,3 +37,25 @@ examples:
type:
kind: uint
bits: 128

$defs:
Element:
type: object
title: Element
description:
An optionally named element type within a tuple. This is an
**ethdebug/format/type/wrapper** with additional fields.
allOf:
- $ref: "schema:ethdebug/format/type/wrapper"
- title: Additional fields
type: object
properties:
name:
type: string
description:
For tuple types where positional element types are identified
by name, this field **should** include this information.

This schema makes no restriction on whether all-or-no elements
have names, and so this field may be sparse across elements of
the same tuple.
9 changes: 6 additions & 3 deletions schemas/type/elementary/contract.schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,24 @@ properties:
$ref: "schema:ethdebug/format/type/definition"

oneOf:
- properties:
- title: Normal contract type
properties:
library:
const: false
interface:
const: false

- properties:
- title: Contract library type
properties:
library:
const: true
description:
Indicates that this is a type representing a library
required:
- library

- properties:
- title: Contract interface type
properties:
interface:
const: true
description:
Expand Down
6 changes: 3 additions & 3 deletions web/spec/type/concepts.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,13 @@ possibly includes other fields alongside `"type"`.
{
"kind": "struct",
"contains": [{
"member": "balance",
"name": "balance",
"type": {
"kind": "uint",
"bits": 256
}
}, {
"member": "scoreSheet",
"name": "scoreSheet",
"type": {
"id": "<some opaque ID for some `ScoreSheet` type>"
}
Expand All @@ -127,7 +127,7 @@ possibly includes other fields alongside `"type"`.
```

In this example, please note how this struct type represents member names
with a `"member"` field alongside the `"type"` field, and note how the
with a `"name"` field alongside the `"type"` field, and note how the
value of `"type"` can be either a complete representation or a reference
object in the form of `{ id }`.
</TabItem>
Expand Down