diff --git a/contracts/package.json b/contracts/package.json index 3651351b..9a896ea1 100644 --- a/contracts/package.json +++ b/contracts/package.json @@ -42,7 +42,7 @@ "tmp-promise": "^3.0.3", "ts-node": "^10.9.1", "typechain": "^8.3.2", - "typescript": "5.0.4" + "typescript": "5.2.2" }, "dependencies": { "@openzeppelin/contracts": "4.9.5", diff --git a/contracts/yarn.lock b/contracts/yarn.lock index 8a55b7cc..f47cde12 100644 --- a/contracts/yarn.lock +++ b/contracts/yarn.lock @@ -5337,10 +5337,10 @@ typedarray@^0.0.6: resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777" integrity sha512-/aCDEGatGvZ2BIk+HmLf4ifCJFwvKFNb9/JeZPMulfgFracn9QFcAf5GO8B/mweUjSoblS5In0cWhqpfs/5PQA== -typescript@5.0.4: - version "5.0.4" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.0.4.tgz#b217fd20119bd61a94d4011274e0ab369058da3b" - integrity sha512-cW9T5W9xY37cc+jfEnaUvX91foxtHkza3Nw3wkoF4sSlKn0MONdkdEndig/qPBWXNkmplh3NzayQzCiHM4/hqw== +typescript@5.2.2: + version "5.2.2" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.2.2.tgz#5ebb5e5a5b75f085f22bc3f8460fba308310fa78" + integrity sha512-mI4WrpHsbCIcwT9cF4FZvr80QUeKvsUsUvKDoR+X/7XHQH98xYD8YHZg7ANtz2GtZt/CBq2QJ0thkGJMHfqc1w== typical@^4.0.0: version "4.0.0" diff --git a/package.json b/package.json index c43392a1..b5e14b4e 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ "prettier-plugin-solidity": "^1.1.3", "solhint": "^3.6.2", "solhint-plugin-prettier": "^0.0.5", - "typescript": "5.0.4" + "typescript": "5.2.2" }, "scripts": { "lint:configs:ts": "eslint --ext .js,.ts ./configs/", diff --git a/sdk/CHANGELOG.md b/sdk/CHANGELOG.md index 07c2f8a2..a2a2382d 100644 --- a/sdk/CHANGELOG.md +++ b/sdk/CHANGELOG.md @@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added +- Created `SingleTargetPermission` type. - Copied files from [aragon/sdk commit 76b4fc](https://github.com/aragon/sdk/tree/76b4fc815cfacce60b7c983ef0ce53110761f23a) - Classes `ClientCore`, `ContextCore`, `Context`, `GraphQLModule`, `Web3Module`, `IPFSModule`, `MultiUri`. diff --git a/sdk/package.json b/sdk/package.json index 4923dc29..8fda9ebf 100644 --- a/sdk/package.json +++ b/sdk/package.json @@ -1,7 +1,7 @@ { "name": "@aragon/osx-commons-sdk", "author": "Aragon Association", - "version": "0.0.1-alpha.3", + "version": "0.0.1-alpha.4", "license": "MIT", "main": "dist/index.js", "module": "dist/osx-commons-sdk.esm.js", @@ -49,7 +49,7 @@ "husky": "^7.0.4", "size-limit": "^7.0.8", "tslib": "^2.3.1", - "typescript": "5.0.4" + "typescript": "5.2.2" }, "dependencies": { "@aragon/osx-ethers": "^1.3.0-rc0.4", diff --git a/sdk/src/constants.ts b/sdk/src/constants.ts index c9aa74cd..7e9682c7 100644 --- a/sdk/src/constants.ts +++ b/sdk/src/constants.ts @@ -38,6 +38,13 @@ const SupportedNetworksToGraphqlNetworks: { [SupportedNetwork.LOCAL]: 'local', }; +export const ADDRESS = { + ZERO: `0x${'0'.repeat(40)}`, // address(0) + ONE: `0x${'0'.repeat(39)}1`, // address(1) + TWO: `0x${'0'.repeat(39)}2`, // address(2) + LAST: `0x${'f'.repeat(40)}`, // address(-1) +}; + export const UNSUPPORTED_PROPOSAL_METADATA_LINK: ProposalMetadata = { title: '(unsupported metadata link)', summary: '(the link to the metadata is not supported)', diff --git a/sdk/src/events.ts b/sdk/src/events.ts index 20121efc..17fa2eef 100644 --- a/sdk/src/events.ts +++ b/sdk/src/events.ts @@ -44,22 +44,66 @@ export async function findEventTopicLog( } return iface.parseLog(log) as LogDescription & (T | LogDescription); } + +export const CALLBACK_HANDLER_EVENTS = { + CallbackReceived: 'CallbackReceived', +}; + +export const DAO_EVENTS = { + NewURI: 'NewURI', +}; + +export const DAO_REGISTRY_EVENTS = { + DAORegistered: 'DAORegistered', +}; + export const IPROPOSAL_EVENTS = { - PROPOSAL_CREATED: 'ProposalCreated', - PROPOSAL_EXECUTED: 'ProposalExecuted', + ProposalCreated: 'ProposalCreated', + ProposalExecuted: 'ProposalExecuted', }; export const IDAO_EVENTS = { - METADATA_SET: 'MetadataSet', - EXECUTED: 'Executed', - DEPOSITED: 'Deposited', - STANDARD_CALLBACK_REGISTERED: 'StandardCallbackRegistered', - TRUSTED_FORWARDER_SET: 'TrustedForwarderSet', - NEW_URI: 'NewURI', + MetadataSet: 'MetadataSet', + Executed: 'Executed', + Deposited: 'Deposited', + StandardCallbackRegistered: 'StandardCallbackRegistered', + TrustedForwarderSet: 'TrustedForwarderSet', + NewURI: 'NewURI', }; export const IMEMBERSHIP_EVENTS = { - MEMBERS_ADDED: 'MembersAdded', - MEMBERS_REMOVED: 'MembersRemoved', - MEMBERSHIP_CONTRACT_ANNOUNCED: 'MembershipContractAnnounced', + MembersAdded: 'MembersAdded', + MembersRemoved: 'MembersRemoved', + MembershipContractAnnounced: 'MembershipContractAnnounced', +}; + +export const INTERFACE_BASED_REGISTRY_EVENTS = { + Registered: 'Registered', +}; + +export const PERMISSION_MANAGER = { + Granted: 'Granted', + Revoked: 'Revoked', +}; + +export const PLUGIN_REPO_EVENTS = { + VersionCreated: 'VersionCreated', +}; + +export const PLUGIN_REPO_REGISTRY_EVENTS = { + PluginRepoRegistered: 'PluginRepoRegistered', + ReleaseMetadataUpdated: 'ReleaseMetadataUpdated', +}; + +export const PLUGIN_SETUP_PROCESSOR_EVENTS = { + InstallationPrepared: 'InstallationPrepared', + InstallationApplied: 'InstallationApplied', + UpdatePrepared: 'UpdatePrepared', + UpdateApplied: 'UpdateApplied', + UninstallationPrepared: 'UninstallationPrepared', + UninstallationApplied: 'UninstallationApplied', +}; + +export const UUPS_UPGRADEABLE_EVENTS = { + Upgraded: 'Upgraded', }; diff --git a/sdk/src/index.ts b/sdk/src/index.ts index 119d9ad3..674358e2 100644 --- a/sdk/src/index.ts +++ b/sdk/src/index.ts @@ -7,6 +7,7 @@ export * from './utils'; export * from './schemas'; export * from './validation'; export * from './multiuri'; +export * from './ipfs'; export * from './metadata'; export * from './interfaces'; export * from './encoding'; diff --git a/sdk/src/permission.ts b/sdk/src/permission.ts index a0440f39..5cc25886 100644 --- a/sdk/src/permission.ts +++ b/sdk/src/permission.ts @@ -1,3 +1,4 @@ +import {ADDRESS} from './constants'; import {id} from '@ethersproject/hash'; export enum Operation { @@ -6,6 +7,13 @@ export enum Operation { GrantWithCondition = 2, } +export const PERMISSION_MANAGER_FLAGS = { + UNSET_FLAG: ADDRESS.ZERO, + ALLOW_FLAG: ADDRESS.TWO, + ANY_ADDR: ADDRESS.LAST, + NO_CONDITION: ADDRESS.ZERO, +}; + export const DAO_PERMISSIONS = { ROOT_PERMISSION_ID: id('ROOT_PERMISSION'), EXECUTE_PERMISSION_ID: id('EXECUTE_PERMISSION'), diff --git a/sdk/src/types.ts b/sdk/src/types.ts index 1c9ed1a4..4781e15e 100644 --- a/sdk/src/types.ts +++ b/sdk/src/types.ts @@ -148,6 +148,12 @@ export enum PermissionOperationType { GRANT_WITH_CONDITION = 2, } +export type SingleTargetPermission = { + operation: PermissionOperationType; + who: string; + permissionId: string; +}; + export type MultiTargetPermission = { operation: PermissionOperationType; where: string; diff --git a/sdk/test/unit/metadata.test.ts b/sdk/test/unit/metadata.test.ts index 8b0a6d80..c617d5e7 100644 --- a/sdk/test/unit/metadata.test.ts +++ b/sdk/test/unit/metadata.test.ts @@ -9,5 +9,237 @@ describe('Utils', () => { 'tuple(address b1, tuple(uint256 c1, tuple(address d1, tuple(address[] e1, tuple(uint32 f1, tuple(uint256 g1, uint256 g2))))))', ]); }); + + it('simple', async () => { + const inputs = [ + { + name: 'number', + type: 'uint256', + internalType: 'uint256', + description: '', + }, + { + name: 'account', + type: 'address', + internalType: 'address', + description: '', + }, + ]; + + expect(getNamedTypesFromMetadata(inputs)).toEqual([ + 'uint256 number', + 'address account', + ]); + }); + + it('array', async () => { + const inputs = [ + { + internalType: 'address[]', + name: 'members', + type: 'address[]', + description: '', + }, + ]; + + expect(getNamedTypesFromMetadata(inputs)).toEqual(['address[] members']); + }); + + it('struct', async () => { + const inputs = [ + { + components: [ + { + internalType: 'bool', + name: 'onlyListed', + type: 'bool', + description: '', + }, + { + internalType: 'uint16', + name: 'minApprovals', + type: 'uint16', + description: '', + }, + ], + internalType: 'struct Multisig.MultisigSettings', + name: 'multisigSettings', + type: 'tuple', + description: '', + }, + ]; + + expect(getNamedTypesFromMetadata(inputs)).toEqual([ + 'tuple(bool onlyListed, uint16 minApprovals)', + ]); + }); + + it('nested struct', async () => { + const inputs = [ + { + components: [ + { + internalType: 'bool', + name: 'var1', + type: 'bool', + description: '', + }, + { + components: [ + { + internalType: 'bool', + name: 'var2', + type: 'bool', + description: '', + }, + { + internalType: 'uint16', + name: 'var3', + type: 'uint16', + description: '', + }, + { + components: [ + { + internalType: 'bool', + name: 'var4', + type: 'bool', + description: '', + }, + { + internalType: 'uint16', + name: 'var5', + type: 'uint16', + description: '', + }, + { + internalType: 'bytes', + name: 'var6', + type: 'bytes', + description: '', + }, + ], + internalType: 'struct Example', + name: 'layer3', + type: 'tuple', + description: '', + }, + ], + internalType: 'struct Example', + name: 'layer2', + type: 'tuple', + description: '', + }, + ], + internalType: 'struct Example', + name: 'layer1', + type: 'tuple', + description: '', + }, + ]; + + expect(getNamedTypesFromMetadata(inputs)).toEqual([ + 'tuple(bool var1, tuple(bool var2, uint16 var3, tuple(bool var4, uint16 var5, bytes var6)))', + ]); + }); + + it('array of structs', async () => { + const inputs = [ + { + components: [ + { + internalType: 'address', + name: 'to', + type: 'address', + description: '', + }, + { + internalType: 'uint256', + name: 'value', + type: 'uint256', + description: '', + }, + { + internalType: 'bytes', + name: 'data', + type: 'bytes', + description: '', + }, + ], + indexed: false, + internalType: 'struct IDAO.Action[]', + name: 'actions', + type: 'tuple[]', + description: '', + }, + ]; + + expect(getNamedTypesFromMetadata(inputs)).toEqual([ + 'tuple(address to, uint256 value, bytes data)[]', + ]); + }); + + it('nested array of structs', async () => { + const inputs = [ + { + components: [ + { + internalType: 'address', + name: 'to', + type: 'address', + description: '', + }, + { + internalType: 'uint256', + name: 'value', + type: 'uint256', + description: '', + }, + { + internalType: 'bytes', + name: 'data', + type: 'bytes', + description: '', + }, + { + components: [ + { + internalType: 'address', + name: 'to', + type: 'address', + description: '', + }, + { + internalType: 'uint256', + name: 'value', + type: 'uint256', + description: '', + }, + { + internalType: 'bytes', + name: 'data', + type: 'bytes', + description: '', + }, + ], + indexed: false, + internalType: 'struct IDAO.Action[]', + name: 'actions', + type: 'tuple[]', + description: '', + }, + ], + indexed: false, + internalType: 'struct IDAO.Action[]', + name: 'actions', + type: 'tuple[]', + description: '', + }, + ]; + + expect(getNamedTypesFromMetadata(inputs)).toEqual([ + 'tuple(address to, uint256 value, bytes data, tuple(address to, uint256 value, bytes data)[])[]', + ]); + }); }); }); diff --git a/sdk/yarn.lock b/sdk/yarn.lock index 591c2912..57199b18 100644 --- a/sdk/yarn.lock +++ b/sdk/yarn.lock @@ -7143,10 +7143,10 @@ typed-array-length@^1.0.4: for-each "^0.3.3" is-typed-array "^1.1.9" -typescript@5.0.4: - version "5.0.4" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.0.4.tgz#b217fd20119bd61a94d4011274e0ab369058da3b" - integrity sha512-cW9T5W9xY37cc+jfEnaUvX91foxtHkza3Nw3wkoF4sSlKn0MONdkdEndig/qPBWXNkmplh3NzayQzCiHM4/hqw== +typescript@5.2.2: + version "5.2.2" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.2.2.tgz#5ebb5e5a5b75f085f22bc3f8460fba308310fa78" + integrity sha512-mI4WrpHsbCIcwT9cF4FZvr80QUeKvsUsUvKDoR+X/7XHQH98xYD8YHZg7ANtz2GtZt/CBq2QJ0thkGJMHfqc1w== typescript@^5.0.2: version "5.3.2" diff --git a/subgraph/package.json b/subgraph/package.json index 522825cf..1d3af2c6 100644 --- a/subgraph/package.json +++ b/subgraph/package.json @@ -34,6 +34,6 @@ "@graphprotocol/graph-cli": "0.56.0", "@types/node": "^20.8.7", "matchstick-as": "0.5.2", - "typescript": "^5.2.2" + "typescript": "5.2.2" } } diff --git a/subgraph/tests/constants.ts b/subgraph/tests/constants.ts index f582e1af..2f482945 100644 --- a/subgraph/tests/constants.ts +++ b/subgraph/tests/constants.ts @@ -1,6 +1,6 @@ -export const ADDRESS_ZERO = '0x0000000000000000000000000000000000000000'; -export const ADDRESS_ONE = '0x0000000000000000000000000000000000000001'; -export const ADDRESS_TWO = '0x0000000000000000000000000000000000000002'; +export const ADDRESS_ZERO = '0x0000000000000000000000000000000000000000'; // TODO use osx-commons-sdk constants once published +export const ADDRESS_ONE = '0x0000000000000000000000000000000000000001'; // TODO use osx-commons-sdk constants once published +export const ADDRESS_TWO = '0x0000000000000000000000000000000000000002'; // TODO use osx-commons-sdk constants once published export const DUMMY_BYTES32_HEX = '0x0000000000000000000000000000000000000000000000000000000000000000'; diff --git a/yarn.lock b/yarn.lock index ed586042..03b2dd21 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2022,10 +2022,10 @@ typed-array-length@^1.0.4: for-each "^0.3.3" is-typed-array "^1.1.9" -typescript@5.0.4: - version "5.0.4" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.0.4.tgz#b217fd20119bd61a94d4011274e0ab369058da3b" - integrity sha512-cW9T5W9xY37cc+jfEnaUvX91foxtHkza3Nw3wkoF4sSlKn0MONdkdEndig/qPBWXNkmplh3NzayQzCiHM4/hqw== +typescript@5.2.2: + version "5.2.2" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.2.2.tgz#5ebb5e5a5b75f085f22bc3f8460fba308310fa78" + integrity sha512-mI4WrpHsbCIcwT9cF4FZvr80QUeKvsUsUvKDoR+X/7XHQH98xYD8YHZg7ANtz2GtZt/CBq2QJ0thkGJMHfqc1w== unbox-primitive@^1.0.2: version "1.0.2"