Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[coinage-coop] feat: add coinage media coop strategy #1627

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/strategies/coinage-coop/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Coinage Media Coop

Fetches current active Coop members and allows them to vote on Coop Specific Proposals.
Users have to be approved to join the COOP by the board [coinage.media](https://coinage.media)
20 changes: 20 additions & 0 deletions src/strategies/coinage-coop/examples.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[
{
"name": "Example of coinage media coop member query",
"strategy": {
"name": "coinage-coop",
"params": {
"symbol": "COINAGE"
}
},
"addresses": [
"0x65A922561638015E394A20356C31E9A6217513B8",
"0xF677b8EF72C34f63c43f47C30612B1A3Ec1b622F",
"0xd7eAd7DD37EFf97531beA958a58282Fa6D3a31A5",
"0x2df292AF809Fd693D94C7D17E36BE352e15Bb98a",
"0x2274091DAad5B7bF734f426B9aA8513955075b9E"
],
"network": "1",
"snapshot": 14101222
}
]
36 changes: 36 additions & 0 deletions src/strategies/coinage-coop/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import fetch from 'cross-fetch';

export const author = 'isaac-martin';
export const version = '1.0.0';

type Wallet = `0x${string}`;
const COINAGE_COOP_MEMBERS_API_URL = 'https://coinage.media/coop/api/members';

/**
* Fetches all active coinage coop members
*/
const fetchActiveUsers = async (): Promise<Array<Wallet>> => {
const response = await fetch(COINAGE_COOP_MEMBERS_API_URL, {
method: 'GET'
});

const payload = await response.json();
return payload.data;
};

export async function strategy(space, network, provider, addresses) {
const calculated: Array<[Wallet, number]> = [];

try {
const activeMembers = await fetchActiveUsers();
addresses.forEach((address) => {
if (activeMembers.includes(address)) {
calculated.push([address, 1]);
}
});

return Object.fromEntries(calculated);
} catch (e) {
console.error('error', e);
}
}
21 changes: 21 additions & 0 deletions src/strategies/coinage-coop/schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$ref": "#/definitions/Strategy",
"definitions": {
"Strategy": {
"title": "Strategy",
"type": "object",
"properties": {
"symbol": {
"type": "string",
"title": "Symbol",
"examples": ["e.g. COINAGE"],
"maxLength": 16
}
},

"required": [],
"additionalProperties": false
}
}
}
2 changes: 2 additions & 0 deletions src/strategies/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,7 @@ import * as superboring from './superboring';
import * as erableGovernanceV1 from './erable-governance-v1';
import * as worldLibertyFinancial from './world-liberty-financial-erc20-balance-of-votes';
import * as snxMultichain from './snx-multichain';
import * as coinageCoop from './coinage-coop';
import * as moxie from './moxie';
import * as stakingAmountDurationLinear from './staking-amount-duration-linear';
import * as stakingAmountDurationExponential from './staking-amount-duration-exponential';
Expand Down Expand Up @@ -930,6 +931,7 @@ const strategies = {
pom,
superboring,
'erable-governance-v1': erableGovernanceV1,
'coinage-coop': coinageCoop,
'world-liberty-financial-erc20-balance-of-votes': worldLibertyFinancial,
'snx-multichain': snxMultichain,
moxie: moxie,
Expand Down
Loading