diff --git a/frontend/.env.development b/frontend/.env.development new file mode 100644 index 00000000..83ec0aa5 --- /dev/null +++ b/frontend/.env.development @@ -0,0 +1 @@ +VITE_APP_ROOT_URL=http://localhost:5173/ diff --git a/frontend/.env.pontusxtest b/frontend/.env.pontusxtest index 3c663bd3..6f7623d8 100644 --- a/frontend/.env.pontusxtest +++ b/frontend/.env.pontusxtest @@ -21,4 +21,4 @@ VITE_CONTRACT_GASLESSVOTING=0xB86FB5Ac170dE6A596cF9262054bB252E75e7e4A VITE_CONTRACT_POLLMANAGER_TX=0x680a0d5bd656523e2113c11e451691440382c8ebcecb705bca18e57bcadcad76 VITE_CONTRACT_POLLMANAGER=0x5C12618F341E39e1263f7886cC0B87Cdcf7A0772 VITE_CONTRACT_POLLMANAGER_ACL=0x96b32310Ecc3F102c8DA0519bE087Fa4e2cA31C2 -VITE_APP_ROOT_URL=http://pontusx-blockvote.csillag.me/ +VITE_APP_ROOT_URL=https://pontusx-blockvote.csillag.me/ diff --git a/frontend/.env.production b/frontend/.env.production index b3055677..52854db1 100644 --- a/frontend/.env.production +++ b/frontend/.env.production @@ -1,3 +1,3 @@ VITE_NETWORK=23294 VITE_WEB3_GATEWAY=https://sapphire.oasis.io -VITE_APP_ROOT_URL=http://vote.oasis.io +VITE_APP_ROOT_URL=https://vote.oasis.io diff --git a/frontend/.env.staging b/frontend/.env.staging index 1e4c1c4e..7405b12c 100644 --- a/frontend/.env.staging +++ b/frontend/.env.staging @@ -21,4 +21,4 @@ VITE_CONTRACT_GASLESSVOTING=0xE57A305f34fD0B6A55A66e8ec9559e6573100cBe VITE_CONTRACT_POLLMANAGER_TX=0xd10fcbd665d5db4baa02351995fe26a02351486e4fd90e484a58bb52e77adf8d VITE_CONTRACT_POLLMANAGER=0x9bDD64340D3CE0607f51bBC7508CA40D45849ab8 VITE_CONTRACT_POLLMANAGER_ACL=0x0C8542AB89c1C60D711B00F309f7EF63b5D9d6eb -VITE_APP_ROOT_URL=http://vote.oasis.io +VITE_APP_ROOT_URL=https://vote.oasis.io diff --git a/frontend/.gitignore b/frontend/.gitignore index b4ed5a46..3c180156 100644 --- a/frontend/.gitignore +++ b/frontend/.gitignore @@ -33,4 +33,3 @@ stats.html .env.*.local stats.html .netlify -.env.development \ No newline at end of file diff --git a/hardhat/Makefile b/hardhat/Makefile index 72c6d00c..d555fa03 100644 --- a/hardhat/Makefile +++ b/hardhat/Makefile @@ -7,7 +7,7 @@ build: .PHONY: deploy-localnet deploy-localnet: - $(NPM) hardhat --network sapphire-localnet deploy --viteenv ../frontend/.env.development + $(NPM) hardhat --network sapphire-localnet deploy --viteenv ../frontend/.env.development.local .PHONY: test-localnet test-localnet: diff --git a/hardhat/contracts/GaslessVoting.sol b/hardhat/contracts/GaslessVoting.sol index 45f523c8..8578ec5b 100644 --- a/hardhat/contracts/GaslessVoting.sol +++ b/hardhat/contracts/GaslessVoting.sol @@ -146,6 +146,24 @@ contract GaslessVoting is IERC165, IGaslessVoter // ------------------------------------------------------------------------ + function onPollDestroyed(bytes32 in_proposalId) external + { + bytes32 gvid = internal_gvid(msg.sender, in_proposalId); + + PollSettings storage poll = s_polls[gvid]; + + for( uint i = 0; i < poll.keypairs.length; i++ ) + { + EthereumKeypair storage kp = poll.keypairs[i]; + + delete s_addrToKeypair[kp.addr]; + } + + delete s_polls[gvid]; + } + + // ------------------------------------------------------------------------ + error onPollClosed_404(); event GasWithdrawTransaction( bytes signedTransaction ); diff --git a/hardhat/contracts/PollManager.sol b/hardhat/contracts/PollManager.sol index 7bb3f4d3..1b8f8887 100644 --- a/hardhat/contracts/PollManager.sol +++ b/hardhat/contracts/PollManager.sol @@ -567,6 +567,8 @@ contract PollManager is IERC165, IPollManager { close(in_proposalId); } + params.acl.onPollDestroyed(in_proposalId); + delete PROPOSALS[in_proposalId]; Ballot storage ballot = s_ballots[in_proposalId]; diff --git a/hardhat/contracts/acl/AllowAllACL.sol b/hardhat/contracts/acl/AllowAllACL.sol index 6bee2338..f048d3aa 100644 --- a/hardhat/contracts/acl/AllowAllACL.sol +++ b/hardhat/contracts/acl/AllowAllACL.sol @@ -34,6 +34,11 @@ contract AllowAllACL is IPollACL, IPollManagerACL // Do nothing } + function onPollDestroyed(bytes32 proposalId) external + { + // Do nothing + } + function canVoteOnPoll(address, bytes32, address, bytes calldata) external pure returns(uint) diff --git a/hardhat/contracts/acl/PasswordACL.sol b/hardhat/contracts/acl/PasswordACL.sol index 19ee9cb1..61abfe16 100644 --- a/hardhat/contracts/acl/PasswordACL.sol +++ b/hardhat/contracts/acl/PasswordACL.sol @@ -34,8 +34,12 @@ contract PasswordACL is IPollACL s_passwords[id] = keccak256(in_password); } - function onPollClosed(bytes32 in_proposalId) - external + function onPollClosed(bytes32 in_proposalId) external + { + // Do nothing + } + + function onPollDestroyed(bytes32 in_proposalId) external { bytes32 id = internal_id(msg.sender, in_proposalId); diff --git a/hardhat/contracts/acl/StorageProofACL.sol b/hardhat/contracts/acl/StorageProofACL.sol index 17b76bd9..de1cf17a 100644 --- a/hardhat/contracts/acl/StorageProofACL.sol +++ b/hardhat/contracts/acl/StorageProofACL.sol @@ -25,7 +25,7 @@ contract StorageProofACL is IPollACL mapping(bytes32 => PollSettings) private s_polls; - StorageProof private storageProof; + StorageProof private immutable storageProof; function internal_id(address in_dao, bytes32 in_proposalId) internal pure @@ -90,6 +90,10 @@ contract StorageProofACL is IPollACL delete s_polls[internal_id(msg.sender, in_proposalId)]; } + function onPollDestroyed(bytes32 in_proposalId) external { + // Do nothing + } + function canVoteOnPoll( address in_dao, bytes32 in_proposalId, diff --git a/hardhat/contracts/acl/TokenHolderACL.sol b/hardhat/contracts/acl/TokenHolderACL.sol index c1f4de11..3c40b07e 100644 --- a/hardhat/contracts/acl/TokenHolderACL.sol +++ b/hardhat/contracts/acl/TokenHolderACL.sol @@ -44,6 +44,10 @@ contract TokenHolderACL is IPollACL delete polls[pid]; } + function onPollDestroyed(bytes32 in_proposalId) external { + // Do nothing + } + /// Does user hold a non-zero balance of the token required to vote? function canVoteOnPoll(address in_dao, bytes32 in_proposalId, address in_user, bytes calldata in_data) external view diff --git a/hardhat/contracts/acl/VoterAllowlistACL.sol b/hardhat/contracts/acl/VoterAllowlistACL.sol index 121417a9..d3bc481f 100644 --- a/hardhat/contracts/acl/VoterAllowlistACL.sol +++ b/hardhat/contracts/acl/VoterAllowlistACL.sol @@ -59,6 +59,10 @@ contract VoterAllowListACL is IPollACL delete eligibleVotersList[pid]; } + function onPollDestroyed(bytes32 in_proposalId) external { + // Do nothing + } + /// Is user allowed to vote on the poll? function canVoteOnPoll(address in_dao, bytes32 in_proposalId, address in_user, bytes calldata) external view diff --git a/hardhat/interfaces/IGaslessVoter.sol b/hardhat/interfaces/IGaslessVoter.sol index 4c360a60..faa923b6 100644 --- a/hardhat/interfaces/IGaslessVoter.sol +++ b/hardhat/interfaces/IGaslessVoter.sol @@ -16,6 +16,8 @@ interface IGaslessVoter { function onPollClosed(bytes32 proposalId) external; + function onPollDestroyed(bytes32 proposalId) external; + function makeVoteTransaction( address addr, uint64 nonce, diff --git a/hardhat/interfaces/IPollACL.sol b/hardhat/interfaces/IPollACL.sol index d77e5bd3..edbb209a 100644 --- a/hardhat/interfaces/IPollACL.sol +++ b/hardhat/interfaces/IPollACL.sol @@ -17,6 +17,8 @@ interface IPollACL is IERC165 { function onPollClosed(bytes32 proposalId) external; + function onPollDestroyed(bytes32 proposalId) external; + // Is a given user eligible voter for the given poll. // Returns the weight of their votes, 0 if they're not allowed to vote! function canVoteOnPoll(address dao, bytes32 proposalId, address user, bytes calldata data) external view returns(uint); diff --git a/hardhat/test/Gasless.spec.ts b/hardhat/test/Gasless.spec.ts index 35366279..87d72e0b 100644 --- a/hardhat/test/Gasless.spec.ts +++ b/hardhat/test/Gasless.spec.ts @@ -123,5 +123,9 @@ describe('Gasless voting', () => { expect(balance <= 10000000000000n).eq(true); console.log(' -', gva, formatEther(balance)); } + + const destroyTx = await pm.destroy(proposalId); + const destroyReceipt = await destroyTx.wait(); + expect(destroyReceipt?.status).eq(1); }); });