Commit graph

62 commits

Author SHA1 Message Date
Brian Meek c243677795
Merge local harmony changes, Dendrite tests passing
Signed-off-by: Brian Meek <brian@hntlabs.com>
2023-02-08 08:23:06 -08:00
Giuseppe Rodriguez cade6d1de3 Audit Fixes 3 - [M-1] More than one Role can contain the Permissions.Owner permission (#1429)
Impact: High

Likelihood: Low

According to the discussion with the team, it is expected that in Space
contracts, only one Role can have the Permissions.Owner permission.
Currently, multiple Roles can be created containing this permission.
This is caused by Space.sol’s createRole() function allowing the
OpenZeppelin owner to create new owner-permissioned roles without limit.

Remediations to consider:

Do not allow multiple roles to be created with the ownership permission.
This could be done with something like: if Space.sol’s ownerRoleId is
set, do not allow new roles to be created with the Permissions.Owner
permission.

 Fixes HNT-703 as well
2023-02-07 19:23:07 -08:00
Giuseppe Rodriguez 7d6ffad2de Audit Fixes 1 - Removes OZ Ownable from Space contract and makes checks for space token ownership to see if caller is space owner (#1424)
Removing the OpenZeppelin ownership logic, and, checking directly for
the ownership of the Space’s SpaceOwner NFT. The SpaceFactory could be
the owner during the bootstrapping phase, and afterwards, could transfer
the NFT to the proper owner. Doing a direct check like
_spaceOwner().ownerOf(tokenId) == _msgSender() would be safe because
that’s what the owner entitlement is going to check eventually.

---------

Co-authored-by: Kerem Kazan <kerem.kazan@gmail.com>
2023-02-07 15:57:39 -08:00
texuf 8a688ef92a Update contract addresses (#1354) 2023-01-27 16:08:13 -08:00
Giuseppe Rodriguez d7cabc8352 Clean up Spaces V1 contracts and testing (#1273) 2023-01-27 15:15:01 -08:00
Tak Wai Wong e3a98393a1 generate user entitlement types for localhost and goerli (#1272)
Need this to get user entitlement role details.
2023-01-24 13:08:46 -08:00
Tak Wai Wong 2506761678 delete v1 smart contract-related code from dendrite (#1263) 2023-01-19 17:08:30 -08:00
Tak Wai Wong 1c61837bfd fix client and dendrite to always use v2 smart contracts (#1259)
Remove the logic to switch between v1 and v2 smart contracts. Always use
v2.
2023-01-19 13:11:35 -08:00
Tak Wai Wong 425b28f2cc Add goerli types to client lib and dendrite (#1247) 2023-01-19 09:42:09 -08:00
Pat Fives 2020161369 Add comments for iSpace and the entitlements (#1233)
Co-authored-by: g <5714678+giuseppecrj@users.noreply.github.com>
2023-01-18 17:27:30 -08:00
Giuseppe Rodriguez fdc253e2ae deploy spaces v2 (#1235) 2023-01-17 17:26:08 -08:00
Tak Wai Wong 69609d885b hnt-571 client integration for v2 (#1237)
Fixes the remaining issues in tests, client lib, and dendrite to interact with v2 smart contracts
2023-01-17 16:04:56 -08:00
Giuseppe Rodriguez 34d457c8b0 Deploy latest space goerli types and contracts (#1230) 2023-01-13 17:02:33 -08:00
Giuseppe Rodriguez b8fd046e51 Updates UserEntitlement to take array of addresses (#1213) 2023-01-13 12:10:38 -08:00
Tak Wai Wong 7f3d10905a regenerate json addresses (#1218)
json addresses changed when i run the deploy script on a new instance of
anvil. Regenerated the json
2023-01-13 09:39:22 -08:00
Giuseppe Rodriguez e51eb13a13 0xMacro Updates (#1200)
Fixes HNT-417, HNT-411, HNT-403, HNT-398, HNT-394
2023-01-12 11:08:20 -08:00
Giuseppe Rodriguez 6745cd8162 adds multicall and updates create role with entitlements and entitlementdata arguments (#1192) 2023-01-10 19:43:14 -08:00
Tak Wai Wong 3700bcbde4 rename isEntitled to isEntitledToSpace (#1174) 2023-01-06 12:12:35 -08:00
Tak Wai Wong b09cd18803 Rename isEntitled func for channel (#1168)
Overloaded isEntitled func in ISpace.sol and Space.sol caused the generated client types to turn into string names. Renaming one of them to isEntitledToChannel.
2023-01-04 14:13:39 -08:00
Evan Salzbrenner 45185aaed0 fix space manager deployment json order (#1164) 2023-01-03 12:58:14 -08:00
texuf 1d13259cf1 New localhost contract addresses (#1160) 2023-01-02 10:38:56 -08:00
Evan Salzbrenner 83fbf169ec regenerate contract addresses (#1159) 2022-12-30 14:58:56 -08:00
Giuseppe Rodriguez 197e74169c Creates SpacesUpgrade script to update the implementation address of a space on space factory and space (#1156) 2022-12-29 20:33:41 -08:00
Tak Wai Wong 982ce71aad fix dendrite to interact with v1 / v2 contracts (#1155)
dendrite uses commandline flag v1 or v2 to choose the smart contracts for the isEntitled check
2022-12-29 15:37:03 -08:00
Giuseppe Rodriguez d04b25996e Space v2 Updates (#1145) 2022-12-28 20:23:01 -08:00
Tak Wai Wong 751030a658 Add a config flag on dendrite to switch between zion contracts v1 / v2 (#1151)
Temporary flag to implement v2 smart contract integration. Once v2 is
done, will remove this flag.
2022-12-28 18:56:40 -08:00
Giuseppe Rodriguez 6aa7e26d52 Space Manager v2 with Upgradeability (#1005) 2022-12-27 18:26:43 -08:00
Giuseppe Rodriguez f690a2ace9 deploy latest goerli (#1143) 2022-12-27 16:38:50 -08:00
Tak Wai Wong ad3be52a8d hnt-535 add modify role function to change roleName, permissions, token and user entitlement data (#1141)
- Add new functions to modify role name, permissions, token entitlement
and user entitlement with a single call
- Add new solidity tests for the new functions
- Re-generated TypeScript and Go types for both localhost and goerli
2022-12-27 14:27:02 -08:00
Tak Wai Wong 88c1b4c7b5 Refactor SpaceManager.createRole to take additional parameters (#1137)
Fixes hnt-445. This change would let the client create a new role by
paying gas 1 time instead of 8+ times.
Re-generated the localhost types
2022-12-22 12:54:46 -08:00
Giuseppe Rodriguez 4586351a29 deploy latest space manager contracts (#1061)
update goerli addresses
2022-12-09 12:49:06 -08:00
Tak Wai Wong 8f4d1828b4 matrix room Id does not resolve to channelId or spaceId correctly (#1010)
Issue: matrix room id does not always resolve to spaceId or channelId
correctly.

Root cause: The clientApi routing endpoint and the syncapi routing
endpoint uses different stores to query for the current room states.

One is correct, the other has incomplete events. Fix the issue by using
the correct store in both routing code paths.
2022-11-30 20:12:00 -08:00
Tak Wai Wong a8127f9bdc Re-generate contract types due to ZionSpaceManger.sol changes (#1015)
- fix build-contract-types.sh to generate goerli
- re-generate types after ZionSpaceManager.sol changes.
2022-11-30 19:46:54 -08:00
Tak Wai Wong 6d6c85aadc Revert from space manager when adding duplicate roleId (#948)
- space manager catches error when adding roleId to channels so that
client can get meaningful error
- Update the createChannel tests to expect the new error AddRoleFailed
- Re-generate localhost and goerli types
2022-11-16 13:43:59 -08:00
Pat Fives b9e047dfac Refactor to track roles associated with channels (#915)
update interfaces to set and remove space entitlements or channel roles

all forge tests passing

all integration tests passing
2022-11-14 20:41:25 -08:00
Tak Wai Wong 22230a238a Make module type property available in the contract + publish client types (#923)
Add the new property moduleType to EntitlementModuleInfo.

Re-generate the typescript types, Go types, and the abi
2022-11-14 10:27:34 -08:00
John Terzis 40830b8a37 Space,Channel soft deletion with dendrite gating, tests (#889)
Closes HNT-244.

The following PR implements Space,Channel soft deletion using on-chain
`disabled` flag scope to space, channel respectively. On message sync,
dendrite will now gate disabled rooms by performing a leave on the user
attempting to sync unless the user is the owner (more on this later). To
re-join, given rooms (spaces,channels) are created by default using
`invite` membership state, the owner will need to undo the on-chain
`disabled` flag, setting it false then re-invite users that left the
room as a side effect of it becoming disabled previously.

The owner does not leave the space, channel because if they did then
there would be no one left to invite users let alone themselves back in
if the action is ever undone.

What is not implemented in this PR:
1. **Transitive leaves on channels in a space** - If a space is
disabled, users will leave the space but not the channels within the
space. To allow for fully disabling a space and all its' channels, the
client can offer a view to the owner that iterates over the channels and
space to disable all on-chain. Furthermore, we could implement a batch
on-chain method that fully disables all channels within a space (plus
the space) in one on-chain call to save the owner gas.
2. **Data deletion** - No data is remove from the DAGs or on-chain.
Therefore deletion is soft and reversible.
3. **New hook to check if a room is disabled** - the client can leverage
existing on-chain public read only methods `getSpaceInfoBySpaceId`,
`getChannelInfoByChannelId` to read the state of each in order to remove
spaces, channels from a member's view that are disabled.
2022-11-09 17:07:51 -07:00
Tak Wai Wong df41f84bfa generate localhost and goerli types (#895) 2022-11-09 14:23:54 -08:00
Tak Wai Wong 29dabec35e fix copy path of the deploy script (#856) 2022-11-07 11:53:26 -08:00
Tak Wai Wong 147b17eccf write out the rolemanager address in the json (#837)
Need the address to implement the ZionRoleManagerShim

I ran this in  zion-governance/ and it worked :
forge script scripts/Local.s.sol:DeployLocal --rpc-url
http://localhost:8545/ --private-key … --broadcast

space-manager.json has the rolemanager address
2022-11-04 14:04:03 -07:00
Tak Wai Wong a0df5f69fb
refresh contracts and addresses (#60) 2022-11-04 10:36:49 -07:00
Giuseppe Rodriguez 686450bdad HNT-320-321 Updates create channel to take role ids and makes contract types script simpler (#807)
Closes HNT-320

Co-authored-by: Tak Wai Wong <64229756+tak-hntlabs@users.noreply.github.com>
2022-11-03 21:35:44 -07:00
John Terzis b4223a1a18 Jterzis/sync dendrite (#793) 2022-11-01 23:17:48 -07:00
John Terzis 6059650464 message sync gating 2022-11-01 18:07:15 -07:00
Tak Wai Wong 424df14000 Sync dendrite fork changes for gating, and single chain support (#778)
* Latest dendrite main (8c7b274e4e)
* Gating implementation from John and Tak

Fixes for https://github.com/matrix-org/dendrite/issues/2838 and
https://github.com/matrix-org/dendrite/issues/2842

Co-authored-by: Tak Wai Wong <tak@hntlabs.com>
2022-11-01 11:09:34 -07:00
Tak Wai Wong 4d655a5e24
refresh latest zion contract types and addresses (#54) 2022-11-01 09:50:45 -07:00
Pat Fives 6cce0b9b43 Update create space interface, allow for setting specific users and multiple tokens during space creation (#734)
This PR finishes changing all the public interfaces at the moment for
space creation and updates the client.

All integration and forge tests passing.

Local and Goerli ABIs generated.

Co-authored-by: g <5714678+giuseppecrj@users.noreply.github.com>
2022-10-26 14:00:59 -04:00
Pat Fives 4c9f469a0c Update token entitlement logic to handle multiple tokens, decode entitlement data into structs (#729)
This change updates token entitlement data structures and allows for
multiple tokens to be set for a single role, permitting the AND
operation for multiple token requirements.

It also decodes structs when creating a space and setting a new token
entitlement.

Added new tests for multiple tokens gating a role. 

Also generates localhost AND Goerli ABIs.

Forge and integration tests all pass
2022-10-25 21:02:11 -07:00
Tak Wai Wong c4afa77636
Fix dendrite config to use env for chain_id and enable_authz (#49)
* Fix config to support env variables
2022-10-25 20:56:36 -07:00
Tak Wai Wong f87fd94b1b
fix spelling in README 2022-10-25 09:29:31 -07:00