forked from snapshot-labs/snapshot-strategies
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[has-rock] Rock NFT voting strategy (snapshot-labs#46)
* Rock Voting Strategy * Rock Voting Strategy * Update src/strategies/has-rock/index.ts Co-authored-by: Chaitanya <[email protected]> * Update src/strategies/has-rock/index.ts Co-authored-by: Chaitanya <[email protected]> * Update src/strategies/has-rock/index.ts Co-authored-by: Chaitanya <[email protected]> Co-authored-by: Chaitanya <[email protected]>
- Loading branch information
Showing
4 changed files
with
73 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# has-rocks | ||
|
||
This is a strategy for addresses with rocks. |
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,17 @@ | ||
[ | ||
{ | ||
"name": "Example query", | ||
"strategy": { | ||
"name": "has-rock", | ||
"params": { | ||
"address": "0x37504AE0282f5f334ED29b4548646f887977b7cC", | ||
"symbol": "ROCK" | ||
} | ||
}, | ||
"network": "1", | ||
"addresses": [ | ||
"0x66C25a700F9c762891b4d6fbf5aF9Dc2eb04266A" | ||
], | ||
"snapshot": 13118882 | ||
} | ||
] |
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,50 @@ | ||
import { multicall } from '../../utils'; | ||
|
||
export const author = 'AngelDAO'; | ||
export const version = '0.1.0'; | ||
|
||
const abi = [ | ||
'function rocks(uint256) view returns (address owner, bool currentlyForSale, uint256 price, uint256 timesSold)' | ||
]; | ||
|
||
export async function strategy( | ||
space, | ||
network, | ||
provider, | ||
addresses, | ||
options, | ||
snapshot | ||
) { | ||
const blockTag = typeof snapshot === 'number' ? snapshot : 'latest'; | ||
|
||
let calls = [] as any; | ||
for (var i=0; i< 100; i++){ | ||
calls.push([ | ||
options.address, | ||
'rocks', | ||
[i] | ||
]) | ||
} | ||
|
||
const response = await multicall( | ||
network, | ||
provider, | ||
abi, | ||
calls, | ||
{ blockTag } | ||
); | ||
|
||
let result = {} as any; | ||
|
||
addresses.forEach((address, x)=> { | ||
let addressRocks = 0; | ||
response.forEach((rockObject, i) => { | ||
if (rockObject.owner == address){ | ||
addressRocks++; | ||
} | ||
}) | ||
result[address] = addressRocks | ||
}) | ||
|
||
return result; | ||
} |
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