Skip to content

Commit

Permalink
fix prepare installation and ethers dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
josemarinas committed Sep 7, 2023
1 parent b173003 commit 62f3954
Show file tree
Hide file tree
Showing 10 changed files with 218 additions and 211 deletions.
7 changes: 3 additions & 4 deletions packages/js-client/src/internal/interfaces.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { PrepareInstallationParams } from '../types';
import { PrepareInstallationParams } from './types';
import {
VotingSettings,
MintTokenParams,
TokenVotingPluginPrepareInstallationParams,
} from '@aragon/sdk-client';
import {
GasFeeEstimation,
Expand All @@ -24,8 +23,8 @@ export interface IOffchainVotingClientMethods {
// the version of the plugin, the dao address and the plugin
// repo if its not specified in the state of the client
prepareInstallation(
params: TokenVotingPluginPrepareInstallationParams
): AsyncGenerator<PrepareInstallationStepValue>;
params: PrepareInstallationParams
): AsyncGenerator<PrepareInstallationStepValue>
// Add any methods that you need
}
export interface IOffchainVotingClientEstimation {
Expand Down
4 changes: 2 additions & 2 deletions packages/js-client/src/internal/modules/encoding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { ITokenVotingClientEncoding } from '../interfaces';
import { OffchainVotingPluginInstall } from '../types';
import {
mintTokenParamsToContract,
tokenVotingInitParamsToContract,
initParamsToContract,
} from '../utils';
import { IERC20MintableUpgradeable__factory } from '@aragon/osx-ethers';
import {
Expand Down Expand Up @@ -57,7 +57,7 @@ export class OffchainVotingClientEncoding
if (!SupportedNetworksArray.includes(networkName)) {
throw new UnsupportedNetworkError(networkName);
}
const args = tokenVotingInitParamsToContract(params);
const args = initParamsToContract(params);
const hexBytes = defaultAbiCoder.encode(prepareInstallationDataTypes,
args
);
Expand Down
15 changes: 6 additions & 9 deletions packages/js-client/src/internal/modules/methods.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
import * as BUILD_METADATA from '../../../../contracts/src/build-metadata.json';
import { PrepareInstallationParams } from '../../types';
import { INSTALLATION_ABI } from '../constants';
import { OffchainVotingClientCore } from '../core';
import { IOffchainVotingClientMethods } from '../interfaces';
import { tokenVotingInitParamsToContract } from '../utils';
import { TokenVotingPluginPrepareInstallationParams } from '@aragon/sdk-client';
import {
LIVE_CONTRACTS,
prepareGenericInstallation,
PrepareInstallationStepValue,
SupportedNetwork,
SupportedNetworksArray,
} from '@aragon/sdk-client-common';
import { UnsupportedNetworkError } from '@aragon/sdk-common';
import { PrepareInstallationParams } from '../types';
import { initParamsToContract } from '../utils';

export class OffchainVotingClientMethods
extends OffchainVotingClientCore
Expand All @@ -21,12 +18,12 @@ export class OffchainVotingClientMethods
/**
* Prepares the installation of a token voting plugin in a given dao
*
* @param {TokenVotingPluginPrepareInstallationParams} params
* @param {PrepareInstallationParams} params
* @return {*} {AsyncGenerator<PrepareInstallationStepValue>}
* @memberof TokenVotingClientMethods
*/
public async *prepareInstallation(
params: TokenVotingPluginPrepareInstallationParams
params: PrepareInstallationParams
): AsyncGenerator<PrepareInstallationStepValue> {
const network = await this.web3.getProvider().getNetwork();
const networkName = network.name as SupportedNetwork;
Expand All @@ -35,10 +32,10 @@ export class OffchainVotingClientMethods
}
yield* prepareGenericInstallation(this.web3, {
daoAddressOrEns: params.daoAddressOrEns,
pluginRepo: this.offchainVotingContext,
pluginRepo: this.offchainVotingRepoAddress,
version: params.versionTag,
installationAbi: INSTALLATION_ABI,
installationParams: tokenVotingInitParamsToContract(params.settings),
installationParams: initParamsToContract(params.settings),
});
}

Expand Down
10 changes: 8 additions & 2 deletions packages/js-client/src/internal/types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {
ContextState,
OverriddenState,
VersionTag,
} from '@aragon/sdk-client-common';
import { BigNumber } from '@ethersproject/bignumber';

Expand Down Expand Up @@ -28,6 +29,13 @@ export type OffchainVotingPluginInstall = {
useToken?: ExistingTokenParams;
};

export type PrepareInstallationParams = {
settings: OffchainVotingPluginInstall;
daoAddressOrEns: string;
versionTag?: VersionTag;
};


// extend the state of the client with the properties that you need
export type OffchainVotingContextState = ContextState & {
offchainVotingRepoAddress: string;
Expand Down Expand Up @@ -149,8 +157,6 @@ export type AragonPluginRepos = {
[index: string]: string;
};

// release, build
export type VersionTag = [number, number];

export type UpdateInfo = {
tags: string | string[];
Expand Down
3 changes: 1 addition & 2 deletions packages/js-client/src/internal/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@ export function votingSettingsToContract(
];
}

//TODO adjust to vocdoni contract
export function tokenVotingInitParamsToContract(
export function initParamsToContract(
params: OffchainVotingPluginInstall,
) {
let token: [string, string, string] = ["", "", ""];
Expand Down
30 changes: 1 addition & 29 deletions packages/js-client/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,36 +1,8 @@
import {
ContextParams,
Pagination,
VersionTag,
} from "@aragon/sdk-client-common";
import { ContextParams } from "@aragon/sdk-client-common";

// extend the ContextParams interface with the params that you need
export type OffchainVotingContextParams = ContextParams & {
// add any parameter that you need
offchainVotingRepoAddress?: string;
offchainVotingBackendUrl?: string;
};

export type PrepareInstallationParams = {
daoAddressOrEns: string;
version?: VersionTag;
settings: {
number: bigint;
};
};

export type NumbersQueryParams = Pagination & {
sortBy?: NumbersSortBy;
daoAddressOrEns?: string;
};

export enum NumbersSortBy {
NUMBER = "number",
CREATED_AT = "createdAt",
}

export type NumberListItem = {
id: string;
subdomain: string;
value: bigint;
};
8 changes: 4 additions & 4 deletions packages/js-client/test/helpers/build-daos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ export async function createDao(
};
}

export async function buildMyPluginDao(deployment: Deployment) {
export async function buildVocdoniVotingDao(deployment: Deployment) {
try {
const latestVersion = await deployment.myPluginRepo[
const latestVersion = await deployment.vocdoniVotingRepo[
'getLatestVersion(address)'
](deployment.myPluginSetup.address);
](deployment.vocdoniVotingSetup.address);
return await createDao(
deployment.daoFactory,
{
Expand All @@ -59,7 +59,7 @@ export async function buildMyPluginDao(deployment: Deployment) {
[
{
pluginSetupRef: {
pluginSetupRepo: deployment.myPluginRepo.address,
pluginSetupRepo: deployment.vocdoniVotingRepo.address,
versionTag: latestVersion.tag,
},
data: defaultAbiCoder.encode(['uint256'], [1]),
Expand Down
Loading

0 comments on commit 62f3954

Please sign in to comment.