Skip to content

Commit

Permalink
Change env name for lambdas
Browse files Browse the repository at this point in the history
  • Loading branch information
jakubcolony committed Jun 27, 2024
1 parent a43d4b0 commit cb9d188
Show file tree
Hide file tree
Showing 16 changed files with 58 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,9 @@ let graphqlURL = 'http://localhost:20002/graphql';

const setEnvVariables = async () => {
const ENV = process.env.ENV;
if (ENV === 'qaarbsep' || ENV === 'prodarbone') {
if (ENV === 'qaarbsep' || ENV === 'prodrevive') {
const { getParams } = require('/opt/nodejs/getParams');
[apiKey, graphqlURL] = await getParams([
'appsyncApiKey',
'graphqlUrl',
]);
[apiKey, graphqlURL] = await getParams(['appsyncApiKey', 'graphqlUrl']);
}
};

Expand All @@ -42,10 +39,9 @@ exports.handler = async (event) => {
tokenThumbnail,
initiatorAddress,
transactionHash,
inviteCode
inviteCode,
} = event.arguments?.input || {};


/*
* Validate invite code
*/
Expand Down Expand Up @@ -132,7 +128,7 @@ exports.handler = async (event) => {
const [error] = colonyMetadataMutation.errors;
throw new Error(
error?.message ||
`Could not create colony "${name}" with address "${checksummedAddress} 's metadata from transaction ${transactionHash}"`,
`Could not create colony "${name}" with address "${checksummedAddress} 's metadata from transaction ${transactionHash}"`,
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ let graphqlURL = 'http://localhost:20002/graphql';

const setEnvVariables = async () => {
const ENV = process.env.ENV;
if (ENV === 'qaarbsep' || ENV === 'prodarbone') {
if (ENV === 'qaarbsep' || ENV === 'prodrevive') {
const { getParams } = require('/opt/nodejs/getParams');
[apiKey, graphqlURL] = await getParams(['appsyncApiKey', 'graphqlUrl']);
}
Expand Down
2 changes: 1 addition & 1 deletion amplify/backend/function/createUniqueUser/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ let graphqlURL = 'http://localhost:20002/graphql';
const setEnvVariables = async () => {
const ENV = process.env.ENV;

if (ENV === 'qaarbsep' || ENV === 'prodarbone') {
if (ENV === 'qaarbsep' || ENV === 'prodrevive') {
const { getParams } = require('/opt/nodejs/getParams');
[apiKey, graphqlURL] = await getParams(['appsyncApiKey', 'graphqlUrl']);
}
Expand Down
2 changes: 1 addition & 1 deletion amplify/backend/function/fetchColonyBalances/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ let networkAddress;

const setEnvVariables = async () => {
const ENV = process.env.ENV;
if (ENV === 'qaarbsep' || ENV === 'prodarbone') {
if (ENV === 'qaarbsep' || ENV === 'prodrevive') {
const { getParams } = require('/opt/nodejs/getParams');
[networkAddress, apiKey, graphqlURL, rpcURL, network] = await getParams([
'networkContractAddress',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ let rpcURL = 'http://network-contracts:8545'; // this needs to be extended to al

const setEnvVariables = async () => {
const ENV = process.env.ENV;
if (ENV === 'qaarbsep' || ENV === 'prodarbone') {
if (ENV === 'qaarbsep' || ENV === 'prodrevive') {
const { getParams } = require('/opt/nodejs/getParams');
[rpcURL] = await getParams(['chainRpcEndpoint']);
}
Expand Down
9 changes: 7 additions & 2 deletions amplify/backend/function/fetchMotionState/src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ let network = Network.Custom;

const setEnvVariables = async () => {
const ENV = process.env.ENV;
if (ENV === 'qaarbsep' || ENV === 'prodarbone') {
if (ENV === 'qaarbsep' || ENV === 'prodrevive') {
const { getParams } = require('/opt/nodejs/getParams');
[
apiKey,
Expand Down Expand Up @@ -285,7 +285,12 @@ const updateMotionMessagesInDB = async (motionData, motionMessages, flag) => {
const updatedStateHistory = {
...motionStateHistory,
[flag]: true,
endedAt: flag === 'hasFailed' || flag === 'hasPassed' || flag === 'hasFailedNotFinalizable' ? new Date().toISOString() : null,
endedAt:
flag === 'hasFailed' ||
flag === 'hasPassed' ||
flag === 'hasFailedNotFinalizable'
? new Date().toISOString()
: null,
};

const messageKeys = new Set(messages.items.map((m) => m.messageKey));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ let reputationOracleEndpoint =

const setEnvVariables = async () => {
const ENV = process.env.ENV;
if (ENV === 'qaarbsep' || ENV === 'prodarbone') {
if (ENV === 'qaarbsep' || ENV === 'prodrevive') {
const { getParams } = require('/opt/nodejs/getParams');
[rpcURL, networkAddress, reputationOracleEndpoint, network] =
await getParams([
Expand Down
17 changes: 13 additions & 4 deletions amplify/backend/function/fetchTokenFromChain/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const setEnvVariables = async (network) => {
rpcURL = getDevRpcUrl(network);
}

if (ENV === 'qaarbsep' || ENV === 'prodarbone') {
if (ENV === 'qaarbsep' || ENV === 'prodrevive') {
let chainRpcParam = getRpcUrlParamName(network);

const { getParams } = require('/opt/nodejs/getParams');
Expand Down Expand Up @@ -116,17 +116,26 @@ exports.handler = async (event) => {
try {
name = await tokenFromChain.name();
} catch (error) {
console.log(`TOKEN NAME NOT AVAILABLE, FALLING BACK TO: "${name}"`, error);
console.log(
`TOKEN NAME NOT AVAILABLE, FALLING BACK TO: "${name}"`,
error,
);
}
try {
symbol = await tokenFromChain.symbol();
} catch (error) {
console.log(`TOKEN SYMBOL NOT AVAILABLE, FALLING BACK TO: "${symbol}"`, error);
console.log(
`TOKEN SYMBOL NOT AVAILABLE, FALLING BACK TO: "${symbol}"`,
error,
);
}
try {
decimals = await tokenFromChain.decimals();
} catch (error) {
console.log(`TOKEN DECIMALS NOT AVAILABLE, FALLING BACK TO: "${decimals}"`, error);
console.log(
`TOKEN DECIMALS NOT AVAILABLE, FALLING BACK TO: "${decimals}"`,
error,
);
}
const type = await getTokenType(tokenFromChain);
const chainId = String((await provider.getNetwork()).chainId);
Expand Down
2 changes: 1 addition & 1 deletion amplify/backend/function/fetchVoterRewards/src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ let reputationOracleEndpoint =

const setEnvVariables = async () => {
const ENV = process.env.ENV;
if (ENV === 'qaarbsep' || ENV === 'prodarbone') {
if (ENV === 'qaarbsep' || ENV === 'prodrevive') {
const { getParams } = require('/opt/nodejs/getParams');
[
apiKey,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ let rpcURL = 'http://network-contracts:8545'; // this needs to be extended to al

const setEnvVariables = async () => {
const ENV = process.env.ENV;
if (ENV === 'qaarbsep' || ENV === 'prodarbone') {
if (ENV === 'qaarbsep' || ENV === 'prodrevive') {
const { getParams } = require('/opt/nodejs/getParams');
[rpcURL] = await getParams(['chainRpcEndpoint']);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const getApiKey = async (chainId) => {
let etherscanApiKey = '';
const ENV = process.env.ENV;

if (ENV === 'qaarbsep' || ENV === 'prodarbone') {
if (ENV === 'qaarbsep' || ENV === 'prodrevive') {
const { getParams } = require('/opt/nodejs/getParams');
[bscscanApiKey, etherscanApiKey] = await getParams([
'bscscanApiKey',
Expand Down Expand Up @@ -139,7 +139,7 @@ const getHomeProvider = async () => {
const ENV = process.env.ENV;
let rpcURL = LOCAL_HOME_CHAIN;

if (ENV === 'qaarbsep' || ENV === 'prodarbone') {
if (ENV === 'qaarbsep' || ENV === 'prodrevive') {
const { getParams } = require('/opt/nodejs/getParams');
[rpcURL] = await getParams(['chainRpcEndpoint']);
}
Expand Down
2 changes: 1 addition & 1 deletion amplify/backend/function/getUserReputation/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ let network = Network.Custom;

const setEnvVariables = async () => {
const ENV = process.env.ENV;
if (ENV === 'qaarbsep' || ENV === 'prodarbone') {
if (ENV === 'qaarbsep' || ENV === 'prodrevive') {
const { getParams } = require('/opt/nodejs/getParams');
[rpcURL, networkAddress, reputationOracleEndpoint, network] =
await getParams([
Expand Down
2 changes: 1 addition & 1 deletion amplify/backend/function/getUserTokenBalance/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ let graphqlURL = 'http://localhost:20002/graphql';

const setEnvVariables = async () => {
const ENV = process.env.ENV;
if (ENV === 'qaarbsep' || ENV === 'prodarbone') {
if (ENV === 'qaarbsep' || ENV === 'prodrevive') {
const { getParams } = require('/opt/nodejs/getParams');
[rpcURL, networkAddress, network, apiKey, graphqlURL] = await getParams([
'chainRpcEndpoint',
Expand Down
2 changes: 1 addition & 1 deletion amplify/backend/function/qaSSMtest/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ let networkAddress;

const setEnvVariables = async () => {
const ENV = process.env.ENV;
if (ENV === 'qaarbsep' || ENV === 'prodarbone') {
if (ENV === 'qaarbsep' || ENV === 'prodrevive') {
const { getParams } = require('/opt/nodejs/getParams');
[
apiKey,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ let network = Network.Custom;
const setEnvVariables = async () => {
const ENV = process.env.ENV;

if (ENV === 'qaarbsep' || ENV === 'prodarbone') {
if (ENV === 'qaarbsep' || ENV === 'prodrevive') {
const { getParams } = require('/opt/nodejs/getParams');
[
apiKey,
Expand Down Expand Up @@ -143,7 +143,7 @@ exports.handler = async (event) => {
const allNativeDomainIds =
data?.getColony?.domains?.items?.map(({ nativeId }) => nativeId) ?? [];

console.log({ allNativeDomainIds })
console.log({ allNativeDomainIds });

const promiseResults = await Promise.allSettled(
allNativeDomainIds.map(async (nativeDomainId) => {
Expand Down Expand Up @@ -183,22 +183,24 @@ exports.handler = async (event) => {

const totalAddresses = sortedAddresses.length;

console.log({ totalAddresses })
console.log({ totalAddresses });

const promiseStatuses = await Promise.allSettled(
sortedAddresses.map(async ({ address, reputationBN }, idx) => {
const contributorAddress = getAddress(address);
const contributorRepDecimal = new Decimal(reputationBN.toString());

const colonyReputationPercentage = contributorRepDecimal
.mul(100)
.div(totalRepInColony.toString())
.toNumber() || 0;
const colonyReputationPercentage =
contributorRepDecimal
.mul(100)
.div(totalRepInColony.toString())
.toNumber() || 0;

const domainReputationPercentage = contributorRepDecimal
.mul(100)
.div(totalRepInDomain.toString())
.toNumber() || 0;
const domainReputationPercentage =
contributorRepDecimal
.mul(100)
.div(totalRepInDomain.toString())
.toNumber() || 0;

const contributorReputationId = `${colonyAddress}_${nativeDomainId}_${contributorAddress}`;
const colonyContributorId = `${colonyAddress}_${contributorAddress}`;
Expand Down Expand Up @@ -230,7 +232,14 @@ exports.handler = async (event) => {

const type = getContributorType(totalAddresses, idx, createdAt);

console.log({ type, colonyReputationPercentage, contributorAddress, contributorRepDecimal, domainReputationPercentage, reputation })
console.log({
type,
colonyReputationPercentage,
contributorAddress,
contributorRepDecimal,
domainReputationPercentage,
reputation,
});

await updateColonyContributorInDb({
id: colonyContributorId,
Expand Down
2 changes: 1 addition & 1 deletion amplify/backend/function/validateUserInvite/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ let graphqlURL = 'http://localhost:20002/graphql';

const setEnvVariables = async () => {
const ENV = process.env.ENV;
if (ENV === 'qaarbsep' || ENV === 'prodarbone') {
if (ENV === 'qaarbsep' || ENV === 'prodrevive') {
const { getParams } = require('/opt/nodejs/getParams');
[apiKey, graphqlURL] = await getParams(['appsyncApiKey', 'graphqlUrl']);
}
Expand Down

0 comments on commit cb9d188

Please sign in to comment.