Skip to content

Commit

Permalink
Merge branch 'dev/deploy-v2' into f/subgraph
Browse files Browse the repository at this point in the history
# Conflicts:
#	packages/js-client/src/internal/graphql-queries/proposal.ts
  • Loading branch information
nigeon committed Nov 8, 2023
2 parents a3d62fa + dfd4f71 commit ba0b1ee
Show file tree
Hide file tree
Showing 9 changed files with 147 additions and 114 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/gasless-voting-ethers",
"author": "Vocdoni Association",
"version": "0.0.1-rc1",
"version": "0.0.1-rc4",
"description": "Plugin contract definitions for ethers.js",
"main": "dist/bundle-cjs.js",
"module": "dist/bundle-esm.js",
Expand Down
6 changes: 3 additions & 3 deletions packages/js-client/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@vocdoni/gasless-voting",
"author": "Vocdoni Association",
"version": "0.0.1-rc7",
"version": "0.0.1-rc13",
"license": "AGPL-3.0-or-later",
"main": "dist/index.js",
"module": "dist/gasless-voting.esm.js",
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 @@ -71,7 +71,7 @@
"@ethersproject/wallet": "^5.7.0",
"graphql": "^16.6.0",
"graphql-request": "4.3.0",
"@vocdoni/gasless-voting-ethers": "./vocdoni-gasless-voting-ethers-v0.0.1-rc1.tgz",
"@vocdoni/gasless-voting-ethers": "./vocdoni-gasless-voting-ethers-v0.0.1-rc4.tgz",
"@vocdoni/sdk": "0.3.1",
"axios": "0.27.2",
"@types/big.js": "^6.1.5"
Expand Down
6 changes: 3 additions & 3 deletions packages/js-client/src/internal/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export const INSTALLATION_ABI: MetadataAbiInput[] = [
components: [
{
internalType: 'bool',
name: 'onlyCommitteeProposalCreation',
name: 'onlyExecutionMultisigProposalCreation',
type: 'bool',
description: '',
},
Expand All @@ -98,7 +98,7 @@ export const INSTALLATION_ABI: MetadataAbiInput[] = [
},
{
internalType: 'uint64',
name: 'minDuration',
name: 'minVoteDuration',
type: 'uint64',
description: '',
},
Expand All @@ -116,7 +116,7 @@ export const INSTALLATION_ABI: MetadataAbiInput[] = [
},
{
internalType: 'string',
name: 'censusStrategy',
name: 'censusStrategyURI',
type: 'string',
description: '',
},
Expand Down
135 changes: 86 additions & 49 deletions packages/js-client/src/internal/graphql-queries/proposal.ts
Original file line number Diff line number Diff line change
@@ -1,54 +1,77 @@
import { gql } from 'graphql-request';

export const QueryPluginProposal = gql`
query PluginProposal($proposalId: ID!) {
export const QueryTokenVotingProposal = gql`
query TokenVotingProposal($proposalId: ID!) {
tokenVotingProposal(id: $proposalId) {
id
dao {
id
subdomain
}
creator
metadata
createdAt
creationBlockNumber
executionDate
executionBlockNumber
actions {
id
to
value
data
}
allowFailureMap
failureMap
pluginProposalId
vochainProposalId
creator
yes
no
abstain
votingMode
supportThreshold
startDate
createdAt
voteEndDate
tallyEndDate
creationBlockNumber
snapshotBlock
executed
executionDate
executionBlockNumber
earlyExecutable
potentiallyExecutable
executionTxHash
approvers {
id
voters {
voter {
address
}
voteReplaced
voteOption
votingPower
}
tally {
id
values
plugin {
token {
id
name
symbol
__typename
... on ERC20Contract {
decimals
}
... on ERC20WrapperContract {
decimals
underlyingToken {
id
name
symbol
decimals
}
}
}
}
tallyApproved
totalVotingPower
minVotingPower
}
}
`;

export const QueryPluginProposals = gql`
query QueryPluginProposals(
$where: PluginProposal_filter!
export const QueryTokenVotingProposals = gql`
query TokenVotingProposals(
$where: TokenVotingProposal_filter!
$limit: Int!
$skip: Int!
$direction: OrderDirection!
$sortBy: TPluginProposal_orderBy!
$sortBy: TokenVotingProposal_orderBy!
) {
pluginProposals(
tokenVotingProposals(
where: $where
first: $limit
skip: $skip
Expand All @@ -58,36 +81,50 @@ export const QueryPluginProposals = gql`
id
dao {
id
subdomain
}
metadata
actions {
id
value
data
}
allowFailureMap
failureMap
pluginProposalId
vochainProposalId
creator
metadata
yes
no
abstain
startDate
createdAt
voteEndDate
tallyEndDate
creationBlockNumber
snapshotBlock
executed
executionDate
executionBlockNumber
executionTxHash
approvers {
id
earlyExecutable
potentiallyExecutable
votingMode
supportThreshold
minVotingPower
totalVotingPower
voters {
voter {
address
}
voteReplaced
voteOption
votingPower
}
tally {
id
values
plugin {
token {
id
name
symbol
__typename
... on ERC20Contract {
decimals
}
... on ERC20WrapperContract {
decimals
underlyingToken {
id
name
symbol
decimals
}
}
}
}
tallyApproved
}
}
`;
13 changes: 8 additions & 5 deletions packages/js-client/src/internal/modules/encoding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,19 +98,22 @@ export class GaslessVotingClientEncoding
const votingInterface = VocdoniVoting__factory.createInterface();
const args = gaslessVotingSettingsToContract(params);
// get hex bytes
// const expectedfunction = votingInterface.getFunction(
// 'updatePluginSettings((bool,uint16,uint32,uint32,uint64,uint64,address,uint256,string))'
// );
const hexBytes = votingInterface.encodeFunctionData(
'updatePluginSettings',
"updatePluginSettings",
[
{
onlyCommitteeProposalCreation: args[0],
onlyExecutionMultisigProposalCreation: args[0],
minTallyApprovals: args[1],
minParticipation: args[2],
supportThreshold: args[3],
minDuration: args[4],
expirationTime: args[5],
minVoteDuration: args[4],
minTallyDuration: args[5],
daoTokenAddress: args[6],
minProposerVotingPower: args[7],
censusStrategy: args[8],
censusStrategyURI: args[8],
},
]
);
Expand Down
12 changes: 7 additions & 5 deletions packages/js-client/src/internal/modules/estimation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,17 @@ export class GaslessVotingClientEstimation


const startTimestamp = params.startDate?.getTime() || 0;
const endTimestamp = params.endDate.getTime();
const expirationTimestamp = params.expirationDate?.getTime() || 0;
const endTimestamp = params.voteEndDate.getTime();
const minTallyDurationTimestamp = params.tallyEndDate?.getTime() || 0;

const votingParams: GaslessProposalParametersContractStruct = {
censusBlock: [] as string[],
startDate: BigInt(Math.round(startTimestamp / 1000)),
endDate: BigInt(Math.round(endTimestamp / 1000)),
expirationDate: BigInt(Math.round(expirationTimestamp / 1000)),
voteEndDate: BigInt(Math.round(endTimestamp / 1000)),
tallyEndDate: BigInt(Math.round(minTallyDurationTimestamp / 1000)),
securityBlock: BigInt(0),
totalVotingPower: params.totalVotingPower,
censusURI: params.censusURI,
censusRoot: hexToBytes(params.censusRoot)
};
const estimatedGasFee =
await gaslessVotingContract.estimateGas.createProposal(
Expand Down
14 changes: 8 additions & 6 deletions packages/js-client/src/internal/modules/methods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,16 +116,18 @@ export class GaslessVotingClientMethods
const allowFailureMap = boolArrayToBitmap(params.failSafeActions);

const startTimestamp = params.startDate?.getTime() || 0;
const endTimestamp = params.endDate.getTime() || 0;
const expirationTimestamp = params.expirationDate?.getTime() || 0;
const endTimestamp = params.voteEndDate.getTime() || 0;
const minTallyDurationTimestamp = params.tallyEndDate?.getTime() || 0;


const votingParams: GaslessProposalParametersContractStruct = {
censusBlock: [] as string[],
startDate: BigInt(Math.round(startTimestamp / 1000)),
endDate: BigInt(Math.round(endTimestamp / 1000)),
expirationDate: BigInt(Math.round(expirationTimestamp / 1000)),
voteEndDate: BigInt(Math.round(endTimestamp / 1000)),
tallyEndDate: BigInt(Math.round(minTallyDurationTimestamp / 1000)),
securityBlock: BigInt(0),
totalVotingPower: params.totalVotingPower,
censusURI: params.censusURI,
censusRoot: hexToBytes(params.censusRoot)
};
const tx = await gaslessVotingContract.createProposal(
// toUtf8Bytes(params.metadataUri),
Expand Down Expand Up @@ -665,7 +667,7 @@ export class GaslessVotingClientMethods
signer
);

return tokenVotingContract.isCommitteeMember(memberAddress);
return tokenVotingContract.isExecutionMultisigMember(memberAddress);
}

/**
Expand Down
Loading

0 comments on commit ba0b1ee

Please sign in to comment.