From f989461a094db70788904a1be415263d75eaed47 Mon Sep 17 00:00:00 2001 From: WuEcho Date: Fri, 13 Dec 2024 11:40:39 +0800 Subject: [PATCH] change openzeppelin version --- .gitmodules | 8 +++++++ docs/src/README.md | 10 +------- .../interface.IPrimusZkTLS.md | 2 +- .../struct.AttNetworkRequest.md | 2 +- .../struct.AttNetworkResponseResolve.md | 2 +- .../IPrimusZkTLS.sol/struct.Attestation.md | 2 +- .../src/IPrimusZkTLS.sol/struct.Attestor.md | 2 +- .../PrimusZkTLS.sol/contract.PrimusZkTLS.md | 6 ++--- lib/openzeppelin-contracts | 1 + lib/openzeppelin-contracts-upgradeable | 1 + script/Counter.s.sol | 19 --------------- script/PrimusZKTLS.s.sol | 2 +- src/Counter.sol | 14 ----------- src/PrimusZKTLS.sol | 14 +++++------ test/Counter.t.sol | 24 ------------------- 15 files changed, 27 insertions(+), 82 deletions(-) create mode 160000 lib/openzeppelin-contracts create mode 160000 lib/openzeppelin-contracts-upgradeable delete mode 100644 script/Counter.s.sol delete mode 100644 src/Counter.sol delete mode 100644 test/Counter.t.sol diff --git a/.gitmodules b/.gitmodules index 888d42d..462a6be 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,11 @@ [submodule "lib/forge-std"] path = lib/forge-std url = https://github.com/foundry-rs/forge-std +[submodule "lib/openzeppelin-contracts"] + path = lib/openzeppelin-contracts + url = https://github.com/OpenZeppelin/openzeppelin-contracts + branch = v4.9.0 +[submodule "lib/openzeppelin-contracts-upgradeable"] + path = lib/openzeppelin-contracts-upgradeable + url = https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable + branch = v4.9.0 \ No newline at end of file diff --git a/docs/src/README.md b/docs/src/README.md index e8e445e..9265b45 100644 --- a/docs/src/README.md +++ b/docs/src/README.md @@ -48,17 +48,9 @@ $ anvil ### Deploy ```shell -$ forge script script/PrimusZKTLS.s.sol --rpc-url --private-key --broadcast +$ forge script script/Counter.s.sol:CounterScript --rpc-url --private-key ``` -### Upgrade - -```shell -$ forge script script/UpgradeZKTLS.s.sol --rpc-url --private-key --broadcast - -``` - - ### Cast ```shell diff --git a/docs/src/src/IPrimusZkTLS.sol/interface.IPrimusZkTLS.md b/docs/src/src/IPrimusZkTLS.sol/interface.IPrimusZkTLS.md index 437f775..e9f7055 100644 --- a/docs/src/src/IPrimusZkTLS.sol/interface.IPrimusZkTLS.md +++ b/docs/src/src/IPrimusZkTLS.sol/interface.IPrimusZkTLS.md @@ -1,5 +1,5 @@ # IPrimusZKTLS -[Git Source](https://github.com/primus-labs/zkTLS-contracts/blob/598ebb1789581520b0b29d02a686bfae9b7ffe60/src/IPrimusZKTLS.sol) +[Git Source](https://github.com/primus-labs/zkTLS-contracts/blob/11f4cead3677496fd937372843f5c9fca4283fc1/src/IPrimusZKTLS.sol) *Interface of PrimusZKTLS, which defines functions for handling attestations and related operations.* diff --git a/docs/src/src/IPrimusZkTLS.sol/struct.AttNetworkRequest.md b/docs/src/src/IPrimusZkTLS.sol/struct.AttNetworkRequest.md index 92a4d35..fc9f16e 100644 --- a/docs/src/src/IPrimusZkTLS.sol/struct.AttNetworkRequest.md +++ b/docs/src/src/IPrimusZkTLS.sol/struct.AttNetworkRequest.md @@ -1,5 +1,5 @@ # AttNetworkRequest -[Git Source](https://github.com/primus-labs/zkTLS-contracts/blob/598ebb1789581520b0b29d02a686bfae9b7ffe60/src/IPrimusZKTLS.sol) +[Git Source](https://github.com/primus-labs/zkTLS-contracts/blob/11f4cead3677496fd937372843f5c9fca4283fc1/src/IPrimusZKTLS.sol) *Structure for representing a network request send to jsk and related to the attestation.* diff --git a/docs/src/src/IPrimusZkTLS.sol/struct.AttNetworkResponseResolve.md b/docs/src/src/IPrimusZkTLS.sol/struct.AttNetworkResponseResolve.md index 558fc29..2592e48 100644 --- a/docs/src/src/IPrimusZkTLS.sol/struct.AttNetworkResponseResolve.md +++ b/docs/src/src/IPrimusZkTLS.sol/struct.AttNetworkResponseResolve.md @@ -1,5 +1,5 @@ # AttNetworkResponseResolve -[Git Source](https://github.com/primus-labs/zkTLS-contracts/blob/598ebb1789581520b0b29d02a686bfae9b7ffe60/src/IPrimusZKTLS.sol) +[Git Source](https://github.com/primus-labs/zkTLS-contracts/blob/11f4cead3677496fd937372843f5c9fca4283fc1/src/IPrimusZKTLS.sol) *Structure for resolving responses from a network request.* diff --git a/docs/src/src/IPrimusZkTLS.sol/struct.Attestation.md b/docs/src/src/IPrimusZkTLS.sol/struct.Attestation.md index fe1a725..898f64f 100644 --- a/docs/src/src/IPrimusZkTLS.sol/struct.Attestation.md +++ b/docs/src/src/IPrimusZkTLS.sol/struct.Attestation.md @@ -1,5 +1,5 @@ # Attestation -[Git Source](https://github.com/primus-labs/zkTLS-contracts/blob/598ebb1789581520b0b29d02a686bfae9b7ffe60/src/IPrimusZKTLS.sol) +[Git Source](https://github.com/primus-labs/zkTLS-contracts/blob/11f4cead3677496fd937372843f5c9fca4283fc1/src/IPrimusZKTLS.sol) *Structure representing an attestation, which is a signed statement of fact.* diff --git a/docs/src/src/IPrimusZkTLS.sol/struct.Attestor.md b/docs/src/src/IPrimusZkTLS.sol/struct.Attestor.md index 7a85264..51072a6 100644 --- a/docs/src/src/IPrimusZkTLS.sol/struct.Attestor.md +++ b/docs/src/src/IPrimusZkTLS.sol/struct.Attestor.md @@ -1,5 +1,5 @@ # Attestor -[Git Source](https://github.com/primus-labs/zkTLS-contracts/blob/598ebb1789581520b0b29d02a686bfae9b7ffe60/src/IPrimusZKTLS.sol) +[Git Source](https://github.com/primus-labs/zkTLS-contracts/blob/11f4cead3677496fd937372843f5c9fca4283fc1/src/IPrimusZKTLS.sol) *Structure representing an attestor, who is responsible for signing the attestation.* diff --git a/docs/src/src/PrimusZkTLS.sol/contract.PrimusZkTLS.md b/docs/src/src/PrimusZkTLS.sol/contract.PrimusZkTLS.md index ac47396..bb91b75 100644 --- a/docs/src/src/PrimusZkTLS.sol/contract.PrimusZkTLS.md +++ b/docs/src/src/PrimusZkTLS.sol/contract.PrimusZkTLS.md @@ -1,5 +1,5 @@ # PrimusZKTLS -[Git Source](https://github.com/primus-labs/zkTLS-contracts/blob/598ebb1789581520b0b29d02a686bfae9b7ffe60/src/PrimusZKTLS.sol) +[Git Source](https://github.com/primus-labs/zkTLS-contracts/blob/11f4cead3677496fd937372843f5c9fca4283fc1/src/PrimusZKTLS.sol) **Inherits:** OwnableUpgradeable, [IPrimusZKTLS](/src/IPrimusZKTLS.sol/interface.IPrimusZKTLS.md) @@ -36,11 +36,11 @@ This function is called during the contract deployment.* function initialize(address _owner) public initializer; ``` -### setupDefaultAttestor +### _setupDefaultAttestor ```solidity -function setupDefaultAttestor(address defaultAddr) internal; +function _setupDefaultAttestor(address _defaultAddr) internal; ``` ### setAttestor diff --git a/lib/openzeppelin-contracts b/lib/openzeppelin-contracts new file mode 160000 index 0000000..54b3f14 --- /dev/null +++ b/lib/openzeppelin-contracts @@ -0,0 +1 @@ +Subproject commit 54b3f14346da01ba0d159114b399197fea8b7cda diff --git a/lib/openzeppelin-contracts-upgradeable b/lib/openzeppelin-contracts-upgradeable new file mode 160000 index 0000000..f6febd7 --- /dev/null +++ b/lib/openzeppelin-contracts-upgradeable @@ -0,0 +1 @@ +Subproject commit f6febd79e2a3a17e26969dd0d450c6ebd64bf459 diff --git a/script/Counter.s.sol b/script/Counter.s.sol deleted file mode 100644 index cdc1fe9..0000000 --- a/script/Counter.s.sol +++ /dev/null @@ -1,19 +0,0 @@ -// SPDX-License-Identifier: UNLICENSED -pragma solidity ^0.8.13; - -import {Script, console} from "forge-std/Script.sol"; -import {Counter} from "../src/Counter.sol"; - -contract CounterScript is Script { - Counter public counter; - - function setUp() public {} - - function run() public { - vm.startBroadcast(); - - counter = new Counter(); - - vm.stopBroadcast(); - } -} diff --git a/script/PrimusZKTLS.s.sol b/script/PrimusZKTLS.s.sol index 1b570a6..7ae8472 100644 --- a/script/PrimusZKTLS.s.sol +++ b/script/PrimusZKTLS.s.sol @@ -17,7 +17,7 @@ contract DeployPrimusZKTLS is Script { PrimusZKTLS logic = new PrimusZKTLS(); // 3. Deploy ProxyAdmin - ProxyAdmin proxyAdmin = new ProxyAdmin(deployerAddress); + ProxyAdmin proxyAdmin = new ProxyAdmin(); // 4. Prepare initialization data bytes memory initializeData = abi.encodeWithSelector( diff --git a/src/Counter.sol b/src/Counter.sol deleted file mode 100644 index aded799..0000000 --- a/src/Counter.sol +++ /dev/null @@ -1,14 +0,0 @@ -// SPDX-License-Identifier: UNLICENSED -pragma solidity ^0.8.13; - -contract Counter { - uint256 public number; - - function setNumber(uint256 newNumber) public { - number = newNumber; - } - - function increment() public { - number++; - } -} diff --git a/src/PrimusZKTLS.sol b/src/PrimusZKTLS.sol index f7587e8..b64980e 100644 --- a/src/PrimusZKTLS.sol +++ b/src/PrimusZKTLS.sol @@ -32,18 +32,18 @@ contract PrimusZKTLS is OwnableUpgradeable, IPrimusZKTLS { * This function is called during the contract deployment. */ function initialize(address _owner) public initializer { - __Ownable_init(_owner); - setupDefaultAttestor(_owner); + __Ownable_init(); + _setupDefaultAttestor(_owner); } - function setupDefaultAttestor(address defaultAddr) internal { - require(defaultAddr != address(0), "Invalid address"); - _attestorsMapping[defaultAddr] = Attestor({ - attestorAddr: defaultAddr, + function _setupDefaultAttestor(address _defaultAddr) internal { + require(_defaultAddr != address(0), "Invalid address"); + _attestorsMapping[_defaultAddr] = Attestor({ + attestorAddr: _defaultAddr, url: "https://primuslabs.xyz/" }); _attestors.push(Attestor({ - attestorAddr: defaultAddr, + attestorAddr: _defaultAddr, url: "https://primuslabs.xyz/" })); } diff --git a/test/Counter.t.sol b/test/Counter.t.sol deleted file mode 100644 index 54b724f..0000000 --- a/test/Counter.t.sol +++ /dev/null @@ -1,24 +0,0 @@ -// SPDX-License-Identifier: UNLICENSED -pragma solidity ^0.8.13; - -import {Test, console} from "forge-std/Test.sol"; -import {Counter} from "../src/Counter.sol"; - -contract CounterTest is Test { - Counter public counter; - - function setUp() public { - counter = new Counter(); - counter.setNumber(0); - } - - function test_Increment() public { - counter.increment(); - assertEq(counter.number(), 1); - } - - function testFuzz_SetNumber(uint256 x) public { - counter.setNumber(x); - assertEq(counter.number(), x); - } -}