Skip to content

Commit

Permalink
Updates aragon packages:
Browse files Browse the repository at this point in the history
  • Loading branch information
emmdim committed Oct 24, 2023
1 parent 6c52945 commit e2e2a73
Show file tree
Hide file tree
Showing 9 changed files with 231 additions and 21 deletions.
2 changes: 1 addition & 1 deletion packages/contracts-ethers/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@vocdoni/offchain-voting-ethers",
"author": "Vocdoni Association",
"version": "0.0.3",
"version": "0.0.4",
"description": "Plugin contract definitions for ethers.js",
"main": "dist/bundle-cjs.js",
"module": "dist/bundle-esm.js",
Expand Down
4 changes: 2 additions & 2 deletions packages/contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@
"tmp-promise": "^3.0.3"
},
"dependencies": {
"@aragon/osx": "^1.3.0-rc0.1",
"@aragon/osx-ethers": "^1.3.0-rc0.1",
"@aragon/osx": "^1.3.0-rc0.3",
"@aragon/osx-ethers": "^1.3.0-rc0.3",
"@ensdomains/ens-contracts": "0.0.20",
"@openzeppelin/contracts": "^4.8.2",
"@openzeppelin/contracts-upgradeable": "^4.8.2",
Expand Down
12 changes: 6 additions & 6 deletions packages/js-client/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@vocdoni/offchain-voting",
"author": "Vocdoni Association",
"version": "0.0.19",
"version": "0.0.76",
"license": "AGPL-3.0-or-later",
"main": "dist/index.js",
"module": "dist/offchain-voting.esm.js",
Expand Down Expand Up @@ -49,7 +49,7 @@
}
],
"devDependencies": {
"@aragon/sdk-client": "1.10.0-rc1",
"@aragon/sdk-client": "^1.14.0",
"@ensdomains/ens-contracts": "^0.0.15",
"@size-limit/preset-small-lib": "^7.0.8",
"@types/jest": "^29.5.2",
Expand All @@ -61,9 +61,9 @@
"typescript": "^4.6.2"
},
"dependencies": {
"@aragon/osx-ethers": "1.3.0-rc0",
"@aragon/sdk-client-common": "1.2.0-rc0",
"@aragon/sdk-common": "1.5.0",
"@aragon/osx-ethers": "1.3.0-rc0.3",
"@aragon/sdk-client-common": "^1.7.0",
"@aragon/sdk-common": "^1.7.0",
"@ethersproject/abstract-signer": "^5.7.0",
"@ethersproject/bignumber": "^5.7.0",
"@ethersproject/constants": "^5.7.0",
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.3.tgz",
"@vocdoni/offchain-voting-ethers": "./vocdoni-offchain-voting-ethers-v0.0.4.tgz",
"@vocdoni/sdk": "0.3.1",
"axios": "0.27.2",
"@types/big.js": "^6.1.5"
Expand Down
16 changes: 16 additions & 0 deletions packages/js-client/src/internal/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,22 @@ export const DEFAULT_ADDRESSES: {
setupAddress: '0x5A6E29875cCa6eb7a9c39938720e6096468a8917',
repoAddress: '0x5BD8F8Dc73476d24F37c4d885c4528d5abB8cBe6',
},
base: {
setupAddress: '',
repoAddress: '',
},
baseGoerli: {
setupAddress: '',
repoAddress: '',
},
local: {
setupAddress: '',
repoAddress: '',
},
sepolia: {
setupAddress: '',
repoAddress: '',
},
};

export const DEFAULT_OFFCHAIN_VOTING_BACKEND_URL =
Expand Down
4 changes: 3 additions & 1 deletion packages/js-client/src/internal/graphql-queries/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
// add your grapql queries here and export them with this file
// add your grapql queries here and export them with this file
export * from './proposal';
export * from './token';
130 changes: 130 additions & 0 deletions packages/js-client/src/internal/graphql-queries/proposal.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
import { gql } from 'graphql-request';

export const QueryTokenVotingProposal = gql`
query TokenVotingProposal($proposalId: ID!) {
tokenVotingProposal(id: $proposalId) {
id
dao {
id
subdomain
}
creator
metadata
createdAt
creationBlockNumber
executionDate
executionBlockNumber
actions {
to
value
data
}
yes
no
abstain
votingMode
supportThreshold
startDate
endDate
executed
earlyExecutable
potentiallyExecutable
executionTxHash
voters {
voter {
address
}
voteReplaced
voteOption
votingPower
}
plugin {
token {
id
name
symbol
__typename
... on ERC20Contract {
decimals
}
... on ERC20WrapperContract {
decimals
underlyingToken {
id
name
symbol
decimals
}
}
}
}
totalVotingPower
minVotingPower
}
}
`;
export const QueryTokenVotingProposals = gql`
query TokenVotingProposals(
$where: TokenVotingProposal_filter!
$limit: Int!
$skip: Int!
$direction: OrderDirection!
$sortBy: TokenVotingProposal_orderBy!
) {
tokenVotingProposals(
where: $where
first: $limit
skip: $skip
orderDirection: $direction
orderBy: $sortBy
) {
id
dao {
id
subdomain
}
creator
metadata
yes
no
abstain
startDate
endDate
executed
earlyExecutable
potentiallyExecutable
votingMode
supportThreshold
minVotingPower
totalVotingPower
voters {
voter {
address
}
voteReplaced
voteOption
votingPower
}
plugin {
token {
id
name
symbol
__typename
... on ERC20Contract {
decimals
}
... on ERC20WrapperContract {
decimals
underlyingToken {
id
name
symbol
decimals
}
}
}
}
}
}
`;
26 changes: 26 additions & 0 deletions packages/js-client/src/internal/graphql-queries/token.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { gql } from 'graphql-request';

export const QueryGalsessVotingPluginToken = gql`
query GalsessVotingPluginToken($address: ID!) {
galsessVotingPluginToken(id: $address) {
token {
id
name
symbol
__typename
... on ERC20WrapperContract {
decimals
underlyingToken {
id
name
symbol
decimals
}
}
... on ERC20Contract {
decimals
}
}
}
}
`;
5 changes: 2 additions & 3 deletions packages/js-client/src/internal/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
Erc20WrapperTokenDetails,
TokenVotingMember,
ExecuteProposalStepValue,
ProposalQueryParams,
} from '@aragon/sdk-client';
import {
GasFeeEstimation,
Expand Down Expand Up @@ -51,9 +52,7 @@ export interface IOffchainVotingClientMethods {
): Promise<GaslessVotingProposal | null>;
//
getProposals(
daoName: string,
daoAddress: string,
pluginAddress: string
params: ProposalQueryParams & { pluginAddress: string }
): Promise<GaslessVotingProposal[]>;
//
getVotingSettings(
Expand Down
53 changes: 45 additions & 8 deletions packages/js-client/src/internal/modules/methods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,13 @@ import {
ExecuteProposalStepValue,
ProposalCreationStepValue,
ProposalCreationSteps,
ProposalQueryParams,
TokenVotingMember,
} from '@aragon/sdk-client';
import {
findLog,
InvalidAddressOrEnsError,
NoProviderError,
prepareGenericInstallation,
PrepareInstallationStepValue,
ProposalMetadata,
Expand Down Expand Up @@ -78,6 +81,9 @@ export class OffchainVotingClientMethods
version: params.versionTag,
installationAbi: INSTALLATION_ABI,
installationParams: initParamsToContract(params.settings),
pluginSetupProcessorAddress: this.web3.getAddress(
'pluginSetupProcessorAddress'
),
});
}

Expand Down Expand Up @@ -247,7 +253,7 @@ export class OffchainVotingClientMethods
proposalId: number
): Promise<GaslessVotingProposal | null> {
try {
if (!isAddress(pluginAddress) || !isAddress(daoAddress)) {
if (!isAddress(pluginAddress)) {
Promise.reject(new InvalidAddressError());
}
if (isNaN(proposalId)) Promise.reject(new InvalidProposalIdError());
Expand Down Expand Up @@ -299,19 +305,50 @@ export class OffchainVotingClientMethods
* @return {*} {Promise<TokenVotingProposalListItem[]>}
* @memberof OffchainVotingClientMethods
*/
public async getProposals(
daoName: string,
daoAddress: string,
pluginAddress: string
): Promise<GaslessVotingProposal[]> {
if (!isAddress(pluginAddress) || !isAddress(daoAddress)) {
public async getProposals({
daoAddressOrEns,
pluginAddress,
}: // limit = 10,
// status,
// skip = 0,
// direction = SortDirection.ASC,
// sortBy = ProposalSortBy.CREATED_AT,
ProposalQueryParams & { pluginAddress: string }): Promise<
GaslessVotingProposal[]
> {
if (!isAddress(pluginAddress)) {
Promise.reject(new InvalidAddressError());
}

let address = daoAddressOrEns;
if (address) {
if (!isAddress(address)) {
await this.web3.ensureOnline();
const provider = this.web3.getProvider();
if (!provider) {
throw new NoProviderError();
}
try {
const resolvedAddress = await provider.resolveName(address);
if (!resolvedAddress) {
throw new InvalidAddressOrEnsError();
}
address = resolvedAddress;
} catch (e) {
throw new InvalidAddressOrEnsError(e);
}
}
}
let id = 0;
let proposal = null;
let proposals: GaslessVotingProposal[] = [];
do {
proposal = await this.getProposal(daoName, daoAddress, pluginAddress, id);
proposal = await this.getProposal(
daoAddressOrEns || '',
address || '',
pluginAddress,
id
);
if (proposal) proposals.push(proposal);
id += 1;
} while (proposal != null);
Expand Down

0 comments on commit e2e2a73

Please sign in to comment.