Skip to content

Commit

Permalink
Naming refactor:
Browse files Browse the repository at this point in the history
- offchain to gasless (including package names)
- restarting package versioning
- removing some deprecated files (_types.ts)
- Changing references to "committee" with "multisig"
  • Loading branch information
emmdim committed Oct 30, 2023
1 parent 5ac8ebc commit f1083ce
Show file tree
Hide file tree
Showing 20 changed files with 176 additions and 184 deletions.
4 changes: 2 additions & 2 deletions packages/contracts-ethers/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@vocdoni/offchain-voting-ethers",
"name": "@vocdoni/gasless-voting-ethers",
"author": "Vocdoni Association",
"version": "0.0.4",
"version": "0.0.1-rc1",
"description": "Plugin contract definitions for ethers.js",
"main": "dist/bundle-cjs.js",
"module": "dist/bundle-esm.js",
Expand Down
1 change: 1 addition & 0 deletions packages/contracts/deployments/goerli/.chainId
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
5
10 changes: 5 additions & 5 deletions packages/js-client/package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"name": "@vocdoni/offchain-voting",
"name": "@vocdoni/gasless-voting",
"author": "Vocdoni Association",
"version": "0.0.76",
"version": "0.0.1-rc1",
"license": "AGPL-3.0-or-later",
"main": "dist/index.js",
"module": "dist/offchain-voting.esm.js",
"module": "dist/gasless-voting.esm.js",
"types": "dist/js-client/src/index.d.ts",
"files": [
"dist"
Expand Down Expand Up @@ -56,7 +56,7 @@
"ganache": "^7.8.0",
"husky": "^7.0.4",
"size-limit": "^7.0.8",
"tsdx": "^0.14.1",
"tsdx": "^0.14.1",
"tslib": "^2.3.1",
"typescript": "^4.6.2"
},
Expand All @@ -72,7 +72,7 @@
"@ethersproject/wallet": "^5.7.0",
"graphql": "^16.6.0",
"graphql-request": "4.3.0",
"@vocdoni/offchain-voting-ethers": "./vocdoni-offchain-voting-ethers-v0.0.4.tgz",
"@vocdoni/gasless-voting-ethers": "./vocdoni-gasless-voting-ethers-v0.0.1-rc1.tgz",
"@vocdoni/sdk": "0.3.1",
"axios": "0.27.2",
"@types/big.js": "^6.1.5"
Expand Down
8 changes: 0 additions & 8 deletions packages/js-client/src/_types.ts

This file was deleted.

54 changes: 27 additions & 27 deletions packages/js-client/src/client.ts
Original file line number Diff line number Diff line change
@@ -1,40 +1,40 @@
import { OffchainVotingContext } from './context';
import { GaslessVotingContext } from './context';
import {
IOffchainVotingClient,
IOffchainVotingClientDecoding,
IOffchainVotingClientEncoding,
IOffchainVotingClientEstimation,
IOffchainVotingClientMethods,
OffchainVotingClientEstimation,
OffchainVotingClientDecoding,
OffchainVotingClientEncoding,
OffchainVotingClientMethods,
IGaslessVotingClient,
IGaslessVotingClientDecoding,
IGaslessVotingClientEncoding,
IGaslessVotingClientEstimation,
IGaslessVotingClientMethods,
GaslessVotingClientEstimation,
GaslessVotingClientDecoding,
GaslessVotingClientEncoding,
GaslessVotingClientMethods,
} from './internal';
import { OffchainVotingClientCore } from './internal/core';
import { OffchainVotingPluginInstall } from './types';
import { GaslessVotingClientCore } from './internal/core';
import { GaslessVotingPluginInstall } from './types';
import { PluginInstallItem } from '@aragon/sdk-client-common';
import { Networkish } from '@ethersproject/providers';
import { EnvOptions } from '@vocdoni/sdk';

export class OffchainVotingClient
extends OffchainVotingClientCore
implements IOffchainVotingClient
export class GaslessVotingClient
extends GaslessVotingClientCore
implements IGaslessVotingClient
{
public methods: IOffchainVotingClientMethods;
public estimation: IOffchainVotingClientEstimation;
public encoding: IOffchainVotingClientEncoding;
public decoding: IOffchainVotingClientDecoding;
public methods: IGaslessVotingClientMethods;
public estimation: IGaslessVotingClientEstimation;
public encoding: IGaslessVotingClientEncoding;
public decoding: IGaslessVotingClientDecoding;

constructor(pluginContext: OffchainVotingContext, vocdoniEnv: EnvOptions) {
constructor(pluginContext: GaslessVotingContext, vocdoniEnv: EnvOptions) {
if (!vocdoniEnv) throw 'Invalid Vocdoni environment';
super(pluginContext, vocdoniEnv);
this.methods = new OffchainVotingClientMethods(pluginContext, vocdoniEnv);
this.estimation = new OffchainVotingClientEstimation(
this.methods = new GaslessVotingClientMethods(pluginContext, vocdoniEnv);
this.estimation = new GaslessVotingClientEstimation(
pluginContext,
vocdoniEnv
);
this.encoding = new OffchainVotingClientEncoding(pluginContext, vocdoniEnv);
this.decoding = new OffchainVotingClientDecoding(pluginContext, vocdoniEnv);
this.encoding = new GaslessVotingClientEncoding(pluginContext, vocdoniEnv);
this.decoding = new GaslessVotingClientDecoding(pluginContext, vocdoniEnv);
}

static encoding = {
Expand All @@ -45,12 +45,12 @@ export class OffchainVotingClient
* @param {TokenVotingPluginInstall} params
* @param {Networkish} [network="mainnet"]
* @return {*} {PluginInstallItem}
* @memberof OffchainVotingClient
* @memberof GaslessVotingClient
*/
getPluginInstallItem: (
params: OffchainVotingPluginInstall,
params: GaslessVotingPluginInstall,
network: Networkish
): PluginInstallItem =>
OffchainVotingClientEncoding.getPluginInstallItem(params, network),
GaslessVotingClientEncoding.getPluginInstallItem(params, network),
};
}
50 changes: 25 additions & 25 deletions packages/js-client/src/context.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import { DEFAULT_OFFCHAIN_VOTING_BACKEND_URL, DEFAULT_OFFCHAIN_VOTING_REPO_ADDRESS } from "./internal";
import { DEFAULT_GASLESS_VOTING_BACKEND_URL, DEFAULT_GASLESS_VOTING_REPO_ADDRESS } from "./internal";
import {
OffchainVotingContextState,
OffchainVotingOverriddenState,
GaslessVotingContextState as GaslessVotingContextState,
GaslessVotingOverriddenState as GaslessVotingOverriddenState,
} from "./types";
import { OffchainVotingContextParams } from "./types";
import { GaslessVotingContextParams } from "./types";
import { Context, ContextCore } from "@aragon/sdk-client-common";
export class OffchainVotingContext extends ContextCore {
export class GaslessVotingContext extends ContextCore {
// This variable keeps track of the state of the context and is an extension of the Base Context State
protected state: OffchainVotingContextState = this.state;
protected state: GaslessVotingContextState = this.state;
// This variable keeps track of the properties that were manually overriden by the user
protected overriden: OffchainVotingOverriddenState = this.overriden;
protected overriden: GaslessVotingOverriddenState = this.overriden;
constructor(
contextParams?: Partial<OffchainVotingContextParams>,
contextParams?: Partial<GaslessVotingContextParams>,
aragonContext?: Context,
) {
// call the parent constructor to be able to have access to this
Expand All @@ -29,47 +29,47 @@ export class OffchainVotingContext extends ContextCore {
}
}

public set(contextParams: OffchainVotingContextParams) {
public set(contextParams: GaslessVotingContextParams) {
// so we need to call the parent set first
super.set(contextParams);

// set the default values for the new params
this.setDefaults();

// override default params if specified in the contexcParams
if (contextParams.offchainVotingBackendUrl) {
// override the offchainVotingBackendUrl value
this.state.offchainVotingBackendUrl =
contextParams.offchainVotingBackendUrl;
if (contextParams.gaslessVotingBackendUrl) {
// override the gaslessVotingBackendUrl value
this.state.gaslessVotingBackendUrl =
contextParams.gaslessVotingBackendUrl;
// set the overriden flag to true in case set is called again
this.overriden.offchainVotingBackendUrl = true;
this.overriden.gaslessVotingBackendUrl = true;
}

if(contextParams.offchainVotingRepoAddress) {
this.state.offchainVotingRepoAddress = contextParams.offchainVotingRepoAddress;
this.overriden.offchainVotingRepoAddress = true;
if(contextParams.gaslessVotingRepoAddress) {
this.state.gaslessVotingRepoAddress = contextParams.gaslessVotingRepoAddress;
this.overriden.gaslessVotingRepoAddress = true;
}
}

// Use this space to set the default values for the properties that you need
// in the context
private setDefaults() {
if (!this.overriden.offchainVotingRepoAddress) {
this.state.offchainVotingRepoAddress = DEFAULT_OFFCHAIN_VOTING_REPO_ADDRESS;
if (!this.overriden.gaslessVotingRepoAddress) {
this.state.gaslessVotingRepoAddress = DEFAULT_GASLESS_VOTING_REPO_ADDRESS;
}
if (!this.overriden.offchainVotingBackendUrl) {
this.state.offchainVotingBackendUrl = DEFAULT_OFFCHAIN_VOTING_BACKEND_URL;
if (!this.overriden.gaslessVotingBackendUrl) {
this.state.gaslessVotingBackendUrl = DEFAULT_GASLESS_VOTING_BACKEND_URL;
}
}

// here add getters for the properies that you need the user to pass in the context
// This can be used to specify a contract addres or and endpoint to a service
get offchainVotingRepoAddress(): string {
return this.state.offchainVotingRepoAddress;
get gaslessVotingRepoAddress(): string {
return this.state.gaslessVotingRepoAddress;
}
// here add getters for the properies that you need the user to pass in the context
// This can be used to specify a contract addres or and endpoint to a service
get offchainVotingBackendUrl(): string {
return this.state.offchainVotingBackendUrl;
get gaslessVotingBackendUrl(): string {
return this.state.gaslessVotingBackendUrl;
}
}
8 changes: 4 additions & 4 deletions packages/js-client/src/internal/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
import { IERC20MintableUpgradeable__factory } from '@aragon/osx-ethers';
import { MetadataAbiInput, SupportedNetwork } from '@aragon/sdk-client-common';
import { BigNumber } from '@ethersproject/bignumber';
import { VocdoniVoting__factory } from '@vocdoni/offchain-voting-ethers';
import { VocdoniVoting__factory } from '@vocdoni/gasless-voting-ethers';

export const DEFAULT_OFFCHAIN_VOTING_REPO_ADDRESS =
export const DEFAULT_GASLESS_VOTING_REPO_ADDRESS =
'0x0000000000000000000000000000000000000000';
export const DEFAULT_ADDRESSES: {
[K in SupportedNetwork]: { repoAddress: string; setupAddress: string };
Expand Down Expand Up @@ -43,8 +43,8 @@ export const DEFAULT_ADDRESSES: {
},
};

export const DEFAULT_OFFCHAIN_VOTING_BACKEND_URL =
'https://example.otg/offchain-voting/rpc';
export const DEFAULT_GASLESS_VOTING_BACKEND_URL =
'https://example.otg/gasless-voting/rpc';

const majorityVotingInterface = VocdoniVoting__factory.createInterface();

Expand Down
14 changes: 7 additions & 7 deletions packages/js-client/src/internal/core.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
import { OffchainVotingContext } from '../context';
import { GaslessVotingContext } from '../context';
import { ClientCore } from '@aragon/sdk-client-common';
import {
EnvOptions,
VocdoniCensus3Client,
VocdoniSDKClient,
} from '@vocdoni/sdk';

export class OffchainVotingClientCore extends ClientCore {
public offchainVotingContext: string;
public offchainVotingRepoAddress: string;
export class GaslessVotingClientCore extends ClientCore {
public gaslessVotingContext: string;
public gaslessVotingRepoAddress: string;
protected vocdoniSDK: VocdoniSDKClient;
protected vocdoniCensus3: VocdoniCensus3Client;

constructor(pluginContext: OffchainVotingContext, vocdoniEnv: EnvOptions) {
constructor(pluginContext: GaslessVotingContext, vocdoniEnv: EnvOptions) {
super(pluginContext);
this.vocdoniSDK = new VocdoniSDKClient({ env: vocdoniEnv });
this.vocdoniCensus3 = new VocdoniCensus3Client({ env: vocdoniEnv });
this.offchainVotingContext = pluginContext.offchainVotingBackendUrl;
this.offchainVotingRepoAddress = pluginContext.offchainVotingRepoAddress;
this.gaslessVotingContext = pluginContext.gaslessVotingBackendUrl;
this.gaslessVotingRepoAddress = pluginContext.gaslessVotingRepoAddress;
}
}
20 changes: 10 additions & 10 deletions packages/js-client/src/internal/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ import {
ProposalMetadata,
} from '@aragon/sdk-client-common';

export interface IOffchainVotingClient {
methods: IOffchainVotingClientMethods;
estimation: IOffchainVotingClientEstimation;
encoding: IOffchainVotingClientEncoding;
decoding: IOffchainVotingClientDecoding;
export interface IGaslessVotingClient {
methods: IGaslessVotingClientMethods;
estimation: IGaslessVotingClientEstimation;
encoding: IGaslessVotingClientEncoding;
decoding: IGaslessVotingClientDecoding;
}

export interface IOffchainVotingClientMethods {
export interface IGaslessVotingClientMethods {
// Generic prepareInstallation method
// it should receive the parameters in the
// prepareInstallation of plugin that you are installing,
Expand Down Expand Up @@ -65,7 +65,7 @@ export interface IOffchainVotingClientMethods {
Erc20TokenDetails | Erc721TokenDetails | Erc20WrapperTokenDetails | null
>;
getMembers(pluginAddress: string): Promise<TokenVotingMember[]>;
isCommitteeMember(
isMultisigMember(
pluginAddress: string,
memberAddress: string
): Promise<boolean>;
Expand All @@ -85,7 +85,7 @@ export interface IOffchainVotingClientMethods {
): AsyncGenerator<ExecuteProposalStepValue>;
pinMetadata(params: ProposalMetadata): Promise<string>;
}
export interface IOffchainVotingClientEstimation {
export interface IGaslessVotingClientEstimation {
// prepareInstallation(
// params: PrepareInstallationParams
// ): Promise<GasFeeEstimation>;
Expand All @@ -101,7 +101,7 @@ export interface IOffchainVotingClientEstimation {
execute(pluginAddress: string, proposalId: number): Promise<GasFeeEstimation>;
// Add any estimation methods that you need
}
export interface IOffchainVotingClientEncoding {
export interface IGaslessVotingClientEncoding {
// Fill with methods that encode actions that can be passed to a proposal
// encodeAction(params: Params): DaoAction;
mintTokenAction: (
Expand All @@ -113,7 +113,7 @@ export interface IOffchainVotingClientEncoding {
params: GaslessPluginVotingSettings
): DaoAction;
}
export interface IOffchainVotingClientDecoding {
export interface IGaslessVotingClientDecoding {
// Fill with methods that encode actions that can be passed to a proposal
// encodeAction(data: Uint8Array): params;
findInterface(data: Uint8Array): InterfaceParams | null;
Expand Down
18 changes: 9 additions & 9 deletions packages/js-client/src/internal/modules/decoding.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { GaslessPluginVotingSettings } from '../../types';
import { AVAILABLE_FUNCTION_SIGNATURES } from '../constants';
import { OffchainVotingClientCore } from '../core';
import { IOffchainVotingClientDecoding } from '../interfaces';
import { GaslessVotingClientCore } from '../core';
import { IGaslessVotingClientDecoding } from '../interfaces';
import {
mintTokenParamsFromContract,
votingSettingsfromContract,
Expand All @@ -16,19 +16,19 @@ import { bytesToHex } from '@aragon/sdk-common';
import {
VocdoniVoting,
VocdoniVoting__factory,
} from '@vocdoni/offchain-voting-ethers';
} from '@vocdoni/gasless-voting-ethers';

export class OffchainVotingClientDecoding
extends OffchainVotingClientCore
implements IOffchainVotingClientDecoding
export class GaslessVotingClientDecoding
extends GaslessVotingClientCore
implements IGaslessVotingClientDecoding
{
// add your action decoders here
/**
* Decodes a dao metadata from an encoded update metadata action
*
* @param {Uint8Array} data
* @return {*} {VotingSettings}
* @memberof OffchainVotingClientDecoding
* @memberof GaslessVotingClientDecoding
*/
public updatePluginSettingsAction(
data: Uint8Array
Expand Down Expand Up @@ -57,7 +57,7 @@ export class OffchainVotingClientDecoding
*
* @param {Uint8Array} data
* @return {*} {MintTokenParams}
* @memberof OffchainVotingClientDecoding
* @memberof GaslessVotingClientDecoding
*/
public mintTokenAction(data: Uint8Array): MintTokenParams {
const votingInterface =
Expand All @@ -76,7 +76,7 @@ export class OffchainVotingClientDecoding
*
* @param {Uint8Array} data
* @return {*} {(InterfaceParams | null)}
* @memberof OffchainVotingClientDecoding
* @memberof GaslessVotingClientDecoding
*/
public findInterface(data: Uint8Array): InterfaceParams | null {
try {
Expand Down
Loading

0 comments on commit f1083ce

Please sign in to comment.