Skip to content

Commit

Permalink
docs(store): add natspec for store errors (#2388)
Browse files Browse the repository at this point in the history
  • Loading branch information
yonadaaa authored Mar 7, 2024
1 parent 927fe85 commit 5873393
Show file tree
Hide file tree
Showing 7 changed files with 349 additions and 12 deletions.
122 changes: 118 additions & 4 deletions docs/pages/store/reference/store.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -129,76 +129,190 @@ This ensures that all possible errors are included in the IStore ABI for proper

#### Store_TableAlreadyExists

Error raised if the provided table already exists.

```solidity
error Store_TableAlreadyExists(ResourceId tableId, string tableIdString);
```

**Parameters**

| Name | Type | Description |
| --------------- | ------------ | -------------------------------------------------------------------------------------- |
| `tableId` | `ResourceId` | The ID of the table. |
| `tableIdString` | `string` | The stringified ID of the table (for easier debugging if cleartext tableIds are used). |

#### Store_TableNotFound

Error raised if the provided table cannot be found.

```solidity
error Store_TableNotFound(ResourceId tableId, string tableIdString);
```

**Parameters**

| Name | Type | Description |
| --------------- | ------------ | -------------------------------------------------------------------------------------- |
| `tableId` | `ResourceId` | The ID of the table. |
| `tableIdString` | `string` | The stringified ID of the table (for easier debugging if cleartext tableIds are used). |

#### Store_InvalidResourceType

Error raised if the provided resource ID cannot be found.

```solidity
error Store_InvalidResourceType(bytes2 expected, ResourceId resourceId, string resourceIdString);
```

#### Store_InvalidStaticDataLength
**Parameters**

```solidity
error Store_InvalidStaticDataLength(uint256 expected, uint256 received);
```
| Name | Type | Description |
| ------------------ | ------------ | --------------------------------------------------- |
| `expected` | `bytes2` | The expected resource type. |
| `resourceId` | `ResourceId` | The resource ID. |
| `resourceIdString` | `string` | The stringified resource ID (for easier debugging). |

#### Store_InvalidBounds

Error raised if the provided slice bounds are invalid.

```solidity
error Store_InvalidBounds(uint256 start, uint256 end);
```

**Parameters**

| Name | Type | Description |
| ------- | --------- | ----------------------------------------------------------------------------- |
| `start` | `uint256` | The start index within the dynamic field for the slice operation (inclusive). |
| `end` | `uint256` | The end index within the dynamic field for the slice operation (exclusive). |

#### Store_IndexOutOfBounds

Error raised if the provided index is out of bounds.

_Raised if the start index is larger than the previous length of the field._

```solidity
error Store_IndexOutOfBounds(uint256 length, uint256 accessedIndex);
```

**Parameters**

| Name | Type | Description |
| --------------- | --------- | ----------- |
| `length` | `uint256` | FIXME |
| `accessedIndex` | `uint256` | FIXME |

#### Store_InvalidStaticDataLength

Error raised if the provided static data length is invalid.

```solidity
error Store_InvalidStaticDataLength(uint256 expected, uint256 received);
```

**Parameters**

| Name | Type | Description |
| ---------- | --------- | -------------------- |
| `expected` | `uint256` | The expected length. |
| `received` | `uint256` | The provided length. |

#### Store_InvalidKeyNamesLength

Error raised if the provided key names length is invalid.

```solidity
error Store_InvalidKeyNamesLength(uint256 expected, uint256 received);
```

**Parameters**

| Name | Type | Description |
| ---------- | --------- | -------------------- |
| `expected` | `uint256` | The expected length. |
| `received` | `uint256` | The provided length. |

#### Store_InvalidFieldNamesLength

Error raised if the provided field names length is invalid.

```solidity
error Store_InvalidFieldNamesLength(uint256 expected, uint256 received);
```

**Parameters**

| Name | Type | Description |
| ---------- | --------- | -------------------- |
| `expected` | `uint256` | The expected length. |
| `received` | `uint256` | The provided length. |

#### Store_InvalidValueSchemaLength

Error raised if the provided value schema length is invalid.

```solidity
error Store_InvalidValueSchemaLength(uint256 expected, uint256 received);
```

**Parameters**

| Name | Type | Description |
| ---------- | --------- | -------------------- |
| `expected` | `uint256` | The expected length. |
| `received` | `uint256` | The provided length. |

#### Store_InvalidValueSchemaStaticLength

Error raised if the provided schema static length is invalid.

```solidity
error Store_InvalidValueSchemaStaticLength(uint256 expected, uint256 received);
```

**Parameters**

| Name | Type | Description |
| ---------- | --------- | -------------------- |
| `expected` | `uint256` | The expected length. |
| `received` | `uint256` | The provided length. |

#### Store_InvalidValueSchemaDynamicLength

Error raised if the provided schema dynamic length is invalid.

```solidity
error Store_InvalidValueSchemaDynamicLength(uint256 expected, uint256 received);
```

**Parameters**

| Name | Type | Description |
| ---------- | --------- | -------------------- |
| `expected` | `uint256` | The expected length. |
| `received` | `uint256` | The provided length. |

#### Store_InvalidSplice

Error raised if the provided splice is invalid.

_Raised if the splice total length of the field is changed but the splice is not at the end of the field._

```solidity
error Store_InvalidSplice(uint40 startWithinField, uint40 deleteCount, uint40 fieldLength);
```

**Parameters**

| Name | Type | Description |
| ------------------ | -------- | ---------------------------------------------------------- |
| `startWithinField` | `uint40` | The start index within the field for the splice operation. |
| `deleteCount` | `uint40` | The number of bytes to delete in the splice operation. |
| `fieldLength` | `uint40` | The field length for the splice operation. |

## IStoreData

[Git Source](https://github.com/latticexyz/mud/blob/main/packages/store/src/IStoreData.sol)
Expand Down
122 changes: 118 additions & 4 deletions docs/pages/world/reference/world-external.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -455,76 +455,190 @@ function unregisterNamespaceDelegation(ResourceId namespaceId) public onlyDelega

#### Store_TableAlreadyExists

Error raised if the provided table already exists.

```solidity
error Store_TableAlreadyExists(ResourceId tableId, string tableIdString);
```

**Parameters**

| Name | Type | Description |
| --------------- | ------------ | -------------------------------------------------------------------------------------- |
| `tableId` | `ResourceId` | The ID of the table. |
| `tableIdString` | `string` | The stringified ID of the table (for easier debugging if cleartext tableIds are used). |

#### Store_TableNotFound

Error raised if the provided table cannot be found.

```solidity
error Store_TableNotFound(ResourceId tableId, string tableIdString);
```

**Parameters**

| Name | Type | Description |
| --------------- | ------------ | -------------------------------------------------------------------------------------- |
| `tableId` | `ResourceId` | The ID of the table. |
| `tableIdString` | `string` | The stringified ID of the table (for easier debugging if cleartext tableIds are used). |

#### Store_InvalidResourceType

Error raised if the provided resource ID cannot be found.

```solidity
error Store_InvalidResourceType(bytes2 expected, ResourceId resourceId, string resourceIdString);
```

#### Store_InvalidStaticDataLength
**Parameters**

```solidity
error Store_InvalidStaticDataLength(uint256 expected, uint256 received);
```
| Name | Type | Description |
| ------------------ | ------------ | --------------------------------------------------- |
| `expected` | `bytes2` | The expected resource type. |
| `resourceId` | `ResourceId` | The resource ID. |
| `resourceIdString` | `string` | The stringified resource ID (for easier debugging). |

#### Store_InvalidBounds

Error raised if the provided slice bounds are invalid.

```solidity
error Store_InvalidBounds(uint256 start, uint256 end);
```

**Parameters**

| Name | Type | Description |
| ------- | --------- | ----------------------------------------------------------------------------- |
| `start` | `uint256` | The start index within the dynamic field for the slice operation (inclusive). |
| `end` | `uint256` | The end index within the dynamic field for the slice operation (exclusive). |

#### Store_IndexOutOfBounds

Error raised if the provided index is out of bounds.

_Raised if the start index is larger than the previous length of the field._

```solidity
error Store_IndexOutOfBounds(uint256 length, uint256 accessedIndex);
```

**Parameters**

| Name | Type | Description |
| --------------- | --------- | ----------- |
| `length` | `uint256` | FIXME |
| `accessedIndex` | `uint256` | FIXME |

#### Store_InvalidStaticDataLength

Error raised if the provided static data length is invalid.

```solidity
error Store_InvalidStaticDataLength(uint256 expected, uint256 received);
```

**Parameters**

| Name | Type | Description |
| ---------- | --------- | -------------------- |
| `expected` | `uint256` | The expected length. |
| `received` | `uint256` | The provided length. |

#### Store_InvalidKeyNamesLength

Error raised if the provided key names length is invalid.

```solidity
error Store_InvalidKeyNamesLength(uint256 expected, uint256 received);
```

**Parameters**

| Name | Type | Description |
| ---------- | --------- | -------------------- |
| `expected` | `uint256` | The expected length. |
| `received` | `uint256` | The provided length. |

#### Store_InvalidFieldNamesLength

Error raised if the provided field names length is invalid.

```solidity
error Store_InvalidFieldNamesLength(uint256 expected, uint256 received);
```

**Parameters**

| Name | Type | Description |
| ---------- | --------- | -------------------- |
| `expected` | `uint256` | The expected length. |
| `received` | `uint256` | The provided length. |

#### Store_InvalidValueSchemaLength

Error raised if the provided value schema length is invalid.

```solidity
error Store_InvalidValueSchemaLength(uint256 expected, uint256 received);
```

**Parameters**

| Name | Type | Description |
| ---------- | --------- | -------------------- |
| `expected` | `uint256` | The expected length. |
| `received` | `uint256` | The provided length. |

#### Store_InvalidValueSchemaStaticLength

Error raised if the provided schema static length is invalid.

```solidity
error Store_InvalidValueSchemaStaticLength(uint256 expected, uint256 received);
```

**Parameters**

| Name | Type | Description |
| ---------- | --------- | -------------------- |
| `expected` | `uint256` | The expected length. |
| `received` | `uint256` | The provided length. |

#### Store_InvalidValueSchemaDynamicLength

Error raised if the provided schema dynamic length is invalid.

```solidity
error Store_InvalidValueSchemaDynamicLength(uint256 expected, uint256 received);
```

**Parameters**

| Name | Type | Description |
| ---------- | --------- | -------------------- |
| `expected` | `uint256` | The expected length. |
| `received` | `uint256` | The provided length. |

#### Store_InvalidSplice

Error raised if the provided splice is invalid.

_Raised if the splice total length of the field is changed but the splice is not at the end of the field._

```solidity
error Store_InvalidSplice(uint40 startWithinField, uint40 deleteCount, uint40 fieldLength);
```

**Parameters**

| Name | Type | Description |
| ------------------ | -------- | ---------------------------------------------------------- |
| `startWithinField` | `uint40` | The start index within the field for the splice operation. |
| `deleteCount` | `uint40` | The number of bytes to delete in the splice operation. |
| `fieldLength` | `uint40` | The field length for the splice operation. |

## IWorldCall

[Git Source](https://github.com/latticexyz/mud/blob/main/packages/world/src/IWorldKernel.sol)
Expand Down
Loading

0 comments on commit 5873393

Please sign in to comment.