diff --git a/src/strategies/index.ts b/src/strategies/index.ts index 12ba9d0c1..d5ce938f4 100644 --- a/src/strategies/index.ts +++ b/src/strategies/index.ts @@ -1,6 +1,7 @@ import { readFileSync } from 'fs'; import path from 'path'; +import * as nedao from './nedao'; import * as subgraphSplitDelegation from './subgraph-split-delegation'; import * as polygonSelfStaked from './polygon-self-staked-pol'; import * as delegatexyzErc721BalanceOf from './delegatexyz-erc721-balance-of'; @@ -942,6 +943,7 @@ const strategies = { 'candy-lock-nft': candyLockNft, 'candy-nft-staking': candyNftStaking, pom, + nedao, superboring, 'erable-governance-v1': erableGovernanceV1, 'world-liberty-financial-erc20-balance-of-votes': worldLibertyFinancial, diff --git a/src/strategies/nedao/README.md b/src/strategies/nedao/README.md new file mode 100644 index 000000000..aef21e2fa --- /dev/null +++ b/src/strategies/nedao/README.md @@ -0,0 +1,12 @@ + # PoM strategy + + This is the basic voting strategy for Nedao which allows validated users to vote. + + Here is an example of parameters: + ```json + { + "contractAddress": "0xB94E35600A925569ea2f4DC57D571657ccDb8FDc", + "validateur": "0x7aaAd3167Ad03809aC61e667bdBC72285CEe3BF4", + "typeValidation": "0xd36f63907c7fad13dd9dc69aa8b9af9c3296a3edad0b0b1eb50c10fd066fc910" + } + ``` diff --git a/src/strategies/nedao/examples.json b/src/strategies/nedao/examples.json new file mode 100644 index 000000000..ded601453 --- /dev/null +++ b/src/strategies/nedao/examples.json @@ -0,0 +1,37 @@ +[ + { + "name": "Example query", + "strategy": { + "name": "nedao", + "params": { + "contractAddress": "0xB94E35600A925569ea2f4DC57D571657ccDb8FDc", + "validateur": "0x7aaAd3167Ad03809aC61e667bdBC72285CEe3BF4", + "typeValidation": "0xd36f63907c7fad13dd9dc69aa8b9af9c3296a3edad0b0b1eb50c10fd066fc910" + } + }, + "network": "11155111", + "addresses": [ + "0xE8a819929930C9Ab85cb89749A2eBAaAb410b80f", + "0x75c41548F9a71c267Cf38E8452435EC580d3978E", + "0x6c6234983BCf60d4497cd8EE416bA04600a0a4C2", + "0xeF8305E140ac520225DAf050e2f71d5fBcC543e7", + "0x1E1A51E25f2816335cA436D65e9Af7694BE232ad", + "0x1F717Ce8ff07597ee7c408b5623dF40AaAf1787C", + "0x1c7a9275F2BD5a260A9c31069F77d53473b8ae2e", + "0x1d5E65a087eBc3d03a294412E46CE5D6882969f4", + "0x1f254336E5c46639A851b9CfC165697150a6c327", + "0x2ec3F80BeDA63Ede96BA20375032CDD3aAfb3030", + "0x4AcBcA6BE2f8D2540bBF4CA77E45dA0A4a095Fa2", + "0x4F3D348a6D09837Ae7961B1E0cEe2cc118cec777", + "0x6D7f23A509E212Ba7773EC1b2505d1A134f54fbe", + "0x07a1f6fc89223c5ebD4e4ddaE89Ac97629856A0f", + "0x8d5F05270da470e015b67Ab5042BDbE2D2FEFB48", + "0x8d07D225a769b7Af3A923481E1FdF49180e6A265", + "0x8f60501dE5b9b01F9EAf1214dbE1924aA97F7fd0", + "0x9B8e8dD9151260c21CB6D7cc59067cd8DF306D58", + "0x17ea92D6FfbAA1c7F6B117c1E9D0c88ABdc8b84C", + "0x38C0039247A31F3939baE65e953612125cB88268" + ], + "snapshot": 7554395 + } +] diff --git a/src/strategies/nedao/index.ts b/src/strategies/nedao/index.ts new file mode 100644 index 000000000..5aefd6ee2 --- /dev/null +++ b/src/strategies/nedao/index.ts @@ -0,0 +1,42 @@ +import { BigNumber } from '@ethersproject/bignumber'; +import { Multicaller } from '../../utils'; + +export const author = 'nedao'; +export const version = '0.1.0'; + +const abi = [ + 'function litProclamation(address validateur,address sujet, bytes32 typeValidation) public view returns (bytes32) ' +]; + +function bytes32ToBool(bytes32) { + const hex = bytes32.startsWith('0x') ? bytes32.slice(2) : bytes32; + return (hex != 0) ? 1 : 0; +} + +export async function strategy( + space, + network, + provider, + addresses, + options, + snapshot +): Promise> { + const blockTag = typeof snapshot === 'number' ? snapshot : 'latest'; + const multi = new Multicaller(network, provider, abi, { blockTag }); + + addresses.forEach((address) => + multi.call(address, options.contractAddress, 'litProclamation', [ + options.validateur, + address, + options.typeValidation + ]) + ); + const result: Record = await multi.execute(); + + return Object.fromEntries( + Object.entries(result).map(([address, id]) => [ + address, + bytes32ToBool(id), + ]) + ); +} diff --git a/src/strategies/nedao/schema.json b/src/strategies/nedao/schema.json new file mode 100644 index 000000000..52b8997a0 --- /dev/null +++ b/src/strategies/nedao/schema.json @@ -0,0 +1,38 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$ref": "#/definitions/Strategy", + "definitions": { + "Strategy": { + "title": "Strategy", + "type": "object", + "properties": { + "contractAddress": { + "type": "string", + "title": "The contract address", + "examples": ["e.g. 0xB94E35600A925569ea2f4DC57D571657ccDb8FDc"], + "pattern": "^0x[a-fA-F0-9]{40}$", + "minLength": 42, + "maxLength": 42 + }, + "validateur": { + "type": "string", + "title": "The idValidateur of the bot", + "examples": ["e.g. 0x7aaAd3167Ad03809aC61e667bdBC72285CEe3BF4"], + "pattern": "^0x[a-fA-F0-9]{40}$", + "minLength": 42, + "maxLength": 42 + }, + "typeValidation": { + "type": "string", + "title": "The keccak256 value of the bot", + "examples": ["e.g. 0xd36f63907c7fad13dd9dc69aa8b9af9c3296a3edad0b0b1eb50c10fd066fc910"], + "pattern": "^0x[a-fA-F0-9]{64}$", + "minLength": 66, + "maxLength": 66 + } + }, + "required": ["contractAddress", "validateur", "typeValidation"], + "additionalProperties": false + } + } +}