diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..f1c1984 Binary files /dev/null and b/.DS_Store differ diff --git a/.gitignore b/.gitignore index 9c4a649..849c59b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,13 +1,12 @@ -out/ -cache/ -node_modules/ -bindings/ -artifacts/ -deployments -deploys -abi/ -types/ -broadcast/ -.env -latticeEnv.sh -foundry.toml +**/out/ +**/cache/ +**/node_modules/ +**/bindings/ +**/artifacts/ +**/deployments +**/deploys +**/abi/ +**/types/ +**/broadcast/ +**/.env +**/latticeEnv.sh \ No newline at end of file diff --git a/.gitmodules b/.gitmodules index 12d229b..c1f5fe4 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ [submodule "src/test/murky"] - path = src/test/murky + path = packages/game/src/test/murky url = https://github.com/dmfxyz/murky diff --git a/.solhintignore b/.solhintignore index df96dc3..1bbd290 100644 --- a/.solhintignore +++ b/.solhintignore @@ -1,2 +1,3 @@ -src/test -src/codegen \ No newline at end of file +**/src/codegen +**/src/test +**/node_modules \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json index 603d9eb..5cc6d51 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,4 +1,5 @@ { "solidity.formatter": "forge", - "solidity.enabledAsYouTypeCompilationErrorCheck": true + "solidity.enabledAsYouTypeCompilationErrorCheck": true, + "solidity.compileUsingRemoteVersion": "v0.8.24+commit.e11b9ed9" } diff --git a/bun.lockb b/bun.lockb new file mode 100755 index 0000000..f7a8d12 Binary files /dev/null and b/bun.lockb differ diff --git a/foundry.toml b/foundry.toml index 6235be1..30fa64c 100644 --- a/foundry.toml +++ b/foundry.toml @@ -1,31 +1,3 @@ -[fmt] - sort_imports=true - bracket_spacing = true - int_types = "long" - line_length = 120 - multiline_func_header = "all" - number_underscore = "thousands" - quote_style = "double" - tab_width = 4 - wrap_comments = true - - -[profile.default] - solc_version = "0.8.24" - ffi = false - optimizer = true - optimizer_runs = 3000 - verbosity = 1 - src = "src" - test = "test" - out = "out" - allow_paths = ["./node_modules"] - extra_output_files = [ - "abi", - "evm.bytecode" - ] - fs_permissions = [{ access = "read", path = "./"}] - [fuzz] runs = 1028 @@ -41,5 +13,5 @@ [profile.base-testnet] eth_rpc_url = "https://goerli.base.org" -[profile.base-mainnet] - eth_rpc_url = "https://base-mainnet.blastapi.io/" \ No newline at end of file +[profile.base] + eth_rpc_url = "https://base-mainnet.blastapi.io" \ No newline at end of file diff --git a/mud/contractComponents.ts b/mud/contractComponents.ts deleted file mode 100644 index b4e8370..0000000 --- a/mud/contractComponents.ts +++ /dev/null @@ -1,246 +0,0 @@ -/* Autogenerated file. Do not edit manually. */ - -import { - defineComponent, - Type as RecsType, - type World, -} from "@latticexyz/recs"; - -export function defineContractComponents(world: World) { - return { - GameConfig: (() => { - return defineComponent( - world, - { - status: RecsType.Number, - endTime: RecsType.BigInt, - crossWordRewardFraction: RecsType.Number, - }, - { - id: "0x0000000000000000000000000000000047616d65436f6e666967000000000000", - metadata: { - componentName: "GameConfig", - tableName: ":GameConfig", - keySchema: {}, - valueSchema: { - status: "uint8", - endTime: "uint256", - crossWordRewardFraction: "uint32", - }, - }, - } as const - ); - })(), - MerkleRootConfig: (() => { - return defineComponent( - world, - { - value: RecsType.String, - }, - { - id: "0x000000000000000000000000000000004d65726b6c65526f6f74436f6e666967", - metadata: { - componentName: "MerkleRootConfig", - tableName: ":MerkleRootConfig", - keySchema: {}, - valueSchema: { value: "bytes32" }, - }, - } as const - ); - })(), - VRGDAConfig: (() => { - return defineComponent( - world, - { - startTime: RecsType.BigInt, - targetPrice: RecsType.BigInt, - priceDecay: RecsType.BigInt, - perDayInitial: RecsType.BigInt, - power: RecsType.BigInt, - }, - { - id: "0x000000000000000000000000000000005652474441436f6e6669670000000000", - metadata: { - componentName: "VRGDAConfig", - tableName: ":VRGDAConfig", - keySchema: {}, - valueSchema: { - startTime: "uint256", - targetPrice: "int256", - priceDecay: "int256", - perDayInitial: "int256", - power: "int256", - }, - }, - } as const - ); - })(), - TileLetter: (() => { - return defineComponent( - world, - { - value: RecsType.Number, - }, - { - id: "0x0000000000000000000000000000000054696c654c6574746572000000000000", - metadata: { - componentName: "TileLetter", - tableName: ":TileLetter", - keySchema: { x: "int32", y: "int32" }, - valueSchema: { value: "uint8" }, - }, - } as const - ); - })(), - TilePlayer: (() => { - return defineComponent( - world, - { - value: RecsType.String, - }, - { - id: "0x0000000000000000000000000000000054696c65506c61796572000000000000", - metadata: { - componentName: "TilePlayer", - tableName: ":TilePlayer", - keySchema: { x: "int32", y: "int32" }, - valueSchema: { value: "address" }, - }, - } as const - ); - })(), - Treasury: (() => { - return defineComponent( - world, - { - value: RecsType.BigInt, - }, - { - id: "0x0000000000000000000000000000000054726561737572790000000000000000", - metadata: { - componentName: "Treasury", - tableName: ":Treasury", - keySchema: {}, - valueSchema: { value: "uint256" }, - }, - } as const - ); - })(), - Points: (() => { - return defineComponent( - world, - { - value: RecsType.Number, - }, - { - id: "0x00000000000000000000000000000000506f696e747300000000000000000000", - metadata: { - componentName: "Points", - tableName: ":Points", - keySchema: { player: "address" }, - valueSchema: { value: "uint32" }, - }, - } as const - ); - })(), - Spent: (() => { - return defineComponent( - world, - { - value: RecsType.BigInt, - }, - { - id: "0x000000000000000000000000000000005370656e740000000000000000000000", - metadata: { - componentName: "Spent", - tableName: ":Spent", - keySchema: { player: "address", id: "uint256" }, - valueSchema: { value: "uint256" }, - }, - } as const - ); - })(), - LetterCount: (() => { - return defineComponent( - world, - { - value: RecsType.Number, - }, - { - id: "0x000000000000000000000000000000004c6574746572436f756e740000000000", - metadata: { - componentName: "LetterCount", - tableName: ":LetterCount", - keySchema: { letter: "uint8" }, - valueSchema: { value: "uint32" }, - }, - } as const - ); - })(), - Claimed: (() => { - return defineComponent( - world, - { - value: RecsType.Boolean, - }, - { - id: "0x00000000000000000000000000000000436c61696d6564000000000000000000", - metadata: { - componentName: "Claimed", - tableName: ":Claimed", - keySchema: { player: "address" }, - valueSchema: { value: "bool" }, - }, - } as const - ); - })(), - PlayResult: (() => { - return defineComponent( - world, - { - player: RecsType.String, - direction: RecsType.Number, - timestamp: RecsType.BigInt, - x: RecsType.Number, - y: RecsType.Number, - word: RecsType.NumberArray, - filledWord: RecsType.NumberArray, - }, - { - id: "0x00000000000000000000000000000000506c6179526573756c74000000000000", - metadata: { - componentName: "PlayResult", - tableName: ":PlayResult", - keySchema: { id: "uint256" }, - valueSchema: { - player: "address", - direction: "uint8", - timestamp: "uint256", - x: "int32", - y: "int32", - word: "uint8[]", - filledWord: "uint8[]", - }, - }, - } as const - ); - })(), - PointsResult: (() => { - return defineComponent( - world, - { - points: RecsType.Number, - }, - { - id: "0x00000000000000000000000000000000506f696e7473526573756c7400000000", - metadata: { - componentName: "PointsResult", - tableName: ":PointsResult", - keySchema: { id: "uint256", player: "address", pointsId: "int16" }, - valueSchema: { points: "uint32" }, - }, - } as const - ); - })(), - }; -} diff --git a/package.json b/package.json index f4a0efc..5b22d67 100644 --- a/package.json +++ b/package.json @@ -1,46 +1,12 @@ { - "name": "contracts", - "version": "0.0.0", - "private": true, - "license": "MIT", - "scripts": { - "clean-murky": "rm -rf src/test/murky/lib && rm -rf src/test/murky/differential_testing && rm -rf src/test/murky/src/test", - "build": "mud worldgen && mud tablegen && forge build", - "clean": "forge clean && rimraf src/codegen", - "deploy:local": "pnpm run build && mud deploy", - "deploy:testnet": "pnpm run build && mud deploy --profile=redstone-garnet", - "deploy:testnet-legacy": "pnpm run build && mud deploy --profile=redstone-holesky-legacy", - "deploy:base": "pnpm run build && mud deploy --profile=base-mainnet", - "dev": "pnpm mud dev-contracts", - "faucet": "DEBUG=mud:faucet pnpm faucet-server", - "lint": "forge fmt && pnpm run solhint", - "solhint": "solhint --config ./.solhint.json 'src/**/*.sol' --fix", - "test": "mud test" - }, - "devDependencies": { - "@latticexyz/cli": "2.0.1", - "@latticexyz/config": "2.0.1", - "@latticexyz/faucet": "2.0.1", - "@latticexyz/store": "2.0.1", - "@latticexyz/schema-type": "2.0.1", - "@latticexyz/world": "2.0.1", - "@latticexyz/world-modules": "2.0.1", - "@openzeppelin/contracts": "^4.8.3", - "@solidstate/contracts": "^0.0.52", - "@types/node": "^18.15.11", - "ds-test": "https://github.com/dapphub/ds-test.git#c9ce3f25bde29fc5eb9901842bf02850dfd2d084", - "ethers": "^5.7.2", - "forge-std": "https://github.com/foundry-rs/forge-std.git#b4f121555729b3afb3c5ffccb62ff4b6e2818fd3", - "prettier": "^2.6.2", - "prettier-plugin-solidity": "^1.0.0-beta.19", - "rimraf": "^3.0.2", - "run-pty": "^4.0.3", - "solhint": "^3.4.1", - "solhint-config-mud": "2.0.1", - "solhint-plugin-mud": "2.0.1", - "solmate": "6.1.0", - "ts-node": "^10.9.1", - "typechain": "^8.1.1", - "typescript": "^5.0.4" - } -} + "name": "words3-contracts", + "workspaces": [ + "packages/*" + ], + "private": true, + "scripts": { + "lint": "cd packages/game && forge fmt && cd ../rng && forge fmt && cd ../.. && bun run solhint", + "solhint": "solhint --config ./.solhint.json '**/src/**/*.sol' --fix" + }, + "engines": {} +} \ No newline at end of file diff --git a/packages/.DS_Store b/packages/.DS_Store new file mode 100644 index 0000000..9456970 Binary files /dev/null and b/packages/.DS_Store differ diff --git a/packages/game/.DS_Store b/packages/game/.DS_Store new file mode 100644 index 0000000..ea59e5a Binary files /dev/null and b/packages/game/.DS_Store differ diff --git a/packages/game/foundry.toml b/packages/game/foundry.toml new file mode 100644 index 0000000..5b03f7a --- /dev/null +++ b/packages/game/foundry.toml @@ -0,0 +1,29 @@ +[fmt] + sort_imports=true + bracket_spacing = true + int_types = "long" + line_length = 120 + multiline_func_header = "all" + number_underscore = "thousands" + quote_style = "double" + tab_width = 4 + wrap_comments = true + +[profile.default] + solc_version = "0.8.24" + ffi = false + optimizer = true + optimizer_runs = 3000 + verbosity = 1 + src = "src" + test = "test" + out = "out" + allow_paths = [ + "../../node_modules", + "../rng", + ] + extra_output_files = [ + "abi", + "evm.bytecode" + ] + fs_permissions = [{ access = "read", path = "./"}] \ No newline at end of file diff --git a/mud.config.ts b/packages/game/mud.config.ts similarity index 91% rename from mud.config.ts rename to packages/game/mud.config.ts index 8ae3a7d..57cb654 100644 --- a/mud.config.ts +++ b/packages/game/mud.config.ts @@ -1,8 +1,8 @@ import { defineWorld } from "@latticexyz/world"; export default defineWorld({ + namespace: "words3", tables: { - // Config GameConfig: { key: [], schema: { @@ -27,7 +27,6 @@ export default defineWorld({ power: "int256", }, }, - // Game TileLetter: { key: ["x", "y"], schema: { x: "int32", y: "int32", value: "Letter" }, @@ -36,6 +35,14 @@ export default defineWorld({ key: ["x", "y"], schema: { x: "int32", y: "int32", value: "address" } }, + DrawRequest: { + key: ["id"], + schema: { + id: "uint256", + player: "address", + fulfilled: "bool" + }, + }, PlayerLetters: { key: ["player", "letter"], schema: { @@ -47,7 +54,7 @@ export default defineWorld({ DrawLetterOdds: { key: [], schema: { - value: "uint8[]" // Letters index the array (A is index 1, B is index 2, etc.) + value: "uint8[]" // Letters index the array (A is index 1, B is index 2, etc.) }, }, Treasury: { @@ -76,7 +83,6 @@ export default defineWorld({ value: "uint32", }, }, - // Activity PlayResult: { key: ["id"], schema: { @@ -121,7 +127,7 @@ export default defineWorld({ points: "uint32", }, type: "offchainTable" - }, + } }, enums: { BonusType: ["MULTIPLY_WORD", "MULTIPLY_LETTER"], diff --git a/packages/game/package.json b/packages/game/package.json new file mode 100644 index 0000000..e07c9a4 --- /dev/null +++ b/packages/game/package.json @@ -0,0 +1,36 @@ +{ + "name": "game", + "private": true, + "license": "MIT", + "scripts": { + "build": "mud worldgen && mud tablegen && forge build", + "clean": "forge clean && rimraf src/codegen", + "deploy:local": "bun run build && mud deploy --worldAddress=$(jq -r '.[\"31337\"].address' ../../packages/rng/worlds.json) --alwaysRunPostDeploy", + "deploy:testnet": "bun run build && mud deploy --profile=redstone-garnet --worldAddress=$(jq -r '.[\"17069\"].address' ../../packages/rng/worlds.json)", + "deploy:base": "bun run build && mud deploy --profile=base --worldAddress=$(jq -r '.[\"8453\"].address' ../../packages/rng/worlds.json)", + "test": "bun run build && mud test --worldAddress=$(jq -r '.[\"31337\"].address' ../../packages/rng/worlds.json) --rpc http://localhost:8545", + "dev": "bun run build && mud dev-contracts --worldAddress=$(jq -r '.[\"31337\"].address' ../../packages/rng/worlds.json) --rpc http://localhost:8545 --alwaysRunPostDeploy" + }, + "devDependencies": { + "@latticexyz/cli": "2.0.6", + "@latticexyz/config": "2.0.6", + "@latticexyz/faucet": "2.0.6", + "@latticexyz/schema-type": "2.0.6", + "@latticexyz/store": "2.0.6", + "@latticexyz/world": "2.0.6", + "@latticexyz/world-modules": "2.0.6", + "@openzeppelin/contracts": "5.0.2", + "@solidstate/contracts": "^0.0.52", + "@types/node": "^18.15.11", + "ds-test": "https://github.com/dapphub/ds-test.git#e282159d5170298eb2455a6c05280ab5a73a4ef0", + "forge-std": "https://github.com/foundry-rs/forge-std.git#74cfb77e308dd188d2f58864aaf44963ae6b88b1", + "prettier": "3.2.5", + "prettier-plugin-solidity": "1.3.1", + "rimraf": "^3.0.2", + "solhint": "^3.4.1", + "solhint-config-mud": "2.0.6", + "solhint-plugin-mud": "2.0.6", + "solmate": "6.2.0", + "typescript": "5.4.2" + } +} diff --git a/packages/game/remappings.txt b/packages/game/remappings.txt new file mode 100644 index 0000000..8fbbacf --- /dev/null +++ b/packages/game/remappings.txt @@ -0,0 +1,12 @@ +@openzeppelin/=../../node_modules/@openzeppelin/ +@latticexyz/=../../node_modules/@latticexyz/ +@solidstate=../../node_modules/@solidstate/ +solmate=../../node_modules/solmate/ +ds-test/=../../node_modules/ds-test/src/ +forge-std/=../../node_modules/forge-std/src/ + +common/=src/common +codegen/=src/codegen +systems/=src/systems +libraries/=src/libraries +rng/=../rng \ No newline at end of file diff --git a/script/PostDeploy.s.sol b/packages/game/script/PostDeploy.s.sol similarity index 99% rename from script/PostDeploy.s.sol rename to packages/game/script/PostDeploy.s.sol index 1f64b83..2b0ac55 100644 --- a/script/PostDeploy.s.sol +++ b/packages/game/script/PostDeploy.s.sol @@ -4,7 +4,6 @@ pragma solidity >=0.8.0; import { Letter, Status } from "codegen/common.sol"; import { GameConfig, GameConfigData, MerkleRootConfig, VRGDAConfig, VRGDAConfigData } from "codegen/index.sol"; import { IWorld } from "codegen/world/IWorld.sol"; - import { Script } from "forge-std/Script.sol"; import { console } from "forge-std/console.sol"; diff --git a/scripts/checkWord.ts b/packages/game/scripts/checkWord.ts similarity index 100% rename from scripts/checkWord.ts rename to packages/game/scripts/checkWord.ts diff --git a/scripts/dictionary.txt b/packages/game/scripts/dictionary.txt similarity index 100% rename from scripts/dictionary.txt rename to packages/game/scripts/dictionary.txt diff --git a/scripts/encodeLetter.ts b/packages/game/scripts/encodeLetter.ts similarity index 100% rename from scripts/encodeLetter.ts rename to packages/game/scripts/encodeLetter.ts diff --git a/scripts/generateMerkleTree.ts b/packages/game/scripts/generateMerkleTree.ts similarity index 100% rename from scripts/generateMerkleTree.ts rename to packages/game/scripts/generateMerkleTree.ts diff --git a/packages/game/src/codegen/common.sol b/packages/game/src/codegen/common.sol new file mode 100644 index 0000000..0668519 --- /dev/null +++ b/packages/game/src/codegen/common.sol @@ -0,0 +1,48 @@ +// SPDX-License-Identifier: MIT +pragma solidity >=0.8.24; + +/* Autogenerated file. Do not edit manually. */ +enum BonusType { + MULTIPLY_WORD, + MULTIPLY_LETTER +} + +enum Direction { + LEFT_TO_RIGHT, + TOP_TO_BOTTOM +} + +enum Status { + NOT_STARTED, + STARTED +} + +enum Letter { + EMPTY, + A, + B, + C, + D, + E, + F, + G, + H, + I, + J, + K, + L, + M, + N, + O, + P, + Q, + R, + S, + T, + U, + V, + W, + X, + Y, + Z +} diff --git a/src/codegen/index.sol b/packages/game/src/codegen/index.sol similarity index 93% rename from src/codegen/index.sol rename to packages/game/src/codegen/index.sol index 6d44789..2ab203b 100644 --- a/src/codegen/index.sol +++ b/packages/game/src/codegen/index.sol @@ -3,19 +3,19 @@ pragma solidity >=0.8.24; /* Autogenerated file. Do not edit manually. */ -import { DrawCount } from "./tables/DrawCount.sol"; -import { DrawLetterOdds } from "./tables/DrawLetterOdds.sol"; import { GameConfig, GameConfigData } from "./tables/GameConfig.sol"; - -import { LettersDrawn, LettersDrawnData } from "./tables/LettersDrawn.sol"; import { MerkleRootConfig } from "./tables/MerkleRootConfig.sol"; -import { PlayResult, PlayResultData } from "./tables/PlayResult.sol"; +import { VRGDAConfig, VRGDAConfigData } from "./tables/VRGDAConfig.sol"; +import { TileLetter } from "./tables/TileLetter.sol"; +import { TilePlayer } from "./tables/TilePlayer.sol"; +import { DrawRequest, DrawRequestData } from "./tables/DrawRequest.sol"; import { PlayerLetters } from "./tables/PlayerLetters.sol"; +import { DrawLetterOdds } from "./tables/DrawLetterOdds.sol"; +import { Treasury } from "./tables/Treasury.sol"; import { Points } from "./tables/Points.sol"; +import { Spent } from "./tables/Spent.sol"; +import { DrawCount } from "./tables/DrawCount.sol"; +import { PlayResult, PlayResultData } from "./tables/PlayResult.sol"; import { PointsClaimed, PointsClaimedData } from "./tables/PointsClaimed.sol"; +import { LettersDrawn, LettersDrawnData } from "./tables/LettersDrawn.sol"; import { PointsResult, PointsResultData } from "./tables/PointsResult.sol"; -import { Spent } from "./tables/Spent.sol"; -import { TileLetter } from "./tables/TileLetter.sol"; -import { TilePlayer } from "./tables/TilePlayer.sol"; -import { Treasury } from "./tables/Treasury.sol"; -import { VRGDAConfig, VRGDAConfigData } from "./tables/VRGDAConfig.sol"; diff --git a/packages/game/src/codegen/tables/DrawCount.sol b/packages/game/src/codegen/tables/DrawCount.sol new file mode 100644 index 0000000..795a19f --- /dev/null +++ b/packages/game/src/codegen/tables/DrawCount.sol @@ -0,0 +1,187 @@ +// SPDX-License-Identifier: MIT +pragma solidity >=0.8.24; + +/* Autogenerated file. Do not edit manually. */ + +// Import store internals +import { IStore } from "@latticexyz/store/src/IStore.sol"; +import { StoreSwitch } from "@latticexyz/store/src/StoreSwitch.sol"; +import { StoreCore } from "@latticexyz/store/src/StoreCore.sol"; +import { Bytes } from "@latticexyz/store/src/Bytes.sol"; +import { Memory } from "@latticexyz/store/src/Memory.sol"; +import { SliceLib } from "@latticexyz/store/src/Slice.sol"; +import { EncodeArray } from "@latticexyz/store/src/tightcoder/EncodeArray.sol"; +import { FieldLayout } from "@latticexyz/store/src/FieldLayout.sol"; +import { Schema } from "@latticexyz/store/src/Schema.sol"; +import { EncodedLengths, EncodedLengthsLib } from "@latticexyz/store/src/EncodedLengths.sol"; +import { ResourceId } from "@latticexyz/store/src/ResourceId.sol"; + +library DrawCount { + // Hex below is the result of `WorldResourceIdLib.encode({ namespace: "words3", name: "DrawCount", typeId: RESOURCE_TABLE });` + ResourceId constant _tableId = ResourceId.wrap(0x7462776f72647333000000000000000044726177436f756e7400000000000000); + + FieldLayout constant _fieldLayout = + FieldLayout.wrap(0x0004010004000000000000000000000000000000000000000000000000000000); + + // Hex-encoded key schema of () + Schema constant _keySchema = Schema.wrap(0x0000000000000000000000000000000000000000000000000000000000000000); + // Hex-encoded value schema of (uint32) + Schema constant _valueSchema = Schema.wrap(0x0004010003000000000000000000000000000000000000000000000000000000); + + /** + * @notice Get the table's key field names. + * @return keyNames An array of strings with the names of key fields. + */ + function getKeyNames() internal pure returns (string[] memory keyNames) { + keyNames = new string[](0); + } + + /** + * @notice Get the table's value field names. + * @return fieldNames An array of strings with the names of value fields. + */ + function getFieldNames() internal pure returns (string[] memory fieldNames) { + fieldNames = new string[](1); + fieldNames[0] = "value"; + } + + /** + * @notice Register the table with its config. + */ + function register() internal { + StoreSwitch.registerTable(_tableId, _fieldLayout, _keySchema, _valueSchema, getKeyNames(), getFieldNames()); + } + + /** + * @notice Register the table with its config. + */ + function _register() internal { + StoreCore.registerTable(_tableId, _fieldLayout, _keySchema, _valueSchema, getKeyNames(), getFieldNames()); + } + + /** + * @notice Get value. + */ + function getValue() internal view returns (uint32 value) { + bytes32[] memory _keyTuple = new bytes32[](0); + + bytes32 _blob = StoreSwitch.getStaticField(_tableId, _keyTuple, 0, _fieldLayout); + return (uint32(bytes4(_blob))); + } + + /** + * @notice Get value. + */ + function _getValue() internal view returns (uint32 value) { + bytes32[] memory _keyTuple = new bytes32[](0); + + bytes32 _blob = StoreCore.getStaticField(_tableId, _keyTuple, 0, _fieldLayout); + return (uint32(bytes4(_blob))); + } + + /** + * @notice Get value. + */ + function get() internal view returns (uint32 value) { + bytes32[] memory _keyTuple = new bytes32[](0); + + bytes32 _blob = StoreSwitch.getStaticField(_tableId, _keyTuple, 0, _fieldLayout); + return (uint32(bytes4(_blob))); + } + + /** + * @notice Get value. + */ + function _get() internal view returns (uint32 value) { + bytes32[] memory _keyTuple = new bytes32[](0); + + bytes32 _blob = StoreCore.getStaticField(_tableId, _keyTuple, 0, _fieldLayout); + return (uint32(bytes4(_blob))); + } + + /** + * @notice Set value. + */ + function setValue(uint32 value) internal { + bytes32[] memory _keyTuple = new bytes32[](0); + + StoreSwitch.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); + } + + /** + * @notice Set value. + */ + function _setValue(uint32 value) internal { + bytes32[] memory _keyTuple = new bytes32[](0); + + StoreCore.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); + } + + /** + * @notice Set value. + */ + function set(uint32 value) internal { + bytes32[] memory _keyTuple = new bytes32[](0); + + StoreSwitch.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); + } + + /** + * @notice Set value. + */ + function _set(uint32 value) internal { + bytes32[] memory _keyTuple = new bytes32[](0); + + StoreCore.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); + } + + /** + * @notice Delete all data for given keys. + */ + function deleteRecord() internal { + bytes32[] memory _keyTuple = new bytes32[](0); + + StoreSwitch.deleteRecord(_tableId, _keyTuple); + } + + /** + * @notice Delete all data for given keys. + */ + function _deleteRecord() internal { + bytes32[] memory _keyTuple = new bytes32[](0); + + StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout); + } + + /** + * @notice Tightly pack static (fixed length) data using this table's schema. + * @return The static data, encoded into a sequence of bytes. + */ + function encodeStatic(uint32 value) internal pure returns (bytes memory) { + return abi.encodePacked(value); + } + + /** + * @notice Encode all of a record's fields. + * @return The static (fixed length) data, encoded into a sequence of bytes. + * @return The lengths of the dynamic fields (packed into a single bytes32 value). + * @return The dynamic (variable length) data, encoded into a sequence of bytes. + */ + function encode(uint32 value) internal pure returns (bytes memory, EncodedLengths, bytes memory) { + bytes memory _staticData = encodeStatic(value); + + EncodedLengths _encodedLengths; + bytes memory _dynamicData; + + return (_staticData, _encodedLengths, _dynamicData); + } + + /** + * @notice Encode keys as a bytes32 array using this table's field layout. + */ + function encodeKeyTuple() internal pure returns (bytes32[] memory) { + bytes32[] memory _keyTuple = new bytes32[](0); + + return _keyTuple; + } +} diff --git a/packages/game/src/codegen/tables/DrawLetterOdds.sol b/packages/game/src/codegen/tables/DrawLetterOdds.sol new file mode 100644 index 0000000..28d62a3 --- /dev/null +++ b/packages/game/src/codegen/tables/DrawLetterOdds.sol @@ -0,0 +1,417 @@ +// SPDX-License-Identifier: MIT +pragma solidity >=0.8.24; + +/* Autogenerated file. Do not edit manually. */ + +// Import store internals +import { IStore } from "@latticexyz/store/src/IStore.sol"; +import { StoreSwitch } from "@latticexyz/store/src/StoreSwitch.sol"; +import { StoreCore } from "@latticexyz/store/src/StoreCore.sol"; +import { Bytes } from "@latticexyz/store/src/Bytes.sol"; +import { Memory } from "@latticexyz/store/src/Memory.sol"; +import { SliceLib } from "@latticexyz/store/src/Slice.sol"; +import { EncodeArray } from "@latticexyz/store/src/tightcoder/EncodeArray.sol"; +import { FieldLayout } from "@latticexyz/store/src/FieldLayout.sol"; +import { Schema } from "@latticexyz/store/src/Schema.sol"; +import { EncodedLengths, EncodedLengthsLib } from "@latticexyz/store/src/EncodedLengths.sol"; +import { ResourceId } from "@latticexyz/store/src/ResourceId.sol"; + +library DrawLetterOdds { + // Hex below is the result of `WorldResourceIdLib.encode({ namespace: "words3", name: "DrawLetterOdds", typeId: RESOURCE_TABLE });` + ResourceId constant _tableId = ResourceId.wrap(0x7462776f726473330000000000000000447261774c65747465724f6464730000); + + FieldLayout constant _fieldLayout = + FieldLayout.wrap(0x0000000100000000000000000000000000000000000000000000000000000000); + + // Hex-encoded key schema of () + Schema constant _keySchema = Schema.wrap(0x0000000000000000000000000000000000000000000000000000000000000000); + // Hex-encoded value schema of (uint8[]) + Schema constant _valueSchema = Schema.wrap(0x0000000162000000000000000000000000000000000000000000000000000000); + + /** + * @notice Get the table's key field names. + * @return keyNames An array of strings with the names of key fields. + */ + function getKeyNames() internal pure returns (string[] memory keyNames) { + keyNames = new string[](0); + } + + /** + * @notice Get the table's value field names. + * @return fieldNames An array of strings with the names of value fields. + */ + function getFieldNames() internal pure returns (string[] memory fieldNames) { + fieldNames = new string[](1); + fieldNames[0] = "value"; + } + + /** + * @notice Register the table with its config. + */ + function register() internal { + StoreSwitch.registerTable(_tableId, _fieldLayout, _keySchema, _valueSchema, getKeyNames(), getFieldNames()); + } + + /** + * @notice Register the table with its config. + */ + function _register() internal { + StoreCore.registerTable(_tableId, _fieldLayout, _keySchema, _valueSchema, getKeyNames(), getFieldNames()); + } + + /** + * @notice Get value. + */ + function getValue() internal view returns (uint8[] memory value) { + bytes32[] memory _keyTuple = new bytes32[](0); + + bytes memory _blob = StoreSwitch.getDynamicField(_tableId, _keyTuple, 0); + return (SliceLib.getSubslice(_blob, 0, _blob.length).decodeArray_uint8()); + } + + /** + * @notice Get value. + */ + function _getValue() internal view returns (uint8[] memory value) { + bytes32[] memory _keyTuple = new bytes32[](0); + + bytes memory _blob = StoreCore.getDynamicField(_tableId, _keyTuple, 0); + return (SliceLib.getSubslice(_blob, 0, _blob.length).decodeArray_uint8()); + } + + /** + * @notice Get value. + */ + function get() internal view returns (uint8[] memory value) { + bytes32[] memory _keyTuple = new bytes32[](0); + + bytes memory _blob = StoreSwitch.getDynamicField(_tableId, _keyTuple, 0); + return (SliceLib.getSubslice(_blob, 0, _blob.length).decodeArray_uint8()); + } + + /** + * @notice Get value. + */ + function _get() internal view returns (uint8[] memory value) { + bytes32[] memory _keyTuple = new bytes32[](0); + + bytes memory _blob = StoreCore.getDynamicField(_tableId, _keyTuple, 0); + return (SliceLib.getSubslice(_blob, 0, _blob.length).decodeArray_uint8()); + } + + /** + * @notice Set value. + */ + function setValue(uint8[] memory value) internal { + bytes32[] memory _keyTuple = new bytes32[](0); + + StoreSwitch.setDynamicField(_tableId, _keyTuple, 0, EncodeArray.encode((value))); + } + + /** + * @notice Set value. + */ + function _setValue(uint8[] memory value) internal { + bytes32[] memory _keyTuple = new bytes32[](0); + + StoreCore.setDynamicField(_tableId, _keyTuple, 0, EncodeArray.encode((value))); + } + + /** + * @notice Set value. + */ + function set(uint8[] memory value) internal { + bytes32[] memory _keyTuple = new bytes32[](0); + + StoreSwitch.setDynamicField(_tableId, _keyTuple, 0, EncodeArray.encode((value))); + } + + /** + * @notice Set value. + */ + function _set(uint8[] memory value) internal { + bytes32[] memory _keyTuple = new bytes32[](0); + + StoreCore.setDynamicField(_tableId, _keyTuple, 0, EncodeArray.encode((value))); + } + + /** + * @notice Get the length of value. + */ + function lengthValue() internal view returns (uint256) { + bytes32[] memory _keyTuple = new bytes32[](0); + + uint256 _byteLength = StoreSwitch.getDynamicFieldLength(_tableId, _keyTuple, 0); + unchecked { + return _byteLength / 1; + } + } + + /** + * @notice Get the length of value. + */ + function _lengthValue() internal view returns (uint256) { + bytes32[] memory _keyTuple = new bytes32[](0); + + uint256 _byteLength = StoreCore.getDynamicFieldLength(_tableId, _keyTuple, 0); + unchecked { + return _byteLength / 1; + } + } + + /** + * @notice Get the length of value. + */ + function length() internal view returns (uint256) { + bytes32[] memory _keyTuple = new bytes32[](0); + + uint256 _byteLength = StoreSwitch.getDynamicFieldLength(_tableId, _keyTuple, 0); + unchecked { + return _byteLength / 1; + } + } + + /** + * @notice Get the length of value. + */ + function _length() internal view returns (uint256) { + bytes32[] memory _keyTuple = new bytes32[](0); + + uint256 _byteLength = StoreCore.getDynamicFieldLength(_tableId, _keyTuple, 0); + unchecked { + return _byteLength / 1; + } + } + + /** + * @notice Get an item of value. + * @dev Reverts with Store_IndexOutOfBounds if `_index` is out of bounds for the array. + */ + function getItemValue(uint256 _index) internal view returns (uint8) { + bytes32[] memory _keyTuple = new bytes32[](0); + + unchecked { + bytes memory _blob = StoreSwitch.getDynamicFieldSlice(_tableId, _keyTuple, 0, _index * 1, (_index + 1) * 1); + return (uint8(bytes1(_blob))); + } + } + + /** + * @notice Get an item of value. + * @dev Reverts with Store_IndexOutOfBounds if `_index` is out of bounds for the array. + */ + function _getItemValue(uint256 _index) internal view returns (uint8) { + bytes32[] memory _keyTuple = new bytes32[](0); + + unchecked { + bytes memory _blob = StoreCore.getDynamicFieldSlice(_tableId, _keyTuple, 0, _index * 1, (_index + 1) * 1); + return (uint8(bytes1(_blob))); + } + } + + /** + * @notice Get an item of value. + * @dev Reverts with Store_IndexOutOfBounds if `_index` is out of bounds for the array. + */ + function getItem(uint256 _index) internal view returns (uint8) { + bytes32[] memory _keyTuple = new bytes32[](0); + + unchecked { + bytes memory _blob = StoreSwitch.getDynamicFieldSlice(_tableId, _keyTuple, 0, _index * 1, (_index + 1) * 1); + return (uint8(bytes1(_blob))); + } + } + + /** + * @notice Get an item of value. + * @dev Reverts with Store_IndexOutOfBounds if `_index` is out of bounds for the array. + */ + function _getItem(uint256 _index) internal view returns (uint8) { + bytes32[] memory _keyTuple = new bytes32[](0); + + unchecked { + bytes memory _blob = StoreCore.getDynamicFieldSlice(_tableId, _keyTuple, 0, _index * 1, (_index + 1) * 1); + return (uint8(bytes1(_blob))); + } + } + + /** + * @notice Push an element to value. + */ + function pushValue(uint8 _element) internal { + bytes32[] memory _keyTuple = new bytes32[](0); + + StoreSwitch.pushToDynamicField(_tableId, _keyTuple, 0, abi.encodePacked((_element))); + } + + /** + * @notice Push an element to value. + */ + function _pushValue(uint8 _element) internal { + bytes32[] memory _keyTuple = new bytes32[](0); + + StoreCore.pushToDynamicField(_tableId, _keyTuple, 0, abi.encodePacked((_element))); + } + + /** + * @notice Push an element to value. + */ + function push(uint8 _element) internal { + bytes32[] memory _keyTuple = new bytes32[](0); + + StoreSwitch.pushToDynamicField(_tableId, _keyTuple, 0, abi.encodePacked((_element))); + } + + /** + * @notice Push an element to value. + */ + function _push(uint8 _element) internal { + bytes32[] memory _keyTuple = new bytes32[](0); + + StoreCore.pushToDynamicField(_tableId, _keyTuple, 0, abi.encodePacked((_element))); + } + + /** + * @notice Pop an element from value. + */ + function popValue() internal { + bytes32[] memory _keyTuple = new bytes32[](0); + + StoreSwitch.popFromDynamicField(_tableId, _keyTuple, 0, 1); + } + + /** + * @notice Pop an element from value. + */ + function _popValue() internal { + bytes32[] memory _keyTuple = new bytes32[](0); + + StoreCore.popFromDynamicField(_tableId, _keyTuple, 0, 1); + } + + /** + * @notice Pop an element from value. + */ + function pop() internal { + bytes32[] memory _keyTuple = new bytes32[](0); + + StoreSwitch.popFromDynamicField(_tableId, _keyTuple, 0, 1); + } + + /** + * @notice Pop an element from value. + */ + function _pop() internal { + bytes32[] memory _keyTuple = new bytes32[](0); + + StoreCore.popFromDynamicField(_tableId, _keyTuple, 0, 1); + } + + /** + * @notice Update an element of value at `_index`. + */ + function updateValue(uint256 _index, uint8 _element) internal { + bytes32[] memory _keyTuple = new bytes32[](0); + + unchecked { + bytes memory _encoded = abi.encodePacked((_element)); + StoreSwitch.spliceDynamicData(_tableId, _keyTuple, 0, uint40(_index * 1), uint40(_encoded.length), _encoded); + } + } + + /** + * @notice Update an element of value at `_index`. + */ + function _updateValue(uint256 _index, uint8 _element) internal { + bytes32[] memory _keyTuple = new bytes32[](0); + + unchecked { + bytes memory _encoded = abi.encodePacked((_element)); + StoreCore.spliceDynamicData(_tableId, _keyTuple, 0, uint40(_index * 1), uint40(_encoded.length), _encoded); + } + } + + /** + * @notice Update an element of value at `_index`. + */ + function update(uint256 _index, uint8 _element) internal { + bytes32[] memory _keyTuple = new bytes32[](0); + + unchecked { + bytes memory _encoded = abi.encodePacked((_element)); + StoreSwitch.spliceDynamicData(_tableId, _keyTuple, 0, uint40(_index * 1), uint40(_encoded.length), _encoded); + } + } + + /** + * @notice Update an element of value at `_index`. + */ + function _update(uint256 _index, uint8 _element) internal { + bytes32[] memory _keyTuple = new bytes32[](0); + + unchecked { + bytes memory _encoded = abi.encodePacked((_element)); + StoreCore.spliceDynamicData(_tableId, _keyTuple, 0, uint40(_index * 1), uint40(_encoded.length), _encoded); + } + } + + /** + * @notice Delete all data for given keys. + */ + function deleteRecord() internal { + bytes32[] memory _keyTuple = new bytes32[](0); + + StoreSwitch.deleteRecord(_tableId, _keyTuple); + } + + /** + * @notice Delete all data for given keys. + */ + function _deleteRecord() internal { + bytes32[] memory _keyTuple = new bytes32[](0); + + StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout); + } + + /** + * @notice Tightly pack dynamic data lengths using this table's schema. + * @return _encodedLengths The lengths of the dynamic fields (packed into a single bytes32 value). + */ + function encodeLengths(uint8[] memory value) internal pure returns (EncodedLengths _encodedLengths) { + // Lengths are effectively checked during copy by 2**40 bytes exceeding gas limits + unchecked { + _encodedLengths = EncodedLengthsLib.pack(value.length * 1); + } + } + + /** + * @notice Tightly pack dynamic (variable length) data using this table's schema. + * @return The dynamic data, encoded into a sequence of bytes. + */ + function encodeDynamic(uint8[] memory value) internal pure returns (bytes memory) { + return abi.encodePacked(EncodeArray.encode((value))); + } + + /** + * @notice Encode all of a record's fields. + * @return The static (fixed length) data, encoded into a sequence of bytes. + * @return The lengths of the dynamic fields (packed into a single bytes32 value). + * @return The dynamic (variable length) data, encoded into a sequence of bytes. + */ + function encode(uint8[] memory value) internal pure returns (bytes memory, EncodedLengths, bytes memory) { + bytes memory _staticData; + EncodedLengths _encodedLengths = encodeLengths(value); + bytes memory _dynamicData = encodeDynamic(value); + + return (_staticData, _encodedLengths, _dynamicData); + } + + /** + * @notice Encode keys as a bytes32 array using this table's field layout. + */ + function encodeKeyTuple() internal pure returns (bytes32[] memory) { + bytes32[] memory _keyTuple = new bytes32[](0); + + return _keyTuple; + } +} diff --git a/packages/game/src/codegen/tables/DrawRequest.sol b/packages/game/src/codegen/tables/DrawRequest.sol new file mode 100644 index 0000000..79f6a7e --- /dev/null +++ b/packages/game/src/codegen/tables/DrawRequest.sol @@ -0,0 +1,330 @@ +// SPDX-License-Identifier: MIT +pragma solidity >=0.8.24; + +/* Autogenerated file. Do not edit manually. */ + +// Import store internals +import { IStore } from "@latticexyz/store/src/IStore.sol"; +import { StoreSwitch } from "@latticexyz/store/src/StoreSwitch.sol"; +import { StoreCore } from "@latticexyz/store/src/StoreCore.sol"; +import { Bytes } from "@latticexyz/store/src/Bytes.sol"; +import { Memory } from "@latticexyz/store/src/Memory.sol"; +import { SliceLib } from "@latticexyz/store/src/Slice.sol"; +import { EncodeArray } from "@latticexyz/store/src/tightcoder/EncodeArray.sol"; +import { FieldLayout } from "@latticexyz/store/src/FieldLayout.sol"; +import { Schema } from "@latticexyz/store/src/Schema.sol"; +import { EncodedLengths, EncodedLengthsLib } from "@latticexyz/store/src/EncodedLengths.sol"; +import { ResourceId } from "@latticexyz/store/src/ResourceId.sol"; + +struct DrawRequestData { + address player; + bool fulfilled; +} + +library DrawRequest { + // Hex below is the result of `WorldResourceIdLib.encode({ namespace: "words3", name: "DrawRequest", typeId: RESOURCE_TABLE });` + ResourceId constant _tableId = ResourceId.wrap(0x7462776f72647333000000000000000044726177526571756573740000000000); + + FieldLayout constant _fieldLayout = + FieldLayout.wrap(0x0015020014010000000000000000000000000000000000000000000000000000); + + // Hex-encoded key schema of (uint256) + Schema constant _keySchema = Schema.wrap(0x002001001f000000000000000000000000000000000000000000000000000000); + // Hex-encoded value schema of (address, bool) + Schema constant _valueSchema = Schema.wrap(0x0015020061600000000000000000000000000000000000000000000000000000); + + /** + * @notice Get the table's key field names. + * @return keyNames An array of strings with the names of key fields. + */ + function getKeyNames() internal pure returns (string[] memory keyNames) { + keyNames = new string[](1); + keyNames[0] = "id"; + } + + /** + * @notice Get the table's value field names. + * @return fieldNames An array of strings with the names of value fields. + */ + function getFieldNames() internal pure returns (string[] memory fieldNames) { + fieldNames = new string[](2); + fieldNames[0] = "player"; + fieldNames[1] = "fulfilled"; + } + + /** + * @notice Register the table with its config. + */ + function register() internal { + StoreSwitch.registerTable(_tableId, _fieldLayout, _keySchema, _valueSchema, getKeyNames(), getFieldNames()); + } + + /** + * @notice Register the table with its config. + */ + function _register() internal { + StoreCore.registerTable(_tableId, _fieldLayout, _keySchema, _valueSchema, getKeyNames(), getFieldNames()); + } + + /** + * @notice Get player. + */ + function getPlayer(uint256 id) internal view returns (address player) { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = bytes32(uint256(id)); + + bytes32 _blob = StoreSwitch.getStaticField(_tableId, _keyTuple, 0, _fieldLayout); + return (address(bytes20(_blob))); + } + + /** + * @notice Get player. + */ + function _getPlayer(uint256 id) internal view returns (address player) { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = bytes32(uint256(id)); + + bytes32 _blob = StoreCore.getStaticField(_tableId, _keyTuple, 0, _fieldLayout); + return (address(bytes20(_blob))); + } + + /** + * @notice Set player. + */ + function setPlayer(uint256 id, address player) internal { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = bytes32(uint256(id)); + + StoreSwitch.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((player)), _fieldLayout); + } + + /** + * @notice Set player. + */ + function _setPlayer(uint256 id, address player) internal { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = bytes32(uint256(id)); + + StoreCore.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((player)), _fieldLayout); + } + + /** + * @notice Get fulfilled. + */ + function getFulfilled(uint256 id) internal view returns (bool fulfilled) { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = bytes32(uint256(id)); + + bytes32 _blob = StoreSwitch.getStaticField(_tableId, _keyTuple, 1, _fieldLayout); + return (_toBool(uint8(bytes1(_blob)))); + } + + /** + * @notice Get fulfilled. + */ + function _getFulfilled(uint256 id) internal view returns (bool fulfilled) { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = bytes32(uint256(id)); + + bytes32 _blob = StoreCore.getStaticField(_tableId, _keyTuple, 1, _fieldLayout); + return (_toBool(uint8(bytes1(_blob)))); + } + + /** + * @notice Set fulfilled. + */ + function setFulfilled(uint256 id, bool fulfilled) internal { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = bytes32(uint256(id)); + + StoreSwitch.setStaticField(_tableId, _keyTuple, 1, abi.encodePacked((fulfilled)), _fieldLayout); + } + + /** + * @notice Set fulfilled. + */ + function _setFulfilled(uint256 id, bool fulfilled) internal { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = bytes32(uint256(id)); + + StoreCore.setStaticField(_tableId, _keyTuple, 1, abi.encodePacked((fulfilled)), _fieldLayout); + } + + /** + * @notice Get the full data. + */ + function get(uint256 id) internal view returns (DrawRequestData memory _table) { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = bytes32(uint256(id)); + + (bytes memory _staticData, EncodedLengths _encodedLengths, bytes memory _dynamicData) = StoreSwitch.getRecord( + _tableId, + _keyTuple, + _fieldLayout + ); + return decode(_staticData, _encodedLengths, _dynamicData); + } + + /** + * @notice Get the full data. + */ + function _get(uint256 id) internal view returns (DrawRequestData memory _table) { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = bytes32(uint256(id)); + + (bytes memory _staticData, EncodedLengths _encodedLengths, bytes memory _dynamicData) = StoreCore.getRecord( + _tableId, + _keyTuple, + _fieldLayout + ); + return decode(_staticData, _encodedLengths, _dynamicData); + } + + /** + * @notice Set the full data using individual values. + */ + function set(uint256 id, address player, bool fulfilled) internal { + bytes memory _staticData = encodeStatic(player, fulfilled); + + EncodedLengths _encodedLengths; + bytes memory _dynamicData; + + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = bytes32(uint256(id)); + + StoreSwitch.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); + } + + /** + * @notice Set the full data using individual values. + */ + function _set(uint256 id, address player, bool fulfilled) internal { + bytes memory _staticData = encodeStatic(player, fulfilled); + + EncodedLengths _encodedLengths; + bytes memory _dynamicData; + + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = bytes32(uint256(id)); + + StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); + } + + /** + * @notice Set the full data using the data struct. + */ + function set(uint256 id, DrawRequestData memory _table) internal { + bytes memory _staticData = encodeStatic(_table.player, _table.fulfilled); + + EncodedLengths _encodedLengths; + bytes memory _dynamicData; + + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = bytes32(uint256(id)); + + StoreSwitch.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); + } + + /** + * @notice Set the full data using the data struct. + */ + function _set(uint256 id, DrawRequestData memory _table) internal { + bytes memory _staticData = encodeStatic(_table.player, _table.fulfilled); + + EncodedLengths _encodedLengths; + bytes memory _dynamicData; + + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = bytes32(uint256(id)); + + StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); + } + + /** + * @notice Decode the tightly packed blob of static data using this table's field layout. + */ + function decodeStatic(bytes memory _blob) internal pure returns (address player, bool fulfilled) { + player = (address(Bytes.getBytes20(_blob, 0))); + + fulfilled = (_toBool(uint8(Bytes.getBytes1(_blob, 20)))); + } + + /** + * @notice Decode the tightly packed blobs using this table's field layout. + * @param _staticData Tightly packed static fields. + * + * + */ + function decode( + bytes memory _staticData, + EncodedLengths, + bytes memory + ) internal pure returns (DrawRequestData memory _table) { + (_table.player, _table.fulfilled) = decodeStatic(_staticData); + } + + /** + * @notice Delete all data for given keys. + */ + function deleteRecord(uint256 id) internal { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = bytes32(uint256(id)); + + StoreSwitch.deleteRecord(_tableId, _keyTuple); + } + + /** + * @notice Delete all data for given keys. + */ + function _deleteRecord(uint256 id) internal { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = bytes32(uint256(id)); + + StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout); + } + + /** + * @notice Tightly pack static (fixed length) data using this table's schema. + * @return The static data, encoded into a sequence of bytes. + */ + function encodeStatic(address player, bool fulfilled) internal pure returns (bytes memory) { + return abi.encodePacked(player, fulfilled); + } + + /** + * @notice Encode all of a record's fields. + * @return The static (fixed length) data, encoded into a sequence of bytes. + * @return The lengths of the dynamic fields (packed into a single bytes32 value). + * @return The dynamic (variable length) data, encoded into a sequence of bytes. + */ + function encode(address player, bool fulfilled) internal pure returns (bytes memory, EncodedLengths, bytes memory) { + bytes memory _staticData = encodeStatic(player, fulfilled); + + EncodedLengths _encodedLengths; + bytes memory _dynamicData; + + return (_staticData, _encodedLengths, _dynamicData); + } + + /** + * @notice Encode keys as a bytes32 array using this table's field layout. + */ + function encodeKeyTuple(uint256 id) internal pure returns (bytes32[] memory) { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = bytes32(uint256(id)); + + return _keyTuple; + } +} + +/** + * @notice Cast a value to a bool. + * @dev Boolean values are encoded as uint8 (1 = true, 0 = false), but Solidity doesn't allow casting between uint8 and bool. + * @param value The uint8 value to convert. + * @return result The boolean value. + */ +function _toBool(uint8 value) pure returns (bool result) { + assembly { + result := value + } +} diff --git a/packages/game/src/codegen/tables/GameConfig.sol b/packages/game/src/codegen/tables/GameConfig.sol new file mode 100644 index 0000000..e51472f --- /dev/null +++ b/packages/game/src/codegen/tables/GameConfig.sol @@ -0,0 +1,355 @@ +// SPDX-License-Identifier: MIT +pragma solidity >=0.8.24; + +/* Autogenerated file. Do not edit manually. */ + +// Import store internals +import { IStore } from "@latticexyz/store/src/IStore.sol"; +import { StoreSwitch } from "@latticexyz/store/src/StoreSwitch.sol"; +import { StoreCore } from "@latticexyz/store/src/StoreCore.sol"; +import { Bytes } from "@latticexyz/store/src/Bytes.sol"; +import { Memory } from "@latticexyz/store/src/Memory.sol"; +import { SliceLib } from "@latticexyz/store/src/Slice.sol"; +import { EncodeArray } from "@latticexyz/store/src/tightcoder/EncodeArray.sol"; +import { FieldLayout } from "@latticexyz/store/src/FieldLayout.sol"; +import { Schema } from "@latticexyz/store/src/Schema.sol"; +import { EncodedLengths, EncodedLengthsLib } from "@latticexyz/store/src/EncodedLengths.sol"; +import { ResourceId } from "@latticexyz/store/src/ResourceId.sol"; + +// Import user types +import { Status } from "./../common.sol"; + +struct GameConfigData { + Status status; + uint32 crossWordRewardFraction; + uint16 bonusDistance; +} + +library GameConfig { + // Hex below is the result of `WorldResourceIdLib.encode({ namespace: "words3", name: "GameConfig", typeId: RESOURCE_TABLE });` + ResourceId constant _tableId = ResourceId.wrap(0x7462776f72647333000000000000000047616d65436f6e666967000000000000); + + FieldLayout constant _fieldLayout = + FieldLayout.wrap(0x0007030001040200000000000000000000000000000000000000000000000000); + + // Hex-encoded key schema of () + Schema constant _keySchema = Schema.wrap(0x0000000000000000000000000000000000000000000000000000000000000000); + // Hex-encoded value schema of (uint8, uint32, uint16) + Schema constant _valueSchema = Schema.wrap(0x0007030000030100000000000000000000000000000000000000000000000000); + + /** + * @notice Get the table's key field names. + * @return keyNames An array of strings with the names of key fields. + */ + function getKeyNames() internal pure returns (string[] memory keyNames) { + keyNames = new string[](0); + } + + /** + * @notice Get the table's value field names. + * @return fieldNames An array of strings with the names of value fields. + */ + function getFieldNames() internal pure returns (string[] memory fieldNames) { + fieldNames = new string[](3); + fieldNames[0] = "status"; + fieldNames[1] = "crossWordRewardFraction"; + fieldNames[2] = "bonusDistance"; + } + + /** + * @notice Register the table with its config. + */ + function register() internal { + StoreSwitch.registerTable(_tableId, _fieldLayout, _keySchema, _valueSchema, getKeyNames(), getFieldNames()); + } + + /** + * @notice Register the table with its config. + */ + function _register() internal { + StoreCore.registerTable(_tableId, _fieldLayout, _keySchema, _valueSchema, getKeyNames(), getFieldNames()); + } + + /** + * @notice Get status. + */ + function getStatus() internal view returns (Status status) { + bytes32[] memory _keyTuple = new bytes32[](0); + + bytes32 _blob = StoreSwitch.getStaticField(_tableId, _keyTuple, 0, _fieldLayout); + return Status(uint8(bytes1(_blob))); + } + + /** + * @notice Get status. + */ + function _getStatus() internal view returns (Status status) { + bytes32[] memory _keyTuple = new bytes32[](0); + + bytes32 _blob = StoreCore.getStaticField(_tableId, _keyTuple, 0, _fieldLayout); + return Status(uint8(bytes1(_blob))); + } + + /** + * @notice Set status. + */ + function setStatus(Status status) internal { + bytes32[] memory _keyTuple = new bytes32[](0); + + StoreSwitch.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked(uint8(status)), _fieldLayout); + } + + /** + * @notice Set status. + */ + function _setStatus(Status status) internal { + bytes32[] memory _keyTuple = new bytes32[](0); + + StoreCore.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked(uint8(status)), _fieldLayout); + } + + /** + * @notice Get crossWordRewardFraction. + */ + function getCrossWordRewardFraction() internal view returns (uint32 crossWordRewardFraction) { + bytes32[] memory _keyTuple = new bytes32[](0); + + bytes32 _blob = StoreSwitch.getStaticField(_tableId, _keyTuple, 1, _fieldLayout); + return (uint32(bytes4(_blob))); + } + + /** + * @notice Get crossWordRewardFraction. + */ + function _getCrossWordRewardFraction() internal view returns (uint32 crossWordRewardFraction) { + bytes32[] memory _keyTuple = new bytes32[](0); + + bytes32 _blob = StoreCore.getStaticField(_tableId, _keyTuple, 1, _fieldLayout); + return (uint32(bytes4(_blob))); + } + + /** + * @notice Set crossWordRewardFraction. + */ + function setCrossWordRewardFraction(uint32 crossWordRewardFraction) internal { + bytes32[] memory _keyTuple = new bytes32[](0); + + StoreSwitch.setStaticField(_tableId, _keyTuple, 1, abi.encodePacked((crossWordRewardFraction)), _fieldLayout); + } + + /** + * @notice Set crossWordRewardFraction. + */ + function _setCrossWordRewardFraction(uint32 crossWordRewardFraction) internal { + bytes32[] memory _keyTuple = new bytes32[](0); + + StoreCore.setStaticField(_tableId, _keyTuple, 1, abi.encodePacked((crossWordRewardFraction)), _fieldLayout); + } + + /** + * @notice Get bonusDistance. + */ + function getBonusDistance() internal view returns (uint16 bonusDistance) { + bytes32[] memory _keyTuple = new bytes32[](0); + + bytes32 _blob = StoreSwitch.getStaticField(_tableId, _keyTuple, 2, _fieldLayout); + return (uint16(bytes2(_blob))); + } + + /** + * @notice Get bonusDistance. + */ + function _getBonusDistance() internal view returns (uint16 bonusDistance) { + bytes32[] memory _keyTuple = new bytes32[](0); + + bytes32 _blob = StoreCore.getStaticField(_tableId, _keyTuple, 2, _fieldLayout); + return (uint16(bytes2(_blob))); + } + + /** + * @notice Set bonusDistance. + */ + function setBonusDistance(uint16 bonusDistance) internal { + bytes32[] memory _keyTuple = new bytes32[](0); + + StoreSwitch.setStaticField(_tableId, _keyTuple, 2, abi.encodePacked((bonusDistance)), _fieldLayout); + } + + /** + * @notice Set bonusDistance. + */ + function _setBonusDistance(uint16 bonusDistance) internal { + bytes32[] memory _keyTuple = new bytes32[](0); + + StoreCore.setStaticField(_tableId, _keyTuple, 2, abi.encodePacked((bonusDistance)), _fieldLayout); + } + + /** + * @notice Get the full data. + */ + function get() internal view returns (GameConfigData memory _table) { + bytes32[] memory _keyTuple = new bytes32[](0); + + (bytes memory _staticData, EncodedLengths _encodedLengths, bytes memory _dynamicData) = StoreSwitch.getRecord( + _tableId, + _keyTuple, + _fieldLayout + ); + return decode(_staticData, _encodedLengths, _dynamicData); + } + + /** + * @notice Get the full data. + */ + function _get() internal view returns (GameConfigData memory _table) { + bytes32[] memory _keyTuple = new bytes32[](0); + + (bytes memory _staticData, EncodedLengths _encodedLengths, bytes memory _dynamicData) = StoreCore.getRecord( + _tableId, + _keyTuple, + _fieldLayout + ); + return decode(_staticData, _encodedLengths, _dynamicData); + } + + /** + * @notice Set the full data using individual values. + */ + function set(Status status, uint32 crossWordRewardFraction, uint16 bonusDistance) internal { + bytes memory _staticData = encodeStatic(status, crossWordRewardFraction, bonusDistance); + + EncodedLengths _encodedLengths; + bytes memory _dynamicData; + + bytes32[] memory _keyTuple = new bytes32[](0); + + StoreSwitch.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); + } + + /** + * @notice Set the full data using individual values. + */ + function _set(Status status, uint32 crossWordRewardFraction, uint16 bonusDistance) internal { + bytes memory _staticData = encodeStatic(status, crossWordRewardFraction, bonusDistance); + + EncodedLengths _encodedLengths; + bytes memory _dynamicData; + + bytes32[] memory _keyTuple = new bytes32[](0); + + StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); + } + + /** + * @notice Set the full data using the data struct. + */ + function set(GameConfigData memory _table) internal { + bytes memory _staticData = encodeStatic(_table.status, _table.crossWordRewardFraction, _table.bonusDistance); + + EncodedLengths _encodedLengths; + bytes memory _dynamicData; + + bytes32[] memory _keyTuple = new bytes32[](0); + + StoreSwitch.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); + } + + /** + * @notice Set the full data using the data struct. + */ + function _set(GameConfigData memory _table) internal { + bytes memory _staticData = encodeStatic(_table.status, _table.crossWordRewardFraction, _table.bonusDistance); + + EncodedLengths _encodedLengths; + bytes memory _dynamicData; + + bytes32[] memory _keyTuple = new bytes32[](0); + + StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); + } + + /** + * @notice Decode the tightly packed blob of static data using this table's field layout. + */ + function decodeStatic( + bytes memory _blob + ) internal pure returns (Status status, uint32 crossWordRewardFraction, uint16 bonusDistance) { + status = Status(uint8(Bytes.getBytes1(_blob, 0))); + + crossWordRewardFraction = (uint32(Bytes.getBytes4(_blob, 1))); + + bonusDistance = (uint16(Bytes.getBytes2(_blob, 5))); + } + + /** + * @notice Decode the tightly packed blobs using this table's field layout. + * @param _staticData Tightly packed static fields. + * + * + */ + function decode( + bytes memory _staticData, + EncodedLengths, + bytes memory + ) internal pure returns (GameConfigData memory _table) { + (_table.status, _table.crossWordRewardFraction, _table.bonusDistance) = decodeStatic(_staticData); + } + + /** + * @notice Delete all data for given keys. + */ + function deleteRecord() internal { + bytes32[] memory _keyTuple = new bytes32[](0); + + StoreSwitch.deleteRecord(_tableId, _keyTuple); + } + + /** + * @notice Delete all data for given keys. + */ + function _deleteRecord() internal { + bytes32[] memory _keyTuple = new bytes32[](0); + + StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout); + } + + /** + * @notice Tightly pack static (fixed length) data using this table's schema. + * @return The static data, encoded into a sequence of bytes. + */ + function encodeStatic( + Status status, + uint32 crossWordRewardFraction, + uint16 bonusDistance + ) internal pure returns (bytes memory) { + return abi.encodePacked(status, crossWordRewardFraction, bonusDistance); + } + + /** + * @notice Encode all of a record's fields. + * @return The static (fixed length) data, encoded into a sequence of bytes. + * @return The lengths of the dynamic fields (packed into a single bytes32 value). + * @return The dynamic (variable length) data, encoded into a sequence of bytes. + */ + function encode( + Status status, + uint32 crossWordRewardFraction, + uint16 bonusDistance + ) internal pure returns (bytes memory, EncodedLengths, bytes memory) { + bytes memory _staticData = encodeStatic(status, crossWordRewardFraction, bonusDistance); + + EncodedLengths _encodedLengths; + bytes memory _dynamicData; + + return (_staticData, _encodedLengths, _dynamicData); + } + + /** + * @notice Encode keys as a bytes32 array using this table's field layout. + */ + function encodeKeyTuple() internal pure returns (bytes32[] memory) { + bytes32[] memory _keyTuple = new bytes32[](0); + + return _keyTuple; + } +} diff --git a/packages/game/src/codegen/tables/LettersDrawn.sol b/packages/game/src/codegen/tables/LettersDrawn.sol new file mode 100644 index 0000000..4e3d977 --- /dev/null +++ b/packages/game/src/codegen/tables/LettersDrawn.sol @@ -0,0 +1,272 @@ +// SPDX-License-Identifier: MIT +pragma solidity >=0.8.24; + +/* Autogenerated file. Do not edit manually. */ + +// Import store internals +import { IStore } from "@latticexyz/store/src/IStore.sol"; +import { StoreSwitch } from "@latticexyz/store/src/StoreSwitch.sol"; +import { StoreCore } from "@latticexyz/store/src/StoreCore.sol"; +import { Bytes } from "@latticexyz/store/src/Bytes.sol"; +import { Memory } from "@latticexyz/store/src/Memory.sol"; +import { SliceLib } from "@latticexyz/store/src/Slice.sol"; +import { EncodeArray } from "@latticexyz/store/src/tightcoder/EncodeArray.sol"; +import { FieldLayout } from "@latticexyz/store/src/FieldLayout.sol"; +import { Schema } from "@latticexyz/store/src/Schema.sol"; +import { EncodedLengths, EncodedLengthsLib } from "@latticexyz/store/src/EncodedLengths.sol"; +import { ResourceId } from "@latticexyz/store/src/ResourceId.sol"; + +struct LettersDrawnData { + address player; + uint256 value; + uint256 timestamp; +} + +library LettersDrawn { + // Hex below is the result of `WorldResourceIdLib.encode({ namespace: "words3", name: "LettersDrawn", typeId: RESOURCE_OFFCHAIN_TABLE });` + ResourceId constant _tableId = ResourceId.wrap(0x6f74776f7264733300000000000000004c657474657273447261776e00000000); + + FieldLayout constant _fieldLayout = + FieldLayout.wrap(0x0054030014202000000000000000000000000000000000000000000000000000); + + // Hex-encoded key schema of (uint256) + Schema constant _keySchema = Schema.wrap(0x002001001f000000000000000000000000000000000000000000000000000000); + // Hex-encoded value schema of (address, uint256, uint256) + Schema constant _valueSchema = Schema.wrap(0x00540300611f1f00000000000000000000000000000000000000000000000000); + + /** + * @notice Get the table's key field names. + * @return keyNames An array of strings with the names of key fields. + */ + function getKeyNames() internal pure returns (string[] memory keyNames) { + keyNames = new string[](1); + keyNames[0] = "id"; + } + + /** + * @notice Get the table's value field names. + * @return fieldNames An array of strings with the names of value fields. + */ + function getFieldNames() internal pure returns (string[] memory fieldNames) { + fieldNames = new string[](3); + fieldNames[0] = "player"; + fieldNames[1] = "value"; + fieldNames[2] = "timestamp"; + } + + /** + * @notice Register the table with its config. + */ + function register() internal { + StoreSwitch.registerTable(_tableId, _fieldLayout, _keySchema, _valueSchema, getKeyNames(), getFieldNames()); + } + + /** + * @notice Register the table with its config. + */ + function _register() internal { + StoreCore.registerTable(_tableId, _fieldLayout, _keySchema, _valueSchema, getKeyNames(), getFieldNames()); + } + + /** + * @notice Set player. + */ + function setPlayer(uint256 id, address player) internal { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = bytes32(uint256(id)); + + StoreSwitch.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((player)), _fieldLayout); + } + + /** + * @notice Set player. + */ + function _setPlayer(uint256 id, address player) internal { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = bytes32(uint256(id)); + + StoreCore.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((player)), _fieldLayout); + } + + /** + * @notice Set value. + */ + function setValue(uint256 id, uint256 value) internal { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = bytes32(uint256(id)); + + StoreSwitch.setStaticField(_tableId, _keyTuple, 1, abi.encodePacked((value)), _fieldLayout); + } + + /** + * @notice Set value. + */ + function _setValue(uint256 id, uint256 value) internal { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = bytes32(uint256(id)); + + StoreCore.setStaticField(_tableId, _keyTuple, 1, abi.encodePacked((value)), _fieldLayout); + } + + /** + * @notice Set timestamp. + */ + function setTimestamp(uint256 id, uint256 timestamp) internal { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = bytes32(uint256(id)); + + StoreSwitch.setStaticField(_tableId, _keyTuple, 2, abi.encodePacked((timestamp)), _fieldLayout); + } + + /** + * @notice Set timestamp. + */ + function _setTimestamp(uint256 id, uint256 timestamp) internal { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = bytes32(uint256(id)); + + StoreCore.setStaticField(_tableId, _keyTuple, 2, abi.encodePacked((timestamp)), _fieldLayout); + } + + /** + * @notice Set the full data using individual values. + */ + function set(uint256 id, address player, uint256 value, uint256 timestamp) internal { + bytes memory _staticData = encodeStatic(player, value, timestamp); + + EncodedLengths _encodedLengths; + bytes memory _dynamicData; + + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = bytes32(uint256(id)); + + StoreSwitch.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); + } + + /** + * @notice Set the full data using individual values. + */ + function _set(uint256 id, address player, uint256 value, uint256 timestamp) internal { + bytes memory _staticData = encodeStatic(player, value, timestamp); + + EncodedLengths _encodedLengths; + bytes memory _dynamicData; + + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = bytes32(uint256(id)); + + StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); + } + + /** + * @notice Set the full data using the data struct. + */ + function set(uint256 id, LettersDrawnData memory _table) internal { + bytes memory _staticData = encodeStatic(_table.player, _table.value, _table.timestamp); + + EncodedLengths _encodedLengths; + bytes memory _dynamicData; + + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = bytes32(uint256(id)); + + StoreSwitch.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); + } + + /** + * @notice Set the full data using the data struct. + */ + function _set(uint256 id, LettersDrawnData memory _table) internal { + bytes memory _staticData = encodeStatic(_table.player, _table.value, _table.timestamp); + + EncodedLengths _encodedLengths; + bytes memory _dynamicData; + + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = bytes32(uint256(id)); + + StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); + } + + /** + * @notice Decode the tightly packed blob of static data using this table's field layout. + */ + function decodeStatic(bytes memory _blob) internal pure returns (address player, uint256 value, uint256 timestamp) { + player = (address(Bytes.getBytes20(_blob, 0))); + + value = (uint256(Bytes.getBytes32(_blob, 20))); + + timestamp = (uint256(Bytes.getBytes32(_blob, 52))); + } + + /** + * @notice Decode the tightly packed blobs using this table's field layout. + * @param _staticData Tightly packed static fields. + * + * + */ + function decode( + bytes memory _staticData, + EncodedLengths, + bytes memory + ) internal pure returns (LettersDrawnData memory _table) { + (_table.player, _table.value, _table.timestamp) = decodeStatic(_staticData); + } + + /** + * @notice Delete all data for given keys. + */ + function deleteRecord(uint256 id) internal { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = bytes32(uint256(id)); + + StoreSwitch.deleteRecord(_tableId, _keyTuple); + } + + /** + * @notice Delete all data for given keys. + */ + function _deleteRecord(uint256 id) internal { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = bytes32(uint256(id)); + + StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout); + } + + /** + * @notice Tightly pack static (fixed length) data using this table's schema. + * @return The static data, encoded into a sequence of bytes. + */ + function encodeStatic(address player, uint256 value, uint256 timestamp) internal pure returns (bytes memory) { + return abi.encodePacked(player, value, timestamp); + } + + /** + * @notice Encode all of a record's fields. + * @return The static (fixed length) data, encoded into a sequence of bytes. + * @return The lengths of the dynamic fields (packed into a single bytes32 value). + * @return The dynamic (variable length) data, encoded into a sequence of bytes. + */ + function encode( + address player, + uint256 value, + uint256 timestamp + ) internal pure returns (bytes memory, EncodedLengths, bytes memory) { + bytes memory _staticData = encodeStatic(player, value, timestamp); + + EncodedLengths _encodedLengths; + bytes memory _dynamicData; + + return (_staticData, _encodedLengths, _dynamicData); + } + + /** + * @notice Encode keys as a bytes32 array using this table's field layout. + */ + function encodeKeyTuple(uint256 id) internal pure returns (bytes32[] memory) { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = bytes32(uint256(id)); + + return _keyTuple; + } +} diff --git a/packages/game/src/codegen/tables/MerkleRootConfig.sol b/packages/game/src/codegen/tables/MerkleRootConfig.sol new file mode 100644 index 0000000..0cfd539 --- /dev/null +++ b/packages/game/src/codegen/tables/MerkleRootConfig.sol @@ -0,0 +1,187 @@ +// SPDX-License-Identifier: MIT +pragma solidity >=0.8.24; + +/* Autogenerated file. Do not edit manually. */ + +// Import store internals +import { IStore } from "@latticexyz/store/src/IStore.sol"; +import { StoreSwitch } from "@latticexyz/store/src/StoreSwitch.sol"; +import { StoreCore } from "@latticexyz/store/src/StoreCore.sol"; +import { Bytes } from "@latticexyz/store/src/Bytes.sol"; +import { Memory } from "@latticexyz/store/src/Memory.sol"; +import { SliceLib } from "@latticexyz/store/src/Slice.sol"; +import { EncodeArray } from "@latticexyz/store/src/tightcoder/EncodeArray.sol"; +import { FieldLayout } from "@latticexyz/store/src/FieldLayout.sol"; +import { Schema } from "@latticexyz/store/src/Schema.sol"; +import { EncodedLengths, EncodedLengthsLib } from "@latticexyz/store/src/EncodedLengths.sol"; +import { ResourceId } from "@latticexyz/store/src/ResourceId.sol"; + +library MerkleRootConfig { + // Hex below is the result of `WorldResourceIdLib.encode({ namespace: "words3", name: "MerkleRootConfig", typeId: RESOURCE_TABLE });` + ResourceId constant _tableId = ResourceId.wrap(0x7462776f7264733300000000000000004d65726b6c65526f6f74436f6e666967); + + FieldLayout constant _fieldLayout = + FieldLayout.wrap(0x0020010020000000000000000000000000000000000000000000000000000000); + + // Hex-encoded key schema of () + Schema constant _keySchema = Schema.wrap(0x0000000000000000000000000000000000000000000000000000000000000000); + // Hex-encoded value schema of (bytes32) + Schema constant _valueSchema = Schema.wrap(0x002001005f000000000000000000000000000000000000000000000000000000); + + /** + * @notice Get the table's key field names. + * @return keyNames An array of strings with the names of key fields. + */ + function getKeyNames() internal pure returns (string[] memory keyNames) { + keyNames = new string[](0); + } + + /** + * @notice Get the table's value field names. + * @return fieldNames An array of strings with the names of value fields. + */ + function getFieldNames() internal pure returns (string[] memory fieldNames) { + fieldNames = new string[](1); + fieldNames[0] = "value"; + } + + /** + * @notice Register the table with its config. + */ + function register() internal { + StoreSwitch.registerTable(_tableId, _fieldLayout, _keySchema, _valueSchema, getKeyNames(), getFieldNames()); + } + + /** + * @notice Register the table with its config. + */ + function _register() internal { + StoreCore.registerTable(_tableId, _fieldLayout, _keySchema, _valueSchema, getKeyNames(), getFieldNames()); + } + + /** + * @notice Get value. + */ + function getValue() internal view returns (bytes32 value) { + bytes32[] memory _keyTuple = new bytes32[](0); + + bytes32 _blob = StoreSwitch.getStaticField(_tableId, _keyTuple, 0, _fieldLayout); + return (bytes32(_blob)); + } + + /** + * @notice Get value. + */ + function _getValue() internal view returns (bytes32 value) { + bytes32[] memory _keyTuple = new bytes32[](0); + + bytes32 _blob = StoreCore.getStaticField(_tableId, _keyTuple, 0, _fieldLayout); + return (bytes32(_blob)); + } + + /** + * @notice Get value. + */ + function get() internal view returns (bytes32 value) { + bytes32[] memory _keyTuple = new bytes32[](0); + + bytes32 _blob = StoreSwitch.getStaticField(_tableId, _keyTuple, 0, _fieldLayout); + return (bytes32(_blob)); + } + + /** + * @notice Get value. + */ + function _get() internal view returns (bytes32 value) { + bytes32[] memory _keyTuple = new bytes32[](0); + + bytes32 _blob = StoreCore.getStaticField(_tableId, _keyTuple, 0, _fieldLayout); + return (bytes32(_blob)); + } + + /** + * @notice Set value. + */ + function setValue(bytes32 value) internal { + bytes32[] memory _keyTuple = new bytes32[](0); + + StoreSwitch.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); + } + + /** + * @notice Set value. + */ + function _setValue(bytes32 value) internal { + bytes32[] memory _keyTuple = new bytes32[](0); + + StoreCore.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); + } + + /** + * @notice Set value. + */ + function set(bytes32 value) internal { + bytes32[] memory _keyTuple = new bytes32[](0); + + StoreSwitch.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); + } + + /** + * @notice Set value. + */ + function _set(bytes32 value) internal { + bytes32[] memory _keyTuple = new bytes32[](0); + + StoreCore.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); + } + + /** + * @notice Delete all data for given keys. + */ + function deleteRecord() internal { + bytes32[] memory _keyTuple = new bytes32[](0); + + StoreSwitch.deleteRecord(_tableId, _keyTuple); + } + + /** + * @notice Delete all data for given keys. + */ + function _deleteRecord() internal { + bytes32[] memory _keyTuple = new bytes32[](0); + + StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout); + } + + /** + * @notice Tightly pack static (fixed length) data using this table's schema. + * @return The static data, encoded into a sequence of bytes. + */ + function encodeStatic(bytes32 value) internal pure returns (bytes memory) { + return abi.encodePacked(value); + } + + /** + * @notice Encode all of a record's fields. + * @return The static (fixed length) data, encoded into a sequence of bytes. + * @return The lengths of the dynamic fields (packed into a single bytes32 value). + * @return The dynamic (variable length) data, encoded into a sequence of bytes. + */ + function encode(bytes32 value) internal pure returns (bytes memory, EncodedLengths, bytes memory) { + bytes memory _staticData = encodeStatic(value); + + EncodedLengths _encodedLengths; + bytes memory _dynamicData; + + return (_staticData, _encodedLengths, _dynamicData); + } + + /** + * @notice Encode keys as a bytes32 array using this table's field layout. + */ + function encodeKeyTuple() internal pure returns (bytes32[] memory) { + bytes32[] memory _keyTuple = new bytes32[](0); + + return _keyTuple; + } +} diff --git a/packages/game/src/codegen/tables/PlayResult.sol b/packages/game/src/codegen/tables/PlayResult.sol new file mode 100644 index 0000000..a2f4cfd --- /dev/null +++ b/packages/game/src/codegen/tables/PlayResult.sol @@ -0,0 +1,402 @@ +// SPDX-License-Identifier: MIT +pragma solidity >=0.8.24; + +/* Autogenerated file. Do not edit manually. */ + +// Import store internals +import { IStore } from "@latticexyz/store/src/IStore.sol"; +import { StoreSwitch } from "@latticexyz/store/src/StoreSwitch.sol"; +import { StoreCore } from "@latticexyz/store/src/StoreCore.sol"; +import { Bytes } from "@latticexyz/store/src/Bytes.sol"; +import { Memory } from "@latticexyz/store/src/Memory.sol"; +import { SliceLib } from "@latticexyz/store/src/Slice.sol"; +import { EncodeArray } from "@latticexyz/store/src/tightcoder/EncodeArray.sol"; +import { FieldLayout } from "@latticexyz/store/src/FieldLayout.sol"; +import { Schema } from "@latticexyz/store/src/Schema.sol"; +import { EncodedLengths, EncodedLengthsLib } from "@latticexyz/store/src/EncodedLengths.sol"; +import { ResourceId } from "@latticexyz/store/src/ResourceId.sol"; + +// Import user types +import { Direction } from "./../common.sol"; + +struct PlayResultData { + address player; + Direction direction; + uint256 timestamp; + int32 x; + int32 y; + uint8[] word; + uint8[] filledWord; +} + +library PlayResult { + // Hex below is the result of `WorldResourceIdLib.encode({ namespace: "words3", name: "PlayResult", typeId: RESOURCE_OFFCHAIN_TABLE });` + ResourceId constant _tableId = ResourceId.wrap(0x6f74776f726473330000000000000000506c6179526573756c74000000000000); + + FieldLayout constant _fieldLayout = + FieldLayout.wrap(0x003d050214012004040000000000000000000000000000000000000000000000); + + // Hex-encoded key schema of (uint256) + Schema constant _keySchema = Schema.wrap(0x002001001f000000000000000000000000000000000000000000000000000000); + // Hex-encoded value schema of (address, uint8, uint256, int32, int32, uint8[], uint8[]) + Schema constant _valueSchema = Schema.wrap(0x003d050261001f23236262000000000000000000000000000000000000000000); + + /** + * @notice Get the table's key field names. + * @return keyNames An array of strings with the names of key fields. + */ + function getKeyNames() internal pure returns (string[] memory keyNames) { + keyNames = new string[](1); + keyNames[0] = "id"; + } + + /** + * @notice Get the table's value field names. + * @return fieldNames An array of strings with the names of value fields. + */ + function getFieldNames() internal pure returns (string[] memory fieldNames) { + fieldNames = new string[](7); + fieldNames[0] = "player"; + fieldNames[1] = "direction"; + fieldNames[2] = "timestamp"; + fieldNames[3] = "x"; + fieldNames[4] = "y"; + fieldNames[5] = "word"; + fieldNames[6] = "filledWord"; + } + + /** + * @notice Register the table with its config. + */ + function register() internal { + StoreSwitch.registerTable(_tableId, _fieldLayout, _keySchema, _valueSchema, getKeyNames(), getFieldNames()); + } + + /** + * @notice Register the table with its config. + */ + function _register() internal { + StoreCore.registerTable(_tableId, _fieldLayout, _keySchema, _valueSchema, getKeyNames(), getFieldNames()); + } + + /** + * @notice Set player. + */ + function setPlayer(uint256 id, address player) internal { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = bytes32(uint256(id)); + + StoreSwitch.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((player)), _fieldLayout); + } + + /** + * @notice Set player. + */ + function _setPlayer(uint256 id, address player) internal { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = bytes32(uint256(id)); + + StoreCore.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((player)), _fieldLayout); + } + + /** + * @notice Set direction. + */ + function setDirection(uint256 id, Direction direction) internal { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = bytes32(uint256(id)); + + StoreSwitch.setStaticField(_tableId, _keyTuple, 1, abi.encodePacked(uint8(direction)), _fieldLayout); + } + + /** + * @notice Set direction. + */ + function _setDirection(uint256 id, Direction direction) internal { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = bytes32(uint256(id)); + + StoreCore.setStaticField(_tableId, _keyTuple, 1, abi.encodePacked(uint8(direction)), _fieldLayout); + } + + /** + * @notice Set timestamp. + */ + function setTimestamp(uint256 id, uint256 timestamp) internal { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = bytes32(uint256(id)); + + StoreSwitch.setStaticField(_tableId, _keyTuple, 2, abi.encodePacked((timestamp)), _fieldLayout); + } + + /** + * @notice Set timestamp. + */ + function _setTimestamp(uint256 id, uint256 timestamp) internal { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = bytes32(uint256(id)); + + StoreCore.setStaticField(_tableId, _keyTuple, 2, abi.encodePacked((timestamp)), _fieldLayout); + } + + /** + * @notice Set x. + */ + function setX(uint256 id, int32 x) internal { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = bytes32(uint256(id)); + + StoreSwitch.setStaticField(_tableId, _keyTuple, 3, abi.encodePacked((x)), _fieldLayout); + } + + /** + * @notice Set x. + */ + function _setX(uint256 id, int32 x) internal { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = bytes32(uint256(id)); + + StoreCore.setStaticField(_tableId, _keyTuple, 3, abi.encodePacked((x)), _fieldLayout); + } + + /** + * @notice Set y. + */ + function setY(uint256 id, int32 y) internal { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = bytes32(uint256(id)); + + StoreSwitch.setStaticField(_tableId, _keyTuple, 4, abi.encodePacked((y)), _fieldLayout); + } + + /** + * @notice Set y. + */ + function _setY(uint256 id, int32 y) internal { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = bytes32(uint256(id)); + + StoreCore.setStaticField(_tableId, _keyTuple, 4, abi.encodePacked((y)), _fieldLayout); + } + + /** + * @notice Set the full data using individual values. + */ + function set( + uint256 id, + address player, + Direction direction, + uint256 timestamp, + int32 x, + int32 y, + uint8[] memory word, + uint8[] memory filledWord + ) internal { + bytes memory _staticData = encodeStatic(player, direction, timestamp, x, y); + + EncodedLengths _encodedLengths = encodeLengths(word, filledWord); + bytes memory _dynamicData = encodeDynamic(word, filledWord); + + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = bytes32(uint256(id)); + + StoreSwitch.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); + } + + /** + * @notice Set the full data using individual values. + */ + function _set( + uint256 id, + address player, + Direction direction, + uint256 timestamp, + int32 x, + int32 y, + uint8[] memory word, + uint8[] memory filledWord + ) internal { + bytes memory _staticData = encodeStatic(player, direction, timestamp, x, y); + + EncodedLengths _encodedLengths = encodeLengths(word, filledWord); + bytes memory _dynamicData = encodeDynamic(word, filledWord); + + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = bytes32(uint256(id)); + + StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); + } + + /** + * @notice Set the full data using the data struct. + */ + function set(uint256 id, PlayResultData memory _table) internal { + bytes memory _staticData = encodeStatic(_table.player, _table.direction, _table.timestamp, _table.x, _table.y); + + EncodedLengths _encodedLengths = encodeLengths(_table.word, _table.filledWord); + bytes memory _dynamicData = encodeDynamic(_table.word, _table.filledWord); + + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = bytes32(uint256(id)); + + StoreSwitch.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); + } + + /** + * @notice Set the full data using the data struct. + */ + function _set(uint256 id, PlayResultData memory _table) internal { + bytes memory _staticData = encodeStatic(_table.player, _table.direction, _table.timestamp, _table.x, _table.y); + + EncodedLengths _encodedLengths = encodeLengths(_table.word, _table.filledWord); + bytes memory _dynamicData = encodeDynamic(_table.word, _table.filledWord); + + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = bytes32(uint256(id)); + + StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); + } + + /** + * @notice Decode the tightly packed blob of static data using this table's field layout. + */ + function decodeStatic( + bytes memory _blob + ) internal pure returns (address player, Direction direction, uint256 timestamp, int32 x, int32 y) { + player = (address(Bytes.getBytes20(_blob, 0))); + + direction = Direction(uint8(Bytes.getBytes1(_blob, 20))); + + timestamp = (uint256(Bytes.getBytes32(_blob, 21))); + + x = (int32(uint32(Bytes.getBytes4(_blob, 53)))); + + y = (int32(uint32(Bytes.getBytes4(_blob, 57)))); + } + + /** + * @notice Decode the tightly packed blob of dynamic data using the encoded lengths. + */ + function decodeDynamic( + EncodedLengths _encodedLengths, + bytes memory _blob + ) internal pure returns (uint8[] memory word, uint8[] memory filledWord) { + uint256 _start; + uint256 _end; + unchecked { + _end = _encodedLengths.atIndex(0); + } + word = (SliceLib.getSubslice(_blob, _start, _end).decodeArray_uint8()); + + _start = _end; + unchecked { + _end += _encodedLengths.atIndex(1); + } + filledWord = (SliceLib.getSubslice(_blob, _start, _end).decodeArray_uint8()); + } + + /** + * @notice Decode the tightly packed blobs using this table's field layout. + * @param _staticData Tightly packed static fields. + * @param _encodedLengths Encoded lengths of dynamic fields. + * @param _dynamicData Tightly packed dynamic fields. + */ + function decode( + bytes memory _staticData, + EncodedLengths _encodedLengths, + bytes memory _dynamicData + ) internal pure returns (PlayResultData memory _table) { + (_table.player, _table.direction, _table.timestamp, _table.x, _table.y) = decodeStatic(_staticData); + + (_table.word, _table.filledWord) = decodeDynamic(_encodedLengths, _dynamicData); + } + + /** + * @notice Delete all data for given keys. + */ + function deleteRecord(uint256 id) internal { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = bytes32(uint256(id)); + + StoreSwitch.deleteRecord(_tableId, _keyTuple); + } + + /** + * @notice Delete all data for given keys. + */ + function _deleteRecord(uint256 id) internal { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = bytes32(uint256(id)); + + StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout); + } + + /** + * @notice Tightly pack static (fixed length) data using this table's schema. + * @return The static data, encoded into a sequence of bytes. + */ + function encodeStatic( + address player, + Direction direction, + uint256 timestamp, + int32 x, + int32 y + ) internal pure returns (bytes memory) { + return abi.encodePacked(player, direction, timestamp, x, y); + } + + /** + * @notice Tightly pack dynamic data lengths using this table's schema. + * @return _encodedLengths The lengths of the dynamic fields (packed into a single bytes32 value). + */ + function encodeLengths( + uint8[] memory word, + uint8[] memory filledWord + ) internal pure returns (EncodedLengths _encodedLengths) { + // Lengths are effectively checked during copy by 2**40 bytes exceeding gas limits + unchecked { + _encodedLengths = EncodedLengthsLib.pack(word.length * 1, filledWord.length * 1); + } + } + + /** + * @notice Tightly pack dynamic (variable length) data using this table's schema. + * @return The dynamic data, encoded into a sequence of bytes. + */ + function encodeDynamic(uint8[] memory word, uint8[] memory filledWord) internal pure returns (bytes memory) { + return abi.encodePacked(EncodeArray.encode((word)), EncodeArray.encode((filledWord))); + } + + /** + * @notice Encode all of a record's fields. + * @return The static (fixed length) data, encoded into a sequence of bytes. + * @return The lengths of the dynamic fields (packed into a single bytes32 value). + * @return The dynamic (variable length) data, encoded into a sequence of bytes. + */ + function encode( + address player, + Direction direction, + uint256 timestamp, + int32 x, + int32 y, + uint8[] memory word, + uint8[] memory filledWord + ) internal pure returns (bytes memory, EncodedLengths, bytes memory) { + bytes memory _staticData = encodeStatic(player, direction, timestamp, x, y); + + EncodedLengths _encodedLengths = encodeLengths(word, filledWord); + bytes memory _dynamicData = encodeDynamic(word, filledWord); + + return (_staticData, _encodedLengths, _dynamicData); + } + + /** + * @notice Encode keys as a bytes32 array using this table's field layout. + */ + function encodeKeyTuple(uint256 id) internal pure returns (bytes32[] memory) { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = bytes32(uint256(id)); + + return _keyTuple; + } +} diff --git a/packages/game/src/codegen/tables/PlayerLetters.sol b/packages/game/src/codegen/tables/PlayerLetters.sol new file mode 100644 index 0000000..11affb7 --- /dev/null +++ b/packages/game/src/codegen/tables/PlayerLetters.sol @@ -0,0 +1,214 @@ +// SPDX-License-Identifier: MIT +pragma solidity >=0.8.24; + +/* Autogenerated file. Do not edit manually. */ + +// Import store internals +import { IStore } from "@latticexyz/store/src/IStore.sol"; +import { StoreSwitch } from "@latticexyz/store/src/StoreSwitch.sol"; +import { StoreCore } from "@latticexyz/store/src/StoreCore.sol"; +import { Bytes } from "@latticexyz/store/src/Bytes.sol"; +import { Memory } from "@latticexyz/store/src/Memory.sol"; +import { SliceLib } from "@latticexyz/store/src/Slice.sol"; +import { EncodeArray } from "@latticexyz/store/src/tightcoder/EncodeArray.sol"; +import { FieldLayout } from "@latticexyz/store/src/FieldLayout.sol"; +import { Schema } from "@latticexyz/store/src/Schema.sol"; +import { EncodedLengths, EncodedLengthsLib } from "@latticexyz/store/src/EncodedLengths.sol"; +import { ResourceId } from "@latticexyz/store/src/ResourceId.sol"; + +// Import user types +import { Letter } from "./../common.sol"; + +library PlayerLetters { + // Hex below is the result of `WorldResourceIdLib.encode({ namespace: "words3", name: "PlayerLetters", typeId: RESOURCE_TABLE });` + ResourceId constant _tableId = ResourceId.wrap(0x7462776f726473330000000000000000506c617965724c657474657273000000); + + FieldLayout constant _fieldLayout = + FieldLayout.wrap(0x0004010004000000000000000000000000000000000000000000000000000000); + + // Hex-encoded key schema of (address, uint8) + Schema constant _keySchema = Schema.wrap(0x0015020061000000000000000000000000000000000000000000000000000000); + // Hex-encoded value schema of (uint32) + Schema constant _valueSchema = Schema.wrap(0x0004010003000000000000000000000000000000000000000000000000000000); + + /** + * @notice Get the table's key field names. + * @return keyNames An array of strings with the names of key fields. + */ + function getKeyNames() internal pure returns (string[] memory keyNames) { + keyNames = new string[](2); + keyNames[0] = "player"; + keyNames[1] = "letter"; + } + + /** + * @notice Get the table's value field names. + * @return fieldNames An array of strings with the names of value fields. + */ + function getFieldNames() internal pure returns (string[] memory fieldNames) { + fieldNames = new string[](1); + fieldNames[0] = "value"; + } + + /** + * @notice Register the table with its config. + */ + function register() internal { + StoreSwitch.registerTable(_tableId, _fieldLayout, _keySchema, _valueSchema, getKeyNames(), getFieldNames()); + } + + /** + * @notice Register the table with its config. + */ + function _register() internal { + StoreCore.registerTable(_tableId, _fieldLayout, _keySchema, _valueSchema, getKeyNames(), getFieldNames()); + } + + /** + * @notice Get value. + */ + function getValue(address player, Letter letter) internal view returns (uint32 value) { + bytes32[] memory _keyTuple = new bytes32[](2); + _keyTuple[0] = bytes32(uint256(uint160(player))); + _keyTuple[1] = bytes32(uint256(uint8(letter))); + + bytes32 _blob = StoreSwitch.getStaticField(_tableId, _keyTuple, 0, _fieldLayout); + return (uint32(bytes4(_blob))); + } + + /** + * @notice Get value. + */ + function _getValue(address player, Letter letter) internal view returns (uint32 value) { + bytes32[] memory _keyTuple = new bytes32[](2); + _keyTuple[0] = bytes32(uint256(uint160(player))); + _keyTuple[1] = bytes32(uint256(uint8(letter))); + + bytes32 _blob = StoreCore.getStaticField(_tableId, _keyTuple, 0, _fieldLayout); + return (uint32(bytes4(_blob))); + } + + /** + * @notice Get value. + */ + function get(address player, Letter letter) internal view returns (uint32 value) { + bytes32[] memory _keyTuple = new bytes32[](2); + _keyTuple[0] = bytes32(uint256(uint160(player))); + _keyTuple[1] = bytes32(uint256(uint8(letter))); + + bytes32 _blob = StoreSwitch.getStaticField(_tableId, _keyTuple, 0, _fieldLayout); + return (uint32(bytes4(_blob))); + } + + /** + * @notice Get value. + */ + function _get(address player, Letter letter) internal view returns (uint32 value) { + bytes32[] memory _keyTuple = new bytes32[](2); + _keyTuple[0] = bytes32(uint256(uint160(player))); + _keyTuple[1] = bytes32(uint256(uint8(letter))); + + bytes32 _blob = StoreCore.getStaticField(_tableId, _keyTuple, 0, _fieldLayout); + return (uint32(bytes4(_blob))); + } + + /** + * @notice Set value. + */ + function setValue(address player, Letter letter, uint32 value) internal { + bytes32[] memory _keyTuple = new bytes32[](2); + _keyTuple[0] = bytes32(uint256(uint160(player))); + _keyTuple[1] = bytes32(uint256(uint8(letter))); + + StoreSwitch.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); + } + + /** + * @notice Set value. + */ + function _setValue(address player, Letter letter, uint32 value) internal { + bytes32[] memory _keyTuple = new bytes32[](2); + _keyTuple[0] = bytes32(uint256(uint160(player))); + _keyTuple[1] = bytes32(uint256(uint8(letter))); + + StoreCore.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); + } + + /** + * @notice Set value. + */ + function set(address player, Letter letter, uint32 value) internal { + bytes32[] memory _keyTuple = new bytes32[](2); + _keyTuple[0] = bytes32(uint256(uint160(player))); + _keyTuple[1] = bytes32(uint256(uint8(letter))); + + StoreSwitch.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); + } + + /** + * @notice Set value. + */ + function _set(address player, Letter letter, uint32 value) internal { + bytes32[] memory _keyTuple = new bytes32[](2); + _keyTuple[0] = bytes32(uint256(uint160(player))); + _keyTuple[1] = bytes32(uint256(uint8(letter))); + + StoreCore.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); + } + + /** + * @notice Delete all data for given keys. + */ + function deleteRecord(address player, Letter letter) internal { + bytes32[] memory _keyTuple = new bytes32[](2); + _keyTuple[0] = bytes32(uint256(uint160(player))); + _keyTuple[1] = bytes32(uint256(uint8(letter))); + + StoreSwitch.deleteRecord(_tableId, _keyTuple); + } + + /** + * @notice Delete all data for given keys. + */ + function _deleteRecord(address player, Letter letter) internal { + bytes32[] memory _keyTuple = new bytes32[](2); + _keyTuple[0] = bytes32(uint256(uint160(player))); + _keyTuple[1] = bytes32(uint256(uint8(letter))); + + StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout); + } + + /** + * @notice Tightly pack static (fixed length) data using this table's schema. + * @return The static data, encoded into a sequence of bytes. + */ + function encodeStatic(uint32 value) internal pure returns (bytes memory) { + return abi.encodePacked(value); + } + + /** + * @notice Encode all of a record's fields. + * @return The static (fixed length) data, encoded into a sequence of bytes. + * @return The lengths of the dynamic fields (packed into a single bytes32 value). + * @return The dynamic (variable length) data, encoded into a sequence of bytes. + */ + function encode(uint32 value) internal pure returns (bytes memory, EncodedLengths, bytes memory) { + bytes memory _staticData = encodeStatic(value); + + EncodedLengths _encodedLengths; + bytes memory _dynamicData; + + return (_staticData, _encodedLengths, _dynamicData); + } + + /** + * @notice Encode keys as a bytes32 array using this table's field layout. + */ + function encodeKeyTuple(address player, Letter letter) internal pure returns (bytes32[] memory) { + bytes32[] memory _keyTuple = new bytes32[](2); + _keyTuple[0] = bytes32(uint256(uint160(player))); + _keyTuple[1] = bytes32(uint256(uint8(letter))); + + return _keyTuple; + } +} diff --git a/packages/game/src/codegen/tables/Points.sol b/packages/game/src/codegen/tables/Points.sol new file mode 100644 index 0000000..7930879 --- /dev/null +++ b/packages/game/src/codegen/tables/Points.sol @@ -0,0 +1,199 @@ +// SPDX-License-Identifier: MIT +pragma solidity >=0.8.24; + +/* Autogenerated file. Do not edit manually. */ + +// Import store internals +import { IStore } from "@latticexyz/store/src/IStore.sol"; +import { StoreSwitch } from "@latticexyz/store/src/StoreSwitch.sol"; +import { StoreCore } from "@latticexyz/store/src/StoreCore.sol"; +import { Bytes } from "@latticexyz/store/src/Bytes.sol"; +import { Memory } from "@latticexyz/store/src/Memory.sol"; +import { SliceLib } from "@latticexyz/store/src/Slice.sol"; +import { EncodeArray } from "@latticexyz/store/src/tightcoder/EncodeArray.sol"; +import { FieldLayout } from "@latticexyz/store/src/FieldLayout.sol"; +import { Schema } from "@latticexyz/store/src/Schema.sol"; +import { EncodedLengths, EncodedLengthsLib } from "@latticexyz/store/src/EncodedLengths.sol"; +import { ResourceId } from "@latticexyz/store/src/ResourceId.sol"; + +library Points { + // Hex below is the result of `WorldResourceIdLib.encode({ namespace: "words3", name: "Points", typeId: RESOURCE_TABLE });` + ResourceId constant _tableId = ResourceId.wrap(0x7462776f726473330000000000000000506f696e747300000000000000000000); + + FieldLayout constant _fieldLayout = + FieldLayout.wrap(0x0004010004000000000000000000000000000000000000000000000000000000); + + // Hex-encoded key schema of (address) + Schema constant _keySchema = Schema.wrap(0x0014010061000000000000000000000000000000000000000000000000000000); + // Hex-encoded value schema of (uint32) + Schema constant _valueSchema = Schema.wrap(0x0004010003000000000000000000000000000000000000000000000000000000); + + /** + * @notice Get the table's key field names. + * @return keyNames An array of strings with the names of key fields. + */ + function getKeyNames() internal pure returns (string[] memory keyNames) { + keyNames = new string[](1); + keyNames[0] = "player"; + } + + /** + * @notice Get the table's value field names. + * @return fieldNames An array of strings with the names of value fields. + */ + function getFieldNames() internal pure returns (string[] memory fieldNames) { + fieldNames = new string[](1); + fieldNames[0] = "value"; + } + + /** + * @notice Register the table with its config. + */ + function register() internal { + StoreSwitch.registerTable(_tableId, _fieldLayout, _keySchema, _valueSchema, getKeyNames(), getFieldNames()); + } + + /** + * @notice Register the table with its config. + */ + function _register() internal { + StoreCore.registerTable(_tableId, _fieldLayout, _keySchema, _valueSchema, getKeyNames(), getFieldNames()); + } + + /** + * @notice Get value. + */ + function getValue(address player) internal view returns (uint32 value) { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = bytes32(uint256(uint160(player))); + + bytes32 _blob = StoreSwitch.getStaticField(_tableId, _keyTuple, 0, _fieldLayout); + return (uint32(bytes4(_blob))); + } + + /** + * @notice Get value. + */ + function _getValue(address player) internal view returns (uint32 value) { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = bytes32(uint256(uint160(player))); + + bytes32 _blob = StoreCore.getStaticField(_tableId, _keyTuple, 0, _fieldLayout); + return (uint32(bytes4(_blob))); + } + + /** + * @notice Get value. + */ + function get(address player) internal view returns (uint32 value) { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = bytes32(uint256(uint160(player))); + + bytes32 _blob = StoreSwitch.getStaticField(_tableId, _keyTuple, 0, _fieldLayout); + return (uint32(bytes4(_blob))); + } + + /** + * @notice Get value. + */ + function _get(address player) internal view returns (uint32 value) { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = bytes32(uint256(uint160(player))); + + bytes32 _blob = StoreCore.getStaticField(_tableId, _keyTuple, 0, _fieldLayout); + return (uint32(bytes4(_blob))); + } + + /** + * @notice Set value. + */ + function setValue(address player, uint32 value) internal { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = bytes32(uint256(uint160(player))); + + StoreSwitch.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); + } + + /** + * @notice Set value. + */ + function _setValue(address player, uint32 value) internal { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = bytes32(uint256(uint160(player))); + + StoreCore.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); + } + + /** + * @notice Set value. + */ + function set(address player, uint32 value) internal { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = bytes32(uint256(uint160(player))); + + StoreSwitch.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); + } + + /** + * @notice Set value. + */ + function _set(address player, uint32 value) internal { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = bytes32(uint256(uint160(player))); + + StoreCore.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); + } + + /** + * @notice Delete all data for given keys. + */ + function deleteRecord(address player) internal { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = bytes32(uint256(uint160(player))); + + StoreSwitch.deleteRecord(_tableId, _keyTuple); + } + + /** + * @notice Delete all data for given keys. + */ + function _deleteRecord(address player) internal { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = bytes32(uint256(uint160(player))); + + StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout); + } + + /** + * @notice Tightly pack static (fixed length) data using this table's schema. + * @return The static data, encoded into a sequence of bytes. + */ + function encodeStatic(uint32 value) internal pure returns (bytes memory) { + return abi.encodePacked(value); + } + + /** + * @notice Encode all of a record's fields. + * @return The static (fixed length) data, encoded into a sequence of bytes. + * @return The lengths of the dynamic fields (packed into a single bytes32 value). + * @return The dynamic (variable length) data, encoded into a sequence of bytes. + */ + function encode(uint32 value) internal pure returns (bytes memory, EncodedLengths, bytes memory) { + bytes memory _staticData = encodeStatic(value); + + EncodedLengths _encodedLengths; + bytes memory _dynamicData; + + return (_staticData, _encodedLengths, _dynamicData); + } + + /** + * @notice Encode keys as a bytes32 array using this table's field layout. + */ + function encodeKeyTuple(address player) internal pure returns (bytes32[] memory) { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = bytes32(uint256(uint160(player))); + + return _keyTuple; + } +} diff --git a/packages/game/src/codegen/tables/PointsClaimed.sol b/packages/game/src/codegen/tables/PointsClaimed.sol new file mode 100644 index 0000000..42079af --- /dev/null +++ b/packages/game/src/codegen/tables/PointsClaimed.sol @@ -0,0 +1,304 @@ +// SPDX-License-Identifier: MIT +pragma solidity >=0.8.24; + +/* Autogenerated file. Do not edit manually. */ + +// Import store internals +import { IStore } from "@latticexyz/store/src/IStore.sol"; +import { StoreSwitch } from "@latticexyz/store/src/StoreSwitch.sol"; +import { StoreCore } from "@latticexyz/store/src/StoreCore.sol"; +import { Bytes } from "@latticexyz/store/src/Bytes.sol"; +import { Memory } from "@latticexyz/store/src/Memory.sol"; +import { SliceLib } from "@latticexyz/store/src/Slice.sol"; +import { EncodeArray } from "@latticexyz/store/src/tightcoder/EncodeArray.sol"; +import { FieldLayout } from "@latticexyz/store/src/FieldLayout.sol"; +import { Schema } from "@latticexyz/store/src/Schema.sol"; +import { EncodedLengths, EncodedLengthsLib } from "@latticexyz/store/src/EncodedLengths.sol"; +import { ResourceId } from "@latticexyz/store/src/ResourceId.sol"; + +struct PointsClaimedData { + address player; + uint32 points; + uint256 value; + uint256 timestamp; +} + +library PointsClaimed { + // Hex below is the result of `WorldResourceIdLib.encode({ namespace: "words3", name: "PointsClaimed", typeId: RESOURCE_OFFCHAIN_TABLE });` + ResourceId constant _tableId = ResourceId.wrap(0x6f74776f726473330000000000000000506f696e7473436c61696d6564000000); + + FieldLayout constant _fieldLayout = + FieldLayout.wrap(0x0058040014042020000000000000000000000000000000000000000000000000); + + // Hex-encoded key schema of (uint256) + Schema constant _keySchema = Schema.wrap(0x002001001f000000000000000000000000000000000000000000000000000000); + // Hex-encoded value schema of (address, uint32, uint256, uint256) + Schema constant _valueSchema = Schema.wrap(0x0058040061031f1f000000000000000000000000000000000000000000000000); + + /** + * @notice Get the table's key field names. + * @return keyNames An array of strings with the names of key fields. + */ + function getKeyNames() internal pure returns (string[] memory keyNames) { + keyNames = new string[](1); + keyNames[0] = "id"; + } + + /** + * @notice Get the table's value field names. + * @return fieldNames An array of strings with the names of value fields. + */ + function getFieldNames() internal pure returns (string[] memory fieldNames) { + fieldNames = new string[](4); + fieldNames[0] = "player"; + fieldNames[1] = "points"; + fieldNames[2] = "value"; + fieldNames[3] = "timestamp"; + } + + /** + * @notice Register the table with its config. + */ + function register() internal { + StoreSwitch.registerTable(_tableId, _fieldLayout, _keySchema, _valueSchema, getKeyNames(), getFieldNames()); + } + + /** + * @notice Register the table with its config. + */ + function _register() internal { + StoreCore.registerTable(_tableId, _fieldLayout, _keySchema, _valueSchema, getKeyNames(), getFieldNames()); + } + + /** + * @notice Set player. + */ + function setPlayer(uint256 id, address player) internal { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = bytes32(uint256(id)); + + StoreSwitch.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((player)), _fieldLayout); + } + + /** + * @notice Set player. + */ + function _setPlayer(uint256 id, address player) internal { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = bytes32(uint256(id)); + + StoreCore.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((player)), _fieldLayout); + } + + /** + * @notice Set points. + */ + function setPoints(uint256 id, uint32 points) internal { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = bytes32(uint256(id)); + + StoreSwitch.setStaticField(_tableId, _keyTuple, 1, abi.encodePacked((points)), _fieldLayout); + } + + /** + * @notice Set points. + */ + function _setPoints(uint256 id, uint32 points) internal { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = bytes32(uint256(id)); + + StoreCore.setStaticField(_tableId, _keyTuple, 1, abi.encodePacked((points)), _fieldLayout); + } + + /** + * @notice Set value. + */ + function setValue(uint256 id, uint256 value) internal { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = bytes32(uint256(id)); + + StoreSwitch.setStaticField(_tableId, _keyTuple, 2, abi.encodePacked((value)), _fieldLayout); + } + + /** + * @notice Set value. + */ + function _setValue(uint256 id, uint256 value) internal { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = bytes32(uint256(id)); + + StoreCore.setStaticField(_tableId, _keyTuple, 2, abi.encodePacked((value)), _fieldLayout); + } + + /** + * @notice Set timestamp. + */ + function setTimestamp(uint256 id, uint256 timestamp) internal { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = bytes32(uint256(id)); + + StoreSwitch.setStaticField(_tableId, _keyTuple, 3, abi.encodePacked((timestamp)), _fieldLayout); + } + + /** + * @notice Set timestamp. + */ + function _setTimestamp(uint256 id, uint256 timestamp) internal { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = bytes32(uint256(id)); + + StoreCore.setStaticField(_tableId, _keyTuple, 3, abi.encodePacked((timestamp)), _fieldLayout); + } + + /** + * @notice Set the full data using individual values. + */ + function set(uint256 id, address player, uint32 points, uint256 value, uint256 timestamp) internal { + bytes memory _staticData = encodeStatic(player, points, value, timestamp); + + EncodedLengths _encodedLengths; + bytes memory _dynamicData; + + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = bytes32(uint256(id)); + + StoreSwitch.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); + } + + /** + * @notice Set the full data using individual values. + */ + function _set(uint256 id, address player, uint32 points, uint256 value, uint256 timestamp) internal { + bytes memory _staticData = encodeStatic(player, points, value, timestamp); + + EncodedLengths _encodedLengths; + bytes memory _dynamicData; + + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = bytes32(uint256(id)); + + StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); + } + + /** + * @notice Set the full data using the data struct. + */ + function set(uint256 id, PointsClaimedData memory _table) internal { + bytes memory _staticData = encodeStatic(_table.player, _table.points, _table.value, _table.timestamp); + + EncodedLengths _encodedLengths; + bytes memory _dynamicData; + + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = bytes32(uint256(id)); + + StoreSwitch.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); + } + + /** + * @notice Set the full data using the data struct. + */ + function _set(uint256 id, PointsClaimedData memory _table) internal { + bytes memory _staticData = encodeStatic(_table.player, _table.points, _table.value, _table.timestamp); + + EncodedLengths _encodedLengths; + bytes memory _dynamicData; + + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = bytes32(uint256(id)); + + StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); + } + + /** + * @notice Decode the tightly packed blob of static data using this table's field layout. + */ + function decodeStatic( + bytes memory _blob + ) internal pure returns (address player, uint32 points, uint256 value, uint256 timestamp) { + player = (address(Bytes.getBytes20(_blob, 0))); + + points = (uint32(Bytes.getBytes4(_blob, 20))); + + value = (uint256(Bytes.getBytes32(_blob, 24))); + + timestamp = (uint256(Bytes.getBytes32(_blob, 56))); + } + + /** + * @notice Decode the tightly packed blobs using this table's field layout. + * @param _staticData Tightly packed static fields. + * + * + */ + function decode( + bytes memory _staticData, + EncodedLengths, + bytes memory + ) internal pure returns (PointsClaimedData memory _table) { + (_table.player, _table.points, _table.value, _table.timestamp) = decodeStatic(_staticData); + } + + /** + * @notice Delete all data for given keys. + */ + function deleteRecord(uint256 id) internal { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = bytes32(uint256(id)); + + StoreSwitch.deleteRecord(_tableId, _keyTuple); + } + + /** + * @notice Delete all data for given keys. + */ + function _deleteRecord(uint256 id) internal { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = bytes32(uint256(id)); + + StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout); + } + + /** + * @notice Tightly pack static (fixed length) data using this table's schema. + * @return The static data, encoded into a sequence of bytes. + */ + function encodeStatic( + address player, + uint32 points, + uint256 value, + uint256 timestamp + ) internal pure returns (bytes memory) { + return abi.encodePacked(player, points, value, timestamp); + } + + /** + * @notice Encode all of a record's fields. + * @return The static (fixed length) data, encoded into a sequence of bytes. + * @return The lengths of the dynamic fields (packed into a single bytes32 value). + * @return The dynamic (variable length) data, encoded into a sequence of bytes. + */ + function encode( + address player, + uint32 points, + uint256 value, + uint256 timestamp + ) internal pure returns (bytes memory, EncodedLengths, bytes memory) { + bytes memory _staticData = encodeStatic(player, points, value, timestamp); + + EncodedLengths _encodedLengths; + bytes memory _dynamicData; + + return (_staticData, _encodedLengths, _dynamicData); + } + + /** + * @notice Encode keys as a bytes32 array using this table's field layout. + */ + function encodeKeyTuple(uint256 id) internal pure returns (bytes32[] memory) { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = bytes32(uint256(id)); + + return _keyTuple; + } +} diff --git a/packages/game/src/codegen/tables/PointsResult.sol b/packages/game/src/codegen/tables/PointsResult.sol new file mode 100644 index 0000000..2f609a7 --- /dev/null +++ b/packages/game/src/codegen/tables/PointsResult.sol @@ -0,0 +1,256 @@ +// SPDX-License-Identifier: MIT +pragma solidity >=0.8.24; + +/* Autogenerated file. Do not edit manually. */ + +// Import store internals +import { IStore } from "@latticexyz/store/src/IStore.sol"; +import { StoreSwitch } from "@latticexyz/store/src/StoreSwitch.sol"; +import { StoreCore } from "@latticexyz/store/src/StoreCore.sol"; +import { Bytes } from "@latticexyz/store/src/Bytes.sol"; +import { Memory } from "@latticexyz/store/src/Memory.sol"; +import { SliceLib } from "@latticexyz/store/src/Slice.sol"; +import { EncodeArray } from "@latticexyz/store/src/tightcoder/EncodeArray.sol"; +import { FieldLayout } from "@latticexyz/store/src/FieldLayout.sol"; +import { Schema } from "@latticexyz/store/src/Schema.sol"; +import { EncodedLengths, EncodedLengthsLib } from "@latticexyz/store/src/EncodedLengths.sol"; +import { ResourceId } from "@latticexyz/store/src/ResourceId.sol"; + +struct PointsResultData { + address player; + uint32 points; +} + +library PointsResult { + // Hex below is the result of `WorldResourceIdLib.encode({ namespace: "words3", name: "PointsResult", typeId: RESOURCE_OFFCHAIN_TABLE });` + ResourceId constant _tableId = ResourceId.wrap(0x6f74776f726473330000000000000000506f696e7473526573756c7400000000); + + FieldLayout constant _fieldLayout = + FieldLayout.wrap(0x0018020014040000000000000000000000000000000000000000000000000000); + + // Hex-encoded key schema of (uint256, int16) + Schema constant _keySchema = Schema.wrap(0x002202001f210000000000000000000000000000000000000000000000000000); + // Hex-encoded value schema of (address, uint32) + Schema constant _valueSchema = Schema.wrap(0x0018020061030000000000000000000000000000000000000000000000000000); + + /** + * @notice Get the table's key field names. + * @return keyNames An array of strings with the names of key fields. + */ + function getKeyNames() internal pure returns (string[] memory keyNames) { + keyNames = new string[](2); + keyNames[0] = "id"; + keyNames[1] = "pointsId"; + } + + /** + * @notice Get the table's value field names. + * @return fieldNames An array of strings with the names of value fields. + */ + function getFieldNames() internal pure returns (string[] memory fieldNames) { + fieldNames = new string[](2); + fieldNames[0] = "player"; + fieldNames[1] = "points"; + } + + /** + * @notice Register the table with its config. + */ + function register() internal { + StoreSwitch.registerTable(_tableId, _fieldLayout, _keySchema, _valueSchema, getKeyNames(), getFieldNames()); + } + + /** + * @notice Register the table with its config. + */ + function _register() internal { + StoreCore.registerTable(_tableId, _fieldLayout, _keySchema, _valueSchema, getKeyNames(), getFieldNames()); + } + + /** + * @notice Set player. + */ + function setPlayer(uint256 id, int16 pointsId, address player) internal { + bytes32[] memory _keyTuple = new bytes32[](2); + _keyTuple[0] = bytes32(uint256(id)); + _keyTuple[1] = bytes32(uint256(int256(pointsId))); + + StoreSwitch.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((player)), _fieldLayout); + } + + /** + * @notice Set player. + */ + function _setPlayer(uint256 id, int16 pointsId, address player) internal { + bytes32[] memory _keyTuple = new bytes32[](2); + _keyTuple[0] = bytes32(uint256(id)); + _keyTuple[1] = bytes32(uint256(int256(pointsId))); + + StoreCore.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((player)), _fieldLayout); + } + + /** + * @notice Set points. + */ + function setPoints(uint256 id, int16 pointsId, uint32 points) internal { + bytes32[] memory _keyTuple = new bytes32[](2); + _keyTuple[0] = bytes32(uint256(id)); + _keyTuple[1] = bytes32(uint256(int256(pointsId))); + + StoreSwitch.setStaticField(_tableId, _keyTuple, 1, abi.encodePacked((points)), _fieldLayout); + } + + /** + * @notice Set points. + */ + function _setPoints(uint256 id, int16 pointsId, uint32 points) internal { + bytes32[] memory _keyTuple = new bytes32[](2); + _keyTuple[0] = bytes32(uint256(id)); + _keyTuple[1] = bytes32(uint256(int256(pointsId))); + + StoreCore.setStaticField(_tableId, _keyTuple, 1, abi.encodePacked((points)), _fieldLayout); + } + + /** + * @notice Set the full data using individual values. + */ + function set(uint256 id, int16 pointsId, address player, uint32 points) internal { + bytes memory _staticData = encodeStatic(player, points); + + EncodedLengths _encodedLengths; + bytes memory _dynamicData; + + bytes32[] memory _keyTuple = new bytes32[](2); + _keyTuple[0] = bytes32(uint256(id)); + _keyTuple[1] = bytes32(uint256(int256(pointsId))); + + StoreSwitch.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); + } + + /** + * @notice Set the full data using individual values. + */ + function _set(uint256 id, int16 pointsId, address player, uint32 points) internal { + bytes memory _staticData = encodeStatic(player, points); + + EncodedLengths _encodedLengths; + bytes memory _dynamicData; + + bytes32[] memory _keyTuple = new bytes32[](2); + _keyTuple[0] = bytes32(uint256(id)); + _keyTuple[1] = bytes32(uint256(int256(pointsId))); + + StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); + } + + /** + * @notice Set the full data using the data struct. + */ + function set(uint256 id, int16 pointsId, PointsResultData memory _table) internal { + bytes memory _staticData = encodeStatic(_table.player, _table.points); + + EncodedLengths _encodedLengths; + bytes memory _dynamicData; + + bytes32[] memory _keyTuple = new bytes32[](2); + _keyTuple[0] = bytes32(uint256(id)); + _keyTuple[1] = bytes32(uint256(int256(pointsId))); + + StoreSwitch.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); + } + + /** + * @notice Set the full data using the data struct. + */ + function _set(uint256 id, int16 pointsId, PointsResultData memory _table) internal { + bytes memory _staticData = encodeStatic(_table.player, _table.points); + + EncodedLengths _encodedLengths; + bytes memory _dynamicData; + + bytes32[] memory _keyTuple = new bytes32[](2); + _keyTuple[0] = bytes32(uint256(id)); + _keyTuple[1] = bytes32(uint256(int256(pointsId))); + + StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); + } + + /** + * @notice Decode the tightly packed blob of static data using this table's field layout. + */ + function decodeStatic(bytes memory _blob) internal pure returns (address player, uint32 points) { + player = (address(Bytes.getBytes20(_blob, 0))); + + points = (uint32(Bytes.getBytes4(_blob, 20))); + } + + /** + * @notice Decode the tightly packed blobs using this table's field layout. + * @param _staticData Tightly packed static fields. + * + * + */ + function decode( + bytes memory _staticData, + EncodedLengths, + bytes memory + ) internal pure returns (PointsResultData memory _table) { + (_table.player, _table.points) = decodeStatic(_staticData); + } + + /** + * @notice Delete all data for given keys. + */ + function deleteRecord(uint256 id, int16 pointsId) internal { + bytes32[] memory _keyTuple = new bytes32[](2); + _keyTuple[0] = bytes32(uint256(id)); + _keyTuple[1] = bytes32(uint256(int256(pointsId))); + + StoreSwitch.deleteRecord(_tableId, _keyTuple); + } + + /** + * @notice Delete all data for given keys. + */ + function _deleteRecord(uint256 id, int16 pointsId) internal { + bytes32[] memory _keyTuple = new bytes32[](2); + _keyTuple[0] = bytes32(uint256(id)); + _keyTuple[1] = bytes32(uint256(int256(pointsId))); + + StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout); + } + + /** + * @notice Tightly pack static (fixed length) data using this table's schema. + * @return The static data, encoded into a sequence of bytes. + */ + function encodeStatic(address player, uint32 points) internal pure returns (bytes memory) { + return abi.encodePacked(player, points); + } + + /** + * @notice Encode all of a record's fields. + * @return The static (fixed length) data, encoded into a sequence of bytes. + * @return The lengths of the dynamic fields (packed into a single bytes32 value). + * @return The dynamic (variable length) data, encoded into a sequence of bytes. + */ + function encode(address player, uint32 points) internal pure returns (bytes memory, EncodedLengths, bytes memory) { + bytes memory _staticData = encodeStatic(player, points); + + EncodedLengths _encodedLengths; + bytes memory _dynamicData; + + return (_staticData, _encodedLengths, _dynamicData); + } + + /** + * @notice Encode keys as a bytes32 array using this table's field layout. + */ + function encodeKeyTuple(uint256 id, int16 pointsId) internal pure returns (bytes32[] memory) { + bytes32[] memory _keyTuple = new bytes32[](2); + _keyTuple[0] = bytes32(uint256(id)); + _keyTuple[1] = bytes32(uint256(int256(pointsId))); + + return _keyTuple; + } +} diff --git a/packages/game/src/codegen/tables/Spent.sol b/packages/game/src/codegen/tables/Spent.sol new file mode 100644 index 0000000..2650442 --- /dev/null +++ b/packages/game/src/codegen/tables/Spent.sol @@ -0,0 +1,199 @@ +// SPDX-License-Identifier: MIT +pragma solidity >=0.8.24; + +/* Autogenerated file. Do not edit manually. */ + +// Import store internals +import { IStore } from "@latticexyz/store/src/IStore.sol"; +import { StoreSwitch } from "@latticexyz/store/src/StoreSwitch.sol"; +import { StoreCore } from "@latticexyz/store/src/StoreCore.sol"; +import { Bytes } from "@latticexyz/store/src/Bytes.sol"; +import { Memory } from "@latticexyz/store/src/Memory.sol"; +import { SliceLib } from "@latticexyz/store/src/Slice.sol"; +import { EncodeArray } from "@latticexyz/store/src/tightcoder/EncodeArray.sol"; +import { FieldLayout } from "@latticexyz/store/src/FieldLayout.sol"; +import { Schema } from "@latticexyz/store/src/Schema.sol"; +import { EncodedLengths, EncodedLengthsLib } from "@latticexyz/store/src/EncodedLengths.sol"; +import { ResourceId } from "@latticexyz/store/src/ResourceId.sol"; + +library Spent { + // Hex below is the result of `WorldResourceIdLib.encode({ namespace: "words3", name: "Spent", typeId: RESOURCE_TABLE });` + ResourceId constant _tableId = ResourceId.wrap(0x7462776f7264733300000000000000005370656e740000000000000000000000); + + FieldLayout constant _fieldLayout = + FieldLayout.wrap(0x0020010020000000000000000000000000000000000000000000000000000000); + + // Hex-encoded key schema of (address) + Schema constant _keySchema = Schema.wrap(0x0014010061000000000000000000000000000000000000000000000000000000); + // Hex-encoded value schema of (uint256) + Schema constant _valueSchema = Schema.wrap(0x002001001f000000000000000000000000000000000000000000000000000000); + + /** + * @notice Get the table's key field names. + * @return keyNames An array of strings with the names of key fields. + */ + function getKeyNames() internal pure returns (string[] memory keyNames) { + keyNames = new string[](1); + keyNames[0] = "player"; + } + + /** + * @notice Get the table's value field names. + * @return fieldNames An array of strings with the names of value fields. + */ + function getFieldNames() internal pure returns (string[] memory fieldNames) { + fieldNames = new string[](1); + fieldNames[0] = "value"; + } + + /** + * @notice Register the table with its config. + */ + function register() internal { + StoreSwitch.registerTable(_tableId, _fieldLayout, _keySchema, _valueSchema, getKeyNames(), getFieldNames()); + } + + /** + * @notice Register the table with its config. + */ + function _register() internal { + StoreCore.registerTable(_tableId, _fieldLayout, _keySchema, _valueSchema, getKeyNames(), getFieldNames()); + } + + /** + * @notice Get value. + */ + function getValue(address player) internal view returns (uint256 value) { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = bytes32(uint256(uint160(player))); + + bytes32 _blob = StoreSwitch.getStaticField(_tableId, _keyTuple, 0, _fieldLayout); + return (uint256(bytes32(_blob))); + } + + /** + * @notice Get value. + */ + function _getValue(address player) internal view returns (uint256 value) { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = bytes32(uint256(uint160(player))); + + bytes32 _blob = StoreCore.getStaticField(_tableId, _keyTuple, 0, _fieldLayout); + return (uint256(bytes32(_blob))); + } + + /** + * @notice Get value. + */ + function get(address player) internal view returns (uint256 value) { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = bytes32(uint256(uint160(player))); + + bytes32 _blob = StoreSwitch.getStaticField(_tableId, _keyTuple, 0, _fieldLayout); + return (uint256(bytes32(_blob))); + } + + /** + * @notice Get value. + */ + function _get(address player) internal view returns (uint256 value) { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = bytes32(uint256(uint160(player))); + + bytes32 _blob = StoreCore.getStaticField(_tableId, _keyTuple, 0, _fieldLayout); + return (uint256(bytes32(_blob))); + } + + /** + * @notice Set value. + */ + function setValue(address player, uint256 value) internal { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = bytes32(uint256(uint160(player))); + + StoreSwitch.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); + } + + /** + * @notice Set value. + */ + function _setValue(address player, uint256 value) internal { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = bytes32(uint256(uint160(player))); + + StoreCore.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); + } + + /** + * @notice Set value. + */ + function set(address player, uint256 value) internal { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = bytes32(uint256(uint160(player))); + + StoreSwitch.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); + } + + /** + * @notice Set value. + */ + function _set(address player, uint256 value) internal { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = bytes32(uint256(uint160(player))); + + StoreCore.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); + } + + /** + * @notice Delete all data for given keys. + */ + function deleteRecord(address player) internal { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = bytes32(uint256(uint160(player))); + + StoreSwitch.deleteRecord(_tableId, _keyTuple); + } + + /** + * @notice Delete all data for given keys. + */ + function _deleteRecord(address player) internal { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = bytes32(uint256(uint160(player))); + + StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout); + } + + /** + * @notice Tightly pack static (fixed length) data using this table's schema. + * @return The static data, encoded into a sequence of bytes. + */ + function encodeStatic(uint256 value) internal pure returns (bytes memory) { + return abi.encodePacked(value); + } + + /** + * @notice Encode all of a record's fields. + * @return The static (fixed length) data, encoded into a sequence of bytes. + * @return The lengths of the dynamic fields (packed into a single bytes32 value). + * @return The dynamic (variable length) data, encoded into a sequence of bytes. + */ + function encode(uint256 value) internal pure returns (bytes memory, EncodedLengths, bytes memory) { + bytes memory _staticData = encodeStatic(value); + + EncodedLengths _encodedLengths; + bytes memory _dynamicData; + + return (_staticData, _encodedLengths, _dynamicData); + } + + /** + * @notice Encode keys as a bytes32 array using this table's field layout. + */ + function encodeKeyTuple(address player) internal pure returns (bytes32[] memory) { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = bytes32(uint256(uint160(player))); + + return _keyTuple; + } +} diff --git a/packages/game/src/codegen/tables/TileLetter.sol b/packages/game/src/codegen/tables/TileLetter.sol new file mode 100644 index 0000000..895694e --- /dev/null +++ b/packages/game/src/codegen/tables/TileLetter.sol @@ -0,0 +1,214 @@ +// SPDX-License-Identifier: MIT +pragma solidity >=0.8.24; + +/* Autogenerated file. Do not edit manually. */ + +// Import store internals +import { IStore } from "@latticexyz/store/src/IStore.sol"; +import { StoreSwitch } from "@latticexyz/store/src/StoreSwitch.sol"; +import { StoreCore } from "@latticexyz/store/src/StoreCore.sol"; +import { Bytes } from "@latticexyz/store/src/Bytes.sol"; +import { Memory } from "@latticexyz/store/src/Memory.sol"; +import { SliceLib } from "@latticexyz/store/src/Slice.sol"; +import { EncodeArray } from "@latticexyz/store/src/tightcoder/EncodeArray.sol"; +import { FieldLayout } from "@latticexyz/store/src/FieldLayout.sol"; +import { Schema } from "@latticexyz/store/src/Schema.sol"; +import { EncodedLengths, EncodedLengthsLib } from "@latticexyz/store/src/EncodedLengths.sol"; +import { ResourceId } from "@latticexyz/store/src/ResourceId.sol"; + +// Import user types +import { Letter } from "./../common.sol"; + +library TileLetter { + // Hex below is the result of `WorldResourceIdLib.encode({ namespace: "words3", name: "TileLetter", typeId: RESOURCE_TABLE });` + ResourceId constant _tableId = ResourceId.wrap(0x7462776f72647333000000000000000054696c654c6574746572000000000000); + + FieldLayout constant _fieldLayout = + FieldLayout.wrap(0x0001010001000000000000000000000000000000000000000000000000000000); + + // Hex-encoded key schema of (int32, int32) + Schema constant _keySchema = Schema.wrap(0x0008020023230000000000000000000000000000000000000000000000000000); + // Hex-encoded value schema of (uint8) + Schema constant _valueSchema = Schema.wrap(0x0001010000000000000000000000000000000000000000000000000000000000); + + /** + * @notice Get the table's key field names. + * @return keyNames An array of strings with the names of key fields. + */ + function getKeyNames() internal pure returns (string[] memory keyNames) { + keyNames = new string[](2); + keyNames[0] = "x"; + keyNames[1] = "y"; + } + + /** + * @notice Get the table's value field names. + * @return fieldNames An array of strings with the names of value fields. + */ + function getFieldNames() internal pure returns (string[] memory fieldNames) { + fieldNames = new string[](1); + fieldNames[0] = "value"; + } + + /** + * @notice Register the table with its config. + */ + function register() internal { + StoreSwitch.registerTable(_tableId, _fieldLayout, _keySchema, _valueSchema, getKeyNames(), getFieldNames()); + } + + /** + * @notice Register the table with its config. + */ + function _register() internal { + StoreCore.registerTable(_tableId, _fieldLayout, _keySchema, _valueSchema, getKeyNames(), getFieldNames()); + } + + /** + * @notice Get value. + */ + function getValue(int32 x, int32 y) internal view returns (Letter value) { + bytes32[] memory _keyTuple = new bytes32[](2); + _keyTuple[0] = bytes32(uint256(int256(x))); + _keyTuple[1] = bytes32(uint256(int256(y))); + + bytes32 _blob = StoreSwitch.getStaticField(_tableId, _keyTuple, 0, _fieldLayout); + return Letter(uint8(bytes1(_blob))); + } + + /** + * @notice Get value. + */ + function _getValue(int32 x, int32 y) internal view returns (Letter value) { + bytes32[] memory _keyTuple = new bytes32[](2); + _keyTuple[0] = bytes32(uint256(int256(x))); + _keyTuple[1] = bytes32(uint256(int256(y))); + + bytes32 _blob = StoreCore.getStaticField(_tableId, _keyTuple, 0, _fieldLayout); + return Letter(uint8(bytes1(_blob))); + } + + /** + * @notice Get value. + */ + function get(int32 x, int32 y) internal view returns (Letter value) { + bytes32[] memory _keyTuple = new bytes32[](2); + _keyTuple[0] = bytes32(uint256(int256(x))); + _keyTuple[1] = bytes32(uint256(int256(y))); + + bytes32 _blob = StoreSwitch.getStaticField(_tableId, _keyTuple, 0, _fieldLayout); + return Letter(uint8(bytes1(_blob))); + } + + /** + * @notice Get value. + */ + function _get(int32 x, int32 y) internal view returns (Letter value) { + bytes32[] memory _keyTuple = new bytes32[](2); + _keyTuple[0] = bytes32(uint256(int256(x))); + _keyTuple[1] = bytes32(uint256(int256(y))); + + bytes32 _blob = StoreCore.getStaticField(_tableId, _keyTuple, 0, _fieldLayout); + return Letter(uint8(bytes1(_blob))); + } + + /** + * @notice Set value. + */ + function setValue(int32 x, int32 y, Letter value) internal { + bytes32[] memory _keyTuple = new bytes32[](2); + _keyTuple[0] = bytes32(uint256(int256(x))); + _keyTuple[1] = bytes32(uint256(int256(y))); + + StoreSwitch.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked(uint8(value)), _fieldLayout); + } + + /** + * @notice Set value. + */ + function _setValue(int32 x, int32 y, Letter value) internal { + bytes32[] memory _keyTuple = new bytes32[](2); + _keyTuple[0] = bytes32(uint256(int256(x))); + _keyTuple[1] = bytes32(uint256(int256(y))); + + StoreCore.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked(uint8(value)), _fieldLayout); + } + + /** + * @notice Set value. + */ + function set(int32 x, int32 y, Letter value) internal { + bytes32[] memory _keyTuple = new bytes32[](2); + _keyTuple[0] = bytes32(uint256(int256(x))); + _keyTuple[1] = bytes32(uint256(int256(y))); + + StoreSwitch.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked(uint8(value)), _fieldLayout); + } + + /** + * @notice Set value. + */ + function _set(int32 x, int32 y, Letter value) internal { + bytes32[] memory _keyTuple = new bytes32[](2); + _keyTuple[0] = bytes32(uint256(int256(x))); + _keyTuple[1] = bytes32(uint256(int256(y))); + + StoreCore.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked(uint8(value)), _fieldLayout); + } + + /** + * @notice Delete all data for given keys. + */ + function deleteRecord(int32 x, int32 y) internal { + bytes32[] memory _keyTuple = new bytes32[](2); + _keyTuple[0] = bytes32(uint256(int256(x))); + _keyTuple[1] = bytes32(uint256(int256(y))); + + StoreSwitch.deleteRecord(_tableId, _keyTuple); + } + + /** + * @notice Delete all data for given keys. + */ + function _deleteRecord(int32 x, int32 y) internal { + bytes32[] memory _keyTuple = new bytes32[](2); + _keyTuple[0] = bytes32(uint256(int256(x))); + _keyTuple[1] = bytes32(uint256(int256(y))); + + StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout); + } + + /** + * @notice Tightly pack static (fixed length) data using this table's schema. + * @return The static data, encoded into a sequence of bytes. + */ + function encodeStatic(Letter value) internal pure returns (bytes memory) { + return abi.encodePacked(value); + } + + /** + * @notice Encode all of a record's fields. + * @return The static (fixed length) data, encoded into a sequence of bytes. + * @return The lengths of the dynamic fields (packed into a single bytes32 value). + * @return The dynamic (variable length) data, encoded into a sequence of bytes. + */ + function encode(Letter value) internal pure returns (bytes memory, EncodedLengths, bytes memory) { + bytes memory _staticData = encodeStatic(value); + + EncodedLengths _encodedLengths; + bytes memory _dynamicData; + + return (_staticData, _encodedLengths, _dynamicData); + } + + /** + * @notice Encode keys as a bytes32 array using this table's field layout. + */ + function encodeKeyTuple(int32 x, int32 y) internal pure returns (bytes32[] memory) { + bytes32[] memory _keyTuple = new bytes32[](2); + _keyTuple[0] = bytes32(uint256(int256(x))); + _keyTuple[1] = bytes32(uint256(int256(y))); + + return _keyTuple; + } +} diff --git a/packages/game/src/codegen/tables/TilePlayer.sol b/packages/game/src/codegen/tables/TilePlayer.sol new file mode 100644 index 0000000..d0aa685 --- /dev/null +++ b/packages/game/src/codegen/tables/TilePlayer.sol @@ -0,0 +1,211 @@ +// SPDX-License-Identifier: MIT +pragma solidity >=0.8.24; + +/* Autogenerated file. Do not edit manually. */ + +// Import store internals +import { IStore } from "@latticexyz/store/src/IStore.sol"; +import { StoreSwitch } from "@latticexyz/store/src/StoreSwitch.sol"; +import { StoreCore } from "@latticexyz/store/src/StoreCore.sol"; +import { Bytes } from "@latticexyz/store/src/Bytes.sol"; +import { Memory } from "@latticexyz/store/src/Memory.sol"; +import { SliceLib } from "@latticexyz/store/src/Slice.sol"; +import { EncodeArray } from "@latticexyz/store/src/tightcoder/EncodeArray.sol"; +import { FieldLayout } from "@latticexyz/store/src/FieldLayout.sol"; +import { Schema } from "@latticexyz/store/src/Schema.sol"; +import { EncodedLengths, EncodedLengthsLib } from "@latticexyz/store/src/EncodedLengths.sol"; +import { ResourceId } from "@latticexyz/store/src/ResourceId.sol"; + +library TilePlayer { + // Hex below is the result of `WorldResourceIdLib.encode({ namespace: "words3", name: "TilePlayer", typeId: RESOURCE_TABLE });` + ResourceId constant _tableId = ResourceId.wrap(0x7462776f72647333000000000000000054696c65506c61796572000000000000); + + FieldLayout constant _fieldLayout = + FieldLayout.wrap(0x0014010014000000000000000000000000000000000000000000000000000000); + + // Hex-encoded key schema of (int32, int32) + Schema constant _keySchema = Schema.wrap(0x0008020023230000000000000000000000000000000000000000000000000000); + // Hex-encoded value schema of (address) + Schema constant _valueSchema = Schema.wrap(0x0014010061000000000000000000000000000000000000000000000000000000); + + /** + * @notice Get the table's key field names. + * @return keyNames An array of strings with the names of key fields. + */ + function getKeyNames() internal pure returns (string[] memory keyNames) { + keyNames = new string[](2); + keyNames[0] = "x"; + keyNames[1] = "y"; + } + + /** + * @notice Get the table's value field names. + * @return fieldNames An array of strings with the names of value fields. + */ + function getFieldNames() internal pure returns (string[] memory fieldNames) { + fieldNames = new string[](1); + fieldNames[0] = "value"; + } + + /** + * @notice Register the table with its config. + */ + function register() internal { + StoreSwitch.registerTable(_tableId, _fieldLayout, _keySchema, _valueSchema, getKeyNames(), getFieldNames()); + } + + /** + * @notice Register the table with its config. + */ + function _register() internal { + StoreCore.registerTable(_tableId, _fieldLayout, _keySchema, _valueSchema, getKeyNames(), getFieldNames()); + } + + /** + * @notice Get value. + */ + function getValue(int32 x, int32 y) internal view returns (address value) { + bytes32[] memory _keyTuple = new bytes32[](2); + _keyTuple[0] = bytes32(uint256(int256(x))); + _keyTuple[1] = bytes32(uint256(int256(y))); + + bytes32 _blob = StoreSwitch.getStaticField(_tableId, _keyTuple, 0, _fieldLayout); + return (address(bytes20(_blob))); + } + + /** + * @notice Get value. + */ + function _getValue(int32 x, int32 y) internal view returns (address value) { + bytes32[] memory _keyTuple = new bytes32[](2); + _keyTuple[0] = bytes32(uint256(int256(x))); + _keyTuple[1] = bytes32(uint256(int256(y))); + + bytes32 _blob = StoreCore.getStaticField(_tableId, _keyTuple, 0, _fieldLayout); + return (address(bytes20(_blob))); + } + + /** + * @notice Get value. + */ + function get(int32 x, int32 y) internal view returns (address value) { + bytes32[] memory _keyTuple = new bytes32[](2); + _keyTuple[0] = bytes32(uint256(int256(x))); + _keyTuple[1] = bytes32(uint256(int256(y))); + + bytes32 _blob = StoreSwitch.getStaticField(_tableId, _keyTuple, 0, _fieldLayout); + return (address(bytes20(_blob))); + } + + /** + * @notice Get value. + */ + function _get(int32 x, int32 y) internal view returns (address value) { + bytes32[] memory _keyTuple = new bytes32[](2); + _keyTuple[0] = bytes32(uint256(int256(x))); + _keyTuple[1] = bytes32(uint256(int256(y))); + + bytes32 _blob = StoreCore.getStaticField(_tableId, _keyTuple, 0, _fieldLayout); + return (address(bytes20(_blob))); + } + + /** + * @notice Set value. + */ + function setValue(int32 x, int32 y, address value) internal { + bytes32[] memory _keyTuple = new bytes32[](2); + _keyTuple[0] = bytes32(uint256(int256(x))); + _keyTuple[1] = bytes32(uint256(int256(y))); + + StoreSwitch.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); + } + + /** + * @notice Set value. + */ + function _setValue(int32 x, int32 y, address value) internal { + bytes32[] memory _keyTuple = new bytes32[](2); + _keyTuple[0] = bytes32(uint256(int256(x))); + _keyTuple[1] = bytes32(uint256(int256(y))); + + StoreCore.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); + } + + /** + * @notice Set value. + */ + function set(int32 x, int32 y, address value) internal { + bytes32[] memory _keyTuple = new bytes32[](2); + _keyTuple[0] = bytes32(uint256(int256(x))); + _keyTuple[1] = bytes32(uint256(int256(y))); + + StoreSwitch.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); + } + + /** + * @notice Set value. + */ + function _set(int32 x, int32 y, address value) internal { + bytes32[] memory _keyTuple = new bytes32[](2); + _keyTuple[0] = bytes32(uint256(int256(x))); + _keyTuple[1] = bytes32(uint256(int256(y))); + + StoreCore.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); + } + + /** + * @notice Delete all data for given keys. + */ + function deleteRecord(int32 x, int32 y) internal { + bytes32[] memory _keyTuple = new bytes32[](2); + _keyTuple[0] = bytes32(uint256(int256(x))); + _keyTuple[1] = bytes32(uint256(int256(y))); + + StoreSwitch.deleteRecord(_tableId, _keyTuple); + } + + /** + * @notice Delete all data for given keys. + */ + function _deleteRecord(int32 x, int32 y) internal { + bytes32[] memory _keyTuple = new bytes32[](2); + _keyTuple[0] = bytes32(uint256(int256(x))); + _keyTuple[1] = bytes32(uint256(int256(y))); + + StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout); + } + + /** + * @notice Tightly pack static (fixed length) data using this table's schema. + * @return The static data, encoded into a sequence of bytes. + */ + function encodeStatic(address value) internal pure returns (bytes memory) { + return abi.encodePacked(value); + } + + /** + * @notice Encode all of a record's fields. + * @return The static (fixed length) data, encoded into a sequence of bytes. + * @return The lengths of the dynamic fields (packed into a single bytes32 value). + * @return The dynamic (variable length) data, encoded into a sequence of bytes. + */ + function encode(address value) internal pure returns (bytes memory, EncodedLengths, bytes memory) { + bytes memory _staticData = encodeStatic(value); + + EncodedLengths _encodedLengths; + bytes memory _dynamicData; + + return (_staticData, _encodedLengths, _dynamicData); + } + + /** + * @notice Encode keys as a bytes32 array using this table's field layout. + */ + function encodeKeyTuple(int32 x, int32 y) internal pure returns (bytes32[] memory) { + bytes32[] memory _keyTuple = new bytes32[](2); + _keyTuple[0] = bytes32(uint256(int256(x))); + _keyTuple[1] = bytes32(uint256(int256(y))); + + return _keyTuple; + } +} diff --git a/packages/game/src/codegen/tables/Treasury.sol b/packages/game/src/codegen/tables/Treasury.sol new file mode 100644 index 0000000..741c716 --- /dev/null +++ b/packages/game/src/codegen/tables/Treasury.sol @@ -0,0 +1,187 @@ +// SPDX-License-Identifier: MIT +pragma solidity >=0.8.24; + +/* Autogenerated file. Do not edit manually. */ + +// Import store internals +import { IStore } from "@latticexyz/store/src/IStore.sol"; +import { StoreSwitch } from "@latticexyz/store/src/StoreSwitch.sol"; +import { StoreCore } from "@latticexyz/store/src/StoreCore.sol"; +import { Bytes } from "@latticexyz/store/src/Bytes.sol"; +import { Memory } from "@latticexyz/store/src/Memory.sol"; +import { SliceLib } from "@latticexyz/store/src/Slice.sol"; +import { EncodeArray } from "@latticexyz/store/src/tightcoder/EncodeArray.sol"; +import { FieldLayout } from "@latticexyz/store/src/FieldLayout.sol"; +import { Schema } from "@latticexyz/store/src/Schema.sol"; +import { EncodedLengths, EncodedLengthsLib } from "@latticexyz/store/src/EncodedLengths.sol"; +import { ResourceId } from "@latticexyz/store/src/ResourceId.sol"; + +library Treasury { + // Hex below is the result of `WorldResourceIdLib.encode({ namespace: "words3", name: "Treasury", typeId: RESOURCE_TABLE });` + ResourceId constant _tableId = ResourceId.wrap(0x7462776f72647333000000000000000054726561737572790000000000000000); + + FieldLayout constant _fieldLayout = + FieldLayout.wrap(0x0020010020000000000000000000000000000000000000000000000000000000); + + // Hex-encoded key schema of () + Schema constant _keySchema = Schema.wrap(0x0000000000000000000000000000000000000000000000000000000000000000); + // Hex-encoded value schema of (uint256) + Schema constant _valueSchema = Schema.wrap(0x002001001f000000000000000000000000000000000000000000000000000000); + + /** + * @notice Get the table's key field names. + * @return keyNames An array of strings with the names of key fields. + */ + function getKeyNames() internal pure returns (string[] memory keyNames) { + keyNames = new string[](0); + } + + /** + * @notice Get the table's value field names. + * @return fieldNames An array of strings with the names of value fields. + */ + function getFieldNames() internal pure returns (string[] memory fieldNames) { + fieldNames = new string[](1); + fieldNames[0] = "value"; + } + + /** + * @notice Register the table with its config. + */ + function register() internal { + StoreSwitch.registerTable(_tableId, _fieldLayout, _keySchema, _valueSchema, getKeyNames(), getFieldNames()); + } + + /** + * @notice Register the table with its config. + */ + function _register() internal { + StoreCore.registerTable(_tableId, _fieldLayout, _keySchema, _valueSchema, getKeyNames(), getFieldNames()); + } + + /** + * @notice Get value. + */ + function getValue() internal view returns (uint256 value) { + bytes32[] memory _keyTuple = new bytes32[](0); + + bytes32 _blob = StoreSwitch.getStaticField(_tableId, _keyTuple, 0, _fieldLayout); + return (uint256(bytes32(_blob))); + } + + /** + * @notice Get value. + */ + function _getValue() internal view returns (uint256 value) { + bytes32[] memory _keyTuple = new bytes32[](0); + + bytes32 _blob = StoreCore.getStaticField(_tableId, _keyTuple, 0, _fieldLayout); + return (uint256(bytes32(_blob))); + } + + /** + * @notice Get value. + */ + function get() internal view returns (uint256 value) { + bytes32[] memory _keyTuple = new bytes32[](0); + + bytes32 _blob = StoreSwitch.getStaticField(_tableId, _keyTuple, 0, _fieldLayout); + return (uint256(bytes32(_blob))); + } + + /** + * @notice Get value. + */ + function _get() internal view returns (uint256 value) { + bytes32[] memory _keyTuple = new bytes32[](0); + + bytes32 _blob = StoreCore.getStaticField(_tableId, _keyTuple, 0, _fieldLayout); + return (uint256(bytes32(_blob))); + } + + /** + * @notice Set value. + */ + function setValue(uint256 value) internal { + bytes32[] memory _keyTuple = new bytes32[](0); + + StoreSwitch.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); + } + + /** + * @notice Set value. + */ + function _setValue(uint256 value) internal { + bytes32[] memory _keyTuple = new bytes32[](0); + + StoreCore.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); + } + + /** + * @notice Set value. + */ + function set(uint256 value) internal { + bytes32[] memory _keyTuple = new bytes32[](0); + + StoreSwitch.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); + } + + /** + * @notice Set value. + */ + function _set(uint256 value) internal { + bytes32[] memory _keyTuple = new bytes32[](0); + + StoreCore.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); + } + + /** + * @notice Delete all data for given keys. + */ + function deleteRecord() internal { + bytes32[] memory _keyTuple = new bytes32[](0); + + StoreSwitch.deleteRecord(_tableId, _keyTuple); + } + + /** + * @notice Delete all data for given keys. + */ + function _deleteRecord() internal { + bytes32[] memory _keyTuple = new bytes32[](0); + + StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout); + } + + /** + * @notice Tightly pack static (fixed length) data using this table's schema. + * @return The static data, encoded into a sequence of bytes. + */ + function encodeStatic(uint256 value) internal pure returns (bytes memory) { + return abi.encodePacked(value); + } + + /** + * @notice Encode all of a record's fields. + * @return The static (fixed length) data, encoded into a sequence of bytes. + * @return The lengths of the dynamic fields (packed into a single bytes32 value). + * @return The dynamic (variable length) data, encoded into a sequence of bytes. + */ + function encode(uint256 value) internal pure returns (bytes memory, EncodedLengths, bytes memory) { + bytes memory _staticData = encodeStatic(value); + + EncodedLengths _encodedLengths; + bytes memory _dynamicData; + + return (_staticData, _encodedLengths, _dynamicData); + } + + /** + * @notice Encode keys as a bytes32 array using this table's field layout. + */ + function encodeKeyTuple() internal pure returns (bytes32[] memory) { + bytes32[] memory _keyTuple = new bytes32[](0); + + return _keyTuple; + } +} diff --git a/packages/game/src/codegen/tables/VRGDAConfig.sol b/packages/game/src/codegen/tables/VRGDAConfig.sol new file mode 100644 index 0000000..a34637e --- /dev/null +++ b/packages/game/src/codegen/tables/VRGDAConfig.sol @@ -0,0 +1,458 @@ +// SPDX-License-Identifier: MIT +pragma solidity >=0.8.24; + +/* Autogenerated file. Do not edit manually. */ + +// Import store internals +import { IStore } from "@latticexyz/store/src/IStore.sol"; +import { StoreSwitch } from "@latticexyz/store/src/StoreSwitch.sol"; +import { StoreCore } from "@latticexyz/store/src/StoreCore.sol"; +import { Bytes } from "@latticexyz/store/src/Bytes.sol"; +import { Memory } from "@latticexyz/store/src/Memory.sol"; +import { SliceLib } from "@latticexyz/store/src/Slice.sol"; +import { EncodeArray } from "@latticexyz/store/src/tightcoder/EncodeArray.sol"; +import { FieldLayout } from "@latticexyz/store/src/FieldLayout.sol"; +import { Schema } from "@latticexyz/store/src/Schema.sol"; +import { EncodedLengths, EncodedLengthsLib } from "@latticexyz/store/src/EncodedLengths.sol"; +import { ResourceId } from "@latticexyz/store/src/ResourceId.sol"; + +struct VRGDAConfigData { + uint256 startTime; + int256 targetPrice; + int256 priceDecay; + int256 perDayInitial; + int256 power; +} + +library VRGDAConfig { + // Hex below is the result of `WorldResourceIdLib.encode({ namespace: "words3", name: "VRGDAConfig", typeId: RESOURCE_TABLE });` + ResourceId constant _tableId = ResourceId.wrap(0x7462776f7264733300000000000000005652474441436f6e6669670000000000); + + FieldLayout constant _fieldLayout = + FieldLayout.wrap(0x00a0050020202020200000000000000000000000000000000000000000000000); + + // Hex-encoded key schema of () + Schema constant _keySchema = Schema.wrap(0x0000000000000000000000000000000000000000000000000000000000000000); + // Hex-encoded value schema of (uint256, int256, int256, int256, int256) + Schema constant _valueSchema = Schema.wrap(0x00a005001f3f3f3f3f0000000000000000000000000000000000000000000000); + + /** + * @notice Get the table's key field names. + * @return keyNames An array of strings with the names of key fields. + */ + function getKeyNames() internal pure returns (string[] memory keyNames) { + keyNames = new string[](0); + } + + /** + * @notice Get the table's value field names. + * @return fieldNames An array of strings with the names of value fields. + */ + function getFieldNames() internal pure returns (string[] memory fieldNames) { + fieldNames = new string[](5); + fieldNames[0] = "startTime"; + fieldNames[1] = "targetPrice"; + fieldNames[2] = "priceDecay"; + fieldNames[3] = "perDayInitial"; + fieldNames[4] = "power"; + } + + /** + * @notice Register the table with its config. + */ + function register() internal { + StoreSwitch.registerTable(_tableId, _fieldLayout, _keySchema, _valueSchema, getKeyNames(), getFieldNames()); + } + + /** + * @notice Register the table with its config. + */ + function _register() internal { + StoreCore.registerTable(_tableId, _fieldLayout, _keySchema, _valueSchema, getKeyNames(), getFieldNames()); + } + + /** + * @notice Get startTime. + */ + function getStartTime() internal view returns (uint256 startTime) { + bytes32[] memory _keyTuple = new bytes32[](0); + + bytes32 _blob = StoreSwitch.getStaticField(_tableId, _keyTuple, 0, _fieldLayout); + return (uint256(bytes32(_blob))); + } + + /** + * @notice Get startTime. + */ + function _getStartTime() internal view returns (uint256 startTime) { + bytes32[] memory _keyTuple = new bytes32[](0); + + bytes32 _blob = StoreCore.getStaticField(_tableId, _keyTuple, 0, _fieldLayout); + return (uint256(bytes32(_blob))); + } + + /** + * @notice Set startTime. + */ + function setStartTime(uint256 startTime) internal { + bytes32[] memory _keyTuple = new bytes32[](0); + + StoreSwitch.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((startTime)), _fieldLayout); + } + + /** + * @notice Set startTime. + */ + function _setStartTime(uint256 startTime) internal { + bytes32[] memory _keyTuple = new bytes32[](0); + + StoreCore.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((startTime)), _fieldLayout); + } + + /** + * @notice Get targetPrice. + */ + function getTargetPrice() internal view returns (int256 targetPrice) { + bytes32[] memory _keyTuple = new bytes32[](0); + + bytes32 _blob = StoreSwitch.getStaticField(_tableId, _keyTuple, 1, _fieldLayout); + return (int256(uint256(bytes32(_blob)))); + } + + /** + * @notice Get targetPrice. + */ + function _getTargetPrice() internal view returns (int256 targetPrice) { + bytes32[] memory _keyTuple = new bytes32[](0); + + bytes32 _blob = StoreCore.getStaticField(_tableId, _keyTuple, 1, _fieldLayout); + return (int256(uint256(bytes32(_blob)))); + } + + /** + * @notice Set targetPrice. + */ + function setTargetPrice(int256 targetPrice) internal { + bytes32[] memory _keyTuple = new bytes32[](0); + + StoreSwitch.setStaticField(_tableId, _keyTuple, 1, abi.encodePacked((targetPrice)), _fieldLayout); + } + + /** + * @notice Set targetPrice. + */ + function _setTargetPrice(int256 targetPrice) internal { + bytes32[] memory _keyTuple = new bytes32[](0); + + StoreCore.setStaticField(_tableId, _keyTuple, 1, abi.encodePacked((targetPrice)), _fieldLayout); + } + + /** + * @notice Get priceDecay. + */ + function getPriceDecay() internal view returns (int256 priceDecay) { + bytes32[] memory _keyTuple = new bytes32[](0); + + bytes32 _blob = StoreSwitch.getStaticField(_tableId, _keyTuple, 2, _fieldLayout); + return (int256(uint256(bytes32(_blob)))); + } + + /** + * @notice Get priceDecay. + */ + function _getPriceDecay() internal view returns (int256 priceDecay) { + bytes32[] memory _keyTuple = new bytes32[](0); + + bytes32 _blob = StoreCore.getStaticField(_tableId, _keyTuple, 2, _fieldLayout); + return (int256(uint256(bytes32(_blob)))); + } + + /** + * @notice Set priceDecay. + */ + function setPriceDecay(int256 priceDecay) internal { + bytes32[] memory _keyTuple = new bytes32[](0); + + StoreSwitch.setStaticField(_tableId, _keyTuple, 2, abi.encodePacked((priceDecay)), _fieldLayout); + } + + /** + * @notice Set priceDecay. + */ + function _setPriceDecay(int256 priceDecay) internal { + bytes32[] memory _keyTuple = new bytes32[](0); + + StoreCore.setStaticField(_tableId, _keyTuple, 2, abi.encodePacked((priceDecay)), _fieldLayout); + } + + /** + * @notice Get perDayInitial. + */ + function getPerDayInitial() internal view returns (int256 perDayInitial) { + bytes32[] memory _keyTuple = new bytes32[](0); + + bytes32 _blob = StoreSwitch.getStaticField(_tableId, _keyTuple, 3, _fieldLayout); + return (int256(uint256(bytes32(_blob)))); + } + + /** + * @notice Get perDayInitial. + */ + function _getPerDayInitial() internal view returns (int256 perDayInitial) { + bytes32[] memory _keyTuple = new bytes32[](0); + + bytes32 _blob = StoreCore.getStaticField(_tableId, _keyTuple, 3, _fieldLayout); + return (int256(uint256(bytes32(_blob)))); + } + + /** + * @notice Set perDayInitial. + */ + function setPerDayInitial(int256 perDayInitial) internal { + bytes32[] memory _keyTuple = new bytes32[](0); + + StoreSwitch.setStaticField(_tableId, _keyTuple, 3, abi.encodePacked((perDayInitial)), _fieldLayout); + } + + /** + * @notice Set perDayInitial. + */ + function _setPerDayInitial(int256 perDayInitial) internal { + bytes32[] memory _keyTuple = new bytes32[](0); + + StoreCore.setStaticField(_tableId, _keyTuple, 3, abi.encodePacked((perDayInitial)), _fieldLayout); + } + + /** + * @notice Get power. + */ + function getPower() internal view returns (int256 power) { + bytes32[] memory _keyTuple = new bytes32[](0); + + bytes32 _blob = StoreSwitch.getStaticField(_tableId, _keyTuple, 4, _fieldLayout); + return (int256(uint256(bytes32(_blob)))); + } + + /** + * @notice Get power. + */ + function _getPower() internal view returns (int256 power) { + bytes32[] memory _keyTuple = new bytes32[](0); + + bytes32 _blob = StoreCore.getStaticField(_tableId, _keyTuple, 4, _fieldLayout); + return (int256(uint256(bytes32(_blob)))); + } + + /** + * @notice Set power. + */ + function setPower(int256 power) internal { + bytes32[] memory _keyTuple = new bytes32[](0); + + StoreSwitch.setStaticField(_tableId, _keyTuple, 4, abi.encodePacked((power)), _fieldLayout); + } + + /** + * @notice Set power. + */ + function _setPower(int256 power) internal { + bytes32[] memory _keyTuple = new bytes32[](0); + + StoreCore.setStaticField(_tableId, _keyTuple, 4, abi.encodePacked((power)), _fieldLayout); + } + + /** + * @notice Get the full data. + */ + function get() internal view returns (VRGDAConfigData memory _table) { + bytes32[] memory _keyTuple = new bytes32[](0); + + (bytes memory _staticData, EncodedLengths _encodedLengths, bytes memory _dynamicData) = StoreSwitch.getRecord( + _tableId, + _keyTuple, + _fieldLayout + ); + return decode(_staticData, _encodedLengths, _dynamicData); + } + + /** + * @notice Get the full data. + */ + function _get() internal view returns (VRGDAConfigData memory _table) { + bytes32[] memory _keyTuple = new bytes32[](0); + + (bytes memory _staticData, EncodedLengths _encodedLengths, bytes memory _dynamicData) = StoreCore.getRecord( + _tableId, + _keyTuple, + _fieldLayout + ); + return decode(_staticData, _encodedLengths, _dynamicData); + } + + /** + * @notice Set the full data using individual values. + */ + function set(uint256 startTime, int256 targetPrice, int256 priceDecay, int256 perDayInitial, int256 power) internal { + bytes memory _staticData = encodeStatic(startTime, targetPrice, priceDecay, perDayInitial, power); + + EncodedLengths _encodedLengths; + bytes memory _dynamicData; + + bytes32[] memory _keyTuple = new bytes32[](0); + + StoreSwitch.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); + } + + /** + * @notice Set the full data using individual values. + */ + function _set(uint256 startTime, int256 targetPrice, int256 priceDecay, int256 perDayInitial, int256 power) internal { + bytes memory _staticData = encodeStatic(startTime, targetPrice, priceDecay, perDayInitial, power); + + EncodedLengths _encodedLengths; + bytes memory _dynamicData; + + bytes32[] memory _keyTuple = new bytes32[](0); + + StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); + } + + /** + * @notice Set the full data using the data struct. + */ + function set(VRGDAConfigData memory _table) internal { + bytes memory _staticData = encodeStatic( + _table.startTime, + _table.targetPrice, + _table.priceDecay, + _table.perDayInitial, + _table.power + ); + + EncodedLengths _encodedLengths; + bytes memory _dynamicData; + + bytes32[] memory _keyTuple = new bytes32[](0); + + StoreSwitch.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); + } + + /** + * @notice Set the full data using the data struct. + */ + function _set(VRGDAConfigData memory _table) internal { + bytes memory _staticData = encodeStatic( + _table.startTime, + _table.targetPrice, + _table.priceDecay, + _table.perDayInitial, + _table.power + ); + + EncodedLengths _encodedLengths; + bytes memory _dynamicData; + + bytes32[] memory _keyTuple = new bytes32[](0); + + StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); + } + + /** + * @notice Decode the tightly packed blob of static data using this table's field layout. + */ + function decodeStatic( + bytes memory _blob + ) + internal + pure + returns (uint256 startTime, int256 targetPrice, int256 priceDecay, int256 perDayInitial, int256 power) + { + startTime = (uint256(Bytes.getBytes32(_blob, 0))); + + targetPrice = (int256(uint256(Bytes.getBytes32(_blob, 32)))); + + priceDecay = (int256(uint256(Bytes.getBytes32(_blob, 64)))); + + perDayInitial = (int256(uint256(Bytes.getBytes32(_blob, 96)))); + + power = (int256(uint256(Bytes.getBytes32(_blob, 128)))); + } + + /** + * @notice Decode the tightly packed blobs using this table's field layout. + * @param _staticData Tightly packed static fields. + * + * + */ + function decode( + bytes memory _staticData, + EncodedLengths, + bytes memory + ) internal pure returns (VRGDAConfigData memory _table) { + (_table.startTime, _table.targetPrice, _table.priceDecay, _table.perDayInitial, _table.power) = decodeStatic( + _staticData + ); + } + + /** + * @notice Delete all data for given keys. + */ + function deleteRecord() internal { + bytes32[] memory _keyTuple = new bytes32[](0); + + StoreSwitch.deleteRecord(_tableId, _keyTuple); + } + + /** + * @notice Delete all data for given keys. + */ + function _deleteRecord() internal { + bytes32[] memory _keyTuple = new bytes32[](0); + + StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout); + } + + /** + * @notice Tightly pack static (fixed length) data using this table's schema. + * @return The static data, encoded into a sequence of bytes. + */ + function encodeStatic( + uint256 startTime, + int256 targetPrice, + int256 priceDecay, + int256 perDayInitial, + int256 power + ) internal pure returns (bytes memory) { + return abi.encodePacked(startTime, targetPrice, priceDecay, perDayInitial, power); + } + + /** + * @notice Encode all of a record's fields. + * @return The static (fixed length) data, encoded into a sequence of bytes. + * @return The lengths of the dynamic fields (packed into a single bytes32 value). + * @return The dynamic (variable length) data, encoded into a sequence of bytes. + */ + function encode( + uint256 startTime, + int256 targetPrice, + int256 priceDecay, + int256 perDayInitial, + int256 power + ) internal pure returns (bytes memory, EncodedLengths, bytes memory) { + bytes memory _staticData = encodeStatic(startTime, targetPrice, priceDecay, perDayInitial, power); + + EncodedLengths _encodedLengths; + bytes memory _dynamicData; + + return (_staticData, _encodedLengths, _dynamicData); + } + + /** + * @notice Encode keys as a bytes32 array using this table's field layout. + */ + function encodeKeyTuple() internal pure returns (bytes32[] memory) { + bytes32[] memory _keyTuple = new bytes32[](0); + + return _keyTuple; + } +} diff --git a/src/codegen/world/IClaimSystem.sol b/packages/game/src/codegen/world/IClaimSystem.sol similarity index 72% rename from src/codegen/world/IClaimSystem.sol rename to packages/game/src/codegen/world/IClaimSystem.sol index 289f583..bfa8a48 100644 --- a/src/codegen/world/IClaimSystem.sol +++ b/packages/game/src/codegen/world/IClaimSystem.sol @@ -9,9 +9,9 @@ pragma solidity >=0.8.24; * @dev This interface is automatically generated from the corresponding system contract. Do not edit manually. */ interface IClaimSystem { - error AlreadyClaimed(); - error InvalidClaimAddress(); - error NotEnoughPoints(); + error AlreadyClaimed(); + error InvalidClaimAddress(); + error NotEnoughPoints(); - function claim(uint32 points) external; + function words3__claim(uint32 points) external; } diff --git a/packages/game/src/codegen/world/IDrawSystem.sol b/packages/game/src/codegen/world/IDrawSystem.sol new file mode 100644 index 0000000..c592bc4 --- /dev/null +++ b/packages/game/src/codegen/world/IDrawSystem.sol @@ -0,0 +1,21 @@ +// SPDX-License-Identifier: MIT +pragma solidity >=0.8.24; + +/* Autogenerated file. Do not edit manually. */ + +/** + * @title IDrawSystem + * @author MUD (https://mud.dev) by Lattice (https://lattice.xyz) + * @dev This interface is automatically generated from the corresponding system contract. Do not edit manually. + */ +interface IDrawSystem { + error InvalidDrawAddress(); + error NotEnoughValue(); + error AlreadyFulfilled(); + + function words3__requestDraw(address player) external payable returns (uint256); + + function words3__fulfillDraw(uint256 id) external; + + function words3__getDrawPrice() external view returns (uint256); +} diff --git a/src/codegen/world/IDrawSystem.sol b/packages/game/src/codegen/world/IHelperSystem.sol similarity index 57% rename from src/codegen/world/IDrawSystem.sol rename to packages/game/src/codegen/world/IHelperSystem.sol index 5c35c2a..2603fe7 100644 --- a/src/codegen/world/IDrawSystem.sol +++ b/packages/game/src/codegen/world/IHelperSystem.sol @@ -4,15 +4,10 @@ pragma solidity >=0.8.24; /* Autogenerated file. Do not edit manually. */ /** - * @title IDrawSystem + * @title IHelperSystem * @author MUD (https://mud.dev) by Lattice (https://lattice.xyz) * @dev This interface is automatically generated from the corresponding system contract. Do not edit manually. */ -interface IDrawSystem { - error InvalidDrawAddress(); - error NotEnoughValue(); - - function draw(address player) external payable; - - function getDrawPrice() external view returns (uint256); +interface IHelperSystem { + function words3__instantDraw(address player) external payable; } diff --git a/src/codegen/world/IPlaySystem.sol b/packages/game/src/codegen/world/IPlaySystem.sol similarity index 58% rename from src/codegen/world/IPlaySystem.sol rename to packages/game/src/codegen/world/IPlaySystem.sol index ac08667..5434d8f 100644 --- a/src/codegen/world/IPlaySystem.sol +++ b/packages/game/src/codegen/world/IPlaySystem.sol @@ -3,10 +3,9 @@ pragma solidity >=0.8.24; /* Autogenerated file. Do not edit manually. */ -import { Direction, Letter } from "codegen/common.sol"; - -import { Bound } from "common/Bound.sol"; +import { Letter, Direction } from "codegen/common.sol"; import { Coord } from "common/Coord.sol"; +import { Bound } from "common/Bound.sol"; /** * @title IPlaySystem @@ -14,15 +13,14 @@ import { Coord } from "common/Coord.sol"; * @dev This interface is automatically generated from the corresponding system contract. Do not edit manually. */ interface IPlaySystem { - error CannotPlay(); - error PlayMissingLetters(); + error CannotPlay(); + error PlayMissingLetters(); - function play( - Letter[] memory word, - bytes32[] memory proof, - Coord memory coord, - Direction direction, - Bound[] memory bounds - ) - external; + function words3__play( + Letter[] memory word, + bytes32[] memory proof, + Coord memory coord, + Direction direction, + Bound[] memory bounds + ) external; } diff --git a/src/codegen/world/ISetDrawLetterOddsSystem.sol b/packages/game/src/codegen/world/ISetDrawLetterOddsSystem.sol similarity index 70% rename from src/codegen/world/ISetDrawLetterOddsSystem.sol rename to packages/game/src/codegen/world/ISetDrawLetterOddsSystem.sol index efc27d2..448a474 100644 --- a/src/codegen/world/ISetDrawLetterOddsSystem.sol +++ b/packages/game/src/codegen/world/ISetDrawLetterOddsSystem.sol @@ -9,9 +9,9 @@ pragma solidity >=0.8.24; * @dev This interface is automatically generated from the corresponding system contract. Do not edit manually. */ interface ISetDrawLetterOddsSystem { - error AlreadySetOdds(); - error InvalidOddsLength(); - error NonzeroFirstValue(); + error AlreadySetOdds(); + error InvalidOddsLength(); + error NonzeroFirstValue(); - function setDrawLetterOdds(uint8[] memory odds) external; + function words3__setDrawLetterOdds(uint8[] memory odds) external; } diff --git a/src/codegen/world/IStartSystem.sol b/packages/game/src/codegen/world/IStartSystem.sol similarity index 53% rename from src/codegen/world/IStartSystem.sol rename to packages/game/src/codegen/world/IStartSystem.sol index 4172ae7..f17b1be 100644 --- a/src/codegen/world/IStartSystem.sol +++ b/packages/game/src/codegen/world/IStartSystem.sol @@ -11,17 +11,16 @@ import { Letter } from "codegen/common.sol"; * @dev This interface is automatically generated from the corresponding system contract. Do not edit manually. */ interface IStartSystem { - error GameAlreadyStarted(); + error GameAlreadyStarted(); - function start( - Letter[] memory initialWord, - bytes32 merkleRoot, - int256 vrgdaTargetPrice, - int256 vrgdaPriceDecay, - int256 vrgdaPerDayInitial, - int256 vrgdaPower, - uint32 crossWordRewardFraction, - uint16 bonusDistance - ) - external; + function words3__start( + Letter[] memory initialWord, + bytes32 merkleRoot, + int256 vrgdaTargetPrice, + int256 vrgdaPriceDecay, + int256 vrgdaPerDayInitial, + int256 vrgdaPower, + uint32 crossWordRewardFraction, + uint16 bonusDistance + ) external; } diff --git a/src/codegen/world/ITransferLettersSystem.sol b/packages/game/src/codegen/world/ITransferLettersSystem.sol similarity index 79% rename from src/codegen/world/ITransferLettersSystem.sol rename to packages/game/src/codegen/world/ITransferLettersSystem.sol index fe7606b..610f9c9 100644 --- a/src/codegen/world/ITransferLettersSystem.sol +++ b/packages/game/src/codegen/world/ITransferLettersSystem.sol @@ -11,7 +11,7 @@ import { Letter } from "codegen/common.sol"; * @dev This interface is automatically generated from the corresponding system contract. Do not edit manually. */ interface ITransferLettersSystem { - error TransferMissingLetters(); + error TransferMissingLetters(); - function transfer(Letter[] memory letters, address to) external; + function words3__transfer(Letter[] memory letters, address to) external; } diff --git a/src/codegen/world/IWorld.sol b/packages/game/src/codegen/world/IWorld.sol similarity index 79% rename from src/codegen/world/IWorld.sol rename to packages/game/src/codegen/world/IWorld.sol index 56fc492..4566747 100644 --- a/src/codegen/world/IWorld.sol +++ b/packages/game/src/codegen/world/IWorld.sol @@ -6,8 +6,8 @@ pragma solidity >=0.8.24; import { IBaseWorld } from "@latticexyz/world/src/codegen/interfaces/IBaseWorld.sol"; import { IClaimSystem } from "./IClaimSystem.sol"; -import { IDonateSystem } from "./IDonateSystem.sol"; import { IDrawSystem } from "./IDrawSystem.sol"; +import { IHelperSystem } from "./IHelperSystem.sol"; import { IPlaySystem } from "./IPlaySystem.sol"; import { ISetDrawLetterOddsSystem } from "./ISetDrawLetterOddsSystem.sol"; import { IStartSystem } from "./IStartSystem.sol"; @@ -21,12 +21,12 @@ import { ITransferLettersSystem } from "./ITransferLettersSystem.sol"; * @dev This is an autogenerated file; do not edit manually. */ interface IWorld is - IBaseWorld, - IClaimSystem, - IDonateSystem, - IDrawSystem, - IPlaySystem, - ISetDrawLetterOddsSystem, - IStartSystem, - ITransferLettersSystem -{ } + IBaseWorld, + IClaimSystem, + IDrawSystem, + IHelperSystem, + IPlaySystem, + ISetDrawLetterOddsSystem, + IStartSystem, + ITransferLettersSystem +{} diff --git a/src/common/Bonus.sol b/packages/game/src/common/Bonus.sol similarity index 100% rename from src/common/Bonus.sol rename to packages/game/src/common/Bonus.sol diff --git a/src/common/Bound.sol b/packages/game/src/common/Bound.sol similarity index 100% rename from src/common/Bound.sol rename to packages/game/src/common/Bound.sol diff --git a/src/common/Constants.sol b/packages/game/src/common/Constants.sol similarity index 100% rename from src/common/Constants.sol rename to packages/game/src/common/Constants.sol diff --git a/src/common/Coord.sol b/packages/game/src/common/Coord.sol similarity index 100% rename from src/common/Coord.sol rename to packages/game/src/common/Coord.sol diff --git a/src/common/Errors.sol b/packages/game/src/common/Errors.sol similarity index 100% rename from src/common/Errors.sol rename to packages/game/src/common/Errors.sol diff --git a/src/libraries/LibBoard.sol b/packages/game/src/libraries/LibBoard.sol similarity index 100% rename from src/libraries/LibBoard.sol rename to packages/game/src/libraries/LibBoard.sol diff --git a/src/libraries/LibBonus.sol b/packages/game/src/libraries/LibBonus.sol similarity index 100% rename from src/libraries/LibBonus.sol rename to packages/game/src/libraries/LibBonus.sol diff --git a/src/libraries/LibGame.sol b/packages/game/src/libraries/LibGame.sol similarity index 100% rename from src/libraries/LibGame.sol rename to packages/game/src/libraries/LibGame.sol diff --git a/src/libraries/LibLetters.sol b/packages/game/src/libraries/LibLetters.sol similarity index 100% rename from src/libraries/LibLetters.sol rename to packages/game/src/libraries/LibLetters.sol diff --git a/src/libraries/LibPlay.sol b/packages/game/src/libraries/LibPlay.sol similarity index 100% rename from src/libraries/LibPlay.sol rename to packages/game/src/libraries/LibPlay.sol diff --git a/src/libraries/LibPlayer.sol b/packages/game/src/libraries/LibPlayer.sol similarity index 100% rename from src/libraries/LibPlayer.sol rename to packages/game/src/libraries/LibPlayer.sol diff --git a/src/libraries/LibPoints.sol b/packages/game/src/libraries/LibPoints.sol similarity index 100% rename from src/libraries/LibPoints.sol rename to packages/game/src/libraries/LibPoints.sol diff --git a/src/libraries/LibPrice.sol b/packages/game/src/libraries/LibPrice.sol similarity index 100% rename from src/libraries/LibPrice.sol rename to packages/game/src/libraries/LibPrice.sol diff --git a/src/libraries/LibTile.sol b/packages/game/src/libraries/LibTile.sol similarity index 100% rename from src/libraries/LibTile.sol rename to packages/game/src/libraries/LibTile.sol diff --git a/src/libraries/LibTreasury.sol b/packages/game/src/libraries/LibTreasury.sol similarity index 100% rename from src/libraries/LibTreasury.sol rename to packages/game/src/libraries/LibTreasury.sol diff --git a/src/systems/ClaimSystem.sol b/packages/game/src/systems/ClaimSystem.sol similarity index 77% rename from src/systems/ClaimSystem.sol rename to packages/game/src/systems/ClaimSystem.sol index 85092f6..cd1abef 100644 --- a/src/systems/ClaimSystem.sol +++ b/packages/game/src/systems/ClaimSystem.sol @@ -2,8 +2,10 @@ pragma solidity >=0.8.0; import { System } from "@latticexyz/world/src/System.sol"; -import { Points, PointsClaimed } from "codegen/index.sol"; +import { WorldResourceIdLib } from "@latticexyz/world/src/WorldResourceId.sol"; +import { Points, PointsClaimed } from "codegen/index.sol"; +import { IWorld } from "codegen/world/IWorld.sol"; import { LibPlayer } from "libraries/LibPlayer.sol"; import { LibTreasury } from "libraries/LibTreasury.sol"; @@ -25,7 +27,11 @@ contract ClaimSystem is System { LibTreasury.decrementTreasury({ decrement: claimAmount }); - payable(player).transfer(claimAmount); + IWorld(_world()).transferBalanceToAddress({ + fromNamespaceId: WorldResourceIdLib.encodeNamespace("words3"), + toAddress: player, + amount: claimAmount + }); PointsClaimed.set({ id: uint256(keccak256(abi.encodePacked(player, playerPoints, block.number))), diff --git a/src/systems/DrawSystem.sol b/packages/game/src/systems/DrawSystem.sol similarity index 53% rename from src/systems/DrawSystem.sol rename to packages/game/src/systems/DrawSystem.sol index b190c40..1ab0c5e 100644 --- a/src/systems/DrawSystem.sol +++ b/packages/game/src/systems/DrawSystem.sol @@ -2,19 +2,21 @@ pragma solidity >=0.8.0; import { System } from "@latticexyz/world/src/System.sol"; - import { Letter } from "codegen/common.sol"; -import { DrawCount, DrawLetterOdds, LettersDrawn } from "codegen/index.sol"; +import { DrawCount, DrawLetterOdds, DrawRequest, DrawRequestData, LettersDrawn } from "codegen/index.sol"; import { SINGLETON_ADDRESS } from "common/Constants.sol"; import { LibLetters } from "libraries/LibLetters.sol"; import { LibPrice } from "libraries/LibPrice.sol"; import { LibTreasury } from "libraries/LibTreasury.sol"; +import { Response } from "rng/src/codegen/index.sol"; +import { IWorld } from "rng/src/codegen/world/IWorld.sol"; contract DrawSystem is System { error InvalidDrawAddress(); error NotEnoughValue(); + error AlreadyFulfilled(); - function draw(address player) public payable { + function requestDraw(address player) public payable returns (uint256) { if (player == address(0) || player == SINGLETON_ADDRESS) { revert InvalidDrawAddress(); } @@ -27,11 +29,35 @@ contract DrawSystem is System { // Sender might be different than player, track the spend under sender LibTreasury.incrementTreasury(_msgSender(), value); + IWorld world = IWorld(_world()); + uint256 id = world.rng__request(); + + DrawRequest.set({ id: id, player: player, fulfilled: false }); + + LettersDrawn.set({ id: id, player: player, value: value, timestamp: block.timestamp }); + + return id; + } + + function fulfillDraw(uint256 id) public { + DrawRequestData memory request = DrawRequest.get({ id: id }); + if (request.fulfilled) { + revert AlreadyFulfilled(); + } + address player = request.player; + + uint256 random = Response.getValue({ id: id }); + if (random == 0) { + IWorld world = IWorld(_world()); + world.rng__setRandao({ id: id }); + } + random = Response.getValue({ id: id }); + // Draw 8 letters for now, undecided on whether players can control Letter[] memory drawnLetters = LibLetters.getDraw({ odds: DrawLetterOdds.get(), numLetters: 8, - random: uint256(keccak256(abi.encodePacked(block.timestamp, _msgSender()))) + random: uint256(keccak256(abi.encodePacked(random, _msgSender(), id))) }); for (uint256 i = 0; i < drawnLetters.length; i++) { @@ -40,8 +66,7 @@ contract DrawSystem is System { uint32 drawCount = DrawCount.get() + 1; DrawCount.set(drawCount); - - LettersDrawn.set({ id: drawCount, player: player, value: value, timestamp: block.timestamp }); + DrawRequest.setFulfilled({ id: id, fulfilled: true }); } function getDrawPrice() public view returns (uint256) { diff --git a/packages/game/src/systems/HelperSystem.sol b/packages/game/src/systems/HelperSystem.sol new file mode 100644 index 0000000..09013e2 --- /dev/null +++ b/packages/game/src/systems/HelperSystem.sol @@ -0,0 +1,13 @@ +// SPDX-License-Identifier: MIT +pragma solidity >=0.8.0; + +import { System } from "@latticexyz/world/src/System.sol"; +import { IWorld } from "codegen/world/IWorld.sol"; + +contract HelperSystem is System { + function instantDraw(address player) public payable { + IWorld world = IWorld(_world()); + uint256 id = world.words3__requestDraw({player: player}); + world.words3__fulfillDraw({id: id}); + } +} diff --git a/src/systems/PlaySystem.sol b/packages/game/src/systems/PlaySystem.sol similarity index 99% rename from src/systems/PlaySystem.sol rename to packages/game/src/systems/PlaySystem.sol index 3afece2..bc48522 100644 --- a/src/systems/PlaySystem.sol +++ b/packages/game/src/systems/PlaySystem.sol @@ -6,7 +6,6 @@ import { Direction, Letter } from "codegen/common.sol"; import { Bound } from "common/Bound.sol"; import { Coord } from "common/Coord.sol"; import { LibGame } from "libraries/LibGame.sol"; - import { LibLetters } from "libraries/LibLetters.sol"; import { LibPlay } from "libraries/LibPlay.sol"; diff --git a/src/systems/SetDrawLetterOddsSystem.sol b/packages/game/src/systems/SetDrawLetterOddsSystem.sol similarity index 100% rename from src/systems/SetDrawLetterOddsSystem.sol rename to packages/game/src/systems/SetDrawLetterOddsSystem.sol diff --git a/src/systems/StartSystem.sol b/packages/game/src/systems/StartSystem.sol similarity index 100% rename from src/systems/StartSystem.sol rename to packages/game/src/systems/StartSystem.sol diff --git a/src/systems/TransferLettersSystem.sol b/packages/game/src/systems/TransferLettersSystem.sol similarity index 100% rename from src/systems/TransferLettersSystem.sol rename to packages/game/src/systems/TransferLettersSystem.sol diff --git a/src/test/Words3Test.t.sol b/packages/game/src/test/Words3Test.t.sol similarity index 71% rename from src/test/Words3Test.t.sol rename to packages/game/src/test/Words3Test.t.sol index bc0c945..017cf40 100644 --- a/src/test/Words3Test.t.sol +++ b/packages/game/src/test/Words3Test.t.sol @@ -6,15 +6,32 @@ import { Letter } from "codegen/common.sol"; import { IWorld } from "codegen/world/IWorld.sol"; contract Words3Test is MudTest { + IWorld world; address deployerAddress; function setUp() public virtual override { super.setUp(); deployerAddress = address(0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266); + world = IWorld(worldAddress); + } + + function startEmpty() public { + Letter[] memory initialWord = new Letter[](2); + initialWord[0] = Letter.H; + initialWord[1] = Letter.I; + world.words3__start({ + initialWord: initialWord, + merkleRoot: bytes32(0), + vrgdaTargetPrice: 1, + vrgdaPriceDecay: 1e17, + vrgdaPerDayInitial: 100e18, + vrgdaPower: 1e16, + crossWordRewardFraction: 3, + bonusDistance: 5 + }); } function setDefaultLetterOdds() public { - IWorld world = IWorld(worldAddress); uint8[] memory odds = new uint8[](27); odds[0] = 0; odds[uint8(Letter.A)] = 9; @@ -44,6 +61,6 @@ contract Words3Test is MudTest { odds[uint8(Letter.Y)] = 2; odds[uint8(Letter.Z)] = 1; - world.setDrawLetterOdds(odds); + world.words3__setDrawLetterOdds(odds); } } diff --git a/packages/game/src/test/integration/Claim.t.sol b/packages/game/src/test/integration/Claim.t.sol new file mode 100644 index 0000000..9591c94 --- /dev/null +++ b/packages/game/src/test/integration/Claim.t.sol @@ -0,0 +1,158 @@ +// // SPDX-License-Identifier: MIT +// pragma solidity >=0.8.0; + +// import { Direction, Letter } from "codegen/common.sol"; +// import { MerkleRootConfig, Points, TileLetter, TilePlayer, Treasury } from "codegen/index.sol"; +// import { IWorld } from "codegen/world/IWorld.sol"; + +// import { Bound } from "common/Bound.sol"; +// import { SINGLETON_ADDRESS } from "common/Constants.sol"; +// import { Coord } from "common/Coord.sol"; + +// import { Words3Test } from "../Words3Test.t.sol"; +// import { Merkle } from "../murky/src/Merkle.sol"; +// import "forge-std/Test.sol"; + +// contract Claim is Words3Test { +// IWorld world; +// bytes32[] public words; +// Merkle private m; + +// function setUp() public override { +// super.setUp(); +// world = IWorld(worldAddress); +// m = new Merkle(); +// Letter[] memory hello = new Letter[](5); +// hello[0] = Letter.H; +// hello[1] = Letter.E; +// hello[1] = Letter.L; +// hello[1] = Letter.L; +// hello[1] = Letter.O; +// Letter[] memory zone = new Letter[](4); +// zone[0] = Letter.Z; +// zone[1] = Letter.O; +// zone[2] = Letter.N; +// zone[3] = Letter.E; +// Letter[] memory echo = new Letter[](4); +// echo[0] = Letter.E; +// echo[1] = Letter.C; +// echo[2] = Letter.H; +// echo[3] = Letter.O; +// Letter[] memory zebra = new Letter[](5); +// zebra[0] = Letter.Z; +// zebra[1] = Letter.E; +// zebra[2] = Letter.B; +// zebra[3] = Letter.R; +// zebra[4] = Letter.A; +// Letter[] memory riot = new Letter[](5); +// riot[0] = Letter.R; +// riot[1] = Letter.I; +// riot[2] = Letter.O; +// riot[3] = Letter.T; +// Letter[] memory emi = new Letter[](3); +// emi[0] = Letter.E; +// emi[1] = Letter.M; +// emi[2] = Letter.I; +// Letter[] memory om = new Letter[](2); +// om[0] = Letter.O; +// om[1] = Letter.M; +// Letter[] memory omq = new Letter[](3); +// omq[0] = Letter.O; +// omq[1] = Letter.M; +// omq[2] = Letter.Q; +// Letter[] memory bqt = new Letter[](3); +// bqt[0] = Letter.B; +// bqt[1] = Letter.Q; +// bqt[2] = Letter.T; +// words.push(keccak256(bytes.concat(keccak256(abi.encode(hello))))); // hello +// words.push(keccak256(bytes.concat(keccak256(abi.encode(zone))))); // zone +// words.push(keccak256(bytes.concat(keccak256(abi.encode(echo))))); // echo +// words.push(keccak256(bytes.concat(keccak256(abi.encode(zebra))))); // zebra +// words.push(keccak256(bytes.concat(keccak256(abi.encode(riot))))); // riot +// words.push(keccak256(bytes.concat(keccak256(abi.encode(emi))))); // emi +// words.push(keccak256(bytes.concat(keccak256(abi.encode(om))))); // om +// words.push(keccak256(bytes.concat(keccak256(abi.encode(omq))))); // omq +// words.push(keccak256(bytes.concat(keccak256(abi.encode(bqt))))); // qt + +// setDefaultLetterOdds(); +// } + +// function test_SimpleClaim() public { +// address player1 = address(0x12345); +// address player2 = address(0x54321); + +// Letter[] memory initialWord = new Letter[](5); +// initialWord[0] = Letter.H; +// initialWord[1] = Letter.E; +// initialWord[2] = Letter.L; +// initialWord[3] = Letter.L; +// initialWord[4] = Letter.O; + +// world.words3__start({ +// initialWord: initialWord, +// merkleRoot: m.getRoot(words), +// vrgdaTargetPrice: 1, +// vrgdaPriceDecay: 1e17, +// vrgdaPerDayInitial: 100e18, +// vrgdaPower: 1e16, +// crossWordRewardFraction: 3, +// bonusDistance: 5 +// }); + +// Letter[] memory word = new Letter[](4); +// word[0] = Letter.Z; +// word[1] = Letter.EMPTY; +// word[2] = Letter.N; +// word[3] = Letter.E; + +// vm.deal(player1, 10 ether); + +// Bound[] memory bounds = new Bound[](4); +// bytes32[] memory proof = m.getProof(words, 1); + +// // Play zone +// vm.startPrank(player1); +// for (uint256 i = 0; i < 20; i++) { +// vm.warp(block.timestamp + 1 days); +// world.words3__draw{ value: 0.5 ether }(player1); +// } +// world.words3__play(word, proof, Coord({ x: 4, y: -1 }), Direction.TOP_TO_BOTTOM, bounds); +// vm.stopPrank(); +// assertEq(address(player1).balance, 0); +// assertEq(address(worldAddress).balance, 10 ether); + +// // Play zebra on zone +// vm.deal(player2, 10 ether); +// Letter[] memory word2 = new Letter[](5); +// word2[0] = Letter.EMPTY; +// word2[1] = Letter.E; +// word2[2] = Letter.B; +// word2[3] = Letter.R; +// word2[4] = Letter.A; + +// bytes32[] memory proof2 = m.getProof(words, 3); +// Bound[] memory bounds2 = new Bound[](5); +// vm.startPrank(player2); +// for (uint256 i = 0; i < 20; i++) { +// vm.warp(block.timestamp + 1 days); +// world.words3__draw{ value: 0.5 ether }(player2); +// } +// world.words3__play(word2, proof2, Coord({ x: 4, y: -1 }), Direction.LEFT_TO_RIGHT, bounds2); +// vm.stopPrank(); +// uint32 player1Points = Points.get(player1); +// uint32 player2Points = Points.get(player2); + +// assertEq(Treasury.get(), 20 ether); + +// vm.prank(player1); +// world.words3__claim(player1Points); + +// vm.prank(player2); +// world.words3__claim(player2Points); + +// uint256 player1ExpectedBalance = (20 ether * player1Points) / (player1Points + player2Points); + +// assertEq(address(player1).balance, player1ExpectedBalance); +// assertEq(address(player2).balance, 20 ether - player1ExpectedBalance); +// } +// } diff --git a/src/test/integration/CrossWord.t.sol b/packages/game/src/test/integration/CrossWord.t.sol similarity index 100% rename from src/test/integration/CrossWord.t.sol rename to packages/game/src/test/integration/CrossWord.t.sol diff --git a/src/test/integration/Points.t.sol b/packages/game/src/test/integration/Points.t.sol similarity index 100% rename from src/test/integration/Points.t.sol rename to packages/game/src/test/integration/Points.t.sol diff --git a/packages/game/src/test/integration/SimpleWord.t.sol b/packages/game/src/test/integration/SimpleWord.t.sol new file mode 100644 index 0000000..5985f2f --- /dev/null +++ b/packages/game/src/test/integration/SimpleWord.t.sol @@ -0,0 +1,115 @@ +// // SPDX-License-Identifier: MIT +// pragma solidity >=0.8.0; + +// import { Direction, Letter } from "codegen/common.sol"; +// import { MerkleRootConfig, TileLetter, TilePlayer } from "codegen/index.sol"; +// import { IWorld } from "codegen/world/IWorld.sol"; + +// import { Bound } from "common/Bound.sol"; +// import { Coord } from "common/Coord.sol"; +// import { GameStartedOrOver } from "common/Errors.sol"; + +// import { Words3Test } from "../Words3Test.t.sol"; +// import { Merkle } from "../murky/src/Merkle.sol"; +// import "forge-std/Test.sol"; + +// contract SimpleWord is Words3Test { +// IWorld world; +// bytes32[] public words; +// Merkle private m; +// Letter[] initialWord; + +// function setUp() public override { +// super.setUp(); +// world = IWorld(worldAddress); + +// m = new Merkle(); +// Letter[] memory hi = new Letter[](2); +// hi[0] = Letter.H; +// hi[1] = Letter.I; +// Letter[] memory go = new Letter[](2); +// go[0] = Letter.G; +// go[1] = Letter.O; +// words.push(keccak256(bytes.concat(keccak256(abi.encode(hi))))); // hi +// words.push(keccak256(bytes.concat(keccak256(abi.encode(go))))); // go + +// setDefaultLetterOdds(); +// } + +// function test_Setup() public { +// initialWord = new Letter[](2); +// initialWord[0] = Letter.H; +// initialWord[1] = Letter.I; +// world.words3__start(initialWord, m.getRoot(words), 0, 0, 0, 1e16, 3, 5); +// assertEq(uint8(TileLetter.get(0, 0)), uint8(Letter.H)); +// assertEq(uint8(TileLetter.get(1, 0)), uint8(Letter.I)); +// } + +// function test_PlayHi() public { +// initialWord = new Letter[](2); +// initialWord[0] = Letter.H; +// initialWord[1] = Letter.I; +// world.words3__start({ +// initialWord: initialWord, +// merkleRoot: m.getRoot(words), +// vrgdaTargetPrice: 1, +// vrgdaPriceDecay: 1e17, +// vrgdaPerDayInitial: 100e18, +// vrgdaPower: 1e16, +// crossWordRewardFraction: 3, +// bonusDistance: 5 +// }); + +// Letter[] memory word = new Letter[](2); +// word[0] = Letter.EMPTY; +// word[1] = Letter.I; +// Bound[] memory bounds = new Bound[](2); +// bytes32[] memory proof = m.getProof(words, 0); + +// address player = address(0x123); +// vm.deal(player, 50 ether); +// vm.startPrank(player); +// for (uint256 i = 0; i < 50; i++) { +// uint256 price = world.words3__getDrawPrice(); +// vm.warp(block.timestamp + 1 days); +// world.words3__draw{ value: price }(player); +// } +// world.words3__play(word, proof, Coord({ x: 0, y: 0 }), Direction.TOP_TO_BOTTOM, bounds); +// vm.stopPrank(); +// } + +// function test_MultipleDraws() public { +// world.words3__start({ +// initialWord: initialWord, +// merkleRoot: 0xacd24e8edae5cf4cdbc3ce0c196a670cbea1dbf37576112b0a3defac3318b432, +// vrgdaTargetPrice: 40e13, +// vrgdaPriceDecay: 99_999e13, +// vrgdaPerDayInitial: 700e18, +// vrgdaPower: 1e18, +// crossWordRewardFraction: 3, +// bonusDistance: 10 +// }); + +// address player = address(0x123); +// vm.deal(player, 50 ether); +// vm.startPrank(player); + +// world.words3__draw{ value: world.words3__getDrawPrice() }(player); +// world.words3__draw{ value: world.words3__getDrawPrice() }(player); +// vm.warp(block.timestamp + 5); +// world.words3__draw{ value: world.words3__getDrawPrice() }(player); +// vm.warp(block.timestamp + 10); +// world.words3__draw{ value: world.words3__getDrawPrice() }(player); +// world.words3__draw{ value: world.words3__getDrawPrice() }(player); +// world.words3__draw{ value: world.words3__getDrawPrice() }(player); +// vm.warp(block.timestamp + 10); +// world.words3__draw{ value: world.words3__getDrawPrice() }(player); +// world.words3__draw{ value: world.words3__getDrawPrice() }(player); +// world.words3__draw{ value: world.words3__getDrawPrice() }(player); +// world.words3__draw{ value: world.words3__getDrawPrice() }(player); +// world.words3__draw{ value: world.words3__getDrawPrice() }(player); +// vm.warp(block.timestamp + 3); +// world.words3__draw{ value: world.words3__getDrawPrice() }(player); +// world.words3__draw{ value: world.words3__getDrawPrice() }(player); +// } +// } diff --git a/packages/game/src/test/integration/Transfer.t.sol b/packages/game/src/test/integration/Transfer.t.sol new file mode 100644 index 0000000..40ff373 --- /dev/null +++ b/packages/game/src/test/integration/Transfer.t.sol @@ -0,0 +1,58 @@ +// // SPDX-License-Identifier: MIT +// pragma solidity >=0.8.0; + +// import { Direction, Letter } from "codegen/common.sol"; +// import { PlayerLetters } from "codegen/index.sol"; +// import { IWorld } from "codegen/world/IWorld.sol"; + +// import { Bound } from "common/Bound.sol"; +// import { Coord } from "common/Coord.sol"; +// import { GameStartedOrOver } from "common/Errors.sol"; + +// import { Words3Test } from "../Words3Test.t.sol"; +// import { Merkle } from "../murky/src/Merkle.sol"; +// import "forge-std/Test.sol"; + +// contract Transfer is Words3Test { +// IWorld world; + +// function setUp() public override { +// super.setUp(); +// world = IWorld(worldAddress); +// setDefaultLetterOdds(); +// } + +// function test_Transfer() public { +// Letter[] memory initialWord = new Letter[](2); +// initialWord[0] = Letter.H; +// initialWord[1] = Letter.I; +// world.words3__start({ +// initialWord: initialWord, +// merkleRoot: bytes32(0), +// vrgdaTargetPrice: 1, +// vrgdaPriceDecay: 1e17, +// vrgdaPerDayInitial: 100e18, +// vrgdaPower: 1e16, +// crossWordRewardFraction: 3, +// bonusDistance: 5 +// }); + +// address player = address(0x123); +// address to = address(0x456); +// vm.deal(player, 50 ether); +// vm.startPrank(player); +// for (uint256 i = 0; i < 50; i++) { +// uint256 price = world.words3__getDrawPrice(); +// vm.warp(block.timestamp + 1 days); +// world.words3__draw{ value: price }(player); +// } +// assertEq(PlayerLetters.get({ player: to, letter: Letter.A }), 0); +// Letter[] memory transferLetters = new Letter[](2); +// transferLetters[0] = Letter.A; +// transferLetters[1] = Letter.B; +// world.words3__transfer({ letters: transferLetters, to: to }); +// assertEq(PlayerLetters.get({ player: to, letter: Letter.A }), 1); +// assertEq(PlayerLetters.get({ player: to, letter: Letter.B }), 1); +// vm.stopPrank(); +// } +// } diff --git a/src/test/integration/WorldExists.t.sol b/packages/game/src/test/integration/WorldExists.t.sol similarity index 77% rename from src/test/integration/WorldExists.t.sol rename to packages/game/src/test/integration/WorldExists.t.sol index b6fce24..2f319d6 100644 --- a/src/test/integration/WorldExists.t.sol +++ b/packages/game/src/test/integration/WorldExists.t.sol @@ -7,13 +7,6 @@ import { Words3Test } from "../Words3Test.t.sol"; import "forge-std/Test.sol"; contract WorldExists is Words3Test { - IWorld world; - - function setUp() public override { - super.setUp(); - world = IWorld(worldAddress); - } - function testWorldExists() public { uint256 codeSize; address addr = worldAddress; diff --git a/packages/game/src/test/murky/.dockerignore b/packages/game/src/test/murky/.dockerignore new file mode 100644 index 0000000..379fe03 --- /dev/null +++ b/packages/game/src/test/murky/.dockerignore @@ -0,0 +1,3 @@ +out +cache +*.txt \ No newline at end of file diff --git a/packages/game/src/test/murky/.gas-snapshot b/packages/game/src/test/murky/.gas-snapshot new file mode 100644 index 0000000..3af1229 --- /dev/null +++ b/packages/game/src/test/murky/.gas-snapshot @@ -0,0 +1,4 @@ +StandardizedInputTest:testMerkleGenerateProofStandard() (gas: 751849) +StandardizedInputTest:testMerkleVerifyProofStandard() (gas: 846894) +StandardizedInputTest:testXorkleGenerateProofStandard() (gas: 695233) +StandardizedInputTest:testXorkleVerifyProofStandard() (gas: 779721) diff --git a/packages/game/src/test/murky/.github/workflows/run_tests.yml b/packages/game/src/test/murky/.github/workflows/run_tests.yml new file mode 100644 index 0000000..f43bdb6 --- /dev/null +++ b/packages/game/src/test/murky/.github/workflows/run_tests.yml @@ -0,0 +1,36 @@ +on: + push: + branches: + - main + pull_request: + +name: tests + +jobs: + check: + name: Run All Tests + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + submodules: recursive + - uses: actions/setup-node@v3 + with: + node-version: 16.15.1 + + - name: Install Foundry + uses: foundry-rs/foundry-toolchain@v1 + with: + version: nightly + + - name: Run Fuzzed Unit Tests + run: forge test --no-match-path src/test/StandardInput.t.sol + + - name: Run Differential Tests + run: | + npm --prefix differential_testing/scripts/ install + npm --prefix differential_testing/scripts/ run compile + FOUNDRY_FUZZ_RUNS=512 forge test --ffi -c differential_testing/test/DifferentialTests.t.sol + + - name: Run Standard Gas Snapshotting + run: forge snapshot --gas-report --ffi --match-path src/test/StandardInput.t.sol \ No newline at end of file diff --git a/packages/game/src/test/murky/.github/workflows/slither.yml b/packages/game/src/test/murky/.github/workflows/slither.yml new file mode 100644 index 0000000..5c23a9f --- /dev/null +++ b/packages/game/src/test/murky/.github/workflows/slither.yml @@ -0,0 +1,16 @@ +name: Slither Analysis +on: + push: + branches: + - main + pull_request: +jobs: + analyze: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: crytic/slither-action@v0.2.0 + with: + target: 'src/' + slither-args: '--exclude-informational --checklist' + fail-on: 'low' diff --git a/packages/game/src/test/murky/.gitignore b/packages/game/src/test/murky/.gitignore new file mode 100644 index 0000000..177604b --- /dev/null +++ b/packages/game/src/test/murky/.gitignore @@ -0,0 +1,8 @@ +cache/ +out/ +*.txt +differential_testing/**/node_modules +differential_testing/**/*.js +differential_testing/data/input + +!remappings.txt \ No newline at end of file diff --git a/packages/game/src/test/murky/.gitmodules b/packages/game/src/test/murky/.gitmodules new file mode 100644 index 0000000..3676266 --- /dev/null +++ b/packages/game/src/test/murky/.gitmodules @@ -0,0 +1,6 @@ +[submodule "lib/openzeppelin-contracts"] + path = lib/openzeppelin-contracts + url = https://github.com/openzeppelin/openzeppelin-contracts +[submodule "lib/forge-std"] + path = lib/forge-std + url = https://github.com/foundry-rs/forge-std diff --git a/packages/game/src/test/murky/Dockerfile.deploy b/packages/game/src/test/murky/Dockerfile.deploy new file mode 100644 index 0000000..d816be1 --- /dev/null +++ b/packages/game/src/test/murky/Dockerfile.deploy @@ -0,0 +1,7 @@ +from ghcr.io/gakonst/foundry:nightly + +WORKDIR /murky +COPY . . +RUN forge build +RUN forge test +ENTRYPOINT ["forge", "create"] \ No newline at end of file diff --git a/packages/game/src/test/murky/README.md b/packages/game/src/test/murky/README.md new file mode 100644 index 0000000..fd3b8b7 --- /dev/null +++ b/packages/game/src/test/murky/README.md @@ -0,0 +1,64 @@ +## Merkle Generator and Prover in Solidity +![Tests](https://github.com/dmfxyz/murky/actions/workflows/run_tests.yml/badge.svg?event=push) +![Slither](https://github.com/dmfxyz/murky/actions/workflows/slither.yml/badge.svg?event=push) + + +Murky contains contracts that can generate merkle roots and proofs. Murky also performs inclusion verification. Both XOR-based and a concatenation-based hashing are currently supported. + +The root generation, proof generation, and verification functions are all fuzz tested (configured 5,000 runs by default) using arbitrary bytes32 arrays and uint leaves. There is also standardized testing and differential testing. + +> Note: Code is not audited (yet). Please do your own due dilligence testing if you are planning to use this code! + +You can currently see Murky in action in the [Seaport](https://github.com/ProjectOpenSea/Seaport) test suite. + +### Building Locally +You can run the repo using [Foundry](https://github.com/gakonst/foundry). +1. clone the repo +2. `forge install` +3. `forge test` + +### Example Usage +```solidity +// Initialize +Merkle m = new Merkle(); +// Toy Data +bytes32[] memory data = new bytes32[](4); +data[0] = bytes32("0x0"); +data[1] = bytes32("0x1"); +data[2] = bytes32("0x2"); +data[3] = bytes32("0x3"); +// Get Root, Proof, and Verify +bytes32 root = m.getRoot(data); +bytes32[] memory proof = m.getProof(data, 2); // will get proof for 0x2 value +bool verified = m.verifyProof(root, proof, data[2]); // true! +assertTrue(verified); +``` + +### Notes +* `Xorkle.sol` is implemented as a XOR tree. This allows for greater gas efficiency: hashes are calculated on 32 bytes instead of 64; it is agnostic of sibling order so there is less lt/gt branching. Note that XOR trees are not appropriate for all use-cases*. + +* `Merkle.sol` is implemented using concatenation and thus is a generic merkle tree. It's less efficient, but is compatible with [OpenZeppelin's Prover](https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/cryptography/MerkleProof.sol) and other implementations. Use this one if you aren't sure. Compatiblity with OZ Prover is implemented as a fuzz test. + +### Testing +The code is both "fuzz" tested and tested with standardized data. [Standard data info](./src/test/standard_data/). + +When measuring a change's performance impact, please ensure you are benchmarking using standardized data only*: + +```sh +forge snapshot --ffi --match-path src/test/StandardInput.t.sol +``` + +Passing just standardized tests is not sufficient for implementation changes. All changes must pass all tests, preferably with 10,000+ fuzz runs. + +There is also early support for [differential testing](./differential_testing/). + +> * It's possible that an improvement is not adequetly revealed by the current standardized data. If that is the case, new standard data should be provided with an accompanying description/justification. + +#### Latest Gas +![gas report](./reports/murky_gas_report.png) + +[Gas Snapshots](./.gas-snapshot) are run only on the standardized tests. See [Testing](#testing). + +--- +#### TODO +- [ ] \* Do a writeup on the use-cases for XORs. \ No newline at end of file diff --git a/packages/game/src/test/murky/foundry.toml b/packages/game/src/test/murky/foundry.toml new file mode 100644 index 0000000..a4d1626 --- /dev/null +++ b/packages/game/src/test/murky/foundry.toml @@ -0,0 +1,6 @@ +[profile.default] +src = 'src' +out = 'out' +libs = ['lib'] +fuzz_runs=5000 +# See more config options https://github.com/gakonst/foundry/tree/master/config \ No newline at end of file diff --git a/packages/game/src/test/murky/remappings.txt b/packages/game/src/test/murky/remappings.txt new file mode 100644 index 0000000..f65f7e6 --- /dev/null +++ b/packages/game/src/test/murky/remappings.txt @@ -0,0 +1,2 @@ +forge-std/=lib/forge-std/src/ +openzeppelin-contracts/=lib/openzeppelin-contracts/ \ No newline at end of file diff --git a/packages/game/src/test/murky/reports/murky_gas_report.png b/packages/game/src/test/murky/reports/murky_gas_report.png new file mode 100644 index 0000000..7daeb85 Binary files /dev/null and b/packages/game/src/test/murky/reports/murky_gas_report.png differ diff --git a/packages/game/src/test/murky/src/Merkle.sol b/packages/game/src/test/murky/src/Merkle.sol new file mode 100644 index 0000000..20e7549 --- /dev/null +++ b/packages/game/src/test/murky/src/Merkle.sol @@ -0,0 +1,31 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.4; + +import "./common/MurkyBase.sol"; + +/// @notice Nascent, simple, kinda efficient (and improving!) Merkle proof generator and verifier +/// @author dmfxyz +/// @dev Note Generic Merkle Tree +contract Merkle is MurkyBase { + /** + * + * HASHING FUNCTION * + * + */ + + /// ascending sort and concat prior to hashing + function hashLeafPairs(bytes32 left, bytes32 right) public pure override returns (bytes32 _hash) { + assembly { + switch lt(left, right) + case 0 { + mstore(0x0, right) + mstore(0x20, left) + } + default { + mstore(0x0, left) + mstore(0x20, right) + } + _hash := keccak256(0x0, 0x40) + } + } +} diff --git a/packages/game/src/test/murky/src/Xorkle.sol b/packages/game/src/test/murky/src/Xorkle.sol new file mode 100644 index 0000000..efb4ea6 --- /dev/null +++ b/packages/game/src/test/murky/src/Xorkle.sol @@ -0,0 +1,22 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.4; + +import "./common/MurkyBase.sol"; + +/// @notice Nascent, simple, kinda efficient (and improving!) Merkle proof generator and verifier +/// @author dmfxyz +/// @dev Note Xor Based "Merkle" Tree +contract Xorkle is MurkyBase { + /** + * + * HASHING FUNCTION * + * + */ + function hashLeafPairs(bytes32 left, bytes32 right) public pure override returns (bytes32 _hash) { + // saves a few gas lol + assembly { + mstore(0x0, xor(left, right)) + _hash := keccak256(0x0, 0x20) + } + } +} diff --git a/packages/game/src/test/murky/src/common/MurkyBase.sol b/packages/game/src/test/murky/src/common/MurkyBase.sol new file mode 100644 index 0000000..5730202 --- /dev/null +++ b/packages/game/src/test/murky/src/common/MurkyBase.sol @@ -0,0 +1,194 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.4; + +abstract contract MurkyBase { + /** + * + * CONSTRUCTOR * + * + */ + constructor() { } + + /** + * + * VIRTUAL HASHING FUNCTIONS * + * + */ + function hashLeafPairs(bytes32 left, bytes32 right) public pure virtual returns (bytes32 _hash); + + /** + * + * PROOF VERIFICATION * + * + */ + function verifyProof(bytes32 root, bytes32[] memory proof, bytes32 valueToProve) external pure returns (bool) { + // proof length must be less than max array size + bytes32 rollingHash = valueToProve; + uint256 length = proof.length; + unchecked { + for (uint256 i = 0; i < length; ++i) { + rollingHash = hashLeafPairs(rollingHash, proof[i]); + } + } + return root == rollingHash; + } + + /** + * + * PROOF GENERATION * + * + */ + function getRoot(bytes32[] memory data) public pure returns (bytes32) { + require(data.length > 1, "won't generate root for single leaf"); + while (data.length > 1) { + data = hashLevel(data); + } + return data[0]; + } + + function getProof(bytes32[] memory data, uint256 node) public pure returns (bytes32[] memory) { + require(data.length > 1, "won't generate proof for single leaf"); + // The size of the proof is equal to the ceiling of log2(numLeaves) + bytes32[] memory result = new bytes32[](log2ceilBitMagic(data.length)); + uint256 pos = 0; + + // Two overflow risks: node, pos + // node: max array size is 2**256-1. Largest index in the array will be 1 less than that. Also, + // for dynamic arrays, size is limited to 2**64-1 + // pos: pos is bounded by log2(data.length), which should be less than type(uint256).max + while (data.length > 1) { + unchecked { + if (node & 0x1 == 1) { + result[pos] = data[node - 1]; + } else if (node + 1 == data.length) { + result[pos] = bytes32(0); + } else { + result[pos] = data[node + 1]; + } + ++pos; + node /= 2; + } + data = hashLevel(data); + } + return result; + } + + ///@dev function is private to prevent unsafe data from being passed + function hashLevel(bytes32[] memory data) private pure returns (bytes32[] memory) { + bytes32[] memory result; + + // Function is private, and all internal callers check that data.length >=2. + // Underflow is not possible as lowest possible value for data/result index is 1 + // overflow should be safe as length is / 2 always. + unchecked { + uint256 length = data.length; + if (length & 0x1 == 1) { + result = new bytes32[](length / 2 + 1); + result[result.length - 1] = hashLeafPairs(data[length - 1], bytes32(0)); + } else { + result = new bytes32[](length / 2); + } + // pos is upper bounded by data.length / 2, so safe even if array is at max size + uint256 pos = 0; + for (uint256 i = 0; i < length - 1; i += 2) { + result[pos] = hashLeafPairs(data[i], data[i + 1]); + ++pos; + } + } + return result; + } + + /** + * + * MATH "LIBRARY" * + * + */ + + /// @dev Note that x is assumed > 0 + function log2ceil(uint256 x) public pure returns (uint256) { + uint256 ceil = 0; + uint256 pOf2; + // If x is a power of 2, then this function will return a ceiling + // that is 1 greater than the actual ceiling. So we need to check if + // x is a power of 2, and subtract one from ceil if so. + assembly { + // we check by seeing if x == (~x + 1) & x. This applies a mask + // to find the lowest set bit of x and then checks it for equality + // with x. If they are equal, then x is a power of 2. + + /* Example + x has single bit set + x := 0000_1000 + (~x + 1) = (1111_0111) + 1 = 1111_1000 + (1111_1000 & 0000_1000) = 0000_1000 == x + + x has multiple bits set + x := 1001_0010 + (~x + 1) = (0110_1101 + 1) = 0110_1110 + (0110_1110 & x) = 0000_0010 != x + */ + + // we do some assembly magic to treat the bool as an integer later on + pOf2 := eq(and(add(not(x), 1), x), x) + } + + // if x == type(uint256).max, than ceil is capped at 256 + // if x == 0, then pO2 == 0, so ceil won't underflow + unchecked { + while (x > 0) { + x >>= 1; + ceil++; + } + ceil -= pOf2; // see above + } + return ceil; + } + + /// Original bitmagic adapted from https://github.com/paulrberg/prb-math/blob/main/contracts/PRBMath.sol + /// @dev Note that x assumed > 1 + function log2ceilBitMagic(uint256 x) public pure returns (uint256) { + if (x <= 1) { + return 0; + } + uint256 msb = 0; + uint256 _x = x; + if (x >= 2 ** 128) { + x >>= 128; + msb += 128; + } + if (x >= 2 ** 64) { + x >>= 64; + msb += 64; + } + if (x >= 2 ** 32) { + x >>= 32; + msb += 32; + } + if (x >= 2 ** 16) { + x >>= 16; + msb += 16; + } + if (x >= 2 ** 8) { + x >>= 8; + msb += 8; + } + if (x >= 2 ** 4) { + x >>= 4; + msb += 4; + } + if (x >= 2 ** 2) { + x >>= 2; + msb += 2; + } + if (x >= 2 ** 1) { + msb += 1; + } + + uint256 lsb = (~_x + 1) & _x; + if ((lsb == _x) && (msb > 0)) { + return msb; + } else { + return msb + 1; + } + } +} diff --git a/packages/game/src/test/unit/Draw.t.sol b/packages/game/src/test/unit/Draw.t.sol new file mode 100644 index 0000000..dedf7a9 --- /dev/null +++ b/packages/game/src/test/unit/Draw.t.sol @@ -0,0 +1,35 @@ +// SPDX-License-Identifier: MIT +pragma solidity >=0.8.0; + +import { Words3Test } from "../Words3Test.t.sol"; +import "forge-std/Test.sol"; + +contract DrawTest is Words3Test { + bytes32[] public words; + + function setUp() public override { + super.setUp(); + setDefaultLetterOdds(); + } + + function test_Draw() public { + address player = address(0x123face); + startEmpty(); + vm.deal(player, 100 ether); + + vm.prank(player); + uint256 id = world.words3__requestDraw{ value: 100 ether }(player); + + vm.roll(block.number + 1); + world.words3__fulfillDraw(id); + } + + function test_InstantDraw() public { + address player = address(0x123face); + startEmpty(); + vm.deal(player, 100 ether); + + vm.prank(player); + world.words3__instantDraw{ value: 100 ether }(player); + } + } diff --git a/src/test/unit/LibBoard.t.sol b/packages/game/src/test/unit/LibBoard.t.sol similarity index 99% rename from src/test/unit/LibBoard.t.sol rename to packages/game/src/test/unit/LibBoard.t.sol index c40638e..093c0f5 100644 --- a/src/test/unit/LibBoard.t.sol +++ b/packages/game/src/test/unit/LibBoard.t.sol @@ -16,12 +16,10 @@ import { Wrapper } from "./Wrapper.sol"; import "forge-std/Test.sol"; contract LibBoardTest is Words3Test { - IWorld world; Wrapper wrapper; function setUp() public override { super.setUp(); - world = IWorld(worldAddress); wrapper = new Wrapper(); } diff --git a/src/test/unit/LibBonus.t.sol b/packages/game/src/test/unit/LibBonus.t.sol similarity index 100% rename from src/test/unit/LibBonus.t.sol rename to packages/game/src/test/unit/LibBonus.t.sol diff --git a/src/test/unit/LibGame.t.sol b/packages/game/src/test/unit/LibGame.t.sol similarity index 92% rename from src/test/unit/LibGame.t.sol rename to packages/game/src/test/unit/LibGame.t.sol index f867125..dda7ddd 100644 --- a/src/test/unit/LibGame.t.sol +++ b/packages/game/src/test/unit/LibGame.t.sol @@ -11,13 +11,6 @@ import { Words3Test } from "../Words3Test.t.sol"; import "forge-std/Test.sol"; contract LibGameTest is Words3Test { - IWorld world; - - function setUp() public override { - super.setUp(); - world = IWorld(worldAddress); - } - function testCanPlay() public { assertFalse(LibGame.canPlay()); vm.startPrank(deployerAddress); diff --git a/src/test/unit/LibLetters.t.sol b/packages/game/src/test/unit/LibLetters.t.sol similarity index 100% rename from src/test/unit/LibLetters.t.sol rename to packages/game/src/test/unit/LibLetters.t.sol diff --git a/src/test/unit/LibPlay.t.sol b/packages/game/src/test/unit/LibPlay.t.sol similarity index 99% rename from src/test/unit/LibPlay.t.sol rename to packages/game/src/test/unit/LibPlay.t.sol index 757169a..7991f46 100644 --- a/src/test/unit/LibPlay.t.sol +++ b/packages/game/src/test/unit/LibPlay.t.sol @@ -31,14 +31,12 @@ import { Wrapper } from "./Wrapper.sol"; import "forge-std/Test.sol"; contract LibPlayTest is Words3Test { - IWorld world; bytes32[] public words; Merkle private m; Wrapper wrapper; function setUp() public override { super.setUp(); - world = IWorld(worldAddress); wrapper = new Wrapper(); m = new Merkle(); diff --git a/src/test/unit/LibPoints.t.sol b/packages/game/src/test/unit/LibPoints.t.sol similarity index 96% rename from src/test/unit/LibPoints.t.sol rename to packages/game/src/test/unit/LibPoints.t.sol index a334e00..ce3e407 100644 --- a/src/test/unit/LibPoints.t.sol +++ b/packages/game/src/test/unit/LibPoints.t.sol @@ -18,13 +18,11 @@ import { Wrapper } from "./Wrapper.sol"; import "forge-std/Test.sol"; contract LibPointsTest is Words3Test { - IWorld world; Wrapper wrapper; function setUp() public override { super.setUp(); wrapper = new Wrapper(); - world = IWorld(worldAddress); } function testGetBaseLetterPoints() public { @@ -81,7 +79,7 @@ contract LibPointsTest is Words3Test { Letter[] memory initialWord = new Letter[](1); initialWord[0] = Letter.A; uint16 bonusDistance = 8; - world.start(initialWord, bytes32(0x0), 0, 1e17, 3e18, 1e16, 3, bonusDistance); + world.words3__start(initialWord, bytes32(0x0), 0, 1e17, 3e18, 1e16, 3, bonusDistance); Letter[] memory playWord = new Letter[](bonusDistance); Letter[] memory filledWord = new Letter[](bonusDistance); @@ -110,7 +108,7 @@ contract LibPointsTest is Words3Test { Letter[] memory initialWord = new Letter[](1); initialWord[0] = Letter.A; uint16 bonusDistance = 3; - world.start(initialWord, bytes32(0x0), 0, 1e17, 3e18, 1e16, 3, bonusDistance); + world.words3__start(initialWord, bytes32(0x0), 0, 1e17, 3e18, 1e16, 3, bonusDistance); // If the word does not touch any bonus tiles, points are equal to the base point value uint256 minLength = playWordRaw.length < bonusDistance - 1 ? playWordRaw.length : bonusDistance - 2; diff --git a/src/test/unit/LibPrice.t.sol b/packages/game/src/test/unit/LibPrice.t.sol similarity index 100% rename from src/test/unit/LibPrice.t.sol rename to packages/game/src/test/unit/LibPrice.t.sol diff --git a/src/test/unit/LibTreasury.t.sol b/packages/game/src/test/unit/LibTreasury.t.sol similarity index 100% rename from src/test/unit/LibTreasury.t.sol rename to packages/game/src/test/unit/LibTreasury.t.sol diff --git a/src/test/unit/Wrapper.sol b/packages/game/src/test/unit/Wrapper.sol similarity index 100% rename from src/test/unit/Wrapper.sol rename to packages/game/src/test/unit/Wrapper.sol diff --git a/tsconfig.json b/packages/game/tsconfig.json similarity index 99% rename from tsconfig.json rename to packages/game/tsconfig.json index 270db8f..fa838db 100644 --- a/tsconfig.json +++ b/packages/game/tsconfig.json @@ -10,4 +10,4 @@ "forceConsistentCasingInFileNames": true, "moduleResolution": "node" } -} +} \ No newline at end of file diff --git a/worlds.json b/packages/game/worlds.json similarity index 91% rename from worlds.json rename to packages/game/worlds.json index a1b5e4a..eb94a2a 100644 --- a/worlds.json +++ b/packages/game/worlds.json @@ -20,7 +20,7 @@ "blockNumber": 603227 }, "31337": { - "address": "0x4f4ddafbc93cf8d11a253f21ddbcf836139efdec" + "address": "0xd6c8022f1af8e9d7c3825557a1374ee518c65a4e" }, "84531": { "address": "0xEF7c64d4773C13158A2419D43b68B6808C00421b", diff --git a/packages/rng/foundry.toml b/packages/rng/foundry.toml new file mode 100644 index 0000000..6d52f29 --- /dev/null +++ b/packages/rng/foundry.toml @@ -0,0 +1,28 @@ +[fmt] + sort_imports=true + bracket_spacing = true + int_types = "long" + line_length = 120 + multiline_func_header = "all" + number_underscore = "thousands" + quote_style = "double" + tab_width = 4 + wrap_comments = true + +[profile.default] + solc_version = "0.8.24" + ffi = false + optimizer = true + optimizer_runs = 3000 + verbosity = 1 + src = "src" + test = "test" + out = "out" + allow_paths = [ + "../../node_modules", + ] + extra_output_files = [ + "abi", + "evm.bytecode" + ] + fs_permissions = [{ access = "read", path = "./"}] \ No newline at end of file diff --git a/packages/rng/mud.config.ts b/packages/rng/mud.config.ts new file mode 100644 index 0000000..4a6b799 --- /dev/null +++ b/packages/rng/mud.config.ts @@ -0,0 +1,35 @@ +import { defineWorld } from "@latticexyz/world"; + +export default defineWorld({ + namespace: "rng", + tables: { + Id: { + key: [], + schema: { + value: "uint256", + } + }, + Config: { + key: [], + schema: { + period: "uint256", // In number of blocks + valueSet: "bool" + } + }, + Request: { + key: ["id"], + schema: { + id: "uint256", + blockNumber: "uint256", + timestamp: "uint256", + }, + }, + Response: { + key: ["id"], + schema: { + id: "uint256", + value: "uint256", + }, + } + }, +}); diff --git a/packages/rng/package.json b/packages/rng/package.json new file mode 100644 index 0000000..cf0b2d2 --- /dev/null +++ b/packages/rng/package.json @@ -0,0 +1,34 @@ +{ + "name": "rng", + "private": true, + "license": "MIT", + "scripts": { + "build": "mud worldgen && mud tablegen && forge build", + "clean": "forge clean && rimraf src/codegen", + "deploy:local": "bun run build && mud deploy", + "deploy:testnet": "bun run build && mud deploy --profile=redstone-garnet", + "deploy:base": "bun run build && mud deploy --profile=base", + "dev": "bun mud dev-contracts", + "test": "mud test" + }, + "devDependencies": { + "@latticexyz/cli": "2.0.6", + "@latticexyz/config": "2.0.6", + "@latticexyz/faucet": "2.0.6", + "@latticexyz/schema-type": "2.0.6", + "@latticexyz/store": "2.0.6", + "@latticexyz/world": "2.0.6", + "@latticexyz/world-modules": "2.0.6", + "@solidstate/contracts": "^0.0.52", + "@types/node": "^18.15.11", + "ds-test": "https://github.com/dapphub/ds-test.git#e282159d5170298eb2455a6c05280ab5a73a4ef0", + "forge-std": "https://github.com/foundry-rs/forge-std.git#74cfb77e308dd188d2f58864aaf44963ae6b88b1", + "prettier": "3.2.5", + "prettier-plugin-solidity": "1.3.1", + "rimraf": "^3.0.2", + "solhint": "^3.4.1", + "solhint-config-mud": "2.0.6", + "solhint-plugin-mud": "2.0.6", + "typescript": "5.4.2" + } +} diff --git a/packages/rng/remappings.txt b/packages/rng/remappings.txt new file mode 100644 index 0000000..66ba3c3 --- /dev/null +++ b/packages/rng/remappings.txt @@ -0,0 +1,7 @@ +@latticexyz/=../../node_modules/@latticexyz/ +ds-test/=../../node_modules/ds-test/src/ +forge-std/=../../node_modules/forge-std/src/ + +codegen/=src/codegen +systems/=src/systems +libraries/=src/libraries \ No newline at end of file diff --git a/packages/rng/src/codegen/index.sol b/packages/rng/src/codegen/index.sol new file mode 100644 index 0000000..d0f4f44 --- /dev/null +++ b/packages/rng/src/codegen/index.sol @@ -0,0 +1,9 @@ +// SPDX-License-Identifier: MIT +pragma solidity >=0.8.24; + +/* Autogenerated file. Do not edit manually. */ + +import { Id } from "./tables/Id.sol"; +import { Config, ConfigData } from "./tables/Config.sol"; +import { Request, RequestData } from "./tables/Request.sol"; +import { Response } from "./tables/Response.sol"; diff --git a/packages/rng/src/codegen/tables/Config.sol b/packages/rng/src/codegen/tables/Config.sol new file mode 100644 index 0000000..b5c79c3 --- /dev/null +++ b/packages/rng/src/codegen/tables/Config.sol @@ -0,0 +1,312 @@ +// SPDX-License-Identifier: MIT +pragma solidity >=0.8.24; + +/* Autogenerated file. Do not edit manually. */ + +// Import store internals +import { IStore } from "@latticexyz/store/src/IStore.sol"; +import { StoreSwitch } from "@latticexyz/store/src/StoreSwitch.sol"; +import { StoreCore } from "@latticexyz/store/src/StoreCore.sol"; +import { Bytes } from "@latticexyz/store/src/Bytes.sol"; +import { Memory } from "@latticexyz/store/src/Memory.sol"; +import { SliceLib } from "@latticexyz/store/src/Slice.sol"; +import { EncodeArray } from "@latticexyz/store/src/tightcoder/EncodeArray.sol"; +import { FieldLayout } from "@latticexyz/store/src/FieldLayout.sol"; +import { Schema } from "@latticexyz/store/src/Schema.sol"; +import { EncodedLengths, EncodedLengthsLib } from "@latticexyz/store/src/EncodedLengths.sol"; +import { ResourceId } from "@latticexyz/store/src/ResourceId.sol"; + +struct ConfigData { + uint256 period; + bool valueSet; +} + +library Config { + // Hex below is the result of `WorldResourceIdLib.encode({ namespace: "rng", name: "Config", typeId: RESOURCE_TABLE });` + ResourceId constant _tableId = ResourceId.wrap(0x7462726e670000000000000000000000436f6e66696700000000000000000000); + + FieldLayout constant _fieldLayout = + FieldLayout.wrap(0x0021020020010000000000000000000000000000000000000000000000000000); + + // Hex-encoded key schema of () + Schema constant _keySchema = Schema.wrap(0x0000000000000000000000000000000000000000000000000000000000000000); + // Hex-encoded value schema of (uint256, bool) + Schema constant _valueSchema = Schema.wrap(0x002102001f600000000000000000000000000000000000000000000000000000); + + /** + * @notice Get the table's key field names. + * @return keyNames An array of strings with the names of key fields. + */ + function getKeyNames() internal pure returns (string[] memory keyNames) { + keyNames = new string[](0); + } + + /** + * @notice Get the table's value field names. + * @return fieldNames An array of strings with the names of value fields. + */ + function getFieldNames() internal pure returns (string[] memory fieldNames) { + fieldNames = new string[](2); + fieldNames[0] = "period"; + fieldNames[1] = "valueSet"; + } + + /** + * @notice Register the table with its config. + */ + function register() internal { + StoreSwitch.registerTable(_tableId, _fieldLayout, _keySchema, _valueSchema, getKeyNames(), getFieldNames()); + } + + /** + * @notice Register the table with its config. + */ + function _register() internal { + StoreCore.registerTable(_tableId, _fieldLayout, _keySchema, _valueSchema, getKeyNames(), getFieldNames()); + } + + /** + * @notice Get period. + */ + function getPeriod() internal view returns (uint256 period) { + bytes32[] memory _keyTuple = new bytes32[](0); + + bytes32 _blob = StoreSwitch.getStaticField(_tableId, _keyTuple, 0, _fieldLayout); + return (uint256(bytes32(_blob))); + } + + /** + * @notice Get period. + */ + function _getPeriod() internal view returns (uint256 period) { + bytes32[] memory _keyTuple = new bytes32[](0); + + bytes32 _blob = StoreCore.getStaticField(_tableId, _keyTuple, 0, _fieldLayout); + return (uint256(bytes32(_blob))); + } + + /** + * @notice Set period. + */ + function setPeriod(uint256 period) internal { + bytes32[] memory _keyTuple = new bytes32[](0); + + StoreSwitch.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((period)), _fieldLayout); + } + + /** + * @notice Set period. + */ + function _setPeriod(uint256 period) internal { + bytes32[] memory _keyTuple = new bytes32[](0); + + StoreCore.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((period)), _fieldLayout); + } + + /** + * @notice Get valueSet. + */ + function getValueSet() internal view returns (bool valueSet) { + bytes32[] memory _keyTuple = new bytes32[](0); + + bytes32 _blob = StoreSwitch.getStaticField(_tableId, _keyTuple, 1, _fieldLayout); + return (_toBool(uint8(bytes1(_blob)))); + } + + /** + * @notice Get valueSet. + */ + function _getValueSet() internal view returns (bool valueSet) { + bytes32[] memory _keyTuple = new bytes32[](0); + + bytes32 _blob = StoreCore.getStaticField(_tableId, _keyTuple, 1, _fieldLayout); + return (_toBool(uint8(bytes1(_blob)))); + } + + /** + * @notice Set valueSet. + */ + function setValueSet(bool valueSet) internal { + bytes32[] memory _keyTuple = new bytes32[](0); + + StoreSwitch.setStaticField(_tableId, _keyTuple, 1, abi.encodePacked((valueSet)), _fieldLayout); + } + + /** + * @notice Set valueSet. + */ + function _setValueSet(bool valueSet) internal { + bytes32[] memory _keyTuple = new bytes32[](0); + + StoreCore.setStaticField(_tableId, _keyTuple, 1, abi.encodePacked((valueSet)), _fieldLayout); + } + + /** + * @notice Get the full data. + */ + function get() internal view returns (ConfigData memory _table) { + bytes32[] memory _keyTuple = new bytes32[](0); + + (bytes memory _staticData, EncodedLengths _encodedLengths, bytes memory _dynamicData) = StoreSwitch.getRecord( + _tableId, + _keyTuple, + _fieldLayout + ); + return decode(_staticData, _encodedLengths, _dynamicData); + } + + /** + * @notice Get the full data. + */ + function _get() internal view returns (ConfigData memory _table) { + bytes32[] memory _keyTuple = new bytes32[](0); + + (bytes memory _staticData, EncodedLengths _encodedLengths, bytes memory _dynamicData) = StoreCore.getRecord( + _tableId, + _keyTuple, + _fieldLayout + ); + return decode(_staticData, _encodedLengths, _dynamicData); + } + + /** + * @notice Set the full data using individual values. + */ + function set(uint256 period, bool valueSet) internal { + bytes memory _staticData = encodeStatic(period, valueSet); + + EncodedLengths _encodedLengths; + bytes memory _dynamicData; + + bytes32[] memory _keyTuple = new bytes32[](0); + + StoreSwitch.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); + } + + /** + * @notice Set the full data using individual values. + */ + function _set(uint256 period, bool valueSet) internal { + bytes memory _staticData = encodeStatic(period, valueSet); + + EncodedLengths _encodedLengths; + bytes memory _dynamicData; + + bytes32[] memory _keyTuple = new bytes32[](0); + + StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); + } + + /** + * @notice Set the full data using the data struct. + */ + function set(ConfigData memory _table) internal { + bytes memory _staticData = encodeStatic(_table.period, _table.valueSet); + + EncodedLengths _encodedLengths; + bytes memory _dynamicData; + + bytes32[] memory _keyTuple = new bytes32[](0); + + StoreSwitch.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); + } + + /** + * @notice Set the full data using the data struct. + */ + function _set(ConfigData memory _table) internal { + bytes memory _staticData = encodeStatic(_table.period, _table.valueSet); + + EncodedLengths _encodedLengths; + bytes memory _dynamicData; + + bytes32[] memory _keyTuple = new bytes32[](0); + + StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); + } + + /** + * @notice Decode the tightly packed blob of static data using this table's field layout. + */ + function decodeStatic(bytes memory _blob) internal pure returns (uint256 period, bool valueSet) { + period = (uint256(Bytes.getBytes32(_blob, 0))); + + valueSet = (_toBool(uint8(Bytes.getBytes1(_blob, 32)))); + } + + /** + * @notice Decode the tightly packed blobs using this table's field layout. + * @param _staticData Tightly packed static fields. + * + * + */ + function decode( + bytes memory _staticData, + EncodedLengths, + bytes memory + ) internal pure returns (ConfigData memory _table) { + (_table.period, _table.valueSet) = decodeStatic(_staticData); + } + + /** + * @notice Delete all data for given keys. + */ + function deleteRecord() internal { + bytes32[] memory _keyTuple = new bytes32[](0); + + StoreSwitch.deleteRecord(_tableId, _keyTuple); + } + + /** + * @notice Delete all data for given keys. + */ + function _deleteRecord() internal { + bytes32[] memory _keyTuple = new bytes32[](0); + + StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout); + } + + /** + * @notice Tightly pack static (fixed length) data using this table's schema. + * @return The static data, encoded into a sequence of bytes. + */ + function encodeStatic(uint256 period, bool valueSet) internal pure returns (bytes memory) { + return abi.encodePacked(period, valueSet); + } + + /** + * @notice Encode all of a record's fields. + * @return The static (fixed length) data, encoded into a sequence of bytes. + * @return The lengths of the dynamic fields (packed into a single bytes32 value). + * @return The dynamic (variable length) data, encoded into a sequence of bytes. + */ + function encode(uint256 period, bool valueSet) internal pure returns (bytes memory, EncodedLengths, bytes memory) { + bytes memory _staticData = encodeStatic(period, valueSet); + + EncodedLengths _encodedLengths; + bytes memory _dynamicData; + + return (_staticData, _encodedLengths, _dynamicData); + } + + /** + * @notice Encode keys as a bytes32 array using this table's field layout. + */ + function encodeKeyTuple() internal pure returns (bytes32[] memory) { + bytes32[] memory _keyTuple = new bytes32[](0); + + return _keyTuple; + } +} + +/** + * @notice Cast a value to a bool. + * @dev Boolean values are encoded as uint8 (1 = true, 0 = false), but Solidity doesn't allow casting between uint8 and bool. + * @param value The uint8 value to convert. + * @return result The boolean value. + */ +function _toBool(uint8 value) pure returns (bool result) { + assembly { + result := value + } +} diff --git a/packages/rng/src/codegen/tables/Id.sol b/packages/rng/src/codegen/tables/Id.sol new file mode 100644 index 0000000..1a30526 --- /dev/null +++ b/packages/rng/src/codegen/tables/Id.sol @@ -0,0 +1,187 @@ +// SPDX-License-Identifier: MIT +pragma solidity >=0.8.24; + +/* Autogenerated file. Do not edit manually. */ + +// Import store internals +import { IStore } from "@latticexyz/store/src/IStore.sol"; +import { StoreSwitch } from "@latticexyz/store/src/StoreSwitch.sol"; +import { StoreCore } from "@latticexyz/store/src/StoreCore.sol"; +import { Bytes } from "@latticexyz/store/src/Bytes.sol"; +import { Memory } from "@latticexyz/store/src/Memory.sol"; +import { SliceLib } from "@latticexyz/store/src/Slice.sol"; +import { EncodeArray } from "@latticexyz/store/src/tightcoder/EncodeArray.sol"; +import { FieldLayout } from "@latticexyz/store/src/FieldLayout.sol"; +import { Schema } from "@latticexyz/store/src/Schema.sol"; +import { EncodedLengths, EncodedLengthsLib } from "@latticexyz/store/src/EncodedLengths.sol"; +import { ResourceId } from "@latticexyz/store/src/ResourceId.sol"; + +library Id { + // Hex below is the result of `WorldResourceIdLib.encode({ namespace: "rng", name: "Id", typeId: RESOURCE_TABLE });` + ResourceId constant _tableId = ResourceId.wrap(0x7462726e67000000000000000000000049640000000000000000000000000000); + + FieldLayout constant _fieldLayout = + FieldLayout.wrap(0x0020010020000000000000000000000000000000000000000000000000000000); + + // Hex-encoded key schema of () + Schema constant _keySchema = Schema.wrap(0x0000000000000000000000000000000000000000000000000000000000000000); + // Hex-encoded value schema of (uint256) + Schema constant _valueSchema = Schema.wrap(0x002001001f000000000000000000000000000000000000000000000000000000); + + /** + * @notice Get the table's key field names. + * @return keyNames An array of strings with the names of key fields. + */ + function getKeyNames() internal pure returns (string[] memory keyNames) { + keyNames = new string[](0); + } + + /** + * @notice Get the table's value field names. + * @return fieldNames An array of strings with the names of value fields. + */ + function getFieldNames() internal pure returns (string[] memory fieldNames) { + fieldNames = new string[](1); + fieldNames[0] = "value"; + } + + /** + * @notice Register the table with its config. + */ + function register() internal { + StoreSwitch.registerTable(_tableId, _fieldLayout, _keySchema, _valueSchema, getKeyNames(), getFieldNames()); + } + + /** + * @notice Register the table with its config. + */ + function _register() internal { + StoreCore.registerTable(_tableId, _fieldLayout, _keySchema, _valueSchema, getKeyNames(), getFieldNames()); + } + + /** + * @notice Get value. + */ + function getValue() internal view returns (uint256 value) { + bytes32[] memory _keyTuple = new bytes32[](0); + + bytes32 _blob = StoreSwitch.getStaticField(_tableId, _keyTuple, 0, _fieldLayout); + return (uint256(bytes32(_blob))); + } + + /** + * @notice Get value. + */ + function _getValue() internal view returns (uint256 value) { + bytes32[] memory _keyTuple = new bytes32[](0); + + bytes32 _blob = StoreCore.getStaticField(_tableId, _keyTuple, 0, _fieldLayout); + return (uint256(bytes32(_blob))); + } + + /** + * @notice Get value. + */ + function get() internal view returns (uint256 value) { + bytes32[] memory _keyTuple = new bytes32[](0); + + bytes32 _blob = StoreSwitch.getStaticField(_tableId, _keyTuple, 0, _fieldLayout); + return (uint256(bytes32(_blob))); + } + + /** + * @notice Get value. + */ + function _get() internal view returns (uint256 value) { + bytes32[] memory _keyTuple = new bytes32[](0); + + bytes32 _blob = StoreCore.getStaticField(_tableId, _keyTuple, 0, _fieldLayout); + return (uint256(bytes32(_blob))); + } + + /** + * @notice Set value. + */ + function setValue(uint256 value) internal { + bytes32[] memory _keyTuple = new bytes32[](0); + + StoreSwitch.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); + } + + /** + * @notice Set value. + */ + function _setValue(uint256 value) internal { + bytes32[] memory _keyTuple = new bytes32[](0); + + StoreCore.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); + } + + /** + * @notice Set value. + */ + function set(uint256 value) internal { + bytes32[] memory _keyTuple = new bytes32[](0); + + StoreSwitch.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); + } + + /** + * @notice Set value. + */ + function _set(uint256 value) internal { + bytes32[] memory _keyTuple = new bytes32[](0); + + StoreCore.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); + } + + /** + * @notice Delete all data for given keys. + */ + function deleteRecord() internal { + bytes32[] memory _keyTuple = new bytes32[](0); + + StoreSwitch.deleteRecord(_tableId, _keyTuple); + } + + /** + * @notice Delete all data for given keys. + */ + function _deleteRecord() internal { + bytes32[] memory _keyTuple = new bytes32[](0); + + StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout); + } + + /** + * @notice Tightly pack static (fixed length) data using this table's schema. + * @return The static data, encoded into a sequence of bytes. + */ + function encodeStatic(uint256 value) internal pure returns (bytes memory) { + return abi.encodePacked(value); + } + + /** + * @notice Encode all of a record's fields. + * @return The static (fixed length) data, encoded into a sequence of bytes. + * @return The lengths of the dynamic fields (packed into a single bytes32 value). + * @return The dynamic (variable length) data, encoded into a sequence of bytes. + */ + function encode(uint256 value) internal pure returns (bytes memory, EncodedLengths, bytes memory) { + bytes memory _staticData = encodeStatic(value); + + EncodedLengths _encodedLengths; + bytes memory _dynamicData; + + return (_staticData, _encodedLengths, _dynamicData); + } + + /** + * @notice Encode keys as a bytes32 array using this table's field layout. + */ + function encodeKeyTuple() internal pure returns (bytes32[] memory) { + bytes32[] memory _keyTuple = new bytes32[](0); + + return _keyTuple; + } +} diff --git a/packages/rng/src/codegen/tables/Request.sol b/packages/rng/src/codegen/tables/Request.sol new file mode 100644 index 0000000..238fbb1 --- /dev/null +++ b/packages/rng/src/codegen/tables/Request.sol @@ -0,0 +1,321 @@ +// SPDX-License-Identifier: MIT +pragma solidity >=0.8.24; + +/* Autogenerated file. Do not edit manually. */ + +// Import store internals +import { IStore } from "@latticexyz/store/src/IStore.sol"; +import { StoreSwitch } from "@latticexyz/store/src/StoreSwitch.sol"; +import { StoreCore } from "@latticexyz/store/src/StoreCore.sol"; +import { Bytes } from "@latticexyz/store/src/Bytes.sol"; +import { Memory } from "@latticexyz/store/src/Memory.sol"; +import { SliceLib } from "@latticexyz/store/src/Slice.sol"; +import { EncodeArray } from "@latticexyz/store/src/tightcoder/EncodeArray.sol"; +import { FieldLayout } from "@latticexyz/store/src/FieldLayout.sol"; +import { Schema } from "@latticexyz/store/src/Schema.sol"; +import { EncodedLengths, EncodedLengthsLib } from "@latticexyz/store/src/EncodedLengths.sol"; +import { ResourceId } from "@latticexyz/store/src/ResourceId.sol"; + +struct RequestData { + uint256 blockNumber; + uint256 timestamp; +} + +library Request { + // Hex below is the result of `WorldResourceIdLib.encode({ namespace: "rng", name: "Request", typeId: RESOURCE_TABLE });` + ResourceId constant _tableId = ResourceId.wrap(0x7462726e67000000000000000000000052657175657374000000000000000000); + + FieldLayout constant _fieldLayout = + FieldLayout.wrap(0x0040020020200000000000000000000000000000000000000000000000000000); + + // Hex-encoded key schema of (uint256) + Schema constant _keySchema = Schema.wrap(0x002001001f000000000000000000000000000000000000000000000000000000); + // Hex-encoded value schema of (uint256, uint256) + Schema constant _valueSchema = Schema.wrap(0x004002001f1f0000000000000000000000000000000000000000000000000000); + + /** + * @notice Get the table's key field names. + * @return keyNames An array of strings with the names of key fields. + */ + function getKeyNames() internal pure returns (string[] memory keyNames) { + keyNames = new string[](1); + keyNames[0] = "id"; + } + + /** + * @notice Get the table's value field names. + * @return fieldNames An array of strings with the names of value fields. + */ + function getFieldNames() internal pure returns (string[] memory fieldNames) { + fieldNames = new string[](2); + fieldNames[0] = "blockNumber"; + fieldNames[1] = "timestamp"; + } + + /** + * @notice Register the table with its config. + */ + function register() internal { + StoreSwitch.registerTable(_tableId, _fieldLayout, _keySchema, _valueSchema, getKeyNames(), getFieldNames()); + } + + /** + * @notice Register the table with its config. + */ + function _register() internal { + StoreCore.registerTable(_tableId, _fieldLayout, _keySchema, _valueSchema, getKeyNames(), getFieldNames()); + } + + /** + * @notice Get blockNumber. + */ + function getBlockNumber(uint256 id) internal view returns (uint256 blockNumber) { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = bytes32(uint256(id)); + + bytes32 _blob = StoreSwitch.getStaticField(_tableId, _keyTuple, 0, _fieldLayout); + return (uint256(bytes32(_blob))); + } + + /** + * @notice Get blockNumber. + */ + function _getBlockNumber(uint256 id) internal view returns (uint256 blockNumber) { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = bytes32(uint256(id)); + + bytes32 _blob = StoreCore.getStaticField(_tableId, _keyTuple, 0, _fieldLayout); + return (uint256(bytes32(_blob))); + } + + /** + * @notice Set blockNumber. + */ + function setBlockNumber(uint256 id, uint256 blockNumber) internal { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = bytes32(uint256(id)); + + StoreSwitch.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((blockNumber)), _fieldLayout); + } + + /** + * @notice Set blockNumber. + */ + function _setBlockNumber(uint256 id, uint256 blockNumber) internal { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = bytes32(uint256(id)); + + StoreCore.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((blockNumber)), _fieldLayout); + } + + /** + * @notice Get timestamp. + */ + function getTimestamp(uint256 id) internal view returns (uint256 timestamp) { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = bytes32(uint256(id)); + + bytes32 _blob = StoreSwitch.getStaticField(_tableId, _keyTuple, 1, _fieldLayout); + return (uint256(bytes32(_blob))); + } + + /** + * @notice Get timestamp. + */ + function _getTimestamp(uint256 id) internal view returns (uint256 timestamp) { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = bytes32(uint256(id)); + + bytes32 _blob = StoreCore.getStaticField(_tableId, _keyTuple, 1, _fieldLayout); + return (uint256(bytes32(_blob))); + } + + /** + * @notice Set timestamp. + */ + function setTimestamp(uint256 id, uint256 timestamp) internal { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = bytes32(uint256(id)); + + StoreSwitch.setStaticField(_tableId, _keyTuple, 1, abi.encodePacked((timestamp)), _fieldLayout); + } + + /** + * @notice Set timestamp. + */ + function _setTimestamp(uint256 id, uint256 timestamp) internal { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = bytes32(uint256(id)); + + StoreCore.setStaticField(_tableId, _keyTuple, 1, abi.encodePacked((timestamp)), _fieldLayout); + } + + /** + * @notice Get the full data. + */ + function get(uint256 id) internal view returns (RequestData memory _table) { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = bytes32(uint256(id)); + + (bytes memory _staticData, EncodedLengths _encodedLengths, bytes memory _dynamicData) = StoreSwitch.getRecord( + _tableId, + _keyTuple, + _fieldLayout + ); + return decode(_staticData, _encodedLengths, _dynamicData); + } + + /** + * @notice Get the full data. + */ + function _get(uint256 id) internal view returns (RequestData memory _table) { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = bytes32(uint256(id)); + + (bytes memory _staticData, EncodedLengths _encodedLengths, bytes memory _dynamicData) = StoreCore.getRecord( + _tableId, + _keyTuple, + _fieldLayout + ); + return decode(_staticData, _encodedLengths, _dynamicData); + } + + /** + * @notice Set the full data using individual values. + */ + function set(uint256 id, uint256 blockNumber, uint256 timestamp) internal { + bytes memory _staticData = encodeStatic(blockNumber, timestamp); + + EncodedLengths _encodedLengths; + bytes memory _dynamicData; + + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = bytes32(uint256(id)); + + StoreSwitch.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); + } + + /** + * @notice Set the full data using individual values. + */ + function _set(uint256 id, uint256 blockNumber, uint256 timestamp) internal { + bytes memory _staticData = encodeStatic(blockNumber, timestamp); + + EncodedLengths _encodedLengths; + bytes memory _dynamicData; + + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = bytes32(uint256(id)); + + StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); + } + + /** + * @notice Set the full data using the data struct. + */ + function set(uint256 id, RequestData memory _table) internal { + bytes memory _staticData = encodeStatic(_table.blockNumber, _table.timestamp); + + EncodedLengths _encodedLengths; + bytes memory _dynamicData; + + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = bytes32(uint256(id)); + + StoreSwitch.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); + } + + /** + * @notice Set the full data using the data struct. + */ + function _set(uint256 id, RequestData memory _table) internal { + bytes memory _staticData = encodeStatic(_table.blockNumber, _table.timestamp); + + EncodedLengths _encodedLengths; + bytes memory _dynamicData; + + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = bytes32(uint256(id)); + + StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); + } + + /** + * @notice Decode the tightly packed blob of static data using this table's field layout. + */ + function decodeStatic(bytes memory _blob) internal pure returns (uint256 blockNumber, uint256 timestamp) { + blockNumber = (uint256(Bytes.getBytes32(_blob, 0))); + + timestamp = (uint256(Bytes.getBytes32(_blob, 32))); + } + + /** + * @notice Decode the tightly packed blobs using this table's field layout. + * @param _staticData Tightly packed static fields. + * + * + */ + function decode( + bytes memory _staticData, + EncodedLengths, + bytes memory + ) internal pure returns (RequestData memory _table) { + (_table.blockNumber, _table.timestamp) = decodeStatic(_staticData); + } + + /** + * @notice Delete all data for given keys. + */ + function deleteRecord(uint256 id) internal { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = bytes32(uint256(id)); + + StoreSwitch.deleteRecord(_tableId, _keyTuple); + } + + /** + * @notice Delete all data for given keys. + */ + function _deleteRecord(uint256 id) internal { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = bytes32(uint256(id)); + + StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout); + } + + /** + * @notice Tightly pack static (fixed length) data using this table's schema. + * @return The static data, encoded into a sequence of bytes. + */ + function encodeStatic(uint256 blockNumber, uint256 timestamp) internal pure returns (bytes memory) { + return abi.encodePacked(blockNumber, timestamp); + } + + /** + * @notice Encode all of a record's fields. + * @return The static (fixed length) data, encoded into a sequence of bytes. + * @return The lengths of the dynamic fields (packed into a single bytes32 value). + * @return The dynamic (variable length) data, encoded into a sequence of bytes. + */ + function encode( + uint256 blockNumber, + uint256 timestamp + ) internal pure returns (bytes memory, EncodedLengths, bytes memory) { + bytes memory _staticData = encodeStatic(blockNumber, timestamp); + + EncodedLengths _encodedLengths; + bytes memory _dynamicData; + + return (_staticData, _encodedLengths, _dynamicData); + } + + /** + * @notice Encode keys as a bytes32 array using this table's field layout. + */ + function encodeKeyTuple(uint256 id) internal pure returns (bytes32[] memory) { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = bytes32(uint256(id)); + + return _keyTuple; + } +} diff --git a/packages/rng/src/codegen/tables/Response.sol b/packages/rng/src/codegen/tables/Response.sol new file mode 100644 index 0000000..4ee28c0 --- /dev/null +++ b/packages/rng/src/codegen/tables/Response.sol @@ -0,0 +1,199 @@ +// SPDX-License-Identifier: MIT +pragma solidity >=0.8.24; + +/* Autogenerated file. Do not edit manually. */ + +// Import store internals +import { IStore } from "@latticexyz/store/src/IStore.sol"; +import { StoreSwitch } from "@latticexyz/store/src/StoreSwitch.sol"; +import { StoreCore } from "@latticexyz/store/src/StoreCore.sol"; +import { Bytes } from "@latticexyz/store/src/Bytes.sol"; +import { Memory } from "@latticexyz/store/src/Memory.sol"; +import { SliceLib } from "@latticexyz/store/src/Slice.sol"; +import { EncodeArray } from "@latticexyz/store/src/tightcoder/EncodeArray.sol"; +import { FieldLayout } from "@latticexyz/store/src/FieldLayout.sol"; +import { Schema } from "@latticexyz/store/src/Schema.sol"; +import { EncodedLengths, EncodedLengthsLib } from "@latticexyz/store/src/EncodedLengths.sol"; +import { ResourceId } from "@latticexyz/store/src/ResourceId.sol"; + +library Response { + // Hex below is the result of `WorldResourceIdLib.encode({ namespace: "rng", name: "Response", typeId: RESOURCE_TABLE });` + ResourceId constant _tableId = ResourceId.wrap(0x7462726e670000000000000000000000526573706f6e73650000000000000000); + + FieldLayout constant _fieldLayout = + FieldLayout.wrap(0x0020010020000000000000000000000000000000000000000000000000000000); + + // Hex-encoded key schema of (uint256) + Schema constant _keySchema = Schema.wrap(0x002001001f000000000000000000000000000000000000000000000000000000); + // Hex-encoded value schema of (uint256) + Schema constant _valueSchema = Schema.wrap(0x002001001f000000000000000000000000000000000000000000000000000000); + + /** + * @notice Get the table's key field names. + * @return keyNames An array of strings with the names of key fields. + */ + function getKeyNames() internal pure returns (string[] memory keyNames) { + keyNames = new string[](1); + keyNames[0] = "id"; + } + + /** + * @notice Get the table's value field names. + * @return fieldNames An array of strings with the names of value fields. + */ + function getFieldNames() internal pure returns (string[] memory fieldNames) { + fieldNames = new string[](1); + fieldNames[0] = "value"; + } + + /** + * @notice Register the table with its config. + */ + function register() internal { + StoreSwitch.registerTable(_tableId, _fieldLayout, _keySchema, _valueSchema, getKeyNames(), getFieldNames()); + } + + /** + * @notice Register the table with its config. + */ + function _register() internal { + StoreCore.registerTable(_tableId, _fieldLayout, _keySchema, _valueSchema, getKeyNames(), getFieldNames()); + } + + /** + * @notice Get value. + */ + function getValue(uint256 id) internal view returns (uint256 value) { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = bytes32(uint256(id)); + + bytes32 _blob = StoreSwitch.getStaticField(_tableId, _keyTuple, 0, _fieldLayout); + return (uint256(bytes32(_blob))); + } + + /** + * @notice Get value. + */ + function _getValue(uint256 id) internal view returns (uint256 value) { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = bytes32(uint256(id)); + + bytes32 _blob = StoreCore.getStaticField(_tableId, _keyTuple, 0, _fieldLayout); + return (uint256(bytes32(_blob))); + } + + /** + * @notice Get value. + */ + function get(uint256 id) internal view returns (uint256 value) { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = bytes32(uint256(id)); + + bytes32 _blob = StoreSwitch.getStaticField(_tableId, _keyTuple, 0, _fieldLayout); + return (uint256(bytes32(_blob))); + } + + /** + * @notice Get value. + */ + function _get(uint256 id) internal view returns (uint256 value) { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = bytes32(uint256(id)); + + bytes32 _blob = StoreCore.getStaticField(_tableId, _keyTuple, 0, _fieldLayout); + return (uint256(bytes32(_blob))); + } + + /** + * @notice Set value. + */ + function setValue(uint256 id, uint256 value) internal { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = bytes32(uint256(id)); + + StoreSwitch.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); + } + + /** + * @notice Set value. + */ + function _setValue(uint256 id, uint256 value) internal { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = bytes32(uint256(id)); + + StoreCore.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); + } + + /** + * @notice Set value. + */ + function set(uint256 id, uint256 value) internal { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = bytes32(uint256(id)); + + StoreSwitch.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); + } + + /** + * @notice Set value. + */ + function _set(uint256 id, uint256 value) internal { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = bytes32(uint256(id)); + + StoreCore.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); + } + + /** + * @notice Delete all data for given keys. + */ + function deleteRecord(uint256 id) internal { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = bytes32(uint256(id)); + + StoreSwitch.deleteRecord(_tableId, _keyTuple); + } + + /** + * @notice Delete all data for given keys. + */ + function _deleteRecord(uint256 id) internal { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = bytes32(uint256(id)); + + StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout); + } + + /** + * @notice Tightly pack static (fixed length) data using this table's schema. + * @return The static data, encoded into a sequence of bytes. + */ + function encodeStatic(uint256 value) internal pure returns (bytes memory) { + return abi.encodePacked(value); + } + + /** + * @notice Encode all of a record's fields. + * @return The static (fixed length) data, encoded into a sequence of bytes. + * @return The lengths of the dynamic fields (packed into a single bytes32 value). + * @return The dynamic (variable length) data, encoded into a sequence of bytes. + */ + function encode(uint256 value) internal pure returns (bytes memory, EncodedLengths, bytes memory) { + bytes memory _staticData = encodeStatic(value); + + EncodedLengths _encodedLengths; + bytes memory _dynamicData; + + return (_staticData, _encodedLengths, _dynamicData); + } + + /** + * @notice Encode keys as a bytes32 array using this table's field layout. + */ + function encodeKeyTuple(uint256 id) internal pure returns (bytes32[] memory) { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = bytes32(uint256(id)); + + return _keyTuple; + } +} diff --git a/src/codegen/world/IDonateSystem.sol b/packages/rng/src/codegen/world/IRequestSystem.sol similarity index 73% rename from src/codegen/world/IDonateSystem.sol rename to packages/rng/src/codegen/world/IRequestSystem.sol index 383cdf6..fbe2d43 100644 --- a/src/codegen/world/IDonateSystem.sol +++ b/packages/rng/src/codegen/world/IRequestSystem.sol @@ -4,10 +4,10 @@ pragma solidity >=0.8.24; /* Autogenerated file. Do not edit manually. */ /** - * @title IDonateSystem + * @title IRequestSystem * @author MUD (https://mud.dev) by Lattice (https://lattice.xyz) * @dev This interface is automatically generated from the corresponding system contract. Do not edit manually. */ -interface IDonateSystem { - function donate() external payable; +interface IRequestSystem { + function rng__request() external returns (uint256); } diff --git a/packages/rng/src/codegen/world/ISetConfigSystem.sol b/packages/rng/src/codegen/world/ISetConfigSystem.sol new file mode 100644 index 0000000..f4908e7 --- /dev/null +++ b/packages/rng/src/codegen/world/ISetConfigSystem.sol @@ -0,0 +1,15 @@ +// SPDX-License-Identifier: MIT +pragma solidity >=0.8.24; + +/* Autogenerated file. Do not edit manually. */ + +/** + * @title ISetConfigSystem + * @author MUD (https://mud.dev) by Lattice (https://lattice.xyz) + * @dev This interface is automatically generated from the corresponding system contract. Do not edit manually. + */ +interface ISetConfigSystem { + error AlreadySet(); + + function rng__setConfig(uint256 period) external; +} diff --git a/packages/rng/src/codegen/world/ISetRandaoSystem.sol b/packages/rng/src/codegen/world/ISetRandaoSystem.sol new file mode 100644 index 0000000..52b0b48 --- /dev/null +++ b/packages/rng/src/codegen/world/ISetRandaoSystem.sol @@ -0,0 +1,15 @@ +// SPDX-License-Identifier: MIT +pragma solidity >=0.8.24; + +/* Autogenerated file. Do not edit manually. */ + +/** + * @title ISetRandaoSystem + * @author MUD (https://mud.dev) by Lattice (https://lattice.xyz) + * @dev This interface is automatically generated from the corresponding system contract. Do not edit manually. + */ +interface ISetRandaoSystem { + error WithinPeriod(); + + function rng__setRandao(uint256 id) external returns (uint256); +} diff --git a/packages/rng/src/codegen/world/IWorld.sol b/packages/rng/src/codegen/world/IWorld.sol new file mode 100644 index 0000000..cc9b557 --- /dev/null +++ b/packages/rng/src/codegen/world/IWorld.sol @@ -0,0 +1,19 @@ +// SPDX-License-Identifier: MIT +pragma solidity >=0.8.24; + +/* Autogenerated file. Do not edit manually. */ + +import { IBaseWorld } from "@latticexyz/world/src/codegen/interfaces/IBaseWorld.sol"; + +import { IRequestSystem } from "./IRequestSystem.sol"; +import { ISetConfigSystem } from "./ISetConfigSystem.sol"; +import { ISetRandaoSystem } from "./ISetRandaoSystem.sol"; + +/** + * @title IWorld + * @author MUD (https://mud.dev) by Lattice (https://lattice.xyz) + * @notice This interface integrates all systems and associated function selectors + * that are dynamically registered in the World during deployment. + * @dev This is an autogenerated file; do not edit manually. + */ +interface IWorld is IBaseWorld, IRequestSystem, ISetConfigSystem, ISetRandaoSystem {} diff --git a/packages/rng/src/libraries/LibId.sol b/packages/rng/src/libraries/LibId.sol new file mode 100644 index 0000000..2838553 --- /dev/null +++ b/packages/rng/src/libraries/LibId.sol @@ -0,0 +1,12 @@ +// SPDX-License-Identifier: MIT +pragma solidity >=0.8.24; + +import { Id } from "codegen/index.sol"; + +library LibId { + function getId() internal returns (uint256) { + uint256 id = Id.get(); + Id.set({ value: id + 1 }); + return id + 1; + } +} diff --git a/packages/rng/src/systems/RequestSystem.sol b/packages/rng/src/systems/RequestSystem.sol new file mode 100644 index 0000000..7cec91f --- /dev/null +++ b/packages/rng/src/systems/RequestSystem.sol @@ -0,0 +1,14 @@ +// SPDX-License-Identifier: MIT +pragma solidity >=0.8.0; + +import { System } from "@latticexyz/world/src/System.sol"; +import { Request } from "codegen/index.sol"; +import { LibId } from "libraries/LibId.sol"; + +contract RequestSystem is System { + function request() public returns (uint256) { + uint256 id = LibId.getId(); + Request.set({ id: id, timestamp: block.timestamp, blockNumber: block.number }); + return id; + } +} diff --git a/packages/rng/src/systems/SetConfigSystem.sol b/packages/rng/src/systems/SetConfigSystem.sol new file mode 100644 index 0000000..3aff20e --- /dev/null +++ b/packages/rng/src/systems/SetConfigSystem.sol @@ -0,0 +1,17 @@ +// SPDX-License-Identifier: MIT +pragma solidity >=0.8.0; + +import { System } from "@latticexyz/world/src/System.sol"; +import { Config } from "codegen/index.sol"; + +contract SetConfigSystem is System { + error AlreadySet(); + + function setConfig(uint256 period) public { + bool set = Config.getValueSet(); + if (set) { + revert AlreadySet(); + } + Config.set({ period: period, valueSet: true }); + } +} diff --git a/packages/rng/src/systems/SetRandaoSystem.sol b/packages/rng/src/systems/SetRandaoSystem.sol new file mode 100644 index 0000000..c3b77d4 --- /dev/null +++ b/packages/rng/src/systems/SetRandaoSystem.sol @@ -0,0 +1,20 @@ +// SPDX-License-Identifier: MIT +pragma solidity >=0.8.0; + +import { System } from "@latticexyz/world/src/System.sol"; +import { Config, Request, RequestData, Response } from "codegen/index.sol"; + +contract SetRandaoSystem is System { + error WithinPeriod(); + + function setRandao(uint256 id) public returns (uint256) { + RequestData memory request = Request.get({ id: id }); + uint256 period = Config.getPeriod(); + if (block.number - request.blockNumber < period) { + revert WithinPeriod(); + } + uint256 randao = block.prevrandao; + Response.set({ id: id, value: randao }); + return randao; + } +} diff --git a/packages/rng/src/test/RngTest.t.sol b/packages/rng/src/test/RngTest.t.sol new file mode 100644 index 0000000..7c4f2b5 --- /dev/null +++ b/packages/rng/src/test/RngTest.t.sol @@ -0,0 +1,16 @@ +// SPDX-License-Identifier: MIT +pragma solidity >=0.8.0; + +import { MudTest } from "@latticexyz/world/test/MudTest.t.sol"; +import { IWorld } from "codegen/world/IWorld.sol"; + +contract RngTest is MudTest { + address deployerAddress; + IWorld world; + + function setUp() public virtual override { + super.setUp(); + deployerAddress = address(0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266); + world = IWorld(worldAddress); + } +} diff --git a/packages/rng/src/test/unit/LibId.t.sol b/packages/rng/src/test/unit/LibId.t.sol new file mode 100644 index 0000000..afbd6fe --- /dev/null +++ b/packages/rng/src/test/unit/LibId.t.sol @@ -0,0 +1,13 @@ +// SPDX-License-Identifier: MIT +pragma solidity >=0.8.24; + +import { RngTest } from "../RngTest.t.sol"; +import { LibId } from "libraries/LibId.sol"; + +contract LibIdTest is RngTest { + function test_IdsIncrement() public { + uint256 id1 = world.rng__request(); + uint256 id2 = world.rng__request(); + assertTrue(id1 < id2); + } +} diff --git a/packages/rng/tsconfig.json b/packages/rng/tsconfig.json new file mode 100644 index 0000000..f24d42b --- /dev/null +++ b/packages/rng/tsconfig.json @@ -0,0 +1,13 @@ +// Visit https://aka.ms/tsconfig.json for all config options +{ + "compilerOptions": { + "target": "ES2020", + "module": "commonjs", + "strict": true, + "resolveJsonModule": true, + "esModuleInterop": true, + "skipLibCheck": true, + "forceConsistentCasingInFileNames": true, + "moduleResolution": "node" + } +} \ No newline at end of file diff --git a/packages/rng/worlds.json b/packages/rng/worlds.json new file mode 100644 index 0000000..866bf36 --- /dev/null +++ b/packages/rng/worlds.json @@ -0,0 +1,5 @@ +{ + "31337": { + "address": "0xd6c8022f1af8e9d7c3825557a1374ee518c65a4e" + } +} \ No newline at end of file diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml deleted file mode 100644 index f8de7c4..0000000 --- a/pnpm-lock.yaml +++ /dev/null @@ -1,3067 +0,0 @@ -lockfileVersion: '6.0' - -settings: - autoInstallPeers: true - excludeLinksFromLockfile: false - -devDependencies: - '@latticexyz/cli': - specifier: 2.0.1 - version: 2.0.1(google-protobuf@3.21.2) - '@latticexyz/config': - specifier: 2.0.1 - version: 2.0.1(typescript@5.4.2) - '@latticexyz/faucet': - specifier: 2.0.1 - version: 2.0.1(typescript@5.4.2) - '@latticexyz/schema-type': - specifier: 2.0.1 - version: 2.0.1(typescript@5.4.2)(zod@3.22.4) - '@latticexyz/store': - specifier: 2.0.1 - version: 2.0.1(typescript@5.4.2) - '@latticexyz/world': - specifier: 2.0.1 - version: 2.0.1(typescript@5.4.2) - '@latticexyz/world-modules': - specifier: 2.0.1 - version: 2.0.1(typescript@5.4.2) - '@openzeppelin/contracts': - specifier: ^4.8.3 - version: 4.9.6 - '@solidstate/contracts': - specifier: ^0.0.52 - version: 0.0.52 - '@types/node': - specifier: ^18.15.11 - version: 18.19.22 - ds-test: - specifier: https://github.com/dapphub/ds-test.git#c9ce3f25bde29fc5eb9901842bf02850dfd2d084 - version: github.com/dapphub/ds-test/c9ce3f25bde29fc5eb9901842bf02850dfd2d084 - ethers: - specifier: ^5.7.2 - version: 5.7.2 - forge-std: - specifier: https://github.com/foundry-rs/forge-std.git#b4f121555729b3afb3c5ffccb62ff4b6e2818fd3 - version: github.com/foundry-rs/forge-std/b4f121555729b3afb3c5ffccb62ff4b6e2818fd3 - prettier: - specifier: ^2.6.2 - version: 2.8.8 - prettier-plugin-solidity: - specifier: ^1.0.0-beta.19 - version: 1.3.1(prettier@2.8.8) - rimraf: - specifier: ^3.0.2 - version: 3.0.2 - run-pty: - specifier: ^4.0.3 - version: 4.1.0 - solhint: - specifier: ^3.4.1 - version: 3.6.2(typescript@5.4.2) - solhint-config-mud: - specifier: 2.0.1 - version: 2.0.1 - solhint-plugin-mud: - specifier: 2.0.1 - version: 2.0.1 - solmate: - specifier: 6.1.0 - version: 6.1.0 - ts-node: - specifier: ^10.9.1 - version: 10.9.2(@types/node@18.19.22)(typescript@5.4.2) - typechain: - specifier: ^8.1.1 - version: 8.3.2(typescript@5.4.2) - typescript: - specifier: ^5.0.4 - version: 5.4.2 - -packages: - - /@adraffy/ens-normalize@1.10.0: - resolution: {integrity: sha512-nA9XHtlAkYfJxY7bce8DcN7eKxWWCWkU+1GR9d+U6MbNpfwQp8TI7vqOsBsMcHoT4mBu2kypKoSKnghEzOOq5Q==} - dev: true - - /@arktype/util@0.0.27: - resolution: {integrity: sha512-ZkPuSU8Q56YVgPInFhojLTujejM+VPfaZx6Guop41CvnozWFOTlC0uAHuDqvY4nYq3zXsMkRwm8LmaRZ3mslMg==} - dev: true - - /@babel/code-frame@7.23.5: - resolution: {integrity: sha512-CgH3s1a96LipHCmSUmYFPwY7MNx8C3avkq7i4Wl3cfa662ldtUe4VM1TPXX70pfmrlWTb6jLqTYrZyT2ZTJBgA==} - engines: {node: '>=6.9.0'} - dependencies: - '@babel/highlight': 7.23.4 - chalk: 2.4.2 - dev: true - - /@babel/helper-validator-identifier@7.22.20: - resolution: {integrity: sha512-Y4OZ+ytlatR8AI+8KZfKuL5urKp7qey08ha31L8b3BwewJAoJamTzyvxPR/5D+KkdJCGPq/+8TukHBlY10FX9A==} - engines: {node: '>=6.9.0'} - dev: true - - /@babel/highlight@7.23.4: - resolution: {integrity: sha512-acGdbYSfp2WheJoJm/EBBBLh/ID8KDc64ISZ9DYtBmC8/Q204PZJLHyzeB5qMzJ5trcOkybd78M4x2KWsUq++A==} - engines: {node: '>=6.9.0'} - dependencies: - '@babel/helper-validator-identifier': 7.22.20 - chalk: 2.4.2 - js-tokens: 4.0.0 - dev: true - - /@cspotcode/source-map-support@0.8.1: - resolution: {integrity: sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==} - engines: {node: '>=12'} - dependencies: - '@jridgewell/trace-mapping': 0.3.9 - dev: true - - /@esbuild/android-arm64@0.17.19: - resolution: {integrity: sha512-KBMWvEZooR7+kzY0BtbTQn0OAYY7CsiydT63pVEaPtVYF0hXbUaOyZog37DKxK7NF3XacBJOpYT4adIJh+avxA==} - engines: {node: '>=12'} - cpu: [arm64] - os: [android] - requiresBuild: true - dev: true - optional: true - - /@esbuild/android-arm@0.17.19: - resolution: {integrity: sha512-rIKddzqhmav7MSmoFCmDIb6e2W57geRsM94gV2l38fzhXMwq7hZoClug9USI2pFRGL06f4IOPHHpFNOkWieR8A==} - engines: {node: '>=12'} - cpu: [arm] - os: [android] - requiresBuild: true - dev: true - optional: true - - /@esbuild/android-x64@0.17.19: - resolution: {integrity: sha512-uUTTc4xGNDT7YSArp/zbtmbhO0uEEK9/ETW29Wk1thYUJBz3IVnvgEiEwEa9IeLyvnpKrWK64Utw2bgUmDveww==} - engines: {node: '>=12'} - cpu: [x64] - os: [android] - requiresBuild: true - dev: true - optional: true - - /@esbuild/darwin-arm64@0.17.19: - resolution: {integrity: sha512-80wEoCfF/hFKM6WE1FyBHc9SfUblloAWx6FJkFWTWiCoht9Mc0ARGEM47e67W9rI09YoUxJL68WHfDRYEAvOhg==} - engines: {node: '>=12'} - cpu: [arm64] - os: [darwin] - requiresBuild: true - dev: true - optional: true - - /@esbuild/darwin-x64@0.17.19: - resolution: {integrity: sha512-IJM4JJsLhRYr9xdtLytPLSH9k/oxR3boaUIYiHkAawtwNOXKE8KoU8tMvryogdcT8AU+Bflmh81Xn6Q0vTZbQw==} - engines: {node: '>=12'} - cpu: [x64] - os: [darwin] - requiresBuild: true - dev: true - optional: true - - /@esbuild/freebsd-arm64@0.17.19: - resolution: {integrity: sha512-pBwbc7DufluUeGdjSU5Si+P3SoMF5DQ/F/UmTSb8HXO80ZEAJmrykPyzo1IfNbAoaqw48YRpv8shwd1NoI0jcQ==} - engines: {node: '>=12'} - cpu: [arm64] - os: [freebsd] - requiresBuild: true - dev: true - optional: true - - /@esbuild/freebsd-x64@0.17.19: - resolution: {integrity: sha512-4lu+n8Wk0XlajEhbEffdy2xy53dpR06SlzvhGByyg36qJw6Kpfk7cp45DR/62aPH9mtJRmIyrXAS5UWBrJT6TQ==} - engines: {node: '>=12'} - cpu: [x64] - os: [freebsd] - requiresBuild: true - dev: true - optional: true - - /@esbuild/linux-arm64@0.17.19: - resolution: {integrity: sha512-ct1Tg3WGwd3P+oZYqic+YZF4snNl2bsnMKRkb3ozHmnM0dGWuxcPTTntAF6bOP0Sp4x0PjSF+4uHQ1xvxfRKqg==} - engines: {node: '>=12'} - cpu: [arm64] - os: [linux] - requiresBuild: true - dev: true - optional: true - - /@esbuild/linux-arm@0.17.19: - resolution: {integrity: sha512-cdmT3KxjlOQ/gZ2cjfrQOtmhG4HJs6hhvm3mWSRDPtZ/lP5oe8FWceS10JaSJC13GBd4eH/haHnqf7hhGNLerA==} - engines: {node: '>=12'} - cpu: [arm] - os: [linux] - requiresBuild: true - dev: true - optional: true - - /@esbuild/linux-ia32@0.17.19: - resolution: {integrity: sha512-w4IRhSy1VbsNxHRQpeGCHEmibqdTUx61Vc38APcsRbuVgK0OPEnQ0YD39Brymn96mOx48Y2laBQGqgZ0j9w6SQ==} - engines: {node: '>=12'} - cpu: [ia32] - os: [linux] - requiresBuild: true - dev: true - optional: true - - /@esbuild/linux-loong64@0.17.19: - resolution: {integrity: sha512-2iAngUbBPMq439a+z//gE+9WBldoMp1s5GWsUSgqHLzLJ9WoZLZhpwWuym0u0u/4XmZ3gpHmzV84PonE+9IIdQ==} - engines: {node: '>=12'} - cpu: [loong64] - os: [linux] - requiresBuild: true - dev: true - optional: true - - /@esbuild/linux-mips64el@0.17.19: - resolution: {integrity: sha512-LKJltc4LVdMKHsrFe4MGNPp0hqDFA1Wpt3jE1gEyM3nKUvOiO//9PheZZHfYRfYl6AwdTH4aTcXSqBerX0ml4A==} - engines: {node: '>=12'} - cpu: [mips64el] - os: [linux] - requiresBuild: true - dev: true - optional: true - - /@esbuild/linux-ppc64@0.17.19: - resolution: {integrity: sha512-/c/DGybs95WXNS8y3Ti/ytqETiW7EU44MEKuCAcpPto3YjQbyK3IQVKfF6nbghD7EcLUGl0NbiL5Rt5DMhn5tg==} - engines: {node: '>=12'} - cpu: [ppc64] - os: [linux] - requiresBuild: true - dev: true - optional: true - - /@esbuild/linux-riscv64@0.17.19: - resolution: {integrity: sha512-FC3nUAWhvFoutlhAkgHf8f5HwFWUL6bYdvLc/TTuxKlvLi3+pPzdZiFKSWz/PF30TB1K19SuCxDTI5KcqASJqA==} - engines: {node: '>=12'} - cpu: [riscv64] - os: [linux] - requiresBuild: true - dev: true - optional: true - - /@esbuild/linux-s390x@0.17.19: - resolution: {integrity: sha512-IbFsFbxMWLuKEbH+7sTkKzL6NJmG2vRyy6K7JJo55w+8xDk7RElYn6xvXtDW8HCfoKBFK69f3pgBJSUSQPr+4Q==} - engines: {node: '>=12'} - cpu: [s390x] - os: [linux] - requiresBuild: true - dev: true - optional: true - - /@esbuild/linux-x64@0.17.19: - resolution: {integrity: sha512-68ngA9lg2H6zkZcyp22tsVt38mlhWde8l3eJLWkyLrp4HwMUr3c1s/M2t7+kHIhvMjglIBrFpncX1SzMckomGw==} - engines: {node: '>=12'} - cpu: [x64] - os: [linux] - requiresBuild: true - dev: true - optional: true - - /@esbuild/netbsd-x64@0.17.19: - resolution: {integrity: sha512-CwFq42rXCR8TYIjIfpXCbRX0rp1jo6cPIUPSaWwzbVI4aOfX96OXY8M6KNmtPcg7QjYeDmN+DD0Wp3LaBOLf4Q==} - engines: {node: '>=12'} - cpu: [x64] - os: [netbsd] - requiresBuild: true - dev: true - optional: true - - /@esbuild/openbsd-x64@0.17.19: - resolution: {integrity: sha512-cnq5brJYrSZ2CF6c35eCmviIN3k3RczmHz8eYaVlNasVqsNY+JKohZU5MKmaOI+KkllCdzOKKdPs762VCPC20g==} - engines: {node: '>=12'} - cpu: [x64] - os: [openbsd] - requiresBuild: true - dev: true - optional: true - - /@esbuild/sunos-x64@0.17.19: - resolution: {integrity: sha512-vCRT7yP3zX+bKWFeP/zdS6SqdWB8OIpaRq/mbXQxTGHnIxspRtigpkUcDMlSCOejlHowLqII7K2JKevwyRP2rg==} - engines: {node: '>=12'} - cpu: [x64] - os: [sunos] - requiresBuild: true - dev: true - optional: true - - /@esbuild/win32-arm64@0.17.19: - resolution: {integrity: sha512-yYx+8jwowUstVdorcMdNlzklLYhPxjniHWFKgRqH7IFlUEa0Umu3KuYplf1HUZZ422e3NU9F4LGb+4O0Kdcaag==} - engines: {node: '>=12'} - cpu: [arm64] - os: [win32] - requiresBuild: true - dev: true - optional: true - - /@esbuild/win32-ia32@0.17.19: - resolution: {integrity: sha512-eggDKanJszUtCdlVs0RB+h35wNlb5v4TWEkq4vZcmVt5u/HiDZrTXe2bWFQUez3RgNHwx/x4sk5++4NSSicKkw==} - engines: {node: '>=12'} - cpu: [ia32] - os: [win32] - requiresBuild: true - dev: true - optional: true - - /@esbuild/win32-x64@0.17.19: - resolution: {integrity: sha512-lAhycmKnVOuRYNtRtatQR1LPQf2oYCkRGkSFnseDAKPl8lu5SOsK/e1sXe5a0Pc5kHIHe6P2I/ilntNv2xf3cA==} - engines: {node: '>=12'} - cpu: [x64] - os: [win32] - requiresBuild: true - dev: true - optional: true - - /@ethersproject/abi@5.7.0: - resolution: {integrity: sha512-351ktp42TiRcYB3H1OP8yajPeAQstMW/yCFokj/AthP9bLHzQFPlOrxOcwYEDkUAICmOHljvN4K39OMTMUa9RA==} - dependencies: - '@ethersproject/address': 5.7.0 - '@ethersproject/bignumber': 5.7.0 - '@ethersproject/bytes': 5.7.0 - '@ethersproject/constants': 5.7.0 - '@ethersproject/hash': 5.7.0 - '@ethersproject/keccak256': 5.7.0 - '@ethersproject/logger': 5.7.0 - '@ethersproject/properties': 5.7.0 - '@ethersproject/strings': 5.7.0 - dev: true - - /@ethersproject/abstract-provider@5.7.0: - resolution: {integrity: sha512-R41c9UkchKCpAqStMYUpdunjo3pkEvZC3FAwZn5S5MGbXoMQOHIdHItezTETxAO5bevtMApSyEhn9+CHcDsWBw==} - dependencies: - '@ethersproject/bignumber': 5.7.0 - '@ethersproject/bytes': 5.7.0 - '@ethersproject/logger': 5.7.0 - '@ethersproject/networks': 5.7.1 - '@ethersproject/properties': 5.7.0 - '@ethersproject/transactions': 5.7.0 - '@ethersproject/web': 5.7.1 - dev: true - - /@ethersproject/abstract-signer@5.7.0: - resolution: {integrity: sha512-a16V8bq1/Cz+TGCkE2OPMTOUDLS3grCpdjoJCYNnVBbdYEMSgKrU0+B90s8b6H+ByYTBZN7a3g76jdIJi7UfKQ==} - dependencies: - '@ethersproject/abstract-provider': 5.7.0 - '@ethersproject/bignumber': 5.7.0 - '@ethersproject/bytes': 5.7.0 - '@ethersproject/logger': 5.7.0 - '@ethersproject/properties': 5.7.0 - dev: true - - /@ethersproject/address@5.7.0: - resolution: {integrity: sha512-9wYhYt7aghVGo758POM5nqcOMaE168Q6aRLJZwUmiqSrAungkG74gSSeKEIR7ukixesdRZGPgVqme6vmxs1fkA==} - dependencies: - '@ethersproject/bignumber': 5.7.0 - '@ethersproject/bytes': 5.7.0 - '@ethersproject/keccak256': 5.7.0 - '@ethersproject/logger': 5.7.0 - '@ethersproject/rlp': 5.7.0 - dev: true - - /@ethersproject/base64@5.7.0: - resolution: {integrity: sha512-Dr8tcHt2mEbsZr/mwTPIQAf3Ai0Bks/7gTw9dSqk1mQvhW3XvRlmDJr/4n+wg1JmCl16NZue17CDh8xb/vZ0sQ==} - dependencies: - '@ethersproject/bytes': 5.7.0 - dev: true - - /@ethersproject/basex@5.7.0: - resolution: {integrity: sha512-ywlh43GwZLv2Voc2gQVTKBoVQ1mti3d8HK5aMxsfu/nRDnMmNqaSJ3r3n85HBByT8OpoY96SXM1FogC533T4zw==} - dependencies: - '@ethersproject/bytes': 5.7.0 - '@ethersproject/properties': 5.7.0 - dev: true - - /@ethersproject/bignumber@5.7.0: - resolution: {integrity: sha512-n1CAdIHRWjSucQO3MC1zPSVgV/6dy/fjL9pMrPP9peL+QxEg9wOsVqwD4+818B6LUEtaXzVHQiuivzRoxPxUGw==} - dependencies: - '@ethersproject/bytes': 5.7.0 - '@ethersproject/logger': 5.7.0 - bn.js: 5.2.1 - dev: true - - /@ethersproject/bytes@5.7.0: - resolution: {integrity: sha512-nsbxwgFXWh9NyYWo+U8atvmMsSdKJprTcICAkvbBffT75qDocbuggBU0SJiVK2MuTrp0q+xvLkTnGMPK1+uA9A==} - dependencies: - '@ethersproject/logger': 5.7.0 - dev: true - - /@ethersproject/constants@5.7.0: - resolution: {integrity: sha512-DHI+y5dBNvkpYUMiRQyxRBYBefZkJfo70VUkUAsRjcPs47muV9evftfZ0PJVCXYbAiCgght0DtcF9srFQmIgWA==} - dependencies: - '@ethersproject/bignumber': 5.7.0 - dev: true - - /@ethersproject/contracts@5.7.0: - resolution: {integrity: sha512-5GJbzEU3X+d33CdfPhcyS+z8MzsTrBGk/sc+G+59+tPa9yFkl6HQ9D6L0QMgNTA9q8dT0XKxxkyp883XsQvbbg==} - dependencies: - '@ethersproject/abi': 5.7.0 - '@ethersproject/abstract-provider': 5.7.0 - '@ethersproject/abstract-signer': 5.7.0 - '@ethersproject/address': 5.7.0 - '@ethersproject/bignumber': 5.7.0 - '@ethersproject/bytes': 5.7.0 - '@ethersproject/constants': 5.7.0 - '@ethersproject/logger': 5.7.0 - '@ethersproject/properties': 5.7.0 - '@ethersproject/transactions': 5.7.0 - dev: true - - /@ethersproject/hash@5.7.0: - resolution: {integrity: sha512-qX5WrQfnah1EFnO5zJv1v46a8HW0+E5xuBBDTwMFZLuVTx0tbU2kkx15NqdjxecrLGatQN9FGQKpb1FKdHCt+g==} - dependencies: - '@ethersproject/abstract-signer': 5.7.0 - '@ethersproject/address': 5.7.0 - '@ethersproject/base64': 5.7.0 - '@ethersproject/bignumber': 5.7.0 - '@ethersproject/bytes': 5.7.0 - '@ethersproject/keccak256': 5.7.0 - '@ethersproject/logger': 5.7.0 - '@ethersproject/properties': 5.7.0 - '@ethersproject/strings': 5.7.0 - dev: true - - /@ethersproject/hdnode@5.7.0: - resolution: {integrity: sha512-OmyYo9EENBPPf4ERhR7oj6uAtUAhYGqOnIS+jE5pTXvdKBS99ikzq1E7Iv0ZQZ5V36Lqx1qZLeak0Ra16qpeOg==} - dependencies: - '@ethersproject/abstract-signer': 5.7.0 - '@ethersproject/basex': 5.7.0 - '@ethersproject/bignumber': 5.7.0 - '@ethersproject/bytes': 5.7.0 - '@ethersproject/logger': 5.7.0 - '@ethersproject/pbkdf2': 5.7.0 - '@ethersproject/properties': 5.7.0 - '@ethersproject/sha2': 5.7.0 - '@ethersproject/signing-key': 5.7.0 - '@ethersproject/strings': 5.7.0 - '@ethersproject/transactions': 5.7.0 - '@ethersproject/wordlists': 5.7.0 - dev: true - - /@ethersproject/json-wallets@5.7.0: - resolution: {integrity: sha512-8oee5Xgu6+RKgJTkvEMl2wDgSPSAQ9MB/3JYjFV9jlKvcYHUXZC+cQp0njgmxdHkYWn8s6/IqIZYm0YWCjO/0g==} - dependencies: - '@ethersproject/abstract-signer': 5.7.0 - '@ethersproject/address': 5.7.0 - '@ethersproject/bytes': 5.7.0 - '@ethersproject/hdnode': 5.7.0 - '@ethersproject/keccak256': 5.7.0 - '@ethersproject/logger': 5.7.0 - '@ethersproject/pbkdf2': 5.7.0 - '@ethersproject/properties': 5.7.0 - '@ethersproject/random': 5.7.0 - '@ethersproject/strings': 5.7.0 - '@ethersproject/transactions': 5.7.0 - aes-js: 3.0.0 - scrypt-js: 3.0.1 - dev: true - - /@ethersproject/keccak256@5.7.0: - resolution: {integrity: sha512-2UcPboeL/iW+pSg6vZ6ydF8tCnv3Iu/8tUmLLzWWGzxWKFFqOBQFLo6uLUv6BDrLgCDfN28RJ/wtByx+jZ4KBg==} - dependencies: - '@ethersproject/bytes': 5.7.0 - js-sha3: 0.8.0 - dev: true - - /@ethersproject/logger@5.7.0: - resolution: {integrity: sha512-0odtFdXu/XHtjQXJYA3u9G0G8btm0ND5Cu8M7i5vhEcE8/HmF4Lbdqanwyv4uQTr2tx6b7fQRmgLrsnpQlmnig==} - dev: true - - /@ethersproject/networks@5.7.1: - resolution: {integrity: sha512-n/MufjFYv3yFcUyfhnXotyDlNdFb7onmkSy8aQERi2PjNcnWQ66xXxa3XlS8nCcA8aJKJjIIMNJTC7tu80GwpQ==} - dependencies: - '@ethersproject/logger': 5.7.0 - dev: true - - /@ethersproject/pbkdf2@5.7.0: - resolution: {integrity: sha512-oR/dBRZR6GTyaofd86DehG72hY6NpAjhabkhxgr3X2FpJtJuodEl2auADWBZfhDHgVCbu3/H/Ocq2uC6dpNjjw==} - dependencies: - '@ethersproject/bytes': 5.7.0 - '@ethersproject/sha2': 5.7.0 - dev: true - - /@ethersproject/properties@5.7.0: - resolution: {integrity: sha512-J87jy8suntrAkIZtecpxEPxY//szqr1mlBaYlQ0r4RCaiD2hjheqF9s1LVE8vVuJCXisjIP+JgtK/Do54ej4Sw==} - dependencies: - '@ethersproject/logger': 5.7.0 - dev: true - - /@ethersproject/providers@5.7.2: - resolution: {integrity: sha512-g34EWZ1WWAVgr4aptGlVBF8mhl3VWjv+8hoAnzStu8Ah22VHBsuGzP17eb6xDVRzw895G4W7vvx60lFFur/1Rg==} - dependencies: - '@ethersproject/abstract-provider': 5.7.0 - '@ethersproject/abstract-signer': 5.7.0 - '@ethersproject/address': 5.7.0 - '@ethersproject/base64': 5.7.0 - '@ethersproject/basex': 5.7.0 - '@ethersproject/bignumber': 5.7.0 - '@ethersproject/bytes': 5.7.0 - '@ethersproject/constants': 5.7.0 - '@ethersproject/hash': 5.7.0 - '@ethersproject/logger': 5.7.0 - '@ethersproject/networks': 5.7.1 - '@ethersproject/properties': 5.7.0 - '@ethersproject/random': 5.7.0 - '@ethersproject/rlp': 5.7.0 - '@ethersproject/sha2': 5.7.0 - '@ethersproject/strings': 5.7.0 - '@ethersproject/transactions': 5.7.0 - '@ethersproject/web': 5.7.1 - bech32: 1.1.4 - ws: 7.4.6 - transitivePeerDependencies: - - bufferutil - - utf-8-validate - dev: true - - /@ethersproject/random@5.7.0: - resolution: {integrity: sha512-19WjScqRA8IIeWclFme75VMXSBvi4e6InrUNuaR4s5pTF2qNhcGdCUwdxUVGtDDqC00sDLCO93jPQoDUH4HVmQ==} - dependencies: - '@ethersproject/bytes': 5.7.0 - '@ethersproject/logger': 5.7.0 - dev: true - - /@ethersproject/rlp@5.7.0: - resolution: {integrity: sha512-rBxzX2vK8mVF7b0Tol44t5Tb8gomOHkj5guL+HhzQ1yBh/ydjGnpw6at+X6Iw0Kp3OzzzkcKp8N9r0W4kYSs9w==} - dependencies: - '@ethersproject/bytes': 5.7.0 - '@ethersproject/logger': 5.7.0 - dev: true - - /@ethersproject/sha2@5.7.0: - resolution: {integrity: sha512-gKlH42riwb3KYp0reLsFTokByAKoJdgFCwI+CCiX/k+Jm2mbNs6oOaCjYQSlI1+XBVejwH2KrmCbMAT/GnRDQw==} - dependencies: - '@ethersproject/bytes': 5.7.0 - '@ethersproject/logger': 5.7.0 - hash.js: 1.1.7 - dev: true - - /@ethersproject/signing-key@5.7.0: - resolution: {integrity: sha512-MZdy2nL3wO0u7gkB4nA/pEf8lu1TlFswPNmy8AiYkfKTdO6eXBJyUdmHO/ehm/htHw9K/qF8ujnTyUAD+Ry54Q==} - dependencies: - '@ethersproject/bytes': 5.7.0 - '@ethersproject/logger': 5.7.0 - '@ethersproject/properties': 5.7.0 - bn.js: 5.2.1 - elliptic: 6.5.4 - hash.js: 1.1.7 - dev: true - - /@ethersproject/solidity@5.7.0: - resolution: {integrity: sha512-HmabMd2Dt/raavyaGukF4XxizWKhKQ24DoLtdNbBmNKUOPqwjsKQSdV9GQtj9CBEea9DlzETlVER1gYeXXBGaA==} - dependencies: - '@ethersproject/bignumber': 5.7.0 - '@ethersproject/bytes': 5.7.0 - '@ethersproject/keccak256': 5.7.0 - '@ethersproject/logger': 5.7.0 - '@ethersproject/sha2': 5.7.0 - '@ethersproject/strings': 5.7.0 - dev: true - - /@ethersproject/strings@5.7.0: - resolution: {integrity: sha512-/9nu+lj0YswRNSH0NXYqrh8775XNyEdUQAuf3f+SmOrnVewcJ5SBNAjF7lpgehKi4abvNNXyf+HX86czCdJ8Mg==} - dependencies: - '@ethersproject/bytes': 5.7.0 - '@ethersproject/constants': 5.7.0 - '@ethersproject/logger': 5.7.0 - dev: true - - /@ethersproject/transactions@5.7.0: - resolution: {integrity: sha512-kmcNicCp1lp8qanMTC3RIikGgoJ80ztTyvtsFvCYpSCfkjhD0jZ2LOrnbcuxuToLIUYYf+4XwD1rP+B/erDIhQ==} - dependencies: - '@ethersproject/address': 5.7.0 - '@ethersproject/bignumber': 5.7.0 - '@ethersproject/bytes': 5.7.0 - '@ethersproject/constants': 5.7.0 - '@ethersproject/keccak256': 5.7.0 - '@ethersproject/logger': 5.7.0 - '@ethersproject/properties': 5.7.0 - '@ethersproject/rlp': 5.7.0 - '@ethersproject/signing-key': 5.7.0 - dev: true - - /@ethersproject/units@5.7.0: - resolution: {integrity: sha512-pD3xLMy3SJu9kG5xDGI7+xhTEmGXlEqXU4OfNapmfnxLVY4EMSSRp7j1k7eezutBPH7RBN/7QPnwR7hzNlEFeg==} - dependencies: - '@ethersproject/bignumber': 5.7.0 - '@ethersproject/constants': 5.7.0 - '@ethersproject/logger': 5.7.0 - dev: true - - /@ethersproject/wallet@5.7.0: - resolution: {integrity: sha512-MhmXlJXEJFBFVKrDLB4ZdDzxcBxQ3rLyCkhNqVu3CDYvR97E+8r01UgrI+TI99Le+aYm/in/0vp86guJuM7FCA==} - dependencies: - '@ethersproject/abstract-provider': 5.7.0 - '@ethersproject/abstract-signer': 5.7.0 - '@ethersproject/address': 5.7.0 - '@ethersproject/bignumber': 5.7.0 - '@ethersproject/bytes': 5.7.0 - '@ethersproject/hash': 5.7.0 - '@ethersproject/hdnode': 5.7.0 - '@ethersproject/json-wallets': 5.7.0 - '@ethersproject/keccak256': 5.7.0 - '@ethersproject/logger': 5.7.0 - '@ethersproject/properties': 5.7.0 - '@ethersproject/random': 5.7.0 - '@ethersproject/signing-key': 5.7.0 - '@ethersproject/transactions': 5.7.0 - '@ethersproject/wordlists': 5.7.0 - dev: true - - /@ethersproject/web@5.7.1: - resolution: {integrity: sha512-Gueu8lSvyjBWL4cYsWsjh6MtMwM0+H4HvqFPZfB6dV8ctbP9zFAO73VG1cMWae0FLPCtz0peKPpZY8/ugJJX2w==} - dependencies: - '@ethersproject/base64': 5.7.0 - '@ethersproject/bytes': 5.7.0 - '@ethersproject/logger': 5.7.0 - '@ethersproject/properties': 5.7.0 - '@ethersproject/strings': 5.7.0 - dev: true - - /@ethersproject/wordlists@5.7.0: - resolution: {integrity: sha512-S2TFNJNfHWVHNE6cNDjbVlZ6MgE17MIxMbMg2zv3wn+3XSJGosL1m9ZVv3GXCf/2ymSsQ+hRI5IzoMJTG6aoVA==} - dependencies: - '@ethersproject/bytes': 5.7.0 - '@ethersproject/hash': 5.7.0 - '@ethersproject/logger': 5.7.0 - '@ethersproject/properties': 5.7.0 - '@ethersproject/strings': 5.7.0 - dev: true - - /@fastify/accept-negotiator@1.1.0: - resolution: {integrity: sha512-OIHZrb2ImZ7XG85HXOONLcJWGosv7sIvM2ifAPQVhg9Lv7qdmMBNVaai4QTdyuaqbKM5eO6sLSQOYI7wEQeCJQ==} - engines: {node: '>=14'} - dev: true - - /@fastify/ajv-compiler@3.5.0: - resolution: {integrity: sha512-ebbEtlI7dxXF5ziNdr05mOY8NnDiPB1XvAlLHctRt/Rc+C3LCOVW5imUVX+mhvUhnNzmPBHewUkOFgGlCxgdAA==} - dependencies: - ajv: 8.12.0 - ajv-formats: 2.1.1(ajv@8.12.0) - fast-uri: 2.3.0 - dev: true - - /@fastify/compress@6.5.0: - resolution: {integrity: sha512-AqUOK714jY7qkzbQbS4zyI4yNFgnRoOJ3eH/oV1T9f5fFdPDRdrFxm5de1ya5n+as4bvitjwU9EY7zvtT9pI2A==} - dependencies: - '@fastify/accept-negotiator': 1.1.0 - fastify-plugin: 4.5.1 - into-stream: 6.0.0 - mime-db: 1.52.0 - minipass: 7.0.4 - peek-stream: 1.1.3 - pump: 3.0.0 - pumpify: 2.0.1 - dev: true - - /@fastify/cors@8.5.0: - resolution: {integrity: sha512-/oZ1QSb02XjP0IK1U0IXktEsw/dUBTxJOW7IpIeO8c/tNalw/KjoNSJv1Sf6eqoBPO+TDGkifq6ynFK3v68HFQ==} - dependencies: - fastify-plugin: 4.5.1 - mnemonist: 0.39.6 - dev: true - - /@fastify/error@3.4.1: - resolution: {integrity: sha512-wWSvph+29GR783IhmvdwWnN4bUxTD01Vm5Xad4i7i1VuAOItLvbPAb69sb0IQ2N57yprvhNIwAP5B6xfKTmjmQ==} - dev: true - - /@fastify/fast-json-stringify-compiler@4.3.0: - resolution: {integrity: sha512-aZAXGYo6m22Fk1zZzEUKBvut/CIIQe/BapEORnxiD5Qr0kPHqqI69NtEMCme74h+at72sPhbkb4ZrLd1W3KRLA==} - dependencies: - fast-json-stringify: 5.12.0 - dev: true - - /@fastify/merge-json-schemas@0.1.1: - resolution: {integrity: sha512-fERDVz7topgNjtXsJTTW1JKLy0rhuLRcquYqNR9rF7OcVpCa2OVW49ZPDIhaRRCaUuvVxI+N416xUoF76HNSXA==} - dependencies: - fast-deep-equal: 3.1.3 - dev: true - - /@improbable-eng/grpc-web-node-http-transport@0.15.0(@improbable-eng/grpc-web@0.15.0): - resolution: {integrity: sha512-HLgJfVolGGpjc9DWPhmMmXJx8YGzkek7jcCFO1YYkSOoO81MWRZentPOd/JiKiZuU08wtc4BG+WNuGzsQB5jZA==} - peerDependencies: - '@improbable-eng/grpc-web': '>=0.13.0' - dependencies: - '@improbable-eng/grpc-web': 0.15.0(google-protobuf@3.21.2) - dev: true - - /@improbable-eng/grpc-web@0.15.0(google-protobuf@3.21.2): - resolution: {integrity: sha512-ERft9/0/8CmYalqOVnJnpdDry28q+j+nAlFFARdjyxXDJ+Mhgv9+F600QC8BR9ygOfrXRlAk6CvST2j+JCpQPg==} - peerDependencies: - google-protobuf: ^3.14.0 - dependencies: - browser-headers: 0.4.1 - google-protobuf: 3.21.2 - dev: true - - /@jridgewell/resolve-uri@3.1.2: - resolution: {integrity: sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==} - engines: {node: '>=6.0.0'} - dev: true - - /@jridgewell/sourcemap-codec@1.4.15: - resolution: {integrity: sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg==} - dev: true - - /@jridgewell/trace-mapping@0.3.9: - resolution: {integrity: sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==} - dependencies: - '@jridgewell/resolve-uri': 3.1.2 - '@jridgewell/sourcemap-codec': 1.4.15 - dev: true - - /@latticexyz/abi-ts@2.0.1: - resolution: {integrity: sha512-1aZYVF/pKFt7arHRWa7JtDMepeE02Ju6waxeNQj2CbISGntdDgPno/ntYLj0V8QmXuSZEKfg/p5zeyvoP3JRQA==} - hasBin: true - dependencies: - chalk: 5.3.0 - debug: 4.3.4 - execa: 7.2.0 - glob: 8.1.0 - yargs: 17.7.2 - transitivePeerDependencies: - - supports-color - dev: true - - /@latticexyz/cli@2.0.1(google-protobuf@3.21.2): - resolution: {integrity: sha512-FSlqfhyU2RnSQcL+couYdapCgi0/QcYPKcSas8nLztu5/+RFuXYJ5lbul3wzgg8PpRkGJ5N6RJsbshCLD2PTfA==} - hasBin: true - dependencies: - '@ethersproject/abi': 5.7.0 - '@ethersproject/providers': 5.7.2 - '@improbable-eng/grpc-web': 0.15.0(google-protobuf@3.21.2) - '@improbable-eng/grpc-web-node-http-transport': 0.15.0(@improbable-eng/grpc-web@0.15.0) - '@latticexyz/abi-ts': 2.0.1 - '@latticexyz/common': 2.0.1(typescript@5.4.2)(zod@3.22.4) - '@latticexyz/config': 2.0.1(typescript@5.4.2) - '@latticexyz/gas-report': 2.0.1 - '@latticexyz/protocol-parser': 2.0.1(typescript@5.4.2)(zod@3.22.4) - '@latticexyz/schema-type': 2.0.1(typescript@5.4.2)(zod@3.22.4) - '@latticexyz/services': 2.0.1(google-protobuf@3.21.2) - '@latticexyz/store': 2.0.1(typescript@5.4.2) - '@latticexyz/utils': 2.0.1 - '@latticexyz/world': 2.0.1(typescript@5.4.2) - '@latticexyz/world-modules': 2.0.1(typescript@5.4.2) - chalk: 5.3.0 - chokidar: 3.6.0 - debug: 4.3.4 - dotenv: 16.4.5 - ejs: 3.1.9 - ethers: 5.7.2 - execa: 7.2.0 - glob: 8.1.0 - nice-grpc-web: 2.0.2(google-protobuf@3.21.2) - openurl: 1.1.1 - p-retry: 5.1.2 - path: 0.12.7 - rxjs: 7.5.5 - throttle-debounce: 5.0.0 - toposort: 2.0.2 - typescript: 5.4.2 - viem: 2.7.12(typescript@5.4.2)(zod@3.22.4) - yargs: 17.7.2 - zod: 3.22.4 - zod-validation-error: 1.5.0(zod@3.22.4) - transitivePeerDependencies: - - bufferutil - - google-protobuf - - supports-color - - utf-8-validate - dev: true - - /@latticexyz/common@2.0.1(typescript@5.4.2)(zod@3.22.4): - resolution: {integrity: sha512-QaHfRb/QzGBUgqcZvI+5FwLEiFu4jOH0qk43sIk3BzrnRORR7/ix9cSIVesmguq7A/QMTGF+qrVqyUjhA5ni9A==} - dependencies: - '@latticexyz/schema-type': 2.0.1(typescript@5.4.2)(zod@3.22.4) - '@solidity-parser/parser': 0.16.2 - debug: 4.3.4 - execa: 7.2.0 - p-queue: 7.4.1 - p-retry: 5.1.2 - prettier: 3.2.5 - prettier-plugin-solidity: 1.3.1(prettier@3.2.5) - viem: 2.7.12(typescript@5.4.2)(zod@3.22.4) - transitivePeerDependencies: - - bufferutil - - supports-color - - typescript - - utf-8-validate - - zod - dev: true - - /@latticexyz/config@2.0.1(typescript@5.4.2): - resolution: {integrity: sha512-Fnnc/PZakHIAc56jVXky3qkQ/tPtNNIkG79D3kaiYITrZNf2WhOCaPqwCksaG8G83fQVaD/9gGl/EDd4OrtiUw==} - dependencies: - '@latticexyz/common': 2.0.1(typescript@5.4.2)(zod@3.22.4) - '@latticexyz/schema-type': 2.0.1(typescript@5.4.2)(zod@3.22.4) - esbuild: 0.17.19 - find-up: 6.3.0 - viem: 2.7.12(typescript@5.4.2)(zod@3.22.4) - zod: 3.22.4 - zod-validation-error: 1.5.0(zod@3.22.4) - transitivePeerDependencies: - - bufferutil - - supports-color - - typescript - - utf-8-validate - dev: true - - /@latticexyz/faucet@2.0.1(typescript@5.4.2): - resolution: {integrity: sha512-qhr3BWiNb0t/hwZLu3IEXdbw4bA96rEO48PhbO/QjTealXQZnkFNCLeWKGimqcDP/HJVp2MgbQpXrmradNb8Kw==} - hasBin: true - dependencies: - '@fastify/compress': 6.5.0 - '@fastify/cors': 8.5.0 - '@latticexyz/common': 2.0.1(typescript@5.4.2)(zod@3.22.4) - '@trpc/client': 10.34.0(@trpc/server@10.34.0) - '@trpc/server': 10.34.0 - debug: 4.3.4 - dotenv: 16.4.5 - fastify: 4.26.2 - viem: 2.7.12(typescript@5.4.2)(zod@3.22.4) - zod: 3.22.4 - transitivePeerDependencies: - - bufferutil - - supports-color - - typescript - - utf-8-validate - dev: true - - /@latticexyz/gas-report@2.0.1: - resolution: {integrity: sha512-yw2+vo/QG9vc1N5FnHINv4I428zaXUj96EQkRV0mcRxO+xSrHyF/3fn6dcpClfswEkEIf4voG9v1iCF7TGcKDg==} - hasBin: true - dependencies: - chalk: 5.3.0 - dotenv: 16.4.5 - execa: 7.2.0 - stream-to-array: 2.3.0 - strip-ansi: 7.1.0 - table: 6.8.1 - yargs: 17.7.2 - dev: true - - /@latticexyz/protocol-parser@2.0.1(typescript@5.4.2)(zod@3.22.4): - resolution: {integrity: sha512-3wrBldp1ia0Gqjr3qUp0dN3nS5kEhWT8BzEdJytpxQ0iwl1aeo0k5zNJ7EeA/7/WJuORNI3+U+carBEaxzvuoQ==} - dependencies: - '@latticexyz/common': 2.0.1(typescript@5.4.2)(zod@3.22.4) - '@latticexyz/config': 2.0.1(typescript@5.4.2) - '@latticexyz/schema-type': 2.0.1(typescript@5.4.2)(zod@3.22.4) - abitype: 1.0.0(typescript@5.4.2)(zod@3.22.4) - viem: 2.7.12(typescript@5.4.2)(zod@3.22.4) - transitivePeerDependencies: - - bufferutil - - supports-color - - typescript - - utf-8-validate - - zod - dev: true - - /@latticexyz/schema-type@2.0.1(typescript@5.4.2)(zod@3.22.4): - resolution: {integrity: sha512-mMFWaKQC1eLxsYQQ1PoxtzrT2BsDP0bJE9AwUS2vPNxMfa3zUWo4pWYVSoHG5/rAkIIanPMacW8ceYCHnZDQHQ==} - dependencies: - abitype: 1.0.0(typescript@5.4.2)(zod@3.22.4) - viem: 2.7.12(typescript@5.4.2)(zod@3.22.4) - transitivePeerDependencies: - - bufferutil - - typescript - - utf-8-validate - - zod - dev: true - - /@latticexyz/services@2.0.1(google-protobuf@3.21.2): - resolution: {integrity: sha512-KIeX8J98ljyaC43G6b0RVxlTjRI6/FGmrM2CbiIoapFH1b2a8DC/h6Fvv/G3I84cUqIuiiZ4UWGvvakBF79/oQ==} - dependencies: - long: 5.2.3 - nice-grpc-common: 2.0.2 - nice-grpc-web: 2.0.2(google-protobuf@3.21.2) - protobufjs: 7.2.6 - transitivePeerDependencies: - - google-protobuf - dev: true - - /@latticexyz/store@2.0.1(typescript@5.4.2): - resolution: {integrity: sha512-DCsmphxH1qe/T+GoZ8MxMR6m0AUbIwC4wiX24U26BXaaUgFl0TgfrlSwbyTaucc9WOvu13ubbFkC2RXFbbNE4w==} - dependencies: - '@arktype/util': 0.0.27 - '@latticexyz/common': 2.0.1(typescript@5.4.2)(zod@3.22.4) - '@latticexyz/config': 2.0.1(typescript@5.4.2) - '@latticexyz/protocol-parser': 2.0.1(typescript@5.4.2)(zod@3.22.4) - '@latticexyz/schema-type': 2.0.1(typescript@5.4.2)(zod@3.22.4) - abitype: 1.0.0(typescript@5.4.2)(zod@3.22.4) - arktype: 1.0.29-alpha - viem: 2.7.12(typescript@5.4.2)(zod@3.22.4) - zod: 3.22.4 - transitivePeerDependencies: - - bufferutil - - supports-color - - typescript - - utf-8-validate - dev: true - - /@latticexyz/utils@2.0.1: - resolution: {integrity: sha512-0pTFpTYcI59LlLgQOcgRKa7MTJvv099wktpocmEdEt+axIl3sENXPo9oB22kU6lWQ4GvCT74eEBmUKYO7ES0MA==} - dependencies: - mobx: 6.12.0 - proxy-deep: 3.1.1 - rxjs: 7.5.5 - dev: true - - /@latticexyz/world-modules@2.0.1(typescript@5.4.2): - resolution: {integrity: sha512-z6sjZ71gAD0VfkSR0GyFPpXRpX8PscDM7i4MYqKSG5vc+qayTaAsCbZtUnOgvuCfC+4NSNv9UCyr2wROZwBHnA==} - dependencies: - '@latticexyz/common': 2.0.1(typescript@5.4.2)(zod@3.22.4) - '@latticexyz/config': 2.0.1(typescript@5.4.2) - '@latticexyz/schema-type': 2.0.1(typescript@5.4.2)(zod@3.22.4) - '@latticexyz/store': 2.0.1(typescript@5.4.2) - '@latticexyz/world': 2.0.1(typescript@5.4.2) - zod: 3.22.4 - transitivePeerDependencies: - - bufferutil - - supports-color - - typescript - - utf-8-validate - dev: true - - /@latticexyz/world@2.0.1(typescript@5.4.2): - resolution: {integrity: sha512-HnEoyAuM+IxNl97uuH+QOZYg/R5KFS9QUw+KRTtGpgUehGB0aHhhAPCV8G7UXNt9ws+eEkY7UtAIOI5+sTdgdg==} - dependencies: - '@arktype/util': 0.0.27 - '@latticexyz/common': 2.0.1(typescript@5.4.2)(zod@3.22.4) - '@latticexyz/config': 2.0.1(typescript@5.4.2) - '@latticexyz/schema-type': 2.0.1(typescript@5.4.2)(zod@3.22.4) - '@latticexyz/store': 2.0.1(typescript@5.4.2) - abitype: 1.0.0(typescript@5.4.2)(zod@3.22.4) - arktype: 1.0.29-alpha - viem: 2.7.12(typescript@5.4.2)(zod@3.22.4) - zod: 3.22.4 - transitivePeerDependencies: - - bufferutil - - supports-color - - typescript - - utf-8-validate - dev: true - - /@noble/curves@1.2.0: - resolution: {integrity: sha512-oYclrNgRaM9SsBUBVbb8M6DTV7ZHRTKugureoYEncY5c65HOmRzvSiTE3y5CYaPYJA/GVkrhXEoF0M3Ya9PMnw==} - dependencies: - '@noble/hashes': 1.3.2 - dev: true - - /@noble/hashes@1.3.2: - resolution: {integrity: sha512-MVC8EAQp7MvEcm30KWENFjgR+Mkmf+D189XJTkFIlwohU5hcBbn1ZkKq7KVTi2Hme3PMGF390DaL52beVrIihQ==} - engines: {node: '>= 16'} - dev: true - - /@openzeppelin/contracts@4.9.6: - resolution: {integrity: sha512-xSmezSupL+y9VkHZJGDoCBpmnB2ogM13ccaYDWqJTfS3dbuHkgjuwDFUmaFauBCboQMGB/S5UqUl2y54X99BmA==} - dev: true - - /@protobufjs/aspromise@1.1.2: - resolution: {integrity: sha512-j+gKExEuLmKwvz3OgROXtrJ2UG2x8Ch2YZUxahh+s1F2HZ+wAceUNLkvy6zKCPVRkU++ZWQrdxsUeQXmcg4uoQ==} - dev: true - - /@protobufjs/base64@1.1.2: - resolution: {integrity: sha512-AZkcAA5vnN/v4PDqKyMR5lx7hZttPDgClv83E//FMNhR2TMcLUhfRUBHCmSl0oi9zMgDDqRUJkSxO3wm85+XLg==} - dev: true - - /@protobufjs/codegen@2.0.4: - resolution: {integrity: sha512-YyFaikqM5sH0ziFZCN3xDC7zeGaB/d0IUb9CATugHWbd1FRFwWwt4ld4OYMPWu5a3Xe01mGAULCdqhMlPl29Jg==} - dev: true - - /@protobufjs/eventemitter@1.1.0: - resolution: {integrity: sha512-j9ednRT81vYJ9OfVuXG6ERSTdEL1xVsNgqpkxMsbIabzSo3goCjDIveeGv5d03om39ML71RdmrGNjG5SReBP/Q==} - dev: true - - /@protobufjs/fetch@1.1.0: - resolution: {integrity: sha512-lljVXpqXebpsijW71PZaCYeIcE5on1w5DlQy5WH6GLbFryLUrBD4932W/E2BSpfRJWseIL4v/KPgBFxDOIdKpQ==} - dependencies: - '@protobufjs/aspromise': 1.1.2 - '@protobufjs/inquire': 1.1.0 - dev: true - - /@protobufjs/float@1.0.2: - resolution: {integrity: sha512-Ddb+kVXlXst9d+R9PfTIxh1EdNkgoRe5tOX6t01f1lYWOvJnSPDBlG241QLzcyPdoNTsblLUdujGSE4RzrTZGQ==} - dev: true - - /@protobufjs/inquire@1.1.0: - resolution: {integrity: sha512-kdSefcPdruJiFMVSbn801t4vFK7KB/5gd2fYvrxhuJYg8ILrmn9SKSX2tZdV6V+ksulWqS7aXjBcRXl3wHoD9Q==} - dev: true - - /@protobufjs/path@1.1.2: - resolution: {integrity: sha512-6JOcJ5Tm08dOHAbdR3GrvP+yUUfkjG5ePsHYczMFLq3ZmMkAD98cDgcT2iA1lJ9NVwFd4tH/iSSoe44YWkltEA==} - dev: true - - /@protobufjs/pool@1.1.0: - resolution: {integrity: sha512-0kELaGSIDBKvcgS4zkjz1PeddatrjYcmMWOlAuAPwAeccUrPHdUqo/J6LiymHHEiJT5NrF1UVwxY14f+fy4WQw==} - dev: true - - /@protobufjs/utf8@1.1.0: - resolution: {integrity: sha512-Vvn3zZrhQZkkBE8LSuW3em98c0FwgO4nxzv6OdSxPKJIEKY2bGbHn+mhGIPerzI4twdxaP8/0+06HBpwf345Lw==} - dev: true - - /@scure/base@1.1.5: - resolution: {integrity: sha512-Brj9FiG2W1MRQSTB212YVPRrcbjkv48FoZi/u4l/zds/ieRrqsh7aUf6CLwkAq61oKXr/ZlTzlY66gLIj3TFTQ==} - dev: true - - /@scure/bip32@1.3.2: - resolution: {integrity: sha512-N1ZhksgwD3OBlwTv3R6KFEcPojl/W4ElJOeCZdi+vuI5QmTFwLq3OFf2zd2ROpKvxFdgZ6hUpb0dx9bVNEwYCA==} - dependencies: - '@noble/curves': 1.2.0 - '@noble/hashes': 1.3.2 - '@scure/base': 1.1.5 - dev: true - - /@scure/bip39@1.2.1: - resolution: {integrity: sha512-Z3/Fsz1yr904dduJD0NpiyRHhRYHdcnyh73FZWiV+/qhWi83wNJ3NWolYqCEN+ZWsUz2TWwajJggcRE9r1zUYg==} - dependencies: - '@noble/hashes': 1.3.2 - '@scure/base': 1.1.5 - dev: true - - /@solidity-parser/parser@0.16.2: - resolution: {integrity: sha512-PI9NfoA3P8XK2VBkK5oIfRgKDsicwDZfkVq9ZTBCQYGOP1N2owgY2dyLGyU5/J/hQs8KRk55kdmvTLjy3Mu3vg==} - dependencies: - antlr4ts: 0.5.0-alpha.4 - dev: true - - /@solidity-parser/parser@0.17.0: - resolution: {integrity: sha512-Nko8R0/kUo391jsEHHxrGM07QFdnPGvlmox4rmH0kNiNAashItAilhy4Mv4pK5gQmW5f4sXAF58fwJbmlkGcVw==} - dev: true - - /@solidstate/contracts@0.0.52: - resolution: {integrity: sha512-xSBn5oLnfYtgNYrsRq/COlWHt0NxK26PFQ3FvI2DDMAFpZKFsffGLzUl8umezj2gVKpN7EZ+EVLdPKjqx6eUOw==} - dev: true - - /@trpc/client@10.34.0(@trpc/server@10.34.0): - resolution: {integrity: sha512-nqtDTIqSY/9syo2EjSy4WWWXPU9GsamEh9Tsg698gLAh1nhgFc5+/YYeb+Ne1pbvWGZ5/3t9Dcz3h4wMyyJ9gQ==} - peerDependencies: - '@trpc/server': 10.34.0 - dependencies: - '@trpc/server': 10.34.0 - dev: true - - /@trpc/server@10.34.0: - resolution: {integrity: sha512-2VMW44Fpaoyqb50dBtzdSWMhqt8lmoJiocEyBBeDb03R0W+XrzbVD5kU/wqKPlcp1DWeNCkOEIMtetMZCfo1hA==} - dev: true - - /@tsconfig/node10@1.0.9: - resolution: {integrity: sha512-jNsYVVxU8v5g43Erja32laIDHXeoNvFEpX33OK4d6hljo3jDhCBDhx5dhCCTMWUojscpAagGiRkBKxpdl9fxqA==} - dev: true - - /@tsconfig/node12@1.0.11: - resolution: {integrity: sha512-cqefuRsh12pWyGsIoBKJA9luFu3mRxCA+ORZvA4ktLSzIuCUtWVxGIuXigEwO5/ywWFMZ2QEGKWvkZG1zDMTag==} - dev: true - - /@tsconfig/node14@1.0.3: - resolution: {integrity: sha512-ysT8mhdixWK6Hw3i1V2AeRqZ5WfXg1G43mqoYlM2nc6388Fq5jcXyr5mRsqViLx/GJYdoL0bfXD8nmF+Zn/Iow==} - dev: true - - /@tsconfig/node16@1.0.4: - resolution: {integrity: sha512-vxhUy4J8lyeyinH7Azl1pdd43GJhZH/tP2weN8TntQblOY+A0XbT8DJk1/oCPuOOyg/Ja757rG0CgHcWC8OfMA==} - dev: true - - /@types/node@18.19.22: - resolution: {integrity: sha512-p3pDIfuMg/aXBmhkyanPshdfJuX5c5+bQjYLIikPLXAUycEogij/c50n/C+8XOA5L93cU4ZRXtn+dNQGi0IZqQ==} - dependencies: - undici-types: 5.26.5 - dev: true - - /@types/prettier@2.7.3: - resolution: {integrity: sha512-+68kP9yzs4LMp7VNh8gdzMSPZFL44MLGqiHWvttYJe+6qnuVr4Ek9wSBQoveqY/r+LwjCcU29kNVkidwim+kYA==} - dev: true - - /@types/retry@0.12.1: - resolution: {integrity: sha512-xoDlM2S4ortawSWORYqsdU+2rxdh4LRW9ytc3zmT37RIKQh6IHyKwwtKhKis9ah8ol07DCkZxPt8BBvPjC6v4g==} - dev: true - - /abitype@1.0.0(typescript@5.4.2)(zod@3.22.4): - resolution: {integrity: sha512-NMeMah//6bJ56H5XRj8QCV4AwuW6hB6zqz2LnhhLdcWVQOsXki6/Pn3APeqxCma62nXIcmZWdu1DlHWS74umVQ==} - peerDependencies: - typescript: '>=5.0.4' - zod: ^3 >=3.22.0 - peerDependenciesMeta: - typescript: - optional: true - zod: - optional: true - dependencies: - typescript: 5.4.2 - zod: 3.22.4 - dev: true - - /abort-controller-x@0.4.3: - resolution: {integrity: sha512-VtUwTNU8fpMwvWGn4xE93ywbogTYsuT+AUxAXOeelbXuQVIwNmC5YLeho9sH4vZ4ITW8414TTAOG1nW6uIVHCA==} - dev: true - - /abort-controller@3.0.0: - resolution: {integrity: sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg==} - engines: {node: '>=6.5'} - dependencies: - event-target-shim: 5.0.1 - dev: true - - /abstract-logging@2.0.1: - resolution: {integrity: sha512-2BjRTZxTPvheOvGbBslFSYOUkr+SjPtOnrLP33f+VIWLzezQpZcqVg7ja3L4dBXmzzgwT+a029jRx5PCi3JuiA==} - dev: true - - /acorn-walk@8.3.2: - resolution: {integrity: sha512-cjkyv4OtNCIeqhHrfS81QWXoCBPExR/J62oyEqepVw8WaQeSqpW2uhuLPh1m9eWhDuOo/jUXVTlifvesOWp/4A==} - engines: {node: '>=0.4.0'} - dev: true - - /acorn@8.11.3: - resolution: {integrity: sha512-Y9rRfJG5jcKOE0CLisYbojUjIrIEE7AGMzA/Sm4BslANhbS+cDMpgBdcPT91oJ7OuJ9hYJBx59RjbhxVnrF8Xg==} - engines: {node: '>=0.4.0'} - hasBin: true - dev: true - - /aes-js@3.0.0: - resolution: {integrity: sha512-H7wUZRn8WpTq9jocdxQ2c8x2sKo9ZVmzfRE13GiNJXfp7NcKYEdvl3vspKjXox6RIG2VtaRe4JFvxG4rqp2Zuw==} - dev: true - - /ajv-formats@2.1.1(ajv@8.12.0): - resolution: {integrity: sha512-Wx0Kx52hxE7C18hkMEggYlEifqWZtYaRgouJor+WMdPnQyEK13vgEWyVNup7SoeeoLMsr4kf5h6dOW11I15MUA==} - peerDependencies: - ajv: ^8.0.0 - peerDependenciesMeta: - ajv: - optional: true - dependencies: - ajv: 8.12.0 - dev: true - - /ajv@6.12.6: - resolution: {integrity: sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==} - dependencies: - fast-deep-equal: 3.1.3 - fast-json-stable-stringify: 2.1.0 - json-schema-traverse: 0.4.1 - uri-js: 4.4.1 - dev: true - - /ajv@8.12.0: - resolution: {integrity: sha512-sRu1kpcO9yLtYxBKvqfTeh9KzZEwO3STyX1HT+4CaDzC6HpTGYhIhPIzj9XuKU7KYDwnaeh5hcOwjy1QuJzBPA==} - dependencies: - fast-deep-equal: 3.1.3 - json-schema-traverse: 1.0.0 - require-from-string: 2.0.2 - uri-js: 4.4.1 - dev: true - - /ansi-regex@5.0.1: - resolution: {integrity: sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==} - engines: {node: '>=8'} - dev: true - - /ansi-regex@6.0.1: - resolution: {integrity: sha512-n5M855fKb2SsfMIiFFoVrABHJC8QtHwVx+mHWP3QcEqBHYienj5dHSgjbxtC0WEZXYt4wcD6zrQElDPhFuZgfA==} - engines: {node: '>=12'} - dev: true - - /ansi-styles@3.2.1: - resolution: {integrity: sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==} - engines: {node: '>=4'} - dependencies: - color-convert: 1.9.3 - dev: true - - /ansi-styles@4.3.0: - resolution: {integrity: sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==} - engines: {node: '>=8'} - dependencies: - color-convert: 2.0.1 - dev: true - - /antlr4@4.13.1: - resolution: {integrity: sha512-kiXTspaRYvnIArgE97z5YVVf/cDVQABr3abFRR6mE7yesLMkgu4ujuyV/sgxafQ8wgve0DJQUJ38Z8tkgA2izA==} - engines: {node: '>=16'} - dev: true - - /antlr4ts@0.5.0-alpha.4: - resolution: {integrity: sha512-WPQDt1B74OfPv/IMS2ekXAKkTZIHl88uMetg6q3OTqgFxZ/dxDXI0EWLyZid/1Pe6hTftyg5N7gel5wNAGxXyQ==} - dev: true - - /any-promise@1.3.0: - resolution: {integrity: sha512-7UvmKalWRt1wgjL1RrGxoSJW/0QZFIegpeGvZG9kjp8vrRu55XTHbwnqq2GpXm9uLbcuhxm3IqX9OB4MZR1b2A==} - dev: true - - /anymatch@3.1.3: - resolution: {integrity: sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==} - engines: {node: '>= 8'} - dependencies: - normalize-path: 3.0.0 - picomatch: 2.3.1 - dev: true - - /archy@1.0.0: - resolution: {integrity: sha512-Xg+9RwCg/0p32teKdGMPTPnVXKD0w3DfHnFTficozsAgsvq2XenPJq/MYpzzQ/v8zrOyJn6Ds39VA4JIDwFfqw==} - dev: true - - /arg@4.1.3: - resolution: {integrity: sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==} - dev: true - - /argparse@2.0.1: - resolution: {integrity: sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==} - dev: true - - /arktype@1.0.29-alpha: - resolution: {integrity: sha512-glMLgVhIQRSkR3tymiS+POAcWVJH09sfrgic0jHnyFL8BlhHAJZX2BzdImU9zYr1y9NBqy+U93ZNrRTHXsKRDw==} - dev: true - - /array-back@3.1.0: - resolution: {integrity: sha512-TkuxA4UCOvxuDK6NZYXCalszEzj+TLszyASooky+i742l9TqsOdYCMJJupxRic61hwquNtppB3hgcuq9SVSH1Q==} - engines: {node: '>=6'} - dev: true - - /array-back@4.0.2: - resolution: {integrity: sha512-NbdMezxqf94cnNfWLL7V/im0Ub+Anbb0IoZhvzie8+4HJ4nMQuzHuy49FkGYCJK2yAloZ3meiB6AVMClbrI1vg==} - engines: {node: '>=8'} - dev: true - - /ast-parents@0.0.1: - resolution: {integrity: sha512-XHusKxKz3zoYk1ic8Un640joHbFMhbqneyoZfoKnEGtf2ey9Uh/IdpcQplODdO/kENaMIWsD0nJm4+wX3UNLHA==} - dev: true - - /astral-regex@2.0.0: - resolution: {integrity: sha512-Z7tMw1ytTXt5jqMcOP+OQteU1VuNK9Y02uuJtKQ1Sv69jXQKKg5cibLwGJow8yzZP+eAc18EmLGPal0bp36rvQ==} - engines: {node: '>=8'} - dev: true - - /async@3.2.5: - resolution: {integrity: sha512-baNZyqaaLhyLVKm/DlvdW051MSgO6b8eVfIezl9E5PqWxFgzLm/wQntEW4zOytVburDEr0JlALEpdOFwvErLsg==} - dev: true - - /atomic-sleep@1.0.0: - resolution: {integrity: sha512-kNOjDqAh7px0XWNI+4QbzoiR/nTkHAWNud2uvnJquD1/x5a7EQZMJT0AczqK0Qn67oY/TTQ1LbUKajZpp3I9tQ==} - engines: {node: '>=8.0.0'} - dev: true - - /avvio@8.3.0: - resolution: {integrity: sha512-VBVH0jubFr9LdFASy/vNtm5giTrnbVquWBhT0fyizuNK2rQ7e7ONU2plZQWUNqtE1EmxFEb+kbSkFRkstiaS9Q==} - dependencies: - '@fastify/error': 3.4.1 - archy: 1.0.0 - debug: 4.3.4 - fastq: 1.17.1 - transitivePeerDependencies: - - supports-color - dev: true - - /balanced-match@1.0.2: - resolution: {integrity: sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==} - dev: true - - /base64-js@1.5.1: - resolution: {integrity: sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==} - dev: true - - /bech32@1.1.4: - resolution: {integrity: sha512-s0IrSOzLlbvX7yp4WBfPITzpAU8sqQcpsmwXDiKwrG4r491vwCO/XpejasRNl0piBMe/DvP4Tz0mIS/X1DPJBQ==} - dev: true - - /binary-extensions@2.2.0: - resolution: {integrity: sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==} - engines: {node: '>=8'} - dev: true - - /bn.js@4.12.0: - resolution: {integrity: sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA==} - dev: true - - /bn.js@5.2.1: - resolution: {integrity: sha512-eXRvHzWyYPBuB4NBy0cmYQjGitUrtqwbvlzP3G6VFnNRbsZQIxQ10PbKKHt8gZ/HW/D/747aDl+QkDqg3KQLMQ==} - dev: true - - /brace-expansion@1.1.11: - resolution: {integrity: sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==} - dependencies: - balanced-match: 1.0.2 - concat-map: 0.0.1 - dev: true - - /brace-expansion@2.0.1: - resolution: {integrity: sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==} - dependencies: - balanced-match: 1.0.2 - dev: true - - /braces@3.0.2: - resolution: {integrity: sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==} - engines: {node: '>=8'} - dependencies: - fill-range: 7.0.1 - dev: true - - /brorand@1.1.0: - resolution: {integrity: sha512-cKV8tMCEpQs4hK/ik71d6LrPOnpkpGBR0wzxqr68g2m/LB2GxVYQroAjMJZRVM1Y4BCjCKc3vAamxSzOY2RP+w==} - dev: true - - /browser-headers@0.4.1: - resolution: {integrity: sha512-CA9hsySZVo9371qEHjHZtYxV2cFtVj5Wj/ZHi8ooEsrtm4vOnl9Y9HmyYWk9q+05d7K3rdoAE0j3MVEFVvtQtg==} - dev: true - - /buffer-from@1.1.2: - resolution: {integrity: sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==} - dev: true - - /buffer@6.0.3: - resolution: {integrity: sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==} - dependencies: - base64-js: 1.5.1 - ieee754: 1.2.1 - dev: true - - /callsites@3.1.0: - resolution: {integrity: sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==} - engines: {node: '>=6'} - dev: true - - /chalk@2.4.2: - resolution: {integrity: sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==} - engines: {node: '>=4'} - dependencies: - ansi-styles: 3.2.1 - escape-string-regexp: 1.0.5 - supports-color: 5.5.0 - dev: true - - /chalk@4.1.2: - resolution: {integrity: sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==} - engines: {node: '>=10'} - dependencies: - ansi-styles: 4.3.0 - supports-color: 7.2.0 - dev: true - - /chalk@5.3.0: - resolution: {integrity: sha512-dLitG79d+GV1Nb/VYcCDFivJeK1hiukt9QjRNVOsUtTy1rR1YJsmpGGTZ3qJos+uw7WmWF4wUwBd9jxjocFC2w==} - engines: {node: ^12.17.0 || ^14.13 || >=16.0.0} - dev: true - - /chokidar@3.6.0: - resolution: {integrity: sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==} - engines: {node: '>= 8.10.0'} - dependencies: - anymatch: 3.1.3 - braces: 3.0.2 - glob-parent: 5.1.2 - is-binary-path: 2.1.0 - is-glob: 4.0.3 - normalize-path: 3.0.0 - readdirp: 3.6.0 - optionalDependencies: - fsevents: 2.3.3 - dev: true - - /cliui@8.0.1: - resolution: {integrity: sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==} - engines: {node: '>=12'} - dependencies: - string-width: 4.2.3 - strip-ansi: 6.0.1 - wrap-ansi: 7.0.0 - dev: true - - /color-convert@1.9.3: - resolution: {integrity: sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==} - dependencies: - color-name: 1.1.3 - dev: true - - /color-convert@2.0.1: - resolution: {integrity: sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==} - engines: {node: '>=7.0.0'} - dependencies: - color-name: 1.1.4 - dev: true - - /color-name@1.1.3: - resolution: {integrity: sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==} - dev: true - - /color-name@1.1.4: - resolution: {integrity: sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==} - dev: true - - /command-line-args@5.2.1: - resolution: {integrity: sha512-H4UfQhZyakIjC74I9d34fGYDwk3XpSr17QhEd0Q3I9Xq1CETHo4Hcuo87WyWHpAF1aSLjLRf5lD9ZGX2qStUvg==} - engines: {node: '>=4.0.0'} - dependencies: - array-back: 3.1.0 - find-replace: 3.0.0 - lodash.camelcase: 4.3.0 - typical: 4.0.0 - dev: true - - /command-line-usage@6.1.3: - resolution: {integrity: sha512-sH5ZSPr+7UStsloltmDh7Ce5fb8XPlHyoPzTpyyMuYCtervL65+ubVZ6Q61cFtFl62UyJlc8/JwERRbAFPUqgw==} - engines: {node: '>=8.0.0'} - dependencies: - array-back: 4.0.2 - chalk: 2.4.2 - table-layout: 1.0.2 - typical: 5.2.0 - dev: true - - /commander@10.0.1: - resolution: {integrity: sha512-y4Mg2tXshplEbSGzx7amzPwKKOCGuoSRP/CjEdwwk0FOGlUbq6lKuoyDZTNZkmxHdJtp54hdfY/JUrdL7Xfdug==} - engines: {node: '>=14'} - dev: true - - /concat-map@0.0.1: - resolution: {integrity: sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==} - dev: true - - /cookie@0.6.0: - resolution: {integrity: sha512-U71cyTamuh1CRNCfpGY6to28lxvNwPG4Guz/EVjgf3Jmzv0vlDp1atT9eS5dDjMYHucpHbWns6Lwf3BKz6svdw==} - engines: {node: '>= 0.6'} - dev: true - - /core-util-is@1.0.3: - resolution: {integrity: sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==} - dev: true - - /cosmiconfig@8.3.6(typescript@5.4.2): - resolution: {integrity: sha512-kcZ6+W5QzcJ3P1Mt+83OUv/oHFqZHIx8DuxG6eZ5RGMERoLqp4BuGjhHLYGK+Kf5XVkQvqBSmAy/nGWN3qDgEA==} - engines: {node: '>=14'} - peerDependencies: - typescript: '>=4.9.5' - peerDependenciesMeta: - typescript: - optional: true - dependencies: - import-fresh: 3.3.0 - js-yaml: 4.1.0 - parse-json: 5.2.0 - path-type: 4.0.0 - typescript: 5.4.2 - dev: true - - /create-require@1.1.1: - resolution: {integrity: sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==} - dev: true - - /cross-spawn@7.0.3: - resolution: {integrity: sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==} - engines: {node: '>= 8'} - dependencies: - path-key: 3.1.1 - shebang-command: 2.0.0 - which: 2.0.2 - dev: true - - /debug@4.3.4: - resolution: {integrity: sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==} - engines: {node: '>=6.0'} - peerDependencies: - supports-color: '*' - peerDependenciesMeta: - supports-color: - optional: true - dependencies: - ms: 2.1.2 - dev: true - - /deep-extend@0.6.0: - resolution: {integrity: sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA==} - engines: {node: '>=4.0.0'} - dev: true - - /diff@4.0.2: - resolution: {integrity: sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==} - engines: {node: '>=0.3.1'} - dev: true - - /dotenv@16.4.5: - resolution: {integrity: sha512-ZmdL2rui+eB2YwhsWzjInR8LldtZHGDoQ1ugH85ppHKwpUHL7j7rN0Ti9NCnGiQbhaZ11FpR+7ao1dNsmduNUg==} - engines: {node: '>=12'} - dev: true - - /duplexify@3.7.1: - resolution: {integrity: sha512-07z8uv2wMyS51kKhD1KsdXJg5WQ6t93RneqRxUHnskXVtlYYkLqM0gqStQZ3pj073g687jPCHrqNfCzawLYh5g==} - dependencies: - end-of-stream: 1.4.4 - inherits: 2.0.4 - readable-stream: 2.3.8 - stream-shift: 1.0.3 - dev: true - - /duplexify@4.1.3: - resolution: {integrity: sha512-M3BmBhwJRZsSx38lZyhE53Csddgzl5R7xGJNk7CVddZD6CcmwMCH8J+7AprIrQKH7TonKxaCjcv27Qmf+sQ+oA==} - dependencies: - end-of-stream: 1.4.4 - inherits: 2.0.4 - readable-stream: 3.6.2 - stream-shift: 1.0.3 - dev: true - - /ejs@3.1.9: - resolution: {integrity: sha512-rC+QVNMJWv+MtPgkt0y+0rVEIdbtxVADApW9JXrUVlzHetgcyczP/E7DJmWJ4fJCZF2cPcBk0laWO9ZHMG3DmQ==} - engines: {node: '>=0.10.0'} - hasBin: true - dependencies: - jake: 10.8.7 - dev: true - - /elliptic@6.5.4: - resolution: {integrity: sha512-iLhC6ULemrljPZb+QutR5TQGB+pdW6KGD5RSegS+8sorOZT+rdQFbsQFJgvN3eRqNALqJer4oQ16YvJHlU8hzQ==} - dependencies: - bn.js: 4.12.0 - brorand: 1.1.0 - hash.js: 1.1.7 - hmac-drbg: 1.0.1 - inherits: 2.0.4 - minimalistic-assert: 1.0.1 - minimalistic-crypto-utils: 1.0.1 - dev: true - - /emoji-regex@8.0.0: - resolution: {integrity: sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==} - dev: true - - /end-of-stream@1.4.4: - resolution: {integrity: sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q==} - dependencies: - once: 1.4.0 - dev: true - - /error-ex@1.3.2: - resolution: {integrity: sha512-7dFHNmqeFSEt2ZBsCriorKnn3Z2pj+fd9kmI6QoWw4//DL+icEBfc0U7qJCisqrTsKTjw4fNFy2pW9OqStD84g==} - dependencies: - is-arrayish: 0.2.1 - dev: true - - /esbuild@0.17.19: - resolution: {integrity: sha512-XQ0jAPFkK/u3LcVRcvVHQcTIqD6E2H1fvZMA5dQPSOWb3suUbWbfbRf94pjc0bNzRYLfIrDRQXr7X+LHIm5oHw==} - engines: {node: '>=12'} - hasBin: true - requiresBuild: true - optionalDependencies: - '@esbuild/android-arm': 0.17.19 - '@esbuild/android-arm64': 0.17.19 - '@esbuild/android-x64': 0.17.19 - '@esbuild/darwin-arm64': 0.17.19 - '@esbuild/darwin-x64': 0.17.19 - '@esbuild/freebsd-arm64': 0.17.19 - '@esbuild/freebsd-x64': 0.17.19 - '@esbuild/linux-arm': 0.17.19 - '@esbuild/linux-arm64': 0.17.19 - '@esbuild/linux-ia32': 0.17.19 - '@esbuild/linux-loong64': 0.17.19 - '@esbuild/linux-mips64el': 0.17.19 - '@esbuild/linux-ppc64': 0.17.19 - '@esbuild/linux-riscv64': 0.17.19 - '@esbuild/linux-s390x': 0.17.19 - '@esbuild/linux-x64': 0.17.19 - '@esbuild/netbsd-x64': 0.17.19 - '@esbuild/openbsd-x64': 0.17.19 - '@esbuild/sunos-x64': 0.17.19 - '@esbuild/win32-arm64': 0.17.19 - '@esbuild/win32-ia32': 0.17.19 - '@esbuild/win32-x64': 0.17.19 - dev: true - - /escalade@3.1.2: - resolution: {integrity: sha512-ErCHMCae19vR8vQGe50xIsVomy19rg6gFu3+r3jkEO46suLMWBksvVyoGgQV+jOfl84ZSOSlmv6Gxa89PmTGmA==} - engines: {node: '>=6'} - dev: true - - /escape-string-regexp@1.0.5: - resolution: {integrity: sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==} - engines: {node: '>=0.8.0'} - dev: true - - /ethers@5.7.2: - resolution: {integrity: sha512-wswUsmWo1aOK8rR7DIKiWSw9DbLWe6x98Jrn8wcTflTVvaXhAMaB5zGAXy0GYQEQp9iO1iSHWVyARQm11zUtyg==} - dependencies: - '@ethersproject/abi': 5.7.0 - '@ethersproject/abstract-provider': 5.7.0 - '@ethersproject/abstract-signer': 5.7.0 - '@ethersproject/address': 5.7.0 - '@ethersproject/base64': 5.7.0 - '@ethersproject/basex': 5.7.0 - '@ethersproject/bignumber': 5.7.0 - '@ethersproject/bytes': 5.7.0 - '@ethersproject/constants': 5.7.0 - '@ethersproject/contracts': 5.7.0 - '@ethersproject/hash': 5.7.0 - '@ethersproject/hdnode': 5.7.0 - '@ethersproject/json-wallets': 5.7.0 - '@ethersproject/keccak256': 5.7.0 - '@ethersproject/logger': 5.7.0 - '@ethersproject/networks': 5.7.1 - '@ethersproject/pbkdf2': 5.7.0 - '@ethersproject/properties': 5.7.0 - '@ethersproject/providers': 5.7.2 - '@ethersproject/random': 5.7.0 - '@ethersproject/rlp': 5.7.0 - '@ethersproject/sha2': 5.7.0 - '@ethersproject/signing-key': 5.7.0 - '@ethersproject/solidity': 5.7.0 - '@ethersproject/strings': 5.7.0 - '@ethersproject/transactions': 5.7.0 - '@ethersproject/units': 5.7.0 - '@ethersproject/wallet': 5.7.0 - '@ethersproject/web': 5.7.1 - '@ethersproject/wordlists': 5.7.0 - transitivePeerDependencies: - - bufferutil - - utf-8-validate - dev: true - - /event-target-shim@5.0.1: - resolution: {integrity: sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ==} - engines: {node: '>=6'} - dev: true - - /eventemitter3@5.0.1: - resolution: {integrity: sha512-GWkBvjiSZK87ELrYOSESUYeVIc9mvLLf/nXalMOS5dYrgZq9o5OVkbZAVM06CVxYsCwH9BDZFPlQTlPA1j4ahA==} - dev: true - - /events@3.3.0: - resolution: {integrity: sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q==} - engines: {node: '>=0.8.x'} - dev: true - - /execa@7.2.0: - resolution: {integrity: sha512-UduyVP7TLB5IcAQl+OzLyLcS/l32W/GLg+AhHJ+ow40FOk2U3SAllPwR44v4vmdFwIWqpdwxxpQbF1n5ta9seA==} - engines: {node: ^14.18.0 || ^16.14.0 || >=18.0.0} - dependencies: - cross-spawn: 7.0.3 - get-stream: 6.0.1 - human-signals: 4.3.1 - is-stream: 3.0.0 - merge-stream: 2.0.0 - npm-run-path: 5.3.0 - onetime: 6.0.0 - signal-exit: 3.0.7 - strip-final-newline: 3.0.0 - dev: true - - /fast-content-type-parse@1.1.0: - resolution: {integrity: sha512-fBHHqSTFLVnR61C+gltJuE5GkVQMV0S2nqUO8TJ+5Z3qAKG8vAx4FKai1s5jq/inV1+sREynIWSuQ6HgoSXpDQ==} - dev: true - - /fast-decode-uri-component@1.0.1: - resolution: {integrity: sha512-WKgKWg5eUxvRZGwW8FvfbaH7AXSh2cL+3j5fMGzUMCxWBJ3dV3a7Wz8y2f/uQ0e3B6WmodD3oS54jTQ9HVTIIg==} - dev: true - - /fast-deep-equal@3.1.3: - resolution: {integrity: sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==} - dev: true - - /fast-diff@1.3.0: - resolution: {integrity: sha512-VxPP4NqbUjj6MaAOafWeUn2cXWLcCtljklUtZf0Ind4XQ+QPtmA0b18zZy0jIQx+ExRVCR/ZQpBmik5lXshNsw==} - dev: true - - /fast-json-stable-stringify@2.1.0: - resolution: {integrity: sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==} - dev: true - - /fast-json-stringify@5.12.0: - resolution: {integrity: sha512-7Nnm9UPa7SfHRbHVA1kJQrGXCRzB7LMlAAqHXQFkEQqueJm1V8owm0FsE/2Do55/4CcdhwiLQERaKomOnKQkyA==} - dependencies: - '@fastify/merge-json-schemas': 0.1.1 - ajv: 8.12.0 - ajv-formats: 2.1.1(ajv@8.12.0) - fast-deep-equal: 3.1.3 - fast-uri: 2.3.0 - json-schema-ref-resolver: 1.0.1 - rfdc: 1.3.1 - dev: true - - /fast-querystring@1.1.2: - resolution: {integrity: sha512-g6KuKWmFXc0fID8WWH0jit4g0AGBoJhCkJMb1RmbsSEUNvQ+ZC8D6CUZ+GtF8nMzSPXnhiePyyqqipzNNEnHjg==} - dependencies: - fast-decode-uri-component: 1.0.1 - dev: true - - /fast-redact@3.4.0: - resolution: {integrity: sha512-2gwPvyna0zwBdxKnng1suu/dTL5s8XEy2ZqH8mwDUwJdDkV8w5kp+JV26mupdK68HmPMbm6yjW9m7/Ys/BHEHg==} - engines: {node: '>=6'} - dev: true - - /fast-uri@2.3.0: - resolution: {integrity: sha512-eel5UKGn369gGEWOqBShmFJWfq/xSJvsgDzgLYC845GneayWvXBf0lJCBn5qTABfewy1ZDPoaR5OZCP+kssfuw==} - dev: true - - /fastify-plugin@4.5.1: - resolution: {integrity: sha512-stRHYGeuqpEZTL1Ef0Ovr2ltazUT9g844X5z/zEBFLG8RYlpDiOCIG+ATvYEp+/zmc7sN29mcIMp8gvYplYPIQ==} - dev: true - - /fastify@4.26.2: - resolution: {integrity: sha512-90pjTuPGrfVKtdpLeLzND5nyC4woXZN5VadiNQCicj/iJU4viNHKhsAnb7jmv1vu2IzkLXyBiCzdWuzeXgQ5Ug==} - dependencies: - '@fastify/ajv-compiler': 3.5.0 - '@fastify/error': 3.4.1 - '@fastify/fast-json-stringify-compiler': 4.3.0 - abstract-logging: 2.0.1 - avvio: 8.3.0 - fast-content-type-parse: 1.1.0 - fast-json-stringify: 5.12.0 - find-my-way: 8.1.0 - light-my-request: 5.12.0 - pino: 8.19.0 - process-warning: 3.0.0 - proxy-addr: 2.0.7 - rfdc: 1.3.1 - secure-json-parse: 2.7.0 - semver: 7.6.0 - toad-cache: 3.7.0 - transitivePeerDependencies: - - supports-color - dev: true - - /fastq@1.17.1: - resolution: {integrity: sha512-sRVD3lWVIXWg6By68ZN7vho9a1pQcN/WBFaAAsDDFzlJjvoGx0P8z7V1t72grFJfJhu3YPZBuu25f7Kaw2jN1w==} - dependencies: - reusify: 1.0.4 - dev: true - - /filelist@1.0.4: - resolution: {integrity: sha512-w1cEuf3S+DrLCQL7ET6kz+gmlJdbq9J7yXCSjK/OZCPA+qEN1WyF4ZAf0YYJa4/shHJra2t/d/r8SV4Ji+x+8Q==} - dependencies: - minimatch: 5.1.6 - dev: true - - /fill-range@7.0.1: - resolution: {integrity: sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==} - engines: {node: '>=8'} - dependencies: - to-regex-range: 5.0.1 - dev: true - - /find-my-way@8.1.0: - resolution: {integrity: sha512-41QwjCGcVTODUmLLqTMeoHeiozbMXYMAE1CKFiDyi9zVZ2Vjh0yz3MF0WQZoIb+cmzP/XlbFjlF2NtJmvZHznA==} - engines: {node: '>=14'} - dependencies: - fast-deep-equal: 3.1.3 - fast-querystring: 1.1.2 - safe-regex2: 2.0.0 - dev: true - - /find-replace@3.0.0: - resolution: {integrity: sha512-6Tb2myMioCAgv5kfvP5/PkZZ/ntTpVK39fHY7WkWBgvbeE+VHd/tZuZ4mrC+bxh4cfOZeYKVPaJIZtZXV7GNCQ==} - engines: {node: '>=4.0.0'} - dependencies: - array-back: 3.1.0 - dev: true - - /find-up@6.3.0: - resolution: {integrity: sha512-v2ZsoEuVHYy8ZIlYqwPe/39Cy+cFDzp4dXPaxNvkEuouymu+2Jbz0PxpKarJHYJTmv2HWT3O382qY8l4jMWthw==} - engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} - dependencies: - locate-path: 7.2.0 - path-exists: 5.0.0 - dev: true - - /forwarded@0.2.0: - resolution: {integrity: sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==} - engines: {node: '>= 0.6'} - dev: true - - /from2@2.3.0: - resolution: {integrity: sha512-OMcX/4IC/uqEPVgGeyfN22LJk6AZrMkRZHxcHBMBvHScDGgwTm2GT2Wkgtocyd3JfZffjj2kYUDXXII0Fk9W0g==} - dependencies: - inherits: 2.0.4 - readable-stream: 2.3.8 - dev: true - - /fs-extra@7.0.1: - resolution: {integrity: sha512-YJDaCJZEnBmcbw13fvdAM9AwNOJwOzrE4pqMqBq5nFiEqXUqHwlK4B+3pUw6JNvfSPtX05xFHtYy/1ni01eGCw==} - engines: {node: '>=6 <7 || >=8'} - dependencies: - graceful-fs: 4.2.11 - jsonfile: 4.0.0 - universalify: 0.1.2 - dev: true - - /fs.realpath@1.0.0: - resolution: {integrity: sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==} - dev: true - - /fsevents@2.3.3: - resolution: {integrity: sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==} - engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0} - os: [darwin] - requiresBuild: true - dev: true - optional: true - - /get-caller-file@2.0.5: - resolution: {integrity: sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==} - engines: {node: 6.* || 8.* || >= 10.*} - dev: true - - /get-stream@6.0.1: - resolution: {integrity: sha512-ts6Wi+2j3jQjqi70w5AlN8DFnkSwC+MqmxEzdEALB2qXZYV3X/b1CTfgPLGJNMeAWxdPfU8FO1ms3NUfaHCPYg==} - engines: {node: '>=10'} - dev: true - - /glob-parent@5.1.2: - resolution: {integrity: sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==} - engines: {node: '>= 6'} - dependencies: - is-glob: 4.0.3 - dev: true - - /glob@7.1.7: - resolution: {integrity: sha512-OvD9ENzPLbegENnYP5UUfJIirTg4+XwMWGaQfQTY0JenxNvvIKP3U3/tAQSPIu/lHxXYSZmpXlUHeqAIdKzBLQ==} - dependencies: - fs.realpath: 1.0.0 - inflight: 1.0.6 - inherits: 2.0.4 - minimatch: 3.1.2 - once: 1.4.0 - path-is-absolute: 1.0.1 - dev: true - - /glob@7.2.3: - resolution: {integrity: sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==} - dependencies: - fs.realpath: 1.0.0 - inflight: 1.0.6 - inherits: 2.0.4 - minimatch: 3.1.2 - once: 1.4.0 - path-is-absolute: 1.0.1 - dev: true - - /glob@8.1.0: - resolution: {integrity: sha512-r8hpEjiQEYlF2QU0df3dS+nxxSIreXQS1qRhMJM0Q5NDdR386C7jb7Hwwod8Fgiuex+k0GFjgft18yvxm5XoCQ==} - engines: {node: '>=12'} - dependencies: - fs.realpath: 1.0.0 - inflight: 1.0.6 - inherits: 2.0.4 - minimatch: 5.1.6 - once: 1.4.0 - dev: true - - /google-protobuf@3.21.2: - resolution: {integrity: sha512-3MSOYFO5U9mPGikIYCzK0SaThypfGgS6bHqrUGXG3DPHCrb+txNqeEcns1W0lkGfk0rCyNXm7xB9rMxnCiZOoA==} - dev: true - - /graceful-fs@4.2.11: - resolution: {integrity: sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==} - dev: true - - /has-flag@3.0.0: - resolution: {integrity: sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==} - engines: {node: '>=4'} - dev: true - - /has-flag@4.0.0: - resolution: {integrity: sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==} - engines: {node: '>=8'} - dev: true - - /hash.js@1.1.7: - resolution: {integrity: sha512-taOaskGt4z4SOANNseOviYDvjEJinIkRgmp7LbKP2YTTmVxWBl87s/uzK9r+44BclBSp2X7K1hqeNfz9JbBeXA==} - dependencies: - inherits: 2.0.4 - minimalistic-assert: 1.0.1 - dev: true - - /hmac-drbg@1.0.1: - resolution: {integrity: sha512-Tti3gMqLdZfhOQY1Mzf/AanLiqh1WTiJgEj26ZuYQ9fbkLomzGchCws4FyrSd4VkpBfiNhaE1On+lOz894jvXg==} - dependencies: - hash.js: 1.1.7 - minimalistic-assert: 1.0.1 - minimalistic-crypto-utils: 1.0.1 - dev: true - - /human-signals@4.3.1: - resolution: {integrity: sha512-nZXjEF2nbo7lIw3mgYjItAfgQXog3OjJogSbKa2CQIIvSGWcKgeJnQlNXip6NglNzYH45nSRiEVimMvYL8DDqQ==} - engines: {node: '>=14.18.0'} - dev: true - - /ieee754@1.2.1: - resolution: {integrity: sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==} - dev: true - - /ignore@5.3.1: - resolution: {integrity: sha512-5Fytz/IraMjqpwfd34ke28PTVMjZjJG2MPn5t7OE4eUCUNf8BAa7b5WUS9/Qvr6mwOQS7Mk6vdsMno5he+T8Xw==} - engines: {node: '>= 4'} - dev: true - - /import-fresh@3.3.0: - resolution: {integrity: sha512-veYYhQa+D1QBKznvhUHxb8faxlrwUnxseDAbAp457E0wLNio2bOSKnjYDhMj+YiAq61xrMGhQk9iXVk5FzgQMw==} - engines: {node: '>=6'} - dependencies: - parent-module: 1.0.1 - resolve-from: 4.0.0 - dev: true - - /inflight@1.0.6: - resolution: {integrity: sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==} - dependencies: - once: 1.4.0 - wrappy: 1.0.2 - dev: true - - /inherits@2.0.3: - resolution: {integrity: sha512-x00IRNXNy63jwGkJmzPigoySHbaqpNuzKbBOmzK+g2OdZpQ9w+sxCN+VSB3ja7IAge2OP2qpfxTjeNcyjmW1uw==} - dev: true - - /inherits@2.0.4: - resolution: {integrity: sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==} - dev: true - - /into-stream@6.0.0: - resolution: {integrity: sha512-XHbaOAvP+uFKUFsOgoNPRjLkwB+I22JFPFe5OjTkQ0nwgj6+pSjb4NmB6VMxaPshLiOf+zcpOCBQuLwC1KHhZA==} - engines: {node: '>=10'} - dependencies: - from2: 2.3.0 - p-is-promise: 3.0.0 - dev: true - - /ipaddr.js@1.9.1: - resolution: {integrity: sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==} - engines: {node: '>= 0.10'} - dev: true - - /is-arrayish@0.2.1: - resolution: {integrity: sha512-zz06S8t0ozoDXMG+ube26zeCTNXcKIPJZJi8hBrF4idCLms4CG9QtK7qBl1boi5ODzFpjswb5JPmHCbMpjaYzg==} - dev: true - - /is-binary-path@2.1.0: - resolution: {integrity: sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==} - engines: {node: '>=8'} - dependencies: - binary-extensions: 2.2.0 - dev: true - - /is-extglob@2.1.1: - resolution: {integrity: sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==} - engines: {node: '>=0.10.0'} - dev: true - - /is-fullwidth-code-point@3.0.0: - resolution: {integrity: sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==} - engines: {node: '>=8'} - dev: true - - /is-glob@4.0.3: - resolution: {integrity: sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==} - engines: {node: '>=0.10.0'} - dependencies: - is-extglob: 2.1.1 - dev: true - - /is-number@7.0.0: - resolution: {integrity: sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==} - engines: {node: '>=0.12.0'} - dev: true - - /is-stream@3.0.0: - resolution: {integrity: sha512-LnQR4bZ9IADDRSkvpqMGvt/tEJWclzklNgSw48V5EAaAeDd6qGvN8ei6k5p0tvxSR171VmGyHuTiAOfxAbr8kA==} - engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} - dev: true - - /isarray@1.0.0: - resolution: {integrity: sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==} - dev: true - - /isexe@2.0.0: - resolution: {integrity: sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==} - dev: true - - /isows@1.0.3(ws@8.13.0): - resolution: {integrity: sha512-2cKei4vlmg2cxEjm3wVSqn8pcoRF/LX/wpifuuNquFO4SQmPwarClT+SUCA2lt+l581tTeZIPIZuIDo2jWN1fg==} - peerDependencies: - ws: '*' - dependencies: - ws: 8.13.0 - dev: true - - /jake@10.8.7: - resolution: {integrity: sha512-ZDi3aP+fG/LchyBzUM804VjddnwfSfsdeYkwt8NcbKRvo4rFkjhs456iLFn3k2ZUWvNe4i48WACDbza8fhq2+w==} - engines: {node: '>=10'} - hasBin: true - dependencies: - async: 3.2.5 - chalk: 4.1.2 - filelist: 1.0.4 - minimatch: 3.1.2 - dev: true - - /js-base64@3.7.7: - resolution: {integrity: sha512-7rCnleh0z2CkXhH67J8K1Ytz0b2Y+yxTPL+/KOJoa20hfnVQ/3/T6W/KflYI4bRHRagNeXeU2bkNGI3v1oS/lw==} - dev: true - - /js-sha3@0.8.0: - resolution: {integrity: sha512-gF1cRrHhIzNfToc802P800N8PpXS+evLLXfsVpowqmAFR9uwbi89WvXg2QspOmXL8QL86J4T1EpFu+yUkwJY3Q==} - dev: true - - /js-tokens@4.0.0: - resolution: {integrity: sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==} - dev: true - - /js-yaml@4.1.0: - resolution: {integrity: sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==} - hasBin: true - dependencies: - argparse: 2.0.1 - dev: true - - /json-parse-even-better-errors@2.3.1: - resolution: {integrity: sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w==} - dev: true - - /json-schema-ref-resolver@1.0.1: - resolution: {integrity: sha512-EJAj1pgHc1hxF6vo2Z3s69fMjO1INq6eGHXZ8Z6wCQeldCuwxGK9Sxf4/cScGn3FZubCVUehfWtcDM/PLteCQw==} - dependencies: - fast-deep-equal: 3.1.3 - dev: true - - /json-schema-traverse@0.4.1: - resolution: {integrity: sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==} - dev: true - - /json-schema-traverse@1.0.0: - resolution: {integrity: sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==} - dev: true - - /jsonfile@4.0.0: - resolution: {integrity: sha512-m6F1R3z8jjlf2imQHS2Qez5sjKWQzbuuhuJ/FKYFRZvPE3PuHcSMVZzfsLhGVOkfd20obL5SWEBew5ShlquNxg==} - optionalDependencies: - graceful-fs: 4.2.11 - dev: true - - /light-my-request@5.12.0: - resolution: {integrity: sha512-P526OX6E7aeCIfw/9UyJNsAISfcFETghysaWHQAlQYayynShT08MOj4c6fBCvTWBrHXSvqBAKDp3amUPSCQI4w==} - dependencies: - cookie: 0.6.0 - process-warning: 3.0.0 - set-cookie-parser: 2.6.0 - dev: true - - /lines-and-columns@1.2.4: - resolution: {integrity: sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==} - dev: true - - /locate-path@7.2.0: - resolution: {integrity: sha512-gvVijfZvn7R+2qyPX8mAuKcFGDf6Nc61GdvGafQsHL0sBIxfKzA+usWn4GFC/bk+QdwPUD4kWFJLhElipq+0VA==} - engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} - dependencies: - p-locate: 6.0.0 - dev: true - - /lodash.camelcase@4.3.0: - resolution: {integrity: sha512-TwuEnCnxbc3rAvhf/LbG7tJUDzhqXyFnv3dtzLOPgCG/hODL7WFnsbwktkD7yUV0RrreP/l1PALq/YSg6VvjlA==} - dev: true - - /lodash.truncate@4.4.2: - resolution: {integrity: sha512-jttmRe7bRse52OsWIMDLaXxWqRAmtIUccAQ3garviCqJjafXOfNMO0yMfNpdD6zbGaTU0P5Nz7e7gAT6cKmJRw==} - dev: true - - /lodash@4.17.21: - resolution: {integrity: sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==} - dev: true - - /long@5.2.3: - resolution: {integrity: sha512-lcHwpNoggQTObv5apGNCTdJrO69eHOZMi4BNC+rTLER8iHAqGrUVeLh/irVIM7zTw2bOXA8T6uNPeujwOLg/2Q==} - dev: true - - /lru-cache@6.0.0: - resolution: {integrity: sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==} - engines: {node: '>=10'} - dependencies: - yallist: 4.0.0 - dev: true - - /make-error@1.3.6: - resolution: {integrity: sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==} - dev: true - - /merge-stream@2.0.0: - resolution: {integrity: sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==} - dev: true - - /mime-db@1.52.0: - resolution: {integrity: sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==} - engines: {node: '>= 0.6'} - dev: true - - /mimic-fn@4.0.0: - resolution: {integrity: sha512-vqiC06CuhBTUdZH+RYl8sFrL096vA45Ok5ISO6sE/Mr1jRbGH4Csnhi8f3wKVl7x8mO4Au7Ir9D3Oyv1VYMFJw==} - engines: {node: '>=12'} - dev: true - - /minimalistic-assert@1.0.1: - resolution: {integrity: sha512-UtJcAD4yEaGtjPezWuO9wC4nwUnVH/8/Im3yEHQP4b67cXlD/Qr9hdITCU1xDbSEXg2XKNaP8jsReV7vQd00/A==} - dev: true - - /minimalistic-crypto-utils@1.0.1: - resolution: {integrity: sha512-JIYlbt6g8i5jKfJ3xz7rF0LXmv2TkDxBLUkiBeZ7bAx4GnnNMr8xFpGnOxn6GhTEHx3SjRrZEoU+j04prX1ktg==} - dev: true - - /minimatch@3.1.2: - resolution: {integrity: sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==} - dependencies: - brace-expansion: 1.1.11 - dev: true - - /minimatch@5.1.6: - resolution: {integrity: sha512-lKwV/1brpG6mBUFHtb7NUmtABCb2WZZmm2wNiOA5hAb8VdCS4B3dtMWyvcoViccwAW/COERjXLt0zP1zXUN26g==} - engines: {node: '>=10'} - dependencies: - brace-expansion: 2.0.1 - dev: true - - /minipass@7.0.4: - resolution: {integrity: sha512-jYofLM5Dam9279rdkWzqHozUo4ybjdZmCsDHePy5V/PbBcVMiSZR97gmAy45aqi8CK1lG2ECd356FU86avfwUQ==} - engines: {node: '>=16 || 14 >=14.17'} - dev: true - - /mkdirp@1.0.4: - resolution: {integrity: sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==} - engines: {node: '>=10'} - hasBin: true - dev: true - - /mnemonist@0.39.6: - resolution: {integrity: sha512-A/0v5Z59y63US00cRSLiloEIw3t5G+MiKz4BhX21FI+YBJXBOGW0ohFxTxO08dsOYlzxo87T7vGfZKYp2bcAWA==} - dependencies: - obliterator: 2.0.4 - dev: true - - /mobx@6.12.0: - resolution: {integrity: sha512-Mn6CN6meXEnMa0a5u6a5+RKrqRedHBhZGd15AWLk9O6uFY4KYHzImdt8JI8WODo1bjTSRnwXhJox+FCUZhCKCQ==} - dev: true - - /ms@2.1.2: - resolution: {integrity: sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==} - dev: true - - /nan@2.19.0: - resolution: {integrity: sha512-nO1xXxfh/RWNxfd/XPfbIfFk5vgLsAxUR9y5O0cHMJu/AW9U95JLXqthYHjEp+8gQ5p96K9jUp8nbVOxCdRbtw==} - dev: true - - /nice-grpc-common@2.0.2: - resolution: {integrity: sha512-7RNWbls5kAL1QVUOXvBsv1uO0wPQK3lHv+cY1gwkTzirnG1Nop4cBJZubpgziNbaVc/bl9QJcyvsf/NQxa3rjQ==} - dependencies: - ts-error: 1.0.6 - dev: true - - /nice-grpc-web@2.0.2(google-protobuf@3.21.2): - resolution: {integrity: sha512-hIgvd0ufjOR1FqrakqQ1HdO6A8M1rps9cTCnO+8aPml2NXyLOsuZCdzCp/f31Y1ngBGvDkoalW5H+CBd11x+GQ==} - dependencies: - '@improbable-eng/grpc-web': 0.15.0(google-protobuf@3.21.2) - abort-controller-x: 0.4.3 - js-base64: 3.7.7 - nice-grpc-common: 2.0.2 - transitivePeerDependencies: - - google-protobuf - dev: true - - /node-pty@1.0.0: - resolution: {integrity: sha512-wtBMWWS7dFZm/VgqElrTvtfMq4GzJ6+edFI0Y0zyzygUSZMgZdraDUMUhCIvkjhJjme15qWmbyJbtAx4ot4uZA==} - requiresBuild: true - dependencies: - nan: 2.19.0 - dev: true - - /normalize-path@3.0.0: - resolution: {integrity: sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==} - engines: {node: '>=0.10.0'} - dev: true - - /npm-run-path@5.3.0: - resolution: {integrity: sha512-ppwTtiJZq0O/ai0z7yfudtBpWIoxM8yE6nHi1X47eFR2EWORqfbu6CnPlNsjeN683eT0qG6H/Pyf9fCcvjnnnQ==} - engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} - dependencies: - path-key: 4.0.0 - dev: true - - /obliterator@2.0.4: - resolution: {integrity: sha512-lgHwxlxV1qIg1Eap7LgIeoBWIMFibOjbrYPIPJZcI1mmGAI2m3lNYpK12Y+GBdPQ0U1hRwSord7GIaawz962qQ==} - dev: true - - /on-exit-leak-free@2.1.2: - resolution: {integrity: sha512-0eJJY6hXLGf1udHwfNftBqH+g73EU4B504nZeKpz1sYRKafAghwxEJunB2O7rDZkL4PGfsMVnTXZ2EjibbqcsA==} - engines: {node: '>=14.0.0'} - dev: true - - /once@1.4.0: - resolution: {integrity: sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==} - dependencies: - wrappy: 1.0.2 - dev: true - - /onetime@6.0.0: - resolution: {integrity: sha512-1FlR+gjXK7X+AsAHso35MnyN5KqGwJRi/31ft6x0M194ht7S+rWAvd7PHss9xSKMzE0asv1pyIHaJYq+BbacAQ==} - engines: {node: '>=12'} - dependencies: - mimic-fn: 4.0.0 - dev: true - - /openurl@1.1.1: - resolution: {integrity: sha512-d/gTkTb1i1GKz5k3XE3XFV/PxQ1k45zDqGP2OA7YhgsaLoqm6qRvARAZOFer1fcXritWlGBRCu/UgeS4HAnXAA==} - dev: true - - /p-is-promise@3.0.0: - resolution: {integrity: sha512-Wo8VsW4IRQSKVXsJCn7TomUaVtyfjVDn3nUP7kE967BQk0CwFpdbZs0X0uk5sW9mkBa9eNM7hCMaG93WUAwxYQ==} - engines: {node: '>=8'} - dev: true - - /p-limit@4.0.0: - resolution: {integrity: sha512-5b0R4txpzjPWVw/cXXUResoD4hb6U/x9BH08L7nw+GN1sezDzPdxeRvpc9c433fZhBan/wusjbCsqwqm4EIBIQ==} - engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} - dependencies: - yocto-queue: 1.0.0 - dev: true - - /p-locate@6.0.0: - resolution: {integrity: sha512-wPrq66Llhl7/4AGC6I+cqxT07LhXvWL08LNXz1fENOw0Ap4sRZZ/gZpTTJ5jpurzzzfS2W/Ge9BY3LgLjCShcw==} - engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} - dependencies: - p-limit: 4.0.0 - dev: true - - /p-queue@7.4.1: - resolution: {integrity: sha512-vRpMXmIkYF2/1hLBKisKeVYJZ8S2tZ0zEAmIJgdVKP2nq0nh4qCdf8bgw+ZgKrkh71AOCaqzwbJJk1WtdcF3VA==} - engines: {node: '>=12'} - dependencies: - eventemitter3: 5.0.1 - p-timeout: 5.1.0 - dev: true - - /p-retry@5.1.2: - resolution: {integrity: sha512-couX95waDu98NfNZV+i/iLt+fdVxmI7CbrrdC2uDWfPdUAApyxT4wmDlyOtR5KtTDmkDO0zDScDjDou9YHhd9g==} - engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} - dependencies: - '@types/retry': 0.12.1 - retry: 0.13.1 - dev: true - - /p-timeout@5.1.0: - resolution: {integrity: sha512-auFDyzzzGZZZdHz3BtET9VEz0SE/uMEAx7uWfGPucfzEwwe/xH0iVeZibQmANYE/hp9T2+UUZT5m+BKyrDp3Ew==} - engines: {node: '>=12'} - dev: true - - /parent-module@1.0.1: - resolution: {integrity: sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==} - engines: {node: '>=6'} - dependencies: - callsites: 3.1.0 - dev: true - - /parse-json@5.2.0: - resolution: {integrity: sha512-ayCKvm/phCGxOkYRSCM82iDwct8/EonSEgCSxWxD7ve6jHggsFl4fZVQBPRNgQoKiuV/odhFrGzQXZwbifC8Rg==} - engines: {node: '>=8'} - dependencies: - '@babel/code-frame': 7.23.5 - error-ex: 1.3.2 - json-parse-even-better-errors: 2.3.1 - lines-and-columns: 1.2.4 - dev: true - - /path-exists@5.0.0: - resolution: {integrity: sha512-RjhtfwJOxzcFmNOi6ltcbcu4Iu+FL3zEj83dk4kAS+fVpTxXLO1b38RvJgT/0QwvV/L3aY9TAnyv0EOqW4GoMQ==} - engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} - dev: true - - /path-is-absolute@1.0.1: - resolution: {integrity: sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==} - engines: {node: '>=0.10.0'} - dev: true - - /path-key@3.1.1: - resolution: {integrity: sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==} - engines: {node: '>=8'} - dev: true - - /path-key@4.0.0: - resolution: {integrity: sha512-haREypq7xkM7ErfgIyA0z+Bj4AGKlMSdlQE2jvJo6huWD1EdkKYV+G/T4nq0YEF2vgTT8kqMFKo1uHn950r4SQ==} - engines: {node: '>=12'} - dev: true - - /path-type@4.0.0: - resolution: {integrity: sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==} - engines: {node: '>=8'} - dev: true - - /path@0.12.7: - resolution: {integrity: sha512-aXXC6s+1w7otVF9UletFkFcDsJeO7lSZBPUQhtb5O0xJe8LtYhj/GxldoL09bBj9+ZmE2hNoHqQSFMN5fikh4Q==} - dependencies: - process: 0.11.10 - util: 0.10.4 - dev: true - - /peek-stream@1.1.3: - resolution: {integrity: sha512-FhJ+YbOSBb9/rIl2ZeE/QHEsWn7PqNYt8ARAY3kIgNGOk13g9FGyIY6JIl/xB/3TFRVoTv5as0l11weORrTekA==} - dependencies: - buffer-from: 1.1.2 - duplexify: 3.7.1 - through2: 2.0.5 - dev: true - - /picomatch@2.3.1: - resolution: {integrity: sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==} - engines: {node: '>=8.6'} - dev: true - - /pino-abstract-transport@1.1.0: - resolution: {integrity: sha512-lsleG3/2a/JIWUtf9Q5gUNErBqwIu1tUKTT3dUzaf5DySw9ra1wcqKjJjLX1VTY64Wk1eEOYsVGSaGfCK85ekA==} - dependencies: - readable-stream: 4.5.2 - split2: 4.2.0 - dev: true - - /pino-std-serializers@6.2.2: - resolution: {integrity: sha512-cHjPPsE+vhj/tnhCy/wiMh3M3z3h/j15zHQX+S9GkTBgqJuTuJzYJ4gUyACLhDaJ7kk9ba9iRDmbH2tJU03OiA==} - dev: true - - /pino@8.19.0: - resolution: {integrity: sha512-oswmokxkav9bADfJ2ifrvfHUwad6MLp73Uat0IkQWY3iAw5xTRoznXbXksZs8oaOUMpmhVWD+PZogNzllWpJaA==} - hasBin: true - dependencies: - atomic-sleep: 1.0.0 - fast-redact: 3.4.0 - on-exit-leak-free: 2.1.2 - pino-abstract-transport: 1.1.0 - pino-std-serializers: 6.2.2 - process-warning: 3.0.0 - quick-format-unescaped: 4.0.4 - real-require: 0.2.0 - safe-stable-stringify: 2.4.3 - sonic-boom: 3.8.0 - thread-stream: 2.4.1 - dev: true - - /pluralize@8.0.0: - resolution: {integrity: sha512-Nc3IT5yHzflTfbjgqWcCPpo7DaKy4FnpB0l/zCAW0Tc7jxAiuqSxHasntB3D7887LSrA93kDJ9IXovxJYxyLCA==} - engines: {node: '>=4'} - dev: true - - /prettier-plugin-solidity@1.3.1(prettier@2.8.8): - resolution: {integrity: sha512-MN4OP5I2gHAzHZG1wcuJl0FsLS3c4Cc5494bbg+6oQWBPuEamjwDvmGfFMZ6NFzsh3Efd9UUxeT7ImgjNH4ozA==} - engines: {node: '>=16'} - peerDependencies: - prettier: '>=2.3.0' - dependencies: - '@solidity-parser/parser': 0.17.0 - prettier: 2.8.8 - semver: 7.6.0 - solidity-comments-extractor: 0.0.8 - dev: true - - /prettier-plugin-solidity@1.3.1(prettier@3.2.5): - resolution: {integrity: sha512-MN4OP5I2gHAzHZG1wcuJl0FsLS3c4Cc5494bbg+6oQWBPuEamjwDvmGfFMZ6NFzsh3Efd9UUxeT7ImgjNH4ozA==} - engines: {node: '>=16'} - peerDependencies: - prettier: '>=2.3.0' - dependencies: - '@solidity-parser/parser': 0.17.0 - prettier: 3.2.5 - semver: 7.6.0 - solidity-comments-extractor: 0.0.8 - dev: true - - /prettier@2.8.8: - resolution: {integrity: sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==} - engines: {node: '>=10.13.0'} - hasBin: true - dev: true - - /prettier@3.2.5: - resolution: {integrity: sha512-3/GWa9aOC0YeD7LUfvOG2NiDyhOWRvt1k+rcKhOuYnMY24iiCphgneUfJDyFXd6rZCAnuLBv6UeAULtrhT/F4A==} - engines: {node: '>=14'} - hasBin: true - dev: true - - /process-nextick-args@2.0.1: - resolution: {integrity: sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==} - dev: true - - /process-warning@3.0.0: - resolution: {integrity: sha512-mqn0kFRl0EoqhnL0GQ0veqFHyIN1yig9RHh/InzORTUiZHFRAur+aMtRkELNwGs9aNwKS6tg/An4NYBPGwvtzQ==} - dev: true - - /process@0.11.10: - resolution: {integrity: sha512-cdGef/drWFoydD1JsMzuFf8100nZl+GT+yacc2bEced5f9Rjk4z+WtFUTBu9PhOi9j/jfmBPu0mMEY4wIdAF8A==} - engines: {node: '>= 0.6.0'} - dev: true - - /protobufjs@7.2.6: - resolution: {integrity: sha512-dgJaEDDL6x8ASUZ1YqWciTRrdOuYNzoOf27oHNfdyvKqHr5i0FV7FSLU+aIeFjyFgVxrpTOtQUi0BLLBymZaBw==} - engines: {node: '>=12.0.0'} - requiresBuild: true - dependencies: - '@protobufjs/aspromise': 1.1.2 - '@protobufjs/base64': 1.1.2 - '@protobufjs/codegen': 2.0.4 - '@protobufjs/eventemitter': 1.1.0 - '@protobufjs/fetch': 1.1.0 - '@protobufjs/float': 1.0.2 - '@protobufjs/inquire': 1.1.0 - '@protobufjs/path': 1.1.2 - '@protobufjs/pool': 1.1.0 - '@protobufjs/utf8': 1.1.0 - '@types/node': 18.19.22 - long: 5.2.3 - dev: true - - /proxy-addr@2.0.7: - resolution: {integrity: sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==} - engines: {node: '>= 0.10'} - dependencies: - forwarded: 0.2.0 - ipaddr.js: 1.9.1 - dev: true - - /proxy-deep@3.1.1: - resolution: {integrity: sha512-kppbvLUNJ4IOMZds9/4gz/rtT5OFiesy3XosLsgMKlF3vb6GA5Y3ptyDlzKLcOcUBW+zaY+RiMINTsgE+O6e+Q==} - dev: true - - /pump@3.0.0: - resolution: {integrity: sha512-LwZy+p3SFs1Pytd/jYct4wpv49HiYCqd9Rlc5ZVdk0V+8Yzv6jR5Blk3TRmPL1ft69TxP0IMZGJ+WPFU2BFhww==} - dependencies: - end-of-stream: 1.4.4 - once: 1.4.0 - dev: true - - /pumpify@2.0.1: - resolution: {integrity: sha512-m7KOje7jZxrmutanlkS1daj1dS6z6BgslzOXmcSEpIlCxM3VJH7lG5QLeck/6hgF6F4crFf01UtQmNsJfweTAw==} - dependencies: - duplexify: 4.1.3 - inherits: 2.0.4 - pump: 3.0.0 - dev: true - - /punycode@2.3.1: - resolution: {integrity: sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==} - engines: {node: '>=6'} - dev: true - - /quick-format-unescaped@4.0.4: - resolution: {integrity: sha512-tYC1Q1hgyRuHgloV/YXs2w15unPVh8qfu/qCTfhTYamaw7fyhumKa2yGpdSo87vY32rIclj+4fWYQXUMs9EHvg==} - dev: true - - /readable-stream@2.3.8: - resolution: {integrity: sha512-8p0AUk4XODgIewSi0l8Epjs+EVnWiK7NoDIEGU0HhE7+ZyY8D1IMY7odu5lRrFXGg71L15KG8QrPmum45RTtdA==} - dependencies: - core-util-is: 1.0.3 - inherits: 2.0.4 - isarray: 1.0.0 - process-nextick-args: 2.0.1 - safe-buffer: 5.1.2 - string_decoder: 1.1.1 - util-deprecate: 1.0.2 - dev: true - - /readable-stream@3.6.2: - resolution: {integrity: sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==} - engines: {node: '>= 6'} - dependencies: - inherits: 2.0.4 - string_decoder: 1.3.0 - util-deprecate: 1.0.2 - dev: true - - /readable-stream@4.5.2: - resolution: {integrity: sha512-yjavECdqeZ3GLXNgRXgeQEdz9fvDDkNKyHnbHRFtOr7/LcfgBcmct7t/ET+HaCTqfh06OzoAxrkN/IfjJBVe+g==} - engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} - dependencies: - abort-controller: 3.0.0 - buffer: 6.0.3 - events: 3.3.0 - process: 0.11.10 - string_decoder: 1.3.0 - dev: true - - /readdirp@3.6.0: - resolution: {integrity: sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==} - engines: {node: '>=8.10.0'} - dependencies: - picomatch: 2.3.1 - dev: true - - /real-require@0.2.0: - resolution: {integrity: sha512-57frrGM/OCTLqLOAh0mhVA9VBMHd+9U7Zb2THMGdBUoZVOtGbJzjxsYGDJ3A9AYYCP4hn6y1TVbaOfzWtm5GFg==} - engines: {node: '>= 12.13.0'} - dev: true - - /reduce-flatten@2.0.0: - resolution: {integrity: sha512-EJ4UNY/U1t2P/2k6oqotuX2Cc3T6nxJwsM0N0asT7dhrtH1ltUxDn4NalSYmPE2rCkVpcf/X6R0wDwcFpzhd4w==} - engines: {node: '>=6'} - dev: true - - /require-directory@2.1.1: - resolution: {integrity: sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==} - engines: {node: '>=0.10.0'} - dev: true - - /require-from-string@2.0.2: - resolution: {integrity: sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==} - engines: {node: '>=0.10.0'} - dev: true - - /resolve-from@4.0.0: - resolution: {integrity: sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==} - engines: {node: '>=4'} - dev: true - - /ret@0.2.2: - resolution: {integrity: sha512-M0b3YWQs7R3Z917WRQy1HHA7Ba7D8hvZg6UE5mLykJxQVE2ju0IXbGlaHPPlkY+WN7wFP+wUMXmBFA0aV6vYGQ==} - engines: {node: '>=4'} - dev: true - - /retry@0.13.1: - resolution: {integrity: sha512-XQBQ3I8W1Cge0Seh+6gjj03LbmRFWuoszgK9ooCpwYIrhhoO80pfq4cUkU5DkknwfOfFteRwlZ56PYOGYyFWdg==} - engines: {node: '>= 4'} - dev: true - - /reusify@1.0.4: - resolution: {integrity: sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==} - engines: {iojs: '>=1.0.0', node: '>=0.10.0'} - dev: true - - /rfdc@1.3.1: - resolution: {integrity: sha512-r5a3l5HzYlIC68TpmYKlxWjmOP6wiPJ1vWv2HeLhNsRZMrCkxeqxiHlQ21oXmQ4F3SiryXBHhAD7JZqvOJjFmg==} - dev: true - - /rimraf@3.0.2: - resolution: {integrity: sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==} - hasBin: true - dependencies: - glob: 7.2.3 - dev: true - - /run-pty@4.1.0: - resolution: {integrity: sha512-Sl0b143FW+4sYX+WQksnE7hcxMgqTDrKntd091x5s+HG36K37mL3INgjK8RasH3YqFQQYTXQX7bmUjgdUoTklQ==} - hasBin: true - dependencies: - node-pty: 1.0.0 - tiny-decoders: 7.0.1 - dev: true - - /rxjs@7.5.5: - resolution: {integrity: sha512-sy+H0pQofO95VDmFLzyaw9xNJU4KTRSwQIGM6+iG3SypAtCiLDzpeG8sJrNCWn2Up9km+KhkvTdbkrdy+yzZdw==} - dependencies: - tslib: 2.6.2 - dev: true - - /safe-buffer@5.1.2: - resolution: {integrity: sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==} - dev: true - - /safe-buffer@5.2.1: - resolution: {integrity: sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==} - dev: true - - /safe-regex2@2.0.0: - resolution: {integrity: sha512-PaUSFsUaNNuKwkBijoAPHAK6/eM6VirvyPWlZ7BAQy4D+hCvh4B6lIG+nPdhbFfIbP+gTGBcrdsOaUs0F+ZBOQ==} - dependencies: - ret: 0.2.2 - dev: true - - /safe-stable-stringify@2.4.3: - resolution: {integrity: sha512-e2bDA2WJT0wxseVd4lsDP4+3ONX6HpMXQa1ZhFQ7SU+GjvORCmShbCMltrtIDfkYhVHrOcPtj+KhmDBdPdZD1g==} - engines: {node: '>=10'} - dev: true - - /scrypt-js@3.0.1: - resolution: {integrity: sha512-cdwTTnqPu0Hyvf5in5asVdZocVDTNRmR7XEcJuIzMjJeSHybHl7vpB66AzwTaIg6CLSbtjcxc8fqcySfnTkccA==} - dev: true - - /secure-json-parse@2.7.0: - resolution: {integrity: sha512-6aU+Rwsezw7VR8/nyvKTx8QpWH9FrcYiXXlqC4z5d5XQBDRqtbfsRjnwGyqbi3gddNtWHuEk9OANUotL26qKUw==} - dev: true - - /semver@7.6.0: - resolution: {integrity: sha512-EnwXhrlwXMk9gKu5/flx5sv/an57AkRplG3hTK68W7FRDN+k+OWBj65M7719OkA82XLBxrcX0KSHj+X5COhOVg==} - engines: {node: '>=10'} - hasBin: true - dependencies: - lru-cache: 6.0.0 - dev: true - - /set-cookie-parser@2.6.0: - resolution: {integrity: sha512-RVnVQxTXuerk653XfuliOxBP81Sf0+qfQE73LIYKcyMYHG94AuH0kgrQpRDuTZnSmjpysHmzxJXKNfa6PjFhyQ==} - dev: true - - /shebang-command@2.0.0: - resolution: {integrity: sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==} - engines: {node: '>=8'} - dependencies: - shebang-regex: 3.0.0 - dev: true - - /shebang-regex@3.0.0: - resolution: {integrity: sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==} - engines: {node: '>=8'} - dev: true - - /signal-exit@3.0.7: - resolution: {integrity: sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==} - dev: true - - /slice-ansi@4.0.0: - resolution: {integrity: sha512-qMCMfhY040cVHT43K9BFygqYbUPFZKHOg7K73mtTWJRb8pyP3fzf4Ixd5SzdEJQ6MRUg/WBnOLxghZtKKurENQ==} - engines: {node: '>=10'} - dependencies: - ansi-styles: 4.3.0 - astral-regex: 2.0.0 - is-fullwidth-code-point: 3.0.0 - dev: true - - /solhint-config-mud@2.0.1: - resolution: {integrity: sha512-c/tZgXe9JNR23lUfMgj2IiQxG8rBsX5sRchgvro82jMMdWcRqZ0XxKTsgvGUbGrndsfC7KhBDcB6Q83CPuUZ4w==} - dev: true - - /solhint-plugin-mud@2.0.1: - resolution: {integrity: sha512-aLGqzJ/DDu6wTIPlUCeBunXT9kzk/xAse66zOa6D5ZJzBg5xUlFr6HBCpOVUzNxR4Go4kDNiOwtN9Txb8c0bng==} - dependencies: - '@solidity-parser/parser': 0.16.2 - dev: true - - /solhint@3.6.2(typescript@5.4.2): - resolution: {integrity: sha512-85EeLbmkcPwD+3JR7aEMKsVC9YrRSxd4qkXuMzrlf7+z2Eqdfm1wHWq1ffTuo5aDhoZxp2I9yF3QkxZOxOL7aQ==} - hasBin: true - dependencies: - '@solidity-parser/parser': 0.16.2 - ajv: 6.12.6 - antlr4: 4.13.1 - ast-parents: 0.0.1 - chalk: 4.1.2 - commander: 10.0.1 - cosmiconfig: 8.3.6(typescript@5.4.2) - fast-diff: 1.3.0 - glob: 8.1.0 - ignore: 5.3.1 - js-yaml: 4.1.0 - lodash: 4.17.21 - pluralize: 8.0.0 - semver: 7.6.0 - strip-ansi: 6.0.1 - table: 6.8.1 - text-table: 0.2.0 - optionalDependencies: - prettier: 2.8.8 - transitivePeerDependencies: - - typescript - dev: true - - /solidity-comments-extractor@0.0.8: - resolution: {integrity: sha512-htM7Vn6LhHreR+EglVMd2s+sZhcXAirB1Zlyrv5zBuTxieCvjfnRpd7iZk75m/u6NOlEyQ94C6TWbBn2cY7w8g==} - dev: true - - /solmate@6.1.0: - resolution: {integrity: sha512-gxG4YU5nnAQ+Ac23R44GS3Xo3+X0+8XCe4/P1KvVobL5ERBzQBG/xMv7NSvVo/pkHSYGufgUAPjiueYxujKJAA==} - dev: true - - /sonic-boom@3.8.0: - resolution: {integrity: sha512-ybz6OYOUjoQQCQ/i4LU8kaToD8ACtYP+Cj5qd2AO36bwbdewxWJ3ArmJ2cr6AvxlL2o0PqnCcPGUgkILbfkaCA==} - dependencies: - atomic-sleep: 1.0.0 - dev: true - - /split2@4.2.0: - resolution: {integrity: sha512-UcjcJOWknrNkF6PLX83qcHM6KHgVKNkV62Y8a5uYDVv9ydGQVwAHMKqHdJje1VTWpljG0WYpCDhrCdAOYH4TWg==} - engines: {node: '>= 10.x'} - dev: true - - /stream-shift@1.0.3: - resolution: {integrity: sha512-76ORR0DO1o1hlKwTbi/DM3EXWGf3ZJYO8cXX5RJwnul2DEg2oyoZyjLNoQM8WsvZiFKCRfC1O0J7iCvie3RZmQ==} - dev: true - - /stream-to-array@2.3.0: - resolution: {integrity: sha512-UsZtOYEn4tWU2RGLOXr/o/xjRBftZRlG3dEWoaHr8j4GuypJ3isitGbVyjQKAuMu+xbiop8q224TjiZWc4XTZA==} - dependencies: - any-promise: 1.3.0 - dev: true - - /string-format@2.0.0: - resolution: {integrity: sha512-bbEs3scLeYNXLecRRuk6uJxdXUSj6le/8rNPHChIJTn2V79aXVTR1EH2OH5zLKKoz0V02fOUKZZcw01pLUShZA==} - dev: true - - /string-width@4.2.3: - resolution: {integrity: sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==} - engines: {node: '>=8'} - dependencies: - emoji-regex: 8.0.0 - is-fullwidth-code-point: 3.0.0 - strip-ansi: 6.0.1 - dev: true - - /string_decoder@1.1.1: - resolution: {integrity: sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==} - dependencies: - safe-buffer: 5.1.2 - dev: true - - /string_decoder@1.3.0: - resolution: {integrity: sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==} - dependencies: - safe-buffer: 5.2.1 - dev: true - - /strip-ansi@6.0.1: - resolution: {integrity: sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==} - engines: {node: '>=8'} - dependencies: - ansi-regex: 5.0.1 - dev: true - - /strip-ansi@7.1.0: - resolution: {integrity: sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ==} - engines: {node: '>=12'} - dependencies: - ansi-regex: 6.0.1 - dev: true - - /strip-final-newline@3.0.0: - resolution: {integrity: sha512-dOESqjYr96iWYylGObzd39EuNTa5VJxyvVAEm5Jnh7KGo75V43Hk1odPQkNDyXNmUR6k+gEiDVXnjB8HJ3crXw==} - engines: {node: '>=12'} - dev: true - - /supports-color@5.5.0: - resolution: {integrity: sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==} - engines: {node: '>=4'} - dependencies: - has-flag: 3.0.0 - dev: true - - /supports-color@7.2.0: - resolution: {integrity: sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==} - engines: {node: '>=8'} - dependencies: - has-flag: 4.0.0 - dev: true - - /table-layout@1.0.2: - resolution: {integrity: sha512-qd/R7n5rQTRFi+Zf2sk5XVVd9UQl6ZkduPFC3S7WEGJAmetDTjY3qPN50eSKzwuzEyQKy5TN2TiZdkIjos2L6A==} - engines: {node: '>=8.0.0'} - dependencies: - array-back: 4.0.2 - deep-extend: 0.6.0 - typical: 5.2.0 - wordwrapjs: 4.0.1 - dev: true - - /table@6.8.1: - resolution: {integrity: sha512-Y4X9zqrCftUhMeH2EptSSERdVKt/nEdijTOacGD/97EKjhQ/Qs8RTlEGABSJNNN8lac9kheH+af7yAkEWlgneA==} - engines: {node: '>=10.0.0'} - dependencies: - ajv: 8.12.0 - lodash.truncate: 4.4.2 - slice-ansi: 4.0.0 - string-width: 4.2.3 - strip-ansi: 6.0.1 - dev: true - - /text-table@0.2.0: - resolution: {integrity: sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw==} - dev: true - - /thread-stream@2.4.1: - resolution: {integrity: sha512-d/Ex2iWd1whipbT681JmTINKw0ZwOUBZm7+Gjs64DHuX34mmw8vJL2bFAaNacaW72zYiTJxSHi5abUuOi5nsfg==} - dependencies: - real-require: 0.2.0 - dev: true - - /throttle-debounce@5.0.0: - resolution: {integrity: sha512-2iQTSgkkc1Zyk0MeVrt/3BvuOXYPl/R8Z0U2xxo9rjwNciaHDG3R+Lm6dh4EeUci49DanvBnuqI6jshoQQRGEg==} - engines: {node: '>=12.22'} - dev: true - - /through2@2.0.5: - resolution: {integrity: sha512-/mrRod8xqpA+IHSLyGCQ2s8SPHiCDEeQJSep1jqLYeEUClOFG2Qsh+4FU6G9VeqpZnGW/Su8LQGc4YKni5rYSQ==} - dependencies: - readable-stream: 2.3.8 - xtend: 4.0.2 - dev: true - - /tiny-decoders@7.0.1: - resolution: {integrity: sha512-P1LaHTLASl/lCrdtwgAAVwxt4bEAPmxpf9HMQrlCkAseaT8oH8oxm8ndy4nx5rLTcL5U/Qxp1a+FDoQfS/ZgQQ==} - dev: true - - /to-regex-range@5.0.1: - resolution: {integrity: sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==} - engines: {node: '>=8.0'} - dependencies: - is-number: 7.0.0 - dev: true - - /toad-cache@3.7.0: - resolution: {integrity: sha512-/m8M+2BJUpoJdgAHoG+baCwBT+tf2VraSfkBgl0Y00qIWt41DJ8R5B8nsEw0I58YwF5IZH6z24/2TobDKnqSWw==} - engines: {node: '>=12'} - dev: true - - /toposort@2.0.2: - resolution: {integrity: sha512-0a5EOkAUp8D4moMi2W8ZF8jcga7BgZd91O/yabJCFY8az+XSzeGyTKs0Aoo897iV1Nj6guFq8orWDS96z91oGg==} - dev: true - - /ts-command-line-args@2.5.1: - resolution: {integrity: sha512-H69ZwTw3rFHb5WYpQya40YAX2/w7Ut75uUECbgBIsLmM+BNuYnxsltfyyLMxy6sEeKxgijLTnQtLd0nKd6+IYw==} - hasBin: true - dependencies: - chalk: 4.1.2 - command-line-args: 5.2.1 - command-line-usage: 6.1.3 - string-format: 2.0.0 - dev: true - - /ts-error@1.0.6: - resolution: {integrity: sha512-tLJxacIQUM82IR7JO1UUkKlYuUTmoY9HBJAmNWFzheSlDS5SPMcNIepejHJa4BpPQLAcbRhRf3GDJzyj6rbKvA==} - dev: true - - /ts-essentials@7.0.3(typescript@5.4.2): - resolution: {integrity: sha512-8+gr5+lqO3G84KdiTSMRLtuyJ+nTBVRKuCrK4lidMPdVeEp0uqC875uE5NMcaA7YYMN7XsNiFQuMvasF8HT/xQ==} - peerDependencies: - typescript: '>=3.7.0' - dependencies: - typescript: 5.4.2 - dev: true - - /ts-node@10.9.2(@types/node@18.19.22)(typescript@5.4.2): - resolution: {integrity: sha512-f0FFpIdcHgn8zcPSbf1dRevwt047YMnaiJM3u2w2RewrB+fob/zePZcrOyQoLMMO7aBIddLcQIEK5dYjkLnGrQ==} - hasBin: true - peerDependencies: - '@swc/core': '>=1.2.50' - '@swc/wasm': '>=1.2.50' - '@types/node': '*' - typescript: '>=2.7' - peerDependenciesMeta: - '@swc/core': - optional: true - '@swc/wasm': - optional: true - dependencies: - '@cspotcode/source-map-support': 0.8.1 - '@tsconfig/node10': 1.0.9 - '@tsconfig/node12': 1.0.11 - '@tsconfig/node14': 1.0.3 - '@tsconfig/node16': 1.0.4 - '@types/node': 18.19.22 - acorn: 8.11.3 - acorn-walk: 8.3.2 - arg: 4.1.3 - create-require: 1.1.1 - diff: 4.0.2 - make-error: 1.3.6 - typescript: 5.4.2 - v8-compile-cache-lib: 3.0.1 - yn: 3.1.1 - dev: true - - /tslib@2.6.2: - resolution: {integrity: sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==} - dev: true - - /typechain@8.3.2(typescript@5.4.2): - resolution: {integrity: sha512-x/sQYr5w9K7yv3es7jo4KTX05CLxOf7TRWwoHlrjRh8H82G64g+k7VuWPJlgMo6qrjfCulOdfBjiaDtmhFYD/Q==} - hasBin: true - peerDependencies: - typescript: '>=4.3.0' - dependencies: - '@types/prettier': 2.7.3 - debug: 4.3.4 - fs-extra: 7.0.1 - glob: 7.1.7 - js-sha3: 0.8.0 - lodash: 4.17.21 - mkdirp: 1.0.4 - prettier: 2.8.8 - ts-command-line-args: 2.5.1 - ts-essentials: 7.0.3(typescript@5.4.2) - typescript: 5.4.2 - transitivePeerDependencies: - - supports-color - dev: true - - /typescript@5.4.2: - resolution: {integrity: sha512-+2/g0Fds1ERlP6JsakQQDXjZdZMM+rqpamFZJEKh4kwTIn3iDkgKtby0CeNd5ATNZ4Ry1ax15TMx0W2V+miizQ==} - engines: {node: '>=14.17'} - hasBin: true - dev: true - - /typical@4.0.0: - resolution: {integrity: sha512-VAH4IvQ7BDFYglMd7BPRDfLgxZZX4O4TFcRDA6EN5X7erNJJq+McIEp8np9aVtxrCJ6qx4GTYVfOWNjcqwZgRw==} - engines: {node: '>=8'} - dev: true - - /typical@5.2.0: - resolution: {integrity: sha512-dvdQgNDNJo+8B2uBQoqdb11eUCE1JQXhvjC/CZtgvZseVd5TYMXnq0+vuUemXbd/Se29cTaUuPX3YIc2xgbvIg==} - engines: {node: '>=8'} - dev: true - - /undici-types@5.26.5: - resolution: {integrity: sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==} - dev: true - - /universalify@0.1.2: - resolution: {integrity: sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==} - engines: {node: '>= 4.0.0'} - dev: true - - /uri-js@4.4.1: - resolution: {integrity: sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==} - dependencies: - punycode: 2.3.1 - dev: true - - /util-deprecate@1.0.2: - resolution: {integrity: sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==} - dev: true - - /util@0.10.4: - resolution: {integrity: sha512-0Pm9hTQ3se5ll1XihRic3FDIku70C+iHUdT/W926rSgHV5QgXsYbKZN8MSC3tJtSkhuROzvsQjAaFENRXr+19A==} - dependencies: - inherits: 2.0.3 - dev: true - - /v8-compile-cache-lib@3.0.1: - resolution: {integrity: sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==} - dev: true - - /viem@2.7.12(typescript@5.4.2)(zod@3.22.4): - resolution: {integrity: sha512-NbV+Bycw0I4X8y6A04mgJ6+Imt7xXwflgnqisR3JXoJRNc77YSaQCscFN/dmwGLESTkgegJvi+j4nZY32GTpwQ==} - peerDependencies: - typescript: '>=5.0.4' - peerDependenciesMeta: - typescript: - optional: true - dependencies: - '@adraffy/ens-normalize': 1.10.0 - '@noble/curves': 1.2.0 - '@noble/hashes': 1.3.2 - '@scure/bip32': 1.3.2 - '@scure/bip39': 1.2.1 - abitype: 1.0.0(typescript@5.4.2)(zod@3.22.4) - isows: 1.0.3(ws@8.13.0) - typescript: 5.4.2 - ws: 8.13.0 - transitivePeerDependencies: - - bufferutil - - utf-8-validate - - zod - dev: true - - /which@2.0.2: - resolution: {integrity: sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==} - engines: {node: '>= 8'} - hasBin: true - dependencies: - isexe: 2.0.0 - dev: true - - /wordwrapjs@4.0.1: - resolution: {integrity: sha512-kKlNACbvHrkpIw6oPeYDSmdCTu2hdMHoyXLTcUKala++lx5Y+wjJ/e474Jqv5abnVmwxw08DiTuHmw69lJGksA==} - engines: {node: '>=8.0.0'} - dependencies: - reduce-flatten: 2.0.0 - typical: 5.2.0 - dev: true - - /wrap-ansi@7.0.0: - resolution: {integrity: sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==} - engines: {node: '>=10'} - dependencies: - ansi-styles: 4.3.0 - string-width: 4.2.3 - strip-ansi: 6.0.1 - dev: true - - /wrappy@1.0.2: - resolution: {integrity: sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==} - dev: true - - /ws@7.4.6: - resolution: {integrity: sha512-YmhHDO4MzaDLB+M9ym/mDA5z0naX8j7SIlT8f8z+I0VtzsRbekxEutHSme7NPS2qE8StCYQNUnfWdXta/Yu85A==} - engines: {node: '>=8.3.0'} - peerDependencies: - bufferutil: ^4.0.1 - utf-8-validate: ^5.0.2 - peerDependenciesMeta: - bufferutil: - optional: true - utf-8-validate: - optional: true - dev: true - - /ws@8.13.0: - resolution: {integrity: sha512-x9vcZYTrFPC7aSIbj7sRCYo7L/Xb8Iy+pW0ng0wt2vCJv7M9HOMy0UoN3rr+IFC7hb7vXoqS+P9ktyLLLhO+LA==} - engines: {node: '>=10.0.0'} - peerDependencies: - bufferutil: ^4.0.1 - utf-8-validate: '>=5.0.2' - peerDependenciesMeta: - bufferutil: - optional: true - utf-8-validate: - optional: true - dev: true - - /xtend@4.0.2: - resolution: {integrity: sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==} - engines: {node: '>=0.4'} - dev: true - - /y18n@5.0.8: - resolution: {integrity: sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==} - engines: {node: '>=10'} - dev: true - - /yallist@4.0.0: - resolution: {integrity: sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==} - dev: true - - /yargs-parser@21.1.1: - resolution: {integrity: sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==} - engines: {node: '>=12'} - dev: true - - /yargs@17.7.2: - resolution: {integrity: sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w==} - engines: {node: '>=12'} - dependencies: - cliui: 8.0.1 - escalade: 3.1.2 - get-caller-file: 2.0.5 - require-directory: 2.1.1 - string-width: 4.2.3 - y18n: 5.0.8 - yargs-parser: 21.1.1 - dev: true - - /yn@3.1.1: - resolution: {integrity: sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==} - engines: {node: '>=6'} - dev: true - - /yocto-queue@1.0.0: - resolution: {integrity: sha512-9bnSc/HEW2uRy67wc+T8UwauLuPJVn28jb+GtJY16iiKWyvmYJRXVT4UamsAEGQfPohgr2q4Tq0sQbQlxTfi1g==} - engines: {node: '>=12.20'} - dev: true - - /zod-validation-error@1.5.0(zod@3.22.4): - resolution: {integrity: sha512-/7eFkAI4qV0tcxMBB/3+d2c1P6jzzZYdYSlBuAklzMuCrJu5bzJfHS0yVAS87dRHVlhftd6RFJDIvv03JgkSbw==} - engines: {node: '>=16.0.0'} - peerDependencies: - zod: ^3.18.0 - dependencies: - zod: 3.22.4 - dev: true - - /zod@3.22.4: - resolution: {integrity: sha512-iC+8Io04lddc+mVqQ9AZ7OQ2MrUKGN+oIQyq1vemgt46jwCwLfhq7/pwnBnNXXXZb8VTVLKwp9EDkx+ryxIWmg==} - dev: true - - github.com/dapphub/ds-test/c9ce3f25bde29fc5eb9901842bf02850dfd2d084: - resolution: {tarball: https://codeload.github.com/dapphub/ds-test/tar.gz/c9ce3f25bde29fc5eb9901842bf02850dfd2d084} - name: ds-test - version: 1.0.0 - dev: true - - github.com/foundry-rs/forge-std/b4f121555729b3afb3c5ffccb62ff4b6e2818fd3: - resolution: {tarball: https://codeload.github.com/foundry-rs/forge-std/tar.gz/b4f121555729b3afb3c5ffccb62ff4b6e2818fd3} - name: forge-std - version: 1.2.0 - dev: true diff --git a/remappings.txt b/remappings.txt deleted file mode 100644 index bdc749d..0000000 --- a/remappings.txt +++ /dev/null @@ -1,11 +0,0 @@ -@openzeppelin/=node_modules/@openzeppelin/ -@latticexyz/=node_modules/@latticexyz/ -@solidstate=node_modules/@solidstate/ -solmate=node_modules/solmate/ - -ds-test/=node_modules/ds-test/src/ -forge-std/=node_modules/forge-std/src/ -common/=src/common -codegen/=src/codegen -systems/=src/systems -libraries/=src/libraries \ No newline at end of file diff --git a/src/codegen/common.sol b/src/codegen/common.sol deleted file mode 100644 index fc0c257..0000000 --- a/src/codegen/common.sol +++ /dev/null @@ -1,48 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity >=0.8.24; - -/* Autogenerated file. Do not edit manually. */ -enum BonusType { - MULTIPLY_WORD, - MULTIPLY_LETTER -} - -enum Direction { - LEFT_TO_RIGHT, - TOP_TO_BOTTOM -} - -enum Status { - NOT_STARTED, - STARTED -} - -enum Letter { - EMPTY, - A, - B, - C, - D, - E, - F, - G, - H, - I, - J, - K, - L, - M, - N, - O, - P, - Q, - R, - S, - T, - U, - V, - W, - X, - Y, - Z -} diff --git a/src/codegen/tables/DrawCount.sol b/src/codegen/tables/DrawCount.sol deleted file mode 100644 index 9819914..0000000 --- a/src/codegen/tables/DrawCount.sol +++ /dev/null @@ -1,192 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity >=0.8.24; - -/* Autogenerated file. Do not edit manually. */ - -// Import store internals - -import { Bytes } from "@latticexyz/store/src/Bytes.sol"; - -import { EncodedLengths, EncodedLengthsLib } from "@latticexyz/store/src/EncodedLengths.sol"; -import { FieldLayout } from "@latticexyz/store/src/FieldLayout.sol"; -import { IStore } from "@latticexyz/store/src/IStore.sol"; -import { Memory } from "@latticexyz/store/src/Memory.sol"; - -import { ResourceId } from "@latticexyz/store/src/ResourceId.sol"; -import { Schema } from "@latticexyz/store/src/Schema.sol"; -import { SliceLib } from "@latticexyz/store/src/Slice.sol"; -import { StoreCore } from "@latticexyz/store/src/StoreCore.sol"; -import { StoreSwitch } from "@latticexyz/store/src/StoreSwitch.sol"; - -import { EncodeArray } from "@latticexyz/store/src/tightcoder/EncodeArray.sol"; - -library DrawCount { - // Hex below is the result of `WorldResourceIdLib.encode({ namespace: "", name: "DrawCount", typeId: RESOURCE_TABLE - // });` - ResourceId constant _tableId = ResourceId.wrap(0x7462000000000000000000000000000044726177436f756e7400000000000000); - - FieldLayout constant _fieldLayout = - FieldLayout.wrap(0x0004010004000000000000000000000000000000000000000000000000000000); - - // Hex-encoded key schema of () - Schema constant _keySchema = Schema.wrap(0x0000000000000000000000000000000000000000000000000000000000000000); - // Hex-encoded value schema of (uint32) - Schema constant _valueSchema = Schema.wrap(0x0004010003000000000000000000000000000000000000000000000000000000); - - /** - * @notice Get the table's key field names. - * @return keyNames An array of strings with the names of key fields. - */ - function getKeyNames() internal pure returns (string[] memory keyNames) { - keyNames = new string[](0); - } - - /** - * @notice Get the table's value field names. - * @return fieldNames An array of strings with the names of value fields. - */ - function getFieldNames() internal pure returns (string[] memory fieldNames) { - fieldNames = new string[](1); - fieldNames[0] = "value"; - } - - /** - * @notice Register the table with its config. - */ - function register() internal { - StoreSwitch.registerTable(_tableId, _fieldLayout, _keySchema, _valueSchema, getKeyNames(), getFieldNames()); - } - - /** - * @notice Register the table with its config. - */ - function _register() internal { - StoreCore.registerTable(_tableId, _fieldLayout, _keySchema, _valueSchema, getKeyNames(), getFieldNames()); - } - - /** - * @notice Get value. - */ - function getValue() internal view returns (uint32 value) { - bytes32[] memory _keyTuple = new bytes32[](0); - - bytes32 _blob = StoreSwitch.getStaticField(_tableId, _keyTuple, 0, _fieldLayout); - return (uint32(bytes4(_blob))); - } - - /** - * @notice Get value. - */ - function _getValue() internal view returns (uint32 value) { - bytes32[] memory _keyTuple = new bytes32[](0); - - bytes32 _blob = StoreCore.getStaticField(_tableId, _keyTuple, 0, _fieldLayout); - return (uint32(bytes4(_blob))); - } - - /** - * @notice Get value. - */ - function get() internal view returns (uint32 value) { - bytes32[] memory _keyTuple = new bytes32[](0); - - bytes32 _blob = StoreSwitch.getStaticField(_tableId, _keyTuple, 0, _fieldLayout); - return (uint32(bytes4(_blob))); - } - - /** - * @notice Get value. - */ - function _get() internal view returns (uint32 value) { - bytes32[] memory _keyTuple = new bytes32[](0); - - bytes32 _blob = StoreCore.getStaticField(_tableId, _keyTuple, 0, _fieldLayout); - return (uint32(bytes4(_blob))); - } - - /** - * @notice Set value. - */ - function setValue(uint32 value) internal { - bytes32[] memory _keyTuple = new bytes32[](0); - - StoreSwitch.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); - } - - /** - * @notice Set value. - */ - function _setValue(uint32 value) internal { - bytes32[] memory _keyTuple = new bytes32[](0); - - StoreCore.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); - } - - /** - * @notice Set value. - */ - function set(uint32 value) internal { - bytes32[] memory _keyTuple = new bytes32[](0); - - StoreSwitch.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); - } - - /** - * @notice Set value. - */ - function _set(uint32 value) internal { - bytes32[] memory _keyTuple = new bytes32[](0); - - StoreCore.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); - } - - /** - * @notice Delete all data for given keys. - */ - function deleteRecord() internal { - bytes32[] memory _keyTuple = new bytes32[](0); - - StoreSwitch.deleteRecord(_tableId, _keyTuple); - } - - /** - * @notice Delete all data for given keys. - */ - function _deleteRecord() internal { - bytes32[] memory _keyTuple = new bytes32[](0); - - StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout); - } - - /** - * @notice Tightly pack static (fixed length) data using this table's schema. - * @return The static data, encoded into a sequence of bytes. - */ - function encodeStatic(uint32 value) internal pure returns (bytes memory) { - return abi.encodePacked(value); - } - - /** - * @notice Encode all of a record's fields. - * @return The static (fixed length) data, encoded into a sequence of bytes. - * @return The lengths of the dynamic fields (packed into a single bytes32 value). - * @return The dynamic (variable length) data, encoded into a sequence of bytes. - */ - function encode(uint32 value) internal pure returns (bytes memory, EncodedLengths, bytes memory) { - bytes memory _staticData = encodeStatic(value); - - EncodedLengths _encodedLengths; - bytes memory _dynamicData; - - return (_staticData, _encodedLengths, _dynamicData); - } - - /** - * @notice Encode keys as a bytes32 array using this table's field layout. - */ - function encodeKeyTuple() internal pure returns (bytes32[] memory) { - bytes32[] memory _keyTuple = new bytes32[](0); - - return _keyTuple; - } -} diff --git a/src/codegen/tables/DrawLetterOdds.sol b/src/codegen/tables/DrawLetterOdds.sol deleted file mode 100644 index 29acfa5..0000000 --- a/src/codegen/tables/DrawLetterOdds.sol +++ /dev/null @@ -1,422 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity >=0.8.24; - -/* Autogenerated file. Do not edit manually. */ - -// Import store internals - -import { Bytes } from "@latticexyz/store/src/Bytes.sol"; - -import { EncodedLengths, EncodedLengthsLib } from "@latticexyz/store/src/EncodedLengths.sol"; -import { FieldLayout } from "@latticexyz/store/src/FieldLayout.sol"; -import { IStore } from "@latticexyz/store/src/IStore.sol"; -import { Memory } from "@latticexyz/store/src/Memory.sol"; - -import { ResourceId } from "@latticexyz/store/src/ResourceId.sol"; -import { Schema } from "@latticexyz/store/src/Schema.sol"; -import { SliceLib } from "@latticexyz/store/src/Slice.sol"; -import { StoreCore } from "@latticexyz/store/src/StoreCore.sol"; -import { StoreSwitch } from "@latticexyz/store/src/StoreSwitch.sol"; - -import { EncodeArray } from "@latticexyz/store/src/tightcoder/EncodeArray.sol"; - -library DrawLetterOdds { - // Hex below is the result of `WorldResourceIdLib.encode({ namespace: "", name: "DrawLetterOdds", typeId: - // RESOURCE_TABLE });` - ResourceId constant _tableId = ResourceId.wrap(0x74620000000000000000000000000000447261774c65747465724f6464730000); - - FieldLayout constant _fieldLayout = - FieldLayout.wrap(0x0000000100000000000000000000000000000000000000000000000000000000); - - // Hex-encoded key schema of () - Schema constant _keySchema = Schema.wrap(0x0000000000000000000000000000000000000000000000000000000000000000); - // Hex-encoded value schema of (uint8[]) - Schema constant _valueSchema = Schema.wrap(0x0000000162000000000000000000000000000000000000000000000000000000); - - /** - * @notice Get the table's key field names. - * @return keyNames An array of strings with the names of key fields. - */ - function getKeyNames() internal pure returns (string[] memory keyNames) { - keyNames = new string[](0); - } - - /** - * @notice Get the table's value field names. - * @return fieldNames An array of strings with the names of value fields. - */ - function getFieldNames() internal pure returns (string[] memory fieldNames) { - fieldNames = new string[](1); - fieldNames[0] = "value"; - } - - /** - * @notice Register the table with its config. - */ - function register() internal { - StoreSwitch.registerTable(_tableId, _fieldLayout, _keySchema, _valueSchema, getKeyNames(), getFieldNames()); - } - - /** - * @notice Register the table with its config. - */ - function _register() internal { - StoreCore.registerTable(_tableId, _fieldLayout, _keySchema, _valueSchema, getKeyNames(), getFieldNames()); - } - - /** - * @notice Get value. - */ - function getValue() internal view returns (uint8[] memory value) { - bytes32[] memory _keyTuple = new bytes32[](0); - - bytes memory _blob = StoreSwitch.getDynamicField(_tableId, _keyTuple, 0); - return (SliceLib.getSubslice(_blob, 0, _blob.length).decodeArray_uint8()); - } - - /** - * @notice Get value. - */ - function _getValue() internal view returns (uint8[] memory value) { - bytes32[] memory _keyTuple = new bytes32[](0); - - bytes memory _blob = StoreCore.getDynamicField(_tableId, _keyTuple, 0); - return (SliceLib.getSubslice(_blob, 0, _blob.length).decodeArray_uint8()); - } - - /** - * @notice Get value. - */ - function get() internal view returns (uint8[] memory value) { - bytes32[] memory _keyTuple = new bytes32[](0); - - bytes memory _blob = StoreSwitch.getDynamicField(_tableId, _keyTuple, 0); - return (SliceLib.getSubslice(_blob, 0, _blob.length).decodeArray_uint8()); - } - - /** - * @notice Get value. - */ - function _get() internal view returns (uint8[] memory value) { - bytes32[] memory _keyTuple = new bytes32[](0); - - bytes memory _blob = StoreCore.getDynamicField(_tableId, _keyTuple, 0); - return (SliceLib.getSubslice(_blob, 0, _blob.length).decodeArray_uint8()); - } - - /** - * @notice Set value. - */ - function setValue(uint8[] memory value) internal { - bytes32[] memory _keyTuple = new bytes32[](0); - - StoreSwitch.setDynamicField(_tableId, _keyTuple, 0, EncodeArray.encode((value))); - } - - /** - * @notice Set value. - */ - function _setValue(uint8[] memory value) internal { - bytes32[] memory _keyTuple = new bytes32[](0); - - StoreCore.setDynamicField(_tableId, _keyTuple, 0, EncodeArray.encode((value))); - } - - /** - * @notice Set value. - */ - function set(uint8[] memory value) internal { - bytes32[] memory _keyTuple = new bytes32[](0); - - StoreSwitch.setDynamicField(_tableId, _keyTuple, 0, EncodeArray.encode((value))); - } - - /** - * @notice Set value. - */ - function _set(uint8[] memory value) internal { - bytes32[] memory _keyTuple = new bytes32[](0); - - StoreCore.setDynamicField(_tableId, _keyTuple, 0, EncodeArray.encode((value))); - } - - /** - * @notice Get the length of value. - */ - function lengthValue() internal view returns (uint256) { - bytes32[] memory _keyTuple = new bytes32[](0); - - uint256 _byteLength = StoreSwitch.getDynamicFieldLength(_tableId, _keyTuple, 0); - unchecked { - return _byteLength / 1; - } - } - - /** - * @notice Get the length of value. - */ - function _lengthValue() internal view returns (uint256) { - bytes32[] memory _keyTuple = new bytes32[](0); - - uint256 _byteLength = StoreCore.getDynamicFieldLength(_tableId, _keyTuple, 0); - unchecked { - return _byteLength / 1; - } - } - - /** - * @notice Get the length of value. - */ - function length() internal view returns (uint256) { - bytes32[] memory _keyTuple = new bytes32[](0); - - uint256 _byteLength = StoreSwitch.getDynamicFieldLength(_tableId, _keyTuple, 0); - unchecked { - return _byteLength / 1; - } - } - - /** - * @notice Get the length of value. - */ - function _length() internal view returns (uint256) { - bytes32[] memory _keyTuple = new bytes32[](0); - - uint256 _byteLength = StoreCore.getDynamicFieldLength(_tableId, _keyTuple, 0); - unchecked { - return _byteLength / 1; - } - } - - /** - * @notice Get an item of value. - * @dev Reverts with Store_IndexOutOfBounds if `_index` is out of bounds for the array. - */ - function getItemValue(uint256 _index) internal view returns (uint8) { - bytes32[] memory _keyTuple = new bytes32[](0); - - unchecked { - bytes memory _blob = StoreSwitch.getDynamicFieldSlice(_tableId, _keyTuple, 0, _index * 1, (_index + 1) * 1); - return (uint8(bytes1(_blob))); - } - } - - /** - * @notice Get an item of value. - * @dev Reverts with Store_IndexOutOfBounds if `_index` is out of bounds for the array. - */ - function _getItemValue(uint256 _index) internal view returns (uint8) { - bytes32[] memory _keyTuple = new bytes32[](0); - - unchecked { - bytes memory _blob = StoreCore.getDynamicFieldSlice(_tableId, _keyTuple, 0, _index * 1, (_index + 1) * 1); - return (uint8(bytes1(_blob))); - } - } - - /** - * @notice Get an item of value. - * @dev Reverts with Store_IndexOutOfBounds if `_index` is out of bounds for the array. - */ - function getItem(uint256 _index) internal view returns (uint8) { - bytes32[] memory _keyTuple = new bytes32[](0); - - unchecked { - bytes memory _blob = StoreSwitch.getDynamicFieldSlice(_tableId, _keyTuple, 0, _index * 1, (_index + 1) * 1); - return (uint8(bytes1(_blob))); - } - } - - /** - * @notice Get an item of value. - * @dev Reverts with Store_IndexOutOfBounds if `_index` is out of bounds for the array. - */ - function _getItem(uint256 _index) internal view returns (uint8) { - bytes32[] memory _keyTuple = new bytes32[](0); - - unchecked { - bytes memory _blob = StoreCore.getDynamicFieldSlice(_tableId, _keyTuple, 0, _index * 1, (_index + 1) * 1); - return (uint8(bytes1(_blob))); - } - } - - /** - * @notice Push an element to value. - */ - function pushValue(uint8 _element) internal { - bytes32[] memory _keyTuple = new bytes32[](0); - - StoreSwitch.pushToDynamicField(_tableId, _keyTuple, 0, abi.encodePacked((_element))); - } - - /** - * @notice Push an element to value. - */ - function _pushValue(uint8 _element) internal { - bytes32[] memory _keyTuple = new bytes32[](0); - - StoreCore.pushToDynamicField(_tableId, _keyTuple, 0, abi.encodePacked((_element))); - } - - /** - * @notice Push an element to value. - */ - function push(uint8 _element) internal { - bytes32[] memory _keyTuple = new bytes32[](0); - - StoreSwitch.pushToDynamicField(_tableId, _keyTuple, 0, abi.encodePacked((_element))); - } - - /** - * @notice Push an element to value. - */ - function _push(uint8 _element) internal { - bytes32[] memory _keyTuple = new bytes32[](0); - - StoreCore.pushToDynamicField(_tableId, _keyTuple, 0, abi.encodePacked((_element))); - } - - /** - * @notice Pop an element from value. - */ - function popValue() internal { - bytes32[] memory _keyTuple = new bytes32[](0); - - StoreSwitch.popFromDynamicField(_tableId, _keyTuple, 0, 1); - } - - /** - * @notice Pop an element from value. - */ - function _popValue() internal { - bytes32[] memory _keyTuple = new bytes32[](0); - - StoreCore.popFromDynamicField(_tableId, _keyTuple, 0, 1); - } - - /** - * @notice Pop an element from value. - */ - function pop() internal { - bytes32[] memory _keyTuple = new bytes32[](0); - - StoreSwitch.popFromDynamicField(_tableId, _keyTuple, 0, 1); - } - - /** - * @notice Pop an element from value. - */ - function _pop() internal { - bytes32[] memory _keyTuple = new bytes32[](0); - - StoreCore.popFromDynamicField(_tableId, _keyTuple, 0, 1); - } - - /** - * @notice Update an element of value at `_index`. - */ - function updateValue(uint256 _index, uint8 _element) internal { - bytes32[] memory _keyTuple = new bytes32[](0); - - unchecked { - bytes memory _encoded = abi.encodePacked((_element)); - StoreSwitch.spliceDynamicData(_tableId, _keyTuple, 0, uint40(_index * 1), uint40(_encoded.length), _encoded); - } - } - - /** - * @notice Update an element of value at `_index`. - */ - function _updateValue(uint256 _index, uint8 _element) internal { - bytes32[] memory _keyTuple = new bytes32[](0); - - unchecked { - bytes memory _encoded = abi.encodePacked((_element)); - StoreCore.spliceDynamicData(_tableId, _keyTuple, 0, uint40(_index * 1), uint40(_encoded.length), _encoded); - } - } - - /** - * @notice Update an element of value at `_index`. - */ - function update(uint256 _index, uint8 _element) internal { - bytes32[] memory _keyTuple = new bytes32[](0); - - unchecked { - bytes memory _encoded = abi.encodePacked((_element)); - StoreSwitch.spliceDynamicData(_tableId, _keyTuple, 0, uint40(_index * 1), uint40(_encoded.length), _encoded); - } - } - - /** - * @notice Update an element of value at `_index`. - */ - function _update(uint256 _index, uint8 _element) internal { - bytes32[] memory _keyTuple = new bytes32[](0); - - unchecked { - bytes memory _encoded = abi.encodePacked((_element)); - StoreCore.spliceDynamicData(_tableId, _keyTuple, 0, uint40(_index * 1), uint40(_encoded.length), _encoded); - } - } - - /** - * @notice Delete all data for given keys. - */ - function deleteRecord() internal { - bytes32[] memory _keyTuple = new bytes32[](0); - - StoreSwitch.deleteRecord(_tableId, _keyTuple); - } - - /** - * @notice Delete all data for given keys. - */ - function _deleteRecord() internal { - bytes32[] memory _keyTuple = new bytes32[](0); - - StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout); - } - - /** - * @notice Tightly pack dynamic data lengths using this table's schema. - * @return _encodedLengths The lengths of the dynamic fields (packed into a single bytes32 value). - */ - function encodeLengths(uint8[] memory value) internal pure returns (EncodedLengths _encodedLengths) { - // Lengths are effectively checked during copy by 2**40 bytes exceeding gas limits - unchecked { - _encodedLengths = EncodedLengthsLib.pack(value.length * 1); - } - } - - /** - * @notice Tightly pack dynamic (variable length) data using this table's schema. - * @return The dynamic data, encoded into a sequence of bytes. - */ - function encodeDynamic(uint8[] memory value) internal pure returns (bytes memory) { - return abi.encodePacked(EncodeArray.encode((value))); - } - - /** - * @notice Encode all of a record's fields. - * @return The static (fixed length) data, encoded into a sequence of bytes. - * @return The lengths of the dynamic fields (packed into a single bytes32 value). - * @return The dynamic (variable length) data, encoded into a sequence of bytes. - */ - function encode(uint8[] memory value) internal pure returns (bytes memory, EncodedLengths, bytes memory) { - bytes memory _staticData; - EncodedLengths _encodedLengths = encodeLengths(value); - bytes memory _dynamicData = encodeDynamic(value); - - return (_staticData, _encodedLengths, _dynamicData); - } - - /** - * @notice Encode keys as a bytes32 array using this table's field layout. - */ - function encodeKeyTuple() internal pure returns (bytes32[] memory) { - bytes32[] memory _keyTuple = new bytes32[](0); - - return _keyTuple; - } -} diff --git a/src/codegen/tables/GameConfig.sol b/src/codegen/tables/GameConfig.sol deleted file mode 100644 index 6d7ffa1..0000000 --- a/src/codegen/tables/GameConfig.sol +++ /dev/null @@ -1,368 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity >=0.8.24; - -/* Autogenerated file. Do not edit manually. */ - -// Import store internals - -import { Bytes } from "@latticexyz/store/src/Bytes.sol"; - -import { EncodedLengths, EncodedLengthsLib } from "@latticexyz/store/src/EncodedLengths.sol"; -import { FieldLayout } from "@latticexyz/store/src/FieldLayout.sol"; -import { IStore } from "@latticexyz/store/src/IStore.sol"; -import { Memory } from "@latticexyz/store/src/Memory.sol"; - -import { ResourceId } from "@latticexyz/store/src/ResourceId.sol"; -import { Schema } from "@latticexyz/store/src/Schema.sol"; -import { SliceLib } from "@latticexyz/store/src/Slice.sol"; -import { StoreCore } from "@latticexyz/store/src/StoreCore.sol"; -import { StoreSwitch } from "@latticexyz/store/src/StoreSwitch.sol"; - -import { EncodeArray } from "@latticexyz/store/src/tightcoder/EncodeArray.sol"; - -// Import user types -import { Status } from "./../common.sol"; - -struct GameConfigData { - Status status; - uint32 crossWordRewardFraction; - uint16 bonusDistance; -} - -library GameConfig { - // Hex below is the result of `WorldResourceIdLib.encode({ namespace: "", name: "GameConfig", typeId: RESOURCE_TABLE - // });` - ResourceId constant _tableId = ResourceId.wrap(0x7462000000000000000000000000000047616d65436f6e666967000000000000); - - FieldLayout constant _fieldLayout = - FieldLayout.wrap(0x0007030001040200000000000000000000000000000000000000000000000000); - - // Hex-encoded key schema of () - Schema constant _keySchema = Schema.wrap(0x0000000000000000000000000000000000000000000000000000000000000000); - // Hex-encoded value schema of (uint8, uint32, uint16) - Schema constant _valueSchema = Schema.wrap(0x0007030000030100000000000000000000000000000000000000000000000000); - - /** - * @notice Get the table's key field names. - * @return keyNames An array of strings with the names of key fields. - */ - function getKeyNames() internal pure returns (string[] memory keyNames) { - keyNames = new string[](0); - } - - /** - * @notice Get the table's value field names. - * @return fieldNames An array of strings with the names of value fields. - */ - function getFieldNames() internal pure returns (string[] memory fieldNames) { - fieldNames = new string[](3); - fieldNames[0] = "status"; - fieldNames[1] = "crossWordRewardFraction"; - fieldNames[2] = "bonusDistance"; - } - - /** - * @notice Register the table with its config. - */ - function register() internal { - StoreSwitch.registerTable(_tableId, _fieldLayout, _keySchema, _valueSchema, getKeyNames(), getFieldNames()); - } - - /** - * @notice Register the table with its config. - */ - function _register() internal { - StoreCore.registerTable(_tableId, _fieldLayout, _keySchema, _valueSchema, getKeyNames(), getFieldNames()); - } - - /** - * @notice Get status. - */ - function getStatus() internal view returns (Status status) { - bytes32[] memory _keyTuple = new bytes32[](0); - - bytes32 _blob = StoreSwitch.getStaticField(_tableId, _keyTuple, 0, _fieldLayout); - return Status(uint8(bytes1(_blob))); - } - - /** - * @notice Get status. - */ - function _getStatus() internal view returns (Status status) { - bytes32[] memory _keyTuple = new bytes32[](0); - - bytes32 _blob = StoreCore.getStaticField(_tableId, _keyTuple, 0, _fieldLayout); - return Status(uint8(bytes1(_blob))); - } - - /** - * @notice Set status. - */ - function setStatus(Status status) internal { - bytes32[] memory _keyTuple = new bytes32[](0); - - StoreSwitch.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked(uint8(status)), _fieldLayout); - } - - /** - * @notice Set status. - */ - function _setStatus(Status status) internal { - bytes32[] memory _keyTuple = new bytes32[](0); - - StoreCore.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked(uint8(status)), _fieldLayout); - } - - /** - * @notice Get crossWordRewardFraction. - */ - function getCrossWordRewardFraction() internal view returns (uint32 crossWordRewardFraction) { - bytes32[] memory _keyTuple = new bytes32[](0); - - bytes32 _blob = StoreSwitch.getStaticField(_tableId, _keyTuple, 1, _fieldLayout); - return (uint32(bytes4(_blob))); - } - - /** - * @notice Get crossWordRewardFraction. - */ - function _getCrossWordRewardFraction() internal view returns (uint32 crossWordRewardFraction) { - bytes32[] memory _keyTuple = new bytes32[](0); - - bytes32 _blob = StoreCore.getStaticField(_tableId, _keyTuple, 1, _fieldLayout); - return (uint32(bytes4(_blob))); - } - - /** - * @notice Set crossWordRewardFraction. - */ - function setCrossWordRewardFraction(uint32 crossWordRewardFraction) internal { - bytes32[] memory _keyTuple = new bytes32[](0); - - StoreSwitch.setStaticField(_tableId, _keyTuple, 1, abi.encodePacked((crossWordRewardFraction)), _fieldLayout); - } - - /** - * @notice Set crossWordRewardFraction. - */ - function _setCrossWordRewardFraction(uint32 crossWordRewardFraction) internal { - bytes32[] memory _keyTuple = new bytes32[](0); - - StoreCore.setStaticField(_tableId, _keyTuple, 1, abi.encodePacked((crossWordRewardFraction)), _fieldLayout); - } - - /** - * @notice Get bonusDistance. - */ - function getBonusDistance() internal view returns (uint16 bonusDistance) { - bytes32[] memory _keyTuple = new bytes32[](0); - - bytes32 _blob = StoreSwitch.getStaticField(_tableId, _keyTuple, 2, _fieldLayout); - return (uint16(bytes2(_blob))); - } - - /** - * @notice Get bonusDistance. - */ - function _getBonusDistance() internal view returns (uint16 bonusDistance) { - bytes32[] memory _keyTuple = new bytes32[](0); - - bytes32 _blob = StoreCore.getStaticField(_tableId, _keyTuple, 2, _fieldLayout); - return (uint16(bytes2(_blob))); - } - - /** - * @notice Set bonusDistance. - */ - function setBonusDistance(uint16 bonusDistance) internal { - bytes32[] memory _keyTuple = new bytes32[](0); - - StoreSwitch.setStaticField(_tableId, _keyTuple, 2, abi.encodePacked((bonusDistance)), _fieldLayout); - } - - /** - * @notice Set bonusDistance. - */ - function _setBonusDistance(uint16 bonusDistance) internal { - bytes32[] memory _keyTuple = new bytes32[](0); - - StoreCore.setStaticField(_tableId, _keyTuple, 2, abi.encodePacked((bonusDistance)), _fieldLayout); - } - - /** - * @notice Get the full data. - */ - function get() internal view returns (GameConfigData memory _table) { - bytes32[] memory _keyTuple = new bytes32[](0); - - (bytes memory _staticData, EncodedLengths _encodedLengths, bytes memory _dynamicData) = - StoreSwitch.getRecord(_tableId, _keyTuple, _fieldLayout); - return decode(_staticData, _encodedLengths, _dynamicData); - } - - /** - * @notice Get the full data. - */ - function _get() internal view returns (GameConfigData memory _table) { - bytes32[] memory _keyTuple = new bytes32[](0); - - (bytes memory _staticData, EncodedLengths _encodedLengths, bytes memory _dynamicData) = - StoreCore.getRecord(_tableId, _keyTuple, _fieldLayout); - return decode(_staticData, _encodedLengths, _dynamicData); - } - - /** - * @notice Set the full data using individual values. - */ - function set(Status status, uint32 crossWordRewardFraction, uint16 bonusDistance) internal { - bytes memory _staticData = encodeStatic(status, crossWordRewardFraction, bonusDistance); - - EncodedLengths _encodedLengths; - bytes memory _dynamicData; - - bytes32[] memory _keyTuple = new bytes32[](0); - - StoreSwitch.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); - } - - /** - * @notice Set the full data using individual values. - */ - function _set(Status status, uint32 crossWordRewardFraction, uint16 bonusDistance) internal { - bytes memory _staticData = encodeStatic(status, crossWordRewardFraction, bonusDistance); - - EncodedLengths _encodedLengths; - bytes memory _dynamicData; - - bytes32[] memory _keyTuple = new bytes32[](0); - - StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); - } - - /** - * @notice Set the full data using the data struct. - */ - function set(GameConfigData memory _table) internal { - bytes memory _staticData = encodeStatic(_table.status, _table.crossWordRewardFraction, _table.bonusDistance); - - EncodedLengths _encodedLengths; - bytes memory _dynamicData; - - bytes32[] memory _keyTuple = new bytes32[](0); - - StoreSwitch.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); - } - - /** - * @notice Set the full data using the data struct. - */ - function _set(GameConfigData memory _table) internal { - bytes memory _staticData = encodeStatic(_table.status, _table.crossWordRewardFraction, _table.bonusDistance); - - EncodedLengths _encodedLengths; - bytes memory _dynamicData; - - bytes32[] memory _keyTuple = new bytes32[](0); - - StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); - } - - /** - * @notice Decode the tightly packed blob of static data using this table's field layout. - */ - function decodeStatic(bytes memory _blob) - internal - pure - returns (Status status, uint32 crossWordRewardFraction, uint16 bonusDistance) - { - status = Status(uint8(Bytes.getBytes1(_blob, 0))); - - crossWordRewardFraction = (uint32(Bytes.getBytes4(_blob, 1))); - - bonusDistance = (uint16(Bytes.getBytes2(_blob, 5))); - } - - /** - * @notice Decode the tightly packed blobs using this table's field layout. - * @param _staticData Tightly packed static fields. - * - * - */ - function decode( - bytes memory _staticData, - EncodedLengths, - bytes memory - ) - internal - pure - returns (GameConfigData memory _table) - { - (_table.status, _table.crossWordRewardFraction, _table.bonusDistance) = decodeStatic(_staticData); - } - - /** - * @notice Delete all data for given keys. - */ - function deleteRecord() internal { - bytes32[] memory _keyTuple = new bytes32[](0); - - StoreSwitch.deleteRecord(_tableId, _keyTuple); - } - - /** - * @notice Delete all data for given keys. - */ - function _deleteRecord() internal { - bytes32[] memory _keyTuple = new bytes32[](0); - - StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout); - } - - /** - * @notice Tightly pack static (fixed length) data using this table's schema. - * @return The static data, encoded into a sequence of bytes. - */ - function encodeStatic( - Status status, - uint32 crossWordRewardFraction, - uint16 bonusDistance - ) - internal - pure - returns (bytes memory) - { - return abi.encodePacked(status, crossWordRewardFraction, bonusDistance); - } - - /** - * @notice Encode all of a record's fields. - * @return The static (fixed length) data, encoded into a sequence of bytes. - * @return The lengths of the dynamic fields (packed into a single bytes32 value). - * @return The dynamic (variable length) data, encoded into a sequence of bytes. - */ - function encode( - Status status, - uint32 crossWordRewardFraction, - uint16 bonusDistance - ) - internal - pure - returns (bytes memory, EncodedLengths, bytes memory) - { - bytes memory _staticData = encodeStatic(status, crossWordRewardFraction, bonusDistance); - - EncodedLengths _encodedLengths; - bytes memory _dynamicData; - - return (_staticData, _encodedLengths, _dynamicData); - } - - /** - * @notice Encode keys as a bytes32 array using this table's field layout. - */ - function encodeKeyTuple() internal pure returns (bytes32[] memory) { - bytes32[] memory _keyTuple = new bytes32[](0); - - return _keyTuple; - } -} diff --git a/src/codegen/tables/LettersDrawn.sol b/src/codegen/tables/LettersDrawn.sol deleted file mode 100644 index 609c321..0000000 --- a/src/codegen/tables/LettersDrawn.sol +++ /dev/null @@ -1,289 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity >=0.8.24; - -/* Autogenerated file. Do not edit manually. */ - -// Import store internals - -import { Bytes } from "@latticexyz/store/src/Bytes.sol"; - -import { EncodedLengths, EncodedLengthsLib } from "@latticexyz/store/src/EncodedLengths.sol"; -import { FieldLayout } from "@latticexyz/store/src/FieldLayout.sol"; -import { IStore } from "@latticexyz/store/src/IStore.sol"; -import { Memory } from "@latticexyz/store/src/Memory.sol"; - -import { ResourceId } from "@latticexyz/store/src/ResourceId.sol"; -import { Schema } from "@latticexyz/store/src/Schema.sol"; -import { SliceLib } from "@latticexyz/store/src/Slice.sol"; -import { StoreCore } from "@latticexyz/store/src/StoreCore.sol"; -import { StoreSwitch } from "@latticexyz/store/src/StoreSwitch.sol"; - -import { EncodeArray } from "@latticexyz/store/src/tightcoder/EncodeArray.sol"; - -struct LettersDrawnData { - address player; - uint256 value; - uint256 timestamp; -} - -library LettersDrawn { - // Hex below is the result of `WorldResourceIdLib.encode({ namespace: "", name: "LettersDrawn", typeId: - // RESOURCE_OFFCHAIN_TABLE });` - ResourceId constant _tableId = ResourceId.wrap(0x6f7400000000000000000000000000004c657474657273447261776e00000000); - - FieldLayout constant _fieldLayout = - FieldLayout.wrap(0x0054030014202000000000000000000000000000000000000000000000000000); - - // Hex-encoded key schema of (uint256) - Schema constant _keySchema = Schema.wrap(0x002001001f000000000000000000000000000000000000000000000000000000); - // Hex-encoded value schema of (address, uint256, uint256) - Schema constant _valueSchema = Schema.wrap(0x00540300611f1f00000000000000000000000000000000000000000000000000); - - /** - * @notice Get the table's key field names. - * @return keyNames An array of strings with the names of key fields. - */ - function getKeyNames() internal pure returns (string[] memory keyNames) { - keyNames = new string[](1); - keyNames[0] = "id"; - } - - /** - * @notice Get the table's value field names. - * @return fieldNames An array of strings with the names of value fields. - */ - function getFieldNames() internal pure returns (string[] memory fieldNames) { - fieldNames = new string[](3); - fieldNames[0] = "player"; - fieldNames[1] = "value"; - fieldNames[2] = "timestamp"; - } - - /** - * @notice Register the table with its config. - */ - function register() internal { - StoreSwitch.registerTable(_tableId, _fieldLayout, _keySchema, _valueSchema, getKeyNames(), getFieldNames()); - } - - /** - * @notice Register the table with its config. - */ - function _register() internal { - StoreCore.registerTable(_tableId, _fieldLayout, _keySchema, _valueSchema, getKeyNames(), getFieldNames()); - } - - /** - * @notice Set player. - */ - function setPlayer(uint256 id, address player) internal { - bytes32[] memory _keyTuple = new bytes32[](1); - _keyTuple[0] = bytes32(uint256(id)); - - StoreSwitch.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((player)), _fieldLayout); - } - - /** - * @notice Set player. - */ - function _setPlayer(uint256 id, address player) internal { - bytes32[] memory _keyTuple = new bytes32[](1); - _keyTuple[0] = bytes32(uint256(id)); - - StoreCore.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((player)), _fieldLayout); - } - - /** - * @notice Set value. - */ - function setValue(uint256 id, uint256 value) internal { - bytes32[] memory _keyTuple = new bytes32[](1); - _keyTuple[0] = bytes32(uint256(id)); - - StoreSwitch.setStaticField(_tableId, _keyTuple, 1, abi.encodePacked((value)), _fieldLayout); - } - - /** - * @notice Set value. - */ - function _setValue(uint256 id, uint256 value) internal { - bytes32[] memory _keyTuple = new bytes32[](1); - _keyTuple[0] = bytes32(uint256(id)); - - StoreCore.setStaticField(_tableId, _keyTuple, 1, abi.encodePacked((value)), _fieldLayout); - } - - /** - * @notice Set timestamp. - */ - function setTimestamp(uint256 id, uint256 timestamp) internal { - bytes32[] memory _keyTuple = new bytes32[](1); - _keyTuple[0] = bytes32(uint256(id)); - - StoreSwitch.setStaticField(_tableId, _keyTuple, 2, abi.encodePacked((timestamp)), _fieldLayout); - } - - /** - * @notice Set timestamp. - */ - function _setTimestamp(uint256 id, uint256 timestamp) internal { - bytes32[] memory _keyTuple = new bytes32[](1); - _keyTuple[0] = bytes32(uint256(id)); - - StoreCore.setStaticField(_tableId, _keyTuple, 2, abi.encodePacked((timestamp)), _fieldLayout); - } - - /** - * @notice Set the full data using individual values. - */ - function set(uint256 id, address player, uint256 value, uint256 timestamp) internal { - bytes memory _staticData = encodeStatic(player, value, timestamp); - - EncodedLengths _encodedLengths; - bytes memory _dynamicData; - - bytes32[] memory _keyTuple = new bytes32[](1); - _keyTuple[0] = bytes32(uint256(id)); - - StoreSwitch.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); - } - - /** - * @notice Set the full data using individual values. - */ - function _set(uint256 id, address player, uint256 value, uint256 timestamp) internal { - bytes memory _staticData = encodeStatic(player, value, timestamp); - - EncodedLengths _encodedLengths; - bytes memory _dynamicData; - - bytes32[] memory _keyTuple = new bytes32[](1); - _keyTuple[0] = bytes32(uint256(id)); - - StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); - } - - /** - * @notice Set the full data using the data struct. - */ - function set(uint256 id, LettersDrawnData memory _table) internal { - bytes memory _staticData = encodeStatic(_table.player, _table.value, _table.timestamp); - - EncodedLengths _encodedLengths; - bytes memory _dynamicData; - - bytes32[] memory _keyTuple = new bytes32[](1); - _keyTuple[0] = bytes32(uint256(id)); - - StoreSwitch.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); - } - - /** - * @notice Set the full data using the data struct. - */ - function _set(uint256 id, LettersDrawnData memory _table) internal { - bytes memory _staticData = encodeStatic(_table.player, _table.value, _table.timestamp); - - EncodedLengths _encodedLengths; - bytes memory _dynamicData; - - bytes32[] memory _keyTuple = new bytes32[](1); - _keyTuple[0] = bytes32(uint256(id)); - - StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); - } - - /** - * @notice Decode the tightly packed blob of static data using this table's field layout. - */ - function decodeStatic(bytes memory _blob) - internal - pure - returns (address player, uint256 value, uint256 timestamp) - { - player = (address(Bytes.getBytes20(_blob, 0))); - - value = (uint256(Bytes.getBytes32(_blob, 20))); - - timestamp = (uint256(Bytes.getBytes32(_blob, 52))); - } - - /** - * @notice Decode the tightly packed blobs using this table's field layout. - * @param _staticData Tightly packed static fields. - * - * - */ - function decode( - bytes memory _staticData, - EncodedLengths, - bytes memory - ) - internal - pure - returns (LettersDrawnData memory _table) - { - (_table.player, _table.value, _table.timestamp) = decodeStatic(_staticData); - } - - /** - * @notice Delete all data for given keys. - */ - function deleteRecord(uint256 id) internal { - bytes32[] memory _keyTuple = new bytes32[](1); - _keyTuple[0] = bytes32(uint256(id)); - - StoreSwitch.deleteRecord(_tableId, _keyTuple); - } - - /** - * @notice Delete all data for given keys. - */ - function _deleteRecord(uint256 id) internal { - bytes32[] memory _keyTuple = new bytes32[](1); - _keyTuple[0] = bytes32(uint256(id)); - - StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout); - } - - /** - * @notice Tightly pack static (fixed length) data using this table's schema. - * @return The static data, encoded into a sequence of bytes. - */ - function encodeStatic(address player, uint256 value, uint256 timestamp) internal pure returns (bytes memory) { - return abi.encodePacked(player, value, timestamp); - } - - /** - * @notice Encode all of a record's fields. - * @return The static (fixed length) data, encoded into a sequence of bytes. - * @return The lengths of the dynamic fields (packed into a single bytes32 value). - * @return The dynamic (variable length) data, encoded into a sequence of bytes. - */ - function encode( - address player, - uint256 value, - uint256 timestamp - ) - internal - pure - returns (bytes memory, EncodedLengths, bytes memory) - { - bytes memory _staticData = encodeStatic(player, value, timestamp); - - EncodedLengths _encodedLengths; - bytes memory _dynamicData; - - return (_staticData, _encodedLengths, _dynamicData); - } - - /** - * @notice Encode keys as a bytes32 array using this table's field layout. - */ - function encodeKeyTuple(uint256 id) internal pure returns (bytes32[] memory) { - bytes32[] memory _keyTuple = new bytes32[](1); - _keyTuple[0] = bytes32(uint256(id)); - - return _keyTuple; - } -} diff --git a/src/codegen/tables/MerkleRootConfig.sol b/src/codegen/tables/MerkleRootConfig.sol deleted file mode 100644 index 1e7c7e9..0000000 --- a/src/codegen/tables/MerkleRootConfig.sol +++ /dev/null @@ -1,192 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity >=0.8.24; - -/* Autogenerated file. Do not edit manually. */ - -// Import store internals - -import { Bytes } from "@latticexyz/store/src/Bytes.sol"; - -import { EncodedLengths, EncodedLengthsLib } from "@latticexyz/store/src/EncodedLengths.sol"; -import { FieldLayout } from "@latticexyz/store/src/FieldLayout.sol"; -import { IStore } from "@latticexyz/store/src/IStore.sol"; -import { Memory } from "@latticexyz/store/src/Memory.sol"; - -import { ResourceId } from "@latticexyz/store/src/ResourceId.sol"; -import { Schema } from "@latticexyz/store/src/Schema.sol"; -import { SliceLib } from "@latticexyz/store/src/Slice.sol"; -import { StoreCore } from "@latticexyz/store/src/StoreCore.sol"; -import { StoreSwitch } from "@latticexyz/store/src/StoreSwitch.sol"; - -import { EncodeArray } from "@latticexyz/store/src/tightcoder/EncodeArray.sol"; - -library MerkleRootConfig { - // Hex below is the result of `WorldResourceIdLib.encode({ namespace: "", name: "MerkleRootConfig", typeId: - // RESOURCE_TABLE });` - ResourceId constant _tableId = ResourceId.wrap(0x746200000000000000000000000000004d65726b6c65526f6f74436f6e666967); - - FieldLayout constant _fieldLayout = - FieldLayout.wrap(0x0020010020000000000000000000000000000000000000000000000000000000); - - // Hex-encoded key schema of () - Schema constant _keySchema = Schema.wrap(0x0000000000000000000000000000000000000000000000000000000000000000); - // Hex-encoded value schema of (bytes32) - Schema constant _valueSchema = Schema.wrap(0x002001005f000000000000000000000000000000000000000000000000000000); - - /** - * @notice Get the table's key field names. - * @return keyNames An array of strings with the names of key fields. - */ - function getKeyNames() internal pure returns (string[] memory keyNames) { - keyNames = new string[](0); - } - - /** - * @notice Get the table's value field names. - * @return fieldNames An array of strings with the names of value fields. - */ - function getFieldNames() internal pure returns (string[] memory fieldNames) { - fieldNames = new string[](1); - fieldNames[0] = "value"; - } - - /** - * @notice Register the table with its config. - */ - function register() internal { - StoreSwitch.registerTable(_tableId, _fieldLayout, _keySchema, _valueSchema, getKeyNames(), getFieldNames()); - } - - /** - * @notice Register the table with its config. - */ - function _register() internal { - StoreCore.registerTable(_tableId, _fieldLayout, _keySchema, _valueSchema, getKeyNames(), getFieldNames()); - } - - /** - * @notice Get value. - */ - function getValue() internal view returns (bytes32 value) { - bytes32[] memory _keyTuple = new bytes32[](0); - - bytes32 _blob = StoreSwitch.getStaticField(_tableId, _keyTuple, 0, _fieldLayout); - return (bytes32(_blob)); - } - - /** - * @notice Get value. - */ - function _getValue() internal view returns (bytes32 value) { - bytes32[] memory _keyTuple = new bytes32[](0); - - bytes32 _blob = StoreCore.getStaticField(_tableId, _keyTuple, 0, _fieldLayout); - return (bytes32(_blob)); - } - - /** - * @notice Get value. - */ - function get() internal view returns (bytes32 value) { - bytes32[] memory _keyTuple = new bytes32[](0); - - bytes32 _blob = StoreSwitch.getStaticField(_tableId, _keyTuple, 0, _fieldLayout); - return (bytes32(_blob)); - } - - /** - * @notice Get value. - */ - function _get() internal view returns (bytes32 value) { - bytes32[] memory _keyTuple = new bytes32[](0); - - bytes32 _blob = StoreCore.getStaticField(_tableId, _keyTuple, 0, _fieldLayout); - return (bytes32(_blob)); - } - - /** - * @notice Set value. - */ - function setValue(bytes32 value) internal { - bytes32[] memory _keyTuple = new bytes32[](0); - - StoreSwitch.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); - } - - /** - * @notice Set value. - */ - function _setValue(bytes32 value) internal { - bytes32[] memory _keyTuple = new bytes32[](0); - - StoreCore.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); - } - - /** - * @notice Set value. - */ - function set(bytes32 value) internal { - bytes32[] memory _keyTuple = new bytes32[](0); - - StoreSwitch.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); - } - - /** - * @notice Set value. - */ - function _set(bytes32 value) internal { - bytes32[] memory _keyTuple = new bytes32[](0); - - StoreCore.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); - } - - /** - * @notice Delete all data for given keys. - */ - function deleteRecord() internal { - bytes32[] memory _keyTuple = new bytes32[](0); - - StoreSwitch.deleteRecord(_tableId, _keyTuple); - } - - /** - * @notice Delete all data for given keys. - */ - function _deleteRecord() internal { - bytes32[] memory _keyTuple = new bytes32[](0); - - StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout); - } - - /** - * @notice Tightly pack static (fixed length) data using this table's schema. - * @return The static data, encoded into a sequence of bytes. - */ - function encodeStatic(bytes32 value) internal pure returns (bytes memory) { - return abi.encodePacked(value); - } - - /** - * @notice Encode all of a record's fields. - * @return The static (fixed length) data, encoded into a sequence of bytes. - * @return The lengths of the dynamic fields (packed into a single bytes32 value). - * @return The dynamic (variable length) data, encoded into a sequence of bytes. - */ - function encode(bytes32 value) internal pure returns (bytes memory, EncodedLengths, bytes memory) { - bytes memory _staticData = encodeStatic(value); - - EncodedLengths _encodedLengths; - bytes memory _dynamicData; - - return (_staticData, _encodedLengths, _dynamicData); - } - - /** - * @notice Encode keys as a bytes32 array using this table's field layout. - */ - function encodeKeyTuple() internal pure returns (bytes32[] memory) { - bytes32[] memory _keyTuple = new bytes32[](0); - - return _keyTuple; - } -} diff --git a/src/codegen/tables/PlayResult.sol b/src/codegen/tables/PlayResult.sol deleted file mode 100644 index 103e045..0000000 --- a/src/codegen/tables/PlayResult.sol +++ /dev/null @@ -1,433 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity >=0.8.24; - -/* Autogenerated file. Do not edit manually. */ - -// Import store internals - -import { Bytes } from "@latticexyz/store/src/Bytes.sol"; - -import { EncodedLengths, EncodedLengthsLib } from "@latticexyz/store/src/EncodedLengths.sol"; -import { FieldLayout } from "@latticexyz/store/src/FieldLayout.sol"; -import { IStore } from "@latticexyz/store/src/IStore.sol"; -import { Memory } from "@latticexyz/store/src/Memory.sol"; - -import { ResourceId } from "@latticexyz/store/src/ResourceId.sol"; -import { Schema } from "@latticexyz/store/src/Schema.sol"; -import { SliceLib } from "@latticexyz/store/src/Slice.sol"; -import { StoreCore } from "@latticexyz/store/src/StoreCore.sol"; -import { StoreSwitch } from "@latticexyz/store/src/StoreSwitch.sol"; - -import { EncodeArray } from "@latticexyz/store/src/tightcoder/EncodeArray.sol"; - -// Import user types -import { Direction } from "./../common.sol"; - -struct PlayResultData { - address player; - Direction direction; - uint256 timestamp; - int32 x; - int32 y; - uint8[] word; - uint8[] filledWord; -} - -library PlayResult { - // Hex below is the result of `WorldResourceIdLib.encode({ namespace: "", name: "PlayResult", typeId: - // RESOURCE_OFFCHAIN_TABLE });` - ResourceId constant _tableId = ResourceId.wrap(0x6f740000000000000000000000000000506c6179526573756c74000000000000); - - FieldLayout constant _fieldLayout = - FieldLayout.wrap(0x003d050214012004040000000000000000000000000000000000000000000000); - - // Hex-encoded key schema of (uint256) - Schema constant _keySchema = Schema.wrap(0x002001001f000000000000000000000000000000000000000000000000000000); - // Hex-encoded value schema of (address, uint8, uint256, int32, int32, uint8[], uint8[]) - Schema constant _valueSchema = Schema.wrap(0x003d050261001f23236262000000000000000000000000000000000000000000); - - /** - * @notice Get the table's key field names. - * @return keyNames An array of strings with the names of key fields. - */ - function getKeyNames() internal pure returns (string[] memory keyNames) { - keyNames = new string[](1); - keyNames[0] = "id"; - } - - /** - * @notice Get the table's value field names. - * @return fieldNames An array of strings with the names of value fields. - */ - function getFieldNames() internal pure returns (string[] memory fieldNames) { - fieldNames = new string[](7); - fieldNames[0] = "player"; - fieldNames[1] = "direction"; - fieldNames[2] = "timestamp"; - fieldNames[3] = "x"; - fieldNames[4] = "y"; - fieldNames[5] = "word"; - fieldNames[6] = "filledWord"; - } - - /** - * @notice Register the table with its config. - */ - function register() internal { - StoreSwitch.registerTable(_tableId, _fieldLayout, _keySchema, _valueSchema, getKeyNames(), getFieldNames()); - } - - /** - * @notice Register the table with its config. - */ - function _register() internal { - StoreCore.registerTable(_tableId, _fieldLayout, _keySchema, _valueSchema, getKeyNames(), getFieldNames()); - } - - /** - * @notice Set player. - */ - function setPlayer(uint256 id, address player) internal { - bytes32[] memory _keyTuple = new bytes32[](1); - _keyTuple[0] = bytes32(uint256(id)); - - StoreSwitch.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((player)), _fieldLayout); - } - - /** - * @notice Set player. - */ - function _setPlayer(uint256 id, address player) internal { - bytes32[] memory _keyTuple = new bytes32[](1); - _keyTuple[0] = bytes32(uint256(id)); - - StoreCore.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((player)), _fieldLayout); - } - - /** - * @notice Set direction. - */ - function setDirection(uint256 id, Direction direction) internal { - bytes32[] memory _keyTuple = new bytes32[](1); - _keyTuple[0] = bytes32(uint256(id)); - - StoreSwitch.setStaticField(_tableId, _keyTuple, 1, abi.encodePacked(uint8(direction)), _fieldLayout); - } - - /** - * @notice Set direction. - */ - function _setDirection(uint256 id, Direction direction) internal { - bytes32[] memory _keyTuple = new bytes32[](1); - _keyTuple[0] = bytes32(uint256(id)); - - StoreCore.setStaticField(_tableId, _keyTuple, 1, abi.encodePacked(uint8(direction)), _fieldLayout); - } - - /** - * @notice Set timestamp. - */ - function setTimestamp(uint256 id, uint256 timestamp) internal { - bytes32[] memory _keyTuple = new bytes32[](1); - _keyTuple[0] = bytes32(uint256(id)); - - StoreSwitch.setStaticField(_tableId, _keyTuple, 2, abi.encodePacked((timestamp)), _fieldLayout); - } - - /** - * @notice Set timestamp. - */ - function _setTimestamp(uint256 id, uint256 timestamp) internal { - bytes32[] memory _keyTuple = new bytes32[](1); - _keyTuple[0] = bytes32(uint256(id)); - - StoreCore.setStaticField(_tableId, _keyTuple, 2, abi.encodePacked((timestamp)), _fieldLayout); - } - - /** - * @notice Set x. - */ - function setX(uint256 id, int32 x) internal { - bytes32[] memory _keyTuple = new bytes32[](1); - _keyTuple[0] = bytes32(uint256(id)); - - StoreSwitch.setStaticField(_tableId, _keyTuple, 3, abi.encodePacked((x)), _fieldLayout); - } - - /** - * @notice Set x. - */ - function _setX(uint256 id, int32 x) internal { - bytes32[] memory _keyTuple = new bytes32[](1); - _keyTuple[0] = bytes32(uint256(id)); - - StoreCore.setStaticField(_tableId, _keyTuple, 3, abi.encodePacked((x)), _fieldLayout); - } - - /** - * @notice Set y. - */ - function setY(uint256 id, int32 y) internal { - bytes32[] memory _keyTuple = new bytes32[](1); - _keyTuple[0] = bytes32(uint256(id)); - - StoreSwitch.setStaticField(_tableId, _keyTuple, 4, abi.encodePacked((y)), _fieldLayout); - } - - /** - * @notice Set y. - */ - function _setY(uint256 id, int32 y) internal { - bytes32[] memory _keyTuple = new bytes32[](1); - _keyTuple[0] = bytes32(uint256(id)); - - StoreCore.setStaticField(_tableId, _keyTuple, 4, abi.encodePacked((y)), _fieldLayout); - } - - /** - * @notice Set the full data using individual values. - */ - function set( - uint256 id, - address player, - Direction direction, - uint256 timestamp, - int32 x, - int32 y, - uint8[] memory word, - uint8[] memory filledWord - ) - internal - { - bytes memory _staticData = encodeStatic(player, direction, timestamp, x, y); - - EncodedLengths _encodedLengths = encodeLengths(word, filledWord); - bytes memory _dynamicData = encodeDynamic(word, filledWord); - - bytes32[] memory _keyTuple = new bytes32[](1); - _keyTuple[0] = bytes32(uint256(id)); - - StoreSwitch.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); - } - - /** - * @notice Set the full data using individual values. - */ - function _set( - uint256 id, - address player, - Direction direction, - uint256 timestamp, - int32 x, - int32 y, - uint8[] memory word, - uint8[] memory filledWord - ) - internal - { - bytes memory _staticData = encodeStatic(player, direction, timestamp, x, y); - - EncodedLengths _encodedLengths = encodeLengths(word, filledWord); - bytes memory _dynamicData = encodeDynamic(word, filledWord); - - bytes32[] memory _keyTuple = new bytes32[](1); - _keyTuple[0] = bytes32(uint256(id)); - - StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); - } - - /** - * @notice Set the full data using the data struct. - */ - function set(uint256 id, PlayResultData memory _table) internal { - bytes memory _staticData = encodeStatic(_table.player, _table.direction, _table.timestamp, _table.x, _table.y); - - EncodedLengths _encodedLengths = encodeLengths(_table.word, _table.filledWord); - bytes memory _dynamicData = encodeDynamic(_table.word, _table.filledWord); - - bytes32[] memory _keyTuple = new bytes32[](1); - _keyTuple[0] = bytes32(uint256(id)); - - StoreSwitch.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); - } - - /** - * @notice Set the full data using the data struct. - */ - function _set(uint256 id, PlayResultData memory _table) internal { - bytes memory _staticData = encodeStatic(_table.player, _table.direction, _table.timestamp, _table.x, _table.y); - - EncodedLengths _encodedLengths = encodeLengths(_table.word, _table.filledWord); - bytes memory _dynamicData = encodeDynamic(_table.word, _table.filledWord); - - bytes32[] memory _keyTuple = new bytes32[](1); - _keyTuple[0] = bytes32(uint256(id)); - - StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); - } - - /** - * @notice Decode the tightly packed blob of static data using this table's field layout. - */ - function decodeStatic(bytes memory _blob) - internal - pure - returns (address player, Direction direction, uint256 timestamp, int32 x, int32 y) - { - player = (address(Bytes.getBytes20(_blob, 0))); - - direction = Direction(uint8(Bytes.getBytes1(_blob, 20))); - - timestamp = (uint256(Bytes.getBytes32(_blob, 21))); - - x = (int32(uint32(Bytes.getBytes4(_blob, 53)))); - - y = (int32(uint32(Bytes.getBytes4(_blob, 57)))); - } - - /** - * @notice Decode the tightly packed blob of dynamic data using the encoded lengths. - */ - function decodeDynamic( - EncodedLengths _encodedLengths, - bytes memory _blob - ) - internal - pure - returns (uint8[] memory word, uint8[] memory filledWord) - { - uint256 _start; - uint256 _end; - unchecked { - _end = _encodedLengths.atIndex(0); - } - word = (SliceLib.getSubslice(_blob, _start, _end).decodeArray_uint8()); - - _start = _end; - unchecked { - _end += _encodedLengths.atIndex(1); - } - filledWord = (SliceLib.getSubslice(_blob, _start, _end).decodeArray_uint8()); - } - - /** - * @notice Decode the tightly packed blobs using this table's field layout. - * @param _staticData Tightly packed static fields. - * @param _encodedLengths Encoded lengths of dynamic fields. - * @param _dynamicData Tightly packed dynamic fields. - */ - function decode( - bytes memory _staticData, - EncodedLengths _encodedLengths, - bytes memory _dynamicData - ) - internal - pure - returns (PlayResultData memory _table) - { - (_table.player, _table.direction, _table.timestamp, _table.x, _table.y) = decodeStatic(_staticData); - - (_table.word, _table.filledWord) = decodeDynamic(_encodedLengths, _dynamicData); - } - - /** - * @notice Delete all data for given keys. - */ - function deleteRecord(uint256 id) internal { - bytes32[] memory _keyTuple = new bytes32[](1); - _keyTuple[0] = bytes32(uint256(id)); - - StoreSwitch.deleteRecord(_tableId, _keyTuple); - } - - /** - * @notice Delete all data for given keys. - */ - function _deleteRecord(uint256 id) internal { - bytes32[] memory _keyTuple = new bytes32[](1); - _keyTuple[0] = bytes32(uint256(id)); - - StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout); - } - - /** - * @notice Tightly pack static (fixed length) data using this table's schema. - * @return The static data, encoded into a sequence of bytes. - */ - function encodeStatic( - address player, - Direction direction, - uint256 timestamp, - int32 x, - int32 y - ) - internal - pure - returns (bytes memory) - { - return abi.encodePacked(player, direction, timestamp, x, y); - } - - /** - * @notice Tightly pack dynamic data lengths using this table's schema. - * @return _encodedLengths The lengths of the dynamic fields (packed into a single bytes32 value). - */ - function encodeLengths( - uint8[] memory word, - uint8[] memory filledWord - ) - internal - pure - returns (EncodedLengths _encodedLengths) - { - // Lengths are effectively checked during copy by 2**40 bytes exceeding gas limits - unchecked { - _encodedLengths = EncodedLengthsLib.pack(word.length * 1, filledWord.length * 1); - } - } - - /** - * @notice Tightly pack dynamic (variable length) data using this table's schema. - * @return The dynamic data, encoded into a sequence of bytes. - */ - function encodeDynamic(uint8[] memory word, uint8[] memory filledWord) internal pure returns (bytes memory) { - return abi.encodePacked(EncodeArray.encode((word)), EncodeArray.encode((filledWord))); - } - - /** - * @notice Encode all of a record's fields. - * @return The static (fixed length) data, encoded into a sequence of bytes. - * @return The lengths of the dynamic fields (packed into a single bytes32 value). - * @return The dynamic (variable length) data, encoded into a sequence of bytes. - */ - function encode( - address player, - Direction direction, - uint256 timestamp, - int32 x, - int32 y, - uint8[] memory word, - uint8[] memory filledWord - ) - internal - pure - returns (bytes memory, EncodedLengths, bytes memory) - { - bytes memory _staticData = encodeStatic(player, direction, timestamp, x, y); - - EncodedLengths _encodedLengths = encodeLengths(word, filledWord); - bytes memory _dynamicData = encodeDynamic(word, filledWord); - - return (_staticData, _encodedLengths, _dynamicData); - } - - /** - * @notice Encode keys as a bytes32 array using this table's field layout. - */ - function encodeKeyTuple(uint256 id) internal pure returns (bytes32[] memory) { - bytes32[] memory _keyTuple = new bytes32[](1); - _keyTuple[0] = bytes32(uint256(id)); - - return _keyTuple; - } -} diff --git a/src/codegen/tables/PlayerLetters.sol b/src/codegen/tables/PlayerLetters.sol deleted file mode 100644 index b3a1b9f..0000000 --- a/src/codegen/tables/PlayerLetters.sol +++ /dev/null @@ -1,219 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity >=0.8.24; - -/* Autogenerated file. Do not edit manually. */ - -// Import store internals - -import { Bytes } from "@latticexyz/store/src/Bytes.sol"; - -import { EncodedLengths, EncodedLengthsLib } from "@latticexyz/store/src/EncodedLengths.sol"; -import { FieldLayout } from "@latticexyz/store/src/FieldLayout.sol"; -import { IStore } from "@latticexyz/store/src/IStore.sol"; -import { Memory } from "@latticexyz/store/src/Memory.sol"; - -import { ResourceId } from "@latticexyz/store/src/ResourceId.sol"; -import { Schema } from "@latticexyz/store/src/Schema.sol"; -import { SliceLib } from "@latticexyz/store/src/Slice.sol"; -import { StoreCore } from "@latticexyz/store/src/StoreCore.sol"; -import { StoreSwitch } from "@latticexyz/store/src/StoreSwitch.sol"; - -import { EncodeArray } from "@latticexyz/store/src/tightcoder/EncodeArray.sol"; - -// Import user types -import { Letter } from "./../common.sol"; - -library PlayerLetters { - // Hex below is the result of `WorldResourceIdLib.encode({ namespace: "", name: "PlayerLetters", typeId: - // RESOURCE_TABLE });` - ResourceId constant _tableId = ResourceId.wrap(0x74620000000000000000000000000000506c617965724c657474657273000000); - - FieldLayout constant _fieldLayout = - FieldLayout.wrap(0x0004010004000000000000000000000000000000000000000000000000000000); - - // Hex-encoded key schema of (address, uint8) - Schema constant _keySchema = Schema.wrap(0x0015020061000000000000000000000000000000000000000000000000000000); - // Hex-encoded value schema of (uint32) - Schema constant _valueSchema = Schema.wrap(0x0004010003000000000000000000000000000000000000000000000000000000); - - /** - * @notice Get the table's key field names. - * @return keyNames An array of strings with the names of key fields. - */ - function getKeyNames() internal pure returns (string[] memory keyNames) { - keyNames = new string[](2); - keyNames[0] = "player"; - keyNames[1] = "letter"; - } - - /** - * @notice Get the table's value field names. - * @return fieldNames An array of strings with the names of value fields. - */ - function getFieldNames() internal pure returns (string[] memory fieldNames) { - fieldNames = new string[](1); - fieldNames[0] = "value"; - } - - /** - * @notice Register the table with its config. - */ - function register() internal { - StoreSwitch.registerTable(_tableId, _fieldLayout, _keySchema, _valueSchema, getKeyNames(), getFieldNames()); - } - - /** - * @notice Register the table with its config. - */ - function _register() internal { - StoreCore.registerTable(_tableId, _fieldLayout, _keySchema, _valueSchema, getKeyNames(), getFieldNames()); - } - - /** - * @notice Get value. - */ - function getValue(address player, Letter letter) internal view returns (uint32 value) { - bytes32[] memory _keyTuple = new bytes32[](2); - _keyTuple[0] = bytes32(uint256(uint160(player))); - _keyTuple[1] = bytes32(uint256(uint8(letter))); - - bytes32 _blob = StoreSwitch.getStaticField(_tableId, _keyTuple, 0, _fieldLayout); - return (uint32(bytes4(_blob))); - } - - /** - * @notice Get value. - */ - function _getValue(address player, Letter letter) internal view returns (uint32 value) { - bytes32[] memory _keyTuple = new bytes32[](2); - _keyTuple[0] = bytes32(uint256(uint160(player))); - _keyTuple[1] = bytes32(uint256(uint8(letter))); - - bytes32 _blob = StoreCore.getStaticField(_tableId, _keyTuple, 0, _fieldLayout); - return (uint32(bytes4(_blob))); - } - - /** - * @notice Get value. - */ - function get(address player, Letter letter) internal view returns (uint32 value) { - bytes32[] memory _keyTuple = new bytes32[](2); - _keyTuple[0] = bytes32(uint256(uint160(player))); - _keyTuple[1] = bytes32(uint256(uint8(letter))); - - bytes32 _blob = StoreSwitch.getStaticField(_tableId, _keyTuple, 0, _fieldLayout); - return (uint32(bytes4(_blob))); - } - - /** - * @notice Get value. - */ - function _get(address player, Letter letter) internal view returns (uint32 value) { - bytes32[] memory _keyTuple = new bytes32[](2); - _keyTuple[0] = bytes32(uint256(uint160(player))); - _keyTuple[1] = bytes32(uint256(uint8(letter))); - - bytes32 _blob = StoreCore.getStaticField(_tableId, _keyTuple, 0, _fieldLayout); - return (uint32(bytes4(_blob))); - } - - /** - * @notice Set value. - */ - function setValue(address player, Letter letter, uint32 value) internal { - bytes32[] memory _keyTuple = new bytes32[](2); - _keyTuple[0] = bytes32(uint256(uint160(player))); - _keyTuple[1] = bytes32(uint256(uint8(letter))); - - StoreSwitch.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); - } - - /** - * @notice Set value. - */ - function _setValue(address player, Letter letter, uint32 value) internal { - bytes32[] memory _keyTuple = new bytes32[](2); - _keyTuple[0] = bytes32(uint256(uint160(player))); - _keyTuple[1] = bytes32(uint256(uint8(letter))); - - StoreCore.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); - } - - /** - * @notice Set value. - */ - function set(address player, Letter letter, uint32 value) internal { - bytes32[] memory _keyTuple = new bytes32[](2); - _keyTuple[0] = bytes32(uint256(uint160(player))); - _keyTuple[1] = bytes32(uint256(uint8(letter))); - - StoreSwitch.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); - } - - /** - * @notice Set value. - */ - function _set(address player, Letter letter, uint32 value) internal { - bytes32[] memory _keyTuple = new bytes32[](2); - _keyTuple[0] = bytes32(uint256(uint160(player))); - _keyTuple[1] = bytes32(uint256(uint8(letter))); - - StoreCore.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); - } - - /** - * @notice Delete all data for given keys. - */ - function deleteRecord(address player, Letter letter) internal { - bytes32[] memory _keyTuple = new bytes32[](2); - _keyTuple[0] = bytes32(uint256(uint160(player))); - _keyTuple[1] = bytes32(uint256(uint8(letter))); - - StoreSwitch.deleteRecord(_tableId, _keyTuple); - } - - /** - * @notice Delete all data for given keys. - */ - function _deleteRecord(address player, Letter letter) internal { - bytes32[] memory _keyTuple = new bytes32[](2); - _keyTuple[0] = bytes32(uint256(uint160(player))); - _keyTuple[1] = bytes32(uint256(uint8(letter))); - - StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout); - } - - /** - * @notice Tightly pack static (fixed length) data using this table's schema. - * @return The static data, encoded into a sequence of bytes. - */ - function encodeStatic(uint32 value) internal pure returns (bytes memory) { - return abi.encodePacked(value); - } - - /** - * @notice Encode all of a record's fields. - * @return The static (fixed length) data, encoded into a sequence of bytes. - * @return The lengths of the dynamic fields (packed into a single bytes32 value). - * @return The dynamic (variable length) data, encoded into a sequence of bytes. - */ - function encode(uint32 value) internal pure returns (bytes memory, EncodedLengths, bytes memory) { - bytes memory _staticData = encodeStatic(value); - - EncodedLengths _encodedLengths; - bytes memory _dynamicData; - - return (_staticData, _encodedLengths, _dynamicData); - } - - /** - * @notice Encode keys as a bytes32 array using this table's field layout. - */ - function encodeKeyTuple(address player, Letter letter) internal pure returns (bytes32[] memory) { - bytes32[] memory _keyTuple = new bytes32[](2); - _keyTuple[0] = bytes32(uint256(uint160(player))); - _keyTuple[1] = bytes32(uint256(uint8(letter))); - - return _keyTuple; - } -} diff --git a/src/codegen/tables/Points.sol b/src/codegen/tables/Points.sol deleted file mode 100644 index 4d5ef19..0000000 --- a/src/codegen/tables/Points.sol +++ /dev/null @@ -1,204 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity >=0.8.24; - -/* Autogenerated file. Do not edit manually. */ - -// Import store internals - -import { Bytes } from "@latticexyz/store/src/Bytes.sol"; - -import { EncodedLengths, EncodedLengthsLib } from "@latticexyz/store/src/EncodedLengths.sol"; -import { FieldLayout } from "@latticexyz/store/src/FieldLayout.sol"; -import { IStore } from "@latticexyz/store/src/IStore.sol"; -import { Memory } from "@latticexyz/store/src/Memory.sol"; - -import { ResourceId } from "@latticexyz/store/src/ResourceId.sol"; -import { Schema } from "@latticexyz/store/src/Schema.sol"; -import { SliceLib } from "@latticexyz/store/src/Slice.sol"; -import { StoreCore } from "@latticexyz/store/src/StoreCore.sol"; -import { StoreSwitch } from "@latticexyz/store/src/StoreSwitch.sol"; - -import { EncodeArray } from "@latticexyz/store/src/tightcoder/EncodeArray.sol"; - -library Points { - // Hex below is the result of `WorldResourceIdLib.encode({ namespace: "", name: "Points", typeId: RESOURCE_TABLE - // });` - ResourceId constant _tableId = ResourceId.wrap(0x74620000000000000000000000000000506f696e747300000000000000000000); - - FieldLayout constant _fieldLayout = - FieldLayout.wrap(0x0004010004000000000000000000000000000000000000000000000000000000); - - // Hex-encoded key schema of (address) - Schema constant _keySchema = Schema.wrap(0x0014010061000000000000000000000000000000000000000000000000000000); - // Hex-encoded value schema of (uint32) - Schema constant _valueSchema = Schema.wrap(0x0004010003000000000000000000000000000000000000000000000000000000); - - /** - * @notice Get the table's key field names. - * @return keyNames An array of strings with the names of key fields. - */ - function getKeyNames() internal pure returns (string[] memory keyNames) { - keyNames = new string[](1); - keyNames[0] = "player"; - } - - /** - * @notice Get the table's value field names. - * @return fieldNames An array of strings with the names of value fields. - */ - function getFieldNames() internal pure returns (string[] memory fieldNames) { - fieldNames = new string[](1); - fieldNames[0] = "value"; - } - - /** - * @notice Register the table with its config. - */ - function register() internal { - StoreSwitch.registerTable(_tableId, _fieldLayout, _keySchema, _valueSchema, getKeyNames(), getFieldNames()); - } - - /** - * @notice Register the table with its config. - */ - function _register() internal { - StoreCore.registerTable(_tableId, _fieldLayout, _keySchema, _valueSchema, getKeyNames(), getFieldNames()); - } - - /** - * @notice Get value. - */ - function getValue(address player) internal view returns (uint32 value) { - bytes32[] memory _keyTuple = new bytes32[](1); - _keyTuple[0] = bytes32(uint256(uint160(player))); - - bytes32 _blob = StoreSwitch.getStaticField(_tableId, _keyTuple, 0, _fieldLayout); - return (uint32(bytes4(_blob))); - } - - /** - * @notice Get value. - */ - function _getValue(address player) internal view returns (uint32 value) { - bytes32[] memory _keyTuple = new bytes32[](1); - _keyTuple[0] = bytes32(uint256(uint160(player))); - - bytes32 _blob = StoreCore.getStaticField(_tableId, _keyTuple, 0, _fieldLayout); - return (uint32(bytes4(_blob))); - } - - /** - * @notice Get value. - */ - function get(address player) internal view returns (uint32 value) { - bytes32[] memory _keyTuple = new bytes32[](1); - _keyTuple[0] = bytes32(uint256(uint160(player))); - - bytes32 _blob = StoreSwitch.getStaticField(_tableId, _keyTuple, 0, _fieldLayout); - return (uint32(bytes4(_blob))); - } - - /** - * @notice Get value. - */ - function _get(address player) internal view returns (uint32 value) { - bytes32[] memory _keyTuple = new bytes32[](1); - _keyTuple[0] = bytes32(uint256(uint160(player))); - - bytes32 _blob = StoreCore.getStaticField(_tableId, _keyTuple, 0, _fieldLayout); - return (uint32(bytes4(_blob))); - } - - /** - * @notice Set value. - */ - function setValue(address player, uint32 value) internal { - bytes32[] memory _keyTuple = new bytes32[](1); - _keyTuple[0] = bytes32(uint256(uint160(player))); - - StoreSwitch.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); - } - - /** - * @notice Set value. - */ - function _setValue(address player, uint32 value) internal { - bytes32[] memory _keyTuple = new bytes32[](1); - _keyTuple[0] = bytes32(uint256(uint160(player))); - - StoreCore.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); - } - - /** - * @notice Set value. - */ - function set(address player, uint32 value) internal { - bytes32[] memory _keyTuple = new bytes32[](1); - _keyTuple[0] = bytes32(uint256(uint160(player))); - - StoreSwitch.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); - } - - /** - * @notice Set value. - */ - function _set(address player, uint32 value) internal { - bytes32[] memory _keyTuple = new bytes32[](1); - _keyTuple[0] = bytes32(uint256(uint160(player))); - - StoreCore.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); - } - - /** - * @notice Delete all data for given keys. - */ - function deleteRecord(address player) internal { - bytes32[] memory _keyTuple = new bytes32[](1); - _keyTuple[0] = bytes32(uint256(uint160(player))); - - StoreSwitch.deleteRecord(_tableId, _keyTuple); - } - - /** - * @notice Delete all data for given keys. - */ - function _deleteRecord(address player) internal { - bytes32[] memory _keyTuple = new bytes32[](1); - _keyTuple[0] = bytes32(uint256(uint160(player))); - - StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout); - } - - /** - * @notice Tightly pack static (fixed length) data using this table's schema. - * @return The static data, encoded into a sequence of bytes. - */ - function encodeStatic(uint32 value) internal pure returns (bytes memory) { - return abi.encodePacked(value); - } - - /** - * @notice Encode all of a record's fields. - * @return The static (fixed length) data, encoded into a sequence of bytes. - * @return The lengths of the dynamic fields (packed into a single bytes32 value). - * @return The dynamic (variable length) data, encoded into a sequence of bytes. - */ - function encode(uint32 value) internal pure returns (bytes memory, EncodedLengths, bytes memory) { - bytes memory _staticData = encodeStatic(value); - - EncodedLengths _encodedLengths; - bytes memory _dynamicData; - - return (_staticData, _encodedLengths, _dynamicData); - } - - /** - * @notice Encode keys as a bytes32 array using this table's field layout. - */ - function encodeKeyTuple(address player) internal pure returns (bytes32[] memory) { - bytes32[] memory _keyTuple = new bytes32[](1); - _keyTuple[0] = bytes32(uint256(uint160(player))); - - return _keyTuple; - } -} diff --git a/src/codegen/tables/PointsClaimed.sol b/src/codegen/tables/PointsClaimed.sol deleted file mode 100644 index b7d8e6e..0000000 --- a/src/codegen/tables/PointsClaimed.sol +++ /dev/null @@ -1,323 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity >=0.8.24; - -/* Autogenerated file. Do not edit manually. */ - -// Import store internals - -import { Bytes } from "@latticexyz/store/src/Bytes.sol"; - -import { EncodedLengths, EncodedLengthsLib } from "@latticexyz/store/src/EncodedLengths.sol"; -import { FieldLayout } from "@latticexyz/store/src/FieldLayout.sol"; -import { IStore } from "@latticexyz/store/src/IStore.sol"; -import { Memory } from "@latticexyz/store/src/Memory.sol"; - -import { ResourceId } from "@latticexyz/store/src/ResourceId.sol"; -import { Schema } from "@latticexyz/store/src/Schema.sol"; -import { SliceLib } from "@latticexyz/store/src/Slice.sol"; -import { StoreCore } from "@latticexyz/store/src/StoreCore.sol"; -import { StoreSwitch } from "@latticexyz/store/src/StoreSwitch.sol"; - -import { EncodeArray } from "@latticexyz/store/src/tightcoder/EncodeArray.sol"; - -struct PointsClaimedData { - address player; - uint32 points; - uint256 value; - uint256 timestamp; -} - -library PointsClaimed { - // Hex below is the result of `WorldResourceIdLib.encode({ namespace: "", name: "PointsClaimed", typeId: - // RESOURCE_OFFCHAIN_TABLE });` - ResourceId constant _tableId = ResourceId.wrap(0x6f740000000000000000000000000000506f696e7473436c61696d6564000000); - - FieldLayout constant _fieldLayout = - FieldLayout.wrap(0x0058040014042020000000000000000000000000000000000000000000000000); - - // Hex-encoded key schema of (uint256) - Schema constant _keySchema = Schema.wrap(0x002001001f000000000000000000000000000000000000000000000000000000); - // Hex-encoded value schema of (address, uint32, uint256, uint256) - Schema constant _valueSchema = Schema.wrap(0x0058040061031f1f000000000000000000000000000000000000000000000000); - - /** - * @notice Get the table's key field names. - * @return keyNames An array of strings with the names of key fields. - */ - function getKeyNames() internal pure returns (string[] memory keyNames) { - keyNames = new string[](1); - keyNames[0] = "id"; - } - - /** - * @notice Get the table's value field names. - * @return fieldNames An array of strings with the names of value fields. - */ - function getFieldNames() internal pure returns (string[] memory fieldNames) { - fieldNames = new string[](4); - fieldNames[0] = "player"; - fieldNames[1] = "points"; - fieldNames[2] = "value"; - fieldNames[3] = "timestamp"; - } - - /** - * @notice Register the table with its config. - */ - function register() internal { - StoreSwitch.registerTable(_tableId, _fieldLayout, _keySchema, _valueSchema, getKeyNames(), getFieldNames()); - } - - /** - * @notice Register the table with its config. - */ - function _register() internal { - StoreCore.registerTable(_tableId, _fieldLayout, _keySchema, _valueSchema, getKeyNames(), getFieldNames()); - } - - /** - * @notice Set player. - */ - function setPlayer(uint256 id, address player) internal { - bytes32[] memory _keyTuple = new bytes32[](1); - _keyTuple[0] = bytes32(uint256(id)); - - StoreSwitch.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((player)), _fieldLayout); - } - - /** - * @notice Set player. - */ - function _setPlayer(uint256 id, address player) internal { - bytes32[] memory _keyTuple = new bytes32[](1); - _keyTuple[0] = bytes32(uint256(id)); - - StoreCore.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((player)), _fieldLayout); - } - - /** - * @notice Set points. - */ - function setPoints(uint256 id, uint32 points) internal { - bytes32[] memory _keyTuple = new bytes32[](1); - _keyTuple[0] = bytes32(uint256(id)); - - StoreSwitch.setStaticField(_tableId, _keyTuple, 1, abi.encodePacked((points)), _fieldLayout); - } - - /** - * @notice Set points. - */ - function _setPoints(uint256 id, uint32 points) internal { - bytes32[] memory _keyTuple = new bytes32[](1); - _keyTuple[0] = bytes32(uint256(id)); - - StoreCore.setStaticField(_tableId, _keyTuple, 1, abi.encodePacked((points)), _fieldLayout); - } - - /** - * @notice Set value. - */ - function setValue(uint256 id, uint256 value) internal { - bytes32[] memory _keyTuple = new bytes32[](1); - _keyTuple[0] = bytes32(uint256(id)); - - StoreSwitch.setStaticField(_tableId, _keyTuple, 2, abi.encodePacked((value)), _fieldLayout); - } - - /** - * @notice Set value. - */ - function _setValue(uint256 id, uint256 value) internal { - bytes32[] memory _keyTuple = new bytes32[](1); - _keyTuple[0] = bytes32(uint256(id)); - - StoreCore.setStaticField(_tableId, _keyTuple, 2, abi.encodePacked((value)), _fieldLayout); - } - - /** - * @notice Set timestamp. - */ - function setTimestamp(uint256 id, uint256 timestamp) internal { - bytes32[] memory _keyTuple = new bytes32[](1); - _keyTuple[0] = bytes32(uint256(id)); - - StoreSwitch.setStaticField(_tableId, _keyTuple, 3, abi.encodePacked((timestamp)), _fieldLayout); - } - - /** - * @notice Set timestamp. - */ - function _setTimestamp(uint256 id, uint256 timestamp) internal { - bytes32[] memory _keyTuple = new bytes32[](1); - _keyTuple[0] = bytes32(uint256(id)); - - StoreCore.setStaticField(_tableId, _keyTuple, 3, abi.encodePacked((timestamp)), _fieldLayout); - } - - /** - * @notice Set the full data using individual values. - */ - function set(uint256 id, address player, uint32 points, uint256 value, uint256 timestamp) internal { - bytes memory _staticData = encodeStatic(player, points, value, timestamp); - - EncodedLengths _encodedLengths; - bytes memory _dynamicData; - - bytes32[] memory _keyTuple = new bytes32[](1); - _keyTuple[0] = bytes32(uint256(id)); - - StoreSwitch.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); - } - - /** - * @notice Set the full data using individual values. - */ - function _set(uint256 id, address player, uint32 points, uint256 value, uint256 timestamp) internal { - bytes memory _staticData = encodeStatic(player, points, value, timestamp); - - EncodedLengths _encodedLengths; - bytes memory _dynamicData; - - bytes32[] memory _keyTuple = new bytes32[](1); - _keyTuple[0] = bytes32(uint256(id)); - - StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); - } - - /** - * @notice Set the full data using the data struct. - */ - function set(uint256 id, PointsClaimedData memory _table) internal { - bytes memory _staticData = encodeStatic(_table.player, _table.points, _table.value, _table.timestamp); - - EncodedLengths _encodedLengths; - bytes memory _dynamicData; - - bytes32[] memory _keyTuple = new bytes32[](1); - _keyTuple[0] = bytes32(uint256(id)); - - StoreSwitch.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); - } - - /** - * @notice Set the full data using the data struct. - */ - function _set(uint256 id, PointsClaimedData memory _table) internal { - bytes memory _staticData = encodeStatic(_table.player, _table.points, _table.value, _table.timestamp); - - EncodedLengths _encodedLengths; - bytes memory _dynamicData; - - bytes32[] memory _keyTuple = new bytes32[](1); - _keyTuple[0] = bytes32(uint256(id)); - - StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); - } - - /** - * @notice Decode the tightly packed blob of static data using this table's field layout. - */ - function decodeStatic(bytes memory _blob) - internal - pure - returns (address player, uint32 points, uint256 value, uint256 timestamp) - { - player = (address(Bytes.getBytes20(_blob, 0))); - - points = (uint32(Bytes.getBytes4(_blob, 20))); - - value = (uint256(Bytes.getBytes32(_blob, 24))); - - timestamp = (uint256(Bytes.getBytes32(_blob, 56))); - } - - /** - * @notice Decode the tightly packed blobs using this table's field layout. - * @param _staticData Tightly packed static fields. - * - * - */ - function decode( - bytes memory _staticData, - EncodedLengths, - bytes memory - ) - internal - pure - returns (PointsClaimedData memory _table) - { - (_table.player, _table.points, _table.value, _table.timestamp) = decodeStatic(_staticData); - } - - /** - * @notice Delete all data for given keys. - */ - function deleteRecord(uint256 id) internal { - bytes32[] memory _keyTuple = new bytes32[](1); - _keyTuple[0] = bytes32(uint256(id)); - - StoreSwitch.deleteRecord(_tableId, _keyTuple); - } - - /** - * @notice Delete all data for given keys. - */ - function _deleteRecord(uint256 id) internal { - bytes32[] memory _keyTuple = new bytes32[](1); - _keyTuple[0] = bytes32(uint256(id)); - - StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout); - } - - /** - * @notice Tightly pack static (fixed length) data using this table's schema. - * @return The static data, encoded into a sequence of bytes. - */ - function encodeStatic( - address player, - uint32 points, - uint256 value, - uint256 timestamp - ) - internal - pure - returns (bytes memory) - { - return abi.encodePacked(player, points, value, timestamp); - } - - /** - * @notice Encode all of a record's fields. - * @return The static (fixed length) data, encoded into a sequence of bytes. - * @return The lengths of the dynamic fields (packed into a single bytes32 value). - * @return The dynamic (variable length) data, encoded into a sequence of bytes. - */ - function encode( - address player, - uint32 points, - uint256 value, - uint256 timestamp - ) - internal - pure - returns (bytes memory, EncodedLengths, bytes memory) - { - bytes memory _staticData = encodeStatic(player, points, value, timestamp); - - EncodedLengths _encodedLengths; - bytes memory _dynamicData; - - return (_staticData, _encodedLengths, _dynamicData); - } - - /** - * @notice Encode keys as a bytes32 array using this table's field layout. - */ - function encodeKeyTuple(uint256 id) internal pure returns (bytes32[] memory) { - bytes32[] memory _keyTuple = new bytes32[](1); - _keyTuple[0] = bytes32(uint256(id)); - - return _keyTuple; - } -} diff --git a/src/codegen/tables/PointsResult.sol b/src/codegen/tables/PointsResult.sol deleted file mode 100644 index 7678aa6..0000000 --- a/src/codegen/tables/PointsResult.sol +++ /dev/null @@ -1,265 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity >=0.8.24; - -/* Autogenerated file. Do not edit manually. */ - -// Import store internals - -import { Bytes } from "@latticexyz/store/src/Bytes.sol"; - -import { EncodedLengths, EncodedLengthsLib } from "@latticexyz/store/src/EncodedLengths.sol"; -import { FieldLayout } from "@latticexyz/store/src/FieldLayout.sol"; -import { IStore } from "@latticexyz/store/src/IStore.sol"; -import { Memory } from "@latticexyz/store/src/Memory.sol"; - -import { ResourceId } from "@latticexyz/store/src/ResourceId.sol"; -import { Schema } from "@latticexyz/store/src/Schema.sol"; -import { SliceLib } from "@latticexyz/store/src/Slice.sol"; -import { StoreCore } from "@latticexyz/store/src/StoreCore.sol"; -import { StoreSwitch } from "@latticexyz/store/src/StoreSwitch.sol"; - -import { EncodeArray } from "@latticexyz/store/src/tightcoder/EncodeArray.sol"; - -struct PointsResultData { - address player; - uint32 points; -} - -library PointsResult { - // Hex below is the result of `WorldResourceIdLib.encode({ namespace: "", name: "PointsResult", typeId: - // RESOURCE_OFFCHAIN_TABLE });` - ResourceId constant _tableId = ResourceId.wrap(0x6f740000000000000000000000000000506f696e7473526573756c7400000000); - - FieldLayout constant _fieldLayout = - FieldLayout.wrap(0x0018020014040000000000000000000000000000000000000000000000000000); - - // Hex-encoded key schema of (uint256, int16) - Schema constant _keySchema = Schema.wrap(0x002202001f210000000000000000000000000000000000000000000000000000); - // Hex-encoded value schema of (address, uint32) - Schema constant _valueSchema = Schema.wrap(0x0018020061030000000000000000000000000000000000000000000000000000); - - /** - * @notice Get the table's key field names. - * @return keyNames An array of strings with the names of key fields. - */ - function getKeyNames() internal pure returns (string[] memory keyNames) { - keyNames = new string[](2); - keyNames[0] = "id"; - keyNames[1] = "pointsId"; - } - - /** - * @notice Get the table's value field names. - * @return fieldNames An array of strings with the names of value fields. - */ - function getFieldNames() internal pure returns (string[] memory fieldNames) { - fieldNames = new string[](2); - fieldNames[0] = "player"; - fieldNames[1] = "points"; - } - - /** - * @notice Register the table with its config. - */ - function register() internal { - StoreSwitch.registerTable(_tableId, _fieldLayout, _keySchema, _valueSchema, getKeyNames(), getFieldNames()); - } - - /** - * @notice Register the table with its config. - */ - function _register() internal { - StoreCore.registerTable(_tableId, _fieldLayout, _keySchema, _valueSchema, getKeyNames(), getFieldNames()); - } - - /** - * @notice Set player. - */ - function setPlayer(uint256 id, int16 pointsId, address player) internal { - bytes32[] memory _keyTuple = new bytes32[](2); - _keyTuple[0] = bytes32(uint256(id)); - _keyTuple[1] = bytes32(uint256(int256(pointsId))); - - StoreSwitch.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((player)), _fieldLayout); - } - - /** - * @notice Set player. - */ - function _setPlayer(uint256 id, int16 pointsId, address player) internal { - bytes32[] memory _keyTuple = new bytes32[](2); - _keyTuple[0] = bytes32(uint256(id)); - _keyTuple[1] = bytes32(uint256(int256(pointsId))); - - StoreCore.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((player)), _fieldLayout); - } - - /** - * @notice Set points. - */ - function setPoints(uint256 id, int16 pointsId, uint32 points) internal { - bytes32[] memory _keyTuple = new bytes32[](2); - _keyTuple[0] = bytes32(uint256(id)); - _keyTuple[1] = bytes32(uint256(int256(pointsId))); - - StoreSwitch.setStaticField(_tableId, _keyTuple, 1, abi.encodePacked((points)), _fieldLayout); - } - - /** - * @notice Set points. - */ - function _setPoints(uint256 id, int16 pointsId, uint32 points) internal { - bytes32[] memory _keyTuple = new bytes32[](2); - _keyTuple[0] = bytes32(uint256(id)); - _keyTuple[1] = bytes32(uint256(int256(pointsId))); - - StoreCore.setStaticField(_tableId, _keyTuple, 1, abi.encodePacked((points)), _fieldLayout); - } - - /** - * @notice Set the full data using individual values. - */ - function set(uint256 id, int16 pointsId, address player, uint32 points) internal { - bytes memory _staticData = encodeStatic(player, points); - - EncodedLengths _encodedLengths; - bytes memory _dynamicData; - - bytes32[] memory _keyTuple = new bytes32[](2); - _keyTuple[0] = bytes32(uint256(id)); - _keyTuple[1] = bytes32(uint256(int256(pointsId))); - - StoreSwitch.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); - } - - /** - * @notice Set the full data using individual values. - */ - function _set(uint256 id, int16 pointsId, address player, uint32 points) internal { - bytes memory _staticData = encodeStatic(player, points); - - EncodedLengths _encodedLengths; - bytes memory _dynamicData; - - bytes32[] memory _keyTuple = new bytes32[](2); - _keyTuple[0] = bytes32(uint256(id)); - _keyTuple[1] = bytes32(uint256(int256(pointsId))); - - StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); - } - - /** - * @notice Set the full data using the data struct. - */ - function set(uint256 id, int16 pointsId, PointsResultData memory _table) internal { - bytes memory _staticData = encodeStatic(_table.player, _table.points); - - EncodedLengths _encodedLengths; - bytes memory _dynamicData; - - bytes32[] memory _keyTuple = new bytes32[](2); - _keyTuple[0] = bytes32(uint256(id)); - _keyTuple[1] = bytes32(uint256(int256(pointsId))); - - StoreSwitch.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); - } - - /** - * @notice Set the full data using the data struct. - */ - function _set(uint256 id, int16 pointsId, PointsResultData memory _table) internal { - bytes memory _staticData = encodeStatic(_table.player, _table.points); - - EncodedLengths _encodedLengths; - bytes memory _dynamicData; - - bytes32[] memory _keyTuple = new bytes32[](2); - _keyTuple[0] = bytes32(uint256(id)); - _keyTuple[1] = bytes32(uint256(int256(pointsId))); - - StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); - } - - /** - * @notice Decode the tightly packed blob of static data using this table's field layout. - */ - function decodeStatic(bytes memory _blob) internal pure returns (address player, uint32 points) { - player = (address(Bytes.getBytes20(_blob, 0))); - - points = (uint32(Bytes.getBytes4(_blob, 20))); - } - - /** - * @notice Decode the tightly packed blobs using this table's field layout. - * @param _staticData Tightly packed static fields. - * - * - */ - function decode( - bytes memory _staticData, - EncodedLengths, - bytes memory - ) - internal - pure - returns (PointsResultData memory _table) - { - (_table.player, _table.points) = decodeStatic(_staticData); - } - - /** - * @notice Delete all data for given keys. - */ - function deleteRecord(uint256 id, int16 pointsId) internal { - bytes32[] memory _keyTuple = new bytes32[](2); - _keyTuple[0] = bytes32(uint256(id)); - _keyTuple[1] = bytes32(uint256(int256(pointsId))); - - StoreSwitch.deleteRecord(_tableId, _keyTuple); - } - - /** - * @notice Delete all data for given keys. - */ - function _deleteRecord(uint256 id, int16 pointsId) internal { - bytes32[] memory _keyTuple = new bytes32[](2); - _keyTuple[0] = bytes32(uint256(id)); - _keyTuple[1] = bytes32(uint256(int256(pointsId))); - - StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout); - } - - /** - * @notice Tightly pack static (fixed length) data using this table's schema. - * @return The static data, encoded into a sequence of bytes. - */ - function encodeStatic(address player, uint32 points) internal pure returns (bytes memory) { - return abi.encodePacked(player, points); - } - - /** - * @notice Encode all of a record's fields. - * @return The static (fixed length) data, encoded into a sequence of bytes. - * @return The lengths of the dynamic fields (packed into a single bytes32 value). - * @return The dynamic (variable length) data, encoded into a sequence of bytes. - */ - function encode(address player, uint32 points) internal pure returns (bytes memory, EncodedLengths, bytes memory) { - bytes memory _staticData = encodeStatic(player, points); - - EncodedLengths _encodedLengths; - bytes memory _dynamicData; - - return (_staticData, _encodedLengths, _dynamicData); - } - - /** - * @notice Encode keys as a bytes32 array using this table's field layout. - */ - function encodeKeyTuple(uint256 id, int16 pointsId) internal pure returns (bytes32[] memory) { - bytes32[] memory _keyTuple = new bytes32[](2); - _keyTuple[0] = bytes32(uint256(id)); - _keyTuple[1] = bytes32(uint256(int256(pointsId))); - - return _keyTuple; - } -} diff --git a/src/codegen/tables/Spent.sol b/src/codegen/tables/Spent.sol deleted file mode 100644 index e710b00..0000000 --- a/src/codegen/tables/Spent.sol +++ /dev/null @@ -1,203 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity >=0.8.24; - -/* Autogenerated file. Do not edit manually. */ - -// Import store internals - -import { Bytes } from "@latticexyz/store/src/Bytes.sol"; - -import { EncodedLengths, EncodedLengthsLib } from "@latticexyz/store/src/EncodedLengths.sol"; -import { FieldLayout } from "@latticexyz/store/src/FieldLayout.sol"; -import { IStore } from "@latticexyz/store/src/IStore.sol"; -import { Memory } from "@latticexyz/store/src/Memory.sol"; - -import { ResourceId } from "@latticexyz/store/src/ResourceId.sol"; -import { Schema } from "@latticexyz/store/src/Schema.sol"; -import { SliceLib } from "@latticexyz/store/src/Slice.sol"; -import { StoreCore } from "@latticexyz/store/src/StoreCore.sol"; -import { StoreSwitch } from "@latticexyz/store/src/StoreSwitch.sol"; - -import { EncodeArray } from "@latticexyz/store/src/tightcoder/EncodeArray.sol"; - -library Spent { - // Hex below is the result of `WorldResourceIdLib.encode({ namespace: "", name: "Spent", typeId: RESOURCE_TABLE });` - ResourceId constant _tableId = ResourceId.wrap(0x746200000000000000000000000000005370656e740000000000000000000000); - - FieldLayout constant _fieldLayout = - FieldLayout.wrap(0x0020010020000000000000000000000000000000000000000000000000000000); - - // Hex-encoded key schema of (address) - Schema constant _keySchema = Schema.wrap(0x0014010061000000000000000000000000000000000000000000000000000000); - // Hex-encoded value schema of (uint256) - Schema constant _valueSchema = Schema.wrap(0x002001001f000000000000000000000000000000000000000000000000000000); - - /** - * @notice Get the table's key field names. - * @return keyNames An array of strings with the names of key fields. - */ - function getKeyNames() internal pure returns (string[] memory keyNames) { - keyNames = new string[](1); - keyNames[0] = "player"; - } - - /** - * @notice Get the table's value field names. - * @return fieldNames An array of strings with the names of value fields. - */ - function getFieldNames() internal pure returns (string[] memory fieldNames) { - fieldNames = new string[](1); - fieldNames[0] = "value"; - } - - /** - * @notice Register the table with its config. - */ - function register() internal { - StoreSwitch.registerTable(_tableId, _fieldLayout, _keySchema, _valueSchema, getKeyNames(), getFieldNames()); - } - - /** - * @notice Register the table with its config. - */ - function _register() internal { - StoreCore.registerTable(_tableId, _fieldLayout, _keySchema, _valueSchema, getKeyNames(), getFieldNames()); - } - - /** - * @notice Get value. - */ - function getValue(address player) internal view returns (uint256 value) { - bytes32[] memory _keyTuple = new bytes32[](1); - _keyTuple[0] = bytes32(uint256(uint160(player))); - - bytes32 _blob = StoreSwitch.getStaticField(_tableId, _keyTuple, 0, _fieldLayout); - return (uint256(bytes32(_blob))); - } - - /** - * @notice Get value. - */ - function _getValue(address player) internal view returns (uint256 value) { - bytes32[] memory _keyTuple = new bytes32[](1); - _keyTuple[0] = bytes32(uint256(uint160(player))); - - bytes32 _blob = StoreCore.getStaticField(_tableId, _keyTuple, 0, _fieldLayout); - return (uint256(bytes32(_blob))); - } - - /** - * @notice Get value. - */ - function get(address player) internal view returns (uint256 value) { - bytes32[] memory _keyTuple = new bytes32[](1); - _keyTuple[0] = bytes32(uint256(uint160(player))); - - bytes32 _blob = StoreSwitch.getStaticField(_tableId, _keyTuple, 0, _fieldLayout); - return (uint256(bytes32(_blob))); - } - - /** - * @notice Get value. - */ - function _get(address player) internal view returns (uint256 value) { - bytes32[] memory _keyTuple = new bytes32[](1); - _keyTuple[0] = bytes32(uint256(uint160(player))); - - bytes32 _blob = StoreCore.getStaticField(_tableId, _keyTuple, 0, _fieldLayout); - return (uint256(bytes32(_blob))); - } - - /** - * @notice Set value. - */ - function setValue(address player, uint256 value) internal { - bytes32[] memory _keyTuple = new bytes32[](1); - _keyTuple[0] = bytes32(uint256(uint160(player))); - - StoreSwitch.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); - } - - /** - * @notice Set value. - */ - function _setValue(address player, uint256 value) internal { - bytes32[] memory _keyTuple = new bytes32[](1); - _keyTuple[0] = bytes32(uint256(uint160(player))); - - StoreCore.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); - } - - /** - * @notice Set value. - */ - function set(address player, uint256 value) internal { - bytes32[] memory _keyTuple = new bytes32[](1); - _keyTuple[0] = bytes32(uint256(uint160(player))); - - StoreSwitch.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); - } - - /** - * @notice Set value. - */ - function _set(address player, uint256 value) internal { - bytes32[] memory _keyTuple = new bytes32[](1); - _keyTuple[0] = bytes32(uint256(uint160(player))); - - StoreCore.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); - } - - /** - * @notice Delete all data for given keys. - */ - function deleteRecord(address player) internal { - bytes32[] memory _keyTuple = new bytes32[](1); - _keyTuple[0] = bytes32(uint256(uint160(player))); - - StoreSwitch.deleteRecord(_tableId, _keyTuple); - } - - /** - * @notice Delete all data for given keys. - */ - function _deleteRecord(address player) internal { - bytes32[] memory _keyTuple = new bytes32[](1); - _keyTuple[0] = bytes32(uint256(uint160(player))); - - StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout); - } - - /** - * @notice Tightly pack static (fixed length) data using this table's schema. - * @return The static data, encoded into a sequence of bytes. - */ - function encodeStatic(uint256 value) internal pure returns (bytes memory) { - return abi.encodePacked(value); - } - - /** - * @notice Encode all of a record's fields. - * @return The static (fixed length) data, encoded into a sequence of bytes. - * @return The lengths of the dynamic fields (packed into a single bytes32 value). - * @return The dynamic (variable length) data, encoded into a sequence of bytes. - */ - function encode(uint256 value) internal pure returns (bytes memory, EncodedLengths, bytes memory) { - bytes memory _staticData = encodeStatic(value); - - EncodedLengths _encodedLengths; - bytes memory _dynamicData; - - return (_staticData, _encodedLengths, _dynamicData); - } - - /** - * @notice Encode keys as a bytes32 array using this table's field layout. - */ - function encodeKeyTuple(address player) internal pure returns (bytes32[] memory) { - bytes32[] memory _keyTuple = new bytes32[](1); - _keyTuple[0] = bytes32(uint256(uint160(player))); - - return _keyTuple; - } -} diff --git a/src/codegen/tables/TileLetter.sol b/src/codegen/tables/TileLetter.sol deleted file mode 100644 index 255a5f7..0000000 --- a/src/codegen/tables/TileLetter.sol +++ /dev/null @@ -1,219 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity >=0.8.24; - -/* Autogenerated file. Do not edit manually. */ - -// Import store internals - -import { Bytes } from "@latticexyz/store/src/Bytes.sol"; - -import { EncodedLengths, EncodedLengthsLib } from "@latticexyz/store/src/EncodedLengths.sol"; -import { FieldLayout } from "@latticexyz/store/src/FieldLayout.sol"; -import { IStore } from "@latticexyz/store/src/IStore.sol"; -import { Memory } from "@latticexyz/store/src/Memory.sol"; - -import { ResourceId } from "@latticexyz/store/src/ResourceId.sol"; -import { Schema } from "@latticexyz/store/src/Schema.sol"; -import { SliceLib } from "@latticexyz/store/src/Slice.sol"; -import { StoreCore } from "@latticexyz/store/src/StoreCore.sol"; -import { StoreSwitch } from "@latticexyz/store/src/StoreSwitch.sol"; - -import { EncodeArray } from "@latticexyz/store/src/tightcoder/EncodeArray.sol"; - -// Import user types -import { Letter } from "./../common.sol"; - -library TileLetter { - // Hex below is the result of `WorldResourceIdLib.encode({ namespace: "", name: "TileLetter", typeId: RESOURCE_TABLE - // });` - ResourceId constant _tableId = ResourceId.wrap(0x7462000000000000000000000000000054696c654c6574746572000000000000); - - FieldLayout constant _fieldLayout = - FieldLayout.wrap(0x0001010001000000000000000000000000000000000000000000000000000000); - - // Hex-encoded key schema of (int32, int32) - Schema constant _keySchema = Schema.wrap(0x0008020023230000000000000000000000000000000000000000000000000000); - // Hex-encoded value schema of (uint8) - Schema constant _valueSchema = Schema.wrap(0x0001010000000000000000000000000000000000000000000000000000000000); - - /** - * @notice Get the table's key field names. - * @return keyNames An array of strings with the names of key fields. - */ - function getKeyNames() internal pure returns (string[] memory keyNames) { - keyNames = new string[](2); - keyNames[0] = "x"; - keyNames[1] = "y"; - } - - /** - * @notice Get the table's value field names. - * @return fieldNames An array of strings with the names of value fields. - */ - function getFieldNames() internal pure returns (string[] memory fieldNames) { - fieldNames = new string[](1); - fieldNames[0] = "value"; - } - - /** - * @notice Register the table with its config. - */ - function register() internal { - StoreSwitch.registerTable(_tableId, _fieldLayout, _keySchema, _valueSchema, getKeyNames(), getFieldNames()); - } - - /** - * @notice Register the table with its config. - */ - function _register() internal { - StoreCore.registerTable(_tableId, _fieldLayout, _keySchema, _valueSchema, getKeyNames(), getFieldNames()); - } - - /** - * @notice Get value. - */ - function getValue(int32 x, int32 y) internal view returns (Letter value) { - bytes32[] memory _keyTuple = new bytes32[](2); - _keyTuple[0] = bytes32(uint256(int256(x))); - _keyTuple[1] = bytes32(uint256(int256(y))); - - bytes32 _blob = StoreSwitch.getStaticField(_tableId, _keyTuple, 0, _fieldLayout); - return Letter(uint8(bytes1(_blob))); - } - - /** - * @notice Get value. - */ - function _getValue(int32 x, int32 y) internal view returns (Letter value) { - bytes32[] memory _keyTuple = new bytes32[](2); - _keyTuple[0] = bytes32(uint256(int256(x))); - _keyTuple[1] = bytes32(uint256(int256(y))); - - bytes32 _blob = StoreCore.getStaticField(_tableId, _keyTuple, 0, _fieldLayout); - return Letter(uint8(bytes1(_blob))); - } - - /** - * @notice Get value. - */ - function get(int32 x, int32 y) internal view returns (Letter value) { - bytes32[] memory _keyTuple = new bytes32[](2); - _keyTuple[0] = bytes32(uint256(int256(x))); - _keyTuple[1] = bytes32(uint256(int256(y))); - - bytes32 _blob = StoreSwitch.getStaticField(_tableId, _keyTuple, 0, _fieldLayout); - return Letter(uint8(bytes1(_blob))); - } - - /** - * @notice Get value. - */ - function _get(int32 x, int32 y) internal view returns (Letter value) { - bytes32[] memory _keyTuple = new bytes32[](2); - _keyTuple[0] = bytes32(uint256(int256(x))); - _keyTuple[1] = bytes32(uint256(int256(y))); - - bytes32 _blob = StoreCore.getStaticField(_tableId, _keyTuple, 0, _fieldLayout); - return Letter(uint8(bytes1(_blob))); - } - - /** - * @notice Set value. - */ - function setValue(int32 x, int32 y, Letter value) internal { - bytes32[] memory _keyTuple = new bytes32[](2); - _keyTuple[0] = bytes32(uint256(int256(x))); - _keyTuple[1] = bytes32(uint256(int256(y))); - - StoreSwitch.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked(uint8(value)), _fieldLayout); - } - - /** - * @notice Set value. - */ - function _setValue(int32 x, int32 y, Letter value) internal { - bytes32[] memory _keyTuple = new bytes32[](2); - _keyTuple[0] = bytes32(uint256(int256(x))); - _keyTuple[1] = bytes32(uint256(int256(y))); - - StoreCore.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked(uint8(value)), _fieldLayout); - } - - /** - * @notice Set value. - */ - function set(int32 x, int32 y, Letter value) internal { - bytes32[] memory _keyTuple = new bytes32[](2); - _keyTuple[0] = bytes32(uint256(int256(x))); - _keyTuple[1] = bytes32(uint256(int256(y))); - - StoreSwitch.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked(uint8(value)), _fieldLayout); - } - - /** - * @notice Set value. - */ - function _set(int32 x, int32 y, Letter value) internal { - bytes32[] memory _keyTuple = new bytes32[](2); - _keyTuple[0] = bytes32(uint256(int256(x))); - _keyTuple[1] = bytes32(uint256(int256(y))); - - StoreCore.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked(uint8(value)), _fieldLayout); - } - - /** - * @notice Delete all data for given keys. - */ - function deleteRecord(int32 x, int32 y) internal { - bytes32[] memory _keyTuple = new bytes32[](2); - _keyTuple[0] = bytes32(uint256(int256(x))); - _keyTuple[1] = bytes32(uint256(int256(y))); - - StoreSwitch.deleteRecord(_tableId, _keyTuple); - } - - /** - * @notice Delete all data for given keys. - */ - function _deleteRecord(int32 x, int32 y) internal { - bytes32[] memory _keyTuple = new bytes32[](2); - _keyTuple[0] = bytes32(uint256(int256(x))); - _keyTuple[1] = bytes32(uint256(int256(y))); - - StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout); - } - - /** - * @notice Tightly pack static (fixed length) data using this table's schema. - * @return The static data, encoded into a sequence of bytes. - */ - function encodeStatic(Letter value) internal pure returns (bytes memory) { - return abi.encodePacked(value); - } - - /** - * @notice Encode all of a record's fields. - * @return The static (fixed length) data, encoded into a sequence of bytes. - * @return The lengths of the dynamic fields (packed into a single bytes32 value). - * @return The dynamic (variable length) data, encoded into a sequence of bytes. - */ - function encode(Letter value) internal pure returns (bytes memory, EncodedLengths, bytes memory) { - bytes memory _staticData = encodeStatic(value); - - EncodedLengths _encodedLengths; - bytes memory _dynamicData; - - return (_staticData, _encodedLengths, _dynamicData); - } - - /** - * @notice Encode keys as a bytes32 array using this table's field layout. - */ - function encodeKeyTuple(int32 x, int32 y) internal pure returns (bytes32[] memory) { - bytes32[] memory _keyTuple = new bytes32[](2); - _keyTuple[0] = bytes32(uint256(int256(x))); - _keyTuple[1] = bytes32(uint256(int256(y))); - - return _keyTuple; - } -} diff --git a/src/codegen/tables/TilePlayer.sol b/src/codegen/tables/TilePlayer.sol deleted file mode 100644 index 4bca3c3..0000000 --- a/src/codegen/tables/TilePlayer.sol +++ /dev/null @@ -1,216 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity >=0.8.24; - -/* Autogenerated file. Do not edit manually. */ - -// Import store internals - -import { Bytes } from "@latticexyz/store/src/Bytes.sol"; - -import { EncodedLengths, EncodedLengthsLib } from "@latticexyz/store/src/EncodedLengths.sol"; -import { FieldLayout } from "@latticexyz/store/src/FieldLayout.sol"; -import { IStore } from "@latticexyz/store/src/IStore.sol"; -import { Memory } from "@latticexyz/store/src/Memory.sol"; - -import { ResourceId } from "@latticexyz/store/src/ResourceId.sol"; -import { Schema } from "@latticexyz/store/src/Schema.sol"; -import { SliceLib } from "@latticexyz/store/src/Slice.sol"; -import { StoreCore } from "@latticexyz/store/src/StoreCore.sol"; -import { StoreSwitch } from "@latticexyz/store/src/StoreSwitch.sol"; - -import { EncodeArray } from "@latticexyz/store/src/tightcoder/EncodeArray.sol"; - -library TilePlayer { - // Hex below is the result of `WorldResourceIdLib.encode({ namespace: "", name: "TilePlayer", typeId: RESOURCE_TABLE - // });` - ResourceId constant _tableId = ResourceId.wrap(0x7462000000000000000000000000000054696c65506c61796572000000000000); - - FieldLayout constant _fieldLayout = - FieldLayout.wrap(0x0014010014000000000000000000000000000000000000000000000000000000); - - // Hex-encoded key schema of (int32, int32) - Schema constant _keySchema = Schema.wrap(0x0008020023230000000000000000000000000000000000000000000000000000); - // Hex-encoded value schema of (address) - Schema constant _valueSchema = Schema.wrap(0x0014010061000000000000000000000000000000000000000000000000000000); - - /** - * @notice Get the table's key field names. - * @return keyNames An array of strings with the names of key fields. - */ - function getKeyNames() internal pure returns (string[] memory keyNames) { - keyNames = new string[](2); - keyNames[0] = "x"; - keyNames[1] = "y"; - } - - /** - * @notice Get the table's value field names. - * @return fieldNames An array of strings with the names of value fields. - */ - function getFieldNames() internal pure returns (string[] memory fieldNames) { - fieldNames = new string[](1); - fieldNames[0] = "value"; - } - - /** - * @notice Register the table with its config. - */ - function register() internal { - StoreSwitch.registerTable(_tableId, _fieldLayout, _keySchema, _valueSchema, getKeyNames(), getFieldNames()); - } - - /** - * @notice Register the table with its config. - */ - function _register() internal { - StoreCore.registerTable(_tableId, _fieldLayout, _keySchema, _valueSchema, getKeyNames(), getFieldNames()); - } - - /** - * @notice Get value. - */ - function getValue(int32 x, int32 y) internal view returns (address value) { - bytes32[] memory _keyTuple = new bytes32[](2); - _keyTuple[0] = bytes32(uint256(int256(x))); - _keyTuple[1] = bytes32(uint256(int256(y))); - - bytes32 _blob = StoreSwitch.getStaticField(_tableId, _keyTuple, 0, _fieldLayout); - return (address(bytes20(_blob))); - } - - /** - * @notice Get value. - */ - function _getValue(int32 x, int32 y) internal view returns (address value) { - bytes32[] memory _keyTuple = new bytes32[](2); - _keyTuple[0] = bytes32(uint256(int256(x))); - _keyTuple[1] = bytes32(uint256(int256(y))); - - bytes32 _blob = StoreCore.getStaticField(_tableId, _keyTuple, 0, _fieldLayout); - return (address(bytes20(_blob))); - } - - /** - * @notice Get value. - */ - function get(int32 x, int32 y) internal view returns (address value) { - bytes32[] memory _keyTuple = new bytes32[](2); - _keyTuple[0] = bytes32(uint256(int256(x))); - _keyTuple[1] = bytes32(uint256(int256(y))); - - bytes32 _blob = StoreSwitch.getStaticField(_tableId, _keyTuple, 0, _fieldLayout); - return (address(bytes20(_blob))); - } - - /** - * @notice Get value. - */ - function _get(int32 x, int32 y) internal view returns (address value) { - bytes32[] memory _keyTuple = new bytes32[](2); - _keyTuple[0] = bytes32(uint256(int256(x))); - _keyTuple[1] = bytes32(uint256(int256(y))); - - bytes32 _blob = StoreCore.getStaticField(_tableId, _keyTuple, 0, _fieldLayout); - return (address(bytes20(_blob))); - } - - /** - * @notice Set value. - */ - function setValue(int32 x, int32 y, address value) internal { - bytes32[] memory _keyTuple = new bytes32[](2); - _keyTuple[0] = bytes32(uint256(int256(x))); - _keyTuple[1] = bytes32(uint256(int256(y))); - - StoreSwitch.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); - } - - /** - * @notice Set value. - */ - function _setValue(int32 x, int32 y, address value) internal { - bytes32[] memory _keyTuple = new bytes32[](2); - _keyTuple[0] = bytes32(uint256(int256(x))); - _keyTuple[1] = bytes32(uint256(int256(y))); - - StoreCore.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); - } - - /** - * @notice Set value. - */ - function set(int32 x, int32 y, address value) internal { - bytes32[] memory _keyTuple = new bytes32[](2); - _keyTuple[0] = bytes32(uint256(int256(x))); - _keyTuple[1] = bytes32(uint256(int256(y))); - - StoreSwitch.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); - } - - /** - * @notice Set value. - */ - function _set(int32 x, int32 y, address value) internal { - bytes32[] memory _keyTuple = new bytes32[](2); - _keyTuple[0] = bytes32(uint256(int256(x))); - _keyTuple[1] = bytes32(uint256(int256(y))); - - StoreCore.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); - } - - /** - * @notice Delete all data for given keys. - */ - function deleteRecord(int32 x, int32 y) internal { - bytes32[] memory _keyTuple = new bytes32[](2); - _keyTuple[0] = bytes32(uint256(int256(x))); - _keyTuple[1] = bytes32(uint256(int256(y))); - - StoreSwitch.deleteRecord(_tableId, _keyTuple); - } - - /** - * @notice Delete all data for given keys. - */ - function _deleteRecord(int32 x, int32 y) internal { - bytes32[] memory _keyTuple = new bytes32[](2); - _keyTuple[0] = bytes32(uint256(int256(x))); - _keyTuple[1] = bytes32(uint256(int256(y))); - - StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout); - } - - /** - * @notice Tightly pack static (fixed length) data using this table's schema. - * @return The static data, encoded into a sequence of bytes. - */ - function encodeStatic(address value) internal pure returns (bytes memory) { - return abi.encodePacked(value); - } - - /** - * @notice Encode all of a record's fields. - * @return The static (fixed length) data, encoded into a sequence of bytes. - * @return The lengths of the dynamic fields (packed into a single bytes32 value). - * @return The dynamic (variable length) data, encoded into a sequence of bytes. - */ - function encode(address value) internal pure returns (bytes memory, EncodedLengths, bytes memory) { - bytes memory _staticData = encodeStatic(value); - - EncodedLengths _encodedLengths; - bytes memory _dynamicData; - - return (_staticData, _encodedLengths, _dynamicData); - } - - /** - * @notice Encode keys as a bytes32 array using this table's field layout. - */ - function encodeKeyTuple(int32 x, int32 y) internal pure returns (bytes32[] memory) { - bytes32[] memory _keyTuple = new bytes32[](2); - _keyTuple[0] = bytes32(uint256(int256(x))); - _keyTuple[1] = bytes32(uint256(int256(y))); - - return _keyTuple; - } -} diff --git a/src/codegen/tables/Treasury.sol b/src/codegen/tables/Treasury.sol deleted file mode 100644 index 49d16e6..0000000 --- a/src/codegen/tables/Treasury.sol +++ /dev/null @@ -1,192 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity >=0.8.24; - -/* Autogenerated file. Do not edit manually. */ - -// Import store internals - -import { Bytes } from "@latticexyz/store/src/Bytes.sol"; - -import { EncodedLengths, EncodedLengthsLib } from "@latticexyz/store/src/EncodedLengths.sol"; -import { FieldLayout } from "@latticexyz/store/src/FieldLayout.sol"; -import { IStore } from "@latticexyz/store/src/IStore.sol"; -import { Memory } from "@latticexyz/store/src/Memory.sol"; - -import { ResourceId } from "@latticexyz/store/src/ResourceId.sol"; -import { Schema } from "@latticexyz/store/src/Schema.sol"; -import { SliceLib } from "@latticexyz/store/src/Slice.sol"; -import { StoreCore } from "@latticexyz/store/src/StoreCore.sol"; -import { StoreSwitch } from "@latticexyz/store/src/StoreSwitch.sol"; - -import { EncodeArray } from "@latticexyz/store/src/tightcoder/EncodeArray.sol"; - -library Treasury { - // Hex below is the result of `WorldResourceIdLib.encode({ namespace: "", name: "Treasury", typeId: RESOURCE_TABLE - // });` - ResourceId constant _tableId = ResourceId.wrap(0x7462000000000000000000000000000054726561737572790000000000000000); - - FieldLayout constant _fieldLayout = - FieldLayout.wrap(0x0020010020000000000000000000000000000000000000000000000000000000); - - // Hex-encoded key schema of () - Schema constant _keySchema = Schema.wrap(0x0000000000000000000000000000000000000000000000000000000000000000); - // Hex-encoded value schema of (uint256) - Schema constant _valueSchema = Schema.wrap(0x002001001f000000000000000000000000000000000000000000000000000000); - - /** - * @notice Get the table's key field names. - * @return keyNames An array of strings with the names of key fields. - */ - function getKeyNames() internal pure returns (string[] memory keyNames) { - keyNames = new string[](0); - } - - /** - * @notice Get the table's value field names. - * @return fieldNames An array of strings with the names of value fields. - */ - function getFieldNames() internal pure returns (string[] memory fieldNames) { - fieldNames = new string[](1); - fieldNames[0] = "value"; - } - - /** - * @notice Register the table with its config. - */ - function register() internal { - StoreSwitch.registerTable(_tableId, _fieldLayout, _keySchema, _valueSchema, getKeyNames(), getFieldNames()); - } - - /** - * @notice Register the table with its config. - */ - function _register() internal { - StoreCore.registerTable(_tableId, _fieldLayout, _keySchema, _valueSchema, getKeyNames(), getFieldNames()); - } - - /** - * @notice Get value. - */ - function getValue() internal view returns (uint256 value) { - bytes32[] memory _keyTuple = new bytes32[](0); - - bytes32 _blob = StoreSwitch.getStaticField(_tableId, _keyTuple, 0, _fieldLayout); - return (uint256(bytes32(_blob))); - } - - /** - * @notice Get value. - */ - function _getValue() internal view returns (uint256 value) { - bytes32[] memory _keyTuple = new bytes32[](0); - - bytes32 _blob = StoreCore.getStaticField(_tableId, _keyTuple, 0, _fieldLayout); - return (uint256(bytes32(_blob))); - } - - /** - * @notice Get value. - */ - function get() internal view returns (uint256 value) { - bytes32[] memory _keyTuple = new bytes32[](0); - - bytes32 _blob = StoreSwitch.getStaticField(_tableId, _keyTuple, 0, _fieldLayout); - return (uint256(bytes32(_blob))); - } - - /** - * @notice Get value. - */ - function _get() internal view returns (uint256 value) { - bytes32[] memory _keyTuple = new bytes32[](0); - - bytes32 _blob = StoreCore.getStaticField(_tableId, _keyTuple, 0, _fieldLayout); - return (uint256(bytes32(_blob))); - } - - /** - * @notice Set value. - */ - function setValue(uint256 value) internal { - bytes32[] memory _keyTuple = new bytes32[](0); - - StoreSwitch.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); - } - - /** - * @notice Set value. - */ - function _setValue(uint256 value) internal { - bytes32[] memory _keyTuple = new bytes32[](0); - - StoreCore.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); - } - - /** - * @notice Set value. - */ - function set(uint256 value) internal { - bytes32[] memory _keyTuple = new bytes32[](0); - - StoreSwitch.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); - } - - /** - * @notice Set value. - */ - function _set(uint256 value) internal { - bytes32[] memory _keyTuple = new bytes32[](0); - - StoreCore.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); - } - - /** - * @notice Delete all data for given keys. - */ - function deleteRecord() internal { - bytes32[] memory _keyTuple = new bytes32[](0); - - StoreSwitch.deleteRecord(_tableId, _keyTuple); - } - - /** - * @notice Delete all data for given keys. - */ - function _deleteRecord() internal { - bytes32[] memory _keyTuple = new bytes32[](0); - - StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout); - } - - /** - * @notice Tightly pack static (fixed length) data using this table's schema. - * @return The static data, encoded into a sequence of bytes. - */ - function encodeStatic(uint256 value) internal pure returns (bytes memory) { - return abi.encodePacked(value); - } - - /** - * @notice Encode all of a record's fields. - * @return The static (fixed length) data, encoded into a sequence of bytes. - * @return The lengths of the dynamic fields (packed into a single bytes32 value). - * @return The dynamic (variable length) data, encoded into a sequence of bytes. - */ - function encode(uint256 value) internal pure returns (bytes memory, EncodedLengths, bytes memory) { - bytes memory _staticData = encodeStatic(value); - - EncodedLengths _encodedLengths; - bytes memory _dynamicData; - - return (_staticData, _encodedLengths, _dynamicData); - } - - /** - * @notice Encode keys as a bytes32 array using this table's field layout. - */ - function encodeKeyTuple() internal pure returns (bytes32[] memory) { - bytes32[] memory _keyTuple = new bytes32[](0); - - return _keyTuple; - } -} diff --git a/src/codegen/tables/VRGDAConfig.sol b/src/codegen/tables/VRGDAConfig.sol deleted file mode 100644 index 32fbf69..0000000 --- a/src/codegen/tables/VRGDAConfig.sol +++ /dev/null @@ -1,472 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity >=0.8.24; - -/* Autogenerated file. Do not edit manually. */ - -// Import store internals - -import { Bytes } from "@latticexyz/store/src/Bytes.sol"; - -import { EncodedLengths, EncodedLengthsLib } from "@latticexyz/store/src/EncodedLengths.sol"; -import { FieldLayout } from "@latticexyz/store/src/FieldLayout.sol"; -import { IStore } from "@latticexyz/store/src/IStore.sol"; -import { Memory } from "@latticexyz/store/src/Memory.sol"; - -import { ResourceId } from "@latticexyz/store/src/ResourceId.sol"; -import { Schema } from "@latticexyz/store/src/Schema.sol"; -import { SliceLib } from "@latticexyz/store/src/Slice.sol"; -import { StoreCore } from "@latticexyz/store/src/StoreCore.sol"; -import { StoreSwitch } from "@latticexyz/store/src/StoreSwitch.sol"; - -import { EncodeArray } from "@latticexyz/store/src/tightcoder/EncodeArray.sol"; - -struct VRGDAConfigData { - uint256 startTime; - int256 targetPrice; - int256 priceDecay; - int256 perDayInitial; - int256 power; -} - -library VRGDAConfig { - // Hex below is the result of `WorldResourceIdLib.encode({ namespace: "", name: "VRGDAConfig", typeId: - // RESOURCE_TABLE });` - ResourceId constant _tableId = ResourceId.wrap(0x746200000000000000000000000000005652474441436f6e6669670000000000); - - FieldLayout constant _fieldLayout = - FieldLayout.wrap(0x00a0050020202020200000000000000000000000000000000000000000000000); - - // Hex-encoded key schema of () - Schema constant _keySchema = Schema.wrap(0x0000000000000000000000000000000000000000000000000000000000000000); - // Hex-encoded value schema of (uint256, int256, int256, int256, int256) - Schema constant _valueSchema = Schema.wrap(0x00a005001f3f3f3f3f0000000000000000000000000000000000000000000000); - - /** - * @notice Get the table's key field names. - * @return keyNames An array of strings with the names of key fields. - */ - function getKeyNames() internal pure returns (string[] memory keyNames) { - keyNames = new string[](0); - } - - /** - * @notice Get the table's value field names. - * @return fieldNames An array of strings with the names of value fields. - */ - function getFieldNames() internal pure returns (string[] memory fieldNames) { - fieldNames = new string[](5); - fieldNames[0] = "startTime"; - fieldNames[1] = "targetPrice"; - fieldNames[2] = "priceDecay"; - fieldNames[3] = "perDayInitial"; - fieldNames[4] = "power"; - } - - /** - * @notice Register the table with its config. - */ - function register() internal { - StoreSwitch.registerTable(_tableId, _fieldLayout, _keySchema, _valueSchema, getKeyNames(), getFieldNames()); - } - - /** - * @notice Register the table with its config. - */ - function _register() internal { - StoreCore.registerTable(_tableId, _fieldLayout, _keySchema, _valueSchema, getKeyNames(), getFieldNames()); - } - - /** - * @notice Get startTime. - */ - function getStartTime() internal view returns (uint256 startTime) { - bytes32[] memory _keyTuple = new bytes32[](0); - - bytes32 _blob = StoreSwitch.getStaticField(_tableId, _keyTuple, 0, _fieldLayout); - return (uint256(bytes32(_blob))); - } - - /** - * @notice Get startTime. - */ - function _getStartTime() internal view returns (uint256 startTime) { - bytes32[] memory _keyTuple = new bytes32[](0); - - bytes32 _blob = StoreCore.getStaticField(_tableId, _keyTuple, 0, _fieldLayout); - return (uint256(bytes32(_blob))); - } - - /** - * @notice Set startTime. - */ - function setStartTime(uint256 startTime) internal { - bytes32[] memory _keyTuple = new bytes32[](0); - - StoreSwitch.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((startTime)), _fieldLayout); - } - - /** - * @notice Set startTime. - */ - function _setStartTime(uint256 startTime) internal { - bytes32[] memory _keyTuple = new bytes32[](0); - - StoreCore.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((startTime)), _fieldLayout); - } - - /** - * @notice Get targetPrice. - */ - function getTargetPrice() internal view returns (int256 targetPrice) { - bytes32[] memory _keyTuple = new bytes32[](0); - - bytes32 _blob = StoreSwitch.getStaticField(_tableId, _keyTuple, 1, _fieldLayout); - return (int256(uint256(bytes32(_blob)))); - } - - /** - * @notice Get targetPrice. - */ - function _getTargetPrice() internal view returns (int256 targetPrice) { - bytes32[] memory _keyTuple = new bytes32[](0); - - bytes32 _blob = StoreCore.getStaticField(_tableId, _keyTuple, 1, _fieldLayout); - return (int256(uint256(bytes32(_blob)))); - } - - /** - * @notice Set targetPrice. - */ - function setTargetPrice(int256 targetPrice) internal { - bytes32[] memory _keyTuple = new bytes32[](0); - - StoreSwitch.setStaticField(_tableId, _keyTuple, 1, abi.encodePacked((targetPrice)), _fieldLayout); - } - - /** - * @notice Set targetPrice. - */ - function _setTargetPrice(int256 targetPrice) internal { - bytes32[] memory _keyTuple = new bytes32[](0); - - StoreCore.setStaticField(_tableId, _keyTuple, 1, abi.encodePacked((targetPrice)), _fieldLayout); - } - - /** - * @notice Get priceDecay. - */ - function getPriceDecay() internal view returns (int256 priceDecay) { - bytes32[] memory _keyTuple = new bytes32[](0); - - bytes32 _blob = StoreSwitch.getStaticField(_tableId, _keyTuple, 2, _fieldLayout); - return (int256(uint256(bytes32(_blob)))); - } - - /** - * @notice Get priceDecay. - */ - function _getPriceDecay() internal view returns (int256 priceDecay) { - bytes32[] memory _keyTuple = new bytes32[](0); - - bytes32 _blob = StoreCore.getStaticField(_tableId, _keyTuple, 2, _fieldLayout); - return (int256(uint256(bytes32(_blob)))); - } - - /** - * @notice Set priceDecay. - */ - function setPriceDecay(int256 priceDecay) internal { - bytes32[] memory _keyTuple = new bytes32[](0); - - StoreSwitch.setStaticField(_tableId, _keyTuple, 2, abi.encodePacked((priceDecay)), _fieldLayout); - } - - /** - * @notice Set priceDecay. - */ - function _setPriceDecay(int256 priceDecay) internal { - bytes32[] memory _keyTuple = new bytes32[](0); - - StoreCore.setStaticField(_tableId, _keyTuple, 2, abi.encodePacked((priceDecay)), _fieldLayout); - } - - /** - * @notice Get perDayInitial. - */ - function getPerDayInitial() internal view returns (int256 perDayInitial) { - bytes32[] memory _keyTuple = new bytes32[](0); - - bytes32 _blob = StoreSwitch.getStaticField(_tableId, _keyTuple, 3, _fieldLayout); - return (int256(uint256(bytes32(_blob)))); - } - - /** - * @notice Get perDayInitial. - */ - function _getPerDayInitial() internal view returns (int256 perDayInitial) { - bytes32[] memory _keyTuple = new bytes32[](0); - - bytes32 _blob = StoreCore.getStaticField(_tableId, _keyTuple, 3, _fieldLayout); - return (int256(uint256(bytes32(_blob)))); - } - - /** - * @notice Set perDayInitial. - */ - function setPerDayInitial(int256 perDayInitial) internal { - bytes32[] memory _keyTuple = new bytes32[](0); - - StoreSwitch.setStaticField(_tableId, _keyTuple, 3, abi.encodePacked((perDayInitial)), _fieldLayout); - } - - /** - * @notice Set perDayInitial. - */ - function _setPerDayInitial(int256 perDayInitial) internal { - bytes32[] memory _keyTuple = new bytes32[](0); - - StoreCore.setStaticField(_tableId, _keyTuple, 3, abi.encodePacked((perDayInitial)), _fieldLayout); - } - - /** - * @notice Get power. - */ - function getPower() internal view returns (int256 power) { - bytes32[] memory _keyTuple = new bytes32[](0); - - bytes32 _blob = StoreSwitch.getStaticField(_tableId, _keyTuple, 4, _fieldLayout); - return (int256(uint256(bytes32(_blob)))); - } - - /** - * @notice Get power. - */ - function _getPower() internal view returns (int256 power) { - bytes32[] memory _keyTuple = new bytes32[](0); - - bytes32 _blob = StoreCore.getStaticField(_tableId, _keyTuple, 4, _fieldLayout); - return (int256(uint256(bytes32(_blob)))); - } - - /** - * @notice Set power. - */ - function setPower(int256 power) internal { - bytes32[] memory _keyTuple = new bytes32[](0); - - StoreSwitch.setStaticField(_tableId, _keyTuple, 4, abi.encodePacked((power)), _fieldLayout); - } - - /** - * @notice Set power. - */ - function _setPower(int256 power) internal { - bytes32[] memory _keyTuple = new bytes32[](0); - - StoreCore.setStaticField(_tableId, _keyTuple, 4, abi.encodePacked((power)), _fieldLayout); - } - - /** - * @notice Get the full data. - */ - function get() internal view returns (VRGDAConfigData memory _table) { - bytes32[] memory _keyTuple = new bytes32[](0); - - (bytes memory _staticData, EncodedLengths _encodedLengths, bytes memory _dynamicData) = - StoreSwitch.getRecord(_tableId, _keyTuple, _fieldLayout); - return decode(_staticData, _encodedLengths, _dynamicData); - } - - /** - * @notice Get the full data. - */ - function _get() internal view returns (VRGDAConfigData memory _table) { - bytes32[] memory _keyTuple = new bytes32[](0); - - (bytes memory _staticData, EncodedLengths _encodedLengths, bytes memory _dynamicData) = - StoreCore.getRecord(_tableId, _keyTuple, _fieldLayout); - return decode(_staticData, _encodedLengths, _dynamicData); - } - - /** - * @notice Set the full data using individual values. - */ - function set( - uint256 startTime, - int256 targetPrice, - int256 priceDecay, - int256 perDayInitial, - int256 power - ) - internal - { - bytes memory _staticData = encodeStatic(startTime, targetPrice, priceDecay, perDayInitial, power); - - EncodedLengths _encodedLengths; - bytes memory _dynamicData; - - bytes32[] memory _keyTuple = new bytes32[](0); - - StoreSwitch.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); - } - - /** - * @notice Set the full data using individual values. - */ - function _set( - uint256 startTime, - int256 targetPrice, - int256 priceDecay, - int256 perDayInitial, - int256 power - ) - internal - { - bytes memory _staticData = encodeStatic(startTime, targetPrice, priceDecay, perDayInitial, power); - - EncodedLengths _encodedLengths; - bytes memory _dynamicData; - - bytes32[] memory _keyTuple = new bytes32[](0); - - StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); - } - - /** - * @notice Set the full data using the data struct. - */ - function set(VRGDAConfigData memory _table) internal { - bytes memory _staticData = - encodeStatic(_table.startTime, _table.targetPrice, _table.priceDecay, _table.perDayInitial, _table.power); - - EncodedLengths _encodedLengths; - bytes memory _dynamicData; - - bytes32[] memory _keyTuple = new bytes32[](0); - - StoreSwitch.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); - } - - /** - * @notice Set the full data using the data struct. - */ - function _set(VRGDAConfigData memory _table) internal { - bytes memory _staticData = - encodeStatic(_table.startTime, _table.targetPrice, _table.priceDecay, _table.perDayInitial, _table.power); - - EncodedLengths _encodedLengths; - bytes memory _dynamicData; - - bytes32[] memory _keyTuple = new bytes32[](0); - - StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); - } - - /** - * @notice Decode the tightly packed blob of static data using this table's field layout. - */ - function decodeStatic(bytes memory _blob) - internal - pure - returns (uint256 startTime, int256 targetPrice, int256 priceDecay, int256 perDayInitial, int256 power) - { - startTime = (uint256(Bytes.getBytes32(_blob, 0))); - - targetPrice = (int256(uint256(Bytes.getBytes32(_blob, 32)))); - - priceDecay = (int256(uint256(Bytes.getBytes32(_blob, 64)))); - - perDayInitial = (int256(uint256(Bytes.getBytes32(_blob, 96)))); - - power = (int256(uint256(Bytes.getBytes32(_blob, 128)))); - } - - /** - * @notice Decode the tightly packed blobs using this table's field layout. - * @param _staticData Tightly packed static fields. - * - * - */ - function decode( - bytes memory _staticData, - EncodedLengths, - bytes memory - ) - internal - pure - returns (VRGDAConfigData memory _table) - { - (_table.startTime, _table.targetPrice, _table.priceDecay, _table.perDayInitial, _table.power) = - decodeStatic(_staticData); - } - - /** - * @notice Delete all data for given keys. - */ - function deleteRecord() internal { - bytes32[] memory _keyTuple = new bytes32[](0); - - StoreSwitch.deleteRecord(_tableId, _keyTuple); - } - - /** - * @notice Delete all data for given keys. - */ - function _deleteRecord() internal { - bytes32[] memory _keyTuple = new bytes32[](0); - - StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout); - } - - /** - * @notice Tightly pack static (fixed length) data using this table's schema. - * @return The static data, encoded into a sequence of bytes. - */ - function encodeStatic( - uint256 startTime, - int256 targetPrice, - int256 priceDecay, - int256 perDayInitial, - int256 power - ) - internal - pure - returns (bytes memory) - { - return abi.encodePacked(startTime, targetPrice, priceDecay, perDayInitial, power); - } - - /** - * @notice Encode all of a record's fields. - * @return The static (fixed length) data, encoded into a sequence of bytes. - * @return The lengths of the dynamic fields (packed into a single bytes32 value). - * @return The dynamic (variable length) data, encoded into a sequence of bytes. - */ - function encode( - uint256 startTime, - int256 targetPrice, - int256 priceDecay, - int256 perDayInitial, - int256 power - ) - internal - pure - returns (bytes memory, EncodedLengths, bytes memory) - { - bytes memory _staticData = encodeStatic(startTime, targetPrice, priceDecay, perDayInitial, power); - - EncodedLengths _encodedLengths; - bytes memory _dynamicData; - - return (_staticData, _encodedLengths, _dynamicData); - } - - /** - * @notice Encode keys as a bytes32 array using this table's field layout. - */ - function encodeKeyTuple() internal pure returns (bytes32[] memory) { - bytes32[] memory _keyTuple = new bytes32[](0); - - return _keyTuple; - } -} diff --git a/src/systems/DonateSystem.sol b/src/systems/DonateSystem.sol deleted file mode 100644 index 283cb5e..0000000 --- a/src/systems/DonateSystem.sol +++ /dev/null @@ -1,16 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity >=0.8.0; - -import { System } from "@latticexyz/world/src/System.sol"; -import { CannotPlay } from "common/Errors.sol"; -import { LibGame } from "libraries/LibGame.sol"; -import { LibTreasury } from "libraries/LibTreasury.sol"; - -contract DonateSystem is System { - function donate() public payable { - if (!LibGame.canPlay()) { - revert CannotPlay(); - } - LibTreasury.incrementTreasury(address(0), _msgValue()); - } -} diff --git a/src/test/integration/Claim.t.sol b/src/test/integration/Claim.t.sol deleted file mode 100644 index 0326829..0000000 --- a/src/test/integration/Claim.t.sol +++ /dev/null @@ -1,158 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity >=0.8.0; - -import { Direction, Letter } from "codegen/common.sol"; -import { MerkleRootConfig, Points, TileLetter, TilePlayer, Treasury } from "codegen/index.sol"; -import { IWorld } from "codegen/world/IWorld.sol"; - -import { Bound } from "common/Bound.sol"; -import { SINGLETON_ADDRESS } from "common/Constants.sol"; -import { Coord } from "common/Coord.sol"; - -import { Words3Test } from "../Words3Test.t.sol"; -import { Merkle } from "../murky/src/Merkle.sol"; -import "forge-std/Test.sol"; - -contract Claim is Words3Test { - IWorld world; - bytes32[] public words; - Merkle private m; - - function setUp() public override { - super.setUp(); - world = IWorld(worldAddress); - m = new Merkle(); - Letter[] memory hello = new Letter[](5); - hello[0] = Letter.H; - hello[1] = Letter.E; - hello[1] = Letter.L; - hello[1] = Letter.L; - hello[1] = Letter.O; - Letter[] memory zone = new Letter[](4); - zone[0] = Letter.Z; - zone[1] = Letter.O; - zone[2] = Letter.N; - zone[3] = Letter.E; - Letter[] memory echo = new Letter[](4); - echo[0] = Letter.E; - echo[1] = Letter.C; - echo[2] = Letter.H; - echo[3] = Letter.O; - Letter[] memory zebra = new Letter[](5); - zebra[0] = Letter.Z; - zebra[1] = Letter.E; - zebra[2] = Letter.B; - zebra[3] = Letter.R; - zebra[4] = Letter.A; - Letter[] memory riot = new Letter[](5); - riot[0] = Letter.R; - riot[1] = Letter.I; - riot[2] = Letter.O; - riot[3] = Letter.T; - Letter[] memory emi = new Letter[](3); - emi[0] = Letter.E; - emi[1] = Letter.M; - emi[2] = Letter.I; - Letter[] memory om = new Letter[](2); - om[0] = Letter.O; - om[1] = Letter.M; - Letter[] memory omq = new Letter[](3); - omq[0] = Letter.O; - omq[1] = Letter.M; - omq[2] = Letter.Q; - Letter[] memory bqt = new Letter[](3); - bqt[0] = Letter.B; - bqt[1] = Letter.Q; - bqt[2] = Letter.T; - words.push(keccak256(bytes.concat(keccak256(abi.encode(hello))))); // hello - words.push(keccak256(bytes.concat(keccak256(abi.encode(zone))))); // zone - words.push(keccak256(bytes.concat(keccak256(abi.encode(echo))))); // echo - words.push(keccak256(bytes.concat(keccak256(abi.encode(zebra))))); // zebra - words.push(keccak256(bytes.concat(keccak256(abi.encode(riot))))); // riot - words.push(keccak256(bytes.concat(keccak256(abi.encode(emi))))); // emi - words.push(keccak256(bytes.concat(keccak256(abi.encode(om))))); // om - words.push(keccak256(bytes.concat(keccak256(abi.encode(omq))))); // omq - words.push(keccak256(bytes.concat(keccak256(abi.encode(bqt))))); // qt - - setDefaultLetterOdds(); - } - - function test_SimpleClaim() public { - address player1 = address(0x12345); - address player2 = address(0x54321); - - Letter[] memory initialWord = new Letter[](5); - initialWord[0] = Letter.H; - initialWord[1] = Letter.E; - initialWord[2] = Letter.L; - initialWord[3] = Letter.L; - initialWord[4] = Letter.O; - - world.start({ - initialWord: initialWord, - merkleRoot: m.getRoot(words), - vrgdaTargetPrice: 1, - vrgdaPriceDecay: 1e17, - vrgdaPerDayInitial: 100e18, - vrgdaPower: 1e16, - crossWordRewardFraction: 3, - bonusDistance: 5 - }); - - Letter[] memory word = new Letter[](4); - word[0] = Letter.Z; - word[1] = Letter.EMPTY; - word[2] = Letter.N; - word[3] = Letter.E; - - vm.deal(player1, 10 ether); - - Bound[] memory bounds = new Bound[](4); - bytes32[] memory proof = m.getProof(words, 1); - - // Play zone - vm.startPrank(player1); - for (uint256 i = 0; i < 20; i++) { - vm.warp(block.timestamp + 1 days); - world.draw{ value: 0.5 ether }(player1); - } - world.play(word, proof, Coord({ x: 4, y: -1 }), Direction.TOP_TO_BOTTOM, bounds); - vm.stopPrank(); - assertEq(address(player1).balance, 0); - assertEq(address(worldAddress).balance, 10 ether); - - // Play zebra on zone - vm.deal(player2, 10 ether); - Letter[] memory word2 = new Letter[](5); - word2[0] = Letter.EMPTY; - word2[1] = Letter.E; - word2[2] = Letter.B; - word2[3] = Letter.R; - word2[4] = Letter.A; - - bytes32[] memory proof2 = m.getProof(words, 3); - Bound[] memory bounds2 = new Bound[](5); - vm.startPrank(player2); - for (uint256 i = 0; i < 20; i++) { - vm.warp(block.timestamp + 1 days); - world.draw{ value: 0.5 ether }(player2); - } - world.play(word2, proof2, Coord({ x: 4, y: -1 }), Direction.LEFT_TO_RIGHT, bounds2); - vm.stopPrank(); - uint32 player1Points = Points.get(player1); - uint32 player2Points = Points.get(player2); - - assertEq(Treasury.get(), 20 ether); - - vm.prank(player1); - world.claim(player1Points); - - vm.prank(player2); - world.claim(player2Points); - - uint256 player1ExpectedBalance = (20 ether * player1Points) / (player1Points + player2Points); - - assertEq(address(player1).balance, player1ExpectedBalance); - assertEq(address(player2).balance, 20 ether - player1ExpectedBalance); - } -} diff --git a/src/test/integration/SimpleWord.t.sol b/src/test/integration/SimpleWord.t.sol deleted file mode 100644 index dfa56f5..0000000 --- a/src/test/integration/SimpleWord.t.sol +++ /dev/null @@ -1,115 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity >=0.8.0; - -import { Direction, Letter } from "codegen/common.sol"; -import { MerkleRootConfig, TileLetter, TilePlayer } from "codegen/index.sol"; -import { IWorld } from "codegen/world/IWorld.sol"; - -import { Bound } from "common/Bound.sol"; -import { Coord } from "common/Coord.sol"; -import { GameStartedOrOver } from "common/Errors.sol"; - -import { Words3Test } from "../Words3Test.t.sol"; -import { Merkle } from "../murky/src/Merkle.sol"; -import "forge-std/Test.sol"; - -contract SimpleWord is Words3Test { - IWorld world; - bytes32[] public words; - Merkle private m; - Letter[] initialWord; - - function setUp() public override { - super.setUp(); - world = IWorld(worldAddress); - - m = new Merkle(); - Letter[] memory hi = new Letter[](2); - hi[0] = Letter.H; - hi[1] = Letter.I; - Letter[] memory go = new Letter[](2); - go[0] = Letter.G; - go[1] = Letter.O; - words.push(keccak256(bytes.concat(keccak256(abi.encode(hi))))); // hi - words.push(keccak256(bytes.concat(keccak256(abi.encode(go))))); // go - - setDefaultLetterOdds(); - } - - function test_Setup() public { - initialWord = new Letter[](2); - initialWord[0] = Letter.H; - initialWord[1] = Letter.I; - world.start(initialWord, m.getRoot(words), 0, 0, 0, 1e16, 3, 5); - assertEq(uint8(TileLetter.get(0, 0)), uint8(Letter.H)); - assertEq(uint8(TileLetter.get(1, 0)), uint8(Letter.I)); - } - - function test_PlayHi() public { - initialWord = new Letter[](2); - initialWord[0] = Letter.H; - initialWord[1] = Letter.I; - world.start({ - initialWord: initialWord, - merkleRoot: m.getRoot(words), - vrgdaTargetPrice: 1, - vrgdaPriceDecay: 1e17, - vrgdaPerDayInitial: 100e18, - vrgdaPower: 1e16, - crossWordRewardFraction: 3, - bonusDistance: 5 - }); - - Letter[] memory word = new Letter[](2); - word[0] = Letter.EMPTY; - word[1] = Letter.I; - Bound[] memory bounds = new Bound[](2); - bytes32[] memory proof = m.getProof(words, 0); - - address player = address(0x123); - vm.deal(player, 50 ether); - vm.startPrank(player); - for (uint256 i = 0; i < 50; i++) { - uint256 price = world.getDrawPrice(); - vm.warp(block.timestamp + 1 days); - world.draw{ value: price }(player); - } - world.play(word, proof, Coord({ x: 0, y: 0 }), Direction.TOP_TO_BOTTOM, bounds); - vm.stopPrank(); - } - - function test_MultipleDraws() public { - world.start({ - initialWord: initialWord, - merkleRoot: 0xacd24e8edae5cf4cdbc3ce0c196a670cbea1dbf37576112b0a3defac3318b432, - vrgdaTargetPrice: 40e13, - vrgdaPriceDecay: 99_999e13, - vrgdaPerDayInitial: 700e18, - vrgdaPower: 1e18, - crossWordRewardFraction: 3, - bonusDistance: 10 - }); - - address player = address(0x123); - vm.deal(player, 50 ether); - vm.startPrank(player); - - world.draw{ value: world.getDrawPrice() }(player); - world.draw{ value: world.getDrawPrice() }(player); - vm.warp(block.timestamp + 5); - world.draw{ value: world.getDrawPrice() }(player); - vm.warp(block.timestamp + 10); - world.draw{ value: world.getDrawPrice() }(player); - world.draw{ value: world.getDrawPrice() }(player); - world.draw{ value: world.getDrawPrice() }(player); - vm.warp(block.timestamp + 10); - world.draw{ value: world.getDrawPrice() }(player); - world.draw{ value: world.getDrawPrice() }(player); - world.draw{ value: world.getDrawPrice() }(player); - world.draw{ value: world.getDrawPrice() }(player); - world.draw{ value: world.getDrawPrice() }(player); - vm.warp(block.timestamp + 3); - world.draw{ value: world.getDrawPrice() }(player); - world.draw{ value: world.getDrawPrice() }(player); - } -} diff --git a/src/test/integration/Transfer.t.sol b/src/test/integration/Transfer.t.sol deleted file mode 100644 index 52811b3..0000000 --- a/src/test/integration/Transfer.t.sol +++ /dev/null @@ -1,58 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity >=0.8.0; - -import { Direction, Letter } from "codegen/common.sol"; -import { PlayerLetters } from "codegen/index.sol"; -import { IWorld } from "codegen/world/IWorld.sol"; - -import { Bound } from "common/Bound.sol"; -import { Coord } from "common/Coord.sol"; -import { GameStartedOrOver } from "common/Errors.sol"; - -import { Words3Test } from "../Words3Test.t.sol"; -import { Merkle } from "../murky/src/Merkle.sol"; -import "forge-std/Test.sol"; - -contract Transfer is Words3Test { - IWorld world; - - function setUp() public override { - super.setUp(); - world = IWorld(worldAddress); - setDefaultLetterOdds(); - } - - function test_Transfer() public { - Letter[] memory initialWord = new Letter[](2); - initialWord[0] = Letter.H; - initialWord[1] = Letter.I; - world.start({ - initialWord: initialWord, - merkleRoot: bytes32(0), - vrgdaTargetPrice: 1, - vrgdaPriceDecay: 1e17, - vrgdaPerDayInitial: 100e18, - vrgdaPower: 1e16, - crossWordRewardFraction: 3, - bonusDistance: 5 - }); - - address player = address(0x123); - address to = address(0x456); - vm.deal(player, 50 ether); - vm.startPrank(player); - for (uint256 i = 0; i < 50; i++) { - uint256 price = world.getDrawPrice(); - vm.warp(block.timestamp + 1 days); - world.draw{ value: price }(player); - } - assertEq(PlayerLetters.get({ player: to, letter: Letter.A }), 0); - Letter[] memory transferLetters = new Letter[](2); - transferLetters[0] = Letter.A; - transferLetters[1] = Letter.B; - world.transfer({ letters: transferLetters, to: to }); - assertEq(PlayerLetters.get({ player: to, letter: Letter.A }), 1); - assertEq(PlayerLetters.get({ player: to, letter: Letter.B }), 1); - vm.stopPrank(); - } -} diff --git a/src/test/murky b/src/test/murky deleted file mode 160000 index 1d9566b..0000000 --- a/src/test/murky +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 1d9566b908b9702c45d354a1caabe8ef5a69938d