Skip to content

Commit

Permalink
separate proposal details chain call
Browse files Browse the repository at this point in the history
Signed-off-by: ryanwolhuter <[email protected]>
  • Loading branch information
ryanwolhuter committed Oct 19, 2023
1 parent c8c6795 commit 7b57dda
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/plugins/oSnap/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,14 @@ export type ProposalDetails = {
assertionEvent: AssertionEvent | undefined;
}

export type OptimisticGovernorProposalDetails = {
safeAddress: string;
oracleAddress: string;
rules: string;
minimumBond: BigNumber;
challengePeriod: BigNumber;
}

/**
* Combines the proposal details with the proposal id and explanation.
*/
Expand Down
39 changes: 38 additions & 1 deletion src/plugins/oSnap/utils/getters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
contractData,
safePrefixes
} from '../constants';
import { Assertion, AssertionEvent, AssertionGql, BalanceResponse, CollateralDetails, NFT, Network, OptimisticGovernorTransaction, ProposalDetails, ProposalExecutionDetails, SafeNetworkPrefix } from '../types';
import { Assertion, AssertionEvent, AssertionGql, BalanceResponse, CollateralDetails, NFT, Network, OptimisticGovernorProposalDetails, OptimisticGovernorTransaction, ProposalDetails, ProposalExecutionDetails, SafeNetworkPrefix } from '../types';
import { pageEvents } from './events';

/**
Expand Down Expand Up @@ -303,6 +303,43 @@ export async function getUserCollateralBalance(erc20Contract: Contract, userAddr
return erc20Contract.balanceOf(userAddress);
}

export async function getOptimisticGovernorProposalDetailsFromChain(params: {
provider: StaticJsonRpcProvider;
network: Network;
moduleAddress: string;
explanation: string;
transactions: OptimisticGovernorTransaction[] | undefined;
}): Promise<OptimisticGovernorProposalDetails> {
const { provider, network, moduleAddress } = params;
const optimisticGovernorProposalDetails: [
[safeAddress: string],
[oracleAddress: string],
[rules: string],
[minimumBond: BigNumber],
[liveness: BigNumber]
] = await multicall(network, provider, OPTIMISTIC_GOVERNOR_ABI as any, [
[moduleAddress, 'avatar'],
[moduleAddress, 'optimisticOracleV3'],
[moduleAddress, 'rules'],
[moduleAddress, 'bondAmount'],
[moduleAddress, 'liveness']
]);

const safeAddress = optimisticGovernorProposalDetails[0][0];
const oracleAddress = optimisticGovernorProposalDetails[1][0];
const rules = optimisticGovernorProposalDetails[2][0];
const minimumBond = optimisticGovernorProposalDetails[3][0];
const challengePeriod = optimisticGovernorProposalDetails[4][0];

return {
safeAddress,
oracleAddress,
rules,
minimumBond,
challengePeriod,
};
}

/**
* Legacy / fallback function to fetch the details of a proposal associated with given assertion from the Optimistic Oracle V3 contract.
*/
Expand Down

0 comments on commit 7b57dda

Please sign in to comment.