Skip to content

Commit

Permalink
DX-128-audit-dev-portal-sdk-client (#318)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
Co-authored-by: Jose Manuel Mariñas Bascoy <[email protected]>
  • Loading branch information
3 people authored Feb 13, 2024
1 parent d2ee59a commit a96e619
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 50 deletions.
13 changes: 6 additions & 7 deletions modules/client-common/test/unit/context.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
);
}
});
});
13 changes: 5 additions & 8 deletions modules/client/examples/01-client/14-prepare-uninstallation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.
Expand Down
14 changes: 6 additions & 8 deletions modules/client/examples/01-client/16-is-plugin-update-valid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
13 changes: 5 additions & 8 deletions modules/client/examples/01-client/18-is-dao-update-valid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
14 changes: 5 additions & 9 deletions modules/client/examples/01-client/19-is-dao-update-proposal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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==
Expand Down

0 comments on commit a96e619

Please sign in to comment.