forked from snapshot-labs/snapshot-hub
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
call proposal-status to get proposalEnd
- Loading branch information
1 parent
76a9d42
commit a95c82b
Showing
2 changed files
with
36 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,30 @@ | ||
import fetch from 'node-fetch'; | ||
|
||
export async function getProposalStatus(id: string, space: string) { | ||
const devUrl = 'https://develop.thelao.io/api/v1/governance/proposal-status'; | ||
const prodUrl = 'https://thelao.io/api/v1/governance/proposal-status'; | ||
|
||
const env = process.env.ENV; | ||
const endpoint = env === 'prod' ? prodUrl : devUrl; | ||
|
||
try { | ||
const proposalStatus = await fetch(endpoint, { | ||
method: 'POST', | ||
body: JSON.stringify([{ id, space }]), | ||
headers: { | ||
'Content-Type': 'application/json' | ||
} | ||
}); | ||
|
||
if (!proposalStatus.ok) { | ||
throw new Error( | ||
`Something went wrong while fetching the proposals status for ${id} ${space}` | ||
); | ||
} | ||
|
||
return await proposalStatus.json(); | ||
} catch (error) { | ||
console.error(error); | ||
return []; | ||
} | ||
} |
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