function
- Explore
- View source
- Playground
Loading ....
- YAML
- JSON
ethdebug/format/type/complex/function
$schema: "https://json-schema.org/draft/2020-12/schema"
$id: "schema:ethdebug/format/type/complex/function"
title: ethdebug/format/type/complex/function
description: |
Schema for representing a function type.
Type representations must indicate whether they represent a function that is
called internally (within the semantics of the language) or a function that
is called externally (via EVM contract call semantics and the Solidity ABI).
Internal function types require the `"internal": true` field; external
function types require `"external": true`.
A function type lists its `parameters` and its `returns`. An empty
`returns` list means that the function returns no values.
External function types may include a `contract` field. It is a wrapper
around the contract type that provides this function as an external
interface. Internal function types must not have a `contract` field.
type: object
properties:
label:
$ref: "schema:ethdebug/format/type/base#/$defs/Label"
class:
type: string
const: complex
kind:
type: string
const: function
parameters:
type: array
title: Parameter types
description: |
The ordered list of parameter types. Each item is an
**ethdebug/format/type/wrapper** that may have a `name`.
items:
$ref: "#/$defs/Value"
returns:
type: array
title: Return types
description: |
The ordered list of return types. Each item is an
**ethdebug/format/type/wrapper** that may have a `name`.
An empty list means that the function returns no values. A function
that returns one tuple value has a list of one struct type.
items:
$ref: "#/$defs/Value"
definition:
$ref: "schema:ethdebug/format/type/definition"
required:
- kind
- parameters
- returns
oneOf:
- type: object
title: External function type
properties:
internal:
const: false
external:
const: true
contract:
title: Contract type providing external function
description: |
A wrapper around the contract type that provides this external
function. The type is an **ethdebug/format/type/elementary/address**
that has a `definition`, or an **ethdebug/format/type/reference**.
allOf:
- $ref: "schema:ethdebug/format/type/wrapper"
- type: object
title: Contract type wrapper
properties:
type:
oneOf:
- allOf:
- $ref: "schema:ethdebug/format/type/elementary/address"
- type: object
required:
- definition
- $ref: "schema:ethdebug/format/type/reference"
required:
- external
- type: object
title: Internal function type
properties:
internal:
const: true
external:
const: false
contract:
not: {}
required:
- internal
examples:
- kind: function
internal: true
definition:
name: increment
parameters:
- name: value
type:
kind: number
returns:
- type:
kind: number
- kind: function
external: true
definition:
name: withdraw
contract:
type:
kind: address
payable: true
definition:
name: Bank
interface: true
parameters:
- name: beneficiary
type:
kind: address
payable: true
- name: amount
type:
kind: number
places: 18
returns: []
$defs:
Value:
type: object
title: Parameter or return type
description: |
An **ethdebug/format/type/wrapper** with an optional `name`.
allOf:
- $ref: "schema:ethdebug/format/type/wrapper"
- type: object
properties:
name:
type: string
ethdebug/format/type/complex/function
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "schema:ethdebug/format/type/complex/function",
"title": "ethdebug/format/type/complex/function",
"description": "Schema for representing a function type.\n\nType representations must indicate whether they represent a function that is\ncalled internally (within the semantics of the language) or a function that\nis called externally (via EVM contract call semantics and the Solidity ABI).\nInternal function types require the `\"internal\": true` field; external\nfunction types require `\"external\": true`.\n\nA function type lists its `parameters` and its `returns`. An empty\n`returns` list means that the function returns no values.\n\nExternal function types may include a `contract` field. It is a wrapper\naround the contract type that provides this function as an external\ninterface. Internal function types must not have a `contract` field.\n",
"type": "object",
"properties": {
"label": {
"$ref": "schema:ethdebug/format/type/base#/$defs/Label"
},
"class": {
"type": "string",
"const": "complex"
},
"kind": {
"type": "string",
"const": "function"
},
"parameters": {
"type": "array",
"title": "Parameter types",
"description": "The ordered list of parameter types. Each item is an\n**ethdebug/format/type/wrapper** that may have a `name`.\n",
"items": {
"$ref": "#/$defs/Value"
}
},
"returns": {
"type": "array",
"title": "Return types",
"description": "The ordered list of return types. Each item is an\n**ethdebug/format/type/wrapper** that may have a `name`.\nAn empty list means that the function returns no values. A function\nthat returns one tuple value has a list of one struct type.\n",
"items": {
"$ref": "#/$defs/Value"
}
},
"definition": {
"$ref": "schema:ethdebug/format/type/definition"
}
},
"required": [
"kind",
"parameters",
"returns"
],
"oneOf": [
{
"type": "object",
"title": "External function type",
"properties": {
"internal": {
"const": false
},
"external": {
"const": true
},
"contract": {
"title": "Contract type providing external function",
"description": "A wrapper around the contract type that provides this external\nfunction. The type is an **ethdebug/format/type/elementary/address**\nthat has a `definition`, or an **ethdebug/format/type/reference**.\n",
"allOf": [
{
"$ref": "schema:ethdebug/format/type/wrapper"
},
{
"type": "object",
"title": "Contract type wrapper",
"properties": {
"type": {
"oneOf": [
{
"allOf": [
{
"$ref": "schema:ethdebug/format/type/elementary/address"
},
{
"type": "object",
"required": [
"definition"
]
}
]
},
{
"$ref": "schema:ethdebug/format/type/reference"
}
]
}
}
}
]
}
},
"required": [
"external"
]
},
{
"type": "object",
"title": "Internal function type",
"properties": {
"internal": {
"const": true
},
"external": {
"const": false
},
"contract": {
"not": {}
}
},
"required": [
"internal"
]
}
],
"examples": [
{
"kind": "function",
"internal": true,
"definition": {
"name": "increment"
},
"parameters": [
{
"name": "value",
"type": {
"kind": "number"
}
}
],
"returns": [
{
"type": {
"kind": "number"
}
}
]
},
{
"kind": "function",
"external": true,
"definition": {
"name": "withdraw"
},
"contract": {
"type": {
"kind": "address",
"payable": true,
"definition": {
"name": "Bank",
"interface": true
}
}
},
"parameters": [
{
"name": "beneficiary",
"type": {
"kind": "address",
"payable": true
}
},
{
"name": "amount",
"type": {
"kind": "number",
"places": 18
}
}
],
"returns": []
}
],
"$defs": {
"Value": {
"type": "object",
"title": "Parameter or return type",
"description": "An **ethdebug/format/type/wrapper** with an optional `name`.\n",
"allOf": [
{
"$ref": "schema:ethdebug/format/type/wrapper"
},
{
"type": "object",
"properties": {
"name": {
"type": "string"
}
}
}
]
}
}
}
Loading playground...