Skip to content

Commit

Permalink
Adds getPluginInstallItem, createProposal,
Browse files Browse the repository at this point in the history
getToken

Signed-off-by: emmdim <emmdim@users.noreply.github.com>
  • Loading branch information
emmdim committed Sep 15, 2023
1 parent 62f3954 commit 295d65d
Show file tree
Hide file tree
Showing 15 changed files with 530 additions and 315 deletions.
4 changes: 2 additions & 2 deletions packages/contracts-ethers/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "@vocdoni/offchain-voting-ethers",
"version": "1.0.0",
"author": "Vocdoni Association",
"version": "0.0.2",
"description": "Plugin contract definitions for ethers.js",
"main": "dist/bundle-cjs.js",
"module": "dist/bundle-esm.js",
Expand All @@ -19,7 +20,6 @@
"type": "git",
"url": "git+https://github.com/aragon/osx.git"
},
"author": "",
"license": "AGPL-3.0-or-later",
"bugs": {
"url": "https://github.com/aragon/osx/issues"
Expand Down
Empty file.
18 changes: 10 additions & 8 deletions packages/js-client/package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": "@aragon/simple-storage-js-client",
"author": "Aragon Association",
"version": "1.0.0",
"license": "MIT",
"name": "@vocdoni/offchain-voting",
"author": "Vocdoni Association",
"version": "0.0.8",
"license": "AGPL-3.0-or-later",
"main": "dist/index.js",
"module": "dist/simple-storage-js-client.esm.js",
"types": "dist/index.d.ts",
"module": "dist/offchain-voting.esm.js",
"types": "dist/js-client/src/index.d.ts",
"files": [
"dist"
],
Expand All @@ -26,7 +26,9 @@
"clean": "rm -Rf .turbo dist",
"examples": "node ./scripts/generate-examples-md.js ./examples ./examples.md"
},
"peerDependencies": {},
"peerDependencies": {
"@vocdoni/offchain-voting-ethers": ">=0.0.1"
},
"husky": {
"hooks": {
"pre-commit": "tsdx lint --fix"
Expand Down Expand Up @@ -72,7 +74,7 @@
"@ethersproject/wallet": "^5.7.0",
"graphql": "^16.6.0",
"graphql-request": "4.3.0",
"@vocdoni/offchain-voting-ethers": "*"
"@vocdoni/offchain-voting-ethers": "./vocdoni-offchain-voting-ethers-v0.0.2.tgz"
},
"jest": {
"testEnvironment": "./test-environment.js",
Expand Down
8 changes: 8 additions & 0 deletions packages/js-client/src/_types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
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;
};
2 changes: 1 addition & 1 deletion packages/js-client/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
PluginInstallItem,
} from '@aragon/sdk-client-common';
import { Networkish } from '@ethersproject/providers';
import { OffchainVotingPluginInstall } from './internal/types';
import { OffchainVotingPluginInstall } from './types';

export class OffchainVotingClient
extends OffchainVotingClientCore
Expand Down
2 changes: 1 addition & 1 deletion packages/js-client/src/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { DEFAULT_OFFCHAIN_VOTING_BACKEND_URL, DEFAULT_OFFCHAIN_VOTING_REPO_ADDRE
import {
OffchainVotingContextState,
OffchainVotingOverriddenState,
} from "./internal/types";
} from "./types";
import { OffchainVotingContextParams } from "./types";
import { Context, ContextCore } from "@aragon/sdk-client-common";
export class OffchainVotingContext extends ContextCore {
Expand Down
26 changes: 14 additions & 12 deletions packages/js-client/src/internal/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,26 @@ import { VocdoniVoting__factory } from '@vocdoni/offchain-voting-ethers';

export const DEFAULT_OFFCHAIN_VOTING_REPO_ADDRESS =
'0x0000000000000000000000000000000000000000';
export const DEFAULT_ADDRESSES:{ [K in SupportedNetwork] : {repoAddress: string, setupAddress:string}} = {
homestead:{
setupAddress: "",
repoAddress: "",
export const DEFAULT_ADDRESSES: {
[K in SupportedNetwork]: { repoAddress: string; setupAddress: string };
} = {
homestead: {
setupAddress: '',
repoAddress: '',
},
goerli: {
setupAddress: "",
repoAddress: "",
setupAddress: '',
repoAddress: '',
},
matic: {
setupAddress: "",
repoAddress: "",
setupAddress: '',
repoAddress: '',
},
maticmum: {
setupAddress: "",
repoAddress: "0xaca70d8c462940b839de386bcdd4cacf745632ca",
}
}
setupAddress: '',
repoAddress: '0xaca70d8c462940b839de386bcdd4cacf745632ca',
},
};

export const DEFAULT_OFFCHAIN_VOTING_BACKEND_URL =
'https://example.otg/offchain-voting/rpc';
Expand Down
4 changes: 2 additions & 2 deletions packages/js-client/src/internal/interfaces.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PrepareInstallationParams } from './types';
import { PrepareInstallationParams } from '../types';
import {
VotingSettings,
MintTokenParams,
Expand All @@ -24,7 +24,7 @@ export interface IOffchainVotingClientMethods {
// repo if its not specified in the state of the client
prepareInstallation(
params: PrepareInstallationParams
): AsyncGenerator<PrepareInstallationStepValue>
): AsyncGenerator<PrepareInstallationStepValue>
// Add any methods that you need
}
export interface IOffchainVotingClientEstimation {
Expand Down
11 changes: 3 additions & 8 deletions packages/js-client/src/internal/modules/encoding.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import metadata from '../../../../contracts/src/build-metadata.json';
import { DEFAULT_ADDRESSES } from '../constants';
import { ITokenVotingClientEncoding } from '../interfaces';
import { OffchainVotingPluginInstall } from '../types';
import {
mintTokenParamsToContract,
initParamsToContract,
} from '../utils';
import { OffchainVotingPluginInstall } from '../../types';
import { mintTokenParamsToContract, initParamsToContract } from '../utils';
import { IERC20MintableUpgradeable__factory } from '@aragon/osx-ethers';
import {
MintTokenParams,
Expand Down Expand Up @@ -58,9 +55,7 @@ export class OffchainVotingClientEncoding
throw new UnsupportedNetworkError(networkName);
}
const args = initParamsToContract(params);
const hexBytes = defaultAbiCoder.encode(prepareInstallationDataTypes,
args
);
const hexBytes = defaultAbiCoder.encode(prepareInstallationDataTypes, args);
return {
id: DEFAULT_ADDRESSES[networkName].repoAddress,
data: hexToBytes(hexBytes),
Expand Down
4 changes: 2 additions & 2 deletions packages/js-client/src/internal/modules/estimation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export class SimpleStoragClientEstimation extends OffchainVotingClientCore
public async prepareInstallation(
params: PrepareInstallationParams,
): Promise<GasFeeEstimation> {
let version = params.version;
let version = params.versionTag;
// if not specified use the lates version
if (!version) {
// get signer
Expand All @@ -37,7 +37,7 @@ export class SimpleStoragClientEstimation extends OffchainVotingClientCore
pluginRepo: this.offchainVotingRepoAddress,
version,
installationAbi: BUILD_METADATA.pluginSetup.prepareInstallation.inputs,
installationParams: [params.settings.number],
// installationParams: [params.settings],
});
}
}
Loading

0 comments on commit 295d65d

Please sign in to comment.