Skip to content

Commit

Permalink
Make the network mandatory on get plugin install item
Browse files Browse the repository at this point in the history
  • Loading branch information
brickpop committed Jul 22, 2023
1 parent 5c3d30f commit 15e362f
Show file tree
Hide file tree
Showing 14 changed files with 36 additions and 20 deletions.
2 changes: 1 addition & 1 deletion modules/client/examples/01-client/01-create-dao.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ const tokenVotingPluginInstallParams: TokenVotingPluginInstall = {

// Creates a TokenVoting plugin client with the parameteres defined above (with an existing token).
const tokenVotingInstallItem = TokenVotingClient.encoding
.getPluginInstallItem(tokenVotingPluginInstallParams);
.getPluginInstallItem(tokenVotingPluginInstallParams, "goerli");

const createDaoParams: CreateDaoParams = {
metadataUri,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const multisigPluginIntallParams: MultisigPluginInstallParams = {

// Encodes the parameters of the Multisig plugin. These will get used in the installation plugin for the DAO.
const multisigPluginInstallItem = MultisigClient.encoding
.getPluginInstallItem(multisigPluginIntallParams);
.getPluginInstallItem(multisigPluginIntallParams, "goerli");

// Pin metadata to IPFS, returns IPFS CID string.
const metadataUri: string = await client.methods.pinMetadata({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@ const tokenVotingPluginInstallParams2: TokenVotingPluginInstall = {

// Creates a TokenVoting plugin client with the parameteres defined above (with an existing token).
const tokenVotingPluginInstallItem1 = TokenVotingClient.encoding
.getPluginInstallItem(tokenVotingPluginInstallParams1);
.getPluginInstallItem(tokenVotingPluginInstallParams1, "goerli");
// Creates a TokenVoting plugin client with the parameteres defined above (with newly minted tokens).
const tokenVotingPluginInstallItem2 = TokenVotingClient.encoding
.getPluginInstallItem(tokenVotingPluginInstallParams2);
.getPluginInstallItem(tokenVotingPluginInstallParams2, "goerli");

const daoMetadata: DaoMetadata = {
name: "My DAO",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const addresslistVotingPluginInstallParams: AddresslistVotingPluginInstall = {

// Encodes the plugin instructions for installing into the DAO with its defined parameters.
const addresslistVotingPluginInstallItem = AddresslistVotingClient
.encoding.getPluginInstallItem(addresslistVotingPluginInstallParams);
.encoding.getPluginInstallItem(addresslistVotingPluginInstallParams, "goerli");

const daoMetadata: DaoMetadata = {
name: "My DAO",
Expand Down
2 changes: 1 addition & 1 deletion modules/client/src/addresslistVoting/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export class AddresslistVotingClient extends ClientCore
*/
getPluginInstallItem: (
params: AddresslistVotingPluginInstall,
network: Networkish = "mainnet",
network: Networkish,
): PluginInstallItem =>
AddresslistVotingClientEncoding.getPluginInstallItem(params, network),
};
Expand Down
2 changes: 1 addition & 1 deletion modules/client/src/multisig/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export class MultisigClient extends ClientCore implements IMultisigClient {

getPluginInstallItem: (
params: MultisigPluginInstallParams,
network: Networkish = "mainnet",
network: Networkish,
): PluginInstallItem =>
MultisigClientEncoding.getPluginInstallItem(params, network),
};
Expand Down
2 changes: 1 addition & 1 deletion modules/client/src/tokenVoting/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export class TokenVotingClient extends ClientCore
*/
getPluginInstallItem: (
params: TokenVotingPluginInstall,
network: Networkish = "mainnet",
network: Networkish,
): PluginInstallItem =>
TokenVotingClientEncoding.getPluginInstallItem(params, network),
};
Expand Down
11 changes: 7 additions & 4 deletions modules/client/test/helpers/build-daos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export async function buildMultisigDAO(pluginRepoAddress: string) {
minApprovals: 1,
onlyListed: true,
},
});
}, client.web3.getProvider().network.name);

const createDaoParams: CreateDaoParams = {
ensSubdomain: "teting-" + Math.random().toString().slice(2),
Expand Down Expand Up @@ -78,7 +78,10 @@ export async function buildTokenVotingDAO(
},
};
const pluginInstallItem = TokenVotingClient.encoding
.getPluginInstallItem(pluginInstallParams);
.getPluginInstallItem(
pluginInstallParams,
client.web3.getProvider().network.name
);

const createDaoParams: CreateDaoParams = {
ensSubdomain: "teting-" + Math.random().toString().slice(2),
Expand Down Expand Up @@ -141,7 +144,7 @@ export async function buildExistingTokenVotingDAO(
minProposerVotingPower: BigInt(0),
votingMode,
},
});
}, client.web3.getProvider().network.name);

const createDaoParams: CreateDaoParams = {
ensSubdomain: "teting-" + Math.random().toString().slice(2),
Expand Down Expand Up @@ -187,7 +190,7 @@ export async function buildAddressListVotingDAO(
minProposerVotingPower: BigInt(0),
votingMode,
},
});
}, client.web3.getProvider().network.name);

const createDaoParams: CreateDaoParams = {
ensSubdomain: "teting-" + Math.random().toString().slice(2),
Expand Down
2 changes: 1 addition & 1 deletion modules/client/test/helpers/deployContracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ export async function createAddresslistDAO(
votingMode,
minProposerVotingPower: BigInt(0),
},
});
}, (await deployment.daoFactory.provider.getNetwork()).name);

const pluginInstallItems = [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ import { bytesToHex, InvalidAddressError } from "@aragon/sdk-common";
import { ADDRESS_ONE, contextParamsLocalChain } from "../constants";
import { Context, SupportedNetworksArray } from "@aragon/sdk-client-common";

const NETWORK_NAME = "goerli";

jest.spyOn(SupportedNetworksArray, "includes").mockReturnValue(true);
jest.spyOn(Context.prototype, "network", "get").mockReturnValue(
{ chainId: 5, name: "goerli" },
{ chainId: 5, name: NETWORK_NAME },
);
describe("Client Address List", () => {
beforeAll(() => {
Expand All @@ -37,6 +39,7 @@ describe("Client Address List", () => {
const installPluginItemItem = AddresslistVotingClient.encoding
.getPluginInstallItem(
withdrawParams,
NETWORK_NAME,
);

expect(typeof installPluginItemItem).toBe("object");
Expand Down
6 changes: 4 additions & 2 deletions modules/client/test/integration/client/estimation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@ import {
TokenType,
} from "@aragon/sdk-client-common";

const NETWORK_NAME = "goerli";

jest.spyOn(SupportedNetworksArray, "includes").mockReturnValue(true);
jest.spyOn(Context.prototype, "network", "get").mockReturnValue(
{ chainId: 5, name: "goerli" },
{ chainId: 5, name: NETWORK_NAME },
);
let daoAddress = "0x1234567890123456789012345678901234567890";
describe("Client", () => {
Expand Down Expand Up @@ -62,7 +64,7 @@ describe("Client", () => {
};

const addresslistVotingPlugin = AddresslistVotingClient.encoding
.getPluginInstallItem(pluginParams);
.getPluginInstallItem(pluginParams, NETWORK_NAME);
addresslistVotingPlugin.id = deployment.addresslistVotingRepo.address;

const daoCreationParams: CreateDaoParams = {
Expand Down
6 changes: 4 additions & 2 deletions modules/client/test/integration/client/methods.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,11 @@ import {
} from "@aragon/sdk-client-common";
import { INSTALLATION_ABI } from "../../../src/multisig/internal/constants";

const NETWORK_NAME = "goerli";

jest.spyOn(SupportedNetworksArray, "includes").mockReturnValue(true);
jest.spyOn(Context.prototype, "network", "get").mockReturnValue(
{ chainId: 5, name: "goerli" },
{ chainId: 5, name: NETWORK_NAME },
);
describe("Client", () => {
let daoAddress: string;
Expand Down Expand Up @@ -144,7 +146,7 @@ describe("Client", () => {
};

const addresslistVotingPlugin = AddresslistVotingClient.encoding
.getPluginInstallItem(pluginParams);
.getPluginInstallItem(pluginParams, NETWORK_NAME);
addresslistVotingPlugin.id = deployment.addresslistVotingRepo.address;

const daoCreationParams: CreateDaoParams = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@ import {
} from "../constants";
import { Context, SupportedNetworksArray } from "@aragon/sdk-client-common";

const NETWORK_NAME = "goerli";

jest.spyOn(SupportedNetworksArray, "includes").mockReturnValue(true);
jest.spyOn(Context.prototype, "network", "get").mockReturnValue(
{ chainId: 5, name: "goerli" },
{ chainId: 5, name: NETWORK_NAME },
);

describe("Client Multisig", () => {
Expand All @@ -43,6 +45,7 @@ describe("Client Multisig", () => {
const installPluginItemItem = MultisigClient.encoding
.getPluginInstallItem(
multisigIntallParams,
NETWORK_NAME
);

expect(typeof installPluginItemItem).toBe("object");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ import { InvalidAddressError } from "@aragon/sdk-common";
import { ADDRESS_ONE, contextParamsLocalChain } from "../constants";
import { Context, SupportedNetworksArray } from "@aragon/sdk-client-common";

const NETWORK_NAME = "goerli";

jest.spyOn(SupportedNetworksArray, "includes").mockReturnValue(true);
jest.spyOn(Context.prototype, "network", "get").mockReturnValue(
{ chainId: 5, name: "goerli" },
{ chainId: 5, name: NETWORK_NAME },
);

describe("Token Voting Client", () => {
Expand All @@ -39,6 +41,7 @@ describe("Token Voting Client", () => {
const tokenVotingInstallPluginItem = TokenVotingClient.encoding
.getPluginInstallItem(
initParams,
NETWORK_NAME
);

expect(typeof tokenVotingInstallPluginItem).toBe("object");
Expand Down

0 comments on commit 15e362f

Please sign in to comment.