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

feat(world): don't index keys of singleton tables #1446

Closed
wants to merge 6 commits into from
Closed
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
19 changes: 19 additions & 0 deletions packages/store/abi/IStore.sol/IStore.abi.json
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,25 @@
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "bytes32",
"name": "table",
"type": "bytes32"
}
],
"name": "hasTable",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
Expand Down
19 changes: 19 additions & 0 deletions packages/store/abi/IStore.sol/IStore.abi.json.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,25 @@ declare const abi: [
stateMutability: "view";
type: "function";
},
{
inputs: [
{
internalType: "bytes32";
name: "table";
type: "bytes32";
}
];
name: "hasTable";
outputs: [
{
internalType: "bool";
name: "";
type: "bool";
}
];
stateMutability: "view";
type: "function";
},
{
inputs: [
{
Expand Down
19 changes: 19 additions & 0 deletions packages/store/abi/IStore.sol/IStoreData.abi.json
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,25 @@
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "bytes32",
"name": "table",
"type": "bytes32"
}
],
"name": "hasTable",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
Expand Down
19 changes: 19 additions & 0 deletions packages/store/abi/IStore.sol/IStoreData.abi.json.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,25 @@ declare const abi: [
stateMutability: "view";
type: "function";
},
{
inputs: [
{
internalType: "bytes32";
name: "table";
type: "bytes32";
}
];
name: "hasTable";
outputs: [
{
internalType: "bool";
name: "";
type: "bool";
}
];
stateMutability: "view";
type: "function";
},
{
inputs: [
{
Expand Down
19 changes: 19 additions & 0 deletions packages/store/abi/IStore.sol/IStoreRead.abi.json
Original file line number Diff line number Diff line change
Expand Up @@ -177,5 +177,24 @@
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "bytes32",
"name": "table",
"type": "bytes32"
}
],
"name": "hasTable",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "view",
"type": "function"
}
]
19 changes: 19 additions & 0 deletions packages/store/abi/IStore.sol/IStoreRead.abi.json.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,25 @@ declare const abi: [
];
stateMutability: "view";
type: "function";
},
{
inputs: [
{
internalType: "bytes32";
name: "table";
type: "bytes32";
}
];
name: "hasTable";
outputs: [
{
internalType: "bool";
name: "";
type: "bool";
}
];
stateMutability: "view";
type: "function";
}
];
export default abi;
19 changes: 19 additions & 0 deletions packages/store/abi/StoreMock.sol/StoreMock.abi.json
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,25 @@
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "bytes32",
"name": "table",
"type": "bytes32"
}
],
"name": "hasTable",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
Expand Down
19 changes: 19 additions & 0 deletions packages/store/abi/StoreMock.sol/StoreMock.abi.json.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,25 @@ declare const abi: [
stateMutability: "view";
type: "function";
},
{
inputs: [
{
internalType: "bytes32";
name: "table";
type: "bytes32";
}
];
name: "hasTable";
outputs: [
{
internalType: "bool";
name: "";
type: "bool";
}
];
stateMutability: "view";
type: "function";
},
{
inputs: [
{
Expand Down
19 changes: 19 additions & 0 deletions packages/store/abi/StoreRead.sol/StoreRead.abi.json
Original file line number Diff line number Diff line change
Expand Up @@ -304,5 +304,24 @@
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "bytes32",
"name": "table",
"type": "bytes32"
}
],
"name": "hasTable",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "view",
"type": "function"
}
]
19 changes: 19 additions & 0 deletions packages/store/abi/StoreRead.sol/StoreRead.abi.json.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,25 @@ declare const abi: [
];
stateMutability: "view";
type: "function";
},
{
inputs: [
{
internalType: "bytes32";
name: "table";
type: "bytes32";
}
];
name: "hasTable";
outputs: [
{
internalType: "bool";
name: "";
type: "bool";
}
];
stateMutability: "view";
type: "function";
}
];
export default abi;
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,25 @@
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "bytes32",
"name": "table",
"type": "bytes32"
}
],
"name": "hasTable",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,25 @@ declare const abi: [
stateMutability: "view";
type: "function";
},
{
inputs: [
{
internalType: "bytes32";
name: "table";
type: "bytes32";
}
];
name: "hasTable";
outputs: [
{
internalType: "bool";
name: "";
type: "bool";
}
];
stateMutability: "view";
type: "function";
},
{
inputs: [
{
Expand Down
12 changes: 6 additions & 6 deletions packages/store/gas-report.json
Original file line number Diff line number Diff line change
Expand Up @@ -585,19 +585,19 @@
"file": "test/StoreCoreGas.t.sol",
"test": "testHooks",
"name": "set record on table with subscriber",
"gasUsed": 70983
"gasUsed": 71006
},
{
"file": "test/StoreCoreGas.t.sol",
"test": "testHooks",
"name": "set static field on table with subscriber",
"gasUsed": 24290
"gasUsed": 24333
},
{
"file": "test/StoreCoreGas.t.sol",
"test": "testHooks",
"name": "delete record on table with subscriber",
"gasUsed": 19379
"gasUsed": 19357
},
{
"file": "test/StoreCoreGas.t.sol",
Expand All @@ -609,19 +609,19 @@
"file": "test/StoreCoreGas.t.sol",
"test": "testHooksDynamicData",
"name": "set (dynamic) record on table with subscriber",
"gasUsed": 163851
"gasUsed": 163874
},
{
"file": "test/StoreCoreGas.t.sol",
"test": "testHooksDynamicData",
"name": "set (dynamic) field on table with subscriber",
"gasUsed": 26226
"gasUsed": 26269
},
{
"file": "test/StoreCoreGas.t.sol",
"test": "testHooksDynamicData",
"name": "delete (dynamic) record on table with subscriber",
"gasUsed": 20852
"gasUsed": 20830
},
{
"file": "test/StoreCoreGas.t.sol",
Expand Down
2 changes: 2 additions & 0 deletions packages/store/src/IStore.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { IStoreErrors } from "./IStoreErrors.sol";
import { Schema } from "./Schema.sol";

interface IStoreRead {
function hasTable(bytes32 table) external view returns (bool);

function getValueSchema(bytes32 table) external view returns (Schema schema);

function getKeySchema(bytes32 table) external view returns (Schema schema);
Expand Down
4 changes: 4 additions & 0 deletions packages/store/src/StoreRead.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ contract StoreRead is IStoreRead {
StoreCore.initialize();
}

function hasTable(bytes32 table) public view virtual returns (bool) {
return StoreCore.hasTable(table);
}

function getValueSchema(bytes32 table) public view virtual returns (Schema schema) {
schema = StoreCore.getValueSchema(table);
}
Expand Down
5 changes: 5 additions & 0 deletions packages/store/test/SchemaEncodeHelper.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ import { Schema, SchemaLib } from "../src/Schema.sol";
* Overrides for encode function to simplify tests
*/
library SchemaEncodeHelper {
function encode() internal pure returns (Schema) {
SchemaType[] memory schema = new SchemaType[](0);
return SchemaLib.encode(schema);
}

function encode(SchemaType a) internal pure returns (Schema) {
SchemaType[] memory schema = new SchemaType[](1);
schema[0] = a;
Expand Down
Loading