-
Notifications
You must be signed in to change notification settings - Fork 809
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
131 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<Record<string, number>> { | ||
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<string, BigNumber> = await multi.execute(); | ||
|
||
return Object.fromEntries( | ||
Object.entries(result).map(([address, id]) => [ | ||
address, | ||
bytes32ToBool(id), | ||
]) | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} | ||
} | ||
} |