Skip to content

Commit

Permalink
use HTTPs for URLs, minor tweaks to ACL to allow for onDestroy callback
Browse files Browse the repository at this point in the history
  • Loading branch information
CedarMist authored and csillag committed Oct 11, 2024
1 parent c74484a commit e77d5d3
Show file tree
Hide file tree
Showing 16 changed files with 57 additions and 8 deletions.
1 change: 1 addition & 0 deletions frontend/.env.development
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
VITE_APP_ROOT_URL=http://localhost:5173/
2 changes: 1 addition & 1 deletion frontend/.env.pontusxtest
Original file line number Diff line number Diff line change
Expand Up @@ -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/
2 changes: 1 addition & 1 deletion frontend/.env.production
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion frontend/.env.staging
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 0 additions & 1 deletion frontend/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,3 @@ stats.html
.env.*.local
stats.html
.netlify
.env.development
2 changes: 1 addition & 1 deletion hardhat/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
18 changes: 18 additions & 0 deletions hardhat/contracts/GaslessVoting.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
2 changes: 2 additions & 0 deletions hardhat/contracts/PollManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
5 changes: 5 additions & 0 deletions hardhat/contracts/acl/AllowAllACL.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 6 additions & 2 deletions hardhat/contracts/acl/PasswordACL.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
6 changes: 5 additions & 1 deletion hardhat/contracts/acl/StorageProofACL.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 4 additions & 0 deletions hardhat/contracts/acl/TokenHolderACL.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions hardhat/contracts/acl/VoterAllowlistACL.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions hardhat/interfaces/IGaslessVoter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ interface IGaslessVoter {

function onPollClosed(bytes32 proposalId) external;

function onPollDestroyed(bytes32 proposalId) external;

function makeVoteTransaction(
address addr,
uint64 nonce,
Expand Down
2 changes: 2 additions & 0 deletions hardhat/interfaces/IPollACL.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 4 additions & 0 deletions hardhat/test/Gasless.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});

0 comments on commit e77d5d3

Please sign in to comment.