From a96e61938a9a7b4c08c4abf6c52400489f7cecb6 Mon Sep 17 00:00:00 2001 From: Aaron Abu Usama <50079365+pythonpete32@users.noreply.github.com> Date: Tue, 13 Feb 2024 16:09:05 +0400 Subject: [PATCH] DX-128-audit-dev-portal-sdk-client (#318) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * docs: update import to `sdk-client-common` * docs: update the params to use proposalId * docs: update the params to use proposalId * docs: update the params to use proposalId * docs: add dependency for auto generate reference guide docs * fix tests --------- Co-authored-by: banasa44 Co-authored-by: Jose Manuel MariƱas Bascoy --- modules/client-common/test/unit/context.test.ts | 13 ++++++------- .../01-client/14-prepare-uninstallation.ts | 13 +++++-------- .../01-client/16-is-plugin-update-valid.ts | 14 ++++++-------- .../01-client/17-is-plugin-update-proposal.ts | 14 +++++--------- .../examples/01-client/18-is-dao-update-valid.ts | 13 +++++-------- .../01-client/19-is-dao-update-proposal.ts | 14 +++++--------- package.json | 1 + yarn.lock | 2 +- 8 files changed, 34 insertions(+), 50 deletions(-) diff --git a/modules/client-common/test/unit/context.test.ts b/modules/client-common/test/unit/context.test.ts index 689ad03d7..244e761d3 100644 --- a/modules/client-common/test/unit/context.test.ts +++ b/modules/client-common/test/unit/context.test.ts @@ -284,13 +284,12 @@ describe("Context instances", () => { for (const provider of context.web3Providers) { expect(provider).toBeInstanceOf(JsonRpcProvider); expect(provider.connection.url).toBe("https://goerli.base.org/"); - provider.getNetwork().then((nw) => { - expect(nw.chainId).toEqual(84531); - expect(nw.name).toEqual("baseGoerli"); - expect(nw.ensAddress).toEqual( - LIVE_CONTRACTS[SupportedVersion.LATEST].baseGoerli.ensRegistryAddress, - ); - }); + const nw = provider.network; + expect(nw.chainId).toEqual(84531); + expect(nw.name).toEqual("baseGoerli"); + expect(nw.ensAddress).toEqual( + LIVE_CONTRACTS[SupportedVersion.LATEST].baseGoerli.ensRegistryAddress, + ); } }); }); diff --git a/modules/client/examples/01-client/14-prepare-uninstallation.ts b/modules/client/examples/01-client/14-prepare-uninstallation.ts index 0afab33f4..0170cd7e9 100644 --- a/modules/client/examples/01-client/14-prepare-uninstallation.ts +++ b/modules/client/examples/01-client/14-prepare-uninstallation.ts @@ -12,12 +12,11 @@ For more details see https://devs.aragon.org/docs/sdk/examples/encoders-decoders */ +import { Client, PrepareUninstallationSteps } from "@aragon/sdk-client"; import { - Client, PrepareUninstallationParams, - PrepareUninstallationSteps, -} from "@aragon/sdk-client"; -import { GasFeeEstimation } from "@aragon/sdk-client-common"; + GasFeeEstimation, +} from "@aragon/sdk-client-common"; import { context } from "../index"; // Instantiate the general purpose client from the Aragon OSx SDK context. @@ -35,10 +34,8 @@ const prepareUninstallationParams: PrepareUninstallationParams = { }; // Estimate how much gas the transaction will cost. -const estimatedGas: GasFeeEstimation = await client.estimation - .prepareUninstallation( - prepareUninstallationParams, - ); +const estimatedGas: GasFeeEstimation = + await client.estimation.prepareUninstallation(prepareUninstallationParams); console.log({ avg: estimatedGas.average, max: estimatedGas.max }); // Deposit the ERC20 tokens. diff --git a/modules/client/examples/01-client/16-is-plugin-update-valid.ts b/modules/client/examples/01-client/16-is-plugin-update-valid.ts index ad37f35a2..ed26d3841 100644 --- a/modules/client/examples/01-client/16-is-plugin-update-valid.ts +++ b/modules/client/examples/01-client/16-is-plugin-update-valid.ts @@ -11,20 +11,18 @@ Goes though the actions of an `IProposal` compatible proposal and checks that th import { Client } from "@aragon/sdk-client"; import { context } from "../index"; -import { DaoAction } from "@aragon/sdk-client-common"; // Instantiate the general purpose client from the Aragon OSx SDK context. const client: Client = new Client(context); -const actions: DaoAction[] = [ - // your actions -]; +// The Id of the proposal. This is the address of the governance plugin and the proposal number in hexadecimal +// you can find it at the last part of the URL to the proposal for example +// https://app.aragon.org/#/daos/polygon/0x6c30c1a36ac486456932b2f106053c42443514b2/governance/proposals/0x0cff359a7455de5bb50aa0567517536d3dfe002d_0x10 +const proposalId = "0x0cff359a7455de5bb50aa0567517536d3dfe002d_0x10" + // check if a plugin update proposal is valid -const isValid = client.methods.isPluginUpdateProposalValid({ - daoAddress: "0x1234567890123456789012345678901234567890", - actions, -}); +const isValid = client.methods.isPluginUpdateProposalValid(proposalId); console.log(isValid); diff --git a/modules/client/examples/01-client/17-is-plugin-update-proposal.ts b/modules/client/examples/01-client/17-is-plugin-update-proposal.ts index 30be8c174..6218c0ceb 100644 --- a/modules/client/examples/01-client/17-is-plugin-update-proposal.ts +++ b/modules/client/examples/01-client/17-is-plugin-update-proposal.ts @@ -10,21 +10,17 @@ Goes though a list of actions and checks that contains the necessary actions for import { Client } from "@aragon/sdk-client"; import { context } from "../index"; -import { DaoAction } from "@aragon/sdk-client-common"; // Instantiate the general purpose client from the Aragon OSx SDK context. const client: Client = new Client(context); -const actions: DaoAction[] = [ - { - to: "0x1234567890123456789012345678901234567890", - value: BigInt(0), - data: new Uint8Array([10, 20 ,30]), - }, -]; +// The Id of the proposal. This is the address of the governance plugin and the proposal number in hexadecimal +// you can find it at the last part of the URL to the proposal for example +// https://app.aragon.org/#/daos/polygon/0x6c30c1a36ac486456932b2f106053c42443514b2/governance/proposals/0x0cff359a7455de5bb50aa0567517536d3dfe002d_0x10 +const proposalId = "0x0cff359a7455de5bb50aa0567517536d3dfe002d_0x10"; // check if a plugin update proposal is valid -const isValid = client.methods.isPluginUpdateProposal(actions); +const isValid = client.methods.isPluginUpdateProposal(proposalId); console.log(isValid); diff --git a/modules/client/examples/01-client/18-is-dao-update-valid.ts b/modules/client/examples/01-client/18-is-dao-update-valid.ts index e110d62f7..92251ea8d 100644 --- a/modules/client/examples/01-client/18-is-dao-update-valid.ts +++ b/modules/client/examples/01-client/18-is-dao-update-valid.ts @@ -11,20 +11,17 @@ Goes though the actions of an `IProposal` compatible proposal and checks that th import { Client } from "@aragon/sdk-client"; import { context } from "../index"; -import { DaoAction } from "@aragon/sdk-client-common"; // Instantiate the general purpose client from the Aragon OSx SDK context. const client: Client = new Client(context); -const actions: DaoAction[] = [ - // your actions -]; +// The Id of the proposal. This is the address of the governance plugin and the proposal number in hexadecimal +// you can find it at the last part of the URL to the proposal for example +// https://app.aragon.org/#/daos/polygon/0x6c30c1a36ac486456932b2f106053c42443514b2/governance/proposals/0x0cff359a7455de5bb50aa0567517536d3dfe002d_0x10 +const proposalId = "0x0cff359a7455de5bb50aa0567517536d3dfe002d_0x11"; // check if a dap update proposal is valid -const isValid = client.methods.isDaoUpdateProposalValid({ - daoAddress: "0x1234567890123456789012345678901234567890", - actions, -}); +const isValid = client.methods.isDaoUpdateProposalValid(proposalId); console.log(isValid); diff --git a/modules/client/examples/01-client/19-is-dao-update-proposal.ts b/modules/client/examples/01-client/19-is-dao-update-proposal.ts index b62bc5639..56de1c4ae 100644 --- a/modules/client/examples/01-client/19-is-dao-update-proposal.ts +++ b/modules/client/examples/01-client/19-is-dao-update-proposal.ts @@ -10,21 +10,17 @@ Goes though a list of actions and checks that contains the necessary actions for import { Client } from "@aragon/sdk-client"; import { context } from "../index"; -import { DaoAction } from "@aragon/sdk-client-common"; // Instantiate the general purpose client from the Aragon OSx SDK context. const client: Client = new Client(context); -const actions: DaoAction[] = [ - { - to: "0x1234567890123456789012345678901234567890", - value: BigInt(0), - data: new Uint8Array([10, 20, 30]), - }, -]; +// The Id of the proposal. This is the address of the governance plugin and the proposal number in hexadecimal +// you can find it at the last part of the URL to the proposal for example +// https://app.aragon.org/#/daos/polygon/0x6c30c1a36ac486456932b2f106053c42443514b2/governance/proposals/0x0cff359a7455de5bb50aa0567517536d3dfe002d_0x10 +const proposalId = "0x0cff359a7455de5bb50aa0567517536d3dfe002d_0x11"; // check if a plugin update proposal is valid -const isValid = client.methods.isDaoUpdateProposalProposal(actions); +const isValid = client.methods.isDaoUpdateProposal(proposalId); console.log(isValid); diff --git a/package.json b/package.json index b5f265f65..841b75afc 100644 --- a/package.json +++ b/package.json @@ -29,6 +29,7 @@ }, "devDependencies": { "@babel/preset-typescript": "^7.18.6", + "@babel/plugin-proposal-object-rest-spread": "^7.20.7", "jsdoc-babel": "^0.5.0", "jsdoc-to-markdown": "^7.1.1", "turbo": "^1.1.9" diff --git a/yarn.lock b/yarn.lock index 2c81f3f16..747380ea6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -704,7 +704,7 @@ "@babel/helper-plugin-utils" "^7.18.6" "@babel/plugin-syntax-numeric-separator" "^7.10.4" -"@babel/plugin-proposal-object-rest-spread@^7.20.2": +"@babel/plugin-proposal-object-rest-spread@^7.20.2", "@babel/plugin-proposal-object-rest-spread@^7.20.7": version "7.20.7" resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-object-rest-spread/-/plugin-proposal-object-rest-spread-7.20.7.tgz#aa662940ef425779c75534a5c41e9d936edc390a" integrity sha512-d2S98yCiLxDVmBmE8UjGcfPvNEUbA1U5q5WxaWFUGRzJSVAZqm5W6MbPct0jxnegUZ0niLeNX+IOzEs7wYg9Dg==