Skip to content

Commit c7bce7e

Browse files
authored
refactor: adaptations to use osx-commons in osx-plugin-template-hardhat (#48)
* feat: single target permission type * chore: bump version and maintain changelog * feat: move more events * feat: move permission manager flags * feat: export address constants * refactor: improved name * test: moved over tests from hardhat template * build: added missing import * build: use the same typescript version * refactor: address constants
1 parent 2a6704c commit c7bce7e

File tree

15 files changed

+330
-31
lines changed

15 files changed

+330
-31
lines changed

contracts/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
"tmp-promise": "^3.0.3",
4343
"ts-node": "^10.9.1",
4444
"typechain": "^8.3.2",
45-
"typescript": "5.0.4"
45+
"typescript": "5.2.2"
4646
},
4747
"dependencies": {
4848
"@openzeppelin/contracts": "4.9.5",

contracts/yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5337,10 +5337,10 @@ typedarray@^0.0.6:
53375337
resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777"
53385338
integrity sha512-/aCDEGatGvZ2BIk+HmLf4ifCJFwvKFNb9/JeZPMulfgFracn9QFcAf5GO8B/mweUjSoblS5In0cWhqpfs/5PQA==
53395339

5340-
typescript@5.0.4:
5341-
version "5.0.4"
5342-
resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.0.4.tgz#b217fd20119bd61a94d4011274e0ab369058da3b"
5343-
integrity sha512-cW9T5W9xY37cc+jfEnaUvX91foxtHkza3Nw3wkoF4sSlKn0MONdkdEndig/qPBWXNkmplh3NzayQzCiHM4/hqw==
5340+
typescript@5.2.2:
5341+
version "5.2.2"
5342+
resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.2.2.tgz#5ebb5e5a5b75f085f22bc3f8460fba308310fa78"
5343+
integrity sha512-mI4WrpHsbCIcwT9cF4FZvr80QUeKvsUsUvKDoR+X/7XHQH98xYD8YHZg7ANtz2GtZt/CBq2QJ0thkGJMHfqc1w==
53445344

53455345
typical@^4.0.0:
53465346
version "4.0.0"

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"prettier-plugin-solidity": "^1.1.3",
1616
"solhint": "^3.6.2",
1717
"solhint-plugin-prettier": "^0.0.5",
18-
"typescript": "5.0.4"
18+
"typescript": "5.2.2"
1919
},
2020
"scripts": {
2121
"lint:configs:ts": "eslint --ext .js,.ts ./configs/",

sdk/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1616

1717
### Added
1818

19+
- Created `SingleTargetPermission` type.
1920
- Copied files from [aragon/sdk commit 76b4fc](https://github.com/aragon/sdk/tree/76b4fc815cfacce60b7c983ef0ce53110761f23a)
2021

2122
- Classes `ClientCore`, `ContextCore`, `Context`, `GraphQLModule`, `Web3Module`, `IPFSModule`, `MultiUri`.

sdk/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@aragon/osx-commons-sdk",
33
"author": "Aragon Association",
4-
"version": "0.0.1-alpha.3",
4+
"version": "0.0.1-alpha.4",
55
"license": "MIT",
66
"main": "dist/index.js",
77
"module": "dist/osx-commons-sdk.esm.js",
@@ -49,7 +49,7 @@
4949
"husky": "^7.0.4",
5050
"size-limit": "^7.0.8",
5151
"tslib": "^2.3.1",
52-
"typescript": "5.0.4"
52+
"typescript": "5.2.2"
5353
},
5454
"dependencies": {
5555
"@aragon/osx-ethers": "^1.3.0-rc0.4",

sdk/src/constants.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,13 @@ const SupportedNetworksToGraphqlNetworks: {
3838
[SupportedNetwork.LOCAL]: 'local',
3939
};
4040

41+
export const ADDRESS = {
42+
ZERO: `0x${'0'.repeat(40)}`, // address(0)
43+
ONE: `0x${'0'.repeat(39)}1`, // address(1)
44+
TWO: `0x${'0'.repeat(39)}2`, // address(2)
45+
LAST: `0x${'f'.repeat(40)}`, // address(-1)
46+
};
47+
4148
export const UNSUPPORTED_PROPOSAL_METADATA_LINK: ProposalMetadata = {
4249
title: '(unsupported metadata link)',
4350
summary: '(the link to the metadata is not supported)',

sdk/src/events.ts

Lines changed: 55 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,22 +44,66 @@ export async function findEventTopicLog<T>(
4444
}
4545
return iface.parseLog(log) as LogDescription & (T | LogDescription);
4646
}
47+
48+
export const CALLBACK_HANDLER_EVENTS = {
49+
CallbackReceived: 'CallbackReceived',
50+
};
51+
52+
export const DAO_EVENTS = {
53+
NewURI: 'NewURI',
54+
};
55+
56+
export const DAO_REGISTRY_EVENTS = {
57+
DAORegistered: 'DAORegistered',
58+
};
59+
4760
export const IPROPOSAL_EVENTS = {
48-
PROPOSAL_CREATED: 'ProposalCreated',
49-
PROPOSAL_EXECUTED: 'ProposalExecuted',
61+
ProposalCreated: 'ProposalCreated',
62+
ProposalExecuted: 'ProposalExecuted',
5063
};
5164

5265
export const IDAO_EVENTS = {
53-
METADATA_SET: 'MetadataSet',
54-
EXECUTED: 'Executed',
55-
DEPOSITED: 'Deposited',
56-
STANDARD_CALLBACK_REGISTERED: 'StandardCallbackRegistered',
57-
TRUSTED_FORWARDER_SET: 'TrustedForwarderSet',
58-
NEW_URI: 'NewURI',
66+
MetadataSet: 'MetadataSet',
67+
Executed: 'Executed',
68+
Deposited: 'Deposited',
69+
StandardCallbackRegistered: 'StandardCallbackRegistered',
70+
TrustedForwarderSet: 'TrustedForwarderSet',
71+
NewURI: 'NewURI',
5972
};
6073

6174
export const IMEMBERSHIP_EVENTS = {
62-
MEMBERS_ADDED: 'MembersAdded',
63-
MEMBERS_REMOVED: 'MembersRemoved',
64-
MEMBERSHIP_CONTRACT_ANNOUNCED: 'MembershipContractAnnounced',
75+
MembersAdded: 'MembersAdded',
76+
MembersRemoved: 'MembersRemoved',
77+
MembershipContractAnnounced: 'MembershipContractAnnounced',
78+
};
79+
80+
export const INTERFACE_BASED_REGISTRY_EVENTS = {
81+
Registered: 'Registered',
82+
};
83+
84+
export const PERMISSION_MANAGER = {
85+
Granted: 'Granted',
86+
Revoked: 'Revoked',
87+
};
88+
89+
export const PLUGIN_REPO_EVENTS = {
90+
VersionCreated: 'VersionCreated',
91+
};
92+
93+
export const PLUGIN_REPO_REGISTRY_EVENTS = {
94+
PluginRepoRegistered: 'PluginRepoRegistered',
95+
ReleaseMetadataUpdated: 'ReleaseMetadataUpdated',
96+
};
97+
98+
export const PLUGIN_SETUP_PROCESSOR_EVENTS = {
99+
InstallationPrepared: 'InstallationPrepared',
100+
InstallationApplied: 'InstallationApplied',
101+
UpdatePrepared: 'UpdatePrepared',
102+
UpdateApplied: 'UpdateApplied',
103+
UninstallationPrepared: 'UninstallationPrepared',
104+
UninstallationApplied: 'UninstallationApplied',
105+
};
106+
107+
export const UUPS_UPGRADEABLE_EVENTS = {
108+
Upgraded: 'Upgraded',
65109
};

sdk/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export * from './utils';
77
export * from './schemas';
88
export * from './validation';
99
export * from './multiuri';
10+
export * from './ipfs';
1011
export * from './metadata';
1112
export * from './interfaces';
1213
export * from './encoding';

sdk/src/permission.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import {ADDRESS} from './constants';
12
import {id} from '@ethersproject/hash';
23

34
export enum Operation {
@@ -6,6 +7,13 @@ export enum Operation {
67
GrantWithCondition = 2,
78
}
89

10+
export const PERMISSION_MANAGER_FLAGS = {
11+
UNSET_FLAG: ADDRESS.ZERO,
12+
ALLOW_FLAG: ADDRESS.TWO,
13+
ANY_ADDR: ADDRESS.LAST,
14+
NO_CONDITION: ADDRESS.ZERO,
15+
};
16+
917
export const DAO_PERMISSIONS = {
1018
ROOT_PERMISSION_ID: id('ROOT_PERMISSION'),
1119
EXECUTE_PERMISSION_ID: id('EXECUTE_PERMISSION'),

sdk/src/types.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,12 @@ export enum PermissionOperationType {
148148
GRANT_WITH_CONDITION = 2,
149149
}
150150

151+
export type SingleTargetPermission = {
152+
operation: PermissionOperationType;
153+
who: string;
154+
permissionId: string;
155+
};
156+
151157
export type MultiTargetPermission = {
152158
operation: PermissionOperationType;
153159
where: string;

0 commit comments

Comments
 (0)