Skip to content

Commit

Permalink
feat(iam): made staking round an env variable (passportxyz#1153)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucianHymer authored Apr 20, 2023
1 parent 1fff094 commit 24e6ed0
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 4 deletions.
3 changes: 2 additions & 1 deletion iam/.env-example.env
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,5 @@ ALCHEMY_API_KEY=<API_KEY>

AMI_API_TOKEN='SECRET_GITCOIN_AMI_API_TOKEN'

GTC_STAKING_GRAPH_API_KEY=<your api key token>
GTC_STAKING_GRAPH_API_KEY=<your api key token>
GTC_STAKING_ROUND=1
4 changes: 4 additions & 0 deletions infra/production/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,10 @@ const service = new awsx.ecs.FargateService("dpopp-iam", {
name: "GTC_STAKING_GRAPH_API_KEY",
valueFrom: `${IAM_SERVER_SSM_ARN}:GTC_STAKING_GRAPH_API_KEY::`,
},
{
name: "GTC_STAKING_ROUND",
valueFrom: `${IAM_SERVER_SSM_ARN}:GTC_STAKING_ROUND::`,
},
{
name: "COINBASE_CLIENT_ID",
valueFrom: `${IAM_SERVER_SSM_ARN}:COINBASE_CLIENT_ID::`,
Expand Down
6 changes: 5 additions & 1 deletion infra/review/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import * as awsx from "@pulumi/awsx";
// The following vars are not allowed to be undefined, hence the `${...}` magic

let route53Zone = `${process.env["ROUTE_53_ZONE"]}`;
export const domain = `iam.${process.env["DOMAIN"]}`; // like: iam.review.passport.gitcoin.co
export const domain = `iam.${process.env["DOMAIN"]}`; // like: iam.review.passport.gitcoin.co
let IAM_SERVER_SSM_ARN = `${process.env["IAM_SERVER_SSM_ARN"]}`;

export const dockerGtcPassportIamImage = `${process.env["DOCKER_GTC_PASSPORT_IAM_IMAGE"]}`;
Expand Down Expand Up @@ -256,6 +256,10 @@ const service = new awsx.ecs.FargateService("dpopp-iam", {
name: "GTC_STAKING_GRAPH_API_KEY",
valueFrom: `${IAM_SERVER_SSM_ARN}:GTC_STAKING_GRAPH_API_KEY::`,
},
{
name: "GTC_STAKING_ROUND",
valueFrom: `${IAM_SERVER_SSM_ARN}:GTC_STAKING_ROUND::`,
},
{
name: "COINBASE_CLIENT_ID",
valueFrom: `${IAM_SERVER_SSM_ARN}:COINBASE_CLIENT_ID::`,
Expand Down
4 changes: 4 additions & 0 deletions infra/staging/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,10 @@ const service = new awsx.ecs.FargateService("dpopp-iam", {
name: "GTC_STAKING_GRAPH_API_KEY",
valueFrom: `${IAM_SERVER_SSM_ARN}:GTC_STAKING_GRAPH_API_KEY::`,
},
{
name: "GTC_STAKING_ROUND",
valueFrom: `${IAM_SERVER_SSM_ARN}:GTC_STAKING_ROUND::`,
},
{
name: "COINBASE_CLIENT_ID",
valueFrom: `${IAM_SERVER_SSM_ARN}:COINBASE_CLIENT_ID::`,
Expand Down
3 changes: 2 additions & 1 deletion platforms/src/GtcStaking/Providers/communityStaking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,14 @@ export interface DataResult {
}

async function verifyStake(payload: RequestPayload): Promise<StakeResponse> {
const round = process.env.GTC_STAKING_ROUND || "1";
const address = payload.address.toLowerCase();
const result = await axios.post(stakingSubgraph, {
query: `
{
users(where: {address: "${address}"}) {
address,
xstakeAggregates(where: {round: "1", total_gt: 0}) {
xstakeAggregates(where: {round: "${round}", total_gt: 0}) {
total
round {
id
Expand Down
3 changes: 2 additions & 1 deletion platforms/src/GtcStaking/Providers/selfStaking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,14 @@ export interface DataResult {
}

async function verifyStake(payload: RequestPayload): Promise<StakeResponse> {
const round = process.env.GTC_STAKING_ROUND || "1";
const address = payload.address.toLowerCase();
const result = await axios.post(stakingSubgraph, {
query: `
{
users(where: {address: "${address}"}) {
address,
stakes(where: {round: "1"}) {
stakes(where: {round: "${round}"}) {
stake
round {
id
Expand Down

0 comments on commit 24e6ed0

Please sign in to comment.