From 14b30f6da03e65ea522f9caf8e9decd376b14e5c Mon Sep 17 00:00:00 2001 From: Marc-Aurele Besner <82244926+marc-aurele-besner@users.noreply.github.com> Date: Thu, 12 Sep 2024 23:02:52 -0400 Subject: [PATCH 1/2] add auto-key-store --- .gitmodules | 6 + .vscode/auto.code-workspace | 4 + packages/auto-key-store/.gitignore | 1 + packages/auto-key-store/README.md | 12 + packages/auto-key-store/foundry.toml | 3 + packages/auto-key-store/lib/forge-std | 1 + .../auto-key-store/lib/openzeppelin-contracts | 1 + packages/auto-key-store/package.json | 31 + packages/auto-key-store/remappings.txt | 5 + .../script/DeployAutoKeyStore.s.sol | 20 + packages/auto-key-store/src/AutoKeyStore.sol | 58 ++ packages/auto-key-store/src/index.ts | 37 + .../auto-key-store/test/AutoKeyStore.t.sol | 100 ++ packages/auto-key-store/tsconfig.json | 11 + yarn.lock | 973 +++++++++++++++++- 15 files changed, 1259 insertions(+), 4 deletions(-) create mode 100644 .gitmodules create mode 100644 packages/auto-key-store/.gitignore create mode 100644 packages/auto-key-store/README.md create mode 100644 packages/auto-key-store/foundry.toml create mode 160000 packages/auto-key-store/lib/forge-std create mode 160000 packages/auto-key-store/lib/openzeppelin-contracts create mode 100644 packages/auto-key-store/package.json create mode 100644 packages/auto-key-store/remappings.txt create mode 100644 packages/auto-key-store/script/DeployAutoKeyStore.s.sol create mode 100644 packages/auto-key-store/src/AutoKeyStore.sol create mode 100644 packages/auto-key-store/src/index.ts create mode 100644 packages/auto-key-store/test/AutoKeyStore.t.sol create mode 100644 packages/auto-key-store/tsconfig.json diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 00000000..834f6e27 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,6 @@ +[submodule "packages/auto-key-store/lib/forge-std"] + path = packages/auto-key-store/lib/forge-std + url = https://github.com/foundry-rs/forge-std +[submodule "packages/auto-key-store/lib/openzeppelin-contracts"] + path = packages/auto-key-store/lib/openzeppelin-contracts + url = https://github.com/OpenZeppelin/openzeppelin-contracts diff --git a/.vscode/auto.code-workspace b/.vscode/auto.code-workspace index 940c8b3c..dc48d531 100644 --- a/.vscode/auto.code-workspace +++ b/.vscode/auto.code-workspace @@ -20,6 +20,10 @@ "name": "Auto-XDM", "path": "../packages/auto-xdm", }, + { + "name": "Auto-Key-Store", + "path": "../packages/auto-key-store", + }, { "name": "Example - NextJS", "path": "../examples/next", diff --git a/packages/auto-key-store/.gitignore b/packages/auto-key-store/.gitignore new file mode 100644 index 00000000..466e2480 --- /dev/null +++ b/packages/auto-key-store/.gitignore @@ -0,0 +1 @@ +out/ \ No newline at end of file diff --git a/packages/auto-key-store/README.md b/packages/auto-key-store/README.md new file mode 100644 index 00000000..ed3b4e72 --- /dev/null +++ b/packages/auto-key-store/README.md @@ -0,0 +1,12 @@ +# Auto-Key-Store + +A compact npm package for deploying and interacting with a key-value store smart contract on Autonomy's Nova network. This package provides a simple and efficient way to manage key-value pairs on the blockchain. + +## Features + +- Easy deployment of a KeyValueStore smart contract +- Simple API for setting and retrieving key-value pairs +- Role-based access control for writers and editors +- Seamless integration with Autonomy's Nova network + +## Installation diff --git a/packages/auto-key-store/foundry.toml b/packages/auto-key-store/foundry.toml new file mode 100644 index 00000000..4e4b1e6f --- /dev/null +++ b/packages/auto-key-store/foundry.toml @@ -0,0 +1,3 @@ +[profile.default] +solc_version = "0.8.19" +rpc_url = "https://nova.autonomy.network" diff --git a/packages/auto-key-store/lib/forge-std b/packages/auto-key-store/lib/forge-std new file mode 160000 index 00000000..e04104ab --- /dev/null +++ b/packages/auto-key-store/lib/forge-std @@ -0,0 +1 @@ +Subproject commit e04104ab93e771441eab03fb76eda1402cb5927b diff --git a/packages/auto-key-store/lib/openzeppelin-contracts b/packages/auto-key-store/lib/openzeppelin-contracts new file mode 160000 index 00000000..fd81a96f --- /dev/null +++ b/packages/auto-key-store/lib/openzeppelin-contracts @@ -0,0 +1 @@ +Subproject commit fd81a96f01cc42ef1c9a5399364968d0e07e9e90 diff --git a/packages/auto-key-store/package.json b/packages/auto-key-store/package.json new file mode 100644 index 00000000..5b57e82d --- /dev/null +++ b/packages/auto-key-store/package.json @@ -0,0 +1,31 @@ +{ + "name": "@autonomys/auto-key-store", + "version": "0.1.0", + "main": "dist/index.js", + "scripts": { + "build": "tsup src/index.ts --format cjs,esm --dts", + "test": "forge test" + }, + "dependencies": { + "ethers": "^5.4.0" + }, + "repository": { + "type": "git", + "url": "https://github.com/autonomys/auto-sdk" + }, + "author": { + "name": "Autonomys", + "url": "https://www.autonomys.net" + }, + "devDependencies": { + "@types/node": "^14.0.0", + "tsup": "^5.0.0", + "typescript": "^4.0.0" + }, + "description": "A compact npm package for deploying and interacting with a key-value store smart contract on Autonomy's Nova network.", + "directories": { + "test": "test" + }, + "keywords": [], + "license": "MIT" +} diff --git a/packages/auto-key-store/remappings.txt b/packages/auto-key-store/remappings.txt new file mode 100644 index 00000000..cbf24b18 --- /dev/null +++ b/packages/auto-key-store/remappings.txt @@ -0,0 +1,5 @@ +ds-test/=lib/openzeppelin-contracts/lib/forge-std/lib/ds-test/src/ +erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/ +forge-std/=lib/forge-std/src/ +@openzeppelin-contracts/=lib/openzeppelin-contracts/ +@openzeppelin/=lib/openzeppelin-contracts/ diff --git a/packages/auto-key-store/script/DeployAutoKeyStore.s.sol b/packages/auto-key-store/script/DeployAutoKeyStore.s.sol new file mode 100644 index 00000000..189f36d5 --- /dev/null +++ b/packages/auto-key-store/script/DeployAutoKeyStore.s.sol @@ -0,0 +1,20 @@ +pragma solidity ^0.8.0; + +import "forge-std/Script.sol"; +import "../src/AutoKeyStore.sol"; + +contract DeployAutoKeyStore is Script { + function run() external { + vm.startBroadcast(); + + AutoKeyStore autoKeyStore = new AutoKeyStore(msg.sender); + + // Set a key-value pair + autoKeyStore.setValue("exampleKey", "exampleValue"); + + // Retrieve the value for the key + autoKeyStore.getValue("exampleKey"); + + vm.stopBroadcast(); + } +} \ No newline at end of file diff --git a/packages/auto-key-store/src/AutoKeyStore.sol b/packages/auto-key-store/src/AutoKeyStore.sol new file mode 100644 index 00000000..8e64d10f --- /dev/null +++ b/packages/auto-key-store/src/AutoKeyStore.sol @@ -0,0 +1,58 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +import "@openzeppelin/contracts/access/AccessControl.sol"; + +contract AutoKeyStore is AccessControl { + bytes32 public constant WRITER_ROLE = keccak256("WRITER_ROLE"); + bytes32 public constant EDITOR_ROLE = keccak256("EDITOR_ROLE"); + + mapping(string => string) private store; + + event KeyValueSet(string indexed key, string value); + + constructor(address admin) { + _grantRole(DEFAULT_ADMIN_ROLE, admin); + } + + function setValue(string memory key, string memory value) public { + require( + hasRole(WRITER_ROLE, msg.sender) || hasRole(EDITOR_ROLE, msg.sender), + "Access denied: No write permissions" + ); + store[key] = value; + emit KeyValueSet(key, value); + } + + function getValue(string memory key) public view returns (string memory) { + return store[key]; + } + + function grantWriterRole(address account) public onlyRole(DEFAULT_ADMIN_ROLE) { + grantRole(WRITER_ROLE, account); + } + + function grantEditorRole(address account) public onlyRole(DEFAULT_ADMIN_ROLE) { + grantRole(EDITOR_ROLE, account); + } + + function setMultipleValues(string[] memory keys, string[] memory values) public { + require(keys.length == values.length, "Keys and values arrays must have the same length"); + require( + hasRole(WRITER_ROLE, msg.sender) || hasRole(EDITOR_ROLE, msg.sender), + "Access denied: No write permissions" + ); + for (uint i = 0; i < keys.length; i++) { + store[keys[i]] = values[i]; + emit KeyValueSet(keys[i], values[i]); + } + } + + function getMultipleValues(string[] memory keys) public view returns (string[] memory) { + string[] memory values = new string[](keys.length); + for (uint i = 0; i < keys.length; i++) { + values[i] = store[keys[i]]; + } + return values; + } +} diff --git a/packages/auto-key-store/src/index.ts b/packages/auto-key-store/src/index.ts new file mode 100644 index 00000000..337daef8 --- /dev/null +++ b/packages/auto-key-store/src/index.ts @@ -0,0 +1,37 @@ +import { ethers } from 'ethers' + +export class AutoKeyStore { + private contract: ethers.Contract + + constructor( + providerOrSigner: ethers.providers.Provider | ethers.Signer, + contractAddress: string, + abi: any, + ) { + this.contract = new ethers.Contract(contractAddress, abi, providerOrSigner) + } + + async setValue(key: string, value: string): Promise { + return this.contract.setValue(key, value) + } + + async getValue(key: string): Promise { + return this.contract.getValue(key) + } + + async grantWriterRole(account: string): Promise { + return this.contract.grantWriterRole(account) + } + + async grantEditorRole(account: string): Promise { + return this.contract.grantEditorRole(account) + } + + async setMultipleValues(keys: string[], values: string[]): Promise { + return this.contract.setMultipleValues(keys, values) + } + + async getMultipleValues(keys: string[]): Promise { + return this.contract.getMultipleValues(keys) + } +} diff --git a/packages/auto-key-store/test/AutoKeyStore.t.sol b/packages/auto-key-store/test/AutoKeyStore.t.sol new file mode 100644 index 00000000..4890fe35 --- /dev/null +++ b/packages/auto-key-store/test/AutoKeyStore.t.sol @@ -0,0 +1,100 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +import "forge-std/Test.sol"; +import "../src/AutoKeyStore.sol"; + +contract AutoKeyStoreTest is Test { + AutoKeyStore autoKeyStore; + address admin = address(1); + address writer = address(2); + address editor = address(3); + address unauthorized = address(4); + + function setUp() public { + vm.startPrank(admin); + autoKeyStore = new AutoKeyStore(admin); + autoKeyStore.grantWriterRole(writer); + autoKeyStore.grantEditorRole(editor); + vm.stopPrank(); + } + + /// @notice Test that a writer can set and get a value + function testSetAndGetValue() public { + vm.prank(writer); + autoKeyStore.setValue("key1", "value1"); + string memory value = autoKeyStore.getValue("key1"); + assertEq(value, "value1"); + } + + /// @notice Test that an unauthorized user cannot set a value + function testUnauthorizedCannotSetValue() public { + vm.prank(unauthorized); + vm.expectRevert("Access denied: No write permissions"); + autoKeyStore.setValue("key1", "value1"); + } + + /// @notice Test that an editor can set and get a value + function testEditorCanSetValue() public { + vm.prank(editor); + autoKeyStore.setValue("key2", "value2"); + string memory value = autoKeyStore.getValue("key2"); + assertEq(value, "value2"); + } + + /// @notice Test setting multiple values + function testSetMultipleValues() public { + vm.prank(writer); + + string[] memory keys = new string[](2); // Declare and initialize keys array + keys[0] = "key1"; + keys[1] = "key2"; + + string[] memory values = new string[](2); // Declare and initialize values array + values[0] = "value1"; + values[1] = "value2"; + + autoKeyStore.setMultipleValues(keys, values); + + string memory value1 = autoKeyStore.getValue("key1"); + string memory value2 = autoKeyStore.getValue("key2"); + + assertEq(value1, "value1"); + assertEq(value2, "value2"); + } + + /// @notice Test getting multiple values + function testGetMultipleValues() public { + vm.startPrank(writer); + autoKeyStore.setValue("key1", "value1"); + autoKeyStore.setValue("key2", "value2"); + vm.stopPrank(); + + string[] memory keys = new string[](2); // Declare and initialize keys array + keys[0] = "key1"; + keys[1] = "key2"; + + string[] memory values = autoKeyStore.getMultipleValues(keys); + + assertEq(values[0], "value1"); + assertEq(values[1], "value2"); + } + + /// @notice Test that only admin can grant roles + function testOnlyAdminCanGrantRoles() public { + vm.prank(unauthorized); + vm.expectRevert(); + autoKeyStore.grantWriterRole(unauthorized); + } + + /// @notice Test that admin can grant roles + function testAdminCanGrantRoles() public { + vm.prank(admin); + autoKeyStore.grantWriterRole(unauthorized); + + vm.prank(unauthorized); + autoKeyStore.setValue("key3", "value3"); + string memory value = autoKeyStore.getValue("key3"); + assertEq(value, "value3"); + } +} diff --git a/packages/auto-key-store/tsconfig.json b/packages/auto-key-store/tsconfig.json new file mode 100644 index 00000000..56b0fa6d --- /dev/null +++ b/packages/auto-key-store/tsconfig.json @@ -0,0 +1,11 @@ +{ + "compilerOptions": { + "target": "ES2020", + "module": "CommonJS", + "strict": true, + "esModuleInterop": true, + "outDir": "dist", + "declaration": true + }, + "include": ["src/**/*"] +} diff --git a/yarn.lock b/yarn.lock index 90417c54..fb1f3dcb 100644 --- a/yarn.lock +++ b/yarn.lock @@ -65,6 +65,17 @@ __metadata: languageName: unknown linkType: soft +"@autonomys/auto-key-store@workspace:packages/auto-key-store": + version: 0.0.0-use.local + resolution: "@autonomys/auto-key-store@workspace:packages/auto-key-store" + dependencies: + "@types/node": "npm:^14.0.0" + ethers: "npm:^5.4.0" + tsup: "npm:^5.0.0" + typescript: "npm:^4.0.0" + languageName: unknown + linkType: soft + "@autonomys/auto-sdk@workspace:.": version: 0.0.0-use.local resolution: "@autonomys/auto-sdk@workspace:." @@ -506,6 +517,13 @@ __metadata: languageName: node linkType: hard +"@esbuild/linux-loong64@npm:0.14.54": + version: 0.14.54 + resolution: "@esbuild/linux-loong64@npm:0.14.54" + conditions: os=linux & cpu=loong64 + languageName: node + linkType: hard + "@eslint-community/eslint-utils@npm:^4.2.0": version: 4.4.0 resolution: "@eslint-community/eslint-utils@npm:4.4.0" @@ -548,6 +566,408 @@ __metadata: languageName: node linkType: hard +"@ethersproject/abi@npm:5.7.0, @ethersproject/abi@npm:^5.7.0": + version: 5.7.0 + resolution: "@ethersproject/abi@npm:5.7.0" + dependencies: + "@ethersproject/address": "npm:^5.7.0" + "@ethersproject/bignumber": "npm:^5.7.0" + "@ethersproject/bytes": "npm:^5.7.0" + "@ethersproject/constants": "npm:^5.7.0" + "@ethersproject/hash": "npm:^5.7.0" + "@ethersproject/keccak256": "npm:^5.7.0" + "@ethersproject/logger": "npm:^5.7.0" + "@ethersproject/properties": "npm:^5.7.0" + "@ethersproject/strings": "npm:^5.7.0" + checksum: 10c0/7de51bf52ff03df2526546dacea6e74f15d4c5ef762d931552082b9600dcefd8e333599f02d7906ba89f7b7f48c45ab72cee76f397212b4f17fa9d9ff5615916 + languageName: node + linkType: hard + +"@ethersproject/abstract-provider@npm:5.7.0, @ethersproject/abstract-provider@npm:^5.7.0": + version: 5.7.0 + resolution: "@ethersproject/abstract-provider@npm:5.7.0" + dependencies: + "@ethersproject/bignumber": "npm:^5.7.0" + "@ethersproject/bytes": "npm:^5.7.0" + "@ethersproject/logger": "npm:^5.7.0" + "@ethersproject/networks": "npm:^5.7.0" + "@ethersproject/properties": "npm:^5.7.0" + "@ethersproject/transactions": "npm:^5.7.0" + "@ethersproject/web": "npm:^5.7.0" + checksum: 10c0/a5708e2811b90ddc53d9318ce152511a32dd4771aa2fb59dbe9e90468bb75ca6e695d958bf44d13da684dc3b6aab03f63d425ff7591332cb5d7ddaf68dff7224 + languageName: node + linkType: hard + +"@ethersproject/abstract-signer@npm:5.7.0, @ethersproject/abstract-signer@npm:^5.7.0": + version: 5.7.0 + resolution: "@ethersproject/abstract-signer@npm:5.7.0" + dependencies: + "@ethersproject/abstract-provider": "npm:^5.7.0" + "@ethersproject/bignumber": "npm:^5.7.0" + "@ethersproject/bytes": "npm:^5.7.0" + "@ethersproject/logger": "npm:^5.7.0" + "@ethersproject/properties": "npm:^5.7.0" + checksum: 10c0/e174966b3be17269a5974a3ae5eef6d15ac62ee8c300ceace26767f218f6bbf3de66f29d9a9c9ca300fa8551aab4c92e28d2cc772f5475fdeaa78d9b5be0e745 + languageName: node + linkType: hard + +"@ethersproject/address@npm:5.7.0, @ethersproject/address@npm:^5.7.0": + version: 5.7.0 + resolution: "@ethersproject/address@npm:5.7.0" + dependencies: + "@ethersproject/bignumber": "npm:^5.7.0" + "@ethersproject/bytes": "npm:^5.7.0" + "@ethersproject/keccak256": "npm:^5.7.0" + "@ethersproject/logger": "npm:^5.7.0" + "@ethersproject/rlp": "npm:^5.7.0" + checksum: 10c0/db5da50abeaae8f6cf17678323e8d01cad697f9a184b0593c62b71b0faa8d7e5c2ba14da78a998d691773ed6a8eb06701f65757218e0eaaeb134e5c5f3e5a908 + languageName: node + linkType: hard + +"@ethersproject/base64@npm:5.7.0, @ethersproject/base64@npm:^5.7.0": + version: 5.7.0 + resolution: "@ethersproject/base64@npm:5.7.0" + dependencies: + "@ethersproject/bytes": "npm:^5.7.0" + checksum: 10c0/4f748cd82af60ff1866db699fbf2bf057feff774ea0a30d1f03ea26426f53293ea10cc8265cda1695301da61093bedb8cc0d38887f43ed9dad96b78f19d7337e + languageName: node + linkType: hard + +"@ethersproject/basex@npm:5.7.0, @ethersproject/basex@npm:^5.7.0": + version: 5.7.0 + resolution: "@ethersproject/basex@npm:5.7.0" + dependencies: + "@ethersproject/bytes": "npm:^5.7.0" + "@ethersproject/properties": "npm:^5.7.0" + checksum: 10c0/02304de77477506ad798eb5c68077efd2531624380d770ef4a823e631a288fb680107a0f9dc4a6339b2a0b0f5b06ee77f53429afdad8f950cde0f3e40d30167d + languageName: node + linkType: hard + +"@ethersproject/bignumber@npm:5.7.0, @ethersproject/bignumber@npm:^5.7.0": + version: 5.7.0 + resolution: "@ethersproject/bignumber@npm:5.7.0" + dependencies: + "@ethersproject/bytes": "npm:^5.7.0" + "@ethersproject/logger": "npm:^5.7.0" + bn.js: "npm:^5.2.1" + checksum: 10c0/14263cdc91a7884b141d9300f018f76f69839c47e95718ef7161b11d2c7563163096fee69724c5fa8ef6f536d3e60f1c605819edbc478383a2b98abcde3d37b2 + languageName: node + linkType: hard + +"@ethersproject/bytes@npm:5.7.0, @ethersproject/bytes@npm:^5.7.0": + version: 5.7.0 + resolution: "@ethersproject/bytes@npm:5.7.0" + dependencies: + "@ethersproject/logger": "npm:^5.7.0" + checksum: 10c0/07dd1f0341b3de584ef26c8696674ff2bb032f4e99073856fc9cd7b4c54d1d846cabe149e864be267934658c3ce799e5ea26babe01f83af0e1f06c51e5ac791f + languageName: node + linkType: hard + +"@ethersproject/constants@npm:5.7.0, @ethersproject/constants@npm:^5.7.0": + version: 5.7.0 + resolution: "@ethersproject/constants@npm:5.7.0" + dependencies: + "@ethersproject/bignumber": "npm:^5.7.0" + checksum: 10c0/6df63ab753e152726b84595250ea722165a5744c046e317df40a6401f38556385a37c84dadf5b11ca651c4fb60f967046125369c57ac84829f6b30e69a096273 + languageName: node + linkType: hard + +"@ethersproject/contracts@npm:5.7.0": + version: 5.7.0 + resolution: "@ethersproject/contracts@npm:5.7.0" + dependencies: + "@ethersproject/abi": "npm:^5.7.0" + "@ethersproject/abstract-provider": "npm:^5.7.0" + "@ethersproject/abstract-signer": "npm:^5.7.0" + "@ethersproject/address": "npm:^5.7.0" + "@ethersproject/bignumber": "npm:^5.7.0" + "@ethersproject/bytes": "npm:^5.7.0" + "@ethersproject/constants": "npm:^5.7.0" + "@ethersproject/logger": "npm:^5.7.0" + "@ethersproject/properties": "npm:^5.7.0" + "@ethersproject/transactions": "npm:^5.7.0" + checksum: 10c0/97a10361dddaccfb3e9e20e24d071cfa570050adcb964d3452c5f7c9eaaddb4e145ec9cf928e14417948701b89e81d4907800e799a6083123e4d13a576842f41 + languageName: node + linkType: hard + +"@ethersproject/hash@npm:5.7.0, @ethersproject/hash@npm:^5.7.0": + version: 5.7.0 + resolution: "@ethersproject/hash@npm:5.7.0" + dependencies: + "@ethersproject/abstract-signer": "npm:^5.7.0" + "@ethersproject/address": "npm:^5.7.0" + "@ethersproject/base64": "npm:^5.7.0" + "@ethersproject/bignumber": "npm:^5.7.0" + "@ethersproject/bytes": "npm:^5.7.0" + "@ethersproject/keccak256": "npm:^5.7.0" + "@ethersproject/logger": "npm:^5.7.0" + "@ethersproject/properties": "npm:^5.7.0" + "@ethersproject/strings": "npm:^5.7.0" + checksum: 10c0/1a631dae34c4cf340dde21d6940dd1715fc7ae483d576f7b8ef9e8cb1d0e30bd7e8d30d4a7d8dc531c14164602323af2c3d51eb2204af18b2e15167e70c9a5ef + languageName: node + linkType: hard + +"@ethersproject/hdnode@npm:5.7.0, @ethersproject/hdnode@npm:^5.7.0": + version: 5.7.0 + resolution: "@ethersproject/hdnode@npm:5.7.0" + dependencies: + "@ethersproject/abstract-signer": "npm:^5.7.0" + "@ethersproject/basex": "npm:^5.7.0" + "@ethersproject/bignumber": "npm:^5.7.0" + "@ethersproject/bytes": "npm:^5.7.0" + "@ethersproject/logger": "npm:^5.7.0" + "@ethersproject/pbkdf2": "npm:^5.7.0" + "@ethersproject/properties": "npm:^5.7.0" + "@ethersproject/sha2": "npm:^5.7.0" + "@ethersproject/signing-key": "npm:^5.7.0" + "@ethersproject/strings": "npm:^5.7.0" + "@ethersproject/transactions": "npm:^5.7.0" + "@ethersproject/wordlists": "npm:^5.7.0" + checksum: 10c0/36d5c13fe69b1e0a18ea98537bc560d8ba166e012d63faac92522a0b5f405eb67d8848c5aca69e2470f62743aaef2ac36638d9e27fd8c68f51506eb61479d51d + languageName: node + linkType: hard + +"@ethersproject/json-wallets@npm:5.7.0, @ethersproject/json-wallets@npm:^5.7.0": + version: 5.7.0 + resolution: "@ethersproject/json-wallets@npm:5.7.0" + dependencies: + "@ethersproject/abstract-signer": "npm:^5.7.0" + "@ethersproject/address": "npm:^5.7.0" + "@ethersproject/bytes": "npm:^5.7.0" + "@ethersproject/hdnode": "npm:^5.7.0" + "@ethersproject/keccak256": "npm:^5.7.0" + "@ethersproject/logger": "npm:^5.7.0" + "@ethersproject/pbkdf2": "npm:^5.7.0" + "@ethersproject/properties": "npm:^5.7.0" + "@ethersproject/random": "npm:^5.7.0" + "@ethersproject/strings": "npm:^5.7.0" + "@ethersproject/transactions": "npm:^5.7.0" + aes-js: "npm:3.0.0" + scrypt-js: "npm:3.0.1" + checksum: 10c0/f1a84d19ff38d3506f453abc4702107cbc96a43c000efcd273a056371363767a06a8d746f84263b1300266eb0c329fe3b49a9b39a37aadd016433faf9e15a4bb + languageName: node + linkType: hard + +"@ethersproject/keccak256@npm:5.7.0, @ethersproject/keccak256@npm:^5.7.0": + version: 5.7.0 + resolution: "@ethersproject/keccak256@npm:5.7.0" + dependencies: + "@ethersproject/bytes": "npm:^5.7.0" + js-sha3: "npm:0.8.0" + checksum: 10c0/3b1a91706ff11f5ab5496840b9c36cedca27db443186d28b94847149fd16baecdc13f6fc5efb8359506392f2aba559d07e7f9c1e17a63f9d5de9f8053cfcb033 + languageName: node + linkType: hard + +"@ethersproject/logger@npm:5.7.0, @ethersproject/logger@npm:^5.7.0": + version: 5.7.0 + resolution: "@ethersproject/logger@npm:5.7.0" + checksum: 10c0/d03d460fb2d4a5e71c627b7986fb9e50e1b59a6f55e8b42a545b8b92398b961e7fd294bd9c3d8f92b35d0f6ff9d15aa14c95eab378f8ea194e943c8ace343501 + languageName: node + linkType: hard + +"@ethersproject/networks@npm:5.7.1, @ethersproject/networks@npm:^5.7.0": + version: 5.7.1 + resolution: "@ethersproject/networks@npm:5.7.1" + dependencies: + "@ethersproject/logger": "npm:^5.7.0" + checksum: 10c0/9efcdce27f150459e85d74af3f72d5c32898823a99f5410e26bf26cca2d21fb14e403377314a93aea248e57fb2964e19cee2c3f7bfc586ceba4c803a8f1b75c0 + languageName: node + linkType: hard + +"@ethersproject/pbkdf2@npm:5.7.0, @ethersproject/pbkdf2@npm:^5.7.0": + version: 5.7.0 + resolution: "@ethersproject/pbkdf2@npm:5.7.0" + dependencies: + "@ethersproject/bytes": "npm:^5.7.0" + "@ethersproject/sha2": "npm:^5.7.0" + checksum: 10c0/e5a29cf28b4f4ca1def94d37cfb6a9c05c896106ed64881707813de01c1e7ded613f1e95febcccda4de96aae929068831d72b9d06beef1377b5a1a13a0eb3ff5 + languageName: node + linkType: hard + +"@ethersproject/properties@npm:5.7.0, @ethersproject/properties@npm:^5.7.0": + version: 5.7.0 + resolution: "@ethersproject/properties@npm:5.7.0" + dependencies: + "@ethersproject/logger": "npm:^5.7.0" + checksum: 10c0/4fe5d36e5550b8e23a305aa236a93e8f04d891d8198eecdc8273914c761b0e198fd6f757877406ee3eb05033ec271132a3e5998c7bd7b9a187964fb4f67b1373 + languageName: node + linkType: hard + +"@ethersproject/providers@npm:5.7.2": + version: 5.7.2 + resolution: "@ethersproject/providers@npm:5.7.2" + dependencies: + "@ethersproject/abstract-provider": "npm:^5.7.0" + "@ethersproject/abstract-signer": "npm:^5.7.0" + "@ethersproject/address": "npm:^5.7.0" + "@ethersproject/base64": "npm:^5.7.0" + "@ethersproject/basex": "npm:^5.7.0" + "@ethersproject/bignumber": "npm:^5.7.0" + "@ethersproject/bytes": "npm:^5.7.0" + "@ethersproject/constants": "npm:^5.7.0" + "@ethersproject/hash": "npm:^5.7.0" + "@ethersproject/logger": "npm:^5.7.0" + "@ethersproject/networks": "npm:^5.7.0" + "@ethersproject/properties": "npm:^5.7.0" + "@ethersproject/random": "npm:^5.7.0" + "@ethersproject/rlp": "npm:^5.7.0" + "@ethersproject/sha2": "npm:^5.7.0" + "@ethersproject/strings": "npm:^5.7.0" + "@ethersproject/transactions": "npm:^5.7.0" + "@ethersproject/web": "npm:^5.7.0" + bech32: "npm:1.1.4" + ws: "npm:7.4.6" + checksum: 10c0/4c8d19e6b31f769c24042fb2d02e483a4ee60dcbfca9e3291f0a029b24337c47d1ea719a390be856f8fd02997125819e834415e77da4fb2023369712348dae4c + languageName: node + linkType: hard + +"@ethersproject/random@npm:5.7.0, @ethersproject/random@npm:^5.7.0": + version: 5.7.0 + resolution: "@ethersproject/random@npm:5.7.0" + dependencies: + "@ethersproject/bytes": "npm:^5.7.0" + "@ethersproject/logger": "npm:^5.7.0" + checksum: 10c0/23e572fc55372653c22062f6a153a68c2e2d3200db734cd0d39621fbfd0ca999585bed2d5682e3ac65d87a2893048375682e49d1473d9965631ff56d2808580b + languageName: node + linkType: hard + +"@ethersproject/rlp@npm:5.7.0, @ethersproject/rlp@npm:^5.7.0": + version: 5.7.0 + resolution: "@ethersproject/rlp@npm:5.7.0" + dependencies: + "@ethersproject/bytes": "npm:^5.7.0" + "@ethersproject/logger": "npm:^5.7.0" + checksum: 10c0/bc863d21dcf7adf6a99ae75c41c4a3fb99698cfdcfc6d5d82021530f3d3551c6305bc7b6f0475ad6de6f69e91802b7e872bee48c0596d98969aefcf121c2a044 + languageName: node + linkType: hard + +"@ethersproject/sha2@npm:5.7.0, @ethersproject/sha2@npm:^5.7.0": + version: 5.7.0 + resolution: "@ethersproject/sha2@npm:5.7.0" + dependencies: + "@ethersproject/bytes": "npm:^5.7.0" + "@ethersproject/logger": "npm:^5.7.0" + hash.js: "npm:1.1.7" + checksum: 10c0/0e7f9ce6b1640817b921b9c6dd9dab8d5bf5a0ce7634d6a7d129b7366a576c2f90dcf4bcb15a0aa9310dde67028f3a44e4fcc2f26b565abcd2a0f465116ff3b1 + languageName: node + linkType: hard + +"@ethersproject/signing-key@npm:5.7.0, @ethersproject/signing-key@npm:^5.7.0": + version: 5.7.0 + resolution: "@ethersproject/signing-key@npm:5.7.0" + dependencies: + "@ethersproject/bytes": "npm:^5.7.0" + "@ethersproject/logger": "npm:^5.7.0" + "@ethersproject/properties": "npm:^5.7.0" + bn.js: "npm:^5.2.1" + elliptic: "npm:6.5.4" + hash.js: "npm:1.1.7" + checksum: 10c0/fe2ca55bcdb6e370d81372191d4e04671234a2da872af20b03c34e6e26b97dc07c1ee67e91b673680fb13344c9d5d7eae52f1fa6117733a3d68652b778843e09 + languageName: node + linkType: hard + +"@ethersproject/solidity@npm:5.7.0": + version: 5.7.0 + resolution: "@ethersproject/solidity@npm:5.7.0" + dependencies: + "@ethersproject/bignumber": "npm:^5.7.0" + "@ethersproject/bytes": "npm:^5.7.0" + "@ethersproject/keccak256": "npm:^5.7.0" + "@ethersproject/logger": "npm:^5.7.0" + "@ethersproject/sha2": "npm:^5.7.0" + "@ethersproject/strings": "npm:^5.7.0" + checksum: 10c0/bedf9918911144b0ec352b8aa7fa44abf63f0b131629c625672794ee196ba7d3992b0e0d3741935ca176813da25b9bcbc81aec454652c63113bdc3a1706beac6 + languageName: node + linkType: hard + +"@ethersproject/strings@npm:5.7.0, @ethersproject/strings@npm:^5.7.0": + version: 5.7.0 + resolution: "@ethersproject/strings@npm:5.7.0" + dependencies: + "@ethersproject/bytes": "npm:^5.7.0" + "@ethersproject/constants": "npm:^5.7.0" + "@ethersproject/logger": "npm:^5.7.0" + checksum: 10c0/570d87040ccc7d94de9861f76fc2fba6c0b84c5d6104a99a5c60b8a2401df2e4f24bf9c30afa536163b10a564a109a96f02e6290b80e8f0c610426f56ad704d1 + languageName: node + linkType: hard + +"@ethersproject/transactions@npm:5.7.0, @ethersproject/transactions@npm:^5.7.0": + version: 5.7.0 + resolution: "@ethersproject/transactions@npm:5.7.0" + dependencies: + "@ethersproject/address": "npm:^5.7.0" + "@ethersproject/bignumber": "npm:^5.7.0" + "@ethersproject/bytes": "npm:^5.7.0" + "@ethersproject/constants": "npm:^5.7.0" + "@ethersproject/keccak256": "npm:^5.7.0" + "@ethersproject/logger": "npm:^5.7.0" + "@ethersproject/properties": "npm:^5.7.0" + "@ethersproject/rlp": "npm:^5.7.0" + "@ethersproject/signing-key": "npm:^5.7.0" + checksum: 10c0/aa4d51379caab35b9c468ed1692a23ae47ce0de121890b4f7093c982ee57e30bd2df0c743faed0f44936d7e59c55fffd80479f2c28ec6777b8de06bfb638c239 + languageName: node + linkType: hard + +"@ethersproject/units@npm:5.7.0": + version: 5.7.0 + resolution: "@ethersproject/units@npm:5.7.0" + dependencies: + "@ethersproject/bignumber": "npm:^5.7.0" + "@ethersproject/constants": "npm:^5.7.0" + "@ethersproject/logger": "npm:^5.7.0" + checksum: 10c0/4da2fdefe2a506cc9f8b408b2c8638ab35b843ec413d52713143f08501a55ff67a808897f9a91874774fb526423a0821090ba294f93e8bf4933a57af9677ac5e + languageName: node + linkType: hard + +"@ethersproject/wallet@npm:5.7.0": + version: 5.7.0 + resolution: "@ethersproject/wallet@npm:5.7.0" + dependencies: + "@ethersproject/abstract-provider": "npm:^5.7.0" + "@ethersproject/abstract-signer": "npm:^5.7.0" + "@ethersproject/address": "npm:^5.7.0" + "@ethersproject/bignumber": "npm:^5.7.0" + "@ethersproject/bytes": "npm:^5.7.0" + "@ethersproject/hash": "npm:^5.7.0" + "@ethersproject/hdnode": "npm:^5.7.0" + "@ethersproject/json-wallets": "npm:^5.7.0" + "@ethersproject/keccak256": "npm:^5.7.0" + "@ethersproject/logger": "npm:^5.7.0" + "@ethersproject/properties": "npm:^5.7.0" + "@ethersproject/random": "npm:^5.7.0" + "@ethersproject/signing-key": "npm:^5.7.0" + "@ethersproject/transactions": "npm:^5.7.0" + "@ethersproject/wordlists": "npm:^5.7.0" + checksum: 10c0/f872b957db46f9de247d39a398538622b6c7a12f93d69bec5f47f9abf0701ef1edc10497924dd1c14a68109284c39a1686fa85586d89b3ee65df49002c40ba4c + languageName: node + linkType: hard + +"@ethersproject/web@npm:5.7.1, @ethersproject/web@npm:^5.7.0": + version: 5.7.1 + resolution: "@ethersproject/web@npm:5.7.1" + dependencies: + "@ethersproject/base64": "npm:^5.7.0" + "@ethersproject/bytes": "npm:^5.7.0" + "@ethersproject/logger": "npm:^5.7.0" + "@ethersproject/properties": "npm:^5.7.0" + "@ethersproject/strings": "npm:^5.7.0" + checksum: 10c0/c82d6745c7f133980e8dab203955260e07da22fa544ccafdd0f21c79fae127bd6ef30957319e37b1cc80cddeb04d6bfb60f291bb14a97c9093d81ce50672f453 + languageName: node + linkType: hard + +"@ethersproject/wordlists@npm:5.7.0, @ethersproject/wordlists@npm:^5.7.0": + version: 5.7.0 + resolution: "@ethersproject/wordlists@npm:5.7.0" + dependencies: + "@ethersproject/bytes": "npm:^5.7.0" + "@ethersproject/hash": "npm:^5.7.0" + "@ethersproject/logger": "npm:^5.7.0" + "@ethersproject/properties": "npm:^5.7.0" + "@ethersproject/strings": "npm:^5.7.0" + checksum: 10c0/da4f3eca6d691ebf4f578e6b2ec3a76dedba791be558f6cf7e10cd0bfbaeab5a6753164201bb72ced745fb02b6ef7ef34edcb7e6065ce2b624c6556a461c3f70 + languageName: node + linkType: hard + "@humanwhocodes/config-array@npm:^0.11.14": version: 0.11.14 resolution: "@humanwhocodes/config-array@npm:0.11.14" @@ -2637,6 +3057,13 @@ __metadata: languageName: node linkType: hard +"@types/node@npm:^14.0.0": + version: 14.18.63 + resolution: "@types/node@npm:14.18.63" + checksum: 10c0/626a371419a6a0e11ca460b22bb4894abe5d75c303739588bc96267e380aa8b90ba5a87bc552400584f0ac2a84b5c458dadcbcf0dfd2396ebeb765f7a7f95893 + languageName: node + linkType: hard + "@types/node@npm:^20, @types/node@npm:^20.12.12": version: 20.14.15 resolution: "@types/node@npm:20.14.15" @@ -2863,6 +3290,13 @@ __metadata: languageName: node linkType: hard +"aes-js@npm:3.0.0": + version: 3.0.0 + resolution: "aes-js@npm:3.0.0" + checksum: 10c0/87dd5b2363534b867db7cef8bc85a90c355460783744877b2db7c8be09740aac5750714f9e00902822f692662bda74cdf40e03fbb5214ffec75c2666666288b8 + languageName: node + linkType: hard + "aes-js@npm:4.0.0-beta.5": version: 4.0.0-beta.5 resolution: "aes-js@npm:4.0.0-beta.5" @@ -3352,6 +3786,13 @@ __metadata: languageName: node linkType: hard +"bech32@npm:1.1.4": + version: 1.1.4 + resolution: "bech32@npm:1.1.4" + checksum: 10c0/5f62ca47b8df99ace9c0e0d8deb36a919d91bf40066700aaa9920a45f86bb10eb56d537d559416fd8703aa0fb60dddb642e58f049701e7291df678b2033e5ee5 + languageName: node + linkType: hard + "before-after-hook@npm:^2.2.0": version: 2.2.3 resolution: "before-after-hook@npm:2.2.3" @@ -3389,6 +3830,13 @@ __metadata: languageName: node linkType: hard +"bn.js@npm:^4.11.9": + version: 4.12.0 + resolution: "bn.js@npm:4.12.0" + checksum: 10c0/9736aaa317421b6b3ed038ff3d4491935a01419ac2d83ddcfebc5717385295fcfcf0c57311d90fe49926d0abbd7a9dbefdd8861e6129939177f7e67ebc645b21 + languageName: node + linkType: hard + "bn.js@npm:^5.2.1": version: 5.2.1 resolution: "bn.js@npm:5.2.1" @@ -3424,6 +3872,13 @@ __metadata: languageName: node linkType: hard +"brorand@npm:^1.1.0": + version: 1.1.0 + resolution: "brorand@npm:1.1.0" + checksum: 10c0/6f366d7c4990f82c366e3878492ba9a372a73163c09871e80d82fb4ae0d23f9f8924cb8a662330308206e6b3b76ba1d528b4601c9ef73c2166b440b2ea3b7571 + languageName: node + linkType: hard + "browserslist@npm:^4.23.1": version: 4.23.3 resolution: "browserslist@npm:4.23.3" @@ -3483,6 +3938,17 @@ __metadata: languageName: node linkType: hard +"bundle-require@npm:^3.0.2": + version: 3.1.2 + resolution: "bundle-require@npm:3.1.2" + dependencies: + load-tsconfig: "npm:^0.2.0" + peerDependencies: + esbuild: ">=0.13" + checksum: 10c0/73f77df391a46f2cefc3bfc4777cd0169a47db1e69a64a16cb6a37208a03992ef68f02921e18ae4fba3387e076f37bcac8388077cba316ce9fd96105aec43f89 + languageName: node + linkType: hard + "busboy@npm:1.6.0": version: 1.6.0 resolution: "busboy@npm:1.6.0" @@ -3499,6 +3965,13 @@ __metadata: languageName: node linkType: hard +"cac@npm:^6.7.12": + version: 6.7.14 + resolution: "cac@npm:6.7.14" + checksum: 10c0/4ee06aaa7bab8981f0d54e5f5f9d4adcd64058e9697563ce336d8a3878ed018ee18ebe5359b2430eceae87e0758e62ea2019c3f52ae6e211b1bd2e133856cd10 + languageName: node + linkType: hard + "cacache@npm:^18.0.0, cacache@npm:^18.0.3": version: 18.0.4 resolution: "cacache@npm:18.0.4" @@ -3630,7 +4103,7 @@ __metadata: languageName: node linkType: hard -"chokidar@npm:^3.5.3": +"chokidar@npm:^3.5.1, chokidar@npm:^3.5.3": version: 3.6.0 resolution: "chokidar@npm:3.6.0" dependencies: @@ -4403,6 +4876,21 @@ __metadata: languageName: node linkType: hard +"elliptic@npm:6.5.4": + version: 6.5.4 + resolution: "elliptic@npm:6.5.4" + dependencies: + bn.js: "npm:^4.11.9" + brorand: "npm:^1.1.0" + hash.js: "npm:^1.0.0" + hmac-drbg: "npm:^1.0.1" + inherits: "npm:^2.0.4" + minimalistic-assert: "npm:^1.0.1" + minimalistic-crypto-utils: "npm:^1.0.1" + checksum: 10c0/5f361270292c3b27cf0843e84526d11dec31652f03c2763c6c2b8178548175ff5eba95341dd62baff92b2265d1af076526915d8af6cc9cb7559c44a62f8ca6e2 + languageName: node + linkType: hard + "emittery@npm:^0.13.1": version: 0.13.1 resolution: "emittery@npm:0.13.1" @@ -4642,6 +5130,220 @@ __metadata: languageName: node linkType: hard +"esbuild-android-64@npm:0.14.54": + version: 0.14.54 + resolution: "esbuild-android-64@npm:0.14.54" + conditions: os=android & cpu=x64 + languageName: node + linkType: hard + +"esbuild-android-arm64@npm:0.14.54": + version: 0.14.54 + resolution: "esbuild-android-arm64@npm:0.14.54" + conditions: os=android & cpu=arm64 + languageName: node + linkType: hard + +"esbuild-darwin-64@npm:0.14.54": + version: 0.14.54 + resolution: "esbuild-darwin-64@npm:0.14.54" + conditions: os=darwin & cpu=x64 + languageName: node + linkType: hard + +"esbuild-darwin-arm64@npm:0.14.54": + version: 0.14.54 + resolution: "esbuild-darwin-arm64@npm:0.14.54" + conditions: os=darwin & cpu=arm64 + languageName: node + linkType: hard + +"esbuild-freebsd-64@npm:0.14.54": + version: 0.14.54 + resolution: "esbuild-freebsd-64@npm:0.14.54" + conditions: os=freebsd & cpu=x64 + languageName: node + linkType: hard + +"esbuild-freebsd-arm64@npm:0.14.54": + version: 0.14.54 + resolution: "esbuild-freebsd-arm64@npm:0.14.54" + conditions: os=freebsd & cpu=arm64 + languageName: node + linkType: hard + +"esbuild-linux-32@npm:0.14.54": + version: 0.14.54 + resolution: "esbuild-linux-32@npm:0.14.54" + conditions: os=linux & cpu=ia32 + languageName: node + linkType: hard + +"esbuild-linux-64@npm:0.14.54": + version: 0.14.54 + resolution: "esbuild-linux-64@npm:0.14.54" + conditions: os=linux & cpu=x64 + languageName: node + linkType: hard + +"esbuild-linux-arm64@npm:0.14.54": + version: 0.14.54 + resolution: "esbuild-linux-arm64@npm:0.14.54" + conditions: os=linux & cpu=arm64 + languageName: node + linkType: hard + +"esbuild-linux-arm@npm:0.14.54": + version: 0.14.54 + resolution: "esbuild-linux-arm@npm:0.14.54" + conditions: os=linux & cpu=arm + languageName: node + linkType: hard + +"esbuild-linux-mips64le@npm:0.14.54": + version: 0.14.54 + resolution: "esbuild-linux-mips64le@npm:0.14.54" + conditions: os=linux & cpu=mips64el + languageName: node + linkType: hard + +"esbuild-linux-ppc64le@npm:0.14.54": + version: 0.14.54 + resolution: "esbuild-linux-ppc64le@npm:0.14.54" + conditions: os=linux & cpu=ppc64 + languageName: node + linkType: hard + +"esbuild-linux-riscv64@npm:0.14.54": + version: 0.14.54 + resolution: "esbuild-linux-riscv64@npm:0.14.54" + conditions: os=linux & cpu=riscv64 + languageName: node + linkType: hard + +"esbuild-linux-s390x@npm:0.14.54": + version: 0.14.54 + resolution: "esbuild-linux-s390x@npm:0.14.54" + conditions: os=linux & cpu=s390x + languageName: node + linkType: hard + +"esbuild-netbsd-64@npm:0.14.54": + version: 0.14.54 + resolution: "esbuild-netbsd-64@npm:0.14.54" + conditions: os=netbsd & cpu=x64 + languageName: node + linkType: hard + +"esbuild-openbsd-64@npm:0.14.54": + version: 0.14.54 + resolution: "esbuild-openbsd-64@npm:0.14.54" + conditions: os=openbsd & cpu=x64 + languageName: node + linkType: hard + +"esbuild-sunos-64@npm:0.14.54": + version: 0.14.54 + resolution: "esbuild-sunos-64@npm:0.14.54" + conditions: os=sunos & cpu=x64 + languageName: node + linkType: hard + +"esbuild-windows-32@npm:0.14.54": + version: 0.14.54 + resolution: "esbuild-windows-32@npm:0.14.54" + conditions: os=win32 & cpu=ia32 + languageName: node + linkType: hard + +"esbuild-windows-64@npm:0.14.54": + version: 0.14.54 + resolution: "esbuild-windows-64@npm:0.14.54" + conditions: os=win32 & cpu=x64 + languageName: node + linkType: hard + +"esbuild-windows-arm64@npm:0.14.54": + version: 0.14.54 + resolution: "esbuild-windows-arm64@npm:0.14.54" + conditions: os=win32 & cpu=arm64 + languageName: node + linkType: hard + +"esbuild@npm:^0.14.25": + version: 0.14.54 + resolution: "esbuild@npm:0.14.54" + dependencies: + "@esbuild/linux-loong64": "npm:0.14.54" + esbuild-android-64: "npm:0.14.54" + esbuild-android-arm64: "npm:0.14.54" + esbuild-darwin-64: "npm:0.14.54" + esbuild-darwin-arm64: "npm:0.14.54" + esbuild-freebsd-64: "npm:0.14.54" + esbuild-freebsd-arm64: "npm:0.14.54" + esbuild-linux-32: "npm:0.14.54" + esbuild-linux-64: "npm:0.14.54" + esbuild-linux-arm: "npm:0.14.54" + esbuild-linux-arm64: "npm:0.14.54" + esbuild-linux-mips64le: "npm:0.14.54" + esbuild-linux-ppc64le: "npm:0.14.54" + esbuild-linux-riscv64: "npm:0.14.54" + esbuild-linux-s390x: "npm:0.14.54" + esbuild-netbsd-64: "npm:0.14.54" + esbuild-openbsd-64: "npm:0.14.54" + esbuild-sunos-64: "npm:0.14.54" + esbuild-windows-32: "npm:0.14.54" + esbuild-windows-64: "npm:0.14.54" + esbuild-windows-arm64: "npm:0.14.54" + dependenciesMeta: + "@esbuild/linux-loong64": + optional: true + esbuild-android-64: + optional: true + esbuild-android-arm64: + optional: true + esbuild-darwin-64: + optional: true + esbuild-darwin-arm64: + optional: true + esbuild-freebsd-64: + optional: true + esbuild-freebsd-arm64: + optional: true + esbuild-linux-32: + optional: true + esbuild-linux-64: + optional: true + esbuild-linux-arm: + optional: true + esbuild-linux-arm64: + optional: true + esbuild-linux-mips64le: + optional: true + esbuild-linux-ppc64le: + optional: true + esbuild-linux-riscv64: + optional: true + esbuild-linux-s390x: + optional: true + esbuild-netbsd-64: + optional: true + esbuild-openbsd-64: + optional: true + esbuild-sunos-64: + optional: true + esbuild-windows-32: + optional: true + esbuild-windows-64: + optional: true + esbuild-windows-arm64: + optional: true + bin: + esbuild: bin/esbuild + checksum: 10c0/1df3cf7c5175ebee284fd027f287385a07ce8a0f0460a4412881aeff707577d91e55302f220ee8397b3b5aa17f4ceeb80eac16f36fc676532ff1b744e5965f2d + languageName: node + linkType: hard + "escalade@npm:^3.1.1, escalade@npm:^3.1.2": version: 3.1.2 resolution: "escalade@npm:3.1.2" @@ -4942,6 +5644,44 @@ __metadata: languageName: node linkType: hard +"ethers@npm:^5.4.0": + version: 5.7.2 + resolution: "ethers@npm:5.7.2" + dependencies: + "@ethersproject/abi": "npm:5.7.0" + "@ethersproject/abstract-provider": "npm:5.7.0" + "@ethersproject/abstract-signer": "npm:5.7.0" + "@ethersproject/address": "npm:5.7.0" + "@ethersproject/base64": "npm:5.7.0" + "@ethersproject/basex": "npm:5.7.0" + "@ethersproject/bignumber": "npm:5.7.0" + "@ethersproject/bytes": "npm:5.7.0" + "@ethersproject/constants": "npm:5.7.0" + "@ethersproject/contracts": "npm:5.7.0" + "@ethersproject/hash": "npm:5.7.0" + "@ethersproject/hdnode": "npm:5.7.0" + "@ethersproject/json-wallets": "npm:5.7.0" + "@ethersproject/keccak256": "npm:5.7.0" + "@ethersproject/logger": "npm:5.7.0" + "@ethersproject/networks": "npm:5.7.1" + "@ethersproject/pbkdf2": "npm:5.7.0" + "@ethersproject/properties": "npm:5.7.0" + "@ethersproject/providers": "npm:5.7.2" + "@ethersproject/random": "npm:5.7.0" + "@ethersproject/rlp": "npm:5.7.0" + "@ethersproject/sha2": "npm:5.7.0" + "@ethersproject/signing-key": "npm:5.7.0" + "@ethersproject/solidity": "npm:5.7.0" + "@ethersproject/strings": "npm:5.7.0" + "@ethersproject/transactions": "npm:5.7.0" + "@ethersproject/units": "npm:5.7.0" + "@ethersproject/wallet": "npm:5.7.0" + "@ethersproject/web": "npm:5.7.1" + "@ethersproject/wordlists": "npm:5.7.0" + checksum: 10c0/90629a4cdb88cde7a7694f5610a83eb00d7fbbaea687446b15631397988f591c554dd68dfa752ddf00aabefd6285e5b298be44187e960f5e4962684e10b39962 + languageName: node + linkType: hard + "ethers@npm:^6.9.1": version: 6.13.2 resolution: "ethers@npm:6.13.2" @@ -5624,7 +6364,7 @@ __metadata: languageName: node linkType: hard -"globby@npm:11.1.0, globby@npm:^11.1.0": +"globby@npm:11.1.0, globby@npm:^11.0.3, globby@npm:^11.1.0": version: 11.1.0 resolution: "globby@npm:11.1.0" dependencies: @@ -5746,6 +6486,16 @@ __metadata: languageName: node linkType: hard +"hash.js@npm:1.1.7, hash.js@npm:^1.0.0, hash.js@npm:^1.0.3": + version: 1.1.7 + resolution: "hash.js@npm:1.1.7" + dependencies: + inherits: "npm:^2.0.3" + minimalistic-assert: "npm:^1.0.1" + checksum: 10c0/41ada59494eac5332cfc1ce6b7ebdd7b88a3864a6d6b08a3ea8ef261332ed60f37f10877e0c825aaa4bddebf164fbffa618286aeeec5296675e2671cbfa746c4 + languageName: node + linkType: hard + "hasown@npm:^2.0.0, hasown@npm:^2.0.1, hasown@npm:^2.0.2": version: 2.0.2 resolution: "hasown@npm:2.0.2" @@ -5755,6 +6505,17 @@ __metadata: languageName: node linkType: hard +"hmac-drbg@npm:^1.0.1": + version: 1.0.1 + resolution: "hmac-drbg@npm:1.0.1" + dependencies: + hash.js: "npm:^1.0.3" + minimalistic-assert: "npm:^1.0.0" + minimalistic-crypto-utils: "npm:^1.0.1" + checksum: 10c0/f3d9ba31b40257a573f162176ac5930109816036c59a09f901eb2ffd7e5e705c6832bedfff507957125f2086a0ab8f853c0df225642a88bf1fcaea945f20600d + languageName: node + linkType: hard + "hosted-git-info@npm:^2.1.4": version: 2.8.9 resolution: "hosted-git-info@npm:2.8.9" @@ -6982,6 +7743,20 @@ __metadata: languageName: node linkType: hard +"joycon@npm:^3.0.1": + version: 3.1.1 + resolution: "joycon@npm:3.1.1" + checksum: 10c0/131fb1e98c9065d067fd49b6e685487ac4ad4d254191d7aa2c9e3b90f4e9ca70430c43cad001602bdbdabcf58717d3b5c5b7461c1bd8e39478c8de706b3fe6ae + languageName: node + linkType: hard + +"js-sha3@npm:0.8.0": + version: 0.8.0 + resolution: "js-sha3@npm:0.8.0" + checksum: 10c0/43a21dc7967c871bd2c46cb1c2ae97441a97169f324e509f382d43330d8f75cf2c96dba7c806ab08a425765a9c847efdd4bffbac2d99c3a4f3de6c0218f40533 + languageName: node + linkType: hard + "js-tokens@npm:^3.0.0 || ^4.0.0, js-tokens@npm:^4.0.0": version: 4.0.0 resolution: "js-tokens@npm:4.0.0" @@ -7330,7 +8105,7 @@ __metadata: languageName: node linkType: hard -"lilconfig@npm:^2.1.0": +"lilconfig@npm:^2.0.5, lilconfig@npm:^2.1.0": version: 2.1.0 resolution: "lilconfig@npm:2.1.0" checksum: 10c0/64645641aa8d274c99338e130554abd6a0190533c0d9eb2ce7ebfaf2e05c7d9961f3ffe2bfa39efd3b60c521ba3dd24fa236fe2775fc38501bf82bf49d4678b8 @@ -7382,6 +8157,13 @@ __metadata: languageName: node linkType: hard +"load-tsconfig@npm:^0.2.0": + version: 0.2.5 + resolution: "load-tsconfig@npm:0.2.5" + checksum: 10c0/bf2823dd26389d3497b6567f07435c5a7a58d9df82e879b0b3892f87d8db26900f84c85bc329ef41c0540c0d6a448d1c23ddc64a80f3ff6838b940f3915a3fcb + languageName: node + linkType: hard + "locate-path@npm:^2.0.0": version: 2.0.0 resolution: "locate-path@npm:2.0.0" @@ -7431,6 +8213,13 @@ __metadata: languageName: node linkType: hard +"lodash.sortby@npm:^4.7.0": + version: 4.7.0 + resolution: "lodash.sortby@npm:4.7.0" + checksum: 10c0/fc48fb54ff7669f33bb32997cab9460757ee99fafaf72400b261c3e10fde21538e47d8cfcbe6a25a31bcb5b7b727c27d52626386fc2de24eb059a6d64a89cdf5 + languageName: node + linkType: hard + "lodash@npm:^4.17.21": version: 4.17.21 resolution: "lodash@npm:4.17.21" @@ -7626,6 +8415,20 @@ __metadata: languageName: node linkType: hard +"minimalistic-assert@npm:^1.0.0, minimalistic-assert@npm:^1.0.1": + version: 1.0.1 + resolution: "minimalistic-assert@npm:1.0.1" + checksum: 10c0/96730e5601cd31457f81a296f521eb56036e6f69133c0b18c13fe941109d53ad23a4204d946a0d638d7f3099482a0cec8c9bb6d642604612ce43ee536be3dddd + languageName: node + linkType: hard + +"minimalistic-crypto-utils@npm:^1.0.1": + version: 1.0.1 + resolution: "minimalistic-crypto-utils@npm:1.0.1" + checksum: 10c0/790ecec8c5c73973a4fbf2c663d911033e8494d5fb0960a4500634766ab05d6107d20af896ca2132e7031741f19888154d44b2408ada0852446705441383e9f8 + languageName: node + linkType: hard + "minimatch@npm:3.0.5": version: 3.0.5 resolution: "minimatch@npm:3.0.5" @@ -8902,6 +9705,24 @@ __metadata: languageName: node linkType: hard +"postcss-load-config@npm:^3.0.1": + version: 3.1.4 + resolution: "postcss-load-config@npm:3.1.4" + dependencies: + lilconfig: "npm:^2.0.5" + yaml: "npm:^1.10.2" + peerDependencies: + postcss: ">=8.0.9" + ts-node: ">=9.0.0" + peerDependenciesMeta: + postcss: + optional: true + ts-node: + optional: true + checksum: 10c0/7d2cc6695c2fc063e4538316d651a687fdb55e48db453ff699de916a6ee55ab68eac2b120c28a6b8ca7aa746a588888351b810a215b5cd090eabea62c5762ede + languageName: node + linkType: hard + "postcss-load-config@npm:^4.0.1": version: 4.0.2 resolution: "postcss-load-config@npm:4.0.2" @@ -9543,6 +10364,20 @@ __metadata: languageName: node linkType: hard +"rollup@npm:^2.74.1": + version: 2.79.1 + resolution: "rollup@npm:2.79.1" + dependencies: + fsevents: "npm:~2.3.2" + dependenciesMeta: + fsevents: + optional: true + bin: + rollup: dist/bin/rollup + checksum: 10c0/421418687f5dcd7324f4387f203c6bfc7118b7ace789e30f5da022471c43e037a76f5fd93837052754eeeae798a4fb266ac05ccee1e594406d912a59af98dde9 + languageName: node + linkType: hard + "run-async@npm:^2.4.0": version: 2.4.1 resolution: "run-async@npm:2.4.1" @@ -9635,6 +10470,13 @@ __metadata: languageName: node linkType: hard +"scrypt-js@npm:3.0.1": + version: 3.0.1 + resolution: "scrypt-js@npm:3.0.1" + checksum: 10c0/e2941e1c8b5c84c7f3732b0153fee624f5329fc4e772a06270ee337d4d2df4174b8abb5e6ad53804a29f53890ecbc78f3775a319323568c0313040c0e55f5b10 + languageName: node + linkType: hard + "semver@npm:2 || 3 || 4 || 5, semver@npm:^5.6.0": version: 5.7.2 resolution: "semver@npm:5.7.2" @@ -9846,6 +10688,15 @@ __metadata: languageName: node linkType: hard +"source-map@npm:0.8.0-beta.0": + version: 0.8.0-beta.0 + resolution: "source-map@npm:0.8.0-beta.0" + dependencies: + whatwg-url: "npm:^7.0.0" + checksum: 10c0/fb4d9bde9a9fdb2c29b10e5eae6c71d10e09ef467e1afb75fdec2eb7e11fa5b343a2af553f74f18b695dbc0b81f9da2e9fa3d7a317d5985e9939499ec6087835 + languageName: node + linkType: hard + "source-map@npm:^0.6.0, source-map@npm:^0.6.1": version: 0.6.1 resolution: "source-map@npm:0.6.1" @@ -10168,7 +11019,7 @@ __metadata: languageName: node linkType: hard -"sucrase@npm:^3.32.0": +"sucrase@npm:^3.20.3, sucrase@npm:^3.32.0": version: 3.35.0 resolution: "sucrase@npm:3.35.0" dependencies: @@ -10402,6 +11253,15 @@ __metadata: languageName: node linkType: hard +"tr46@npm:^1.0.1": + version: 1.0.1 + resolution: "tr46@npm:1.0.1" + dependencies: + punycode: "npm:^2.1.0" + checksum: 10c0/41525c2ccce86e3ef30af6fa5e1464e6d8bb4286a58ea8db09228f598889581ef62347153f6636cd41553dc41685bdfad0a9d032ef58df9fbb0792b3447d0f04 + languageName: node + linkType: hard + "tr46@npm:~0.0.3": version: 0.0.3 resolution: "tr46@npm:0.0.3" @@ -10409,6 +11269,15 @@ __metadata: languageName: node linkType: hard +"tree-kill@npm:^1.2.2": + version: 1.2.2 + resolution: "tree-kill@npm:1.2.2" + bin: + tree-kill: cli.js + checksum: 10c0/7b1b7c7f17608a8f8d20a162e7957ac1ef6cd1636db1aba92f4e072dc31818c2ff0efac1e3d91064ede67ed5dc57c565420531a8134090a12ac10cf792ab14d2 + languageName: node + linkType: hard + "treeverse@npm:^3.0.0": version: 3.0.0 resolution: "treeverse@npm:3.0.0" @@ -10558,6 +11427,42 @@ __metadata: languageName: node linkType: hard +"tsup@npm:^5.0.0": + version: 5.12.9 + resolution: "tsup@npm:5.12.9" + dependencies: + bundle-require: "npm:^3.0.2" + cac: "npm:^6.7.12" + chokidar: "npm:^3.5.1" + debug: "npm:^4.3.1" + esbuild: "npm:^0.14.25" + execa: "npm:^5.0.0" + globby: "npm:^11.0.3" + joycon: "npm:^3.0.1" + postcss-load-config: "npm:^3.0.1" + resolve-from: "npm:^5.0.0" + rollup: "npm:^2.74.1" + source-map: "npm:0.8.0-beta.0" + sucrase: "npm:^3.20.3" + tree-kill: "npm:^1.2.2" + peerDependencies: + "@swc/core": ^1 + postcss: ^8.4.12 + typescript: ^4.1.0 + peerDependenciesMeta: + "@swc/core": + optional: true + postcss: + optional: true + typescript: + optional: true + bin: + tsup: dist/cli-default.js + tsup-node: dist/cli-node.js + checksum: 10c0/f1ab754974001ef7cccd2cc1322f718e4b29902edae6ea629cad13d104596b9c7372e4d1140e32bed9a586a33cb121f1f399bd63d08195337053efe951949fdd + languageName: node + linkType: hard + "tsyringe@npm:^4.8.0": version: 4.8.0 resolution: "tsyringe@npm:4.8.0" @@ -10705,6 +11610,16 @@ __metadata: languageName: node linkType: hard +"typescript@npm:^4.0.0": + version: 4.9.5 + resolution: "typescript@npm:4.9.5" + bin: + tsc: bin/tsc + tsserver: bin/tsserver + checksum: 10c0/5f6cad2e728a8a063521328e612d7876e12f0d8a8390d3b3aaa452a6a65e24e9ac8ea22beb72a924fd96ea0a49ea63bb4e251fb922b12eedfb7f7a26475e5c56 + languageName: node + linkType: hard + "typescript@patch:typescript@npm%3A>=3 < 6#optional!builtin, typescript@patch:typescript@npm%3A^5#optional!builtin, typescript@patch:typescript@npm%3A^5.4.5#optional!builtin, typescript@patch:typescript@npm%3A^5.5.4#optional!builtin": version: 5.5.4 resolution: "typescript@patch:typescript@npm%3A5.5.4#optional!builtin::version=5.5.4&hash=b45daf" @@ -10715,6 +11630,16 @@ __metadata: languageName: node linkType: hard +"typescript@patch:typescript@npm%3A^4.0.0#optional!builtin": + version: 4.9.5 + resolution: "typescript@patch:typescript@npm%3A4.9.5#optional!builtin::version=4.9.5&hash=289587" + bin: + tsc: bin/tsc + tsserver: bin/tsserver + checksum: 10c0/e3333f887c6829dfe0ab6c1dbe0dd1e3e2aeb56c66460cb85c5440c566f900c833d370ca34eb47558c0c69e78ced4bfe09b8f4f98b6de7afed9b84b8d1dd06a1 + languageName: node + linkType: hard + "uglify-js@npm:^3.1.4": version: 3.19.2 resolution: "uglify-js@npm:3.19.2" @@ -10943,6 +11868,13 @@ __metadata: languageName: node linkType: hard +"webidl-conversions@npm:^4.0.2": + version: 4.0.2 + resolution: "webidl-conversions@npm:4.0.2" + checksum: 10c0/def5c5ac3479286dffcb604547628b2e6b46c5c5b8a8cfaa8c71dc3bafc85859bde5fbe89467ff861f571ab38987cf6ab3d6e7c80b39b999e50e803c12f3164f + languageName: node + linkType: hard + "whatwg-url@npm:^5.0.0": version: 5.0.0 resolution: "whatwg-url@npm:5.0.0" @@ -10953,6 +11885,17 @@ __metadata: languageName: node linkType: hard +"whatwg-url@npm:^7.0.0": + version: 7.1.0 + resolution: "whatwg-url@npm:7.1.0" + dependencies: + lodash.sortby: "npm:^4.7.0" + tr46: "npm:^1.0.1" + webidl-conversions: "npm:^4.0.2" + checksum: 10c0/2785fe4647690e5a0225a79509ba5e21fdf4a71f9de3eabdba1192483fe006fc79961198e0b99f82751557309f17fc5a07d4d83c251aa5b2f85ba71e674cbee9 + languageName: node + linkType: hard + "which-boxed-primitive@npm:^1.0.2": version: 1.0.2 resolution: "which-boxed-primitive@npm:1.0.2" @@ -11152,6 +12095,21 @@ __metadata: languageName: node linkType: hard +"ws@npm:7.4.6": + version: 7.4.6 + resolution: "ws@npm:7.4.6" + peerDependencies: + bufferutil: ^4.0.1 + utf-8-validate: ^5.0.2 + peerDependenciesMeta: + bufferutil: + optional: true + utf-8-validate: + optional: true + checksum: 10c0/4b44b59bbc0549c852fb2f0cdb48e40e122a1b6078aeed3d65557cbeb7d37dda7a4f0027afba2e6a7a695de17701226d02b23bd15c97b0837808c16345c62f8e + languageName: node + linkType: hard + "ws@npm:8.17.1": version: 8.17.1 resolution: "ws@npm:8.17.1" @@ -11210,6 +12168,13 @@ __metadata: languageName: node linkType: hard +"yaml@npm:^1.10.2": + version: 1.10.2 + resolution: "yaml@npm:1.10.2" + checksum: 10c0/5c28b9eb7adc46544f28d9a8d20c5b3cb1215a886609a2fd41f51628d8aaa5878ccd628b755dbcd29f6bb4921bd04ffbc6dcc370689bb96e594e2f9813d2605f + languageName: node + linkType: hard + "yaml@npm:^2.3.4": version: 2.5.0 resolution: "yaml@npm:2.5.0" From f5db671be5459349092c0fbedfb586c0a87e7cdf Mon Sep 17 00:00:00 2001 From: Marc-Aurele Besner <82244926+marc-aurele-besner@users.noreply.github.com> Date: Mon, 16 Sep 2024 10:06:08 -0400 Subject: [PATCH 2/2] improve and make even more flexible -> auto-evm-storage --- .vscode/auto.code-workspace | 4 +- packages/auto-evm-storage/.gitignore | 2 + packages/auto-evm-storage/README.md | 62 +++++ .../foundry.toml | 0 .../package.json | 4 +- .../remappings.txt | 0 .../script/DeployAutoEnumerableMap.s.sol | 20 ++ .../script/DeployAutoEventLogger.s.sol | 18 ++ .../script/DeployAutoKeyValue.s.sol | 20 ++ .../script/DeployAutoLinkedList.s.sol | 0 .../script/DeployAutoMultiMap.s.sol | 22 ++ .../script/DeployAutoStackQueue.s.sol | 22 ++ .../src/AutoEnumerableMap.sol | 43 +++ .../auto-evm-storage/src/AutoEventLogger.sol | 38 +++ .../src/AutoKeyValue.sol} | 2 +- .../auto-evm-storage/src/AutoLinkedList.sol | 57 ++++ .../auto-evm-storage/src/AutoMultiMap.sol | 33 +++ .../auto-evm-storage/src/AutoStackQueue.sol | 86 ++++++ packages/auto-evm-storage/src/index.ts | 263 ++++++++++++++++++ .../test/AutoEnumerableMapTest.sol | 66 +++++ .../test/AutoEventLoggerTest.sol | 34 +++ .../test/AutoKeyValue.t.sol} | 42 +-- .../test/AutoLinkedListTest.sol | 47 ++++ .../test/AutoMultiMapTest.sol | 55 ++++ .../test/AutoStackQueueTest.sol | 65 +++++ .../tsconfig.json | 0 packages/auto-key-store/.gitignore | 1 - packages/auto-key-store/README.md | 12 - .../script/DeployAutoKeyStore.s.sol | 20 -- packages/auto-key-store/src/index.ts | 37 --- 30 files changed, 979 insertions(+), 96 deletions(-) create mode 100644 packages/auto-evm-storage/.gitignore create mode 100644 packages/auto-evm-storage/README.md rename packages/{auto-key-store => auto-evm-storage}/foundry.toml (100%) rename packages/{auto-key-store => auto-evm-storage}/package.json (83%) rename packages/{auto-key-store => auto-evm-storage}/remappings.txt (100%) create mode 100644 packages/auto-evm-storage/script/DeployAutoEnumerableMap.s.sol create mode 100644 packages/auto-evm-storage/script/DeployAutoEventLogger.s.sol create mode 100644 packages/auto-evm-storage/script/DeployAutoKeyValue.s.sol create mode 100644 packages/auto-evm-storage/script/DeployAutoLinkedList.s.sol create mode 100644 packages/auto-evm-storage/script/DeployAutoMultiMap.s.sol create mode 100644 packages/auto-evm-storage/script/DeployAutoStackQueue.s.sol create mode 100644 packages/auto-evm-storage/src/AutoEnumerableMap.sol create mode 100644 packages/auto-evm-storage/src/AutoEventLogger.sol rename packages/{auto-key-store/src/AutoKeyStore.sol => auto-evm-storage/src/AutoKeyValue.sol} (97%) create mode 100644 packages/auto-evm-storage/src/AutoLinkedList.sol create mode 100644 packages/auto-evm-storage/src/AutoMultiMap.sol create mode 100644 packages/auto-evm-storage/src/AutoStackQueue.sol create mode 100644 packages/auto-evm-storage/src/index.ts create mode 100644 packages/auto-evm-storage/test/AutoEnumerableMapTest.sol create mode 100644 packages/auto-evm-storage/test/AutoEventLoggerTest.sol rename packages/{auto-key-store/test/AutoKeyStore.t.sol => auto-evm-storage/test/AutoKeyValue.t.sol} (66%) create mode 100644 packages/auto-evm-storage/test/AutoLinkedListTest.sol create mode 100644 packages/auto-evm-storage/test/AutoMultiMapTest.sol create mode 100644 packages/auto-evm-storage/test/AutoStackQueueTest.sol rename packages/{auto-key-store => auto-evm-storage}/tsconfig.json (100%) delete mode 100644 packages/auto-key-store/.gitignore delete mode 100644 packages/auto-key-store/README.md delete mode 100644 packages/auto-key-store/script/DeployAutoKeyStore.s.sol delete mode 100644 packages/auto-key-store/src/index.ts diff --git a/.vscode/auto.code-workspace b/.vscode/auto.code-workspace index dc48d531..02901da7 100644 --- a/.vscode/auto.code-workspace +++ b/.vscode/auto.code-workspace @@ -21,8 +21,8 @@ "path": "../packages/auto-xdm", }, { - "name": "Auto-Key-Store", - "path": "../packages/auto-key-store", + "name": "Auto-EVM-Storage", + "path": "../packages/auto-evm-storage", }, { "name": "Example - NextJS", diff --git a/packages/auto-evm-storage/.gitignore b/packages/auto-evm-storage/.gitignore new file mode 100644 index 00000000..396a6f5a --- /dev/null +++ b/packages/auto-evm-storage/.gitignore @@ -0,0 +1,2 @@ +out/ +cache/ \ No newline at end of file diff --git a/packages/auto-evm-storage/README.md b/packages/auto-evm-storage/README.md new file mode 100644 index 00000000..9c6a6fed --- /dev/null +++ b/packages/auto-evm-storage/README.md @@ -0,0 +1,62 @@ +# @autonomys/auto-emv-storage + +A comprehensive npm package for deploying and interacting with various data structure smart contracts on Autonomys Nova (EVM) domains. This package provides a simple and efficient way to manage different types of data structures on the blockchain. + +## Features + +- Easy deployment and interaction with multiple smart contract data structures: + + - AutoKeyValue: Key-value store with role-based access control + - AutoEnumerableMap: Enumerable map with key-value pairs + - AutoMultiMap: Multi-map allowing multiple values per key + - AutoLinkedList: Linked list implementation + - AutoStackQueue: Combined stack and queue data structure + - AutoEventLogger: Event logging and retrieval system + +- Simple TypeScript API for interacting with each data structure +- Role-based access control for writers and editors (where applicable) +- Seamless integration with Ethereum-compatible networks + +## Installation + +To install the package, use npm or yarn: + +```bash +npm install @autonomys/auto-evm-storage +# or +yarn add @autonomys/auto-evm-storage +``` + +## Usage + +### AutoKeyValue + +The `AutoKeyValue` contract is a key-value store with role-based access control. It allows for setting and retrieving values associated with specific keys. + +#### Deployment + +To deploy the `AutoKeyValue` contract, use the following TypeScript code: + +```typescript +import { AutoKeyValue } from '@autonomys/auto-evm-storage' + +const autoKeyValue = new AutoKeyValue(provider) +``` + +#### Setting and Retrieving Values + +To set a value for a key, use the `setValue` method: + +```typescript +const value = await autoKeyValue.setValue('key', 'value') +``` + +To retrieve a value for a key, use the `getValue` method: + +```typescript +const value = await autoKeyValue.getValue('key') +``` + +### AutoEnumerableMap + +The `AutoEnumerableMap` contract is an enumerable map with key-value pairs. It allows for setting and retrieving values associated with specific keys. diff --git a/packages/auto-key-store/foundry.toml b/packages/auto-evm-storage/foundry.toml similarity index 100% rename from packages/auto-key-store/foundry.toml rename to packages/auto-evm-storage/foundry.toml diff --git a/packages/auto-key-store/package.json b/packages/auto-evm-storage/package.json similarity index 83% rename from packages/auto-key-store/package.json rename to packages/auto-evm-storage/package.json index 5b57e82d..47f58c00 100644 --- a/packages/auto-key-store/package.json +++ b/packages/auto-evm-storage/package.json @@ -1,5 +1,5 @@ { - "name": "@autonomys/auto-key-store", + "name": "@autonomys/auto-emv-storage", "version": "0.1.0", "main": "dist/index.js", "scripts": { @@ -22,7 +22,7 @@ "tsup": "^5.0.0", "typescript": "^4.0.0" }, - "description": "A compact npm package for deploying and interacting with a key-value store smart contract on Autonomy's Nova network.", + "description": "A compact npm package for deploying and interacting with different types of storage smart contracts on Autonomy's Nova network.", "directories": { "test": "test" }, diff --git a/packages/auto-key-store/remappings.txt b/packages/auto-evm-storage/remappings.txt similarity index 100% rename from packages/auto-key-store/remappings.txt rename to packages/auto-evm-storage/remappings.txt diff --git a/packages/auto-evm-storage/script/DeployAutoEnumerableMap.s.sol b/packages/auto-evm-storage/script/DeployAutoEnumerableMap.s.sol new file mode 100644 index 00000000..8cc059d9 --- /dev/null +++ b/packages/auto-evm-storage/script/DeployAutoEnumerableMap.s.sol @@ -0,0 +1,20 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +import "forge-std/Script.sol"; +import "../src/AutoEnumerableMap.sol"; + +contract DeployAutoEnumerableMap is Script { + function run() external { + vm.startBroadcast(); + + AutoEnumerableMap autoEnumerableMap = new AutoEnumerableMap(msg.sender); + + // Example usage + bytes32 key = keccak256(abi.encodePacked("exampleKey")); + bytes32 value = keccak256(abi.encodePacked("exampleValue")); + autoEnumerableMap.set(key, value); + + vm.stopBroadcast(); + } +} diff --git a/packages/auto-evm-storage/script/DeployAutoEventLogger.s.sol b/packages/auto-evm-storage/script/DeployAutoEventLogger.s.sol new file mode 100644 index 00000000..46bcd6ef --- /dev/null +++ b/packages/auto-evm-storage/script/DeployAutoEventLogger.s.sol @@ -0,0 +1,18 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +import "forge-std/Script.sol"; +import "../src/AutoEventLogger.sol"; + +contract DeployAutoEventLogger is Script { + function run() external { + vm.startBroadcast(); + + AutoEventLogger autoEventLogger = new AutoEventLogger(); + + // Example usage + autoEventLogger.logAction("Deployed contract"); + + vm.stopBroadcast(); + } +} diff --git a/packages/auto-evm-storage/script/DeployAutoKeyValue.s.sol b/packages/auto-evm-storage/script/DeployAutoKeyValue.s.sol new file mode 100644 index 00000000..820d6216 --- /dev/null +++ b/packages/auto-evm-storage/script/DeployAutoKeyValue.s.sol @@ -0,0 +1,20 @@ +pragma solidity ^0.8.0; + +import "forge-std/Script.sol"; +import "../src/AutoKeyValue.sol"; + +contract DeployAutoKeyValue is Script { + function run() external { + vm.startBroadcast(); + + AutoKeyValue autoKeyValue = new AutoKeyValue(msg.sender); + + // Set a key-value pair + autoKeyValue.setValue("exampleKey", "exampleValue"); + + // Retrieve the value for the key + autoKeyValue.getValue("exampleKey"); + + vm.stopBroadcast(); + } +} \ No newline at end of file diff --git a/packages/auto-evm-storage/script/DeployAutoLinkedList.s.sol b/packages/auto-evm-storage/script/DeployAutoLinkedList.s.sol new file mode 100644 index 00000000..e69de29b diff --git a/packages/auto-evm-storage/script/DeployAutoMultiMap.s.sol b/packages/auto-evm-storage/script/DeployAutoMultiMap.s.sol new file mode 100644 index 00000000..93edab08 --- /dev/null +++ b/packages/auto-evm-storage/script/DeployAutoMultiMap.s.sol @@ -0,0 +1,22 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +import "forge-std/Script.sol"; +import "../src/AutoMultiMap.sol"; + +contract DeployAutoMultiMap is Script { + function run() external { + vm.startBroadcast(); + + AutoMultiMap autoMultiMap = new AutoMultiMap(msg.sender); + + // Example usage + bytes32 key = keccak256(abi.encodePacked("exampleKey")); + bytes32 value1 = keccak256(abi.encodePacked("value1")); + bytes32 value2 = keccak256(abi.encodePacked("value2")); + autoMultiMap.addValue(key, value1); + autoMultiMap.addValue(key, value2); + + vm.stopBroadcast(); + } +} diff --git a/packages/auto-evm-storage/script/DeployAutoStackQueue.s.sol b/packages/auto-evm-storage/script/DeployAutoStackQueue.s.sol new file mode 100644 index 00000000..7ecd54b0 --- /dev/null +++ b/packages/auto-evm-storage/script/DeployAutoStackQueue.s.sol @@ -0,0 +1,22 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +import "forge-std/Script.sol"; +import "../src/AutoStackQueue.sol"; + +contract DeployAutoStackQueue is Script { + function run() external { + vm.startBroadcast(); + + AutoStackQueue autoStackQueue = new AutoStackQueue(msg.sender); + + // Example usage + autoStackQueue.push(1); + autoStackQueue.push(2); + + autoStackQueue.enqueue(10); + autoStackQueue.enqueue(20); + + vm.stopBroadcast(); + } +} diff --git a/packages/auto-evm-storage/src/AutoEnumerableMap.sol b/packages/auto-evm-storage/src/AutoEnumerableMap.sol new file mode 100644 index 00000000..1206f535 --- /dev/null +++ b/packages/auto-evm-storage/src/AutoEnumerableMap.sol @@ -0,0 +1,43 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +import "@openzeppelin/contracts/access/AccessControl.sol"; + +contract AutoEnumerableMap is AccessControl { + bytes32 public constant WRITER_ROLE = keccak256("WRITER_ROLE"); + + mapping(bytes32 => bytes32) private map; + bytes32[] private keys; + + event KeyValueSet(bytes32 indexed key, bytes32 value); + + constructor(address admin) { + _grantRole(DEFAULT_ADMIN_ROLE, admin); + } + + function set(bytes32 key, bytes32 value) public { + require( + hasRole(WRITER_ROLE, msg.sender), + "Access denied: No write permissions" + ); + + if (map[key] == bytes32(0)) { + keys.push(key); + } + + map[key] = value; + emit KeyValueSet(key, value); + } + + function get(bytes32 key) public view returns (bytes32) { + return map[key]; + } + + function getKeys() public view returns (bytes32[] memory) { + return keys; + } + + function grantWriterRole(address account) public onlyRole(DEFAULT_ADMIN_ROLE) { + grantRole(WRITER_ROLE, account); + } +} diff --git a/packages/auto-evm-storage/src/AutoEventLogger.sol b/packages/auto-evm-storage/src/AutoEventLogger.sol new file mode 100644 index 00000000..460a49ae --- /dev/null +++ b/packages/auto-evm-storage/src/AutoEventLogger.sol @@ -0,0 +1,38 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +contract AutoEventLogger { + struct Event { + address user; + string action; + uint256 timestamp; + } + + Event[] public events; + + event ActionLogged(address indexed user, string action, uint256 timestamp); + + function logAction(string memory action) public { + Event memory newEvent = Event({ + user: msg.sender, + action: action, + timestamp: block.timestamp + }); + + events.push(newEvent); + emit ActionLogged(msg.sender, action, block.timestamp); + } + + function getEvents() public view returns (Event[] memory) { + return events; + } + + function getEvent(uint256 index) public view returns (Event memory) { + require(index < events.length, "Invalid index"); + return events[index]; + } + + function getEventsCount() public view returns (uint256) { + return events.length; + } +} diff --git a/packages/auto-key-store/src/AutoKeyStore.sol b/packages/auto-evm-storage/src/AutoKeyValue.sol similarity index 97% rename from packages/auto-key-store/src/AutoKeyStore.sol rename to packages/auto-evm-storage/src/AutoKeyValue.sol index 8e64d10f..182838e5 100644 --- a/packages/auto-key-store/src/AutoKeyStore.sol +++ b/packages/auto-evm-storage/src/AutoKeyValue.sol @@ -3,7 +3,7 @@ pragma solidity ^0.8.0; import "@openzeppelin/contracts/access/AccessControl.sol"; -contract AutoKeyStore is AccessControl { +contract AutoKeyValue is AccessControl { bytes32 public constant WRITER_ROLE = keccak256("WRITER_ROLE"); bytes32 public constant EDITOR_ROLE = keccak256("EDITOR_ROLE"); diff --git a/packages/auto-evm-storage/src/AutoLinkedList.sol b/packages/auto-evm-storage/src/AutoLinkedList.sol new file mode 100644 index 00000000..67fdc954 --- /dev/null +++ b/packages/auto-evm-storage/src/AutoLinkedList.sol @@ -0,0 +1,57 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +import "@openzeppelin/contracts/access/AccessControl.sol"; + +contract AutoLinkedList is AccessControl { + bytes32 public constant WRITER_ROLE = keccak256("WRITER_ROLE"); + + struct Node { + uint256 data; + uint256 next; + } + + mapping(uint256 => Node) public nodes; + uint256 public head; + uint256 public size; + + event NodeAdded(uint256 indexed index, uint256 data); + + constructor(address admin) { + _grantRole(DEFAULT_ADMIN_ROLE, admin); + head = type(uint256).max; // Indicates the end of the list + size = 0; + } + + function addNode(uint256 data) public { + require( + hasRole(WRITER_ROLE, msg.sender), + "Access denied: No write permissions" + ); + + nodes[size] = Node(data, head); + head = size; + emit NodeAdded(size, data); + size++; + } + + function getNode(uint256 index) public view returns (uint256 data, uint256 next) { + require(index < size, "Index out of bounds"); + Node storage node = nodes[index]; + return (node.data, node.next); + } + + function traverse() public view returns (uint256[] memory) { + uint256[] memory dataList = new uint256[](size); + uint256 currentIndex = head; + for (uint256 i = 0; i < size; i++) { + dataList[i] = nodes[currentIndex].data; + currentIndex = nodes[currentIndex].next; + } + return dataList; + } + + function grantWriterRole(address account) public onlyRole(DEFAULT_ADMIN_ROLE) { + grantRole(WRITER_ROLE, account); + } +} diff --git a/packages/auto-evm-storage/src/AutoMultiMap.sol b/packages/auto-evm-storage/src/AutoMultiMap.sol new file mode 100644 index 00000000..1451ee84 --- /dev/null +++ b/packages/auto-evm-storage/src/AutoMultiMap.sol @@ -0,0 +1,33 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +import "@openzeppelin/contracts/access/AccessControl.sol"; + +contract AutoMultiMap is AccessControl { + bytes32 public constant WRITER_ROLE = keccak256("WRITER_ROLE"); + + mapping(bytes32 => bytes32[]) private multimap; + + event ValueAdded(bytes32 indexed key, bytes32 value); + + constructor(address admin) { + _grantRole(DEFAULT_ADMIN_ROLE, admin); + } + + function addValue(bytes32 key, bytes32 value) public { + require( + hasRole(WRITER_ROLE, msg.sender), + "Access denied: No write permissions" + ); + multimap[key].push(value); + emit ValueAdded(key, value); + } + + function getValues(bytes32 key) public view returns (bytes32[] memory) { + return multimap[key]; + } + + function grantWriterRole(address account) public onlyRole(DEFAULT_ADMIN_ROLE) { + grantRole(WRITER_ROLE, account); + } +} diff --git a/packages/auto-evm-storage/src/AutoStackQueue.sol b/packages/auto-evm-storage/src/AutoStackQueue.sol new file mode 100644 index 00000000..35cd4a2f --- /dev/null +++ b/packages/auto-evm-storage/src/AutoStackQueue.sol @@ -0,0 +1,86 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +import "@openzeppelin/contracts/access/AccessControl.sol"; + +contract AutoStackQueue is AccessControl { + bytes32 public constant WRITER_ROLE = keccak256("WRITER_ROLE"); + + uint256[] private stack; + uint256[] private queue; + uint256 private queueHead; + + event StackPushed(uint256 value); + event StackPopped(uint256 value); + event QueueEnqueued(uint256 value); + event QueueDequeued(uint256 value); + + constructor(address admin) { + _grantRole(DEFAULT_ADMIN_ROLE, admin); + queueHead = 0; + } + + // Stack functions + function push(uint256 value) public { + require( + hasRole(WRITER_ROLE, msg.sender), + "Access denied: No write permissions" + ); + stack.push(value); + emit StackPushed(value); + } + + function pop() public { + require( + hasRole(WRITER_ROLE, msg.sender), + "Access denied: No write permissions" + ); + require(stack.length > 0, "Stack is empty"); + uint256 value = stack[stack.length - 1]; + stack.pop(); + emit StackPopped(value); + } + + function stackTop() public view returns (uint256) { + require(stack.length > 0, "Stack is empty"); + return stack[stack.length - 1]; + } + + function stackSize() public view returns (uint256) { + return stack.length; + } + + // Queue functions + function enqueue(uint256 value) public { + require( + hasRole(WRITER_ROLE, msg.sender), + "Access denied: No write permissions" + ); + queue.push(value); + emit QueueEnqueued(value); + } + + function dequeue() public { + require( + hasRole(WRITER_ROLE, msg.sender), + "Access denied: No write permissions" + ); + require(queueHead < queue.length, "Queue is empty"); + uint256 value = queue[queueHead]; + queueHead++; + emit QueueDequeued(value); + } + + function queueFront() public view returns (uint256) { + require(queueHead < queue.length, "Queue is empty"); + return queue[queueHead]; + } + + function queueSize() public view returns (uint256) { + return queue.length - queueHead; + } + + function grantWriterRole(address account) public onlyRole(DEFAULT_ADMIN_ROLE) { + grantRole(WRITER_ROLE, account); + } +} diff --git a/packages/auto-evm-storage/src/index.ts b/packages/auto-evm-storage/src/index.ts new file mode 100644 index 00000000..5a697657 --- /dev/null +++ b/packages/auto-evm-storage/src/index.ts @@ -0,0 +1,263 @@ +// src/index.ts + +import { ethers } from 'ethers' + +// Utility functions +const stringToBytes32 = (str: string): string => ethers.utils.formatBytes32String(str) +const bytes32ToString = (bytes: ethers.BytesLike): string => ethers.utils.parseBytes32String(bytes) + +// Helper to create a contract instance +const createContract = ( + providerOrSigner: ethers.providers.Provider | ethers.Signer, + contractAddress: string, + abi: any, +): ethers.Contract => new ethers.Contract(contractAddress, abi, providerOrSigner) + +// AutoKeyValue functions +export const autoKeyValue = ( + providerOrSigner: ethers.providers.Provider | ethers.Signer, + contractAddress: string, + abi: any, +) => { + const contract = createContract(providerOrSigner, contractAddress, abi) + + const setValue = (key: string, value: string): Promise => { + return contract.setValue(key, value) + } + + const getValue = (key: string): Promise => { + return contract.getValue(key) + } + + const grantWriterRole = (account: string): Promise => { + return contract.grantWriterRole(account) + } + + const grantEditorRole = (account: string): Promise => { + return contract.grantEditorRole(account) + } + + const setMultipleValues = ( + keys: string[], + values: string[], + ): Promise => { + return contract.setMultipleValues(keys, values) + } + + const getMultipleValues = (keys: string[]): Promise => { + return contract.getMultipleValues(keys) + } + + return { + setValue, + getValue, + grantWriterRole, + grantEditorRole, + setMultipleValues, + getMultipleValues, + } +} + +// AutoEnumerableMap functions +export const autoEnumerableMap = ( + providerOrSigner: ethers.providers.Provider | ethers.Signer, + contractAddress: string, + abi: any, +) => { + const contract = createContract(providerOrSigner, contractAddress, abi) + + const set = (key: string, value: string): Promise => { + return contract.set(stringToBytes32(key), stringToBytes32(value)) + } + + const get = async (key: string): Promise => { + const value = await contract.get(stringToBytes32(key)) + return bytes32ToString(value) + } + + const getKeys = async (): Promise => { + const keys = await contract.getKeys() + return keys.map((key: ethers.BytesLike) => bytes32ToString(key)) + } + + const grantWriterRole = (account: string): Promise => { + return contract.grantWriterRole(account) + } + + return { + set, + get, + getKeys, + grantWriterRole, + } +} + +// AutoMultiMap functions +export const autoMultiMap = ( + providerOrSigner: ethers.providers.Provider | ethers.Signer, + contractAddress: string, + abi: any, +) => { + const contract = createContract(providerOrSigner, contractAddress, abi) + + const addValue = (key: string, value: string): Promise => { + return contract.addValue(stringToBytes32(key), stringToBytes32(value)) + } + + const getValues = async (key: string): Promise => { + const values = await contract.getValues(stringToBytes32(key)) + return values.map((value: ethers.BytesLike) => bytes32ToString(value)) + } + + const grantWriterRole = (account: string): Promise => { + return contract.grantWriterRole(account) + } + + return { + addValue, + getValues, + grantWriterRole, + } +} + +// AutoLinkedList functions +export const autoLinkedList = ( + providerOrSigner: ethers.providers.Provider | ethers.Signer, + contractAddress: string, + abi: any, +) => { + const contract = createContract(providerOrSigner, contractAddress, abi) + + const addNode = (data: number): Promise => { + return contract.addNode(data) + } + + const getNode = async (index: number): Promise<{ data: number; next: number }> => { + const [data, next] = await contract.getNode(index) + return { data: data.toNumber(), next: next.toNumber() } + } + + const traverse = async (): Promise => { + const dataList = await contract.traverse() + return dataList.map((data: ethers.BigNumber) => data.toNumber()) + } + + const grantWriterRole = (account: string): Promise => { + return contract.grantWriterRole(account) + } + + return { + addNode, + getNode, + traverse, + grantWriterRole, + } +} + +// AutoStackQueue functions +export const autoStackQueue = ( + providerOrSigner: ethers.providers.Provider | ethers.Signer, + contractAddress: string, + abi: any, +) => { + const contract = createContract(providerOrSigner, contractAddress, abi) + + const push = (value: number): Promise => { + return contract.push(value) + } + + const pop = (): Promise => { + return contract.pop() + } + + const stackTop = async (): Promise => { + const value = await contract.stackTop() + return value.toNumber() + } + + const stackSize = async (): Promise => { + const size = await contract.stackSize() + return size.toNumber() + } + + const enqueue = (value: number): Promise => { + return contract.enqueue(value) + } + + const dequeue = (): Promise => { + return contract.dequeue() + } + + const queueFront = async (): Promise => { + const value = await contract.queueFront() + return value.toNumber() + } + + const queueSize = async (): Promise => { + const size = await contract.queueSize() + return size.toNumber() + } + + const grantWriterRole = (account: string): Promise => { + return contract.grantWriterRole(account) + } + + return { + push, + pop, + stackTop, + stackSize, + enqueue, + dequeue, + queueFront, + queueSize, + grantWriterRole, + } +} + +// AutoEventLogger functions +export const autoEventLogger = ( + providerOrSigner: ethers.providers.Provider | ethers.Signer, + contractAddress: string, + abi: any, +) => { + const contract = createContract(providerOrSigner, contractAddress, abi) + + const logAction = (action: string): Promise => { + return contract.logAction(action) + } + + const getEventsCount = async (): Promise => { + const count = await contract.getEventsCount() + return count.toNumber() + } + + const getEvent = async ( + index: number, + ): Promise<{ user: string; action: string; timestamp: number }> => { + const event = await contract.getEvent(index) + return { + user: event.user, + action: event.action, + timestamp: event.timestamp.toNumber(), + } + } + + const getEvents = async (): Promise< + Array<{ user: string; action: string; timestamp: number }> + > => { + const events = await contract.getEvents() + return events.map((event: any) => ({ + user: event.user, + action: event.action, + timestamp: event.timestamp.toNumber(), + })) + } + + return { + logAction, + getEventsCount, + getEvent, + getEvents, + } +} diff --git a/packages/auto-evm-storage/test/AutoEnumerableMapTest.sol b/packages/auto-evm-storage/test/AutoEnumerableMapTest.sol new file mode 100644 index 00000000..cc2508dd --- /dev/null +++ b/packages/auto-evm-storage/test/AutoEnumerableMapTest.sol @@ -0,0 +1,66 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +import "forge-std/Test.sol"; +import "../src/AutoEnumerableMap.sol"; + +contract AutoEnumerableMapTest is Test { + AutoEnumerableMap autoEnumerableMap; + address admin = address(1); + address writer = address(2); + address unauthorized = address(3); + + function setUp() public { + vm.startPrank(admin); + autoEnumerableMap = new AutoEnumerableMap(admin); + autoEnumerableMap.grantWriterRole(writer); + vm.stopPrank(); + } + + function testSetAndGet() public { + vm.prank(writer); + bytes32 key = keccak256(abi.encodePacked("key1")); + bytes32 value = keccak256(abi.encodePacked("value1")); + autoEnumerableMap.set(key, value); + + bytes32 retrievedValue = autoEnumerableMap.get(key); + assertEq(retrievedValue, value); + } + + function testUnauthorizedCannotSet() public { + vm.prank(unauthorized); + bytes32 key = keccak256(abi.encodePacked("key1")); + bytes32 value = keccak256(abi.encodePacked("value1")); + vm.expectRevert("Access denied: No write permissions"); + autoEnumerableMap.set(key, value); + } + + function testGetKeys() public { + vm.prank(writer); + bytes32 key1 = keccak256(abi.encodePacked("key1")); + bytes32 value1 = keccak256(abi.encodePacked("value1")); + autoEnumerableMap.set(key1, value1); + + bytes32 key2 = keccak256(abi.encodePacked("key2")); + bytes32 value2 = keccak256(abi.encodePacked("value2")); + autoEnumerableMap.set(key2, value2); + + bytes32[] memory keys = autoEnumerableMap.getKeys(); + assertEq(keys.length, 2); + assertEq(keys[0], key1); + assertEq(keys[1], key2); + } + + function testGrantWriterRole() public { + vm.prank(admin); + autoEnumerableMap.grantWriterRole(unauthorized); + + bytes32 key = keccak256(abi.encodePacked("key3")); + bytes32 value = keccak256(abi.encodePacked("value3")); + vm.prank(unauthorized); + autoEnumerableMap.set(key, value); + + bytes32 retrievedValue = autoEnumerableMap.get(key); + assertEq(retrievedValue, value); + } +} diff --git a/packages/auto-evm-storage/test/AutoEventLoggerTest.sol b/packages/auto-evm-storage/test/AutoEventLoggerTest.sol new file mode 100644 index 00000000..141597e9 --- /dev/null +++ b/packages/auto-evm-storage/test/AutoEventLoggerTest.sol @@ -0,0 +1,34 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +import "forge-std/Test.sol"; +import "../src/AutoEventLogger.sol"; + +contract AutoEventLoggerTest is Test { + AutoEventLogger autoEventLogger; + address user1 = address(1); + address user2 = address(2); + + function setUp() public { + autoEventLogger = new AutoEventLogger(); + } + + function testLogAction() public { + vm.prank(user1); + autoEventLogger.logAction("User1 did something"); + + vm.prank(user2); + autoEventLogger.logAction("User2 did something else"); + + uint256 count = autoEventLogger.getEventsCount(); + assertEq(count, 2); + + AutoEventLogger.Event memory event1 = autoEventLogger.getEvent(0); + assertEq(event1.user, user1); + assertEq(event1.action, "User1 did something"); + + AutoEventLogger.Event memory event2 = autoEventLogger.getEvent(1); + assertEq(event2.user, user2); + assertEq(event2.action, "User2 did something else"); + } +} diff --git a/packages/auto-key-store/test/AutoKeyStore.t.sol b/packages/auto-evm-storage/test/AutoKeyValue.t.sol similarity index 66% rename from packages/auto-key-store/test/AutoKeyStore.t.sol rename to packages/auto-evm-storage/test/AutoKeyValue.t.sol index 4890fe35..2712750c 100644 --- a/packages/auto-key-store/test/AutoKeyStore.t.sol +++ b/packages/auto-evm-storage/test/AutoKeyValue.t.sol @@ -2,10 +2,10 @@ pragma solidity ^0.8.0; import "forge-std/Test.sol"; -import "../src/AutoKeyStore.sol"; +import "../src/AutoKeyValue.sol"; -contract AutoKeyStoreTest is Test { - AutoKeyStore autoKeyStore; +contract AutoKeyValueTest is Test { + AutoKeyValue autoKeyValue; address admin = address(1); address writer = address(2); address editor = address(3); @@ -13,17 +13,17 @@ contract AutoKeyStoreTest is Test { function setUp() public { vm.startPrank(admin); - autoKeyStore = new AutoKeyStore(admin); - autoKeyStore.grantWriterRole(writer); - autoKeyStore.grantEditorRole(editor); + autoKeyValue = new AutoKeyValue(admin); + autoKeyValue.grantWriterRole(writer); + autoKeyValue.grantEditorRole(editor); vm.stopPrank(); } /// @notice Test that a writer can set and get a value function testSetAndGetValue() public { vm.prank(writer); - autoKeyStore.setValue("key1", "value1"); - string memory value = autoKeyStore.getValue("key1"); + autoKeyValue.setValue("key1", "value1"); + string memory value = autoKeyValue.getValue("key1"); assertEq(value, "value1"); } @@ -31,14 +31,14 @@ contract AutoKeyStoreTest is Test { function testUnauthorizedCannotSetValue() public { vm.prank(unauthorized); vm.expectRevert("Access denied: No write permissions"); - autoKeyStore.setValue("key1", "value1"); + autoKeyValue.setValue("key1", "value1"); } /// @notice Test that an editor can set and get a value function testEditorCanSetValue() public { vm.prank(editor); - autoKeyStore.setValue("key2", "value2"); - string memory value = autoKeyStore.getValue("key2"); + autoKeyValue.setValue("key2", "value2"); + string memory value = autoKeyValue.getValue("key2"); assertEq(value, "value2"); } @@ -54,10 +54,10 @@ contract AutoKeyStoreTest is Test { values[0] = "value1"; values[1] = "value2"; - autoKeyStore.setMultipleValues(keys, values); + autoKeyValue.setMultipleValues(keys, values); - string memory value1 = autoKeyStore.getValue("key1"); - string memory value2 = autoKeyStore.getValue("key2"); + string memory value1 = autoKeyValue.getValue("key1"); + string memory value2 = autoKeyValue.getValue("key2"); assertEq(value1, "value1"); assertEq(value2, "value2"); @@ -66,15 +66,15 @@ contract AutoKeyStoreTest is Test { /// @notice Test getting multiple values function testGetMultipleValues() public { vm.startPrank(writer); - autoKeyStore.setValue("key1", "value1"); - autoKeyStore.setValue("key2", "value2"); + autoKeyValue.setValue("key1", "value1"); + autoKeyValue.setValue("key2", "value2"); vm.stopPrank(); string[] memory keys = new string[](2); // Declare and initialize keys array keys[0] = "key1"; keys[1] = "key2"; - string[] memory values = autoKeyStore.getMultipleValues(keys); + string[] memory values = autoKeyValue.getMultipleValues(keys); assertEq(values[0], "value1"); assertEq(values[1], "value2"); @@ -84,17 +84,17 @@ contract AutoKeyStoreTest is Test { function testOnlyAdminCanGrantRoles() public { vm.prank(unauthorized); vm.expectRevert(); - autoKeyStore.grantWriterRole(unauthorized); + autoKeyValue.grantWriterRole(unauthorized); } /// @notice Test that admin can grant roles function testAdminCanGrantRoles() public { vm.prank(admin); - autoKeyStore.grantWriterRole(unauthorized); + autoKeyValue.grantWriterRole(unauthorized); vm.prank(unauthorized); - autoKeyStore.setValue("key3", "value3"); - string memory value = autoKeyStore.getValue("key3"); + autoKeyValue.setValue("key3", "value3"); + string memory value = autoKeyValue.getValue("key3"); assertEq(value, "value3"); } } diff --git a/packages/auto-evm-storage/test/AutoLinkedListTest.sol b/packages/auto-evm-storage/test/AutoLinkedListTest.sol new file mode 100644 index 00000000..22f78367 --- /dev/null +++ b/packages/auto-evm-storage/test/AutoLinkedListTest.sol @@ -0,0 +1,47 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +import "forge-std/Test.sol"; +import "../src/AutoLinkedList.sol"; + +contract AutoLinkedListTest is Test { + AutoLinkedList autoLinkedList; + address admin = address(1); + address writer = address(2); + address unauthorized = address(3); + + function setUp() public { + vm.startPrank(admin); + autoLinkedList = new AutoLinkedList(admin); + autoLinkedList.grantWriterRole(writer); + vm.stopPrank(); + } + + function testAddAndGetNode() public { + vm.prank(writer); + autoLinkedList.addNode(100); + + (uint256 data, uint256 next) = autoLinkedList.getNode(0); + assertEq(data, 100); + assertEq(next, type(uint256).max); + } + + function testTraverse() public { + vm.prank(writer); + autoLinkedList.addNode(100); + autoLinkedList.addNode(200); + autoLinkedList.addNode(300); + + uint256[] memory dataList = autoLinkedList.traverse(); + assertEq(dataList.length, 3); + assertEq(dataList[0], 300); + assertEq(dataList[1], 200); + assertEq(dataList[2], 100); + } + + function testUnauthorizedCannotAddNode() public { + vm.prank(unauthorized); + vm.expectRevert("Access denied: No write permissions"); + autoLinkedList.addNode(400); + } +} diff --git a/packages/auto-evm-storage/test/AutoMultiMapTest.sol b/packages/auto-evm-storage/test/AutoMultiMapTest.sol new file mode 100644 index 00000000..d7c6e742 --- /dev/null +++ b/packages/auto-evm-storage/test/AutoMultiMapTest.sol @@ -0,0 +1,55 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +import "forge-std/Test.sol"; +import "../src/AutoMultiMap.sol"; + +contract AutoMultiMapTest is Test { + AutoMultiMap autoMultiMap; + address admin = address(1); + address writer = address(2); + address unauthorized = address(3); + + function setUp() public { + vm.startPrank(admin); + autoMultiMap = new AutoMultiMap(admin); + autoMultiMap.grantWriterRole(writer); + vm.stopPrank(); + } + + function testAddAndGetValues() public { + vm.prank(writer); + bytes32 key = keccak256(abi.encodePacked("key1")); + bytes32 value1 = keccak256(abi.encodePacked("value1")); + bytes32 value2 = keccak256(abi.encodePacked("value2")); + autoMultiMap.addValue(key, value1); + autoMultiMap.addValue(key, value2); + + bytes32[] memory values = autoMultiMap.getValues(key); + assertEq(values.length, 2); + assertEq(values[0], value1); + assertEq(values[1], value2); + } + + function testUnauthorizedCannotAddValue() public { + vm.prank(unauthorized); + bytes32 key = keccak256(abi.encodePacked("key1")); + bytes32 value = keccak256(abi.encodePacked("value1")); + vm.expectRevert("Access denied: No write permissions"); + autoMultiMap.addValue(key, value); + } + + function testGrantWriterRole() public { + vm.prank(admin); + autoMultiMap.grantWriterRole(unauthorized); + + vm.prank(unauthorized); + bytes32 key = keccak256(abi.encodePacked("key2")); + bytes32 value = keccak256(abi.encodePacked("value3")); + autoMultiMap.addValue(key, value); + + bytes32[] memory values = autoMultiMap.getValues(key); + assertEq(values.length, 1); + assertEq(values[0], value); + } +} diff --git a/packages/auto-evm-storage/test/AutoStackQueueTest.sol b/packages/auto-evm-storage/test/AutoStackQueueTest.sol new file mode 100644 index 00000000..f76c032f --- /dev/null +++ b/packages/auto-evm-storage/test/AutoStackQueueTest.sol @@ -0,0 +1,65 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +import "forge-std/Test.sol"; +import "../src/AutoStackQueue.sol"; + +contract AutoStackQueueTest is Test { + AutoStackQueue autoStackQueue; + address admin = address(1); + address writer = address(2); + address unauthorized = address(3); + + function setUp() public { + vm.startPrank(admin); + autoStackQueue = new AutoStackQueue(admin); + autoStackQueue.grantWriterRole(writer); + vm.stopPrank(); + } + + function testStackPushAndPop() public { + vm.prank(writer); + autoStackQueue.push(1); + autoStackQueue.push(2); + autoStackQueue.push(3); + + assertEq(autoStackQueue.stackTop(), 3); + assertEq(autoStackQueue.stackSize(), 3); + + autoStackQueue.pop(); + assertEq(autoStackQueue.stackTop(), 2); + assertEq(autoStackQueue.stackSize(), 2); + + autoStackQueue.pop(); + autoStackQueue.pop(); + assertEq(autoStackQueue.stackSize(), 0); + } + + function testQueueEnqueueAndDequeue() public { + vm.prank(writer); + autoStackQueue.enqueue(10); + autoStackQueue.enqueue(20); + autoStackQueue.enqueue(30); + + assertEq(autoStackQueue.queueFront(), 10); + assertEq(autoStackQueue.queueSize(), 3); + + autoStackQueue.dequeue(); + assertEq(autoStackQueue.queueFront(), 20); + assertEq(autoStackQueue.queueSize(), 2); + + autoStackQueue.dequeue(); + autoStackQueue.dequeue(); + assertEq(autoStackQueue.queueSize(), 0); + } + + function testUnauthorizedCannotModify() public { + vm.prank(unauthorized); + vm.expectRevert("Access denied: No write permissions"); + autoStackQueue.push(100); + + vm.prank(unauthorized); + vm.expectRevert("Access denied: No write permissions"); + autoStackQueue.enqueue(200); + } +} diff --git a/packages/auto-key-store/tsconfig.json b/packages/auto-evm-storage/tsconfig.json similarity index 100% rename from packages/auto-key-store/tsconfig.json rename to packages/auto-evm-storage/tsconfig.json diff --git a/packages/auto-key-store/.gitignore b/packages/auto-key-store/.gitignore deleted file mode 100644 index 466e2480..00000000 --- a/packages/auto-key-store/.gitignore +++ /dev/null @@ -1 +0,0 @@ -out/ \ No newline at end of file diff --git a/packages/auto-key-store/README.md b/packages/auto-key-store/README.md deleted file mode 100644 index ed3b4e72..00000000 --- a/packages/auto-key-store/README.md +++ /dev/null @@ -1,12 +0,0 @@ -# Auto-Key-Store - -A compact npm package for deploying and interacting with a key-value store smart contract on Autonomy's Nova network. This package provides a simple and efficient way to manage key-value pairs on the blockchain. - -## Features - -- Easy deployment of a KeyValueStore smart contract -- Simple API for setting and retrieving key-value pairs -- Role-based access control for writers and editors -- Seamless integration with Autonomy's Nova network - -## Installation diff --git a/packages/auto-key-store/script/DeployAutoKeyStore.s.sol b/packages/auto-key-store/script/DeployAutoKeyStore.s.sol deleted file mode 100644 index 189f36d5..00000000 --- a/packages/auto-key-store/script/DeployAutoKeyStore.s.sol +++ /dev/null @@ -1,20 +0,0 @@ -pragma solidity ^0.8.0; - -import "forge-std/Script.sol"; -import "../src/AutoKeyStore.sol"; - -contract DeployAutoKeyStore is Script { - function run() external { - vm.startBroadcast(); - - AutoKeyStore autoKeyStore = new AutoKeyStore(msg.sender); - - // Set a key-value pair - autoKeyStore.setValue("exampleKey", "exampleValue"); - - // Retrieve the value for the key - autoKeyStore.getValue("exampleKey"); - - vm.stopBroadcast(); - } -} \ No newline at end of file diff --git a/packages/auto-key-store/src/index.ts b/packages/auto-key-store/src/index.ts deleted file mode 100644 index 337daef8..00000000 --- a/packages/auto-key-store/src/index.ts +++ /dev/null @@ -1,37 +0,0 @@ -import { ethers } from 'ethers' - -export class AutoKeyStore { - private contract: ethers.Contract - - constructor( - providerOrSigner: ethers.providers.Provider | ethers.Signer, - contractAddress: string, - abi: any, - ) { - this.contract = new ethers.Contract(contractAddress, abi, providerOrSigner) - } - - async setValue(key: string, value: string): Promise { - return this.contract.setValue(key, value) - } - - async getValue(key: string): Promise { - return this.contract.getValue(key) - } - - async grantWriterRole(account: string): Promise { - return this.contract.grantWriterRole(account) - } - - async grantEditorRole(account: string): Promise { - return this.contract.grantEditorRole(account) - } - - async setMultipleValues(keys: string[], values: string[]): Promise { - return this.contract.setMultipleValues(keys, values) - } - - async getMultipleValues(keys: string[]): Promise { - return this.contract.getMultipleValues(keys) - } -}